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"
69 #define TOKENIZE_ERROR -1
70 #define TOKENIZE_ERROR_REPORT -2
72 #define MAX_INSN_FIXUPS 2
73 #define MAX_INSN_ARGS 5
78 bfd_reloc_code_real_type reloc
;
85 struct alpha_fixup fixups
[MAX_INSN_FIXUPS
];
86 unsigned sequence
[MAX_INSN_FIXUPS
];
107 void (*emit
) PARAMS ((const expressionS
*, int, const PTR
));
109 enum alpha_macro_arg argsets
[16];
112 /* Extra expression types. */
114 #define O_pregister O_md1 /* O_register, in parentheses */
115 #define O_cpregister O_md2 /* + a leading comma */
118 /* Note, the alpha_reloc_op table below depends on the ordering
119 of O_literal .. O_gprelow. */
120 #define O_literal O_md3 /* !literal relocation */
121 #define O_lituse_base O_md4 /* !lituse_base relocation */
122 #define O_lituse_bytoff O_md5 /* !lituse_bytoff relocation */
123 #define O_lituse_jsr O_md6 /* !lituse_jsr relocation */
124 #define O_gpdisp O_md7 /* !gpdisp relocation */
125 #define O_gprelhigh O_md8 /* !gprelhigh relocation */
126 #define O_gprellow O_md9 /* !gprellow relocation */
128 #define USER_RELOC_P(R) ((R) >= O_literal && (R) <= O_gprellow)
131 /* Macros for extracting the type and number of encoded register tokens */
133 #define is_ir_num(x) (((x) & 32) == 0)
134 #define is_fpr_num(x) (((x) & 32) != 0)
135 #define regno(x) ((x) & 31)
137 /* Something odd inherited from the old assembler */
139 #define note_gpreg(R) (alpha_gprmask |= (1 << (R)))
140 #define note_fpreg(R) (alpha_fprmask |= (1 << (R)))
142 /* Predicates for 16- and 32-bit ranges */
143 /* XXX: The non-shift version appears to trigger a compiler bug when
144 cross-assembling from x86 w/ gcc 2.7.2. */
147 #define range_signed_16(x) \
148 (((offsetT) (x) >> 15) == 0 || ((offsetT) (x) >> 15) == -1)
149 #define range_signed_32(x) \
150 (((offsetT) (x) >> 31) == 0 || ((offsetT) (x) >> 31) == -1)
152 #define range_signed_16(x) ((offsetT) (x) >= -(offsetT) 0x8000 && \
153 (offsetT) (x) <= (offsetT) 0x7FFF)
154 #define range_signed_32(x) ((offsetT) (x) >= -(offsetT) 0x80000000 && \
155 (offsetT) (x) <= (offsetT) 0x7FFFFFFF)
158 /* Macros for sign extending from 16- and 32-bits. */
159 /* XXX: The cast macros will work on all the systems that I care about,
160 but really a predicate should be found to use the non-cast forms. */
163 #define sign_extend_16(x) ((short) (x))
164 #define sign_extend_32(x) ((int) (x))
166 #define sign_extend_16(x) ((offsetT) (((x) & 0xFFFF) ^ 0x8000) - 0x8000)
167 #define sign_extend_32(x) ((offsetT) (((x) & 0xFFFFFFFF) \
168 ^ 0x80000000) - 0x80000000)
171 /* Macros to build tokens */
173 #define set_tok_reg(t, r) (memset (&(t), 0, sizeof (t)), \
174 (t).X_op = O_register, \
175 (t).X_add_number = (r))
176 #define set_tok_preg(t, r) (memset (&(t), 0, sizeof (t)), \
177 (t).X_op = O_pregister, \
178 (t).X_add_number = (r))
179 #define set_tok_cpreg(t, r) (memset (&(t), 0, sizeof (t)), \
180 (t).X_op = O_cpregister, \
181 (t).X_add_number = (r))
182 #define set_tok_freg(t, r) (memset (&(t), 0, sizeof (t)), \
183 (t).X_op = O_register, \
184 (t).X_add_number = (r)+32)
185 #define set_tok_sym(t, s, a) (memset (&(t), 0, sizeof (t)), \
186 (t).X_op = O_symbol, \
187 (t).X_add_symbol = (s), \
188 (t).X_add_number = (a))
189 #define set_tok_const(t, n) (memset (&(t), 0, sizeof (t)), \
190 (t).X_op = O_constant, \
191 (t).X_add_number = (n))
194 /* Prototypes for all local functions */
196 static int tokenize_arguments
PARAMS ((char *, expressionS
*, int));
197 static const struct alpha_opcode
*find_opcode_match
198 PARAMS ((const struct alpha_opcode
*, const expressionS
*, int *, int *));
199 static const struct alpha_macro
*find_macro_match
200 PARAMS ((const struct alpha_macro
*, const expressionS
*, int *));
201 static unsigned insert_operand
202 PARAMS ((unsigned, const struct alpha_operand
*, offsetT
, char *, unsigned));
203 static void assemble_insn
204 PARAMS ((const struct alpha_opcode
*, const expressionS
*, int,
205 struct alpha_insn
*));
206 static void emit_insn
PARAMS ((struct alpha_insn
*));
207 static void assemble_tokens_to_insn
208 PARAMS ((const char *, const expressionS
*, int, struct alpha_insn
*));
209 static void assemble_tokens
210 PARAMS ((const char *, const expressionS
*, int, int));
212 static int load_expression
213 PARAMS ((int, const expressionS
*, int *, expressionS
*,
214 const expressionS
*));
216 static void emit_ldgp
PARAMS ((const expressionS
*, int, const PTR
));
217 static void emit_division
PARAMS ((const expressionS
*, int, const PTR
));
218 static void emit_lda
PARAMS ((const expressionS
*, int, const PTR
));
219 static void emit_ldah
PARAMS ((const expressionS
*, int, const PTR
));
220 static void emit_ir_load
PARAMS ((const expressionS
*, int, const PTR
));
221 static void emit_loadstore
PARAMS ((const expressionS
*, int, const PTR
));
222 static void emit_jsrjmp
PARAMS ((const expressionS
*, int, const PTR
));
223 static void emit_ldX
PARAMS ((const expressionS
*, int, const PTR
));
224 static void emit_ldXu
PARAMS ((const expressionS
*, int, const PTR
));
225 static void emit_uldX
PARAMS ((const expressionS
*, int, const PTR
));
226 static void emit_uldXu
PARAMS ((const expressionS
*, int, const PTR
));
227 static void emit_ldil
PARAMS ((const expressionS
*, int, const PTR
));
228 static void emit_stX
PARAMS ((const expressionS
*, int, const PTR
));
229 static void emit_ustX
PARAMS ((const expressionS
*, int, const PTR
));
230 static void emit_sextX
PARAMS ((const expressionS
*, int, const PTR
));
231 static void emit_retjcr
PARAMS ((const expressionS
*, int, const PTR
));
233 static void s_alpha_text
PARAMS ((int));
234 static void s_alpha_data
PARAMS ((int));
236 static void s_alpha_comm
PARAMS ((int));
237 static void s_alpha_rdata
PARAMS ((int));
240 static void s_alpha_sdata
PARAMS ((int));
243 static void s_alpha_section
PARAMS ((int));
244 static void s_alpha_ent
PARAMS ((int));
245 static void s_alpha_end
PARAMS ((int));
246 static void s_alpha_mask
PARAMS ((int));
247 static void s_alpha_frame
PARAMS ((int));
248 static void s_alpha_prologue
PARAMS ((int));
249 static void s_alpha_file
PARAMS ((int));
250 static void s_alpha_loc
PARAMS ((int));
251 static void s_alpha_stab
PARAMS ((int));
252 static void s_alpha_coff_wrapper
PARAMS ((int));
255 static void s_alpha_section
PARAMS ((int));
257 static void s_alpha_gprel32
PARAMS ((int));
258 static void s_alpha_float_cons
PARAMS ((int));
259 static void s_alpha_proc
PARAMS ((int));
260 static void s_alpha_set
PARAMS ((int));
261 static void s_alpha_base
PARAMS ((int));
262 static void s_alpha_align
PARAMS ((int));
263 static void s_alpha_stringer
PARAMS ((int));
264 static void s_alpha_space
PARAMS ((int));
266 static void create_literal_section
PARAMS ((const char *, segT
*, symbolS
**));
268 static void select_gp_value
PARAMS ((void));
270 static void alpha_align
PARAMS ((int, char *, symbolS
*, int));
273 static void alpha_adjust_symtab_relocs
PARAMS ((bfd
*, asection
*, PTR
));
277 /* Generic assembler global variables which must be defined by all
280 /* Characters which always start a comment. */
281 const char comment_chars
[] = "#";
283 /* Characters which start a comment at the beginning of a line. */
284 const char line_comment_chars
[] = "#";
286 /* Characters which may be used to separate multiple commands on a
288 const char line_separator_chars
[] = ";";
290 /* Characters which are used to indicate an exponent in a floating
292 const char EXP_CHARS
[] = "eE";
294 /* Characters which mean that a number is a floating point constant,
297 const char FLT_CHARS
[] = "dD";
299 /* XXX: Do all of these really get used on the alpha?? */
300 char FLT_CHARS
[] = "rRsSfFdDxXpP";
304 const char *md_shortopts
= "Fm:g+1h:HG:";
306 const char *md_shortopts
= "Fm:gG:";
309 struct option md_longopts
[] = {
310 #define OPTION_32ADDR (OPTION_MD_BASE)
311 { "32addr", no_argument
, NULL
, OPTION_32ADDR
},
312 #define OPTION_RELAX (OPTION_32ADDR+1)
313 { "relax", no_argument
, NULL
, OPTION_RELAX
},
315 #define OPTION_MDEBUG (OPTION_RELAX+1)
316 #define OPTION_NO_MDEBUG (OPTION_MDEBUG+1)
317 { "mdebug", no_argument
, NULL
, OPTION_MDEBUG
},
318 { "no-mdebug", no_argument
, NULL
, OPTION_NO_MDEBUG
},
320 { NULL
, no_argument
, NULL
, 0 }
323 size_t md_longopts_size
= sizeof (md_longopts
);
328 #define AXP_REG_R16 16
329 #define AXP_REG_R17 17
331 #define AXP_REG_T9 22
333 #define AXP_REG_T10 23
335 #define AXP_REG_T11 24
337 #define AXP_REG_T12 25
338 #define AXP_REG_AI 25
340 #define AXP_REG_FP 29
343 #define AXP_REG_GP AXP_REG_PV
344 #endif /* OBJ_EVAX */
346 /* The cpu for which we are generating code */
347 static unsigned alpha_target
= AXP_OPCODE_BASE
;
348 static const char *alpha_target_name
= "<all>";
350 /* The hash table of instruction opcodes */
351 static struct hash_control
*alpha_opcode_hash
;
353 /* The hash table of macro opcodes */
354 static struct hash_control
*alpha_macro_hash
;
357 /* The $gp relocation symbol */
358 static symbolS
*alpha_gp_symbol
;
360 /* XXX: what is this, and why is it exported? */
361 valueT alpha_gp_value
;
364 /* The current $gp register */
365 static int alpha_gp_register
= AXP_REG_GP
;
367 /* A table of the register symbols */
368 static symbolS
*alpha_register_table
[64];
370 /* Constant sections, or sections of constants */
372 static segT alpha_lita_section
;
373 static segT alpha_lit4_section
;
376 static segT alpha_link_section
;
377 static segT alpha_ctors_section
;
378 static segT alpha_dtors_section
;
380 static segT alpha_lit8_section
;
382 /* Symbols referring to said sections. */
384 static symbolS
*alpha_lita_symbol
;
385 static symbolS
*alpha_lit4_symbol
;
388 static symbolS
*alpha_link_symbol
;
389 static symbolS
*alpha_ctors_symbol
;
390 static symbolS
*alpha_dtors_symbol
;
392 static symbolS
*alpha_lit8_symbol
;
394 /* Literal for .litX+0x8000 within .lita */
396 static offsetT alpha_lit4_literal
;
397 static offsetT alpha_lit8_literal
;
401 /* The active .ent symbol. */
402 static symbolS
*alpha_cur_ent_sym
;
405 /* Is the assembler not allowed to use $at? */
406 static int alpha_noat_on
= 0;
408 /* Are macros enabled? */
409 static int alpha_macros_on
= 1;
411 /* Are floats disabled? */
412 static int alpha_nofloats_on
= 0;
414 /* Are addresses 32 bit? */
415 static int alpha_addr32_on
= 0;
417 /* Symbol labelling the current insn. When the Alpha gas sees
420 and the section happens to not be on an eight byte boundary, it
421 will align both the symbol and the .quad to an eight byte boundary. */
422 static symbolS
*alpha_insn_label
;
424 /* Whether we should automatically align data generation pseudo-ops.
425 .align 0 will turn this off. */
426 static int alpha_auto_align_on
= 1;
428 /* The known current alignment of the current section. */
429 static int alpha_current_align
;
431 /* These are exported to ECOFF code. */
432 unsigned long alpha_gprmask
, alpha_fprmask
;
434 /* Whether the debugging option was seen. */
435 static int alpha_debug
;
438 /* Whether we are emitting an mdebug section. */
439 int alpha_flag_mdebug
= -1;
442 /* Don't fully resolve relocations, allowing code movement in the linker. */
443 static int alpha_flag_relax
;
445 /* What value to give to bfd_set_gp_size. */
446 static int g_switch_value
= 8;
449 /* Collect information about current procedure here. */
451 symbolS
*symbol
; /* proc pdesc symbol */
453 int framereg
; /* register for frame pointer */
454 int framesize
; /* size of frame */
464 static int alpha_flag_hash_long_names
= 0; /* -+ */
465 static int alpha_flag_show_after_trunc
= 0; /* -H */
467 /* If the -+ switch is given, then a hash is appended to any name that is
468 * longer than 64 characters, else longer symbol names are truncated.
474 /* A table to map the spelling of a relocation operand into an appropriate
475 bfd_reloc_code_real_type type. The table is assumed to be ordered such
476 that op-O_literal indexes into it. */
478 #define ALPHA_RELOC_TABLE(op) \
479 &alpha_reloc_op[ ((!USER_RELOC_P (op)) \
481 : (int) (op) - (int) O_literal) ]
483 #define LITUSE_BASE 1
484 #define LITUSE_BYTOFF 2
487 static const struct alpha_reloc_op_tag
{
488 const char *name
; /* string to lookup */
489 size_t length
; /* size of the string */
490 bfd_reloc_code_real_type reloc
; /* relocation before frob */
491 operatorT op
; /* which operator to use */
492 int lituse
; /* addened to specify lituse */
493 } alpha_reloc_op
[] = {
496 "literal", /* name */
497 sizeof ("literal")-1, /* length */
498 BFD_RELOC_ALPHA_USER_LITERAL
, /* reloc */
504 "lituse_base", /* name */
505 sizeof ("lituse_base")-1, /* length */
506 BFD_RELOC_ALPHA_USER_LITUSE_BASE
, /* reloc */
507 O_lituse_base
, /* op */
508 LITUSE_BASE
, /* lituse */
512 "lituse_bytoff", /* name */
513 sizeof ("lituse_bytoff")-1, /* length */
514 BFD_RELOC_ALPHA_USER_LITUSE_BYTOFF
, /* reloc */
515 O_lituse_bytoff
, /* op */
516 LITUSE_BYTOFF
, /* lituse */
520 "lituse_jsr", /* name */
521 sizeof ("lituse_jsr")-1, /* length */
522 BFD_RELOC_ALPHA_USER_LITUSE_JSR
, /* reloc */
523 O_lituse_jsr
, /* op */
524 LITUSE_JSR
, /* lituse */
529 sizeof ("gpdisp")-1, /* length */
530 BFD_RELOC_ALPHA_USER_GPDISP
, /* reloc */
536 "gprelhigh", /* name */
537 sizeof ("gprelhigh")-1, /* length */
538 BFD_RELOC_ALPHA_USER_GPRELHIGH
, /* reloc */
539 O_gprelhigh
, /* op */
544 "gprellow", /* name */
545 sizeof ("gprellow")-1, /* length */
546 BFD_RELOC_ALPHA_USER_GPRELLOW
, /* reloc */
552 static const int alpha_num_reloc_op
553 = sizeof (alpha_reloc_op
) / sizeof (*alpha_reloc_op
);
555 /* Maximum # digits needed to hold the largest sequence # */
556 #define ALPHA_RELOC_DIGITS 25
558 /* Whether a sequence number is valid. */
559 #define ALPHA_RELOC_SEQUENCE_OK(X) ((X) > 0 && ((unsigned) (X)) == (X))
561 /* Structure to hold explict sequence information. */
562 struct alpha_literal_tag
564 fixS
*lituse
; /* head of linked list of !literals */
565 segT segment
; /* segment relocs are in or undefined_section*/
566 int multi_section_p
; /* True if more than one section was used */
567 unsigned sequence
; /* sequence # */
568 unsigned n_literals
; /* # of literals */
569 unsigned n_lituses
; /* # of lituses */
570 char string
[1]; /* printable form of sequence to hash with */
573 /* Hash table to link up literals with the appropriate lituse */
574 static struct hash_control
*alpha_literal_hash
;
577 /* A table of CPU names and opcode sets. */
579 static const struct cpu_type
585 /* Ad hoc convention: cpu number gets palcode, process code doesn't.
586 This supports usage under DU 4.0b that does ".arch ev4", and
587 usage in MILO that does -m21064. Probably something more
588 specific like -m21064-pal should be used, but oh well. */
590 { "21064", AXP_OPCODE_BASE
|AXP_OPCODE_EV4
},
591 { "21064a", AXP_OPCODE_BASE
|AXP_OPCODE_EV4
},
592 { "21066", AXP_OPCODE_BASE
|AXP_OPCODE_EV4
},
593 { "21068", AXP_OPCODE_BASE
|AXP_OPCODE_EV4
},
594 { "21164", AXP_OPCODE_BASE
|AXP_OPCODE_EV5
},
595 { "21164a", AXP_OPCODE_BASE
|AXP_OPCODE_EV5
|AXP_OPCODE_BWX
},
596 { "21164pc", (AXP_OPCODE_BASE
|AXP_OPCODE_EV5
|AXP_OPCODE_BWX
598 { "21264", (AXP_OPCODE_BASE
|AXP_OPCODE_EV6
|AXP_OPCODE_BWX
599 |AXP_OPCODE_MAX
|AXP_OPCODE_CIX
) },
601 { "ev4", AXP_OPCODE_BASE
},
602 { "ev45", AXP_OPCODE_BASE
},
603 { "lca45", AXP_OPCODE_BASE
},
604 { "ev5", AXP_OPCODE_BASE
},
605 { "ev56", AXP_OPCODE_BASE
|AXP_OPCODE_BWX
},
606 { "pca56", AXP_OPCODE_BASE
|AXP_OPCODE_BWX
|AXP_OPCODE_MAX
},
607 { "ev6", AXP_OPCODE_BASE
|AXP_OPCODE_BWX
|AXP_OPCODE_MAX
|AXP_OPCODE_CIX
},
609 { "all", AXP_OPCODE_BASE
},
613 /* The macro table */
615 static const struct alpha_macro alpha_macros
[] = {
616 /* Load/Store macros */
617 { "lda", emit_lda
, NULL
,
618 { MACRO_IR
, MACRO_EXP
, MACRO_OPIR
, MACRO_LITERAL
, MACRO_BASE
, MACRO_EOA
} },
619 { "ldah", emit_ldah
, NULL
,
620 { MACRO_IR
, MACRO_EXP
, MACRO_EOA
} },
622 { "ldl", emit_ir_load
, "ldl",
623 { MACRO_IR
, MACRO_EXP
, MACRO_OPIR
, MACRO_BASE
, MACRO_EOA
} },
624 { "ldl_l", emit_ir_load
, "ldl_l",
625 { MACRO_IR
, MACRO_EXP
, MACRO_OPIR
, MACRO_BASE
, MACRO_EOA
} },
626 { "ldq", emit_ir_load
, "ldq",
627 { MACRO_IR
, MACRO_EXP
, MACRO_OPIR
, MACRO_BASE
, MACRO_LITERAL
, MACRO_EOA
} },
628 { "ldq_l", emit_ir_load
, "ldq_l",
629 { MACRO_IR
, MACRO_EXP
, MACRO_OPIR
, MACRO_BASE
, MACRO_EOA
} },
630 { "ldq_u", emit_ir_load
, "ldq_u",
631 { MACRO_IR
, MACRO_EXP
, MACRO_OPIR
, MACRO_BASE
, MACRO_EOA
} },
632 { "ldf", emit_loadstore
, "ldf",
633 { MACRO_FPR
, MACRO_EXP
, MACRO_OPIR
, MACRO_BASE
, MACRO_EOA
} },
634 { "ldg", emit_loadstore
, "ldg",
635 { MACRO_FPR
, MACRO_EXP
, MACRO_OPIR
, MACRO_BASE
, MACRO_EOA
} },
636 { "lds", emit_loadstore
, "lds",
637 { MACRO_FPR
, MACRO_EXP
, MACRO_OPIR
, MACRO_BASE
, MACRO_EOA
} },
638 { "ldt", emit_loadstore
, "ldt",
639 { MACRO_FPR
, MACRO_EXP
, MACRO_OPIR
, MACRO_BASE
, MACRO_EOA
} },
641 { "ldb", emit_ldX
, (PTR
) 0,
642 { MACRO_IR
, MACRO_EXP
, MACRO_OPIR
, MACRO_BASE
, MACRO_EOA
} },
643 { "ldbu", emit_ldXu
, (PTR
) 0,
644 { MACRO_IR
, MACRO_EXP
, MACRO_OPIR
, MACRO_BASE
, MACRO_EOA
} },
645 { "ldw", emit_ldX
, (PTR
) 1,
646 { MACRO_IR
, MACRO_EXP
, MACRO_OPIR
, MACRO_BASE
, MACRO_EOA
} },
647 { "ldwu", emit_ldXu
, (PTR
) 1,
648 { MACRO_IR
, MACRO_EXP
, MACRO_OPIR
, MACRO_BASE
, MACRO_EOA
} },
650 { "uldw", emit_uldX
, (PTR
) 1,
651 { MACRO_IR
, MACRO_EXP
, MACRO_OPIR
, MACRO_BASE
, MACRO_EOA
} },
652 { "uldwu", emit_uldXu
, (PTR
) 1,
653 { MACRO_IR
, MACRO_EXP
, MACRO_OPIR
, MACRO_BASE
, MACRO_EOA
} },
654 { "uldl", emit_uldX
, (PTR
) 2,
655 { MACRO_IR
, MACRO_EXP
, MACRO_OPIR
, MACRO_BASE
, MACRO_EOA
} },
656 { "uldlu", emit_uldXu
, (PTR
) 2,
657 { MACRO_IR
, MACRO_EXP
, MACRO_OPIR
, MACRO_BASE
, MACRO_EOA
} },
658 { "uldq", emit_uldXu
, (PTR
) 3,
659 { MACRO_IR
, MACRO_EXP
, MACRO_OPIR
, MACRO_BASE
, MACRO_EOA
} },
661 { "ldgp", emit_ldgp
, NULL
,
662 { MACRO_IR
, MACRO_EXP
, MACRO_PIR
, MACRO_EOA
} },
664 { "ldi", emit_lda
, NULL
,
665 { MACRO_IR
, MACRO_EXP
, MACRO_EOA
} },
666 { "ldil", emit_ldil
, NULL
,
667 { MACRO_IR
, MACRO_EXP
, MACRO_EOA
} },
668 { "ldiq", emit_lda
, NULL
,
669 { MACRO_IR
, MACRO_EXP
, MACRO_EOA
} },
671 { "ldif" emit_ldiq
, NULL
,
672 { MACRO_FPR
, MACRO_EXP
, MACRO_EOA
} },
673 { "ldid" emit_ldiq
, NULL
,
674 { MACRO_FPR
, MACRO_EXP
, MACRO_EOA
} },
675 { "ldig" emit_ldiq
, NULL
,
676 { MACRO_FPR
, MACRO_EXP
, MACRO_EOA
} },
677 { "ldis" emit_ldiq
, NULL
,
678 { MACRO_FPR
, MACRO_EXP
, MACRO_EOA
} },
679 { "ldit" emit_ldiq
, NULL
,
680 { MACRO_FPR
, MACRO_EXP
, MACRO_EOA
} },
683 { "stl", emit_loadstore
, "stl",
684 { MACRO_IR
, MACRO_EXP
, MACRO_OPIR
, MACRO_BASE
, MACRO_EOA
} },
685 { "stl_c", emit_loadstore
, "stl_c",
686 { MACRO_IR
, MACRO_EXP
, MACRO_OPIR
, MACRO_BASE
, MACRO_EOA
} },
687 { "stq", emit_loadstore
, "stq",
688 { MACRO_IR
, MACRO_EXP
, MACRO_OPIR
, MACRO_BASE
, MACRO_EOA
} },
689 { "stq_c", emit_loadstore
, "stq_c",
690 { MACRO_IR
, MACRO_EXP
, MACRO_OPIR
, MACRO_BASE
, MACRO_EOA
} },
691 { "stq_u", emit_loadstore
, "stq_u",
692 { MACRO_IR
, MACRO_EXP
, MACRO_OPIR
, MACRO_BASE
, MACRO_EOA
} },
693 { "stf", emit_loadstore
, "stf",
694 { MACRO_FPR
, MACRO_EXP
, MACRO_OPIR
, MACRO_BASE
, MACRO_EOA
} },
695 { "stg", emit_loadstore
, "stg",
696 { MACRO_FPR
, MACRO_EXP
, MACRO_OPIR
, MACRO_BASE
, MACRO_EOA
} },
697 { "sts", emit_loadstore
, "sts",
698 { MACRO_FPR
, MACRO_EXP
, MACRO_OPIR
, MACRO_BASE
, MACRO_EOA
} },
699 { "stt", emit_loadstore
, "stt",
700 { MACRO_FPR
, MACRO_EXP
, MACRO_OPIR
, MACRO_BASE
, MACRO_EOA
} },
702 { "stb", emit_stX
, (PTR
) 0,
703 { MACRO_IR
, MACRO_EXP
, MACRO_OPIR
, MACRO_BASE
, MACRO_EOA
} },
704 { "stw", emit_stX
, (PTR
) 1,
705 { MACRO_IR
, MACRO_EXP
, MACRO_OPIR
, MACRO_BASE
, MACRO_EOA
} },
706 { "ustw", emit_ustX
, (PTR
) 1,
707 { MACRO_IR
, MACRO_EXP
, MACRO_OPIR
, MACRO_BASE
, MACRO_EOA
} },
708 { "ustl", emit_ustX
, (PTR
) 2,
709 { MACRO_IR
, MACRO_EXP
, MACRO_OPIR
, MACRO_BASE
, MACRO_EOA
} },
710 { "ustq", emit_ustX
, (PTR
) 3,
711 { MACRO_IR
, MACRO_EXP
, MACRO_OPIR
, MACRO_BASE
, MACRO_EOA
} },
713 /* Arithmetic macros */
715 { "absl" emit_absl
, 1, { IR
} },
716 { "absl" emit_absl
, 2, { IR
, IR
} },
717 { "absl" emit_absl
, 2, { EXP
, IR
} },
718 { "absq" emit_absq
, 1, { IR
} },
719 { "absq" emit_absq
, 2, { IR
, IR
} },
720 { "absq" emit_absq
, 2, { EXP
, IR
} },
723 { "sextb", emit_sextX
, (PTR
) 0,
724 { MACRO_IR
, MACRO_IR
, MACRO_EOA
,
726 /* MACRO_EXP, MACRO_IR, MACRO_EOA */ } },
727 { "sextw", emit_sextX
, (PTR
) 1,
728 { MACRO_IR
, MACRO_IR
, MACRO_EOA
,
730 /* MACRO_EXP, MACRO_IR, MACRO_EOA */ } },
732 { "divl", emit_division
, "__divl",
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 { "divlu", emit_division
, "__divlu",
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 { "divq", emit_division
, "__divq",
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 { "divqu", emit_division
, "__divqu",
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 { "reml", emit_division
, "__reml",
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 { "remlu", emit_division
, "__remlu",
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 */ } },
762 { "remq", emit_division
, "__remq",
763 { MACRO_IR
, MACRO_IR
, MACRO_IR
, MACRO_EOA
,
764 MACRO_IR
, MACRO_IR
, MACRO_EOA
,
765 /* MACRO_IR, MACRO_EXP, MACRO_IR, MACRO_EOA,
766 MACRO_IR, MACRO_EXP, MACRO_EOA */ } },
767 { "remqu", emit_division
, "__remqu",
768 { MACRO_IR
, MACRO_IR
, MACRO_IR
, MACRO_EOA
,
769 MACRO_IR
, MACRO_IR
, MACRO_EOA
,
770 /* MACRO_IR, MACRO_EXP, MACRO_IR, MACRO_EOA,
771 MACRO_IR, MACRO_EXP, MACRO_EOA */ } },
773 { "jsr", emit_jsrjmp
, "jsr",
774 { MACRO_PIR
, MACRO_EXP
, MACRO_JSR
, MACRO_EOA
,
775 MACRO_PIR
, MACRO_JSR
, MACRO_EOA
,
776 MACRO_IR
, MACRO_EXP
, MACRO_JSR
, MACRO_EOA
,
777 MACRO_EXP
, MACRO_JSR
, MACRO_EOA
} },
778 { "jmp", emit_jsrjmp
, "jmp",
779 { MACRO_PIR
, MACRO_EXP
, MACRO_JSR
, MACRO_EOA
,
780 MACRO_PIR
, MACRO_JSR
, MACRO_EOA
,
781 MACRO_IR
, MACRO_EXP
, MACRO_JSR
, MACRO_EOA
,
782 MACRO_EXP
, MACRO_JSR
, MACRO_EOA
} },
783 { "ret", emit_retjcr
, "ret",
784 { MACRO_IR
, MACRO_EXP
, MACRO_EOA
,
786 MACRO_PIR
, MACRO_EXP
, MACRO_EOA
,
787 MACRO_PIR
, MACRO_EOA
,
788 MACRO_EXP
, MACRO_EOA
,
790 { "jcr", emit_retjcr
, "jcr",
791 { MACRO_IR
, MACRO_EXP
, MACRO_EOA
,
793 MACRO_PIR
, MACRO_EXP
, MACRO_EOA
,
794 MACRO_PIR
, MACRO_EOA
,
795 MACRO_EXP
, MACRO_EOA
,
797 { "jsr_coroutine", emit_retjcr
, "jcr",
798 { MACRO_IR
, MACRO_EXP
, MACRO_EOA
,
800 MACRO_PIR
, MACRO_EXP
, MACRO_EOA
,
801 MACRO_PIR
, MACRO_EOA
,
802 MACRO_EXP
, MACRO_EOA
,
806 static const unsigned int alpha_num_macros
807 = sizeof (alpha_macros
) / sizeof (*alpha_macros
);
809 /* Public interface functions */
811 /* This function is called once, at assembler startup time. It sets
812 up all the tables, etc. that the MD part of the assembler will
813 need, that can be determined before arguments are parsed. */
820 /* Verify that X_op field is wide enough. */
824 assert (e
.X_op
== O_max
);
827 /* Create the opcode hash table */
829 alpha_opcode_hash
= hash_new ();
830 for (i
= 0; i
< alpha_num_opcodes
; )
832 const char *name
, *retval
, *slash
;
834 name
= alpha_opcodes
[i
].name
;
835 retval
= hash_insert (alpha_opcode_hash
, name
, (PTR
)&alpha_opcodes
[i
]);
837 as_fatal (_("internal error: can't hash opcode `%s': %s"), name
, retval
);
839 /* Some opcodes include modifiers of various sorts with a "/mod"
840 syntax, like the architecture manual suggests. However, for
841 use with gcc at least, we also need access to those same opcodes
844 if ((slash
= strchr (name
, '/')) != NULL
)
846 char *p
= xmalloc (strlen (name
));
847 memcpy (p
, name
, slash
- name
);
848 strcpy (p
+ (slash
- name
), slash
+ 1);
850 (void) hash_insert (alpha_opcode_hash
, p
, (PTR
)&alpha_opcodes
[i
]);
851 /* Ignore failures -- the opcode table does duplicate some
852 variants in different forms, like "hw_stq" and "hw_st/q". */
855 while (++i
< alpha_num_opcodes
856 && (alpha_opcodes
[i
].name
== name
857 || !strcmp (alpha_opcodes
[i
].name
, name
)))
861 /* Create the macro hash table */
863 alpha_macro_hash
= hash_new ();
864 for (i
= 0; i
< alpha_num_macros
; )
866 const char *name
, *retval
;
868 name
= alpha_macros
[i
].name
;
869 retval
= hash_insert (alpha_macro_hash
, name
, (PTR
)&alpha_macros
[i
]);
871 as_fatal (_("internal error: can't hash macro `%s': %s"), name
, retval
);
873 while (++i
< alpha_num_macros
874 && (alpha_macros
[i
].name
== name
875 || !strcmp (alpha_macros
[i
].name
, name
)))
879 /* Construct symbols for each of the registers */
881 for (i
= 0; i
< 32; ++i
)
884 sprintf (name
, "$%d", i
);
885 alpha_register_table
[i
] = symbol_create (name
, reg_section
, i
,
891 sprintf (name
, "$f%d", i
-32);
892 alpha_register_table
[i
] = symbol_create (name
, reg_section
, i
,
896 /* Create the special symbols and sections we'll be using */
898 /* So .sbss will get used for tiny objects. */
899 bfd_set_gp_size (stdoutput
, g_switch_value
);
902 create_literal_section (".lita", &alpha_lita_section
, &alpha_lita_symbol
);
904 /* For handling the GP, create a symbol that won't be output in the
905 symbol table. We'll edit it out of relocs later. */
906 alpha_gp_symbol
= symbol_create ("<GP value>", alpha_lita_section
, 0x8000,
911 create_literal_section (".link", &alpha_link_section
, &alpha_link_symbol
);
917 segT sec
= subseg_new (".mdebug", (subsegT
) 0);
918 bfd_set_section_flags (stdoutput
, sec
, SEC_HAS_CONTENTS
|SEC_READONLY
);
919 bfd_set_section_alignment (stdoutput
, sec
, 3);
923 subseg_set (text_section
, 0);
926 /* Create literal lookup hash table. */
927 alpha_literal_hash
= hash_new ();
931 /* The public interface to the instruction assembler. */
937 char opname
[32]; /* current maximum is 13 */
938 expressionS tok
[MAX_INSN_ARGS
];
942 /* split off the opcode */
943 opnamelen
= strspn (str
, "abcdefghijklmnopqrstuvwxyz_/46819");
944 trunclen
= (opnamelen
< sizeof (opname
) - 1
946 : sizeof (opname
) - 1);
947 memcpy (opname
, str
, trunclen
);
948 opname
[trunclen
] = '\0';
950 /* tokenize the rest of the line */
951 if ((ntok
= tokenize_arguments (str
+ opnamelen
, tok
, MAX_INSN_ARGS
)) < 0)
953 if (ntok
!= TOKENIZE_ERROR_REPORT
)
954 as_bad (_("syntax error"));
960 assemble_tokens (opname
, tok
, ntok
, alpha_macros_on
);
963 /* Round up a section's size to the appropriate boundary. */
966 md_section_align (seg
, size
)
970 int align
= bfd_get_section_alignment (stdoutput
, seg
);
971 valueT mask
= ((valueT
) 1 << align
) - 1;
973 return (size
+ mask
) & ~mask
;
976 /* Turn a string in input_line_pointer into a floating point constant
977 of type TYPE, and store the appropriate bytes in *LITP. The number
978 of LITTLENUMS emitted is stored in *SIZEP. An error message is
979 returned, or NULL on OK. */
981 /* Equal to MAX_PRECISION in atof-ieee.c */
982 #define MAX_LITTLENUMS 6
984 extern char *vax_md_atof
PARAMS ((int, char *, int *));
987 md_atof (type
, litP
, sizeP
)
993 LITTLENUM_TYPE words
[MAX_LITTLENUMS
];
994 LITTLENUM_TYPE
*wordP
;
1001 /* VAX md_atof doesn't like "G" for some reason. */
1005 return vax_md_atof (type
, litP
, sizeP
);
1028 return _("Bad call to MD_ATOF()");
1030 t
= atof_ieee (input_line_pointer
, type
, words
);
1032 input_line_pointer
= t
;
1033 *sizeP
= prec
* sizeof (LITTLENUM_TYPE
);
1035 for (wordP
= words
+ prec
- 1; prec
--;)
1037 md_number_to_chars (litP
, (long) (*wordP
--), sizeof (LITTLENUM_TYPE
));
1038 litP
+= sizeof (LITTLENUM_TYPE
);
1044 /* Take care of the target-specific command-line options. */
1047 md_parse_option (c
, arg
)
1054 alpha_nofloats_on
= 1;
1058 alpha_addr32_on
= 1;
1066 g_switch_value
= atoi (arg
);
1071 const struct cpu_type
*p
;
1072 for (p
= cpu_types
; p
->name
; ++p
)
1073 if (strcmp (arg
, p
->name
) == 0)
1075 alpha_target_name
= p
->name
, alpha_target
= p
->flags
;
1078 as_warn (_("Unknown CPU identifier `%s'"), arg
);
1084 case '+': /* For g++. Hash any name > 63 chars long. */
1085 alpha_flag_hash_long_names
= 1;
1088 case 'H': /* Show new symbol after hash truncation */
1089 alpha_flag_show_after_trunc
= 1;
1092 case 'h': /* for gnu-c/vax compatibility. */
1097 alpha_flag_relax
= 1;
1102 alpha_flag_mdebug
= 1;
1104 case OPTION_NO_MDEBUG
:
1105 alpha_flag_mdebug
= 0;
1116 /* Print a description of the command-line options that we accept. */
1119 md_show_usage (stream
)
1124 -32addr treat addresses as 32-bit values\n\
1125 -F lack floating point instructions support\n\
1126 -mev4 | -mev45 | -mev5 | -mev56 | -mpca56 | -mev6 | -mall\n\
1127 specify variant of Alpha architecture\n\
1128 -m21064 | -m21066 | -m21164 | -m21164a | -m21164pc | -m21264\n\
1129 these variants include PALcode opcodes\n"),
1134 -+ hash encode (don't truncate) names longer than 64 characters\n\
1135 -H show new symbol after hash truncation\n"),
1140 /* Decide from what point a pc-relative relocation is relative to,
1141 relative to the pc-relative fixup. Er, relatively speaking. */
1144 md_pcrel_from (fixP
)
1147 valueT addr
= fixP
->fx_where
+ fixP
->fx_frag
->fr_address
;
1148 switch (fixP
->fx_r_type
)
1150 case BFD_RELOC_ALPHA_GPDISP
:
1151 case BFD_RELOC_ALPHA_GPDISP_HI16
:
1152 case BFD_RELOC_ALPHA_GPDISP_LO16
:
1155 return fixP
->fx_size
+ addr
;
1159 /* Attempt to simplify or even eliminate a fixup. The return value is
1160 ignored; perhaps it was once meaningful, but now it is historical.
1161 To indicate that a fixup has been eliminated, set fixP->fx_done.
1163 For ELF, here it is that we transform the GPDISP_HI16 reloc we used
1164 internally into the GPDISP reloc used externally. We had to do
1165 this so that we'd have the GPDISP_LO16 reloc as a tag to compute
1166 the distance to the "lda" instruction for setting the addend to
1170 md_apply_fix (fixP
, valueP
)
1174 char * const fixpos
= fixP
->fx_frag
->fr_literal
+ fixP
->fx_where
;
1175 valueT value
= *valueP
;
1176 unsigned image
, size
;
1178 switch (fixP
->fx_r_type
)
1180 /* The GPDISP relocations are processed internally with a symbol
1181 referring to the current function; we need to drop in a value
1182 which, when added to the address of the start of the function,
1183 gives the desired GP. */
1184 case BFD_RELOC_ALPHA_GPDISP_HI16
:
1186 fixS
*next
= fixP
->fx_next
;
1187 assert (next
->fx_r_type
== BFD_RELOC_ALPHA_GPDISP_LO16
);
1189 fixP
->fx_offset
= (next
->fx_frag
->fr_address
+ next
->fx_where
1190 - fixP
->fx_frag
->fr_address
- fixP
->fx_where
);
1192 value
= (value
- sign_extend_16 (value
)) >> 16;
1195 fixP
->fx_r_type
= BFD_RELOC_ALPHA_GPDISP
;
1199 case BFD_RELOC_ALPHA_GPDISP_LO16
:
1200 value
= sign_extend_16 (value
);
1201 fixP
->fx_offset
= 0;
1207 fixP
->fx_addsy
= section_symbol (now_seg
);
1208 md_number_to_chars (fixpos
, value
, 2);
1213 fixP
->fx_r_type
= BFD_RELOC_16_PCREL
;
1218 fixP
->fx_r_type
= BFD_RELOC_32_PCREL
;
1223 fixP
->fx_r_type
= BFD_RELOC_64_PCREL
;
1226 if (fixP
->fx_pcrel
== 0 && fixP
->fx_addsy
== 0)
1228 md_number_to_chars (fixpos
, value
, size
);
1234 case BFD_RELOC_GPREL32
:
1235 assert (fixP
->fx_subsy
== alpha_gp_symbol
);
1237 /* FIXME: inherited this obliviousness of `value' -- why? */
1238 md_number_to_chars (fixpos
, -alpha_gp_value
, 4);
1242 case BFD_RELOC_GPREL32
:
1246 case BFD_RELOC_23_PCREL_S2
:
1247 if (fixP
->fx_pcrel
== 0 && fixP
->fx_addsy
== 0)
1249 image
= bfd_getl32 (fixpos
);
1250 image
= (image
& ~0x1FFFFF) | ((value
>> 2) & 0x1FFFFF);
1255 case BFD_RELOC_ALPHA_HINT
:
1256 if (fixP
->fx_pcrel
== 0 && fixP
->fx_addsy
== 0)
1258 image
= bfd_getl32 (fixpos
);
1259 image
= (image
& ~0x3FFF) | ((value
>> 2) & 0x3FFF);
1265 case BFD_RELOC_ALPHA_LITERAL
:
1266 md_number_to_chars (fixpos
, value
, 2);
1269 case BFD_RELOC_ALPHA_LITUSE
:
1273 case BFD_RELOC_ALPHA_ELF_LITERAL
:
1274 case BFD_RELOC_ALPHA_LITUSE
:
1278 case BFD_RELOC_ALPHA_LINKAGE
:
1279 case BFD_RELOC_ALPHA_CODEADDR
:
1284 case BFD_RELOC_ALPHA_USER_LITERAL
:
1285 case BFD_RELOC_ALPHA_USER_LITUSE_BASE
:
1286 case BFD_RELOC_ALPHA_USER_LITUSE_BYTOFF
:
1287 case BFD_RELOC_ALPHA_USER_LITUSE_JSR
:
1290 case BFD_RELOC_ALPHA_USER_GPDISP
:
1291 case BFD_RELOC_ALPHA_USER_GPRELHIGH
:
1292 case BFD_RELOC_ALPHA_USER_GPRELLOW
:
1296 case BFD_RELOC_VTABLE_INHERIT
:
1297 case BFD_RELOC_VTABLE_ENTRY
:
1302 const struct alpha_operand
*operand
;
1304 if ((int) fixP
->fx_r_type
>= 0)
1305 as_fatal (_("unhandled relocation type %s"),
1306 bfd_get_reloc_code_name (fixP
->fx_r_type
));
1308 assert (-(int) fixP
->fx_r_type
< (int) alpha_num_operands
);
1309 operand
= &alpha_operands
[-(int) fixP
->fx_r_type
];
1311 /* The rest of these fixups only exist internally during symbol
1312 resolution and have no representation in the object file.
1313 Therefore they must be completely resolved as constants. */
1315 if (fixP
->fx_addsy
!= 0
1316 && S_GET_SEGMENT (fixP
->fx_addsy
) != absolute_section
)
1317 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
1318 _("non-absolute expression in constant field"));
1320 image
= bfd_getl32 (fixpos
);
1321 image
= insert_operand (image
, operand
, (offsetT
) value
,
1322 fixP
->fx_file
, fixP
->fx_line
);
1327 if (fixP
->fx_addsy
!= 0 || fixP
->fx_pcrel
!= 0)
1331 as_warn_where (fixP
->fx_file
, fixP
->fx_line
,
1332 _("type %d reloc done?\n"), (int) fixP
->fx_r_type
);
1337 md_number_to_chars (fixpos
, image
, 4);
1345 * Look for a register name in the given symbol.
1349 md_undefined_symbol (name
)
1354 int is_float
= 0, num
;
1359 if (name
[1] == 'p' && name
[2] == '\0')
1360 return alpha_register_table
[AXP_REG_FP
];
1365 if (!isdigit (*++name
))
1369 case '0': case '1': case '2': case '3': case '4':
1370 case '5': case '6': case '7': case '8': case '9':
1371 if (name
[1] == '\0')
1372 num
= name
[0] - '0';
1373 else if (name
[0] != '0' && isdigit (name
[1]) && name
[2] == '\0')
1375 num
= (name
[0] - '0') * 10 + name
[1] - '0';
1382 if (!alpha_noat_on
&& (num
+ is_float
) == AXP_REG_AT
)
1383 as_warn (_("Used $at without \".set noat\""));
1384 return alpha_register_table
[num
+ is_float
];
1387 if (name
[1] == 't' && name
[2] == '\0')
1390 as_warn (_("Used $at without \".set noat\""));
1391 return alpha_register_table
[AXP_REG_AT
];
1396 if (name
[1] == 'p' && name
[2] == '\0')
1397 return alpha_register_table
[alpha_gp_register
];
1401 if (name
[1] == 'p' && name
[2] == '\0')
1402 return alpha_register_table
[AXP_REG_SP
];
1410 /* @@@ Magic ECOFF bits. */
1413 alpha_frob_ecoff_data ()
1416 /* $zero and $f31 are read-only */
1417 alpha_gprmask
&= ~1;
1418 alpha_fprmask
&= ~1;
1422 /* Hook to remember a recently defined label so that the auto-align
1423 code can adjust the symbol after we know what alignment will be
1427 alpha_define_label (sym
)
1430 alpha_insn_label
= sym
;
1433 /* Return true if we must always emit a reloc for a type and false if
1434 there is some hope of resolving it a assembly time. */
1437 alpha_force_relocation (f
)
1440 if (alpha_flag_relax
)
1443 switch (f
->fx_r_type
)
1445 case BFD_RELOC_ALPHA_GPDISP_HI16
:
1446 case BFD_RELOC_ALPHA_GPDISP_LO16
:
1447 case BFD_RELOC_ALPHA_GPDISP
:
1449 case BFD_RELOC_ALPHA_LITERAL
:
1452 case BFD_RELOC_ALPHA_ELF_LITERAL
:
1454 case BFD_RELOC_ALPHA_LITUSE
:
1455 case BFD_RELOC_GPREL32
:
1457 case BFD_RELOC_ALPHA_LINKAGE
:
1458 case BFD_RELOC_ALPHA_CODEADDR
:
1461 case BFD_RELOC_ALPHA_USER_LITERAL
:
1462 case BFD_RELOC_ALPHA_USER_LITUSE_BASE
:
1463 case BFD_RELOC_ALPHA_USER_LITUSE_BYTOFF
:
1464 case BFD_RELOC_ALPHA_USER_LITUSE_JSR
:
1465 case BFD_RELOC_ALPHA_USER_GPDISP
:
1466 case BFD_RELOC_ALPHA_USER_GPRELHIGH
:
1467 case BFD_RELOC_ALPHA_USER_GPRELLOW
:
1469 case BFD_RELOC_VTABLE_INHERIT
:
1470 case BFD_RELOC_VTABLE_ENTRY
:
1473 case BFD_RELOC_23_PCREL_S2
:
1476 case BFD_RELOC_ALPHA_HINT
:
1480 assert ((int) f
->fx_r_type
< 0 && -(int) f
->fx_r_type
< (int) alpha_num_operands
);
1485 /* Return true if we can partially resolve a relocation now. */
1488 alpha_fix_adjustable (f
)
1492 /* Prevent all adjustments to global symbols */
1493 if (S_IS_EXTERN (f
->fx_addsy
) || S_IS_WEAK (f
->fx_addsy
))
1497 /* Are there any relocation types for which we must generate a reloc
1498 but we can adjust the values contained within it? */
1499 switch (f
->fx_r_type
)
1501 case BFD_RELOC_ALPHA_GPDISP_HI16
:
1502 case BFD_RELOC_ALPHA_GPDISP_LO16
:
1503 case BFD_RELOC_ALPHA_GPDISP
:
1507 case BFD_RELOC_ALPHA_LITERAL
:
1510 case BFD_RELOC_ALPHA_ELF_LITERAL
:
1513 case BFD_RELOC_ALPHA_USER_LITERAL
:
1516 case BFD_RELOC_ALPHA_LINKAGE
:
1517 case BFD_RELOC_ALPHA_CODEADDR
:
1521 case BFD_RELOC_ALPHA_LITUSE
:
1523 case BFD_RELOC_ALPHA_USER_LITUSE_BASE
:
1524 case BFD_RELOC_ALPHA_USER_LITUSE_BYTOFF
:
1525 case BFD_RELOC_ALPHA_USER_LITUSE_JSR
:
1526 case BFD_RELOC_ALPHA_USER_GPDISP
:
1527 case BFD_RELOC_ALPHA_USER_GPRELHIGH
:
1528 case BFD_RELOC_ALPHA_USER_GPRELLOW
:
1530 case BFD_RELOC_VTABLE_ENTRY
:
1531 case BFD_RELOC_VTABLE_INHERIT
:
1534 case BFD_RELOC_GPREL32
:
1535 case BFD_RELOC_23_PCREL_S2
:
1538 case BFD_RELOC_ALPHA_HINT
:
1542 assert ((int) f
->fx_r_type
< 0
1543 && - (int) f
->fx_r_type
< (int) alpha_num_operands
);
1549 /* Generate the BFD reloc to be stuck in the object file from the
1550 fixup used internally in the assembler. */
1553 tc_gen_reloc (sec
, fixp
)
1554 asection
*sec ATTRIBUTE_UNUSED
;
1559 reloc
= (arelent
*) xmalloc (sizeof (arelent
));
1560 reloc
->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
1561 *reloc
->sym_ptr_ptr
= symbol_get_bfdsym (fixp
->fx_addsy
);
1562 reloc
->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
1564 /* Make sure none of our internal relocations make it this far.
1565 They'd better have been fully resolved by this point. */
1566 assert ((int) fixp
->fx_r_type
> 0);
1568 reloc
->howto
= bfd_reloc_type_lookup (stdoutput
, fixp
->fx_r_type
);
1569 if (reloc
->howto
== NULL
)
1571 as_bad_where (fixp
->fx_file
, fixp
->fx_line
,
1572 _("cannot represent `%s' relocation in object file"),
1573 bfd_get_reloc_code_name (fixp
->fx_r_type
));
1577 if (!fixp
->fx_pcrel
!= !reloc
->howto
->pc_relative
)
1579 as_fatal (_("internal error? cannot generate `%s' relocation"),
1580 bfd_get_reloc_code_name (fixp
->fx_r_type
));
1582 assert (!fixp
->fx_pcrel
== !reloc
->howto
->pc_relative
);
1585 if (fixp
->fx_r_type
== BFD_RELOC_ALPHA_LITERAL
)
1587 /* fake out bfd_perform_relocation. sigh */
1588 reloc
->addend
= -alpha_gp_value
;
1593 reloc
->addend
= fixp
->fx_offset
;
1596 * Ohhh, this is ugly. The problem is that if this is a local global
1597 * symbol, the relocation will entirely be performed at link time, not
1598 * at assembly time. bfd_perform_reloc doesn't know about this sort
1599 * of thing, and as a result we need to fake it out here.
1601 if ((S_IS_EXTERN (fixp
->fx_addsy
) || S_IS_WEAK (fixp
->fx_addsy
))
1602 && !S_IS_COMMON (fixp
->fx_addsy
))
1603 reloc
->addend
-= symbol_get_bfdsym (fixp
->fx_addsy
)->value
;
1610 /* Parse a register name off of the input_line and return a register
1611 number. Gets md_undefined_symbol above to do the register name
1614 Only called as a part of processing the ECOFF .frame directive. */
1617 tc_get_register (frame
)
1618 int frame ATTRIBUTE_UNUSED
;
1620 int framereg
= AXP_REG_SP
;
1623 if (*input_line_pointer
== '$')
1625 char *s
= input_line_pointer
;
1626 char c
= get_symbol_end ();
1627 symbolS
*sym
= md_undefined_symbol (s
);
1629 *strchr (s
, '\0') = c
;
1630 if (sym
&& (framereg
= S_GET_VALUE (sym
)) <= 31)
1633 as_warn (_("frame reg expected, using $%d."), framereg
);
1636 note_gpreg (framereg
);
1640 /* This is called before the symbol table is processed. In order to
1641 work with gcc when using mips-tfile, we must keep all local labels.
1642 However, in other cases, we want to discard them. If we were
1643 called with -g, but we didn't see any debugging information, it may
1644 mean that gcc is smuggling debugging information through to
1645 mips-tfile, in which case we must generate all local labels. */
1650 alpha_frob_file_before_adjust ()
1652 if (alpha_debug
!= 0
1653 && ! ecoff_debugging_seen
)
1654 flag_keep_locals
= 1;
1657 #endif /* OBJ_ECOFF */
1661 /* Before the relocations are written, reorder them, so that user supplied
1662 !lituse relocations follow the appropriate !literal relocations. Also
1663 convert the gas-internal relocations to the appropriate linker relocations.
1667 alpha_adjust_symtab ()
1669 if (alpha_literal_hash
)
1672 fprintf (stderr
, "alpha_adjust_symtab called\n");
1675 /* Go over each section, reordering the relocations so that all of the
1676 explicit LITUSE's are adjacent to the explicit LITERAL's */
1677 bfd_map_over_sections (stdoutput
, alpha_adjust_symtab_relocs
, (char *) 0);
1682 /* Inner function to move LITUSE's next to the LITERAL. */
1685 alpha_adjust_symtab_relocs (abfd
, sec
, ptr
)
1686 bfd
*abfd ATTRIBUTE_UNUSED
;
1688 PTR ptr ATTRIBUTE_UNUSED
;
1690 segment_info_type
*seginfo
= seg_info (sec
);
1700 int n_dup_literals
= 0;
1703 /* If seginfo is NULL, we did not create this section; don't do anything with
1704 it. By using a pointer to a pointer, we can update the links in place. */
1705 if (seginfo
== NULL
)
1708 /* If there are no relocations, skip the section. */
1709 if (! seginfo
->fix_root
)
1712 /* First rebuild the fixup chain without the expicit lituse's. */
1713 prevP
= &(seginfo
->fix_root
);
1714 for (fixp
= seginfo
->fix_root
; fixp
; fixp
= next
)
1716 next
= fixp
->fx_next
;
1717 fixp
->fx_next
= (fixS
*) 0;
1722 switch (fixp
->fx_r_type
)
1726 prevP
= &(fixp
->fx_next
);
1729 "alpha_adjust_symtab_relocs: 0x%lx, other relocation %s\n",
1731 bfd_get_reloc_code_name (fixp
->fx_r_type
));
1735 case BFD_RELOC_ALPHA_USER_LITERAL
:
1737 prevP
= &(fixp
->fx_next
);
1738 /* prevent assembler from trying to adjust the offset */
1741 if (fixp
->tc_fix_data
.info
->n_literals
!= 1)
1744 "alpha_adjust_symtab_relocs: 0x%lx, !literal!%.6d, # literals = %2d\n",
1746 fixp
->tc_fix_data
.info
->sequence
,
1747 fixp
->tc_fix_data
.info
->n_literals
);
1751 /* do not link in lituse's */
1752 case BFD_RELOC_ALPHA_USER_LITUSE_BASE
:
1753 case BFD_RELOC_ALPHA_USER_LITUSE_BYTOFF
:
1754 case BFD_RELOC_ALPHA_USER_LITUSE_JSR
:
1756 if (fixp
->tc_fix_data
.info
->n_literals
== 0)
1757 as_bad_where (fixp
->fx_file
, fixp
->fx_line
,
1758 _("No !literal!%d was found"),
1759 fixp
->tc_fix_data
.info
->sequence
);
1762 "alpha_adjust_symtab_relocs: 0x%lx, !lituse !%.6d, # lituses = %2d, next_lituse = 0x%lx\n",
1764 fixp
->tc_fix_data
.info
->sequence
,
1765 fixp
->tc_fix_data
.info
->n_lituses
,
1766 (long) fixp
->tc_fix_data
.next_lituse
);
1772 /* If there were any lituses, go and add them to the chain, unless there is
1773 more than one !literal for a given sequence number. They are linked
1774 through the next_lituse field in reverse order, so as we go through the
1775 next_lituse chain, we effectively reverse the chain once again. If there
1776 was more than one !literal, we fall back to loading up the address w/o
1777 optimization. Also, if the !literals/!lituses are spread in different
1778 segments (happens in the Linux kernel semaphores), suppress the
1782 for (fixp
= seginfo
->fix_root
; fixp
; fixp
= fixp
->fx_next
)
1784 switch (fixp
->fx_r_type
)
1789 case BFD_RELOC_ALPHA_USER_LITERAL
:
1791 fixp
->fx_r_type
= BFD_RELOC_ALPHA_ELF_LITERAL
;
1793 fixp
->fx_r_type
= BFD_RELOC_ALPHA_LITERAL
; /* XXX check this */
1795 if (fixp
->tc_fix_data
.info
->n_literals
== 1
1796 && ! fixp
->tc_fix_data
.info
->multi_section_p
)
1798 for (lituse
= fixp
->tc_fix_data
.info
->lituse
;
1799 lituse
!= (fixS
*) 0;
1800 lituse
= lituse
->tc_fix_data
.next_lituse
)
1802 lituse
->fx_next
= fixp
->fx_next
;
1803 fixp
->fx_next
= lituse
;
1808 case BFD_RELOC_ALPHA_USER_LITUSE_BASE
:
1809 case BFD_RELOC_ALPHA_USER_LITUSE_BYTOFF
:
1810 case BFD_RELOC_ALPHA_USER_LITUSE_JSR
:
1811 fixp
->fx_r_type
= BFD_RELOC_ALPHA_LITUSE
;
1818 fprintf (stderr
, "alpha_adjust_symtab_relocs: %s, %d literal%s, %d duplicate literal%s, %d lituse%s\n\n",
1820 n_literals
, (n_literals
== 1) ? "" : "s",
1821 n_dup_literals
, (n_dup_literals
== 1) ? "" : "s",
1822 n_lituses
, (n_lituses
== 1) ? "" : "s");
1826 #endif /* RELOC_OP_P */
1831 debug_exp (tok
, ntok
)
1837 fprintf (stderr
, "debug_exp: %d tokens", ntok
);
1838 for (i
= 0; i
< ntok
; i
++)
1840 expressionS
*t
= &tok
[i
];
1844 default: name
= "unknown"; break;
1845 case O_illegal
: name
= "O_illegal"; break;
1846 case O_absent
: name
= "O_absent"; break;
1847 case O_constant
: name
= "O_constant"; break;
1848 case O_symbol
: name
= "O_symbol"; break;
1849 case O_symbol_rva
: name
= "O_symbol_rva"; break;
1850 case O_register
: name
= "O_register"; break;
1851 case O_big
: name
= "O_big"; break;
1852 case O_uminus
: name
= "O_uminus"; break;
1853 case O_bit_not
: name
= "O_bit_not"; break;
1854 case O_logical_not
: name
= "O_logical_not"; break;
1855 case O_multiply
: name
= "O_multiply"; break;
1856 case O_divide
: name
= "O_divide"; break;
1857 case O_modulus
: name
= "O_modulus"; break;
1858 case O_left_shift
: name
= "O_left_shift"; break;
1859 case O_right_shift
: name
= "O_right_shift"; break;
1860 case O_bit_inclusive_or
: name
= "O_bit_inclusive_or"; break;
1861 case O_bit_or_not
: name
= "O_bit_or_not"; break;
1862 case O_bit_exclusive_or
: name
= "O_bit_exclusive_or"; break;
1863 case O_bit_and
: name
= "O_bit_and"; break;
1864 case O_add
: name
= "O_add"; break;
1865 case O_subtract
: name
= "O_subtract"; break;
1866 case O_eq
: name
= "O_eq"; break;
1867 case O_ne
: name
= "O_ne"; break;
1868 case O_lt
: name
= "O_lt"; break;
1869 case O_le
: name
= "O_le"; break;
1870 case O_ge
: name
= "O_ge"; break;
1871 case O_gt
: name
= "O_gt"; break;
1872 case O_logical_and
: name
= "O_logical_and"; break;
1873 case O_logical_or
: name
= "O_logical_or"; break;
1874 case O_index
: name
= "O_index"; break;
1875 case O_pregister
: name
= "O_pregister"; break;
1876 case O_cpregister
: name
= "O_cpregister"; break;
1877 case O_literal
: name
= "O_literal"; break;
1878 case O_lituse_base
: name
= "O_lituse_base"; break;
1879 case O_lituse_bytoff
: name
= "O_lituse_bytoff"; break;
1880 case O_lituse_jsr
: name
= "O_lituse_jsr"; break;
1881 case O_gpdisp
: name
= "O_gpdisp"; break;
1882 case O_gprelhigh
: name
= "O_gprelhigh"; break;
1883 case O_gprellow
: name
= "O_gprellow"; break;
1884 case O_md10
: name
= "O_md10"; break;
1885 case O_md11
: name
= "O_md11"; break;
1886 case O_md12
: name
= "O_md12"; break;
1887 case O_md13
: name
= "O_md13"; break;
1888 case O_md14
: name
= "O_md14"; break;
1889 case O_md15
: name
= "O_md15"; break;
1890 case O_md16
: name
= "O_md16"; break;
1893 fprintf (stderr
, ", %s(%s, %s, %d)", name
,
1894 (t
->X_add_symbol
) ? S_GET_NAME (t
->X_add_symbol
) : "--",
1895 (t
->X_op_symbol
) ? S_GET_NAME (t
->X_op_symbol
) : "--",
1896 (int) t
->X_add_number
);
1898 fprintf (stderr
, "\n");
1903 /* Parse the arguments to an opcode. */
1906 tokenize_arguments (str
, tok
, ntok
)
1911 expressionS
*end_tok
= tok
+ ntok
;
1912 char *old_input_line_pointer
;
1913 int saw_comma
= 0, saw_arg
= 0;
1915 expressionS
*orig_tok
= tok
;
1919 const struct alpha_reloc_op_tag
*r
;
1922 int reloc_found_p
= 0;
1925 memset (tok
, 0, sizeof (*tok
) * ntok
);
1927 /* Save and restore input_line_pointer around this function */
1928 old_input_line_pointer
= input_line_pointer
;
1929 input_line_pointer
= str
;
1931 while (tok
< end_tok
&& *input_line_pointer
)
1934 switch (*input_line_pointer
)
1941 /* A relocation operand can be placed after the normal operand on an
1942 assembly language statement, and has the following form:
1943 !relocation_type!sequence_number. */
1945 { /* only support one relocation op per insn */
1946 as_bad (_("More than one relocation op per insn"));
1953 for (p
= ++input_line_pointer
;
1954 ((c
= *p
) != '!' && c
!= ';' && c
!= '#' && c
!= ','
1955 && !is_end_of_line
[c
]);
1959 /* Parse !relocation_type */
1960 len
= p
- input_line_pointer
;
1963 as_bad (_("No relocation operand"));
1969 as_bad (_("No !sequence-number after !%s"), input_line_pointer
);
1973 r
= &alpha_reloc_op
[0];
1974 for (i
= alpha_num_reloc_op
-1; i
>= 0; i
--, r
++)
1976 if (len
== r
->length
1977 && memcmp (input_line_pointer
, r
->name
, len
) == 0)
1982 as_bad (_("Unknown relocation operand: !%s"), input_line_pointer
);
1986 input_line_pointer
= ++p
;
1988 /* Parse !sequence_number */
1989 memset (tok
, '\0', sizeof (expressionS
));
1992 if (tok
->X_op
!= O_constant
1993 || ! ALPHA_RELOC_SEQUENCE_OK (tok
->X_add_number
))
1995 as_bad (_("Bad sequence number: !%s!%s"), r
->name
, input_line_pointer
);
2006 ++input_line_pointer
;
2007 if (saw_comma
|| !saw_arg
)
2014 char *hold
= input_line_pointer
++;
2016 /* First try for parenthesized register ... */
2018 if (*input_line_pointer
== ')' && tok
->X_op
== O_register
)
2020 tok
->X_op
= (saw_comma
? O_cpregister
: O_pregister
);
2023 ++input_line_pointer
;
2028 /* ... then fall through to plain expression */
2029 input_line_pointer
= hold
;
2033 if (saw_arg
&& !saw_comma
)
2037 if (tok
->X_op
== O_illegal
|| tok
->X_op
== O_absent
)
2050 input_line_pointer
= old_input_line_pointer
;
2053 debug_exp (orig_tok
, ntok
- (end_tok
- tok
));
2056 return ntok
- (end_tok
- tok
);
2059 input_line_pointer
= old_input_line_pointer
;
2060 return TOKENIZE_ERROR
;
2064 input_line_pointer
= old_input_line_pointer
;
2065 return TOKENIZE_ERROR_REPORT
;
2069 /* Search forward through all variants of an opcode looking for a
2072 static const struct alpha_opcode
*
2073 find_opcode_match (first_opcode
, tok
, pntok
, pcpumatch
)
2074 const struct alpha_opcode
*first_opcode
;
2075 const expressionS
*tok
;
2079 const struct alpha_opcode
*opcode
= first_opcode
;
2081 int got_cpu_match
= 0;
2085 const unsigned char *opidx
;
2088 /* Don't match opcodes that don't exist on this architecture */
2089 if (!(opcode
->flags
& alpha_target
))
2094 for (opidx
= opcode
->operands
; *opidx
; ++opidx
)
2096 const struct alpha_operand
*operand
= &alpha_operands
[*opidx
];
2098 /* only take input from real operands */
2099 if (operand
->flags
& AXP_OPERAND_FAKE
)
2102 /* when we expect input, make sure we have it */
2105 if ((operand
->flags
& AXP_OPERAND_OPTIONAL_MASK
) == 0)
2110 /* match operand type with expression type */
2111 switch (operand
->flags
& AXP_OPERAND_TYPECHECK_MASK
)
2113 case AXP_OPERAND_IR
:
2114 if (tok
[tokidx
].X_op
!= O_register
2115 || !is_ir_num (tok
[tokidx
].X_add_number
))
2118 case AXP_OPERAND_FPR
:
2119 if (tok
[tokidx
].X_op
!= O_register
2120 || !is_fpr_num (tok
[tokidx
].X_add_number
))
2123 case AXP_OPERAND_IR
|AXP_OPERAND_PARENS
:
2124 if (tok
[tokidx
].X_op
!= O_pregister
2125 || !is_ir_num (tok
[tokidx
].X_add_number
))
2128 case AXP_OPERAND_IR
|AXP_OPERAND_PARENS
|AXP_OPERAND_COMMA
:
2129 if (tok
[tokidx
].X_op
!= O_cpregister
2130 || !is_ir_num (tok
[tokidx
].X_add_number
))
2134 case AXP_OPERAND_RELATIVE
:
2135 case AXP_OPERAND_SIGNED
:
2136 case AXP_OPERAND_UNSIGNED
:
2137 switch (tok
[tokidx
].X_op
)
2152 /* everything else should have been fake */
2158 /* possible match -- did we use all of our input? */
2167 while (++opcode
-alpha_opcodes
< alpha_num_opcodes
2168 && !strcmp (opcode
->name
, first_opcode
->name
));
2171 *pcpumatch
= got_cpu_match
;
2176 /* Search forward through all variants of a macro looking for a syntax
2179 static const struct alpha_macro
*
2180 find_macro_match (first_macro
, tok
, pntok
)
2181 const struct alpha_macro
*first_macro
;
2182 const expressionS
*tok
;
2185 const struct alpha_macro
*macro
= first_macro
;
2190 const enum alpha_macro_arg
*arg
= macro
->argsets
;
2204 /* index register */
2206 if (tokidx
>= ntok
|| tok
[tokidx
].X_op
!= O_register
2207 || !is_ir_num (tok
[tokidx
].X_add_number
))
2212 /* parenthesized index register */
2214 if (tokidx
>= ntok
|| tok
[tokidx
].X_op
!= O_pregister
2215 || !is_ir_num (tok
[tokidx
].X_add_number
))
2220 /* optional parenthesized index register */
2222 if (tokidx
< ntok
&& tok
[tokidx
].X_op
== O_pregister
2223 && is_ir_num (tok
[tokidx
].X_add_number
))
2227 /* leading comma with a parenthesized index register */
2229 if (tokidx
>= ntok
|| tok
[tokidx
].X_op
!= O_cpregister
2230 || !is_ir_num (tok
[tokidx
].X_add_number
))
2235 /* floating point register */
2237 if (tokidx
>= ntok
|| tok
[tokidx
].X_op
!= O_register
2238 || !is_fpr_num (tok
[tokidx
].X_add_number
))
2243 /* normal expression */
2247 switch (tok
[tokidx
].X_op
)
2257 case O_lituse_bytoff
:
2271 /* optional !literal!<number> */
2274 if (tokidx
< ntok
&& tok
[tokidx
].X_op
== O_literal
)
2279 /* optional !lituse_base!<number> */
2282 if (tokidx
< ntok
&& tok
[tokidx
].X_op
== O_lituse_base
)
2287 /* optional !lituse_bytoff!<number> */
2290 if (tokidx
< ntok
&& tok
[tokidx
].X_op
== O_lituse_bytoff
)
2295 /* optional !lituse_jsr!<number> */
2298 if (tokidx
< ntok
&& tok
[tokidx
].X_op
== O_lituse_jsr
)
2304 while (*arg
!= MACRO_EOA
)
2312 while (++macro
-alpha_macros
< alpha_num_macros
2313 && !strcmp (macro
->name
, first_macro
->name
));
2318 /* Insert an operand value into an instruction. */
2321 insert_operand (insn
, operand
, val
, file
, line
)
2323 const struct alpha_operand
*operand
;
2328 if (operand
->bits
!= 32 && !(operand
->flags
& AXP_OPERAND_NOOVERFLOW
))
2332 if (operand
->flags
& AXP_OPERAND_SIGNED
)
2334 max
= (1 << (operand
->bits
- 1)) - 1;
2335 min
= -(1 << (operand
->bits
- 1));
2339 max
= (1 << operand
->bits
) - 1;
2343 if (val
< min
|| val
> max
)
2346 _("operand out of range (%s not between %d and %d)");
2347 char buf
[sizeof (val
) * 3 + 2];
2349 sprint_value (buf
, val
);
2351 as_warn_where (file
, line
, err
, buf
, min
, max
);
2353 as_warn (err
, buf
, min
, max
);
2357 if (operand
->insert
)
2359 const char *errmsg
= NULL
;
2361 insn
= (*operand
->insert
) (insn
, val
, &errmsg
);
2366 insn
|= ((val
& ((1 << operand
->bits
) - 1)) << operand
->shift
);
2372 * Turn an opcode description and a set of arguments into
2373 * an instruction and a fixup.
2377 assemble_insn (opcode
, tok
, ntok
, insn
)
2378 const struct alpha_opcode
*opcode
;
2379 const expressionS
*tok
;
2381 struct alpha_insn
*insn
;
2383 const unsigned char *argidx
;
2387 memset (insn
, 0, sizeof (*insn
));
2388 image
= opcode
->opcode
;
2390 for (argidx
= opcode
->operands
; *argidx
; ++argidx
)
2392 const struct alpha_operand
*operand
= &alpha_operands
[*argidx
];
2393 const expressionS
*t
= (const expressionS
*) 0;
2395 if (operand
->flags
& AXP_OPERAND_FAKE
)
2397 /* fake operands take no value and generate no fixup */
2398 image
= insert_operand (image
, operand
, 0, NULL
, 0);
2404 switch (operand
->flags
& AXP_OPERAND_OPTIONAL_MASK
)
2406 case AXP_OPERAND_DEFAULT_FIRST
:
2409 case AXP_OPERAND_DEFAULT_SECOND
:
2412 case AXP_OPERAND_DEFAULT_ZERO
:
2414 static expressionS zero_exp
;
2416 zero_exp
.X_op
= O_constant
;
2417 zero_exp
.X_unsigned
= 1;
2432 image
= insert_operand (image
, operand
, regno (t
->X_add_number
),
2437 image
= insert_operand (image
, operand
, t
->X_add_number
, NULL
, 0);
2442 struct alpha_fixup
*fixup
;
2444 if (insn
->nfixups
>= MAX_INSN_FIXUPS
)
2445 as_fatal (_("too many fixups"));
2447 fixup
= &insn
->fixups
[insn
->nfixups
++];
2450 fixup
->reloc
= operand
->default_reloc
;
2460 * Actually output an instruction with its fixup.
2465 struct alpha_insn
*insn
;
2470 /* Take care of alignment duties */
2471 if (alpha_auto_align_on
&& alpha_current_align
< 2)
2472 alpha_align (2, (char *) NULL
, alpha_insn_label
, 0);
2473 if (alpha_current_align
> 2)
2474 alpha_current_align
= 2;
2475 alpha_insn_label
= NULL
;
2477 /* Write out the instruction. */
2479 md_number_to_chars (f
, insn
->insn
, 4);
2482 dwarf2_emit_insn (4);
2485 /* Apply the fixups in order */
2486 for (i
= 0; i
< insn
->nfixups
; ++i
)
2488 const struct alpha_operand
*operand
= (const struct alpha_operand
*) 0;
2489 struct alpha_fixup
*fixup
= &insn
->fixups
[i
];
2493 char buffer
[ALPHA_RELOC_DIGITS
];
2494 struct alpha_literal_tag
*info
;
2497 /* Some fixups are only used internally and so have no howto */
2498 if ((int) fixup
->reloc
< 0)
2500 operand
= &alpha_operands
[-(int) fixup
->reloc
];
2502 pcrel
= ((operand
->flags
& AXP_OPERAND_RELATIVE
) != 0);
2505 switch (fixup
->reloc
)
2508 /* These relocation types are only used internally. */
2509 case BFD_RELOC_ALPHA_GPDISP_HI16
:
2510 case BFD_RELOC_ALPHA_GPDISP_LO16
:
2516 /* and these also are internal only relocations */
2517 case BFD_RELOC_ALPHA_USER_LITERAL
:
2518 case BFD_RELOC_ALPHA_USER_LITUSE_BASE
:
2519 case BFD_RELOC_ALPHA_USER_LITUSE_BYTOFF
:
2520 case BFD_RELOC_ALPHA_USER_LITUSE_JSR
:
2521 case BFD_RELOC_ALPHA_USER_GPDISP
:
2522 case BFD_RELOC_ALPHA_USER_GPRELHIGH
:
2523 case BFD_RELOC_ALPHA_USER_GPRELLOW
:
2531 reloc_howto_type
*reloc_howto
2532 = bfd_reloc_type_lookup (stdoutput
, fixup
->reloc
);
2533 assert (reloc_howto
);
2535 size
= bfd_get_reloc_size (reloc_howto
);
2536 pcrel
= reloc_howto
->pc_relative
;
2538 assert (size
>= 1 && size
<= 4);
2542 fixP
= fix_new_exp (frag_now
, f
- frag_now
->fr_literal
, size
,
2543 &fixup
->exp
, pcrel
, fixup
->reloc
);
2545 /* Turn off complaints that the addend is too large for some fixups,
2546 and copy in the sequence number for the explicit relocations. */
2547 switch (fixup
->reloc
)
2549 case BFD_RELOC_ALPHA_GPDISP_LO16
:
2551 case BFD_RELOC_ALPHA_LITERAL
:
2554 case BFD_RELOC_ALPHA_ELF_LITERAL
:
2556 case BFD_RELOC_GPREL32
:
2557 fixP
->fx_no_overflow
= 1;
2561 case BFD_RELOC_ALPHA_USER_LITERAL
:
2562 fixP
->fx_no_overflow
= 1;
2563 sprintf (buffer
, "!%u", insn
->sequence
[i
]);
2564 info
= ((struct alpha_literal_tag
*)
2565 hash_find (alpha_literal_hash
, buffer
));
2569 size_t len
= strlen (buffer
);
2572 info
= ((struct alpha_literal_tag
*)
2573 xcalloc (sizeof (struct alpha_literal_tag
) + len
, 1));
2575 info
->segment
= now_seg
;
2576 info
->sequence
= insn
->sequence
[i
];
2577 strcpy (info
->string
, buffer
);
2578 errmsg
= hash_insert (alpha_literal_hash
, info
->string
, (PTR
) info
);
2585 if (info
->segment
!= now_seg
)
2586 info
->multi_section_p
= 1;
2588 fixP
->tc_fix_data
.info
= info
;
2591 case BFD_RELOC_ALPHA_USER_LITUSE_BASE
:
2592 case BFD_RELOC_ALPHA_USER_LITUSE_BYTOFF
:
2593 case BFD_RELOC_ALPHA_USER_LITUSE_JSR
:
2594 sprintf (buffer
, "!%u", insn
->sequence
[i
]);
2595 info
= ((struct alpha_literal_tag
*)
2596 hash_find (alpha_literal_hash
, buffer
));
2600 size_t len
= strlen (buffer
);
2603 info
= ((struct alpha_literal_tag
*)
2604 xcalloc (sizeof (struct alpha_literal_tag
) + len
, 1));
2606 info
->segment
= now_seg
;
2607 info
->sequence
= insn
->sequence
[i
];
2608 strcpy (info
->string
, buffer
);
2609 errmsg
= hash_insert (alpha_literal_hash
, info
->string
, (PTR
) info
);
2614 fixP
->tc_fix_data
.info
= info
;
2615 fixP
->tc_fix_data
.next_lituse
= info
->lituse
;
2616 info
->lituse
= fixP
;
2617 if (info
->segment
!= now_seg
)
2618 info
->multi_section_p
= 1;
2624 if ((int) fixup
->reloc
< 0)
2626 if (operand
->flags
& AXP_OPERAND_NOOVERFLOW
)
2627 fixP
->fx_no_overflow
= 1;
2634 /* Given an opcode name and a pre-tokenized set of arguments, assemble
2635 the insn, but do not emit it.
2637 Note that this implies no macros allowed, since we can't store more
2638 than one insn in an insn structure. */
2641 assemble_tokens_to_insn (opname
, tok
, ntok
, insn
)
2643 const expressionS
*tok
;
2645 struct alpha_insn
*insn
;
2647 const struct alpha_opcode
*opcode
;
2649 /* search opcodes */
2650 opcode
= (const struct alpha_opcode
*) hash_find (alpha_opcode_hash
, opname
);
2654 opcode
= find_opcode_match (opcode
, tok
, &ntok
, &cpumatch
);
2657 assemble_insn (opcode
, tok
, ntok
, insn
);
2661 as_bad (_("inappropriate arguments for opcode `%s'"), opname
);
2663 as_bad (_("opcode `%s' not supported for target %s"), opname
,
2667 as_bad (_("unknown opcode `%s'"), opname
);
2670 /* Given an opcode name and a pre-tokenized set of arguments, take the
2671 opcode all the way through emission. */
2674 assemble_tokens (opname
, tok
, ntok
, local_macros_on
)
2676 const expressionS
*tok
;
2678 int local_macros_on
;
2680 int found_something
= 0;
2681 const struct alpha_opcode
*opcode
;
2682 const struct alpha_macro
*macro
;
2686 if (local_macros_on
)
2688 macro
= ((const struct alpha_macro
*)
2689 hash_find (alpha_macro_hash
, opname
));
2692 found_something
= 1;
2693 macro
= find_macro_match (macro
, tok
, &ntok
);
2696 (*macro
->emit
) (tok
, ntok
, macro
->arg
);
2703 if (ntok
&& USER_RELOC_P (tok
[ntok
-1].X_op
))
2705 const expressionS
*reloc_exp
= &tok
[ntok
-1];
2706 const struct alpha_reloc_op_tag
*r
= ALPHA_RELOC_TABLE (reloc_exp
->X_op
);
2707 as_bad (_("Cannot use !%s!%d with %s"), r
->name
,
2708 (int) reloc_exp
->X_add_number
, opname
);
2713 /* search opcodes */
2714 opcode
= (const struct alpha_opcode
*) hash_find (alpha_opcode_hash
, opname
);
2717 found_something
= 1;
2718 opcode
= find_opcode_match (opcode
, tok
, &ntok
, &cpumatch
);
2721 struct alpha_insn insn
;
2722 assemble_insn (opcode
, tok
, ntok
, &insn
);
2728 if (found_something
)
2730 as_bad (_("inappropriate arguments for opcode `%s'"), opname
);
2732 as_bad (_("opcode `%s' not supported for target %s"), opname
,
2735 as_bad (_("unknown opcode `%s'"), opname
);
2739 /* Some instruction sets indexed by lg(size) */
2740 static const char * const sextX_op
[] = { "sextb", "sextw", "sextl", NULL
};
2741 static const char * const insXl_op
[] = { "insbl", "inswl", "insll", "insql" };
2742 static const char * const insXh_op
[] = { NULL
, "inswh", "inslh", "insqh" };
2743 static const char * const extXl_op
[] = { "extbl", "extwl", "extll", "extql" };
2744 static const char * const extXh_op
[] = { NULL
, "extwh", "extlh", "extqh" };
2745 static const char * const mskXl_op
[] = { "mskbl", "mskwl", "mskll", "mskql" };
2746 static const char * const mskXh_op
[] = { NULL
, "mskwh", "msklh", "mskqh" };
2747 static const char * const stX_op
[] = { "stb", "stw", "stl", "stq" };
2748 static const char * const ldX_op
[] = { "ldb", "ldw", "ldll", "ldq" };
2749 static const char * const ldXu_op
[] = { "ldbu", "ldwu", NULL
, NULL
};
2751 /* Implement the ldgp macro. */
2754 emit_ldgp (tok
, ntok
, unused
)
2755 const expressionS
*tok
;
2756 int ntok ATTRIBUTE_UNUSED
;
2757 const PTR unused ATTRIBUTE_UNUSED
;
2762 #if defined(OBJ_ECOFF) || defined(OBJ_ELF)
2763 /* from "ldgp r1,n(r2)", generate "ldah r1,X(R2); lda r1,Y(r1)"
2764 with appropriate constants and relocations. */
2765 struct alpha_insn insn
;
2766 expressionS newtok
[3];
2770 if (ntok
&& USER_RELOC_P (tok
[ntok
-1].X_op
))
2772 const expressionS
*reloc_exp
= &tok
[ntok
-1];
2773 const struct alpha_reloc_op_tag
*r
= ALPHA_RELOC_TABLE (reloc_exp
->X_op
);
2774 as_bad (_("Cannot use !%s!%d with %s"), r
->name
,
2775 (int) reloc_exp
->X_add_number
, "ldgp");
2781 if (regno (tok
[2].X_add_number
) == AXP_REG_PV
)
2782 ecoff_set_gp_prolog_size (0);
2786 set_tok_const (newtok
[1], 0);
2789 assemble_tokens_to_insn ("ldah", newtok
, 3, &insn
);
2794 if (addend
.X_op
!= O_constant
)
2795 as_bad (_("can not resolve expression"));
2796 addend
.X_op
= O_symbol
;
2797 addend
.X_add_symbol
= alpha_gp_symbol
;
2801 insn
.fixups
[0].exp
= addend
;
2802 insn
.fixups
[0].reloc
= BFD_RELOC_ALPHA_GPDISP_HI16
;
2806 set_tok_preg (newtok
[2], tok
[0].X_add_number
);
2808 assemble_tokens_to_insn ("lda", newtok
, 3, &insn
);
2811 addend
.X_add_number
+= 4;
2815 insn
.fixups
[0].exp
= addend
;
2816 insn
.fixups
[0].reloc
= BFD_RELOC_ALPHA_GPDISP_LO16
;
2819 #endif /* OBJ_ECOFF || OBJ_ELF */
2824 /* Add symbol+addend to link pool.
2825 Return offset from basesym to entry in link pool.
2827 Add new fixup only if offset isn't 16bit. */
2830 add_to_link_pool (basesym
, sym
, addend
)
2835 segT current_section
= now_seg
;
2836 int current_subsec
= now_subseg
;
2838 bfd_reloc_code_real_type reloc_type
;
2840 segment_info_type
*seginfo
= seg_info (alpha_link_section
);
2843 offset
= - *symbol_get_obj (basesym
);
2845 /* @@ This assumes all entries in a given section will be of the same
2846 size... Probably correct, but unwise to rely on. */
2847 /* This must always be called with the same subsegment. */
2849 if (seginfo
->frchainP
)
2850 for (fixp
= seginfo
->frchainP
->fix_root
;
2851 fixp
!= (fixS
*) NULL
;
2852 fixp
= fixp
->fx_next
, offset
+= 8)
2854 if (fixp
->fx_addsy
== sym
&& fixp
->fx_offset
== addend
)
2856 if (range_signed_16 (offset
))
2863 /* Not found in 16bit signed range. */
2865 subseg_set (alpha_link_section
, 0);
2869 fix_new (frag_now
, p
- frag_now
->fr_literal
, 8, sym
, addend
, 0,
2872 subseg_set (current_section
, current_subsec
);
2873 seginfo
->literal_pool_size
+= 8;
2877 #endif /* OBJ_EVAX */
2879 /* Load a (partial) expression into a target register.
2881 If poffset is not null, after the call it will either contain
2882 O_constant 0, or a 16-bit offset appropriate for any MEM format
2883 instruction. In addition, pbasereg will be modified to point to
2884 the base register to use in that MEM format instruction.
2886 In any case, *pbasereg should contain a base register to add to the
2887 expression. This will normally be either AXP_REG_ZERO or
2888 alpha_gp_register. Symbol addresses will always be loaded via $gp,
2889 so "foo($0)" is interpreted as adding the address of foo to $0;
2890 i.e. "ldq $targ, LIT($gp); addq $targ, $0, $targ". Odd, perhaps,
2891 but this is what OSF/1 does.
2893 If explicit relocations of the form !literal!<number> are allowed,
2894 and used, then explict_reloc with be an expression pointer.
2896 Finally, the return value is true if the calling macro may emit a
2897 LITUSE reloc if otherwise appropriate. */
2900 load_expression (targreg
, exp
, pbasereg
, poffset
, explicit_reloc
)
2902 const expressionS
*exp
;
2904 expressionS
*poffset
;
2905 const expressionS
*explicit_reloc
;
2907 int emit_lituse
= 0;
2908 offsetT addend
= exp
->X_add_number
;
2909 int basereg
= *pbasereg
;
2910 struct alpha_insn insn
;
2911 expressionS newtok
[3];
2920 /* attempt to reduce .lit load by splitting the offset from
2921 its symbol when possible, but don't create a situation in
2923 if (!range_signed_32 (addend
) &&
2924 (alpha_noat_on
|| targreg
== AXP_REG_AT
))
2926 lit
= add_to_literal_pool (exp
->X_add_symbol
, addend
,
2927 alpha_lita_section
, 8);
2932 lit
= add_to_literal_pool (exp
->X_add_symbol
, 0,
2933 alpha_lita_section
, 8);
2937 as_fatal (_("overflow in literal (.lita) table"));
2939 /* emit "ldq r, lit(gp)" */
2941 if (basereg
!= alpha_gp_register
&& targreg
== basereg
)
2944 as_bad (_("macro requires $at register while noat in effect"));
2945 if (targreg
== AXP_REG_AT
)
2946 as_bad (_("macro requires $at while $at in use"));
2948 set_tok_reg (newtok
[0], AXP_REG_AT
);
2951 set_tok_reg (newtok
[0], targreg
);
2952 set_tok_sym (newtok
[1], alpha_lita_symbol
, lit
);
2953 set_tok_preg (newtok
[2], alpha_gp_register
);
2955 assemble_tokens_to_insn ("ldq", newtok
, 3, &insn
);
2957 assert (explicit_reloc
== (const expressionS
*) 0);
2958 assert (insn
.nfixups
== 1);
2959 insn
.fixups
[0].reloc
= BFD_RELOC_ALPHA_LITERAL
;
2960 #endif /* OBJ_ECOFF */
2962 /* emit "ldq r, gotoff(gp)" */
2964 if (basereg
!= alpha_gp_register
&& targreg
== basereg
)
2967 as_bad (_("macro requires $at register while noat in effect"));
2968 if (targreg
== AXP_REG_AT
)
2969 as_bad (_("macro requires $at while $at in use"));
2971 set_tok_reg (newtok
[0], AXP_REG_AT
);
2974 set_tok_reg (newtok
[0], targreg
);
2976 /* XXX: Disable this .got minimizing optimization so that we can get
2977 better instruction offset knowledge in the compiler. This happens
2978 very infrequently anyway. */
2979 if (1 || (!range_signed_32 (addend
)
2980 && (alpha_noat_on
|| targreg
== AXP_REG_AT
)))
2987 set_tok_sym (newtok
[1], exp
->X_add_symbol
, 0);
2990 set_tok_preg (newtok
[2], alpha_gp_register
);
2992 assemble_tokens_to_insn ("ldq", newtok
, 3, &insn
);
2994 assert (insn
.nfixups
== 1);
2995 if (!explicit_reloc
)
2996 insn
.fixups
[0].reloc
= BFD_RELOC_ALPHA_ELF_LITERAL
;
3000 insn
.fixups
[0].reloc
3001 = (ALPHA_RELOC_TABLE (explicit_reloc
->X_op
))->reloc
;
3002 insn
.sequence
[0] = explicit_reloc
->X_add_number
;
3007 #endif /* OBJ_ELF */
3011 /* Find symbol or symbol pointer in link section. */
3013 assert (explicit_reloc
== (const expressionS
*) 0);
3014 if (exp
->X_add_symbol
== alpha_evax_proc
.symbol
)
3016 if (range_signed_16 (addend
))
3018 set_tok_reg (newtok
[0], targreg
);
3019 set_tok_const (newtok
[1], addend
);
3020 set_tok_preg (newtok
[2], basereg
);
3021 assemble_tokens_to_insn ("lda", newtok
, 3, &insn
);
3026 set_tok_reg (newtok
[0], targreg
);
3027 set_tok_const (newtok
[1], 0);
3028 set_tok_preg (newtok
[2], basereg
);
3029 assemble_tokens_to_insn ("lda", newtok
, 3, &insn
);
3034 if (!range_signed_32 (addend
))
3036 link
= add_to_link_pool (alpha_evax_proc
.symbol
,
3037 exp
->X_add_symbol
, addend
);
3042 link
= add_to_link_pool (alpha_evax_proc
.symbol
,
3043 exp
->X_add_symbol
, 0);
3045 set_tok_reg (newtok
[0], targreg
);
3046 set_tok_const (newtok
[1], link
);
3047 set_tok_preg (newtok
[2], basereg
);
3048 assemble_tokens_to_insn ("ldq", newtok
, 3, &insn
);
3050 #endif /* OBJ_EVAX */
3057 if (basereg
!= alpha_gp_register
&& basereg
!= AXP_REG_ZERO
)
3059 /* emit "addq r, base, r" */
3061 set_tok_reg (newtok
[1], basereg
);
3062 set_tok_reg (newtok
[2], targreg
);
3063 assemble_tokens ("addq", newtok
, 3, 0);
3072 assert (explicit_reloc
== (const expressionS
*) 0);
3076 /* Assume that this difference expression will be resolved to an
3077 absolute value and that that value will fit in 16 bits. */
3079 assert (explicit_reloc
== (const expressionS
*) 0);
3080 set_tok_reg (newtok
[0], targreg
);
3082 set_tok_preg (newtok
[2], basereg
);
3083 assemble_tokens ("lda", newtok
, 3, 0);
3086 set_tok_const (*poffset
, 0);
3090 if (exp
->X_add_number
> 0)
3091 as_bad (_("bignum invalid; zero assumed"));
3093 as_bad (_("floating point number invalid; zero assumed"));
3098 as_bad (_("can't handle expression"));
3103 if (!range_signed_32 (addend
))
3107 /* for 64-bit addends, just put it in the literal pool */
3110 /* emit "ldq targreg, lit(basereg)" */
3111 lit
= add_to_link_pool (alpha_evax_proc
.symbol
,
3112 section_symbol (absolute_section
), addend
);
3113 set_tok_reg (newtok
[0], targreg
);
3114 set_tok_const (newtok
[1], lit
);
3115 set_tok_preg (newtok
[2], alpha_gp_register
);
3116 assemble_tokens ("ldq", newtok
, 3, 0);
3119 if (alpha_lit8_section
== NULL
)
3121 create_literal_section (".lit8",
3122 &alpha_lit8_section
,
3123 &alpha_lit8_symbol
);
3126 alpha_lit8_literal
= add_to_literal_pool (alpha_lit8_symbol
, 0x8000,
3127 alpha_lita_section
, 8);
3128 if (alpha_lit8_literal
>= 0x8000)
3129 as_fatal (_("overflow in literal (.lita) table"));
3133 lit
= add_to_literal_pool (NULL
, addend
, alpha_lit8_section
, 8) - 0x8000;
3135 as_fatal (_("overflow in literal (.lit8) table"));
3137 /* emit "lda litreg, .lit8+0x8000" */
3139 if (targreg
== basereg
)
3142 as_bad (_("macro requires $at register while noat in effect"));
3143 if (targreg
== AXP_REG_AT
)
3144 as_bad (_("macro requires $at while $at in use"));
3146 set_tok_reg (newtok
[0], AXP_REG_AT
);
3149 set_tok_reg (newtok
[0], targreg
);
3151 set_tok_sym (newtok
[1], alpha_lita_symbol
, alpha_lit8_literal
);
3154 set_tok_sym (newtok
[1], alpha_lit8_symbol
, 0x8000);
3156 set_tok_preg (newtok
[2], alpha_gp_register
);
3158 assemble_tokens_to_insn ("ldq", newtok
, 3, &insn
);
3160 assert (insn
.nfixups
== 1);
3162 insn
.fixups
[0].reloc
= BFD_RELOC_ALPHA_LITERAL
;
3165 insn
.fixups
[0].reloc
= BFD_RELOC_ALPHA_ELF_LITERAL
;
3170 /* emit "ldq litreg, lit(litreg)" */
3172 set_tok_const (newtok
[1], lit
);
3173 set_tok_preg (newtok
[2], newtok
[0].X_add_number
);
3175 assemble_tokens_to_insn ("ldq", newtok
, 3, &insn
);
3177 assert (insn
.nfixups
< MAX_INSN_FIXUPS
);
3178 if (insn
.nfixups
> 0)
3180 memmove (&insn
.fixups
[1], &insn
.fixups
[0],
3181 sizeof (struct alpha_fixup
) * insn
.nfixups
);
3184 insn
.fixups
[0].reloc
= BFD_RELOC_ALPHA_LITUSE
;
3185 insn
.fixups
[0].exp
.X_op
= O_symbol
;
3186 insn
.fixups
[0].exp
.X_add_symbol
= section_symbol (now_seg
);
3187 insn
.fixups
[0].exp
.X_add_number
= LITUSE_BASE
;
3192 /* emit "addq litreg, base, target" */
3194 if (basereg
!= AXP_REG_ZERO
)
3196 set_tok_reg (newtok
[1], basereg
);
3197 set_tok_reg (newtok
[2], targreg
);
3198 assemble_tokens ("addq", newtok
, 3, 0);
3200 #endif /* !OBJ_EVAX */
3203 set_tok_const (*poffset
, 0);
3204 *pbasereg
= targreg
;
3208 offsetT low
, high
, extra
, tmp
;
3210 /* for 32-bit operands, break up the addend */
3212 low
= sign_extend_16 (addend
);
3214 high
= sign_extend_16 (tmp
>> 16);
3216 if (tmp
- (high
<< 16))
3220 high
= sign_extend_16 (tmp
>> 16);
3225 set_tok_reg (newtok
[0], targreg
);
3226 set_tok_preg (newtok
[2], basereg
);
3230 /* emit "ldah r, extra(r) */
3231 set_tok_const (newtok
[1], extra
);
3232 assemble_tokens ("ldah", newtok
, 3, 0);
3233 set_tok_preg (newtok
[2], basereg
= targreg
);
3238 /* emit "ldah r, high(r) */
3239 set_tok_const (newtok
[1], high
);
3240 assemble_tokens ("ldah", newtok
, 3, 0);
3242 set_tok_preg (newtok
[2], basereg
);
3245 if ((low
&& !poffset
) || (!poffset
&& basereg
!= targreg
))
3247 /* emit "lda r, low(base)" */
3248 set_tok_const (newtok
[1], low
);
3249 assemble_tokens ("lda", newtok
, 3, 0);
3255 set_tok_const (*poffset
, low
);
3256 *pbasereg
= basereg
;
3262 /* The lda macro differs from the lda instruction in that it handles
3263 most simple expressions, particualrly symbol address loads and
3267 emit_lda (tok
, ntok
, opname
)
3268 const expressionS
*tok
;
3273 const expressionS
*reloc
= (const expressionS
*) 0;
3276 if (ntok
&& USER_RELOC_P (tok
[ntok
-1].X_op
))
3278 const struct alpha_reloc_op_tag
*r
;
3280 reloc
= &tok
[ntok
-1];
3281 r
= ALPHA_RELOC_TABLE (reloc
->X_op
);
3282 switch (reloc
->X_op
)
3285 as_bad (_("Cannot use !%s!%d with %s"), r
->name
,
3286 (int) reloc
->X_add_number
, (const char *) opname
);
3288 reloc
= (const expressionS
*) 0;
3296 /* For lda $x,0($x)!lituse_base!y, don't use load_expression, since
3297 it is really too general for our needs. Instead just generate the
3301 || tok
[0].X_op
!= O_register
3302 || !is_ir_num (tok
[0].X_add_number
)
3303 || tok
[1].X_op
!= O_constant
3304 || tok
[2].X_op
!= O_pregister
3305 || !is_ir_num (tok
[2].X_add_number
))
3307 as_bad (_("bad instruction format for lda !%s!%ld"), r
->name
,
3308 (long) reloc
->X_add_number
);
3310 reloc
= (const expressionS
*) 0;
3315 emit_loadstore (tok
, ntok
, "lda");
3322 basereg
= (tok
[1].X_op
== O_constant
? AXP_REG_ZERO
: alpha_gp_register
);
3324 basereg
= tok
[2].X_add_number
;
3326 (void) load_expression (tok
[0].X_add_number
, &tok
[1], &basereg
, NULL
, reloc
);
3329 /* The ldah macro differs from the ldah instruction in that it has $31
3330 as an implied base register. */
3333 emit_ldah (tok
, ntok
, unused
)
3334 const expressionS
*tok
;
3335 int ntok ATTRIBUTE_UNUSED
;
3336 const PTR unused ATTRIBUTE_UNUSED
;
3338 expressionS newtok
[3];
3341 if (ntok
&& USER_RELOC_P (tok
[ntok
-1].X_op
))
3343 const expressionS
*reloc_exp
= &tok
[ntok
-1];
3344 const struct alpha_reloc_op_tag
*r
= ALPHA_RELOC_TABLE (reloc_exp
->X_op
);
3345 as_bad (_("Cannot use !%s!%d with %s"), r
->name
,
3346 (int) reloc_exp
->X_add_number
, "ldah");
3353 set_tok_preg (newtok
[2], AXP_REG_ZERO
);
3355 assemble_tokens ("ldah", newtok
, 3, 0);
3358 /* Handle all "simple" integer register loads -- ldq, ldq_l, ldq_u,
3359 etc. They differ from the real instructions in that they do simple
3360 expressions like the lda macro. */
3363 emit_ir_load (tok
, ntok
, opname
)
3364 const expressionS
*tok
;
3368 int basereg
, lituse
;
3369 expressionS newtok
[3];
3370 struct alpha_insn insn
;
3373 const expressionS
*reloc
= (const expressionS
*) 0;
3375 if (ntok
&& USER_RELOC_P (tok
[ntok
-1].X_op
))
3377 const struct alpha_reloc_op_tag
*r
;
3379 reloc
= &tok
[ntok
-1];
3380 switch (reloc
->X_op
)
3387 if (strcmp ((const char *) opname
, "ldq") == 0)
3389 emit_lda (tok
, ntok
, opname
);
3396 r
= ALPHA_RELOC_TABLE (reloc
->X_op
);
3397 as_bad (_("Cannot use !%s!%d with %s"), r
->name
,
3398 (int) reloc
->X_add_number
, (const char *) opname
);
3404 basereg
= (tok
[1].X_op
== O_constant
? AXP_REG_ZERO
: alpha_gp_register
);
3406 basereg
= tok
[2].X_add_number
;
3408 lituse
= load_expression (tok
[0].X_add_number
, &tok
[1], &basereg
,
3409 &newtok
[1], (const expressionS
*) 0);
3412 set_tok_preg (newtok
[2], basereg
);
3414 assemble_tokens_to_insn ((const char *) opname
, newtok
, 3, &insn
);
3419 int nfixups
= insn
.nfixups
;
3420 const struct alpha_reloc_op_tag
*r
= ALPHA_RELOC_TABLE (reloc
->X_op
);
3422 assert (nfixups
< MAX_INSN_FIXUPS
);
3423 insn
.fixups
[nfixups
].reloc
= r
->reloc
;
3424 insn
.fixups
[nfixups
].exp
.X_op
= O_symbol
;
3425 insn
.fixups
[nfixups
].exp
.X_add_symbol
= section_symbol (now_seg
);
3426 insn
.fixups
[nfixups
].exp
.X_add_number
= r
->lituse
;
3427 insn
.sequence
[nfixups
] = reloc
->X_add_number
;
3434 assert (insn
.nfixups
< MAX_INSN_FIXUPS
);
3435 if (insn
.nfixups
> 0)
3437 memmove (&insn
.fixups
[1], &insn
.fixups
[0],
3438 sizeof (struct alpha_fixup
) * insn
.nfixups
);
3441 insn
.fixups
[0].reloc
= BFD_RELOC_ALPHA_LITUSE
;
3442 insn
.fixups
[0].exp
.X_op
= O_symbol
;
3443 insn
.fixups
[0].exp
.X_add_symbol
= section_symbol (now_seg
);
3444 insn
.fixups
[0].exp
.X_add_number
= LITUSE_BASE
;
3450 /* Handle fp register loads, and both integer and fp register stores.
3451 Again, we handle simple expressions. */
3454 emit_loadstore (tok
, ntok
, opname
)
3455 const expressionS
*tok
;
3459 int basereg
, lituse
;
3460 expressionS newtok
[3];
3461 struct alpha_insn insn
;
3464 const expressionS
*reloc
= (const expressionS
*) 0;
3466 if (ntok
&& USER_RELOC_P (tok
[ntok
-1].X_op
))
3468 reloc
= &tok
[--ntok
];
3469 if (reloc
->X_op
!= O_lituse_base
)
3471 const struct alpha_reloc_op_tag
*r
= &alpha_reloc_op
[ reloc
->X_md
];
3472 as_bad (_("Cannot use !%s!%d with %s"), r
->name
,
3473 (int) reloc
->X_add_number
, (const char *) opname
);
3479 basereg
= (tok
[1].X_op
== O_constant
? AXP_REG_ZERO
: alpha_gp_register
);
3481 basereg
= tok
[2].X_add_number
;
3483 if (tok
[1].X_op
!= O_constant
|| !range_signed_16 (tok
[1].X_add_number
))
3486 as_bad (_("macro requires $at register while noat in effect"));
3488 lituse
= load_expression (AXP_REG_AT
, &tok
[1], &basereg
, &newtok
[1],
3489 (const expressionS
*) 0);
3498 set_tok_preg (newtok
[2], basereg
);
3500 assemble_tokens_to_insn ((const char *) opname
, newtok
, 3, &insn
);
3505 int nfixups
= insn
.nfixups
;
3506 const struct alpha_reloc_op_tag
*r
= ALPHA_RELOC_TABLE (reloc
->X_op
);
3508 assert (nfixups
< MAX_INSN_FIXUPS
);
3509 insn
.fixups
[nfixups
].reloc
= r
->reloc
;
3510 insn
.fixups
[nfixups
].exp
.X_op
= O_symbol
;
3511 insn
.fixups
[nfixups
].exp
.X_add_symbol
= section_symbol (now_seg
);
3512 insn
.fixups
[nfixups
].exp
.X_add_number
= r
->lituse
;
3513 insn
.sequence
[nfixups
] = reloc
->X_add_number
;
3520 assert (insn
.nfixups
< MAX_INSN_FIXUPS
);
3521 if (insn
.nfixups
> 0)
3523 memmove (&insn
.fixups
[1], &insn
.fixups
[0],
3524 sizeof (struct alpha_fixup
) * insn
.nfixups
);
3527 insn
.fixups
[0].reloc
= BFD_RELOC_ALPHA_LITUSE
;
3528 insn
.fixups
[0].exp
.X_op
= O_symbol
;
3529 insn
.fixups
[0].exp
.X_add_symbol
= section_symbol (now_seg
);
3530 insn
.fixups
[0].exp
.X_add_number
= LITUSE_BASE
;
3536 /* Load a half-word or byte as an unsigned value. */
3539 emit_ldXu (tok
, ntok
, vlgsize
)
3540 const expressionS
*tok
;
3544 if (alpha_target
& AXP_OPCODE_BWX
)
3545 emit_ir_load (tok
, ntok
, ldXu_op
[(long) vlgsize
]);
3548 expressionS newtok
[3];
3551 if (ntok
&& USER_RELOC_P (tok
[ntok
-1].X_op
))
3553 const expressionS
*reloc_exp
= &tok
[ntok
-1];
3554 const struct alpha_reloc_op_tag
*r
3555 = ALPHA_RELOC_TABLE (reloc_exp
->X_op
);
3557 as_bad (_("Cannot use !%s!%d with %s"), r
->name
,
3558 (int) reloc_exp
->X_add_number
, "ldbu/ldwu");
3564 as_bad (_("macro requires $at register while noat in effect"));
3566 /* emit "lda $at, exp" */
3568 memcpy (newtok
, tok
, sizeof (expressionS
) * ntok
);
3569 newtok
[0].X_add_number
= AXP_REG_AT
;
3570 assemble_tokens ("lda", newtok
, ntok
, 1);
3572 /* emit "ldq_u targ, 0($at)" */
3575 set_tok_const (newtok
[1], 0);
3576 set_tok_preg (newtok
[2], AXP_REG_AT
);
3577 assemble_tokens ("ldq_u", newtok
, 3, 1);
3579 /* emit "extXl targ, $at, targ" */
3581 set_tok_reg (newtok
[1], AXP_REG_AT
);
3582 newtok
[2] = newtok
[0];
3583 assemble_tokens (extXl_op
[(long) vlgsize
], newtok
, 3, 1);
3587 /* Load a half-word or byte as a signed value. */
3590 emit_ldX (tok
, ntok
, vlgsize
)
3591 const expressionS
*tok
;
3595 emit_ldXu (tok
, ntok
, vlgsize
);
3596 assemble_tokens (sextX_op
[(long) vlgsize
], tok
, 1, 1);
3599 /* Load an integral value from an unaligned address as an unsigned
3603 emit_uldXu (tok
, ntok
, vlgsize
)
3604 const expressionS
*tok
;
3608 long lgsize
= (long) vlgsize
;
3609 expressionS newtok
[3];
3612 as_bad (_("macro requires $at register while noat in effect"));
3614 /* emit "lda $at, exp" */
3616 memcpy (newtok
, tok
, sizeof (expressionS
) * ntok
);
3617 newtok
[0].X_add_number
= AXP_REG_AT
;
3618 assemble_tokens ("lda", newtok
, ntok
, 1);
3620 /* emit "ldq_u $t9, 0($at)" */
3622 set_tok_reg (newtok
[0], AXP_REG_T9
);
3623 set_tok_const (newtok
[1], 0);
3624 set_tok_preg (newtok
[2], AXP_REG_AT
);
3625 assemble_tokens ("ldq_u", newtok
, 3, 1);
3627 /* emit "ldq_u $t10, size-1($at)" */
3629 set_tok_reg (newtok
[0], AXP_REG_T10
);
3630 set_tok_const (newtok
[1], (1<<lgsize
)-1);
3631 assemble_tokens ("ldq_u", newtok
, 3, 1);
3633 /* emit "extXl $t9, $at, $t9" */
3635 set_tok_reg (newtok
[0], AXP_REG_T9
);
3636 set_tok_reg (newtok
[1], AXP_REG_AT
);
3637 set_tok_reg (newtok
[2], AXP_REG_T9
);
3638 assemble_tokens (extXl_op
[lgsize
], newtok
, 3, 1);
3640 /* emit "extXh $t10, $at, $t10" */
3642 set_tok_reg (newtok
[0], AXP_REG_T10
);
3643 set_tok_reg (newtok
[2], AXP_REG_T10
);
3644 assemble_tokens (extXh_op
[lgsize
], newtok
, 3, 1);
3646 /* emit "or $t9, $t10, targ" */
3648 set_tok_reg (newtok
[0], AXP_REG_T9
);
3649 set_tok_reg (newtok
[1], AXP_REG_T10
);
3651 assemble_tokens ("or", newtok
, 3, 1);
3654 /* Load an integral value from an unaligned address as a signed value.
3655 Note that quads should get funneled to the unsigned load since we
3656 don't have to do the sign extension. */
3659 emit_uldX (tok
, ntok
, vlgsize
)
3660 const expressionS
*tok
;
3664 emit_uldXu (tok
, ntok
, vlgsize
);
3665 assemble_tokens (sextX_op
[(long) vlgsize
], tok
, 1, 1);
3668 /* Implement the ldil macro. */
3671 emit_ldil (tok
, ntok
, unused
)
3672 const expressionS
*tok
;
3674 const PTR unused ATTRIBUTE_UNUSED
;
3676 expressionS newtok
[2];
3679 if (ntok
&& USER_RELOC_P (tok
[ntok
-1].X_op
))
3681 const expressionS
*reloc_exp
= &tok
[ntok
-1];
3682 const struct alpha_reloc_op_tag
*r
= ALPHA_RELOC_TABLE (reloc_exp
->X_op
);
3683 as_bad (_("Cannot use !%s!%d with %s"), r
->name
,
3684 (int) reloc_exp
->X_add_number
, "ldil");
3689 memcpy (newtok
, tok
, sizeof (newtok
));
3690 newtok
[1].X_add_number
= sign_extend_32 (tok
[1].X_add_number
);
3692 assemble_tokens ("lda", newtok
, ntok
, 1);
3695 /* Store a half-word or byte. */
3698 emit_stX (tok
, ntok
, vlgsize
)
3699 const expressionS
*tok
;
3703 int lgsize
= (int) (long) vlgsize
;
3705 if (alpha_target
& AXP_OPCODE_BWX
)
3706 emit_loadstore (tok
, ntok
, stX_op
[lgsize
]);
3709 expressionS newtok
[3];
3712 as_bad (_("macro requires $at register while noat in effect"));
3714 /* emit "lda $at, exp" */
3716 memcpy (newtok
, tok
, sizeof (expressionS
) * ntok
);
3717 newtok
[0].X_add_number
= AXP_REG_AT
;
3718 assemble_tokens ("lda", newtok
, ntok
, 1);
3720 /* emit "ldq_u $t9, 0($at)" */
3722 set_tok_reg (newtok
[0], AXP_REG_T9
);
3723 set_tok_const (newtok
[1], 0);
3724 set_tok_preg (newtok
[2], AXP_REG_AT
);
3725 assemble_tokens ("ldq_u", newtok
, 3, 1);
3727 /* emit "insXl src, $at, $t10" */
3730 set_tok_reg (newtok
[1], AXP_REG_AT
);
3731 set_tok_reg (newtok
[2], AXP_REG_T10
);
3732 assemble_tokens (insXl_op
[lgsize
], newtok
, 3, 1);
3734 /* emit "mskXl $t9, $at, $t9" */
3736 set_tok_reg (newtok
[0], AXP_REG_T9
);
3737 newtok
[2] = newtok
[0];
3738 assemble_tokens (mskXl_op
[lgsize
], newtok
, 3, 1);
3740 /* emit "or $t9, $t10, $t9" */
3742 set_tok_reg (newtok
[1], AXP_REG_T10
);
3743 assemble_tokens ("or", newtok
, 3, 1);
3745 /* emit "stq_u $t9, 0($at) */
3747 set_tok_const (newtok
[1], 0);
3748 set_tok_preg (newtok
[2], AXP_REG_AT
);
3749 assemble_tokens ("stq_u", newtok
, 3, 1);
3753 /* Store an integer to an unaligned address. */
3756 emit_ustX (tok
, ntok
, vlgsize
)
3757 const expressionS
*tok
;
3761 int lgsize
= (int) (long) vlgsize
;
3762 expressionS newtok
[3];
3764 /* emit "lda $at, exp" */
3766 memcpy (newtok
, tok
, sizeof (expressionS
) * ntok
);
3767 newtok
[0].X_add_number
= AXP_REG_AT
;
3768 assemble_tokens ("lda", newtok
, ntok
, 1);
3770 /* emit "ldq_u $9, 0($at)" */
3772 set_tok_reg (newtok
[0], AXP_REG_T9
);
3773 set_tok_const (newtok
[1], 0);
3774 set_tok_preg (newtok
[2], AXP_REG_AT
);
3775 assemble_tokens ("ldq_u", newtok
, 3, 1);
3777 /* emit "ldq_u $10, size-1($at)" */
3779 set_tok_reg (newtok
[0], AXP_REG_T10
);
3780 set_tok_const (newtok
[1], (1 << lgsize
)-1);
3781 assemble_tokens ("ldq_u", newtok
, 3, 1);
3783 /* emit "insXl src, $at, $t11" */
3786 set_tok_reg (newtok
[1], AXP_REG_AT
);
3787 set_tok_reg (newtok
[2], AXP_REG_T11
);
3788 assemble_tokens (insXl_op
[lgsize
], newtok
, 3, 1);
3790 /* emit "insXh src, $at, $t12" */
3792 set_tok_reg (newtok
[2], AXP_REG_T12
);
3793 assemble_tokens (insXh_op
[lgsize
], newtok
, 3, 1);
3795 /* emit "mskXl $t9, $at, $t9" */
3797 set_tok_reg (newtok
[0], AXP_REG_T9
);
3798 newtok
[2] = newtok
[0];
3799 assemble_tokens (mskXl_op
[lgsize
], newtok
, 3, 1);
3801 /* emit "mskXh $t10, $at, $t10" */
3803 set_tok_reg (newtok
[0], AXP_REG_T10
);
3804 newtok
[2] = newtok
[0];
3805 assemble_tokens (mskXh_op
[lgsize
], newtok
, 3, 1);
3807 /* emit "or $t9, $t11, $t9" */
3809 set_tok_reg (newtok
[0], AXP_REG_T9
);
3810 set_tok_reg (newtok
[1], AXP_REG_T11
);
3811 newtok
[2] = newtok
[0];
3812 assemble_tokens ("or", newtok
, 3, 1);
3814 /* emit "or $t10, $t12, $t10" */
3816 set_tok_reg (newtok
[0], AXP_REG_T10
);
3817 set_tok_reg (newtok
[1], AXP_REG_T12
);
3818 newtok
[2] = newtok
[0];
3819 assemble_tokens ("or", newtok
, 3, 1);
3821 /* emit "stq_u $t9, 0($at)" */
3823 set_tok_reg (newtok
[0], AXP_REG_T9
);
3824 set_tok_const (newtok
[1], 0);
3825 set_tok_preg (newtok
[2], AXP_REG_AT
);
3826 assemble_tokens ("stq_u", newtok
, 3, 1);
3828 /* emit "stq_u $t10, size-1($at)" */
3830 set_tok_reg (newtok
[0], AXP_REG_T10
);
3831 set_tok_const (newtok
[1], (1 << lgsize
)-1);
3832 assemble_tokens ("stq_u", newtok
, 3, 1);
3835 /* Sign extend a half-word or byte. The 32-bit sign extend is
3836 implemented as "addl $31, $r, $t" in the opcode table. */
3839 emit_sextX (tok
, ntok
, vlgsize
)
3840 const expressionS
*tok
;
3844 long lgsize
= (long) vlgsize
;
3846 if (alpha_target
& AXP_OPCODE_BWX
)
3847 assemble_tokens (sextX_op
[lgsize
], tok
, ntok
, 0);
3850 int bitshift
= 64 - 8 * (1 << lgsize
);
3851 expressionS newtok
[3];
3854 if (ntok
&& USER_RELOC_P (tok
[ntok
-1].X_op
))
3856 const expressionS
*reloc_exp
= &tok
[ntok
-1];
3857 const struct alpha_reloc_op_tag
*r
3858 = ALPHA_RELOC_TABLE (reloc_exp
->X_op
);
3860 as_bad (_("Cannot use !%s!%d with %s"), r
->name
,
3861 (int) reloc_exp
->X_add_number
, "setxt");
3866 /* emit "sll src,bits,dst" */
3869 set_tok_const (newtok
[1], bitshift
);
3870 newtok
[2] = tok
[ntok
- 1];
3871 assemble_tokens ("sll", newtok
, 3, 1);
3873 /* emit "sra dst,bits,dst" */
3875 newtok
[0] = newtok
[2];
3876 assemble_tokens ("sra", newtok
, 3, 1);
3880 /* Implement the division and modulus macros. */
3884 /* Make register usage like in normal procedure call.
3885 Don't clobber PV and RA. */
3888 emit_division (tok
, ntok
, symname
)
3889 const expressionS
*tok
;
3893 /* DIVISION and MODULUS. Yech.
3898 * mov x,R16 # if x != R16
3899 * mov y,R17 # if y != R17
3904 * with appropriate optimizations if R0,R16,R17 are the registers
3905 * specified by the compiler.
3910 expressionS newtok
[3];
3913 if (ntok
&& USER_RELOC_P (tok
[ntok
-1].X_op
))
3915 const expressionS
*reloc_exp
= &tok
[ntok
-1];
3916 const struct alpha_reloc_op_tag
*r
= ALPHA_RELOC_TABLE (reloc_exp
->X_op
);
3917 as_bad (_("Cannot use !%s!%d with %s"), r
->name
,
3918 (int) reloc_exp
->X_add_number
, (char char *) symname
);
3923 xr
= regno (tok
[0].X_add_number
);
3924 yr
= regno (tok
[1].X_add_number
);
3929 rr
= regno (tok
[2].X_add_number
);
3931 /* Move the operands into the right place */
3932 if (yr
== AXP_REG_R16
&& xr
== AXP_REG_R17
)
3934 /* They are in exactly the wrong order -- swap through AT */
3937 as_bad (_("macro requires $at register while noat in effect"));
3939 set_tok_reg (newtok
[0], AXP_REG_R16
);
3940 set_tok_reg (newtok
[1], AXP_REG_AT
);
3941 assemble_tokens ("mov", newtok
, 2, 1);
3943 set_tok_reg (newtok
[0], AXP_REG_R17
);
3944 set_tok_reg (newtok
[1], AXP_REG_R16
);
3945 assemble_tokens ("mov", newtok
, 2, 1);
3947 set_tok_reg (newtok
[0], AXP_REG_AT
);
3948 set_tok_reg (newtok
[1], AXP_REG_R17
);
3949 assemble_tokens ("mov", newtok
, 2, 1);
3953 if (yr
== AXP_REG_R16
)
3955 set_tok_reg (newtok
[0], AXP_REG_R16
);
3956 set_tok_reg (newtok
[1], AXP_REG_R17
);
3957 assemble_tokens ("mov", newtok
, 2, 1);
3960 if (xr
!= AXP_REG_R16
)
3962 set_tok_reg (newtok
[0], xr
);
3963 set_tok_reg (newtok
[1], AXP_REG_R16
);
3964 assemble_tokens ("mov", newtok
, 2, 1);
3967 if (yr
!= AXP_REG_R16
&& yr
!= AXP_REG_R17
)
3969 set_tok_reg (newtok
[0], yr
);
3970 set_tok_reg (newtok
[1], AXP_REG_R17
);
3971 assemble_tokens ("mov", newtok
, 2, 1);
3975 sym
= symbol_find_or_make ((const char *) symname
);
3977 set_tok_reg (newtok
[0], AXP_REG_AT
);
3978 set_tok_sym (newtok
[1], sym
, 0);
3979 assemble_tokens ("lda", newtok
, 2, 1);
3981 /* Call the division routine */
3982 set_tok_reg (newtok
[0], AXP_REG_AT
);
3983 set_tok_cpreg (newtok
[1], AXP_REG_AT
);
3984 set_tok_const (newtok
[2], 0);
3985 assemble_tokens ("jsr", newtok
, 3, 1);
3987 /* Move the result to the right place */
3988 if (rr
!= AXP_REG_R0
)
3990 set_tok_reg (newtok
[0], AXP_REG_R0
);
3991 set_tok_reg (newtok
[1], rr
);
3992 assemble_tokens ("mov", newtok
, 2, 1);
3996 #else /* !OBJ_EVAX */
3999 emit_division (tok
, ntok
, symname
)
4000 const expressionS
*tok
;
4004 /* DIVISION and MODULUS. Yech.
4014 * with appropriate optimizations if t10,t11,t12 are the registers
4015 * specified by the compiler.
4020 expressionS newtok
[3];
4023 if (ntok
&& USER_RELOC_P (tok
[ntok
-1].X_op
))
4025 const expressionS
*reloc_exp
= &tok
[ntok
-1];
4026 const struct alpha_reloc_op_tag
*r
= ALPHA_RELOC_TABLE (reloc_exp
->X_op
);
4027 as_bad (_("Cannot use !%s!%d with %s"), r
->name
,
4028 (int) reloc_exp
->X_add_number
, (const char *) symname
);
4033 xr
= regno (tok
[0].X_add_number
);
4034 yr
= regno (tok
[1].X_add_number
);
4039 rr
= regno (tok
[2].X_add_number
);
4041 sym
= symbol_find_or_make ((const char *) symname
);
4043 /* Move the operands into the right place */
4044 if (yr
== AXP_REG_T10
&& xr
== AXP_REG_T11
)
4046 /* They are in exactly the wrong order -- swap through AT */
4049 as_bad (_("macro requires $at register while noat in effect"));
4051 set_tok_reg (newtok
[0], AXP_REG_T10
);
4052 set_tok_reg (newtok
[1], AXP_REG_AT
);
4053 assemble_tokens ("mov", newtok
, 2, 1);
4055 set_tok_reg (newtok
[0], AXP_REG_T11
);
4056 set_tok_reg (newtok
[1], AXP_REG_T10
);
4057 assemble_tokens ("mov", newtok
, 2, 1);
4059 set_tok_reg (newtok
[0], AXP_REG_AT
);
4060 set_tok_reg (newtok
[1], AXP_REG_T11
);
4061 assemble_tokens ("mov", newtok
, 2, 1);
4065 if (yr
== AXP_REG_T10
)
4067 set_tok_reg (newtok
[0], AXP_REG_T10
);
4068 set_tok_reg (newtok
[1], AXP_REG_T11
);
4069 assemble_tokens ("mov", newtok
, 2, 1);
4072 if (xr
!= AXP_REG_T10
)
4074 set_tok_reg (newtok
[0], xr
);
4075 set_tok_reg (newtok
[1], AXP_REG_T10
);
4076 assemble_tokens ("mov", newtok
, 2, 1);
4079 if (yr
!= AXP_REG_T10
&& yr
!= AXP_REG_T11
)
4081 set_tok_reg (newtok
[0], yr
);
4082 set_tok_reg (newtok
[1], AXP_REG_T11
);
4083 assemble_tokens ("mov", newtok
, 2, 1);
4087 /* Call the division routine */
4088 set_tok_reg (newtok
[0], AXP_REG_T9
);
4089 set_tok_sym (newtok
[1], sym
, 0);
4090 assemble_tokens ("jsr", newtok
, 2, 1);
4092 /* Reload the GP register */
4096 #if defined(OBJ_ECOFF) || defined(OBJ_ELF)
4097 set_tok_reg (newtok
[0], alpha_gp_register
);
4098 set_tok_const (newtok
[1], 0);
4099 set_tok_preg (newtok
[2], AXP_REG_T9
);
4100 assemble_tokens ("ldgp", newtok
, 3, 1);
4103 /* Move the result to the right place */
4104 if (rr
!= AXP_REG_T12
)
4106 set_tok_reg (newtok
[0], AXP_REG_T12
);
4107 set_tok_reg (newtok
[1], rr
);
4108 assemble_tokens ("mov", newtok
, 2, 1);
4112 #endif /* !OBJ_EVAX */
4114 /* The jsr and jmp macros differ from their instruction counterparts
4115 in that they can load the target address and default most
4119 emit_jsrjmp (tok
, ntok
, vopname
)
4120 const expressionS
*tok
;
4124 const char *opname
= (const char *) vopname
;
4125 struct alpha_insn insn
;
4126 expressionS newtok
[3];
4127 int r
, tokidx
= 0, lituse
= 0;
4130 if (ntok
&& USER_RELOC_P (tok
[ntok
-1].X_op
))
4132 const expressionS
*reloc_exp
= &tok
[ntok
-1];
4133 const struct alpha_reloc_op_tag
*r
= ALPHA_RELOC_TABLE (reloc_exp
->X_op
);
4134 as_bad (_("Cannot use !%s!%d with %s"), r
->name
,
4135 (int) reloc_exp
->X_add_number
, opname
);
4140 if (tokidx
< ntok
&& tok
[tokidx
].X_op
== O_register
)
4141 r
= regno (tok
[tokidx
++].X_add_number
);
4143 r
= strcmp (opname
, "jmp") == 0 ? AXP_REG_ZERO
: AXP_REG_RA
;
4145 set_tok_reg (newtok
[0], r
);
4147 if (tokidx
< ntok
&&
4148 (tok
[tokidx
].X_op
== O_pregister
|| tok
[tokidx
].X_op
== O_cpregister
))
4149 r
= regno (tok
[tokidx
++].X_add_number
);
4151 /* keep register if jsr $n.<sym> */
4155 int basereg
= alpha_gp_register
;
4156 lituse
= load_expression (r
= AXP_REG_PV
, &tok
[tokidx
], &basereg
, NULL
,
4157 (const expressionS
*) 0);
4161 set_tok_cpreg (newtok
[1], r
);
4164 /* FIXME: Add hint relocs to BFD for evax. */
4167 newtok
[2] = tok
[tokidx
];
4170 set_tok_const (newtok
[2], 0);
4172 assemble_tokens_to_insn (opname
, newtok
, 3, &insn
);
4174 /* add the LITUSE fixup */
4177 assert (insn
.nfixups
< MAX_INSN_FIXUPS
);
4178 if (insn
.nfixups
> 0)
4180 memmove (&insn
.fixups
[1], &insn
.fixups
[0],
4181 sizeof (struct alpha_fixup
) * insn
.nfixups
);
4184 insn
.fixups
[0].reloc
= BFD_RELOC_ALPHA_LITUSE
;
4185 insn
.fixups
[0].exp
.X_op
= O_symbol
;
4186 insn
.fixups
[0].exp
.X_add_symbol
= section_symbol (now_seg
);
4187 insn
.fixups
[0].exp
.X_add_number
= LITUSE_JSR
;
4193 /* The ret and jcr instructions differ from their instruction
4194 counterparts in that everything can be defaulted. */
4197 emit_retjcr (tok
, ntok
, vopname
)
4198 const expressionS
*tok
;
4202 const char *opname
= (const char *) vopname
;
4203 expressionS newtok
[3];
4207 if (ntok
&& USER_RELOC_P (tok
[ntok
-1].X_op
))
4209 const expressionS
*reloc_exp
= &tok
[ntok
-1];
4210 const struct alpha_reloc_op_tag
*r
= ALPHA_RELOC_TABLE (reloc_exp
->X_op
);
4211 as_bad (_("Cannot use !%s!%d with %s"), r
->name
,
4212 (int) reloc_exp
->X_add_number
, opname
);
4217 if (tokidx
< ntok
&& tok
[tokidx
].X_op
== O_register
)
4218 r
= regno (tok
[tokidx
++].X_add_number
);
4222 set_tok_reg (newtok
[0], r
);
4224 if (tokidx
< ntok
&&
4225 (tok
[tokidx
].X_op
== O_pregister
|| tok
[tokidx
].X_op
== O_cpregister
))
4226 r
= regno (tok
[tokidx
++].X_add_number
);
4230 set_tok_cpreg (newtok
[1], r
);
4233 newtok
[2] = tok
[tokidx
];
4235 set_tok_const (newtok
[2], strcmp (opname
, "ret") == 0);
4237 assemble_tokens (opname
, newtok
, 3, 0);
4240 /* Assembler directives */
4242 /* Handle the .text pseudo-op. This is like the usual one, but it
4243 clears alpha_insn_label and restores auto alignment. */
4251 alpha_insn_label
= NULL
;
4252 alpha_auto_align_on
= 1;
4253 alpha_current_align
= 0;
4256 /* Handle the .data pseudo-op. This is like the usual one, but it
4257 clears alpha_insn_label and restores auto alignment. */
4264 alpha_insn_label
= NULL
;
4265 alpha_auto_align_on
= 1;
4266 alpha_current_align
= 0;
4269 #if defined (OBJ_ECOFF) || defined (OBJ_EVAX)
4271 /* Handle the OSF/1 and openVMS .comm pseudo quirks.
4272 openVMS constructs a section for every common symbol. */
4275 s_alpha_comm (ignore
)
4278 register char *name
;
4282 register symbolS
*symbolP
;
4285 segT current_section
= now_seg
;
4286 int current_subsec
= now_subseg
;
4290 name
= input_line_pointer
;
4291 c
= get_symbol_end ();
4293 /* just after name is now '\0' */
4294 p
= input_line_pointer
;
4299 /* Alpha OSF/1 compiler doesn't provide the comma, gcc does. */
4300 if (*input_line_pointer
== ',')
4302 input_line_pointer
++;
4305 if ((temp
= get_absolute_expression ()) < 0)
4307 as_warn (_(".COMMon length (%ld.) <0! Ignored."), (long) temp
);
4308 ignore_rest_of_line ();
4313 symbolP
= symbol_find_or_make (name
);
4316 /* Make a section for the common symbol. */
4317 new_seg
= subseg_new (xstrdup (name
), 0);
4323 /* alignment might follow */
4324 if (*input_line_pointer
== ',')
4328 input_line_pointer
++;
4329 align
= get_absolute_expression ();
4330 bfd_set_section_alignment (stdoutput
, new_seg
, align
);
4334 if (S_IS_DEFINED (symbolP
) && ! S_IS_COMMON (symbolP
))
4336 as_bad (_("Ignoring attempt to re-define symbol"));
4337 ignore_rest_of_line ();
4342 if (bfd_section_size (stdoutput
, new_seg
) > 0)
4344 if (bfd_section_size (stdoutput
, new_seg
) != temp
)
4345 as_bad (_("Length of .comm \"%s\" is already %ld. Not changed to %ld."),
4346 S_GET_NAME (symbolP
),
4347 (long) bfd_section_size (stdoutput
, new_seg
),
4351 if (S_GET_VALUE (symbolP
))
4353 if (S_GET_VALUE (symbolP
) != (valueT
) temp
)
4354 as_bad (_("Length of .comm \"%s\" is already %ld. Not changed to %ld."),
4355 S_GET_NAME (symbolP
),
4356 (long) S_GET_VALUE (symbolP
),
4363 subseg_set (new_seg
, 0);
4364 p
= frag_more (temp
);
4365 new_seg
->flags
|= SEC_IS_COMMON
;
4366 if (! S_IS_DEFINED (symbolP
))
4367 S_SET_SEGMENT (symbolP
, new_seg
);
4369 S_SET_VALUE (symbolP
, (valueT
) temp
);
4371 S_SET_EXTERNAL (symbolP
);
4375 subseg_set (current_section
, current_subsec
);
4378 know (symbol_get_frag (symbolP
) == &zero_address_frag
);
4380 demand_empty_rest_of_line ();
4383 #endif /* ! OBJ_ELF */
4387 /* Handle the .rdata pseudo-op. This is like the usual one, but it
4388 clears alpha_insn_label and restores auto alignment. */
4391 s_alpha_rdata (ignore
)
4396 temp
= get_absolute_expression ();
4397 subseg_new (".rdata", 0);
4398 demand_empty_rest_of_line ();
4399 alpha_insn_label
= NULL
;
4400 alpha_auto_align_on
= 1;
4401 alpha_current_align
= 0;
4408 /* Handle the .sdata pseudo-op. This is like the usual one, but it
4409 clears alpha_insn_label and restores auto alignment. */
4412 s_alpha_sdata (ignore
)
4417 temp
= get_absolute_expression ();
4418 subseg_new (".sdata", 0);
4419 demand_empty_rest_of_line ();
4420 alpha_insn_label
= NULL
;
4421 alpha_auto_align_on
= 1;
4422 alpha_current_align
= 0;
4428 /* Handle the .section pseudo-op. This is like the usual one, but it
4429 clears alpha_insn_label and restores auto alignment. */
4432 s_alpha_section (ignore
)
4435 obj_elf_section (ignore
);
4437 alpha_insn_label
= NULL
;
4438 alpha_auto_align_on
= 1;
4439 alpha_current_align
= 0;
4444 int dummy ATTRIBUTE_UNUSED
;
4446 if (ECOFF_DEBUGGING
)
4447 ecoff_directive_ent (0);
4450 char *name
, name_end
;
4451 name
= input_line_pointer
;
4452 name_end
= get_symbol_end ();
4454 if (! is_name_beginner (*name
))
4456 as_warn (_(".ent directive has no name"));
4457 *input_line_pointer
= name_end
;
4463 if (alpha_cur_ent_sym
)
4464 as_warn (_("nested .ent directives"));
4466 sym
= symbol_find_or_make (name
);
4467 symbol_get_bfdsym (sym
)->flags
|= BSF_FUNCTION
;
4468 alpha_cur_ent_sym
= sym
;
4470 /* The .ent directive is sometimes followed by a number. Not sure
4471 what it really means, but ignore it. */
4472 *input_line_pointer
= name_end
;
4474 if (*input_line_pointer
== ',')
4476 input_line_pointer
++;
4479 if (isdigit (*input_line_pointer
) || *input_line_pointer
== '-')
4480 (void) get_absolute_expression ();
4482 demand_empty_rest_of_line ();
4488 int dummy ATTRIBUTE_UNUSED
;
4490 if (ECOFF_DEBUGGING
)
4491 ecoff_directive_end (0);
4494 char *name
, name_end
;
4495 name
= input_line_pointer
;
4496 name_end
= get_symbol_end ();
4498 if (! is_name_beginner (*name
))
4500 as_warn (_(".end directive has no name"));
4501 *input_line_pointer
= name_end
;
4507 sym
= symbol_find (name
);
4508 if (sym
!= alpha_cur_ent_sym
)
4509 as_warn (_(".end directive names different symbol than .ent"));
4511 /* Create an expression to calculate the size of the function. */
4514 symbol_get_obj (sym
)->size
=
4515 (expressionS
*) xmalloc (sizeof (expressionS
));
4516 symbol_get_obj (sym
)->size
->X_op
= O_subtract
;
4517 symbol_get_obj (sym
)->size
->X_add_symbol
4518 = symbol_new ("L0\001", now_seg
, frag_now_fix (), frag_now
);
4519 symbol_get_obj (sym
)->size
->X_op_symbol
= sym
;
4520 symbol_get_obj (sym
)->size
->X_add_number
= 0;
4523 alpha_cur_ent_sym
= NULL
;
4525 *input_line_pointer
= name_end
;
4527 demand_empty_rest_of_line ();
4535 if (ECOFF_DEBUGGING
)
4538 ecoff_directive_fmask (0);
4540 ecoff_directive_mask (0);
4543 discard_rest_of_line ();
4547 s_alpha_frame (dummy
)
4548 int dummy ATTRIBUTE_UNUSED
;
4550 if (ECOFF_DEBUGGING
)
4551 ecoff_directive_frame (0);
4553 discard_rest_of_line ();
4557 s_alpha_prologue (ignore
)
4558 int ignore ATTRIBUTE_UNUSED
;
4563 arg
= get_absolute_expression ();
4564 demand_empty_rest_of_line ();
4566 if (ECOFF_DEBUGGING
)
4567 sym
= ecoff_get_cur_proc_sym ();
4569 sym
= alpha_cur_ent_sym
;
4574 case 0: /* No PV required. */
4575 S_SET_OTHER (sym
, STO_ALPHA_NOPV
4576 | (S_GET_OTHER (sym
) & ~STO_ALPHA_STD_GPLOAD
));
4578 case 1: /* Std GP load. */
4579 S_SET_OTHER (sym
, STO_ALPHA_STD_GPLOAD
4580 | (S_GET_OTHER (sym
) & ~STO_ALPHA_STD_GPLOAD
));
4582 case 2: /* Non-std use of PV. */
4586 as_bad (_("Invalid argument %d to .prologue."), arg
);
4591 static char * first_file_directive
;
4594 s_alpha_file (ignore
)
4595 int ignore ATTRIBUTE_UNUSED
;
4597 /* Save the first .file directive we see, so that we can change our
4598 minds about whether ecoff debugging should or shouldn't be enabled. */
4599 if (alpha_flag_mdebug
< 0 && ! first_file_directive
)
4601 char *start
= input_line_pointer
;
4604 discard_rest_of_line ();
4606 len
= input_line_pointer
- start
;
4607 first_file_directive
= xmalloc (len
+ 1);
4608 memcpy (first_file_directive
, start
, len
);
4609 first_file_directive
[len
] = '\0';
4611 input_line_pointer
= start
;
4614 if (ECOFF_DEBUGGING
)
4615 ecoff_directive_file (0);
4617 dwarf2_directive_file (0);
4621 s_alpha_loc (ignore
)
4622 int ignore ATTRIBUTE_UNUSED
;
4624 if (ECOFF_DEBUGGING
)
4625 ecoff_directive_loc (0);
4627 dwarf2_directive_loc (0);
4634 /* If we've been undecided about mdebug, make up our minds in favour. */
4635 if (alpha_flag_mdebug
< 0)
4637 segT sec
= subseg_new (".mdebug", 0);
4638 bfd_set_section_flags (stdoutput
, sec
, SEC_HAS_CONTENTS
|SEC_READONLY
);
4639 bfd_set_section_alignment (stdoutput
, sec
, 3);
4641 ecoff_read_begin_hook ();
4643 if (first_file_directive
)
4645 char *save_ilp
= input_line_pointer
;
4646 input_line_pointer
= first_file_directive
;
4647 ecoff_directive_file (0);
4648 input_line_pointer
= save_ilp
;
4649 free (first_file_directive
);
4652 alpha_flag_mdebug
= 1;
4658 s_alpha_coff_wrapper (which
)
4661 static void (* const fns
[]) PARAMS ((int)) = {
4662 ecoff_directive_begin
,
4663 ecoff_directive_bend
,
4664 ecoff_directive_def
,
4665 ecoff_directive_dim
,
4666 ecoff_directive_endef
,
4667 ecoff_directive_scl
,
4668 ecoff_directive_tag
,
4669 ecoff_directive_val
,
4672 assert (which
>= 0 && which
< (int) (sizeof (fns
)/sizeof (*fns
)));
4674 if (ECOFF_DEBUGGING
)
4678 as_bad (_("ECOFF debugging is disabled."));
4679 ignore_rest_of_line ();
4682 #endif /* OBJ_ELF */
4686 /* Handle the section specific pseudo-op. */
4689 s_alpha_section (secid
)
4693 #define EVAX_SECTION_COUNT 5
4694 static char *section_name
[EVAX_SECTION_COUNT
+1] =
4695 { "NULL", ".rdata", ".comm", ".link", ".ctors", ".dtors" };
4697 if ((secid
<= 0) || (secid
> EVAX_SECTION_COUNT
))
4699 as_fatal (_("Unknown section directive"));
4700 demand_empty_rest_of_line ();
4703 temp
= get_absolute_expression ();
4704 subseg_new (section_name
[secid
], 0);
4705 demand_empty_rest_of_line ();
4706 alpha_insn_label
= NULL
;
4707 alpha_auto_align_on
= 1;
4708 alpha_current_align
= 0;
4711 /* Parse .ent directives. */
4714 s_alpha_ent (ignore
)
4718 expressionS symexpr
;
4720 alpha_evax_proc
.pdsckind
= 0;
4721 alpha_evax_proc
.framereg
= -1;
4722 alpha_evax_proc
.framesize
= 0;
4723 alpha_evax_proc
.rsa_offset
= 0;
4724 alpha_evax_proc
.ra_save
= AXP_REG_RA
;
4725 alpha_evax_proc
.fp_save
= -1;
4726 alpha_evax_proc
.imask
= 0;
4727 alpha_evax_proc
.fmask
= 0;
4728 alpha_evax_proc
.prologue
= 0;
4729 alpha_evax_proc
.type
= 0;
4731 expression (&symexpr
);
4733 if (symexpr
.X_op
!= O_symbol
)
4735 as_fatal (_(".ent directive has no symbol"));
4736 demand_empty_rest_of_line ();
4740 symbol
= make_expr_symbol (&symexpr
);
4741 symbol_get_bfdsym (symbol
)->flags
|= BSF_FUNCTION
;
4742 alpha_evax_proc
.symbol
= symbol
;
4744 demand_empty_rest_of_line ();
4748 /* Parse .frame <framreg>,<framesize>,RA,<rsa_offset> directives. */
4751 s_alpha_frame (ignore
)
4756 alpha_evax_proc
.framereg
= tc_get_register (1);
4759 if (*input_line_pointer
++ != ','
4760 || get_absolute_expression_and_terminator (&val
) != ',')
4762 as_warn (_("Bad .frame directive 1./2. param"));
4763 --input_line_pointer
;
4764 demand_empty_rest_of_line ();
4768 alpha_evax_proc
.framesize
= val
;
4770 (void) tc_get_register (1);
4772 if (*input_line_pointer
++ != ',')
4774 as_warn (_("Bad .frame directive 3./4. param"));
4775 --input_line_pointer
;
4776 demand_empty_rest_of_line ();
4779 alpha_evax_proc
.rsa_offset
= get_absolute_expression ();
4785 s_alpha_pdesc (ignore
)
4795 segment_info_type
*seginfo
= seg_info (alpha_link_section
);
4797 if (now_seg
!= alpha_link_section
)
4799 as_bad (_(".pdesc directive not in link (.link) section"));
4800 demand_empty_rest_of_line ();
4804 if ((alpha_evax_proc
.symbol
== 0)
4805 || (!S_IS_DEFINED (alpha_evax_proc
.symbol
)))
4807 as_fatal (_(".pdesc has no matching .ent"));
4808 demand_empty_rest_of_line ();
4812 *symbol_get_obj (alpha_evax_proc
.symbol
) =
4813 (valueT
) seginfo
->literal_pool_size
;
4816 if (exp
.X_op
!= O_symbol
)
4818 as_warn (_(".pdesc directive has no entry symbol"));
4819 demand_empty_rest_of_line ();
4823 entry_sym
= make_expr_symbol (&exp
);
4824 /* Save bfd symbol of proc desc in function symbol. */
4825 symbol_get_bfdsym (alpha_evax_proc
.symbol
)->udata
.p
4826 = symbol_get_bfdsym (entry_sym
);
4829 if (*input_line_pointer
++ != ',')
4831 as_warn (_("No comma after .pdesc <entryname>"));
4832 demand_empty_rest_of_line ();
4837 name
= input_line_pointer
;
4838 name_end
= get_symbol_end ();
4840 if (strncmp (name
, "stack", 5) == 0)
4842 alpha_evax_proc
.pdsckind
= PDSC_S_K_KIND_FP_STACK
;
4844 else if (strncmp (name
, "reg", 3) == 0)
4846 alpha_evax_proc
.pdsckind
= PDSC_S_K_KIND_FP_REGISTER
;
4848 else if (strncmp (name
, "null", 4) == 0)
4850 alpha_evax_proc
.pdsckind
= PDSC_S_K_KIND_NULL
;
4854 as_fatal (_("unknown procedure kind"));
4855 demand_empty_rest_of_line ();
4859 *input_line_pointer
= name_end
;
4860 demand_empty_rest_of_line ();
4862 #ifdef md_flush_pending_output
4863 md_flush_pending_output ();
4866 frag_align (3, 0, 0);
4868 fixp
= fix_new (frag_now
, p
- frag_now
->fr_literal
, 8, 0, 0, 0, 0);
4870 seginfo
->literal_pool_size
+= 16;
4872 *p
= alpha_evax_proc
.pdsckind
4873 | ((alpha_evax_proc
.framereg
== 29) ? PDSC_S_M_BASE_REG_IS_FP
: 0);
4874 *(p
+1) = PDSC_S_M_NATIVE
4875 | PDSC_S_M_NO_JACKET
;
4877 switch (alpha_evax_proc
.pdsckind
)
4879 case PDSC_S_K_KIND_NULL
:
4883 case PDSC_S_K_KIND_FP_REGISTER
:
4884 *(p
+2) = alpha_evax_proc
.fp_save
;
4885 *(p
+3) = alpha_evax_proc
.ra_save
;
4887 case PDSC_S_K_KIND_FP_STACK
:
4888 md_number_to_chars (p
+2, (valueT
) alpha_evax_proc
.rsa_offset
, 2);
4890 default: /* impossible */
4895 *(p
+5) = alpha_evax_proc
.type
& 0x0f;
4897 /* Signature offset. */
4898 md_number_to_chars (p
+6, (valueT
) 0, 2);
4900 fix_new_exp (frag_now
, p
-frag_now
->fr_literal
+8, 8, &exp
, 0, BFD_RELOC_64
);
4902 if (alpha_evax_proc
.pdsckind
== PDSC_S_K_KIND_NULL
)
4905 /* Add dummy fix to make add_to_link_pool work. */
4907 fixp
= fix_new (frag_now
, p
- frag_now
->fr_literal
, 8, 0, 0, 0, 0);
4909 seginfo
->literal_pool_size
+= 8;
4911 /* pdesc+16: Size. */
4912 md_number_to_chars (p
, (valueT
) alpha_evax_proc
.framesize
, 4);
4914 md_number_to_chars (p
+4, (valueT
) 0, 2);
4917 md_number_to_chars (p
+6, alpha_evax_proc
.prologue
, 2);
4919 if (alpha_evax_proc
.pdsckind
== PDSC_S_K_KIND_FP_REGISTER
)
4922 /* Add dummy fix to make add_to_link_pool work. */
4924 fixp
= fix_new (frag_now
, p
- frag_now
->fr_literal
, 8, 0, 0, 0, 0);
4926 seginfo
->literal_pool_size
+= 8;
4928 /* pdesc+24: register masks. */
4930 md_number_to_chars (p
, alpha_evax_proc
.imask
, 4);
4931 md_number_to_chars (p
+4, alpha_evax_proc
.fmask
, 4);
4936 /* Support for crash debug on vms. */
4939 s_alpha_name (ignore
)
4944 segment_info_type
*seginfo
= seg_info (alpha_link_section
);
4946 if (now_seg
!= alpha_link_section
)
4948 as_bad (_(".name directive not in link (.link) section"));
4949 demand_empty_rest_of_line ();
4954 if (exp
.X_op
!= O_symbol
)
4956 as_warn (_(".name directive has no symbol"));
4957 demand_empty_rest_of_line ();
4961 demand_empty_rest_of_line ();
4963 #ifdef md_flush_pending_output
4964 md_flush_pending_output ();
4967 frag_align (3, 0, 0);
4969 seginfo
->literal_pool_size
+= 8;
4971 fix_new_exp (frag_now
, p
-frag_now
->fr_literal
, 8, &exp
, 0, BFD_RELOC_64
);
4977 s_alpha_linkage (ignore
)
4983 #ifdef md_flush_pending_output
4984 md_flush_pending_output ();
4988 if (exp
.X_op
!= O_symbol
)
4990 as_fatal (_("No symbol after .linkage"));
4994 p
= frag_more (LKP_S_K_SIZE
);
4995 memset (p
, 0, LKP_S_K_SIZE
);
4996 fix_new_exp (frag_now
, p
- frag_now
->fr_literal
, LKP_S_K_SIZE
, &exp
, 0,\
4997 BFD_RELOC_ALPHA_LINKAGE
);
4999 demand_empty_rest_of_line ();
5005 s_alpha_code_address (ignore
)
5011 #ifdef md_flush_pending_output
5012 md_flush_pending_output ();
5016 if (exp
.X_op
!= O_symbol
)
5018 as_fatal (_("No symbol after .code_address"));
5024 fix_new_exp (frag_now
, p
- frag_now
->fr_literal
, 8, &exp
, 0,\
5025 BFD_RELOC_ALPHA_CODEADDR
);
5027 demand_empty_rest_of_line ();
5033 s_alpha_fp_save (ignore
)
5037 alpha_evax_proc
.fp_save
= tc_get_register (1);
5039 demand_empty_rest_of_line ();
5044 s_alpha_mask (ignore
)
5049 if (get_absolute_expression_and_terminator (&val
) != ',')
5051 as_warn (_("Bad .mask directive"));
5052 --input_line_pointer
;
5056 alpha_evax_proc
.imask
= val
;
5057 (void) get_absolute_expression ();
5059 demand_empty_rest_of_line ();
5065 s_alpha_fmask (ignore
)
5070 if (get_absolute_expression_and_terminator (&val
) != ',')
5072 as_warn (_("Bad .fmask directive"));
5073 --input_line_pointer
;
5077 alpha_evax_proc
.fmask
= val
;
5078 (void) get_absolute_expression ();
5080 demand_empty_rest_of_line ();
5086 s_alpha_end (ignore
)
5091 c
= get_symbol_end ();
5092 *input_line_pointer
= c
;
5093 demand_empty_rest_of_line ();
5094 alpha_evax_proc
.symbol
= 0;
5100 s_alpha_file (ignore
)
5105 static char case_hack
[32];
5107 extern char *demand_copy_string
PARAMS ((int *lenP
));
5109 sprintf (case_hack
, "<CASE:%01d%01d>",
5110 alpha_flag_hash_long_names
, alpha_flag_show_after_trunc
);
5112 s
= symbol_find_or_make (case_hack
);
5113 symbol_get_bfdsym (s
)->flags
|= BSF_FILE
;
5115 get_absolute_expression ();
5116 s
= symbol_find_or_make (demand_copy_string (&length
));
5117 symbol_get_bfdsym (s
)->flags
|= BSF_FILE
;
5118 demand_empty_rest_of_line ();
5122 #endif /* OBJ_EVAX */
5124 /* Handle the .gprel32 pseudo op. */
5127 s_alpha_gprel32 (ignore
)
5128 int ignore ATTRIBUTE_UNUSED
;
5140 e
.X_add_symbol
= section_symbol (absolute_section
);
5153 e
.X_add_symbol
= section_symbol (absolute_section
);
5156 e
.X_op
= O_subtract
;
5157 e
.X_op_symbol
= alpha_gp_symbol
;
5165 if (alpha_auto_align_on
&& alpha_current_align
< 2)
5166 alpha_align (2, (char *) NULL
, alpha_insn_label
, 0);
5167 if (alpha_current_align
> 2)
5168 alpha_current_align
= 2;
5169 alpha_insn_label
= NULL
;
5173 fix_new_exp (frag_now
, p
-frag_now
->fr_literal
, 4,
5174 &e
, 0, BFD_RELOC_GPREL32
);
5177 /* Handle floating point allocation pseudo-ops. This is like the
5178 generic vresion, but it makes sure the current label, if any, is
5179 correctly aligned. */
5182 s_alpha_float_cons (type
)
5209 if (alpha_auto_align_on
&& alpha_current_align
< log_size
)
5210 alpha_align (log_size
, (char *) NULL
, alpha_insn_label
, 0);
5211 if (alpha_current_align
> log_size
)
5212 alpha_current_align
= log_size
;
5213 alpha_insn_label
= NULL
;
5218 /* Handle the .proc pseudo op. We don't really do much with it except
5222 s_alpha_proc (is_static
)
5223 int is_static ATTRIBUTE_UNUSED
;
5231 /* Takes ".proc name,nargs" */
5233 name
= input_line_pointer
;
5234 c
= get_symbol_end ();
5235 p
= input_line_pointer
;
5236 symbolP
= symbol_find_or_make (name
);
5239 if (*input_line_pointer
!= ',')
5242 as_warn (_("Expected comma after name \"%s\""), name
);
5245 ignore_rest_of_line ();
5249 input_line_pointer
++;
5250 temp
= get_absolute_expression ();
5252 /* *symbol_get_obj (symbolP) = (signed char) temp; */
5253 as_warn (_("unhandled: .proc %s,%d"), name
, temp
);
5254 demand_empty_rest_of_line ();
5257 /* Handle the .set pseudo op. This is used to turn on and off most of
5258 the assembler features. */
5262 int x ATTRIBUTE_UNUSED
;
5268 name
= input_line_pointer
;
5269 ch
= get_symbol_end ();
5272 if (s
[0] == 'n' && s
[1] == 'o')
5277 if (!strcmp ("reorder", s
))
5279 else if (!strcmp ("at", s
))
5280 alpha_noat_on
= !yesno
;
5281 else if (!strcmp ("macro", s
))
5282 alpha_macros_on
= yesno
;
5283 else if (!strcmp ("move", s
))
5285 else if (!strcmp ("volatile", s
))
5288 as_warn (_("Tried to .set unrecognized mode `%s'"), name
);
5290 *input_line_pointer
= ch
;
5291 demand_empty_rest_of_line ();
5294 /* Handle the .base pseudo op. This changes the assembler's notion of
5295 the $gp register. */
5298 s_alpha_base (ignore
)
5299 int ignore ATTRIBUTE_UNUSED
;
5302 if (first_32bit_quadrant
)
5304 /* not fatal, but it might not work in the end */
5305 as_warn (_("File overrides no-base-register option."));
5306 first_32bit_quadrant
= 0;
5311 if (*input_line_pointer
== '$')
5313 input_line_pointer
++;
5314 if (*input_line_pointer
== 'r')
5315 input_line_pointer
++;
5318 alpha_gp_register
= get_absolute_expression ();
5319 if (alpha_gp_register
< 0 || alpha_gp_register
> 31)
5321 alpha_gp_register
= AXP_REG_GP
;
5322 as_warn (_("Bad base register, using $%d."), alpha_gp_register
);
5325 demand_empty_rest_of_line ();
5328 /* Handle the .align pseudo-op. This aligns to a power of two. It
5329 also adjusts any current instruction label. We treat this the same
5330 way the MIPS port does: .align 0 turns off auto alignment. */
5333 s_alpha_align (ignore
)
5334 int ignore ATTRIBUTE_UNUSED
;
5338 long max_alignment
= 15;
5340 align
= get_absolute_expression ();
5341 if (align
> max_alignment
)
5343 align
= max_alignment
;
5344 as_bad (_("Alignment too large: %d. assumed"), align
);
5348 as_warn (_("Alignment negative: 0 assumed"));
5352 if (*input_line_pointer
== ',')
5354 input_line_pointer
++;
5355 fill
= get_absolute_expression ();
5363 alpha_auto_align_on
= 1;
5364 alpha_align (align
, pfill
, alpha_insn_label
, 1);
5368 alpha_auto_align_on
= 0;
5371 demand_empty_rest_of_line ();
5374 /* Hook the normal string processor to reset known alignment. */
5377 s_alpha_stringer (terminate
)
5380 alpha_current_align
= 0;
5381 alpha_insn_label
= NULL
;
5382 stringer (terminate
);
5385 /* Hook the normal space processing to reset known alignment. */
5388 s_alpha_space (ignore
)
5391 alpha_current_align
= 0;
5392 alpha_insn_label
= NULL
;
5396 /* Hook into cons for auto-alignment. */
5399 alpha_cons_align (size
)
5405 while ((size
>>= 1) != 0)
5408 if (alpha_auto_align_on
&& alpha_current_align
< log_size
)
5409 alpha_align (log_size
, (char *) NULL
, alpha_insn_label
, 0);
5410 if (alpha_current_align
> log_size
)
5411 alpha_current_align
= log_size
;
5412 alpha_insn_label
= NULL
;
5415 /* Here come the .uword, .ulong, and .uquad explicitly unaligned
5416 pseudos. We just turn off auto-alignment and call down to cons. */
5419 s_alpha_ucons (bytes
)
5422 int hold
= alpha_auto_align_on
;
5423 alpha_auto_align_on
= 0;
5425 alpha_auto_align_on
= hold
;
5428 /* Switch the working cpu type. */
5431 s_alpha_arch (ignored
)
5432 int ignored ATTRIBUTE_UNUSED
;
5435 const struct cpu_type
*p
;
5438 name
= input_line_pointer
;
5439 ch
= get_symbol_end ();
5441 for (p
= cpu_types
; p
->name
; ++p
)
5442 if (strcmp (name
, p
->name
) == 0)
5444 alpha_target_name
= p
->name
, alpha_target
= p
->flags
;
5447 as_warn ("Unknown CPU identifier `%s'", name
);
5450 *input_line_pointer
= ch
;
5451 demand_empty_rest_of_line ();
5457 /* print token expression with alpha specific extension. */
5460 alpha_print_token (f
, exp
)
5462 const expressionS
*exp
;
5472 expressionS nexp
= *exp
;
5473 nexp
.X_op
= O_register
;
5474 print_expr (f
, &nexp
);
5479 print_expr (f
, exp
);
5486 /* The target specific pseudo-ops which we support. */
5488 const pseudo_typeS md_pseudo_table
[] =
5491 {"comm", s_alpha_comm
, 0}, /* osf1 compiler does this */
5492 {"rdata", s_alpha_rdata
, 0},
5494 {"text", s_alpha_text
, 0},
5495 {"data", s_alpha_data
, 0},
5497 {"sdata", s_alpha_sdata
, 0},
5500 {"section", s_alpha_section
, 0},
5501 {"section.s", s_alpha_section
, 0},
5502 {"sect", s_alpha_section
, 0},
5503 {"sect.s", s_alpha_section
, 0},
5506 { "pdesc", s_alpha_pdesc
, 0},
5507 { "name", s_alpha_name
, 0},
5508 { "linkage", s_alpha_linkage
, 0},
5509 { "code_address", s_alpha_code_address
, 0},
5510 { "ent", s_alpha_ent
, 0},
5511 { "frame", s_alpha_frame
, 0},
5512 { "fp_save", s_alpha_fp_save
, 0},
5513 { "mask", s_alpha_mask
, 0},
5514 { "fmask", s_alpha_fmask
, 0},
5515 { "end", s_alpha_end
, 0},
5516 { "file", s_alpha_file
, 0},
5517 { "rdata", s_alpha_section
, 1},
5518 { "comm", s_alpha_comm
, 0},
5519 { "link", s_alpha_section
, 3},
5520 { "ctors", s_alpha_section
, 4},
5521 { "dtors", s_alpha_section
, 5},
5524 /* Frame related pseudos. */
5525 {"ent", s_alpha_ent
, 0},
5526 {"end", s_alpha_end
, 0},
5527 {"mask", s_alpha_mask
, 0},
5528 {"fmask", s_alpha_mask
, 1},
5529 {"frame", s_alpha_frame
, 0},
5530 {"prologue", s_alpha_prologue
, 0},
5531 {"file", s_alpha_file
, 5},
5532 {"loc", s_alpha_loc
, 9},
5533 {"stabs", s_alpha_stab
, 's'},
5534 {"stabn", s_alpha_stab
, 'n'},
5535 /* COFF debugging related pseudos. */
5536 {"begin", s_alpha_coff_wrapper
, 0},
5537 {"bend", s_alpha_coff_wrapper
, 1},
5538 {"def", s_alpha_coff_wrapper
, 2},
5539 {"dim", s_alpha_coff_wrapper
, 3},
5540 {"endef", s_alpha_coff_wrapper
, 4},
5541 {"scl", s_alpha_coff_wrapper
, 5},
5542 {"tag", s_alpha_coff_wrapper
, 6},
5543 {"val", s_alpha_coff_wrapper
, 7},
5545 {"prologue", s_ignore
, 0},
5547 {"gprel32", s_alpha_gprel32
, 0},
5548 {"t_floating", s_alpha_float_cons
, 'd'},
5549 {"s_floating", s_alpha_float_cons
, 'f'},
5550 {"f_floating", s_alpha_float_cons
, 'F'},
5551 {"g_floating", s_alpha_float_cons
, 'G'},
5552 {"d_floating", s_alpha_float_cons
, 'D'},
5554 {"proc", s_alpha_proc
, 0},
5555 {"aproc", s_alpha_proc
, 1},
5556 {"set", s_alpha_set
, 0},
5557 {"reguse", s_ignore
, 0},
5558 {"livereg", s_ignore
, 0},
5559 {"base", s_alpha_base
, 0}, /*??*/
5560 {"option", s_ignore
, 0},
5561 {"aent", s_ignore
, 0},
5562 {"ugen", s_ignore
, 0},
5563 {"eflag", s_ignore
, 0},
5565 {"align", s_alpha_align
, 0},
5566 {"double", s_alpha_float_cons
, 'd'},
5567 {"float", s_alpha_float_cons
, 'f'},
5568 {"single", s_alpha_float_cons
, 'f'},
5569 {"ascii", s_alpha_stringer
, 0},
5570 {"asciz", s_alpha_stringer
, 1},
5571 {"string", s_alpha_stringer
, 1},
5572 {"space", s_alpha_space
, 0},
5573 {"skip", s_alpha_space
, 0},
5574 {"zero", s_alpha_space
, 0},
5576 /* Unaligned data pseudos. */
5577 {"uword", s_alpha_ucons
, 2},
5578 {"ulong", s_alpha_ucons
, 4},
5579 {"uquad", s_alpha_ucons
, 8},
5582 /* Dwarf wants these versions of unaligned. */
5583 {"2byte", s_alpha_ucons
, 2},
5584 {"4byte", s_alpha_ucons
, 4},
5585 {"8byte", s_alpha_ucons
, 8},
5588 /* We don't do any optimizing, so we can safely ignore these. */
5589 {"noalias", s_ignore
, 0},
5590 {"alias", s_ignore
, 0},
5592 {"arch", s_alpha_arch
, 0},
5598 /* Build a BFD section with its flags set appropriately for the .lita,
5599 .lit8, or .lit4 sections. */
5602 create_literal_section (name
, secp
, symp
)
5607 segT current_section
= now_seg
;
5608 int current_subsec
= now_subseg
;
5611 *secp
= new_sec
= subseg_new (name
, 0);
5612 subseg_set (current_section
, current_subsec
);
5613 bfd_set_section_alignment (stdoutput
, new_sec
, 4);
5614 bfd_set_section_flags (stdoutput
, new_sec
,
5615 SEC_RELOC
| SEC_ALLOC
| SEC_LOAD
| SEC_READONLY
5618 S_CLEAR_EXTERNAL (*symp
= section_symbol (new_sec
));
5623 /* @@@ GP selection voodoo. All of this seems overly complicated and
5624 unnecessary; which is the primary reason it's for ECOFF only. */
5633 vma
= bfd_get_section_vma (foo
, sec
);
5634 if (vma
&& vma
< alpha_gp_value
)
5635 alpha_gp_value
= vma
;
5641 assert (alpha_gp_value
== 0);
5643 /* Get minus-one in whatever width... */
5644 alpha_gp_value
= 0; alpha_gp_value
--;
5646 /* Select the smallest VMA of these existing sections. */
5647 maybe_set_gp (alpha_lita_section
);
5649 /* These were disabled before -- should we use them? */
5650 maybe_set_gp (sdata
);
5651 maybe_set_gp (lit8_sec
);
5652 maybe_set_gp (lit4_sec
);
5655 /* @@ Will a simple 0x8000 work here? If not, why not? */
5656 #define GP_ADJUSTMENT (0x8000 - 0x10)
5658 alpha_gp_value
+= GP_ADJUSTMENT
;
5660 S_SET_VALUE (alpha_gp_symbol
, alpha_gp_value
);
5663 printf (_("Chose GP value of %lx\n"), alpha_gp_value
);
5666 #endif /* OBJ_ECOFF */
5668 /* Called internally to handle all alignment needs. This takes care
5669 of eliding calls to frag_align if'n the cached current alignment
5670 says we've already got it, as well as taking care of the auto-align
5671 feature wrt labels. */
5674 alpha_align (n
, pfill
, label
, force
)
5678 int force ATTRIBUTE_UNUSED
;
5680 if (alpha_current_align
>= n
)
5685 if (subseg_text_p (now_seg
))
5686 frag_align_code (n
, 0);
5688 frag_align (n
, 0, 0);
5691 frag_align (n
, *pfill
, 0);
5693 alpha_current_align
= n
;
5695 if (label
!= NULL
&& S_GET_SEGMENT (label
) == now_seg
)
5697 symbol_set_frag (label
, frag_now
);
5698 S_SET_VALUE (label
, (valueT
) frag_now_fix ());
5701 record_alignment (now_seg
, n
);
5703 /* ??? If alpha_flag_relax && force && elf, record the requested alignment
5704 in a reloc for the linker to see. */
5707 /* This is called from HANDLE_ALIGN in write.c. Fill in the contents
5708 of an rs_align_code fragment. */
5711 alpha_handle_align (fragp
)
5714 static char const unop
[4] = { 0x00, 0x00, 0xe0, 0x2f };
5715 static char const nopunop
[8] = {
5716 0x1f, 0x04, 0xff, 0x47,
5717 0x00, 0x00, 0xe0, 0x2f
5723 if (fragp
->fr_type
!= rs_align_code
)
5726 bytes
= fragp
->fr_next
->fr_address
- fragp
->fr_address
- fragp
->fr_fix
;
5727 p
= fragp
->fr_literal
+ fragp
->fr_fix
;
5740 memcpy (p
, unop
, 4);
5746 memcpy (p
, nopunop
, 8);
5748 fragp
->fr_fix
+= fix
;
5752 /* The Alpha has support for some VAX floating point types, as well as for
5753 IEEE floating point. We consider IEEE to be the primary floating point
5754 format, and sneak in the VAX floating point support here. */
5755 #define md_atof vax_md_atof
5756 #include "config/atof-vax.c"