1 /* tc-alpha.c - Processor-specific code for the DEC Alpha AXP CPU.
2 Copyright (C) 1989, 93-98, 1999 Free Software Foundation, Inc.
3 Contributed by Carnegie Mellon University, 1993.
4 Written by Alessandro Forin, based on earlier gas-1.38 target CPU files.
5 Modified by Ken Raeburn for gas-2.x and ECOFF support.
6 Modified by Richard Henderson for ELF support.
7 Modified by Klaus K"ampf for EVAX (OpenVMS/Alpha) support.
9 This file is part of GAS, the GNU Assembler.
11 GAS is free software; you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation; either version 2, or (at your option)
16 GAS is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with GAS; see the file COPYING. If not, write to the Free
23 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
27 * Mach Operating System
28 * Copyright (c) 1993 Carnegie Mellon University
29 * All Rights Reserved.
31 * Permission to use, copy, modify and distribute this software and its
32 * documentation is hereby granted, provided that both the copyright
33 * notice and this permission notice appear in all copies of the
34 * software, derivative works or modified versions, and any portions
35 * thereof, and that both notices appear in supporting documentation.
37 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS
38 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
39 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
41 * Carnegie Mellon requests users of this software to return to
43 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
44 * School of Computer Science
45 * Carnegie Mellon University
46 * Pittsburgh PA 15213-3890
48 * any improvements or extensions that they make and grant Carnegie the
49 * rights to redistribute these changes.
56 #include "opcode/alpha.h"
59 #include "elf/alpha.h"
67 #define MAX_INSN_FIXUPS 2
68 #define MAX_INSN_ARGS 5
73 bfd_reloc_code_real_type reloc
;
80 struct alpha_fixup fixups
[MAX_INSN_FIXUPS
];
85 MACRO_EOA
= 1, MACRO_IR
, MACRO_PIR
, MACRO_CPIR
, MACRO_FPR
, MACRO_EXP
91 void (*emit
) PARAMS ((const expressionS
*, int, const PTR
));
93 enum alpha_macro_arg argsets
[16];
96 /* Two extra symbols we want to see in our input. This is a blatent
97 misuse of the expressionS.X_op field. */
99 #define O_pregister ((operatorT) (O_max+1)) /* O_register, in parentheses */
100 #define O_cpregister ((operatorT) (O_pregister+1)) /* + a leading comma */
101 #define O_alpha_max ((operatorT) (O_cpregister+1))
103 /* Macros for extracting the type and number of encoded register tokens */
105 #define is_ir_num(x) (((x) & 32) == 0)
106 #define is_fpr_num(x) (((x) & 32) != 0)
107 #define regno(x) ((x) & 31)
109 /* Something odd inherited from the old assembler */
111 #define note_gpreg(R) (alpha_gprmask |= (1 << (R)))
112 #define note_fpreg(R) (alpha_fprmask |= (1 << (R)))
114 /* Predicates for 16- and 32-bit ranges */
115 /* XXX: The non-shift version appears to trigger a compiler bug when
116 cross-assembling from x86 w/ gcc 2.7.2. */
119 #define range_signed_16(x) \
120 (((offsetT)(x) >> 15) == 0 || ((offsetT)(x) >> 15) == -1)
121 #define range_signed_32(x) \
122 (((offsetT)(x) >> 31) == 0 || ((offsetT)(x) >> 31) == -1)
124 #define range_signed_16(x) ((offsetT)(x) >= -(offsetT)0x8000 && \
125 (offsetT)(x) <= (offsetT)0x7FFF)
126 #define range_signed_32(x) ((offsetT)(x) >= -(offsetT)0x80000000 && \
127 (offsetT)(x) <= (offsetT)0x7FFFFFFF)
130 /* Macros for sign extending from 16- and 32-bits. */
131 /* XXX: The cast macros will work on all the systems that I care about,
132 but really a predicate should be found to use the non-cast forms. */
135 #define sign_extend_16(x) ((short)(x))
136 #define sign_extend_32(x) ((int)(x))
138 #define sign_extend_16(x) ((offsetT)(((x) & 0xFFFF) ^ 0x8000) - 0x8000)
139 #define sign_extend_32(x) ((offsetT)(((x) & 0xFFFFFFFF) \
140 ^ 0x80000000) - 0x80000000)
143 /* Macros to build tokens */
145 #define set_tok_reg(t, r) (memset(&(t), 0, sizeof(t)), \
146 (t).X_op = O_register, \
147 (t).X_add_number = (r))
148 #define set_tok_preg(t, r) (memset(&(t), 0, sizeof(t)), \
149 (t).X_op = O_pregister, \
150 (t).X_add_number = (r))
151 #define set_tok_cpreg(t, r) (memset(&(t), 0, sizeof(t)), \
152 (t).X_op = O_cpregister, \
153 (t).X_add_number = (r))
154 #define set_tok_freg(t, r) (memset(&(t), 0, sizeof(t)), \
155 (t).X_op = O_register, \
156 (t).X_add_number = (r)+32)
157 #define set_tok_sym(t, s, a) (memset(&(t), 0, sizeof(t)), \
158 (t).X_op = O_symbol, \
159 (t).X_add_symbol = (s), \
160 (t).X_add_number = (a))
161 #define set_tok_const(t, n) (memset(&(t), 0, sizeof(t)), \
162 (t).X_op = O_constant, \
163 (t).X_add_number = (n))
166 /* Prototypes for all local functions */
168 static int tokenize_arguments
PARAMS ((char *, expressionS
*, int));
169 static const struct alpha_opcode
*find_opcode_match
170 PARAMS ((const struct alpha_opcode
*, const expressionS
*, int *, int *));
171 static const struct alpha_macro
*find_macro_match
172 PARAMS ((const struct alpha_macro
*, const expressionS
*, int *));
173 static unsigned insert_operand
174 PARAMS ((unsigned, const struct alpha_operand
*, offsetT
, char *, unsigned));
175 static void assemble_insn
176 PARAMS ((const struct alpha_opcode
*, const expressionS
*, int,
177 struct alpha_insn
*));
178 static void emit_insn
PARAMS ((struct alpha_insn
*));
179 static void assemble_tokens_to_insn
180 PARAMS ((const char *, const expressionS
*, int, struct alpha_insn
*));
181 static void assemble_tokens
182 PARAMS ((const char *, const expressionS
*, int, int));
184 static int load_expression
185 PARAMS ((int, const expressionS
*, int *, expressionS
*));
187 static void emit_ldgp
PARAMS ((const expressionS
*, int, const PTR
));
188 static void emit_division
PARAMS ((const expressionS
*, int, const PTR
));
189 static void emit_lda
PARAMS ((const expressionS
*, int, const PTR
));
190 static void emit_ldah
PARAMS ((const expressionS
*, int, const PTR
));
191 static void emit_ir_load
PARAMS ((const expressionS
*, int, const PTR
));
192 static void emit_loadstore
PARAMS ((const expressionS
*, int, const PTR
));
193 static void emit_jsrjmp
PARAMS ((const expressionS
*, int, const PTR
));
194 static void emit_ldX
PARAMS ((const expressionS
*, int, const PTR
));
195 static void emit_ldXu
PARAMS ((const expressionS
*, int, const PTR
));
196 static void emit_uldX
PARAMS ((const expressionS
*, int, const PTR
));
197 static void emit_uldXu
PARAMS ((const expressionS
*, int, const PTR
));
198 static void emit_ldil
PARAMS ((const expressionS
*, int, const PTR
));
199 static void emit_stX
PARAMS ((const expressionS
*, int, const PTR
));
200 static void emit_ustX
PARAMS ((const expressionS
*, int, const PTR
));
201 static void emit_sextX
PARAMS ((const expressionS
*, int, const PTR
));
202 static void emit_retjcr
PARAMS ((const expressionS
*, int, const PTR
));
204 static void s_alpha_text
PARAMS ((int));
205 static void s_alpha_data
PARAMS ((int));
207 static void s_alpha_comm
PARAMS ((int));
208 static void s_alpha_rdata
PARAMS ((int));
211 static void s_alpha_sdata
PARAMS ((int));
214 static void s_alpha_section
PARAMS ((int));
215 static void s_alpha_ent
PARAMS ((int));
216 static void s_alpha_end
PARAMS ((int));
217 static void s_alpha_mask
PARAMS ((int));
218 static void s_alpha_frame
PARAMS ((int));
219 static void s_alpha_prologue
PARAMS ((int));
220 static void s_alpha_coff_wrapper
PARAMS ((int));
223 static void s_alpha_section
PARAMS ((int));
225 static void s_alpha_gprel32
PARAMS ((int));
226 static void s_alpha_float_cons
PARAMS ((int));
227 static void s_alpha_proc
PARAMS ((int));
228 static void s_alpha_set
PARAMS ((int));
229 static void s_alpha_base
PARAMS ((int));
230 static void s_alpha_align
PARAMS ((int));
231 static void s_alpha_stringer
PARAMS ((int));
232 static void s_alpha_space
PARAMS ((int));
234 static void create_literal_section
PARAMS ((const char *, segT
*, symbolS
**));
236 static void select_gp_value
PARAMS ((void));
238 static void alpha_align
PARAMS ((int, char *, symbolS
*, int));
241 /* Generic assembler global variables which must be defined by all
244 /* Characters which always start a comment. */
245 const char comment_chars
[] = "#";
247 /* Characters which start a comment at the beginning of a line. */
248 const char line_comment_chars
[] = "#";
250 /* Characters which may be used to separate multiple commands on a
252 const char line_separator_chars
[] = ";";
254 /* Characters which are used to indicate an exponent in a floating
256 const char EXP_CHARS
[] = "eE";
258 /* Characters which mean that a number is a floating point constant,
261 const char FLT_CHARS
[] = "dD";
263 /* XXX: Do all of these really get used on the alpha?? */
264 char FLT_CHARS
[] = "rRsSfFdDxXpP";
268 const char *md_shortopts
= "Fm:g+1h:HG:";
270 const char *md_shortopts
= "Fm:gG:";
273 struct option md_longopts
[] = {
274 #define OPTION_32ADDR (OPTION_MD_BASE)
275 { "32addr", no_argument
, NULL
, OPTION_32ADDR
},
276 #define OPTION_RELAX (OPTION_32ADDR+1)
277 { "relax", no_argument
, NULL
, OPTION_RELAX
},
279 #define OPTION_MDEBUG (OPTION_RELAX+1)
280 #define OPTION_NO_MDEBUG (OPTION_MDEBUG+1)
281 { "mdebug", no_argument
, NULL
, OPTION_MDEBUG
},
282 { "no-mdebug", no_argument
, NULL
, OPTION_NO_MDEBUG
},
284 { NULL
, no_argument
, NULL
, 0 }
287 size_t md_longopts_size
= sizeof(md_longopts
);
292 #define AXP_REG_R16 16
293 #define AXP_REG_R17 17
295 #define AXP_REG_T9 22
297 #define AXP_REG_T10 23
299 #define AXP_REG_T11 24
301 #define AXP_REG_T12 25
302 #define AXP_REG_AI 25
304 #define AXP_REG_FP 29
307 #define AXP_REG_GP AXP_REG_PV
308 #endif /* OBJ_EVAX */
310 /* The cpu for which we are generating code */
311 static unsigned alpha_target
= AXP_OPCODE_BASE
;
312 static const char *alpha_target_name
= "<all>";
314 /* The hash table of instruction opcodes */
315 static struct hash_control
*alpha_opcode_hash
;
317 /* The hash table of macro opcodes */
318 static struct hash_control
*alpha_macro_hash
;
321 /* The $gp relocation symbol */
322 static symbolS
*alpha_gp_symbol
;
324 /* XXX: what is this, and why is it exported? */
325 valueT alpha_gp_value
;
328 /* The current $gp register */
329 static int alpha_gp_register
= AXP_REG_GP
;
331 /* A table of the register symbols */
332 static symbolS
*alpha_register_table
[64];
334 /* Constant sections, or sections of constants */
336 static segT alpha_lita_section
;
337 static segT alpha_lit4_section
;
340 static segT alpha_link_section
;
341 static segT alpha_ctors_section
;
342 static segT alpha_dtors_section
;
344 static segT alpha_lit8_section
;
346 /* Symbols referring to said sections. */
348 static symbolS
*alpha_lita_symbol
;
349 static symbolS
*alpha_lit4_symbol
;
352 static symbolS
*alpha_link_symbol
;
353 static symbolS
*alpha_ctors_symbol
;
354 static symbolS
*alpha_dtors_symbol
;
356 static symbolS
*alpha_lit8_symbol
;
358 /* Literal for .litX+0x8000 within .lita */
360 static offsetT alpha_lit4_literal
;
361 static offsetT alpha_lit8_literal
;
364 /* The active .ent symbol. */
366 static symbolS
*alpha_cur_ent_sym
;
369 /* Is the assembler not allowed to use $at? */
370 static int alpha_noat_on
= 0;
372 /* Are macros enabled? */
373 static int alpha_macros_on
= 1;
375 /* Are floats disabled? */
376 static int alpha_nofloats_on
= 0;
378 /* Are addresses 32 bit? */
379 static int alpha_addr32_on
= 0;
381 /* Symbol labelling the current insn. When the Alpha gas sees
384 and the section happens to not be on an eight byte boundary, it
385 will align both the symbol and the .quad to an eight byte boundary. */
386 static symbolS
*alpha_insn_label
;
388 /* Whether we should automatically align data generation pseudo-ops.
389 .align 0 will turn this off. */
390 static int alpha_auto_align_on
= 1;
392 /* The known current alignment of the current section. */
393 static int alpha_current_align
;
395 /* These are exported to ECOFF code. */
396 unsigned long alpha_gprmask
, alpha_fprmask
;
398 /* Whether the debugging option was seen. */
399 static int alpha_debug
;
402 /* Whether we are emitting an mdebug section. */
403 int alpha_flag_mdebug
= 1;
406 /* Don't fully resolve relocations, allowing code movement in the linker. */
407 static int alpha_flag_relax
;
409 /* What value to give to bfd_set_gp_size. */
410 static int g_switch_value
= 8;
413 /* Collect information about current procedure here. */
415 symbolS
*symbol
; /* proc pdesc symbol */
417 int framereg
; /* register for frame pointer */
418 int framesize
; /* size of frame */
428 static int alpha_flag_hash_long_names
= 0; /* -+ */
429 static int alpha_flag_show_after_trunc
= 0; /* -H */
431 /* If the -+ switch is given, then a hash is appended to any name that is
432 * longer than 64 characters, else longer symbol names are truncated.
437 /* A table of CPU names and opcode sets. */
439 static const struct cpu_type
445 /* Ad hoc convention: cpu number gets palcode, process code doesn't.
446 This supports usage under DU 4.0b that does ".arch ev4", and
447 usage in MILO that does -m21064. Probably something more
448 specific like -m21064-pal should be used, but oh well. */
450 { "21064", AXP_OPCODE_BASE
|AXP_OPCODE_EV4
},
451 { "21064a", AXP_OPCODE_BASE
|AXP_OPCODE_EV4
},
452 { "21066", AXP_OPCODE_BASE
|AXP_OPCODE_EV4
},
453 { "21068", AXP_OPCODE_BASE
|AXP_OPCODE_EV4
},
454 { "21164", AXP_OPCODE_BASE
|AXP_OPCODE_EV5
},
455 { "21164a", AXP_OPCODE_BASE
|AXP_OPCODE_EV5
|AXP_OPCODE_BWX
},
456 { "21164pc", (AXP_OPCODE_BASE
|AXP_OPCODE_EV5
|AXP_OPCODE_BWX
458 { "21264", (AXP_OPCODE_BASE
|AXP_OPCODE_EV6
|AXP_OPCODE_BWX
459 |AXP_OPCODE_MAX
|AXP_OPCODE_CIX
) },
461 { "ev4", AXP_OPCODE_BASE
},
462 { "ev45", AXP_OPCODE_BASE
},
463 { "lca45", AXP_OPCODE_BASE
},
464 { "ev5", AXP_OPCODE_BASE
},
465 { "ev56", AXP_OPCODE_BASE
|AXP_OPCODE_BWX
},
466 { "pca56", AXP_OPCODE_BASE
|AXP_OPCODE_BWX
|AXP_OPCODE_MAX
},
467 { "ev6", AXP_OPCODE_BASE
|AXP_OPCODE_BWX
|AXP_OPCODE_MAX
|AXP_OPCODE_CIX
},
469 { "all", AXP_OPCODE_BASE
},
473 /* The macro table */
475 static const struct alpha_macro alpha_macros
[] = {
476 /* Load/Store macros */
477 { "lda", emit_lda
, NULL
,
478 { MACRO_IR
, MACRO_EXP
, MACRO_PIR
, MACRO_EOA
,
479 MACRO_IR
, MACRO_EXP
, MACRO_EOA
} },
480 { "ldah", emit_ldah
, NULL
,
481 { MACRO_IR
, MACRO_EXP
, MACRO_EOA
} },
483 { "ldl", emit_ir_load
, "ldl",
484 { MACRO_IR
, MACRO_EXP
, MACRO_PIR
, MACRO_EOA
,
485 MACRO_IR
, MACRO_EXP
, MACRO_EOA
} },
486 { "ldl_l", emit_ir_load
, "ldl_l",
487 { MACRO_IR
, MACRO_EXP
, MACRO_PIR
, MACRO_EOA
,
488 MACRO_IR
, MACRO_EXP
, MACRO_EOA
} },
489 { "ldq", emit_ir_load
, "ldq",
490 { MACRO_IR
, MACRO_EXP
, MACRO_PIR
, MACRO_EOA
,
491 MACRO_IR
, MACRO_EXP
, MACRO_EOA
} },
492 { "ldq_l", emit_ir_load
, "ldq_l",
493 { MACRO_IR
, MACRO_EXP
, MACRO_PIR
, MACRO_EOA
,
494 MACRO_IR
, MACRO_EXP
, MACRO_EOA
} },
495 { "ldq_u", emit_ir_load
, "ldq_u",
496 { MACRO_IR
, MACRO_EXP
, MACRO_PIR
, MACRO_EOA
,
497 MACRO_IR
, MACRO_EXP
, MACRO_EOA
} },
498 { "ldf", emit_loadstore
, "ldf",
499 { MACRO_FPR
, MACRO_EXP
, MACRO_PIR
, MACRO_EOA
,
500 MACRO_FPR
, MACRO_EXP
, MACRO_EOA
} },
501 { "ldg", emit_loadstore
, "ldg",
502 { MACRO_FPR
, MACRO_EXP
, MACRO_PIR
, MACRO_EOA
,
503 MACRO_FPR
, MACRO_EXP
, MACRO_EOA
} },
504 { "lds", emit_loadstore
, "lds",
505 { MACRO_FPR
, MACRO_EXP
, MACRO_PIR
, MACRO_EOA
,
506 MACRO_FPR
, MACRO_EXP
, MACRO_EOA
} },
507 { "ldt", emit_loadstore
, "ldt",
508 { MACRO_FPR
, MACRO_EXP
, MACRO_PIR
, MACRO_EOA
,
509 MACRO_FPR
, MACRO_EXP
, MACRO_EOA
} },
511 { "ldb", emit_ldX
, (PTR
)0,
512 { MACRO_IR
, MACRO_EXP
, MACRO_PIR
, MACRO_EOA
,
513 MACRO_IR
, MACRO_EXP
, MACRO_EOA
} },
514 { "ldbu", emit_ldXu
, (PTR
)0,
515 { MACRO_IR
, MACRO_EXP
, MACRO_PIR
, MACRO_EOA
,
516 MACRO_IR
, MACRO_EXP
, MACRO_EOA
} },
517 { "ldw", emit_ldX
, (PTR
)1,
518 { MACRO_IR
, MACRO_EXP
, MACRO_PIR
, MACRO_EOA
,
519 MACRO_IR
, MACRO_EXP
, MACRO_EOA
} },
520 { "ldwu", emit_ldXu
, (PTR
)1,
521 { MACRO_IR
, MACRO_EXP
, MACRO_PIR
, MACRO_EOA
,
522 MACRO_IR
, MACRO_EXP
, MACRO_EOA
} },
524 { "uldw", emit_uldX
, (PTR
)1,
525 { MACRO_IR
, MACRO_EXP
, MACRO_PIR
, MACRO_EOA
,
526 MACRO_IR
, MACRO_EXP
, MACRO_EOA
} },
527 { "uldwu", emit_uldXu
, (PTR
)1,
528 { MACRO_IR
, MACRO_EXP
, MACRO_PIR
, MACRO_EOA
,
529 MACRO_IR
, MACRO_EXP
, MACRO_EOA
} },
530 { "uldl", emit_uldX
, (PTR
)2,
531 { MACRO_IR
, MACRO_EXP
, MACRO_PIR
, MACRO_EOA
,
532 MACRO_IR
, MACRO_EXP
, MACRO_EOA
} },
533 { "uldlu", emit_uldXu
, (PTR
)2,
534 { MACRO_IR
, MACRO_EXP
, MACRO_PIR
, MACRO_EOA
,
535 MACRO_IR
, MACRO_EXP
, MACRO_EOA
} },
536 { "uldq", emit_uldXu
, (PTR
)3,
537 { MACRO_IR
, MACRO_EXP
, MACRO_PIR
, MACRO_EOA
,
538 MACRO_IR
, MACRO_EXP
, MACRO_EOA
} },
540 { "ldgp", emit_ldgp
, NULL
,
541 { MACRO_IR
, MACRO_EXP
, MACRO_PIR
, MACRO_EOA
} },
543 { "ldi", emit_lda
, NULL
,
544 { MACRO_IR
, MACRO_EXP
, MACRO_EOA
} },
545 { "ldil", emit_ldil
, NULL
,
546 { MACRO_IR
, MACRO_EXP
, MACRO_EOA
} },
547 { "ldiq", emit_lda
, NULL
,
548 { MACRO_IR
, MACRO_EXP
, MACRO_EOA
} },
550 { "ldif" emit_ldiq
, NULL
,
551 { MACRO_FPR
, MACRO_EXP
, MACRO_EOA
} },
552 { "ldid" emit_ldiq
, NULL
,
553 { MACRO_FPR
, MACRO_EXP
, MACRO_EOA
} },
554 { "ldig" emit_ldiq
, NULL
,
555 { MACRO_FPR
, MACRO_EXP
, MACRO_EOA
} },
556 { "ldis" emit_ldiq
, NULL
,
557 { MACRO_FPR
, MACRO_EXP
, MACRO_EOA
} },
558 { "ldit" emit_ldiq
, NULL
,
559 { MACRO_FPR
, MACRO_EXP
, MACRO_EOA
} },
562 { "stl", emit_loadstore
, "stl",
563 { MACRO_IR
, MACRO_EXP
, MACRO_PIR
, MACRO_EOA
,
564 MACRO_IR
, MACRO_EXP
, MACRO_EOA
} },
565 { "stl_c", emit_loadstore
, "stl_c",
566 { MACRO_IR
, MACRO_EXP
, MACRO_PIR
, MACRO_EOA
,
567 MACRO_IR
, MACRO_EXP
, MACRO_EOA
} },
568 { "stq", emit_loadstore
, "stq",
569 { MACRO_IR
, MACRO_EXP
, MACRO_PIR
, MACRO_EOA
,
570 MACRO_IR
, MACRO_EXP
, MACRO_EOA
} },
571 { "stq_c", emit_loadstore
, "stq_c",
572 { MACRO_IR
, MACRO_EXP
, MACRO_PIR
, MACRO_EOA
,
573 MACRO_IR
, MACRO_EXP
, MACRO_EOA
} },
574 { "stq_u", emit_loadstore
, "stq_u",
575 { MACRO_IR
, MACRO_EXP
, MACRO_PIR
, MACRO_EOA
,
576 MACRO_IR
, MACRO_EXP
, MACRO_EOA
} },
577 { "stf", emit_loadstore
, "stf",
578 { MACRO_FPR
, MACRO_EXP
, MACRO_PIR
, MACRO_EOA
,
579 MACRO_FPR
, MACRO_EXP
, MACRO_EOA
} },
580 { "stg", emit_loadstore
, "stg",
581 { MACRO_FPR
, MACRO_EXP
, MACRO_PIR
, MACRO_EOA
,
582 MACRO_FPR
, MACRO_EXP
, MACRO_EOA
} },
583 { "sts", emit_loadstore
, "sts",
584 { MACRO_FPR
, MACRO_EXP
, MACRO_PIR
, MACRO_EOA
,
585 MACRO_FPR
, MACRO_EXP
, MACRO_EOA
} },
586 { "stt", emit_loadstore
, "stt",
587 { MACRO_FPR
, MACRO_EXP
, MACRO_PIR
, MACRO_EOA
,
588 MACRO_FPR
, MACRO_EXP
, MACRO_EOA
} },
590 { "stb", emit_stX
, (PTR
)0,
591 { MACRO_IR
, MACRO_EXP
, MACRO_PIR
, MACRO_EOA
,
592 MACRO_IR
, MACRO_EXP
, MACRO_EOA
} },
593 { "stw", emit_stX
, (PTR
)1,
594 { MACRO_IR
, MACRO_EXP
, MACRO_PIR
, MACRO_EOA
,
595 MACRO_IR
, MACRO_EXP
, MACRO_EOA
} },
596 { "ustw", emit_ustX
, (PTR
)1,
597 { MACRO_IR
, MACRO_EXP
, MACRO_PIR
, MACRO_EOA
,
598 MACRO_IR
, MACRO_EXP
, MACRO_EOA
} },
599 { "ustl", emit_ustX
, (PTR
)2,
600 { MACRO_IR
, MACRO_EXP
, MACRO_PIR
, MACRO_EOA
,
601 MACRO_IR
, MACRO_EXP
, MACRO_EOA
} },
602 { "ustq", emit_ustX
, (PTR
)3,
603 { MACRO_IR
, MACRO_EXP
, MACRO_PIR
, MACRO_EOA
,
604 MACRO_IR
, MACRO_EXP
, MACRO_EOA
} },
606 /* Arithmetic macros */
608 { "absl" emit_absl
, 1, { IR
} },
609 { "absl" emit_absl
, 2, { IR
, IR
} },
610 { "absl" emit_absl
, 2, { EXP
, IR
} },
611 { "absq" emit_absq
, 1, { IR
} },
612 { "absq" emit_absq
, 2, { IR
, IR
} },
613 { "absq" emit_absq
, 2, { EXP
, IR
} },
616 { "sextb", emit_sextX
, (PTR
)0,
617 { MACRO_IR
, MACRO_IR
, MACRO_EOA
,
619 /* MACRO_EXP, MACRO_IR, MACRO_EOA */ } },
620 { "sextw", emit_sextX
, (PTR
)1,
621 { MACRO_IR
, MACRO_IR
, MACRO_EOA
,
623 /* MACRO_EXP, MACRO_IR, MACRO_EOA */ } },
625 { "divl", emit_division
, "__divl",
626 { MACRO_IR
, MACRO_IR
, MACRO_IR
, MACRO_EOA
,
627 MACRO_IR
, MACRO_IR
, MACRO_EOA
,
628 /* MACRO_IR, MACRO_EXP, MACRO_IR, MACRO_EOA,
629 MACRO_IR, MACRO_EXP, MACRO_EOA */ } },
630 { "divlu", emit_division
, "__divlu",
631 { MACRO_IR
, MACRO_IR
, MACRO_IR
, MACRO_EOA
,
632 MACRO_IR
, MACRO_IR
, MACRO_EOA
,
633 /* MACRO_IR, MACRO_EXP, MACRO_IR, MACRO_EOA,
634 MACRO_IR, MACRO_EXP, MACRO_EOA */ } },
635 { "divq", emit_division
, "__divq",
636 { MACRO_IR
, MACRO_IR
, MACRO_IR
, MACRO_EOA
,
637 MACRO_IR
, MACRO_IR
, MACRO_EOA
,
638 /* MACRO_IR, MACRO_EXP, MACRO_IR, MACRO_EOA,
639 MACRO_IR, MACRO_EXP, MACRO_EOA */ } },
640 { "divqu", emit_division
, "__divqu",
641 { MACRO_IR
, MACRO_IR
, MACRO_IR
, MACRO_EOA
,
642 MACRO_IR
, MACRO_IR
, MACRO_EOA
,
643 /* MACRO_IR, MACRO_EXP, MACRO_IR, MACRO_EOA,
644 MACRO_IR, MACRO_EXP, MACRO_EOA */ } },
645 { "reml", emit_division
, "__reml",
646 { MACRO_IR
, MACRO_IR
, MACRO_IR
, MACRO_EOA
,
647 MACRO_IR
, MACRO_IR
, MACRO_EOA
,
648 /* MACRO_IR, MACRO_EXP, MACRO_IR, MACRO_EOA,
649 MACRO_IR, MACRO_EXP, MACRO_EOA */ } },
650 { "remlu", emit_division
, "__remlu",
651 { MACRO_IR
, MACRO_IR
, MACRO_IR
, MACRO_EOA
,
652 MACRO_IR
, MACRO_IR
, MACRO_EOA
,
653 /* MACRO_IR, MACRO_EXP, MACRO_IR, MACRO_EOA,
654 MACRO_IR, MACRO_EXP, MACRO_EOA */ } },
655 { "remq", emit_division
, "__remq",
656 { MACRO_IR
, MACRO_IR
, MACRO_IR
, MACRO_EOA
,
657 MACRO_IR
, MACRO_IR
, MACRO_EOA
,
658 /* MACRO_IR, MACRO_EXP, MACRO_IR, MACRO_EOA,
659 MACRO_IR, MACRO_EXP, MACRO_EOA */ } },
660 { "remqu", emit_division
, "__remqu",
661 { MACRO_IR
, MACRO_IR
, MACRO_IR
, MACRO_EOA
,
662 MACRO_IR
, MACRO_IR
, MACRO_EOA
,
663 /* MACRO_IR, MACRO_EXP, MACRO_IR, MACRO_EOA,
664 MACRO_IR, MACRO_EXP, MACRO_EOA */ } },
666 { "jsr", emit_jsrjmp
, "jsr",
667 { MACRO_PIR
, MACRO_EXP
, MACRO_EOA
,
668 MACRO_PIR
, MACRO_EOA
,
669 MACRO_IR
, MACRO_EXP
, MACRO_EOA
,
670 MACRO_EXP
, MACRO_EOA
} },
671 { "jmp", emit_jsrjmp
, "jmp",
672 { MACRO_PIR
, MACRO_EXP
, MACRO_EOA
,
673 MACRO_PIR
, MACRO_EOA
,
674 MACRO_IR
, MACRO_EXP
, MACRO_EOA
,
675 MACRO_EXP
, MACRO_EOA
} },
676 { "ret", emit_retjcr
, "ret",
677 { MACRO_IR
, MACRO_EXP
, MACRO_EOA
,
679 MACRO_PIR
, MACRO_EXP
, MACRO_EOA
,
680 MACRO_PIR
, MACRO_EOA
,
681 MACRO_EXP
, MACRO_EOA
,
683 { "jcr", emit_retjcr
, "jcr",
684 { MACRO_IR
, MACRO_EXP
, MACRO_EOA
,
686 MACRO_PIR
, MACRO_EXP
, MACRO_EOA
,
687 MACRO_PIR
, MACRO_EOA
,
688 MACRO_EXP
, MACRO_EOA
,
690 { "jsr_coroutine", emit_retjcr
, "jcr",
691 { MACRO_IR
, MACRO_EXP
, MACRO_EOA
,
693 MACRO_PIR
, MACRO_EXP
, MACRO_EOA
,
694 MACRO_PIR
, MACRO_EOA
,
695 MACRO_EXP
, MACRO_EOA
,
699 static const int alpha_num_macros
700 = sizeof(alpha_macros
) / sizeof(*alpha_macros
);
702 /* Public interface functions */
704 /* This function is called once, at assembler startup time. It sets
705 up all the tables, etc. that the MD part of the assembler will
706 need, that can be determined before arguments are parsed. */
713 /* Verify that X_op field is wide enough. */
716 e
.X_op
= O_alpha_max
;
717 assert (e
.X_op
== O_alpha_max
);
720 /* Create the opcode hash table */
722 alpha_opcode_hash
= hash_new ();
723 for (i
= 0; i
< alpha_num_opcodes
; )
725 const char *name
, *retval
, *slash
;
727 name
= alpha_opcodes
[i
].name
;
728 retval
= hash_insert (alpha_opcode_hash
, name
, (PTR
)&alpha_opcodes
[i
]);
730 as_fatal (_("internal error: can't hash opcode `%s': %s"), name
, retval
);
732 /* Some opcodes include modifiers of various sorts with a "/mod"
733 syntax, like the architecture manual suggests. However, for
734 use with gcc at least, we also need access to those same opcodes
737 if ((slash
= strchr (name
, '/')) != NULL
)
739 char *p
= xmalloc (strlen (name
));
740 memcpy (p
, name
, slash
- name
);
741 strcpy (p
+ (slash
- name
), slash
+ 1);
743 (void)hash_insert(alpha_opcode_hash
, p
, (PTR
)&alpha_opcodes
[i
]);
744 /* Ignore failures -- the opcode table does duplicate some
745 variants in different forms, like "hw_stq" and "hw_st/q". */
748 while (++i
< alpha_num_opcodes
749 && (alpha_opcodes
[i
].name
== name
750 || !strcmp (alpha_opcodes
[i
].name
, name
)))
754 /* Create the macro hash table */
756 alpha_macro_hash
= hash_new ();
757 for (i
= 0; i
< alpha_num_macros
; )
759 const char *name
, *retval
;
761 name
= alpha_macros
[i
].name
;
762 retval
= hash_insert (alpha_macro_hash
, name
, (PTR
)&alpha_macros
[i
]);
764 as_fatal (_("internal error: can't hash macro `%s': %s"), name
, retval
);
766 while (++i
< alpha_num_macros
767 && (alpha_macros
[i
].name
== name
768 || !strcmp (alpha_macros
[i
].name
, name
)))
772 /* Construct symbols for each of the registers */
774 for (i
= 0; i
< 32; ++i
)
777 sprintf(name
, "$%d", i
);
778 alpha_register_table
[i
] = symbol_create(name
, reg_section
, i
,
784 sprintf(name
, "$f%d", i
-32);
785 alpha_register_table
[i
] = symbol_create(name
, reg_section
, i
,
789 /* Create the special symbols and sections we'll be using */
791 /* So .sbss will get used for tiny objects. */
792 bfd_set_gp_size (stdoutput
, g_switch_value
);
795 create_literal_section (".lita", &alpha_lita_section
, &alpha_lita_symbol
);
797 /* For handling the GP, create a symbol that won't be output in the
798 symbol table. We'll edit it out of relocs later. */
799 alpha_gp_symbol
= symbol_create ("<GP value>", alpha_lita_section
, 0x8000,
804 create_literal_section (".link", &alpha_link_section
, &alpha_link_symbol
);
810 segT sec
= subseg_new(".mdebug", (subsegT
)0);
811 bfd_set_section_flags(stdoutput
, sec
, SEC_HAS_CONTENTS
|SEC_READONLY
);
812 bfd_set_section_alignment(stdoutput
, sec
, 3);
816 subseg_set(text_section
, 0);
819 /* The public interface to the instruction assembler. */
825 char opname
[32]; /* current maximum is 13 */
826 expressionS tok
[MAX_INSN_ARGS
];
827 int ntok
, opnamelen
, trunclen
;
829 /* split off the opcode */
830 opnamelen
= strspn (str
, "abcdefghijklmnopqrstuvwxyz_/468");
831 trunclen
= (opnamelen
< sizeof (opname
) - 1
833 : sizeof (opname
) - 1);
834 memcpy (opname
, str
, trunclen
);
835 opname
[trunclen
] = '\0';
837 /* tokenize the rest of the line */
838 if ((ntok
= tokenize_arguments (str
+ opnamelen
, tok
, MAX_INSN_ARGS
)) < 0)
840 as_bad (_("syntax error"));
845 assemble_tokens (opname
, tok
, ntok
, alpha_macros_on
);
848 /* Round up a section's size to the appropriate boundary. */
851 md_section_align (seg
, size
)
855 int align
= bfd_get_section_alignment(stdoutput
, seg
);
856 valueT mask
= ((valueT
)1 << align
) - 1;
858 return (size
+ mask
) & ~mask
;
861 /* Turn a string in input_line_pointer into a floating point constant
862 of type type, and store the appropriate bytes in *litP. The number
863 of LITTLENUMS emitted is stored in *sizeP. An error message is
864 returned, or NULL on OK. */
866 /* Equal to MAX_PRECISION in atof-ieee.c */
867 #define MAX_LITTLENUMS 6
869 extern char *vax_md_atof
PARAMS ((int, char *, int *));
872 md_atof (type
, litP
, sizeP
)
878 LITTLENUM_TYPE words
[MAX_LITTLENUMS
];
879 LITTLENUM_TYPE
*wordP
;
886 /* VAX md_atof doesn't like "G" for some reason. */
890 return vax_md_atof (type
, litP
, sizeP
);
913 return _("Bad call to MD_ATOF()");
915 t
= atof_ieee (input_line_pointer
, type
, words
);
917 input_line_pointer
= t
;
918 *sizeP
= prec
* sizeof (LITTLENUM_TYPE
);
920 for (wordP
= words
+ prec
- 1; prec
--;)
922 md_number_to_chars (litP
, (long) (*wordP
--), sizeof (LITTLENUM_TYPE
));
923 litP
+= sizeof (LITTLENUM_TYPE
);
929 /* Take care of the target-specific command-line options. */
932 md_parse_option (c
, arg
)
939 alpha_nofloats_on
= 1;
951 g_switch_value
= atoi(arg
);
956 const struct cpu_type
*p
;
957 for (p
= cpu_types
; p
->name
; ++p
)
958 if (strcmp(arg
, p
->name
) == 0)
960 alpha_target_name
= p
->name
, alpha_target
= p
->flags
;
963 as_warn(_("Unknown CPU identifier `%s'"), arg
);
969 case '+': /* For g++. Hash any name > 63 chars long. */
970 alpha_flag_hash_long_names
= 1;
973 case 'H': /* Show new symbol after hash truncation */
974 alpha_flag_show_after_trunc
= 1;
977 case 'h': /* for gnu-c/vax compatibility. */
982 alpha_flag_relax
= 1;
987 alpha_flag_mdebug
= 1;
989 case OPTION_NO_MDEBUG
:
990 alpha_flag_mdebug
= 0;
1001 /* Print a description of the command-line options that we accept. */
1004 md_show_usage (stream
)
1009 -32addr treat addresses as 32-bit values\n\
1010 -F lack floating point instructions support\n\
1011 -mev4 | -mev45 | -mev5 | -mev56 | -mpca56 | -mev6 | -mall\n\
1012 specify variant of Alpha architecture\n\
1013 -m21064 | -m21066 | -m21164 | -m21164a | -m21164pc | -m21264\n\
1014 these variants include PALcode opcodes\n"),
1019 -+ hash encode (don't truncate) names longer than 64 characters\n\
1020 -H show new symbol after hash truncation\n"),
1025 /* Decide from what point a pc-relative relocation is relative to,
1026 relative to the pc-relative fixup. Er, relatively speaking. */
1029 md_pcrel_from (fixP
)
1032 valueT addr
= fixP
->fx_where
+ fixP
->fx_frag
->fr_address
;
1033 switch (fixP
->fx_r_type
)
1035 case BFD_RELOC_ALPHA_GPDISP
:
1036 case BFD_RELOC_ALPHA_GPDISP_HI16
:
1037 case BFD_RELOC_ALPHA_GPDISP_LO16
:
1040 return fixP
->fx_size
+ addr
;
1044 /* Attempt to simplify or even eliminate a fixup. The return value is
1045 ignored; perhaps it was once meaningful, but now it is historical.
1046 To indicate that a fixup has been eliminated, set fixP->fx_done.
1048 For ELF, here it is that we transform the GPDISP_HI16 reloc we used
1049 internally into the GPDISP reloc used externally. We had to do
1050 this so that we'd have the GPDISP_LO16 reloc as a tag to compute
1051 the distance to the "lda" instruction for setting the addend to
1055 md_apply_fix (fixP
, valueP
)
1059 char * const fixpos
= fixP
->fx_frag
->fr_literal
+ fixP
->fx_where
;
1060 valueT value
= *valueP
;
1061 unsigned image
, size
;
1063 switch (fixP
->fx_r_type
)
1065 /* The GPDISP relocations are processed internally with a symbol
1066 referring to the current function; we need to drop in a value
1067 which, when added to the address of the start of the function,
1068 gives the desired GP. */
1069 case BFD_RELOC_ALPHA_GPDISP_HI16
:
1071 fixS
*next
= fixP
->fx_next
;
1072 assert (next
->fx_r_type
== BFD_RELOC_ALPHA_GPDISP_LO16
);
1074 fixP
->fx_offset
= (next
->fx_frag
->fr_address
+ next
->fx_where
1075 - fixP
->fx_frag
->fr_address
- fixP
->fx_where
);
1077 value
= (value
- sign_extend_16 (value
)) >> 16;
1080 fixP
->fx_r_type
= BFD_RELOC_ALPHA_GPDISP
;
1084 case BFD_RELOC_ALPHA_GPDISP_LO16
:
1085 value
= sign_extend_16 (value
);
1086 fixP
->fx_offset
= 0;
1092 fixP
->fx_addsy
= section_symbol (now_seg
);
1093 md_number_to_chars (fixpos
, value
, 2);
1098 fixP
->fx_r_type
= BFD_RELOC_16_PCREL
;
1103 fixP
->fx_r_type
= BFD_RELOC_32_PCREL
;
1108 fixP
->fx_r_type
= BFD_RELOC_64_PCREL
;
1111 if (fixP
->fx_pcrel
== 0 && fixP
->fx_addsy
== 0)
1113 md_number_to_chars (fixpos
, value
, size
);
1119 case BFD_RELOC_GPREL32
:
1120 assert (fixP
->fx_subsy
== alpha_gp_symbol
);
1122 /* FIXME: inherited this obliviousness of `value' -- why? */
1123 md_number_to_chars (fixpos
, -alpha_gp_value
, 4);
1127 case BFD_RELOC_GPREL32
:
1131 case BFD_RELOC_23_PCREL_S2
:
1132 if (fixP
->fx_pcrel
== 0 && fixP
->fx_addsy
== 0)
1134 image
= bfd_getl32(fixpos
);
1135 image
= (image
& ~0x1FFFFF) | ((value
>> 2) & 0x1FFFFF);
1140 case BFD_RELOC_ALPHA_HINT
:
1141 if (fixP
->fx_pcrel
== 0 && fixP
->fx_addsy
== 0)
1143 image
= bfd_getl32(fixpos
);
1144 image
= (image
& ~0x3FFF) | ((value
>> 2) & 0x3FFF);
1150 case BFD_RELOC_ALPHA_LITERAL
:
1151 md_number_to_chars (fixpos
, value
, 2);
1154 case BFD_RELOC_ALPHA_LITUSE
:
1158 case BFD_RELOC_ALPHA_ELF_LITERAL
:
1159 case BFD_RELOC_ALPHA_LITUSE
:
1163 case BFD_RELOC_ALPHA_LINKAGE
:
1164 case BFD_RELOC_ALPHA_CODEADDR
:
1170 const struct alpha_operand
*operand
;
1172 if ((int)fixP
->fx_r_type
>= 0)
1173 as_fatal (_("unhandled relocation type %s"),
1174 bfd_get_reloc_code_name (fixP
->fx_r_type
));
1176 assert (-(int)fixP
->fx_r_type
< alpha_num_operands
);
1177 operand
= &alpha_operands
[-(int)fixP
->fx_r_type
];
1179 /* The rest of these fixups only exist internally during symbol
1180 resolution and have no representation in the object file.
1181 Therefore they must be completely resolved as constants. */
1183 if (fixP
->fx_addsy
!= 0
1184 && S_GET_SEGMENT (fixP
->fx_addsy
) != absolute_section
)
1185 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
1186 _("non-absolute expression in constant field"));
1188 image
= bfd_getl32(fixpos
);
1189 image
= insert_operand(image
, operand
, (offsetT
)value
,
1190 fixP
->fx_file
, fixP
->fx_line
);
1195 if (fixP
->fx_addsy
!= 0 || fixP
->fx_pcrel
!= 0)
1199 as_warn_where(fixP
->fx_file
, fixP
->fx_line
,
1200 _("type %d reloc done?\n"), (int)fixP
->fx_r_type
);
1205 md_number_to_chars(fixpos
, image
, 4);
1213 * Look for a register name in the given symbol.
1217 md_undefined_symbol(name
)
1222 int is_float
= 0, num
;
1227 if (name
[1] == 'p' && name
[2] == '\0')
1228 return alpha_register_table
[AXP_REG_FP
];
1233 if (!isdigit(*++name
))
1237 case '0': case '1': case '2': case '3': case '4':
1238 case '5': case '6': case '7': case '8': case '9':
1239 if (name
[1] == '\0')
1240 num
= name
[0] - '0';
1241 else if (name
[0] != '0' && isdigit(name
[1]) && name
[2] == '\0')
1243 num
= (name
[0] - '0') * 10 + name
[1] - '0';
1250 if (!alpha_noat_on
&& num
== AXP_REG_AT
)
1251 as_warn(_("Used $at without \".set noat\""));
1252 return alpha_register_table
[num
+ is_float
];
1255 if (name
[1] == 't' && name
[2] == '\0')
1258 as_warn(_("Used $at without \".set noat\""));
1259 return alpha_register_table
[AXP_REG_AT
];
1264 if (name
[1] == 'p' && name
[2] == '\0')
1265 return alpha_register_table
[alpha_gp_register
];
1269 if (name
[1] == 'p' && name
[2] == '\0')
1270 return alpha_register_table
[AXP_REG_SP
];
1278 /* @@@ Magic ECOFF bits. */
1281 alpha_frob_ecoff_data ()
1284 /* $zero and $f31 are read-only */
1285 alpha_gprmask
&= ~1;
1286 alpha_fprmask
&= ~1;
1290 /* Hook to remember a recently defined label so that the auto-align
1291 code can adjust the symbol after we know what alignment will be
1295 alpha_define_label (sym
)
1298 alpha_insn_label
= sym
;
1301 /* Return true if we must always emit a reloc for a type and false if
1302 there is some hope of resolving it a assembly time. */
1305 alpha_force_relocation (f
)
1308 if (alpha_flag_relax
)
1311 switch (f
->fx_r_type
)
1313 case BFD_RELOC_ALPHA_GPDISP_HI16
:
1314 case BFD_RELOC_ALPHA_GPDISP_LO16
:
1315 case BFD_RELOC_ALPHA_GPDISP
:
1317 case BFD_RELOC_ALPHA_LITERAL
:
1320 case BFD_RELOC_ALPHA_ELF_LITERAL
:
1322 case BFD_RELOC_ALPHA_LITUSE
:
1323 case BFD_RELOC_GPREL32
:
1325 case BFD_RELOC_ALPHA_LINKAGE
:
1326 case BFD_RELOC_ALPHA_CODEADDR
:
1330 case BFD_RELOC_23_PCREL_S2
:
1333 case BFD_RELOC_ALPHA_HINT
:
1337 assert((int)f
->fx_r_type
< 0 && -(int)f
->fx_r_type
< alpha_num_operands
);
1342 /* Return true if we can partially resolve a relocation now. */
1345 alpha_fix_adjustable (f
)
1349 /* Prevent all adjustments to global symbols */
1350 if (S_IS_EXTERN (f
->fx_addsy
) || S_IS_WEAK (f
->fx_addsy
))
1354 /* Are there any relocation types for which we must generate a reloc
1355 but we can adjust the values contained within it? */
1356 switch (f
->fx_r_type
)
1358 case BFD_RELOC_ALPHA_GPDISP_HI16
:
1359 case BFD_RELOC_ALPHA_GPDISP_LO16
:
1360 case BFD_RELOC_ALPHA_GPDISP
:
1364 case BFD_RELOC_ALPHA_LITERAL
:
1367 case BFD_RELOC_ALPHA_ELF_LITERAL
:
1370 case BFD_RELOC_ALPHA_LINKAGE
:
1371 case BFD_RELOC_ALPHA_CODEADDR
:
1375 case BFD_RELOC_ALPHA_LITUSE
:
1378 case BFD_RELOC_GPREL32
:
1379 case BFD_RELOC_23_PCREL_S2
:
1382 case BFD_RELOC_ALPHA_HINT
:
1386 assert ((int)f
->fx_r_type
< 0
1387 && - (int)f
->fx_r_type
< alpha_num_operands
);
1393 /* Generate the BFD reloc to be stuck in the object file from the
1394 fixup used internally in the assembler. */
1397 tc_gen_reloc (sec
, fixp
)
1403 reloc
= (arelent
*) xmalloc (sizeof (arelent
));
1404 reloc
->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
1405 *reloc
->sym_ptr_ptr
= symbol_get_bfdsym (fixp
->fx_addsy
);
1406 reloc
->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
1408 /* Make sure none of our internal relocations make it this far.
1409 They'd better have been fully resolved by this point. */
1410 assert ((int)fixp
->fx_r_type
> 0);
1412 reloc
->howto
= bfd_reloc_type_lookup (stdoutput
, fixp
->fx_r_type
);
1413 if (reloc
->howto
== NULL
)
1415 as_bad_where (fixp
->fx_file
, fixp
->fx_line
,
1416 _("cannot represent `%s' relocation in object file"),
1417 bfd_get_reloc_code_name (fixp
->fx_r_type
));
1421 if (!fixp
->fx_pcrel
!= !reloc
->howto
->pc_relative
)
1423 as_fatal (_("internal error? cannot generate `%s' relocation"),
1424 bfd_get_reloc_code_name (fixp
->fx_r_type
));
1426 assert (!fixp
->fx_pcrel
== !reloc
->howto
->pc_relative
);
1429 if (fixp
->fx_r_type
== BFD_RELOC_ALPHA_LITERAL
)
1431 /* fake out bfd_perform_relocation. sigh */
1432 reloc
->addend
= -alpha_gp_value
;
1437 reloc
->addend
= fixp
->fx_offset
;
1440 * Ohhh, this is ugly. The problem is that if this is a local global
1441 * symbol, the relocation will entirely be performed at link time, not
1442 * at assembly time. bfd_perform_reloc doesn't know about this sort
1443 * of thing, and as a result we need to fake it out here.
1445 if ((S_IS_EXTERN (fixp
->fx_addsy
) || S_IS_WEAK (fixp
->fx_addsy
))
1446 && !S_IS_COMMON(fixp
->fx_addsy
))
1447 reloc
->addend
-= symbol_get_bfdsym (fixp
->fx_addsy
)->value
;
1454 /* Parse a register name off of the input_line and return a register
1455 number. Gets md_undefined_symbol above to do the register name
1458 Only called as a part of processing the ECOFF .frame directive. */
1461 tc_get_register (frame
)
1464 int framereg
= AXP_REG_SP
;
1467 if (*input_line_pointer
== '$')
1469 char *s
= input_line_pointer
;
1470 char c
= get_symbol_end ();
1471 symbolS
*sym
= md_undefined_symbol (s
);
1473 *strchr(s
, '\0') = c
;
1474 if (sym
&& (framereg
= S_GET_VALUE (sym
)) <= 31)
1477 as_warn (_("frame reg expected, using $%d."), framereg
);
1480 note_gpreg (framereg
);
1484 /* This is called before the symbol table is processed. In order to
1485 work with gcc when using mips-tfile, we must keep all local labels.
1486 However, in other cases, we want to discard them. If we were
1487 called with -g, but we didn't see any debugging information, it may
1488 mean that gcc is smuggling debugging information through to
1489 mips-tfile, in which case we must generate all local labels. */
1494 alpha_frob_file_before_adjust ()
1496 if (alpha_debug
!= 0
1497 && ! ecoff_debugging_seen
)
1498 flag_keep_locals
= 1;
1501 #endif /* OBJ_ECOFF */
1503 /* Parse the arguments to an opcode. */
1506 tokenize_arguments (str
, tok
, ntok
)
1511 expressionS
*end_tok
= tok
+ ntok
;
1512 char *old_input_line_pointer
;
1513 int saw_comma
= 0, saw_arg
= 0;
1515 memset (tok
, 0, sizeof (*tok
) * ntok
);
1517 /* Save and restore input_line_pointer around this function */
1518 old_input_line_pointer
= input_line_pointer
;
1519 input_line_pointer
= str
;
1521 while (tok
< end_tok
&& *input_line_pointer
)
1524 switch (*input_line_pointer
)
1530 ++input_line_pointer
;
1531 if (saw_comma
|| !saw_arg
)
1538 char *hold
= input_line_pointer
++;
1540 /* First try for parenthesized register ... */
1542 if (*input_line_pointer
== ')' && tok
->X_op
== O_register
)
1544 tok
->X_op
= (saw_comma
? O_cpregister
: O_pregister
);
1547 ++input_line_pointer
;
1552 /* ... then fall through to plain expression */
1553 input_line_pointer
= hold
;
1557 if (saw_arg
&& !saw_comma
)
1560 if (tok
->X_op
== O_illegal
|| tok
->X_op
== O_absent
)
1573 input_line_pointer
= old_input_line_pointer
;
1574 return ntok
- (end_tok
- tok
);
1577 input_line_pointer
= old_input_line_pointer
;
1581 /* Search forward through all variants of an opcode looking for a
1584 static const struct alpha_opcode
*
1585 find_opcode_match(first_opcode
, tok
, pntok
, pcpumatch
)
1586 const struct alpha_opcode
*first_opcode
;
1587 const expressionS
*tok
;
1591 const struct alpha_opcode
*opcode
= first_opcode
;
1593 int got_cpu_match
= 0;
1597 const unsigned char *opidx
;
1600 /* Don't match opcodes that don't exist on this architecture */
1601 if (!(opcode
->flags
& alpha_target
))
1606 for (opidx
= opcode
->operands
; *opidx
; ++opidx
)
1608 const struct alpha_operand
*operand
= &alpha_operands
[*opidx
];
1610 /* only take input from real operands */
1611 if (operand
->flags
& AXP_OPERAND_FAKE
)
1614 /* when we expect input, make sure we have it */
1617 if ((operand
->flags
& AXP_OPERAND_OPTIONAL_MASK
) == 0)
1622 /* match operand type with expression type */
1623 switch (operand
->flags
& AXP_OPERAND_TYPECHECK_MASK
)
1625 case AXP_OPERAND_IR
:
1626 if (tok
[tokidx
].X_op
!= O_register
1627 || !is_ir_num(tok
[tokidx
].X_add_number
))
1630 case AXP_OPERAND_FPR
:
1631 if (tok
[tokidx
].X_op
!= O_register
1632 || !is_fpr_num(tok
[tokidx
].X_add_number
))
1635 case AXP_OPERAND_IR
|AXP_OPERAND_PARENS
:
1636 if (tok
[tokidx
].X_op
!= O_pregister
1637 || !is_ir_num(tok
[tokidx
].X_add_number
))
1640 case AXP_OPERAND_IR
|AXP_OPERAND_PARENS
|AXP_OPERAND_COMMA
:
1641 if (tok
[tokidx
].X_op
!= O_cpregister
1642 || !is_ir_num(tok
[tokidx
].X_add_number
))
1646 case AXP_OPERAND_RELATIVE
:
1647 case AXP_OPERAND_SIGNED
:
1648 case AXP_OPERAND_UNSIGNED
:
1649 switch (tok
[tokidx
].X_op
)
1664 /* everything else should have been fake */
1670 /* possible match -- did we use all of our input? */
1679 while (++opcode
-alpha_opcodes
< alpha_num_opcodes
1680 && !strcmp(opcode
->name
, first_opcode
->name
));
1683 *pcpumatch
= got_cpu_match
;
1688 /* Search forward through all variants of a macro looking for a syntax
1691 static const struct alpha_macro
*
1692 find_macro_match(first_macro
, tok
, pntok
)
1693 const struct alpha_macro
*first_macro
;
1694 const expressionS
*tok
;
1697 const struct alpha_macro
*macro
= first_macro
;
1702 const enum alpha_macro_arg
*arg
= macro
->argsets
;
1717 if (tokidx
>= ntok
|| tok
[tokidx
].X_op
!= O_register
1718 || !is_ir_num(tok
[tokidx
].X_add_number
))
1723 if (tokidx
>= ntok
|| tok
[tokidx
].X_op
!= O_pregister
1724 || !is_ir_num(tok
[tokidx
].X_add_number
))
1729 if (tokidx
>= ntok
|| tok
[tokidx
].X_op
!= O_cpregister
1730 || !is_ir_num(tok
[tokidx
].X_add_number
))
1735 if (tokidx
>= ntok
|| tok
[tokidx
].X_op
!= O_register
1736 || !is_fpr_num(tok
[tokidx
].X_add_number
))
1744 switch (tok
[tokidx
].X_op
)
1760 while (*arg
!= MACRO_EOA
)
1768 while (++macro
-alpha_macros
< alpha_num_macros
1769 && !strcmp(macro
->name
, first_macro
->name
));
1774 /* Insert an operand value into an instruction. */
1777 insert_operand(insn
, operand
, val
, file
, line
)
1779 const struct alpha_operand
*operand
;
1784 if (operand
->bits
!= 32 && !(operand
->flags
& AXP_OPERAND_NOOVERFLOW
))
1788 if (operand
->flags
& AXP_OPERAND_SIGNED
)
1790 max
= (1 << (operand
->bits
- 1)) - 1;
1791 min
= -(1 << (operand
->bits
- 1));
1795 max
= (1 << operand
->bits
) - 1;
1799 if (val
< min
|| val
> max
)
1802 _("operand out of range (%s not between %d and %d)");
1803 char buf
[sizeof (val
) * 3 + 2];
1805 sprint_value(buf
, val
);
1807 as_warn_where(file
, line
, err
, buf
, min
, max
);
1809 as_warn(err
, buf
, min
, max
);
1813 if (operand
->insert
)
1815 const char *errmsg
= NULL
;
1817 insn
= (*operand
->insert
) (insn
, val
, &errmsg
);
1822 insn
|= ((val
& ((1 << operand
->bits
) - 1)) << operand
->shift
);
1828 * Turn an opcode description and a set of arguments into
1829 * an instruction and a fixup.
1833 assemble_insn(opcode
, tok
, ntok
, insn
)
1834 const struct alpha_opcode
*opcode
;
1835 const expressionS
*tok
;
1837 struct alpha_insn
*insn
;
1839 const unsigned char *argidx
;
1843 memset (insn
, 0, sizeof (*insn
));
1844 image
= opcode
->opcode
;
1846 for (argidx
= opcode
->operands
; *argidx
; ++argidx
)
1848 const struct alpha_operand
*operand
= &alpha_operands
[*argidx
];
1849 const expressionS
*t
;
1851 if (operand
->flags
& AXP_OPERAND_FAKE
)
1853 /* fake operands take no value and generate no fixup */
1854 image
= insert_operand(image
, operand
, 0, NULL
, 0);
1860 switch (operand
->flags
& AXP_OPERAND_OPTIONAL_MASK
)
1862 case AXP_OPERAND_DEFAULT_FIRST
:
1865 case AXP_OPERAND_DEFAULT_SECOND
:
1868 case AXP_OPERAND_DEFAULT_ZERO
:
1870 static const expressionS zero_exp
= { 0, 0, 0, O_constant
, 1 };
1886 image
= insert_operand(image
, operand
, regno(t
->X_add_number
),
1891 image
= insert_operand(image
, operand
, t
->X_add_number
, NULL
, 0);
1896 struct alpha_fixup
*fixup
;
1898 if (insn
->nfixups
>= MAX_INSN_FIXUPS
)
1899 as_fatal(_("too many fixups"));
1901 fixup
= &insn
->fixups
[insn
->nfixups
++];
1904 fixup
->reloc
= operand
->default_reloc
;
1914 * Actually output an instruction with its fixup.
1919 struct alpha_insn
*insn
;
1924 /* Take care of alignment duties */
1925 if (alpha_auto_align_on
&& alpha_current_align
< 2)
1926 alpha_align (2, (char *) NULL
, alpha_insn_label
, 0);
1927 if (alpha_current_align
> 2)
1928 alpha_current_align
= 2;
1929 alpha_insn_label
= NULL
;
1931 /* Write out the instruction. */
1933 md_number_to_chars (f
, insn
->insn
, 4);
1935 /* Apply the fixups in order */
1936 for (i
= 0; i
< insn
->nfixups
; ++i
)
1938 const struct alpha_operand
*operand
;
1939 struct alpha_fixup
*fixup
= &insn
->fixups
[i
];
1943 /* Some fixups are only used internally and so have no howto */
1944 if ((int)fixup
->reloc
< 0)
1946 operand
= &alpha_operands
[-(int)fixup
->reloc
];
1948 pcrel
= ((operand
->flags
& AXP_OPERAND_RELATIVE
) != 0);
1951 /* These relocation types are only used internally. */
1952 else if (fixup
->reloc
== BFD_RELOC_ALPHA_GPDISP_HI16
1953 || fixup
->reloc
== BFD_RELOC_ALPHA_GPDISP_LO16
)
1955 size
= 2, pcrel
= 0;
1960 reloc_howto_type
*reloc_howto
1961 = bfd_reloc_type_lookup (stdoutput
, fixup
->reloc
);
1962 assert (reloc_howto
);
1964 size
= bfd_get_reloc_size (reloc_howto
);
1965 pcrel
= reloc_howto
->pc_relative
;
1967 assert (size
>= 1 && size
<= 4);
1969 fixP
= fix_new_exp (frag_now
, f
- frag_now
->fr_literal
, size
,
1970 &fixup
->exp
, pcrel
, fixup
->reloc
);
1972 /* Turn off complaints that the addend is too large for some fixups */
1973 switch (fixup
->reloc
)
1975 case BFD_RELOC_ALPHA_GPDISP_LO16
:
1977 case BFD_RELOC_ALPHA_LITERAL
:
1980 case BFD_RELOC_ALPHA_ELF_LITERAL
:
1982 case BFD_RELOC_GPREL32
:
1983 fixP
->fx_no_overflow
= 1;
1987 if ((int)fixup
->reloc
< 0)
1989 if (operand
->flags
& AXP_OPERAND_NOOVERFLOW
)
1990 fixP
->fx_no_overflow
= 1;
1997 /* Given an opcode name and a pre-tokenized set of arguments, assemble
1998 the insn, but do not emit it.
2000 Note that this implies no macros allowed, since we can't store more
2001 than one insn in an insn structure. */
2004 assemble_tokens_to_insn(opname
, tok
, ntok
, insn
)
2006 const expressionS
*tok
;
2008 struct alpha_insn
*insn
;
2010 const struct alpha_opcode
*opcode
;
2012 /* search opcodes */
2013 opcode
= (const struct alpha_opcode
*) hash_find (alpha_opcode_hash
, opname
);
2017 opcode
= find_opcode_match (opcode
, tok
, &ntok
, &cpumatch
);
2020 assemble_insn (opcode
, tok
, ntok
, insn
);
2024 as_bad (_("inappropriate arguments for opcode `%s'"), opname
);
2026 as_bad (_("opcode `%s' not supported for target %s"), opname
,
2030 as_bad (_("unknown opcode `%s'"), opname
);
2033 /* Given an opcode name and a pre-tokenized set of arguments, take the
2034 opcode all the way through emission. */
2037 assemble_tokens (opname
, tok
, ntok
, local_macros_on
)
2039 const expressionS
*tok
;
2041 int local_macros_on
;
2043 int found_something
= 0;
2044 const struct alpha_opcode
*opcode
;
2045 const struct alpha_macro
*macro
;
2049 if (local_macros_on
)
2051 macro
= ((const struct alpha_macro
*)
2052 hash_find (alpha_macro_hash
, opname
));
2055 found_something
= 1;
2056 macro
= find_macro_match (macro
, tok
, &ntok
);
2059 (*macro
->emit
) (tok
, ntok
, macro
->arg
);
2065 /* search opcodes */
2066 opcode
= (const struct alpha_opcode
*) hash_find (alpha_opcode_hash
, opname
);
2069 found_something
= 1;
2070 opcode
= find_opcode_match (opcode
, tok
, &ntok
, &cpumatch
);
2073 struct alpha_insn insn
;
2074 assemble_insn (opcode
, tok
, ntok
, &insn
);
2080 if (found_something
)
2082 as_bad (_("inappropriate arguments for opcode `%s'"), opname
);
2084 as_bad (_("opcode `%s' not supported for target %s"), opname
,
2087 as_bad (_("unknown opcode `%s'"), opname
);
2091 /* Some instruction sets indexed by lg(size) */
2092 static const char * const sextX_op
[] = { "sextb", "sextw", "sextl", NULL
};
2093 static const char * const insXl_op
[] = { "insbl", "inswl", "insll", "insql" };
2094 static const char * const insXh_op
[] = { NULL
, "inswh", "inslh", "insqh" };
2095 static const char * const extXl_op
[] = { "extbl", "extwl", "extll", "extql" };
2096 static const char * const extXh_op
[] = { NULL
, "extwh", "extlh", "extqh" };
2097 static const char * const mskXl_op
[] = { "mskbl", "mskwl", "mskll", "mskql" };
2098 static const char * const mskXh_op
[] = { NULL
, "mskwh", "msklh", "mskqh" };
2099 static const char * const stX_op
[] = { "stb", "stw", "stl", "stq" };
2100 static const char * const ldX_op
[] = { "ldb", "ldw", "ldll", "ldq" };
2101 static const char * const ldXu_op
[] = { "ldbu", "ldwu", NULL
, NULL
};
2103 /* Implement the ldgp macro. */
2106 emit_ldgp (tok
, ntok
, unused
)
2107 const expressionS
*tok
;
2114 #if defined(OBJ_ECOFF) || defined(OBJ_ELF)
2115 /* from "ldgp r1,n(r2)", generate "ldah r1,X(R2); lda r1,Y(r1)"
2116 with appropriate constants and relocations. */
2117 struct alpha_insn insn
;
2118 expressionS newtok
[3];
2122 if (regno (tok
[2].X_add_number
) == AXP_REG_PV
)
2123 ecoff_set_gp_prolog_size (0);
2127 set_tok_const (newtok
[1], 0);
2130 assemble_tokens_to_insn ("ldah", newtok
, 3, &insn
);
2135 if (addend
.X_op
!= O_constant
)
2136 as_bad (_("can not resolve expression"));
2137 addend
.X_op
= O_symbol
;
2138 addend
.X_add_symbol
= alpha_gp_symbol
;
2142 insn
.fixups
[0].exp
= addend
;
2143 insn
.fixups
[0].reloc
= BFD_RELOC_ALPHA_GPDISP_HI16
;
2147 set_tok_preg (newtok
[2], tok
[0].X_add_number
);
2149 assemble_tokens_to_insn ("lda", newtok
, 3, &insn
);
2152 addend
.X_add_number
+= 4;
2156 insn
.fixups
[0].exp
= addend
;
2157 insn
.fixups
[0].reloc
= BFD_RELOC_ALPHA_GPDISP_LO16
;
2160 #endif /* OBJ_ECOFF || OBJ_ELF */
2165 /* Add symbol+addend to link pool.
2166 Return offset from basesym to entry in link pool.
2168 Add new fixup only if offset isn't 16bit. */
2171 add_to_link_pool (basesym
, sym
, addend
)
2176 segT current_section
= now_seg
;
2177 int current_subsec
= now_subseg
;
2179 bfd_reloc_code_real_type reloc_type
;
2181 segment_info_type
*seginfo
= seg_info (alpha_link_section
);
2184 offset
= -basesym
->sy_obj
;
2186 /* @@ This assumes all entries in a given section will be of the same
2187 size... Probably correct, but unwise to rely on. */
2188 /* This must always be called with the same subsegment. */
2190 if (seginfo
->frchainP
)
2191 for (fixp
= seginfo
->frchainP
->fix_root
;
2192 fixp
!= (fixS
*) NULL
;
2193 fixp
= fixp
->fx_next
, offset
+= 8)
2195 if (fixp
->fx_addsy
== sym
&& fixp
->fx_offset
== addend
)
2197 if (range_signed_16 (offset
))
2204 /* Not found in 16bit signed range. */
2206 subseg_set (alpha_link_section
, 0);
2210 fix_new (frag_now
, p
- frag_now
->fr_literal
, 8, sym
, addend
, 0,
2213 subseg_set (current_section
, current_subsec
);
2214 seginfo
->literal_pool_size
+= 8;
2218 #endif /* OBJ_EVAX */
2220 /* Load a (partial) expression into a target register.
2222 If poffset is not null, after the call it will either contain
2223 O_constant 0, or a 16-bit offset appropriate for any MEM format
2224 instruction. In addition, pbasereg will be modified to point to
2225 the base register to use in that MEM format instruction.
2227 In any case, *pbasereg should contain a base register to add to the
2228 expression. This will normally be either AXP_REG_ZERO or
2229 alpha_gp_register. Symbol addresses will always be loaded via $gp,
2230 so "foo($0)" is interpreted as adding the address of foo to $0;
2231 i.e. "ldq $targ, LIT($gp); addq $targ, $0, $targ". Odd, perhaps,
2232 but this is what OSF/1 does.
2234 Finally, the return value is true if the calling macro may emit a
2235 LITUSE reloc if otherwise appropriate. */
2238 load_expression (targreg
, exp
, pbasereg
, poffset
)
2240 const expressionS
*exp
;
2242 expressionS
*poffset
;
2244 int emit_lituse
= 0;
2245 offsetT addend
= exp
->X_add_number
;
2246 int basereg
= *pbasereg
;
2247 struct alpha_insn insn
;
2248 expressionS newtok
[3];
2257 /* attempt to reduce .lit load by splitting the offset from
2258 its symbol when possible, but don't create a situation in
2260 if (!range_signed_32 (addend
) &&
2261 (alpha_noat_on
|| targreg
== AXP_REG_AT
))
2263 lit
= add_to_literal_pool (exp
->X_add_symbol
, addend
,
2264 alpha_lita_section
, 8);
2269 lit
= add_to_literal_pool (exp
->X_add_symbol
, 0,
2270 alpha_lita_section
, 8);
2274 as_fatal (_("overflow in literal (.lita) table"));
2276 /* emit "ldq r, lit(gp)" */
2278 if (basereg
!= alpha_gp_register
&& targreg
== basereg
)
2281 as_bad (_("macro requires $at register while noat in effect"));
2282 if (targreg
== AXP_REG_AT
)
2283 as_bad (_("macro requires $at while $at in use"));
2285 set_tok_reg (newtok
[0], AXP_REG_AT
);
2288 set_tok_reg (newtok
[0], targreg
);
2289 set_tok_sym (newtok
[1], alpha_lita_symbol
, lit
);
2290 set_tok_preg (newtok
[2], alpha_gp_register
);
2292 assemble_tokens_to_insn ("ldq", newtok
, 3, &insn
);
2294 assert (insn
.nfixups
== 1);
2295 insn
.fixups
[0].reloc
= BFD_RELOC_ALPHA_LITERAL
;
2296 #endif /* OBJ_ECOFF */
2298 /* emit "ldq r, gotoff(gp)" */
2300 if (basereg
!= alpha_gp_register
&& targreg
== basereg
)
2303 as_bad (_("macro requires $at register while noat in effect"));
2304 if (targreg
== AXP_REG_AT
)
2305 as_bad (_("macro requires $at while $at in use"));
2307 set_tok_reg (newtok
[0], AXP_REG_AT
);
2310 set_tok_reg (newtok
[0], targreg
);
2312 /* XXX: Disable this .got minimizing optimization so that we can get
2313 better instruction offset knowledge in the compiler. This happens
2314 very infrequently anyway. */
2315 if (1 || (!range_signed_32 (addend
)
2316 && (alpha_noat_on
|| targreg
== AXP_REG_AT
)))
2323 set_tok_sym (newtok
[1], exp
->X_add_symbol
, 0);
2326 set_tok_preg (newtok
[2], alpha_gp_register
);
2328 assemble_tokens_to_insn ("ldq", newtok
, 3, &insn
);
2330 assert (insn
.nfixups
== 1);
2331 insn
.fixups
[0].reloc
= BFD_RELOC_ALPHA_ELF_LITERAL
;
2332 #endif /* OBJ_ELF */
2336 /* Find symbol or symbol pointer in link section. */
2338 if (exp
->X_add_symbol
== alpha_evax_proc
.symbol
)
2340 if (range_signed_16 (addend
))
2342 set_tok_reg (newtok
[0], targreg
);
2343 set_tok_const (newtok
[1], addend
);
2344 set_tok_preg (newtok
[2], basereg
);
2345 assemble_tokens_to_insn ("lda", newtok
, 3, &insn
);
2350 set_tok_reg (newtok
[0], targreg
);
2351 set_tok_const (newtok
[1], 0);
2352 set_tok_preg (newtok
[2], basereg
);
2353 assemble_tokens_to_insn ("lda", newtok
, 3, &insn
);
2358 if (!range_signed_32 (addend
))
2360 link
= add_to_link_pool (alpha_evax_proc
.symbol
,
2361 exp
->X_add_symbol
, addend
);
2366 link
= add_to_link_pool (alpha_evax_proc
.symbol
,
2367 exp
->X_add_symbol
, 0);
2369 set_tok_reg (newtok
[0], targreg
);
2370 set_tok_const (newtok
[1], link
);
2371 set_tok_preg (newtok
[2], basereg
);
2372 assemble_tokens_to_insn ("ldq", newtok
, 3, &insn
);
2374 #endif /* OBJ_EVAX */
2381 if (basereg
!= alpha_gp_register
&& basereg
!= AXP_REG_ZERO
)
2383 /* emit "addq r, base, r" */
2385 set_tok_reg (newtok
[1], basereg
);
2386 set_tok_reg (newtok
[2], targreg
);
2387 assemble_tokens ("addq", newtok
, 3, 0);
2399 /* Assume that this difference expression will be resolved to an
2400 absolute value and that that value will fit in 16 bits. */
2402 set_tok_reg (newtok
[0], targreg
);
2404 set_tok_preg (newtok
[2], basereg
);
2405 assemble_tokens ("lda", newtok
, 3, 0);
2408 set_tok_const (*poffset
, 0);
2412 if (exp
->X_add_number
> 0)
2413 as_bad (_("bignum invalid; zero assumed"));
2415 as_bad (_("floating point number invalid; zero assumed"));
2420 as_bad (_("can't handle expression"));
2425 if (!range_signed_32 (addend
))
2429 /* for 64-bit addends, just put it in the literal pool */
2432 /* emit "ldq targreg, lit(basereg)" */
2433 lit
= add_to_link_pool (alpha_evax_proc
.symbol
,
2434 section_symbol (absolute_section
), addend
);
2435 set_tok_reg (newtok
[0], targreg
);
2436 set_tok_const (newtok
[1], lit
);
2437 set_tok_preg (newtok
[2], alpha_gp_register
);
2438 assemble_tokens ("ldq", newtok
, 3, 0);
2441 if (alpha_lit8_section
== NULL
)
2443 create_literal_section (".lit8",
2444 &alpha_lit8_section
,
2445 &alpha_lit8_symbol
);
2448 alpha_lit8_literal
= add_to_literal_pool (alpha_lit8_symbol
, 0x8000,
2449 alpha_lita_section
, 8);
2450 if (alpha_lit8_literal
>= 0x8000)
2451 as_fatal (_("overflow in literal (.lita) table"));
2455 lit
= add_to_literal_pool (NULL
, addend
, alpha_lit8_section
, 8) - 0x8000;
2457 as_fatal (_("overflow in literal (.lit8) table"));
2459 /* emit "lda litreg, .lit8+0x8000" */
2461 if (targreg
== basereg
)
2464 as_bad (_("macro requires $at register while noat in effect"));
2465 if (targreg
== AXP_REG_AT
)
2466 as_bad (_("macro requires $at while $at in use"));
2468 set_tok_reg (newtok
[0], AXP_REG_AT
);
2471 set_tok_reg (newtok
[0], targreg
);
2473 set_tok_sym (newtok
[1], alpha_lita_symbol
, alpha_lit8_literal
);
2476 set_tok_sym (newtok
[1], alpha_lit8_symbol
, 0x8000);
2478 set_tok_preg (newtok
[2], alpha_gp_register
);
2480 assemble_tokens_to_insn ("ldq", newtok
, 3, &insn
);
2482 assert (insn
.nfixups
== 1);
2484 insn
.fixups
[0].reloc
= BFD_RELOC_ALPHA_LITERAL
;
2487 insn
.fixups
[0].reloc
= BFD_RELOC_ALPHA_ELF_LITERAL
;
2492 /* emit "ldq litreg, lit(litreg)" */
2494 set_tok_const (newtok
[1], lit
);
2495 set_tok_preg (newtok
[2], newtok
[0].X_add_number
);
2497 assemble_tokens_to_insn ("ldq", newtok
, 3, &insn
);
2499 assert (insn
.nfixups
< MAX_INSN_FIXUPS
);
2500 if (insn
.nfixups
> 0)
2502 memmove (&insn
.fixups
[1], &insn
.fixups
[0],
2503 sizeof(struct alpha_fixup
) * insn
.nfixups
);
2506 insn
.fixups
[0].reloc
= BFD_RELOC_ALPHA_LITUSE
;
2507 insn
.fixups
[0].exp
.X_op
= O_symbol
;
2508 insn
.fixups
[0].exp
.X_add_symbol
= section_symbol (now_seg
);
2509 insn
.fixups
[0].exp
.X_add_number
= 1;
2514 /* emit "addq litreg, base, target" */
2516 if (basereg
!= AXP_REG_ZERO
)
2518 set_tok_reg (newtok
[1], basereg
);
2519 set_tok_reg (newtok
[2], targreg
);
2520 assemble_tokens ("addq", newtok
, 3, 0);
2522 #endif /* !OBJ_EVAX */
2525 set_tok_const (*poffset
, 0);
2526 *pbasereg
= targreg
;
2530 offsetT low
, high
, extra
, tmp
;
2532 /* for 32-bit operands, break up the addend */
2534 low
= sign_extend_16 (addend
);
2536 high
= sign_extend_16 (tmp
>> 16);
2538 if (tmp
- (high
<< 16))
2542 high
= sign_extend_16 (tmp
>> 16);
2547 set_tok_reg (newtok
[0], targreg
);
2548 set_tok_preg (newtok
[2], basereg
);
2552 /* emit "ldah r, extra(r) */
2553 set_tok_const (newtok
[1], extra
);
2554 assemble_tokens ("ldah", newtok
, 3, 0);
2555 set_tok_preg (newtok
[2], basereg
= targreg
);
2560 /* emit "ldah r, high(r) */
2561 set_tok_const (newtok
[1], high
);
2562 assemble_tokens ("ldah", newtok
, 3, 0);
2564 set_tok_preg (newtok
[2], basereg
);
2567 if ((low
&& !poffset
) || (!poffset
&& basereg
!= targreg
))
2569 /* emit "lda r, low(base)" */
2570 set_tok_const (newtok
[1], low
);
2571 assemble_tokens ("lda", newtok
, 3, 0);
2577 set_tok_const (*poffset
, low
);
2578 *pbasereg
= basereg
;
2584 /* The lda macro differs from the lda instruction in that it handles
2585 most simple expressions, particualrly symbol address loads and
2589 emit_lda (tok
, ntok
, unused
)
2590 const expressionS
*tok
;
2597 basereg
= (tok
[1].X_op
== O_constant
? AXP_REG_ZERO
: alpha_gp_register
);
2599 basereg
= tok
[2].X_add_number
;
2601 (void) load_expression (tok
[0].X_add_number
, &tok
[1], &basereg
, NULL
);
2604 /* The ldah macro differs from the ldah instruction in that it has $31
2605 as an implied base register. */
2608 emit_ldah (tok
, ntok
, unused
)
2609 const expressionS
*tok
;
2613 expressionS newtok
[3];
2617 set_tok_preg (newtok
[2], AXP_REG_ZERO
);
2619 assemble_tokens ("ldah", newtok
, 3, 0);
2622 /* Handle all "simple" integer register loads -- ldq, ldq_l, ldq_u,
2623 etc. They differ from the real instructions in that they do simple
2624 expressions like the lda macro. */
2627 emit_ir_load (tok
, ntok
, opname
)
2628 const expressionS
*tok
;
2632 int basereg
, lituse
;
2633 expressionS newtok
[3];
2634 struct alpha_insn insn
;
2637 basereg
= (tok
[1].X_op
== O_constant
? AXP_REG_ZERO
: alpha_gp_register
);
2639 basereg
= tok
[2].X_add_number
;
2641 lituse
= load_expression (tok
[0].X_add_number
, &tok
[1], &basereg
,
2645 set_tok_preg (newtok
[2], basereg
);
2647 assemble_tokens_to_insn ((const char *)opname
, newtok
, 3, &insn
);
2651 assert (insn
.nfixups
< MAX_INSN_FIXUPS
);
2652 if (insn
.nfixups
> 0)
2654 memmove (&insn
.fixups
[1], &insn
.fixups
[0],
2655 sizeof(struct alpha_fixup
) * insn
.nfixups
);
2658 insn
.fixups
[0].reloc
= BFD_RELOC_ALPHA_LITUSE
;
2659 insn
.fixups
[0].exp
.X_op
= O_symbol
;
2660 insn
.fixups
[0].exp
.X_add_symbol
= section_symbol (now_seg
);
2661 insn
.fixups
[0].exp
.X_add_number
= 1;
2667 /* Handle fp register loads, and both integer and fp register stores.
2668 Again, we handle simple expressions. */
2671 emit_loadstore (tok
, ntok
, opname
)
2672 const expressionS
*tok
;
2676 int basereg
, lituse
;
2677 expressionS newtok
[3];
2678 struct alpha_insn insn
;
2681 basereg
= (tok
[1].X_op
== O_constant
? AXP_REG_ZERO
: alpha_gp_register
);
2683 basereg
= tok
[2].X_add_number
;
2685 if (tok
[1].X_op
!= O_constant
|| !range_signed_16(tok
[1].X_add_number
))
2688 as_bad (_("macro requires $at register while noat in effect"));
2690 lituse
= load_expression (AXP_REG_AT
, &tok
[1], &basereg
, &newtok
[1]);
2699 set_tok_preg (newtok
[2], basereg
);
2701 assemble_tokens_to_insn ((const char *)opname
, newtok
, 3, &insn
);
2705 assert (insn
.nfixups
< MAX_INSN_FIXUPS
);
2706 if (insn
.nfixups
> 0)
2708 memmove (&insn
.fixups
[1], &insn
.fixups
[0],
2709 sizeof(struct alpha_fixup
) * insn
.nfixups
);
2712 insn
.fixups
[0].reloc
= BFD_RELOC_ALPHA_LITUSE
;
2713 insn
.fixups
[0].exp
.X_op
= O_symbol
;
2714 insn
.fixups
[0].exp
.X_add_symbol
= section_symbol (now_seg
);
2715 insn
.fixups
[0].exp
.X_add_number
= 1;
2721 /* Load a half-word or byte as an unsigned value. */
2724 emit_ldXu (tok
, ntok
, vlgsize
)
2725 const expressionS
*tok
;
2729 if (alpha_target
& AXP_OPCODE_BWX
)
2730 emit_ir_load (tok
, ntok
, ldXu_op
[(long)vlgsize
]);
2733 expressionS newtok
[3];
2736 as_bad (_("macro requires $at register while noat in effect"));
2738 /* emit "lda $at, exp" */
2740 memcpy (newtok
, tok
, sizeof (expressionS
) * ntok
);
2741 newtok
[0].X_add_number
= AXP_REG_AT
;
2742 assemble_tokens ("lda", newtok
, ntok
, 1);
2744 /* emit "ldq_u targ, 0($at)" */
2747 set_tok_const (newtok
[1], 0);
2748 set_tok_preg (newtok
[2], AXP_REG_AT
);
2749 assemble_tokens ("ldq_u", newtok
, 3, 1);
2751 /* emit "extXl targ, $at, targ" */
2753 set_tok_reg (newtok
[1], AXP_REG_AT
);
2754 newtok
[2] = newtok
[0];
2755 assemble_tokens (extXl_op
[(long)vlgsize
], newtok
, 3, 1);
2759 /* Load a half-word or byte as a signed value. */
2762 emit_ldX (tok
, ntok
, vlgsize
)
2763 const expressionS
*tok
;
2767 emit_ldXu (tok
, ntok
, vlgsize
);
2768 assemble_tokens (sextX_op
[(long)vlgsize
], tok
, 1, 1);
2771 /* Load an integral value from an unaligned address as an unsigned
2775 emit_uldXu (tok
, ntok
, vlgsize
)
2776 const expressionS
*tok
;
2780 long lgsize
= (long)vlgsize
;
2781 expressionS newtok
[3];
2784 as_bad (_("macro requires $at register while noat in effect"));
2786 /* emit "lda $at, exp" */
2788 memcpy (newtok
, tok
, sizeof (expressionS
) * ntok
);
2789 newtok
[0].X_add_number
= AXP_REG_AT
;
2790 assemble_tokens ("lda", newtok
, ntok
, 1);
2792 /* emit "ldq_u $t9, 0($at)" */
2794 set_tok_reg (newtok
[0], AXP_REG_T9
);
2795 set_tok_const (newtok
[1], 0);
2796 set_tok_preg (newtok
[2], AXP_REG_AT
);
2797 assemble_tokens ("ldq_u", newtok
, 3, 1);
2799 /* emit "ldq_u $t10, size-1($at)" */
2801 set_tok_reg (newtok
[0], AXP_REG_T10
);
2802 set_tok_const (newtok
[1], (1<<lgsize
)-1);
2803 assemble_tokens ("ldq_u", newtok
, 3, 1);
2805 /* emit "extXl $t9, $at, $t9" */
2807 set_tok_reg (newtok
[0], AXP_REG_T9
);
2808 set_tok_reg (newtok
[1], AXP_REG_AT
);
2809 set_tok_reg (newtok
[2], AXP_REG_T9
);
2810 assemble_tokens (extXl_op
[lgsize
], newtok
, 3, 1);
2812 /* emit "extXh $t10, $at, $t10" */
2814 set_tok_reg (newtok
[0], AXP_REG_T10
);
2815 set_tok_reg (newtok
[2], AXP_REG_T10
);
2816 assemble_tokens (extXh_op
[lgsize
], newtok
, 3, 1);
2818 /* emit "or $t9, $t10, targ" */
2820 set_tok_reg (newtok
[0], AXP_REG_T9
);
2821 set_tok_reg (newtok
[1], AXP_REG_T10
);
2823 assemble_tokens ("or", newtok
, 3, 1);
2826 /* Load an integral value from an unaligned address as a signed value.
2827 Note that quads should get funneled to the unsigned load since we
2828 don't have to do the sign extension. */
2831 emit_uldX (tok
, ntok
, vlgsize
)
2832 const expressionS
*tok
;
2836 emit_uldXu (tok
, ntok
, vlgsize
);
2837 assemble_tokens (sextX_op
[(long)vlgsize
], tok
, 1, 1);
2840 /* Implement the ldil macro. */
2843 emit_ldil (tok
, ntok
, unused
)
2844 const expressionS
*tok
;
2848 expressionS newtok
[2];
2850 memcpy (newtok
, tok
, sizeof(newtok
));
2851 newtok
[1].X_add_number
= sign_extend_32 (tok
[1].X_add_number
);
2853 assemble_tokens ("lda", newtok
, ntok
, 1);
2856 /* Store a half-word or byte. */
2859 emit_stX (tok
, ntok
, vlgsize
)
2860 const expressionS
*tok
;
2864 int lgsize
= (int)(long)vlgsize
;
2866 if (alpha_target
& AXP_OPCODE_BWX
)
2867 emit_loadstore (tok
, ntok
, stX_op
[lgsize
]);
2870 expressionS newtok
[3];
2873 as_bad(_("macro requires $at register while noat in effect"));
2875 /* emit "lda $at, exp" */
2877 memcpy (newtok
, tok
, sizeof (expressionS
) * ntok
);
2878 newtok
[0].X_add_number
= AXP_REG_AT
;
2879 assemble_tokens ("lda", newtok
, ntok
, 1);
2881 /* emit "ldq_u $t9, 0($at)" */
2883 set_tok_reg (newtok
[0], AXP_REG_T9
);
2884 set_tok_const (newtok
[1], 0);
2885 set_tok_preg (newtok
[2], AXP_REG_AT
);
2886 assemble_tokens ("ldq_u", newtok
, 3, 1);
2888 /* emit "insXl src, $at, $t10" */
2891 set_tok_reg (newtok
[1], AXP_REG_AT
);
2892 set_tok_reg (newtok
[2], AXP_REG_T10
);
2893 assemble_tokens (insXl_op
[lgsize
], newtok
, 3, 1);
2895 /* emit "mskXl $t9, $at, $t9" */
2897 set_tok_reg (newtok
[0], AXP_REG_T9
);
2898 newtok
[2] = newtok
[0];
2899 assemble_tokens (mskXl_op
[lgsize
], newtok
, 3, 1);
2901 /* emit "or $t9, $t10, $t9" */
2903 set_tok_reg (newtok
[1], AXP_REG_T10
);
2904 assemble_tokens ("or", newtok
, 3, 1);
2906 /* emit "stq_u $t9, 0($at) */
2908 set_tok_const (newtok
[1], 0);
2909 set_tok_preg (newtok
[2], AXP_REG_AT
);
2910 assemble_tokens ("stq_u", newtok
, 3, 1);
2914 /* Store an integer to an unaligned address. */
2917 emit_ustX (tok
, ntok
, vlgsize
)
2918 const expressionS
*tok
;
2922 int lgsize
= (int)(long)vlgsize
;
2923 expressionS newtok
[3];
2925 /* emit "lda $at, exp" */
2927 memcpy (newtok
, tok
, sizeof (expressionS
) * ntok
);
2928 newtok
[0].X_add_number
= AXP_REG_AT
;
2929 assemble_tokens ("lda", newtok
, ntok
, 1);
2931 /* emit "ldq_u $9, 0($at)" */
2933 set_tok_reg (newtok
[0], AXP_REG_T9
);
2934 set_tok_const (newtok
[1], 0);
2935 set_tok_preg (newtok
[2], AXP_REG_AT
);
2936 assemble_tokens ("ldq_u", newtok
, 3, 1);
2938 /* emit "ldq_u $10, size-1($at)" */
2940 set_tok_reg (newtok
[0], AXP_REG_T10
);
2941 set_tok_const (newtok
[1], (1 << lgsize
)-1);
2942 assemble_tokens ("ldq_u", newtok
, 3, 1);
2944 /* emit "insXl src, $at, $t11" */
2947 set_tok_reg (newtok
[1], AXP_REG_AT
);
2948 set_tok_reg (newtok
[2], AXP_REG_T11
);
2949 assemble_tokens (insXl_op
[lgsize
], newtok
, 3, 1);
2951 /* emit "insXh src, $at, $t12" */
2953 set_tok_reg (newtok
[2], AXP_REG_T12
);
2954 assemble_tokens (insXh_op
[lgsize
], newtok
, 3, 1);
2956 /* emit "mskXl $t9, $at, $t9" */
2958 set_tok_reg (newtok
[0], AXP_REG_T9
);
2959 newtok
[2] = newtok
[0];
2960 assemble_tokens (mskXl_op
[lgsize
], newtok
, 3, 1);
2962 /* emit "mskXh $t10, $at, $t10" */
2964 set_tok_reg (newtok
[0], AXP_REG_T10
);
2965 newtok
[2] = newtok
[0];
2966 assemble_tokens (mskXh_op
[lgsize
], newtok
, 3, 1);
2968 /* emit "or $t9, $t11, $t9" */
2970 set_tok_reg (newtok
[0], AXP_REG_T9
);
2971 set_tok_reg (newtok
[1], AXP_REG_T11
);
2972 newtok
[2] = newtok
[0];
2973 assemble_tokens ("or", newtok
, 3, 1);
2975 /* emit "or $t10, $t12, $t10" */
2977 set_tok_reg (newtok
[0], AXP_REG_T10
);
2978 set_tok_reg (newtok
[1], AXP_REG_T12
);
2979 newtok
[2] = newtok
[0];
2980 assemble_tokens ("or", newtok
, 3, 1);
2982 /* emit "stq_u $t9, 0($at)" */
2984 set_tok_reg (newtok
[0], AXP_REG_T9
);
2985 set_tok_const (newtok
[1], 0);
2986 set_tok_preg (newtok
[2], AXP_REG_AT
);
2987 assemble_tokens ("stq_u", newtok
, 3, 1);
2989 /* emit "stq_u $t10, size-1($at)" */
2991 set_tok_reg (newtok
[0], AXP_REG_T10
);
2992 set_tok_const (newtok
[1], (1 << lgsize
)-1);
2993 assemble_tokens ("stq_u", newtok
, 3, 1);
2996 /* Sign extend a half-word or byte. The 32-bit sign extend is
2997 implemented as "addl $31, $r, $t" in the opcode table. */
3000 emit_sextX (tok
, ntok
, vlgsize
)
3001 const expressionS
*tok
;
3005 long lgsize
= (long)vlgsize
;
3007 if (alpha_target
& AXP_OPCODE_BWX
)
3008 assemble_tokens (sextX_op
[lgsize
], tok
, ntok
, 0);
3011 int bitshift
= 64 - 8 * (1 << lgsize
);
3012 expressionS newtok
[3];
3014 /* emit "sll src,bits,dst" */
3017 set_tok_const (newtok
[1], bitshift
);
3018 newtok
[2] = tok
[ntok
- 1];
3019 assemble_tokens ("sll", newtok
, 3, 1);
3021 /* emit "sra dst,bits,dst" */
3023 newtok
[0] = newtok
[2];
3024 assemble_tokens ("sra", newtok
, 3, 1);
3028 /* Implement the division and modulus macros. */
3032 /* Make register usage like in normal procedure call.
3033 Don't clobber PV and RA. */
3036 emit_division (tok
, ntok
, symname
)
3037 const expressionS
*tok
;
3041 /* DIVISION and MODULUS. Yech.
3046 * mov x,R16 # if x != R16
3047 * mov y,R17 # if y != R17
3052 * with appropriate optimizations if R0,R16,R17 are the registers
3053 * specified by the compiler.
3058 expressionS newtok
[3];
3060 xr
= regno (tok
[0].X_add_number
);
3061 yr
= regno (tok
[1].X_add_number
);
3066 rr
= regno (tok
[2].X_add_number
);
3068 /* Move the operands into the right place */
3069 if (yr
== AXP_REG_R16
&& xr
== AXP_REG_R17
)
3071 /* They are in exactly the wrong order -- swap through AT */
3074 as_bad (_("macro requires $at register while noat in effect"));
3076 set_tok_reg (newtok
[0], AXP_REG_R16
);
3077 set_tok_reg (newtok
[1], AXP_REG_AT
);
3078 assemble_tokens ("mov", newtok
, 2, 1);
3080 set_tok_reg (newtok
[0], AXP_REG_R17
);
3081 set_tok_reg (newtok
[1], AXP_REG_R16
);
3082 assemble_tokens ("mov", newtok
, 2, 1);
3084 set_tok_reg (newtok
[0], AXP_REG_AT
);
3085 set_tok_reg (newtok
[1], AXP_REG_R17
);
3086 assemble_tokens ("mov", newtok
, 2, 1);
3090 if (yr
== AXP_REG_R16
)
3092 set_tok_reg (newtok
[0], AXP_REG_R16
);
3093 set_tok_reg (newtok
[1], AXP_REG_R17
);
3094 assemble_tokens ("mov", newtok
, 2, 1);
3097 if (xr
!= AXP_REG_R16
)
3099 set_tok_reg (newtok
[0], xr
);
3100 set_tok_reg (newtok
[1], AXP_REG_R16
);
3101 assemble_tokens ("mov", newtok
, 2, 1);
3104 if (yr
!= AXP_REG_R16
&& yr
!= AXP_REG_R17
)
3106 set_tok_reg (newtok
[0], yr
);
3107 set_tok_reg (newtok
[1], AXP_REG_R17
);
3108 assemble_tokens ("mov", newtok
, 2, 1);
3112 sym
= symbol_find_or_make ((const char *)symname
);
3114 set_tok_reg (newtok
[0], AXP_REG_AT
);
3115 set_tok_sym (newtok
[1], sym
, 0);
3116 assemble_tokens ("lda", newtok
, 2, 1);
3118 /* Call the division routine */
3119 set_tok_reg (newtok
[0], AXP_REG_AT
);
3120 set_tok_cpreg (newtok
[1], AXP_REG_AT
);
3121 set_tok_const (newtok
[2], 0);
3122 assemble_tokens ("jsr", newtok
, 3, 1);
3124 /* Move the result to the right place */
3125 if (rr
!= AXP_REG_R0
)
3127 set_tok_reg (newtok
[0], AXP_REG_R0
);
3128 set_tok_reg (newtok
[1], rr
);
3129 assemble_tokens ("mov", newtok
, 2, 1);
3133 #else /* !OBJ_EVAX */
3136 emit_division (tok
, ntok
, symname
)
3137 const expressionS
*tok
;
3141 /* DIVISION and MODULUS. Yech.
3151 * with appropriate optimizations if t10,t11,t12 are the registers
3152 * specified by the compiler.
3157 expressionS newtok
[3];
3159 xr
= regno (tok
[0].X_add_number
);
3160 yr
= regno (tok
[1].X_add_number
);
3165 rr
= regno (tok
[2].X_add_number
);
3167 sym
= symbol_find_or_make ((const char *)symname
);
3169 /* Move the operands into the right place */
3170 if (yr
== AXP_REG_T10
&& xr
== AXP_REG_T11
)
3172 /* They are in exactly the wrong order -- swap through AT */
3175 as_bad (_("macro requires $at register while noat in effect"));
3177 set_tok_reg (newtok
[0], AXP_REG_T10
);
3178 set_tok_reg (newtok
[1], AXP_REG_AT
);
3179 assemble_tokens ("mov", newtok
, 2, 1);
3181 set_tok_reg (newtok
[0], AXP_REG_T11
);
3182 set_tok_reg (newtok
[1], AXP_REG_T10
);
3183 assemble_tokens ("mov", newtok
, 2, 1);
3185 set_tok_reg (newtok
[0], AXP_REG_AT
);
3186 set_tok_reg (newtok
[1], AXP_REG_T11
);
3187 assemble_tokens ("mov", newtok
, 2, 1);
3191 if (yr
== AXP_REG_T10
)
3193 set_tok_reg (newtok
[0], AXP_REG_T10
);
3194 set_tok_reg (newtok
[1], AXP_REG_T11
);
3195 assemble_tokens ("mov", newtok
, 2, 1);
3198 if (xr
!= AXP_REG_T10
)
3200 set_tok_reg (newtok
[0], xr
);
3201 set_tok_reg (newtok
[1], AXP_REG_T10
);
3202 assemble_tokens ("mov", newtok
, 2, 1);
3205 if (yr
!= AXP_REG_T10
&& yr
!= AXP_REG_T11
)
3207 set_tok_reg (newtok
[0], yr
);
3208 set_tok_reg (newtok
[1], AXP_REG_T11
);
3209 assemble_tokens ("mov", newtok
, 2, 1);
3213 /* Call the division routine */
3214 set_tok_reg (newtok
[0], AXP_REG_T9
);
3215 set_tok_sym (newtok
[1], sym
, 0);
3216 assemble_tokens ("jsr", newtok
, 2, 1);
3218 /* Reload the GP register */
3222 #if defined(OBJ_ECOFF) || defined(OBJ_ELF)
3223 set_tok_reg (newtok
[0], alpha_gp_register
);
3224 set_tok_const (newtok
[1], 0);
3225 set_tok_preg (newtok
[2], AXP_REG_T9
);
3226 assemble_tokens ("ldgp", newtok
, 3, 1);
3229 /* Move the result to the right place */
3230 if (rr
!= AXP_REG_T12
)
3232 set_tok_reg (newtok
[0], AXP_REG_T12
);
3233 set_tok_reg (newtok
[1], rr
);
3234 assemble_tokens ("mov", newtok
, 2, 1);
3238 #endif /* !OBJ_EVAX */
3240 /* The jsr and jmp macros differ from their instruction counterparts
3241 in that they can load the target address and default most
3245 emit_jsrjmp (tok
, ntok
, vopname
)
3246 const expressionS
*tok
;
3250 const char *opname
= (const char *) vopname
;
3251 struct alpha_insn insn
;
3252 expressionS newtok
[3];
3253 int r
, tokidx
= 0, lituse
= 0;
3255 if (tokidx
< ntok
&& tok
[tokidx
].X_op
== O_register
)
3256 r
= regno (tok
[tokidx
++].X_add_number
);
3258 r
= strcmp (opname
, "jmp") == 0 ? AXP_REG_ZERO
: AXP_REG_RA
;
3260 set_tok_reg (newtok
[0], r
);
3262 if (tokidx
< ntok
&&
3263 (tok
[tokidx
].X_op
== O_pregister
|| tok
[tokidx
].X_op
== O_cpregister
))
3264 r
= regno (tok
[tokidx
++].X_add_number
);
3266 /* keep register if jsr $n.<sym> */
3270 int basereg
= alpha_gp_register
;
3271 lituse
= load_expression (r
= AXP_REG_PV
, &tok
[tokidx
], &basereg
, NULL
);
3275 set_tok_cpreg (newtok
[1], r
);
3278 /* FIXME: Add hint relocs to BFD for evax. */
3281 newtok
[2] = tok
[tokidx
];
3284 set_tok_const (newtok
[2], 0);
3286 assemble_tokens_to_insn (opname
, newtok
, 3, &insn
);
3288 /* add the LITUSE fixup */
3291 assert (insn
.nfixups
< MAX_INSN_FIXUPS
);
3292 if (insn
.nfixups
> 0)
3294 memmove (&insn
.fixups
[1], &insn
.fixups
[0],
3295 sizeof(struct alpha_fixup
) * insn
.nfixups
);
3298 insn
.fixups
[0].reloc
= BFD_RELOC_ALPHA_LITUSE
;
3299 insn
.fixups
[0].exp
.X_op
= O_symbol
;
3300 insn
.fixups
[0].exp
.X_add_symbol
= section_symbol (now_seg
);
3301 insn
.fixups
[0].exp
.X_add_number
= 3;
3307 /* The ret and jcr instructions differ from their instruction
3308 counterparts in that everything can be defaulted. */
3311 emit_retjcr (tok
, ntok
, vopname
)
3312 const expressionS
*tok
;
3316 const char *opname
= (const char *)vopname
;
3317 expressionS newtok
[3];
3320 if (tokidx
< ntok
&& tok
[tokidx
].X_op
== O_register
)
3321 r
= regno (tok
[tokidx
++].X_add_number
);
3325 set_tok_reg (newtok
[0], r
);
3327 if (tokidx
< ntok
&&
3328 (tok
[tokidx
].X_op
== O_pregister
|| tok
[tokidx
].X_op
== O_cpregister
))
3329 r
= regno (tok
[tokidx
++].X_add_number
);
3333 set_tok_cpreg (newtok
[1], r
);
3336 newtok
[2] = tok
[tokidx
];
3338 set_tok_const (newtok
[2], strcmp(opname
, "ret") == 0);
3340 assemble_tokens (opname
, newtok
, 3, 0);
3343 /* Assembler directives */
3345 /* Handle the .text pseudo-op. This is like the usual one, but it
3346 clears alpha_insn_label and restores auto alignment. */
3354 alpha_insn_label
= NULL
;
3355 alpha_auto_align_on
= 1;
3356 alpha_current_align
= 0;
3359 /* Handle the .data pseudo-op. This is like the usual one, but it
3360 clears alpha_insn_label and restores auto alignment. */
3367 alpha_insn_label
= NULL
;
3368 alpha_auto_align_on
= 1;
3369 alpha_current_align
= 0;
3372 #if defined (OBJ_ECOFF) || defined (OBJ_EVAX)
3374 /* Handle the OSF/1 and openVMS .comm pseudo quirks.
3375 openVMS constructs a section for every common symbol. */
3378 s_alpha_comm (ignore
)
3381 register char *name
;
3385 register symbolS
*symbolP
;
3388 segT current_section
= now_seg
;
3389 int current_subsec
= now_subseg
;
3393 name
= input_line_pointer
;
3394 c
= get_symbol_end ();
3396 /* just after name is now '\0' */
3397 p
= input_line_pointer
;
3402 /* Alpha OSF/1 compiler doesn't provide the comma, gcc does. */
3403 if (*input_line_pointer
== ',')
3405 input_line_pointer
++;
3408 if ((temp
= get_absolute_expression ()) < 0)
3410 as_warn (_(".COMMon length (%ld.) <0! Ignored."), (long) temp
);
3411 ignore_rest_of_line ();
3416 symbolP
= symbol_find_or_make (name
);
3419 /* Make a section for the common symbol. */
3420 new_seg
= subseg_new (xstrdup (name
), 0);
3426 /* alignment might follow */
3427 if (*input_line_pointer
== ',')
3431 input_line_pointer
++;
3432 align
= get_absolute_expression ();
3433 bfd_set_section_alignment (stdoutput
, new_seg
, align
);
3437 if (S_IS_DEFINED (symbolP
) && ! S_IS_COMMON (symbolP
))
3439 as_bad (_("Ignoring attempt to re-define symbol"));
3440 ignore_rest_of_line ();
3445 if (bfd_section_size (stdoutput
, new_seg
) > 0)
3447 if (bfd_section_size (stdoutput
, new_seg
) != temp
)
3448 as_bad (_("Length of .comm \"%s\" is already %ld. Not changed to %ld."),
3449 S_GET_NAME (symbolP
),
3450 (long) bfd_section_size (stdoutput
, new_seg
),
3454 if (S_GET_VALUE (symbolP
))
3456 if (S_GET_VALUE (symbolP
) != (valueT
) temp
)
3457 as_bad (_("Length of .comm \"%s\" is already %ld. Not changed to %ld."),
3458 S_GET_NAME (symbolP
),
3459 (long) S_GET_VALUE (symbolP
),
3466 subseg_set (new_seg
, 0);
3467 p
= frag_more (temp
);
3468 new_seg
->flags
|= SEC_IS_COMMON
;
3469 if (! S_IS_DEFINED (symbolP
))
3470 S_SET_SEGMENT (symbolP
, new_seg
);
3472 S_SET_VALUE (symbolP
, (valueT
) temp
);
3474 S_SET_EXTERNAL (symbolP
);
3478 subseg_set (current_section
, current_subsec
);
3481 know (symbolP
->sy_frag
== &zero_address_frag
);
3483 demand_empty_rest_of_line ();
3486 #endif /* ! OBJ_ELF */
3490 /* Handle the .rdata pseudo-op. This is like the usual one, but it
3491 clears alpha_insn_label and restores auto alignment. */
3494 s_alpha_rdata (ignore
)
3499 temp
= get_absolute_expression ();
3500 subseg_new (".rdata", 0);
3501 demand_empty_rest_of_line ();
3502 alpha_insn_label
= NULL
;
3503 alpha_auto_align_on
= 1;
3504 alpha_current_align
= 0;
3511 /* Handle the .sdata pseudo-op. This is like the usual one, but it
3512 clears alpha_insn_label and restores auto alignment. */
3515 s_alpha_sdata (ignore
)
3520 temp
= get_absolute_expression ();
3521 subseg_new (".sdata", 0);
3522 demand_empty_rest_of_line ();
3523 alpha_insn_label
= NULL
;
3524 alpha_auto_align_on
= 1;
3525 alpha_current_align
= 0;
3531 /* Handle the .section pseudo-op. This is like the usual one, but it
3532 clears alpha_insn_label and restores auto alignment. */
3535 s_alpha_section (ignore
)
3538 obj_elf_section (ignore
);
3540 alpha_insn_label
= NULL
;
3541 alpha_auto_align_on
= 1;
3542 alpha_current_align
= 0;
3549 if (ECOFF_DEBUGGING
)
3550 ecoff_directive_ent (0);
3553 char *name
, name_end
;
3554 name
= input_line_pointer
;
3555 name_end
= get_symbol_end ();
3557 if (! is_name_beginner (*name
))
3559 as_warn (_(".ent directive has no name"));
3560 *input_line_pointer
= name_end
;
3566 if (alpha_cur_ent_sym
)
3567 as_warn (_("nested .ent directives"));
3569 sym
= symbol_find_or_make (name
);
3570 symbol_get_bfdsym (sym
)->flags
|= BSF_FUNCTION
;
3571 alpha_cur_ent_sym
= sym
;
3573 /* The .ent directive is sometimes followed by a number. Not sure
3574 what it really means, but ignore it. */
3575 *input_line_pointer
= name_end
;
3577 if (*input_line_pointer
== ',')
3579 input_line_pointer
++;
3582 if (isdigit (*input_line_pointer
) || *input_line_pointer
== '-')
3583 (void) get_absolute_expression ();
3585 demand_empty_rest_of_line ();
3593 if (ECOFF_DEBUGGING
)
3594 ecoff_directive_end (0);
3597 char *name
, name_end
;
3598 name
= input_line_pointer
;
3599 name_end
= get_symbol_end ();
3601 if (! is_name_beginner (*name
))
3603 as_warn (_(".end directive has no name"));
3604 *input_line_pointer
= name_end
;
3610 sym
= symbol_find (name
);
3611 if (sym
!= alpha_cur_ent_sym
)
3612 as_warn (_(".end directive names different symbol than .ent"));
3614 /* Create an expression to calculate the size of the function. */
3617 symbol_get_obj (sym
)->size
=
3618 (expressionS
*) xmalloc (sizeof (expressionS
));
3619 symbol_get_obj (sym
)->size
->X_op
= O_subtract
;
3620 symbol_get_obj (sym
)->size
->X_add_symbol
3621 = symbol_new ("L0\001", now_seg
, frag_now_fix (), frag_now
);
3622 symbol_get_obj (sym
)->size
->X_op_symbol
= sym
;
3623 symbol_get_obj (sym
)->size
->X_add_number
= 0;
3626 alpha_cur_ent_sym
= NULL
;
3628 *input_line_pointer
= name_end
;
3630 demand_empty_rest_of_line ();
3638 if (ECOFF_DEBUGGING
)
3641 ecoff_directive_fmask (0);
3643 ecoff_directive_mask (0);
3646 discard_rest_of_line ();
3650 s_alpha_frame (dummy
)
3653 if (ECOFF_DEBUGGING
)
3654 ecoff_directive_frame (0);
3656 discard_rest_of_line ();
3660 s_alpha_prologue (ignore
)
3666 arg
= get_absolute_expression ();
3667 demand_empty_rest_of_line ();
3669 if (ECOFF_DEBUGGING
)
3670 sym
= ecoff_get_cur_proc_sym ();
3672 sym
= alpha_cur_ent_sym
;
3677 case 0: /* No PV required. */
3678 S_SET_OTHER (sym
, STO_ALPHA_NOPV
);
3680 case 1: /* Std GP load. */
3681 S_SET_OTHER (sym
, STO_ALPHA_STD_GPLOAD
);
3683 case 2: /* Non-std use of PV. */
3687 as_bad (_("Invalid argument %d to .prologue."), arg
);
3693 s_alpha_coff_wrapper (which
)
3696 static void (* const fns
[]) PARAMS ((int)) = {
3697 ecoff_directive_begin
,
3698 ecoff_directive_bend
,
3699 ecoff_directive_def
,
3700 ecoff_directive_dim
,
3701 ecoff_directive_endef
,
3702 ecoff_directive_file
,
3703 ecoff_directive_scl
,
3704 ecoff_directive_tag
,
3705 ecoff_directive_val
,
3706 ecoff_directive_loc
,
3709 assert (which
>= 0 && which
< sizeof(fns
)/sizeof(*fns
));
3711 if (ECOFF_DEBUGGING
)
3715 as_bad (_("ECOFF debugging is disabled."));
3716 ignore_rest_of_line ();
3719 #endif /* OBJ_ELF */
3723 /* Handle the section specific pseudo-op. */
3726 s_alpha_section (secid
)
3730 #define EVAX_SECTION_COUNT 5
3731 static char *section_name
[EVAX_SECTION_COUNT
+1] =
3732 { "NULL", ".rdata", ".comm", ".link", ".ctors", ".dtors" };
3734 if ((secid
<= 0) || (secid
> EVAX_SECTION_COUNT
))
3736 as_fatal (_("Unknown section directive"));
3737 demand_empty_rest_of_line ();
3740 temp
= get_absolute_expression ();
3741 subseg_new (section_name
[secid
], 0);
3742 demand_empty_rest_of_line ();
3743 alpha_insn_label
= NULL
;
3744 alpha_auto_align_on
= 1;
3745 alpha_current_align
= 0;
3749 /* Parse .ent directives. */
3752 s_alpha_ent (ignore
)
3756 expressionS symexpr
;
3758 alpha_evax_proc
.pdsckind
= 0;
3759 alpha_evax_proc
.framereg
= -1;
3760 alpha_evax_proc
.framesize
= 0;
3761 alpha_evax_proc
.rsa_offset
= 0;
3762 alpha_evax_proc
.ra_save
= AXP_REG_RA
;
3763 alpha_evax_proc
.fp_save
= -1;
3764 alpha_evax_proc
.imask
= 0;
3765 alpha_evax_proc
.fmask
= 0;
3766 alpha_evax_proc
.prologue
= 0;
3767 alpha_evax_proc
.type
= 0;
3769 expression (&symexpr
);
3771 if (symexpr
.X_op
!= O_symbol
)
3773 as_fatal (_(".ent directive has no symbol"));
3774 demand_empty_rest_of_line ();
3778 symbol
= make_expr_symbol (&symexpr
);
3779 symbol_get_bfdsym (symbol
)->flags
|= BSF_FUNCTION
;
3780 alpha_evax_proc
.symbol
= symbol
;
3782 demand_empty_rest_of_line ();
3787 /* Parse .frame <framreg>,<framesize>,RA,<rsa_offset> directives. */
3790 s_alpha_frame (ignore
)
3795 alpha_evax_proc
.framereg
= tc_get_register (1);
3798 if (*input_line_pointer
++ != ','
3799 || get_absolute_expression_and_terminator (&val
) != ',')
3801 as_warn (_("Bad .frame directive 1./2. param"));
3802 --input_line_pointer
;
3803 demand_empty_rest_of_line ();
3807 alpha_evax_proc
.framesize
= val
;
3809 (void) tc_get_register (1);
3811 if (*input_line_pointer
++ != ',')
3813 as_warn (_("Bad .frame directive 3./4. param"));
3814 --input_line_pointer
;
3815 demand_empty_rest_of_line ();
3818 alpha_evax_proc
.rsa_offset
= get_absolute_expression ();
3824 s_alpha_pdesc (ignore
)
3834 segment_info_type
*seginfo
= seg_info (alpha_link_section
);
3836 if (now_seg
!= alpha_link_section
)
3838 as_bad (_(".pdesc directive not in link (.link) section"));
3839 demand_empty_rest_of_line ();
3843 if ((alpha_evax_proc
.symbol
== 0)
3844 || (!S_IS_DEFINED (alpha_evax_proc
.symbol
)))
3846 as_fatal (_(".pdesc has no matching .ent"));
3847 demand_empty_rest_of_line ();
3851 alpha_evax_proc
.symbol
->sy_obj
= (valueT
)seginfo
->literal_pool_size
;
3854 if (exp
.X_op
!= O_symbol
)
3856 as_warn (_(".pdesc directive has no entry symbol"));
3857 demand_empty_rest_of_line ();
3861 entry_sym
= make_expr_symbol (&exp
);
3862 /* Save bfd symbol of proc desc in function symbol. */
3863 symbol_get_bfdsym (alpha_evax_proc
.symbol
)->udata
.p
3864 = symbol_get_bfdsym (entry_sym
);
3867 if (*input_line_pointer
++ != ',')
3869 as_warn (_("No comma after .pdesc <entryname>"));
3870 demand_empty_rest_of_line ();
3875 name
= input_line_pointer
;
3876 name_end
= get_symbol_end ();
3878 if (strncmp(name
, "stack", 5) == 0)
3880 alpha_evax_proc
.pdsckind
= PDSC_S_K_KIND_FP_STACK
;
3882 else if (strncmp(name
, "reg", 3) == 0)
3884 alpha_evax_proc
.pdsckind
= PDSC_S_K_KIND_FP_REGISTER
;
3886 else if (strncmp(name
, "null", 4) == 0)
3888 alpha_evax_proc
.pdsckind
= PDSC_S_K_KIND_NULL
;
3892 as_fatal (_("unknown procedure kind"));
3893 demand_empty_rest_of_line ();
3897 *input_line_pointer
= name_end
;
3898 demand_empty_rest_of_line ();
3900 #ifdef md_flush_pending_output
3901 md_flush_pending_output ();
3904 frag_align (3, 0, 0);
3906 fixp
= fix_new (frag_now
, p
- frag_now
->fr_literal
, 8, 0, 0, 0, 0);
3908 seginfo
->literal_pool_size
+= 16;
3910 *p
= alpha_evax_proc
.pdsckind
3911 | ((alpha_evax_proc
.framereg
== 29) ? PDSC_S_M_BASE_REG_IS_FP
: 0);
3912 *(p
+1) = PDSC_S_M_NATIVE
3913 | PDSC_S_M_NO_JACKET
;
3915 switch (alpha_evax_proc
.pdsckind
)
3917 case PDSC_S_K_KIND_NULL
:
3921 case PDSC_S_K_KIND_FP_REGISTER
:
3922 *(p
+2) = alpha_evax_proc
.fp_save
;
3923 *(p
+3) = alpha_evax_proc
.ra_save
;
3925 case PDSC_S_K_KIND_FP_STACK
:
3926 md_number_to_chars (p
+2, (valueT
)alpha_evax_proc
.rsa_offset
, 2);
3928 default: /* impossible */
3933 *(p
+5) = alpha_evax_proc
.type
& 0x0f;
3935 /* Signature offset. */
3936 md_number_to_chars (p
+6, (valueT
)0, 2);
3938 fix_new_exp (frag_now
, p
-frag_now
->fr_literal
+8, 8, &exp
, 0, BFD_RELOC_64
);
3940 if (alpha_evax_proc
.pdsckind
== PDSC_S_K_KIND_NULL
)
3943 /* Add dummy fix to make add_to_link_pool work. */
3945 fixp
= fix_new (frag_now
, p
- frag_now
->fr_literal
, 8, 0, 0, 0, 0);
3947 seginfo
->literal_pool_size
+= 8;
3949 /* pdesc+16: Size. */
3950 md_number_to_chars (p
, (valueT
)alpha_evax_proc
.framesize
, 4);
3952 md_number_to_chars (p
+4, (valueT
)0, 2);
3955 md_number_to_chars (p
+6, alpha_evax_proc
.prologue
, 2);
3957 if (alpha_evax_proc
.pdsckind
== PDSC_S_K_KIND_FP_REGISTER
)
3960 /* Add dummy fix to make add_to_link_pool work. */
3962 fixp
= fix_new (frag_now
, p
- frag_now
->fr_literal
, 8, 0, 0, 0, 0);
3964 seginfo
->literal_pool_size
+= 8;
3966 /* pdesc+24: register masks. */
3968 md_number_to_chars (p
, alpha_evax_proc
.imask
, 4);
3969 md_number_to_chars (p
+4, alpha_evax_proc
.fmask
, 4);
3975 /* Support for crash debug on vms. */
3978 s_alpha_name (ignore
)
3983 segment_info_type
*seginfo
= seg_info (alpha_link_section
);
3985 if (now_seg
!= alpha_link_section
)
3987 as_bad (_(".name directive not in link (.link) section"));
3988 demand_empty_rest_of_line ();
3993 if (exp
.X_op
!= O_symbol
)
3995 as_warn (_(".name directive has no symbol"));
3996 demand_empty_rest_of_line ();
4000 demand_empty_rest_of_line ();
4002 #ifdef md_flush_pending_output
4003 md_flush_pending_output ();
4006 frag_align (3, 0, 0);
4008 seginfo
->literal_pool_size
+= 8;
4010 fix_new_exp (frag_now
, p
-frag_now
->fr_literal
, 8, &exp
, 0, BFD_RELOC_64
);
4017 s_alpha_linkage (ignore
)
4023 #ifdef md_flush_pending_output
4024 md_flush_pending_output ();
4028 if (exp
.X_op
!= O_symbol
)
4030 as_fatal (_("No symbol after .linkage"));
4034 p
= frag_more (LKP_S_K_SIZE
);
4035 memset (p
, 0, LKP_S_K_SIZE
);
4036 fix_new_exp (frag_now
, p
- frag_now
->fr_literal
, LKP_S_K_SIZE
, &exp
, 0,\
4037 BFD_RELOC_ALPHA_LINKAGE
);
4039 demand_empty_rest_of_line ();
4046 s_alpha_code_address (ignore
)
4052 #ifdef md_flush_pending_output
4053 md_flush_pending_output ();
4057 if (exp
.X_op
!= O_symbol
)
4059 as_fatal (_("No symbol after .code_address"));
4065 fix_new_exp (frag_now
, p
- frag_now
->fr_literal
, 8, &exp
, 0,\
4066 BFD_RELOC_ALPHA_CODEADDR
);
4068 demand_empty_rest_of_line ();
4075 s_alpha_fp_save (ignore
)
4079 alpha_evax_proc
.fp_save
= tc_get_register (1);
4081 demand_empty_rest_of_line ();
4087 s_alpha_mask (ignore
)
4092 if (get_absolute_expression_and_terminator (&val
) != ',')
4094 as_warn (_("Bad .mask directive"));
4095 --input_line_pointer
;
4099 alpha_evax_proc
.imask
= val
;
4100 (void)get_absolute_expression ();
4102 demand_empty_rest_of_line ();
4109 s_alpha_fmask (ignore
)
4114 if (get_absolute_expression_and_terminator (&val
) != ',')
4116 as_warn (_("Bad .fmask directive"));
4117 --input_line_pointer
;
4121 alpha_evax_proc
.fmask
= val
;
4122 (void) get_absolute_expression ();
4124 demand_empty_rest_of_line ();
4130 s_alpha_end (ignore
)
4135 c
= get_symbol_end ();
4136 *input_line_pointer
= c
;
4137 demand_empty_rest_of_line ();
4138 alpha_evax_proc
.symbol
= 0;
4145 s_alpha_file (ignore
)
4150 static char case_hack
[32];
4152 extern char *demand_copy_string
PARAMS ((int *lenP
));
4154 sprintf (case_hack
, "<CASE:%01d%01d>",
4155 alpha_flag_hash_long_names
, alpha_flag_show_after_trunc
);
4157 s
= symbol_find_or_make (case_hack
);
4158 symbol_get_bfdsym (s
)->flags
|= BSF_FILE
;
4160 get_absolute_expression ();
4161 s
= symbol_find_or_make (demand_copy_string (&length
));
4162 symbol_get_bfdsym (s
)->flags
|= BSF_FILE
;
4163 demand_empty_rest_of_line ();
4167 #endif /* OBJ_EVAX */
4169 /* Handle the .gprel32 pseudo op. */
4172 s_alpha_gprel32 (ignore
)
4185 e
.X_add_symbol
= section_symbol(absolute_section
);
4198 e
.X_add_symbol
= section_symbol (absolute_section
);
4201 e
.X_op
= O_subtract
;
4202 e
.X_op_symbol
= alpha_gp_symbol
;
4210 if (alpha_auto_align_on
&& alpha_current_align
< 2)
4211 alpha_align (2, (char *) NULL
, alpha_insn_label
, 0);
4212 if (alpha_current_align
> 2)
4213 alpha_current_align
= 2;
4214 alpha_insn_label
= NULL
;
4218 fix_new_exp (frag_now
, p
-frag_now
->fr_literal
, 4,
4219 &e
, 0, BFD_RELOC_GPREL32
);
4222 /* Handle floating point allocation pseudo-ops. This is like the
4223 generic vresion, but it makes sure the current label, if any, is
4224 correctly aligned. */
4227 s_alpha_float_cons (type
)
4254 if (alpha_auto_align_on
&& alpha_current_align
< log_size
)
4255 alpha_align (log_size
, (char *) NULL
, alpha_insn_label
, 0);
4256 if (alpha_current_align
> log_size
)
4257 alpha_current_align
= log_size
;
4258 alpha_insn_label
= NULL
;
4263 /* Handle the .proc pseudo op. We don't really do much with it except
4267 s_alpha_proc (is_static
)
4276 /* Takes ".proc name,nargs" */
4278 name
= input_line_pointer
;
4279 c
= get_symbol_end ();
4280 p
= input_line_pointer
;
4281 symbolP
= symbol_find_or_make (name
);
4284 if (*input_line_pointer
!= ',')
4287 as_warn (_("Expected comma after name \"%s\""), name
);
4290 ignore_rest_of_line ();
4294 input_line_pointer
++;
4295 temp
= get_absolute_expression ();
4297 /* symbolP->sy_other = (signed char) temp; */
4298 as_warn (_("unhandled: .proc %s,%d"), name
, temp
);
4299 demand_empty_rest_of_line ();
4302 /* Handle the .set pseudo op. This is used to turn on and off most of
4303 the assembler features. */
4313 name
= input_line_pointer
;
4314 ch
= get_symbol_end ();
4317 if (s
[0] == 'n' && s
[1] == 'o')
4322 if (!strcmp ("reorder", s
))
4324 else if (!strcmp ("at", s
))
4325 alpha_noat_on
= !yesno
;
4326 else if (!strcmp ("macro", s
))
4327 alpha_macros_on
= yesno
;
4328 else if (!strcmp ("move", s
))
4330 else if (!strcmp ("volatile", s
))
4333 as_warn (_("Tried to .set unrecognized mode `%s'"), name
);
4335 *input_line_pointer
= ch
;
4336 demand_empty_rest_of_line ();
4339 /* Handle the .base pseudo op. This changes the assembler's notion of
4340 the $gp register. */
4343 s_alpha_base (ignore
)
4347 if (first_32bit_quadrant
)
4349 /* not fatal, but it might not work in the end */
4350 as_warn (_("File overrides no-base-register option."));
4351 first_32bit_quadrant
= 0;
4356 if (*input_line_pointer
== '$')
4358 input_line_pointer
++;
4359 if (*input_line_pointer
== 'r')
4360 input_line_pointer
++;
4363 alpha_gp_register
= get_absolute_expression ();
4364 if (alpha_gp_register
< 0 || alpha_gp_register
> 31)
4366 alpha_gp_register
= AXP_REG_GP
;
4367 as_warn (_("Bad base register, using $%d."), alpha_gp_register
);
4370 demand_empty_rest_of_line ();
4373 /* Handle the .align pseudo-op. This aligns to a power of two. It
4374 also adjusts any current instruction label. We treat this the same
4375 way the MIPS port does: .align 0 turns off auto alignment. */
4378 s_alpha_align (ignore
)
4383 long max_alignment
= 15;
4385 align
= get_absolute_expression ();
4386 if (align
> max_alignment
)
4388 align
= max_alignment
;
4389 as_bad (_("Alignment too large: %d. assumed"), align
);
4393 as_warn (_("Alignment negative: 0 assumed"));
4397 if (*input_line_pointer
== ',')
4399 input_line_pointer
++;
4400 fill
= get_absolute_expression ();
4408 alpha_auto_align_on
= 1;
4409 alpha_align (align
, pfill
, alpha_insn_label
, 1);
4413 alpha_auto_align_on
= 0;
4416 demand_empty_rest_of_line ();
4419 /* Hook the normal string processor to reset known alignment. */
4422 s_alpha_stringer (terminate
)
4425 alpha_current_align
= 0;
4426 alpha_insn_label
= NULL
;
4427 stringer (terminate
);
4430 /* Hook the normal space processing to reset known alignment. */
4433 s_alpha_space (ignore
)
4436 alpha_current_align
= 0;
4437 alpha_insn_label
= NULL
;
4441 /* Hook into cons for auto-alignment. */
4444 alpha_cons_align (size
)
4450 while ((size
>>= 1) != 0)
4453 if (alpha_auto_align_on
&& alpha_current_align
< log_size
)
4454 alpha_align (log_size
, (char *) NULL
, alpha_insn_label
, 0);
4455 if (alpha_current_align
> log_size
)
4456 alpha_current_align
= log_size
;
4457 alpha_insn_label
= NULL
;
4460 /* Here come the .uword, .ulong, and .uquad explicitly unaligned
4461 pseudos. We just turn off auto-alignment and call down to cons. */
4464 s_alpha_ucons (bytes
)
4467 int hold
= alpha_auto_align_on
;
4468 alpha_auto_align_on
= 0;
4470 alpha_auto_align_on
= hold
;
4473 /* Switch the working cpu type. */
4476 s_alpha_arch (ignored
)
4480 const struct cpu_type
*p
;
4483 name
= input_line_pointer
;
4484 ch
= get_symbol_end ();
4486 for (p
= cpu_types
; p
->name
; ++p
)
4487 if (strcmp(name
, p
->name
) == 0)
4489 alpha_target_name
= p
->name
, alpha_target
= p
->flags
;
4492 as_warn("Unknown CPU identifier `%s'", name
);
4495 *input_line_pointer
= ch
;
4496 demand_empty_rest_of_line ();
4502 /* print token expression with alpha specific extension. */
4505 alpha_print_token(f
, exp
)
4507 const expressionS
*exp
;
4517 expressionS nexp
= *exp
;
4518 nexp
.X_op
= O_register
;
4519 print_expr (f
, &nexp
);
4524 print_expr (f
, exp
);
4531 /* The target specific pseudo-ops which we support. */
4533 const pseudo_typeS md_pseudo_table
[] =
4536 {"comm", s_alpha_comm
, 0}, /* osf1 compiler does this */
4537 {"rdata", s_alpha_rdata
, 0},
4539 {"text", s_alpha_text
, 0},
4540 {"data", s_alpha_data
, 0},
4542 {"sdata", s_alpha_sdata
, 0},
4545 {"section", s_alpha_section
, 0},
4546 {"section.s", s_alpha_section
, 0},
4547 {"sect", s_alpha_section
, 0},
4548 {"sect.s", s_alpha_section
, 0},
4551 { "pdesc", s_alpha_pdesc
, 0},
4552 { "name", s_alpha_name
, 0},
4553 { "linkage", s_alpha_linkage
, 0},
4554 { "code_address", s_alpha_code_address
, 0},
4555 { "ent", s_alpha_ent
, 0},
4556 { "frame", s_alpha_frame
, 0},
4557 { "fp_save", s_alpha_fp_save
, 0},
4558 { "mask", s_alpha_mask
, 0},
4559 { "fmask", s_alpha_fmask
, 0},
4560 { "end", s_alpha_end
, 0},
4561 { "file", s_alpha_file
, 0},
4562 { "rdata", s_alpha_section
, 1},
4563 { "comm", s_alpha_comm
, 0},
4564 { "link", s_alpha_section
, 3},
4565 { "ctors", s_alpha_section
, 4},
4566 { "dtors", s_alpha_section
, 5},
4569 /* Frame related pseudos. */
4570 {"ent", s_alpha_ent
, 0},
4571 {"end", s_alpha_end
, 0},
4572 {"mask", s_alpha_mask
, 0},
4573 {"fmask", s_alpha_mask
, 1},
4574 {"frame", s_alpha_frame
, 0},
4575 {"prologue", s_alpha_prologue
, 0},
4576 /* COFF debugging related pseudos. */
4577 {"begin", s_alpha_coff_wrapper
, 0},
4578 {"bend", s_alpha_coff_wrapper
, 1},
4579 {"def", s_alpha_coff_wrapper
, 2},
4580 {"dim", s_alpha_coff_wrapper
, 3},
4581 {"endef", s_alpha_coff_wrapper
, 4},
4582 {"file", s_alpha_coff_wrapper
, 5},
4583 {"scl", s_alpha_coff_wrapper
, 6},
4584 {"tag", s_alpha_coff_wrapper
, 7},
4585 {"val", s_alpha_coff_wrapper
, 8},
4586 {"loc", s_alpha_coff_wrapper
, 9},
4588 {"prologue", s_ignore
, 0},
4590 {"gprel32", s_alpha_gprel32
, 0},
4591 {"t_floating", s_alpha_float_cons
, 'd'},
4592 {"s_floating", s_alpha_float_cons
, 'f'},
4593 {"f_floating", s_alpha_float_cons
, 'F'},
4594 {"g_floating", s_alpha_float_cons
, 'G'},
4595 {"d_floating", s_alpha_float_cons
, 'D'},
4597 {"proc", s_alpha_proc
, 0},
4598 {"aproc", s_alpha_proc
, 1},
4599 {"set", s_alpha_set
, 0},
4600 {"reguse", s_ignore
, 0},
4601 {"livereg", s_ignore
, 0},
4602 {"base", s_alpha_base
, 0}, /*??*/
4603 {"option", s_ignore
, 0},
4604 {"aent", s_ignore
, 0},
4605 {"ugen", s_ignore
, 0},
4606 {"eflag", s_ignore
, 0},
4608 {"align", s_alpha_align
, 0},
4609 {"double", s_alpha_float_cons
, 'd'},
4610 {"float", s_alpha_float_cons
, 'f'},
4611 {"single", s_alpha_float_cons
, 'f'},
4612 {"ascii", s_alpha_stringer
, 0},
4613 {"asciz", s_alpha_stringer
, 1},
4614 {"string", s_alpha_stringer
, 1},
4615 {"space", s_alpha_space
, 0},
4616 {"skip", s_alpha_space
, 0},
4617 {"zero", s_alpha_space
, 0},
4619 /* Unaligned data pseudos. */
4620 {"uword", s_alpha_ucons
, 2},
4621 {"ulong", s_alpha_ucons
, 4},
4622 {"uquad", s_alpha_ucons
, 8},
4625 /* Dwarf wants these versions of unaligned. */
4626 {"2byte", s_alpha_ucons
, 2},
4627 {"4byte", s_alpha_ucons
, 4},
4628 {"8byte", s_alpha_ucons
, 8},
4631 /* We don't do any optimizing, so we can safely ignore these. */
4632 {"noalias", s_ignore
, 0},
4633 {"alias", s_ignore
, 0},
4635 {"arch", s_alpha_arch
, 0},
4641 /* Build a BFD section with its flags set appropriately for the .lita,
4642 .lit8, or .lit4 sections. */
4645 create_literal_section (name
, secp
, symp
)
4650 segT current_section
= now_seg
;
4651 int current_subsec
= now_subseg
;
4654 *secp
= new_sec
= subseg_new (name
, 0);
4655 subseg_set (current_section
, current_subsec
);
4656 bfd_set_section_alignment (stdoutput
, new_sec
, 4);
4657 bfd_set_section_flags (stdoutput
, new_sec
,
4658 SEC_RELOC
| SEC_ALLOC
| SEC_LOAD
| SEC_READONLY
4661 S_CLEAR_EXTERNAL (*symp
= section_symbol (new_sec
));
4666 /* @@@ GP selection voodoo. All of this seems overly complicated and
4667 unnecessary; which is the primary reason it's for ECOFF only. */
4676 vma
= bfd_get_section_vma (foo
, sec
);
4677 if (vma
&& vma
< alpha_gp_value
)
4678 alpha_gp_value
= vma
;
4684 assert (alpha_gp_value
== 0);
4686 /* Get minus-one in whatever width... */
4687 alpha_gp_value
= 0; alpha_gp_value
--;
4689 /* Select the smallest VMA of these existing sections. */
4690 maybe_set_gp (alpha_lita_section
);
4692 /* These were disabled before -- should we use them? */
4693 maybe_set_gp (sdata
);
4694 maybe_set_gp (lit8_sec
);
4695 maybe_set_gp (lit4_sec
);
4698 /* @@ Will a simple 0x8000 work here? If not, why not? */
4699 #define GP_ADJUSTMENT (0x8000 - 0x10)
4701 alpha_gp_value
+= GP_ADJUSTMENT
;
4703 S_SET_VALUE (alpha_gp_symbol
, alpha_gp_value
);
4706 printf (_("Chose GP value of %lx\n"), alpha_gp_value
);
4709 #endif /* OBJ_ECOFF */
4711 /* Called internally to handle all alignment needs. This takes care
4712 of eliding calls to frag_align if'n the cached current alignment
4713 says we've already got it, as well as taking care of the auto-align
4714 feature wrt labels. */
4717 alpha_align (n
, pfill
, label
, force
)
4723 if (alpha_current_align
>= n
)
4729 && (bfd_get_section_flags (stdoutput
, now_seg
) & SEC_CODE
) != 0)
4731 static char const unop
[4] = { 0x00, 0x00, 0xe0, 0x2f };
4732 static char const nopunop
[8] = {
4733 0x1f, 0x04, 0xff, 0x47,
4734 0x00, 0x00, 0xe0, 0x2f
4737 /* First, make sure we're on a four-byte boundary, in case
4738 someone has been putting .byte values into the text
4739 section. The DEC assembler silently fills with unaligned
4740 no-op instructions. This will zero-fill, then nop-fill
4741 with proper alignment. */
4742 if (alpha_current_align
< 2)
4743 frag_align (2, 0, 0);
4744 if (alpha_current_align
< 3)
4745 frag_align_pattern (3, unop
, sizeof unop
, 0);
4747 frag_align_pattern (n
, nopunop
, sizeof nopunop
, 0);
4750 frag_align (n
, 0, 0);
4753 frag_align (n
, *pfill
, 0);
4755 alpha_current_align
= n
;
4759 assert (S_GET_SEGMENT (label
) == now_seg
);
4760 symbol_set_frag (label
, frag_now
);
4761 S_SET_VALUE (label
, (valueT
) frag_now_fix ());
4764 record_alignment(now_seg
, n
);
4766 /* ??? if alpha_flag_relax && force && elf, record the requested alignment
4767 in a reloc for the linker to see. */
4770 /* The Alpha has support for some VAX floating point types, as well as for
4771 IEEE floating point. We consider IEEE to be the primary floating point
4772 format, and sneak in the VAX floating point support here. */
4773 #define md_atof vax_md_atof
4774 #include "config/atof-vax.c"