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, 2004, 2005, 2007, 2008, 2009
4 Free Software Foundation, Inc.
5 Contributed by Carnegie Mellon University, 1993.
6 Written by Alessandro Forin, based on earlier gas-1.38 target CPU files.
7 Modified by Ken Raeburn for gas-2.x and ECOFF support.
8 Modified by Richard Henderson for ELF support.
9 Modified by Klaus K"ampf for EVAX (OpenVMS/Alpha) support.
11 This file is part of GAS, the GNU Assembler.
13 GAS is free software; you can redistribute it and/or modify
14 it under the terms of the GNU General Public License as published by
15 the Free Software Foundation; either version 3, or (at your option)
18 GAS is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 GNU General Public License for more details.
23 You should have received a copy of the GNU General Public License
24 along with GAS; see the file COPYING. If not, write to the Free
25 Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
28 /* Mach Operating System
29 Copyright (c) 1993 Carnegie Mellon University
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. */
54 #include "struc-symbol.h"
57 #include "opcode/alpha.h"
60 #include "elf/alpha.h"
67 #include "dwarf2dbg.h"
68 #include "dw2gencfi.h"
69 #include "safe-ctype.h"
73 #define TOKENIZE_ERROR -1
74 #define TOKENIZE_ERROR_REPORT -2
75 #define MAX_INSN_FIXUPS 2
76 #define MAX_INSN_ARGS 5
81 bfd_reloc_code_real_type reloc
;
83 symbolS
*xtrasym
, *procsym
;
91 struct alpha_fixup fixups
[MAX_INSN_FIXUPS
];
109 void (*emit
) (const expressionS
*, int, const void *);
111 enum alpha_macro_arg argsets
[16];
114 /* Extra expression types. */
116 #define O_pregister O_md1 /* O_register, in parentheses. */
117 #define O_cpregister O_md2 /* + a leading comma. */
119 /* The alpha_reloc_op table below depends on the ordering of these. */
120 #define O_literal O_md3 /* !literal relocation. */
121 #define O_lituse_addr O_md4 /* !lituse_addr relocation. */
122 #define O_lituse_base O_md5 /* !lituse_base relocation. */
123 #define O_lituse_bytoff O_md6 /* !lituse_bytoff relocation. */
124 #define O_lituse_jsr O_md7 /* !lituse_jsr relocation. */
125 #define O_lituse_tlsgd O_md8 /* !lituse_tlsgd relocation. */
126 #define O_lituse_tlsldm O_md9 /* !lituse_tlsldm relocation. */
127 #define O_lituse_jsrdirect O_md10 /* !lituse_jsrdirect relocation. */
128 #define O_gpdisp O_md11 /* !gpdisp relocation. */
129 #define O_gprelhigh O_md12 /* !gprelhigh relocation. */
130 #define O_gprellow O_md13 /* !gprellow relocation. */
131 #define O_gprel O_md14 /* !gprel relocation. */
132 #define O_samegp O_md15 /* !samegp relocation. */
133 #define O_tlsgd O_md16 /* !tlsgd relocation. */
134 #define O_tlsldm O_md17 /* !tlsldm relocation. */
135 #define O_gotdtprel O_md18 /* !gotdtprel relocation. */
136 #define O_dtprelhi O_md19 /* !dtprelhi relocation. */
137 #define O_dtprello O_md20 /* !dtprello relocation. */
138 #define O_dtprel O_md21 /* !dtprel relocation. */
139 #define O_gottprel O_md22 /* !gottprel relocation. */
140 #define O_tprelhi O_md23 /* !tprelhi relocation. */
141 #define O_tprello O_md24 /* !tprello relocation. */
142 #define O_tprel O_md25 /* !tprel relocation. */
144 #define DUMMY_RELOC_LITUSE_ADDR (BFD_RELOC_UNUSED + 1)
145 #define DUMMY_RELOC_LITUSE_BASE (BFD_RELOC_UNUSED + 2)
146 #define DUMMY_RELOC_LITUSE_BYTOFF (BFD_RELOC_UNUSED + 3)
147 #define DUMMY_RELOC_LITUSE_JSR (BFD_RELOC_UNUSED + 4)
148 #define DUMMY_RELOC_LITUSE_TLSGD (BFD_RELOC_UNUSED + 5)
149 #define DUMMY_RELOC_LITUSE_TLSLDM (BFD_RELOC_UNUSED + 6)
150 #define DUMMY_RELOC_LITUSE_JSRDIRECT (BFD_RELOC_UNUSED + 7)
152 #define USER_RELOC_P(R) ((R) >= O_literal && (R) <= O_tprel)
154 /* Macros for extracting the type and number of encoded register tokens. */
156 #define is_ir_num(x) (((x) & 32) == 0)
157 #define is_fpr_num(x) (((x) & 32) != 0)
158 #define regno(x) ((x) & 31)
160 /* Something odd inherited from the old assembler. */
162 #define note_gpreg(R) (alpha_gprmask |= (1 << (R)))
163 #define note_fpreg(R) (alpha_fprmask |= (1 << (R)))
165 /* Predicates for 16- and 32-bit ranges */
166 /* XXX: The non-shift version appears to trigger a compiler bug when
167 cross-assembling from x86 w/ gcc 2.7.2. */
170 #define range_signed_16(x) \
171 (((offsetT) (x) >> 15) == 0 || ((offsetT) (x) >> 15) == -1)
172 #define range_signed_32(x) \
173 (((offsetT) (x) >> 31) == 0 || ((offsetT) (x) >> 31) == -1)
175 #define range_signed_16(x) ((offsetT) (x) >= -(offsetT) 0x8000 && \
176 (offsetT) (x) <= (offsetT) 0x7FFF)
177 #define range_signed_32(x) ((offsetT) (x) >= -(offsetT) 0x80000000 && \
178 (offsetT) (x) <= (offsetT) 0x7FFFFFFF)
181 /* Macros for sign extending from 16- and 32-bits. */
182 /* XXX: The cast macros will work on all the systems that I care about,
183 but really a predicate should be found to use the non-cast forms. */
186 #define sign_extend_16(x) ((short) (x))
187 #define sign_extend_32(x) ((int) (x))
189 #define sign_extend_16(x) ((offsetT) (((x) & 0xFFFF) ^ 0x8000) - 0x8000)
190 #define sign_extend_32(x) ((offsetT) (((x) & 0xFFFFFFFF) \
191 ^ 0x80000000) - 0x80000000)
194 /* Macros to build tokens. */
196 #define set_tok_reg(t, r) (memset (&(t), 0, sizeof (t)), \
197 (t).X_op = O_register, \
198 (t).X_add_number = (r))
199 #define set_tok_preg(t, r) (memset (&(t), 0, sizeof (t)), \
200 (t).X_op = O_pregister, \
201 (t).X_add_number = (r))
202 #define set_tok_cpreg(t, r) (memset (&(t), 0, sizeof (t)), \
203 (t).X_op = O_cpregister, \
204 (t).X_add_number = (r))
205 #define set_tok_freg(t, r) (memset (&(t), 0, sizeof (t)), \
206 (t).X_op = O_register, \
207 (t).X_add_number = (r) + 32)
208 #define set_tok_sym(t, s, a) (memset (&(t), 0, sizeof (t)), \
209 (t).X_op = O_symbol, \
210 (t).X_add_symbol = (s), \
211 (t).X_add_number = (a))
212 #define set_tok_const(t, n) (memset (&(t), 0, sizeof (t)), \
213 (t).X_op = O_constant, \
214 (t).X_add_number = (n))
216 /* Generic assembler global variables which must be defined by all
219 /* Characters which always start a comment. */
220 const char comment_chars
[] = "#";
222 /* Characters which start a comment at the beginning of a line. */
223 const char line_comment_chars
[] = "#";
225 /* Characters which may be used to separate multiple commands on a
227 const char line_separator_chars
[] = ";";
229 /* Characters which are used to indicate an exponent in a floating
231 const char EXP_CHARS
[] = "eE";
233 /* Characters which mean that a number is a floating point constant,
235 /* XXX: Do all of these really get used on the alpha?? */
236 char FLT_CHARS
[] = "rRsSfFdDxXpP";
239 const char *md_shortopts
= "Fm:g+1h:HG:";
241 const char *md_shortopts
= "Fm:gG:";
244 struct option md_longopts
[] =
246 #define OPTION_32ADDR (OPTION_MD_BASE)
247 { "32addr", no_argument
, NULL
, OPTION_32ADDR
},
248 #define OPTION_RELAX (OPTION_32ADDR + 1)
249 { "relax", no_argument
, NULL
, OPTION_RELAX
},
251 #define OPTION_MDEBUG (OPTION_RELAX + 1)
252 #define OPTION_NO_MDEBUG (OPTION_MDEBUG + 1)
253 { "mdebug", no_argument
, NULL
, OPTION_MDEBUG
},
254 { "no-mdebug", no_argument
, NULL
, OPTION_NO_MDEBUG
},
257 #define OPTION_REPLACE (OPTION_RELAX + 1)
258 #define OPTION_NOREPLACE (OPTION_REPLACE+1)
259 { "replace", no_argument
, NULL
, OPTION_REPLACE
},
260 { "noreplace", no_argument
, NULL
, OPTION_NOREPLACE
},
262 { NULL
, no_argument
, NULL
, 0 }
265 size_t md_longopts_size
= sizeof (md_longopts
);
269 #define AXP_REG_R16 16
270 #define AXP_REG_R17 17
272 #define AXP_REG_T9 22
274 #define AXP_REG_T10 23
276 #define AXP_REG_T11 24
278 #define AXP_REG_T12 25
279 #define AXP_REG_AI 25
281 #define AXP_REG_FP 29
284 #define AXP_REG_GP AXP_REG_PV
286 static struct hash_control
*alpha_evax_proc_hash
;
288 #endif /* OBJ_EVAX */
290 /* The cpu for which we are generating code. */
291 static unsigned alpha_target
= AXP_OPCODE_BASE
;
292 static const char *alpha_target_name
= "<all>";
294 /* The hash table of instruction opcodes. */
295 static struct hash_control
*alpha_opcode_hash
;
297 /* The hash table of macro opcodes. */
298 static struct hash_control
*alpha_macro_hash
;
301 /* The $gp relocation symbol. */
302 static symbolS
*alpha_gp_symbol
;
304 /* XXX: what is this, and why is it exported? */
305 valueT alpha_gp_value
;
308 /* The current $gp register. */
309 static int alpha_gp_register
= AXP_REG_GP
;
311 /* A table of the register symbols. */
312 static symbolS
*alpha_register_table
[64];
314 /* Constant sections, or sections of constants. */
316 static segT alpha_lita_section
;
319 segT alpha_link_section
;
322 static segT alpha_lit8_section
;
325 /* Symbols referring to said sections. */
327 static symbolS
*alpha_lita_symbol
;
330 static symbolS
*alpha_link_symbol
;
333 static symbolS
*alpha_lit8_symbol
;
336 /* Literal for .litX+0x8000 within .lita. */
338 static offsetT alpha_lit8_literal
;
341 /* Is the assembler not allowed to use $at? */
342 static int alpha_noat_on
= 0;
344 /* Are macros enabled? */
345 static int alpha_macros_on
= 1;
347 /* Are floats disabled? */
348 static int alpha_nofloats_on
= 0;
350 /* Are addresses 32 bit? */
351 static int alpha_addr32_on
= 0;
353 /* Symbol labelling the current insn. When the Alpha gas sees
356 and the section happens to not be on an eight byte boundary, it
357 will align both the symbol and the .quad to an eight byte boundary. */
358 static symbolS
*alpha_insn_label
;
359 #if defined(OBJ_ELF) || defined (OBJ_EVAX)
360 static symbolS
*alpha_prologue_label
;
364 /* Symbol associate with the current jsr instruction. */
365 static symbolS
*alpha_linkage_symbol
;
368 /* Whether we should automatically align data generation pseudo-ops.
369 .align 0 will turn this off. */
370 static int alpha_auto_align_on
= 1;
372 /* The known current alignment of the current section. */
373 static int alpha_current_align
;
375 /* These are exported to ECOFF code. */
376 unsigned long alpha_gprmask
, alpha_fprmask
;
378 /* Whether the debugging option was seen. */
379 static int alpha_debug
;
382 /* Whether we are emitting an mdebug section. */
383 int alpha_flag_mdebug
= -1;
387 /* Whether to perform the VMS procedure call optimization. */
388 int alpha_flag_replace
= 1;
391 /* Don't fully resolve relocations, allowing code movement in the linker. */
392 static int alpha_flag_relax
;
394 /* What value to give to bfd_set_gp_size. */
395 static int g_switch_value
= 8;
398 /* Collect information about current procedure here. */
399 struct alpha_evax_procs
401 symbolS
*symbol
; /* Proc pdesc symbol. */
403 int framereg
; /* Register for frame pointer. */
404 int framesize
; /* Size of frame. */
416 struct alpha_linkage_fixups
*alpha_linkage_fixup_root
;
417 static struct alpha_linkage_fixups
*alpha_linkage_fixup_tail
;
419 static struct alpha_evax_procs
*alpha_evax_proc
;
421 static int alpha_flag_hash_long_names
= 0; /* -+ */
422 static int alpha_flag_show_after_trunc
= 0; /* -H */
424 /* If the -+ switch is given, then a hash is appended to any name that is
425 longer than 64 characters, else longer symbol names are truncated. */
430 /* A table to map the spelling of a relocation operand into an appropriate
431 bfd_reloc_code_real_type type. The table is assumed to be ordered such
432 that op-O_literal indexes into it. */
434 #define ALPHA_RELOC_TABLE(op) \
435 (&alpha_reloc_op[ ((!USER_RELOC_P (op)) \
437 : (int) (op) - (int) O_literal) ])
439 #define DEF(NAME, RELOC, REQ, ALLOW) \
440 { #NAME, sizeof(#NAME)-1, O_##NAME, RELOC, REQ, ALLOW}
442 static const struct alpha_reloc_op_tag
444 const char *name
; /* String to lookup. */
445 size_t length
; /* Size of the string. */
446 operatorT op
; /* Which operator to use. */
447 bfd_reloc_code_real_type reloc
; /* Relocation before frob. */
448 unsigned int require_seq
: 1; /* Require a sequence number. */
449 unsigned int allow_seq
: 1; /* Allow a sequence number. */
453 DEF (literal
, BFD_RELOC_ALPHA_ELF_LITERAL
, 0, 1),
454 DEF (lituse_addr
, DUMMY_RELOC_LITUSE_ADDR
, 1, 1),
455 DEF (lituse_base
, DUMMY_RELOC_LITUSE_BASE
, 1, 1),
456 DEF (lituse_bytoff
, DUMMY_RELOC_LITUSE_BYTOFF
, 1, 1),
457 DEF (lituse_jsr
, DUMMY_RELOC_LITUSE_JSR
, 1, 1),
458 DEF (lituse_tlsgd
, DUMMY_RELOC_LITUSE_TLSGD
, 1, 1),
459 DEF (lituse_tlsldm
, DUMMY_RELOC_LITUSE_TLSLDM
, 1, 1),
460 DEF (lituse_jsrdirect
, DUMMY_RELOC_LITUSE_JSRDIRECT
, 1, 1),
461 DEF (gpdisp
, BFD_RELOC_ALPHA_GPDISP
, 1, 1),
462 DEF (gprelhigh
, BFD_RELOC_ALPHA_GPREL_HI16
, 0, 0),
463 DEF (gprellow
, BFD_RELOC_ALPHA_GPREL_LO16
, 0, 0),
464 DEF (gprel
, BFD_RELOC_GPREL16
, 0, 0),
465 DEF (samegp
, BFD_RELOC_ALPHA_BRSGP
, 0, 0),
466 DEF (tlsgd
, BFD_RELOC_ALPHA_TLSGD
, 0, 1),
467 DEF (tlsldm
, BFD_RELOC_ALPHA_TLSLDM
, 0, 1),
468 DEF (gotdtprel
, BFD_RELOC_ALPHA_GOTDTPREL16
, 0, 0),
469 DEF (dtprelhi
, BFD_RELOC_ALPHA_DTPREL_HI16
, 0, 0),
470 DEF (dtprello
, BFD_RELOC_ALPHA_DTPREL_LO16
, 0, 0),
471 DEF (dtprel
, BFD_RELOC_ALPHA_DTPREL16
, 0, 0),
472 DEF (gottprel
, BFD_RELOC_ALPHA_GOTTPREL16
, 0, 0),
473 DEF (tprelhi
, BFD_RELOC_ALPHA_TPREL_HI16
, 0, 0),
474 DEF (tprello
, BFD_RELOC_ALPHA_TPREL_LO16
, 0, 0),
475 DEF (tprel
, BFD_RELOC_ALPHA_TPREL16
, 0, 0),
480 static const int alpha_num_reloc_op
481 = sizeof (alpha_reloc_op
) / sizeof (*alpha_reloc_op
);
482 #endif /* RELOC_OP_P */
484 /* Maximum # digits needed to hold the largest sequence #. */
485 #define ALPHA_RELOC_DIGITS 25
487 /* Structure to hold explicit sequence information. */
488 struct alpha_reloc_tag
490 fixS
*master
; /* The literal reloc. */
495 fixS
*slaves
; /* Head of linked list of lituses. */
496 segT segment
; /* Segment relocs are in or undefined_section. */
497 long sequence
; /* Sequence #. */
498 unsigned n_master
; /* # of literals. */
499 unsigned n_slaves
; /* # of lituses. */
500 unsigned saw_tlsgd
: 1; /* True if ... */
501 unsigned saw_tlsldm
: 1;
502 unsigned saw_lu_tlsgd
: 1;
503 unsigned saw_lu_tlsldm
: 1;
504 unsigned multi_section_p
: 1; /* True if more than one section was used. */
505 char string
[1]; /* Printable form of sequence to hash with. */
508 /* Hash table to link up literals with the appropriate lituse. */
509 static struct hash_control
*alpha_literal_hash
;
511 /* Sequence numbers for internal use by macros. */
512 static long next_sequence_num
= -1;
514 /* A table of CPU names and opcode sets. */
516 static const struct cpu_type
523 /* Ad hoc convention: cpu number gets palcode, process code doesn't.
524 This supports usage under DU 4.0b that does ".arch ev4", and
525 usage in MILO that does -m21064. Probably something more
526 specific like -m21064-pal should be used, but oh well. */
528 { "21064", AXP_OPCODE_BASE
|AXP_OPCODE_EV4
},
529 { "21064a", AXP_OPCODE_BASE
|AXP_OPCODE_EV4
},
530 { "21066", AXP_OPCODE_BASE
|AXP_OPCODE_EV4
},
531 { "21068", AXP_OPCODE_BASE
|AXP_OPCODE_EV4
},
532 { "21164", AXP_OPCODE_BASE
|AXP_OPCODE_EV5
},
533 { "21164a", AXP_OPCODE_BASE
|AXP_OPCODE_EV5
|AXP_OPCODE_BWX
},
534 { "21164pc", (AXP_OPCODE_BASE
|AXP_OPCODE_EV5
|AXP_OPCODE_BWX
536 { "21264", (AXP_OPCODE_BASE
|AXP_OPCODE_EV6
|AXP_OPCODE_BWX
537 |AXP_OPCODE_MAX
|AXP_OPCODE_CIX
) },
538 { "21264a", (AXP_OPCODE_BASE
|AXP_OPCODE_EV6
|AXP_OPCODE_BWX
539 |AXP_OPCODE_MAX
|AXP_OPCODE_CIX
) },
540 { "21264b", (AXP_OPCODE_BASE
|AXP_OPCODE_EV6
|AXP_OPCODE_BWX
541 |AXP_OPCODE_MAX
|AXP_OPCODE_CIX
) },
543 { "ev4", AXP_OPCODE_BASE
},
544 { "ev45", AXP_OPCODE_BASE
},
545 { "lca45", AXP_OPCODE_BASE
},
546 { "ev5", AXP_OPCODE_BASE
},
547 { "ev56", AXP_OPCODE_BASE
|AXP_OPCODE_BWX
},
548 { "pca56", AXP_OPCODE_BASE
|AXP_OPCODE_BWX
|AXP_OPCODE_MAX
},
549 { "ev6", AXP_OPCODE_BASE
|AXP_OPCODE_BWX
|AXP_OPCODE_MAX
|AXP_OPCODE_CIX
},
550 { "ev67", AXP_OPCODE_BASE
|AXP_OPCODE_BWX
|AXP_OPCODE_MAX
|AXP_OPCODE_CIX
},
551 { "ev68", AXP_OPCODE_BASE
|AXP_OPCODE_BWX
|AXP_OPCODE_MAX
|AXP_OPCODE_CIX
},
553 { "all", AXP_OPCODE_BASE
},
557 /* Some instruction sets indexed by lg(size). */
558 static const char * const sextX_op
[] = { "sextb", "sextw", "sextl", NULL
};
559 static const char * const insXl_op
[] = { "insbl", "inswl", "insll", "insql" };
560 static const char * const insXh_op
[] = { NULL
, "inswh", "inslh", "insqh" };
561 static const char * const extXl_op
[] = { "extbl", "extwl", "extll", "extql" };
562 static const char * const extXh_op
[] = { NULL
, "extwh", "extlh", "extqh" };
563 static const char * const mskXl_op
[] = { "mskbl", "mskwl", "mskll", "mskql" };
564 static const char * const mskXh_op
[] = { NULL
, "mskwh", "msklh", "mskqh" };
565 static const char * const stX_op
[] = { "stb", "stw", "stl", "stq" };
566 static const char * const ldXu_op
[] = { "ldbu", "ldwu", NULL
, NULL
};
568 static void assemble_insn (const struct alpha_opcode
*, const expressionS
*, int, struct alpha_insn
*, bfd_reloc_code_real_type
);
569 static void emit_insn (struct alpha_insn
*);
570 static void assemble_tokens (const char *, const expressionS
*, int, int);
572 static char *s_alpha_section_name (void);
573 static symbolS
*add_to_link_pool (symbolS
*, symbolS
*, offsetT
);
576 static struct alpha_reloc_tag
*
577 get_alpha_reloc_tag (long sequence
)
579 char buffer
[ALPHA_RELOC_DIGITS
];
580 struct alpha_reloc_tag
*info
;
582 sprintf (buffer
, "!%ld", sequence
);
584 info
= (struct alpha_reloc_tag
*) hash_find (alpha_literal_hash
, buffer
);
587 size_t len
= strlen (buffer
);
590 info
= xcalloc (sizeof (struct alpha_reloc_tag
) + len
, 1);
592 info
->segment
= now_seg
;
593 info
->sequence
= sequence
;
594 strcpy (info
->string
, buffer
);
595 errmsg
= hash_insert (alpha_literal_hash
, info
->string
, (void *) info
);
597 as_fatal ("%s", errmsg
);
610 alpha_adjust_relocs (bfd
*abfd ATTRIBUTE_UNUSED
,
612 void * ptr ATTRIBUTE_UNUSED
)
614 segment_info_type
*seginfo
= seg_info (sec
);
620 /* If seginfo is NULL, we did not create this section; don't do
621 anything with it. By using a pointer to a pointer, we can update
622 the links in place. */
626 /* If there are no relocations, skip the section. */
627 if (! seginfo
->fix_root
)
630 /* First rebuild the fixup chain without the explicit lituse and
631 gpdisp_lo16 relocs. */
632 prevP
= &seginfo
->fix_root
;
633 for (fixp
= seginfo
->fix_root
; fixp
; fixp
= next
)
635 next
= fixp
->fx_next
;
636 fixp
->fx_next
= (fixS
*) 0;
638 switch (fixp
->fx_r_type
)
640 case BFD_RELOC_ALPHA_LITUSE
:
641 if (fixp
->tc_fix_data
.info
->n_master
== 0)
642 as_bad_where (fixp
->fx_file
, fixp
->fx_line
,
643 _("No !literal!%ld was found"),
644 fixp
->tc_fix_data
.info
->sequence
);
646 if (fixp
->fx_offset
== LITUSE_ALPHA_TLSGD
)
648 if (! fixp
->tc_fix_data
.info
->saw_tlsgd
)
649 as_bad_where (fixp
->fx_file
, fixp
->fx_line
,
650 _("No !tlsgd!%ld was found"),
651 fixp
->tc_fix_data
.info
->sequence
);
653 else if (fixp
->fx_offset
== LITUSE_ALPHA_TLSLDM
)
655 if (! fixp
->tc_fix_data
.info
->saw_tlsldm
)
656 as_bad_where (fixp
->fx_file
, fixp
->fx_line
,
657 _("No !tlsldm!%ld was found"),
658 fixp
->tc_fix_data
.info
->sequence
);
663 case BFD_RELOC_ALPHA_GPDISP_LO16
:
664 if (fixp
->tc_fix_data
.info
->n_master
== 0)
665 as_bad_where (fixp
->fx_file
, fixp
->fx_line
,
666 _("No ldah !gpdisp!%ld was found"),
667 fixp
->tc_fix_data
.info
->sequence
);
670 case BFD_RELOC_ALPHA_ELF_LITERAL
:
671 if (fixp
->tc_fix_data
.info
672 && (fixp
->tc_fix_data
.info
->saw_tlsgd
673 || fixp
->tc_fix_data
.info
->saw_tlsldm
))
679 prevP
= &fixp
->fx_next
;
684 /* Go back and re-chain dependent relocations. They are currently
685 linked through the next_reloc field in reverse order, so as we
686 go through the next_reloc chain, we effectively reverse the chain
689 Except if there is more than one !literal for a given sequence
690 number. In that case, the programmer and/or compiler is not sure
691 how control flows from literal to lituse, and we can't be sure to
692 get the relaxation correct.
694 ??? Well, actually we could, if there are enough lituses such that
695 we can make each literal have at least one of each lituse type
696 present. Not implemented.
698 Also suppress the optimization if the !literals/!lituses are spread
699 in different segments. This can happen with "intersting" uses of
700 inline assembly; examples are present in the Linux kernel semaphores. */
702 for (fixp
= seginfo
->fix_root
; fixp
; fixp
= next
)
704 next
= fixp
->fx_next
;
705 switch (fixp
->fx_r_type
)
707 case BFD_RELOC_ALPHA_TLSGD
:
708 case BFD_RELOC_ALPHA_TLSLDM
:
709 if (!fixp
->tc_fix_data
.info
)
711 if (fixp
->tc_fix_data
.info
->n_master
== 0)
713 else if (fixp
->tc_fix_data
.info
->n_master
> 1)
715 as_bad_where (fixp
->fx_file
, fixp
->fx_line
,
716 _("too many !literal!%ld for %s"),
717 fixp
->tc_fix_data
.info
->sequence
,
718 (fixp
->fx_r_type
== BFD_RELOC_ALPHA_TLSGD
719 ? "!tlsgd" : "!tlsldm"));
723 fixp
->tc_fix_data
.info
->master
->fx_next
= fixp
->fx_next
;
724 fixp
->fx_next
= fixp
->tc_fix_data
.info
->master
;
725 fixp
= fixp
->fx_next
;
728 case BFD_RELOC_ALPHA_ELF_LITERAL
:
729 if (fixp
->tc_fix_data
.info
730 && fixp
->tc_fix_data
.info
->n_master
== 1
731 && ! fixp
->tc_fix_data
.info
->multi_section_p
)
733 for (slave
= fixp
->tc_fix_data
.info
->slaves
;
735 slave
= slave
->tc_fix_data
.next_reloc
)
737 slave
->fx_next
= fixp
->fx_next
;
738 fixp
->fx_next
= slave
;
743 case BFD_RELOC_ALPHA_GPDISP_HI16
:
744 if (fixp
->tc_fix_data
.info
->n_slaves
== 0)
745 as_bad_where (fixp
->fx_file
, fixp
->fx_line
,
746 _("No lda !gpdisp!%ld was found"),
747 fixp
->tc_fix_data
.info
->sequence
);
750 slave
= fixp
->tc_fix_data
.info
->slaves
;
751 slave
->fx_next
= next
;
752 fixp
->fx_next
= slave
;
762 /* Before the relocations are written, reorder them, so that user
763 supplied !lituse relocations follow the appropriate !literal
764 relocations, and similarly for !gpdisp relocations. */
767 alpha_before_fix (void)
769 if (alpha_literal_hash
)
770 bfd_map_over_sections (stdoutput
, alpha_adjust_relocs
, NULL
);
777 debug_exp (expressionS tok
[], int ntok
)
781 fprintf (stderr
, "debug_exp: %d tokens", ntok
);
782 for (i
= 0; i
< ntok
; i
++)
784 expressionS
*t
= &tok
[i
];
789 default: name
= "unknown"; break;
790 case O_illegal
: name
= "O_illegal"; break;
791 case O_absent
: name
= "O_absent"; break;
792 case O_constant
: name
= "O_constant"; break;
793 case O_symbol
: name
= "O_symbol"; break;
794 case O_symbol_rva
: name
= "O_symbol_rva"; break;
795 case O_register
: name
= "O_register"; break;
796 case O_big
: name
= "O_big"; break;
797 case O_uminus
: name
= "O_uminus"; break;
798 case O_bit_not
: name
= "O_bit_not"; break;
799 case O_logical_not
: name
= "O_logical_not"; break;
800 case O_multiply
: name
= "O_multiply"; break;
801 case O_divide
: name
= "O_divide"; break;
802 case O_modulus
: name
= "O_modulus"; break;
803 case O_left_shift
: name
= "O_left_shift"; break;
804 case O_right_shift
: name
= "O_right_shift"; break;
805 case O_bit_inclusive_or
: name
= "O_bit_inclusive_or"; break;
806 case O_bit_or_not
: name
= "O_bit_or_not"; break;
807 case O_bit_exclusive_or
: name
= "O_bit_exclusive_or"; break;
808 case O_bit_and
: name
= "O_bit_and"; break;
809 case O_add
: name
= "O_add"; break;
810 case O_subtract
: name
= "O_subtract"; break;
811 case O_eq
: name
= "O_eq"; break;
812 case O_ne
: name
= "O_ne"; break;
813 case O_lt
: name
= "O_lt"; break;
814 case O_le
: name
= "O_le"; break;
815 case O_ge
: name
= "O_ge"; break;
816 case O_gt
: name
= "O_gt"; break;
817 case O_logical_and
: name
= "O_logical_and"; break;
818 case O_logical_or
: name
= "O_logical_or"; break;
819 case O_index
: name
= "O_index"; break;
820 case O_pregister
: name
= "O_pregister"; break;
821 case O_cpregister
: name
= "O_cpregister"; break;
822 case O_literal
: name
= "O_literal"; break;
823 case O_lituse_addr
: name
= "O_lituse_addr"; break;
824 case O_lituse_base
: name
= "O_lituse_base"; break;
825 case O_lituse_bytoff
: name
= "O_lituse_bytoff"; break;
826 case O_lituse_jsr
: name
= "O_lituse_jsr"; break;
827 case O_lituse_tlsgd
: name
= "O_lituse_tlsgd"; break;
828 case O_lituse_tlsldm
: name
= "O_lituse_tlsldm"; break;
829 case O_lituse_jsrdirect
: name
= "O_lituse_jsrdirect"; break;
830 case O_gpdisp
: name
= "O_gpdisp"; break;
831 case O_gprelhigh
: name
= "O_gprelhigh"; break;
832 case O_gprellow
: name
= "O_gprellow"; break;
833 case O_gprel
: name
= "O_gprel"; break;
834 case O_samegp
: name
= "O_samegp"; break;
835 case O_tlsgd
: name
= "O_tlsgd"; break;
836 case O_tlsldm
: name
= "O_tlsldm"; break;
837 case O_gotdtprel
: name
= "O_gotdtprel"; break;
838 case O_dtprelhi
: name
= "O_dtprelhi"; break;
839 case O_dtprello
: name
= "O_dtprello"; break;
840 case O_dtprel
: name
= "O_dtprel"; break;
841 case O_gottprel
: name
= "O_gottprel"; break;
842 case O_tprelhi
: name
= "O_tprelhi"; break;
843 case O_tprello
: name
= "O_tprello"; break;
844 case O_tprel
: name
= "O_tprel"; break;
847 fprintf (stderr
, ", %s(%s, %s, %d)", name
,
848 (t
->X_add_symbol
) ? S_GET_NAME (t
->X_add_symbol
) : "--",
849 (t
->X_op_symbol
) ? S_GET_NAME (t
->X_op_symbol
) : "--",
850 (int) t
->X_add_number
);
852 fprintf (stderr
, "\n");
857 /* Parse the arguments to an opcode. */
860 tokenize_arguments (char *str
,
864 expressionS
*end_tok
= tok
+ ntok
;
865 char *old_input_line_pointer
;
866 int saw_comma
= 0, saw_arg
= 0;
868 expressionS
*orig_tok
= tok
;
872 const struct alpha_reloc_op_tag
*r
;
875 int reloc_found_p
= 0;
878 memset (tok
, 0, sizeof (*tok
) * ntok
);
880 /* Save and restore input_line_pointer around this function. */
881 old_input_line_pointer
= input_line_pointer
;
882 input_line_pointer
= str
;
885 /* ??? Wrest control of ! away from the regular expression parser. */
886 is_end_of_line
[(unsigned char) '!'] = 1;
889 while (tok
< end_tok
&& *input_line_pointer
)
892 switch (*input_line_pointer
)
899 /* A relocation operand can be placed after the normal operand on an
900 assembly language statement, and has the following form:
901 !relocation_type!sequence_number. */
904 /* Only support one relocation op per insn. */
905 as_bad (_("More than one relocation op per insn"));
912 ++input_line_pointer
;
914 p
= input_line_pointer
;
915 c
= get_symbol_end ();
917 /* Parse !relocation_type. */
918 len
= input_line_pointer
- p
;
921 as_bad (_("No relocation operand"));
925 r
= &alpha_reloc_op
[0];
926 for (i
= alpha_num_reloc_op
- 1; i
>= 0; i
--, r
++)
927 if (len
== r
->length
&& memcmp (p
, r
->name
, len
) == 0)
931 as_bad (_("Unknown relocation operand: !%s"), p
);
935 *input_line_pointer
= c
;
937 if (*input_line_pointer
!= '!')
941 as_bad (_("no sequence number after !%s"), p
);
945 tok
->X_add_number
= 0;
951 as_bad (_("!%s does not use a sequence number"), p
);
955 input_line_pointer
++;
957 /* Parse !sequence_number. */
959 if (tok
->X_op
!= O_constant
|| tok
->X_add_number
<= 0)
961 as_bad (_("Bad sequence number: !%s!%s"),
962 r
->name
, input_line_pointer
);
971 #endif /* RELOC_OP_P */
974 ++input_line_pointer
;
975 if (saw_comma
|| !saw_arg
)
982 char *hold
= input_line_pointer
++;
984 /* First try for parenthesized register ... */
986 if (*input_line_pointer
== ')' && tok
->X_op
== O_register
)
988 tok
->X_op
= (saw_comma
? O_cpregister
: O_pregister
);
991 ++input_line_pointer
;
996 /* ... then fall through to plain expression. */
997 input_line_pointer
= hold
;
1001 if (saw_arg
&& !saw_comma
)
1005 if (tok
->X_op
== O_illegal
|| tok
->X_op
== O_absent
)
1018 input_line_pointer
= old_input_line_pointer
;
1021 debug_exp (orig_tok
, ntok
- (end_tok
- tok
));
1024 is_end_of_line
[(unsigned char) '!'] = 0;
1027 return ntok
- (end_tok
- tok
);
1031 is_end_of_line
[(unsigned char) '!'] = 0;
1033 input_line_pointer
= old_input_line_pointer
;
1034 return TOKENIZE_ERROR
;
1038 is_end_of_line
[(unsigned char) '!'] = 0;
1040 input_line_pointer
= old_input_line_pointer
;
1041 return TOKENIZE_ERROR_REPORT
;
1044 /* Search forward through all variants of an opcode looking for a
1047 static const struct alpha_opcode
*
1048 find_opcode_match (const struct alpha_opcode
*first_opcode
,
1049 const expressionS
*tok
,
1053 const struct alpha_opcode
*opcode
= first_opcode
;
1055 int got_cpu_match
= 0;
1059 const unsigned char *opidx
;
1062 /* Don't match opcodes that don't exist on this architecture. */
1063 if (!(opcode
->flags
& alpha_target
))
1068 for (opidx
= opcode
->operands
; *opidx
; ++opidx
)
1070 const struct alpha_operand
*operand
= &alpha_operands
[*opidx
];
1072 /* Only take input from real operands. */
1073 if (operand
->flags
& AXP_OPERAND_FAKE
)
1076 /* When we expect input, make sure we have it. */
1079 if ((operand
->flags
& AXP_OPERAND_OPTIONAL_MASK
) == 0)
1084 /* Match operand type with expression type. */
1085 switch (operand
->flags
& AXP_OPERAND_TYPECHECK_MASK
)
1087 case AXP_OPERAND_IR
:
1088 if (tok
[tokidx
].X_op
!= O_register
1089 || !is_ir_num (tok
[tokidx
].X_add_number
))
1092 case AXP_OPERAND_FPR
:
1093 if (tok
[tokidx
].X_op
!= O_register
1094 || !is_fpr_num (tok
[tokidx
].X_add_number
))
1097 case AXP_OPERAND_IR
| AXP_OPERAND_PARENS
:
1098 if (tok
[tokidx
].X_op
!= O_pregister
1099 || !is_ir_num (tok
[tokidx
].X_add_number
))
1102 case AXP_OPERAND_IR
| AXP_OPERAND_PARENS
| AXP_OPERAND_COMMA
:
1103 if (tok
[tokidx
].X_op
!= O_cpregister
1104 || !is_ir_num (tok
[tokidx
].X_add_number
))
1108 case AXP_OPERAND_RELATIVE
:
1109 case AXP_OPERAND_SIGNED
:
1110 case AXP_OPERAND_UNSIGNED
:
1111 switch (tok
[tokidx
].X_op
)
1126 /* Everything else should have been fake. */
1132 /* Possible match -- did we use all of our input? */
1141 while (++opcode
- alpha_opcodes
< (int) alpha_num_opcodes
1142 && !strcmp (opcode
->name
, first_opcode
->name
));
1145 *pcpumatch
= got_cpu_match
;
1150 /* Given an opcode name and a pre-tokenized set of arguments, assemble
1151 the insn, but do not emit it.
1153 Note that this implies no macros allowed, since we can't store more
1154 than one insn in an insn structure. */
1157 assemble_tokens_to_insn (const char *opname
,
1158 const expressionS
*tok
,
1160 struct alpha_insn
*insn
)
1162 const struct alpha_opcode
*opcode
;
1164 /* Search opcodes. */
1165 opcode
= (const struct alpha_opcode
*) hash_find (alpha_opcode_hash
, opname
);
1169 opcode
= find_opcode_match (opcode
, tok
, &ntok
, &cpumatch
);
1172 assemble_insn (opcode
, tok
, ntok
, insn
, BFD_RELOC_UNUSED
);
1176 as_bad (_("inappropriate arguments for opcode `%s'"), opname
);
1178 as_bad (_("opcode `%s' not supported for target %s"), opname
,
1182 as_bad (_("unknown opcode `%s'"), opname
);
1185 /* Build a BFD section with its flags set appropriately for the .lita,
1186 .lit8, or .lit4 sections. */
1189 create_literal_section (const char *name
,
1193 segT current_section
= now_seg
;
1194 int current_subsec
= now_subseg
;
1197 *secp
= new_sec
= subseg_new (name
, 0);
1198 subseg_set (current_section
, current_subsec
);
1199 bfd_set_section_alignment (stdoutput
, new_sec
, 4);
1200 bfd_set_section_flags (stdoutput
, new_sec
,
1201 SEC_RELOC
| SEC_ALLOC
| SEC_LOAD
| SEC_READONLY
1204 S_CLEAR_EXTERNAL (*symp
= section_symbol (new_sec
));
1207 /* Load a (partial) expression into a target register.
1209 If poffset is not null, after the call it will either contain
1210 O_constant 0, or a 16-bit offset appropriate for any MEM format
1211 instruction. In addition, pbasereg will be modified to point to
1212 the base register to use in that MEM format instruction.
1214 In any case, *pbasereg should contain a base register to add to the
1215 expression. This will normally be either AXP_REG_ZERO or
1216 alpha_gp_register. Symbol addresses will always be loaded via $gp,
1217 so "foo($0)" is interpreted as adding the address of foo to $0;
1218 i.e. "ldq $targ, LIT($gp); addq $targ, $0, $targ". Odd, perhaps,
1219 but this is what OSF/1 does.
1221 If explicit relocations of the form !literal!<number> are allowed,
1222 and used, then explicit_reloc with be an expression pointer.
1224 Finally, the return value is nonzero if the calling macro may emit
1225 a LITUSE reloc if otherwise appropriate; the return value is the
1226 sequence number to use. */
1229 load_expression (int targreg
,
1230 const expressionS
*exp
,
1232 expressionS
*poffset
,
1235 long emit_lituse
= 0;
1236 offsetT addend
= exp
->X_add_number
;
1237 int basereg
= *pbasereg
;
1238 struct alpha_insn insn
;
1239 expressionS newtok
[3];
1248 /* Attempt to reduce .lit load by splitting the offset from
1249 its symbol when possible, but don't create a situation in
1251 if (!range_signed_32 (addend
) &&
1252 (alpha_noat_on
|| targreg
== AXP_REG_AT
))
1254 lit
= add_to_literal_pool (exp
->X_add_symbol
, addend
,
1255 alpha_lita_section
, 8);
1259 lit
= add_to_literal_pool (exp
->X_add_symbol
, 0,
1260 alpha_lita_section
, 8);
1263 as_fatal (_("overflow in literal (.lita) table"));
1265 /* Emit "ldq r, lit(gp)". */
1267 if (basereg
!= alpha_gp_register
&& targreg
== basereg
)
1270 as_bad (_("macro requires $at register while noat in effect"));
1271 if (targreg
== AXP_REG_AT
)
1272 as_bad (_("macro requires $at while $at in use"));
1274 set_tok_reg (newtok
[0], AXP_REG_AT
);
1277 set_tok_reg (newtok
[0], targreg
);
1279 set_tok_sym (newtok
[1], alpha_lita_symbol
, lit
);
1280 set_tok_preg (newtok
[2], alpha_gp_register
);
1282 assemble_tokens_to_insn ("ldq", newtok
, 3, &insn
);
1284 gas_assert (insn
.nfixups
== 1);
1285 insn
.fixups
[0].reloc
= BFD_RELOC_ALPHA_LITERAL
;
1286 insn
.sequence
= emit_lituse
= next_sequence_num
--;
1287 #endif /* OBJ_ECOFF */
1289 /* Emit "ldq r, gotoff(gp)". */
1291 if (basereg
!= alpha_gp_register
&& targreg
== basereg
)
1294 as_bad (_("macro requires $at register while noat in effect"));
1295 if (targreg
== AXP_REG_AT
)
1296 as_bad (_("macro requires $at while $at in use"));
1298 set_tok_reg (newtok
[0], AXP_REG_AT
);
1301 set_tok_reg (newtok
[0], targreg
);
1303 /* XXX: Disable this .got minimizing optimization so that we can get
1304 better instruction offset knowledge in the compiler. This happens
1305 very infrequently anyway. */
1307 || (!range_signed_32 (addend
)
1308 && (alpha_noat_on
|| targreg
== AXP_REG_AT
)))
1314 set_tok_sym (newtok
[1], exp
->X_add_symbol
, 0);
1316 set_tok_preg (newtok
[2], alpha_gp_register
);
1318 assemble_tokens_to_insn ("ldq", newtok
, 3, &insn
);
1320 gas_assert (insn
.nfixups
== 1);
1321 insn
.fixups
[0].reloc
= BFD_RELOC_ALPHA_ELF_LITERAL
;
1322 insn
.sequence
= emit_lituse
= next_sequence_num
--;
1323 #endif /* OBJ_ELF */
1325 /* Find symbol or symbol pointer in link section. */
1327 if (exp
->X_add_symbol
== alpha_evax_proc
->symbol
)
1329 if (range_signed_16 (addend
))
1331 set_tok_reg (newtok
[0], targreg
);
1332 set_tok_const (newtok
[1], addend
);
1333 set_tok_preg (newtok
[2], basereg
);
1334 assemble_tokens_to_insn ("lda", newtok
, 3, &insn
);
1339 set_tok_reg (newtok
[0], targreg
);
1340 set_tok_const (newtok
[1], 0);
1341 set_tok_preg (newtok
[2], basereg
);
1342 assemble_tokens_to_insn ("lda", newtok
, 3, &insn
);
1347 const char *symname
= S_GET_NAME (exp
->X_add_symbol
);
1348 const char *ptr1
, *ptr2
;
1349 int symlen
= strlen (symname
);
1352 strcmp (ptr2
= &symname
[symlen
- 4], "..lk") == 0))
1354 set_tok_reg (newtok
[0], targreg
);
1357 newtok
[1].X_op
= O_subtract
;
1358 newtok
[1].X_op_symbol
= alpha_evax_proc
->symbol
;
1360 set_tok_preg (newtok
[2], basereg
);
1361 assemble_tokens_to_insn ("ldq", newtok
, 3, &insn
);
1362 alpha_linkage_symbol
= exp
->X_add_symbol
;
1365 set_tok_const (*poffset
, 0);
1367 if (alpha_flag_replace
&& targreg
== 26)
1371 volatile asymbol
*dummy
;
1373 ptr1
= strstr (symname
, "..") + 2;
1376 ensymname
= (char *) xmalloc (ptr2
- ptr1
+ 5);
1377 memcpy (ensymname
, ptr1
, ptr2
- ptr1
);
1378 memcpy (ensymname
+ (ptr2
- ptr1
), "..en", 5);
1380 gas_assert (insn
.nfixups
+ 1 <= MAX_INSN_FIXUPS
);
1381 insn
.fixups
[insn
.nfixups
].reloc
= BFD_RELOC_ALPHA_NOP
;
1382 ensym
= symbol_find_or_make (ensymname
);
1384 /* The fixup must be the same as the BFD_RELOC_ALPHA_BOH
1385 case in emit_jsrjmp. See B.4.5.2 of the OpenVMS Linker
1387 insn
.fixups
[insn
.nfixups
].exp
.X_op
= O_symbol
;
1388 insn
.fixups
[insn
.nfixups
].exp
.X_add_symbol
= ensym
;
1389 insn
.fixups
[insn
.nfixups
].exp
.X_add_number
= 0;
1390 insn
.fixups
[insn
.nfixups
].xtrasym
= alpha_linkage_symbol
;
1391 insn
.fixups
[insn
.nfixups
].procsym
= alpha_evax_proc
->symbol
;
1394 /* ??? Force bsym to be instantiated now, as it will be
1395 too late to do so in tc_gen_reloc. */
1396 dummy
= symbol_get_bfdsym (exp
->X_add_symbol
);
1398 else if (alpha_flag_replace
&& targreg
== 27)
1403 ptr1
= strstr (symname
, "..") + 2;
1406 psymname
= (char *) xmalloc (ptr2
- ptr1
+ 1);
1407 memcpy (psymname
, ptr1
, ptr2
- ptr1
);
1408 psymname
[ptr2
- ptr1
] = 0;
1409 gas_assert (insn
.nfixups
+ 1 <= MAX_INSN_FIXUPS
);
1410 insn
.fixups
[insn
.nfixups
].reloc
= BFD_RELOC_ALPHA_LDA
;
1411 psym
= symbol_find_or_make (psymname
);
1413 insn
.fixups
[insn
.nfixups
].exp
.X_op
= O_subtract
;
1414 insn
.fixups
[insn
.nfixups
].exp
.X_add_symbol
= psym
;
1415 insn
.fixups
[insn
.nfixups
].exp
.X_op_symbol
= alpha_evax_proc
->symbol
;
1416 insn
.fixups
[insn
.nfixups
].exp
.X_add_number
= 0;
1417 insn
.fixups
[insn
.nfixups
].xtrasym
= alpha_linkage_symbol
;
1418 insn
.fixups
[insn
.nfixups
].procsym
= alpha_evax_proc
->symbol
;
1429 if (!range_signed_32 (addend
))
1430 addend
= sign_extend_32 (addend
);
1431 linkexp
= add_to_link_pool (alpha_evax_proc
->symbol
,
1432 exp
->X_add_symbol
, 0);
1433 set_tok_reg (newtok
[0], targreg
);
1434 set_tok_sym (newtok
[1], linkexp
, 0);
1435 set_tok_preg (newtok
[2], basereg
);
1436 assemble_tokens_to_insn ("ldq", newtok
, 3, &insn
);
1439 #endif /* OBJ_EVAX */
1444 if (basereg
!= alpha_gp_register
&& basereg
!= AXP_REG_ZERO
)
1446 /* Emit "addq r, base, r". */
1448 set_tok_reg (newtok
[1], basereg
);
1449 set_tok_reg (newtok
[2], targreg
);
1450 assemble_tokens ("addq", newtok
, 3, 0);
1461 /* Assume that this difference expression will be resolved to an
1462 absolute value and that that value will fit in 16 bits. */
1464 set_tok_reg (newtok
[0], targreg
);
1466 set_tok_preg (newtok
[2], basereg
);
1467 assemble_tokens (opname
, newtok
, 3, 0);
1470 set_tok_const (*poffset
, 0);
1474 if (exp
->X_add_number
> 0)
1475 as_bad (_("bignum invalid; zero assumed"));
1477 as_bad (_("floating point number invalid; zero assumed"));
1482 as_bad (_("can't handle expression"));
1487 if (!range_signed_32 (addend
))
1493 long seq_num
= next_sequence_num
--;
1496 /* For 64-bit addends, just put it in the literal pool. */
1498 /* Emit "ldq targreg, lit(basereg)". */
1499 litexp
= add_to_link_pool (alpha_evax_proc
->symbol
,
1500 section_symbol (absolute_section
), addend
);
1501 set_tok_reg (newtok
[0], targreg
);
1502 set_tok_sym (newtok
[1], litexp
, 0);
1503 set_tok_preg (newtok
[2], alpha_gp_register
);
1504 assemble_tokens ("ldq", newtok
, 3, 0);
1507 if (alpha_lit8_section
== NULL
)
1509 create_literal_section (".lit8",
1510 &alpha_lit8_section
,
1511 &alpha_lit8_symbol
);
1514 alpha_lit8_literal
= add_to_literal_pool (alpha_lit8_symbol
, 0x8000,
1515 alpha_lita_section
, 8);
1516 if (alpha_lit8_literal
>= 0x8000)
1517 as_fatal (_("overflow in literal (.lita) table"));
1521 lit
= add_to_literal_pool (NULL
, addend
, alpha_lit8_section
, 8) - 0x8000;
1523 as_fatal (_("overflow in literal (.lit8) table"));
1525 /* Emit "lda litreg, .lit8+0x8000". */
1527 if (targreg
== basereg
)
1530 as_bad (_("macro requires $at register while noat in effect"));
1531 if (targreg
== AXP_REG_AT
)
1532 as_bad (_("macro requires $at while $at in use"));
1534 set_tok_reg (newtok
[0], AXP_REG_AT
);
1537 set_tok_reg (newtok
[0], targreg
);
1539 set_tok_sym (newtok
[1], alpha_lita_symbol
, alpha_lit8_literal
);
1542 set_tok_sym (newtok
[1], alpha_lit8_symbol
, 0x8000);
1544 set_tok_preg (newtok
[2], alpha_gp_register
);
1546 assemble_tokens_to_insn ("ldq", newtok
, 3, &insn
);
1548 gas_assert (insn
.nfixups
== 1);
1550 insn
.fixups
[0].reloc
= BFD_RELOC_ALPHA_LITERAL
;
1553 insn
.fixups
[0].reloc
= BFD_RELOC_ALPHA_ELF_LITERAL
;
1555 insn
.sequence
= seq_num
;
1559 /* Emit "ldq litreg, lit(litreg)". */
1561 set_tok_const (newtok
[1], lit
);
1562 set_tok_preg (newtok
[2], newtok
[0].X_add_number
);
1564 assemble_tokens_to_insn ("ldq", newtok
, 3, &insn
);
1566 gas_assert (insn
.nfixups
< MAX_INSN_FIXUPS
);
1567 insn
.fixups
[insn
.nfixups
].reloc
= DUMMY_RELOC_LITUSE_BASE
;
1568 insn
.fixups
[insn
.nfixups
].exp
.X_op
= O_absent
;
1570 insn
.sequence
= seq_num
;
1575 /* Emit "addq litreg, base, target". */
1577 if (basereg
!= AXP_REG_ZERO
)
1579 set_tok_reg (newtok
[1], basereg
);
1580 set_tok_reg (newtok
[2], targreg
);
1581 assemble_tokens ("addq", newtok
, 3, 0);
1583 #endif /* !OBJ_EVAX */
1586 set_tok_const (*poffset
, 0);
1587 *pbasereg
= targreg
;
1591 offsetT low
, high
, extra
, tmp
;
1593 /* For 32-bit operands, break up the addend. */
1595 low
= sign_extend_16 (addend
);
1597 high
= sign_extend_16 (tmp
>> 16);
1599 if (tmp
- (high
<< 16))
1603 high
= sign_extend_16 (tmp
>> 16);
1608 set_tok_reg (newtok
[0], targreg
);
1609 set_tok_preg (newtok
[2], basereg
);
1613 /* Emit "ldah r, extra(r). */
1614 set_tok_const (newtok
[1], extra
);
1615 assemble_tokens ("ldah", newtok
, 3, 0);
1616 set_tok_preg (newtok
[2], basereg
= targreg
);
1621 /* Emit "ldah r, high(r). */
1622 set_tok_const (newtok
[1], high
);
1623 assemble_tokens ("ldah", newtok
, 3, 0);
1625 set_tok_preg (newtok
[2], basereg
);
1628 if ((low
&& !poffset
) || (!poffset
&& basereg
!= targreg
))
1630 /* Emit "lda r, low(base)". */
1631 set_tok_const (newtok
[1], low
);
1632 assemble_tokens ("lda", newtok
, 3, 0);
1638 set_tok_const (*poffset
, low
);
1639 *pbasereg
= basereg
;
1645 /* The lda macro differs from the lda instruction in that it handles
1646 most simple expressions, particularly symbol address loads and
1650 emit_lda (const expressionS
*tok
,
1652 const void * unused ATTRIBUTE_UNUSED
)
1657 basereg
= (tok
[1].X_op
== O_constant
? AXP_REG_ZERO
: alpha_gp_register
);
1659 basereg
= tok
[2].X_add_number
;
1661 (void) load_expression (tok
[0].X_add_number
, &tok
[1], &basereg
, NULL
, "lda");
1664 /* The ldah macro differs from the ldah instruction in that it has $31
1665 as an implied base register. */
1668 emit_ldah (const expressionS
*tok
,
1669 int ntok ATTRIBUTE_UNUSED
,
1670 const void * unused ATTRIBUTE_UNUSED
)
1672 expressionS newtok
[3];
1676 set_tok_preg (newtok
[2], AXP_REG_ZERO
);
1678 assemble_tokens ("ldah", newtok
, 3, 0);
1681 /* Called internally to handle all alignment needs. This takes care
1682 of eliding calls to frag_align if'n the cached current alignment
1683 says we've already got it, as well as taking care of the auto-align
1684 feature wrt labels. */
1690 int force ATTRIBUTE_UNUSED
)
1692 if (alpha_current_align
>= n
)
1697 if (subseg_text_p (now_seg
))
1698 frag_align_code (n
, 0);
1700 frag_align (n
, 0, 0);
1703 frag_align (n
, *pfill
, 0);
1705 alpha_current_align
= n
;
1707 if (label
!= NULL
&& S_GET_SEGMENT (label
) == now_seg
)
1709 symbol_set_frag (label
, frag_now
);
1710 S_SET_VALUE (label
, (valueT
) frag_now_fix ());
1713 record_alignment (now_seg
, n
);
1715 /* ??? If alpha_flag_relax && force && elf, record the requested alignment
1716 in a reloc for the linker to see. */
1719 /* Actually output an instruction with its fixup. */
1722 emit_insn (struct alpha_insn
*insn
)
1727 /* Take care of alignment duties. */
1728 if (alpha_auto_align_on
&& alpha_current_align
< 2)
1729 alpha_align (2, (char *) NULL
, alpha_insn_label
, 0);
1730 if (alpha_current_align
> 2)
1731 alpha_current_align
= 2;
1732 alpha_insn_label
= NULL
;
1734 /* Write out the instruction. */
1736 md_number_to_chars (f
, insn
->insn
, 4);
1739 dwarf2_emit_insn (4);
1742 /* Apply the fixups in order. */
1743 for (i
= 0; i
< insn
->nfixups
; ++i
)
1745 const struct alpha_operand
*operand
= (const struct alpha_operand
*) 0;
1746 struct alpha_fixup
*fixup
= &insn
->fixups
[i
];
1747 struct alpha_reloc_tag
*info
= NULL
;
1751 /* Some fixups are only used internally and so have no howto. */
1752 if ((int) fixup
->reloc
< 0)
1754 operand
= &alpha_operands
[-(int) fixup
->reloc
];
1756 pcrel
= ((operand
->flags
& AXP_OPERAND_RELATIVE
) != 0);
1758 else if (fixup
->reloc
> BFD_RELOC_UNUSED
1759 || fixup
->reloc
== BFD_RELOC_ALPHA_GPDISP_HI16
1760 || fixup
->reloc
== BFD_RELOC_ALPHA_GPDISP_LO16
)
1767 reloc_howto_type
*reloc_howto
1768 = bfd_reloc_type_lookup (stdoutput
, fixup
->reloc
);
1769 gas_assert (reloc_howto
);
1771 size
= bfd_get_reloc_size (reloc_howto
);
1773 switch (fixup
->reloc
)
1776 case BFD_RELOC_ALPHA_NOP
:
1777 case BFD_RELOC_ALPHA_BSR
:
1778 case BFD_RELOC_ALPHA_LDA
:
1779 case BFD_RELOC_ALPHA_BOH
:
1783 gas_assert (size
>= 1 && size
<= 4);
1786 pcrel
= reloc_howto
->pc_relative
;
1789 fixP
= fix_new_exp (frag_now
, f
- frag_now
->fr_literal
, size
,
1790 &fixup
->exp
, pcrel
, fixup
->reloc
);
1792 /* Turn off complaints that the addend is too large for some fixups,
1793 and copy in the sequence number for the explicit relocations. */
1794 switch (fixup
->reloc
)
1796 case BFD_RELOC_ALPHA_HINT
:
1797 case BFD_RELOC_GPREL32
:
1798 case BFD_RELOC_GPREL16
:
1799 case BFD_RELOC_ALPHA_GPREL_HI16
:
1800 case BFD_RELOC_ALPHA_GPREL_LO16
:
1801 case BFD_RELOC_ALPHA_GOTDTPREL16
:
1802 case BFD_RELOC_ALPHA_DTPREL_HI16
:
1803 case BFD_RELOC_ALPHA_DTPREL_LO16
:
1804 case BFD_RELOC_ALPHA_DTPREL16
:
1805 case BFD_RELOC_ALPHA_GOTTPREL16
:
1806 case BFD_RELOC_ALPHA_TPREL_HI16
:
1807 case BFD_RELOC_ALPHA_TPREL_LO16
:
1808 case BFD_RELOC_ALPHA_TPREL16
:
1809 fixP
->fx_no_overflow
= 1;
1812 case BFD_RELOC_ALPHA_GPDISP_HI16
:
1813 fixP
->fx_no_overflow
= 1;
1814 fixP
->fx_addsy
= section_symbol (now_seg
);
1815 fixP
->fx_offset
= 0;
1817 info
= get_alpha_reloc_tag (insn
->sequence
);
1818 if (++info
->n_master
> 1)
1819 as_bad (_("too many ldah insns for !gpdisp!%ld"), insn
->sequence
);
1820 if (info
->segment
!= now_seg
)
1821 as_bad (_("both insns for !gpdisp!%ld must be in the same section"),
1823 fixP
->tc_fix_data
.info
= info
;
1826 case BFD_RELOC_ALPHA_GPDISP_LO16
:
1827 fixP
->fx_no_overflow
= 1;
1829 info
= get_alpha_reloc_tag (insn
->sequence
);
1830 if (++info
->n_slaves
> 1)
1831 as_bad (_("too many lda insns for !gpdisp!%ld"), insn
->sequence
);
1832 if (info
->segment
!= now_seg
)
1833 as_bad (_("both insns for !gpdisp!%ld must be in the same section"),
1835 fixP
->tc_fix_data
.info
= info
;
1836 info
->slaves
= fixP
;
1839 case BFD_RELOC_ALPHA_LITERAL
:
1840 case BFD_RELOC_ALPHA_ELF_LITERAL
:
1841 fixP
->fx_no_overflow
= 1;
1843 if (insn
->sequence
== 0)
1845 info
= get_alpha_reloc_tag (insn
->sequence
);
1846 info
->master
= fixP
;
1848 if (info
->segment
!= now_seg
)
1849 info
->multi_section_p
= 1;
1850 fixP
->tc_fix_data
.info
= info
;
1854 case DUMMY_RELOC_LITUSE_ADDR
:
1855 fixP
->fx_offset
= LITUSE_ALPHA_ADDR
;
1857 case DUMMY_RELOC_LITUSE_BASE
:
1858 fixP
->fx_offset
= LITUSE_ALPHA_BASE
;
1860 case DUMMY_RELOC_LITUSE_BYTOFF
:
1861 fixP
->fx_offset
= LITUSE_ALPHA_BYTOFF
;
1863 case DUMMY_RELOC_LITUSE_JSR
:
1864 fixP
->fx_offset
= LITUSE_ALPHA_JSR
;
1866 case DUMMY_RELOC_LITUSE_TLSGD
:
1867 fixP
->fx_offset
= LITUSE_ALPHA_TLSGD
;
1869 case DUMMY_RELOC_LITUSE_TLSLDM
:
1870 fixP
->fx_offset
= LITUSE_ALPHA_TLSLDM
;
1872 case DUMMY_RELOC_LITUSE_JSRDIRECT
:
1873 fixP
->fx_offset
= LITUSE_ALPHA_JSRDIRECT
;
1876 fixP
->fx_addsy
= section_symbol (now_seg
);
1877 fixP
->fx_r_type
= BFD_RELOC_ALPHA_LITUSE
;
1879 info
= get_alpha_reloc_tag (insn
->sequence
);
1880 if (fixup
->reloc
== DUMMY_RELOC_LITUSE_TLSGD
)
1881 info
->saw_lu_tlsgd
= 1;
1882 else if (fixup
->reloc
== DUMMY_RELOC_LITUSE_TLSLDM
)
1883 info
->saw_lu_tlsldm
= 1;
1884 if (++info
->n_slaves
> 1)
1886 if (info
->saw_lu_tlsgd
)
1887 as_bad (_("too many lituse insns for !lituse_tlsgd!%ld"),
1889 else if (info
->saw_lu_tlsldm
)
1890 as_bad (_("too many lituse insns for !lituse_tlsldm!%ld"),
1893 fixP
->tc_fix_data
.info
= info
;
1894 fixP
->tc_fix_data
.next_reloc
= info
->slaves
;
1895 info
->slaves
= fixP
;
1896 if (info
->segment
!= now_seg
)
1897 info
->multi_section_p
= 1;
1900 case BFD_RELOC_ALPHA_TLSGD
:
1901 fixP
->fx_no_overflow
= 1;
1903 if (insn
->sequence
== 0)
1905 info
= get_alpha_reloc_tag (insn
->sequence
);
1906 if (info
->saw_tlsgd
)
1907 as_bad (_("duplicate !tlsgd!%ld"), insn
->sequence
);
1908 else if (info
->saw_tlsldm
)
1909 as_bad (_("sequence number in use for !tlsldm!%ld"),
1912 info
->saw_tlsgd
= 1;
1913 fixP
->tc_fix_data
.info
= info
;
1916 case BFD_RELOC_ALPHA_TLSLDM
:
1917 fixP
->fx_no_overflow
= 1;
1919 if (insn
->sequence
== 0)
1921 info
= get_alpha_reloc_tag (insn
->sequence
);
1922 if (info
->saw_tlsldm
)
1923 as_bad (_("duplicate !tlsldm!%ld"), insn
->sequence
);
1924 else if (info
->saw_tlsgd
)
1925 as_bad (_("sequence number in use for !tlsgd!%ld"),
1928 info
->saw_tlsldm
= 1;
1929 fixP
->tc_fix_data
.info
= info
;
1933 case BFD_RELOC_ALPHA_NOP
:
1934 case BFD_RELOC_ALPHA_LDA
:
1935 case BFD_RELOC_ALPHA_BSR
:
1936 case BFD_RELOC_ALPHA_BOH
:
1937 info
= get_alpha_reloc_tag (next_sequence_num
--);
1938 fixP
->tc_fix_data
.info
= info
;
1939 fixP
->tc_fix_data
.info
->sym
= fixup
->xtrasym
;
1940 fixP
->tc_fix_data
.info
->psym
= fixup
->procsym
;
1945 if ((int) fixup
->reloc
< 0)
1947 if (operand
->flags
& AXP_OPERAND_NOOVERFLOW
)
1948 fixP
->fx_no_overflow
= 1;
1955 /* Insert an operand value into an instruction. */
1958 insert_operand (unsigned insn
,
1959 const struct alpha_operand
*operand
,
1964 if (operand
->bits
!= 32 && !(operand
->flags
& AXP_OPERAND_NOOVERFLOW
))
1968 if (operand
->flags
& AXP_OPERAND_SIGNED
)
1970 max
= (1 << (operand
->bits
- 1)) - 1;
1971 min
= -(1 << (operand
->bits
- 1));
1975 max
= (1 << operand
->bits
) - 1;
1979 if (val
< min
|| val
> max
)
1980 as_warn_value_out_of_range (_("operand"), val
, min
, max
, file
, line
);
1983 if (operand
->insert
)
1985 const char *errmsg
= NULL
;
1987 insn
= (*operand
->insert
) (insn
, val
, &errmsg
);
1989 as_warn ("%s", errmsg
);
1992 insn
|= ((val
& ((1 << operand
->bits
) - 1)) << operand
->shift
);
1997 /* Turn an opcode description and a set of arguments into
1998 an instruction and a fixup. */
2001 assemble_insn (const struct alpha_opcode
*opcode
,
2002 const expressionS
*tok
,
2004 struct alpha_insn
*insn
,
2005 bfd_reloc_code_real_type reloc
)
2007 const struct alpha_operand
*reloc_operand
= NULL
;
2008 const expressionS
*reloc_exp
= NULL
;
2009 const unsigned char *argidx
;
2013 memset (insn
, 0, sizeof (*insn
));
2014 image
= opcode
->opcode
;
2016 for (argidx
= opcode
->operands
; *argidx
; ++argidx
)
2018 const struct alpha_operand
*operand
= &alpha_operands
[*argidx
];
2019 const expressionS
*t
= (const expressionS
*) 0;
2021 if (operand
->flags
& AXP_OPERAND_FAKE
)
2023 /* Fake operands take no value and generate no fixup. */
2024 image
= insert_operand (image
, operand
, 0, NULL
, 0);
2030 switch (operand
->flags
& AXP_OPERAND_OPTIONAL_MASK
)
2032 case AXP_OPERAND_DEFAULT_FIRST
:
2035 case AXP_OPERAND_DEFAULT_SECOND
:
2038 case AXP_OPERAND_DEFAULT_ZERO
:
2040 static expressionS zero_exp
;
2042 zero_exp
.X_op
= O_constant
;
2043 zero_exp
.X_unsigned
= 1;
2058 image
= insert_operand (image
, operand
, regno (t
->X_add_number
),
2063 image
= insert_operand (image
, operand
, t
->X_add_number
, NULL
, 0);
2064 gas_assert (reloc_operand
== NULL
);
2065 reloc_operand
= operand
;
2070 /* This is only 0 for fields that should contain registers,
2071 which means this pattern shouldn't have matched. */
2072 if (operand
->default_reloc
== 0)
2075 /* There is one special case for which an insn receives two
2076 relocations, and thus the user-supplied reloc does not
2077 override the operand reloc. */
2078 if (operand
->default_reloc
== BFD_RELOC_ALPHA_HINT
)
2080 struct alpha_fixup
*fixup
;
2082 if (insn
->nfixups
>= MAX_INSN_FIXUPS
)
2083 as_fatal (_("too many fixups"));
2085 fixup
= &insn
->fixups
[insn
->nfixups
++];
2087 fixup
->reloc
= BFD_RELOC_ALPHA_HINT
;
2091 if (reloc
== BFD_RELOC_UNUSED
)
2092 reloc
= operand
->default_reloc
;
2094 gas_assert (reloc_operand
== NULL
);
2095 reloc_operand
= operand
;
2102 if (reloc
!= BFD_RELOC_UNUSED
)
2104 struct alpha_fixup
*fixup
;
2106 if (insn
->nfixups
>= MAX_INSN_FIXUPS
)
2107 as_fatal (_("too many fixups"));
2109 /* ??? My but this is hacky. But the OSF/1 assembler uses the same
2110 relocation tag for both ldah and lda with gpdisp. Choose the
2111 correct internal relocation based on the opcode. */
2112 if (reloc
== BFD_RELOC_ALPHA_GPDISP
)
2114 if (strcmp (opcode
->name
, "ldah") == 0)
2115 reloc
= BFD_RELOC_ALPHA_GPDISP_HI16
;
2116 else if (strcmp (opcode
->name
, "lda") == 0)
2117 reloc
= BFD_RELOC_ALPHA_GPDISP_LO16
;
2119 as_bad (_("invalid relocation for instruction"));
2122 /* If this is a real relocation (as opposed to a lituse hint), then
2123 the relocation width should match the operand width.
2124 Take care of -MDISP in operand table. */
2125 else if (reloc
< BFD_RELOC_UNUSED
&& reloc
> 0)
2127 reloc_howto_type
*reloc_howto
2128 = bfd_reloc_type_lookup (stdoutput
, reloc
);
2129 if (reloc_operand
== NULL
2130 || reloc_howto
->bitsize
!= reloc_operand
->bits
)
2132 as_bad (_("invalid relocation for field"));
2137 fixup
= &insn
->fixups
[insn
->nfixups
++];
2139 fixup
->exp
= *reloc_exp
;
2141 fixup
->exp
.X_op
= O_absent
;
2142 fixup
->reloc
= reloc
;
2148 /* Handle all "simple" integer register loads -- ldq, ldq_l, ldq_u,
2149 etc. They differ from the real instructions in that they do simple
2150 expressions like the lda macro. */
2153 emit_ir_load (const expressionS
*tok
,
2155 const void * opname
)
2159 expressionS newtok
[3];
2160 struct alpha_insn insn
;
2162 = tok
[1].X_add_symbol
? S_GET_NAME (tok
[1].X_add_symbol
): "";
2163 int symlen
= strlen (symname
);
2166 basereg
= (tok
[1].X_op
== O_constant
? AXP_REG_ZERO
: alpha_gp_register
);
2168 basereg
= tok
[2].X_add_number
;
2170 lituse
= load_expression (tok
[0].X_add_number
, &tok
[1],
2171 &basereg
, &newtok
[1], opname
);
2173 if (basereg
== alpha_gp_register
&&
2174 (symlen
> 4 && strcmp (&symname
[symlen
- 4], "..lk") == 0))
2178 set_tok_preg (newtok
[2], basereg
);
2180 assemble_tokens_to_insn ((const char *) opname
, newtok
, 3, &insn
);
2184 gas_assert (insn
.nfixups
< MAX_INSN_FIXUPS
);
2185 insn
.fixups
[insn
.nfixups
].reloc
= DUMMY_RELOC_LITUSE_BASE
;
2186 insn
.fixups
[insn
.nfixups
].exp
.X_op
= O_absent
;
2188 insn
.sequence
= lituse
;
2194 /* Handle fp register loads, and both integer and fp register stores.
2195 Again, we handle simple expressions. */
2198 emit_loadstore (const expressionS
*tok
,
2200 const void * opname
)
2204 expressionS newtok
[3];
2205 struct alpha_insn insn
;
2208 basereg
= (tok
[1].X_op
== O_constant
? AXP_REG_ZERO
: alpha_gp_register
);
2210 basereg
= tok
[2].X_add_number
;
2212 if (tok
[1].X_op
!= O_constant
|| !range_signed_16 (tok
[1].X_add_number
))
2215 as_bad (_("macro requires $at register while noat in effect"));
2217 lituse
= load_expression (AXP_REG_AT
, &tok
[1],
2218 &basereg
, &newtok
[1], opname
);
2227 set_tok_preg (newtok
[2], basereg
);
2229 assemble_tokens_to_insn ((const char *) opname
, newtok
, 3, &insn
);
2233 gas_assert (insn
.nfixups
< MAX_INSN_FIXUPS
);
2234 insn
.fixups
[insn
.nfixups
].reloc
= DUMMY_RELOC_LITUSE_BASE
;
2235 insn
.fixups
[insn
.nfixups
].exp
.X_op
= O_absent
;
2237 insn
.sequence
= lituse
;
2243 /* Load a half-word or byte as an unsigned value. */
2246 emit_ldXu (const expressionS
*tok
,
2248 const void * vlgsize
)
2250 if (alpha_target
& AXP_OPCODE_BWX
)
2251 emit_ir_load (tok
, ntok
, ldXu_op
[(long) vlgsize
]);
2254 expressionS newtok
[3];
2255 struct alpha_insn insn
;
2260 as_bad (_("macro requires $at register while noat in effect"));
2263 basereg
= (tok
[1].X_op
== O_constant
2264 ? AXP_REG_ZERO
: alpha_gp_register
);
2266 basereg
= tok
[2].X_add_number
;
2268 /* Emit "lda $at, exp". */
2269 lituse
= load_expression (AXP_REG_AT
, &tok
[1], &basereg
, NULL
, "lda");
2271 /* Emit "ldq_u targ, 0($at)". */
2273 set_tok_const (newtok
[1], 0);
2274 set_tok_preg (newtok
[2], basereg
);
2275 assemble_tokens_to_insn ("ldq_u", newtok
, 3, &insn
);
2279 gas_assert (insn
.nfixups
< MAX_INSN_FIXUPS
);
2280 insn
.fixups
[insn
.nfixups
].reloc
= DUMMY_RELOC_LITUSE_BASE
;
2281 insn
.fixups
[insn
.nfixups
].exp
.X_op
= O_absent
;
2283 insn
.sequence
= lituse
;
2288 /* Emit "extXl targ, $at, targ". */
2289 set_tok_reg (newtok
[1], basereg
);
2290 newtok
[2] = newtok
[0];
2291 assemble_tokens_to_insn (extXl_op
[(long) vlgsize
], newtok
, 3, &insn
);
2295 gas_assert (insn
.nfixups
< MAX_INSN_FIXUPS
);
2296 insn
.fixups
[insn
.nfixups
].reloc
= DUMMY_RELOC_LITUSE_BYTOFF
;
2297 insn
.fixups
[insn
.nfixups
].exp
.X_op
= O_absent
;
2299 insn
.sequence
= lituse
;
2306 /* Load a half-word or byte as a signed value. */
2309 emit_ldX (const expressionS
*tok
,
2311 const void * vlgsize
)
2313 emit_ldXu (tok
, ntok
, vlgsize
);
2314 assemble_tokens (sextX_op
[(long) vlgsize
], tok
, 1, 1);
2317 /* Load an integral value from an unaligned address as an unsigned
2321 emit_uldXu (const expressionS
*tok
,
2323 const void * vlgsize
)
2325 long lgsize
= (long) vlgsize
;
2326 expressionS newtok
[3];
2329 as_bad (_("macro requires $at register while noat in effect"));
2331 /* Emit "lda $at, exp". */
2332 memcpy (newtok
, tok
, sizeof (expressionS
) * ntok
);
2333 newtok
[0].X_add_number
= AXP_REG_AT
;
2334 assemble_tokens ("lda", newtok
, ntok
, 1);
2336 /* Emit "ldq_u $t9, 0($at)". */
2337 set_tok_reg (newtok
[0], AXP_REG_T9
);
2338 set_tok_const (newtok
[1], 0);
2339 set_tok_preg (newtok
[2], AXP_REG_AT
);
2340 assemble_tokens ("ldq_u", newtok
, 3, 1);
2342 /* Emit "ldq_u $t10, size-1($at)". */
2343 set_tok_reg (newtok
[0], AXP_REG_T10
);
2344 set_tok_const (newtok
[1], (1 << lgsize
) - 1);
2345 assemble_tokens ("ldq_u", newtok
, 3, 1);
2347 /* Emit "extXl $t9, $at, $t9". */
2348 set_tok_reg (newtok
[0], AXP_REG_T9
);
2349 set_tok_reg (newtok
[1], AXP_REG_AT
);
2350 set_tok_reg (newtok
[2], AXP_REG_T9
);
2351 assemble_tokens (extXl_op
[lgsize
], newtok
, 3, 1);
2353 /* Emit "extXh $t10, $at, $t10". */
2354 set_tok_reg (newtok
[0], AXP_REG_T10
);
2355 set_tok_reg (newtok
[2], AXP_REG_T10
);
2356 assemble_tokens (extXh_op
[lgsize
], newtok
, 3, 1);
2358 /* Emit "or $t9, $t10, targ". */
2359 set_tok_reg (newtok
[0], AXP_REG_T9
);
2360 set_tok_reg (newtok
[1], AXP_REG_T10
);
2362 assemble_tokens ("or", newtok
, 3, 1);
2365 /* Load an integral value from an unaligned address as a signed value.
2366 Note that quads should get funneled to the unsigned load since we
2367 don't have to do the sign extension. */
2370 emit_uldX (const expressionS
*tok
,
2372 const void * vlgsize
)
2374 emit_uldXu (tok
, ntok
, vlgsize
);
2375 assemble_tokens (sextX_op
[(long) vlgsize
], tok
, 1, 1);
2378 /* Implement the ldil macro. */
2381 emit_ldil (const expressionS
*tok
,
2383 const void * unused ATTRIBUTE_UNUSED
)
2385 expressionS newtok
[2];
2387 memcpy (newtok
, tok
, sizeof (newtok
));
2388 newtok
[1].X_add_number
= sign_extend_32 (tok
[1].X_add_number
);
2390 assemble_tokens ("lda", newtok
, ntok
, 1);
2393 /* Store a half-word or byte. */
2396 emit_stX (const expressionS
*tok
,
2398 const void * vlgsize
)
2400 int lgsize
= (int) (long) vlgsize
;
2402 if (alpha_target
& AXP_OPCODE_BWX
)
2403 emit_loadstore (tok
, ntok
, stX_op
[lgsize
]);
2406 expressionS newtok
[3];
2407 struct alpha_insn insn
;
2412 as_bad (_("macro requires $at register while noat in effect"));
2415 basereg
= (tok
[1].X_op
== O_constant
2416 ? AXP_REG_ZERO
: alpha_gp_register
);
2418 basereg
= tok
[2].X_add_number
;
2420 /* Emit "lda $at, exp". */
2421 lituse
= load_expression (AXP_REG_AT
, &tok
[1], &basereg
, NULL
, "lda");
2423 /* Emit "ldq_u $t9, 0($at)". */
2424 set_tok_reg (newtok
[0], AXP_REG_T9
);
2425 set_tok_const (newtok
[1], 0);
2426 set_tok_preg (newtok
[2], basereg
);
2427 assemble_tokens_to_insn ("ldq_u", newtok
, 3, &insn
);
2431 gas_assert (insn
.nfixups
< MAX_INSN_FIXUPS
);
2432 insn
.fixups
[insn
.nfixups
].reloc
= DUMMY_RELOC_LITUSE_BASE
;
2433 insn
.fixups
[insn
.nfixups
].exp
.X_op
= O_absent
;
2435 insn
.sequence
= lituse
;
2440 /* Emit "insXl src, $at, $t10". */
2442 set_tok_reg (newtok
[1], basereg
);
2443 set_tok_reg (newtok
[2], AXP_REG_T10
);
2444 assemble_tokens_to_insn (insXl_op
[lgsize
], newtok
, 3, &insn
);
2448 gas_assert (insn
.nfixups
< MAX_INSN_FIXUPS
);
2449 insn
.fixups
[insn
.nfixups
].reloc
= DUMMY_RELOC_LITUSE_BYTOFF
;
2450 insn
.fixups
[insn
.nfixups
].exp
.X_op
= O_absent
;
2452 insn
.sequence
= lituse
;
2457 /* Emit "mskXl $t9, $at, $t9". */
2458 set_tok_reg (newtok
[0], AXP_REG_T9
);
2459 newtok
[2] = newtok
[0];
2460 assemble_tokens_to_insn (mskXl_op
[lgsize
], newtok
, 3, &insn
);
2464 gas_assert (insn
.nfixups
< MAX_INSN_FIXUPS
);
2465 insn
.fixups
[insn
.nfixups
].reloc
= DUMMY_RELOC_LITUSE_BYTOFF
;
2466 insn
.fixups
[insn
.nfixups
].exp
.X_op
= O_absent
;
2468 insn
.sequence
= lituse
;
2473 /* Emit "or $t9, $t10, $t9". */
2474 set_tok_reg (newtok
[1], AXP_REG_T10
);
2475 assemble_tokens ("or", newtok
, 3, 1);
2477 /* Emit "stq_u $t9, 0($at). */
2478 set_tok_const(newtok
[1], 0);
2479 set_tok_preg (newtok
[2], AXP_REG_AT
);
2480 assemble_tokens_to_insn ("stq_u", newtok
, 3, &insn
);
2484 gas_assert (insn
.nfixups
< MAX_INSN_FIXUPS
);
2485 insn
.fixups
[insn
.nfixups
].reloc
= DUMMY_RELOC_LITUSE_BASE
;
2486 insn
.fixups
[insn
.nfixups
].exp
.X_op
= O_absent
;
2488 insn
.sequence
= lituse
;
2495 /* Store an integer to an unaligned address. */
2498 emit_ustX (const expressionS
*tok
,
2500 const void * vlgsize
)
2502 int lgsize
= (int) (long) vlgsize
;
2503 expressionS newtok
[3];
2505 /* Emit "lda $at, exp". */
2506 memcpy (newtok
, tok
, sizeof (expressionS
) * ntok
);
2507 newtok
[0].X_add_number
= AXP_REG_AT
;
2508 assemble_tokens ("lda", newtok
, ntok
, 1);
2510 /* Emit "ldq_u $9, 0($at)". */
2511 set_tok_reg (newtok
[0], AXP_REG_T9
);
2512 set_tok_const (newtok
[1], 0);
2513 set_tok_preg (newtok
[2], AXP_REG_AT
);
2514 assemble_tokens ("ldq_u", newtok
, 3, 1);
2516 /* Emit "ldq_u $10, size-1($at)". */
2517 set_tok_reg (newtok
[0], AXP_REG_T10
);
2518 set_tok_const (newtok
[1], (1 << lgsize
) - 1);
2519 assemble_tokens ("ldq_u", newtok
, 3, 1);
2521 /* Emit "insXl src, $at, $t11". */
2523 set_tok_reg (newtok
[1], AXP_REG_AT
);
2524 set_tok_reg (newtok
[2], AXP_REG_T11
);
2525 assemble_tokens (insXl_op
[lgsize
], newtok
, 3, 1);
2527 /* Emit "insXh src, $at, $t12". */
2528 set_tok_reg (newtok
[2], AXP_REG_T12
);
2529 assemble_tokens (insXh_op
[lgsize
], newtok
, 3, 1);
2531 /* Emit "mskXl $t9, $at, $t9". */
2532 set_tok_reg (newtok
[0], AXP_REG_T9
);
2533 newtok
[2] = newtok
[0];
2534 assemble_tokens (mskXl_op
[lgsize
], newtok
, 3, 1);
2536 /* Emit "mskXh $t10, $at, $t10". */
2537 set_tok_reg (newtok
[0], AXP_REG_T10
);
2538 newtok
[2] = newtok
[0];
2539 assemble_tokens (mskXh_op
[lgsize
], newtok
, 3, 1);
2541 /* Emit "or $t9, $t11, $t9". */
2542 set_tok_reg (newtok
[0], AXP_REG_T9
);
2543 set_tok_reg (newtok
[1], AXP_REG_T11
);
2544 newtok
[2] = newtok
[0];
2545 assemble_tokens ("or", newtok
, 3, 1);
2547 /* Emit "or $t10, $t12, $t10". */
2548 set_tok_reg (newtok
[0], AXP_REG_T10
);
2549 set_tok_reg (newtok
[1], AXP_REG_T12
);
2550 newtok
[2] = newtok
[0];
2551 assemble_tokens ("or", newtok
, 3, 1);
2553 /* Emit "stq_u $t10, size-1($at)". */
2554 set_tok_reg (newtok
[0], AXP_REG_T10
);
2555 set_tok_const (newtok
[1], (1 << lgsize
) - 1);
2556 set_tok_preg (newtok
[2], AXP_REG_AT
);
2557 assemble_tokens ("stq_u", newtok
, 3, 1);
2559 /* Emit "stq_u $t9, 0($at)". */
2560 set_tok_reg (newtok
[0], AXP_REG_T9
);
2561 set_tok_const (newtok
[1], 0);
2562 assemble_tokens ("stq_u", newtok
, 3, 1);
2565 /* Sign extend a half-word or byte. The 32-bit sign extend is
2566 implemented as "addl $31, $r, $t" in the opcode table. */
2569 emit_sextX (const expressionS
*tok
,
2571 const void * vlgsize
)
2573 long lgsize
= (long) vlgsize
;
2575 if (alpha_target
& AXP_OPCODE_BWX
)
2576 assemble_tokens (sextX_op
[lgsize
], tok
, ntok
, 0);
2579 int bitshift
= 64 - 8 * (1 << lgsize
);
2580 expressionS newtok
[3];
2582 /* Emit "sll src,bits,dst". */
2584 set_tok_const (newtok
[1], bitshift
);
2585 newtok
[2] = tok
[ntok
- 1];
2586 assemble_tokens ("sll", newtok
, 3, 1);
2588 /* Emit "sra dst,bits,dst". */
2589 newtok
[0] = newtok
[2];
2590 assemble_tokens ("sra", newtok
, 3, 1);
2594 /* Implement the division and modulus macros. */
2598 /* Make register usage like in normal procedure call.
2599 Don't clobber PV and RA. */
2602 emit_division (const expressionS
*tok
,
2604 const void * symname
)
2606 /* DIVISION and MODULUS. Yech.
2611 mov x,R16 # if x != R16
2612 mov y,R17 # if y != R17
2617 with appropriate optimizations if R0,R16,R17 are the registers
2618 specified by the compiler. */
2622 expressionS newtok
[3];
2624 xr
= regno (tok
[0].X_add_number
);
2625 yr
= regno (tok
[1].X_add_number
);
2630 rr
= regno (tok
[2].X_add_number
);
2632 /* Move the operands into the right place. */
2633 if (yr
== AXP_REG_R16
&& xr
== AXP_REG_R17
)
2635 /* They are in exactly the wrong order -- swap through AT. */
2637 as_bad (_("macro requires $at register while noat in effect"));
2639 set_tok_reg (newtok
[0], AXP_REG_R16
);
2640 set_tok_reg (newtok
[1], AXP_REG_AT
);
2641 assemble_tokens ("mov", newtok
, 2, 1);
2643 set_tok_reg (newtok
[0], AXP_REG_R17
);
2644 set_tok_reg (newtok
[1], AXP_REG_R16
);
2645 assemble_tokens ("mov", newtok
, 2, 1);
2647 set_tok_reg (newtok
[0], AXP_REG_AT
);
2648 set_tok_reg (newtok
[1], AXP_REG_R17
);
2649 assemble_tokens ("mov", newtok
, 2, 1);
2653 if (yr
== AXP_REG_R16
)
2655 set_tok_reg (newtok
[0], AXP_REG_R16
);
2656 set_tok_reg (newtok
[1], AXP_REG_R17
);
2657 assemble_tokens ("mov", newtok
, 2, 1);
2660 if (xr
!= AXP_REG_R16
)
2662 set_tok_reg (newtok
[0], xr
);
2663 set_tok_reg (newtok
[1], AXP_REG_R16
);
2664 assemble_tokens ("mov", newtok
, 2, 1);
2667 if (yr
!= AXP_REG_R16
&& yr
!= AXP_REG_R17
)
2669 set_tok_reg (newtok
[0], yr
);
2670 set_tok_reg (newtok
[1], AXP_REG_R17
);
2671 assemble_tokens ("mov", newtok
, 2, 1);
2675 sym
= symbol_find_or_make ((const char *) symname
);
2677 set_tok_reg (newtok
[0], AXP_REG_AT
);
2678 set_tok_sym (newtok
[1], sym
, 0);
2679 assemble_tokens ("lda", newtok
, 2, 1);
2681 /* Call the division routine. */
2682 set_tok_reg (newtok
[0], AXP_REG_AT
);
2683 set_tok_cpreg (newtok
[1], AXP_REG_AT
);
2684 set_tok_const (newtok
[2], 0);
2685 assemble_tokens ("jsr", newtok
, 3, 1);
2687 /* Move the result to the right place. */
2688 if (rr
!= AXP_REG_R0
)
2690 set_tok_reg (newtok
[0], AXP_REG_R0
);
2691 set_tok_reg (newtok
[1], rr
);
2692 assemble_tokens ("mov", newtok
, 2, 1);
2696 #else /* !OBJ_EVAX */
2699 emit_division (const expressionS
*tok
,
2701 const void * symname
)
2703 /* DIVISION and MODULUS. Yech.
2713 with appropriate optimizations if t10,t11,t12 are the registers
2714 specified by the compiler. */
2718 expressionS newtok
[3];
2720 xr
= regno (tok
[0].X_add_number
);
2721 yr
= regno (tok
[1].X_add_number
);
2726 rr
= regno (tok
[2].X_add_number
);
2728 sym
= symbol_find_or_make ((const char *) symname
);
2730 /* Move the operands into the right place. */
2731 if (yr
== AXP_REG_T10
&& xr
== AXP_REG_T11
)
2733 /* They are in exactly the wrong order -- swap through AT. */
2735 as_bad (_("macro requires $at register while noat in effect"));
2737 set_tok_reg (newtok
[0], AXP_REG_T10
);
2738 set_tok_reg (newtok
[1], AXP_REG_AT
);
2739 assemble_tokens ("mov", newtok
, 2, 1);
2741 set_tok_reg (newtok
[0], AXP_REG_T11
);
2742 set_tok_reg (newtok
[1], AXP_REG_T10
);
2743 assemble_tokens ("mov", newtok
, 2, 1);
2745 set_tok_reg (newtok
[0], AXP_REG_AT
);
2746 set_tok_reg (newtok
[1], AXP_REG_T11
);
2747 assemble_tokens ("mov", newtok
, 2, 1);
2751 if (yr
== AXP_REG_T10
)
2753 set_tok_reg (newtok
[0], AXP_REG_T10
);
2754 set_tok_reg (newtok
[1], AXP_REG_T11
);
2755 assemble_tokens ("mov", newtok
, 2, 1);
2758 if (xr
!= AXP_REG_T10
)
2760 set_tok_reg (newtok
[0], xr
);
2761 set_tok_reg (newtok
[1], AXP_REG_T10
);
2762 assemble_tokens ("mov", newtok
, 2, 1);
2765 if (yr
!= AXP_REG_T10
&& yr
!= AXP_REG_T11
)
2767 set_tok_reg (newtok
[0], yr
);
2768 set_tok_reg (newtok
[1], AXP_REG_T11
);
2769 assemble_tokens ("mov", newtok
, 2, 1);
2773 /* Call the division routine. */
2774 set_tok_reg (newtok
[0], AXP_REG_T9
);
2775 set_tok_sym (newtok
[1], sym
, 0);
2776 assemble_tokens ("jsr", newtok
, 2, 1);
2778 /* Reload the GP register. */
2782 #if defined(OBJ_ECOFF) || defined(OBJ_ELF)
2783 set_tok_reg (newtok
[0], alpha_gp_register
);
2784 set_tok_const (newtok
[1], 0);
2785 set_tok_preg (newtok
[2], AXP_REG_T9
);
2786 assemble_tokens ("ldgp", newtok
, 3, 1);
2789 /* Move the result to the right place. */
2790 if (rr
!= AXP_REG_T12
)
2792 set_tok_reg (newtok
[0], AXP_REG_T12
);
2793 set_tok_reg (newtok
[1], rr
);
2794 assemble_tokens ("mov", newtok
, 2, 1);
2798 #endif /* !OBJ_EVAX */
2800 /* The jsr and jmp macros differ from their instruction counterparts
2801 in that they can load the target address and default most
2805 emit_jsrjmp (const expressionS
*tok
,
2807 const void * vopname
)
2809 const char *opname
= (const char *) vopname
;
2810 struct alpha_insn insn
;
2811 expressionS newtok
[3];
2815 if (tokidx
< ntok
&& tok
[tokidx
].X_op
== O_register
)
2816 r
= regno (tok
[tokidx
++].X_add_number
);
2818 r
= strcmp (opname
, "jmp") == 0 ? AXP_REG_ZERO
: AXP_REG_RA
;
2820 set_tok_reg (newtok
[0], r
);
2822 if (tokidx
< ntok
&&
2823 (tok
[tokidx
].X_op
== O_pregister
|| tok
[tokidx
].X_op
== O_cpregister
))
2824 r
= regno (tok
[tokidx
++].X_add_number
);
2826 /* Keep register if jsr $n.<sym>. */
2830 int basereg
= alpha_gp_register
;
2831 lituse
= load_expression (r
= AXP_REG_PV
, &tok
[tokidx
],
2832 &basereg
, NULL
, opname
);
2836 set_tok_cpreg (newtok
[1], r
);
2840 newtok
[2] = tok
[tokidx
];
2843 set_tok_const (newtok
[2], 0);
2845 assemble_tokens_to_insn (opname
, newtok
, 3, &insn
);
2849 gas_assert (insn
.nfixups
< MAX_INSN_FIXUPS
);
2850 insn
.fixups
[insn
.nfixups
].reloc
= DUMMY_RELOC_LITUSE_JSR
;
2851 insn
.fixups
[insn
.nfixups
].exp
.X_op
= O_absent
;
2853 insn
.sequence
= lituse
;
2857 if (alpha_flag_replace
2859 && tok
[tokidx
].X_add_symbol
2860 && alpha_linkage_symbol
)
2862 const char *symname
= S_GET_NAME (tok
[tokidx
].X_add_symbol
);
2863 int symlen
= strlen (symname
);
2866 ensymname
= (char *) xmalloc (symlen
+ 5);
2867 memcpy (ensymname
, symname
, symlen
);
2868 memcpy (ensymname
+ symlen
, "..en", 5);
2870 gas_assert (insn
.nfixups
< MAX_INSN_FIXUPS
);
2871 if (insn
.nfixups
> 0)
2873 memmove (&insn
.fixups
[1], &insn
.fixups
[0],
2874 sizeof(struct alpha_fixup
) * insn
.nfixups
);
2877 /* The fixup must be the same as the BFD_RELOC_ALPHA_NOP
2878 case in load_expression. See B.4.5.2 of the OpenVMS
2879 Linker Utility Manual. */
2880 insn
.fixups
[0].reloc
= BFD_RELOC_ALPHA_BOH
;
2881 insn
.fixups
[0].exp
.X_op
= O_symbol
;
2882 insn
.fixups
[0].exp
.X_add_symbol
= symbol_find_or_make (ensymname
);
2883 insn
.fixups
[0].exp
.X_add_number
= 0;
2884 insn
.fixups
[0].xtrasym
= alpha_linkage_symbol
;
2885 insn
.fixups
[0].procsym
= alpha_evax_proc
->symbol
;
2887 alpha_linkage_symbol
= 0;
2894 /* The ret and jcr instructions differ from their instruction
2895 counterparts in that everything can be defaulted. */
2898 emit_retjcr (const expressionS
*tok
,
2900 const void * vopname
)
2902 const char *opname
= (const char *) vopname
;
2903 expressionS newtok
[3];
2906 if (tokidx
< ntok
&& tok
[tokidx
].X_op
== O_register
)
2907 r
= regno (tok
[tokidx
++].X_add_number
);
2911 set_tok_reg (newtok
[0], r
);
2913 if (tokidx
< ntok
&&
2914 (tok
[tokidx
].X_op
== O_pregister
|| tok
[tokidx
].X_op
== O_cpregister
))
2915 r
= regno (tok
[tokidx
++].X_add_number
);
2919 set_tok_cpreg (newtok
[1], r
);
2922 newtok
[2] = tok
[tokidx
];
2924 set_tok_const (newtok
[2], strcmp (opname
, "ret") == 0);
2926 assemble_tokens (opname
, newtok
, 3, 0);
2929 /* Implement the ldgp macro. */
2932 emit_ldgp (const expressionS
*tok
,
2933 int ntok ATTRIBUTE_UNUSED
,
2934 const void * unused ATTRIBUTE_UNUSED
)
2939 #if defined(OBJ_ECOFF) || defined(OBJ_ELF)
2940 /* from "ldgp r1,n(r2)", generate "ldah r1,X(R2); lda r1,Y(r1)"
2941 with appropriate constants and relocations. */
2942 struct alpha_insn insn
;
2943 expressionS newtok
[3];
2947 if (regno (tok
[2].X_add_number
) == AXP_REG_PV
)
2948 ecoff_set_gp_prolog_size (0);
2952 set_tok_const (newtok
[1], 0);
2955 assemble_tokens_to_insn ("ldah", newtok
, 3, &insn
);
2960 if (addend
.X_op
!= O_constant
)
2961 as_bad (_("can not resolve expression"));
2962 addend
.X_op
= O_symbol
;
2963 addend
.X_add_symbol
= alpha_gp_symbol
;
2967 insn
.fixups
[0].exp
= addend
;
2968 insn
.fixups
[0].reloc
= BFD_RELOC_ALPHA_GPDISP_HI16
;
2969 insn
.sequence
= next_sequence_num
;
2973 set_tok_preg (newtok
[2], tok
[0].X_add_number
);
2975 assemble_tokens_to_insn ("lda", newtok
, 3, &insn
);
2978 addend
.X_add_number
+= 4;
2982 insn
.fixups
[0].exp
= addend
;
2983 insn
.fixups
[0].reloc
= BFD_RELOC_ALPHA_GPDISP_LO16
;
2984 insn
.sequence
= next_sequence_num
--;
2987 #else /* OBJ_ECOFF || OBJ_ELF */
2988 /* Avoid warning. */
2993 /* The macro table. */
2995 static const struct alpha_macro alpha_macros
[] =
2997 /* Load/Store macros. */
2998 { "lda", emit_lda
, NULL
,
2999 { MACRO_IR
, MACRO_EXP
, MACRO_OPIR
, MACRO_EOA
} },
3000 { "ldah", emit_ldah
, NULL
,
3001 { MACRO_IR
, MACRO_EXP
, MACRO_EOA
} },
3003 { "ldl", emit_ir_load
, "ldl",
3004 { MACRO_IR
, MACRO_EXP
, MACRO_OPIR
, MACRO_EOA
} },
3005 { "ldl_l", emit_ir_load
, "ldl_l",
3006 { MACRO_IR
, MACRO_EXP
, MACRO_OPIR
, MACRO_EOA
} },
3007 { "ldq", emit_ir_load
, "ldq",
3008 { MACRO_IR
, MACRO_EXP
, MACRO_OPIR
, MACRO_EOA
} },
3009 { "ldq_l", emit_ir_load
, "ldq_l",
3010 { MACRO_IR
, MACRO_EXP
, MACRO_OPIR
, MACRO_EOA
} },
3011 { "ldq_u", emit_ir_load
, "ldq_u",
3012 { MACRO_IR
, MACRO_EXP
, MACRO_OPIR
, MACRO_EOA
} },
3013 { "ldf", emit_loadstore
, "ldf",
3014 { MACRO_FPR
, MACRO_EXP
, MACRO_OPIR
, MACRO_EOA
} },
3015 { "ldg", emit_loadstore
, "ldg",
3016 { MACRO_FPR
, MACRO_EXP
, MACRO_OPIR
, MACRO_EOA
} },
3017 { "lds", emit_loadstore
, "lds",
3018 { MACRO_FPR
, MACRO_EXP
, MACRO_OPIR
, MACRO_EOA
} },
3019 { "ldt", emit_loadstore
, "ldt",
3020 { MACRO_FPR
, MACRO_EXP
, MACRO_OPIR
, MACRO_EOA
} },
3022 { "ldb", emit_ldX
, (void *) 0,
3023 { MACRO_IR
, MACRO_EXP
, MACRO_OPIR
, MACRO_EOA
} },
3024 { "ldbu", emit_ldXu
, (void *) 0,
3025 { MACRO_IR
, MACRO_EXP
, MACRO_OPIR
, MACRO_EOA
} },
3026 { "ldw", emit_ldX
, (void *) 1,
3027 { MACRO_IR
, MACRO_EXP
, MACRO_OPIR
, MACRO_EOA
} },
3028 { "ldwu", emit_ldXu
, (void *) 1,
3029 { MACRO_IR
, MACRO_EXP
, MACRO_OPIR
, MACRO_EOA
} },
3031 { "uldw", emit_uldX
, (void *) 1,
3032 { MACRO_IR
, MACRO_EXP
, MACRO_OPIR
, MACRO_EOA
} },
3033 { "uldwu", emit_uldXu
, (void *) 1,
3034 { MACRO_IR
, MACRO_EXP
, MACRO_OPIR
, MACRO_EOA
} },
3035 { "uldl", emit_uldX
, (void *) 2,
3036 { MACRO_IR
, MACRO_EXP
, MACRO_OPIR
, MACRO_EOA
} },
3037 { "uldlu", emit_uldXu
, (void *) 2,
3038 { MACRO_IR
, MACRO_EXP
, MACRO_OPIR
, MACRO_EOA
} },
3039 { "uldq", emit_uldXu
, (void *) 3,
3040 { MACRO_IR
, MACRO_EXP
, MACRO_OPIR
, MACRO_EOA
} },
3042 { "ldgp", emit_ldgp
, NULL
,
3043 { MACRO_IR
, MACRO_EXP
, MACRO_PIR
, MACRO_EOA
} },
3045 { "ldi", emit_lda
, NULL
,
3046 { MACRO_IR
, MACRO_EXP
, MACRO_EOA
} },
3047 { "ldil", emit_ldil
, NULL
,
3048 { MACRO_IR
, MACRO_EXP
, MACRO_EOA
} },
3049 { "ldiq", emit_lda
, NULL
,
3050 { MACRO_IR
, MACRO_EXP
, MACRO_EOA
} },
3052 { "stl", emit_loadstore
, "stl",
3053 { MACRO_IR
, MACRO_EXP
, MACRO_OPIR
, MACRO_EOA
} },
3054 { "stl_c", emit_loadstore
, "stl_c",
3055 { MACRO_IR
, MACRO_EXP
, MACRO_OPIR
, MACRO_EOA
} },
3056 { "stq", emit_loadstore
, "stq",
3057 { MACRO_IR
, MACRO_EXP
, MACRO_OPIR
, MACRO_EOA
} },
3058 { "stq_c", emit_loadstore
, "stq_c",
3059 { MACRO_IR
, MACRO_EXP
, MACRO_OPIR
, MACRO_EOA
} },
3060 { "stq_u", emit_loadstore
, "stq_u",
3061 { MACRO_IR
, MACRO_EXP
, MACRO_OPIR
, MACRO_EOA
} },
3062 { "stf", emit_loadstore
, "stf",
3063 { MACRO_FPR
, MACRO_EXP
, MACRO_OPIR
, MACRO_EOA
} },
3064 { "stg", emit_loadstore
, "stg",
3065 { MACRO_FPR
, MACRO_EXP
, MACRO_OPIR
, MACRO_EOA
} },
3066 { "sts", emit_loadstore
, "sts",
3067 { MACRO_FPR
, MACRO_EXP
, MACRO_OPIR
, MACRO_EOA
} },
3068 { "stt", emit_loadstore
, "stt",
3069 { MACRO_FPR
, MACRO_EXP
, MACRO_OPIR
, MACRO_EOA
} },
3071 { "stb", emit_stX
, (void *) 0,
3072 { MACRO_IR
, MACRO_EXP
, MACRO_OPIR
, MACRO_EOA
} },
3073 { "stw", emit_stX
, (void *) 1,
3074 { MACRO_IR
, MACRO_EXP
, MACRO_OPIR
, MACRO_EOA
} },
3075 { "ustw", emit_ustX
, (void *) 1,
3076 { MACRO_IR
, MACRO_EXP
, MACRO_OPIR
, MACRO_EOA
} },
3077 { "ustl", emit_ustX
, (void *) 2,
3078 { MACRO_IR
, MACRO_EXP
, MACRO_OPIR
, MACRO_EOA
} },
3079 { "ustq", emit_ustX
, (void *) 3,
3080 { MACRO_IR
, MACRO_EXP
, MACRO_OPIR
, MACRO_EOA
} },
3082 /* Arithmetic macros. */
3084 { "sextb", emit_sextX
, (void *) 0,
3085 { MACRO_IR
, MACRO_IR
, MACRO_EOA
,
3086 MACRO_IR
, MACRO_EOA
,
3087 /* MACRO_EXP, MACRO_IR, MACRO_EOA */ } },
3088 { "sextw", emit_sextX
, (void *) 1,
3089 { MACRO_IR
, MACRO_IR
, MACRO_EOA
,
3090 MACRO_IR
, MACRO_EOA
,
3091 /* MACRO_EXP, MACRO_IR, MACRO_EOA */ } },
3093 { "divl", emit_division
, "__divl",
3094 { MACRO_IR
, MACRO_IR
, MACRO_IR
, MACRO_EOA
,
3095 MACRO_IR
, MACRO_IR
, MACRO_EOA
,
3096 /* MACRO_IR, MACRO_EXP, MACRO_IR, MACRO_EOA,
3097 MACRO_IR, MACRO_EXP, MACRO_EOA */ } },
3098 { "divlu", emit_division
, "__divlu",
3099 { MACRO_IR
, MACRO_IR
, MACRO_IR
, MACRO_EOA
,
3100 MACRO_IR
, MACRO_IR
, MACRO_EOA
,
3101 /* MACRO_IR, MACRO_EXP, MACRO_IR, MACRO_EOA,
3102 MACRO_IR, MACRO_EXP, MACRO_EOA */ } },
3103 { "divq", emit_division
, "__divq",
3104 { MACRO_IR
, MACRO_IR
, MACRO_IR
, MACRO_EOA
,
3105 MACRO_IR
, MACRO_IR
, MACRO_EOA
,
3106 /* MACRO_IR, MACRO_EXP, MACRO_IR, MACRO_EOA,
3107 MACRO_IR, MACRO_EXP, MACRO_EOA */ } },
3108 { "divqu", emit_division
, "__divqu",
3109 { MACRO_IR
, MACRO_IR
, MACRO_IR
, MACRO_EOA
,
3110 MACRO_IR
, MACRO_IR
, MACRO_EOA
,
3111 /* MACRO_IR, MACRO_EXP, MACRO_IR, MACRO_EOA,
3112 MACRO_IR, MACRO_EXP, MACRO_EOA */ } },
3113 { "reml", emit_division
, "__reml",
3114 { MACRO_IR
, MACRO_IR
, MACRO_IR
, MACRO_EOA
,
3115 MACRO_IR
, MACRO_IR
, MACRO_EOA
,
3116 /* MACRO_IR, MACRO_EXP, MACRO_IR, MACRO_EOA,
3117 MACRO_IR, MACRO_EXP, MACRO_EOA */ } },
3118 { "remlu", emit_division
, "__remlu",
3119 { MACRO_IR
, MACRO_IR
, MACRO_IR
, MACRO_EOA
,
3120 MACRO_IR
, MACRO_IR
, MACRO_EOA
,
3121 /* MACRO_IR, MACRO_EXP, MACRO_IR, MACRO_EOA,
3122 MACRO_IR, MACRO_EXP, MACRO_EOA */ } },
3123 { "remq", emit_division
, "__remq",
3124 { MACRO_IR
, MACRO_IR
, MACRO_IR
, MACRO_EOA
,
3125 MACRO_IR
, MACRO_IR
, MACRO_EOA
,
3126 /* MACRO_IR, MACRO_EXP, MACRO_IR, MACRO_EOA,
3127 MACRO_IR, MACRO_EXP, MACRO_EOA */ } },
3128 { "remqu", emit_division
, "__remqu",
3129 { MACRO_IR
, MACRO_IR
, MACRO_IR
, MACRO_EOA
,
3130 MACRO_IR
, MACRO_IR
, MACRO_EOA
,
3131 /* MACRO_IR, MACRO_EXP, MACRO_IR, MACRO_EOA,
3132 MACRO_IR, MACRO_EXP, MACRO_EOA */ } },
3134 { "jsr", emit_jsrjmp
, "jsr",
3135 { MACRO_PIR
, MACRO_EXP
, MACRO_EOA
,
3136 MACRO_PIR
, MACRO_EOA
,
3137 MACRO_IR
, MACRO_EXP
, MACRO_EOA
,
3138 MACRO_EXP
, MACRO_EOA
} },
3139 { "jmp", emit_jsrjmp
, "jmp",
3140 { MACRO_PIR
, MACRO_EXP
, MACRO_EOA
,
3141 MACRO_PIR
, MACRO_EOA
,
3142 MACRO_IR
, MACRO_EXP
, MACRO_EOA
,
3143 MACRO_EXP
, MACRO_EOA
} },
3144 { "ret", emit_retjcr
, "ret",
3145 { MACRO_IR
, MACRO_EXP
, MACRO_EOA
,
3146 MACRO_IR
, MACRO_EOA
,
3147 MACRO_PIR
, MACRO_EXP
, MACRO_EOA
,
3148 MACRO_PIR
, MACRO_EOA
,
3149 MACRO_EXP
, MACRO_EOA
,
3151 { "jcr", emit_retjcr
, "jcr",
3152 { MACRO_IR
, MACRO_EXP
, MACRO_EOA
,
3153 MACRO_IR
, MACRO_EOA
,
3154 MACRO_PIR
, MACRO_EXP
, MACRO_EOA
,
3155 MACRO_PIR
, MACRO_EOA
,
3156 MACRO_EXP
, MACRO_EOA
,
3158 { "jsr_coroutine", emit_retjcr
, "jcr",
3159 { MACRO_IR
, MACRO_EXP
, MACRO_EOA
,
3160 MACRO_IR
, MACRO_EOA
,
3161 MACRO_PIR
, MACRO_EXP
, MACRO_EOA
,
3162 MACRO_PIR
, MACRO_EOA
,
3163 MACRO_EXP
, MACRO_EOA
,
3167 static const unsigned int alpha_num_macros
3168 = sizeof (alpha_macros
) / sizeof (*alpha_macros
);
3170 /* Search forward through all variants of a macro looking for a syntax
3173 static const struct alpha_macro
*
3174 find_macro_match (const struct alpha_macro
*first_macro
,
3175 const expressionS
*tok
,
3179 const struct alpha_macro
*macro
= first_macro
;
3184 const enum alpha_macro_arg
*arg
= macro
->argsets
;
3198 /* Index register. */
3200 if (tokidx
>= ntok
|| tok
[tokidx
].X_op
!= O_register
3201 || !is_ir_num (tok
[tokidx
].X_add_number
))
3206 /* Parenthesized index register. */
3208 if (tokidx
>= ntok
|| tok
[tokidx
].X_op
!= O_pregister
3209 || !is_ir_num (tok
[tokidx
].X_add_number
))
3214 /* Optional parenthesized index register. */
3216 if (tokidx
< ntok
&& tok
[tokidx
].X_op
== O_pregister
3217 && is_ir_num (tok
[tokidx
].X_add_number
))
3221 /* Leading comma with a parenthesized index register. */
3223 if (tokidx
>= ntok
|| tok
[tokidx
].X_op
!= O_cpregister
3224 || !is_ir_num (tok
[tokidx
].X_add_number
))
3229 /* Floating point register. */
3231 if (tokidx
>= ntok
|| tok
[tokidx
].X_op
!= O_register
3232 || !is_fpr_num (tok
[tokidx
].X_add_number
))
3237 /* Normal expression. */
3241 switch (tok
[tokidx
].X_op
)
3250 case O_lituse_bytoff
:
3266 while (*arg
!= MACRO_EOA
)
3274 while (++macro
- alpha_macros
< (int) alpha_num_macros
3275 && !strcmp (macro
->name
, first_macro
->name
));
3280 /* Given an opcode name and a pre-tokenized set of arguments, take the
3281 opcode all the way through emission. */
3284 assemble_tokens (const char *opname
,
3285 const expressionS
*tok
,
3287 int local_macros_on
)
3289 int found_something
= 0;
3290 const struct alpha_opcode
*opcode
;
3291 const struct alpha_macro
*macro
;
3293 bfd_reloc_code_real_type reloc
= BFD_RELOC_UNUSED
;
3296 /* If a user-specified relocation is present, this is not a macro. */
3297 if (ntok
&& USER_RELOC_P (tok
[ntok
- 1].X_op
))
3299 reloc
= ALPHA_RELOC_TABLE (tok
[ntok
- 1].X_op
)->reloc
;
3304 if (local_macros_on
)
3306 macro
= ((const struct alpha_macro
*)
3307 hash_find (alpha_macro_hash
, opname
));
3310 found_something
= 1;
3311 macro
= find_macro_match (macro
, tok
, &ntok
);
3314 (*macro
->emit
) (tok
, ntok
, macro
->arg
);
3320 /* Search opcodes. */
3321 opcode
= (const struct alpha_opcode
*) hash_find (alpha_opcode_hash
, opname
);
3324 found_something
= 1;
3325 opcode
= find_opcode_match (opcode
, tok
, &ntok
, &cpumatch
);
3328 struct alpha_insn insn
;
3329 assemble_insn (opcode
, tok
, ntok
, &insn
, reloc
);
3331 /* Copy the sequence number for the reloc from the reloc token. */
3332 if (reloc
!= BFD_RELOC_UNUSED
)
3333 insn
.sequence
= tok
[ntok
].X_add_number
;
3340 if (found_something
)
3343 as_bad (_("inappropriate arguments for opcode `%s'"), opname
);
3345 as_bad (_("opcode `%s' not supported for target %s"), opname
,
3349 as_bad (_("unknown opcode `%s'"), opname
);
3354 /* Add symbol+addend to link pool.
3355 Return offset from basesym to entry in link pool.
3357 Add new fixup only if offset isn't 16bit. */
3360 add_to_link_pool (symbolS
*basesym
,
3364 segT current_section
= now_seg
;
3365 int current_subsec
= now_subseg
;
3368 segment_info_type
*seginfo
= seg_info (alpha_link_section
);
3370 symbolS
*linksym
, *expsym
;
3373 offset
= 0; /* ??? DBR */
3375 /* @@ This assumes all entries in a given section will be of the same
3376 size... Probably correct, but unwise to rely on. */
3377 /* This must always be called with the same subsegment. */
3379 if (seginfo
->frchainP
)
3380 for (fixp
= seginfo
->frchainP
->fix_root
;
3381 fixp
!= (fixS
*) NULL
;
3382 fixp
= fixp
->fx_next
)
3384 if (fixp
->tc_fix_data
.info
3385 && fixp
->tc_fix_data
.info
->sym
3386 && fixp
->tc_fix_data
.info
->sym
->sy_value
.X_op_symbol
== basesym
)
3389 if (fixp
->fx_addsy
== sym
3390 && fixp
->fx_offset
== (valueT
)addend
3391 && fixp
->tc_fix_data
.info
3392 && fixp
->tc_fix_data
.info
->sym
3393 && fixp
->tc_fix_data
.info
->sym
->sy_value
.X_op_symbol
== basesym
)
3394 return fixp
->tc_fix_data
.info
->sym
;
3397 /* Not found in 16bit signed range. */
3399 subseg_set (alpha_link_section
, 0);
3400 linksym
= symbol_new
3401 (FAKE_LABEL_NAME
, now_seg
, (valueT
) frag_now_fix (), frag_now
);
3405 e
.X_op
= O_subtract
;
3406 e
.X_add_symbol
= linksym
;
3407 e
.X_op_symbol
= basesym
;
3409 expsym
= make_expr_symbol (&e
);
3412 (frag_now
, p
-frag_now
->fr_literal
, 8, sym
, addend
, 0, BFD_RELOC_64
);
3413 fixp
->tc_fix_data
.info
= get_alpha_reloc_tag (next_sequence_num
--);
3414 fixp
->tc_fix_data
.info
->sym
= expsym
;
3416 subseg_set (current_section
, current_subsec
);
3417 seginfo
->literal_pool_size
+= 8;
3420 #endif /* OBJ_EVAX */
3422 /* Assembler directives. */
3424 /* Handle the .text pseudo-op. This is like the usual one, but it
3425 clears alpha_insn_label and restores auto alignment. */
3428 s_alpha_text (int i
)
3439 symbolP
= symbol_find (".text");
3440 if (symbolP
== NULL
)
3442 symbolP
= symbol_make (".text");
3443 S_SET_SEGMENT (symbolP
, text_section
);
3444 symbol_table_insert (symbolP
);
3448 alpha_insn_label
= NULL
;
3449 alpha_auto_align_on
= 1;
3450 alpha_current_align
= 0;
3453 /* Handle the .data pseudo-op. This is like the usual one, but it
3454 clears alpha_insn_label and restores auto alignment. */
3457 s_alpha_data (int i
)
3464 alpha_insn_label
= NULL
;
3465 alpha_auto_align_on
= 1;
3466 alpha_current_align
= 0;
3469 #if defined (OBJ_ECOFF) || defined (OBJ_EVAX)
3471 /* Handle the OSF/1 and openVMS .comm pseudo quirks. */
3474 s_alpha_comm (int ignore ATTRIBUTE_UNUSED
)
3486 name
= input_line_pointer
;
3487 c
= get_symbol_end ();
3489 /* Just after name is now '\0'. */
3490 p
= input_line_pointer
;
3495 /* Alpha OSF/1 compiler doesn't provide the comma, gcc does. */
3496 if (*input_line_pointer
== ',')
3498 input_line_pointer
++;
3501 if ((size
= get_absolute_expression ()) < 0)
3503 as_warn (_(".COMMon length (%ld.) <0! Ignored."), (long) size
);
3504 ignore_rest_of_line ();
3509 symbolP
= symbol_find_or_make (name
);
3512 if (S_IS_DEFINED (symbolP
) && ! S_IS_COMMON (symbolP
))
3514 as_bad (_("Ignoring attempt to re-define symbol"));
3515 ignore_rest_of_line ();
3520 if (*input_line_pointer
!= ',')
3521 temp
= 8; /* Default alignment. */
3524 input_line_pointer
++;
3526 temp
= get_absolute_expression ();
3529 /* ??? Unlike on OSF/1, the alignment factor is not in log units. */
3530 while ((temp
>>= 1) != 0)
3533 if (*input_line_pointer
== ',')
3535 /* Extended form of the directive
3537 .comm symbol, size, alignment, section
3539 where the "common" semantics is transferred to the section.
3540 The symbol is effectively an alias for the section name. */
3544 symbolS
*sec_symbol
;
3545 segT current_seg
= now_seg
;
3546 subsegT current_subseg
= now_subseg
;
3549 input_line_pointer
++;
3551 sec_name
= s_alpha_section_name ();
3552 sec_symbol
= symbol_find_or_make (sec_name
);
3553 sec
= subseg_new (sec_name
, 0);
3554 S_SET_SEGMENT (sec_symbol
, sec
);
3555 symbol_get_bfdsym (sec_symbol
)->flags
|= BSF_SECTION_SYM
;
3556 bfd_vms_set_section_flags (stdoutput
, sec
,
3557 EGPS_S_V_OVR
| EGPS_S_V_GBL
| EGPS_S_V_NOMOD
);
3558 record_alignment (sec
, log_align
);
3560 /* Reuse stab_string_size to store the size of the section. */
3561 cur_size
= seg_info (sec
)->stabu
.stab_string_size
;
3562 if ((int) size
> cur_size
)
3565 = frag_var (rs_fill
, 1, 1, (relax_substateT
)0, NULL
,
3566 (valueT
)size
- (valueT
)cur_size
, NULL
);
3568 seg_info (sec
)->stabu
.stab_string_size
= (int)size
;
3571 S_SET_SEGMENT (symbolP
, sec
);
3573 subseg_set (current_seg
, current_subseg
);
3577 /* Regular form of the directive
3579 .comm symbol, size, alignment
3581 where the "common" semantics in on the symbol.
3582 These symbols are assembled in the .bss section. */
3585 segT current_seg
= now_seg
;
3586 subsegT current_subseg
= now_subseg
;
3588 subseg_set (bss_section
, 1);
3589 frag_align (log_align
, 0, 0);
3590 record_alignment (bss_section
, log_align
);
3592 symbolP
->sy_frag
= frag_now
;
3593 pfrag
= frag_var (rs_org
, 1, 1, (relax_substateT
)0, symbolP
,
3597 S_SET_SEGMENT (symbolP
, bss_section
);
3599 subseg_set (current_seg
, current_subseg
);
3603 if (S_GET_VALUE (symbolP
))
3605 if (S_GET_VALUE (symbolP
) != (valueT
) size
)
3606 as_bad (_("Length of .comm \"%s\" is already %ld. Not changed to %ld."),
3607 S_GET_NAME (symbolP
),
3608 (long) S_GET_VALUE (symbolP
),
3614 S_SET_VALUE (symbolP
, (valueT
) size
);
3616 S_SET_EXTERNAL (symbolP
);
3620 know (symbolP
->sy_frag
== &zero_address_frag
);
3622 demand_empty_rest_of_line ();
3625 #endif /* ! OBJ_ELF */
3629 /* Handle the .rdata pseudo-op. This is like the usual one, but it
3630 clears alpha_insn_label and restores auto alignment. */
3633 s_alpha_rdata (int ignore ATTRIBUTE_UNUSED
)
3637 temp
= get_absolute_expression ();
3638 subseg_new (".rdata", 0);
3639 demand_empty_rest_of_line ();
3640 alpha_insn_label
= NULL
;
3641 alpha_auto_align_on
= 1;
3642 alpha_current_align
= 0;
3649 /* Handle the .sdata pseudo-op. This is like the usual one, but it
3650 clears alpha_insn_label and restores auto alignment. */
3653 s_alpha_sdata (int ignore ATTRIBUTE_UNUSED
)
3657 temp
= get_absolute_expression ();
3658 subseg_new (".sdata", 0);
3659 demand_empty_rest_of_line ();
3660 alpha_insn_label
= NULL
;
3661 alpha_auto_align_on
= 1;
3662 alpha_current_align
= 0;
3667 struct alpha_elf_frame_data
3670 symbolS
*func_end_sym
;
3671 symbolS
*prologue_sym
;
3677 offsetT mask_offset
;
3678 offsetT fmask_offset
;
3680 struct alpha_elf_frame_data
*next
;
3683 static struct alpha_elf_frame_data
*all_frame_data
;
3684 static struct alpha_elf_frame_data
**plast_frame_data
= &all_frame_data
;
3685 static struct alpha_elf_frame_data
*cur_frame_data
;
3687 /* Handle the .section pseudo-op. This is like the usual one, but it
3688 clears alpha_insn_label and restores auto alignment. */
3691 s_alpha_section (int ignore ATTRIBUTE_UNUSED
)
3693 obj_elf_section (ignore
);
3695 alpha_insn_label
= NULL
;
3696 alpha_auto_align_on
= 1;
3697 alpha_current_align
= 0;
3701 s_alpha_ent (int dummy ATTRIBUTE_UNUSED
)
3703 if (ECOFF_DEBUGGING
)
3704 ecoff_directive_ent (0);
3707 char *name
, name_end
;
3708 name
= input_line_pointer
;
3709 name_end
= get_symbol_end ();
3711 if (! is_name_beginner (*name
))
3713 as_warn (_(".ent directive has no name"));
3714 *input_line_pointer
= name_end
;
3721 as_warn (_("nested .ent directives"));
3723 sym
= symbol_find_or_make (name
);
3724 symbol_get_bfdsym (sym
)->flags
|= BSF_FUNCTION
;
3726 cur_frame_data
= calloc (1, sizeof (*cur_frame_data
));
3727 cur_frame_data
->func_sym
= sym
;
3729 /* Provide sensible defaults. */
3730 cur_frame_data
->fp_regno
= 30; /* sp */
3731 cur_frame_data
->ra_regno
= 26; /* ra */
3733 *plast_frame_data
= cur_frame_data
;
3734 plast_frame_data
= &cur_frame_data
->next
;
3736 /* The .ent directive is sometimes followed by a number. Not sure
3737 what it really means, but ignore it. */
3738 *input_line_pointer
= name_end
;
3740 if (*input_line_pointer
== ',')
3742 input_line_pointer
++;
3745 if (ISDIGIT (*input_line_pointer
) || *input_line_pointer
== '-')
3746 (void) get_absolute_expression ();
3748 demand_empty_rest_of_line ();
3753 s_alpha_end (int dummy ATTRIBUTE_UNUSED
)
3755 if (ECOFF_DEBUGGING
)
3756 ecoff_directive_end (0);
3759 char *name
, name_end
;
3760 name
= input_line_pointer
;
3761 name_end
= get_symbol_end ();
3763 if (! is_name_beginner (*name
))
3765 as_warn (_(".end directive has no name"));
3766 *input_line_pointer
= name_end
;
3772 sym
= symbol_find (name
);
3773 if (!cur_frame_data
)
3774 as_warn (_(".end directive without matching .ent"));
3775 else if (sym
!= cur_frame_data
->func_sym
)
3776 as_warn (_(".end directive names different symbol than .ent"));
3778 /* Create an expression to calculate the size of the function. */
3779 if (sym
&& cur_frame_data
)
3781 OBJ_SYMFIELD_TYPE
*obj
= symbol_get_obj (sym
);
3782 expressionS
*exp
= xmalloc (sizeof (expressionS
));
3785 exp
->X_op
= O_subtract
;
3786 exp
->X_add_symbol
= symbol_temp_new_now ();
3787 exp
->X_op_symbol
= sym
;
3788 exp
->X_add_number
= 0;
3790 cur_frame_data
->func_end_sym
= exp
->X_add_symbol
;
3793 cur_frame_data
= NULL
;
3795 *input_line_pointer
= name_end
;
3797 demand_empty_rest_of_line ();
3802 s_alpha_mask (int fp
)
3804 if (ECOFF_DEBUGGING
)
3807 ecoff_directive_fmask (0);
3809 ecoff_directive_mask (0);
3816 if (!cur_frame_data
)
3819 as_warn (_(".fmask outside of .ent"));
3821 as_warn (_(".mask outside of .ent"));
3822 discard_rest_of_line ();
3826 if (get_absolute_expression_and_terminator (&val
) != ',')
3829 as_warn (_("bad .fmask directive"));
3831 as_warn (_("bad .mask directive"));
3832 --input_line_pointer
;
3833 discard_rest_of_line ();
3837 offset
= get_absolute_expression ();
3838 demand_empty_rest_of_line ();
3842 cur_frame_data
->fmask
= val
;
3843 cur_frame_data
->fmask_offset
= offset
;
3847 cur_frame_data
->mask
= val
;
3848 cur_frame_data
->mask_offset
= offset
;
3854 s_alpha_frame (int dummy ATTRIBUTE_UNUSED
)
3856 if (ECOFF_DEBUGGING
)
3857 ecoff_directive_frame (0);
3862 if (!cur_frame_data
)
3864 as_warn (_(".frame outside of .ent"));
3865 discard_rest_of_line ();
3869 cur_frame_data
->fp_regno
= tc_get_register (1);
3872 if (*input_line_pointer
++ != ','
3873 || get_absolute_expression_and_terminator (&val
) != ',')
3875 as_warn (_("bad .frame directive"));
3876 --input_line_pointer
;
3877 discard_rest_of_line ();
3880 cur_frame_data
->frame_size
= val
;
3882 cur_frame_data
->ra_regno
= tc_get_register (0);
3884 /* Next comes the "offset of saved $a0 from $sp". In gcc terms
3885 this is current_function_pretend_args_size. There's no place
3886 to put this value, so ignore it. */
3892 s_alpha_prologue (int ignore ATTRIBUTE_UNUSED
)
3897 arg
= get_absolute_expression ();
3898 demand_empty_rest_of_line ();
3899 alpha_prologue_label
= symbol_new
3900 (FAKE_LABEL_NAME
, now_seg
, (valueT
) frag_now_fix (), frag_now
);
3902 if (ECOFF_DEBUGGING
)
3903 sym
= ecoff_get_cur_proc_sym ();
3905 sym
= cur_frame_data
? cur_frame_data
->func_sym
: NULL
;
3909 as_bad (_(".prologue directive without a preceding .ent directive"));
3915 case 0: /* No PV required. */
3916 S_SET_OTHER (sym
, STO_ALPHA_NOPV
3917 | (S_GET_OTHER (sym
) & ~STO_ALPHA_STD_GPLOAD
));
3919 case 1: /* Std GP load. */
3920 S_SET_OTHER (sym
, STO_ALPHA_STD_GPLOAD
3921 | (S_GET_OTHER (sym
) & ~STO_ALPHA_STD_GPLOAD
));
3923 case 2: /* Non-std use of PV. */
3927 as_bad (_("Invalid argument %d to .prologue."), arg
);
3932 cur_frame_data
->prologue_sym
= symbol_temp_new_now ();
3935 static char *first_file_directive
;
3938 s_alpha_file (int ignore ATTRIBUTE_UNUSED
)
3940 /* Save the first .file directive we see, so that we can change our
3941 minds about whether ecoff debugging should or shouldn't be enabled. */
3942 if (alpha_flag_mdebug
< 0 && ! first_file_directive
)
3944 char *start
= input_line_pointer
;
3947 discard_rest_of_line ();
3949 len
= input_line_pointer
- start
;
3950 first_file_directive
= xmalloc (len
+ 1);
3951 memcpy (first_file_directive
, start
, len
);
3952 first_file_directive
[len
] = '\0';
3954 input_line_pointer
= start
;
3957 if (ECOFF_DEBUGGING
)
3958 ecoff_directive_file (0);
3960 dwarf2_directive_file (0);
3964 s_alpha_loc (int ignore ATTRIBUTE_UNUSED
)
3966 if (ECOFF_DEBUGGING
)
3967 ecoff_directive_loc (0);
3969 dwarf2_directive_loc (0);
3973 s_alpha_stab (int n
)
3975 /* If we've been undecided about mdebug, make up our minds in favour. */
3976 if (alpha_flag_mdebug
< 0)
3978 segT sec
= subseg_new (".mdebug", 0);
3979 bfd_set_section_flags (stdoutput
, sec
, SEC_HAS_CONTENTS
| SEC_READONLY
);
3980 bfd_set_section_alignment (stdoutput
, sec
, 3);
3982 ecoff_read_begin_hook ();
3984 if (first_file_directive
)
3986 char *save_ilp
= input_line_pointer
;
3987 input_line_pointer
= first_file_directive
;
3988 ecoff_directive_file (0);
3989 input_line_pointer
= save_ilp
;
3990 free (first_file_directive
);
3993 alpha_flag_mdebug
= 1;
3999 s_alpha_coff_wrapper (int which
)
4001 static void (* const fns
[]) (int) = {
4002 ecoff_directive_begin
,
4003 ecoff_directive_bend
,
4004 ecoff_directive_def
,
4005 ecoff_directive_dim
,
4006 ecoff_directive_endef
,
4007 ecoff_directive_scl
,
4008 ecoff_directive_tag
,
4009 ecoff_directive_val
,
4012 gas_assert (which
>= 0 && which
< (int) (sizeof (fns
)/sizeof (*fns
)));
4014 if (ECOFF_DEBUGGING
)
4018 as_bad (_("ECOFF debugging is disabled."));
4019 ignore_rest_of_line ();
4023 /* Called at the end of assembly. Here we emit unwind info for frames
4024 unless the compiler has done it for us. */
4027 alpha_elf_md_end (void)
4029 struct alpha_elf_frame_data
*p
;
4032 as_warn (_(".ent directive without matching .end"));
4034 /* If someone has generated the unwind info themselves, great. */
4035 if (bfd_get_section_by_name (stdoutput
, ".eh_frame") != NULL
)
4038 /* Generate .eh_frame data for the unwind directives specified. */
4039 for (p
= all_frame_data
; p
; p
= p
->next
)
4040 if (p
->prologue_sym
)
4042 /* Create a temporary symbol at the same location as our
4043 function symbol. This prevents problems with globals. */
4044 cfi_new_fde (symbol_temp_new (S_GET_SEGMENT (p
->func_sym
),
4045 S_GET_VALUE (p
->func_sym
),
4046 symbol_get_frag (p
->func_sym
)));
4048 cfi_set_return_column (p
->ra_regno
);
4049 cfi_add_CFA_def_cfa_register (30);
4050 if (p
->fp_regno
!= 30 || p
->mask
|| p
->fmask
|| p
->frame_size
)
4055 cfi_add_advance_loc (p
->prologue_sym
);
4057 if (p
->fp_regno
!= 30)
4058 if (p
->frame_size
!= 0)
4059 cfi_add_CFA_def_cfa (p
->fp_regno
, p
->frame_size
);
4061 cfi_add_CFA_def_cfa_register (p
->fp_regno
);
4062 else if (p
->frame_size
!= 0)
4063 cfi_add_CFA_def_cfa_offset (p
->frame_size
);
4066 offset
= p
->mask_offset
;
4068 /* Recall that $26 is special-cased and stored first. */
4069 if ((mask
>> 26) & 1)
4071 cfi_add_CFA_offset (26, offset
);
4082 cfi_add_CFA_offset (i
, offset
);
4087 offset
= p
->fmask_offset
;
4095 cfi_add_CFA_offset (i
+ 32, offset
);
4100 cfi_end_fde (p
->func_end_sym
);
4105 s_alpha_usepv (int unused ATTRIBUTE_UNUSED
)
4107 char *name
, name_end
;
4108 char *which
, which_end
;
4112 name
= input_line_pointer
;
4113 name_end
= get_symbol_end ();
4115 if (! is_name_beginner (*name
))
4117 as_bad (_(".usepv directive has no name"));
4118 *input_line_pointer
= name_end
;
4119 ignore_rest_of_line ();
4123 sym
= symbol_find_or_make (name
);
4124 *input_line_pointer
++ = name_end
;
4126 if (name_end
!= ',')
4128 as_bad (_(".usepv directive has no type"));
4129 ignore_rest_of_line ();
4134 which
= input_line_pointer
;
4135 which_end
= get_symbol_end ();
4137 if (strcmp (which
, "no") == 0)
4138 other
= STO_ALPHA_NOPV
;
4139 else if (strcmp (which
, "std") == 0)
4140 other
= STO_ALPHA_STD_GPLOAD
;
4143 as_bad (_("unknown argument for .usepv"));
4147 *input_line_pointer
= which_end
;
4148 demand_empty_rest_of_line ();
4150 S_SET_OTHER (sym
, other
| (S_GET_OTHER (sym
) & ~STO_ALPHA_STD_GPLOAD
));
4152 #endif /* OBJ_ELF */
4154 /* Standard calling conventions leaves the CFA at $30 on entry. */
4157 alpha_cfi_frame_initial_instructions (void)
4159 cfi_add_CFA_def_cfa_register (30);
4164 /* Get name of section. */
4166 s_alpha_section_name (void)
4171 if (*input_line_pointer
== '"')
4175 name
= demand_copy_C_string (&dummy
);
4178 ignore_rest_of_line ();
4184 char *end
= input_line_pointer
;
4186 while (0 == strchr ("\n\t,; ", *end
))
4188 if (end
== input_line_pointer
)
4190 as_warn (_("missing name"));
4191 ignore_rest_of_line ();
4195 name
= xmalloc (end
- input_line_pointer
+ 1);
4196 memcpy (name
, input_line_pointer
, end
- input_line_pointer
);
4197 name
[end
- input_line_pointer
] = '\0';
4198 input_line_pointer
= end
;
4205 s_alpha_section_word (char *str
, size_t len
)
4210 if (len
== 5 && strncmp (str
, "NO", 2) == 0)
4219 if (strncmp (str
, "PIC", 3) == 0)
4220 flag
= EGPS_S_V_PIC
;
4221 else if (strncmp (str
, "LIB", 3) == 0)
4222 flag
= EGPS_S_V_LIB
;
4223 else if (strncmp (str
, "OVR", 3) == 0)
4224 flag
= EGPS_S_V_OVR
;
4225 else if (strncmp (str
, "REL", 3) == 0)
4226 flag
= EGPS_S_V_REL
;
4227 else if (strncmp (str
, "GBL", 3) == 0)
4228 flag
= EGPS_S_V_GBL
;
4229 else if (strncmp (str
, "SHR", 3) == 0)
4230 flag
= EGPS_S_V_SHR
;
4231 else if (strncmp (str
, "EXE", 3) == 0)
4232 flag
= EGPS_S_V_EXE
;
4233 else if (strncmp (str
, "WRT", 3) == 0)
4234 flag
= EGPS_S_V_WRT
;
4235 else if (strncmp (str
, "VEC", 3) == 0)
4236 flag
= EGPS_S_V_VEC
;
4237 else if (strncmp (str
, "MOD", 3) == 0)
4239 flag
= no
? EGPS_S_V_NOMOD
: EGPS_S_V_NOMOD
<< EGPS_S_V_NO_SHIFT
;
4242 else if (strncmp (str
, "COM", 3) == 0)
4243 flag
= EGPS_S_V_COM
;
4250 as_warn (_("unknown section attribute %s"), str
);
4256 return flag
<< EGPS_S_V_NO_SHIFT
;
4261 /* Handle the section specific pseudo-op. */
4263 #define EVAX_SECTION_COUNT 5
4265 static char *section_name
[EVAX_SECTION_COUNT
+ 1] =
4266 { "NULL", ".rdata", ".comm", ".link", ".ctors", ".dtors" };
4269 s_alpha_section (int secid
)
4274 flagword vms_flags
= 0;
4279 name
= s_alpha_section_name ();
4282 sec
= subseg_new (name
, 0);
4283 if (*input_line_pointer
== ',')
4285 /* Skip the comma. */
4286 ++input_line_pointer
;
4294 beg
= input_line_pointer
;
4295 c
= get_symbol_end ();
4296 *input_line_pointer
= c
;
4298 vms_flags
|= s_alpha_section_word (beg
, input_line_pointer
- beg
);
4302 while (*input_line_pointer
++ == ',');
4303 --input_line_pointer
;
4306 symbol
= symbol_find_or_make (name
);
4307 S_SET_SEGMENT (symbol
, sec
);
4308 symbol_get_bfdsym (symbol
)->flags
|= BSF_SECTION_SYM
;
4309 bfd_vms_set_section_flags (stdoutput
, sec
, vms_flags
);
4313 temp
= get_absolute_expression ();
4314 subseg_new (section_name
[secid
], 0);
4317 demand_empty_rest_of_line ();
4318 alpha_insn_label
= NULL
;
4319 alpha_auto_align_on
= 1;
4320 alpha_current_align
= 0;
4324 s_alpha_literals (int ignore ATTRIBUTE_UNUSED
)
4326 subseg_new (".literals", 0);
4327 demand_empty_rest_of_line ();
4328 alpha_insn_label
= NULL
;
4329 alpha_auto_align_on
= 1;
4330 alpha_current_align
= 0;
4333 /* Parse .ent directives. */
4336 s_alpha_ent (int ignore ATTRIBUTE_UNUSED
)
4339 expressionS symexpr
;
4342 = (struct alpha_evax_procs
*) xmalloc (sizeof (struct alpha_evax_procs
));
4344 alpha_evax_proc
->pdsckind
= 0;
4345 alpha_evax_proc
->framereg
= -1;
4346 alpha_evax_proc
->framesize
= 0;
4347 alpha_evax_proc
->rsa_offset
= 0;
4348 alpha_evax_proc
->ra_save
= AXP_REG_RA
;
4349 alpha_evax_proc
->fp_save
= -1;
4350 alpha_evax_proc
->imask
= 0;
4351 alpha_evax_proc
->fmask
= 0;
4352 alpha_evax_proc
->prologue
= 0;
4353 alpha_evax_proc
->type
= 0;
4354 alpha_evax_proc
->handler
= 0;
4355 alpha_evax_proc
->handler_data
= 0;
4357 expression (&symexpr
);
4359 if (symexpr
.X_op
!= O_symbol
)
4361 as_fatal (_(".ent directive has no symbol"));
4362 demand_empty_rest_of_line ();
4366 symbol
= make_expr_symbol (&symexpr
);
4367 symbol_get_bfdsym (symbol
)->flags
|= BSF_FUNCTION
;
4368 alpha_evax_proc
->symbol
= symbol
;
4371 (alpha_evax_proc_hash
,
4372 symbol_get_bfdsym (alpha_evax_proc
->symbol
)->name
, (PTR
)alpha_evax_proc
);
4374 demand_empty_rest_of_line ();
4378 s_alpha_handler (int is_data
)
4381 alpha_evax_proc
->handler_data
= get_absolute_expression ();
4384 char *name
, name_end
;
4385 name
= input_line_pointer
;
4386 name_end
= get_symbol_end ();
4388 if (! is_name_beginner (*name
))
4390 as_warn (_(".handler directive has no name"));
4391 *input_line_pointer
= name_end
;
4397 sym
= symbol_find_or_make (name
);
4398 symbol_get_bfdsym (sym
)->flags
|= BSF_FUNCTION
;
4399 alpha_evax_proc
->handler
= sym
;
4400 *input_line_pointer
= name_end
;
4403 demand_empty_rest_of_line ();
4406 /* Parse .frame <framreg>,<framesize>,RA,<rsa_offset> directives. */
4409 s_alpha_frame (int ignore ATTRIBUTE_UNUSED
)
4413 alpha_evax_proc
->framereg
= tc_get_register (1);
4416 if (*input_line_pointer
++ != ','
4417 || get_absolute_expression_and_terminator (&val
) != ',')
4419 as_warn (_("Bad .frame directive 1./2. param"));
4420 --input_line_pointer
;
4421 demand_empty_rest_of_line ();
4425 alpha_evax_proc
->framesize
= val
;
4427 (void) tc_get_register (1);
4429 if (*input_line_pointer
++ != ',')
4431 as_warn (_("Bad .frame directive 3./4. param"));
4432 --input_line_pointer
;
4433 demand_empty_rest_of_line ();
4436 alpha_evax_proc
->rsa_offset
= get_absolute_expression ();
4440 s_alpha_prologue (int ignore ATTRIBUTE_UNUSED
)
4444 arg
= get_absolute_expression ();
4445 demand_empty_rest_of_line ();
4446 alpha_prologue_label
= symbol_new
4447 (FAKE_LABEL_NAME
, now_seg
, (valueT
) frag_now_fix (), frag_now
);
4451 s_alpha_pdesc (int ignore ATTRIBUTE_UNUSED
)
4459 segment_info_type
*seginfo
= seg_info (alpha_link_section
);
4460 const char *entry_sym_name
;
4464 if (now_seg
!= alpha_link_section
)
4466 as_bad (_(".pdesc directive not in link (.link) section"));
4467 demand_empty_rest_of_line ();
4472 if (exp
.X_op
!= O_symbol
)
4474 as_warn (_(".pdesc directive has no entry symbol"));
4475 demand_empty_rest_of_line ();
4479 entry_sym
= make_expr_symbol (&exp
);
4480 entry_sym_name
= symbol_get_bfdsym (entry_sym
)->name
;
4482 len
= strlen (entry_sym_name
);
4483 sym_name
= (char *) xmalloc (len
- 4 + 1);
4484 strncpy (sym_name
, entry_sym_name
, len
- 4);
4485 sym_name
[len
- 4] = 0;
4487 alpha_evax_proc
= (struct alpha_evax_procs
*)
4488 hash_find (alpha_evax_proc_hash
, sym_name
);
4490 if (!alpha_evax_proc
|| !S_IS_DEFINED (alpha_evax_proc
->symbol
))
4492 as_fatal (_(".pdesc has no matching .ent"));
4493 demand_empty_rest_of_line ();
4497 *symbol_get_obj (alpha_evax_proc
->symbol
) =
4498 (valueT
) seginfo
->literal_pool_size
;
4500 alpha_evax_proc
->symbol
->sy_obj
= (valueT
)seginfo
->literal_pool_size
;
4502 /* Save bfd symbol of proc entry in function symbol. */
4503 ((struct evax_private_udata_struct
*)
4504 symbol_get_bfdsym (alpha_evax_proc
->symbol
)->udata
.p
)->enbsym
4505 = symbol_get_bfdsym (entry_sym
);
4508 if (*input_line_pointer
++ != ',')
4510 as_warn (_("No comma after .pdesc <entryname>"));
4511 demand_empty_rest_of_line ();
4516 name
= input_line_pointer
;
4517 name_end
= get_symbol_end ();
4519 if (strncmp (name
, "stack", 5) == 0)
4520 alpha_evax_proc
->pdsckind
= PDSC_S_K_KIND_FP_STACK
;
4522 else if (strncmp (name
, "reg", 3) == 0)
4523 alpha_evax_proc
->pdsckind
= PDSC_S_K_KIND_FP_REGISTER
;
4525 else if (strncmp (name
, "null", 4) == 0)
4526 alpha_evax_proc
->pdsckind
= PDSC_S_K_KIND_NULL
;
4530 as_fatal (_("unknown procedure kind"));
4531 demand_empty_rest_of_line ();
4535 *input_line_pointer
= name_end
;
4536 demand_empty_rest_of_line ();
4538 #ifdef md_flush_pending_output
4539 md_flush_pending_output ();
4542 frag_align (3, 0, 0);
4544 fixp
= fix_new (frag_now
, p
- frag_now
->fr_literal
, 8, 0, 0, 0, 0);
4546 seginfo
->literal_pool_size
+= 16;
4548 *p
= alpha_evax_proc
->pdsckind
4549 | ((alpha_evax_proc
->framereg
== 29) ? PDSC_S_M_BASE_REG_IS_FP
: 0)
4550 | ((alpha_evax_proc
->handler
) ? PDSC_S_M_HANDLER_VALID
: 0)
4551 | ((alpha_evax_proc
->handler_data
) ? PDSC_S_M_HANDLER_DATA_VALID
: 0);
4552 *(p
+ 1) = PDSC_S_M_NATIVE
| PDSC_S_M_NO_JACKET
;
4554 switch (alpha_evax_proc
->pdsckind
)
4556 case PDSC_S_K_KIND_NULL
:
4560 case PDSC_S_K_KIND_FP_REGISTER
:
4561 *(p
+ 2) = alpha_evax_proc
->fp_save
;
4562 *(p
+ 3) = alpha_evax_proc
->ra_save
;
4564 case PDSC_S_K_KIND_FP_STACK
:
4565 md_number_to_chars (p
+ 2, (valueT
) alpha_evax_proc
->rsa_offset
, 2);
4567 default: /* impossible */
4572 *(p
+ 5) = alpha_evax_proc
->type
& 0x0f;
4574 /* Signature offset. */
4575 md_number_to_chars (p
+ 6, (valueT
) 0, 2);
4577 fix_new_exp (frag_now
, p
- frag_now
->fr_literal
+8, 8, &exp
, 0, BFD_RELOC_64
);
4579 if (alpha_evax_proc
->pdsckind
== PDSC_S_K_KIND_NULL
)
4582 /* Add dummy fix to make add_to_link_pool work. */
4584 fixp
= fix_new (frag_now
, p
- frag_now
->fr_literal
, 6, 0, 0, 0, 0);
4586 seginfo
->literal_pool_size
+= 6;
4588 /* pdesc+16: Size. */
4589 md_number_to_chars (p
, (valueT
) alpha_evax_proc
->framesize
, 4);
4591 md_number_to_chars (p
+ 4, (valueT
) 0, 2);
4594 exp
.X_op
= O_subtract
;
4595 exp
.X_add_symbol
= alpha_prologue_label
;
4596 exp
.X_op_symbol
= entry_sym
;
4597 emit_expr (&exp
, 2);
4599 if (alpha_evax_proc
->pdsckind
== PDSC_S_K_KIND_FP_REGISTER
)
4602 /* Add dummy fix to make add_to_link_pool work. */
4604 fixp
= fix_new (frag_now
, p
- frag_now
->fr_literal
, 8, 0, 0, 0, 0);
4606 seginfo
->literal_pool_size
+= 8;
4608 /* pdesc+24: register masks. */
4610 md_number_to_chars (p
, alpha_evax_proc
->imask
, 4);
4611 md_number_to_chars (p
+ 4, alpha_evax_proc
->fmask
, 4);
4613 if (alpha_evax_proc
->handler
)
4616 fixp
= fix_new (frag_now
, p
- frag_now
->fr_literal
, 8,
4617 alpha_evax_proc
->handler
, 0, 0, BFD_RELOC_64
);
4620 if (alpha_evax_proc
->handler_data
)
4622 /* Add dummy fix to make add_to_link_pool work. */
4624 fixp
= fix_new (frag_now
, p
- frag_now
->fr_literal
, 8, 0, 0, 0, 0);
4626 seginfo
->literal_pool_size
+= 8;
4627 md_number_to_chars (p
, alpha_evax_proc
->handler_data
, 8);
4631 /* Support for crash debug on vms. */
4634 s_alpha_name (int ignore ATTRIBUTE_UNUSED
)
4638 segment_info_type
*seginfo
= seg_info (alpha_link_section
);
4640 if (now_seg
!= alpha_link_section
)
4642 as_bad (_(".name directive not in link (.link) section"));
4643 demand_empty_rest_of_line ();
4648 if (exp
.X_op
!= O_symbol
)
4650 as_warn (_(".name directive has no symbol"));
4651 demand_empty_rest_of_line ();
4655 demand_empty_rest_of_line ();
4657 #ifdef md_flush_pending_output
4658 md_flush_pending_output ();
4661 frag_align (3, 0, 0);
4663 seginfo
->literal_pool_size
+= 8;
4665 fix_new_exp (frag_now
, p
- frag_now
->fr_literal
, 8, &exp
, 0, BFD_RELOC_64
);
4669 s_alpha_linkage (int ignore ATTRIBUTE_UNUSED
)
4675 #ifdef md_flush_pending_output
4676 md_flush_pending_output ();
4680 if (exp
.X_op
!= O_symbol
)
4682 as_fatal (_("No symbol after .linkage"));
4686 struct alpha_linkage_fixups
*linkage_fixup
;
4688 p
= frag_more (LKP_S_K_SIZE
);
4689 memset (p
, 0, LKP_S_K_SIZE
);
4691 (frag_now
, p
- frag_now
->fr_literal
, LKP_S_K_SIZE
, &exp
, 0,\
4692 BFD_RELOC_ALPHA_LINKAGE
);
4694 linkage_fixup
= (struct alpha_linkage_fixups
*)
4695 xmalloc (sizeof (struct alpha_linkage_fixups
));
4697 linkage_fixup
->fixp
= fixp
;
4698 linkage_fixup
->next
= 0;
4700 if (alpha_insn_label
== 0)
4701 alpha_insn_label
= symbol_new
4702 (FAKE_LABEL_NAME
, now_seg
, (valueT
) frag_now_fix (), frag_now
);
4703 linkage_fixup
->label
= alpha_insn_label
;
4705 if (alpha_linkage_fixup_root
== 0)
4707 alpha_linkage_fixup_root
= alpha_linkage_fixup_tail
= linkage_fixup
;
4708 alpha_linkage_fixup_tail
->next
= 0;
4712 alpha_linkage_fixup_tail
->next
= linkage_fixup
;
4713 alpha_linkage_fixup_tail
= linkage_fixup
;
4714 alpha_linkage_fixup_tail
->next
= 0;
4717 demand_empty_rest_of_line ();
4721 s_alpha_code_address (int ignore ATTRIBUTE_UNUSED
)
4726 #ifdef md_flush_pending_output
4727 md_flush_pending_output ();
4731 if (exp
.X_op
!= O_symbol
)
4732 as_fatal (_("No symbol after .code_address"));
4737 fix_new_exp (frag_now
, p
- frag_now
->fr_literal
, 8, &exp
, 0,\
4738 BFD_RELOC_ALPHA_CODEADDR
);
4740 demand_empty_rest_of_line ();
4744 s_alpha_fp_save (int ignore ATTRIBUTE_UNUSED
)
4747 alpha_evax_proc
->fp_save
= tc_get_register (1);
4749 demand_empty_rest_of_line ();
4753 s_alpha_mask (int ignore ATTRIBUTE_UNUSED
)
4757 if (get_absolute_expression_and_terminator (&val
) != ',')
4759 as_warn (_("Bad .mask directive"));
4760 --input_line_pointer
;
4764 alpha_evax_proc
->imask
= val
;
4765 (void) get_absolute_expression ();
4767 demand_empty_rest_of_line ();
4771 s_alpha_fmask (int ignore ATTRIBUTE_UNUSED
)
4775 if (get_absolute_expression_and_terminator (&val
) != ',')
4777 as_warn (_("Bad .fmask directive"));
4778 --input_line_pointer
;
4782 alpha_evax_proc
->fmask
= val
;
4783 (void) get_absolute_expression ();
4785 demand_empty_rest_of_line ();
4789 s_alpha_end (int ignore ATTRIBUTE_UNUSED
)
4793 c
= get_symbol_end ();
4794 *input_line_pointer
= c
;
4795 demand_empty_rest_of_line ();
4796 alpha_evax_proc
= 0;
4800 s_alpha_file (int ignore ATTRIBUTE_UNUSED
)
4804 static char case_hack
[32];
4806 sprintf (case_hack
, "<CASE:%01d%01d>",
4807 alpha_flag_hash_long_names
, alpha_flag_show_after_trunc
);
4809 s
= symbol_find_or_make (case_hack
);
4810 symbol_get_bfdsym (s
)->flags
|= BSF_FILE
;
4812 get_absolute_expression ();
4813 s
= symbol_find_or_make (demand_copy_string (&length
));
4814 symbol_get_bfdsym (s
)->flags
|= BSF_FILE
;
4815 demand_empty_rest_of_line ();
4817 #endif /* OBJ_EVAX */
4819 /* Handle the .gprel32 pseudo op. */
4822 s_alpha_gprel32 (int ignore ATTRIBUTE_UNUSED
)
4834 e
.X_add_symbol
= section_symbol (absolute_section
);
4847 e
.X_add_symbol
= section_symbol (absolute_section
);
4850 e
.X_op
= O_subtract
;
4851 e
.X_op_symbol
= alpha_gp_symbol
;
4859 if (alpha_auto_align_on
&& alpha_current_align
< 2)
4860 alpha_align (2, (char *) NULL
, alpha_insn_label
, 0);
4861 if (alpha_current_align
> 2)
4862 alpha_current_align
= 2;
4863 alpha_insn_label
= NULL
;
4867 fix_new_exp (frag_now
, p
- frag_now
->fr_literal
, 4,
4868 &e
, 0, BFD_RELOC_GPREL32
);
4871 /* Handle floating point allocation pseudo-ops. This is like the
4872 generic vresion, but it makes sure the current label, if any, is
4873 correctly aligned. */
4876 s_alpha_float_cons (int type
)
4902 if (alpha_auto_align_on
&& alpha_current_align
< log_size
)
4903 alpha_align (log_size
, (char *) NULL
, alpha_insn_label
, 0);
4904 if (alpha_current_align
> log_size
)
4905 alpha_current_align
= log_size
;
4906 alpha_insn_label
= NULL
;
4911 /* Handle the .proc pseudo op. We don't really do much with it except
4915 s_alpha_proc (int is_static ATTRIBUTE_UNUSED
)
4923 /* Takes ".proc name,nargs". */
4925 name
= input_line_pointer
;
4926 c
= get_symbol_end ();
4927 p
= input_line_pointer
;
4928 symbolP
= symbol_find_or_make (name
);
4931 if (*input_line_pointer
!= ',')
4934 as_warn (_("Expected comma after name \"%s\""), name
);
4937 ignore_rest_of_line ();
4941 input_line_pointer
++;
4942 temp
= get_absolute_expression ();
4944 /* *symbol_get_obj (symbolP) = (signed char) temp; */
4945 as_warn (_("unhandled: .proc %s,%d"), name
, temp
);
4946 demand_empty_rest_of_line ();
4949 /* Handle the .set pseudo op. This is used to turn on and off most of
4950 the assembler features. */
4953 s_alpha_set (int x ATTRIBUTE_UNUSED
)
4959 name
= input_line_pointer
;
4960 ch
= get_symbol_end ();
4963 if (s
[0] == 'n' && s
[1] == 'o')
4968 if (!strcmp ("reorder", s
))
4970 else if (!strcmp ("at", s
))
4971 alpha_noat_on
= !yesno
;
4972 else if (!strcmp ("macro", s
))
4973 alpha_macros_on
= yesno
;
4974 else if (!strcmp ("move", s
))
4976 else if (!strcmp ("volatile", s
))
4979 as_warn (_("Tried to .set unrecognized mode `%s'"), name
);
4981 *input_line_pointer
= ch
;
4982 demand_empty_rest_of_line ();
4985 /* Handle the .base pseudo op. This changes the assembler's notion of
4986 the $gp register. */
4989 s_alpha_base (int ignore ATTRIBUTE_UNUSED
)
4993 if (*input_line_pointer
== '$')
4996 input_line_pointer
++;
4997 if (*input_line_pointer
== 'r')
4998 input_line_pointer
++;
5001 alpha_gp_register
= get_absolute_expression ();
5002 if (alpha_gp_register
< 0 || alpha_gp_register
> 31)
5004 alpha_gp_register
= AXP_REG_GP
;
5005 as_warn (_("Bad base register, using $%d."), alpha_gp_register
);
5008 demand_empty_rest_of_line ();
5011 /* Handle the .align pseudo-op. This aligns to a power of two. It
5012 also adjusts any current instruction label. We treat this the same
5013 way the MIPS port does: .align 0 turns off auto alignment. */
5016 s_alpha_align (int ignore ATTRIBUTE_UNUSED
)
5020 long max_alignment
= 16;
5022 align
= get_absolute_expression ();
5023 if (align
> max_alignment
)
5025 align
= max_alignment
;
5026 as_bad (_("Alignment too large: %d. assumed"), align
);
5030 as_warn (_("Alignment negative: 0 assumed"));
5034 if (*input_line_pointer
== ',')
5036 input_line_pointer
++;
5037 fill
= get_absolute_expression ();
5045 alpha_auto_align_on
= 1;
5046 alpha_align (align
, pfill
, alpha_insn_label
, 1);
5050 alpha_auto_align_on
= 0;
5053 demand_empty_rest_of_line ();
5056 /* Hook the normal string processor to reset known alignment. */
5059 s_alpha_stringer (int terminate
)
5061 alpha_current_align
= 0;
5062 alpha_insn_label
= NULL
;
5063 stringer (8 + terminate
);
5066 /* Hook the normal space processing to reset known alignment. */
5069 s_alpha_space (int ignore
)
5071 alpha_current_align
= 0;
5072 alpha_insn_label
= NULL
;
5076 /* Hook into cons for auto-alignment. */
5079 alpha_cons_align (int size
)
5084 while ((size
>>= 1) != 0)
5087 if (alpha_auto_align_on
&& alpha_current_align
< log_size
)
5088 alpha_align (log_size
, (char *) NULL
, alpha_insn_label
, 0);
5089 if (alpha_current_align
> log_size
)
5090 alpha_current_align
= log_size
;
5091 alpha_insn_label
= NULL
;
5094 /* Here come the .uword, .ulong, and .uquad explicitly unaligned
5095 pseudos. We just turn off auto-alignment and call down to cons. */
5098 s_alpha_ucons (int bytes
)
5100 int hold
= alpha_auto_align_on
;
5101 alpha_auto_align_on
= 0;
5103 alpha_auto_align_on
= hold
;
5106 /* Switch the working cpu type. */
5109 s_alpha_arch (int ignored ATTRIBUTE_UNUSED
)
5112 const struct cpu_type
*p
;
5115 name
= input_line_pointer
;
5116 ch
= get_symbol_end ();
5118 for (p
= cpu_types
; p
->name
; ++p
)
5119 if (strcmp (name
, p
->name
) == 0)
5121 alpha_target_name
= p
->name
, alpha_target
= p
->flags
;
5124 as_warn (_("Unknown CPU identifier `%s'"), name
);
5127 *input_line_pointer
= ch
;
5128 demand_empty_rest_of_line ();
5132 /* print token expression with alpha specific extension. */
5135 alpha_print_token (FILE *f
, const expressionS
*exp
)
5145 expressionS nexp
= *exp
;
5146 nexp
.X_op
= O_register
;
5147 print_expr_1 (f
, &nexp
);
5152 print_expr_1 (f
, exp
);
5158 /* The target specific pseudo-ops which we support. */
5160 const pseudo_typeS md_pseudo_table
[] =
5163 {"comm", s_alpha_comm
, 0}, /* OSF1 compiler does this. */
5164 {"rdata", s_alpha_rdata
, 0},
5166 {"text", s_alpha_text
, 0},
5167 {"data", s_alpha_data
, 0},
5169 {"sdata", s_alpha_sdata
, 0},
5172 {"section", s_alpha_section
, 0},
5173 {"section.s", s_alpha_section
, 0},
5174 {"sect", s_alpha_section
, 0},
5175 {"sect.s", s_alpha_section
, 0},
5178 {"section", s_alpha_section
, 0},
5179 {"literals", s_alpha_literals
, 0},
5180 {"pdesc", s_alpha_pdesc
, 0},
5181 {"name", s_alpha_name
, 0},
5182 {"linkage", s_alpha_linkage
, 0},
5183 {"code_address", s_alpha_code_address
, 0},
5184 {"ent", s_alpha_ent
, 0},
5185 {"frame", s_alpha_frame
, 0},
5186 {"fp_save", s_alpha_fp_save
, 0},
5187 {"mask", s_alpha_mask
, 0},
5188 {"fmask", s_alpha_fmask
, 0},
5189 {"end", s_alpha_end
, 0},
5190 {"file", s_alpha_file
, 0},
5191 {"rdata", s_alpha_section
, 1},
5192 {"comm", s_alpha_comm
, 0},
5193 {"link", s_alpha_section
, 3},
5194 {"ctors", s_alpha_section
, 4},
5195 {"dtors", s_alpha_section
, 5},
5196 {"handler", s_alpha_handler
, 0},
5197 {"handler_data", s_alpha_handler
, 1},
5200 /* Frame related pseudos. */
5201 {"ent", s_alpha_ent
, 0},
5202 {"end", s_alpha_end
, 0},
5203 {"mask", s_alpha_mask
, 0},
5204 {"fmask", s_alpha_mask
, 1},
5205 {"frame", s_alpha_frame
, 0},
5206 {"prologue", s_alpha_prologue
, 0},
5207 {"file", s_alpha_file
, 5},
5208 {"loc", s_alpha_loc
, 9},
5209 {"stabs", s_alpha_stab
, 's'},
5210 {"stabn", s_alpha_stab
, 'n'},
5211 {"usepv", s_alpha_usepv
, 0},
5212 /* COFF debugging related pseudos. */
5213 {"begin", s_alpha_coff_wrapper
, 0},
5214 {"bend", s_alpha_coff_wrapper
, 1},
5215 {"def", s_alpha_coff_wrapper
, 2},
5216 {"dim", s_alpha_coff_wrapper
, 3},
5217 {"endef", s_alpha_coff_wrapper
, 4},
5218 {"scl", s_alpha_coff_wrapper
, 5},
5219 {"tag", s_alpha_coff_wrapper
, 6},
5220 {"val", s_alpha_coff_wrapper
, 7},
5223 {"prologue", s_alpha_prologue
, 0},
5225 {"prologue", s_ignore
, 0},
5228 {"gprel32", s_alpha_gprel32
, 0},
5229 {"t_floating", s_alpha_float_cons
, 'd'},
5230 {"s_floating", s_alpha_float_cons
, 'f'},
5231 {"f_floating", s_alpha_float_cons
, 'F'},
5232 {"g_floating", s_alpha_float_cons
, 'G'},
5233 {"d_floating", s_alpha_float_cons
, 'D'},
5235 {"proc", s_alpha_proc
, 0},
5236 {"aproc", s_alpha_proc
, 1},
5237 {"set", s_alpha_set
, 0},
5238 {"reguse", s_ignore
, 0},
5239 {"livereg", s_ignore
, 0},
5240 {"base", s_alpha_base
, 0}, /*??*/
5241 {"option", s_ignore
, 0},
5242 {"aent", s_ignore
, 0},
5243 {"ugen", s_ignore
, 0},
5244 {"eflag", s_ignore
, 0},
5246 {"align", s_alpha_align
, 0},
5247 {"double", s_alpha_float_cons
, 'd'},
5248 {"float", s_alpha_float_cons
, 'f'},
5249 {"single", s_alpha_float_cons
, 'f'},
5250 {"ascii", s_alpha_stringer
, 0},
5251 {"asciz", s_alpha_stringer
, 1},
5252 {"string", s_alpha_stringer
, 1},
5253 {"space", s_alpha_space
, 0},
5254 {"skip", s_alpha_space
, 0},
5255 {"zero", s_alpha_space
, 0},
5257 /* Unaligned data pseudos. */
5258 {"uword", s_alpha_ucons
, 2},
5259 {"ulong", s_alpha_ucons
, 4},
5260 {"uquad", s_alpha_ucons
, 8},
5263 /* Dwarf wants these versions of unaligned. */
5264 {"2byte", s_alpha_ucons
, 2},
5265 {"4byte", s_alpha_ucons
, 4},
5266 {"8byte", s_alpha_ucons
, 8},
5269 /* We don't do any optimizing, so we can safely ignore these. */
5270 {"noalias", s_ignore
, 0},
5271 {"alias", s_ignore
, 0},
5273 {"arch", s_alpha_arch
, 0},
5280 /* @@@ GP selection voodoo. All of this seems overly complicated and
5281 unnecessary; which is the primary reason it's for ECOFF only. */
5284 maybe_set_gp (asection
*sec
)
5290 vma
= bfd_get_section_vma (foo
, sec
);
5291 if (vma
&& vma
< alpha_gp_value
)
5292 alpha_gp_value
= vma
;
5296 select_gp_value (void)
5298 gas_assert (alpha_gp_value
== 0);
5300 /* Get minus-one in whatever width... */
5304 /* Select the smallest VMA of these existing sections. */
5305 maybe_set_gp (alpha_lita_section
);
5307 /* @@ Will a simple 0x8000 work here? If not, why not? */
5308 #define GP_ADJUSTMENT (0x8000 - 0x10)
5310 alpha_gp_value
+= GP_ADJUSTMENT
;
5312 S_SET_VALUE (alpha_gp_symbol
, alpha_gp_value
);
5315 printf (_("Chose GP value of %lx\n"), alpha_gp_value
);
5318 #endif /* OBJ_ECOFF */
5321 /* Map 's' to SHF_ALPHA_GPREL. */
5324 alpha_elf_section_letter (int letter
, char **ptr_msg
)
5327 return SHF_ALPHA_GPREL
;
5329 *ptr_msg
= _("Bad .section directive: want a,s,w,x,M,S,G,T in string");
5333 /* Map SHF_ALPHA_GPREL to SEC_SMALL_DATA. */
5336 alpha_elf_section_flags (flagword flags
, bfd_vma attr
, int type ATTRIBUTE_UNUSED
)
5338 if (attr
& SHF_ALPHA_GPREL
)
5339 flags
|= SEC_SMALL_DATA
;
5342 #endif /* OBJ_ELF */
5344 /* This is called from HANDLE_ALIGN in write.c. Fill in the contents
5345 of an rs_align_code fragment. */
5348 alpha_handle_align (fragS
*fragp
)
5350 static char const unop
[4] = { 0x00, 0x00, 0xfe, 0x2f };
5351 static char const nopunop
[8] =
5353 0x1f, 0x04, 0xff, 0x47,
5354 0x00, 0x00, 0xfe, 0x2f
5360 if (fragp
->fr_type
!= rs_align_code
)
5363 bytes
= fragp
->fr_next
->fr_address
- fragp
->fr_address
- fragp
->fr_fix
;
5364 p
= fragp
->fr_literal
+ fragp
->fr_fix
;
5377 memcpy (p
, unop
, 4);
5383 memcpy (p
, nopunop
, 8);
5385 fragp
->fr_fix
+= fix
;
5389 /* Public interface functions. */
5391 /* This function is called once, at assembler startup time. It sets
5392 up all the tables, etc. that the MD part of the assembler will
5393 need, that can be determined before arguments are parsed. */
5400 /* Verify that X_op field is wide enough. */
5405 gas_assert (e
.X_op
== O_max
);
5408 /* Create the opcode hash table. */
5409 alpha_opcode_hash
= hash_new ();
5411 for (i
= 0; i
< alpha_num_opcodes
;)
5413 const char *name
, *retval
, *slash
;
5415 name
= alpha_opcodes
[i
].name
;
5416 retval
= hash_insert (alpha_opcode_hash
, name
, (void *) &alpha_opcodes
[i
]);
5418 as_fatal (_("internal error: can't hash opcode `%s': %s"),
5421 /* Some opcodes include modifiers of various sorts with a "/mod"
5422 syntax, like the architecture manual suggests. However, for
5423 use with gcc at least, we also need access to those same opcodes
5426 if ((slash
= strchr (name
, '/')) != NULL
)
5428 char *p
= xmalloc (strlen (name
));
5430 memcpy (p
, name
, slash
- name
);
5431 strcpy (p
+ (slash
- name
), slash
+ 1);
5433 (void) hash_insert (alpha_opcode_hash
, p
, (void *) &alpha_opcodes
[i
]);
5434 /* Ignore failures -- the opcode table does duplicate some
5435 variants in different forms, like "hw_stq" and "hw_st/q". */
5438 while (++i
< alpha_num_opcodes
5439 && (alpha_opcodes
[i
].name
== name
5440 || !strcmp (alpha_opcodes
[i
].name
, name
)))
5444 /* Create the macro hash table. */
5445 alpha_macro_hash
= hash_new ();
5447 for (i
= 0; i
< alpha_num_macros
;)
5449 const char *name
, *retval
;
5451 name
= alpha_macros
[i
].name
;
5452 retval
= hash_insert (alpha_macro_hash
, name
, (void *) &alpha_macros
[i
]);
5454 as_fatal (_("internal error: can't hash macro `%s': %s"),
5457 while (++i
< alpha_num_macros
5458 && (alpha_macros
[i
].name
== name
5459 || !strcmp (alpha_macros
[i
].name
, name
)))
5463 /* Construct symbols for each of the registers. */
5464 for (i
= 0; i
< 32; ++i
)
5468 sprintf (name
, "$%d", i
);
5469 alpha_register_table
[i
] = symbol_create (name
, reg_section
, i
,
5470 &zero_address_frag
);
5477 sprintf (name
, "$f%d", i
- 32);
5478 alpha_register_table
[i
] = symbol_create (name
, reg_section
, i
,
5479 &zero_address_frag
);
5482 /* Create the special symbols and sections we'll be using. */
5484 /* So .sbss will get used for tiny objects. */
5485 bfd_set_gp_size (stdoutput
, g_switch_value
);
5488 create_literal_section (".lita", &alpha_lita_section
, &alpha_lita_symbol
);
5490 /* For handling the GP, create a symbol that won't be output in the
5491 symbol table. We'll edit it out of relocs later. */
5492 alpha_gp_symbol
= symbol_create ("<GP value>", alpha_lita_section
, 0x8000,
5493 &zero_address_frag
);
5497 create_literal_section (".link", &alpha_link_section
, &alpha_link_symbol
);
5498 alpha_evax_proc_hash
= hash_new ();
5502 if (ECOFF_DEBUGGING
)
5504 segT sec
= subseg_new (".mdebug", (subsegT
) 0);
5505 bfd_set_section_flags (stdoutput
, sec
, SEC_HAS_CONTENTS
| SEC_READONLY
);
5506 bfd_set_section_alignment (stdoutput
, sec
, 3);
5510 /* Create literal lookup hash table. */
5511 alpha_literal_hash
= hash_new ();
5513 subseg_set (text_section
, 0);
5516 /* The public interface to the instruction assembler. */
5519 md_assemble (char *str
)
5521 /* Current maximum is 13. */
5523 expressionS tok
[MAX_INSN_ARGS
];
5527 /* Split off the opcode. */
5528 opnamelen
= strspn (str
, "abcdefghijklmnopqrstuvwxyz_/46819");
5529 trunclen
= (opnamelen
< sizeof (opname
) - 1
5531 : sizeof (opname
) - 1);
5532 memcpy (opname
, str
, trunclen
);
5533 opname
[trunclen
] = '\0';
5535 /* Tokenize the rest of the line. */
5536 if ((ntok
= tokenize_arguments (str
+ opnamelen
, tok
, MAX_INSN_ARGS
)) < 0)
5538 if (ntok
!= TOKENIZE_ERROR_REPORT
)
5539 as_bad (_("syntax error"));
5544 /* Finish it off. */
5545 assemble_tokens (opname
, tok
, ntok
, alpha_macros_on
);
5548 /* Round up a section's size to the appropriate boundary. */
5551 md_section_align (segT seg
, valueT size
)
5553 int align
= bfd_get_section_alignment (stdoutput
, seg
);
5554 valueT mask
= ((valueT
) 1 << align
) - 1;
5556 return (size
+ mask
) & ~mask
;
5559 /* Turn a string in input_line_pointer into a floating point constant
5560 of type TYPE, and store the appropriate bytes in *LITP. The number
5561 of LITTLENUMS emitted is stored in *SIZEP. An error message is
5562 returned, or NULL on OK. */
5565 md_atof (int type
, char *litP
, int *sizeP
)
5567 extern char *vax_md_atof (int, char *, int *);
5573 /* vax_md_atof() doesn't like "G" for some reason. */
5577 return vax_md_atof (type
, litP
, sizeP
);
5580 return ieee_md_atof (type
, litP
, sizeP
, FALSE
);
5584 /* Take care of the target-specific command-line options. */
5587 md_parse_option (int c
, char *arg
)
5592 alpha_nofloats_on
= 1;
5596 alpha_addr32_on
= 1;
5604 g_switch_value
= atoi (arg
);
5609 const struct cpu_type
*p
;
5611 for (p
= cpu_types
; p
->name
; ++p
)
5612 if (strcmp (arg
, p
->name
) == 0)
5614 alpha_target_name
= p
->name
, alpha_target
= p
->flags
;
5617 as_warn (_("Unknown CPU identifier `%s'"), arg
);
5623 case '+': /* For g++. Hash any name > 63 chars long. */
5624 alpha_flag_hash_long_names
= 1;
5627 case 'H': /* Show new symbol after hash truncation. */
5628 alpha_flag_show_after_trunc
= 1;
5631 case 'h': /* For gnu-c/vax compatibility. */
5634 case OPTION_REPLACE
:
5635 alpha_flag_replace
= 1;
5638 case OPTION_NOREPLACE
:
5639 alpha_flag_replace
= 0;
5644 alpha_flag_relax
= 1;
5649 alpha_flag_mdebug
= 1;
5651 case OPTION_NO_MDEBUG
:
5652 alpha_flag_mdebug
= 0;
5663 /* Print a description of the command-line options that we accept. */
5666 md_show_usage (FILE *stream
)
5670 -32addr treat addresses as 32-bit values\n\
5671 -F lack floating point instructions support\n\
5672 -mev4 | -mev45 | -mev5 | -mev56 | -mpca56 | -mev6 | -mev67 | -mev68 | -mall\n\
5673 specify variant of Alpha architecture\n\
5674 -m21064 | -m21066 | -m21164 | -m21164a | -m21164pc | -m21264 | -m21264a | -m21264b\n\
5675 these variants include PALcode opcodes\n"),
5680 -+ encode (don't truncate) names longer than 64 characters\n\
5681 -H show new symbol after hash truncation\n\
5682 -replace/-noreplace enable or disable the optimization of procedure calls\n"),
5687 /* Decide from what point a pc-relative relocation is relative to,
5688 relative to the pc-relative fixup. Er, relatively speaking. */
5691 md_pcrel_from (fixS
*fixP
)
5693 valueT addr
= fixP
->fx_where
+ fixP
->fx_frag
->fr_address
;
5695 switch (fixP
->fx_r_type
)
5697 case BFD_RELOC_23_PCREL_S2
:
5698 case BFD_RELOC_ALPHA_HINT
:
5699 case BFD_RELOC_ALPHA_BRSGP
:
5706 /* Attempt to simplify or even eliminate a fixup. The return value is
5707 ignored; perhaps it was once meaningful, but now it is historical.
5708 To indicate that a fixup has been eliminated, set fixP->fx_done.
5710 For ELF, here it is that we transform the GPDISP_HI16 reloc we used
5711 internally into the GPDISP reloc used externally. We had to do
5712 this so that we'd have the GPDISP_LO16 reloc as a tag to compute
5713 the distance to the "lda" instruction for setting the addend to
5717 md_apply_fix (fixS
*fixP
, valueT
* valP
, segT seg
)
5719 char * const fixpos
= fixP
->fx_frag
->fr_literal
+ fixP
->fx_where
;
5720 valueT value
= * valP
;
5721 unsigned image
, size
;
5723 switch (fixP
->fx_r_type
)
5725 /* The GPDISP relocations are processed internally with a symbol
5726 referring to the current function's section; we need to drop
5727 in a value which, when added to the address of the start of
5728 the function, gives the desired GP. */
5729 case BFD_RELOC_ALPHA_GPDISP_HI16
:
5731 fixS
*next
= fixP
->fx_next
;
5733 /* With user-specified !gpdisp relocations, we can be missing
5734 the matching LO16 reloc. We will have already issued an
5737 fixP
->fx_offset
= (next
->fx_frag
->fr_address
+ next
->fx_where
5738 - fixP
->fx_frag
->fr_address
- fixP
->fx_where
);
5740 value
= (value
- sign_extend_16 (value
)) >> 16;
5743 fixP
->fx_r_type
= BFD_RELOC_ALPHA_GPDISP
;
5747 case BFD_RELOC_ALPHA_GPDISP_LO16
:
5748 value
= sign_extend_16 (value
);
5749 fixP
->fx_offset
= 0;
5755 fixP
->fx_addsy
= section_symbol (seg
);
5756 md_number_to_chars (fixpos
, value
, 2);
5761 fixP
->fx_r_type
= BFD_RELOC_16_PCREL
;
5767 fixP
->fx_r_type
= BFD_RELOC_32_PCREL
;
5773 fixP
->fx_r_type
= BFD_RELOC_64_PCREL
;
5777 if (fixP
->fx_pcrel
== 0 && fixP
->fx_addsy
== 0)
5779 md_number_to_chars (fixpos
, value
, size
);
5785 case BFD_RELOC_GPREL32
:
5786 gas_assert (fixP
->fx_subsy
== alpha_gp_symbol
);
5788 /* FIXME: inherited this obliviousness of `value' -- why? */
5789 md_number_to_chars (fixpos
, -alpha_gp_value
, 4);
5792 case BFD_RELOC_GPREL32
:
5794 case BFD_RELOC_GPREL16
:
5795 case BFD_RELOC_ALPHA_GPREL_HI16
:
5796 case BFD_RELOC_ALPHA_GPREL_LO16
:
5799 case BFD_RELOC_23_PCREL_S2
:
5800 if (fixP
->fx_pcrel
== 0 && fixP
->fx_addsy
== 0)
5802 image
= bfd_getl32 (fixpos
);
5803 image
= (image
& ~0x1FFFFF) | ((value
>> 2) & 0x1FFFFF);
5808 case BFD_RELOC_ALPHA_HINT
:
5809 if (fixP
->fx_pcrel
== 0 && fixP
->fx_addsy
== 0)
5811 image
= bfd_getl32 (fixpos
);
5812 image
= (image
& ~0x3FFF) | ((value
>> 2) & 0x3FFF);
5818 case BFD_RELOC_ALPHA_BRSGP
:
5821 case BFD_RELOC_ALPHA_TLSGD
:
5822 case BFD_RELOC_ALPHA_TLSLDM
:
5823 case BFD_RELOC_ALPHA_GOTDTPREL16
:
5824 case BFD_RELOC_ALPHA_DTPREL_HI16
:
5825 case BFD_RELOC_ALPHA_DTPREL_LO16
:
5826 case BFD_RELOC_ALPHA_DTPREL16
:
5827 case BFD_RELOC_ALPHA_GOTTPREL16
:
5828 case BFD_RELOC_ALPHA_TPREL_HI16
:
5829 case BFD_RELOC_ALPHA_TPREL_LO16
:
5830 case BFD_RELOC_ALPHA_TPREL16
:
5832 S_SET_THREAD_LOCAL (fixP
->fx_addsy
);
5837 case BFD_RELOC_ALPHA_LITERAL
:
5838 md_number_to_chars (fixpos
, value
, 2);
5841 case BFD_RELOC_ALPHA_ELF_LITERAL
:
5842 case BFD_RELOC_ALPHA_LITUSE
:
5843 case BFD_RELOC_ALPHA_LINKAGE
:
5844 case BFD_RELOC_ALPHA_CODEADDR
:
5848 case BFD_RELOC_ALPHA_NOP
:
5849 value
-= (8 + 4); /* PC-relative, base is jsr+4. */
5851 /* From B.4.5.2 of the OpenVMS Linker Utility Manual:
5852 "Finally, the ETIR$C_STC_BSR command passes the same address
5853 as ETIR$C_STC_NOP (so that they will fail or succeed together),
5854 and the same test is done again." */
5855 if (S_GET_SEGMENT (fixP
->fx_addsy
) == undefined_section
)
5857 fixP
->fx_addnumber
= -value
;
5861 if ((abs (value
) >> 2) & ~0xfffff)
5865 /* Change to a nop. */
5870 case BFD_RELOC_ALPHA_LDA
:
5871 /* fixup_segment sets fixP->fx_addsy to NULL when it can pre-compute
5872 the value for an O_subtract. */
5874 && S_GET_SEGMENT (fixP
->fx_addsy
) == undefined_section
)
5876 fixP
->fx_addnumber
= symbol_get_bfdsym (fixP
->fx_subsy
)->value
;
5880 if ((abs (value
)) & ~0x7fff)
5884 /* Change to an lda. */
5885 image
= 0x237B0000 | (value
& 0xFFFF);
5889 case BFD_RELOC_ALPHA_BSR
:
5890 case BFD_RELOC_ALPHA_BOH
:
5891 value
-= 4; /* PC-relative, base is jsr+4. */
5893 /* See comment in the BFD_RELOC_ALPHA_NOP case above. */
5894 if (S_GET_SEGMENT (fixP
->fx_addsy
) == undefined_section
)
5896 fixP
->fx_addnumber
= -value
;
5900 if ((abs (value
) >> 2) & ~0xfffff)
5903 if (fixP
->fx_r_type
== BFD_RELOC_ALPHA_BOH
)
5906 image
= bfd_getl32(fixpos
);
5907 image
= (image
& ~0x3FFF) | ((value
>> 2) & 0x3FFF);
5914 /* Change to a branch. */
5915 image
= 0xD3400000 | ((value
>> 2) & 0x1FFFFF);
5920 case BFD_RELOC_VTABLE_INHERIT
:
5921 case BFD_RELOC_VTABLE_ENTRY
:
5926 const struct alpha_operand
*operand
;
5928 if ((int) fixP
->fx_r_type
>= 0)
5929 as_fatal (_("unhandled relocation type %s"),
5930 bfd_get_reloc_code_name (fixP
->fx_r_type
));
5932 gas_assert (-(int) fixP
->fx_r_type
< (int) alpha_num_operands
);
5933 operand
= &alpha_operands
[-(int) fixP
->fx_r_type
];
5935 /* The rest of these fixups only exist internally during symbol
5936 resolution and have no representation in the object file.
5937 Therefore they must be completely resolved as constants. */
5939 if (fixP
->fx_addsy
!= 0
5940 && S_GET_SEGMENT (fixP
->fx_addsy
) != absolute_section
)
5941 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
5942 _("non-absolute expression in constant field"));
5944 image
= bfd_getl32 (fixpos
);
5945 image
= insert_operand (image
, operand
, (offsetT
) value
,
5946 fixP
->fx_file
, fixP
->fx_line
);
5951 if (fixP
->fx_addsy
!= 0 || fixP
->fx_pcrel
!= 0)
5955 as_warn_where (fixP
->fx_file
, fixP
->fx_line
,
5956 _("type %d reloc done?\n"), (int) fixP
->fx_r_type
);
5961 md_number_to_chars (fixpos
, image
, 4);
5967 /* Look for a register name in the given symbol. */
5970 md_undefined_symbol (char *name
)
5974 int is_float
= 0, num
;
5979 if (name
[1] == 'p' && name
[2] == '\0')
5980 return alpha_register_table
[AXP_REG_FP
];
5985 if (!ISDIGIT (*++name
))
5989 case '0': case '1': case '2': case '3': case '4':
5990 case '5': case '6': case '7': case '8': case '9':
5991 if (name
[1] == '\0')
5992 num
= name
[0] - '0';
5993 else if (name
[0] != '0' && ISDIGIT (name
[1]) && name
[2] == '\0')
5995 num
= (name
[0] - '0') * 10 + name
[1] - '0';
6002 if (!alpha_noat_on
&& (num
+ is_float
) == AXP_REG_AT
)
6003 as_warn (_("Used $at without \".set noat\""));
6004 return alpha_register_table
[num
+ is_float
];
6007 if (name
[1] == 't' && name
[2] == '\0')
6010 as_warn (_("Used $at without \".set noat\""));
6011 return alpha_register_table
[AXP_REG_AT
];
6016 if (name
[1] == 'p' && name
[2] == '\0')
6017 return alpha_register_table
[alpha_gp_register
];
6021 if (name
[1] == 'p' && name
[2] == '\0')
6022 return alpha_register_table
[AXP_REG_SP
];
6030 /* @@@ Magic ECOFF bits. */
6033 alpha_frob_ecoff_data (void)
6036 /* $zero and $f31 are read-only. */
6037 alpha_gprmask
&= ~1;
6038 alpha_fprmask
&= ~1;
6042 /* Hook to remember a recently defined label so that the auto-align
6043 code can adjust the symbol after we know what alignment will be
6047 alpha_define_label (symbolS
*sym
)
6049 alpha_insn_label
= sym
;
6051 dwarf2_emit_label (sym
);
6055 /* Return true if we must always emit a reloc for a type and false if
6056 there is some hope of resolving it at assembly time. */
6059 alpha_force_relocation (fixS
*f
)
6061 if (alpha_flag_relax
)
6064 switch (f
->fx_r_type
)
6066 case BFD_RELOC_ALPHA_GPDISP_HI16
:
6067 case BFD_RELOC_ALPHA_GPDISP_LO16
:
6068 case BFD_RELOC_ALPHA_GPDISP
:
6069 case BFD_RELOC_ALPHA_LITERAL
:
6070 case BFD_RELOC_ALPHA_ELF_LITERAL
:
6071 case BFD_RELOC_ALPHA_LITUSE
:
6072 case BFD_RELOC_GPREL16
:
6073 case BFD_RELOC_GPREL32
:
6074 case BFD_RELOC_ALPHA_GPREL_HI16
:
6075 case BFD_RELOC_ALPHA_GPREL_LO16
:
6076 case BFD_RELOC_ALPHA_LINKAGE
:
6077 case BFD_RELOC_ALPHA_CODEADDR
:
6078 case BFD_RELOC_ALPHA_BRSGP
:
6079 case BFD_RELOC_ALPHA_TLSGD
:
6080 case BFD_RELOC_ALPHA_TLSLDM
:
6081 case BFD_RELOC_ALPHA_GOTDTPREL16
:
6082 case BFD_RELOC_ALPHA_DTPREL_HI16
:
6083 case BFD_RELOC_ALPHA_DTPREL_LO16
:
6084 case BFD_RELOC_ALPHA_DTPREL16
:
6085 case BFD_RELOC_ALPHA_GOTTPREL16
:
6086 case BFD_RELOC_ALPHA_TPREL_HI16
:
6087 case BFD_RELOC_ALPHA_TPREL_LO16
:
6088 case BFD_RELOC_ALPHA_TPREL16
:
6090 case BFD_RELOC_ALPHA_NOP
:
6091 case BFD_RELOC_ALPHA_BSR
:
6092 case BFD_RELOC_ALPHA_LDA
:
6093 case BFD_RELOC_ALPHA_BOH
:
6101 return generic_force_reloc (f
);
6104 /* Return true if we can partially resolve a relocation now. */
6107 alpha_fix_adjustable (fixS
*f
)
6109 /* Are there any relocation types for which we must generate a
6110 reloc but we can adjust the values contained within it? */
6111 switch (f
->fx_r_type
)
6113 case BFD_RELOC_ALPHA_GPDISP_HI16
:
6114 case BFD_RELOC_ALPHA_GPDISP_LO16
:
6115 case BFD_RELOC_ALPHA_GPDISP
:
6118 case BFD_RELOC_ALPHA_LITERAL
:
6119 case BFD_RELOC_ALPHA_ELF_LITERAL
:
6120 case BFD_RELOC_ALPHA_LITUSE
:
6121 case BFD_RELOC_ALPHA_LINKAGE
:
6122 case BFD_RELOC_ALPHA_CODEADDR
:
6125 case BFD_RELOC_VTABLE_ENTRY
:
6126 case BFD_RELOC_VTABLE_INHERIT
:
6129 case BFD_RELOC_GPREL16
:
6130 case BFD_RELOC_GPREL32
:
6131 case BFD_RELOC_ALPHA_GPREL_HI16
:
6132 case BFD_RELOC_ALPHA_GPREL_LO16
:
6133 case BFD_RELOC_23_PCREL_S2
:
6137 case BFD_RELOC_ALPHA_HINT
:
6140 case BFD_RELOC_ALPHA_TLSGD
:
6141 case BFD_RELOC_ALPHA_TLSLDM
:
6142 case BFD_RELOC_ALPHA_GOTDTPREL16
:
6143 case BFD_RELOC_ALPHA_DTPREL_HI16
:
6144 case BFD_RELOC_ALPHA_DTPREL_LO16
:
6145 case BFD_RELOC_ALPHA_DTPREL16
:
6146 case BFD_RELOC_ALPHA_GOTTPREL16
:
6147 case BFD_RELOC_ALPHA_TPREL_HI16
:
6148 case BFD_RELOC_ALPHA_TPREL_LO16
:
6149 case BFD_RELOC_ALPHA_TPREL16
:
6150 /* ??? No idea why we can't return a reference to .tbss+10, but
6151 we're preventing this in the other assemblers. Follow for now. */
6155 case BFD_RELOC_ALPHA_BRSGP
:
6156 /* If we have a BRSGP reloc to a local symbol, adjust it to BRADDR and
6157 let it get resolved at assembly time. */
6159 symbolS
*sym
= f
->fx_addsy
;
6163 if (generic_force_reloc (f
))
6166 switch (S_GET_OTHER (sym
) & STO_ALPHA_STD_GPLOAD
)
6168 case STO_ALPHA_NOPV
:
6170 case STO_ALPHA_STD_GPLOAD
:
6174 if (S_IS_LOCAL (sym
))
6177 name
= S_GET_NAME (sym
);
6178 as_bad_where (f
->fx_file
, f
->fx_line
,
6179 _("!samegp reloc against symbol without .prologue: %s"),
6183 f
->fx_r_type
= BFD_RELOC_23_PCREL_S2
;
6184 f
->fx_offset
+= offset
;
6189 case BFD_RELOC_ALPHA_NOP
:
6190 case BFD_RELOC_ALPHA_BSR
:
6191 case BFD_RELOC_ALPHA_LDA
:
6192 case BFD_RELOC_ALPHA_BOH
:
6201 /* Generate the BFD reloc to be stuck in the object file from the
6202 fixup used internally in the assembler. */
6205 tc_gen_reloc (asection
*sec ATTRIBUTE_UNUSED
,
6210 reloc
= xmalloc (sizeof (* reloc
));
6211 reloc
->sym_ptr_ptr
= xmalloc (sizeof (asymbol
*));
6212 *reloc
->sym_ptr_ptr
= symbol_get_bfdsym (fixp
->fx_addsy
);
6213 reloc
->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
6215 /* Make sure none of our internal relocations make it this far.
6216 They'd better have been fully resolved by this point. */
6217 gas_assert ((int) fixp
->fx_r_type
> 0);
6219 reloc
->howto
= bfd_reloc_type_lookup (stdoutput
, fixp
->fx_r_type
);
6220 if (reloc
->howto
== NULL
)
6222 as_bad_where (fixp
->fx_file
, fixp
->fx_line
,
6223 _("cannot represent `%s' relocation in object file"),
6224 bfd_get_reloc_code_name (fixp
->fx_r_type
));
6228 if (!fixp
->fx_pcrel
!= !reloc
->howto
->pc_relative
)
6229 as_fatal (_("internal error? cannot generate `%s' relocation"),
6230 bfd_get_reloc_code_name (fixp
->fx_r_type
));
6232 gas_assert (!fixp
->fx_pcrel
== !reloc
->howto
->pc_relative
);
6235 if (fixp
->fx_r_type
== BFD_RELOC_ALPHA_LITERAL
)
6236 /* Fake out bfd_perform_relocation. sigh. */
6237 reloc
->addend
= -alpha_gp_value
;
6241 reloc
->addend
= fixp
->fx_offset
;
6243 /* Ohhh, this is ugly. The problem is that if this is a local global
6244 symbol, the relocation will entirely be performed at link time, not
6245 at assembly time. bfd_perform_reloc doesn't know about this sort
6246 of thing, and as a result we need to fake it out here. */
6247 if ((S_IS_EXTERNAL (fixp
->fx_addsy
) || S_IS_WEAK (fixp
->fx_addsy
)
6248 || (S_GET_SEGMENT (fixp
->fx_addsy
)->flags
& SEC_MERGE
)
6249 || (S_GET_SEGMENT (fixp
->fx_addsy
)->flags
& SEC_THREAD_LOCAL
))
6250 && !S_IS_COMMON (fixp
->fx_addsy
))
6251 reloc
->addend
-= symbol_get_bfdsym (fixp
->fx_addsy
)->value
;
6256 switch (fixp
->fx_r_type
)
6258 struct evax_private_udata_struct
*udata
;
6262 case BFD_RELOC_ALPHA_LINKAGE
:
6263 reloc
->addend
= fixp
->fx_addnumber
;
6266 case BFD_RELOC_ALPHA_NOP
:
6267 case BFD_RELOC_ALPHA_BSR
:
6268 case BFD_RELOC_ALPHA_LDA
:
6269 case BFD_RELOC_ALPHA_BOH
:
6270 pname
= symbol_get_bfdsym (fixp
->fx_addsy
)->name
;
6272 /* We need the non-suffixed name of the procedure. Beware that
6273 the main symbol might be equated so look it up and take its name. */
6274 pname_len
= strlen (pname
);
6275 if (pname_len
> 4 && strcmp (pname
+ pname_len
- 4, "..en") == 0)
6278 char *my_pname
= xstrdup (pname
);
6279 my_pname
[pname_len
- 4] = 0;
6280 sym
= symbol_find (my_pname
);
6283 while (symbol_equated_reloc_p (sym
))
6285 symbolS
*n
= symbol_get_value_expression (sym
)->X_add_symbol
;
6287 /* We must avoid looping, as that can occur with a badly
6293 pname
= symbol_get_bfdsym (sym
)->name
;
6296 udata
= (struct evax_private_udata_struct
*)
6297 xmalloc (sizeof (struct evax_private_udata_struct
));
6298 udata
->enbsym
= symbol_get_bfdsym (fixp
->fx_addsy
);
6299 udata
->bsym
= symbol_get_bfdsym (fixp
->tc_fix_data
.info
->psym
);
6300 udata
->origname
= (char *)pname
;
6301 udata
->lkindex
= ((struct evax_private_udata_struct
*)
6302 symbol_get_bfdsym (fixp
->tc_fix_data
.info
->sym
)->udata
.p
)->lkindex
;
6303 reloc
->sym_ptr_ptr
= (void *)udata
;
6304 reloc
->addend
= fixp
->fx_addnumber
;
6314 /* Parse a register name off of the input_line and return a register
6315 number. Gets md_undefined_symbol above to do the register name
6318 Only called as a part of processing the ECOFF .frame directive. */
6321 tc_get_register (int frame ATTRIBUTE_UNUSED
)
6323 int framereg
= AXP_REG_SP
;
6326 if (*input_line_pointer
== '$')
6328 char *s
= input_line_pointer
;
6329 char c
= get_symbol_end ();
6330 symbolS
*sym
= md_undefined_symbol (s
);
6332 *strchr (s
, '\0') = c
;
6333 if (sym
&& (framereg
= S_GET_VALUE (sym
)) <= 31)
6336 as_warn (_("frame reg expected, using $%d."), framereg
);
6339 note_gpreg (framereg
);
6343 /* This is called before the symbol table is processed. In order to
6344 work with gcc when using mips-tfile, we must keep all local labels.
6345 However, in other cases, we want to discard them. If we were
6346 called with -g, but we didn't see any debugging information, it may
6347 mean that gcc is smuggling debugging information through to
6348 mips-tfile, in which case we must generate all local labels. */
6353 alpha_frob_file_before_adjust (void)
6355 if (alpha_debug
!= 0
6356 && ! ecoff_debugging_seen
)
6357 flag_keep_locals
= 1;
6360 #endif /* OBJ_ECOFF */
6362 /* The Alpha has support for some VAX floating point types, as well as for
6363 IEEE floating point. We consider IEEE to be the primary floating point
6364 format, and sneak in the VAX floating point support here. */
6365 #include "config/atof-vax.c"