1 /* tc-mmix.c -- Assembler for Don Knuth's MMIX.
2 Copyright (C) 2001, 2002 Free Software Foundation.
4 This file is part of GAS, the GNU Assembler.
6 GAS is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GAS is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GAS; see the file COPYING. If not, write to
18 the Free Software Foundation, 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
21 /* Knuth's assembler mmixal does not provide a relocatable format; mmo is
22 to be considered a final link-format. In the final link, we make mmo,
23 but for relocatable files, we use ELF.
25 One goal is to provide a superset of what mmixal does, including
26 compatible syntax, but the main purpose is to serve GCC. */
34 #include "opcode/mmix.h"
35 #include "safe-ctype.h"
36 #include "dwarf2dbg.h"
39 /* Something to describe what we need to do with a fixup before output,
40 for example assert something of what it became or make a relocation. */
42 enum mmix_fixup_action
46 mmix_fixup_register_or_adjust_for_byte
49 static int get_spec_regno PARAMS ((char *));
50 static int get_operands PARAMS ((int, char *, expressionS[]));
51 static int get_putget_operands
52 PARAMS ((struct mmix_opcode *, char *, expressionS[]));
53 static void s_prefix PARAMS ((int));
54 static void s_greg PARAMS ((int));
55 static void s_loc PARAMS ((int));
56 static void s_bspec PARAMS ((int));
57 static void s_espec PARAMS ((int));
58 static void mmix_s_local PARAMS ((int));
59 static void mmix_greg_internal PARAMS ((char *));
60 static void mmix_set_geta_branch_offset PARAMS ((char *, offsetT value));
61 static void mmix_set_jmp_offset PARAMS ((char *, offsetT));
62 static void mmix_fill_nops PARAMS ((char *, int));
63 static int cmp_greg_symbol_fixes PARAMS ((const PTR, const PTR));
64 static int cmp_greg_val_greg_symbol_fixes
65 PARAMS ((const PTR p1, const PTR p2));
66 static void mmix_handle_rest_of_empty_line PARAMS ((void));
67 static void mmix_discard_rest_of_line PARAMS ((void));
68 static void mmix_byte PARAMS ((void));
69 static void mmix_cons PARAMS ((int));
70 static void mmix_frob_local_reloc PARAMS ((bfd *, asection *, PTR));
72 /* Continue the tradition of symbols.c; use control characters to enforce
73 magic. These are used when replacing e.g. 8F and 8B so we can handle
74 such labels correctly with the common parser hooks. */
75 #define MAGIC_FB_BACKWARD_CHAR '\003'
76 #define MAGIC_FB_FORWARD_CHAR '\004'
78 /* Copy the location of a frag to a fix. */
79 #define COPY_FR_WHERE_TO_FX(FRAG, FIX) \
82 (FIX)->fx_file = (FRAG)->fr_file; \
83 (FIX)->fx_line = (FRAG)->fr_line; \
87 const char *md_shortopts = "x";
88 static int current_fb_label = -1;
89 static char *pending_label = NULL;
91 static bfd_vma lowest_text_loc = (bfd_vma) -1;
92 static int text_has_contents = 0;
94 /* The alignment of the previous instruction, and a boolean for whether we
95 want to avoid aligning the next WYDE, TETRA, OCTA or insn. */
96 static int last_alignment = 0;
97 static int want_unaligned = 0;
99 static bfd_vma lowest_data_loc = (bfd_vma) -1;
100 static int data_has_contents = 0;
102 /* The fragS of the instruction being assembled. Only valid from within
104 fragS *mmix_opcode_frag = NULL;
106 /* Raw GREGs as appearing in input. These may be fewer than the number
108 static int n_of_raw_gregs = 0;
113 } mmix_raw_gregs[MAX_GREGS];
115 /* Fixups for all unique GREG registers. We store the fixups here in
116 md_convert_frag, then we use the array to convert
117 BFD_RELOC_MMIX_BASE_PLUS_OFFSET fixups in tc_gen_reloc. The index is
118 just a running number and is not supposed to be correlated to a
120 static fixS *mmix_gregs[MAX_GREGS];
121 static int n_of_cooked_gregs = 0;
123 /* Pointing to the register section we use for output. */
124 static asection *real_reg_section;
126 /* For each symbol; unknown or section symbol, we keep a list of GREG
127 definitions sorted on increasing offset. It seems no use keeping count
128 to allocate less room than the maximum number of gregs when we've found
129 one for a section or symbol. */
130 struct mmix_symbol_gregs
133 struct mmix_symbol_greg_fixes
137 /* A signed type, since we may have GREGs pointing slightly before the
138 contents of a section. */
140 } greg_fixes[MAX_GREGS];
143 /* Should read insert a colon on something that starts in column 0 on
145 static int label_without_colon_this_line = 1;
147 /* Should we expand operands for external symbols? */
148 static int expand_op = 1;
150 /* Should we warn when expanding operands? FIXME: test-cases for when -x
152 static int warn_on_expansion = 1;
154 /* Should we merge non-zero GREG register definitions? */
155 static int merge_gregs = 1;
157 /* Should we pass on undefined BFD_RELOC_MMIX_BASE_PLUS_OFFSET relocs
158 (missing suitable GREG definitions) to the linker? */
159 static int allocate_undefined_gregs_in_linker = 0;
161 /* Should we emit built-in symbols? */
162 static int predefined_syms = 1;
164 /* Should we allow anything but the listed special register name
165 (e.g. equated symbols)? */
166 static int equated_spec_regs = 1;
168 /* Do we require standard GNU syntax? */
169 int mmix_gnu_syntax = 0;
171 /* Do we globalize all symbols? */
172 int mmix_globalize_symbols = 0;
174 /* Do we know that the next semicolon is at the end of the operands field
175 (in mmixal mode; constant 1 in GNU mode)? */
176 int mmix_next_semicolon_is_eoln = 1;
178 /* Do we have a BSPEC in progress? */
179 static int doing_bspec = 0;
180 static char *bspec_file;
181 static unsigned int bspec_line;
183 struct option md_longopts[] =
185 #define OPTION_RELAX (OPTION_MD_BASE)
186 #define OPTION_NOEXPAND (OPTION_RELAX + 1)
187 #define OPTION_NOMERGEGREG (OPTION_NOEXPAND + 1)
188 #define OPTION_NOSYMS (OPTION_NOMERGEGREG + 1)
189 #define OPTION_GNU_SYNTAX (OPTION_NOSYMS + 1)
190 #define OPTION_GLOBALIZE_SYMBOLS (OPTION_GNU_SYNTAX + 1)
191 #define OPTION_FIXED_SPEC_REGS (OPTION_GLOBALIZE_SYMBOLS + 1)
192 #define OPTION_LINKER_ALLOCATED_GREGS (OPTION_FIXED_SPEC_REGS + 1)
193 {"linkrelax", no_argument, NULL, OPTION_RELAX},
194 {"no-expand", no_argument, NULL, OPTION_NOEXPAND},
195 {"no-merge-gregs", no_argument, NULL, OPTION_NOMERGEGREG},
196 {"no-predefined-syms", no_argument, NULL, OPTION_NOSYMS},
197 {"gnu-syntax", no_argument, NULL, OPTION_GNU_SYNTAX},
198 {"globalize-symbols", no_argument, NULL, OPTION_GLOBALIZE_SYMBOLS},
199 {"fixed-special-register-names", no_argument, NULL,
200 OPTION_FIXED_SPEC_REGS},
201 {"linker-allocated-gregs", no_argument, NULL,
202 OPTION_LINKER_ALLOCATED_GREGS},
203 {NULL, no_argument, NULL, 0}
206 size_t md_longopts_size = sizeof (md_longopts);
208 static struct hash_control *mmix_opcode_hash;
210 /* We use these when implementing the PREFIX pseudo. */
211 char *mmix_current_prefix;
212 struct obstack mmix_sym_obstack;
215 /* For MMIX, we encode the relax_substateT:s (in e.g. fr_substate) as one
216 bit length, and the relax-type shifted on top of that. There seems to
217 be no point in making the relaxation more fine-grained; the linker does
218 that better and we might interfere by changing non-optimal relaxations
219 into other insns that cannot be relaxed as easily.
221 Groups for MMIX relaxing:
224 extra length: zero or three insns.
227 extra length: zero or five insns.
230 extra length: zero or four insns.
233 extra length: zero or four insns. */
235 #define STATE_GETA (1)
236 #define STATE_BCC (2)
237 #define STATE_PUSHJ (3)
238 #define STATE_JMP (4)
239 #define STATE_GREG (5)
241 /* No fine-grainedness here. */
242 #define STATE_LENGTH_MASK (1)
244 #define STATE_ZERO (0)
245 #define STATE_MAX (1)
247 /* More descriptive name for convenience. */
248 /* FIXME: We should start on something different, not MAX. */
249 #define STATE_UNDF STATE_MAX
251 /* FIXME: For GREG, we must have other definitions; UNDF == MAX isn't
252 appropriate; we need it the other way round. This value together with
253 fragP->tc_frag_data shows what state the frag is in: tc_frag_data
254 non-NULL means 0, NULL means 8 bytes. */
255 #define STATE_GREG_UNDF ENCODE_RELAX (STATE_GREG, STATE_ZERO)
256 #define STATE_GREG_DEF ENCODE_RELAX (STATE_GREG, STATE_MAX)
258 /* These displacements are relative to the adress following the opcode
259 word of the instruction. The catch-all states have zero for "reach"
260 and "next" entries. */
262 #define GETA_0F (65536 * 4 - 8)
263 #define GETA_0B (-65536 * 4 - 4)
265 #define GETA_MAX_LEN 4*4
269 #define BCC_0F GETA_0F
270 #define BCC_0B GETA_0B
272 #define BCC_MAX_LEN 6*4
273 #define BCC_5F GETA_3F
274 #define BCC_5B GETA_3B
276 #define PUSHJ_0F GETA_0F
277 #define PUSHJ_0B GETA_0B
279 #define PUSHJ_MAX_LEN 5*4
280 #define PUSHJ_4F GETA_3F
281 #define PUSHJ_4B GETA_3B
283 #define JMP_0F (65536 * 256 * 4 - 8)
284 #define JMP_0B (-65536 * 256 * 4 - 4)
286 #define JMP_MAX_LEN 5*4
290 #define RELAX_ENCODE_SHIFT 1
291 #define ENCODE_RELAX(what, length) (((what) << RELAX_ENCODE_SHIFT) + (length))
293 const relax_typeS mmix_relax_table[] =
295 /* Error sentinel (0, 0). */
302 {GETA_0F, GETA_0B, 0, ENCODE_RELAX (STATE_GETA, STATE_MAX)},
306 GETA_MAX_LEN - 4, 0},
309 {BCC_0F, BCC_0B, 0, ENCODE_RELAX (STATE_BCC, STATE_MAX)},
316 {PUSHJ_0F, PUSHJ_0B, 0, ENCODE_RELAX (STATE_PUSHJ, STATE_MAX)},
320 PUSHJ_MAX_LEN - 4, 0},
323 {JMP_0F, JMP_0B, 0, ENCODE_RELAX (STATE_JMP, STATE_MAX)},
329 /* GREG (5, 0), (5, 1), though the table entry isn't used. */
330 {0, 0, 0, 0}, {0, 0, 0, 0}
333 const pseudo_typeS md_pseudo_table[] =
335 /* Support " .greg sym,expr" syntax. */
338 /* Support " .bspec expr" syntax. */
339 {"bspec", s_bspec, 1},
341 /* Support " .espec" syntax. */
342 {"espec", s_espec, 1},
344 /* Support " .local $45" syntax. */
345 {"local", mmix_s_local, 1},
347 /* Support DWARF2 debugging info. */
348 {"file", dwarf2_directive_file, 0},
349 {"loc", dwarf2_directive_loc, 0},
354 const char mmix_comment_chars[] = "%!";
356 /* A ':' is a valid symbol character in mmixal. It's the prefix
357 delimiter, but other than that, it works like a symbol character,
358 except that we strip one off at the beginning of symbols. An '@' is a
359 symbol by itself (for the current location); space around it must not
361 const char mmix_symbol_chars[] = ":@";
363 const char line_comment_chars[] = "*#";
365 const char line_separator_chars[] = ";";
367 const char mmix_exp_chars[] = "eE";
369 const char mmix_flt_chars[] = "rf";
372 /* Fill in the offset-related part of GETA or Bcc. */
375 mmix_set_geta_branch_offset (opcodep, value)
386 md_number_to_chars (opcodep + 2, value, 2);
389 /* Fill in the offset-related part of JMP. */
392 mmix_set_jmp_offset (opcodep, value)
398 value += 65536 * 256 * 4;
403 md_number_to_chars (opcodep + 1, value, 3);
406 /* Fill in NOP:s for the expanded part of GETA/JMP/Bcc/PUSHJ. */
409 mmix_fill_nops (opcodep, n)
415 for (i = 0; i < n; i++)
416 md_number_to_chars (opcodep + i*4, SWYM_INSN_BYTE << 24, 4);
419 /* See macro md_parse_name in tc-mmix.h. */
422 mmix_current_location (fn, exp)
423 void (*fn) PARAMS ((expressionS *));
431 /* Get up to three operands, filling them into the exp array.
432 General idea and code stolen from the tic80 port. */
435 get_operands (max_operands, s, exp)
444 while (nextchar == ',')
446 /* Skip leading whitespace */
447 while (*p == ' ' || *p == '\t')
450 /* Check to see if we have any operands left to parse */
451 if (*p == 0 || *p == '\n' || *p == '\r')
455 else if (numexp == max_operands)
457 /* This seems more sane than saying "too many operands". We'll
458 get here only if the trailing trash starts with a comma. */
459 as_bad (_("invalid operands"));
460 mmix_discard_rest_of_line ();
464 /* Begin operand parsing at the current scan point. */
466 input_line_pointer = p;
467 expression (&exp[numexp]);
469 if (exp[numexp].X_op == O_illegal)
471 as_bad (_("invalid operands"));
473 else if (exp[numexp].X_op == O_absent)
475 as_bad (_("missing operand"));
479 p = input_line_pointer;
481 /* Skip leading whitespace */
482 while (*p == ' ' || *p == '\t')
487 /* If we allow "naked" comments, ignore the rest of the line. */
490 mmix_handle_rest_of_empty_line ();
491 input_line_pointer--;
494 /* Mark the end of the valid operands with an illegal expression. */
495 exp[numexp].X_op = O_illegal;
500 /* Get the value of a special register, or -1 if the name does not match
501 one. NAME is a null-terminated string. */
504 get_spec_regno (name)
515 /* Well, it's a short array and we'll most often just match the first
517 for (i = 0; mmix_spec_regs[i].name != NULL; i++)
518 if (strcmp (name, mmix_spec_regs[i].name) == 0)
519 return mmix_spec_regs[i].number;
524 /* For GET and PUT, parse the register names "manually", so we don't use
527 get_putget_operands (insn, operands, exp)
528 struct mmix_opcode *insn;
532 expressionS *expp_reg;
533 expressionS *expp_sreg;
535 char *sregend = operands;
540 /* Skip leading whitespace */
541 while (*p == ' ' || *p == '\t')
544 input_line_pointer = p;
546 if (insn->operands == mmix_operands_get)
551 expression (expp_reg);
553 p = input_line_pointer;
555 /* Skip whitespace */
556 while (*p == ' ' || *p == '\t')
563 /* Skip whitespace */
564 while (*p == ' ' || *p == '\t')
567 input_line_pointer = sregp;
568 c = get_symbol_end ();
569 sregend = input_line_pointer;
577 /* Initialize to error state in case we'll never call expression on
579 expp_reg->X_op = O_illegal;
582 c = get_symbol_end ();
583 sregend = p = input_line_pointer;
586 /* Skip whitespace */
587 while (*p == ' ' || *p == '\t')
594 /* Skip whitespace */
595 while (*p == ' ' || *p == '\t')
598 input_line_pointer = p;
599 expression (expp_reg);
604 regno = get_spec_regno (sregp);
607 /* Let the caller issue errors; we've made sure the operands are
609 if (expp_reg->X_op != O_illegal
610 && expp_reg->X_op != O_absent
613 expp_sreg->X_op = O_register;
614 expp_sreg->X_add_number = regno + 256;
620 /* Handle MMIX-specific option. */
623 md_parse_option (c, arg)
625 char *arg ATTRIBUTE_UNUSED;
630 warn_on_expansion = 0;
631 allocate_undefined_gregs_in_linker = 1;
638 case OPTION_NOEXPAND:
642 case OPTION_NOMERGEGREG:
648 equated_spec_regs = 0;
651 case OPTION_GNU_SYNTAX:
653 label_without_colon_this_line = 0;
656 case OPTION_GLOBALIZE_SYMBOLS:
657 mmix_globalize_symbols = 1;
660 case OPTION_FIXED_SPEC_REGS:
661 equated_spec_regs = 0;
664 case OPTION_LINKER_ALLOCATED_GREGS:
665 allocate_undefined_gregs_in_linker = 1;
675 /* Display MMIX-specific help text. */
678 md_show_usage (stream)
681 fprintf (stream, _(" MMIX-specific command line options:\n"));
682 fprintf (stream, _("\
683 -fixed-special-register-names\n\
684 Allow only the original special register names.\n"));
685 fprintf (stream, _("\
686 -globalize-symbols Make all symbols global.\n"));
687 fprintf (stream, _("\
688 -gnu-syntax Turn off mmixal syntax compatibility.\n"));
689 fprintf (stream, _("\
690 -relax Create linker relaxable code.\n"));
691 fprintf (stream, _("\
692 -no-predefined-syms Do not provide mmixal built-in constants.\n\
693 Implies -fixed-special-register-names.\n"));
694 fprintf (stream, _("\
695 -no-expand Do not expand GETA, branches, PUSHJ or JUMP\n\
696 into multiple instructions.\n"));
697 fprintf (stream, _("\
698 -no-merge-gregs Do not merge GREG definitions with nearby values.\n"));
699 fprintf (stream, _("\
700 -linker-allocated-gregs If there's no suitable GREG definition for the\
701 operands of an instruction, let the linker resolve.\n"));
702 fprintf (stream, _("\
703 -x Do not warn when an operand to GETA, a branch,\n\
704 PUSHJ or JUMP is not known to be within range.\n\
705 The linker will catch any errors. Implies\n\
706 -linker-allocated-gregs."));
709 /* Step to end of line, but don't step over the end of the line. */
712 mmix_discard_rest_of_line ()
714 while (*input_line_pointer
715 && (! is_end_of_line [(unsigned char) *input_line_pointer]
716 || TC_EOL_IN_INSN (input_line_pointer)))
717 input_line_pointer++;
720 /* Act as demand_empty_rest_of_line if we're in strict GNU syntax mode,
721 otherwise just ignore the rest of the line (and skip the end-of-line
725 mmix_handle_rest_of_empty_line ()
728 demand_empty_rest_of_line ();
731 mmix_discard_rest_of_line ();
732 input_line_pointer++;
736 /* Initialize GAS MMIX specifics. */
742 const struct mmix_opcode *opcode;
744 /* We assume nobody will use this, so don't allocate any room. */
745 obstack_begin (&mmix_sym_obstack, 0);
747 /* This will break the day the "lex" thingy changes. For now, it's the
748 only way to make ':' part of a name, and a name beginner. */
749 lex_type [':'] = (LEX_NAME | LEX_BEGIN_NAME);
751 mmix_opcode_hash = hash_new ();
754 = bfd_make_section_old_way (stdoutput, MMIX_REG_SECTION_NAME);
756 for (opcode = mmix_opcodes; opcode->name; opcode++)
757 hash_insert (mmix_opcode_hash, opcode->name, (char *) opcode);
759 /* We always insert the ordinary registers 0..255 as registers. */
760 for (i = 0; i < 256; i++)
764 /* Alternatively, we could diddle with '$' and the following number,
765 but keeping the registers as symbols helps keep parsing simple. */
766 sprintf (buf, "$%d", i);
767 symbol_table_insert (symbol_new (buf, reg_section, i,
768 &zero_address_frag));
771 /* Insert mmixal built-in names if allowed. */
774 for (i = 0; mmix_spec_regs[i].name != NULL; i++)
775 symbol_table_insert (symbol_new (mmix_spec_regs[i].name,
777 mmix_spec_regs[i].number + 256,
778 &zero_address_frag));
780 /* FIXME: Perhaps these should be recognized as specials; as field
781 names for those instructions. */
782 symbol_table_insert (symbol_new ("ROUND_CURRENT", reg_section, 512,
783 &zero_address_frag));
784 symbol_table_insert (symbol_new ("ROUND_OFF", reg_section, 512 + 1,
785 &zero_address_frag));
786 symbol_table_insert (symbol_new ("ROUND_UP", reg_section, 512 + 2,
787 &zero_address_frag));
788 symbol_table_insert (symbol_new ("ROUND_DOWN", reg_section, 512 + 3,
789 &zero_address_frag));
790 symbol_table_insert (symbol_new ("ROUND_NEAR", reg_section, 512 + 4,
791 &zero_address_frag));
795 /* Assemble one insn in STR. */
801 char *operands = str;
802 char modified_char = 0;
803 struct mmix_opcode *instruction;
804 fragS *opc_fragP = NULL;
805 int max_operands = 3;
807 /* Note that the struct frag member fr_literal in frags.h is char[], so
808 I have to make this a plain char *. */
809 /* unsigned */ char *opcodep = NULL;
814 /* Move to end of opcode. */
816 is_part_of_name (*operands);
820 if (ISSPACE (*operands))
822 modified_char = *operands;
826 instruction = (struct mmix_opcode *) hash_find (mmix_opcode_hash, str);
827 if (instruction == NULL)
829 as_bad (_("unknown opcode: `%s'"), str);
831 /* Avoid "unhandled label" errors. */
832 pending_label = NULL;
836 /* Put back the character after the opcode. */
837 if (modified_char != 0)
838 operands[-1] = modified_char;
840 input_line_pointer = operands;
842 /* Is this a mmixal pseudodirective? */
843 if (instruction->type == mmix_type_pseudo)
845 /* For mmixal compatibility, a label for an instruction (and
846 emitting pseudo) refers to the _aligned_ address. We emit the
847 label here for the pseudos that don't handle it themselves. When
848 having an fb-label, emit it here, and increment the counter after
850 switch (instruction->operands)
852 case mmix_operands_loc:
853 case mmix_operands_byte:
854 case mmix_operands_prefix:
855 case mmix_operands_local:
856 case mmix_operands_bspec:
857 case mmix_operands_espec:
858 if (current_fb_label >= 0)
859 colon (fb_label_name (current_fb_label, 1));
860 else if (pending_label != NULL)
862 colon (pending_label);
863 pending_label = NULL;
871 /* Some of the pseudos emit contents, others don't. Set a
872 contents-emitted flag when we emit something into .text */
873 switch (instruction->operands)
875 case mmix_operands_loc:
880 case mmix_operands_byte:
885 case mmix_operands_wyde:
890 case mmix_operands_tetra:
895 case mmix_operands_octa:
900 case mmix_operands_prefix:
905 case mmix_operands_local:
910 case mmix_operands_bspec:
915 case mmix_operands_espec:
921 BAD_CASE (instruction->operands);
924 /* These are all working like the pseudo functions in read.c:s_...,
925 in that they step over the end-of-line marker at the end of the
926 line. We don't want that here. */
927 input_line_pointer--;
929 /* Step up the fb-label counter if there was a definition on this
931 if (current_fb_label >= 0)
933 fb_label_instance_inc (current_fb_label);
934 current_fb_label = -1;
937 /* Reset any don't-align-next-datum request, unless this was a LOC
939 if (instruction->operands != mmix_operands_loc)
945 /* Not a pseudo; we *will* emit contents. */
946 if (now_seg == data_section)
948 if (lowest_data_loc != (bfd_vma) -1 && (lowest_data_loc & 3) != 0)
950 if (data_has_contents)
951 as_bad (_("specified location wasn't TETRA-aligned"));
952 else if (want_unaligned)
953 as_bad (_("unaligned data at an absolute location is not supported"));
955 lowest_data_loc &= ~(bfd_vma) 3;
956 lowest_data_loc += 4;
959 data_has_contents = 1;
961 else if (now_seg == text_section)
963 if (lowest_text_loc != (bfd_vma) -1 && (lowest_text_loc & 3) != 0)
965 if (text_has_contents)
966 as_bad (_("specified location wasn't TETRA-aligned"));
967 else if (want_unaligned)
968 as_bad (_("unaligned data at an absolute location is not supported"));
970 lowest_text_loc &= ~(bfd_vma) 3;
971 lowest_text_loc += 4;
974 text_has_contents = 1;
977 /* After a sequence of BYTEs or WYDEs, we need to get to instruction
978 alignment. For other pseudos, a ".p2align 2" is supposed to be
979 inserted by the user. */
980 if (last_alignment < 2 && ! want_unaligned)
982 frag_align (2, 0, 0);
983 record_alignment (now_seg, 2);
987 /* Reset any don't-align-next-datum request. */
990 /* For mmixal compatibility, a label for an instruction (and emitting
991 pseudo) refers to the _aligned_ address. So we have to emit the
993 if (pending_label != NULL)
995 colon (pending_label);
996 pending_label = NULL;
999 /* We assume that mmix_opcodes keeps having unique mnemonics for each
1000 opcode, so we don't have to iterate over more than one opcode; if the
1001 syntax does not match, then there's a syntax error. */
1003 /* Operands have little or no context and are all comma-separated; it is
1004 easier to parse each expression first. */
1005 switch (instruction->operands)
1007 case mmix_operands_reg_yz:
1008 case mmix_operands_pop:
1009 case mmix_operands_regaddr:
1010 case mmix_operands_pushj:
1011 case mmix_operands_get:
1012 case mmix_operands_put:
1013 case mmix_operands_set:
1014 case mmix_operands_save:
1015 case mmix_operands_unsave:
1019 case mmix_operands_sync:
1020 case mmix_operands_jmp:
1021 case mmix_operands_resume:
1025 /* The original 3 is fine for the rest. */
1030 /* If this is GET or PUT, and we don't do allow those names to be
1031 equated, we need to parse the names ourselves, so we don't pick up a
1032 user label instead of the special register. */
1033 if (! equated_spec_regs
1034 && (instruction->operands == mmix_operands_get
1035 || instruction->operands == mmix_operands_put))
1036 n_operands = get_putget_operands (instruction, operands, exp);
1038 n_operands = get_operands (max_operands, operands, exp);
1040 /* If there's a fb-label on the current line, set that label. This must
1041 be done *after* evaluating expressions of operands, since neither a
1042 "1B" nor a "1F" refers to "1H" on the same line. */
1043 if (current_fb_label >= 0)
1045 fb_label_instance_inc (current_fb_label);
1046 colon (fb_label_name (current_fb_label, 0));
1047 current_fb_label = -1;
1050 /* We also assume that the length of the instruction is at least 4, the
1051 size of an unexpanded instruction. We need a self-contained frag
1052 since we want the relocation to point to the instruction, not the
1055 opcodep = frag_more (4);
1056 mmix_opcode_frag = opc_fragP = frag_now;
1057 frag_now->fr_opcode = opcodep;
1059 /* Mark start of insn for DWARF2 debug features. */
1060 if (OUTPUT_FLAVOR == bfd_target_elf_flavour)
1061 dwarf2_emit_insn (4);
1063 md_number_to_chars (opcodep, instruction->match, 4);
1065 switch (instruction->operands)
1067 case mmix_operands_jmp:
1068 if (n_operands == 0 && ! mmix_gnu_syntax)
1069 /* Zeros are in place - nothing needs to be done when we have no
1073 /* Add a frag for a JMP relaxation; we need room for max four
1074 extra instructions. We don't do any work around here to check if
1075 we can determine the offset right away. */
1076 if (n_operands != 1 || exp[0].X_op == O_register)
1078 as_bad (_("invalid operand to opcode %s: `%s'"),
1079 instruction->name, operands);
1084 frag_var (rs_machine_dependent, 4*4, 0,
1085 ENCODE_RELAX (STATE_JMP, STATE_UNDF),
1086 exp[0].X_add_symbol,
1087 exp[0].X_add_number,
1090 fix_new_exp (opc_fragP, opcodep - opc_fragP->fr_literal, 4,
1091 exp + 0, 1, BFD_RELOC_MMIX_ADDR27);
1094 case mmix_operands_pushj:
1095 /* We take care of PUSHJ in full here. */
1097 || ((exp[0].X_op == O_constant || exp[0].X_op == O_register)
1098 && (exp[0].X_add_number > 255 || exp[0].X_add_number < 0)))
1100 as_bad (_("invalid operands to opcode %s: `%s'"),
1101 instruction->name, operands);
1105 if (exp[0].X_op == O_register || exp[0].X_op == O_constant)
1106 opcodep[1] = exp[0].X_add_number;
1108 fix_new_exp (opc_fragP, opcodep - opc_fragP->fr_literal + 1,
1109 1, exp + 0, 0, BFD_RELOC_MMIX_REG_OR_BYTE);
1112 frag_var (rs_machine_dependent, PUSHJ_MAX_LEN - 4, 0,
1113 ENCODE_RELAX (STATE_PUSHJ, STATE_UNDF),
1114 exp[1].X_add_symbol,
1115 exp[1].X_add_number,
1118 fix_new_exp (opc_fragP, opcodep - opc_fragP->fr_literal, 4,
1119 exp + 1, 1, BFD_RELOC_MMIX_ADDR19);
1122 case mmix_operands_regaddr:
1123 /* GETA/branch: Add a frag for relaxation. We don't do any work
1124 around here to check if we can determine the offset right away. */
1125 if (n_operands != 2 || exp[1].X_op == O_register)
1127 as_bad (_("invalid operands to opcode %s: `%s'"),
1128 instruction->name, operands);
1133 fix_new_exp (opc_fragP, opcodep - opc_fragP->fr_literal, 4,
1134 exp + 1, 1, BFD_RELOC_MMIX_ADDR19);
1135 else if (instruction->type == mmix_type_condbranch)
1136 frag_var (rs_machine_dependent, BCC_MAX_LEN - 4, 0,
1137 ENCODE_RELAX (STATE_BCC, STATE_UNDF),
1138 exp[1].X_add_symbol,
1139 exp[1].X_add_number,
1142 frag_var (rs_machine_dependent, GETA_MAX_LEN - 4, 0,
1143 ENCODE_RELAX (STATE_GETA, STATE_UNDF),
1144 exp[1].X_add_symbol,
1145 exp[1].X_add_number,
1153 switch (instruction->operands)
1155 case mmix_operands_regs:
1156 /* We check the number of operands here, since we're in a
1157 FALLTHROUGH sequence in the next switch. */
1158 if (n_operands != 3 || exp[2].X_op == O_constant)
1160 as_bad (_("invalid operands to opcode %s: `%s'"),
1161 instruction->name, operands);
1165 case mmix_operands_regs_z:
1166 if (n_operands != 3)
1168 as_bad (_("invalid operands to opcode %s: `%s'"),
1169 instruction->name, operands);
1173 case mmix_operands_reg_yz:
1174 case mmix_operands_roundregs_z:
1175 case mmix_operands_roundregs:
1176 case mmix_operands_regs_z_opt:
1177 case mmix_operands_neg:
1178 case mmix_operands_regaddr:
1179 case mmix_operands_get:
1180 case mmix_operands_set:
1181 case mmix_operands_save:
1183 || (exp[0].X_op == O_register && exp[0].X_add_number > 255))
1185 as_bad (_("invalid operands to opcode %s: `%s'"),
1186 instruction->name, operands);
1190 if (exp[0].X_op == O_register)
1191 opcodep[1] = exp[0].X_add_number;
1193 fix_new_exp (opc_fragP, opcodep - opc_fragP->fr_literal + 1,
1194 1, exp + 0, 0, BFD_RELOC_MMIX_REG);
1201 /* A corresponding once-over for those who take an 8-bit constant as
1202 their first operand. */
1203 switch (instruction->operands)
1205 case mmix_operands_pushgo:
1206 /* PUSHGO: X is a constant, but can be expressed as a register.
1207 We handle X here and use the common machinery of T,X,3,$ for
1208 the rest of the operands. */
1210 || ((exp[0].X_op == O_constant || exp[0].X_op == O_register)
1211 && (exp[0].X_add_number > 255 || exp[0].X_add_number < 0)))
1213 as_bad (_("invalid operands to opcode %s: `%s'"),
1214 instruction->name, operands);
1217 else if (exp[0].X_op == O_constant || exp[0].X_op == O_register)
1218 opcodep[1] = exp[0].X_add_number;
1220 fix_new_exp (opc_fragP, opcodep - opc_fragP->fr_literal + 1,
1221 1, exp + 0, 0, BFD_RELOC_MMIX_REG_OR_BYTE);
1224 case mmix_operands_pop:
1225 if ((n_operands == 0 || n_operands == 1) && ! mmix_gnu_syntax)
1228 case mmix_operands_x_regs_z:
1230 || (exp[0].X_op == O_constant
1231 && (exp[0].X_add_number > 255
1232 || exp[0].X_add_number < 0)))
1234 as_bad (_("invalid operands to opcode %s: `%s'"),
1235 instruction->name, operands);
1239 if (exp[0].X_op == O_constant)
1240 opcodep[1] = exp[0].X_add_number;
1242 /* FIXME: This doesn't bring us unsignedness checking. */
1243 fix_new_exp (opc_fragP, opcodep - opc_fragP->fr_literal + 1,
1244 1, exp + 0, 0, BFD_RELOC_8);
1249 /* Handle the rest. */
1250 switch (instruction->operands)
1252 case mmix_operands_set:
1253 /* SET: Either two registers, "$X,$Y", with Z field as zero, or
1254 "$X,YZ", meaning change the opcode to SETL. */
1256 || (exp[1].X_op == O_constant
1257 && (exp[1].X_add_number > 0xffff || exp[1].X_add_number < 0)))
1259 as_bad (_("invalid operands to opcode %s: `%s'"),
1260 instruction->name, operands);
1264 if (exp[1].X_op == O_constant)
1266 /* There's an ambiguity with "SET $0,Y" when Y isn't defined
1267 yet. To keep things simple, we assume that Y is then a
1268 register, and only change the opcode if Y is defined at this
1271 There's no compatibility problem with mmixal, since it emits
1272 errors if the field is not defined at this point. */
1273 md_number_to_chars (opcodep, SETL_INSN_BYTE, 1);
1275 opcodep[2] = (exp[1].X_add_number >> 8) & 255;
1276 opcodep[3] = exp[1].X_add_number & 255;
1280 case mmix_operands_x_regs_z:
1281 /* SYNCD: "X,$Y,$Z|Z". */
1283 case mmix_operands_regs:
1284 /* Three registers, $X,$Y,$Z. */
1286 case mmix_operands_regs_z:
1287 /* Operands "$X,$Y,$Z|Z", number of arguments checked above. */
1289 case mmix_operands_pushgo:
1290 /* Operands "$X|X,$Y,$Z|Z", optional Z. */
1292 case mmix_operands_regs_z_opt:
1293 /* Operands "$X,$Y,$Z|Z", with $Z|Z being optional, default 0. Any
1294 operands not completely decided yet are postponed to later in
1295 assembly (but not until link-time yet). */
1297 if ((n_operands != 2 && n_operands != 3)
1298 || (exp[1].X_op == O_register && exp[1].X_add_number > 255)
1300 && ((exp[2].X_op == O_register
1301 && exp[2].X_add_number > 255
1303 || (exp[2].X_op == O_constant
1304 && (exp[2].X_add_number > 255
1305 || exp[2].X_add_number < 0)))))
1307 as_bad (_("invalid operands to opcode %s: `%s'"),
1308 instruction->name, operands);
1312 if (n_operands == 2)
1316 /* The last operand is immediate whenever we see just two
1318 opcodep[0] |= IMM_OFFSET_BIT;
1320 /* Now, we could either have an implied "0" as the Z operand, or
1321 it could be the constant of a "base address plus offset". It
1322 depends on whether it is allowed; only memory operations, as
1323 signified by instruction->type and "T" and "X" operand types,
1324 and it depends on whether we find a register in the second
1326 if (exp[1].X_op == O_register && exp[1].X_add_number <= 255)
1328 /* A zero then; all done. */
1329 opcodep[2] = exp[1].X_add_number;
1333 /* Not known as a register. Is base address plus offset
1334 allowed, or can we assume that it is a register anyway? */
1335 if ((instruction->operands != mmix_operands_regs_z_opt
1336 && instruction->operands != mmix_operands_x_regs_z
1337 && instruction->operands != mmix_operands_pushgo)
1338 || (instruction->type != mmix_type_memaccess_octa
1339 && instruction->type != mmix_type_memaccess_tetra
1340 && instruction->type != mmix_type_memaccess_wyde
1341 && instruction->type != mmix_type_memaccess_byte
1342 && instruction->type != mmix_type_memaccess_block
1343 && instruction->type != mmix_type_jsr
1344 && instruction->type != mmix_type_branch))
1346 fix_new_exp (opc_fragP, opcodep - opc_fragP->fr_literal + 2,
1347 1, exp + 1, 0, BFD_RELOC_MMIX_REG);
1351 /* To avoid getting a NULL add_symbol for constants and then
1352 catching a SEGV in write_relocs since it doesn't handle
1353 constants well for relocs other than PC-relative, we need to
1354 pass expressions as symbols and use fix_new, not fix_new_exp. */
1355 sym = make_expr_symbol (exp + 1);
1357 /* Now we know it can be a "base address plus offset". Add
1358 proper fixup types so we can handle this later, when we've
1359 parsed everything. */
1360 fix_new (opc_fragP, opcodep - opc_fragP->fr_literal + 2,
1361 8, sym, 0, 0, BFD_RELOC_MMIX_BASE_PLUS_OFFSET);
1365 if (exp[1].X_op == O_register)
1366 opcodep[2] = exp[1].X_add_number;
1368 fix_new_exp (opc_fragP, opcodep - opc_fragP->fr_literal + 2,
1369 1, exp + 1, 0, BFD_RELOC_MMIX_REG);
1371 /* In mmixal compatibility mode, we allow special registers as
1372 constants for the Z operand. They have 256 added to their
1373 register numbers, so the right thing will happen if we just treat
1374 those as constants. */
1375 if (exp[2].X_op == O_register && exp[2].X_add_number <= 255)
1376 opcodep[3] = exp[2].X_add_number;
1377 else if (exp[2].X_op == O_constant
1378 || (exp[2].X_op == O_register && exp[2].X_add_number > 255))
1380 opcodep[3] = exp[2].X_add_number;
1381 opcodep[0] |= IMM_OFFSET_BIT;
1384 fix_new_exp (opc_fragP, opcodep - opc_fragP->fr_literal + 3,
1386 (instruction->operands == mmix_operands_set
1387 || instruction->operands == mmix_operands_regs)
1388 ? BFD_RELOC_MMIX_REG : BFD_RELOC_MMIX_REG_OR_BYTE);
1391 case mmix_operands_pop:
1392 /* POP, one eight and one 16-bit operand. */
1393 if (n_operands == 0 && ! mmix_gnu_syntax)
1395 if (n_operands == 1 && ! mmix_gnu_syntax)
1396 goto a_single_24_bit_number_operand;
1398 case mmix_operands_reg_yz:
1399 /* A register and a 16-bit unsigned number. */
1401 || exp[1].X_op == O_register
1402 || (exp[1].X_op == O_constant
1403 && (exp[1].X_add_number > 0xffff || exp[1].X_add_number < 0)))
1405 as_bad (_("invalid operands to opcode %s: `%s'"),
1406 instruction->name, operands);
1410 if (exp[1].X_op == O_constant)
1412 opcodep[2] = (exp[1].X_add_number >> 8) & 255;
1413 opcodep[3] = exp[1].X_add_number & 255;
1416 /* FIXME: This doesn't bring us unsignedness checking. */
1417 fix_new_exp (opc_fragP, opcodep - opc_fragP->fr_literal + 2,
1418 2, exp + 1, 0, BFD_RELOC_16);
1421 case mmix_operands_jmp:
1422 /* A JMP. Everyhing is already done. */
1425 case mmix_operands_roundregs:
1426 /* Two registers with optional rounding mode or constant in between. */
1427 if ((n_operands == 3 && exp[2].X_op == O_constant)
1428 || (n_operands == 2 && exp[1].X_op == O_constant))
1430 as_bad (_("invalid operands to opcode %s: `%s'"),
1431 instruction->name, operands);
1435 case mmix_operands_roundregs_z:
1436 /* Like FLOT, "$X,ROUND_MODE,$Z|Z", but the rounding mode is
1437 optional and can be the corresponding constant. */
1439 /* Which exp index holds the second operand (not the rounding
1441 int op2no = n_operands - 1;
1443 if ((n_operands != 2 && n_operands != 3)
1444 || ((exp[op2no].X_op == O_register
1445 && exp[op2no].X_add_number > 255)
1446 || (exp[op2no].X_op == O_constant
1447 && (exp[op2no].X_add_number > 255
1448 || exp[op2no].X_add_number < 0)))
1450 /* We don't allow for the rounding mode to be deferred; it
1451 must be determined in the "first pass". It cannot be a
1452 symbol equated to a rounding mode, but defined after
1454 && ((exp[1].X_op == O_register
1455 && exp[1].X_add_number < 512)
1456 || (exp[1].X_op == O_constant
1457 && exp[1].X_add_number < 0
1458 && exp[1].X_add_number > 4)
1459 || (exp[1].X_op != O_register
1460 && exp[1].X_op != O_constant))))
1462 as_bad (_("invalid operands to opcode %s: `%s'"),
1463 instruction->name, operands);
1467 /* Add rounding mode if present. */
1468 if (n_operands == 3)
1469 opcodep[2] = exp[1].X_add_number & 255;
1471 if (exp[op2no].X_op == O_register)
1472 opcodep[3] = exp[op2no].X_add_number;
1473 else if (exp[op2no].X_op == O_constant)
1475 opcodep[3] = exp[op2no].X_add_number;
1476 opcodep[0] |= IMM_OFFSET_BIT;
1479 fix_new_exp (opc_fragP, opcodep - opc_fragP->fr_literal + 3,
1481 instruction->operands == mmix_operands_roundregs
1482 ? BFD_RELOC_MMIX_REG
1483 : BFD_RELOC_MMIX_REG_OR_BYTE);
1487 case mmix_operands_sync:
1488 a_single_24_bit_number_operand:
1490 || exp[0].X_op == O_register
1491 || (exp[0].X_op == O_constant
1492 && (exp[0].X_add_number > 0xffffff || exp[0].X_add_number < 0)))
1494 as_bad (_("invalid operands to opcode %s: `%s'"),
1495 instruction->name, operands);
1499 if (exp[0].X_op == O_constant)
1501 opcodep[1] = (exp[0].X_add_number >> 16) & 255;
1502 opcodep[2] = (exp[0].X_add_number >> 8) & 255;
1503 opcodep[3] = exp[0].X_add_number & 255;
1506 /* FIXME: This doesn't bring us unsignedness checking. */
1507 fix_new_exp (opc_fragP, opcodep - opc_fragP->fr_literal + 1,
1508 3, exp + 0, 0, BFD_RELOC_24);
1511 case mmix_operands_neg:
1512 /* Operands "$X,Y,$Z|Z"; NEG or NEGU. Y is optional, 0 is default. */
1514 if ((n_operands != 3 && n_operands != 2)
1515 || (n_operands == 3 && exp[1].X_op == O_register)
1516 || ((exp[1].X_op == O_constant || exp[1].X_op == O_register)
1517 && (exp[1].X_add_number > 255 || exp[1].X_add_number < 0))
1519 && ((exp[2].X_op == O_register && exp[2].X_add_number > 255)
1520 || (exp[2].X_op == O_constant
1521 && (exp[2].X_add_number > 255
1522 || exp[2].X_add_number < 0)))))
1524 as_bad (_("invalid operands to opcode %s: `%s'"),
1525 instruction->name, operands);
1529 if (n_operands == 2)
1531 if (exp[1].X_op == O_register)
1532 opcodep[3] = exp[1].X_add_number;
1533 else if (exp[1].X_op == O_constant)
1535 opcodep[3] = exp[1].X_add_number;
1536 opcodep[0] |= IMM_OFFSET_BIT;
1539 fix_new_exp (opc_fragP, opcodep - opc_fragP->fr_literal + 3,
1540 1, exp + 1, 0, BFD_RELOC_MMIX_REG_OR_BYTE);
1544 if (exp[1].X_op == O_constant)
1545 opcodep[2] = exp[1].X_add_number;
1547 fix_new_exp (opc_fragP, opcodep - opc_fragP->fr_literal + 2,
1548 1, exp + 1, 0, BFD_RELOC_8);
1550 if (exp[2].X_op == O_register)
1551 opcodep[3] = exp[2].X_add_number;
1552 else if (exp[2].X_op == O_constant)
1554 opcodep[3] = exp[2].X_add_number;
1555 opcodep[0] |= IMM_OFFSET_BIT;
1558 fix_new_exp (opc_fragP, opcodep - opc_fragP->fr_literal + 3,
1559 1, exp + 2, 0, BFD_RELOC_MMIX_REG_OR_BYTE);
1562 case mmix_operands_regaddr:
1563 /* A GETA/branch-type. */
1566 case mmix_operands_get:
1567 /* "$X,spec_reg"; GET.
1568 Like with rounding modes, we demand that the special register or
1569 symbol is already defined when we get here at the point of use. */
1571 || (exp[1].X_op == O_register
1572 && (exp[1].X_add_number < 256 || exp[1].X_add_number >= 512))
1573 || (exp[1].X_op == O_constant
1574 && (exp[1].X_add_number < 0 || exp[1].X_add_number > 256))
1575 || (exp[1].X_op != O_constant && exp[1].X_op != O_register))
1577 as_bad (_("invalid operands to opcode %s: `%s'"),
1578 instruction->name, operands);
1582 opcodep[3] = exp[1].X_add_number - 256;
1585 case mmix_operands_put:
1586 /* "spec_reg,$Z|Z"; PUT. */
1588 || (exp[0].X_op == O_register
1589 && (exp[0].X_add_number < 256 || exp[0].X_add_number >= 512))
1590 || (exp[0].X_op == O_constant
1591 && (exp[0].X_add_number < 0 || exp[0].X_add_number > 256))
1592 || (exp[0].X_op != O_constant && exp[0].X_op != O_register))
1594 as_bad (_("invalid operands to opcode %s: `%s'"),
1595 instruction->name, operands);
1599 opcodep[1] = exp[0].X_add_number - 256;
1601 /* Note that the Y field is zero. */
1603 if (exp[1].X_op == O_register)
1604 opcodep[3] = exp[1].X_add_number;
1605 else if (exp[1].X_op == O_constant)
1607 opcodep[3] = exp[1].X_add_number;
1608 opcodep[0] |= IMM_OFFSET_BIT;
1611 fix_new_exp (opc_fragP, opcodep - opc_fragP->fr_literal + 3,
1612 1, exp + 1, 0, BFD_RELOC_MMIX_REG_OR_BYTE);
1615 case mmix_operands_save:
1618 || exp[1].X_op != O_constant
1619 || exp[1].X_add_number != 0)
1621 as_bad (_("invalid operands to opcode %s: `%s'"),
1622 instruction->name, operands);
1627 case mmix_operands_unsave:
1628 if (n_operands < 2 && ! mmix_gnu_syntax)
1630 if (n_operands == 1)
1632 if (exp[0].X_op == O_register)
1633 opcodep[3] = exp[0].X_add_number;
1635 fix_new_exp (opc_fragP, opcodep - opc_fragP->fr_literal + 3,
1636 1, exp, 0, BFD_RELOC_MMIX_REG);
1641 /* "0,$Z"; UNSAVE. */
1643 || exp[0].X_op != O_constant
1644 || exp[0].X_add_number != 0
1645 || exp[1].X_op == O_constant
1646 || (exp[1].X_op == O_register
1647 && exp[1].X_add_number > 255))
1649 as_bad (_("invalid operands to opcode %s: `%s'"),
1650 instruction->name, operands);
1654 if (exp[1].X_op == O_register)
1655 opcodep[3] = exp[1].X_add_number;
1657 fix_new_exp (opc_fragP, opcodep - opc_fragP->fr_literal + 3,
1658 1, exp + 1, 0, BFD_RELOC_MMIX_REG);
1661 case mmix_operands_xyz_opt:
1662 /* SWYM, TRIP, TRAP: zero, one, two or three operands. */
1663 if (n_operands == 0 && ! mmix_gnu_syntax)
1664 /* Zeros are in place - nothing needs to be done for zero
1665 operands. We don't allow this in GNU syntax mode, because it
1666 was believed that the risk of missing to supply an operand is
1667 higher than the benefit of not having to specify a zero. */
1669 else if (n_operands == 1 && exp[0].X_op != O_register)
1671 if (exp[0].X_op == O_constant)
1673 if (exp[0].X_add_number > 255*255*255
1674 || exp[0].X_add_number < 0)
1676 as_bad (_("invalid operands to opcode %s: `%s'"),
1677 instruction->name, operands);
1682 opcodep[1] = (exp[0].X_add_number >> 16) & 255;
1683 opcodep[2] = (exp[0].X_add_number >> 8) & 255;
1684 opcodep[3] = exp[0].X_add_number & 255;
1688 fix_new_exp (opc_fragP, opcodep - opc_fragP->fr_literal + 1,
1689 3, exp, 0, BFD_RELOC_24);
1691 else if (n_operands == 2
1692 && exp[0].X_op != O_register
1693 && exp[1].X_op != O_register)
1697 if (exp[0].X_op == O_constant)
1699 if (exp[0].X_add_number > 255
1700 || exp[0].X_add_number < 0)
1702 as_bad (_("invalid operands to opcode %s: `%s'"),
1703 instruction->name, operands);
1707 opcodep[1] = exp[0].X_add_number & 255;
1710 fix_new_exp (opc_fragP, opcodep - opc_fragP->fr_literal + 1,
1711 1, exp, 0, BFD_RELOC_8);
1713 if (exp[1].X_op == O_constant)
1715 if (exp[1].X_add_number > 255*255
1716 || exp[1].X_add_number < 0)
1718 as_bad (_("invalid operands to opcode %s: `%s'"),
1719 instruction->name, operands);
1724 opcodep[2] = (exp[1].X_add_number >> 8) & 255;
1725 opcodep[3] = exp[1].X_add_number & 255;
1729 fix_new_exp (opc_fragP, opcodep - opc_fragP->fr_literal + 2,
1730 2, exp + 1, 0, BFD_RELOC_16);
1732 else if (n_operands == 3
1733 && exp[0].X_op != O_register
1734 && exp[1].X_op != O_register
1735 && exp[2].X_op != O_register)
1737 /* Three operands. */
1739 if (exp[0].X_op == O_constant)
1741 if (exp[0].X_add_number > 255
1742 || exp[0].X_add_number < 0)
1744 as_bad (_("invalid operands to opcode %s: `%s'"),
1745 instruction->name, operands);
1749 opcodep[1] = exp[0].X_add_number & 255;
1752 fix_new_exp (opc_fragP, opcodep - opc_fragP->fr_literal + 1,
1753 1, exp, 0, BFD_RELOC_8);
1755 if (exp[1].X_op == O_constant)
1757 if (exp[1].X_add_number > 255
1758 || exp[1].X_add_number < 0)
1760 as_bad (_("invalid operands to opcode %s: `%s'"),
1761 instruction->name, operands);
1765 opcodep[2] = exp[1].X_add_number & 255;
1768 fix_new_exp (opc_fragP, opcodep - opc_fragP->fr_literal + 2,
1769 1, exp + 1, 0, BFD_RELOC_8);
1771 if (exp[2].X_op == O_constant)
1773 if (exp[2].X_add_number > 255
1774 || exp[2].X_add_number < 0)
1776 as_bad (_("invalid operands to opcode %s: `%s'"),
1777 instruction->name, operands);
1781 opcodep[3] = exp[2].X_add_number & 255;
1784 fix_new_exp (opc_fragP, opcodep - opc_fragP->fr_literal + 3,
1785 1, exp + 2, 0, BFD_RELOC_8);
1787 else if (n_operands <= 3
1788 && (strcmp (instruction->name, "trip") == 0
1789 || strcmp (instruction->name, "trap") == 0))
1791 /* The meaning of operands to TRIP and TRAP are not defined, so
1792 we add combinations not handled above here as we find them. */
1793 if (n_operands == 3)
1795 /* Don't require non-register operands. Always generate
1796 fixups, so we don't have to copy lots of code and create
1797 maintanance problems. TRIP is supposed to be a rare
1798 instruction, so the overhead should not matter. We
1799 aren't allowed to fix_new_exp for an expression which is
1800 an O_register at this point, however. */
1801 if (exp[0].X_op == O_register)
1802 opcodep[1] = exp[0].X_add_number;
1804 fix_new_exp (opc_fragP, opcodep - opc_fragP->fr_literal + 1,
1805 1, exp, 0, BFD_RELOC_MMIX_REG_OR_BYTE);
1806 if (exp[1].X_op == O_register)
1807 opcodep[2] = exp[1].X_add_number;
1809 fix_new_exp (opc_fragP, opcodep - opc_fragP->fr_literal + 2,
1810 1, exp + 1, 0, BFD_RELOC_MMIX_REG_OR_BYTE);
1811 if (exp[2].X_op == O_register)
1812 opcodep[3] = exp[2].X_add_number;
1814 fix_new_exp (opc_fragP, opcodep - opc_fragP->fr_literal + 3,
1815 1, exp + 2, 0, BFD_RELOC_MMIX_REG_OR_BYTE);
1817 else if (n_operands == 2)
1819 if (exp[0].X_op == O_register)
1820 opcodep[2] = exp[0].X_add_number;
1822 fix_new_exp (opc_fragP, opcodep - opc_fragP->fr_literal + 2,
1823 1, exp, 0, BFD_RELOC_MMIX_REG_OR_BYTE);
1824 if (exp[1].X_op == O_register)
1825 opcodep[3] = exp[1].X_add_number;
1827 fix_new_exp (opc_fragP, opcodep - opc_fragP->fr_literal + 3,
1828 1, exp + 1, 0, BFD_RELOC_MMIX_REG_OR_BYTE);
1832 as_bad (_("unsupported operands to %s: `%s'"),
1833 instruction->name, operands);
1839 as_bad (_("invalid operands to opcode %s: `%s'"),
1840 instruction->name, operands);
1845 case mmix_operands_resume:
1846 if (n_operands == 0 && ! mmix_gnu_syntax)
1850 || exp[0].X_op == O_register
1851 || (exp[0].X_op == O_constant
1852 && (exp[0].X_add_number < 0
1853 || exp[0].X_add_number > 255)))
1855 as_bad (_("invalid operands to opcode %s: `%s'"),
1856 instruction->name, operands);
1860 if (exp[0].X_op == O_constant)
1861 opcodep[3] = exp[0].X_add_number;
1863 fix_new_exp (opc_fragP, opcodep - opc_fragP->fr_literal + 3,
1864 1, exp + 0, 0, BFD_RELOC_8);
1867 case mmix_operands_pushj:
1868 /* All is done for PUSHJ already. */
1872 BAD_CASE (instruction->operands);
1876 /* For the benefit of insns that start with a digit, we assemble by way of
1877 tc_unrecognized_line too, through this function. */
1880 mmix_assemble_return_nonzero (str)
1883 int last_error_count = had_errors ();
1887 /* Normal instruction handling downcases, so we must too. */
1888 while (ISALNUM (*s2))
1890 if (ISUPPER ((unsigned char) *s2))
1891 *s2 = TOLOWER (*s2);
1895 /* Cut the line for sake of the assembly. */
1896 for (s2 = str; *s2 && *s2 != '\n'; s2++)
1904 return had_errors () == last_error_count;
1907 /* The PREFIX pseudo. */
1911 int unused ATTRIBUTE_UNUSED;
1918 p = input_line_pointer;
1920 c = get_symbol_end ();
1922 /* Reseting prefix? */
1923 if (*p == ':' && p[1] == 0)
1924 mmix_current_prefix = NULL;
1927 /* Put this prefix on the mmix symbols obstack. We could malloc and
1928 free it separately, but then we'd have to worry about that.
1929 People using up memory on prefixes have other problems. */
1930 obstack_grow (&mmix_sym_obstack, p, strlen (p) + 1);
1931 p = obstack_finish (&mmix_sym_obstack);
1933 /* Accumulate prefixes, and strip a leading ':'. */
1934 if (mmix_current_prefix != NULL || *p == ':')
1935 p = mmix_prefix_name (p);
1937 mmix_current_prefix = p;
1940 *input_line_pointer = c;
1942 mmix_handle_rest_of_empty_line ();
1945 /* We implement prefixes by using the tc_canonicalize_symbol_name hook,
1946 and store each prefixed name on a (separate) obstack. This means that
1947 the name is on the "notes" obstack in non-prefixed form and on the
1948 mmix_sym_obstack in prefixed form, but currently it is not worth
1949 rewriting the whole GAS symbol handling to improve "hooking" to avoid
1950 that. (It might be worth a rewrite for other reasons, though). */
1953 mmix_prefix_name (shortname)
1956 if (*shortname == ':')
1957 return shortname + 1;
1959 if (mmix_current_prefix == NULL)
1960 as_fatal (_("internal: mmix_prefix_name but empty prefix"));
1962 if (*shortname == '$')
1965 obstack_grow (&mmix_sym_obstack, mmix_current_prefix,
1966 strlen (mmix_current_prefix));
1967 obstack_grow (&mmix_sym_obstack, shortname, strlen (shortname) + 1);
1968 return obstack_finish (&mmix_sym_obstack);
1971 /* The GREG pseudo. At LABEL, we have the name of a symbol that we
1972 want to make a register symbol, and which should be initialized with
1973 the value in the expression at INPUT_LINE_POINTER (defaulting to 0).
1974 Either and (perhaps less meaningful) both may be missing. LABEL must
1975 be persistent, perhaps allocated on an obstack. */
1978 mmix_greg_internal (label)
1981 expressionS *expP = &mmix_raw_gregs[n_of_raw_gregs].exp;
1983 /* Don't set the section to register contents section before the
1984 expression has been parsed; it may refer to the current position. */
1987 /* FIXME: Check that no expression refers to the register contents
1988 section. May need to be done in elf64-mmix.c. */
1989 if (expP->X_op == O_absent)
1991 /* Default to zero if the expression was absent. */
1992 expP->X_op = O_constant;
1993 expP->X_add_number = 0;
1994 expP->X_unsigned = 0;
1995 expP->X_add_symbol = NULL;
1996 expP->X_op_symbol = NULL;
1999 /* We must handle prefixes here, as we save the labels and expressions
2000 to be output later. */
2001 mmix_raw_gregs[n_of_raw_gregs].label
2002 = mmix_current_prefix == NULL ? label : mmix_prefix_name (label);
2004 if (n_of_raw_gregs == MAX_GREGS - 1)
2005 as_bad (_("too many GREG registers allocated (max %d)"), MAX_GREGS);
2009 mmix_handle_rest_of_empty_line ();
2012 /* The ".greg label,expr" worker. */
2016 int unused ATTRIBUTE_UNUSED;
2020 p = input_line_pointer;
2022 /* This will skip over what can be a symbol and zero out the next
2023 character, which we assume is a ',' or other meaningful delimiter.
2024 What comes after that is the initializer expression for the
2026 c = get_symbol_end ();
2028 if (! is_end_of_line [(unsigned char) c])
2029 input_line_pointer++;
2033 /* The label must be persistent; it's not used until after all input
2035 obstack_grow (&mmix_sym_obstack, p, strlen (p) + 1);
2036 mmix_greg_internal (obstack_finish (&mmix_sym_obstack));
2039 mmix_greg_internal (NULL);
2042 /* The "BSPEC expr" worker. */
2046 int unused ATTRIBUTE_UNUSED;
2050 char secname[sizeof (MMIX_OTHER_SPEC_SECTION_PREFIX) + 20]
2051 = MMIX_OTHER_SPEC_SECTION_PREFIX;
2055 /* Get a constant expression which we can evaluate *now*. Supporting
2056 more complex (though assembly-time computable) expressions is
2057 feasible but Too Much Work for something of unknown usefulness like
2059 expsec = expression (&exp);
2060 mmix_handle_rest_of_empty_line ();
2062 /* Check that we don't have another BSPEC in progress. */
2065 as_bad (_("BSPEC already active. Nesting is not supported."));
2069 if (exp.X_op != O_constant
2070 || expsec != absolute_section
2071 || exp.X_add_number < 0
2072 || exp.X_add_number > 65535)
2074 as_bad (_("invalid BSPEC expression"));
2075 exp.X_add_number = 0;
2078 n = (int) exp.X_add_number;
2080 sprintf (secname + strlen (MMIX_OTHER_SPEC_SECTION_PREFIX), "%d", n);
2081 sec = bfd_get_section_by_name (stdoutput, secname);
2084 /* We need a non-volatile name as it will be stored in the section
2086 char *newsecname = xstrdup (secname);
2087 sec = bfd_make_section (stdoutput, newsecname);
2090 as_fatal (_("can't create section %s"), newsecname);
2092 if (!bfd_set_section_flags (stdoutput, sec,
2093 bfd_get_section_flags (stdoutput, sec)
2095 as_fatal (_("can't set section flags for section %s"), newsecname);
2098 /* Tell ELF about the pending section change. */
2099 obj_elf_section_change_hook ();
2100 subseg_set (sec, 0);
2102 /* Save position for missing ESPEC. */
2103 as_where (&bspec_file, &bspec_line);
2108 /* The "ESPEC" worker. */
2112 int unused ATTRIBUTE_UNUSED;
2114 /* First, check that we *do* have a BSPEC in progress. */
2117 as_bad (_("ESPEC without preceding BSPEC"));
2121 mmix_handle_rest_of_empty_line ();
2124 /* When we told ELF about the section change in s_bspec, it stored the
2125 previous section for us so we can get at it with the equivalent of a
2126 .previous pseudo. */
2127 obj_elf_previous (0);
2130 /* The " .local expr" and " local expr" worker. We make a BFD_MMIX_LOCAL
2131 relocation against the current position against the expression.
2132 Implementing this by means of contents in a section lost. */
2135 mmix_s_local (unused)
2136 int unused ATTRIBUTE_UNUSED;
2140 /* Don't set the section to register contents section before the
2141 expression has been parsed; it may refer to the current position in
2142 some contorted way. */
2145 if (exp.X_op == O_absent)
2147 as_bad (_("missing local expression"));
2150 else if (exp.X_op == O_register)
2152 /* fix_new_exp doesn't like O_register. Should be configurable.
2153 We're fine with a constant here, though. */
2154 exp.X_op = O_constant;
2157 fix_new_exp (frag_now, 0, 0, &exp, 0, BFD_RELOC_MMIX_LOCAL);
2158 mmix_handle_rest_of_empty_line ();
2161 /* Set fragP->fr_var to the initial guess of the size of a relaxable insn
2162 and return it. Sizes of other instructions are not known. This
2163 function may be called multiple times. */
2166 md_estimate_size_before_relax (fragP, segment)
2172 #define HANDLE_RELAXABLE(state) \
2173 case ENCODE_RELAX (state, STATE_UNDF): \
2174 if (fragP->fr_symbol != NULL \
2175 && S_GET_SEGMENT (fragP->fr_symbol) == segment) \
2177 /* The symbol lies in the same segment - a relaxable case. */ \
2179 = ENCODE_RELAX (state, STATE_ZERO); \
2183 switch (fragP->fr_subtype)
2185 HANDLE_RELAXABLE (STATE_GETA);
2186 HANDLE_RELAXABLE (STATE_BCC);
2187 HANDLE_RELAXABLE (STATE_PUSHJ);
2188 HANDLE_RELAXABLE (STATE_JMP);
2190 case ENCODE_RELAX (STATE_GETA, STATE_ZERO):
2191 case ENCODE_RELAX (STATE_BCC, STATE_ZERO):
2192 case ENCODE_RELAX (STATE_PUSHJ, STATE_ZERO):
2193 case ENCODE_RELAX (STATE_JMP, STATE_ZERO):
2194 /* When relaxing a section for the second time, we don't need to do
2195 anything except making sure that fr_var is set right. */
2198 case STATE_GREG_DEF:
2199 length = fragP->tc_frag_data != NULL ? 0 : 8;
2200 fragP->fr_var = length;
2202 /* Don't consult the relax_table; it isn't valid for this
2208 BAD_CASE (fragP->fr_subtype);
2211 length = mmix_relax_table[fragP->fr_subtype].rlx_length;
2212 fragP->fr_var = length;
2217 /* Turn a string in input_line_pointer into a floating point constant of type
2218 type, and store the appropriate bytes in *litP. The number of LITTLENUMS
2219 emitted is stored in *sizeP . An error message is returned, or NULL on
2223 md_atof (type, litP, sizeP)
2229 LITTLENUM_TYPE words[4];
2235 /* FIXME: Having 'f' in mmix_flt_chars (and here) makes it
2236 problematic to also have a forward reference in an expression.
2237 The testsuite wants it, and it's customary.
2238 We'll deal with the real problems when they come; we share the
2239 problem with most other ports. */
2249 return _("bad call to md_atof");
2252 t = atof_ieee (input_line_pointer, type, words);
2254 input_line_pointer = t;
2258 for (i = 0; i < prec; i++)
2260 md_number_to_chars (litP, (valueT) words[i], 2);
2266 /* Convert variable-sized frags into one or more fixups. */
2269 md_convert_frag (abfd, sec, fragP)
2270 bfd *abfd ATTRIBUTE_UNUSED;
2271 segT sec ATTRIBUTE_UNUSED;
2274 /* Pointer to first byte in variable-sized part of the frag. */
2277 /* Pointer to first opcode byte in frag. */
2280 /* Size in bytes of variable-sized part of frag. */
2281 int var_part_size = 0;
2283 /* This is part of *fragP. It contains all information about addresses
2284 and offsets to varying parts. */
2286 unsigned long var_part_offset;
2288 /* This is the frag for the opcode. It, rather than fragP, must be used
2289 when emitting a frag for the opcode. */
2290 fragS *opc_fragP = fragP->tc_frag_data;
2293 /* Where, in file space, does addr point? */
2294 bfd_vma target_address;
2295 bfd_vma opcode_address;
2297 know (fragP->fr_type == rs_machine_dependent);
2299 var_part_offset = fragP->fr_fix;
2300 var_partp = fragP->fr_literal + var_part_offset;
2301 opcodep = fragP->fr_opcode;
2303 symbolP = fragP->fr_symbol;
2306 = ((symbolP ? S_GET_VALUE (symbolP) : 0) + fragP->fr_offset);
2308 /* The opcode that would be extended is the last four "fixed" bytes. */
2309 opcode_address = fragP->fr_address + fragP->fr_fix - 4;
2311 switch (fragP->fr_subtype)
2313 case ENCODE_RELAX (STATE_GETA, STATE_ZERO):
2314 case ENCODE_RELAX (STATE_BCC, STATE_ZERO):
2315 case ENCODE_RELAX (STATE_PUSHJ, STATE_ZERO):
2316 mmix_set_geta_branch_offset (opcodep, target_address - opcode_address);
2320 = fix_new (opc_fragP, opcodep - opc_fragP->fr_literal, 4,
2321 fragP->fr_symbol, fragP->fr_offset, 1,
2322 BFD_RELOC_MMIX_ADDR19);
2323 COPY_FR_WHERE_TO_FX (fragP, tmpfixP);
2328 case ENCODE_RELAX (STATE_JMP, STATE_ZERO):
2329 mmix_set_jmp_offset (opcodep, target_address - opcode_address);
2333 = fix_new (opc_fragP, opcodep - opc_fragP->fr_literal, 4,
2334 fragP->fr_symbol, fragP->fr_offset, 1,
2335 BFD_RELOC_MMIX_ADDR27);
2336 COPY_FR_WHERE_TO_FX (fragP, tmpfixP);
2341 case STATE_GREG_DEF:
2342 if (fragP->tc_frag_data == NULL)
2345 = fix_new (fragP, var_partp - fragP->fr_literal, 8,
2346 fragP->fr_symbol, fragP->fr_offset, 0, BFD_RELOC_64);
2347 COPY_FR_WHERE_TO_FX (fragP, tmpfixP);
2348 mmix_gregs[n_of_cooked_gregs++] = tmpfixP;
2355 #define HANDLE_MAX_RELOC(state, reloc) \
2356 case ENCODE_RELAX (state, STATE_MAX): \
2358 = mmix_relax_table[ENCODE_RELAX (state, STATE_MAX)].rlx_length; \
2359 mmix_fill_nops (var_partp, var_part_size / 4); \
2360 if (warn_on_expansion) \
2361 as_warn_where (fragP->fr_file, fragP->fr_line, \
2362 _("operand out of range, instruction expanded")); \
2363 tmpfixP = fix_new (fragP, var_partp - fragP->fr_literal - 4, 8, \
2364 fragP->fr_symbol, fragP->fr_offset, 1, reloc); \
2365 COPY_FR_WHERE_TO_FX (fragP, tmpfixP); \
2368 HANDLE_MAX_RELOC (STATE_GETA, BFD_RELOC_MMIX_GETA);
2369 HANDLE_MAX_RELOC (STATE_BCC, BFD_RELOC_MMIX_CBRANCH);
2370 HANDLE_MAX_RELOC (STATE_PUSHJ, BFD_RELOC_MMIX_PUSHJ);
2371 HANDLE_MAX_RELOC (STATE_JMP, BFD_RELOC_MMIX_JMP);
2374 BAD_CASE (fragP->fr_subtype);
2378 fragP->fr_fix += var_part_size;
2382 /* Applies the desired value to the specified location.
2383 Also sets up addends for RELA type relocations.
2384 Stolen from tc-mcore.c.
2386 Note that this function isn't called when linkrelax != 0. */
2389 md_apply_fix3 (fixP, valP, segment)
2394 char *buf = fixP->fx_where + fixP->fx_frag->fr_literal;
2395 /* Note: use offsetT because it is signed, valueT is unsigned. */
2396 offsetT val = (offsetT) * valP;
2398 = (fixP->fx_addsy == NULL
2399 ? absolute_section : S_GET_SEGMENT (fixP->fx_addsy));
2401 /* If the fix is relative to a symbol which is not defined, or, (if
2402 pcrel), not in the same segment as the fix, we cannot resolve it
2404 if (fixP->fx_addsy != NULL
2405 && (! S_IS_DEFINED (fixP->fx_addsy)
2406 || S_IS_WEAK (fixP->fx_addsy)
2407 || (fixP->fx_pcrel && symsec != segment)
2408 || (! fixP->fx_pcrel
2409 && symsec != absolute_section
2410 && ((fixP->fx_r_type != BFD_RELOC_MMIX_REG
2411 && fixP->fx_r_type != BFD_RELOC_MMIX_REG_OR_BYTE)
2412 || (symsec != reg_section
2413 && symsec != real_reg_section)))))
2418 else if (fixP->fx_r_type == BFD_RELOC_MMIX_LOCAL
2419 || fixP->fx_r_type == BFD_RELOC_VTABLE_INHERIT
2420 || fixP->fx_r_type == BFD_RELOC_VTABLE_ENTRY)
2422 /* These are never "fixed". */
2427 /* We assume every other relocation is "fixed". */
2430 switch (fixP->fx_r_type)
2437 case BFD_RELOC_64_PCREL:
2438 case BFD_RELOC_32_PCREL:
2439 case BFD_RELOC_24_PCREL:
2440 case BFD_RELOC_16_PCREL:
2441 case BFD_RELOC_8_PCREL:
2442 md_number_to_chars (buf, val, fixP->fx_size);
2445 case BFD_RELOC_MMIX_ADDR19:
2448 /* This shouldn't happen. */
2449 BAD_CASE (fixP->fx_r_type);
2453 case BFD_RELOC_MMIX_GETA:
2454 case BFD_RELOC_MMIX_CBRANCH:
2455 case BFD_RELOC_MMIX_PUSHJ:
2456 /* If this fixup is out of range, punt to the linker to emit an
2457 error. This should only happen with -no-expand. */
2458 if (val < -(((offsetT) 1 << 19)/2)
2459 || val >= ((offsetT) 1 << 19)/2 - 1
2462 if (warn_on_expansion)
2463 as_warn_where (fixP->fx_file, fixP->fx_line,
2464 _("operand out of range"));
2468 mmix_set_geta_branch_offset (buf, val);
2471 case BFD_RELOC_MMIX_ADDR27:
2474 /* This shouldn't happen. */
2475 BAD_CASE (fixP->fx_r_type);
2479 case BFD_RELOC_MMIX_JMP:
2480 /* If this fixup is out of range, punt to the linker to emit an
2481 error. This should only happen with -no-expand. */
2482 if (val < -(((offsetT) 1 << 27)/2)
2483 || val >= ((offsetT) 1 << 27)/2 - 1
2486 if (warn_on_expansion)
2487 as_warn_where (fixP->fx_file, fixP->fx_line,
2488 _("operand out of range"));
2492 mmix_set_jmp_offset (buf, val);
2495 case BFD_RELOC_MMIX_REG_OR_BYTE:
2496 if (fixP->fx_addsy != NULL
2497 && (S_GET_SEGMENT (fixP->fx_addsy) != real_reg_section
2498 || S_GET_VALUE (fixP->fx_addsy) > 255)
2499 && S_GET_SEGMENT (fixP->fx_addsy) != absolute_section)
2500 as_bad_where (fixP->fx_file, fixP->fx_line,
2501 _("invalid operands"));
2504 /* If this reloc is for a Z field, we need to adjust
2505 the opcode if we got a constant here.
2506 FIXME: Can we make this more robust? */
2508 if ((fixP->fx_where & 3) == 3
2509 && (fixP->fx_addsy == NULL
2510 || S_GET_SEGMENT (fixP->fx_addsy) == absolute_section))
2511 buf[-3] |= IMM_OFFSET_BIT;
2513 /* We don't want this "symbol" appearing in output, because that
2516 && S_GET_SEGMENT (fixP->fx_addsy) == real_reg_section)
2517 symbol_clear_used_in_reloc (fixP->fx_addsy);
2520 case BFD_RELOC_MMIX_REG:
2521 if (fixP->fx_addsy == NULL
2522 || S_GET_SEGMENT (fixP->fx_addsy) != real_reg_section
2523 || S_GET_VALUE (fixP->fx_addsy) > 255)
2524 as_bad_where (fixP->fx_file, fixP->fx_line,
2525 _("invalid operands"));
2529 && S_GET_SEGMENT (fixP->fx_addsy) == real_reg_section)
2530 symbol_clear_used_in_reloc (fixP->fx_addsy);
2533 case BFD_RELOC_MMIX_BASE_PLUS_OFFSET:
2534 /* These are never "fixed". */
2538 case BFD_RELOC_MMIX_PUSHJ_1:
2539 case BFD_RELOC_MMIX_PUSHJ_2:
2540 case BFD_RELOC_MMIX_PUSHJ_3:
2541 case BFD_RELOC_MMIX_CBRANCH_J:
2542 case BFD_RELOC_MMIX_CBRANCH_1:
2543 case BFD_RELOC_MMIX_CBRANCH_2:
2544 case BFD_RELOC_MMIX_CBRANCH_3:
2545 case BFD_RELOC_MMIX_GETA_1:
2546 case BFD_RELOC_MMIX_GETA_2:
2547 case BFD_RELOC_MMIX_GETA_3:
2548 case BFD_RELOC_MMIX_JMP_1:
2549 case BFD_RELOC_MMIX_JMP_2:
2550 case BFD_RELOC_MMIX_JMP_3:
2552 BAD_CASE (fixP->fx_r_type);
2557 /* Make sure that for completed fixups we have the value around for
2558 use by e.g. mmix_frob_file. */
2559 fixP->fx_offset = val;
2562 /* A bsearch function for looking up a value against offsets for GREG
2566 cmp_greg_val_greg_symbol_fixes (p1, p2)
2570 offsetT val1 = *(offsetT *) p1;
2571 offsetT val2 = ((struct mmix_symbol_greg_fixes *) p2)->offs;
2573 if (val1 >= val2 && val1 < val2 + 255)
2582 /* Generate a machine-dependent relocation. */
2585 tc_gen_reloc (section, fixP)
2586 asection *section ATTRIBUTE_UNUSED;
2591 + (fixP->fx_addsy != NULL
2592 && !S_IS_WEAK (fixP->fx_addsy)
2593 && !S_IS_COMMON (fixP->fx_addsy)
2594 ? S_GET_VALUE (fixP->fx_addsy) : 0);
2596 bfd_reloc_code_real_type code = BFD_RELOC_NONE;
2597 char *buf = fixP->fx_where + fixP->fx_frag->fr_literal;
2598 symbolS *addsy = fixP->fx_addsy;
2599 asection *addsec = addsy == NULL ? NULL : S_GET_SEGMENT (addsy);
2600 asymbol *baddsy = addsy != NULL ? symbol_get_bfdsym (addsy) : NULL;
2602 = val - (baddsy == NULL || S_IS_COMMON (addsy) || S_IS_WEAK (addsy)
2603 ? 0 : bfd_asymbol_value (baddsy));
2605 /* A single " LOCAL expression" in the wrong section will not work when
2606 linking to MMO; relocations for zero-content sections are then
2607 ignored. Normally, relocations would modify section contents, and
2608 you'd never think or be able to do something like that. The
2609 relocation resulting from a LOCAL directive doesn't have an obvious
2610 and mandatory location. I can't figure out a way to do this better
2611 than just helping the user around this limitation here; hopefully the
2612 code using the local expression is around. Putting the LOCAL
2613 semantics in a relocation still seems right; a section didn't do. */
2614 if (bfd_section_size (section->owner, section) == 0)
2616 (fixP->fx_file, fixP->fx_line,
2617 fixP->fx_r_type == BFD_RELOC_MMIX_LOCAL
2618 /* The BFD_RELOC_MMIX_LOCAL-specific message is supposed to be
2619 user-friendly, though a little bit non-substantial. */
2620 ? _("directive LOCAL must be placed in code or data")
2621 : _("internal confusion: relocation in a section without contents"));
2623 /* FIXME: Range tests for all these. */
2624 switch (fixP->fx_r_type)
2631 code = fixP->fx_r_type;
2633 if (addsy == NULL || bfd_is_abs_section (addsec))
2635 /* Resolve this reloc now, as md_apply_fix3 would have done (not
2636 called if -linkrelax). There is no point in keeping a reloc
2637 to an absolute symbol. No reloc that is subject to
2638 relaxation must be to an absolute symbol; difference
2639 involving symbols in a specific section must be signalled as
2640 an error if the relaxing cannot be expressed; having a reloc
2641 to the resolved (now absolute) value does not help. */
2642 md_number_to_chars (buf, val, fixP->fx_size);
2647 case BFD_RELOC_64_PCREL:
2648 case BFD_RELOC_32_PCREL:
2649 case BFD_RELOC_24_PCREL:
2650 case BFD_RELOC_16_PCREL:
2651 case BFD_RELOC_8_PCREL:
2652 case BFD_RELOC_MMIX_LOCAL:
2653 case BFD_RELOC_VTABLE_INHERIT:
2654 case BFD_RELOC_VTABLE_ENTRY:
2655 case BFD_RELOC_MMIX_GETA:
2656 case BFD_RELOC_MMIX_GETA_1:
2657 case BFD_RELOC_MMIX_GETA_2:
2658 case BFD_RELOC_MMIX_GETA_3:
2659 case BFD_RELOC_MMIX_CBRANCH:
2660 case BFD_RELOC_MMIX_CBRANCH_J:
2661 case BFD_RELOC_MMIX_CBRANCH_1:
2662 case BFD_RELOC_MMIX_CBRANCH_2:
2663 case BFD_RELOC_MMIX_CBRANCH_3:
2664 case BFD_RELOC_MMIX_PUSHJ:
2665 case BFD_RELOC_MMIX_PUSHJ_1:
2666 case BFD_RELOC_MMIX_PUSHJ_2:
2667 case BFD_RELOC_MMIX_PUSHJ_3:
2668 case BFD_RELOC_MMIX_JMP:
2669 case BFD_RELOC_MMIX_JMP_1:
2670 case BFD_RELOC_MMIX_JMP_2:
2671 case BFD_RELOC_MMIX_JMP_3:
2672 case BFD_RELOC_MMIX_ADDR19:
2673 case BFD_RELOC_MMIX_ADDR27:
2674 code = fixP->fx_r_type;
2677 case BFD_RELOC_MMIX_REG_OR_BYTE:
2678 /* If we have this kind of relocation to an unknown symbol or to the
2679 register contents section (that is, to a register), then we can't
2680 resolve the relocation here. */
2682 && (bfd_is_und_section (addsec)
2683 || strcmp (bfd_get_section_name (addsec->owner, addsec),
2684 MMIX_REG_CONTENTS_SECTION_NAME) == 0))
2686 code = fixP->fx_r_type;
2690 /* If the relocation is not to the register section or to the
2691 absolute section (a numeric value), then we have an error. */
2693 && (S_GET_SEGMENT (addsy) != real_reg_section
2696 && ! bfd_is_abs_section (addsec))
2699 /* Set the "immediate" bit of the insn if this relocation is to Z
2700 field when the value is a numeric value, i.e. not a register. */
2701 if ((fixP->fx_where & 3) == 3
2702 && (addsy == NULL || bfd_is_abs_section (addsec)))
2703 buf[-3] |= IMM_OFFSET_BIT;
2708 case BFD_RELOC_MMIX_BASE_PLUS_OFFSET:
2710 && strcmp (bfd_get_section_name (addsec->owner, addsec),
2711 MMIX_REG_CONTENTS_SECTION_NAME) == 0)
2713 /* This changed into a register; the relocation is for the
2714 register-contents section. The constant part remains zero. */
2715 code = BFD_RELOC_MMIX_REG;
2719 /* If we've found out that this was indeed a register, then replace
2720 with the register number. The constant part is already zero.
2722 If we encounter any other defined symbol, then we must find a
2723 suitable register and emit a reloc. */
2724 if (addsy == NULL || addsec != real_reg_section)
2726 struct mmix_symbol_gregs *gregs;
2727 struct mmix_symbol_greg_fixes *fix;
2729 if (S_IS_DEFINED (addsy)
2730 && !bfd_is_com_section (addsec)
2731 && !S_IS_WEAK (addsy))
2733 if (! symbol_section_p (addsy) && ! bfd_is_abs_section (addsec))
2734 as_fatal (_("internal: BFD_RELOC_MMIX_BASE_PLUS_OFFSET not resolved to section"));
2736 /* If this is an absolute symbol sufficiently near
2737 lowest_data_loc, then we canonicalize on the data
2738 section. Note that val is signed here; we may subtract
2739 lowest_data_loc which is unsigned. Careful with those
2741 if (lowest_data_loc != (bfd_vma) -1
2742 && (bfd_vma) val + 256 > lowest_data_loc
2743 && bfd_is_abs_section (addsec))
2745 val -= (offsetT) lowest_data_loc;
2746 addsy = section_symbol (data_section);
2748 /* Likewise text section. */
2749 else if (lowest_text_loc != (bfd_vma) -1
2750 && (bfd_vma) val + 256 > lowest_text_loc
2751 && bfd_is_abs_section (addsec))
2753 val -= (offsetT) lowest_text_loc;
2754 addsy = section_symbol (text_section);
2758 gregs = *symbol_get_tc (addsy);
2760 /* If that symbol does not have any associated GREG definitions,
2761 we can't do anything. */
2763 || (fix = bsearch (&val, gregs->greg_fixes, gregs->n_gregs,
2764 sizeof (gregs->greg_fixes[0]),
2765 cmp_greg_val_greg_symbol_fixes)) == NULL
2766 /* The register must not point *after* the address we want. */
2768 /* Neither must the register point more than 255 bytes
2769 before the address we want. */
2770 || fix->offs + 255 < val)
2772 /* We can either let the linker allocate GREGs
2773 automatically, or emit an error. */
2774 if (allocate_undefined_gregs_in_linker)
2776 /* The values in baddsy and addend are right. */
2777 code = fixP->fx_r_type;
2781 as_bad_where (fixP->fx_file, fixP->fx_line,
2782 _("no suitable GREG definition for operands"));
2787 /* Transform the base-plus-offset reloc for the actual area
2788 to a reloc for the register with the address of the area.
2789 Put addend for register in Z operand. */
2790 buf[1] = val - fix->offs;
2791 code = BFD_RELOC_MMIX_REG;
2793 = (bfd_get_section_by_name (stdoutput,
2794 MMIX_REG_CONTENTS_SECTION_NAME)
2797 addend = fix->fix->fx_frag->fr_address + fix->fix->fx_where;
2800 else if (S_GET_VALUE (addsy) > 255)
2801 as_bad_where (fixP->fx_file, fixP->fx_line,
2802 _("invalid operands"));
2810 case BFD_RELOC_MMIX_REG:
2812 && (bfd_is_und_section (addsec)
2813 || strcmp (bfd_get_section_name (addsec->owner, addsec),
2814 MMIX_REG_CONTENTS_SECTION_NAME) == 0))
2816 code = fixP->fx_r_type;
2821 && (addsec != real_reg_section
2824 && ! bfd_is_und_section (addsec))
2825 /* Drop through to error message. */
2834 /* The others are supposed to be handled by md_apply_fix3.
2835 FIXME: ... which isn't called when -linkrelax. Move over
2836 md_apply_fix3 code here for everything reasonable. */
2840 (fixP->fx_file, fixP->fx_line,
2841 _("operands were not reducible at assembly-time"));
2843 /* Unmark this symbol as used in a reloc, so we don't bump into a BFD
2844 assert when trying to output reg_section. FIXME: A gas bug. */
2846 symbol_clear_used_in_reloc (addsy);
2850 relP = (arelent *) xmalloc (sizeof (arelent));
2852 relP->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *));
2853 *relP->sym_ptr_ptr = baddsy;
2854 relP->address = fixP->fx_frag->fr_address + fixP->fx_where;
2856 relP->addend = addend;
2858 /* If this had been a.out, we would have had a kludge for weak symbols
2861 relP->howto = bfd_reloc_type_lookup (stdoutput, code);
2866 name = S_GET_NAME (addsy);
2868 name = _("<unknown>");
2869 as_fatal (_("cannot generate relocation type for symbol %s, code %s"),
2870 name, bfd_get_reloc_code_name (code));
2876 /* Do some reformatting of a line. FIXME: We could transform a mmixal
2877 line into traditional (GNU?) format, unless #NO_APP, and get rid of all
2878 ugly labels_without_colons etc. */
2881 mmix_handle_mmixal ()
2883 char *s0 = input_line_pointer;
2888 if (pending_label != NULL)
2889 as_fatal (_("internal: unhandled label %s"), pending_label);
2891 if (mmix_gnu_syntax)
2894 /* If the first character is a '.', then it's a pseudodirective, not a
2895 label. Make GAS not handle label-without-colon on this line. We
2896 also don't do mmixal-specific stuff on this line. */
2897 if (input_line_pointer[0] == '.')
2899 label_without_colon_this_line = 0;
2903 /* Don't handle empty lines here. */
2906 if (*s0 == 0 || is_end_of_line [(unsigned int) *s0])
2909 if (! ISSPACE (*s0))
2915 /* If we're on a line with a label, check if it's a mmixal fb-label.
2916 Save an indicator and skip the label; it must be set only after all
2917 fb-labels of expressions are evaluated. */
2918 if (ISDIGIT (input_line_pointer[0])
2919 && input_line_pointer[1] == 'H'
2920 && ISSPACE (input_line_pointer[2]))
2923 current_fb_label = input_line_pointer[0] - '0';
2925 /* We have to skip the label, but also preserve the newlineness of
2926 the previous character, since the caller checks that. It's a
2927 mess we blame on the caller. */
2928 input_line_pointer[1] = input_line_pointer[-1];
2929 input_line_pointer += 2;
2931 s = input_line_pointer;
2932 while (*s && ISSPACE (*s) && ! is_end_of_line[(unsigned int) *s])
2935 /* For errors emitted here, the book-keeping is off by one; the
2936 caller is about to bump the counters. Adjust the error messages. */
2937 if (is_end_of_line [(unsigned int) *s])
2941 as_where (&name, &line);
2942 as_bad_where (name, line + 1,
2943 _("[0-9]H labels may not appear alone on a line"));
2944 current_fb_label = -1;
2950 as_where (&name, &line);
2951 as_bad_where (name, line + 1,
2952 _("[0-9]H labels do not mix with dot-pseudos"));
2953 current_fb_label = -1;
2958 current_fb_label = -1;
2959 if (is_name_beginner (input_line_pointer[0]))
2960 label = input_line_pointer;
2963 s0 = input_line_pointer;
2964 /* Skip over label. */
2965 while (*s0 && is_part_of_name (*s0))
2968 /* Remove trailing ":" off labels, as they'd otherwise be considered
2969 part of the name. But don't do it for local labels. */
2970 if (s0 != input_line_pointer && s0[-1] == ':'
2971 && (s0 - 2 != input_line_pointer
2972 || ! ISDIGIT (s0[-2])))
2974 else if (label != NULL)
2976 /* For labels that don't end in ":", we save it so we can later give
2977 it the same alignment and address as the associated instruction. */
2979 /* Make room for the label including the ending nul. */
2980 int len_0 = s0 - label + 1;
2982 /* Save this label on the MMIX symbol obstack. Saving it on an
2983 obstack is needless for "IS"-pseudos, but it's harmless and we
2984 avoid a little code-cluttering. */
2985 obstack_grow (&mmix_sym_obstack, label, len_0);
2986 pending_label = obstack_finish (&mmix_sym_obstack);
2987 pending_label[len_0 - 1] = 0;
2990 while (*s0 && ISSPACE (*s0) && ! is_end_of_line [(unsigned int) *s0])
2993 if (pending_label != NULL && is_end_of_line [(unsigned int) *s0])
2994 /* Whoops, this was actually a lone label on a line. Like :-ended
2995 labels, we don't attach such labels to the next instruction or
2997 pending_label = NULL;
2999 /* Find local labels of operands. Look for "[0-9][FB]" where the
3000 characters before and after are not part of words. Break if a single
3001 or double quote is seen anywhere. It means we can't have local
3002 labels as part of list with mixed quoted and unquoted members for
3003 mmixal compatibility but we can't have it all. For the moment.
3004 Replace the '<N>B' or '<N>F' with MAGIC_FB_BACKWARD_CHAR<N> and
3005 MAGIC_FB_FORWARD_CHAR<N> respectively. */
3007 /* First make sure we don't have any of the magic characters on the line
3008 appearing as input. */
3013 if (is_end_of_line [(unsigned int) c])
3015 if (c == MAGIC_FB_BACKWARD_CHAR || c == MAGIC_FB_FORWARD_CHAR)
3016 as_bad (_("invalid characters in input"));
3019 /* Scan again, this time looking for ';' after operands. */
3022 /* Skip the insn. */
3026 && ! is_end_of_line[(unsigned int) *s])
3029 /* Skip the spaces after the insn. */
3033 && ! is_end_of_line[(unsigned int) *s])
3036 /* Skip the operands. While doing this, replace [0-9][BF] with
3037 (MAGIC_FB_BACKWARD_CHAR|MAGIC_FB_FORWARD_CHAR)[0-9]. */
3038 while ((c = *s) != 0
3041 && ! is_end_of_line[(unsigned int) c])
3047 /* FIXME: Test-case for semi-colon in string. */
3050 && (! is_end_of_line [(unsigned int) *s] || *s == ';'))
3056 else if (ISDIGIT (c))
3058 if ((s[1] != 'B' && s[1] != 'F')
3059 || is_part_of_name (s[-1])
3060 || is_part_of_name (s[2]))
3065 ? MAGIC_FB_BACKWARD_CHAR : MAGIC_FB_FORWARD_CHAR);
3073 /* Skip any spaces after the operands. */
3077 && !is_end_of_line[(unsigned int) *s])
3080 /* If we're now looking at a semi-colon, then it's an end-of-line
3082 mmix_next_semicolon_is_eoln = (*s == ';');
3084 /* Make IS into an EQU by replacing it with "= ". Only match upper-case
3085 though; let lower-case be a syntax error. */
3087 if (s[0] == 'I' && s[1] == 'S' && ISSPACE (s[2]))
3092 /* Since labels can start without ":", we have to handle "X IS 42"
3093 in full here, or "X" will be parsed as a label to be set at ".". */
3094 input_line_pointer = s;
3096 /* Right after this function ends, line numbers will be bumped if
3097 input_line_pointer[-1] = '\n'. We want accurate line numbers for
3098 the equals call, so we bump them before the call, and make sure
3099 they aren't bumped afterwards. */
3100 bump_line_counters ();
3102 /* A fb-label is valid as an IS-label. */
3103 if (current_fb_label >= 0)
3107 /* We need to save this name on our symbol obstack, since the
3108 string we got in fb_label_name is volatile and will change
3109 with every call to fb_label_name, like those resulting from
3110 parsing the IS-operand. */
3111 fb_name = fb_label_name (current_fb_label, 1);
3112 obstack_grow (&mmix_sym_obstack, fb_name, strlen (fb_name) + 1);
3113 equals (obstack_finish (&mmix_sym_obstack), 0);
3114 fb_label_instance_inc (current_fb_label);
3115 current_fb_label = -1;
3119 if (pending_label == NULL)
3120 as_bad (_("empty label field for IS"));
3122 equals (pending_label, 0);
3123 pending_label = NULL;
3126 /* For mmixal, we can have comments without a comment-start
3128 mmix_handle_rest_of_empty_line ();
3129 input_line_pointer--;
3131 input_line_pointer[-1] = ' ';
3133 else if (s[0] == 'G'
3135 && strncmp (s, "GREG", 4) == 0
3136 && (ISSPACE (s[4]) || is_end_of_line[(unsigned char) s[4]]))
3138 input_line_pointer = s + 4;
3140 /* Right after this function ends, line numbers will be bumped if
3141 input_line_pointer[-1] = '\n'. We want accurate line numbers for
3142 the s_greg call, so we bump them before the call, and make sure
3143 they aren't bumped afterwards. */
3144 bump_line_counters ();
3146 /* A fb-label is valid as a GREG-label. */
3147 if (current_fb_label >= 0)
3151 /* We need to save this name on our symbol obstack, since the
3152 string we got in fb_label_name is volatile and will change
3153 with every call to fb_label_name, like those resulting from
3154 parsing the IS-operand. */
3155 fb_name = fb_label_name (current_fb_label, 1);
3157 /* Make sure we save the canonical name and don't get bitten by
3159 obstack_1grow (&mmix_sym_obstack, ':');
3160 obstack_grow (&mmix_sym_obstack, fb_name, strlen (fb_name) + 1);
3161 mmix_greg_internal (obstack_finish (&mmix_sym_obstack));
3162 fb_label_instance_inc (current_fb_label);
3163 current_fb_label = -1;
3166 mmix_greg_internal (pending_label);
3168 /* Back up before the end-of-line marker that was skipped in
3169 mmix_greg_internal. */
3170 input_line_pointer--;
3171 input_line_pointer[-1] = ' ';
3173 pending_label = NULL;
3175 else if (pending_label != NULL)
3177 input_line_pointer += strlen (pending_label);
3179 /* See comment above about getting line numbers bumped. */
3180 input_line_pointer[-1] = '\n';
3184 /* Give the value of an fb-label rewritten as in mmix_handle_mmixal, when
3185 parsing an expression.
3187 On valid calls, input_line_pointer points at a MAGIC_FB_BACKWARD_CHAR
3188 or MAGIC_FB_BACKWARD_CHAR, followed by an ascii digit for the label.
3189 We fill in the label as an expression. */
3192 mmix_fb_label (expP)
3196 char *fb_internal_name;
3198 /* This doesn't happen when not using mmixal syntax. */
3200 || (input_line_pointer[0] != MAGIC_FB_BACKWARD_CHAR
3201 && input_line_pointer[0] != MAGIC_FB_FORWARD_CHAR))
3204 /* The current backward reference has augmentation 0. A forward
3205 reference has augmentation 1, unless it's the same as a fb-label on
3206 _this_ line, in which case we add one more so we don't refer to it.
3207 This is the semantics of mmixal; it differs to that of common
3208 fb-labels which refer to a here-label on the current line as a
3209 backward reference. */
3211 = fb_label_name (input_line_pointer[1] - '0',
3212 (input_line_pointer[0] == MAGIC_FB_FORWARD_CHAR ? 1 : 0)
3213 + ((input_line_pointer[1] - '0' == current_fb_label
3214 && input_line_pointer[0] == MAGIC_FB_FORWARD_CHAR)
3217 input_line_pointer += 2;
3218 sym = symbol_find_or_make (fb_internal_name);
3220 /* We don't have to clean up unrelated fields here; we just do what the
3221 expr machinery does, but *not* just what it does for [0-9][fb], since
3222 we need to treat those as ordinary symbols sometimes; see testcases
3223 err-byte2.s and fb-2.s. */
3224 if (S_GET_SEGMENT (sym) == absolute_section)
3226 expP->X_op = O_constant;
3227 expP->X_add_number = S_GET_VALUE (sym);
3231 expP->X_op = O_symbol;
3232 expP->X_add_symbol = sym;
3233 expP->X_add_number = 0;
3237 /* See whether we need to force a relocation into the output file.
3238 This is used to force out switch and PC relative relocations when
3242 mmix_force_relocation (fixP)
3245 if (fixP->fx_r_type == BFD_RELOC_MMIX_LOCAL
3246 || fixP->fx_r_type == BFD_RELOC_VTABLE_INHERIT
3247 || fixP->fx_r_type == BFD_RELOC_VTABLE_ENTRY
3248 || fixP->fx_r_type == BFD_RELOC_MMIX_BASE_PLUS_OFFSET)
3251 /* FIXME: This is dubious. Handling of weak symbols should have been
3252 caught before we get here. */
3253 if ((fixP->fx_addsy && S_IS_WEAK (fixP->fx_addsy)))
3259 /* All our pcrel relocations are must-keep. Note that md_apply_fix3 is
3260 called *after* this, and will handle getting rid of the presumed
3261 reloc; a relocation isn't *forced* other than to be handled by
3262 md_apply_fix3 (or tc_gen_reloc if linkrelax). */
3269 /* The location from which a PC relative jump should be calculated,
3270 given a PC relative reloc. */
3273 md_pcrel_from_section (fixP, sec)
3277 if (fixP->fx_addsy != (symbolS *) NULL
3278 && (! S_IS_DEFINED (fixP->fx_addsy)
3279 || S_GET_SEGMENT (fixP->fx_addsy) != sec))
3281 /* The symbol is undefined (or is defined but not in this section).
3282 Let the linker figure it out. */
3286 return (fixP->fx_frag->fr_address + fixP->fx_where);
3289 /* Adjust the symbol table. We make reg_section relative to the real
3292 FIXME: There's a gas bug; should be fixed when the reg_section symbol
3293 is "accidentally" saved for relocs which are really fixups that will be
3297 mmix_adjust_symtab ()
3301 symbolS *regsec = section_symbol (reg_section);
3302 segT realregsec = NULL;
3304 for (prevsym = sym = symbol_rootP;
3306 prevsym = sym, sym = symbol_next (sym))
3307 if (S_GET_SEGMENT (sym) == reg_section)
3310 || (!S_IS_EXTERN (sym) && !symbol_used_in_reloc_p (sym)))
3312 symbol_remove (sym, &symbol_rootP, &symbol_lastP);
3314 /* We make one extra turn, or we'll lose the next symbol. We
3315 assume that the symbol we remove is not the symbol root
3316 (.text normally is). */
3321 /* Change section to the *real* register section, so it gets
3322 proper treatment when writing it out. Only do this for
3323 global symbols. This also means we don't have to check for
3325 if (realregsec == NULL)
3327 = bfd_make_section_old_way (stdoutput, MMIX_REG_SECTION_NAME);
3329 S_SET_SEGMENT (sym, realregsec);
3334 /* This is the expansion of LABELS_WITHOUT_COLONS.
3335 We let md_start_line_hook tweak label_without_colon_this_line, and then
3336 this function returns the tweaked value, and sets it to 1 for the next
3337 line. FIXME: Very, very brittle. Not sure it works the way I
3338 thought at the time I first wrote this. */
3341 mmix_label_without_colon_this_line ()
3343 int retval = label_without_colon_this_line;
3345 if (! mmix_gnu_syntax)
3346 label_without_colon_this_line = 1;
3351 /* This is the expansion of md_relax_frag. We go through the ordinary
3352 relax table function except when the frag is for a GREG. Then we have
3353 to check whether there's another GREG by the same value that we can
3357 mmix_md_relax_frag (seg, fragP, stretch)
3362 if (fragP->fr_subtype != STATE_GREG_DEF
3363 && fragP->fr_subtype != STATE_GREG_UNDF)
3364 return relax_frag (seg, fragP, stretch);
3366 /* If we're defined, we don't grow. */
3367 if (fragP->fr_subtype == STATE_GREG_DEF)
3370 as_fatal (_("internal: unexpected relax type %d:%d"),
3371 fragP->fr_type, fragP->fr_subtype);
3375 /* Various things we punt until all input is seen. */
3384 /* The first frag of GREG:s going into the register contents section. */
3385 fragS *mmix_reg_contents_frags = NULL;
3387 /* Reset prefix. All labels reachable at this point must be
3389 mmix_current_prefix = NULL;
3392 as_bad_where (bspec_file, bspec_line, _("BSPEC without ESPEC."));
3394 /* Emit the low LOC setting of .text. */
3395 if (text_has_contents && lowest_text_loc != (bfd_vma) -1)
3398 char locsymbol[sizeof (":") - 1
3399 + sizeof (MMIX_LOC_SECTION_START_SYMBOL_PREFIX) - 1
3400 + sizeof (".text")];
3402 /* An exercise in non-ISO-C-ness, this one. */
3403 sprintf (locsymbol, ":%s%s", MMIX_LOC_SECTION_START_SYMBOL_PREFIX,
3406 = symbol_new (locsymbol, absolute_section, lowest_text_loc,
3407 &zero_address_frag);
3408 S_SET_EXTERNAL (symbolP);
3412 if (data_has_contents && lowest_data_loc != (bfd_vma) -1)
3415 char locsymbol[sizeof (":") - 1
3416 + sizeof (MMIX_LOC_SECTION_START_SYMBOL_PREFIX) - 1
3417 + sizeof (".data")];
3419 sprintf (locsymbol, ":%s%s", MMIX_LOC_SECTION_START_SYMBOL_PREFIX,
3422 = symbol_new (locsymbol, absolute_section, lowest_data_loc,
3423 &zero_address_frag);
3424 S_SET_EXTERNAL (symbolP);
3427 /* Unless GNU syntax mode, set "Main" to be a function, so the
3428 disassembler doesn't get confused when we write truly
3429 mmixal-compatible code (and don't use .type). Similarly set it
3430 global (regardless of -globalize-symbols), so the linker sees it as
3431 the start symbol in ELF mode. */
3432 mainsym = symbol_find (MMIX_START_SYMBOL_NAME);
3433 if (mainsym != NULL && ! mmix_gnu_syntax)
3435 symbol_get_bfdsym (mainsym)->flags |= BSF_FUNCTION;
3436 S_SET_EXTERNAL (mainsym);
3439 if (n_of_raw_gregs != 0)
3441 /* Emit GREGs. They are collected in order of appearance, but must
3442 be emitted in opposite order to both have section address regno*8
3443 and the same allocation order (within a file) as mmixal. */
3444 segT this_segment = now_seg;
3445 subsegT this_subsegment = now_subseg;
3447 = bfd_make_section_old_way (stdoutput,
3448 MMIX_REG_CONTENTS_SECTION_NAME);
3449 subseg_set (regsec, 0);
3451 /* Finally emit the initialization-value. Emit a variable frag, which
3452 we'll fix in md_estimate_size_before_relax. We set the initializer
3453 for the tc_frag_data field to NULL, so we can use that field for
3454 relaxation purposes. */
3455 mmix_opcode_frag = NULL;
3458 mmix_reg_contents_frags = frag_now;
3460 for (i = n_of_raw_gregs - 1; i >= 0; i--)
3462 if (mmix_raw_gregs[i].label != NULL)
3463 /* There's a symbol. Let it refer to this location in the
3464 register contents section. The symbol must be globalized
3466 colon (mmix_raw_gregs[i].label);
3468 frag_var (rs_machine_dependent, 8, 0, STATE_GREG_UNDF,
3469 make_expr_symbol (&mmix_raw_gregs[i].exp), 0, NULL);
3472 subseg_set (this_segment, this_subsegment);
3475 /* Iterate over frags resulting from GREGs and move those that evidently
3476 have the same value together and point one to another.
3478 This works in time O(N^2) but since the upper bound for non-error use
3479 is 223, it's best to keep this simpler algorithm. */
3480 for (fragP = mmix_reg_contents_frags; fragP != NULL; fragP = fragP->fr_next)
3487 symbolS *symbolP = fragP->fr_symbol;
3489 if (fragP->fr_type != rs_machine_dependent
3490 || fragP->fr_subtype != STATE_GREG_UNDF)
3493 /* Whatever the outcome, we will have this GREG judged merged or
3494 non-merged. Since the tc_frag_data is NULL at this point, we
3495 default to non-merged. */
3496 fragP->fr_subtype = STATE_GREG_DEF;
3498 /* If we're not supposed to merge GREG definitions, then just don't
3499 look for equivalents. */
3503 osymval = (offsetT) S_GET_VALUE (symbolP);
3504 osymfrag = symbol_get_frag (symbolP);
3506 /* If the symbol isn't defined, we can't say that another symbol
3507 equals this frag, then. FIXME: We can look at the "deepest"
3508 defined name; if a = c and b = c then obviously a == b. */
3509 if (! S_IS_DEFINED (symbolP))
3512 oexpP = symbol_get_value_expression (fragP->fr_symbol);
3514 /* If the initialization value is zero, then we must not merge them. */
3515 if (oexpP->X_op == O_constant && osymval == 0)
3518 /* Iterate through the frags downward this one. If we find one that
3519 has the same non-zero value, move it to after this one and point
3520 to it as the equivalent. */
3521 for (fpp = &fragP->fr_next; *fpp != NULL; fpp = &fpp[0]->fr_next)
3525 if (fp->fr_type != rs_machine_dependent
3526 || fp->fr_subtype != STATE_GREG_UNDF)
3529 /* Calling S_GET_VALUE may simplify the symbol, changing from
3530 expr_section etc. so call it first. */
3531 if ((offsetT) S_GET_VALUE (fp->fr_symbol) == osymval
3532 && symbol_get_frag (fp->fr_symbol) == osymfrag)
3534 /* Move the frag links so the one we found equivalent comes
3535 after the current one, carefully considering that
3536 sometimes fpp == &fragP->fr_next and the moves must be a
3539 fp->fr_next = fragP->fr_next;
3540 fragP->fr_next = fp;
3546 fragP->tc_frag_data = fp;
3550 /* qsort function for mmix_symbol_gregs. */
3553 cmp_greg_symbol_fixes (parg, qarg)
3557 const struct mmix_symbol_greg_fixes *p
3558 = (const struct mmix_symbol_greg_fixes *) parg;
3559 const struct mmix_symbol_greg_fixes *q
3560 = (const struct mmix_symbol_greg_fixes *) qarg;
3562 return p->offs > q->offs ? 1 : p->offs < q->offs ? -1 : 0;
3565 /* Collect GREG definitions from mmix_gregs and hang them as lists sorted
3566 on increasing offsets onto each section symbol or undefined symbol.
3568 Also, remove the register convenience section so it doesn't get output
3569 as an ELF section. */
3575 struct mmix_symbol_gregs *all_greg_symbols[MAX_GREGS];
3576 int n_greg_symbols = 0;
3578 /* Collect all greg fixups and decorate each corresponding symbol with
3579 the greg fixups for it. */
3580 for (i = 0; i < n_of_cooked_gregs; i++)
3584 struct mmix_symbol_gregs *gregs;
3587 fixP = mmix_gregs[i];
3588 know (fixP->fx_r_type == BFD_RELOC_64);
3590 /* This case isn't doable in general anyway, methinks. */
3591 if (fixP->fx_subsy != NULL)
3593 as_bad_where (fixP->fx_file, fixP->fx_line,
3594 _("GREG expression too complicated"));
3598 sym = fixP->fx_addsy;
3599 offs = (offsetT) fixP->fx_offset;
3601 /* If the symbol is defined, then it must be resolved to a section
3602 symbol at this time, or else we don't know how to handle it. */
3603 if (S_IS_DEFINED (sym)
3604 && !bfd_is_com_section (S_GET_SEGMENT (sym))
3605 && !S_IS_WEAK (sym))
3607 if (! symbol_section_p (sym)
3608 && ! bfd_is_abs_section (S_GET_SEGMENT (sym)))
3609 as_fatal (_("internal: GREG expression not resolved to section"));
3611 offs += S_GET_VALUE (sym);
3614 /* If this is an absolute symbol sufficiently near lowest_data_loc,
3615 then we canonicalize on the data section. Note that offs is
3616 signed here; we may subtract lowest_data_loc which is unsigned.
3617 Careful with those comparisons. */
3618 if (lowest_data_loc != (bfd_vma) -1
3619 && (bfd_vma) offs + 256 > lowest_data_loc
3620 && bfd_is_abs_section (S_GET_SEGMENT (sym)))
3622 offs -= (offsetT) lowest_data_loc;
3623 sym = section_symbol (data_section);
3625 /* Likewise text section. */
3626 else if (lowest_text_loc != (bfd_vma) -1
3627 && (bfd_vma) offs + 256 > lowest_text_loc
3628 && bfd_is_abs_section (S_GET_SEGMENT (sym)))
3630 offs -= (offsetT) lowest_text_loc;
3631 sym = section_symbol (text_section);
3634 gregs = *symbol_get_tc (sym);
3638 gregs = xmalloc (sizeof (*gregs));
3640 symbol_set_tc (sym, &gregs);
3641 all_greg_symbols[n_greg_symbols++] = gregs;
3644 gregs->greg_fixes[gregs->n_gregs].fix = fixP;
3645 gregs->greg_fixes[gregs->n_gregs++].offs = offs;
3648 /* For each symbol having a GREG definition, sort those definitions on
3650 for (i = 0; i < n_greg_symbols; i++)
3651 qsort (all_greg_symbols[i]->greg_fixes, all_greg_symbols[i]->n_gregs,
3652 sizeof (all_greg_symbols[i]->greg_fixes[0]), cmp_greg_symbol_fixes);
3654 if (real_reg_section != NULL)
3658 /* FIXME: Pass error state gracefully. */
3659 if (bfd_get_section_flags (stdoutput, real_reg_section) & SEC_HAS_CONTENTS)
3660 as_fatal (_("register section has contents\n"));
3662 /* Really remove the section. */
3663 for (secpp = &stdoutput->sections;
3664 *secpp != real_reg_section;
3665 secpp = &(*secpp)->next)
3667 bfd_section_list_remove (stdoutput, secpp);
3668 --stdoutput->section_count;
3673 /* Provide an expression for a built-in name provided when-used.
3674 Either a symbol that is a handler; living in 0x10*[1..8] and having
3675 name [DVWIOUZX]_Handler, or a mmixal built-in symbol.
3677 If the name isn't a built-in name and parsed into *EXPP, return zero. */
3680 mmix_parse_predefined_name (name, expP)
3685 char *handler_charp;
3686 const char handler_chars[] = "DVWIOUZX";
3689 if (! predefined_syms)
3692 canon_name = tc_canonicalize_symbol_name (name);
3694 if (canon_name[1] == '_'
3695 && strcmp (canon_name + 2, "Handler") == 0
3696 && (handler_charp = strchr (handler_chars, *canon_name)) != NULL)
3698 /* If the symbol doesn't exist, provide one relative to the .text
3701 FIXME: We should provide separate sections, mapped in the linker
3703 symp = symbol_find (name);
3705 symp = symbol_new (name, text_section,
3706 0x10 * (handler_charp + 1 - handler_chars),
3707 &zero_address_frag);
3711 /* These symbols appear when referenced; needed for
3712 mmixal-compatible programs. */
3719 } predefined_abs_syms[] =
3721 {"Data_Segment", (valueT) 0x20 << 56},
3722 {"Pool_Segment", (valueT) 0x40 << 56},
3723 {"Stack_Segment", (valueT) 0x60 << 56},
3731 {"BinaryReadWrite", 4},
3754 /* If it's already in the symbol table, we shouldn't do anything. */
3755 symp = symbol_find (name);
3760 i < sizeof (predefined_abs_syms)/sizeof (predefined_abs_syms[0]);
3762 if (strcmp (canon_name, predefined_abs_syms[i].name) == 0)
3764 symbol_table_insert (symbol_new (predefined_abs_syms[i].name,
3766 predefined_abs_syms[i].val,
3767 &zero_address_frag));
3769 /* Let gas find the symbol we just created, through its
3774 /* Not one of those symbols. Let gas handle it. */
3778 expP->X_op = O_symbol;
3779 expP->X_add_number = 0;
3780 expP->X_add_symbol = symp;
3781 expP->X_op_symbol = NULL;
3786 /* Worker for mmix_frob_file_before_adjust. */
3789 mmix_frob_local_reloc (abfd, sec, xxx)
3790 bfd *abfd ATTRIBUTE_UNUSED;
3792 PTR xxx ATTRIBUTE_UNUSED;
3794 segment_info_type *seginfo = seg_info (sec);
3797 if (seginfo == NULL)
3800 for (fixp = seginfo->fix_root; fixp; fixp = fixp->fx_next)
3801 if (! fixp->fx_done && fixp->fx_addsy != NULL)
3803 symbolS *sym = fixp->fx_addsy;
3804 asection *section = S_GET_SEGMENT (sym);
3806 if (section == reg_section
3807 && fixp->fx_r_type == BFD_RELOC_MMIX_LOCAL)
3809 /* If the register is marked global, we don't need to replace
3810 with the *real* register section since that will be done
3811 when the symbol is changed. */
3812 if (! S_IS_EXTERNAL (sym))
3813 /* If it's a local symbol, we replace it with an anonymous
3814 one with the same constant value. */
3815 fixp->fx_addsy = expr_build_uconstant (S_GET_VALUE (sym));
3820 /* Change fixups for register symbols for BFD_MMIX_LOCAL to be for an
3824 mmix_frob_file_before_adjust ()
3827 bfd_map_over_sections (stdoutput, mmix_frob_local_reloc, (char *) 0);
3830 /* Just check that we don't have a BSPEC/ESPEC pair active when changing
3831 sections "normally", and get knowledge about alignment from the new
3835 mmix_md_elf_section_change_hook ()
3838 as_bad (_("section change from within a BSPEC/ESPEC pair is not supported"));
3840 last_alignment = bfd_get_section_alignment (now_seg->owner, now_seg);
3844 /* The LOC worker. This is like s_org, but we have to support changing
3849 int ignore ATTRIBUTE_UNUSED;
3857 /* Must not have a BSPEC in progress. */
3860 as_bad (_("directive LOC from within a BSPEC/ESPEC pair is not supported"));
3864 section = expression (&exp);
3866 if (exp.X_op == O_illegal
3867 || exp.X_op == O_absent
3868 || exp.X_op == O_big
3869 || section == undefined_section)
3871 as_bad (_("invalid LOC expression"));
3875 if (section == absolute_section)
3877 /* Translate a constant into a suitable section. */
3879 if (exp.X_add_number < ((offsetT) 0x20 << 56))
3881 /* Lower than Data_Segment - assume it's .text. */
3882 section = text_section;
3884 /* Save the lowest seen location, so we can pass on this
3885 information to the linker. We don't actually org to this
3886 location here, we just pass on information to the linker so
3887 it can put the code there for us. */
3889 /* If there was already a loc (that has to be set lower than
3890 this one), we org at (this - lower). There's an implicit
3891 "LOC 0" before any entered code. FIXME: handled by spurious
3892 settings of text_has_contents. */
3893 if (exp.X_add_number < 0
3894 || exp.X_add_number < (offsetT) lowest_text_loc)
3896 as_bad (_("LOC expression stepping backwards is not supported"));
3897 exp.X_op = O_absent;
3901 if (text_has_contents && lowest_text_loc == (bfd_vma) -1)
3902 lowest_text_loc = 0;
3904 if (lowest_text_loc == (bfd_vma) -1)
3906 lowest_text_loc = exp.X_add_number;
3908 /* We want only to change the section, not set an offset. */
3909 exp.X_op = O_absent;
3912 exp.X_add_number -= lowest_text_loc;
3917 /* Do the same for the .data section. */
3918 section = data_section;
3920 if (exp.X_add_number < (offsetT) lowest_data_loc)
3922 as_bad (_("LOC expression stepping backwards is not supported"));
3923 exp.X_op = O_absent;
3927 if (data_has_contents && lowest_data_loc == (bfd_vma) -1)
3928 lowest_data_loc = (bfd_vma) 0x20 << 56;
3930 if (lowest_data_loc == (bfd_vma) -1)
3932 lowest_data_loc = exp.X_add_number;
3934 /* We want only to change the section, not set an offset. */
3935 exp.X_op = O_absent;
3938 exp.X_add_number -= lowest_data_loc;
3943 if (section != now_seg)
3945 obj_elf_section_change_hook ();
3946 subseg_set (section, 0);
3948 /* Call our section change hooks using the official hook. */
3949 md_elf_section_change_hook ();
3952 if (exp.X_op != O_absent)
3954 if (exp.X_op != O_constant && exp.X_op != O_symbol)
3956 /* Handle complex expressions. */
3957 sym = make_expr_symbol (&exp);
3962 sym = exp.X_add_symbol;
3963 off = exp.X_add_number;
3966 p = frag_var (rs_org, 1, 1, (relax_substateT) 0, sym, off, (char *) 0);
3970 mmix_handle_rest_of_empty_line ();
3973 /* The BYTE worker. We have to support sequences of mixed "strings",
3974 numbers and other constant "first-pass" reducible expressions separated
3983 if (now_seg == text_section)
3984 text_has_contents = 1;
3985 else if (now_seg == data_section)
3986 data_has_contents = 1;
3991 switch (*input_line_pointer)
3994 ++input_line_pointer;
3995 start = input_line_pointer;
3996 while (is_a_char (c = next_char_of_string ()))
3998 FRAG_APPEND_1_CHAR (c);
4001 if (input_line_pointer[-1] != '\"')
4003 /* We will only get here in rare cases involving #NO_APP,
4004 where the unterminated string is not recognized by the
4005 preformatting pass. */
4006 as_bad (_("unterminated string"));
4007 mmix_discard_rest_of_line ();
4015 segT expseg = expression (&exp);
4017 /* We have to allow special register names as constant numbers. */
4018 if ((expseg != absolute_section && expseg != reg_section)
4019 || (exp.X_op != O_constant
4020 && (exp.X_op != O_register
4021 || exp.X_add_number <= 255)))
4023 as_bad (_("BYTE expression not a pure number"));
4024 mmix_discard_rest_of_line ();
4027 else if ((exp.X_add_number > 255 && exp.X_op != O_register)
4028 || exp.X_add_number < 0)
4030 /* Note that mmixal does not allow negative numbers in
4031 BYTE sequences, so neither should we. */
4032 as_bad (_("BYTE expression not in the range 0..255"));
4033 mmix_discard_rest_of_line ();
4037 FRAG_APPEND_1_CHAR (exp.X_add_number);
4043 c = *input_line_pointer++;
4047 input_line_pointer--;
4049 if (mmix_gnu_syntax)
4050 demand_empty_rest_of_line ();
4053 mmix_discard_rest_of_line ();
4054 /* Do like demand_empty_rest_of_line and step over the end-of-line
4056 input_line_pointer++;
4059 /* Make sure we align for the next instruction. */
4063 /* Like cons_worker, but we have to ignore "naked comments", not barf on
4064 them. Implements WYDE, TETRA and OCTA. We're a little bit more
4065 lenient than mmix_byte but FIXME: they should eventually merge. */
4074 /* If we don't have any contents, then it's ok to have a specified start
4075 address that is not a multiple of the max data size. We will then
4076 align it as necessary when we get here. Otherwise, it's a fatal sin. */
4077 if (now_seg == text_section)
4079 if (lowest_text_loc != (bfd_vma) -1
4080 && (lowest_text_loc & (nbytes - 1)) != 0)
4082 if (text_has_contents)
4083 as_bad (_("data item with alignment larger than location"));
4084 else if (want_unaligned)
4085 as_bad (_("unaligned data at an absolute location is not supported"));
4087 lowest_text_loc &= ~((bfd_vma) nbytes - 1);
4088 lowest_text_loc += (bfd_vma) nbytes;
4091 text_has_contents = 1;
4093 else if (now_seg == data_section)
4095 if (lowest_data_loc != (bfd_vma) -1
4096 && (lowest_data_loc & (nbytes - 1)) != 0)
4098 if (data_has_contents)
4099 as_bad (_("data item with alignment larger than location"));
4100 else if (want_unaligned)
4101 as_bad (_("unaligned data at an absolute location is not supported"));
4103 lowest_data_loc &= ~((bfd_vma) nbytes - 1);
4104 lowest_data_loc += (bfd_vma) nbytes;
4107 data_has_contents = 1;
4110 /* Always align these unless asked not to (valid for the current pseudo). */
4111 if (! want_unaligned)
4113 last_alignment = nbytes == 2 ? 1 : (nbytes == 4 ? 2 : 3);
4114 frag_align (last_alignment, 0, 0);
4115 record_alignment (now_seg, last_alignment);
4118 /* For mmixal compatibility, a label for an instruction (and emitting
4119 pseudo) refers to the _aligned_ address. So we have to emit the
4121 if (current_fb_label >= 0)
4122 colon (fb_label_name (current_fb_label, 1));
4123 else if (pending_label != NULL)
4125 colon (pending_label);
4126 pending_label = NULL;
4131 if (is_end_of_line [(unsigned int) *input_line_pointer])
4133 /* Default to zero if the expression was absent. */
4135 exp.X_op = O_constant;
4136 exp.X_add_number = 0;
4138 exp.X_add_symbol = NULL;
4139 exp.X_op_symbol = NULL;
4140 emit_expr (&exp, (unsigned int) nbytes);
4147 switch (*input_line_pointer)
4149 /* We support strings here too; each character takes up nbytes
4152 ++input_line_pointer;
4153 start = input_line_pointer;
4154 while (is_a_char (c = next_char_of_string ()))
4156 exp.X_op = O_constant;
4157 exp.X_add_number = c;
4159 emit_expr (&exp, (unsigned int) nbytes);
4162 if (input_line_pointer[-1] != '\"')
4164 /* We will only get here in rare cases involving #NO_APP,
4165 where the unterminated string is not recognized by the
4166 preformatting pass. */
4167 as_bad (_("unterminated string"));
4168 mmix_discard_rest_of_line ();
4176 emit_expr (&exp, (unsigned int) nbytes);
4182 while (*input_line_pointer++ == ',');
4184 input_line_pointer--; /* Put terminator back into stream. */
4186 mmix_handle_rest_of_empty_line ();
4188 /* We don't need to step up the counter for the current_fb_label here;
4189 that's handled by the caller. */
4192 /* The md_do_align worker. At present, we just record an alignment to
4193 nullify the automatic alignment we do for WYDE, TETRA and OCTA, as gcc
4194 does not use the unaligned macros when attribute packed is used.
4195 Arguably this is a GCC bug. */
4198 mmix_md_do_align (n, fill, len, max)
4200 char *fill ATTRIBUTE_UNUSED;
4201 int len ATTRIBUTE_UNUSED;
4202 int max ATTRIBUTE_UNUSED;
4205 want_unaligned = n == 0;