1 /* tc-alpha.c - Processor-specific code for the DEC Alpha AXP CPU.
2 Copyright 1989, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
3 2001, 2002, 2003 Free Software Foundation, Inc.
4 Contributed by Carnegie Mellon University, 1993.
5 Written by Alessandro Forin, based on earlier gas-1.38 target CPU files.
6 Modified by Ken Raeburn for gas-2.x and ECOFF support.
7 Modified by Richard Henderson for ELF support.
8 Modified by Klaus K"ampf for EVAX (OpenVMS/Alpha) support.
10 This file is part of GAS, the GNU Assembler.
12 GAS is free software; you can redistribute it and/or modify
13 it under the terms of the GNU General Public License as published by
14 the Free Software Foundation; either version 2, or (at your option)
17 GAS is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License for more details.
22 You should have received a copy of the GNU General Public License
23 along with GAS; see the file COPYING. If not, write to the Free
24 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
28 * Mach Operating System
29 * Copyright (c) 1993 Carnegie Mellon University
30 * All Rights Reserved.
32 * Permission to use, copy, modify and distribute this software and its
33 * documentation is hereby granted, provided that both the copyright
34 * notice and this permission notice appear in all copies of the
35 * software, derivative works or modified versions, and any portions
36 * thereof, and that both notices appear in supporting documentation.
38 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS
39 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
40 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
42 * Carnegie Mellon requests users of this software to return to
44 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
45 * School of Computer Science
46 * Carnegie Mellon University
47 * Pittsburgh PA 15213-3890
49 * any improvements or extensions that they make and grant Carnegie the
50 * rights to redistribute these changes.
55 #include "struc-symbol.h"
58 #include "opcode/alpha.h"
61 #include "elf/alpha.h"
62 #include "dwarf2dbg.h"
63 #include "dw2gencfi.h"
66 #include "safe-ctype.h"
70 #define TOKENIZE_ERROR -1
71 #define TOKENIZE_ERROR_REPORT -2
73 #define MAX_INSN_FIXUPS 2
74 #define MAX_INSN_ARGS 5
79 bfd_reloc_code_real_type reloc
;
86 struct alpha_fixup fixups
[MAX_INSN_FIXUPS
];
104 void (*emit
) PARAMS ((const expressionS
*, int, const PTR
));
106 enum alpha_macro_arg argsets
[16];
109 /* Extra expression types. */
111 #define O_pregister O_md1 /* O_register, in parentheses */
112 #define O_cpregister O_md2 /* + a leading comma */
114 /* The alpha_reloc_op table below depends on the ordering of these. */
115 #define O_literal O_md3 /* !literal relocation */
116 #define O_lituse_addr O_md4 /* !lituse_addr relocation */
117 #define O_lituse_base O_md5 /* !lituse_base relocation */
118 #define O_lituse_bytoff O_md6 /* !lituse_bytoff relocation */
119 #define O_lituse_jsr O_md7 /* !lituse_jsr relocation */
120 #define O_lituse_tlsgd O_md8 /* !lituse_tlsgd relocation */
121 #define O_lituse_tlsldm O_md9 /* !lituse_tlsldm relocation */
122 #define O_gpdisp O_md10 /* !gpdisp relocation */
123 #define O_gprelhigh O_md11 /* !gprelhigh relocation */
124 #define O_gprellow O_md12 /* !gprellow relocation */
125 #define O_gprel O_md13 /* !gprel relocation */
126 #define O_samegp O_md14 /* !samegp relocation */
127 #define O_tlsgd O_md15 /* !tlsgd relocation */
128 #define O_tlsldm O_md16 /* !tlsldm relocation */
129 #define O_gotdtprel O_md17 /* !gotdtprel relocation */
130 #define O_dtprelhi O_md18 /* !dtprelhi relocation */
131 #define O_dtprello O_md19 /* !dtprello relocation */
132 #define O_dtprel O_md20 /* !dtprel relocation */
133 #define O_gottprel O_md21 /* !gottprel relocation */
134 #define O_tprelhi O_md22 /* !tprelhi relocation */
135 #define O_tprello O_md23 /* !tprello relocation */
136 #define O_tprel O_md24 /* !tprel relocation */
138 #define DUMMY_RELOC_LITUSE_ADDR (BFD_RELOC_UNUSED + 1)
139 #define DUMMY_RELOC_LITUSE_BASE (BFD_RELOC_UNUSED + 2)
140 #define DUMMY_RELOC_LITUSE_BYTOFF (BFD_RELOC_UNUSED + 3)
141 #define DUMMY_RELOC_LITUSE_JSR (BFD_RELOC_UNUSED + 4)
142 #define DUMMY_RELOC_LITUSE_TLSGD (BFD_RELOC_UNUSED + 5)
143 #define DUMMY_RELOC_LITUSE_TLSLDM (BFD_RELOC_UNUSED + 6)
145 #define USER_RELOC_P(R) ((R) >= O_literal && (R) <= O_tprel)
147 /* Macros for extracting the type and number of encoded register tokens. */
149 #define is_ir_num(x) (((x) & 32) == 0)
150 #define is_fpr_num(x) (((x) & 32) != 0)
151 #define regno(x) ((x) & 31)
153 /* Something odd inherited from the old assembler. */
155 #define note_gpreg(R) (alpha_gprmask |= (1 << (R)))
156 #define note_fpreg(R) (alpha_fprmask |= (1 << (R)))
158 /* Predicates for 16- and 32-bit ranges */
159 /* XXX: The non-shift version appears to trigger a compiler bug when
160 cross-assembling from x86 w/ gcc 2.7.2. */
163 #define range_signed_16(x) \
164 (((offsetT) (x) >> 15) == 0 || ((offsetT) (x) >> 15) == -1)
165 #define range_signed_32(x) \
166 (((offsetT) (x) >> 31) == 0 || ((offsetT) (x) >> 31) == -1)
168 #define range_signed_16(x) ((offsetT) (x) >= -(offsetT) 0x8000 && \
169 (offsetT) (x) <= (offsetT) 0x7FFF)
170 #define range_signed_32(x) ((offsetT) (x) >= -(offsetT) 0x80000000 && \
171 (offsetT) (x) <= (offsetT) 0x7FFFFFFF)
174 /* Macros for sign extending from 16- and 32-bits. */
175 /* XXX: The cast macros will work on all the systems that I care about,
176 but really a predicate should be found to use the non-cast forms. */
179 #define sign_extend_16(x) ((short) (x))
180 #define sign_extend_32(x) ((int) (x))
182 #define sign_extend_16(x) ((offsetT) (((x) & 0xFFFF) ^ 0x8000) - 0x8000)
183 #define sign_extend_32(x) ((offsetT) (((x) & 0xFFFFFFFF) \
184 ^ 0x80000000) - 0x80000000)
187 /* Macros to build tokens. */
189 #define set_tok_reg(t, r) (memset (&(t), 0, sizeof (t)), \
190 (t).X_op = O_register, \
191 (t).X_add_number = (r))
192 #define set_tok_preg(t, r) (memset (&(t), 0, sizeof (t)), \
193 (t).X_op = O_pregister, \
194 (t).X_add_number = (r))
195 #define set_tok_cpreg(t, r) (memset (&(t), 0, sizeof (t)), \
196 (t).X_op = O_cpregister, \
197 (t).X_add_number = (r))
198 #define set_tok_freg(t, r) (memset (&(t), 0, sizeof (t)), \
199 (t).X_op = O_register, \
200 (t).X_add_number = (r) + 32)
201 #define set_tok_sym(t, s, a) (memset (&(t), 0, sizeof (t)), \
202 (t).X_op = O_symbol, \
203 (t).X_add_symbol = (s), \
204 (t).X_add_number = (a))
205 #define set_tok_const(t, n) (memset (&(t), 0, sizeof (t)), \
206 (t).X_op = O_constant, \
207 (t).X_add_number = (n))
209 /* Prototypes for all local functions. */
211 static struct alpha_reloc_tag
*get_alpha_reloc_tag
PARAMS ((long));
212 static void alpha_adjust_relocs
PARAMS ((bfd
*, asection
*, PTR
));
214 static int tokenize_arguments
PARAMS ((char *, expressionS
*, int));
215 static const struct alpha_opcode
*find_opcode_match
216 PARAMS ((const struct alpha_opcode
*, const expressionS
*, int *, int *));
217 static const struct alpha_macro
*find_macro_match
218 PARAMS ((const struct alpha_macro
*, const expressionS
*, int *));
219 static unsigned insert_operand
220 PARAMS ((unsigned, const struct alpha_operand
*, offsetT
, char *, unsigned));
221 static void assemble_insn
222 PARAMS ((const struct alpha_opcode
*, const expressionS
*, int,
223 struct alpha_insn
*, bfd_reloc_code_real_type
));
224 static void emit_insn
PARAMS ((struct alpha_insn
*));
225 static void assemble_tokens_to_insn
226 PARAMS ((const char *, const expressionS
*, int, struct alpha_insn
*));
227 static void assemble_tokens
228 PARAMS ((const char *, const expressionS
*, int, int));
230 static long load_expression
231 PARAMS ((int, const expressionS
*, int *, expressionS
*));
233 static void emit_ldgp
PARAMS ((const expressionS
*, int, const PTR
));
234 static void emit_division
PARAMS ((const expressionS
*, int, const PTR
));
235 static void emit_lda
PARAMS ((const expressionS
*, int, const PTR
));
236 static void emit_ldah
PARAMS ((const expressionS
*, int, const PTR
));
237 static void emit_ir_load
PARAMS ((const expressionS
*, int, const PTR
));
238 static void emit_loadstore
PARAMS ((const expressionS
*, int, const PTR
));
239 static void emit_jsrjmp
PARAMS ((const expressionS
*, int, const PTR
));
240 static void emit_ldX
PARAMS ((const expressionS
*, int, const PTR
));
241 static void emit_ldXu
PARAMS ((const expressionS
*, int, const PTR
));
242 static void emit_uldX
PARAMS ((const expressionS
*, int, const PTR
));
243 static void emit_uldXu
PARAMS ((const expressionS
*, int, const PTR
));
244 static void emit_ldil
PARAMS ((const expressionS
*, int, const PTR
));
245 static void emit_stX
PARAMS ((const expressionS
*, int, const PTR
));
246 static void emit_ustX
PARAMS ((const expressionS
*, int, const PTR
));
247 static void emit_sextX
PARAMS ((const expressionS
*, int, const PTR
));
248 static void emit_retjcr
PARAMS ((const expressionS
*, int, const PTR
));
250 static void s_alpha_text
PARAMS ((int));
251 static void s_alpha_data
PARAMS ((int));
253 static void s_alpha_comm
PARAMS ((int));
254 static void s_alpha_rdata
PARAMS ((int));
257 static void s_alpha_sdata
PARAMS ((int));
260 static void s_alpha_section
PARAMS ((int));
261 static void s_alpha_ent
PARAMS ((int));
262 static void s_alpha_end
PARAMS ((int));
263 static void s_alpha_mask
PARAMS ((int));
264 static void s_alpha_frame
PARAMS ((int));
265 static void s_alpha_prologue
PARAMS ((int));
266 static void s_alpha_file
PARAMS ((int));
267 static void s_alpha_loc
PARAMS ((int));
268 static void s_alpha_stab
PARAMS ((int));
269 static void s_alpha_coff_wrapper
PARAMS ((int));
270 static void s_alpha_usepv
PARAMS ((int));
273 static void s_alpha_section
PARAMS ((int));
275 static void s_alpha_gprel32
PARAMS ((int));
276 static void s_alpha_float_cons
PARAMS ((int));
277 static void s_alpha_proc
PARAMS ((int));
278 static void s_alpha_set
PARAMS ((int));
279 static void s_alpha_base
PARAMS ((int));
280 static void s_alpha_align
PARAMS ((int));
281 static void s_alpha_stringer
PARAMS ((int));
282 static void s_alpha_space
PARAMS ((int));
283 static void s_alpha_ucons
PARAMS ((int));
284 static void s_alpha_arch
PARAMS ((int));
286 static void create_literal_section
PARAMS ((const char *, segT
*, symbolS
**));
288 static void select_gp_value
PARAMS ((void));
290 static void alpha_align
PARAMS ((int, char *, symbolS
*, int));
292 /* Generic assembler global variables which must be defined by all
295 /* Characters which always start a comment. */
296 const char comment_chars
[] = "#";
298 /* Characters which start a comment at the beginning of a line. */
299 const char line_comment_chars
[] = "#";
301 /* Characters which may be used to separate multiple commands on a
303 const char line_separator_chars
[] = ";";
305 /* Characters which are used to indicate an exponent in a floating
307 const char EXP_CHARS
[] = "eE";
309 /* Characters which mean that a number is a floating point constant,
312 const char FLT_CHARS
[] = "dD";
314 /* XXX: Do all of these really get used on the alpha?? */
315 char FLT_CHARS
[] = "rRsSfFdDxXpP";
319 const char *md_shortopts
= "Fm:g+1h:HG:";
321 const char *md_shortopts
= "Fm:gG:";
324 struct option md_longopts
[] =
326 #define OPTION_32ADDR (OPTION_MD_BASE)
327 { "32addr", no_argument
, NULL
, OPTION_32ADDR
},
328 #define OPTION_RELAX (OPTION_32ADDR + 1)
329 { "relax", no_argument
, NULL
, OPTION_RELAX
},
331 #define OPTION_MDEBUG (OPTION_RELAX + 1)
332 #define OPTION_NO_MDEBUG (OPTION_MDEBUG + 1)
333 { "mdebug", no_argument
, NULL
, OPTION_MDEBUG
},
334 { "no-mdebug", no_argument
, NULL
, OPTION_NO_MDEBUG
},
336 { NULL
, no_argument
, NULL
, 0 }
339 size_t md_longopts_size
= sizeof (md_longopts
);
343 #define AXP_REG_R16 16
344 #define AXP_REG_R17 17
346 #define AXP_REG_T9 22
348 #define AXP_REG_T10 23
350 #define AXP_REG_T11 24
352 #define AXP_REG_T12 25
353 #define AXP_REG_AI 25
355 #define AXP_REG_FP 29
358 #define AXP_REG_GP AXP_REG_PV
359 #endif /* OBJ_EVAX */
361 /* The cpu for which we are generating code. */
362 static unsigned alpha_target
= AXP_OPCODE_BASE
;
363 static const char *alpha_target_name
= "<all>";
365 /* The hash table of instruction opcodes. */
366 static struct hash_control
*alpha_opcode_hash
;
368 /* The hash table of macro opcodes. */
369 static struct hash_control
*alpha_macro_hash
;
372 /* The $gp relocation symbol. */
373 static symbolS
*alpha_gp_symbol
;
375 /* XXX: what is this, and why is it exported? */
376 valueT alpha_gp_value
;
379 /* The current $gp register. */
380 static int alpha_gp_register
= AXP_REG_GP
;
382 /* A table of the register symbols. */
383 static symbolS
*alpha_register_table
[64];
385 /* Constant sections, or sections of constants. */
387 static segT alpha_lita_section
;
390 static segT alpha_link_section
;
391 static segT alpha_ctors_section
;
392 static segT alpha_dtors_section
;
394 static segT alpha_lit8_section
;
396 /* Symbols referring to said sections. */
398 static symbolS
*alpha_lita_symbol
;
401 static symbolS
*alpha_link_symbol
;
402 static symbolS
*alpha_ctors_symbol
;
403 static symbolS
*alpha_dtors_symbol
;
405 static symbolS
*alpha_lit8_symbol
;
407 /* Literal for .litX+0x8000 within .lita. */
409 static offsetT alpha_lit8_literal
;
412 /* Is the assembler not allowed to use $at? */
413 static int alpha_noat_on
= 0;
415 /* Are macros enabled? */
416 static int alpha_macros_on
= 1;
418 /* Are floats disabled? */
419 static int alpha_nofloats_on
= 0;
421 /* Are addresses 32 bit? */
422 static int alpha_addr32_on
= 0;
424 /* Symbol labelling the current insn. When the Alpha gas sees
427 and the section happens to not be on an eight byte boundary, it
428 will align both the symbol and the .quad to an eight byte boundary. */
429 static symbolS
*alpha_insn_label
;
431 /* Whether we should automatically align data generation pseudo-ops.
432 .align 0 will turn this off. */
433 static int alpha_auto_align_on
= 1;
435 /* The known current alignment of the current section. */
436 static int alpha_current_align
;
438 /* These are exported to ECOFF code. */
439 unsigned long alpha_gprmask
, alpha_fprmask
;
441 /* Whether the debugging option was seen. */
442 static int alpha_debug
;
445 /* Whether we are emitting an mdebug section. */
446 int alpha_flag_mdebug
= -1;
449 /* Don't fully resolve relocations, allowing code movement in the linker. */
450 static int alpha_flag_relax
;
452 /* What value to give to bfd_set_gp_size. */
453 static int g_switch_value
= 8;
456 /* Collect information about current procedure here. */
458 symbolS
*symbol
; /* proc pdesc symbol */
460 int framereg
; /* register for frame pointer */
461 int framesize
; /* size of frame */
471 static int alpha_flag_hash_long_names
= 0; /* -+ */
472 static int alpha_flag_show_after_trunc
= 0; /* -H */
474 /* If the -+ switch is given, then a hash is appended to any name that is
475 longer than 64 characters, else longer symbol names are truncated. */
480 /* A table to map the spelling of a relocation operand into an appropriate
481 bfd_reloc_code_real_type type. The table is assumed to be ordered such
482 that op-O_literal indexes into it. */
484 #define ALPHA_RELOC_TABLE(op) \
485 (&alpha_reloc_op[ ((!USER_RELOC_P (op)) \
487 : (int) (op) - (int) O_literal) ])
489 #define DEF(NAME, RELOC, REQ, ALLOW) \
490 { #NAME, sizeof(#NAME)-1, O_##NAME, RELOC, REQ, ALLOW}
492 static const struct alpha_reloc_op_tag
494 const char *name
; /* string to lookup */
495 size_t length
; /* size of the string */
496 operatorT op
; /* which operator to use */
497 bfd_reloc_code_real_type reloc
; /* relocation before frob */
498 unsigned int require_seq
: 1; /* require a sequence number */
499 unsigned int allow_seq
: 1; /* allow a sequence number */
503 DEF(literal
, BFD_RELOC_ALPHA_ELF_LITERAL
, 0, 1),
504 DEF(lituse_addr
, DUMMY_RELOC_LITUSE_ADDR
, 1, 1),
505 DEF(lituse_base
, DUMMY_RELOC_LITUSE_BASE
, 1, 1),
506 DEF(lituse_bytoff
, DUMMY_RELOC_LITUSE_BYTOFF
, 1, 1),
507 DEF(lituse_jsr
, DUMMY_RELOC_LITUSE_JSR
, 1, 1),
508 DEF(lituse_tlsgd
, DUMMY_RELOC_LITUSE_TLSGD
, 1, 1),
509 DEF(lituse_tlsldm
, DUMMY_RELOC_LITUSE_TLSLDM
, 1, 1),
510 DEF(gpdisp
, BFD_RELOC_ALPHA_GPDISP
, 1, 1),
511 DEF(gprelhigh
, BFD_RELOC_ALPHA_GPREL_HI16
, 0, 0),
512 DEF(gprellow
, BFD_RELOC_ALPHA_GPREL_LO16
, 0, 0),
513 DEF(gprel
, BFD_RELOC_GPREL16
, 0, 0),
514 DEF(samegp
, BFD_RELOC_ALPHA_BRSGP
, 0, 0),
515 DEF(tlsgd
, BFD_RELOC_ALPHA_TLSGD
, 0, 1),
516 DEF(tlsldm
, BFD_RELOC_ALPHA_TLSLDM
, 0, 1),
517 DEF(gotdtprel
, BFD_RELOC_ALPHA_GOTDTPREL16
, 0, 0),
518 DEF(dtprelhi
, BFD_RELOC_ALPHA_DTPREL_HI16
, 0, 0),
519 DEF(dtprello
, BFD_RELOC_ALPHA_DTPREL_LO16
, 0, 0),
520 DEF(dtprel
, BFD_RELOC_ALPHA_DTPREL16
, 0, 0),
521 DEF(gottprel
, BFD_RELOC_ALPHA_GOTTPREL16
, 0, 0),
522 DEF(tprelhi
, BFD_RELOC_ALPHA_TPREL_HI16
, 0, 0),
523 DEF(tprello
, BFD_RELOC_ALPHA_TPREL_LO16
, 0, 0),
524 DEF(tprel
, BFD_RELOC_ALPHA_TPREL16
, 0, 0),
529 static const int alpha_num_reloc_op
530 = sizeof (alpha_reloc_op
) / sizeof (*alpha_reloc_op
);
531 #endif /* RELOC_OP_P */
533 /* Maximum # digits needed to hold the largest sequence # */
534 #define ALPHA_RELOC_DIGITS 25
536 /* Structure to hold explicit sequence information. */
537 struct alpha_reloc_tag
539 fixS
*master
; /* the literal reloc */
540 fixS
*slaves
; /* head of linked list of lituses */
541 segT segment
; /* segment relocs are in or undefined_section*/
542 long sequence
; /* sequence # */
543 unsigned n_master
; /* # of literals */
544 unsigned n_slaves
; /* # of lituses */
545 unsigned saw_tlsgd
: 1; /* true if ... */
546 unsigned saw_tlsldm
: 1;
547 unsigned saw_lu_tlsgd
: 1;
548 unsigned saw_lu_tlsldm
: 1;
549 unsigned multi_section_p
: 1; /* true if more than one section was used */
550 char string
[1]; /* printable form of sequence to hash with */
553 /* Hash table to link up literals with the appropriate lituse */
554 static struct hash_control
*alpha_literal_hash
;
556 /* Sequence numbers for internal use by macros. */
557 static long next_sequence_num
= -1;
559 /* A table of CPU names and opcode sets. */
561 static const struct cpu_type
568 /* Ad hoc convention: cpu number gets palcode, process code doesn't.
569 This supports usage under DU 4.0b that does ".arch ev4", and
570 usage in MILO that does -m21064. Probably something more
571 specific like -m21064-pal should be used, but oh well. */
573 { "21064", AXP_OPCODE_BASE
|AXP_OPCODE_EV4
},
574 { "21064a", AXP_OPCODE_BASE
|AXP_OPCODE_EV4
},
575 { "21066", AXP_OPCODE_BASE
|AXP_OPCODE_EV4
},
576 { "21068", AXP_OPCODE_BASE
|AXP_OPCODE_EV4
},
577 { "21164", AXP_OPCODE_BASE
|AXP_OPCODE_EV5
},
578 { "21164a", AXP_OPCODE_BASE
|AXP_OPCODE_EV5
|AXP_OPCODE_BWX
},
579 { "21164pc", (AXP_OPCODE_BASE
|AXP_OPCODE_EV5
|AXP_OPCODE_BWX
581 { "21264", (AXP_OPCODE_BASE
|AXP_OPCODE_EV6
|AXP_OPCODE_BWX
582 |AXP_OPCODE_MAX
|AXP_OPCODE_CIX
) },
583 { "21264a", (AXP_OPCODE_BASE
|AXP_OPCODE_EV6
|AXP_OPCODE_BWX
584 |AXP_OPCODE_MAX
|AXP_OPCODE_CIX
) },
585 { "21264b", (AXP_OPCODE_BASE
|AXP_OPCODE_EV6
|AXP_OPCODE_BWX
586 |AXP_OPCODE_MAX
|AXP_OPCODE_CIX
) },
588 { "ev4", AXP_OPCODE_BASE
},
589 { "ev45", AXP_OPCODE_BASE
},
590 { "lca45", AXP_OPCODE_BASE
},
591 { "ev5", AXP_OPCODE_BASE
},
592 { "ev56", AXP_OPCODE_BASE
|AXP_OPCODE_BWX
},
593 { "pca56", AXP_OPCODE_BASE
|AXP_OPCODE_BWX
|AXP_OPCODE_MAX
},
594 { "ev6", AXP_OPCODE_BASE
|AXP_OPCODE_BWX
|AXP_OPCODE_MAX
|AXP_OPCODE_CIX
},
595 { "ev67", AXP_OPCODE_BASE
|AXP_OPCODE_BWX
|AXP_OPCODE_MAX
|AXP_OPCODE_CIX
},
596 { "ev68", AXP_OPCODE_BASE
|AXP_OPCODE_BWX
|AXP_OPCODE_MAX
|AXP_OPCODE_CIX
},
598 { "all", AXP_OPCODE_BASE
},
602 /* The macro table */
604 static const struct alpha_macro alpha_macros
[] =
606 /* Load/Store macros */
607 { "lda", emit_lda
, NULL
,
608 { MACRO_IR
, MACRO_EXP
, MACRO_OPIR
, MACRO_EOA
} },
609 { "ldah", emit_ldah
, NULL
,
610 { MACRO_IR
, MACRO_EXP
, MACRO_EOA
} },
612 { "ldl", emit_ir_load
, "ldl",
613 { MACRO_IR
, MACRO_EXP
, MACRO_OPIR
, MACRO_EOA
} },
614 { "ldl_l", emit_ir_load
, "ldl_l",
615 { MACRO_IR
, MACRO_EXP
, MACRO_OPIR
, MACRO_EOA
} },
616 { "ldq", emit_ir_load
, "ldq",
617 { MACRO_IR
, MACRO_EXP
, MACRO_OPIR
, MACRO_EOA
} },
618 { "ldq_l", emit_ir_load
, "ldq_l",
619 { MACRO_IR
, MACRO_EXP
, MACRO_OPIR
, MACRO_EOA
} },
620 { "ldq_u", emit_ir_load
, "ldq_u",
621 { MACRO_IR
, MACRO_EXP
, MACRO_OPIR
, MACRO_EOA
} },
622 { "ldf", emit_loadstore
, "ldf",
623 { MACRO_FPR
, MACRO_EXP
, MACRO_OPIR
, MACRO_EOA
} },
624 { "ldg", emit_loadstore
, "ldg",
625 { MACRO_FPR
, MACRO_EXP
, MACRO_OPIR
, MACRO_EOA
} },
626 { "lds", emit_loadstore
, "lds",
627 { MACRO_FPR
, MACRO_EXP
, MACRO_OPIR
, MACRO_EOA
} },
628 { "ldt", emit_loadstore
, "ldt",
629 { MACRO_FPR
, MACRO_EXP
, MACRO_OPIR
, MACRO_EOA
} },
631 { "ldb", emit_ldX
, (PTR
) 0,
632 { MACRO_IR
, MACRO_EXP
, MACRO_OPIR
, MACRO_EOA
} },
633 { "ldbu", emit_ldXu
, (PTR
) 0,
634 { MACRO_IR
, MACRO_EXP
, MACRO_OPIR
, MACRO_EOA
} },
635 { "ldw", emit_ldX
, (PTR
) 1,
636 { MACRO_IR
, MACRO_EXP
, MACRO_OPIR
, MACRO_EOA
} },
637 { "ldwu", emit_ldXu
, (PTR
) 1,
638 { MACRO_IR
, MACRO_EXP
, MACRO_OPIR
, MACRO_EOA
} },
640 { "uldw", emit_uldX
, (PTR
) 1,
641 { MACRO_IR
, MACRO_EXP
, MACRO_OPIR
, MACRO_EOA
} },
642 { "uldwu", emit_uldXu
, (PTR
) 1,
643 { MACRO_IR
, MACRO_EXP
, MACRO_OPIR
, MACRO_EOA
} },
644 { "uldl", emit_uldX
, (PTR
) 2,
645 { MACRO_IR
, MACRO_EXP
, MACRO_OPIR
, MACRO_EOA
} },
646 { "uldlu", emit_uldXu
, (PTR
) 2,
647 { MACRO_IR
, MACRO_EXP
, MACRO_OPIR
, MACRO_EOA
} },
648 { "uldq", emit_uldXu
, (PTR
) 3,
649 { MACRO_IR
, MACRO_EXP
, MACRO_OPIR
, MACRO_EOA
} },
651 { "ldgp", emit_ldgp
, NULL
,
652 { MACRO_IR
, MACRO_EXP
, MACRO_PIR
, MACRO_EOA
} },
654 { "ldi", emit_lda
, NULL
,
655 { MACRO_IR
, MACRO_EXP
, MACRO_EOA
} },
656 { "ldil", emit_ldil
, NULL
,
657 { MACRO_IR
, MACRO_EXP
, MACRO_EOA
} },
658 { "ldiq", emit_lda
, NULL
,
659 { MACRO_IR
, MACRO_EXP
, MACRO_EOA
} },
661 { "ldif" emit_ldiq
, NULL
,
662 { MACRO_FPR
, MACRO_EXP
, MACRO_EOA
} },
663 { "ldid" emit_ldiq
, NULL
,
664 { MACRO_FPR
, MACRO_EXP
, MACRO_EOA
} },
665 { "ldig" emit_ldiq
, NULL
,
666 { MACRO_FPR
, MACRO_EXP
, MACRO_EOA
} },
667 { "ldis" emit_ldiq
, NULL
,
668 { MACRO_FPR
, MACRO_EXP
, MACRO_EOA
} },
669 { "ldit" emit_ldiq
, NULL
,
670 { MACRO_FPR
, MACRO_EXP
, MACRO_EOA
} },
673 { "stl", emit_loadstore
, "stl",
674 { MACRO_IR
, MACRO_EXP
, MACRO_OPIR
, MACRO_EOA
} },
675 { "stl_c", emit_loadstore
, "stl_c",
676 { MACRO_IR
, MACRO_EXP
, MACRO_OPIR
, MACRO_EOA
} },
677 { "stq", emit_loadstore
, "stq",
678 { MACRO_IR
, MACRO_EXP
, MACRO_OPIR
, MACRO_EOA
} },
679 { "stq_c", emit_loadstore
, "stq_c",
680 { MACRO_IR
, MACRO_EXP
, MACRO_OPIR
, MACRO_EOA
} },
681 { "stq_u", emit_loadstore
, "stq_u",
682 { MACRO_IR
, MACRO_EXP
, MACRO_OPIR
, MACRO_EOA
} },
683 { "stf", emit_loadstore
, "stf",
684 { MACRO_FPR
, MACRO_EXP
, MACRO_OPIR
, MACRO_EOA
} },
685 { "stg", emit_loadstore
, "stg",
686 { MACRO_FPR
, MACRO_EXP
, MACRO_OPIR
, MACRO_EOA
} },
687 { "sts", emit_loadstore
, "sts",
688 { MACRO_FPR
, MACRO_EXP
, MACRO_OPIR
, MACRO_EOA
} },
689 { "stt", emit_loadstore
, "stt",
690 { MACRO_FPR
, MACRO_EXP
, MACRO_OPIR
, MACRO_EOA
} },
692 { "stb", emit_stX
, (PTR
) 0,
693 { MACRO_IR
, MACRO_EXP
, MACRO_OPIR
, MACRO_EOA
} },
694 { "stw", emit_stX
, (PTR
) 1,
695 { MACRO_IR
, MACRO_EXP
, MACRO_OPIR
, MACRO_EOA
} },
696 { "ustw", emit_ustX
, (PTR
) 1,
697 { MACRO_IR
, MACRO_EXP
, MACRO_OPIR
, MACRO_EOA
} },
698 { "ustl", emit_ustX
, (PTR
) 2,
699 { MACRO_IR
, MACRO_EXP
, MACRO_OPIR
, MACRO_EOA
} },
700 { "ustq", emit_ustX
, (PTR
) 3,
701 { MACRO_IR
, MACRO_EXP
, MACRO_OPIR
, MACRO_EOA
} },
703 /* Arithmetic macros */
705 { "absl" emit_absl
, 1, { IR
} },
706 { "absl" emit_absl
, 2, { IR
, IR
} },
707 { "absl" emit_absl
, 2, { EXP
, IR
} },
708 { "absq" emit_absq
, 1, { IR
} },
709 { "absq" emit_absq
, 2, { IR
, IR
} },
710 { "absq" emit_absq
, 2, { EXP
, IR
} },
713 { "sextb", emit_sextX
, (PTR
) 0,
714 { MACRO_IR
, MACRO_IR
, MACRO_EOA
,
716 /* MACRO_EXP, MACRO_IR, MACRO_EOA */ } },
717 { "sextw", emit_sextX
, (PTR
) 1,
718 { MACRO_IR
, MACRO_IR
, MACRO_EOA
,
720 /* MACRO_EXP, MACRO_IR, MACRO_EOA */ } },
722 { "divl", emit_division
, "__divl",
723 { MACRO_IR
, MACRO_IR
, MACRO_IR
, MACRO_EOA
,
724 MACRO_IR
, MACRO_IR
, MACRO_EOA
,
725 /* MACRO_IR, MACRO_EXP, MACRO_IR, MACRO_EOA,
726 MACRO_IR, MACRO_EXP, MACRO_EOA */ } },
727 { "divlu", emit_division
, "__divlu",
728 { MACRO_IR
, MACRO_IR
, MACRO_IR
, MACRO_EOA
,
729 MACRO_IR
, MACRO_IR
, MACRO_EOA
,
730 /* MACRO_IR, MACRO_EXP, MACRO_IR, MACRO_EOA,
731 MACRO_IR, MACRO_EXP, MACRO_EOA */ } },
732 { "divq", emit_division
, "__divq",
733 { MACRO_IR
, MACRO_IR
, MACRO_IR
, MACRO_EOA
,
734 MACRO_IR
, MACRO_IR
, MACRO_EOA
,
735 /* MACRO_IR, MACRO_EXP, MACRO_IR, MACRO_EOA,
736 MACRO_IR, MACRO_EXP, MACRO_EOA */ } },
737 { "divqu", emit_division
, "__divqu",
738 { MACRO_IR
, MACRO_IR
, MACRO_IR
, MACRO_EOA
,
739 MACRO_IR
, MACRO_IR
, MACRO_EOA
,
740 /* MACRO_IR, MACRO_EXP, MACRO_IR, MACRO_EOA,
741 MACRO_IR, MACRO_EXP, MACRO_EOA */ } },
742 { "reml", emit_division
, "__reml",
743 { MACRO_IR
, MACRO_IR
, MACRO_IR
, MACRO_EOA
,
744 MACRO_IR
, MACRO_IR
, MACRO_EOA
,
745 /* MACRO_IR, MACRO_EXP, MACRO_IR, MACRO_EOA,
746 MACRO_IR, MACRO_EXP, MACRO_EOA */ } },
747 { "remlu", emit_division
, "__remlu",
748 { MACRO_IR
, MACRO_IR
, MACRO_IR
, MACRO_EOA
,
749 MACRO_IR
, MACRO_IR
, MACRO_EOA
,
750 /* MACRO_IR, MACRO_EXP, MACRO_IR, MACRO_EOA,
751 MACRO_IR, MACRO_EXP, MACRO_EOA */ } },
752 { "remq", emit_division
, "__remq",
753 { MACRO_IR
, MACRO_IR
, MACRO_IR
, MACRO_EOA
,
754 MACRO_IR
, MACRO_IR
, MACRO_EOA
,
755 /* MACRO_IR, MACRO_EXP, MACRO_IR, MACRO_EOA,
756 MACRO_IR, MACRO_EXP, MACRO_EOA */ } },
757 { "remqu", emit_division
, "__remqu",
758 { MACRO_IR
, MACRO_IR
, MACRO_IR
, MACRO_EOA
,
759 MACRO_IR
, MACRO_IR
, MACRO_EOA
,
760 /* MACRO_IR, MACRO_EXP, MACRO_IR, MACRO_EOA,
761 MACRO_IR, MACRO_EXP, MACRO_EOA */ } },
763 { "jsr", emit_jsrjmp
, "jsr",
764 { MACRO_PIR
, MACRO_EXP
, MACRO_EOA
,
765 MACRO_PIR
, MACRO_EOA
,
766 MACRO_IR
, MACRO_EXP
, MACRO_EOA
,
767 MACRO_EXP
, MACRO_EOA
} },
768 { "jmp", emit_jsrjmp
, "jmp",
769 { MACRO_PIR
, MACRO_EXP
, MACRO_EOA
,
770 MACRO_PIR
, MACRO_EOA
,
771 MACRO_IR
, MACRO_EXP
, MACRO_EOA
,
772 MACRO_EXP
, MACRO_EOA
} },
773 { "ret", emit_retjcr
, "ret",
774 { MACRO_IR
, MACRO_EXP
, MACRO_EOA
,
776 MACRO_PIR
, MACRO_EXP
, MACRO_EOA
,
777 MACRO_PIR
, MACRO_EOA
,
778 MACRO_EXP
, MACRO_EOA
,
780 { "jcr", emit_retjcr
, "jcr",
781 { MACRO_IR
, MACRO_EXP
, MACRO_EOA
,
783 MACRO_PIR
, MACRO_EXP
, MACRO_EOA
,
784 MACRO_PIR
, MACRO_EOA
,
785 MACRO_EXP
, MACRO_EOA
,
787 { "jsr_coroutine", emit_retjcr
, "jcr",
788 { MACRO_IR
, MACRO_EXP
, MACRO_EOA
,
790 MACRO_PIR
, MACRO_EXP
, MACRO_EOA
,
791 MACRO_PIR
, MACRO_EOA
,
792 MACRO_EXP
, MACRO_EOA
,
796 static const unsigned int alpha_num_macros
797 = sizeof (alpha_macros
) / sizeof (*alpha_macros
);
799 /* Public interface functions */
801 /* This function is called once, at assembler startup time. It sets
802 up all the tables, etc. that the MD part of the assembler will
803 need, that can be determined before arguments are parsed. */
810 /* Verify that X_op field is wide enough. */
814 assert (e
.X_op
== O_max
);
817 /* Create the opcode hash table. */
818 alpha_opcode_hash
= hash_new ();
819 for (i
= 0; i
< alpha_num_opcodes
;)
821 const char *name
, *retval
, *slash
;
823 name
= alpha_opcodes
[i
].name
;
824 retval
= hash_insert (alpha_opcode_hash
, name
, (PTR
) &alpha_opcodes
[i
]);
826 as_fatal (_("internal error: can't hash opcode `%s': %s"),
829 /* Some opcodes include modifiers of various sorts with a "/mod"
830 syntax, like the architecture manual suggests. However, for
831 use with gcc at least, we also need access to those same opcodes
834 if ((slash
= strchr (name
, '/')) != NULL
)
836 char *p
= xmalloc (strlen (name
));
837 memcpy (p
, name
, slash
- name
);
838 strcpy (p
+ (slash
- name
), slash
+ 1);
840 (void) hash_insert (alpha_opcode_hash
, p
, (PTR
) &alpha_opcodes
[i
]);
841 /* Ignore failures -- the opcode table does duplicate some
842 variants in different forms, like "hw_stq" and "hw_st/q". */
845 while (++i
< alpha_num_opcodes
846 && (alpha_opcodes
[i
].name
== name
847 || !strcmp (alpha_opcodes
[i
].name
, name
)))
851 /* Create the macro hash table. */
852 alpha_macro_hash
= hash_new ();
853 for (i
= 0; i
< alpha_num_macros
;)
855 const char *name
, *retval
;
857 name
= alpha_macros
[i
].name
;
858 retval
= hash_insert (alpha_macro_hash
, name
, (PTR
) &alpha_macros
[i
]);
860 as_fatal (_("internal error: can't hash macro `%s': %s"),
863 while (++i
< alpha_num_macros
864 && (alpha_macros
[i
].name
== name
865 || !strcmp (alpha_macros
[i
].name
, name
)))
869 /* Construct symbols for each of the registers. */
870 for (i
= 0; i
< 32; ++i
)
874 sprintf (name
, "$%d", i
);
875 alpha_register_table
[i
] = symbol_create (name
, reg_section
, i
,
882 sprintf (name
, "$f%d", i
- 32);
883 alpha_register_table
[i
] = symbol_create (name
, reg_section
, i
,
887 /* Create the special symbols and sections we'll be using. */
889 /* So .sbss will get used for tiny objects. */
890 bfd_set_gp_size (stdoutput
, g_switch_value
);
893 create_literal_section (".lita", &alpha_lita_section
, &alpha_lita_symbol
);
895 /* For handling the GP, create a symbol that won't be output in the
896 symbol table. We'll edit it out of relocs later. */
897 alpha_gp_symbol
= symbol_create ("<GP value>", alpha_lita_section
, 0x8000,
902 create_literal_section (".link", &alpha_link_section
, &alpha_link_symbol
);
908 segT sec
= subseg_new (".mdebug", (subsegT
) 0);
909 bfd_set_section_flags (stdoutput
, sec
, SEC_HAS_CONTENTS
| SEC_READONLY
);
910 bfd_set_section_alignment (stdoutput
, sec
, 3);
914 /* Create literal lookup hash table. */
915 alpha_literal_hash
= hash_new ();
917 subseg_set (text_section
, 0);
920 /* The public interface to the instruction assembler. */
926 char opname
[32]; /* Current maximum is 13. */
927 expressionS tok
[MAX_INSN_ARGS
];
931 /* Split off the opcode. */
932 opnamelen
= strspn (str
, "abcdefghijklmnopqrstuvwxyz_/46819");
933 trunclen
= (opnamelen
< sizeof (opname
) - 1
935 : sizeof (opname
) - 1);
936 memcpy (opname
, str
, trunclen
);
937 opname
[trunclen
] = '\0';
939 /* Tokenize the rest of the line. */
940 if ((ntok
= tokenize_arguments (str
+ opnamelen
, tok
, MAX_INSN_ARGS
)) < 0)
942 if (ntok
!= TOKENIZE_ERROR_REPORT
)
943 as_bad (_("syntax error"));
949 assemble_tokens (opname
, tok
, ntok
, alpha_macros_on
);
952 /* Round up a section's size to the appropriate boundary. */
955 md_section_align (seg
, size
)
959 int align
= bfd_get_section_alignment (stdoutput
, seg
);
960 valueT mask
= ((valueT
) 1 << align
) - 1;
962 return (size
+ mask
) & ~mask
;
965 /* Turn a string in input_line_pointer into a floating point constant
966 of type TYPE, and store the appropriate bytes in *LITP. The number
967 of LITTLENUMS emitted is stored in *SIZEP. An error message is
968 returned, or NULL on OK. */
970 /* Equal to MAX_PRECISION in atof-ieee.c. */
971 #define MAX_LITTLENUMS 6
973 extern char *vax_md_atof
PARAMS ((int, char *, int *));
976 md_atof (type
, litP
, sizeP
)
982 LITTLENUM_TYPE words
[MAX_LITTLENUMS
];
983 LITTLENUM_TYPE
*wordP
;
990 /* VAX md_atof doesn't like "G" for some reason. */
994 return vax_md_atof (type
, litP
, sizeP
);
1017 return _("Bad call to MD_ATOF()");
1019 t
= atof_ieee (input_line_pointer
, type
, words
);
1021 input_line_pointer
= t
;
1022 *sizeP
= prec
* sizeof (LITTLENUM_TYPE
);
1024 for (wordP
= words
+ prec
- 1; prec
--;)
1026 md_number_to_chars (litP
, (long) (*wordP
--), sizeof (LITTLENUM_TYPE
));
1027 litP
+= sizeof (LITTLENUM_TYPE
);
1033 /* Take care of the target-specific command-line options. */
1036 md_parse_option (c
, arg
)
1043 alpha_nofloats_on
= 1;
1047 alpha_addr32_on
= 1;
1055 g_switch_value
= atoi (arg
);
1060 const struct cpu_type
*p
;
1061 for (p
= cpu_types
; p
->name
; ++p
)
1062 if (strcmp (arg
, p
->name
) == 0)
1064 alpha_target_name
= p
->name
, alpha_target
= p
->flags
;
1067 as_warn (_("Unknown CPU identifier `%s'"), arg
);
1073 case '+': /* For g++. Hash any name > 63 chars long. */
1074 alpha_flag_hash_long_names
= 1;
1077 case 'H': /* Show new symbol after hash truncation */
1078 alpha_flag_show_after_trunc
= 1;
1081 case 'h': /* for gnu-c/vax compatibility. */
1086 alpha_flag_relax
= 1;
1091 alpha_flag_mdebug
= 1;
1093 case OPTION_NO_MDEBUG
:
1094 alpha_flag_mdebug
= 0;
1105 /* Print a description of the command-line options that we accept. */
1108 md_show_usage (stream
)
1113 -32addr treat addresses as 32-bit values\n\
1114 -F lack floating point instructions support\n\
1115 -mev4 | -mev45 | -mev5 | -mev56 | -mpca56 | -mev6 | -mev67 | -mev68 | -mall\n\
1116 specify variant of Alpha architecture\n\
1117 -m21064 | -m21066 | -m21164 | -m21164a | -m21164pc | -m21264 | -m21264a | -m21264b\n\
1118 these variants include PALcode opcodes\n"),
1123 -+ hash encode (don't truncate) names longer than 64 characters\n\
1124 -H show new symbol after hash truncation\n"),
1129 /* Decide from what point a pc-relative relocation is relative to,
1130 relative to the pc-relative fixup. Er, relatively speaking. */
1133 md_pcrel_from (fixP
)
1136 valueT addr
= fixP
->fx_where
+ fixP
->fx_frag
->fr_address
;
1137 switch (fixP
->fx_r_type
)
1139 case BFD_RELOC_23_PCREL_S2
:
1140 case BFD_RELOC_ALPHA_HINT
:
1141 case BFD_RELOC_ALPHA_BRSGP
:
1148 /* Attempt to simplify or even eliminate a fixup. The return value is
1149 ignored; perhaps it was once meaningful, but now it is historical.
1150 To indicate that a fixup has been eliminated, set fixP->fx_done.
1152 For ELF, here it is that we transform the GPDISP_HI16 reloc we used
1153 internally into the GPDISP reloc used externally. We had to do
1154 this so that we'd have the GPDISP_LO16 reloc as a tag to compute
1155 the distance to the "lda" instruction for setting the addend to
1159 md_apply_fix3 (fixP
, valP
, seg
)
1164 char * const fixpos
= fixP
->fx_frag
->fr_literal
+ fixP
->fx_where
;
1165 valueT value
= * valP
;
1166 unsigned image
, size
;
1168 switch (fixP
->fx_r_type
)
1170 /* The GPDISP relocations are processed internally with a symbol
1171 referring to the current function's section; we need to drop
1172 in a value which, when added to the address of the start of
1173 the function, gives the desired GP. */
1174 case BFD_RELOC_ALPHA_GPDISP_HI16
:
1176 fixS
*next
= fixP
->fx_next
;
1178 /* With user-specified !gpdisp relocations, we can be missing
1179 the matching LO16 reloc. We will have already issued an
1182 fixP
->fx_offset
= (next
->fx_frag
->fr_address
+ next
->fx_where
1183 - fixP
->fx_frag
->fr_address
- fixP
->fx_where
);
1185 value
= (value
- sign_extend_16 (value
)) >> 16;
1188 fixP
->fx_r_type
= BFD_RELOC_ALPHA_GPDISP
;
1192 case BFD_RELOC_ALPHA_GPDISP_LO16
:
1193 value
= sign_extend_16 (value
);
1194 fixP
->fx_offset
= 0;
1200 fixP
->fx_addsy
= section_symbol (seg
);
1201 md_number_to_chars (fixpos
, value
, 2);
1206 fixP
->fx_r_type
= BFD_RELOC_16_PCREL
;
1211 fixP
->fx_r_type
= BFD_RELOC_32_PCREL
;
1216 fixP
->fx_r_type
= BFD_RELOC_64_PCREL
;
1219 if (fixP
->fx_pcrel
== 0 && fixP
->fx_addsy
== 0)
1221 md_number_to_chars (fixpos
, value
, size
);
1227 case BFD_RELOC_GPREL32
:
1228 assert (fixP
->fx_subsy
== alpha_gp_symbol
);
1230 /* FIXME: inherited this obliviousness of `value' -- why? */
1231 md_number_to_chars (fixpos
, -alpha_gp_value
, 4);
1234 case BFD_RELOC_GPREL32
:
1236 case BFD_RELOC_GPREL16
:
1237 case BFD_RELOC_ALPHA_GPREL_HI16
:
1238 case BFD_RELOC_ALPHA_GPREL_LO16
:
1241 case BFD_RELOC_23_PCREL_S2
:
1242 if (fixP
->fx_pcrel
== 0 && fixP
->fx_addsy
== 0)
1244 image
= bfd_getl32 (fixpos
);
1245 image
= (image
& ~0x1FFFFF) | ((value
>> 2) & 0x1FFFFF);
1250 case BFD_RELOC_ALPHA_HINT
:
1251 if (fixP
->fx_pcrel
== 0 && fixP
->fx_addsy
== 0)
1253 image
= bfd_getl32 (fixpos
);
1254 image
= (image
& ~0x3FFF) | ((value
>> 2) & 0x3FFF);
1260 case BFD_RELOC_ALPHA_BRSGP
:
1263 case BFD_RELOC_ALPHA_TLSGD
:
1264 case BFD_RELOC_ALPHA_TLSLDM
:
1265 case BFD_RELOC_ALPHA_GOTDTPREL16
:
1266 case BFD_RELOC_ALPHA_DTPREL_HI16
:
1267 case BFD_RELOC_ALPHA_DTPREL_LO16
:
1268 case BFD_RELOC_ALPHA_DTPREL16
:
1269 case BFD_RELOC_ALPHA_GOTTPREL16
:
1270 case BFD_RELOC_ALPHA_TPREL_HI16
:
1271 case BFD_RELOC_ALPHA_TPREL_LO16
:
1272 case BFD_RELOC_ALPHA_TPREL16
:
1274 S_SET_THREAD_LOCAL (fixP
->fx_addsy
);
1279 case BFD_RELOC_ALPHA_LITERAL
:
1280 md_number_to_chars (fixpos
, value
, 2);
1283 case BFD_RELOC_ALPHA_ELF_LITERAL
:
1284 case BFD_RELOC_ALPHA_LITUSE
:
1285 case BFD_RELOC_ALPHA_LINKAGE
:
1286 case BFD_RELOC_ALPHA_CODEADDR
:
1289 case BFD_RELOC_VTABLE_INHERIT
:
1290 case BFD_RELOC_VTABLE_ENTRY
:
1295 const struct alpha_operand
*operand
;
1297 if ((int) fixP
->fx_r_type
>= 0)
1298 as_fatal (_("unhandled relocation type %s"),
1299 bfd_get_reloc_code_name (fixP
->fx_r_type
));
1301 assert (-(int) fixP
->fx_r_type
< (int) alpha_num_operands
);
1302 operand
= &alpha_operands
[-(int) fixP
->fx_r_type
];
1304 /* The rest of these fixups only exist internally during symbol
1305 resolution and have no representation in the object file.
1306 Therefore they must be completely resolved as constants. */
1308 if (fixP
->fx_addsy
!= 0
1309 && S_GET_SEGMENT (fixP
->fx_addsy
) != absolute_section
)
1310 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
1311 _("non-absolute expression in constant field"));
1313 image
= bfd_getl32 (fixpos
);
1314 image
= insert_operand (image
, operand
, (offsetT
) value
,
1315 fixP
->fx_file
, fixP
->fx_line
);
1320 if (fixP
->fx_addsy
!= 0 || fixP
->fx_pcrel
!= 0)
1324 as_warn_where (fixP
->fx_file
, fixP
->fx_line
,
1325 _("type %d reloc done?\n"), (int) fixP
->fx_r_type
);
1330 md_number_to_chars (fixpos
, image
, 4);
1336 /* Look for a register name in the given symbol. */
1339 md_undefined_symbol (name
)
1344 int is_float
= 0, num
;
1349 if (name
[1] == 'p' && name
[2] == '\0')
1350 return alpha_register_table
[AXP_REG_FP
];
1355 if (!ISDIGIT (*++name
))
1359 case '0': case '1': case '2': case '3': case '4':
1360 case '5': case '6': case '7': case '8': case '9':
1361 if (name
[1] == '\0')
1362 num
= name
[0] - '0';
1363 else if (name
[0] != '0' && ISDIGIT (name
[1]) && name
[2] == '\0')
1365 num
= (name
[0] - '0') * 10 + name
[1] - '0';
1372 if (!alpha_noat_on
&& (num
+ is_float
) == AXP_REG_AT
)
1373 as_warn (_("Used $at without \".set noat\""));
1374 return alpha_register_table
[num
+ is_float
];
1377 if (name
[1] == 't' && name
[2] == '\0')
1380 as_warn (_("Used $at without \".set noat\""));
1381 return alpha_register_table
[AXP_REG_AT
];
1386 if (name
[1] == 'p' && name
[2] == '\0')
1387 return alpha_register_table
[alpha_gp_register
];
1391 if (name
[1] == 'p' && name
[2] == '\0')
1392 return alpha_register_table
[AXP_REG_SP
];
1400 /* @@@ Magic ECOFF bits. */
1403 alpha_frob_ecoff_data ()
1406 /* $zero and $f31 are read-only */
1407 alpha_gprmask
&= ~1;
1408 alpha_fprmask
&= ~1;
1412 /* Hook to remember a recently defined label so that the auto-align
1413 code can adjust the symbol after we know what alignment will be
1417 alpha_define_label (sym
)
1420 alpha_insn_label
= sym
;
1423 /* Return true if we must always emit a reloc for a type and false if
1424 there is some hope of resolving it at assembly time. */
1427 alpha_force_relocation (f
)
1430 if (alpha_flag_relax
)
1433 switch (f
->fx_r_type
)
1435 case BFD_RELOC_ALPHA_GPDISP_HI16
:
1436 case BFD_RELOC_ALPHA_GPDISP_LO16
:
1437 case BFD_RELOC_ALPHA_GPDISP
:
1438 case BFD_RELOC_ALPHA_LITERAL
:
1439 case BFD_RELOC_ALPHA_ELF_LITERAL
:
1440 case BFD_RELOC_ALPHA_LITUSE
:
1441 case BFD_RELOC_GPREL16
:
1442 case BFD_RELOC_GPREL32
:
1443 case BFD_RELOC_ALPHA_GPREL_HI16
:
1444 case BFD_RELOC_ALPHA_GPREL_LO16
:
1445 case BFD_RELOC_ALPHA_LINKAGE
:
1446 case BFD_RELOC_ALPHA_CODEADDR
:
1447 case BFD_RELOC_ALPHA_BRSGP
:
1448 case BFD_RELOC_ALPHA_TLSGD
:
1449 case BFD_RELOC_ALPHA_TLSLDM
:
1450 case BFD_RELOC_ALPHA_GOTDTPREL16
:
1451 case BFD_RELOC_ALPHA_DTPREL_HI16
:
1452 case BFD_RELOC_ALPHA_DTPREL_LO16
:
1453 case BFD_RELOC_ALPHA_DTPREL16
:
1454 case BFD_RELOC_ALPHA_GOTTPREL16
:
1455 case BFD_RELOC_ALPHA_TPREL_HI16
:
1456 case BFD_RELOC_ALPHA_TPREL_LO16
:
1457 case BFD_RELOC_ALPHA_TPREL16
:
1464 return generic_force_reloc (f
);
1467 /* Return true if we can partially resolve a relocation now. */
1470 alpha_fix_adjustable (f
)
1473 /* Are there any relocation types for which we must generate a reloc
1474 but we can adjust the values contained within it? */
1475 switch (f
->fx_r_type
)
1477 case BFD_RELOC_ALPHA_GPDISP_HI16
:
1478 case BFD_RELOC_ALPHA_GPDISP_LO16
:
1479 case BFD_RELOC_ALPHA_GPDISP
:
1482 case BFD_RELOC_ALPHA_LITERAL
:
1483 case BFD_RELOC_ALPHA_ELF_LITERAL
:
1484 case BFD_RELOC_ALPHA_LITUSE
:
1485 case BFD_RELOC_ALPHA_LINKAGE
:
1486 case BFD_RELOC_ALPHA_CODEADDR
:
1489 case BFD_RELOC_VTABLE_ENTRY
:
1490 case BFD_RELOC_VTABLE_INHERIT
:
1493 case BFD_RELOC_GPREL16
:
1494 case BFD_RELOC_GPREL32
:
1495 case BFD_RELOC_ALPHA_GPREL_HI16
:
1496 case BFD_RELOC_ALPHA_GPREL_LO16
:
1497 case BFD_RELOC_23_PCREL_S2
:
1500 case BFD_RELOC_ALPHA_HINT
:
1503 case BFD_RELOC_ALPHA_TLSGD
:
1504 case BFD_RELOC_ALPHA_TLSLDM
:
1505 case BFD_RELOC_ALPHA_GOTDTPREL16
:
1506 case BFD_RELOC_ALPHA_DTPREL_HI16
:
1507 case BFD_RELOC_ALPHA_DTPREL_LO16
:
1508 case BFD_RELOC_ALPHA_DTPREL16
:
1509 case BFD_RELOC_ALPHA_GOTTPREL16
:
1510 case BFD_RELOC_ALPHA_TPREL_HI16
:
1511 case BFD_RELOC_ALPHA_TPREL_LO16
:
1512 case BFD_RELOC_ALPHA_TPREL16
:
1513 /* ??? No idea why we can't return a reference to .tbss+10, but
1514 we're preventing this in the other assemblers. Follow for now. */
1518 case BFD_RELOC_ALPHA_BRSGP
:
1519 /* If we have a BRSGP reloc to a local symbol, adjust it to BRADDR and
1520 let it get resolved at assembly time. */
1522 symbolS
*sym
= f
->fx_addsy
;
1526 if (generic_force_reloc (f
))
1529 switch (S_GET_OTHER (sym
) & STO_ALPHA_STD_GPLOAD
)
1531 case STO_ALPHA_NOPV
:
1533 case STO_ALPHA_STD_GPLOAD
:
1537 if (S_IS_LOCAL (sym
))
1540 name
= S_GET_NAME (sym
);
1541 as_bad_where (f
->fx_file
, f
->fx_line
,
1542 _("!samegp reloc against symbol without .prologue: %s"),
1546 f
->fx_r_type
= BFD_RELOC_23_PCREL_S2
;
1547 f
->fx_offset
+= offset
;
1558 /* Generate the BFD reloc to be stuck in the object file from the
1559 fixup used internally in the assembler. */
1562 tc_gen_reloc (sec
, fixp
)
1563 asection
*sec ATTRIBUTE_UNUSED
;
1568 reloc
= (arelent
*) xmalloc (sizeof (arelent
));
1569 reloc
->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
1570 *reloc
->sym_ptr_ptr
= symbol_get_bfdsym (fixp
->fx_addsy
);
1571 reloc
->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
1573 /* Make sure none of our internal relocations make it this far.
1574 They'd better have been fully resolved by this point. */
1575 assert ((int) fixp
->fx_r_type
> 0);
1577 reloc
->howto
= bfd_reloc_type_lookup (stdoutput
, fixp
->fx_r_type
);
1578 if (reloc
->howto
== NULL
)
1580 as_bad_where (fixp
->fx_file
, fixp
->fx_line
,
1581 _("cannot represent `%s' relocation in object file"),
1582 bfd_get_reloc_code_name (fixp
->fx_r_type
));
1586 if (!fixp
->fx_pcrel
!= !reloc
->howto
->pc_relative
)
1588 as_fatal (_("internal error? cannot generate `%s' relocation"),
1589 bfd_get_reloc_code_name (fixp
->fx_r_type
));
1591 assert (!fixp
->fx_pcrel
== !reloc
->howto
->pc_relative
);
1594 if (fixp
->fx_r_type
== BFD_RELOC_ALPHA_LITERAL
)
1596 /* Fake out bfd_perform_relocation. sigh. */
1597 reloc
->addend
= -alpha_gp_value
;
1602 reloc
->addend
= fixp
->fx_offset
;
1604 /* Ohhh, this is ugly. The problem is that if this is a local global
1605 symbol, the relocation will entirely be performed at link time, not
1606 at assembly time. bfd_perform_reloc doesn't know about this sort
1607 of thing, and as a result we need to fake it out here. */
1608 if ((S_IS_EXTERN (fixp
->fx_addsy
) || S_IS_WEAK (fixp
->fx_addsy
)
1609 || (S_GET_SEGMENT (fixp
->fx_addsy
)->flags
& SEC_MERGE
)
1610 || (S_GET_SEGMENT (fixp
->fx_addsy
)->flags
& SEC_THREAD_LOCAL
))
1611 && !S_IS_COMMON (fixp
->fx_addsy
))
1612 reloc
->addend
-= symbol_get_bfdsym (fixp
->fx_addsy
)->value
;
1619 /* Parse a register name off of the input_line and return a register
1620 number. Gets md_undefined_symbol above to do the register name
1623 Only called as a part of processing the ECOFF .frame directive. */
1626 tc_get_register (frame
)
1627 int frame ATTRIBUTE_UNUSED
;
1629 int framereg
= AXP_REG_SP
;
1632 if (*input_line_pointer
== '$')
1634 char *s
= input_line_pointer
;
1635 char c
= get_symbol_end ();
1636 symbolS
*sym
= md_undefined_symbol (s
);
1638 *strchr (s
, '\0') = c
;
1639 if (sym
&& (framereg
= S_GET_VALUE (sym
)) <= 31)
1642 as_warn (_("frame reg expected, using $%d."), framereg
);
1645 note_gpreg (framereg
);
1649 /* This is called before the symbol table is processed. In order to
1650 work with gcc when using mips-tfile, we must keep all local labels.
1651 However, in other cases, we want to discard them. If we were
1652 called with -g, but we didn't see any debugging information, it may
1653 mean that gcc is smuggling debugging information through to
1654 mips-tfile, in which case we must generate all local labels. */
1659 alpha_frob_file_before_adjust ()
1661 if (alpha_debug
!= 0
1662 && ! ecoff_debugging_seen
)
1663 flag_keep_locals
= 1;
1666 #endif /* OBJ_ECOFF */
1668 static struct alpha_reloc_tag
*
1669 get_alpha_reloc_tag (sequence
)
1672 char buffer
[ALPHA_RELOC_DIGITS
];
1673 struct alpha_reloc_tag
*info
;
1675 sprintf (buffer
, "!%ld", sequence
);
1677 info
= (struct alpha_reloc_tag
*) hash_find (alpha_literal_hash
, buffer
);
1680 size_t len
= strlen (buffer
);
1683 info
= (struct alpha_reloc_tag
*)
1684 xcalloc (sizeof (struct alpha_reloc_tag
) + len
, 1);
1686 info
->segment
= now_seg
;
1687 info
->sequence
= sequence
;
1688 strcpy (info
->string
, buffer
);
1689 errmsg
= hash_insert (alpha_literal_hash
, info
->string
, (PTR
) info
);
1697 /* Before the relocations are written, reorder them, so that user
1698 supplied !lituse relocations follow the appropriate !literal
1699 relocations, and similarly for !gpdisp relocations. */
1704 if (alpha_literal_hash
)
1705 bfd_map_over_sections (stdoutput
, alpha_adjust_relocs
, NULL
);
1709 alpha_adjust_relocs (abfd
, sec
, ptr
)
1710 bfd
*abfd ATTRIBUTE_UNUSED
;
1712 PTR ptr ATTRIBUTE_UNUSED
;
1714 segment_info_type
*seginfo
= seg_info (sec
);
1720 /* If seginfo is NULL, we did not create this section; don't do
1721 anything with it. By using a pointer to a pointer, we can update
1722 the links in place. */
1723 if (seginfo
== NULL
)
1726 /* If there are no relocations, skip the section. */
1727 if (! seginfo
->fix_root
)
1730 /* First rebuild the fixup chain without the explicit lituse and
1731 gpdisp_lo16 relocs. */
1732 prevP
= &seginfo
->fix_root
;
1733 for (fixp
= seginfo
->fix_root
; fixp
; fixp
= next
)
1735 next
= fixp
->fx_next
;
1736 fixp
->fx_next
= (fixS
*) 0;
1738 switch (fixp
->fx_r_type
)
1740 case BFD_RELOC_ALPHA_LITUSE
:
1741 if (fixp
->tc_fix_data
.info
->n_master
== 0)
1742 as_bad_where (fixp
->fx_file
, fixp
->fx_line
,
1743 _("No !literal!%ld was found"),
1744 fixp
->tc_fix_data
.info
->sequence
);
1746 if (fixp
->fx_offset
== LITUSE_ALPHA_TLSGD
)
1748 if (! fixp
->tc_fix_data
.info
->saw_tlsgd
)
1749 as_bad_where (fixp
->fx_file
, fixp
->fx_line
,
1750 _("No !tlsgd!%ld was found"),
1751 fixp
->tc_fix_data
.info
->sequence
);
1753 else if (fixp
->fx_offset
== LITUSE_ALPHA_TLSLDM
)
1755 if (! fixp
->tc_fix_data
.info
->saw_tlsldm
)
1756 as_bad_where (fixp
->fx_file
, fixp
->fx_line
,
1757 _("No !tlsldm!%ld was found"),
1758 fixp
->tc_fix_data
.info
->sequence
);
1763 case BFD_RELOC_ALPHA_GPDISP_LO16
:
1764 if (fixp
->tc_fix_data
.info
->n_master
== 0)
1765 as_bad_where (fixp
->fx_file
, fixp
->fx_line
,
1766 _("No ldah !gpdisp!%ld was found"),
1767 fixp
->tc_fix_data
.info
->sequence
);
1770 case BFD_RELOC_ALPHA_ELF_LITERAL
:
1771 if (fixp
->tc_fix_data
.info
1772 && (fixp
->tc_fix_data
.info
->saw_tlsgd
1773 || fixp
->tc_fix_data
.info
->saw_tlsldm
))
1779 prevP
= &fixp
->fx_next
;
1784 /* Go back and re-chain dependent relocations. They are currently
1785 linked through the next_reloc field in reverse order, so as we
1786 go through the next_reloc chain, we effectively reverse the chain
1789 Except if there is more than one !literal for a given sequence
1790 number. In that case, the programmer and/or compiler is not sure
1791 how control flows from literal to lituse, and we can't be sure to
1792 get the relaxation correct.
1794 ??? Well, actually we could, if there are enough lituses such that
1795 we can make each literal have at least one of each lituse type
1796 present. Not implemented.
1798 Also suppress the optimization if the !literals/!lituses are spread
1799 in different segments. This can happen with "intersting" uses of
1800 inline assembly; examples are present in the Linux kernel semaphores. */
1802 for (fixp
= seginfo
->fix_root
; fixp
; fixp
= next
)
1804 next
= fixp
->fx_next
;
1805 switch (fixp
->fx_r_type
)
1807 case BFD_RELOC_ALPHA_TLSGD
:
1808 case BFD_RELOC_ALPHA_TLSLDM
:
1809 if (!fixp
->tc_fix_data
.info
)
1811 if (fixp
->tc_fix_data
.info
->n_master
== 0)
1813 else if (fixp
->tc_fix_data
.info
->n_master
> 1)
1815 as_bad_where (fixp
->fx_file
, fixp
->fx_line
,
1816 _("too many !literal!%ld for %s"),
1817 fixp
->tc_fix_data
.info
->sequence
,
1818 (fixp
->fx_r_type
== BFD_RELOC_ALPHA_TLSGD
1819 ? "!tlsgd" : "!tlsldm"));
1823 fixp
->tc_fix_data
.info
->master
->fx_next
= fixp
->fx_next
;
1824 fixp
->fx_next
= fixp
->tc_fix_data
.info
->master
;
1825 fixp
= fixp
->fx_next
;
1828 case BFD_RELOC_ALPHA_ELF_LITERAL
:
1829 if (fixp
->tc_fix_data
.info
1830 && fixp
->tc_fix_data
.info
->n_master
== 1
1831 && ! fixp
->tc_fix_data
.info
->multi_section_p
)
1833 for (slave
= fixp
->tc_fix_data
.info
->slaves
;
1834 slave
!= (fixS
*) 0;
1835 slave
= slave
->tc_fix_data
.next_reloc
)
1837 slave
->fx_next
= fixp
->fx_next
;
1838 fixp
->fx_next
= slave
;
1843 case BFD_RELOC_ALPHA_GPDISP_HI16
:
1844 if (fixp
->tc_fix_data
.info
->n_slaves
== 0)
1845 as_bad_where (fixp
->fx_file
, fixp
->fx_line
,
1846 _("No lda !gpdisp!%ld was found"),
1847 fixp
->tc_fix_data
.info
->sequence
);
1850 slave
= fixp
->tc_fix_data
.info
->slaves
;
1851 slave
->fx_next
= next
;
1852 fixp
->fx_next
= slave
;
1864 debug_exp (tok
, ntok
)
1870 fprintf (stderr
, "debug_exp: %d tokens", ntok
);
1871 for (i
= 0; i
< ntok
; i
++)
1873 expressionS
*t
= &tok
[i
];
1878 default: name
= "unknown"; break;
1879 case O_illegal
: name
= "O_illegal"; break;
1880 case O_absent
: name
= "O_absent"; break;
1881 case O_constant
: name
= "O_constant"; break;
1882 case O_symbol
: name
= "O_symbol"; break;
1883 case O_symbol_rva
: name
= "O_symbol_rva"; break;
1884 case O_register
: name
= "O_register"; break;
1885 case O_big
: name
= "O_big"; break;
1886 case O_uminus
: name
= "O_uminus"; break;
1887 case O_bit_not
: name
= "O_bit_not"; break;
1888 case O_logical_not
: name
= "O_logical_not"; break;
1889 case O_multiply
: name
= "O_multiply"; break;
1890 case O_divide
: name
= "O_divide"; break;
1891 case O_modulus
: name
= "O_modulus"; break;
1892 case O_left_shift
: name
= "O_left_shift"; break;
1893 case O_right_shift
: name
= "O_right_shift"; break;
1894 case O_bit_inclusive_or
: name
= "O_bit_inclusive_or"; break;
1895 case O_bit_or_not
: name
= "O_bit_or_not"; break;
1896 case O_bit_exclusive_or
: name
= "O_bit_exclusive_or"; break;
1897 case O_bit_and
: name
= "O_bit_and"; break;
1898 case O_add
: name
= "O_add"; break;
1899 case O_subtract
: name
= "O_subtract"; break;
1900 case O_eq
: name
= "O_eq"; break;
1901 case O_ne
: name
= "O_ne"; break;
1902 case O_lt
: name
= "O_lt"; break;
1903 case O_le
: name
= "O_le"; break;
1904 case O_ge
: name
= "O_ge"; break;
1905 case O_gt
: name
= "O_gt"; break;
1906 case O_logical_and
: name
= "O_logical_and"; break;
1907 case O_logical_or
: name
= "O_logical_or"; break;
1908 case O_index
: name
= "O_index"; break;
1909 case O_pregister
: name
= "O_pregister"; break;
1910 case O_cpregister
: name
= "O_cpregister"; break;
1911 case O_literal
: name
= "O_literal"; break;
1912 case O_lituse_addr
: name
= "O_lituse_addr"; break;
1913 case O_lituse_base
: name
= "O_lituse_base"; break;
1914 case O_lituse_bytoff
: name
= "O_lituse_bytoff"; break;
1915 case O_lituse_jsr
: name
= "O_lituse_jsr"; break;
1916 case O_lituse_tlsgd
: name
= "O_lituse_tlsgd"; break;
1917 case O_lituse_tlsldm
: name
= "O_lituse_tlsldm"; break;
1918 case O_gpdisp
: name
= "O_gpdisp"; break;
1919 case O_gprelhigh
: name
= "O_gprelhigh"; break;
1920 case O_gprellow
: name
= "O_gprellow"; break;
1921 case O_gprel
: name
= "O_gprel"; break;
1922 case O_samegp
: name
= "O_samegp"; break;
1923 case O_tlsgd
: name
= "O_tlsgd"; break;
1924 case O_tlsldm
: name
= "O_tlsldm"; break;
1925 case O_gotdtprel
: name
= "O_gotdtprel"; break;
1926 case O_dtprelhi
: name
= "O_dtprelhi"; break;
1927 case O_dtprello
: name
= "O_dtprello"; break;
1928 case O_dtprel
: name
= "O_dtprel"; break;
1929 case O_gottprel
: name
= "O_gottprel"; break;
1930 case O_tprelhi
: name
= "O_tprelhi"; break;
1931 case O_tprello
: name
= "O_tprello"; break;
1932 case O_tprel
: name
= "O_tprel"; break;
1935 fprintf (stderr
, ", %s(%s, %s, %d)", name
,
1936 (t
->X_add_symbol
) ? S_GET_NAME (t
->X_add_symbol
) : "--",
1937 (t
->X_op_symbol
) ? S_GET_NAME (t
->X_op_symbol
) : "--",
1938 (int) t
->X_add_number
);
1940 fprintf (stderr
, "\n");
1945 /* Parse the arguments to an opcode. */
1948 tokenize_arguments (str
, tok
, ntok
)
1953 expressionS
*end_tok
= tok
+ ntok
;
1954 char *old_input_line_pointer
;
1955 int saw_comma
= 0, saw_arg
= 0;
1957 expressionS
*orig_tok
= tok
;
1961 const struct alpha_reloc_op_tag
*r
;
1964 int reloc_found_p
= 0;
1967 memset (tok
, 0, sizeof (*tok
) * ntok
);
1969 /* Save and restore input_line_pointer around this function. */
1970 old_input_line_pointer
= input_line_pointer
;
1971 input_line_pointer
= str
;
1974 /* ??? Wrest control of ! away from the regular expression parser. */
1975 is_end_of_line
[(unsigned char) '!'] = 1;
1978 while (tok
< end_tok
&& *input_line_pointer
)
1981 switch (*input_line_pointer
)
1988 /* A relocation operand can be placed after the normal operand on an
1989 assembly language statement, and has the following form:
1990 !relocation_type!sequence_number. */
1993 /* Only support one relocation op per insn. */
1994 as_bad (_("More than one relocation op per insn"));
2001 ++input_line_pointer
;
2003 p
= input_line_pointer
;
2004 c
= get_symbol_end ();
2006 /* Parse !relocation_type. */
2007 len
= input_line_pointer
- p
;
2010 as_bad (_("No relocation operand"));
2014 r
= &alpha_reloc_op
[0];
2015 for (i
= alpha_num_reloc_op
- 1; i
>= 0; i
--, r
++)
2016 if (len
== r
->length
&& memcmp (p
, r
->name
, len
) == 0)
2020 as_bad (_("Unknown relocation operand: !%s"), p
);
2024 *input_line_pointer
= c
;
2026 if (*input_line_pointer
!= '!')
2030 as_bad (_("no sequence number after !%s"), p
);
2034 tok
->X_add_number
= 0;
2040 as_bad (_("!%s does not use a sequence number"), p
);
2044 input_line_pointer
++;
2046 /* Parse !sequence_number. */
2048 if (tok
->X_op
!= O_constant
|| tok
->X_add_number
<= 0)
2050 as_bad (_("Bad sequence number: !%s!%s"),
2051 r
->name
, input_line_pointer
);
2060 #endif /* RELOC_OP_P */
2063 ++input_line_pointer
;
2064 if (saw_comma
|| !saw_arg
)
2071 char *hold
= input_line_pointer
++;
2073 /* First try for parenthesized register ... */
2075 if (*input_line_pointer
== ')' && tok
->X_op
== O_register
)
2077 tok
->X_op
= (saw_comma
? O_cpregister
: O_pregister
);
2080 ++input_line_pointer
;
2085 /* ... then fall through to plain expression. */
2086 input_line_pointer
= hold
;
2090 if (saw_arg
&& !saw_comma
)
2094 if (tok
->X_op
== O_illegal
|| tok
->X_op
== O_absent
)
2107 input_line_pointer
= old_input_line_pointer
;
2110 debug_exp (orig_tok
, ntok
- (end_tok
- tok
));
2113 is_end_of_line
[(unsigned char) '!'] = 0;
2116 return ntok
- (end_tok
- tok
);
2120 is_end_of_line
[(unsigned char) '!'] = 0;
2122 input_line_pointer
= old_input_line_pointer
;
2123 return TOKENIZE_ERROR
;
2127 is_end_of_line
[(unsigned char) '!'] = 0;
2129 input_line_pointer
= old_input_line_pointer
;
2130 return TOKENIZE_ERROR_REPORT
;
2133 /* Search forward through all variants of an opcode looking for a
2136 static const struct alpha_opcode
*
2137 find_opcode_match (first_opcode
, tok
, pntok
, pcpumatch
)
2138 const struct alpha_opcode
*first_opcode
;
2139 const expressionS
*tok
;
2143 const struct alpha_opcode
*opcode
= first_opcode
;
2145 int got_cpu_match
= 0;
2149 const unsigned char *opidx
;
2152 /* Don't match opcodes that don't exist on this architecture. */
2153 if (!(opcode
->flags
& alpha_target
))
2158 for (opidx
= opcode
->operands
; *opidx
; ++opidx
)
2160 const struct alpha_operand
*operand
= &alpha_operands
[*opidx
];
2162 /* Only take input from real operands. */
2163 if (operand
->flags
& AXP_OPERAND_FAKE
)
2166 /* When we expect input, make sure we have it. */
2169 if ((operand
->flags
& AXP_OPERAND_OPTIONAL_MASK
) == 0)
2174 /* Match operand type with expression type. */
2175 switch (operand
->flags
& AXP_OPERAND_TYPECHECK_MASK
)
2177 case AXP_OPERAND_IR
:
2178 if (tok
[tokidx
].X_op
!= O_register
2179 || !is_ir_num (tok
[tokidx
].X_add_number
))
2182 case AXP_OPERAND_FPR
:
2183 if (tok
[tokidx
].X_op
!= O_register
2184 || !is_fpr_num (tok
[tokidx
].X_add_number
))
2187 case AXP_OPERAND_IR
| AXP_OPERAND_PARENS
:
2188 if (tok
[tokidx
].X_op
!= O_pregister
2189 || !is_ir_num (tok
[tokidx
].X_add_number
))
2192 case AXP_OPERAND_IR
| AXP_OPERAND_PARENS
| AXP_OPERAND_COMMA
:
2193 if (tok
[tokidx
].X_op
!= O_cpregister
2194 || !is_ir_num (tok
[tokidx
].X_add_number
))
2198 case AXP_OPERAND_RELATIVE
:
2199 case AXP_OPERAND_SIGNED
:
2200 case AXP_OPERAND_UNSIGNED
:
2201 switch (tok
[tokidx
].X_op
)
2216 /* Everything else should have been fake. */
2222 /* Possible match -- did we use all of our input? */
2231 while (++opcode
- alpha_opcodes
< (int) alpha_num_opcodes
2232 && !strcmp (opcode
->name
, first_opcode
->name
));
2235 *pcpumatch
= got_cpu_match
;
2240 /* Search forward through all variants of a macro looking for a syntax
2243 static const struct alpha_macro
*
2244 find_macro_match (first_macro
, tok
, pntok
)
2245 const struct alpha_macro
*first_macro
;
2246 const expressionS
*tok
;
2249 const struct alpha_macro
*macro
= first_macro
;
2254 const enum alpha_macro_arg
*arg
= macro
->argsets
;
2268 /* Index register. */
2270 if (tokidx
>= ntok
|| tok
[tokidx
].X_op
!= O_register
2271 || !is_ir_num (tok
[tokidx
].X_add_number
))
2276 /* Parenthesized index register. */
2278 if (tokidx
>= ntok
|| tok
[tokidx
].X_op
!= O_pregister
2279 || !is_ir_num (tok
[tokidx
].X_add_number
))
2284 /* Optional parenthesized index register. */
2286 if (tokidx
< ntok
&& tok
[tokidx
].X_op
== O_pregister
2287 && is_ir_num (tok
[tokidx
].X_add_number
))
2291 /* Leading comma with a parenthesized index register. */
2293 if (tokidx
>= ntok
|| tok
[tokidx
].X_op
!= O_cpregister
2294 || !is_ir_num (tok
[tokidx
].X_add_number
))
2299 /* Floating point register. */
2301 if (tokidx
>= ntok
|| tok
[tokidx
].X_op
!= O_register
2302 || !is_fpr_num (tok
[tokidx
].X_add_number
))
2307 /* Normal expression. */
2311 switch (tok
[tokidx
].X_op
)
2320 case O_lituse_bytoff
:
2336 while (*arg
!= MACRO_EOA
)
2344 while (++macro
- alpha_macros
< (int) alpha_num_macros
2345 && !strcmp (macro
->name
, first_macro
->name
));
2350 /* Insert an operand value into an instruction. */
2353 insert_operand (insn
, operand
, val
, file
, line
)
2355 const struct alpha_operand
*operand
;
2360 if (operand
->bits
!= 32 && !(operand
->flags
& AXP_OPERAND_NOOVERFLOW
))
2364 if (operand
->flags
& AXP_OPERAND_SIGNED
)
2366 max
= (1 << (operand
->bits
- 1)) - 1;
2367 min
= -(1 << (operand
->bits
- 1));
2371 max
= (1 << operand
->bits
) - 1;
2375 if (val
< min
|| val
> max
)
2376 as_warn_value_out_of_range (_("operand"), val
, min
, max
, file
, line
);
2379 if (operand
->insert
)
2381 const char *errmsg
= NULL
;
2383 insn
= (*operand
->insert
) (insn
, val
, &errmsg
);
2388 insn
|= ((val
& ((1 << operand
->bits
) - 1)) << operand
->shift
);
2393 /* Turn an opcode description and a set of arguments into
2394 an instruction and a fixup. */
2397 assemble_insn (opcode
, tok
, ntok
, insn
, reloc
)
2398 const struct alpha_opcode
*opcode
;
2399 const expressionS
*tok
;
2401 struct alpha_insn
*insn
;
2402 bfd_reloc_code_real_type reloc
;
2404 const struct alpha_operand
*reloc_operand
= NULL
;
2405 const expressionS
*reloc_exp
= NULL
;
2406 const unsigned char *argidx
;
2410 memset (insn
, 0, sizeof (*insn
));
2411 image
= opcode
->opcode
;
2413 for (argidx
= opcode
->operands
; *argidx
; ++argidx
)
2415 const struct alpha_operand
*operand
= &alpha_operands
[*argidx
];
2416 const expressionS
*t
= (const expressionS
*) 0;
2418 if (operand
->flags
& AXP_OPERAND_FAKE
)
2420 /* fake operands take no value and generate no fixup */
2421 image
= insert_operand (image
, operand
, 0, NULL
, 0);
2427 switch (operand
->flags
& AXP_OPERAND_OPTIONAL_MASK
)
2429 case AXP_OPERAND_DEFAULT_FIRST
:
2432 case AXP_OPERAND_DEFAULT_SECOND
:
2435 case AXP_OPERAND_DEFAULT_ZERO
:
2437 static expressionS zero_exp
;
2439 zero_exp
.X_op
= O_constant
;
2440 zero_exp
.X_unsigned
= 1;
2455 image
= insert_operand (image
, operand
, regno (t
->X_add_number
),
2460 image
= insert_operand (image
, operand
, t
->X_add_number
, NULL
, 0);
2461 assert (reloc_operand
== NULL
);
2462 reloc_operand
= operand
;
2467 /* This is only 0 for fields that should contain registers,
2468 which means this pattern shouldn't have matched. */
2469 if (operand
->default_reloc
== 0)
2472 /* There is one special case for which an insn receives two
2473 relocations, and thus the user-supplied reloc does not
2474 override the operand reloc. */
2475 if (operand
->default_reloc
== BFD_RELOC_ALPHA_HINT
)
2477 struct alpha_fixup
*fixup
;
2479 if (insn
->nfixups
>= MAX_INSN_FIXUPS
)
2480 as_fatal (_("too many fixups"));
2482 fixup
= &insn
->fixups
[insn
->nfixups
++];
2484 fixup
->reloc
= BFD_RELOC_ALPHA_HINT
;
2488 if (reloc
== BFD_RELOC_UNUSED
)
2489 reloc
= operand
->default_reloc
;
2491 assert (reloc_operand
== NULL
);
2492 reloc_operand
= operand
;
2499 if (reloc
!= BFD_RELOC_UNUSED
)
2501 struct alpha_fixup
*fixup
;
2503 if (insn
->nfixups
>= MAX_INSN_FIXUPS
)
2504 as_fatal (_("too many fixups"));
2506 /* ??? My but this is hacky. But the OSF/1 assembler uses the same
2507 relocation tag for both ldah and lda with gpdisp. Choose the
2508 correct internal relocation based on the opcode. */
2509 if (reloc
== BFD_RELOC_ALPHA_GPDISP
)
2511 if (strcmp (opcode
->name
, "ldah") == 0)
2512 reloc
= BFD_RELOC_ALPHA_GPDISP_HI16
;
2513 else if (strcmp (opcode
->name
, "lda") == 0)
2514 reloc
= BFD_RELOC_ALPHA_GPDISP_LO16
;
2516 as_bad (_("invalid relocation for instruction"));
2519 /* If this is a real relocation (as opposed to a lituse hint), then
2520 the relocation width should match the operand width. */
2521 else if (reloc
< BFD_RELOC_UNUSED
)
2523 reloc_howto_type
*reloc_howto
2524 = bfd_reloc_type_lookup (stdoutput
, reloc
);
2525 if (reloc_howto
->bitsize
!= reloc_operand
->bits
)
2527 as_bad (_("invalid relocation for field"));
2532 fixup
= &insn
->fixups
[insn
->nfixups
++];
2534 fixup
->exp
= *reloc_exp
;
2536 fixup
->exp
.X_op
= O_absent
;
2537 fixup
->reloc
= reloc
;
2543 /* Actually output an instruction with its fixup. */
2547 struct alpha_insn
*insn
;
2552 /* Take care of alignment duties. */
2553 if (alpha_auto_align_on
&& alpha_current_align
< 2)
2554 alpha_align (2, (char *) NULL
, alpha_insn_label
, 0);
2555 if (alpha_current_align
> 2)
2556 alpha_current_align
= 2;
2557 alpha_insn_label
= NULL
;
2559 /* Write out the instruction. */
2561 md_number_to_chars (f
, insn
->insn
, 4);
2564 dwarf2_emit_insn (4);
2567 /* Apply the fixups in order. */
2568 for (i
= 0; i
< insn
->nfixups
; ++i
)
2570 const struct alpha_operand
*operand
= (const struct alpha_operand
*) 0;
2571 struct alpha_fixup
*fixup
= &insn
->fixups
[i
];
2572 struct alpha_reloc_tag
*info
= NULL
;
2576 /* Some fixups are only used internally and so have no howto. */
2577 if ((int) fixup
->reloc
< 0)
2579 operand
= &alpha_operands
[-(int) fixup
->reloc
];
2581 pcrel
= ((operand
->flags
& AXP_OPERAND_RELATIVE
) != 0);
2583 else if (fixup
->reloc
> BFD_RELOC_UNUSED
2584 || fixup
->reloc
== BFD_RELOC_ALPHA_GPDISP_HI16
2585 || fixup
->reloc
== BFD_RELOC_ALPHA_GPDISP_LO16
)
2592 reloc_howto_type
*reloc_howto
2593 = bfd_reloc_type_lookup (stdoutput
, fixup
->reloc
);
2594 assert (reloc_howto
);
2596 size
= bfd_get_reloc_size (reloc_howto
);
2597 assert (size
>= 1 && size
<= 4);
2599 pcrel
= reloc_howto
->pc_relative
;
2602 fixP
= fix_new_exp (frag_now
, f
- frag_now
->fr_literal
, size
,
2603 &fixup
->exp
, pcrel
, fixup
->reloc
);
2605 /* Turn off complaints that the addend is too large for some fixups,
2606 and copy in the sequence number for the explicit relocations. */
2607 switch (fixup
->reloc
)
2609 case BFD_RELOC_ALPHA_HINT
:
2610 case BFD_RELOC_GPREL32
:
2611 case BFD_RELOC_GPREL16
:
2612 case BFD_RELOC_ALPHA_GPREL_HI16
:
2613 case BFD_RELOC_ALPHA_GPREL_LO16
:
2614 case BFD_RELOC_ALPHA_GOTDTPREL16
:
2615 case BFD_RELOC_ALPHA_DTPREL_HI16
:
2616 case BFD_RELOC_ALPHA_DTPREL_LO16
:
2617 case BFD_RELOC_ALPHA_DTPREL16
:
2618 case BFD_RELOC_ALPHA_GOTTPREL16
:
2619 case BFD_RELOC_ALPHA_TPREL_HI16
:
2620 case BFD_RELOC_ALPHA_TPREL_LO16
:
2621 case BFD_RELOC_ALPHA_TPREL16
:
2622 fixP
->fx_no_overflow
= 1;
2625 case BFD_RELOC_ALPHA_GPDISP_HI16
:
2626 fixP
->fx_no_overflow
= 1;
2627 fixP
->fx_addsy
= section_symbol (now_seg
);
2628 fixP
->fx_offset
= 0;
2630 info
= get_alpha_reloc_tag (insn
->sequence
);
2631 if (++info
->n_master
> 1)
2632 as_bad (_("too many ldah insns for !gpdisp!%ld"), insn
->sequence
);
2633 if (info
->segment
!= now_seg
)
2634 as_bad (_("both insns for !gpdisp!%ld must be in the same section"),
2636 fixP
->tc_fix_data
.info
= info
;
2639 case BFD_RELOC_ALPHA_GPDISP_LO16
:
2640 fixP
->fx_no_overflow
= 1;
2642 info
= get_alpha_reloc_tag (insn
->sequence
);
2643 if (++info
->n_slaves
> 1)
2644 as_bad (_("too many lda insns for !gpdisp!%ld"), insn
->sequence
);
2645 if (info
->segment
!= now_seg
)
2646 as_bad (_("both insns for !gpdisp!%ld must be in the same section"),
2648 fixP
->tc_fix_data
.info
= info
;
2649 info
->slaves
= fixP
;
2652 case BFD_RELOC_ALPHA_LITERAL
:
2653 case BFD_RELOC_ALPHA_ELF_LITERAL
:
2654 fixP
->fx_no_overflow
= 1;
2656 if (insn
->sequence
== 0)
2658 info
= get_alpha_reloc_tag (insn
->sequence
);
2659 info
->master
= fixP
;
2661 if (info
->segment
!= now_seg
)
2662 info
->multi_section_p
= 1;
2663 fixP
->tc_fix_data
.info
= info
;
2667 case DUMMY_RELOC_LITUSE_ADDR
:
2668 fixP
->fx_offset
= LITUSE_ALPHA_ADDR
;
2670 case DUMMY_RELOC_LITUSE_BASE
:
2671 fixP
->fx_offset
= LITUSE_ALPHA_BASE
;
2673 case DUMMY_RELOC_LITUSE_BYTOFF
:
2674 fixP
->fx_offset
= LITUSE_ALPHA_BYTOFF
;
2676 case DUMMY_RELOC_LITUSE_JSR
:
2677 fixP
->fx_offset
= LITUSE_ALPHA_JSR
;
2679 case DUMMY_RELOC_LITUSE_TLSGD
:
2680 fixP
->fx_offset
= LITUSE_ALPHA_TLSGD
;
2682 case DUMMY_RELOC_LITUSE_TLSLDM
:
2683 fixP
->fx_offset
= LITUSE_ALPHA_TLSLDM
;
2686 fixP
->fx_addsy
= section_symbol (now_seg
);
2687 fixP
->fx_r_type
= BFD_RELOC_ALPHA_LITUSE
;
2689 info
= get_alpha_reloc_tag (insn
->sequence
);
2690 if (fixup
->reloc
== DUMMY_RELOC_LITUSE_TLSGD
)
2691 info
->saw_lu_tlsgd
= 1;
2692 else if (fixup
->reloc
== DUMMY_RELOC_LITUSE_TLSLDM
)
2693 info
->saw_lu_tlsldm
= 1;
2694 if (++info
->n_slaves
> 1)
2696 if (info
->saw_lu_tlsgd
)
2697 as_bad (_("too many lituse insns for !lituse_tlsgd!%ld"),
2699 else if (info
->saw_lu_tlsldm
)
2700 as_bad (_("too many lituse insns for !lituse_tlsldm!%ld"),
2703 fixP
->tc_fix_data
.info
= info
;
2704 fixP
->tc_fix_data
.next_reloc
= info
->slaves
;
2705 info
->slaves
= fixP
;
2706 if (info
->segment
!= now_seg
)
2707 info
->multi_section_p
= 1;
2710 case BFD_RELOC_ALPHA_TLSGD
:
2711 fixP
->fx_no_overflow
= 1;
2713 if (insn
->sequence
== 0)
2715 info
= get_alpha_reloc_tag (insn
->sequence
);
2716 if (info
->saw_tlsgd
)
2717 as_bad (_("duplicate !tlsgd!%ld"), insn
->sequence
);
2718 else if (info
->saw_tlsldm
)
2719 as_bad (_("sequence number in use for !tlsldm!%ld"),
2722 info
->saw_tlsgd
= 1;
2723 fixP
->tc_fix_data
.info
= info
;
2726 case BFD_RELOC_ALPHA_TLSLDM
:
2727 fixP
->fx_no_overflow
= 1;
2729 if (insn
->sequence
== 0)
2731 info
= get_alpha_reloc_tag (insn
->sequence
);
2732 if (info
->saw_tlsldm
)
2733 as_bad (_("duplicate !tlsldm!%ld"), insn
->sequence
);
2734 else if (info
->saw_tlsgd
)
2735 as_bad (_("sequence number in use for !tlsgd!%ld"),
2738 info
->saw_tlsldm
= 1;
2739 fixP
->tc_fix_data
.info
= info
;
2743 if ((int) fixup
->reloc
< 0)
2745 if (operand
->flags
& AXP_OPERAND_NOOVERFLOW
)
2746 fixP
->fx_no_overflow
= 1;
2753 /* Given an opcode name and a pre-tokenized set of arguments, assemble
2754 the insn, but do not emit it.
2756 Note that this implies no macros allowed, since we can't store more
2757 than one insn in an insn structure. */
2760 assemble_tokens_to_insn (opname
, tok
, ntok
, insn
)
2762 const expressionS
*tok
;
2764 struct alpha_insn
*insn
;
2766 const struct alpha_opcode
*opcode
;
2768 /* search opcodes */
2769 opcode
= (const struct alpha_opcode
*) hash_find (alpha_opcode_hash
, opname
);
2773 opcode
= find_opcode_match (opcode
, tok
, &ntok
, &cpumatch
);
2776 assemble_insn (opcode
, tok
, ntok
, insn
, BFD_RELOC_UNUSED
);
2780 as_bad (_("inappropriate arguments for opcode `%s'"), opname
);
2782 as_bad (_("opcode `%s' not supported for target %s"), opname
,
2786 as_bad (_("unknown opcode `%s'"), opname
);
2789 /* Given an opcode name and a pre-tokenized set of arguments, take the
2790 opcode all the way through emission. */
2793 assemble_tokens (opname
, tok
, ntok
, local_macros_on
)
2795 const expressionS
*tok
;
2797 int local_macros_on
;
2799 int found_something
= 0;
2800 const struct alpha_opcode
*opcode
;
2801 const struct alpha_macro
*macro
;
2803 bfd_reloc_code_real_type reloc
= BFD_RELOC_UNUSED
;
2806 /* If a user-specified relocation is present, this is not a macro. */
2807 if (ntok
&& USER_RELOC_P (tok
[ntok
- 1].X_op
))
2809 reloc
= ALPHA_RELOC_TABLE (tok
[ntok
- 1].X_op
)->reloc
;
2814 if (local_macros_on
)
2816 macro
= ((const struct alpha_macro
*)
2817 hash_find (alpha_macro_hash
, opname
));
2820 found_something
= 1;
2821 macro
= find_macro_match (macro
, tok
, &ntok
);
2824 (*macro
->emit
) (tok
, ntok
, macro
->arg
);
2830 /* Search opcodes. */
2831 opcode
= (const struct alpha_opcode
*) hash_find (alpha_opcode_hash
, opname
);
2834 found_something
= 1;
2835 opcode
= find_opcode_match (opcode
, tok
, &ntok
, &cpumatch
);
2838 struct alpha_insn insn
;
2839 assemble_insn (opcode
, tok
, ntok
, &insn
, reloc
);
2841 /* Copy the sequence number for the reloc from the reloc token. */
2842 if (reloc
!= BFD_RELOC_UNUSED
)
2843 insn
.sequence
= tok
[ntok
].X_add_number
;
2850 if (found_something
)
2853 as_bad (_("inappropriate arguments for opcode `%s'"), opname
);
2855 as_bad (_("opcode `%s' not supported for target %s"), opname
,
2859 as_bad (_("unknown opcode `%s'"), opname
);
2862 /* Some instruction sets indexed by lg(size). */
2863 static const char * const sextX_op
[] = { "sextb", "sextw", "sextl", NULL
};
2864 static const char * const insXl_op
[] = { "insbl", "inswl", "insll", "insql" };
2865 static const char * const insXh_op
[] = { NULL
, "inswh", "inslh", "insqh" };
2866 static const char * const extXl_op
[] = { "extbl", "extwl", "extll", "extql" };
2867 static const char * const extXh_op
[] = { NULL
, "extwh", "extlh", "extqh" };
2868 static const char * const mskXl_op
[] = { "mskbl", "mskwl", "mskll", "mskql" };
2869 static const char * const mskXh_op
[] = { NULL
, "mskwh", "msklh", "mskqh" };
2870 static const char * const stX_op
[] = { "stb", "stw", "stl", "stq" };
2871 static const char * const ldXu_op
[] = { "ldbu", "ldwu", NULL
, NULL
};
2873 /* Implement the ldgp macro. */
2876 emit_ldgp (tok
, ntok
, unused
)
2877 const expressionS
*tok
;
2878 int ntok ATTRIBUTE_UNUSED
;
2879 const PTR unused ATTRIBUTE_UNUSED
;
2884 #if defined(OBJ_ECOFF) || defined(OBJ_ELF)
2885 /* from "ldgp r1,n(r2)", generate "ldah r1,X(R2); lda r1,Y(r1)"
2886 with appropriate constants and relocations. */
2887 struct alpha_insn insn
;
2888 expressionS newtok
[3];
2892 if (regno (tok
[2].X_add_number
) == AXP_REG_PV
)
2893 ecoff_set_gp_prolog_size (0);
2897 set_tok_const (newtok
[1], 0);
2900 assemble_tokens_to_insn ("ldah", newtok
, 3, &insn
);
2905 if (addend
.X_op
!= O_constant
)
2906 as_bad (_("can not resolve expression"));
2907 addend
.X_op
= O_symbol
;
2908 addend
.X_add_symbol
= alpha_gp_symbol
;
2912 insn
.fixups
[0].exp
= addend
;
2913 insn
.fixups
[0].reloc
= BFD_RELOC_ALPHA_GPDISP_HI16
;
2914 insn
.sequence
= next_sequence_num
;
2918 set_tok_preg (newtok
[2], tok
[0].X_add_number
);
2920 assemble_tokens_to_insn ("lda", newtok
, 3, &insn
);
2923 addend
.X_add_number
+= 4;
2927 insn
.fixups
[0].exp
= addend
;
2928 insn
.fixups
[0].reloc
= BFD_RELOC_ALPHA_GPDISP_LO16
;
2929 insn
.sequence
= next_sequence_num
--;
2932 #endif /* OBJ_ECOFF || OBJ_ELF */
2937 /* Add symbol+addend to link pool.
2938 Return offset from basesym to entry in link pool.
2940 Add new fixup only if offset isn't 16bit. */
2943 add_to_link_pool (basesym
, sym
, addend
)
2948 segT current_section
= now_seg
;
2949 int current_subsec
= now_subseg
;
2951 bfd_reloc_code_real_type reloc_type
;
2953 segment_info_type
*seginfo
= seg_info (alpha_link_section
);
2956 offset
= - *symbol_get_obj (basesym
);
2958 /* @@ This assumes all entries in a given section will be of the same
2959 size... Probably correct, but unwise to rely on. */
2960 /* This must always be called with the same subsegment. */
2962 if (seginfo
->frchainP
)
2963 for (fixp
= seginfo
->frchainP
->fix_root
;
2964 fixp
!= (fixS
*) NULL
;
2965 fixp
= fixp
->fx_next
, offset
+= 8)
2967 if (fixp
->fx_addsy
== sym
&& fixp
->fx_offset
== addend
)
2969 if (range_signed_16 (offset
))
2976 /* Not found in 16bit signed range. */
2978 subseg_set (alpha_link_section
, 0);
2982 fix_new (frag_now
, p
- frag_now
->fr_literal
, 8, sym
, addend
, 0,
2985 subseg_set (current_section
, current_subsec
);
2986 seginfo
->literal_pool_size
+= 8;
2990 #endif /* OBJ_EVAX */
2992 /* Load a (partial) expression into a target register.
2994 If poffset is not null, after the call it will either contain
2995 O_constant 0, or a 16-bit offset appropriate for any MEM format
2996 instruction. In addition, pbasereg will be modified to point to
2997 the base register to use in that MEM format instruction.
2999 In any case, *pbasereg should contain a base register to add to the
3000 expression. This will normally be either AXP_REG_ZERO or
3001 alpha_gp_register. Symbol addresses will always be loaded via $gp,
3002 so "foo($0)" is interpreted as adding the address of foo to $0;
3003 i.e. "ldq $targ, LIT($gp); addq $targ, $0, $targ". Odd, perhaps,
3004 but this is what OSF/1 does.
3006 If explicit relocations of the form !literal!<number> are allowed,
3007 and used, then explicit_reloc with be an expression pointer.
3009 Finally, the return value is nonzero if the calling macro may emit
3010 a LITUSE reloc if otherwise appropriate; the return value is the
3011 sequence number to use. */
3014 load_expression (targreg
, exp
, pbasereg
, poffset
)
3016 const expressionS
*exp
;
3018 expressionS
*poffset
;
3020 long emit_lituse
= 0;
3021 offsetT addend
= exp
->X_add_number
;
3022 int basereg
= *pbasereg
;
3023 struct alpha_insn insn
;
3024 expressionS newtok
[3];
3033 /* Attempt to reduce .lit load by splitting the offset from
3034 its symbol when possible, but don't create a situation in
3036 if (!range_signed_32 (addend
) &&
3037 (alpha_noat_on
|| targreg
== AXP_REG_AT
))
3039 lit
= add_to_literal_pool (exp
->X_add_symbol
, addend
,
3040 alpha_lita_section
, 8);
3045 lit
= add_to_literal_pool (exp
->X_add_symbol
, 0,
3046 alpha_lita_section
, 8);
3050 as_fatal (_("overflow in literal (.lita) table"));
3052 /* emit "ldq r, lit(gp)" */
3054 if (basereg
!= alpha_gp_register
&& targreg
== basereg
)
3057 as_bad (_("macro requires $at register while noat in effect"));
3058 if (targreg
== AXP_REG_AT
)
3059 as_bad (_("macro requires $at while $at in use"));
3061 set_tok_reg (newtok
[0], AXP_REG_AT
);
3064 set_tok_reg (newtok
[0], targreg
);
3065 set_tok_sym (newtok
[1], alpha_lita_symbol
, lit
);
3066 set_tok_preg (newtok
[2], alpha_gp_register
);
3068 assemble_tokens_to_insn ("ldq", newtok
, 3, &insn
);
3070 assert (insn
.nfixups
== 1);
3071 insn
.fixups
[0].reloc
= BFD_RELOC_ALPHA_LITERAL
;
3072 insn
.sequence
= emit_lituse
= next_sequence_num
--;
3073 #endif /* OBJ_ECOFF */
3075 /* emit "ldq r, gotoff(gp)" */
3077 if (basereg
!= alpha_gp_register
&& targreg
== basereg
)
3080 as_bad (_("macro requires $at register while noat in effect"));
3081 if (targreg
== AXP_REG_AT
)
3082 as_bad (_("macro requires $at while $at in use"));
3084 set_tok_reg (newtok
[0], AXP_REG_AT
);
3087 set_tok_reg (newtok
[0], targreg
);
3089 /* XXX: Disable this .got minimizing optimization so that we can get
3090 better instruction offset knowledge in the compiler. This happens
3091 very infrequently anyway. */
3093 || (!range_signed_32 (addend
)
3094 && (alpha_noat_on
|| targreg
== AXP_REG_AT
)))
3101 set_tok_sym (newtok
[1], exp
->X_add_symbol
, 0);
3104 set_tok_preg (newtok
[2], alpha_gp_register
);
3106 assemble_tokens_to_insn ("ldq", newtok
, 3, &insn
);
3108 assert (insn
.nfixups
== 1);
3109 insn
.fixups
[0].reloc
= BFD_RELOC_ALPHA_ELF_LITERAL
;
3110 insn
.sequence
= emit_lituse
= next_sequence_num
--;
3111 #endif /* OBJ_ELF */
3115 /* Find symbol or symbol pointer in link section. */
3117 if (exp
->X_add_symbol
== alpha_evax_proc
.symbol
)
3119 if (range_signed_16 (addend
))
3121 set_tok_reg (newtok
[0], targreg
);
3122 set_tok_const (newtok
[1], addend
);
3123 set_tok_preg (newtok
[2], basereg
);
3124 assemble_tokens_to_insn ("lda", newtok
, 3, &insn
);
3129 set_tok_reg (newtok
[0], targreg
);
3130 set_tok_const (newtok
[1], 0);
3131 set_tok_preg (newtok
[2], basereg
);
3132 assemble_tokens_to_insn ("lda", newtok
, 3, &insn
);
3137 if (!range_signed_32 (addend
))
3139 link
= add_to_link_pool (alpha_evax_proc
.symbol
,
3140 exp
->X_add_symbol
, addend
);
3145 link
= add_to_link_pool (alpha_evax_proc
.symbol
,
3146 exp
->X_add_symbol
, 0);
3148 set_tok_reg (newtok
[0], targreg
);
3149 set_tok_const (newtok
[1], link
);
3150 set_tok_preg (newtok
[2], basereg
);
3151 assemble_tokens_to_insn ("ldq", newtok
, 3, &insn
);
3153 #endif /* OBJ_EVAX */
3158 if (basereg
!= alpha_gp_register
&& basereg
!= AXP_REG_ZERO
)
3160 /* emit "addq r, base, r" */
3162 set_tok_reg (newtok
[1], basereg
);
3163 set_tok_reg (newtok
[2], targreg
);
3164 assemble_tokens ("addq", newtok
, 3, 0);
3176 /* Assume that this difference expression will be resolved to an
3177 absolute value and that that value will fit in 16 bits. */
3179 set_tok_reg (newtok
[0], targreg
);
3181 set_tok_preg (newtok
[2], basereg
);
3182 assemble_tokens ("lda", newtok
, 3, 0);
3185 set_tok_const (*poffset
, 0);
3189 if (exp
->X_add_number
> 0)
3190 as_bad (_("bignum invalid; zero assumed"));
3192 as_bad (_("floating point number invalid; zero assumed"));
3197 as_bad (_("can't handle expression"));
3202 if (!range_signed_32 (addend
))
3205 long seq_num
= next_sequence_num
--;
3207 /* For 64-bit addends, just put it in the literal pool. */
3210 /* emit "ldq targreg, lit(basereg)" */
3211 lit
= add_to_link_pool (alpha_evax_proc
.symbol
,
3212 section_symbol (absolute_section
), addend
);
3213 set_tok_reg (newtok
[0], targreg
);
3214 set_tok_const (newtok
[1], lit
);
3215 set_tok_preg (newtok
[2], alpha_gp_register
);
3216 assemble_tokens ("ldq", newtok
, 3, 0);
3219 if (alpha_lit8_section
== NULL
)
3221 create_literal_section (".lit8",
3222 &alpha_lit8_section
,
3223 &alpha_lit8_symbol
);
3226 alpha_lit8_literal
= add_to_literal_pool (alpha_lit8_symbol
, 0x8000,
3227 alpha_lita_section
, 8);
3228 if (alpha_lit8_literal
>= 0x8000)
3229 as_fatal (_("overflow in literal (.lita) table"));
3233 lit
= add_to_literal_pool (NULL
, addend
, alpha_lit8_section
, 8) - 0x8000;
3235 as_fatal (_("overflow in literal (.lit8) table"));
3237 /* emit "lda litreg, .lit8+0x8000" */
3239 if (targreg
== basereg
)
3242 as_bad (_("macro requires $at register while noat in effect"));
3243 if (targreg
== AXP_REG_AT
)
3244 as_bad (_("macro requires $at while $at in use"));
3246 set_tok_reg (newtok
[0], AXP_REG_AT
);
3249 set_tok_reg (newtok
[0], targreg
);
3251 set_tok_sym (newtok
[1], alpha_lita_symbol
, alpha_lit8_literal
);
3254 set_tok_sym (newtok
[1], alpha_lit8_symbol
, 0x8000);
3256 set_tok_preg (newtok
[2], alpha_gp_register
);
3258 assemble_tokens_to_insn ("ldq", newtok
, 3, &insn
);
3260 assert (insn
.nfixups
== 1);
3262 insn
.fixups
[0].reloc
= BFD_RELOC_ALPHA_LITERAL
;
3265 insn
.fixups
[0].reloc
= BFD_RELOC_ALPHA_ELF_LITERAL
;
3267 insn
.sequence
= seq_num
;
3271 /* emit "ldq litreg, lit(litreg)" */
3273 set_tok_const (newtok
[1], lit
);
3274 set_tok_preg (newtok
[2], newtok
[0].X_add_number
);
3276 assemble_tokens_to_insn ("ldq", newtok
, 3, &insn
);
3278 assert (insn
.nfixups
< MAX_INSN_FIXUPS
);
3279 insn
.fixups
[insn
.nfixups
].reloc
= DUMMY_RELOC_LITUSE_BASE
;
3280 insn
.fixups
[insn
.nfixups
].exp
.X_op
= O_absent
;
3282 insn
.sequence
= seq_num
;
3287 /* emit "addq litreg, base, target" */
3289 if (basereg
!= AXP_REG_ZERO
)
3291 set_tok_reg (newtok
[1], basereg
);
3292 set_tok_reg (newtok
[2], targreg
);
3293 assemble_tokens ("addq", newtok
, 3, 0);
3295 #endif /* !OBJ_EVAX */
3298 set_tok_const (*poffset
, 0);
3299 *pbasereg
= targreg
;
3303 offsetT low
, high
, extra
, tmp
;
3305 /* for 32-bit operands, break up the addend */
3307 low
= sign_extend_16 (addend
);
3309 high
= sign_extend_16 (tmp
>> 16);
3311 if (tmp
- (high
<< 16))
3315 high
= sign_extend_16 (tmp
>> 16);
3320 set_tok_reg (newtok
[0], targreg
);
3321 set_tok_preg (newtok
[2], basereg
);
3325 /* emit "ldah r, extra(r) */
3326 set_tok_const (newtok
[1], extra
);
3327 assemble_tokens ("ldah", newtok
, 3, 0);
3328 set_tok_preg (newtok
[2], basereg
= targreg
);
3333 /* emit "ldah r, high(r) */
3334 set_tok_const (newtok
[1], high
);
3335 assemble_tokens ("ldah", newtok
, 3, 0);
3337 set_tok_preg (newtok
[2], basereg
);
3340 if ((low
&& !poffset
) || (!poffset
&& basereg
!= targreg
))
3342 /* emit "lda r, low(base)" */
3343 set_tok_const (newtok
[1], low
);
3344 assemble_tokens ("lda", newtok
, 3, 0);
3350 set_tok_const (*poffset
, low
);
3351 *pbasereg
= basereg
;
3357 /* The lda macro differs from the lda instruction in that it handles
3358 most simple expressions, particularly symbol address loads and
3362 emit_lda (tok
, ntok
, unused
)
3363 const expressionS
*tok
;
3365 const PTR unused ATTRIBUTE_UNUSED
;
3370 basereg
= (tok
[1].X_op
== O_constant
? AXP_REG_ZERO
: alpha_gp_register
);
3372 basereg
= tok
[2].X_add_number
;
3374 (void) load_expression (tok
[0].X_add_number
, &tok
[1], &basereg
, NULL
);
3377 /* The ldah macro differs from the ldah instruction in that it has $31
3378 as an implied base register. */
3381 emit_ldah (tok
, ntok
, unused
)
3382 const expressionS
*tok
;
3383 int ntok ATTRIBUTE_UNUSED
;
3384 const PTR unused ATTRIBUTE_UNUSED
;
3386 expressionS newtok
[3];
3390 set_tok_preg (newtok
[2], AXP_REG_ZERO
);
3392 assemble_tokens ("ldah", newtok
, 3, 0);
3395 /* Handle all "simple" integer register loads -- ldq, ldq_l, ldq_u,
3396 etc. They differ from the real instructions in that they do simple
3397 expressions like the lda macro. */
3400 emit_ir_load (tok
, ntok
, opname
)
3401 const expressionS
*tok
;
3407 expressionS newtok
[3];
3408 struct alpha_insn insn
;
3411 basereg
= (tok
[1].X_op
== O_constant
? AXP_REG_ZERO
: alpha_gp_register
);
3413 basereg
= tok
[2].X_add_number
;
3415 lituse
= load_expression (tok
[0].X_add_number
, &tok
[1], &basereg
,
3419 set_tok_preg (newtok
[2], basereg
);
3421 assemble_tokens_to_insn ((const char *) opname
, newtok
, 3, &insn
);
3425 assert (insn
.nfixups
< MAX_INSN_FIXUPS
);
3426 insn
.fixups
[insn
.nfixups
].reloc
= DUMMY_RELOC_LITUSE_BASE
;
3427 insn
.fixups
[insn
.nfixups
].exp
.X_op
= O_absent
;
3429 insn
.sequence
= lituse
;
3435 /* Handle fp register loads, and both integer and fp register stores.
3436 Again, we handle simple expressions. */
3439 emit_loadstore (tok
, ntok
, opname
)
3440 const expressionS
*tok
;
3446 expressionS newtok
[3];
3447 struct alpha_insn insn
;
3450 basereg
= (tok
[1].X_op
== O_constant
? AXP_REG_ZERO
: alpha_gp_register
);
3452 basereg
= tok
[2].X_add_number
;
3454 if (tok
[1].X_op
!= O_constant
|| !range_signed_16 (tok
[1].X_add_number
))
3457 as_bad (_("macro requires $at register while noat in effect"));
3459 lituse
= load_expression (AXP_REG_AT
, &tok
[1], &basereg
, &newtok
[1]);
3468 set_tok_preg (newtok
[2], basereg
);
3470 assemble_tokens_to_insn ((const char *) opname
, newtok
, 3, &insn
);
3474 assert (insn
.nfixups
< MAX_INSN_FIXUPS
);
3475 insn
.fixups
[insn
.nfixups
].reloc
= DUMMY_RELOC_LITUSE_BASE
;
3476 insn
.fixups
[insn
.nfixups
].exp
.X_op
= O_absent
;
3478 insn
.sequence
= lituse
;
3484 /* Load a half-word or byte as an unsigned value. */
3487 emit_ldXu (tok
, ntok
, vlgsize
)
3488 const expressionS
*tok
;
3492 if (alpha_target
& AXP_OPCODE_BWX
)
3493 emit_ir_load (tok
, ntok
, ldXu_op
[(long) vlgsize
]);
3496 expressionS newtok
[3];
3497 struct alpha_insn insn
;
3502 as_bad (_("macro requires $at register while noat in effect"));
3505 basereg
= (tok
[1].X_op
== O_constant
3506 ? AXP_REG_ZERO
: alpha_gp_register
);
3508 basereg
= tok
[2].X_add_number
;
3510 /* emit "lda $at, exp" */
3512 lituse
= load_expression (AXP_REG_AT
, &tok
[1], &basereg
, NULL
);
3514 /* emit "ldq_u targ, 0($at)" */
3517 set_tok_const (newtok
[1], 0);
3518 set_tok_preg (newtok
[2], basereg
);
3519 assemble_tokens_to_insn ("ldq_u", newtok
, 3, &insn
);
3523 assert (insn
.nfixups
< MAX_INSN_FIXUPS
);
3524 insn
.fixups
[insn
.nfixups
].reloc
= DUMMY_RELOC_LITUSE_BASE
;
3525 insn
.fixups
[insn
.nfixups
].exp
.X_op
= O_absent
;
3527 insn
.sequence
= lituse
;
3532 /* emit "extXl targ, $at, targ" */
3534 set_tok_reg (newtok
[1], basereg
);
3535 newtok
[2] = newtok
[0];
3536 assemble_tokens_to_insn (extXl_op
[(long) vlgsize
], newtok
, 3, &insn
);
3540 assert (insn
.nfixups
< MAX_INSN_FIXUPS
);
3541 insn
.fixups
[insn
.nfixups
].reloc
= DUMMY_RELOC_LITUSE_BYTOFF
;
3542 insn
.fixups
[insn
.nfixups
].exp
.X_op
= O_absent
;
3544 insn
.sequence
= lituse
;
3551 /* Load a half-word or byte as a signed value. */
3554 emit_ldX (tok
, ntok
, vlgsize
)
3555 const expressionS
*tok
;
3559 emit_ldXu (tok
, ntok
, vlgsize
);
3560 assemble_tokens (sextX_op
[(long) vlgsize
], tok
, 1, 1);
3563 /* Load an integral value from an unaligned address as an unsigned
3567 emit_uldXu (tok
, ntok
, vlgsize
)
3568 const expressionS
*tok
;
3572 long lgsize
= (long) vlgsize
;
3573 expressionS newtok
[3];
3576 as_bad (_("macro requires $at register while noat in effect"));
3578 /* emit "lda $at, exp" */
3580 memcpy (newtok
, tok
, sizeof (expressionS
) * ntok
);
3581 newtok
[0].X_add_number
= AXP_REG_AT
;
3582 assemble_tokens ("lda", newtok
, ntok
, 1);
3584 /* emit "ldq_u $t9, 0($at)" */
3586 set_tok_reg (newtok
[0], AXP_REG_T9
);
3587 set_tok_const (newtok
[1], 0);
3588 set_tok_preg (newtok
[2], AXP_REG_AT
);
3589 assemble_tokens ("ldq_u", newtok
, 3, 1);
3591 /* emit "ldq_u $t10, size-1($at)" */
3593 set_tok_reg (newtok
[0], AXP_REG_T10
);
3594 set_tok_const (newtok
[1], (1 << lgsize
) - 1);
3595 assemble_tokens ("ldq_u", newtok
, 3, 1);
3597 /* emit "extXl $t9, $at, $t9" */
3599 set_tok_reg (newtok
[0], AXP_REG_T9
);
3600 set_tok_reg (newtok
[1], AXP_REG_AT
);
3601 set_tok_reg (newtok
[2], AXP_REG_T9
);
3602 assemble_tokens (extXl_op
[lgsize
], newtok
, 3, 1);
3604 /* emit "extXh $t10, $at, $t10" */
3606 set_tok_reg (newtok
[0], AXP_REG_T10
);
3607 set_tok_reg (newtok
[2], AXP_REG_T10
);
3608 assemble_tokens (extXh_op
[lgsize
], newtok
, 3, 1);
3610 /* emit "or $t9, $t10, targ" */
3612 set_tok_reg (newtok
[0], AXP_REG_T9
);
3613 set_tok_reg (newtok
[1], AXP_REG_T10
);
3615 assemble_tokens ("or", newtok
, 3, 1);
3618 /* Load an integral value from an unaligned address as a signed value.
3619 Note that quads should get funneled to the unsigned load since we
3620 don't have to do the sign extension. */
3623 emit_uldX (tok
, ntok
, vlgsize
)
3624 const expressionS
*tok
;
3628 emit_uldXu (tok
, ntok
, vlgsize
);
3629 assemble_tokens (sextX_op
[(long) vlgsize
], tok
, 1, 1);
3632 /* Implement the ldil macro. */
3635 emit_ldil (tok
, ntok
, unused
)
3636 const expressionS
*tok
;
3638 const PTR unused ATTRIBUTE_UNUSED
;
3640 expressionS newtok
[2];
3642 memcpy (newtok
, tok
, sizeof (newtok
));
3643 newtok
[1].X_add_number
= sign_extend_32 (tok
[1].X_add_number
);
3645 assemble_tokens ("lda", newtok
, ntok
, 1);
3648 /* Store a half-word or byte. */
3651 emit_stX (tok
, ntok
, vlgsize
)
3652 const expressionS
*tok
;
3656 int lgsize
= (int) (long) vlgsize
;
3658 if (alpha_target
& AXP_OPCODE_BWX
)
3659 emit_loadstore (tok
, ntok
, stX_op
[lgsize
]);
3662 expressionS newtok
[3];
3663 struct alpha_insn insn
;
3668 as_bad (_("macro requires $at register while noat in effect"));
3671 basereg
= (tok
[1].X_op
== O_constant
3672 ? AXP_REG_ZERO
: alpha_gp_register
);
3674 basereg
= tok
[2].X_add_number
;
3676 /* emit "lda $at, exp" */
3678 lituse
= load_expression (AXP_REG_AT
, &tok
[1], &basereg
, NULL
);
3680 /* emit "ldq_u $t9, 0($at)" */
3682 set_tok_reg (newtok
[0], AXP_REG_T9
);
3683 set_tok_const (newtok
[1], 0);
3684 set_tok_preg (newtok
[2], basereg
);
3685 assemble_tokens_to_insn ("ldq_u", newtok
, 3, &insn
);
3689 assert (insn
.nfixups
< MAX_INSN_FIXUPS
);
3690 insn
.fixups
[insn
.nfixups
].reloc
= DUMMY_RELOC_LITUSE_BASE
;
3691 insn
.fixups
[insn
.nfixups
].exp
.X_op
= O_absent
;
3693 insn
.sequence
= lituse
;
3698 /* emit "insXl src, $at, $t10" */
3701 set_tok_reg (newtok
[1], basereg
);
3702 set_tok_reg (newtok
[2], AXP_REG_T10
);
3703 assemble_tokens_to_insn (insXl_op
[lgsize
], newtok
, 3, &insn
);
3707 assert (insn
.nfixups
< MAX_INSN_FIXUPS
);
3708 insn
.fixups
[insn
.nfixups
].reloc
= DUMMY_RELOC_LITUSE_BYTOFF
;
3709 insn
.fixups
[insn
.nfixups
].exp
.X_op
= O_absent
;
3711 insn
.sequence
= lituse
;
3716 /* emit "mskXl $t9, $at, $t9" */
3718 set_tok_reg (newtok
[0], AXP_REG_T9
);
3719 newtok
[2] = newtok
[0];
3720 assemble_tokens_to_insn (mskXl_op
[lgsize
], newtok
, 3, &insn
);
3724 assert (insn
.nfixups
< MAX_INSN_FIXUPS
);
3725 insn
.fixups
[insn
.nfixups
].reloc
= DUMMY_RELOC_LITUSE_BYTOFF
;
3726 insn
.fixups
[insn
.nfixups
].exp
.X_op
= O_absent
;
3728 insn
.sequence
= lituse
;
3733 /* emit "or $t9, $t10, $t9" */
3735 set_tok_reg (newtok
[1], AXP_REG_T10
);
3736 assemble_tokens ("or", newtok
, 3, 1);
3738 /* emit "stq_u $t9, 0($at) */
3740 set_tok_const(newtok
[1], 0);
3741 set_tok_preg (newtok
[2], AXP_REG_AT
);
3742 assemble_tokens_to_insn ("stq_u", newtok
, 3, &insn
);
3746 assert (insn
.nfixups
< MAX_INSN_FIXUPS
);
3747 insn
.fixups
[insn
.nfixups
].reloc
= DUMMY_RELOC_LITUSE_BASE
;
3748 insn
.fixups
[insn
.nfixups
].exp
.X_op
= O_absent
;
3750 insn
.sequence
= lituse
;
3757 /* Store an integer to an unaligned address. */
3760 emit_ustX (tok
, ntok
, vlgsize
)
3761 const expressionS
*tok
;
3765 int lgsize
= (int) (long) vlgsize
;
3766 expressionS newtok
[3];
3768 /* emit "lda $at, exp" */
3770 memcpy (newtok
, tok
, sizeof (expressionS
) * ntok
);
3771 newtok
[0].X_add_number
= AXP_REG_AT
;
3772 assemble_tokens ("lda", newtok
, ntok
, 1);
3774 /* emit "ldq_u $9, 0($at)" */
3776 set_tok_reg (newtok
[0], AXP_REG_T9
);
3777 set_tok_const (newtok
[1], 0);
3778 set_tok_preg (newtok
[2], AXP_REG_AT
);
3779 assemble_tokens ("ldq_u", newtok
, 3, 1);
3781 /* emit "ldq_u $10, size-1($at)" */
3783 set_tok_reg (newtok
[0], AXP_REG_T10
);
3784 set_tok_const (newtok
[1], (1 << lgsize
) - 1);
3785 assemble_tokens ("ldq_u", newtok
, 3, 1);
3787 /* emit "insXl src, $at, $t11" */
3790 set_tok_reg (newtok
[1], AXP_REG_AT
);
3791 set_tok_reg (newtok
[2], AXP_REG_T11
);
3792 assemble_tokens (insXl_op
[lgsize
], newtok
, 3, 1);
3794 /* emit "insXh src, $at, $t12" */
3796 set_tok_reg (newtok
[2], AXP_REG_T12
);
3797 assemble_tokens (insXh_op
[lgsize
], newtok
, 3, 1);
3799 /* emit "mskXl $t9, $at, $t9" */
3801 set_tok_reg (newtok
[0], AXP_REG_T9
);
3802 newtok
[2] = newtok
[0];
3803 assemble_tokens (mskXl_op
[lgsize
], newtok
, 3, 1);
3805 /* emit "mskXh $t10, $at, $t10" */
3807 set_tok_reg (newtok
[0], AXP_REG_T10
);
3808 newtok
[2] = newtok
[0];
3809 assemble_tokens (mskXh_op
[lgsize
], newtok
, 3, 1);
3811 /* emit "or $t9, $t11, $t9" */
3813 set_tok_reg (newtok
[0], AXP_REG_T9
);
3814 set_tok_reg (newtok
[1], AXP_REG_T11
);
3815 newtok
[2] = newtok
[0];
3816 assemble_tokens ("or", newtok
, 3, 1);
3818 /* emit "or $t10, $t12, $t10" */
3820 set_tok_reg (newtok
[0], AXP_REG_T10
);
3821 set_tok_reg (newtok
[1], AXP_REG_T12
);
3822 newtok
[2] = newtok
[0];
3823 assemble_tokens ("or", newtok
, 3, 1);
3825 /* emit "stq_u $t9, 0($at)" */
3827 set_tok_reg (newtok
[0], AXP_REG_T9
);
3828 set_tok_const (newtok
[1], 0);
3829 set_tok_preg (newtok
[2], AXP_REG_AT
);
3830 assemble_tokens ("stq_u", newtok
, 3, 1);
3832 /* emit "stq_u $t10, size-1($at)" */
3834 set_tok_reg (newtok
[0], AXP_REG_T10
);
3835 set_tok_const (newtok
[1], (1 << lgsize
) - 1);
3836 assemble_tokens ("stq_u", newtok
, 3, 1);
3839 /* Sign extend a half-word or byte. The 32-bit sign extend is
3840 implemented as "addl $31, $r, $t" in the opcode table. */
3843 emit_sextX (tok
, ntok
, vlgsize
)
3844 const expressionS
*tok
;
3848 long lgsize
= (long) vlgsize
;
3850 if (alpha_target
& AXP_OPCODE_BWX
)
3851 assemble_tokens (sextX_op
[lgsize
], tok
, ntok
, 0);
3854 int bitshift
= 64 - 8 * (1 << lgsize
);
3855 expressionS newtok
[3];
3857 /* emit "sll src,bits,dst" */
3860 set_tok_const (newtok
[1], bitshift
);
3861 newtok
[2] = tok
[ntok
- 1];
3862 assemble_tokens ("sll", newtok
, 3, 1);
3864 /* emit "sra dst,bits,dst" */
3866 newtok
[0] = newtok
[2];
3867 assemble_tokens ("sra", newtok
, 3, 1);
3871 /* Implement the division and modulus macros. */
3875 /* Make register usage like in normal procedure call.
3876 Don't clobber PV and RA. */
3879 emit_division (tok
, ntok
, symname
)
3880 const expressionS
*tok
;
3884 /* DIVISION and MODULUS. Yech.
3889 mov x,R16 # if x != R16
3890 mov y,R17 # if y != R17
3895 with appropriate optimizations if R0,R16,R17 are the registers
3896 specified by the compiler. */
3900 expressionS newtok
[3];
3902 xr
= regno (tok
[0].X_add_number
);
3903 yr
= regno (tok
[1].X_add_number
);
3908 rr
= regno (tok
[2].X_add_number
);
3910 /* Move the operands into the right place. */
3911 if (yr
== AXP_REG_R16
&& xr
== AXP_REG_R17
)
3913 /* They are in exactly the wrong order -- swap through AT. */
3916 as_bad (_("macro requires $at register while noat in effect"));
3918 set_tok_reg (newtok
[0], AXP_REG_R16
);
3919 set_tok_reg (newtok
[1], AXP_REG_AT
);
3920 assemble_tokens ("mov", newtok
, 2, 1);
3922 set_tok_reg (newtok
[0], AXP_REG_R17
);
3923 set_tok_reg (newtok
[1], AXP_REG_R16
);
3924 assemble_tokens ("mov", newtok
, 2, 1);
3926 set_tok_reg (newtok
[0], AXP_REG_AT
);
3927 set_tok_reg (newtok
[1], AXP_REG_R17
);
3928 assemble_tokens ("mov", newtok
, 2, 1);
3932 if (yr
== AXP_REG_R16
)
3934 set_tok_reg (newtok
[0], AXP_REG_R16
);
3935 set_tok_reg (newtok
[1], AXP_REG_R17
);
3936 assemble_tokens ("mov", newtok
, 2, 1);
3939 if (xr
!= AXP_REG_R16
)
3941 set_tok_reg (newtok
[0], xr
);
3942 set_tok_reg (newtok
[1], AXP_REG_R16
);
3943 assemble_tokens ("mov", newtok
, 2, 1);
3946 if (yr
!= AXP_REG_R16
&& yr
!= AXP_REG_R17
)
3948 set_tok_reg (newtok
[0], yr
);
3949 set_tok_reg (newtok
[1], AXP_REG_R17
);
3950 assemble_tokens ("mov", newtok
, 2, 1);
3954 sym
= symbol_find_or_make ((const char *) symname
);
3956 set_tok_reg (newtok
[0], AXP_REG_AT
);
3957 set_tok_sym (newtok
[1], sym
, 0);
3958 assemble_tokens ("lda", newtok
, 2, 1);
3960 /* Call the division routine. */
3961 set_tok_reg (newtok
[0], AXP_REG_AT
);
3962 set_tok_cpreg (newtok
[1], AXP_REG_AT
);
3963 set_tok_const (newtok
[2], 0);
3964 assemble_tokens ("jsr", newtok
, 3, 1);
3966 /* Move the result to the right place. */
3967 if (rr
!= AXP_REG_R0
)
3969 set_tok_reg (newtok
[0], AXP_REG_R0
);
3970 set_tok_reg (newtok
[1], rr
);
3971 assemble_tokens ("mov", newtok
, 2, 1);
3975 #else /* !OBJ_EVAX */
3978 emit_division (tok
, ntok
, symname
)
3979 const expressionS
*tok
;
3983 /* DIVISION and MODULUS. Yech.
3993 with appropriate optimizations if t10,t11,t12 are the registers
3994 specified by the compiler. */
3998 expressionS newtok
[3];
4000 xr
= regno (tok
[0].X_add_number
);
4001 yr
= regno (tok
[1].X_add_number
);
4006 rr
= regno (tok
[2].X_add_number
);
4008 sym
= symbol_find_or_make ((const char *) symname
);
4010 /* Move the operands into the right place. */
4011 if (yr
== AXP_REG_T10
&& xr
== AXP_REG_T11
)
4013 /* They are in exactly the wrong order -- swap through AT. */
4015 as_bad (_("macro requires $at register while noat in effect"));
4017 set_tok_reg (newtok
[0], AXP_REG_T10
);
4018 set_tok_reg (newtok
[1], AXP_REG_AT
);
4019 assemble_tokens ("mov", newtok
, 2, 1);
4021 set_tok_reg (newtok
[0], AXP_REG_T11
);
4022 set_tok_reg (newtok
[1], AXP_REG_T10
);
4023 assemble_tokens ("mov", newtok
, 2, 1);
4025 set_tok_reg (newtok
[0], AXP_REG_AT
);
4026 set_tok_reg (newtok
[1], AXP_REG_T11
);
4027 assemble_tokens ("mov", newtok
, 2, 1);
4031 if (yr
== AXP_REG_T10
)
4033 set_tok_reg (newtok
[0], AXP_REG_T10
);
4034 set_tok_reg (newtok
[1], AXP_REG_T11
);
4035 assemble_tokens ("mov", newtok
, 2, 1);
4038 if (xr
!= AXP_REG_T10
)
4040 set_tok_reg (newtok
[0], xr
);
4041 set_tok_reg (newtok
[1], AXP_REG_T10
);
4042 assemble_tokens ("mov", newtok
, 2, 1);
4045 if (yr
!= AXP_REG_T10
&& yr
!= AXP_REG_T11
)
4047 set_tok_reg (newtok
[0], yr
);
4048 set_tok_reg (newtok
[1], AXP_REG_T11
);
4049 assemble_tokens ("mov", newtok
, 2, 1);
4053 /* Call the division routine. */
4054 set_tok_reg (newtok
[0], AXP_REG_T9
);
4055 set_tok_sym (newtok
[1], sym
, 0);
4056 assemble_tokens ("jsr", newtok
, 2, 1);
4058 /* Reload the GP register. */
4062 #if defined(OBJ_ECOFF) || defined(OBJ_ELF)
4063 set_tok_reg (newtok
[0], alpha_gp_register
);
4064 set_tok_const (newtok
[1], 0);
4065 set_tok_preg (newtok
[2], AXP_REG_T9
);
4066 assemble_tokens ("ldgp", newtok
, 3, 1);
4069 /* Move the result to the right place. */
4070 if (rr
!= AXP_REG_T12
)
4072 set_tok_reg (newtok
[0], AXP_REG_T12
);
4073 set_tok_reg (newtok
[1], rr
);
4074 assemble_tokens ("mov", newtok
, 2, 1);
4078 #endif /* !OBJ_EVAX */
4080 /* The jsr and jmp macros differ from their instruction counterparts
4081 in that they can load the target address and default most
4085 emit_jsrjmp (tok
, ntok
, vopname
)
4086 const expressionS
*tok
;
4090 const char *opname
= (const char *) vopname
;
4091 struct alpha_insn insn
;
4092 expressionS newtok
[3];
4096 if (tokidx
< ntok
&& tok
[tokidx
].X_op
== O_register
)
4097 r
= regno (tok
[tokidx
++].X_add_number
);
4099 r
= strcmp (opname
, "jmp") == 0 ? AXP_REG_ZERO
: AXP_REG_RA
;
4101 set_tok_reg (newtok
[0], r
);
4103 if (tokidx
< ntok
&&
4104 (tok
[tokidx
].X_op
== O_pregister
|| tok
[tokidx
].X_op
== O_cpregister
))
4105 r
= regno (tok
[tokidx
++].X_add_number
);
4107 /* keep register if jsr $n.<sym> */
4111 int basereg
= alpha_gp_register
;
4112 lituse
= load_expression (r
= AXP_REG_PV
, &tok
[tokidx
], &basereg
, NULL
);
4116 set_tok_cpreg (newtok
[1], r
);
4119 /* FIXME: Add hint relocs to BFD for evax. */
4122 newtok
[2] = tok
[tokidx
];
4125 set_tok_const (newtok
[2], 0);
4127 assemble_tokens_to_insn (opname
, newtok
, 3, &insn
);
4131 assert (insn
.nfixups
< MAX_INSN_FIXUPS
);
4132 insn
.fixups
[insn
.nfixups
].reloc
= DUMMY_RELOC_LITUSE_JSR
;
4133 insn
.fixups
[insn
.nfixups
].exp
.X_op
= O_absent
;
4135 insn
.sequence
= lituse
;
4141 /* The ret and jcr instructions differ from their instruction
4142 counterparts in that everything can be defaulted. */
4145 emit_retjcr (tok
, ntok
, vopname
)
4146 const expressionS
*tok
;
4150 const char *opname
= (const char *) vopname
;
4151 expressionS newtok
[3];
4154 if (tokidx
< ntok
&& tok
[tokidx
].X_op
== O_register
)
4155 r
= regno (tok
[tokidx
++].X_add_number
);
4159 set_tok_reg (newtok
[0], r
);
4161 if (tokidx
< ntok
&&
4162 (tok
[tokidx
].X_op
== O_pregister
|| tok
[tokidx
].X_op
== O_cpregister
))
4163 r
= regno (tok
[tokidx
++].X_add_number
);
4167 set_tok_cpreg (newtok
[1], r
);
4170 newtok
[2] = tok
[tokidx
];
4172 set_tok_const (newtok
[2], strcmp (opname
, "ret") == 0);
4174 assemble_tokens (opname
, newtok
, 3, 0);
4177 /* Assembler directives. */
4179 /* Handle the .text pseudo-op. This is like the usual one, but it
4180 clears alpha_insn_label and restores auto alignment. */
4192 alpha_insn_label
= NULL
;
4193 alpha_auto_align_on
= 1;
4194 alpha_current_align
= 0;
4197 /* Handle the .data pseudo-op. This is like the usual one, but it
4198 clears alpha_insn_label and restores auto alignment. */
4209 alpha_insn_label
= NULL
;
4210 alpha_auto_align_on
= 1;
4211 alpha_current_align
= 0;
4214 #if defined (OBJ_ECOFF) || defined (OBJ_EVAX)
4216 /* Handle the OSF/1 and openVMS .comm pseudo quirks.
4217 openVMS constructs a section for every common symbol. */
4220 s_alpha_comm (ignore
)
4221 int ignore ATTRIBUTE_UNUSED
;
4223 register char *name
;
4227 register symbolS
*symbolP
;
4230 segT current_section
= now_seg
;
4231 int current_subsec
= now_subseg
;
4235 name
= input_line_pointer
;
4236 c
= get_symbol_end ();
4238 /* just after name is now '\0' */
4239 p
= input_line_pointer
;
4244 /* Alpha OSF/1 compiler doesn't provide the comma, gcc does. */
4245 if (*input_line_pointer
== ',')
4247 input_line_pointer
++;
4250 if ((temp
= get_absolute_expression ()) < 0)
4252 as_warn (_(".COMMon length (%ld.) <0! Ignored."), (long) temp
);
4253 ignore_rest_of_line ();
4258 symbolP
= symbol_find_or_make (name
);
4261 /* Make a section for the common symbol. */
4262 new_seg
= subseg_new (xstrdup (name
), 0);
4268 /* alignment might follow */
4269 if (*input_line_pointer
== ',')
4273 input_line_pointer
++;
4274 align
= get_absolute_expression ();
4275 bfd_set_section_alignment (stdoutput
, new_seg
, align
);
4279 if (S_IS_DEFINED (symbolP
) && ! S_IS_COMMON (symbolP
))
4281 as_bad (_("Ignoring attempt to re-define symbol"));
4282 ignore_rest_of_line ();
4287 if (bfd_section_size (stdoutput
, new_seg
) > 0)
4289 if (bfd_section_size (stdoutput
, new_seg
) != temp
)
4290 as_bad (_("Length of .comm \"%s\" is already %ld. Not changed to %ld."),
4291 S_GET_NAME (symbolP
),
4292 (long) bfd_section_size (stdoutput
, new_seg
),
4296 if (S_GET_VALUE (symbolP
))
4298 if (S_GET_VALUE (symbolP
) != (valueT
) temp
)
4299 as_bad (_("Length of .comm \"%s\" is already %ld. Not changed to %ld."),
4300 S_GET_NAME (symbolP
),
4301 (long) S_GET_VALUE (symbolP
),
4308 subseg_set (new_seg
, 0);
4309 p
= frag_more (temp
);
4310 new_seg
->flags
|= SEC_IS_COMMON
;
4311 if (! S_IS_DEFINED (symbolP
))
4312 S_SET_SEGMENT (symbolP
, new_seg
);
4314 S_SET_VALUE (symbolP
, (valueT
) temp
);
4316 S_SET_EXTERNAL (symbolP
);
4320 subseg_set (current_section
, current_subsec
);
4323 know (symbol_get_frag (symbolP
) == &zero_address_frag
);
4325 demand_empty_rest_of_line ();
4328 #endif /* ! OBJ_ELF */
4332 /* Handle the .rdata pseudo-op. This is like the usual one, but it
4333 clears alpha_insn_label and restores auto alignment. */
4336 s_alpha_rdata (ignore
)
4337 int ignore ATTRIBUTE_UNUSED
;
4341 temp
= get_absolute_expression ();
4342 subseg_new (".rdata", 0);
4343 demand_empty_rest_of_line ();
4344 alpha_insn_label
= NULL
;
4345 alpha_auto_align_on
= 1;
4346 alpha_current_align
= 0;
4353 /* Handle the .sdata pseudo-op. This is like the usual one, but it
4354 clears alpha_insn_label and restores auto alignment. */
4357 s_alpha_sdata (ignore
)
4358 int ignore ATTRIBUTE_UNUSED
;
4362 temp
= get_absolute_expression ();
4363 subseg_new (".sdata", 0);
4364 demand_empty_rest_of_line ();
4365 alpha_insn_label
= NULL
;
4366 alpha_auto_align_on
= 1;
4367 alpha_current_align
= 0;
4372 struct alpha_elf_frame_data
4375 symbolS
*func_end_sym
;
4376 symbolS
*prologue_sym
;
4382 offsetT mask_offset
;
4383 offsetT fmask_offset
;
4385 struct alpha_elf_frame_data
*next
;
4388 static struct alpha_elf_frame_data
*all_frame_data
;
4389 static struct alpha_elf_frame_data
**plast_frame_data
= &all_frame_data
;
4390 static struct alpha_elf_frame_data
*cur_frame_data
;
4392 /* Handle the .section pseudo-op. This is like the usual one, but it
4393 clears alpha_insn_label and restores auto alignment. */
4396 s_alpha_section (ignore
)
4397 int ignore ATTRIBUTE_UNUSED
;
4399 obj_elf_section (ignore
);
4401 alpha_insn_label
= NULL
;
4402 alpha_auto_align_on
= 1;
4403 alpha_current_align
= 0;
4408 int dummy ATTRIBUTE_UNUSED
;
4410 if (ECOFF_DEBUGGING
)
4411 ecoff_directive_ent (0);
4414 char *name
, name_end
;
4415 name
= input_line_pointer
;
4416 name_end
= get_symbol_end ();
4418 if (! is_name_beginner (*name
))
4420 as_warn (_(".ent directive has no name"));
4421 *input_line_pointer
= name_end
;
4428 as_warn (_("nested .ent directives"));
4430 sym
= symbol_find_or_make (name
);
4431 symbol_get_bfdsym (sym
)->flags
|= BSF_FUNCTION
;
4433 cur_frame_data
= calloc (1, sizeof (*cur_frame_data
));
4434 cur_frame_data
->func_sym
= sym
;
4436 /* Provide sensible defaults. */
4437 cur_frame_data
->fp_regno
= 30; /* sp */
4438 cur_frame_data
->ra_regno
= 26; /* ra */
4440 *plast_frame_data
= cur_frame_data
;
4441 plast_frame_data
= &cur_frame_data
->next
;
4443 /* The .ent directive is sometimes followed by a number. Not sure
4444 what it really means, but ignore it. */
4445 *input_line_pointer
= name_end
;
4447 if (*input_line_pointer
== ',')
4449 input_line_pointer
++;
4452 if (ISDIGIT (*input_line_pointer
) || *input_line_pointer
== '-')
4453 (void) get_absolute_expression ();
4455 demand_empty_rest_of_line ();
4461 int dummy ATTRIBUTE_UNUSED
;
4463 if (ECOFF_DEBUGGING
)
4464 ecoff_directive_end (0);
4467 char *name
, name_end
;
4468 name
= input_line_pointer
;
4469 name_end
= get_symbol_end ();
4471 if (! is_name_beginner (*name
))
4473 as_warn (_(".end directive has no name"));
4474 *input_line_pointer
= name_end
;
4480 sym
= symbol_find (name
);
4481 if (!cur_frame_data
)
4482 as_warn (_(".end directive without matching .ent"));
4483 else if (sym
!= cur_frame_data
->func_sym
)
4484 as_warn (_(".end directive names different symbol than .ent"));
4486 /* Create an expression to calculate the size of the function. */
4487 if (sym
&& cur_frame_data
)
4489 OBJ_SYMFIELD_TYPE
*obj
= symbol_get_obj (sym
);
4490 expressionS
*exp
= xmalloc (sizeof (expressionS
));
4493 exp
->X_op
= O_subtract
;
4494 exp
->X_add_symbol
= symbol_temp_new_now ();
4495 exp
->X_op_symbol
= sym
;
4496 exp
->X_add_number
= 0;
4498 cur_frame_data
->func_end_sym
= exp
->X_add_symbol
;
4501 cur_frame_data
= NULL
;
4503 *input_line_pointer
= name_end
;
4505 demand_empty_rest_of_line ();
4513 if (ECOFF_DEBUGGING
)
4516 ecoff_directive_fmask (0);
4518 ecoff_directive_mask (0);
4525 if (!cur_frame_data
)
4528 as_warn (_(".fmask outside of .ent"));
4530 as_warn (_(".mask outside of .ent"));
4531 discard_rest_of_line ();
4535 if (get_absolute_expression_and_terminator (&val
) != ',')
4538 as_warn (_("bad .fmask directive"));
4540 as_warn (_("bad .mask directive"));
4541 --input_line_pointer
;
4542 discard_rest_of_line ();
4546 offset
= get_absolute_expression ();
4547 demand_empty_rest_of_line ();
4551 cur_frame_data
->fmask
= val
;
4552 cur_frame_data
->fmask_offset
= offset
;
4556 cur_frame_data
->mask
= val
;
4557 cur_frame_data
->mask_offset
= offset
;
4563 s_alpha_frame (dummy
)
4564 int dummy ATTRIBUTE_UNUSED
;
4566 if (ECOFF_DEBUGGING
)
4567 ecoff_directive_frame (0);
4572 if (!cur_frame_data
)
4574 as_warn (_(".frame outside of .ent"));
4575 discard_rest_of_line ();
4579 cur_frame_data
->fp_regno
= tc_get_register (1);
4582 if (*input_line_pointer
++ != ','
4583 || get_absolute_expression_and_terminator (&val
) != ',')
4585 as_warn (_("bad .frame directive"));
4586 --input_line_pointer
;
4587 discard_rest_of_line ();
4590 cur_frame_data
->frame_size
= val
;
4592 cur_frame_data
->ra_regno
= tc_get_register (0);
4594 /* Next comes the "offset of saved $a0 from $sp". In gcc terms
4595 this is current_function_pretend_args_size. There's no place
4596 to put this value, so ignore it. */
4602 s_alpha_prologue (ignore
)
4603 int ignore ATTRIBUTE_UNUSED
;
4608 arg
= get_absolute_expression ();
4609 demand_empty_rest_of_line ();
4611 if (ECOFF_DEBUGGING
)
4612 sym
= ecoff_get_cur_proc_sym ();
4614 sym
= cur_frame_data
? cur_frame_data
->func_sym
: NULL
;
4618 as_bad (_(".prologue directive without a preceding .ent directive"));
4624 case 0: /* No PV required. */
4625 S_SET_OTHER (sym
, STO_ALPHA_NOPV
4626 | (S_GET_OTHER (sym
) & ~STO_ALPHA_STD_GPLOAD
));
4628 case 1: /* Std GP load. */
4629 S_SET_OTHER (sym
, STO_ALPHA_STD_GPLOAD
4630 | (S_GET_OTHER (sym
) & ~STO_ALPHA_STD_GPLOAD
));
4632 case 2: /* Non-std use of PV. */
4636 as_bad (_("Invalid argument %d to .prologue."), arg
);
4641 cur_frame_data
->prologue_sym
= symbol_temp_new_now ();
4644 static char *first_file_directive
;
4647 s_alpha_file (ignore
)
4648 int ignore ATTRIBUTE_UNUSED
;
4650 /* Save the first .file directive we see, so that we can change our
4651 minds about whether ecoff debugging should or shouldn't be enabled. */
4652 if (alpha_flag_mdebug
< 0 && ! first_file_directive
)
4654 char *start
= input_line_pointer
;
4657 discard_rest_of_line ();
4659 len
= input_line_pointer
- start
;
4660 first_file_directive
= xmalloc (len
+ 1);
4661 memcpy (first_file_directive
, start
, len
);
4662 first_file_directive
[len
] = '\0';
4664 input_line_pointer
= start
;
4667 if (ECOFF_DEBUGGING
)
4668 ecoff_directive_file (0);
4670 dwarf2_directive_file (0);
4674 s_alpha_loc (ignore
)
4675 int ignore ATTRIBUTE_UNUSED
;
4677 if (ECOFF_DEBUGGING
)
4678 ecoff_directive_loc (0);
4680 dwarf2_directive_loc (0);
4687 /* If we've been undecided about mdebug, make up our minds in favour. */
4688 if (alpha_flag_mdebug
< 0)
4690 segT sec
= subseg_new (".mdebug", 0);
4691 bfd_set_section_flags (stdoutput
, sec
, SEC_HAS_CONTENTS
| SEC_READONLY
);
4692 bfd_set_section_alignment (stdoutput
, sec
, 3);
4694 ecoff_read_begin_hook ();
4696 if (first_file_directive
)
4698 char *save_ilp
= input_line_pointer
;
4699 input_line_pointer
= first_file_directive
;
4700 ecoff_directive_file (0);
4701 input_line_pointer
= save_ilp
;
4702 free (first_file_directive
);
4705 alpha_flag_mdebug
= 1;
4711 s_alpha_coff_wrapper (which
)
4714 static void (* const fns
[]) PARAMS ((int)) = {
4715 ecoff_directive_begin
,
4716 ecoff_directive_bend
,
4717 ecoff_directive_def
,
4718 ecoff_directive_dim
,
4719 ecoff_directive_endef
,
4720 ecoff_directive_scl
,
4721 ecoff_directive_tag
,
4722 ecoff_directive_val
,
4725 assert (which
>= 0 && which
< (int) (sizeof (fns
)/sizeof (*fns
)));
4727 if (ECOFF_DEBUGGING
)
4731 as_bad (_("ECOFF debugging is disabled."));
4732 ignore_rest_of_line ();
4736 /* Called at the end of assembly. Here we emit unwind info for frames
4737 unless the compiler has done it for us. */
4740 alpha_elf_md_end (void)
4742 struct alpha_elf_frame_data
*p
;
4745 as_warn (_(".ent directive without matching .end"));
4747 /* If someone has generated the unwind info themselves, great. */
4748 if (bfd_get_section_by_name (stdoutput
, ".eh_frame") != NULL
)
4751 /* Generate .eh_frame data for the unwind directives specified. */
4752 for (p
= all_frame_data
; p
; p
= p
->next
)
4753 if (p
->prologue_sym
)
4755 /* Create a temporary symbol at the same location as our
4756 function symbol. This prevents problems with globals. */
4757 cfi_new_fde (symbol_temp_new (S_GET_SEGMENT (p
->func_sym
),
4758 S_GET_VALUE (p
->func_sym
),
4759 symbol_get_frag (p
->func_sym
)));
4761 cfi_set_return_column (p
->ra_regno
);
4762 cfi_add_CFA_def_cfa_register (30);
4763 if (p
->fp_regno
!= 30 || p
->mask
|| p
->fmask
|| p
->frame_size
)
4768 cfi_add_advance_loc (p
->prologue_sym
);
4770 if (p
->fp_regno
!= 30)
4771 if (p
->frame_size
!= 0)
4772 cfi_add_CFA_def_cfa (p
->fp_regno
, p
->frame_size
);
4774 cfi_add_CFA_def_cfa_register (p
->fp_regno
);
4775 else if (p
->frame_size
!= 0)
4776 cfi_add_CFA_def_cfa_offset (p
->frame_size
);
4779 offset
= p
->mask_offset
;
4781 /* Recall that $26 is special-cased and stored first. */
4782 if ((mask
>> 26) & 1)
4784 cfi_add_CFA_offset (26, offset
);
4795 cfi_add_CFA_offset (i
, offset
);
4800 offset
= p
->fmask_offset
;
4808 cfi_add_CFA_offset (i
+ 32, offset
);
4813 cfi_end_fde (p
->func_end_sym
);
4818 s_alpha_usepv (int unused ATTRIBUTE_UNUSED
)
4820 char *name
, name_end
;
4821 char *which
, which_end
;
4825 name
= input_line_pointer
;
4826 name_end
= get_symbol_end ();
4828 if (! is_name_beginner (*name
))
4830 as_bad (_(".usepv directive has no name"));
4831 *input_line_pointer
= name_end
;
4832 ignore_rest_of_line ();
4836 sym
= symbol_find_or_make (name
);
4837 *input_line_pointer
++ = name_end
;
4839 if (name_end
!= ',')
4841 as_bad (_(".usepv directive has no type"));
4842 ignore_rest_of_line ();
4847 which
= input_line_pointer
;
4848 which_end
= get_symbol_end ();
4850 if (strcmp (which
, "no") == 0)
4851 other
= STO_ALPHA_NOPV
;
4852 else if (strcmp (which
, "std") == 0)
4853 other
= STO_ALPHA_STD_GPLOAD
;
4856 as_bad (_("unknown argument for .usepv"));
4860 *input_line_pointer
= which_end
;
4861 demand_empty_rest_of_line ();
4863 S_SET_OTHER (sym
, other
| (S_GET_OTHER (sym
) & ~STO_ALPHA_STD_GPLOAD
));
4865 #endif /* OBJ_ELF */
4867 /* Standard calling conventions leaves the CFA at $30 on entry. */
4870 alpha_cfi_frame_initial_instructions ()
4872 cfi_add_CFA_def_cfa_register (30);
4877 /* Handle the section specific pseudo-op. */
4880 s_alpha_section (secid
)
4884 #define EVAX_SECTION_COUNT 5
4885 static char *section_name
[EVAX_SECTION_COUNT
+ 1] =
4886 { "NULL", ".rdata", ".comm", ".link", ".ctors", ".dtors" };
4888 if ((secid
<= 0) || (secid
> EVAX_SECTION_COUNT
))
4890 as_fatal (_("Unknown section directive"));
4891 demand_empty_rest_of_line ();
4894 temp
= get_absolute_expression ();
4895 subseg_new (section_name
[secid
], 0);
4896 demand_empty_rest_of_line ();
4897 alpha_insn_label
= NULL
;
4898 alpha_auto_align_on
= 1;
4899 alpha_current_align
= 0;
4902 /* Parse .ent directives. */
4905 s_alpha_ent (ignore
)
4906 int ignore ATTRIBUTE_UNUSED
;
4909 expressionS symexpr
;
4911 alpha_evax_proc
.pdsckind
= 0;
4912 alpha_evax_proc
.framereg
= -1;
4913 alpha_evax_proc
.framesize
= 0;
4914 alpha_evax_proc
.rsa_offset
= 0;
4915 alpha_evax_proc
.ra_save
= AXP_REG_RA
;
4916 alpha_evax_proc
.fp_save
= -1;
4917 alpha_evax_proc
.imask
= 0;
4918 alpha_evax_proc
.fmask
= 0;
4919 alpha_evax_proc
.prologue
= 0;
4920 alpha_evax_proc
.type
= 0;
4922 expression (&symexpr
);
4924 if (symexpr
.X_op
!= O_symbol
)
4926 as_fatal (_(".ent directive has no symbol"));
4927 demand_empty_rest_of_line ();
4931 symbol
= make_expr_symbol (&symexpr
);
4932 symbol_get_bfdsym (symbol
)->flags
|= BSF_FUNCTION
;
4933 alpha_evax_proc
.symbol
= symbol
;
4935 demand_empty_rest_of_line ();
4938 /* Parse .frame <framreg>,<framesize>,RA,<rsa_offset> directives. */
4941 s_alpha_frame (ignore
)
4942 int ignore ATTRIBUTE_UNUSED
;
4946 alpha_evax_proc
.framereg
= tc_get_register (1);
4949 if (*input_line_pointer
++ != ','
4950 || get_absolute_expression_and_terminator (&val
) != ',')
4952 as_warn (_("Bad .frame directive 1./2. param"));
4953 --input_line_pointer
;
4954 demand_empty_rest_of_line ();
4958 alpha_evax_proc
.framesize
= val
;
4960 (void) tc_get_register (1);
4962 if (*input_line_pointer
++ != ',')
4964 as_warn (_("Bad .frame directive 3./4. param"));
4965 --input_line_pointer
;
4966 demand_empty_rest_of_line ();
4969 alpha_evax_proc
.rsa_offset
= get_absolute_expression ();
4973 s_alpha_pdesc (ignore
)
4974 int ignore ATTRIBUTE_UNUSED
;
4983 segment_info_type
*seginfo
= seg_info (alpha_link_section
);
4985 if (now_seg
!= alpha_link_section
)
4987 as_bad (_(".pdesc directive not in link (.link) section"));
4988 demand_empty_rest_of_line ();
4992 if ((alpha_evax_proc
.symbol
== 0)
4993 || (!S_IS_DEFINED (alpha_evax_proc
.symbol
)))
4995 as_fatal (_(".pdesc has no matching .ent"));
4996 demand_empty_rest_of_line ();
5000 *symbol_get_obj (alpha_evax_proc
.symbol
) =
5001 (valueT
) seginfo
->literal_pool_size
;
5004 if (exp
.X_op
!= O_symbol
)
5006 as_warn (_(".pdesc directive has no entry symbol"));
5007 demand_empty_rest_of_line ();
5011 entry_sym
= make_expr_symbol (&exp
);
5012 /* Save bfd symbol of proc desc in function symbol. */
5013 symbol_get_bfdsym (alpha_evax_proc
.symbol
)->udata
.p
5014 = symbol_get_bfdsym (entry_sym
);
5017 if (*input_line_pointer
++ != ',')
5019 as_warn (_("No comma after .pdesc <entryname>"));
5020 demand_empty_rest_of_line ();
5025 name
= input_line_pointer
;
5026 name_end
= get_symbol_end ();
5028 if (strncmp (name
, "stack", 5) == 0)
5030 alpha_evax_proc
.pdsckind
= PDSC_S_K_KIND_FP_STACK
;
5032 else if (strncmp (name
, "reg", 3) == 0)
5034 alpha_evax_proc
.pdsckind
= PDSC_S_K_KIND_FP_REGISTER
;
5036 else if (strncmp (name
, "null", 4) == 0)
5038 alpha_evax_proc
.pdsckind
= PDSC_S_K_KIND_NULL
;
5042 as_fatal (_("unknown procedure kind"));
5043 demand_empty_rest_of_line ();
5047 *input_line_pointer
= name_end
;
5048 demand_empty_rest_of_line ();
5050 #ifdef md_flush_pending_output
5051 md_flush_pending_output ();
5054 frag_align (3, 0, 0);
5056 fixp
= fix_new (frag_now
, p
- frag_now
->fr_literal
, 8, 0, 0, 0, 0);
5058 seginfo
->literal_pool_size
+= 16;
5060 *p
= alpha_evax_proc
.pdsckind
5061 | ((alpha_evax_proc
.framereg
== 29) ? PDSC_S_M_BASE_REG_IS_FP
: 0);
5062 *(p
+ 1) = PDSC_S_M_NATIVE
| PDSC_S_M_NO_JACKET
;
5064 switch (alpha_evax_proc
.pdsckind
)
5066 case PDSC_S_K_KIND_NULL
:
5070 case PDSC_S_K_KIND_FP_REGISTER
:
5071 *(p
+ 2) = alpha_evax_proc
.fp_save
;
5072 *(p
+ 3) = alpha_evax_proc
.ra_save
;
5074 case PDSC_S_K_KIND_FP_STACK
:
5075 md_number_to_chars (p
+ 2, (valueT
) alpha_evax_proc
.rsa_offset
, 2);
5077 default: /* impossible */
5082 *(p
+ 5) = alpha_evax_proc
.type
& 0x0f;
5084 /* Signature offset. */
5085 md_number_to_chars (p
+ 6, (valueT
) 0, 2);
5087 fix_new_exp (frag_now
, p
- frag_now
->fr_literal
+8, 8, &exp
, 0, BFD_RELOC_64
);
5089 if (alpha_evax_proc
.pdsckind
== PDSC_S_K_KIND_NULL
)
5092 /* Add dummy fix to make add_to_link_pool work. */
5094 fixp
= fix_new (frag_now
, p
- frag_now
->fr_literal
, 8, 0, 0, 0, 0);
5096 seginfo
->literal_pool_size
+= 8;
5098 /* pdesc+16: Size. */
5099 md_number_to_chars (p
, (valueT
) alpha_evax_proc
.framesize
, 4);
5101 md_number_to_chars (p
+ 4, (valueT
) 0, 2);
5104 md_number_to_chars (p
+ 6, alpha_evax_proc
.prologue
, 2);
5106 if (alpha_evax_proc
.pdsckind
== PDSC_S_K_KIND_FP_REGISTER
)
5109 /* Add dummy fix to make add_to_link_pool work. */
5111 fixp
= fix_new (frag_now
, p
- frag_now
->fr_literal
, 8, 0, 0, 0, 0);
5113 seginfo
->literal_pool_size
+= 8;
5115 /* pdesc+24: register masks. */
5117 md_number_to_chars (p
, alpha_evax_proc
.imask
, 4);
5118 md_number_to_chars (p
+ 4, alpha_evax_proc
.fmask
, 4);
5121 /* Support for crash debug on vms. */
5124 s_alpha_name (ignore
)
5125 int ignore ATTRIBUTE_UNUSED
;
5129 segment_info_type
*seginfo
= seg_info (alpha_link_section
);
5131 if (now_seg
!= alpha_link_section
)
5133 as_bad (_(".name directive not in link (.link) section"));
5134 demand_empty_rest_of_line ();
5139 if (exp
.X_op
!= O_symbol
)
5141 as_warn (_(".name directive has no symbol"));
5142 demand_empty_rest_of_line ();
5146 demand_empty_rest_of_line ();
5148 #ifdef md_flush_pending_output
5149 md_flush_pending_output ();
5152 frag_align (3, 0, 0);
5154 seginfo
->literal_pool_size
+= 8;
5156 fix_new_exp (frag_now
, p
- frag_now
->fr_literal
, 8, &exp
, 0, BFD_RELOC_64
);
5160 s_alpha_linkage (ignore
)
5161 int ignore ATTRIBUTE_UNUSED
;
5166 #ifdef md_flush_pending_output
5167 md_flush_pending_output ();
5171 if (exp
.X_op
!= O_symbol
)
5173 as_fatal (_("No symbol after .linkage"));
5177 p
= frag_more (LKP_S_K_SIZE
);
5178 memset (p
, 0, LKP_S_K_SIZE
);
5179 fix_new_exp (frag_now
, p
- frag_now
->fr_literal
, LKP_S_K_SIZE
, &exp
, 0,\
5180 BFD_RELOC_ALPHA_LINKAGE
);
5182 demand_empty_rest_of_line ();
5186 s_alpha_code_address (ignore
)
5187 int ignore ATTRIBUTE_UNUSED
;
5192 #ifdef md_flush_pending_output
5193 md_flush_pending_output ();
5197 if (exp
.X_op
!= O_symbol
)
5199 as_fatal (_("No symbol after .code_address"));
5205 fix_new_exp (frag_now
, p
- frag_now
->fr_literal
, 8, &exp
, 0,\
5206 BFD_RELOC_ALPHA_CODEADDR
);
5208 demand_empty_rest_of_line ();
5212 s_alpha_fp_save (ignore
)
5213 int ignore ATTRIBUTE_UNUSED
;
5216 alpha_evax_proc
.fp_save
= tc_get_register (1);
5218 demand_empty_rest_of_line ();
5222 s_alpha_mask (ignore
)
5223 int ignore ATTRIBUTE_UNUSED
;
5227 if (get_absolute_expression_and_terminator (&val
) != ',')
5229 as_warn (_("Bad .mask directive"));
5230 --input_line_pointer
;
5234 alpha_evax_proc
.imask
= val
;
5235 (void) get_absolute_expression ();
5237 demand_empty_rest_of_line ();
5241 s_alpha_fmask (ignore
)
5242 int ignore ATTRIBUTE_UNUSED
;
5246 if (get_absolute_expression_and_terminator (&val
) != ',')
5248 as_warn (_("Bad .fmask directive"));
5249 --input_line_pointer
;
5253 alpha_evax_proc
.fmask
= val
;
5254 (void) get_absolute_expression ();
5256 demand_empty_rest_of_line ();
5260 s_alpha_end (ignore
)
5261 int ignore ATTRIBUTE_UNUSED
;
5265 c
= get_symbol_end ();
5266 *input_line_pointer
= c
;
5267 demand_empty_rest_of_line ();
5268 alpha_evax_proc
.symbol
= 0;
5272 s_alpha_file (ignore
)
5273 int ignore ATTRIBUTE_UNUSED
;
5277 static char case_hack
[32];
5279 sprintf (case_hack
, "<CASE:%01d%01d>",
5280 alpha_flag_hash_long_names
, alpha_flag_show_after_trunc
);
5282 s
= symbol_find_or_make (case_hack
);
5283 symbol_get_bfdsym (s
)->flags
|= BSF_FILE
;
5285 get_absolute_expression ();
5286 s
= symbol_find_or_make (demand_copy_string (&length
));
5287 symbol_get_bfdsym (s
)->flags
|= BSF_FILE
;
5288 demand_empty_rest_of_line ();
5290 #endif /* OBJ_EVAX */
5292 /* Handle the .gprel32 pseudo op. */
5295 s_alpha_gprel32 (ignore
)
5296 int ignore ATTRIBUTE_UNUSED
;
5308 e
.X_add_symbol
= section_symbol (absolute_section
);
5321 e
.X_add_symbol
= section_symbol (absolute_section
);
5324 e
.X_op
= O_subtract
;
5325 e
.X_op_symbol
= alpha_gp_symbol
;
5333 if (alpha_auto_align_on
&& alpha_current_align
< 2)
5334 alpha_align (2, (char *) NULL
, alpha_insn_label
, 0);
5335 if (alpha_current_align
> 2)
5336 alpha_current_align
= 2;
5337 alpha_insn_label
= NULL
;
5341 fix_new_exp (frag_now
, p
- frag_now
->fr_literal
, 4,
5342 &e
, 0, BFD_RELOC_GPREL32
);
5345 /* Handle floating point allocation pseudo-ops. This is like the
5346 generic vresion, but it makes sure the current label, if any, is
5347 correctly aligned. */
5350 s_alpha_float_cons (type
)
5377 if (alpha_auto_align_on
&& alpha_current_align
< log_size
)
5378 alpha_align (log_size
, (char *) NULL
, alpha_insn_label
, 0);
5379 if (alpha_current_align
> log_size
)
5380 alpha_current_align
= log_size
;
5381 alpha_insn_label
= NULL
;
5386 /* Handle the .proc pseudo op. We don't really do much with it except
5390 s_alpha_proc (is_static
)
5391 int is_static ATTRIBUTE_UNUSED
;
5399 /* Takes ".proc name,nargs" */
5401 name
= input_line_pointer
;
5402 c
= get_symbol_end ();
5403 p
= input_line_pointer
;
5404 symbolP
= symbol_find_or_make (name
);
5407 if (*input_line_pointer
!= ',')
5410 as_warn (_("Expected comma after name \"%s\""), name
);
5413 ignore_rest_of_line ();
5417 input_line_pointer
++;
5418 temp
= get_absolute_expression ();
5420 /* *symbol_get_obj (symbolP) = (signed char) temp; */
5421 as_warn (_("unhandled: .proc %s,%d"), name
, temp
);
5422 demand_empty_rest_of_line ();
5425 /* Handle the .set pseudo op. This is used to turn on and off most of
5426 the assembler features. */
5430 int x ATTRIBUTE_UNUSED
;
5436 name
= input_line_pointer
;
5437 ch
= get_symbol_end ();
5440 if (s
[0] == 'n' && s
[1] == 'o')
5445 if (!strcmp ("reorder", s
))
5447 else if (!strcmp ("at", s
))
5448 alpha_noat_on
= !yesno
;
5449 else if (!strcmp ("macro", s
))
5450 alpha_macros_on
= yesno
;
5451 else if (!strcmp ("move", s
))
5453 else if (!strcmp ("volatile", s
))
5456 as_warn (_("Tried to .set unrecognized mode `%s'"), name
);
5458 *input_line_pointer
= ch
;
5459 demand_empty_rest_of_line ();
5462 /* Handle the .base pseudo op. This changes the assembler's notion of
5463 the $gp register. */
5466 s_alpha_base (ignore
)
5467 int ignore ATTRIBUTE_UNUSED
;
5470 if (first_32bit_quadrant
)
5472 /* not fatal, but it might not work in the end */
5473 as_warn (_("File overrides no-base-register option."));
5474 first_32bit_quadrant
= 0;
5479 if (*input_line_pointer
== '$')
5481 input_line_pointer
++;
5482 if (*input_line_pointer
== 'r')
5483 input_line_pointer
++;
5486 alpha_gp_register
= get_absolute_expression ();
5487 if (alpha_gp_register
< 0 || alpha_gp_register
> 31)
5489 alpha_gp_register
= AXP_REG_GP
;
5490 as_warn (_("Bad base register, using $%d."), alpha_gp_register
);
5493 demand_empty_rest_of_line ();
5496 /* Handle the .align pseudo-op. This aligns to a power of two. It
5497 also adjusts any current instruction label. We treat this the same
5498 way the MIPS port does: .align 0 turns off auto alignment. */
5501 s_alpha_align (ignore
)
5502 int ignore ATTRIBUTE_UNUSED
;
5506 long max_alignment
= 15;
5508 align
= get_absolute_expression ();
5509 if (align
> max_alignment
)
5511 align
= max_alignment
;
5512 as_bad (_("Alignment too large: %d. assumed"), align
);
5516 as_warn (_("Alignment negative: 0 assumed"));
5520 if (*input_line_pointer
== ',')
5522 input_line_pointer
++;
5523 fill
= get_absolute_expression ();
5531 alpha_auto_align_on
= 1;
5532 alpha_align (align
, pfill
, alpha_insn_label
, 1);
5536 alpha_auto_align_on
= 0;
5539 demand_empty_rest_of_line ();
5542 /* Hook the normal string processor to reset known alignment. */
5545 s_alpha_stringer (terminate
)
5548 alpha_current_align
= 0;
5549 alpha_insn_label
= NULL
;
5550 stringer (terminate
);
5553 /* Hook the normal space processing to reset known alignment. */
5556 s_alpha_space (ignore
)
5559 alpha_current_align
= 0;
5560 alpha_insn_label
= NULL
;
5564 /* Hook into cons for auto-alignment. */
5567 alpha_cons_align (size
)
5573 while ((size
>>= 1) != 0)
5576 if (alpha_auto_align_on
&& alpha_current_align
< log_size
)
5577 alpha_align (log_size
, (char *) NULL
, alpha_insn_label
, 0);
5578 if (alpha_current_align
> log_size
)
5579 alpha_current_align
= log_size
;
5580 alpha_insn_label
= NULL
;
5583 /* Here come the .uword, .ulong, and .uquad explicitly unaligned
5584 pseudos. We just turn off auto-alignment and call down to cons. */
5587 s_alpha_ucons (bytes
)
5590 int hold
= alpha_auto_align_on
;
5591 alpha_auto_align_on
= 0;
5593 alpha_auto_align_on
= hold
;
5596 /* Switch the working cpu type. */
5599 s_alpha_arch (ignored
)
5600 int ignored ATTRIBUTE_UNUSED
;
5603 const struct cpu_type
*p
;
5606 name
= input_line_pointer
;
5607 ch
= get_symbol_end ();
5609 for (p
= cpu_types
; p
->name
; ++p
)
5610 if (strcmp (name
, p
->name
) == 0)
5612 alpha_target_name
= p
->name
, alpha_target
= p
->flags
;
5615 as_warn ("Unknown CPU identifier `%s'", name
);
5618 *input_line_pointer
= ch
;
5619 demand_empty_rest_of_line ();
5623 /* print token expression with alpha specific extension. */
5626 alpha_print_token (f
, exp
)
5628 const expressionS
*exp
;
5638 expressionS nexp
= *exp
;
5639 nexp
.X_op
= O_register
;
5640 print_expr (f
, &nexp
);
5645 print_expr (f
, exp
);
5651 /* The target specific pseudo-ops which we support. */
5653 const pseudo_typeS md_pseudo_table
[] = {
5655 {"comm", s_alpha_comm
, 0}, /* osf1 compiler does this */
5656 {"rdata", s_alpha_rdata
, 0},
5658 {"text", s_alpha_text
, 0},
5659 {"data", s_alpha_data
, 0},
5661 {"sdata", s_alpha_sdata
, 0},
5664 {"section", s_alpha_section
, 0},
5665 {"section.s", s_alpha_section
, 0},
5666 {"sect", s_alpha_section
, 0},
5667 {"sect.s", s_alpha_section
, 0},
5670 { "pdesc", s_alpha_pdesc
, 0},
5671 { "name", s_alpha_name
, 0},
5672 { "linkage", s_alpha_linkage
, 0},
5673 { "code_address", s_alpha_code_address
, 0},
5674 { "ent", s_alpha_ent
, 0},
5675 { "frame", s_alpha_frame
, 0},
5676 { "fp_save", s_alpha_fp_save
, 0},
5677 { "mask", s_alpha_mask
, 0},
5678 { "fmask", s_alpha_fmask
, 0},
5679 { "end", s_alpha_end
, 0},
5680 { "file", s_alpha_file
, 0},
5681 { "rdata", s_alpha_section
, 1},
5682 { "comm", s_alpha_comm
, 0},
5683 { "link", s_alpha_section
, 3},
5684 { "ctors", s_alpha_section
, 4},
5685 { "dtors", s_alpha_section
, 5},
5688 /* Frame related pseudos. */
5689 {"ent", s_alpha_ent
, 0},
5690 {"end", s_alpha_end
, 0},
5691 {"mask", s_alpha_mask
, 0},
5692 {"fmask", s_alpha_mask
, 1},
5693 {"frame", s_alpha_frame
, 0},
5694 {"prologue", s_alpha_prologue
, 0},
5695 {"file", s_alpha_file
, 5},
5696 {"loc", s_alpha_loc
, 9},
5697 {"stabs", s_alpha_stab
, 's'},
5698 {"stabn", s_alpha_stab
, 'n'},
5699 {"usepv", s_alpha_usepv
, 0},
5700 /* COFF debugging related pseudos. */
5701 {"begin", s_alpha_coff_wrapper
, 0},
5702 {"bend", s_alpha_coff_wrapper
, 1},
5703 {"def", s_alpha_coff_wrapper
, 2},
5704 {"dim", s_alpha_coff_wrapper
, 3},
5705 {"endef", s_alpha_coff_wrapper
, 4},
5706 {"scl", s_alpha_coff_wrapper
, 5},
5707 {"tag", s_alpha_coff_wrapper
, 6},
5708 {"val", s_alpha_coff_wrapper
, 7},
5710 {"prologue", s_ignore
, 0},
5712 {"gprel32", s_alpha_gprel32
, 0},
5713 {"t_floating", s_alpha_float_cons
, 'd'},
5714 {"s_floating", s_alpha_float_cons
, 'f'},
5715 {"f_floating", s_alpha_float_cons
, 'F'},
5716 {"g_floating", s_alpha_float_cons
, 'G'},
5717 {"d_floating", s_alpha_float_cons
, 'D'},
5719 {"proc", s_alpha_proc
, 0},
5720 {"aproc", s_alpha_proc
, 1},
5721 {"set", s_alpha_set
, 0},
5722 {"reguse", s_ignore
, 0},
5723 {"livereg", s_ignore
, 0},
5724 {"base", s_alpha_base
, 0}, /*??*/
5725 {"option", s_ignore
, 0},
5726 {"aent", s_ignore
, 0},
5727 {"ugen", s_ignore
, 0},
5728 {"eflag", s_ignore
, 0},
5730 {"align", s_alpha_align
, 0},
5731 {"double", s_alpha_float_cons
, 'd'},
5732 {"float", s_alpha_float_cons
, 'f'},
5733 {"single", s_alpha_float_cons
, 'f'},
5734 {"ascii", s_alpha_stringer
, 0},
5735 {"asciz", s_alpha_stringer
, 1},
5736 {"string", s_alpha_stringer
, 1},
5737 {"space", s_alpha_space
, 0},
5738 {"skip", s_alpha_space
, 0},
5739 {"zero", s_alpha_space
, 0},
5741 /* Unaligned data pseudos. */
5742 {"uword", s_alpha_ucons
, 2},
5743 {"ulong", s_alpha_ucons
, 4},
5744 {"uquad", s_alpha_ucons
, 8},
5747 /* Dwarf wants these versions of unaligned. */
5748 {"2byte", s_alpha_ucons
, 2},
5749 {"4byte", s_alpha_ucons
, 4},
5750 {"8byte", s_alpha_ucons
, 8},
5753 /* We don't do any optimizing, so we can safely ignore these. */
5754 {"noalias", s_ignore
, 0},
5755 {"alias", s_ignore
, 0},
5757 {"arch", s_alpha_arch
, 0},
5762 /* Build a BFD section with its flags set appropriately for the .lita,
5763 .lit8, or .lit4 sections. */
5766 create_literal_section (name
, secp
, symp
)
5771 segT current_section
= now_seg
;
5772 int current_subsec
= now_subseg
;
5775 *secp
= new_sec
= subseg_new (name
, 0);
5776 subseg_set (current_section
, current_subsec
);
5777 bfd_set_section_alignment (stdoutput
, new_sec
, 4);
5778 bfd_set_section_flags (stdoutput
, new_sec
,
5779 SEC_RELOC
| SEC_ALLOC
| SEC_LOAD
| SEC_READONLY
5782 S_CLEAR_EXTERNAL (*symp
= section_symbol (new_sec
));
5787 /* @@@ GP selection voodoo. All of this seems overly complicated and
5788 unnecessary; which is the primary reason it's for ECOFF only. */
5789 static inline void maybe_set_gp
PARAMS ((asection
*));
5798 vma
= bfd_get_section_vma (foo
, sec
);
5799 if (vma
&& vma
< alpha_gp_value
)
5800 alpha_gp_value
= vma
;
5806 assert (alpha_gp_value
== 0);
5808 /* Get minus-one in whatever width... */
5812 /* Select the smallest VMA of these existing sections. */
5813 maybe_set_gp (alpha_lita_section
);
5815 /* These were disabled before -- should we use them? */
5816 maybe_set_gp (sdata
);
5817 maybe_set_gp (lit8_sec
);
5818 maybe_set_gp (lit4_sec
);
5821 /* @@ Will a simple 0x8000 work here? If not, why not? */
5822 #define GP_ADJUSTMENT (0x8000 - 0x10)
5824 alpha_gp_value
+= GP_ADJUSTMENT
;
5826 S_SET_VALUE (alpha_gp_symbol
, alpha_gp_value
);
5829 printf (_("Chose GP value of %lx\n"), alpha_gp_value
);
5832 #endif /* OBJ_ECOFF */
5835 /* Map 's' to SHF_ALPHA_GPREL. */
5838 alpha_elf_section_letter (letter
, ptr_msg
)
5843 return SHF_ALPHA_GPREL
;
5845 *ptr_msg
= _("Bad .section directive: want a,s,w,x,M,S,G,T in string");
5849 /* Map SHF_ALPHA_GPREL to SEC_SMALL_DATA. */
5852 alpha_elf_section_flags (flags
, attr
, type
)
5854 int attr
, type ATTRIBUTE_UNUSED
;
5856 if (attr
& SHF_ALPHA_GPREL
)
5857 flags
|= SEC_SMALL_DATA
;
5860 #endif /* OBJ_ELF */
5862 /* Called internally to handle all alignment needs. This takes care
5863 of eliding calls to frag_align if'n the cached current alignment
5864 says we've already got it, as well as taking care of the auto-align
5865 feature wrt labels. */
5868 alpha_align (n
, pfill
, label
, force
)
5872 int force ATTRIBUTE_UNUSED
;
5874 if (alpha_current_align
>= n
)
5879 if (subseg_text_p (now_seg
))
5880 frag_align_code (n
, 0);
5882 frag_align (n
, 0, 0);
5885 frag_align (n
, *pfill
, 0);
5887 alpha_current_align
= n
;
5889 if (label
!= NULL
&& S_GET_SEGMENT (label
) == now_seg
)
5891 symbol_set_frag (label
, frag_now
);
5892 S_SET_VALUE (label
, (valueT
) frag_now_fix ());
5895 record_alignment (now_seg
, n
);
5897 /* ??? If alpha_flag_relax && force && elf, record the requested alignment
5898 in a reloc for the linker to see. */
5901 /* This is called from HANDLE_ALIGN in write.c. Fill in the contents
5902 of an rs_align_code fragment. */
5905 alpha_handle_align (fragp
)
5908 static char const unop
[4] = { 0x00, 0x00, 0xfe, 0x2f };
5909 static char const nopunop
[8] = {
5910 0x1f, 0x04, 0xff, 0x47,
5911 0x00, 0x00, 0xfe, 0x2f
5917 if (fragp
->fr_type
!= rs_align_code
)
5920 bytes
= fragp
->fr_next
->fr_address
- fragp
->fr_address
- fragp
->fr_fix
;
5921 p
= fragp
->fr_literal
+ fragp
->fr_fix
;
5934 memcpy (p
, unop
, 4);
5940 memcpy (p
, nopunop
, 8);
5942 fragp
->fr_fix
+= fix
;
5946 /* The Alpha has support for some VAX floating point types, as well as for
5947 IEEE floating point. We consider IEEE to be the primary floating point
5948 format, and sneak in the VAX floating point support here. */
5949 #define md_atof vax_md_atof
5950 #include "config/atof-vax.c"