1 /* tc-arm.c -- Assemble for the ARM
2 Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
4 Free Software Foundation, Inc.
11 This file is part of GAS, the GNU Assembler.
13 GAS is free software; you can redistribute it and/or modify
14 it under the terms of the GNU General Public License as published by
15 the Free Software Foundation; either version 2, or (at your option)
18 GAS is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 GNU General Public License for more details.
23 You should have received a copy of the GNU General Public License
24 along with GAS; see the file COPYING. If not, write to the Free
25 Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
31 #include "safe-ctype.h"
33 /* Need TARGET_CPU. */
40 #include "opcode/arm.h"
44 #include "dwarf2dbg.h"
45 #include "dw2gencfi.h"
48 /* XXX Set this to 1 after the next binutils release. */
49 #define WARN_DEPRECATED 0
52 /* Must be at least the size of the largest unwind opcode (currently two). */
53 #define ARM_OPCODE_CHUNK_SIZE 8
55 /* This structure holds the unwinding state. */
60 symbolS * table_entry;
61 symbolS * personality_routine;
62 int personality_index;
63 /* The segment containing the function. */
66 /* Opcodes generated from this function. */
67 unsigned char * opcodes;
70 /* The number of bytes pushed to the stack. */
72 /* We don't add stack adjustment opcodes immediately so that we can merge
73 multiple adjustments. We can also omit the final adjustment
74 when using a frame pointer. */
75 offsetT pending_offset;
76 /* These two fields are set by both unwind_movsp and unwind_setfp. They
77 hold the reg+offset to use when restoring sp from a frame pointer. */
80 /* Nonzero if an unwind_setfp directive has been seen. */
82 /* Nonzero if the last opcode restores sp from fp_reg. */
83 unsigned sp_restored:1;
86 /* Bit N indicates that an R_ARM_NONE relocation has been output for
87 __aeabi_unwind_cpp_prN already if set. This enables dependencies to be
88 emitted only once per section, to save unnecessary bloat. */
89 static unsigned int marked_pr_dependency = 0;
100 /* Types of processor to assemble for. */
101 #define ARM_1 ARM_ARCH_V1
102 #define ARM_2 ARM_ARCH_V2
103 #define ARM_3 ARM_ARCH_V2S
104 #define ARM_250 ARM_ARCH_V2S
105 #define ARM_6 ARM_ARCH_V3
106 #define ARM_7 ARM_ARCH_V3
107 #define ARM_8 ARM_ARCH_V4
108 #define ARM_9 ARM_ARCH_V4T
109 #define ARM_STRONG ARM_ARCH_V4
110 #define ARM_CPU_MASK 0x0000000f /* XXX? */
113 #if defined __XSCALE__
114 #define CPU_DEFAULT (ARM_ARCH_XSCALE)
116 #if defined __thumb__
117 #define CPU_DEFAULT (ARM_ARCH_V5T)
119 #define CPU_DEFAULT ARM_ANY
126 # define FPU_DEFAULT FPU_ARCH_FPA
127 # elif defined (TE_NetBSD)
129 # define FPU_DEFAULT FPU_ARCH_VFP /* Soft-float, but VFP order. */
131 /* Legacy a.out format. */
132 # define FPU_DEFAULT FPU_ARCH_FPA /* Soft-float, but FPA order. */
134 # elif defined (TE_VXWORKS)
135 # define FPU_DEFAULT FPU_ARCH_VFP /* Soft-float, VFP order. */
137 /* For backwards compatibility, default to FPA. */
138 # define FPU_DEFAULT FPU_ARCH_FPA
140 #endif /* ifndef FPU_DEFAULT */
142 #define streq(a, b) (strcmp (a, b) == 0)
144 static unsigned long cpu_variant;
146 /* Flags stored in private area of BFD structure. */
147 static int uses_apcs_26 = FALSE;
148 static int atpcs = FALSE;
149 static int support_interwork = FALSE;
150 static int uses_apcs_float = FALSE;
151 static int pic_code = FALSE;
153 /* Variables that we set while parsing command-line options. Once all
154 options have been read we re-process these values to set the real
156 static int legacy_cpu = -1;
157 static int legacy_fpu = -1;
159 static int mcpu_cpu_opt = -1;
160 static int mcpu_fpu_opt = -1;
161 static int march_cpu_opt = -1;
162 static int march_fpu_opt = -1;
163 static int mfpu_opt = -1;
164 static int mfloat_abi_opt = -1;
167 static int meabi_flags = EABI_DEFAULT;
169 static int meabi_flags = EF_ARM_EABI_UNKNOWN;
174 /* Pre-defined "_GLOBAL_OFFSET_TABLE_" */
175 symbolS * GOT_symbol;
178 /* 0: assemble for ARM,
179 1: assemble for Thumb,
180 2: assemble for Thumb even though target CPU does not support thumb
182 static int thumb_mode = 0;
184 /* If unified_syntax is true, we are processing the new unified
185 ARM/Thumb syntax. Important differences from the old ARM mode:
187 - Immediate operands do not require a # prefix.
188 - Conditional affixes always appear at the end of the
189 instruction. (For backward compatibility, those instructions
190 that formerly had them in the middle, continue to accept them
192 - The IT instruction may appear, and if it does is validated
193 against subsequent conditional affixes. It does not generate
196 Important differences from the old Thumb mode:
198 - Immediate operands do not require a # prefix.
199 - Most of the V6T2 instructions are only available in unified mode.
200 - The .N and .W suffixes are recognized and honored (it is an error
201 if they cannot be honored).
202 - All instructions set the flags if and only if they have an 's' affix.
203 - Conditional affixes may be used. They are validated against
204 preceding IT instructions. Unlike ARM mode, you cannot use a
205 conditional affix except in the scope of an IT instruction. */
207 static bfd_boolean unified_syntax = FALSE;
212 unsigned long instruction;
218 bfd_reloc_code_real_type type;
227 unsigned present : 1; /* Operand present. */
228 unsigned isreg : 1; /* Operand was a register. */
229 unsigned immisreg : 1; /* .imm field is a second register. */
230 unsigned hasreloc : 1; /* Operand has relocation suffix. */
231 unsigned writeback : 1; /* Operand has trailing ! */
232 unsigned preind : 1; /* Preindexed address. */
233 unsigned postind : 1; /* Postindexed address. */
234 unsigned negative : 1; /* Index register was negated. */
235 unsigned shifted : 1; /* Shift applied to operation. */
236 unsigned shift_kind : 3; /* Shift operation (enum shift_kind). */
240 static struct arm_it inst;
242 #define NUM_FLOAT_VALS 8
244 const char * fp_const[] =
246 "0.0", "1.0", "2.0", "3.0", "4.0", "5.0", "0.5", "10.0", 0
249 /* Number of littlenums required to hold an extended precision number. */
250 #define MAX_LITTLENUMS 6
252 LITTLENUM_TYPE fp_values[NUM_FLOAT_VALS][MAX_LITTLENUMS];
262 #define CP_T_X 0x00008000
263 #define CP_T_Y 0x00400000
265 #define CONDS_BIT 0x00100000
266 #define LOAD_BIT 0x00100000
268 #define DOUBLE_LOAD_FLAG 0x00000001
272 const char * template;
276 #define COND_ALWAYS 0xE
280 const char *template;
284 /* The bit that distinguishes CPSR and SPSR. */
285 #define SPSR_BIT (1 << 22)
287 /* The individual PSR flag bits. */
288 #define PSR_c (1 << 16)
289 #define PSR_x (1 << 17)
290 #define PSR_s (1 << 18)
291 #define PSR_f (1 << 19)
296 bfd_reloc_code_real_type reloc;
301 VFP_REG_Sd, VFP_REG_Sm, VFP_REG_Sn
306 VFP_LDSTMIA, VFP_LDSTMDB, VFP_LDSTMIAX, VFP_LDSTMDBX
309 /* ARM register categories. This includes coprocessor numbers and various
310 architecture extensions' registers. */
332 /* Structure for a hash table entry for a register. */
336 unsigned char number;
338 unsigned char builtin;
341 /* Diagnostics used when we don't get a register of the expected type. */
342 const char *const reg_expected_msgs[] =
344 N_("ARM register expected"),
345 N_("bad or missing co-processor number"),
346 N_("co-processor register expected"),
347 N_("FPA register expected"),
348 N_("VFP single precision register expected"),
349 N_("VFP double precision register expected"),
350 N_("VFP system register expected"),
351 N_("Maverick MVF register expected"),
352 N_("Maverick MVD register expected"),
353 N_("Maverick MVFX register expected"),
354 N_("Maverick MVDX register expected"),
355 N_("Maverick MVAX register expected"),
356 N_("Maverick DSPSC register expected"),
357 N_("iWMMXt data register expected"),
358 N_("iWMMXt control register expected"),
359 N_("iWMMXt scalar register expected"),
360 N_("XScale accumulator register expected"),
363 /* Some well known registers that we refer to directly elsewhere. */
368 /* ARM instructions take 4bytes in the object file, Thumb instructions
374 /* Basic string to match. */
375 const char *template;
377 /* Parameters to instruction. */
378 unsigned char operands[8];
380 /* Conditional tag - see opcode_lookup. */
381 unsigned int tag : 4;
383 /* Basic instruction code. */
384 unsigned int avalue : 28;
386 /* Thumb-format instruction code. */
389 /* Which architecture variant provides this instruction. */
390 unsigned long avariant;
391 unsigned long tvariant;
393 /* Function to call to encode instruction in ARM format. */
394 void (* aencode) (void);
396 /* Function to call to encode instruction in Thumb format. */
397 void (* tencode) (void);
400 /* Defines for various bits that we will want to toggle. */
401 #define INST_IMMEDIATE 0x02000000
402 #define OFFSET_REG 0x02000000
403 #define HWOFFSET_IMM 0x00400000
404 #define SHIFT_BY_REG 0x00000010
405 #define PRE_INDEX 0x01000000
406 #define INDEX_UP 0x00800000
407 #define WRITE_BACK 0x00200000
408 #define LDM_TYPE_2_OR_3 0x00400000
410 #define LITERAL_MASK 0xf000f000
411 #define OPCODE_MASK 0xfe1fffff
412 #define V4_STR_BIT 0x00000020
414 #define DATA_OP_SHIFT 21
416 /* Codes to distinguish the arithmetic instructions. */
427 #define OPCODE_CMP 10
428 #define OPCODE_CMN 11
429 #define OPCODE_ORR 12
430 #define OPCODE_MOV 13
431 #define OPCODE_BIC 14
432 #define OPCODE_MVN 15
434 #define T_OPCODE_MUL 0x4340
435 #define T_OPCODE_TST 0x4200
436 #define T_OPCODE_CMN 0x42c0
437 #define T_OPCODE_NEG 0x4240
438 #define T_OPCODE_MVN 0x43c0
440 #define T_OPCODE_ADD_R3 0x1800
441 #define T_OPCODE_SUB_R3 0x1a00
442 #define T_OPCODE_ADD_HI 0x4400
443 #define T_OPCODE_ADD_ST 0xb000
444 #define T_OPCODE_SUB_ST 0xb080
445 #define T_OPCODE_ADD_SP 0xa800
446 #define T_OPCODE_ADD_PC 0xa000
447 #define T_OPCODE_ADD_I8 0x3000
448 #define T_OPCODE_SUB_I8 0x3800
449 #define T_OPCODE_ADD_I3 0x1c00
450 #define T_OPCODE_SUB_I3 0x1e00
452 #define T_OPCODE_ASR_R 0x4100
453 #define T_OPCODE_LSL_R 0x4080
454 #define T_OPCODE_LSR_R 0x40c0
455 #define T_OPCODE_ROR_R 0x41c0
456 #define T_OPCODE_ASR_I 0x1000
457 #define T_OPCODE_LSL_I 0x0000
458 #define T_OPCODE_LSR_I 0x0800
460 #define T_OPCODE_MOV_I8 0x2000
461 #define T_OPCODE_CMP_I8 0x2800
462 #define T_OPCODE_CMP_LR 0x4280
463 #define T_OPCODE_MOV_HR 0x4600
464 #define T_OPCODE_CMP_HR 0x4500
466 #define T_OPCODE_LDR_PC 0x4800
467 #define T_OPCODE_LDR_SP 0x9800
468 #define T_OPCODE_STR_SP 0x9000
469 #define T_OPCODE_LDR_IW 0x6800
470 #define T_OPCODE_STR_IW 0x6000
471 #define T_OPCODE_LDR_IH 0x8800
472 #define T_OPCODE_STR_IH 0x8000
473 #define T_OPCODE_LDR_IB 0x7800
474 #define T_OPCODE_STR_IB 0x7000
475 #define T_OPCODE_LDR_RW 0x5800
476 #define T_OPCODE_STR_RW 0x5000
477 #define T_OPCODE_LDR_RH 0x5a00
478 #define T_OPCODE_STR_RH 0x5200
479 #define T_OPCODE_LDR_RB 0x5c00
480 #define T_OPCODE_STR_RB 0x5400
482 #define T_OPCODE_PUSH 0xb400
483 #define T_OPCODE_POP 0xbc00
485 #define T_OPCODE_BRANCH 0xe000
487 #define THUMB_SIZE 2 /* Size of thumb instruction. */
488 #define THUMB_PP_PC_LR 0x0100
489 #define THUMB_LOAD_BIT 0x0800
491 #define BAD_ARGS _("bad arguments to instruction")
492 #define BAD_PC _("r15 not allowed here")
493 #define BAD_COND _("instruction cannot be conditional")
494 #define BAD_OVERLAP _("registers may not be the same")
495 #define BAD_HIREG _("lo register required")
496 #define BAD_THUMB32 _("instruction not supported in Thumb16 mode")
498 static struct hash_control *arm_ops_hsh;
499 static struct hash_control *arm_cond_hsh;
500 static struct hash_control *arm_shift_hsh;
501 static struct hash_control *arm_psr_hsh;
502 static struct hash_control *arm_reg_hsh;
503 static struct hash_control *arm_reloc_hsh;
505 /* Stuff needed to resolve the label ambiguity
515 symbolS * last_label_seen;
516 static int label_is_thumb_function_name = FALSE;
518 /* Literal pool structure. Held on a per-section
519 and per-sub-section basis. */
521 #define MAX_LITERAL_POOL_SIZE 1024
522 typedef struct literal_pool
524 expressionS literals [MAX_LITERAL_POOL_SIZE];
525 unsigned int next_free_entry;
530 struct literal_pool * next;
533 /* Pointer to a linked list of literal pools. */
534 literal_pool * list_of_pools = NULL;
536 /* State variables for IT block handling. */
537 static bfd_boolean current_it_mask = 0;
538 static int current_cc;
543 /* This array holds the chars that always start a comment. If the
544 pre-processor is disabled, these aren't very useful. */
545 const char comment_chars[] = "@";
547 /* This array holds the chars that only start a comment at the beginning of
548 a line. If the line seems to have the form '# 123 filename'
549 .line and .file directives will appear in the pre-processed output. */
550 /* Note that input_file.c hand checks for '#' at the beginning of the
551 first line of the input file. This is because the compiler outputs
552 #NO_APP at the beginning of its output. */
553 /* Also note that comments like this one will always work. */
554 const char line_comment_chars[] = "#";
556 const char line_separator_chars[] = ";";
558 /* Chars that can be used to separate mant
559 from exp in floating point numbers. */
560 const char EXP_CHARS[] = "eE";
562 /* Chars that mean this number is a floating point constant. */
566 const char FLT_CHARS[] = "rRsSfFdDxXeEpP";
568 /* Prefix characters that indicate the start of an immediate
570 #define is_immediate_prefix(C) ((C) == '#' || (C) == '$')
572 /* Separator character handling. */
574 #define skip_whitespace(str) do { if (*(str) == ' ') ++(str); } while (0)
577 skip_past_char (char ** str, char c)
587 #define skip_past_comma(str) skip_past_char (str, ',')
589 /* Arithmetic expressions (possibly involving symbols). */
591 /* Return TRUE if anything in the expression is a bignum. */
594 walk_no_bignums (symbolS * sp)
596 if (symbol_get_value_expression (sp)->X_op == O_big)
599 if (symbol_get_value_expression (sp)->X_add_symbol)
601 return (walk_no_bignums (symbol_get_value_expression (sp)->X_add_symbol)
602 || (symbol_get_value_expression (sp)->X_op_symbol
603 && walk_no_bignums (symbol_get_value_expression (sp)->X_op_symbol)));
609 static int in_my_get_expression = 0;
611 /* Third argument to my_get_expression. */
612 #define GE_NO_PREFIX 0
613 #define GE_IMM_PREFIX 1
614 #define GE_OPT_PREFIX 2
617 my_get_expression (expressionS * ep, char ** str, int prefix_mode)
622 /* In unified syntax, all prefixes are optional. */
624 prefix_mode = GE_OPT_PREFIX;
628 case GE_NO_PREFIX: break;
630 if (!is_immediate_prefix (**str))
632 inst.error = _("immediate expression requires a # prefix");
638 if (is_immediate_prefix (**str))
644 memset (ep, 0, sizeof (expressionS));
646 save_in = input_line_pointer;
647 input_line_pointer = *str;
648 in_my_get_expression = 1;
649 seg = expression (ep);
650 in_my_get_expression = 0;
652 if (ep->X_op == O_illegal)
654 /* We found a bad expression in md_operand(). */
655 *str = input_line_pointer;
656 input_line_pointer = save_in;
657 if (inst.error == NULL)
658 inst.error = _("bad expression");
663 if (seg != absolute_section
664 && seg != text_section
665 && seg != data_section
666 && seg != bss_section
667 && seg != undefined_section)
669 inst.error = _("bad segment");
670 *str = input_line_pointer;
671 input_line_pointer = save_in;
676 /* Get rid of any bignums now, so that we don't generate an error for which
677 we can't establish a line number later on. Big numbers are never valid
678 in instructions, which is where this routine is always called. */
679 if (ep->X_op == O_big
681 && (walk_no_bignums (ep->X_add_symbol)
683 && walk_no_bignums (ep->X_op_symbol)))))
685 inst.error = _("invalid constant");
686 *str = input_line_pointer;
687 input_line_pointer = save_in;
691 *str = input_line_pointer;
692 input_line_pointer = save_in;
696 /* Turn a string in input_line_pointer into a floating point constant
697 of type TYPE, and store the appropriate bytes in *LITP. The number
698 of LITTLENUMS emitted is stored in *SIZEP. An error message is
699 returned, or NULL on OK.
701 Note that fp constants aren't represent in the normal way on the ARM.
702 In big endian mode, things are as expected. However, in little endian
703 mode fp constants are big-endian word-wise, and little-endian byte-wise
704 within the words. For example, (double) 1.1 in big endian mode is
705 the byte sequence 3f f1 99 99 99 99 99 9a, and in little endian mode is
706 the byte sequence 99 99 f1 3f 9a 99 99 99.
708 ??? The format of 12 byte floats is uncertain according to gcc's arm.h. */
711 md_atof (int type, char * litP, int * sizeP)
714 LITTLENUM_TYPE words[MAX_LITTLENUMS];
746 return _("bad call to MD_ATOF()");
749 t = atof_ieee (input_line_pointer, type, words);
751 input_line_pointer = t;
754 if (target_big_endian)
756 for (i = 0; i < prec; i++)
758 md_number_to_chars (litP, (valueT) words[i], 2);
764 if (cpu_variant & FPU_ARCH_VFP)
765 for (i = prec - 1; i >= 0; i--)
767 md_number_to_chars (litP, (valueT) words[i], 2);
771 /* For a 4 byte float the order of elements in `words' is 1 0.
772 For an 8 byte float the order is 1 0 3 2. */
773 for (i = 0; i < prec; i += 2)
775 md_number_to_chars (litP, (valueT) words[i + 1], 2);
776 md_number_to_chars (litP + 2, (valueT) words[i], 2);
784 /* We handle all bad expressions here, so that we can report the faulty
785 instruction in the error message. */
787 md_operand (expressionS * expr)
789 if (in_my_get_expression)
790 expr->X_op = O_illegal;
793 /* Immediate values. */
795 /* Generic immediate-value read function for use in directives.
796 Accepts anything that 'expression' can fold to a constant.
797 *val receives the number. */
800 immediate_for_directive (int *val)
803 exp.X_op = O_illegal;
805 if (is_immediate_prefix (*input_line_pointer))
807 input_line_pointer++;
811 if (exp.X_op != O_constant)
813 as_bad (_("expected #constant"));
814 ignore_rest_of_line ();
817 *val = exp.X_add_number;
822 /* Register parsing. */
824 /* Generic register parser. CCP points to what should be the
825 beginning of a register name. If it is indeed a valid register
826 name, advance CCP over it and return the reg_entry structure;
827 otherwise return NULL. Does not issue diagnostics. */
829 static struct reg_entry *
830 arm_reg_parse_multi (char **ccp)
834 struct reg_entry *reg;
836 #ifdef REGISTER_PREFIX
837 if (*start != REGISTER_PREFIX)
841 #ifdef OPTIONAL_REGISTER_PREFIX
842 if (*start == OPTIONAL_REGISTER_PREFIX)
847 if (!ISALPHA (*p) || !is_name_beginner (*p))
852 while (ISALPHA (*p) || ISDIGIT (*p) || *p == '_');
854 reg = (struct reg_entry *) hash_find_n (arm_reg_hsh, start, p - start);
863 /* As above, but the register must be of type TYPE, and the return
864 value is the register number or NULL. */
867 arm_reg_parse (char **ccp, enum arm_reg_type type)
870 struct reg_entry *reg = arm_reg_parse_multi (ccp);
872 if (reg && reg->type == type)
875 /* Alternative syntaxes are accepted for a few register classes. */
882 /* Generic coprocessor register names are allowed for these. */
883 if (reg->type == REG_TYPE_CN)
888 /* For backward compatibility, a bare number is valid here. */
890 unsigned long processor = strtoul (start, ccp, 10);
891 if (*ccp != start && processor <= 15)
896 /* WC includes WCG. ??? I'm not sure this is true for all
897 instructions that take WC registers. */
898 if (reg->type == REG_TYPE_MMXWCG)
910 /* Parse an ARM register list. Returns the bitmask, or FAIL. */
912 parse_reg_list (char ** strp)
918 /* We come back here if we get ranges concatenated by '+' or '|'. */
933 if ((reg = arm_reg_parse (&str, REG_TYPE_RN)) == FAIL)
935 inst.error = _(reg_expected_msgs[REG_TYPE_RN]);
945 inst.error = _("bad range in register list");
949 for (i = cur_reg + 1; i < reg; i++)
951 if (range & (1 << i))
953 (_("Warning: duplicated register (r%d) in register list"),
961 if (range & (1 << reg))
962 as_tsktsk (_("Warning: duplicated register (r%d) in register list"),
964 else if (reg <= cur_reg)
965 as_tsktsk (_("Warning: register range not in ascending order"));
970 while (skip_past_comma (&str) != FAIL
971 || (in_range = 1, *str++ == '-'));
976 inst.error = _("missing `}'");
984 if (my_get_expression (&expr, &str, GE_NO_PREFIX))
987 if (expr.X_op == O_constant)
989 if (expr.X_add_number
990 != (expr.X_add_number & 0x0000ffff))
992 inst.error = _("invalid register mask");
996 if ((range & expr.X_add_number) != 0)
998 int regno = range & expr.X_add_number;
1001 regno = (1 << regno) - 1;
1003 (_("Warning: duplicated register (r%d) in register list"),
1007 range |= expr.X_add_number;
1011 if (inst.reloc.type != 0)
1013 inst.error = _("expression too complex");
1017 memcpy (&inst.reloc.exp, &expr, sizeof (expressionS));
1018 inst.reloc.type = BFD_RELOC_ARM_MULTI;
1019 inst.reloc.pc_rel = 0;
1023 if (*str == '|' || *str == '+')
1029 while (another_range);
1035 /* Parse a VFP register list. If the string is invalid return FAIL.
1036 Otherwise return the number of registers, and set PBASE to the first
1037 register. Double precision registers are matched if DP is nonzero. */
1040 parse_vfp_reg_list (char **str, unsigned int *pbase, int dp)
1048 unsigned long mask = 0;
1058 regtype = REG_TYPE_VFD;
1063 regtype = REG_TYPE_VFS;
1067 base_reg = max_regs;
1071 new_base = arm_reg_parse (str, regtype);
1072 if (new_base == FAIL)
1074 inst.error = gettext (reg_expected_msgs[regtype]);
1078 if (new_base < base_reg)
1079 base_reg = new_base;
1081 if (mask & (1 << new_base))
1083 inst.error = _("invalid register list");
1087 if ((mask >> new_base) != 0 && ! warned)
1089 as_tsktsk (_("register list not in ascending order"));
1093 mask |= 1 << new_base;
1096 if (**str == '-') /* We have the start of a range expression */
1102 if ((high_range = arm_reg_parse (str, regtype)) == FAIL)
1104 inst.error = gettext (reg_expected_msgs[regtype]);
1108 if (high_range <= new_base)
1110 inst.error = _("register range not in ascending order");
1114 for (new_base++; new_base <= high_range; new_base++)
1116 if (mask & (1 << new_base))
1118 inst.error = _("invalid register list");
1122 mask |= 1 << new_base;
1127 while (skip_past_comma (str) != FAIL);
1131 /* Sanity check -- should have raised a parse error above. */
1132 if (count == 0 || count > max_regs)
1137 /* Final test -- the registers must be consecutive. */
1139 for (i = 0; i < count; i++)
1141 if ((mask & (1u << i)) == 0)
1143 inst.error = _("non-contiguous register range");
1151 /* Parse an explicit relocation suffix on an expression. This is
1152 either nothing, or a word in parentheses. Note that if !OBJ_ELF,
1153 arm_reloc_hsh contains no entries, so this function can only
1154 succeed if there is no () after the word. Returns -1 on error,
1155 BFD_RELOC_UNUSED if there wasn't any suffix. */
1157 parse_reloc (char **str)
1159 struct reloc_entry *r;
1163 return BFD_RELOC_UNUSED;
1168 while (*q && *q != ')' && *q != ',')
1173 if ((r = hash_find_n (arm_reloc_hsh, p, q - p)) == NULL)
1180 /* Directives: register aliases. */
1183 insert_reg_alias (char *str, int number, int type)
1185 struct reg_entry *new;
1188 if ((new = hash_find (arm_reg_hsh, str)) != 0)
1191 as_warn (_("ignoring attempt to redefine built-in register '%s'"), str);
1193 /* Only warn about a redefinition if it's not defined as the
1195 else if (new->number != number || new->type != type)
1196 as_warn (_("ignoring redefinition of register alias '%s'"), str);
1201 name = xstrdup (str);
1202 new = xmalloc (sizeof (struct reg_entry));
1205 new->number = number;
1207 new->builtin = FALSE;
1209 if (hash_insert (arm_reg_hsh, name, (PTR) new))
1213 /* Look for the .req directive. This is of the form:
1215 new_register_name .req existing_register_name
1217 If we find one, or if it looks sufficiently like one that we want to
1218 handle any error here, return non-zero. Otherwise return zero. */
1221 create_register_alias (char * newname, char *p)
1223 struct reg_entry *old;
1224 char *oldname, *nbuf;
1227 /* The input scrubber ensures that whitespace after the mnemonic is
1228 collapsed to single spaces. */
1230 if (strncmp (oldname, " .req ", 6) != 0)
1234 if (*oldname == '\0')
1237 old = hash_find (arm_reg_hsh, oldname);
1240 as_warn (_("unknown register '%s' -- .req ignored"), oldname);
1244 /* If TC_CASE_SENSITIVE is defined, then newname already points to
1245 the desired alias name, and p points to its end. If not, then
1246 the desired alias name is in the global original_case_string. */
1247 #ifdef TC_CASE_SENSITIVE
1250 newname = original_case_string;
1251 nlen = strlen (newname);
1254 nbuf = alloca (nlen + 1);
1255 memcpy (nbuf, newname, nlen);
1258 /* Create aliases under the new name as stated; an all-lowercase
1259 version of the new name; and an all-uppercase version of the new
1261 insert_reg_alias (nbuf, old->number, old->type);
1263 for (p = nbuf; *p; p++)
1266 if (strncmp (nbuf, newname, nlen))
1267 insert_reg_alias (nbuf, old->number, old->type);
1269 for (p = nbuf; *p; p++)
1272 if (strncmp (nbuf, newname, nlen))
1273 insert_reg_alias (nbuf, old->number, old->type);
1278 /* Should never be called, as .req goes between the alias and the
1279 register name, not at the beginning of the line. */
1281 s_req (int a ATTRIBUTE_UNUSED)
1283 as_bad (_("invalid syntax for .req directive"));
1286 /* The .unreq directive deletes an alias which was previously defined
1287 by .req. For example:
1293 s_unreq (int a ATTRIBUTE_UNUSED)
1298 name = input_line_pointer;
1300 while (*input_line_pointer != 0
1301 && *input_line_pointer != ' '
1302 && *input_line_pointer != '\n')
1303 ++input_line_pointer;
1305 saved_char = *input_line_pointer;
1306 *input_line_pointer = 0;
1309 as_bad (_("invalid syntax for .unreq directive"));
1312 struct reg_entry *reg = hash_find (arm_reg_hsh, name);
1315 as_bad (_("unknown register alias '%s'"), name);
1316 else if (reg->builtin)
1317 as_warn (_("ignoring attempt to undefine built-in register '%s'"),
1321 hash_delete (arm_reg_hsh, name);
1322 free ((char *) reg->name);
1327 *input_line_pointer = saved_char;
1328 demand_empty_rest_of_line ();
1331 /* Directives: Instruction set selection. */
1334 /* This code is to handle mapping symbols as defined in the ARM ELF spec.
1335 (See "Mapping symbols", section 4.5.5, ARM AAELF version 1.0).
1336 Note that previously, $a and $t has type STT_FUNC (BSF_OBJECT flag),
1337 and $d has type STT_OBJECT (BSF_OBJECT flag). Now all three are untyped. */
1339 static enum mstate mapstate = MAP_UNDEFINED;
1342 mapping_state (enum mstate state)
1345 const char * symname;
1348 if (mapstate == state)
1349 /* The mapping symbol has already been emitted.
1350 There is nothing else to do. */
1359 type = BSF_NO_FLAGS;
1363 type = BSF_NO_FLAGS;
1367 type = BSF_NO_FLAGS;
1375 seg_info (now_seg)->tc_segment_info_data.mapstate = state;
1377 symbolP = symbol_new (symname, now_seg, (valueT) frag_now_fix (), frag_now);
1378 symbol_table_insert (symbolP);
1379 symbol_get_bfdsym (symbolP)->flags |= type | BSF_LOCAL;
1384 THUMB_SET_FUNC (symbolP, 0);
1385 ARM_SET_THUMB (symbolP, 0);
1386 ARM_SET_INTERWORK (symbolP, support_interwork);
1390 THUMB_SET_FUNC (symbolP, 1);
1391 ARM_SET_THUMB (symbolP, 1);
1392 ARM_SET_INTERWORK (symbolP, support_interwork);
1401 #define mapping_state(x) /* nothing */
1404 /* Find the real, Thumb encoded start of a Thumb function. */
1407 find_real_start (symbolS * symbolP)
1410 const char * name = S_GET_NAME (symbolP);
1411 symbolS * new_target;
1413 /* This definition must agree with the one in gcc/config/arm/thumb.c. */
1414 #define STUB_NAME ".real_start_of"
1419 /* The compiler may generate BL instructions to local labels because
1420 it needs to perform a branch to a far away location. These labels
1421 do not have a corresponding ".real_start_of" label. We check
1422 both for S_IS_LOCAL and for a leading dot, to give a way to bypass
1423 the ".real_start_of" convention for nonlocal branches. */
1424 if (S_IS_LOCAL (symbolP) || name[0] == '.')
1427 real_start = ACONCAT ((STUB_NAME, name, NULL));
1428 new_target = symbol_find (real_start);
1430 if (new_target == NULL)
1432 as_warn ("Failed to find real start of function: %s\n", name);
1433 new_target = symbolP;
1440 opcode_select (int width)
1447 if (! (cpu_variant & ARM_EXT_V4T))
1448 as_bad (_("selected processor does not support THUMB opcodes"));
1451 /* No need to force the alignment, since we will have been
1452 coming from ARM mode, which is word-aligned. */
1453 record_alignment (now_seg, 1);
1455 mapping_state (MAP_THUMB);
1461 if ((cpu_variant & ARM_ALL) == ARM_EXT_V4T)
1462 as_bad (_("selected processor does not support ARM opcodes"));
1467 frag_align (2, 0, 0);
1469 record_alignment (now_seg, 1);
1471 mapping_state (MAP_ARM);
1475 as_bad (_("invalid instruction size selected (%d)"), width);
1480 s_arm (int ignore ATTRIBUTE_UNUSED)
1483 demand_empty_rest_of_line ();
1487 s_thumb (int ignore ATTRIBUTE_UNUSED)
1490 demand_empty_rest_of_line ();
1494 s_code (int unused ATTRIBUTE_UNUSED)
1498 temp = get_absolute_expression ();
1503 opcode_select (temp);
1507 as_bad (_("invalid operand to .code directive (%d) (expecting 16 or 32)"), temp);
1512 s_force_thumb (int ignore ATTRIBUTE_UNUSED)
1514 /* If we are not already in thumb mode go into it, EVEN if
1515 the target processor does not support thumb instructions.
1516 This is used by gcc/config/arm/lib1funcs.asm for example
1517 to compile interworking support functions even if the
1518 target processor should not support interworking. */
1522 record_alignment (now_seg, 1);
1525 demand_empty_rest_of_line ();
1529 s_thumb_func (int ignore ATTRIBUTE_UNUSED)
1533 /* The following label is the name/address of the start of a Thumb function.
1534 We need to know this for the interworking support. */
1535 label_is_thumb_function_name = TRUE;
1538 /* Perform a .set directive, but also mark the alias as
1539 being a thumb function. */
1542 s_thumb_set (int equiv)
1544 /* XXX the following is a duplicate of the code for s_set() in read.c
1545 We cannot just call that code as we need to get at the symbol that
1552 /* Especial apologies for the random logic:
1553 This just grew, and could be parsed much more simply!
1555 name = input_line_pointer;
1556 delim = get_symbol_end ();
1557 end_name = input_line_pointer;
1560 if (*input_line_pointer != ',')
1563 as_bad (_("expected comma after name \"%s\""), name);
1565 ignore_rest_of_line ();
1569 input_line_pointer++;
1572 if (name[0] == '.' && name[1] == '\0')
1574 /* XXX - this should not happen to .thumb_set. */
1578 if ((symbolP = symbol_find (name)) == NULL
1579 && (symbolP = md_undefined_symbol (name)) == NULL)
1582 /* When doing symbol listings, play games with dummy fragments living
1583 outside the normal fragment chain to record the file and line info
1585 if (listing & LISTING_SYMBOLS)
1587 extern struct list_info_struct * listing_tail;
1588 fragS * dummy_frag = xmalloc (sizeof (fragS));
1590 memset (dummy_frag, 0, sizeof (fragS));
1591 dummy_frag->fr_type = rs_fill;
1592 dummy_frag->line = listing_tail;
1593 symbolP = symbol_new (name, undefined_section, 0, dummy_frag);
1594 dummy_frag->fr_symbol = symbolP;
1598 symbolP = symbol_new (name, undefined_section, 0, &zero_address_frag);
1601 /* "set" symbols are local unless otherwise specified. */
1602 SF_SET_LOCAL (symbolP);
1603 #endif /* OBJ_COFF */
1604 } /* Make a new symbol. */
1606 symbol_table_insert (symbolP);
1611 && S_IS_DEFINED (symbolP)
1612 && S_GET_SEGMENT (symbolP) != reg_section)
1613 as_bad (_("symbol `%s' already defined"), S_GET_NAME (symbolP));
1615 pseudo_set (symbolP);
1617 demand_empty_rest_of_line ();
1619 /* XXX Now we come to the Thumb specific bit of code. */
1621 THUMB_SET_FUNC (symbolP, 1);
1622 ARM_SET_THUMB (symbolP, 1);
1623 #if defined OBJ_ELF || defined OBJ_COFF
1624 ARM_SET_INTERWORK (symbolP, support_interwork);
1628 /* Directives: Mode selection. */
1630 /* .syntax [unified|divided] - choose the new unified syntax
1631 (same for Arm and Thumb encoding, modulo slight differences in what
1632 can be represented) or the old divergent syntax for each mode. */
1634 s_syntax (int unused ATTRIBUTE_UNUSED)
1638 name = input_line_pointer;
1639 delim = get_symbol_end ();
1641 if (!strcasecmp (name, "unified"))
1642 unified_syntax = TRUE;
1643 else if (!strcasecmp (name, "divided"))
1644 unified_syntax = FALSE;
1647 as_bad (_("unrecognized syntax mode \"%s\""), name);
1650 *input_line_pointer = delim;
1651 demand_empty_rest_of_line ();
1654 /* Directives: sectioning and alignment. */
1656 /* Same as s_align_ptwo but align 0 => align 2. */
1659 s_align (int unused ATTRIBUTE_UNUSED)
1663 long max_alignment = 15;
1665 temp = get_absolute_expression ();
1666 if (temp > max_alignment)
1667 as_bad (_("alignment too large: %d assumed"), temp = max_alignment);
1670 as_bad (_("alignment negative. 0 assumed."));
1674 if (*input_line_pointer == ',')
1676 input_line_pointer++;
1677 temp_fill = get_absolute_expression ();
1685 /* Only make a frag if we HAVE to. */
1686 if (temp && !need_pass_2)
1687 frag_align (temp, (int) temp_fill, 0);
1688 demand_empty_rest_of_line ();
1690 record_alignment (now_seg, temp);
1694 s_bss (int ignore ATTRIBUTE_UNUSED)
1696 /* We don't support putting frags in the BSS segment, we fake it by
1697 marking in_bss, then looking at s_skip for clues. */
1698 subseg_set (bss_section, 0);
1699 demand_empty_rest_of_line ();
1700 mapping_state (MAP_DATA);
1704 s_even (int ignore ATTRIBUTE_UNUSED)
1706 /* Never make frag if expect extra pass. */
1708 frag_align (1, 0, 0);
1710 record_alignment (now_seg, 1);
1712 demand_empty_rest_of_line ();
1715 /* Directives: Literal pools. */
1717 static literal_pool *
1718 find_literal_pool (void)
1720 literal_pool * pool;
1722 for (pool = list_of_pools; pool != NULL; pool = pool->next)
1724 if (pool->section == now_seg
1725 && pool->sub_section == now_subseg)
1732 static literal_pool *
1733 find_or_make_literal_pool (void)
1735 /* Next literal pool ID number. */
1736 static unsigned int latest_pool_num = 1;
1737 literal_pool * pool;
1739 pool = find_literal_pool ();
1743 /* Create a new pool. */
1744 pool = xmalloc (sizeof (* pool));
1748 pool->next_free_entry = 0;
1749 pool->section = now_seg;
1750 pool->sub_section = now_subseg;
1751 pool->next = list_of_pools;
1752 pool->symbol = NULL;
1754 /* Add it to the list. */
1755 list_of_pools = pool;
1758 /* New pools, and emptied pools, will have a NULL symbol. */
1759 if (pool->symbol == NULL)
1761 pool->symbol = symbol_create (FAKE_LABEL_NAME, undefined_section,
1762 (valueT) 0, &zero_address_frag);
1763 pool->id = latest_pool_num ++;
1770 /* Add the literal in the global 'inst'
1771 structure to the relevent literal pool. */
1774 add_to_lit_pool (void)
1776 literal_pool * pool;
1779 pool = find_or_make_literal_pool ();
1781 /* Check if this literal value is already in the pool. */
1782 for (entry = 0; entry < pool->next_free_entry; entry ++)
1784 if ((pool->literals[entry].X_op == inst.reloc.exp.X_op)
1785 && (inst.reloc.exp.X_op == O_constant)
1786 && (pool->literals[entry].X_add_number
1787 == inst.reloc.exp.X_add_number)
1788 && (pool->literals[entry].X_unsigned
1789 == inst.reloc.exp.X_unsigned))
1792 if ((pool->literals[entry].X_op == inst.reloc.exp.X_op)
1793 && (inst.reloc.exp.X_op == O_symbol)
1794 && (pool->literals[entry].X_add_number
1795 == inst.reloc.exp.X_add_number)
1796 && (pool->literals[entry].X_add_symbol
1797 == inst.reloc.exp.X_add_symbol)
1798 && (pool->literals[entry].X_op_symbol
1799 == inst.reloc.exp.X_op_symbol))
1803 /* Do we need to create a new entry? */
1804 if (entry == pool->next_free_entry)
1806 if (entry >= MAX_LITERAL_POOL_SIZE)
1808 inst.error = _("literal pool overflow");
1812 pool->literals[entry] = inst.reloc.exp;
1813 pool->next_free_entry += 1;
1816 inst.reloc.exp.X_op = O_symbol;
1817 inst.reloc.exp.X_add_number = ((int) entry) * 4;
1818 inst.reloc.exp.X_add_symbol = pool->symbol;
1823 /* Can't use symbol_new here, so have to create a symbol and then at
1824 a later date assign it a value. Thats what these functions do. */
1827 symbol_locate (symbolS * symbolP,
1828 const char * name, /* It is copied, the caller can modify. */
1829 segT segment, /* Segment identifier (SEG_<something>). */
1830 valueT valu, /* Symbol value. */
1831 fragS * frag) /* Associated fragment. */
1833 unsigned int name_length;
1834 char * preserved_copy_of_name;
1836 name_length = strlen (name) + 1; /* +1 for \0. */
1837 obstack_grow (¬es, name, name_length);
1838 preserved_copy_of_name = obstack_finish (¬es);
1840 #ifdef tc_canonicalize_symbol_name
1841 preserved_copy_of_name =
1842 tc_canonicalize_symbol_name (preserved_copy_of_name);
1845 S_SET_NAME (symbolP, preserved_copy_of_name);
1847 S_SET_SEGMENT (symbolP, segment);
1848 S_SET_VALUE (symbolP, valu);
1849 symbol_clear_list_pointers (symbolP);
1851 symbol_set_frag (symbolP, frag);
1853 /* Link to end of symbol chain. */
1855 extern int symbol_table_frozen;
1857 if (symbol_table_frozen)
1861 symbol_append (symbolP, symbol_lastP, & symbol_rootP, & symbol_lastP);
1863 obj_symbol_new_hook (symbolP);
1865 #ifdef tc_symbol_new_hook
1866 tc_symbol_new_hook (symbolP);
1870 verify_symbol_chain (symbol_rootP, symbol_lastP);
1871 #endif /* DEBUG_SYMS */
1876 s_ltorg (int ignored ATTRIBUTE_UNUSED)
1879 literal_pool * pool;
1882 pool = find_literal_pool ();
1884 || pool->symbol == NULL
1885 || pool->next_free_entry == 0)
1888 mapping_state (MAP_DATA);
1890 /* Align pool as you have word accesses.
1891 Only make a frag if we have to. */
1893 frag_align (2, 0, 0);
1895 record_alignment (now_seg, 2);
1897 sprintf (sym_name, "$$lit_\002%x", pool->id);
1899 symbol_locate (pool->symbol, sym_name, now_seg,
1900 (valueT) frag_now_fix (), frag_now);
1901 symbol_table_insert (pool->symbol);
1903 ARM_SET_THUMB (pool->symbol, thumb_mode);
1905 #if defined OBJ_COFF || defined OBJ_ELF
1906 ARM_SET_INTERWORK (pool->symbol, support_interwork);
1909 for (entry = 0; entry < pool->next_free_entry; entry ++)
1910 /* First output the expression in the instruction to the pool. */
1911 emit_expr (&(pool->literals[entry]), 4); /* .word */
1913 /* Mark the pool as empty. */
1914 pool->next_free_entry = 0;
1915 pool->symbol = NULL;
1919 /* Forward declarations for functions below, in the MD interface
1921 static void fix_new_arm (fragS *, int, short, expressionS *, int, int);
1922 static valueT create_unwind_entry (int);
1923 static void start_unwind_section (const segT, int);
1924 static void add_unwind_opcode (valueT, int);
1925 static void flush_pending_unwind (void);
1927 /* Directives: Data. */
1930 s_arm_elf_cons (int nbytes)
1934 #ifdef md_flush_pending_output
1935 md_flush_pending_output ();
1938 if (is_it_end_of_statement ())
1940 demand_empty_rest_of_line ();
1944 #ifdef md_cons_align
1945 md_cons_align (nbytes);
1948 mapping_state (MAP_DATA);
1952 char *base = input_line_pointer;
1956 if (exp.X_op != O_symbol)
1957 emit_expr (&exp, (unsigned int) nbytes);
1960 char *before_reloc = input_line_pointer;
1961 reloc = parse_reloc (&input_line_pointer);
1964 as_bad (_("unrecognized relocation suffix"));
1965 ignore_rest_of_line ();
1968 else if (reloc == BFD_RELOC_UNUSED)
1969 emit_expr (&exp, (unsigned int) nbytes);
1972 reloc_howto_type *howto = bfd_reloc_type_lookup (stdoutput, reloc);
1973 int size = bfd_get_reloc_size (howto);
1975 if (reloc == BFD_RELOC_ARM_PLT32)
1977 as_bad (_("(plt) is only valid on branch targets"));
1978 reloc = BFD_RELOC_UNUSED;
1983 as_bad (_("%s relocations do not fit in %d bytes"),
1984 howto->name, nbytes);
1987 /* We've parsed an expression stopping at O_symbol.
1988 But there may be more expression left now that we
1989 have parsed the relocation marker. Parse it again.
1990 XXX Surely there is a cleaner way to do this. */
1991 char *p = input_line_pointer;
1993 char *save_buf = alloca (input_line_pointer - base);
1994 memcpy (save_buf, base, input_line_pointer - base);
1995 memmove (base + (input_line_pointer - before_reloc),
1996 base, before_reloc - base);
1998 input_line_pointer = base + (input_line_pointer-before_reloc);
2000 memcpy (base, save_buf, p - base);
2002 offset = nbytes - size;
2003 p = frag_more ((int) nbytes);
2004 fix_new_exp (frag_now, p - frag_now->fr_literal + offset,
2005 size, &exp, 0, reloc);
2010 while (*input_line_pointer++ == ',');
2012 /* Put terminator back into stream. */
2013 input_line_pointer --;
2014 demand_empty_rest_of_line ();
2018 /* Parse a .rel31 directive. */
2021 s_arm_rel31 (int ignored ATTRIBUTE_UNUSED)
2028 if (*input_line_pointer == '1')
2029 highbit = 0x80000000;
2030 else if (*input_line_pointer != '0')
2031 as_bad (_("expected 0 or 1"));
2033 input_line_pointer++;
2034 if (*input_line_pointer != ',')
2035 as_bad (_("missing comma"));
2036 input_line_pointer++;
2038 #ifdef md_flush_pending_output
2039 md_flush_pending_output ();
2042 #ifdef md_cons_align
2046 mapping_state (MAP_DATA);
2051 md_number_to_chars (p, highbit, 4);
2052 fix_new_arm (frag_now, p - frag_now->fr_literal, 4, &exp, 1,
2053 BFD_RELOC_ARM_PREL31);
2055 demand_empty_rest_of_line ();
2058 /* Directives: AEABI stack-unwind tables. */
2060 /* Parse an unwind_fnstart directive. Simply records the current location. */
2063 s_arm_unwind_fnstart (int ignored ATTRIBUTE_UNUSED)
2065 demand_empty_rest_of_line ();
2066 /* Mark the start of the function. */
2067 unwind.proc_start = expr_build_dot ();
2069 /* Reset the rest of the unwind info. */
2070 unwind.opcode_count = 0;
2071 unwind.table_entry = NULL;
2072 unwind.personality_routine = NULL;
2073 unwind.personality_index = -1;
2074 unwind.frame_size = 0;
2075 unwind.fp_offset = 0;
2078 unwind.sp_restored = 0;
2082 /* Parse a handlerdata directive. Creates the exception handling table entry
2083 for the function. */
2086 s_arm_unwind_handlerdata (int ignored ATTRIBUTE_UNUSED)
2088 demand_empty_rest_of_line ();
2089 if (unwind.table_entry)
2090 as_bad (_("dupicate .handlerdata directive"));
2092 create_unwind_entry (1);
2095 /* Parse an unwind_fnend directive. Generates the index table entry. */
2098 s_arm_unwind_fnend (int ignored ATTRIBUTE_UNUSED)
2104 demand_empty_rest_of_line ();
2106 /* Add eh table entry. */
2107 if (unwind.table_entry == NULL)
2108 val = create_unwind_entry (0);
2112 /* Add index table entry. This is two words. */
2113 start_unwind_section (unwind.saved_seg, 1);
2114 frag_align (2, 0, 0);
2115 record_alignment (now_seg, 2);
2117 ptr = frag_more (8);
2118 where = frag_now_fix () - 8;
2120 /* Self relative offset of the function start. */
2121 fix_new (frag_now, where, 4, unwind.proc_start, 0, 1,
2122 BFD_RELOC_ARM_PREL31);
2124 /* Indicate dependency on EHABI-defined personality routines to the
2125 linker, if it hasn't been done already. */
2126 if (unwind.personality_index >= 0 && unwind.personality_index < 3
2127 && !(marked_pr_dependency & (1 << unwind.personality_index)))
2129 static const char *const name[] = {
2130 "__aeabi_unwind_cpp_pr0",
2131 "__aeabi_unwind_cpp_pr1",
2132 "__aeabi_unwind_cpp_pr2"
2134 symbolS *pr = symbol_find_or_make (name[unwind.personality_index]);
2135 fix_new (frag_now, where, 0, pr, 0, 1, BFD_RELOC_NONE);
2136 marked_pr_dependency |= 1 << unwind.personality_index;
2137 seg_info (now_seg)->tc_segment_info_data.marked_pr_dependency
2138 = marked_pr_dependency;
2142 /* Inline exception table entry. */
2143 md_number_to_chars (ptr + 4, val, 4);
2145 /* Self relative offset of the table entry. */
2146 fix_new (frag_now, where + 4, 4, unwind.table_entry, 0, 1,
2147 BFD_RELOC_ARM_PREL31);
2149 /* Restore the original section. */
2150 subseg_set (unwind.saved_seg, unwind.saved_subseg);
2154 /* Parse an unwind_cantunwind directive. */
2157 s_arm_unwind_cantunwind (int ignored ATTRIBUTE_UNUSED)
2159 demand_empty_rest_of_line ();
2160 if (unwind.personality_routine || unwind.personality_index != -1)
2161 as_bad (_("personality routine specified for cantunwind frame"));
2163 unwind.personality_index = -2;
2167 /* Parse a personalityindex directive. */
2170 s_arm_unwind_personalityindex (int ignored ATTRIBUTE_UNUSED)
2174 if (unwind.personality_routine || unwind.personality_index != -1)
2175 as_bad (_("duplicate .personalityindex directive"));
2179 if (exp.X_op != O_constant
2180 || exp.X_add_number < 0 || exp.X_add_number > 15)
2182 as_bad (_("bad personality routine number"));
2183 ignore_rest_of_line ();
2187 unwind.personality_index = exp.X_add_number;
2189 demand_empty_rest_of_line ();
2193 /* Parse a personality directive. */
2196 s_arm_unwind_personality (int ignored ATTRIBUTE_UNUSED)
2200 if (unwind.personality_routine || unwind.personality_index != -1)
2201 as_bad (_("duplicate .personality directive"));
2203 name = input_line_pointer;
2204 c = get_symbol_end ();
2205 p = input_line_pointer;
2206 unwind.personality_routine = symbol_find_or_make (name);
2208 demand_empty_rest_of_line ();
2212 /* Parse a directive saving core registers. */
2215 s_arm_unwind_save_core (void)
2221 range = parse_reg_list (&input_line_pointer);
2224 as_bad (_("expected register list"));
2225 ignore_rest_of_line ();
2229 demand_empty_rest_of_line ();
2231 /* Turn .unwind_movsp ip followed by .unwind_save {..., ip, ...}
2232 into .unwind_save {..., sp...}. We aren't bothered about the value of
2233 ip because it is clobbered by calls. */
2234 if (unwind.sp_restored && unwind.fp_reg == 12
2235 && (range & 0x3000) == 0x1000)
2237 unwind.opcode_count--;
2238 unwind.sp_restored = 0;
2239 range = (range | 0x2000) & ~0x1000;
2240 unwind.pending_offset = 0;
2243 /* See if we can use the short opcodes. These pop a block of upto 8
2244 registers starting with r4, plus maybe r14. */
2245 for (n = 0; n < 8; n++)
2247 /* Break at the first non-saved register. */
2248 if ((range & (1 << (n + 4))) == 0)
2251 /* See if there are any other bits set. */
2252 if (n == 0 || (range & (0xfff0 << n) & 0xbff0) != 0)
2254 /* Use the long form. */
2255 op = 0x8000 | ((range >> 4) & 0xfff);
2256 add_unwind_opcode (op, 2);
2260 /* Use the short form. */
2262 op = 0xa8; /* Pop r14. */
2264 op = 0xa0; /* Do not pop r14. */
2266 add_unwind_opcode (op, 1);
2272 op = 0xb100 | (range & 0xf);
2273 add_unwind_opcode (op, 2);
2276 /* Record the number of bytes pushed. */
2277 for (n = 0; n < 16; n++)
2279 if (range & (1 << n))
2280 unwind.frame_size += 4;
2285 /* Parse a directive saving FPA registers. */
2288 s_arm_unwind_save_fpa (int reg)
2294 /* Get Number of registers to transfer. */
2295 if (skip_past_comma (&input_line_pointer) != FAIL)
2298 exp.X_op = O_illegal;
2300 if (exp.X_op != O_constant)
2302 as_bad (_("expected , <constant>"));
2303 ignore_rest_of_line ();
2307 num_regs = exp.X_add_number;
2309 if (num_regs < 1 || num_regs > 4)
2311 as_bad (_("number of registers must be in the range [1:4]"));
2312 ignore_rest_of_line ();
2316 demand_empty_rest_of_line ();
2321 op = 0xb4 | (num_regs - 1);
2322 add_unwind_opcode (op, 1);
2327 op = 0xc800 | (reg << 4) | (num_regs - 1);
2328 add_unwind_opcode (op, 2);
2330 unwind.frame_size += num_regs * 12;
2334 /* Parse a directive saving VFP registers. */
2337 s_arm_unwind_save_vfp (void)
2343 count = parse_vfp_reg_list (&input_line_pointer, ®, 1);
2346 as_bad (_("expected register list"));
2347 ignore_rest_of_line ();
2351 demand_empty_rest_of_line ();
2356 op = 0xb8 | (count - 1);
2357 add_unwind_opcode (op, 1);
2362 op = 0xb300 | (reg << 4) | (count - 1);
2363 add_unwind_opcode (op, 2);
2365 unwind.frame_size += count * 8 + 4;
2369 /* Parse a directive saving iWMMXt data registers. */
2372 s_arm_unwind_save_mmxwr (void)
2380 if (*input_line_pointer == '{')
2381 input_line_pointer++;
2385 reg = arm_reg_parse (&input_line_pointer, REG_TYPE_MMXWR);
2389 as_bad (_(reg_expected_msgs[REG_TYPE_MMXWR]));
2394 as_tsktsk (_("register list not in ascending order"));
2397 if (*input_line_pointer == '-')
2399 input_line_pointer++;
2400 hi_reg = arm_reg_parse (&input_line_pointer, REG_TYPE_MMXWR);
2403 as_bad (_(reg_expected_msgs[REG_TYPE_MMXWR]));
2406 else if (reg >= hi_reg)
2408 as_bad (_("bad register range"));
2411 for (; reg < hi_reg; reg++)
2415 while (skip_past_comma (&input_line_pointer) != FAIL);
2417 if (*input_line_pointer == '}')
2418 input_line_pointer++;
2420 demand_empty_rest_of_line ();
2422 /* Generate any deferred opcodes becuuse we're going to be looking at
2424 flush_pending_unwind ();
2426 for (i = 0; i < 16; i++)
2428 if (mask & (1 << i))
2429 unwind.frame_size += 8;
2432 /* Attempt to combine with a previous opcode. We do this because gcc
2433 likes to output separate unwind directives for a single block of
2435 if (unwind.opcode_count > 0)
2437 i = unwind.opcodes[unwind.opcode_count - 1];
2438 if ((i & 0xf8) == 0xc0)
2441 /* Only merge if the blocks are contiguous. */
2444 if ((mask & 0xfe00) == (1 << 9))
2446 mask |= ((1 << (i + 11)) - 1) & 0xfc00;
2447 unwind.opcode_count--;
2450 else if (i == 6 && unwind.opcode_count >= 2)
2452 i = unwind.opcodes[unwind.opcode_count - 2];
2456 op = 0xffff << (reg - 1);
2458 || ((mask & op) == (1u << (reg - 1))))
2460 op = (1 << (reg + i + 1)) - 1;
2461 op &= ~((1 << reg) - 1);
2463 unwind.opcode_count -= 2;
2470 /* We want to generate opcodes in the order the registers have been
2471 saved, ie. descending order. */
2472 for (reg = 15; reg >= -1; reg--)
2474 /* Save registers in blocks. */
2476 || !(mask & (1 << reg)))
2478 /* We found an unsaved reg. Generate opcodes to save the
2479 preceeding block. */
2485 op = 0xc0 | (hi_reg - 10);
2486 add_unwind_opcode (op, 1);
2491 op = 0xc600 | ((reg + 1) << 4) | ((hi_reg - reg) - 1);
2492 add_unwind_opcode (op, 2);
2501 ignore_rest_of_line ();
2505 s_arm_unwind_save_mmxwcg (void)
2512 if (*input_line_pointer == '{')
2513 input_line_pointer++;
2517 reg = arm_reg_parse (&input_line_pointer, REG_TYPE_MMXWCG);
2521 as_bad (_(reg_expected_msgs[REG_TYPE_MMXWCG]));
2527 as_tsktsk (_("register list not in ascending order"));
2530 if (*input_line_pointer == '-')
2532 input_line_pointer++;
2533 hi_reg = arm_reg_parse (&input_line_pointer, REG_TYPE_MMXWCG);
2536 as_bad (_(reg_expected_msgs[REG_TYPE_MMXWCG]));
2539 else if (reg >= hi_reg)
2541 as_bad (_("bad register range"));
2544 for (; reg < hi_reg; reg++)
2548 while (skip_past_comma (&input_line_pointer) != FAIL);
2550 if (*input_line_pointer == '}')
2551 input_line_pointer++;
2553 demand_empty_rest_of_line ();
2555 /* Generate any deferred opcodes becuuse we're going to be looking at
2557 flush_pending_unwind ();
2559 for (reg = 0; reg < 16; reg++)
2561 if (mask & (1 << reg))
2562 unwind.frame_size += 4;
2565 add_unwind_opcode (op, 2);
2568 ignore_rest_of_line ();
2572 /* Parse an unwind_save directive. */
2575 s_arm_unwind_save (int ignored ATTRIBUTE_UNUSED)
2578 struct reg_entry *reg;
2579 bfd_boolean had_brace = FALSE;
2581 /* Figure out what sort of save we have. */
2582 peek = input_line_pointer;
2590 reg = arm_reg_parse_multi (&peek);
2594 as_bad (_("register expected"));
2595 ignore_rest_of_line ();
2604 as_bad (_("FPA .unwind_save does not take a register list"));
2605 ignore_rest_of_line ();
2608 s_arm_unwind_save_fpa (reg->number);
2611 case REG_TYPE_RN: s_arm_unwind_save_core (); return;
2612 case REG_TYPE_VFD: s_arm_unwind_save_vfp (); return;
2613 case REG_TYPE_MMXWR: s_arm_unwind_save_mmxwr (); return;
2614 case REG_TYPE_MMXWCG: s_arm_unwind_save_mmxwcg (); return;
2617 as_bad (_(".unwind_save does not support this kind of register"));
2618 ignore_rest_of_line ();
2623 /* Parse an unwind_movsp directive. */
2626 s_arm_unwind_movsp (int ignored ATTRIBUTE_UNUSED)
2631 reg = arm_reg_parse (&input_line_pointer, REG_TYPE_RN);
2634 as_bad (_(reg_expected_msgs[REG_TYPE_RN]));
2635 ignore_rest_of_line ();
2638 demand_empty_rest_of_line ();
2640 if (reg == REG_SP || reg == REG_PC)
2642 as_bad (_("SP and PC not permitted in .unwind_movsp directive"));
2646 if (unwind.fp_reg != REG_SP)
2647 as_bad (_("unexpected .unwind_movsp directive"));
2649 /* Generate opcode to restore the value. */
2651 add_unwind_opcode (op, 1);
2653 /* Record the information for later. */
2654 unwind.fp_reg = reg;
2655 unwind.fp_offset = unwind.frame_size;
2656 unwind.sp_restored = 1;
2659 /* Parse an unwind_pad directive. */
2662 s_arm_unwind_pad (int ignored ATTRIBUTE_UNUSED)
2666 if (immediate_for_directive (&offset) == FAIL)
2671 as_bad (_("stack increment must be multiple of 4"));
2672 ignore_rest_of_line ();
2676 /* Don't generate any opcodes, just record the details for later. */
2677 unwind.frame_size += offset;
2678 unwind.pending_offset += offset;
2680 demand_empty_rest_of_line ();
2683 /* Parse an unwind_setfp directive. */
2686 s_arm_unwind_setfp (int ignored ATTRIBUTE_UNUSED)
2692 fp_reg = arm_reg_parse (&input_line_pointer, REG_TYPE_RN);
2693 if (skip_past_comma (&input_line_pointer) == FAIL)
2696 sp_reg = arm_reg_parse (&input_line_pointer, REG_TYPE_RN);
2698 if (fp_reg == FAIL || sp_reg == FAIL)
2700 as_bad (_("expected <reg>, <reg>"));
2701 ignore_rest_of_line ();
2705 /* Optional constant. */
2706 if (skip_past_comma (&input_line_pointer) != FAIL)
2708 if (immediate_for_directive (&offset) == FAIL)
2714 demand_empty_rest_of_line ();
2716 if (sp_reg != 13 && sp_reg != unwind.fp_reg)
2718 as_bad (_("register must be either sp or set by a previous"
2719 "unwind_movsp directive"));
2723 /* Don't generate any opcodes, just record the information for later. */
2724 unwind.fp_reg = fp_reg;
2727 unwind.fp_offset = unwind.frame_size - offset;
2729 unwind.fp_offset -= offset;
2732 /* Parse an unwind_raw directive. */
2735 s_arm_unwind_raw (int ignored ATTRIBUTE_UNUSED)
2738 /* This is an arbitary limit. */
2739 unsigned char op[16];
2743 if (exp.X_op == O_constant
2744 && skip_past_comma (&input_line_pointer) != FAIL)
2746 unwind.frame_size += exp.X_add_number;
2750 exp.X_op = O_illegal;
2752 if (exp.X_op != O_constant)
2754 as_bad (_("expected <offset>, <opcode>"));
2755 ignore_rest_of_line ();
2761 /* Parse the opcode. */
2766 as_bad (_("unwind opcode too long"));
2767 ignore_rest_of_line ();
2769 if (exp.X_op != O_constant || exp.X_add_number & ~0xff)
2771 as_bad (_("invalid unwind opcode"));
2772 ignore_rest_of_line ();
2775 op[count++] = exp.X_add_number;
2777 /* Parse the next byte. */
2778 if (skip_past_comma (&input_line_pointer) == FAIL)
2784 /* Add the opcode bytes in reverse order. */
2786 add_unwind_opcode (op[count], 1);
2788 demand_empty_rest_of_line ();
2790 #endif /* OBJ_ELF */
2792 /* This table describes all the machine specific pseudo-ops the assembler
2793 has to support. The fields are:
2794 pseudo-op name without dot
2795 function to call to execute this pseudo-op
2796 Integer arg to pass to the function. */
2798 const pseudo_typeS md_pseudo_table[] =
2800 /* Never called because '.req' does not start a line. */
2801 { "req", s_req, 0 },
2802 { "unreq", s_unreq, 0 },
2803 { "bss", s_bss, 0 },
2804 { "align", s_align, 0 },
2805 { "arm", s_arm, 0 },
2806 { "thumb", s_thumb, 0 },
2807 { "code", s_code, 0 },
2808 { "force_thumb", s_force_thumb, 0 },
2809 { "thumb_func", s_thumb_func, 0 },
2810 { "thumb_set", s_thumb_set, 0 },
2811 { "even", s_even, 0 },
2812 { "ltorg", s_ltorg, 0 },
2813 { "pool", s_ltorg, 0 },
2814 { "syntax", s_syntax, 0 },
2816 { "word", s_arm_elf_cons, 4 },
2817 { "long", s_arm_elf_cons, 4 },
2818 { "rel31", s_arm_rel31, 0 },
2819 { "fnstart", s_arm_unwind_fnstart, 0 },
2820 { "fnend", s_arm_unwind_fnend, 0 },
2821 { "cantunwind", s_arm_unwind_cantunwind, 0 },
2822 { "personality", s_arm_unwind_personality, 0 },
2823 { "personalityindex", s_arm_unwind_personalityindex, 0 },
2824 { "handlerdata", s_arm_unwind_handlerdata, 0 },
2825 { "save", s_arm_unwind_save, 0 },
2826 { "movsp", s_arm_unwind_movsp, 0 },
2827 { "pad", s_arm_unwind_pad, 0 },
2828 { "setfp", s_arm_unwind_setfp, 0 },
2829 { "unwind_raw", s_arm_unwind_raw, 0 },
2833 { "extend", float_cons, 'x' },
2834 { "ldouble", float_cons, 'x' },
2835 { "packed", float_cons, 'p' },
2839 /* Parser functions used exclusively in instruction operands. */
2841 /* Generic immediate-value read function for use in insn parsing.
2842 STR points to the beginning of the immediate (the leading #);
2843 VAL receives the value; if the value is outside [MIN, MAX]
2844 issue an error. PREFIX_OPT is true if the immediate prefix is
2848 parse_immediate (char **str, int *val, int min, int max,
2849 bfd_boolean prefix_opt)
2852 my_get_expression (&exp, str, prefix_opt ? GE_OPT_PREFIX : GE_IMM_PREFIX);
2853 if (exp.X_op != O_constant)
2855 inst.error = _("constant expression required");
2859 if (exp.X_add_number < min || exp.X_add_number > max)
2861 inst.error = _("immediate value out of range");
2865 *val = exp.X_add_number;
2869 /* Returns the pseudo-register number of an FPA immediate constant,
2870 or FAIL if there isn't a valid constant here. */
2873 parse_fpa_immediate (char ** str)
2875 LITTLENUM_TYPE words[MAX_LITTLENUMS];
2881 /* First try and match exact strings, this is to guarantee
2882 that some formats will work even for cross assembly. */
2884 for (i = 0; fp_const[i]; i++)
2886 if (strncmp (*str, fp_const[i], strlen (fp_const[i])) == 0)
2890 *str += strlen (fp_const[i]);
2891 if (is_end_of_line[(unsigned char) **str])
2897 /* Just because we didn't get a match doesn't mean that the constant
2898 isn't valid, just that it is in a format that we don't
2899 automatically recognize. Try parsing it with the standard
2900 expression routines. */
2902 memset (words, 0, MAX_LITTLENUMS * sizeof (LITTLENUM_TYPE));
2904 /* Look for a raw floating point number. */
2905 if ((save_in = atof_ieee (*str, 'x', words)) != NULL
2906 && is_end_of_line[(unsigned char) *save_in])
2908 for (i = 0; i < NUM_FLOAT_VALS; i++)
2910 for (j = 0; j < MAX_LITTLENUMS; j++)
2912 if (words[j] != fp_values[i][j])
2916 if (j == MAX_LITTLENUMS)
2924 /* Try and parse a more complex expression, this will probably fail
2925 unless the code uses a floating point prefix (eg "0f"). */
2926 save_in = input_line_pointer;
2927 input_line_pointer = *str;
2928 if (expression (&exp) == absolute_section
2929 && exp.X_op == O_big
2930 && exp.X_add_number < 0)
2932 /* FIXME: 5 = X_PRECISION, should be #define'd where we can use it.
2934 if (gen_to_words (words, 5, (long) 15) == 0)
2936 for (i = 0; i < NUM_FLOAT_VALS; i++)
2938 for (j = 0; j < MAX_LITTLENUMS; j++)
2940 if (words[j] != fp_values[i][j])
2944 if (j == MAX_LITTLENUMS)
2946 *str = input_line_pointer;
2947 input_line_pointer = save_in;
2954 *str = input_line_pointer;
2955 input_line_pointer = save_in;
2956 inst.error = _("invalid FPA immediate expression");
2960 /* Shift operands. */
2963 SHIFT_LSL, SHIFT_LSR, SHIFT_ASR, SHIFT_ROR, SHIFT_RRX
2966 struct asm_shift_name
2969 enum shift_kind kind;
2972 /* Third argument to parse_shift. */
2973 enum parse_shift_mode
2975 NO_SHIFT_RESTRICT, /* Any kind of shift is accepted. */
2976 SHIFT_IMMEDIATE, /* Shift operand must be an immediate. */
2977 SHIFT_LSL_OR_ASR_IMMEDIATE, /* Shift must be LSL or ASR immediate. */
2978 SHIFT_ASR_IMMEDIATE, /* Shift must be ASR immediate. */
2979 SHIFT_LSL_IMMEDIATE, /* Shift must be LSL immediate. */
2982 /* Parse a <shift> specifier on an ARM data processing instruction.
2983 This has three forms:
2985 (LSL|LSR|ASL|ASR|ROR) Rs
2986 (LSL|LSR|ASL|ASR|ROR) #imm
2989 Note that ASL is assimilated to LSL in the instruction encoding, and
2990 RRX to ROR #0 (which cannot be written as such). */
2993 parse_shift (char **str, int i, enum parse_shift_mode mode)
2995 const struct asm_shift_name *shift_name;
2996 enum shift_kind shift;
3001 for (p = *str; ISALPHA (*p); p++)
3006 inst.error = _("shift expression expected");
3010 shift_name = hash_find_n (arm_shift_hsh, *str, p - *str);
3012 if (shift_name == NULL)
3014 inst.error = _("shift expression expected");
3018 shift = shift_name->kind;
3022 case NO_SHIFT_RESTRICT:
3023 case SHIFT_IMMEDIATE: break;
3025 case SHIFT_LSL_OR_ASR_IMMEDIATE:
3026 if (shift != SHIFT_LSL && shift != SHIFT_ASR)
3028 inst.error = _("'LSL' or 'ASR' required");
3033 case SHIFT_LSL_IMMEDIATE:
3034 if (shift != SHIFT_LSL)
3036 inst.error = _("'LSL' required");
3041 case SHIFT_ASR_IMMEDIATE:
3042 if (shift != SHIFT_ASR)
3044 inst.error = _("'ASR' required");
3052 if (shift != SHIFT_RRX)
3054 /* Whitespace can appear here if the next thing is a bare digit. */
3055 skip_whitespace (p);
3057 if (mode == NO_SHIFT_RESTRICT
3058 && (reg = arm_reg_parse (&p, REG_TYPE_RN)) != FAIL)
3060 inst.operands[i].imm = reg;
3061 inst.operands[i].immisreg = 1;
3063 else if (my_get_expression (&inst.reloc.exp, &p, GE_IMM_PREFIX))
3066 inst.operands[i].shift_kind = shift;
3067 inst.operands[i].shifted = 1;
3072 /* Parse a <shifter_operand> for an ARM data processing instruction:
3075 #<immediate>, <rotate>
3079 where <shift> is defined by parse_shift above, and <rotate> is a
3080 multiple of 2 between 0 and 30. Validation of immediate operands
3081 is deferred to md_apply_fix. */
3084 parse_shifter_operand (char **str, int i)
3089 if ((value = arm_reg_parse (str, REG_TYPE_RN)) != FAIL)
3091 inst.operands[i].reg = value;
3092 inst.operands[i].isreg = 1;
3094 /* parse_shift will override this if appropriate */
3095 inst.reloc.exp.X_op = O_constant;
3096 inst.reloc.exp.X_add_number = 0;
3098 if (skip_past_comma (str) == FAIL)
3101 /* Shift operation on register. */
3102 return parse_shift (str, i, NO_SHIFT_RESTRICT);
3105 if (my_get_expression (&inst.reloc.exp, str, GE_IMM_PREFIX))
3108 if (skip_past_comma (str) == SUCCESS)
3110 /* #x, y -- ie explicit rotation by Y. */
3111 if (my_get_expression (&expr, str, GE_NO_PREFIX))
3114 if (expr.X_op != O_constant || inst.reloc.exp.X_op != O_constant)
3116 inst.error = _("constant expression expected");
3120 value = expr.X_add_number;
3121 if (value < 0 || value > 30 || value % 2 != 0)
3123 inst.error = _("invalid rotation");
3126 if (inst.reloc.exp.X_add_number < 0 || inst.reloc.exp.X_add_number > 255)
3128 inst.error = _("invalid constant");
3132 /* Convert to decoded value. md_apply_fix will put it back. */
3133 inst.reloc.exp.X_add_number
3134 = (((inst.reloc.exp.X_add_number << (32 - value))
3135 | (inst.reloc.exp.X_add_number >> value)) & 0xffffffff);
3138 inst.reloc.type = BFD_RELOC_ARM_IMMEDIATE;
3139 inst.reloc.pc_rel = 0;
3143 /* Parse all forms of an ARM address expression. Information is written
3144 to inst.operands[i] and/or inst.reloc.
3146 Preindexed addressing (.preind=1):
3148 [Rn, #offset] .reg=Rn .reloc.exp=offset
3149 [Rn, +/-Rm] .reg=Rn .imm=Rm .immisreg=1 .negative=0/1
3150 [Rn, +/-Rm, shift] .reg=Rn .imm=Rm .immisreg=1 .negative=0/1
3151 .shift_kind=shift .reloc.exp=shift_imm
3153 These three may have a trailing ! which causes .writeback to be set also.
3155 Postindexed addressing (.postind=1, .writeback=1):
3157 [Rn], #offset .reg=Rn .reloc.exp=offset
3158 [Rn], +/-Rm .reg=Rn .imm=Rm .immisreg=1 .negative=0/1
3159 [Rn], +/-Rm, shift .reg=Rn .imm=Rm .immisreg=1 .negative=0/1
3160 .shift_kind=shift .reloc.exp=shift_imm
3162 Unindexed addressing (.preind=0, .postind=0):
3164 [Rn], {option} .reg=Rn .imm=option .immisreg=0
3168 [Rn]{!} shorthand for [Rn,#0]{!}
3169 =immediate .isreg=0 .reloc.exp=immediate
3170 label .reg=PC .reloc.pc_rel=1 .reloc.exp=label
3172 It is the caller's responsibility to check for addressing modes not
3173 supported by the instruction, and to set inst.reloc.type. */
3176 parse_address (char **str, int i)
3181 if (skip_past_char (&p, '[') == FAIL)
3183 if (skip_past_char (&p, '=') == FAIL)
3185 /* bare address - translate to PC-relative offset */
3186 inst.reloc.pc_rel = 1;
3187 inst.operands[i].reg = REG_PC;
3188 inst.operands[i].isreg = 1;
3189 inst.operands[i].preind = 1;
3191 /* else a load-constant pseudo op, no special treatment needed here */
3193 if (my_get_expression (&inst.reloc.exp, &p, GE_NO_PREFIX))
3200 if ((reg = arm_reg_parse (&p, REG_TYPE_RN)) == FAIL)
3202 inst.error = _(reg_expected_msgs[REG_TYPE_RN]);
3205 inst.operands[i].reg = reg;
3206 inst.operands[i].isreg = 1;
3208 if (skip_past_comma (&p) == SUCCESS)
3210 inst.operands[i].preind = 1;
3213 else if (*p == '-') p++, inst.operands[i].negative = 1;
3215 if ((reg = arm_reg_parse (&p, REG_TYPE_RN)) != FAIL)
3217 inst.operands[i].imm = reg;
3218 inst.operands[i].immisreg = 1;
3220 if (skip_past_comma (&p) == SUCCESS)
3221 if (parse_shift (&p, i, SHIFT_IMMEDIATE) == FAIL)
3226 if (inst.operands[i].negative)
3228 inst.operands[i].negative = 0;
3231 if (my_get_expression (&inst.reloc.exp, &p, GE_IMM_PREFIX))
3236 if (skip_past_char (&p, ']') == FAIL)
3238 inst.error = _("']' expected");
3242 if (skip_past_char (&p, '!') == SUCCESS)
3243 inst.operands[i].writeback = 1;
3245 else if (skip_past_comma (&p) == SUCCESS)
3247 if (skip_past_char (&p, '{') == SUCCESS)
3249 /* [Rn], {expr} - unindexed, with option */
3250 if (parse_immediate (&p, &inst.operands[i].imm,
3251 0, 255, TRUE) == FAIL)
3254 if (skip_past_char (&p, '}') == FAIL)
3256 inst.error = _("'}' expected at end of 'option' field");
3259 if (inst.operands[i].preind)
3261 inst.error = _("cannot combine index with option");
3269 inst.operands[i].postind = 1;
3270 inst.operands[i].writeback = 1;
3272 if (inst.operands[i].preind)
3274 inst.error = _("cannot combine pre- and post-indexing");
3279 else if (*p == '-') p++, inst.operands[i].negative = 1;
3281 if ((reg = arm_reg_parse (&p, REG_TYPE_RN)) != FAIL)
3283 inst.operands[i].imm = reg;
3284 inst.operands[i].immisreg = 1;
3286 if (skip_past_comma (&p) == SUCCESS)
3287 if (parse_shift (&p, i, SHIFT_IMMEDIATE) == FAIL)
3292 if (inst.operands[i].negative)
3294 inst.operands[i].negative = 0;
3297 if (my_get_expression (&inst.reloc.exp, &p, GE_IMM_PREFIX))
3303 /* If at this point neither .preind nor .postind is set, we have a
3304 bare [Rn]{!}, which is shorthand for [Rn,#0]{!}. */
3305 if (inst.operands[i].preind == 0 && inst.operands[i].postind == 0)
3307 inst.operands[i].preind = 1;
3308 inst.reloc.exp.X_op = O_constant;
3309 inst.reloc.exp.X_add_number = 0;
3315 /* Miscellaneous. */
3317 /* Parse a PSR flag operand. The value returned is FAIL on syntax error,
3318 or a bitmask suitable to be or-ed into the ARM msr instruction. */
3320 parse_psr (char **str)
3323 unsigned long psr_field;
3325 /* CPSR's and SPSR's can now be lowercase. This is just a convenience
3326 feature for ease of use and backwards compatibility. */
3328 if (*p == 's' || *p == 'S')
3329 psr_field = SPSR_BIT;
3330 else if (*p == 'c' || *p == 'C')
3336 if (strncasecmp (p, "PSR", 3) != 0)
3342 /* A suffix follows. */
3343 const struct asm_psr *psr;
3351 while (ISALNUM (*p) || *p == '_');
3353 psr = hash_find_n (arm_psr_hsh, start, p - start);
3357 psr_field |= psr->field;
3362 goto error; /* Garbage after "[CS]PSR". */
3364 psr_field |= (PSR_c | PSR_f);
3370 inst.error = _("flag for {c}psr instruction expected");
3374 /* Parse the flags argument to CPSI[ED]. Returns FAIL on error, or a
3375 value suitable for splatting into the AIF field of the instruction. */
3378 parse_cps_flags (char **str)
3387 case '\0': case ',':
3390 case 'a': case 'A': saw_a_flag = 1; val |= 0x4; break;
3391 case 'i': case 'I': saw_a_flag = 1; val |= 0x2; break;
3392 case 'f': case 'F': saw_a_flag = 1; val |= 0x1; break;
3395 inst.error = _("unrecognized CPS flag");
3400 if (saw_a_flag == 0)
3402 inst.error = _("missing CPS flags");
3410 /* Parse an endian specifier ("BE" or "LE", case insensitive);
3411 returns 0 for big-endian, 1 for little-endian, FAIL for an error. */
3414 parse_endian_specifier (char **str)
3419 if (strncasecmp (s, "BE", 2))
3421 else if (strncasecmp (s, "LE", 2))
3425 inst.error = _("valid endian specifiers are be or le");
3429 if (ISALNUM (s[2]) || s[2] == '_')
3431 inst.error = _("valid endian specifiers are be or le");
3436 return little_endian;
3439 /* Parse a rotation specifier: ROR #0, #8, #16, #24. *val receives a
3440 value suitable for poking into the rotate field of an sxt or sxta
3441 instruction, or FAIL on error. */
3444 parse_ror (char **str)
3449 if (strncasecmp (s, "ROR", 3) == 0)
3453 inst.error = _("missing rotation field after comma");
3457 if (parse_immediate (&s, &rot, 0, 24, FALSE) == FAIL)
3462 case 0: *str = s; return 0x0;
3463 case 8: *str = s; return 0x1;
3464 case 16: *str = s; return 0x2;
3465 case 24: *str = s; return 0x3;
3468 inst.error = _("rotation can only be 0, 8, 16, or 24");
3473 /* Parse a conditional code (from conds[] below). The value returned is in the
3474 range 0 .. 14, or FAIL. */
3476 parse_cond (char **str)
3479 const struct asm_cond *c;
3482 while (ISALPHA (*q))
3485 c = hash_find_n (arm_cond_hsh, p, q - p);
3488 inst.error = _("condition required");
3496 /* Parse the operands of a table branch instruction. Similar to a memory
3499 parse_tb (char **str)
3504 if (skip_past_char (&p, '[') == FAIL)
3507 if ((reg = arm_reg_parse (&p, REG_TYPE_RN)) == FAIL)
3509 inst.error = _(reg_expected_msgs[REG_TYPE_RN]);
3512 inst.operands[0].reg = reg;
3514 if (skip_past_comma (&p) == FAIL)
3517 if ((reg = arm_reg_parse (&p, REG_TYPE_RN)) == FAIL)
3519 inst.error = _(reg_expected_msgs[REG_TYPE_RN]);
3522 inst.operands[0].imm = reg;
3524 if (skip_past_comma (&p) == SUCCESS)
3526 if (parse_shift (&p, 0, SHIFT_LSL_IMMEDIATE) == FAIL)
3528 if (inst.reloc.exp.X_add_number != 1)
3530 inst.error = _("invalid shift");
3533 inst.operands[0].shifted = 1;
3536 if (skip_past_char (&p, ']') == FAIL)
3538 inst.error = _("']' expected");
3545 /* Matcher codes for parse_operands. */
3546 enum operand_parse_code
3548 OP_stop, /* end of line */
3550 OP_RR, /* ARM register */
3551 OP_RRnpc, /* ARM register, not r15 */
3552 OP_RRnpcb, /* ARM register, not r15, in square brackets */
3553 OP_RRw, /* ARM register, not r15, optional trailing ! */
3554 OP_RCP, /* Coprocessor number */
3555 OP_RCN, /* Coprocessor register */
3556 OP_RF, /* FPA register */
3557 OP_RVS, /* VFP single precision register */
3558 OP_RVD, /* VFP double precision register */
3559 OP_RVC, /* VFP control register */
3560 OP_RMF, /* Maverick F register */
3561 OP_RMD, /* Maverick D register */
3562 OP_RMFX, /* Maverick FX register */
3563 OP_RMDX, /* Maverick DX register */
3564 OP_RMAX, /* Maverick AX register */
3565 OP_RMDS, /* Maverick DSPSC register */
3566 OP_RIWR, /* iWMMXt wR register */
3567 OP_RIWC, /* iWMMXt wC register */
3568 OP_RIWG, /* iWMMXt wCG register */
3569 OP_RXA, /* XScale accumulator register */
3571 OP_REGLST, /* ARM register list */
3572 OP_VRSLST, /* VFP single-precision register list */
3573 OP_VRDLST, /* VFP double-precision register list */
3575 OP_I7, /* immediate value 0 .. 7 */
3576 OP_I15, /* 0 .. 15 */
3577 OP_I16, /* 1 .. 16 */
3578 OP_I31, /* 0 .. 31 */
3579 OP_I31w, /* 0 .. 31, optional trailing ! */
3580 OP_I32, /* 1 .. 32 */
3581 OP_I63s, /* -64 .. 63 */
3582 OP_I255, /* 0 .. 255 */
3583 OP_Iffff, /* 0 .. 65535 */
3585 OP_I4b, /* immediate, prefix optional, 1 .. 4 */
3586 OP_I7b, /* 0 .. 7 */
3587 OP_I15b, /* 0 .. 15 */
3588 OP_I31b, /* 0 .. 31 */
3590 OP_SH, /* shifter operand */
3591 OP_ADDR, /* Memory address expression (any mode) */
3592 OP_EXP, /* arbitrary expression */
3593 OP_EXPi, /* same, with optional immediate prefix */
3594 OP_EXPr, /* same, with optional relocation suffix */
3596 OP_CPSF, /* CPS flags */
3597 OP_ENDI, /* Endianness specifier */
3598 OP_PSR, /* CPSR/SPSR mask for msr */
3599 OP_COND, /* conditional code */
3600 OP_TB, /* Table branch. */
3602 OP_RRnpc_I0, /* ARM register or literal 0 */
3603 OP_RR_EXr, /* ARM register or expression with opt. reloc suff. */
3604 OP_RR_EXi, /* ARM register or expression with imm prefix */
3605 OP_RF_IF, /* FPA register or immediate */
3606 OP_RIWR_RIWC, /* iWMMXt R or C reg */
3608 /* Optional operands. */
3609 OP_oI7b, /* immediate, prefix optional, 0 .. 7 */
3610 OP_oI31b, /* 0 .. 31 */
3611 OP_oIffffb, /* 0 .. 65535 */
3612 OP_oI255c, /* curly-brace enclosed, 0 .. 255 */
3614 OP_oRR, /* ARM register */
3615 OP_oRRnpc, /* ARM register, not the PC */
3616 OP_oSHll, /* LSL immediate */
3617 OP_oSHar, /* ASR immediate */
3618 OP_oSHllar, /* LSL or ASR immediate */
3619 OP_oROR, /* ROR 0/8/16/24 */
3621 OP_FIRST_OPTIONAL = OP_oI7b
3624 /* Generic instruction operand parser. This does no encoding and no
3625 semantic validation; it merely squirrels values away in the inst
3626 structure. Returns SUCCESS or FAIL depending on whether the
3627 specified grammar matched. */
3629 parse_operands (char *str, const unsigned char *pattern)
3631 unsigned const char *upat = pattern;
3632 char *backtrack_pos = 0;
3633 const char *backtrack_error = 0;
3634 int i, val, backtrack_index = 0;
3636 #define po_char_or_fail(chr) do { \
3637 if (skip_past_char (&str, chr) == FAIL) \
3641 #define po_reg_or_fail(regtype) do { \
3642 val = arm_reg_parse (&str, regtype); \
3645 inst.error = _(reg_expected_msgs[regtype]); \
3648 inst.operands[i].reg = val; \
3649 inst.operands[i].isreg = 1; \
3652 #define po_reg_or_goto(regtype, label) do { \
3653 val = arm_reg_parse (&str, regtype); \
3657 inst.operands[i].reg = val; \
3658 inst.operands[i].isreg = 1; \
3661 #define po_imm_or_fail(min, max, popt) do { \
3662 if (parse_immediate (&str, &val, min, max, popt) == FAIL) \
3664 inst.operands[i].imm = val; \
3667 #define po_misc_or_fail(expr) do { \
3672 skip_whitespace (str);
3674 for (i = 0; upat[i] != OP_stop; i++)
3676 if (upat[i] >= OP_FIRST_OPTIONAL)
3678 /* Remember where we are in case we need to backtrack. */
3679 assert (!backtrack_pos);
3680 backtrack_pos = str;
3681 backtrack_error = inst.error;
3682 backtrack_index = i;
3686 po_char_or_fail (',');
3694 case OP_RR: po_reg_or_fail (REG_TYPE_RN); break;
3695 case OP_RCP: po_reg_or_fail (REG_TYPE_CP); break;
3696 case OP_RCN: po_reg_or_fail (REG_TYPE_CN); break;
3697 case OP_RF: po_reg_or_fail (REG_TYPE_FN); break;
3698 case OP_RVS: po_reg_or_fail (REG_TYPE_VFS); break;
3699 case OP_RVD: po_reg_or_fail (REG_TYPE_VFD); break;
3700 case OP_RVC: po_reg_or_fail (REG_TYPE_VFC); break;
3701 case OP_RMF: po_reg_or_fail (REG_TYPE_MVF); break;
3702 case OP_RMD: po_reg_or_fail (REG_TYPE_MVD); break;
3703 case OP_RMFX: po_reg_or_fail (REG_TYPE_MVFX); break;
3704 case OP_RMDX: po_reg_or_fail (REG_TYPE_MVDX); break;
3705 case OP_RMAX: po_reg_or_fail (REG_TYPE_MVAX); break;
3706 case OP_RMDS: po_reg_or_fail (REG_TYPE_DSPSC); break;
3707 case OP_RIWR: po_reg_or_fail (REG_TYPE_MMXWR); break;
3708 case OP_RIWC: po_reg_or_fail (REG_TYPE_MMXWC); break;
3709 case OP_RIWG: po_reg_or_fail (REG_TYPE_MMXWCG); break;
3710 case OP_RXA: po_reg_or_fail (REG_TYPE_XSCALE); break;
3713 po_char_or_fail ('[');
3714 po_reg_or_fail (REG_TYPE_RN);
3715 po_char_or_fail (']');
3719 po_reg_or_fail (REG_TYPE_RN);
3720 if (skip_past_char (&str, '!') == SUCCESS)
3721 inst.operands[i].writeback = 1;
3725 case OP_I7: po_imm_or_fail ( 0, 7, FALSE); break;
3726 case OP_I15: po_imm_or_fail ( 0, 15, FALSE); break;
3727 case OP_I16: po_imm_or_fail ( 1, 16, FALSE); break;
3728 case OP_I31: po_imm_or_fail ( 0, 31, FALSE); break;
3729 case OP_I32: po_imm_or_fail ( 1, 32, FALSE); break;
3730 case OP_I63s: po_imm_or_fail (-64, 63, FALSE); break;
3731 case OP_I255: po_imm_or_fail ( 0, 255, FALSE); break;
3732 case OP_Iffff: po_imm_or_fail ( 0, 0xffff, FALSE); break;
3734 case OP_I4b: po_imm_or_fail ( 1, 4, TRUE); break;
3736 case OP_I7b: po_imm_or_fail ( 0, 7, TRUE); break;
3737 case OP_I15b: po_imm_or_fail ( 0, 15, TRUE); break;
3739 case OP_I31b: po_imm_or_fail ( 0, 31, TRUE); break;
3740 case OP_oIffffb: po_imm_or_fail ( 0, 0xffff, TRUE); break;
3742 /* Immediate variants */
3744 po_char_or_fail ('{');
3745 po_imm_or_fail (0, 255, TRUE);
3746 po_char_or_fail ('}');
3750 /* The expression parser chokes on a trailing !, so we have
3751 to find it first and zap it. */
3754 while (*s && *s != ',')
3759 inst.operands[i].writeback = 1;
3761 po_imm_or_fail (0, 31, TRUE);
3769 po_misc_or_fail (my_get_expression (&inst.reloc.exp, &str,
3774 po_misc_or_fail (my_get_expression (&inst.reloc.exp, &str,
3779 po_misc_or_fail (my_get_expression (&inst.reloc.exp, &str,
3781 if (inst.reloc.exp.X_op == O_symbol)
3783 val = parse_reloc (&str);
3786 inst.error = _("unrecognized relocation suffix");
3789 else if (val != BFD_RELOC_UNUSED)
3791 inst.operands[i].imm = val;
3792 inst.operands[i].hasreloc = 1;
3797 /* Register or expression */
3798 case OP_RR_EXr: po_reg_or_goto (REG_TYPE_RN, EXPr); break;
3799 case OP_RR_EXi: po_reg_or_goto (REG_TYPE_RN, EXPi); break;
3801 /* Register or immediate */
3802 case OP_RRnpc_I0: po_reg_or_goto (REG_TYPE_RN, I0); break;
3803 I0: po_imm_or_fail (0, 0, FALSE); break;
3805 case OP_RF_IF: po_reg_or_goto (REG_TYPE_FN, IF); break;
3807 if (!is_immediate_prefix (*str))
3810 val = parse_fpa_immediate (&str);
3813 /* FPA immediates are encoded as registers 8-15.
3814 parse_fpa_immediate has already applied the offset. */
3815 inst.operands[i].reg = val;
3816 inst.operands[i].isreg = 1;
3819 /* Two kinds of register */
3822 struct reg_entry *rege = arm_reg_parse_multi (&str);
3823 if (rege->type != REG_TYPE_MMXWR
3824 && rege->type != REG_TYPE_MMXWC
3825 && rege->type != REG_TYPE_MMXWCG)
3827 inst.error = _("iWMMXt data or control register expected");
3830 inst.operands[i].reg = rege->number;
3831 inst.operands[i].isreg = (rege->type == REG_TYPE_MMXWR);
3836 case OP_CPSF: val = parse_cps_flags (&str); break;
3837 case OP_ENDI: val = parse_endian_specifier (&str); break;
3838 case OP_oROR: val = parse_ror (&str); break;
3839 case OP_PSR: val = parse_psr (&str); break;
3840 case OP_COND: val = parse_cond (&str); break;
3843 po_misc_or_fail (parse_tb (&str));
3846 /* Register lists */
3848 val = parse_reg_list (&str);
3851 inst.operands[1].writeback = 1;
3857 val = parse_vfp_reg_list (&str, &inst.operands[i].reg, 0);
3861 val = parse_vfp_reg_list (&str, &inst.operands[i].reg, 1);
3864 /* Addressing modes */
3866 po_misc_or_fail (parse_address (&str, i));
3870 po_misc_or_fail (parse_shifter_operand (&str, i));
3874 po_misc_or_fail (parse_shift (&str, i, SHIFT_LSL_IMMEDIATE));
3878 po_misc_or_fail (parse_shift (&str, i, SHIFT_ASR_IMMEDIATE));
3882 po_misc_or_fail (parse_shift (&str, i, SHIFT_LSL_OR_ASR_IMMEDIATE));
3886 as_fatal ("unhandled operand code %d", upat[i]);
3889 /* Various value-based sanity checks and shared operations. We
3890 do not signal immediate failures for the register constraints;
3891 this allows a syntax error to take precedence. */
3899 if (inst.operands[i].isreg && inst.operands[i].reg == REG_PC)
3900 inst.error = BAD_PC;
3913 inst.operands[i].imm = val;
3920 /* If we get here, this operand was successfully parsed. */
3921 inst.operands[i].present = 1;
3925 inst.error = BAD_ARGS;
3931 /* Do not backtrack over a trailing optional argument that
3932 absorbed some text. We will only fail again, with the
3933 'garbage following instruction' error message, which is
3934 probably less helpful than the current one. */
3935 if (backtrack_index == i && backtrack_pos != str
3936 && upat[i+1] == OP_stop)
3939 /* Try again, skipping the optional argument at backtrack_pos. */
3940 str = backtrack_pos;
3941 inst.error = backtrack_error;
3942 inst.operands[backtrack_index].present = 0;
3943 i = backtrack_index;
3947 /* Check that we have parsed all the arguments. */
3948 if (*str != '\0' && !inst.error)
3949 inst.error = _("garbage following instruction");
3951 return inst.error ? FAIL : SUCCESS;
3954 #undef po_char_or_fail
3955 #undef po_reg_or_fail
3956 #undef po_reg_or_goto
3957 #undef po_imm_or_fail
3959 /* Shorthand macro for instruction encoding functions issuing errors. */
3960 #define constraint(expr, err) do { \
3968 /* Functions for operand encoding. ARM, then Thumb. */
3970 #define rotate_left(v, n) (v << n | v >> (32 - n))
3972 /* If VAL can be encoded in the immediate field of an ARM instruction,
3973 return the encoded form. Otherwise, return FAIL. */
3976 encode_arm_immediate (unsigned int val)
3980 for (i = 0; i < 32; i += 2)
3981 if ((a = rotate_left (val, i)) <= 0xff)
3982 return a | (i << 7); /* 12-bit pack: [shift-cnt,const]. */
3987 /* If VAL can be encoded in the immediate field of a Thumb32 instruction,
3988 return the encoded form. Otherwise, return FAIL. */
3990 encode_thumb32_immediate (unsigned int val)
3997 for (i = 1; i <= 24; i++)
4000 if ((val & ~(0xff << i)) == 0)
4001 return ((val >> i) & 0x7f) | ((32 - i) << 7);
4005 if (val == ((a << 16) | a))
4007 if (val == ((a << 24) | (a << 16) | (a << 8) | a))
4011 if (val == ((a << 16) | a))
4012 return 0x200 | (a >> 8);
4016 /* Encode a VFP SP register number into inst.instruction. */
4019 encode_arm_vfp_sp_reg (int reg, enum vfp_sp_reg_pos pos)
4024 inst.instruction |= ((reg >> 1) << 12) | ((reg & 1) << 22);
4028 inst.instruction |= ((reg >> 1) << 16) | ((reg & 1) << 7);
4032 inst.instruction |= ((reg >> 1) << 0) | ((reg & 1) << 5);
4040 /* Encode a <shift> in an ARM-format instruction. The immediate,
4041 if any, is handled by md_apply_fix. */
4043 encode_arm_shift (int i)
4045 if (inst.operands[i].shift_kind == SHIFT_RRX)
4046 inst.instruction |= SHIFT_ROR << 5;
4049 inst.instruction |= inst.operands[i].shift_kind << 5;
4050 if (inst.operands[i].immisreg)
4052 inst.instruction |= SHIFT_BY_REG;
4053 inst.instruction |= inst.operands[i].imm << 8;
4056 inst.reloc.type = BFD_RELOC_ARM_SHIFT_IMM;
4061 encode_arm_shifter_operand (int i)
4063 if (inst.operands[i].isreg)
4065 inst.instruction |= inst.operands[i].reg;
4066 encode_arm_shift (i);
4069 inst.instruction |= INST_IMMEDIATE;
4072 /* Subroutine of encode_arm_addr_mode_2 and encode_arm_addr_mode_3. */
4074 encode_arm_addr_mode_common (int i, bfd_boolean is_t)
4076 assert (inst.operands[i].isreg);
4077 inst.instruction |= inst.operands[i].reg << 16;
4079 if (inst.operands[i].preind)
4083 inst.error = _("instruction does not accept preindexed addressing");
4086 inst.instruction |= PRE_INDEX;
4087 if (inst.operands[i].writeback)
4088 inst.instruction |= WRITE_BACK;
4091 else if (inst.operands[i].postind)
4093 assert (inst.operands[i].writeback);
4095 inst.instruction |= WRITE_BACK;
4097 else /* unindexed - only for coprocessor */
4099 inst.error = _("instruction does not accept unindexed addressing");
4103 if (((inst.instruction & WRITE_BACK) || !(inst.instruction & PRE_INDEX))
4104 && (((inst.instruction & 0x000f0000) >> 16)
4105 == ((inst.instruction & 0x0000f000) >> 12)))
4106 as_warn ((inst.instruction & LOAD_BIT)
4107 ? _("destination register same as write-back base")
4108 : _("source register same as write-back base"));
4111 /* inst.operands[i] was set up by parse_address. Encode it into an
4112 ARM-format mode 2 load or store instruction. If is_t is true,
4113 reject forms that cannot be used with a T instruction (i.e. not
4116 encode_arm_addr_mode_2 (int i, bfd_boolean is_t)
4118 encode_arm_addr_mode_common (i, is_t);
4120 if (inst.operands[i].immisreg)
4122 inst.instruction |= INST_IMMEDIATE; /* yes, this is backwards */
4123 inst.instruction |= inst.operands[i].imm;
4124 if (!inst.operands[i].negative)
4125 inst.instruction |= INDEX_UP;
4126 if (inst.operands[i].shifted)
4128 if (inst.operands[i].shift_kind == SHIFT_RRX)
4129 inst.instruction |= SHIFT_ROR << 5;
4132 inst.instruction |= inst.operands[i].shift_kind << 5;
4133 inst.reloc.type = BFD_RELOC_ARM_SHIFT_IMM;
4137 else /* immediate offset in inst.reloc */
4139 if (inst.reloc.type == BFD_RELOC_UNUSED)
4140 inst.reloc.type = BFD_RELOC_ARM_OFFSET_IMM;
4144 /* inst.operands[i] was set up by parse_address. Encode it into an
4145 ARM-format mode 3 load or store instruction. Reject forms that
4146 cannot be used with such instructions. If is_t is true, reject
4147 forms that cannot be used with a T instruction (i.e. not
4150 encode_arm_addr_mode_3 (int i, bfd_boolean is_t)
4152 if (inst.operands[i].immisreg && inst.operands[i].shifted)
4154 inst.error = _("instruction does not accept scaled register index");
4158 encode_arm_addr_mode_common (i, is_t);
4160 if (inst.operands[i].immisreg)
4162 inst.instruction |= inst.operands[i].imm;
4163 if (!inst.operands[i].negative)
4164 inst.instruction |= INDEX_UP;
4166 else /* immediate offset in inst.reloc */
4168 inst.instruction |= HWOFFSET_IMM;
4169 if (inst.reloc.type == BFD_RELOC_UNUSED)
4170 inst.reloc.type = BFD_RELOC_ARM_OFFSET_IMM8;
4174 /* inst.operands[i] was set up by parse_address. Encode it into an
4175 ARM-format instruction. Reject all forms which cannot be encoded
4176 into a coprocessor load/store instruction. If wb_ok is false,
4177 reject use of writeback; if unind_ok is false, reject use of
4178 unindexed addressing. If reloc_override is not 0, use it instead
4179 of BFD_ARM_CP_OFF_IMM. */
4182 encode_arm_cp_address (int i, int wb_ok, int unind_ok, int reloc_override)
4184 inst.instruction |= inst.operands[i].reg << 16;
4186 assert (!(inst.operands[i].preind && inst.operands[i].postind));
4188 if (!inst.operands[i].preind && !inst.operands[i].postind) /* unindexed */
4190 assert (!inst.operands[i].writeback);
4193 inst.error = _("instruction does not support unindexed addressing");
4196 inst.instruction |= inst.operands[i].imm;
4197 inst.instruction |= INDEX_UP;
4201 if (inst.operands[i].preind)
4202 inst.instruction |= PRE_INDEX;
4204 if (inst.operands[i].writeback)
4206 if (inst.operands[i].reg == REG_PC)
4208 inst.error = _("pc may not be used with write-back");
4213 inst.error = _("instruction does not support writeback");
4216 inst.instruction |= WRITE_BACK;
4220 inst.reloc.type = reloc_override;
4222 inst.reloc.type = BFD_RELOC_ARM_CP_OFF_IMM;
4226 /* inst.reloc.exp describes an "=expr" load pseudo-operation.
4227 Determine whether it can be performed with a move instruction; if
4228 it can, convert inst.instruction to that move instruction and
4229 return 1; if it can't, convert inst.instruction to a literal-pool
4230 load and return 0. If this is not a valid thing to do in the
4231 current context, set inst.error and return 1.
4233 inst.operands[i] describes the destination register. */
4236 move_or_literal_pool (int i, bfd_boolean thumb_p, bfd_boolean mode_3)
4238 if ((inst.instruction & (thumb_p ? THUMB_LOAD_BIT : LOAD_BIT)) == 0)
4240 inst.error = _("invalid pseudo operation");
4243 if (inst.reloc.exp.X_op != O_constant && inst.reloc.exp.X_op != O_symbol)
4245 inst.error = _("constant expression expected");
4248 if (inst.reloc.exp.X_op == O_constant)
4252 if ((inst.reloc.exp.X_add_number & ~0xFF) == 0)
4254 /* This can be done with a mov(1) instruction. */
4255 inst.instruction = T_OPCODE_MOV_I8 | (inst.operands[i].reg << 8);
4256 inst.instruction |= inst.reloc.exp.X_add_number;
4262 int value = encode_arm_immediate (inst.reloc.exp.X_add_number);
4265 /* This can be done with a mov instruction. */
4266 inst.instruction &= LITERAL_MASK;
4267 inst.instruction |= INST_IMMEDIATE | (OPCODE_MOV << DATA_OP_SHIFT);
4268 inst.instruction |= value & 0xfff;
4272 value = encode_arm_immediate (~inst.reloc.exp.X_add_number);
4275 /* This can be done with a mvn instruction. */
4276 inst.instruction &= LITERAL_MASK;
4277 inst.instruction |= INST_IMMEDIATE | (OPCODE_MVN << DATA_OP_SHIFT);
4278 inst.instruction |= value & 0xfff;
4284 if (add_to_lit_pool () == FAIL)
4286 inst.error = _("literal pool insertion failed");
4289 inst.operands[1].reg = REG_PC;
4290 inst.operands[1].isreg = 1;
4291 inst.operands[1].preind = 1;
4292 inst.reloc.pc_rel = 1;
4293 inst.reloc.type = (thumb_p
4294 ? BFD_RELOC_ARM_THUMB_OFFSET
4296 ? BFD_RELOC_ARM_HWLITERAL
4297 : BFD_RELOC_ARM_LITERAL));
4301 /* Functions for instruction encoding, sorted by subarchitecture.
4302 First some generics; their names are taken from the conventional
4303 bit positions for register arguments in ARM format instructions. */
4313 inst.instruction |= inst.operands[0].reg << 12;
4319 inst.instruction |= inst.operands[0].reg << 12;
4320 inst.instruction |= inst.operands[1].reg;
4326 inst.instruction |= inst.operands[0].reg << 12;
4327 inst.instruction |= inst.operands[1].reg << 16;
4333 inst.instruction |= inst.operands[0].reg << 16;
4334 inst.instruction |= inst.operands[1].reg << 12;
4340 inst.instruction |= inst.operands[0].reg << 12;
4341 inst.instruction |= inst.operands[1].reg;
4342 inst.instruction |= inst.operands[2].reg << 16;
4348 inst.instruction |= inst.operands[0].reg << 12;
4349 inst.instruction |= inst.operands[1].reg << 16;
4350 inst.instruction |= inst.operands[2].reg;
4356 inst.instruction |= inst.operands[0].reg;
4357 inst.instruction |= inst.operands[1].reg << 12;
4358 inst.instruction |= inst.operands[2].reg << 16;
4364 inst.instruction |= inst.operands[0].imm;
4370 inst.instruction |= inst.operands[0].reg << 12;
4371 encode_arm_cp_address (1, TRUE, TRUE, 0);
4374 /* ARM instructions, in alphabetical order by function name (except
4375 that wrapper functions appear immediately after the function they
4378 /* This is a pseudo-op of the form "adr rd, label" to be converted
4379 into a relative address of the form "add rd, pc, #label-.-8". */
4384 inst.instruction |= (inst.operands[0].reg << 12); /* Rd */
4386 /* Frag hacking will turn this into a sub instruction if the offset turns
4387 out to be negative. */
4388 inst.reloc.type = BFD_RELOC_ARM_IMMEDIATE;
4389 inst.reloc.pc_rel = 1;
4390 inst.reloc.exp.X_add_number -= 8;
4393 /* This is a pseudo-op of the form "adrl rd, label" to be converted
4394 into a relative address of the form:
4395 add rd, pc, #low(label-.-8)"
4396 add rd, rd, #high(label-.-8)" */
4401 inst.instruction |= (inst.operands[0].reg << 12); /* Rd */
4403 /* Frag hacking will turn this into a sub instruction if the offset turns
4404 out to be negative. */
4405 inst.reloc.type = BFD_RELOC_ARM_ADRL_IMMEDIATE;
4406 inst.reloc.pc_rel = 1;
4407 inst.size = INSN_SIZE * 2;
4408 inst.reloc.exp.X_add_number -= 8;
4414 if (!inst.operands[1].present)
4415 inst.operands[1].reg = inst.operands[0].reg;
4416 inst.instruction |= inst.operands[0].reg << 12;
4417 inst.instruction |= inst.operands[1].reg << 16;
4418 encode_arm_shifter_operand (2);
4424 unsigned int msb = inst.operands[1].imm + inst.operands[2].imm;
4425 constraint (msb > 32, _("bit-field extends past end of register"));
4426 /* The instruction encoding stores the LSB and MSB,
4427 not the LSB and width. */
4428 inst.instruction |= inst.operands[0].reg << 12;
4429 inst.instruction |= inst.operands[1].imm << 7;
4430 inst.instruction |= (msb - 1) << 16;
4438 /* #0 in second position is alternative syntax for bfc, which is
4439 the same instruction but with REG_PC in the Rm field. */
4440 if (!inst.operands[1].isreg)
4441 inst.operands[1].reg = REG_PC;
4443 msb = inst.operands[2].imm + inst.operands[3].imm;
4444 constraint (msb > 32, _("bit-field extends past end of register"));
4445 /* The instruction encoding stores the LSB and MSB,
4446 not the LSB and width. */
4447 inst.instruction |= inst.operands[0].reg << 12;
4448 inst.instruction |= inst.operands[1].reg;
4449 inst.instruction |= inst.operands[2].imm << 7;
4450 inst.instruction |= (msb - 1) << 16;
4456 constraint (inst.operands[2].imm + inst.operands[3].imm > 32,
4457 _("bit-field extends past end of register"));
4458 inst.instruction |= inst.operands[0].reg << 12;
4459 inst.instruction |= inst.operands[1].reg;
4460 inst.instruction |= inst.operands[2].imm << 7;
4461 inst.instruction |= (inst.operands[3].imm - 1) << 16;
4464 /* ARM V5 breakpoint instruction (argument parse)
4465 BKPT <16 bit unsigned immediate>
4466 Instruction is not conditional.
4467 The bit pattern given in insns[] has the COND_ALWAYS condition,
4468 and it is an error if the caller tried to override that. */
4473 /* Top 12 of 16 bits to bits 19:8. */
4474 inst.instruction |= (inst.operands[0].imm & 0xfff0) << 4;
4476 /* Bottom 4 of 16 bits to bits 3:0. */
4477 inst.instruction |= inst.operands[0].imm & 0xf;
4481 encode_branch (int default_reloc)
4483 if (inst.operands[0].hasreloc)
4485 constraint (inst.operands[0].imm != BFD_RELOC_ARM_PLT32,
4486 _("the only suffix valid here is '(plt)'"));
4487 inst.reloc.type = BFD_RELOC_ARM_PLT32;
4491 inst.reloc.type = default_reloc;
4493 inst.reloc.pc_rel = 1;
4499 encode_branch (BFD_RELOC_ARM_PCREL_BRANCH);
4502 /* ARM V5 branch-link-exchange instruction (argument parse)
4503 BLX <target_addr> ie BLX(1)
4504 BLX{<condition>} <Rm> ie BLX(2)
4505 Unfortunately, there are two different opcodes for this mnemonic.
4506 So, the insns[].value is not used, and the code here zaps values
4507 into inst.instruction.
4508 Also, the <target_addr> can be 25 bits, hence has its own reloc. */
4513 if (inst.operands[0].isreg)
4515 /* Arg is a register; the opcode provided by insns[] is correct.
4516 It is not illegal to do "blx pc", just useless. */
4517 if (inst.operands[0].reg == REG_PC)
4518 as_tsktsk (_("use of r15 in blx in ARM mode is not really useful"));
4520 inst.instruction |= inst.operands[0].reg;
4524 /* Arg is an address; this instruction cannot be executed
4525 conditionally, and the opcode must be adjusted. */
4526 constraint (inst.cond != COND_ALWAYS, BAD_COND);
4527 inst.instruction = 0xfa000000;
4528 encode_branch (BFD_RELOC_ARM_PCREL_BLX);
4535 if (inst.operands[0].reg == REG_PC)
4536 as_tsktsk (_("use of r15 in bx in ARM mode is not really useful"));
4538 inst.instruction |= inst.operands[0].reg;
4542 /* ARM v5TEJ. Jump to Jazelle code. */
4547 if (inst.operands[0].reg == REG_PC)
4548 as_tsktsk (_("use of r15 in bxj is not really useful"));
4550 inst.instruction |= inst.operands[0].reg;
4553 /* Co-processor data operation:
4554 CDP{cond} <coproc>, <opcode_1>, <CRd>, <CRn>, <CRm>{, <opcode_2>}
4555 CDP2 <coproc>, <opcode_1>, <CRd>, <CRn>, <CRm>{, <opcode_2>} */
4559 inst.instruction |= inst.operands[0].reg << 8;
4560 inst.instruction |= inst.operands[1].imm << 20;
4561 inst.instruction |= inst.operands[2].reg << 12;
4562 inst.instruction |= inst.operands[3].reg << 16;
4563 inst.instruction |= inst.operands[4].reg;
4564 inst.instruction |= inst.operands[5].imm << 5;
4570 inst.instruction |= inst.operands[0].reg << 16;
4571 encode_arm_shifter_operand (1);
4574 /* Transfer between coprocessor and ARM registers.
4575 MRC{cond} <coproc>, <opcode_1>, <Rd>, <CRn>, <CRm>{, <opcode_2>}
4580 No special properties. */
4585 inst.instruction |= inst.operands[0].reg << 8;
4586 inst.instruction |= inst.operands[1].imm << 21;
4587 inst.instruction |= inst.operands[2].reg << 12;
4588 inst.instruction |= inst.operands[3].reg << 16;
4589 inst.instruction |= inst.operands[4].reg;
4590 inst.instruction |= inst.operands[5].imm << 5;
4593 /* Transfer between coprocessor register and pair of ARM registers.
4594 MCRR{cond} <coproc>, <opcode>, <Rd>, <Rn>, <CRm>.
4599 Two XScale instructions are special cases of these:
4601 MAR{cond} acc0, <RdLo>, <RdHi> == MCRR{cond} p0, #0, <RdLo>, <RdHi>, c0
4602 MRA{cond} acc0, <RdLo>, <RdHi> == MRRC{cond} p0, #0, <RdLo>, <RdHi>, c0
4604 Result unpredicatable if Rd or Rn is R15. */
4609 inst.instruction |= inst.operands[0].reg << 8;
4610 inst.instruction |= inst.operands[1].imm << 4;
4611 inst.instruction |= inst.operands[2].reg << 12;
4612 inst.instruction |= inst.operands[3].reg << 16;
4613 inst.instruction |= inst.operands[4].reg;
4619 inst.instruction |= inst.operands[0].imm << 6;
4620 inst.instruction |= inst.operands[1].imm;
4626 /* There is no IT instruction in ARM mode. We
4627 process it but do not generate code for it. */
4634 int base_reg = inst.operands[0].reg;
4635 int range = inst.operands[1].imm;
4637 inst.instruction |= base_reg << 16;
4638 inst.instruction |= range;
4640 if (inst.operands[1].writeback)
4641 inst.instruction |= LDM_TYPE_2_OR_3;
4643 if (inst.operands[0].writeback)
4645 inst.instruction |= WRITE_BACK;
4646 /* Check for unpredictable uses of writeback. */
4647 if (inst.instruction & LOAD_BIT)
4649 /* Not allowed in LDM type 2. */
4650 if ((inst.instruction & LDM_TYPE_2_OR_3)
4651 && ((range & (1 << REG_PC)) == 0))
4652 as_warn (_("writeback of base register is UNPREDICTABLE"));
4653 /* Only allowed if base reg not in list for other types. */
4654 else if (range & (1 << base_reg))
4655 as_warn (_("writeback of base register when in register list is UNPREDICTABLE"));
4659 /* Not allowed for type 2. */
4660 if (inst.instruction & LDM_TYPE_2_OR_3)
4661 as_warn (_("writeback of base register is UNPREDICTABLE"));
4662 /* Only allowed if base reg not in list, or first in list. */
4663 else if ((range & (1 << base_reg))
4664 && (range & ((1 << base_reg) - 1)))
4665 as_warn (_("if writeback register is in list, it must be the lowest reg in the list"));
4670 /* ARMv5TE load-consecutive (argument parse)
4679 constraint (inst.operands[0].reg % 2 != 0,
4680 _("first destination register must be even"));
4681 constraint (inst.operands[1].present
4682 && inst.operands[1].reg != inst.operands[0].reg + 1,
4683 _("can only load two consecutive registers"));
4684 constraint (inst.operands[0].reg == REG_LR, _("r14 not allowed here"));
4685 constraint (!inst.operands[2].isreg, _("'[' expected"));
4687 if (!inst.operands[1].present)
4688 inst.operands[1].reg = inst.operands[0].reg + 1;
4690 if (inst.instruction & LOAD_BIT)
4692 /* encode_arm_addr_mode_3 will diagnose overlap between the base
4693 register and the first register written; we have to diagnose
4694 overlap between the base and the second register written here. */
4696 if (inst.operands[2].reg == inst.operands[1].reg
4697 && (inst.operands[2].writeback || inst.operands[2].postind))
4698 as_warn (_("base register written back, and overlaps "
4699 "second destination register"));
4701 /* For an index-register load, the index register must not overlap the
4702 destination (even if not write-back). */
4703 else if (inst.operands[2].immisreg
4704 && ((unsigned) inst.operands[2].imm == inst.operands[0].reg
4705 || (unsigned) inst.operands[2].imm == inst.operands[1].reg))
4706 as_warn (_("index register overlaps destination register"));
4709 inst.instruction |= inst.operands[0].reg << 12;
4710 encode_arm_addr_mode_3 (2, /*is_t=*/FALSE);
4716 constraint (!inst.operands[1].isreg || !inst.operands[1].preind
4717 || inst.operands[1].postind || inst.operands[1].writeback
4718 || inst.operands[1].immisreg || inst.operands[1].shifted
4719 || inst.operands[1].negative,
4720 _("instruction does not accept this addressing mode"));
4722 constraint (inst.operands[1].reg == REG_PC, BAD_PC);
4724 constraint (inst.reloc.exp.X_op != O_constant
4725 || inst.reloc.exp.X_add_number != 0,
4726 _("offset must be zero in ARM encoding"));
4728 inst.instruction |= inst.operands[0].reg << 12;
4729 inst.instruction |= inst.operands[1].reg << 16;
4730 inst.reloc.type = BFD_RELOC_UNUSED;
4736 constraint (inst.operands[0].reg % 2 != 0,
4737 _("even register required"));
4738 constraint (inst.operands[1].present
4739 && inst.operands[1].reg != inst.operands[0].reg + 1,
4740 _("can only load two consecutive registers"));
4741 /* If op 1 were present and equal to PC, this function wouldn't
4742 have been called in the first place. */
4743 constraint (inst.operands[0].reg == REG_LR, _("r14 not allowed here"));
4745 inst.instruction |= inst.operands[0].reg << 12;
4746 inst.instruction |= inst.operands[2].reg << 16;
4752 inst.instruction |= inst.operands[0].reg << 12;
4753 if (!inst.operands[1].isreg)
4754 if (move_or_literal_pool (0, /*thumb_p=*/FALSE, /*mode_3=*/FALSE))
4756 encode_arm_addr_mode_2 (1, /*is_t=*/FALSE);
4762 /* ldrt/strt always use post-indexed addressing. Turn [Rn] into [Rn]! and
4764 if (inst.operands[1].preind)
4766 constraint (inst.reloc.exp.X_op != O_constant ||
4767 inst.reloc.exp.X_add_number != 0,
4768 _("this instruction requires a post-indexed address"));
4770 inst.operands[1].preind = 0;
4771 inst.operands[1].postind = 1;
4772 inst.operands[1].writeback = 1;
4774 inst.instruction |= inst.operands[0].reg << 12;
4775 encode_arm_addr_mode_2 (1, /*is_t=*/TRUE);
4778 /* Halfword and signed-byte load/store operations. */
4783 inst.instruction |= inst.operands[0].reg << 12;
4784 if (!inst.operands[1].isreg)
4785 if (move_or_literal_pool (0, /*thumb_p=*/FALSE, /*mode_3=*/TRUE))
4787 encode_arm_addr_mode_3 (1, /*is_t=*/FALSE);
4793 /* ldrt/strt always use post-indexed addressing. Turn [Rn] into [Rn]! and
4795 if (inst.operands[1].preind)
4797 constraint (inst.reloc.exp.X_op != O_constant ||
4798 inst.reloc.exp.X_add_number != 0,
4799 _("this instruction requires a post-indexed address"));
4801 inst.operands[1].preind = 0;
4802 inst.operands[1].postind = 1;
4803 inst.operands[1].writeback = 1;
4805 inst.instruction |= inst.operands[0].reg << 12;
4806 encode_arm_addr_mode_3 (1, /*is_t=*/TRUE);
4809 /* Co-processor register load/store.
4810 Format: <LDC|STC>{cond}[L] CP#,CRd,<address> */
4814 inst.instruction |= inst.operands[0].reg << 8;
4815 inst.instruction |= inst.operands[1].reg << 12;
4816 encode_arm_cp_address (2, TRUE, TRUE, 0);
4822 /* This restriction does not apply to mls (nor to mla in v6, but
4823 that's hard to detect at present). */
4824 if (inst.operands[0].reg == inst.operands[1].reg
4825 && !(inst.instruction & 0x00400000))
4826 as_tsktsk (_("rd and rm should be different in mla"));
4828 inst.instruction |= inst.operands[0].reg << 16;
4829 inst.instruction |= inst.operands[1].reg;
4830 inst.instruction |= inst.operands[2].reg << 8;
4831 inst.instruction |= inst.operands[3].reg << 12;
4838 inst.instruction |= inst.operands[0].reg << 12;
4839 encode_arm_shifter_operand (1);
4842 /* ARM V6T2 16-bit immediate register load: MOV[WT]{cond} Rd, #<imm16>. */
4846 inst.instruction |= inst.operands[0].reg << 12;
4847 /* The value is in two pieces: 0:11, 16:19. */
4848 inst.instruction |= (inst.operands[1].imm & 0x00000fff);
4849 inst.instruction |= (inst.operands[1].imm & 0x0000f000) << 4;
4855 /* mrs only accepts CPSR/SPSR/CPSR_all/SPSR_all. */
4856 constraint ((inst.operands[1].imm & (PSR_c|PSR_x|PSR_s|PSR_f))
4858 _("'CPSR' or 'SPSR' expected"));
4859 inst.instruction |= inst.operands[0].reg << 12;
4860 inst.instruction |= (inst.operands[1].imm & SPSR_BIT);
4863 /* Two possible forms:
4864 "{C|S}PSR_<field>, Rm",
4865 "{C|S}PSR_f, #expression". */
4870 inst.instruction |= inst.operands[0].imm;
4871 if (inst.operands[1].isreg)
4872 inst.instruction |= inst.operands[1].reg;
4875 inst.instruction |= INST_IMMEDIATE;
4876 inst.reloc.type = BFD_RELOC_ARM_IMMEDIATE;
4877 inst.reloc.pc_rel = 0;
4884 if (!inst.operands[2].present)
4885 inst.operands[2].reg = inst.operands[0].reg;
4886 inst.instruction |= inst.operands[0].reg << 16;
4887 inst.instruction |= inst.operands[1].reg;
4888 inst.instruction |= inst.operands[2].reg << 8;
4890 if (inst.operands[0].reg == inst.operands[1].reg)
4891 as_tsktsk (_("rd and rm should be different in mul"));
4894 /* Long Multiply Parser
4895 UMULL RdLo, RdHi, Rm, Rs
4896 SMULL RdLo, RdHi, Rm, Rs
4897 UMLAL RdLo, RdHi, Rm, Rs
4898 SMLAL RdLo, RdHi, Rm, Rs. */
4903 inst.instruction |= inst.operands[0].reg << 12;
4904 inst.instruction |= inst.operands[1].reg << 16;
4905 inst.instruction |= inst.operands[2].reg;
4906 inst.instruction |= inst.operands[3].reg << 8;
4908 /* rdhi, rdlo and rm must all be different. */
4909 if (inst.operands[0].reg == inst.operands[1].reg
4910 || inst.operands[0].reg == inst.operands[2].reg
4911 || inst.operands[1].reg == inst.operands[2].reg)
4912 as_tsktsk (_("rdhi, rdlo and rm must all be different"));
4918 if (inst.operands[0].present)
4920 /* Architectural NOP hints are CPSR sets with no bits selected. */
4921 inst.instruction &= 0xf0000000;
4922 inst.instruction |= 0x0320f000 + inst.operands[0].imm;
4926 /* ARM V6 Pack Halfword Bottom Top instruction (argument parse).
4927 PKHBT {<cond>} <Rd>, <Rn>, <Rm> {, LSL #<shift_imm>}
4928 Condition defaults to COND_ALWAYS.
4929 Error if Rd, Rn or Rm are R15. */
4934 inst.instruction |= inst.operands[0].reg << 12;
4935 inst.instruction |= inst.operands[1].reg << 16;
4936 inst.instruction |= inst.operands[2].reg;
4937 if (inst.operands[3].present)
4938 encode_arm_shift (3);
4941 /* ARM V6 PKHTB (Argument Parse). */
4946 if (!inst.operands[3].present)
4948 /* If the shift specifier is omitted, turn the instruction
4949 into pkhbt rd, rm, rn. */
4950 inst.instruction &= 0xfff00010;
4951 inst.instruction |= inst.operands[0].reg << 12;
4952 inst.instruction |= inst.operands[1].reg;
4953 inst.instruction |= inst.operands[2].reg << 16;
4957 inst.instruction |= inst.operands[0].reg << 12;
4958 inst.instruction |= inst.operands[1].reg << 16;
4959 inst.instruction |= inst.operands[2].reg;
4960 encode_arm_shift (3);
4964 /* ARMv5TE: Preload-Cache
4968 Syntactically, like LDR with B=1, W=0, L=1. */
4973 constraint (!inst.operands[0].isreg,
4974 _("'[' expected after PLD mnemonic"));
4975 constraint (inst.operands[0].postind,
4976 _("post-indexed expression used in preload instruction"));
4977 constraint (inst.operands[0].writeback,
4978 _("writeback used in preload instruction"));
4979 constraint (!inst.operands[0].preind,
4980 _("unindexed addressing used in preload instruction"));
4981 inst.instruction |= inst.operands[0].reg;
4982 encode_arm_addr_mode_2 (0, /*is_t=*/FALSE);
4988 inst.operands[1] = inst.operands[0];
4989 memset (&inst.operands[0], 0, sizeof inst.operands[0]);
4990 inst.operands[0].isreg = 1;
4991 inst.operands[0].writeback = 1;
4992 inst.operands[0].reg = REG_SP;
4996 /* ARM V6 RFE (Return from Exception) loads the PC and CPSR from the
4997 word at the specified address and the following word
4999 Unconditionally executed.
5000 Error if Rn is R15. */
5005 inst.instruction |= inst.operands[0].reg << 16;
5006 if (inst.operands[0].writeback)
5007 inst.instruction |= WRITE_BACK;
5010 /* ARM V6 ssat (argument parse). */
5015 inst.instruction |= inst.operands[0].reg << 12;
5016 inst.instruction |= (inst.operands[1].imm - 1) << 16;
5017 inst.instruction |= inst.operands[2].reg;
5019 if (inst.operands[3].present)
5020 encode_arm_shift (3);
5023 /* ARM V6 usat (argument parse). */
5028 inst.instruction |= inst.operands[0].reg << 12;
5029 inst.instruction |= inst.operands[1].imm << 16;
5030 inst.instruction |= inst.operands[2].reg;
5032 if (inst.operands[3].present)
5033 encode_arm_shift (3);
5036 /* ARM V6 ssat16 (argument parse). */
5041 inst.instruction |= inst.operands[0].reg << 12;
5042 inst.instruction |= ((inst.operands[1].imm - 1) << 16);
5043 inst.instruction |= inst.operands[2].reg;
5049 inst.instruction |= inst.operands[0].reg << 12;
5050 inst.instruction |= inst.operands[1].imm << 16;
5051 inst.instruction |= inst.operands[2].reg;
5054 /* ARM V6 SETEND (argument parse). Sets the E bit in the CPSR while
5055 preserving the other bits.
5057 setend <endian_specifier>, where <endian_specifier> is either
5063 if (inst.operands[0].imm)
5064 inst.instruction |= 0x200;
5070 unsigned int Rm = (inst.operands[1].present
5071 ? inst.operands[1].reg
5072 : inst.operands[0].reg);
5074 inst.instruction |= inst.operands[0].reg << 12;
5075 inst.instruction |= Rm;
5076 if (inst.operands[2].isreg) /* Rd, {Rm,} Rs */
5078 constraint (inst.operands[0].reg != Rm,
5079 _("source1 and dest must be same register"));
5080 inst.instruction |= inst.operands[2].reg << 8;
5081 inst.instruction |= SHIFT_BY_REG;
5084 inst.reloc.type = BFD_RELOC_ARM_SHIFT_IMM;
5090 inst.reloc.type = BFD_RELOC_ARM_SMI;
5091 inst.reloc.pc_rel = 0;
5097 inst.reloc.type = BFD_RELOC_ARM_SWI;
5098 inst.reloc.pc_rel = 0;
5101 /* ARM V5E (El Segundo) signed-multiply-accumulate (argument parse)
5102 SMLAxy{cond} Rd,Rm,Rs,Rn
5103 SMLAWy{cond} Rd,Rm,Rs,Rn
5104 Error if any register is R15. */
5109 inst.instruction |= inst.operands[0].reg << 16;
5110 inst.instruction |= inst.operands[1].reg;
5111 inst.instruction |= inst.operands[2].reg << 8;
5112 inst.instruction |= inst.operands[3].reg << 12;
5115 /* ARM V5E (El Segundo) signed-multiply-accumulate-long (argument parse)
5116 SMLALxy{cond} Rdlo,Rdhi,Rm,Rs
5117 Error if any register is R15.
5118 Warning if Rdlo == Rdhi. */
5123 inst.instruction |= inst.operands[0].reg << 12;
5124 inst.instruction |= inst.operands[1].reg << 16;
5125 inst.instruction |= inst.operands[2].reg;
5126 inst.instruction |= inst.operands[3].reg << 8;
5128 if (inst.operands[0].reg == inst.operands[1].reg)
5129 as_tsktsk (_("rdhi and rdlo must be different"));
5132 /* ARM V5E (El Segundo) signed-multiply (argument parse)
5133 SMULxy{cond} Rd,Rm,Rs
5134 Error if any register is R15. */
5139 inst.instruction |= inst.operands[0].reg << 16;
5140 inst.instruction |= inst.operands[1].reg;
5141 inst.instruction |= inst.operands[2].reg << 8;
5144 /* ARM V6 srs (argument parse). */
5149 inst.instruction |= inst.operands[0].imm;
5150 if (inst.operands[0].writeback)
5151 inst.instruction |= WRITE_BACK;
5154 /* ARM V6 strex (argument parse). */
5159 constraint (!inst.operands[2].isreg || !inst.operands[2].preind
5160 || inst.operands[2].postind || inst.operands[2].writeback
5161 || inst.operands[2].immisreg || inst.operands[2].shifted
5162 || inst.operands[2].negative,
5163 _("instruction does not accept this addressing mode"));
5165 constraint (inst.operands[2].reg == REG_PC, BAD_PC);
5167 constraint (inst.operands[0].reg == inst.operands[1].reg
5168 || inst.operands[0].reg == inst.operands[2].reg, BAD_OVERLAP);
5170 constraint (inst.reloc.exp.X_op != O_constant
5171 || inst.reloc.exp.X_add_number != 0,
5172 _("offset must be zero in ARM encoding"));
5174 inst.instruction |= inst.operands[0].reg << 12;
5175 inst.instruction |= inst.operands[1].reg;
5176 inst.instruction |= inst.operands[2].reg << 16;
5177 inst.reloc.type = BFD_RELOC_UNUSED;
5183 constraint (inst.operands[1].reg % 2 != 0,
5184 _("even register required"));
5185 constraint (inst.operands[2].present
5186 && inst.operands[2].reg != inst.operands[1].reg + 1,
5187 _("can only store two consecutive registers"));
5188 /* If op 2 were present and equal to PC, this function wouldn't
5189 have been called in the first place. */
5190 constraint (inst.operands[1].reg == REG_LR, _("r14 not allowed here"));
5192 constraint (inst.operands[0].reg == inst.operands[1].reg
5193 || inst.operands[0].reg == inst.operands[1].reg + 1
5194 || inst.operands[0].reg == inst.operands[3].reg,
5197 inst.instruction |= inst.operands[0].reg << 12;
5198 inst.instruction |= inst.operands[1].reg;
5199 inst.instruction |= inst.operands[3].reg << 16;
5202 /* ARM V6 SXTAH extracts a 16-bit value from a register, sign
5203 extends it to 32-bits, and adds the result to a value in another
5204 register. You can specify a rotation by 0, 8, 16, or 24 bits
5205 before extracting the 16-bit value.
5206 SXTAH{<cond>} <Rd>, <Rn>, <Rm>{, <rotation>}
5207 Condition defaults to COND_ALWAYS.
5208 Error if any register uses R15. */
5213 inst.instruction |= inst.operands[0].reg << 12;
5214 inst.instruction |= inst.operands[1].reg << 16;
5215 inst.instruction |= inst.operands[2].reg;
5216 inst.instruction |= inst.operands[3].imm << 10;
5221 SXTH {<cond>} <Rd>, <Rm>{, <rotation>}
5222 Condition defaults to COND_ALWAYS.
5223 Error if any register uses R15. */
5228 inst.instruction |= inst.operands[0].reg << 12;
5229 inst.instruction |= inst.operands[1].reg;
5230 inst.instruction |= inst.operands[2].imm << 10;
5233 /* VFP instructions. In a logical order: SP variant first, monad
5234 before dyad, arithmetic then move then load/store. */
5237 do_vfp_sp_monadic (void)
5239 encode_arm_vfp_sp_reg (inst.operands[0].reg, VFP_REG_Sd);
5240 encode_arm_vfp_sp_reg (inst.operands[1].reg, VFP_REG_Sm);
5244 do_vfp_sp_dyadic (void)
5246 encode_arm_vfp_sp_reg (inst.operands[0].reg, VFP_REG_Sd);
5247 encode_arm_vfp_sp_reg (inst.operands[1].reg, VFP_REG_Sn);
5248 encode_arm_vfp_sp_reg (inst.operands[2].reg, VFP_REG_Sm);
5252 do_vfp_sp_compare_z (void)
5254 encode_arm_vfp_sp_reg (inst.operands[0].reg, VFP_REG_Sd);
5258 do_vfp_dp_sp_cvt (void)
5260 inst.instruction |= inst.operands[0].reg << 12;
5261 encode_arm_vfp_sp_reg (inst.operands[1].reg, VFP_REG_Sm);
5265 do_vfp_sp_dp_cvt (void)
5267 encode_arm_vfp_sp_reg (inst.operands[0].reg, VFP_REG_Sd);
5268 inst.instruction |= inst.operands[1].reg;
5272 do_vfp_reg_from_sp (void)
5274 inst.instruction |= inst.operands[0].reg << 12;
5275 encode_arm_vfp_sp_reg (inst.operands[1].reg, VFP_REG_Sn);
5279 do_vfp_reg2_from_sp2 (void)
5281 constraint (inst.operands[2].imm != 2,
5282 _("only two consecutive VFP SP registers allowed here"));
5283 inst.instruction |= inst.operands[0].reg << 12;
5284 inst.instruction |= inst.operands[1].reg << 16;
5285 encode_arm_vfp_sp_reg (inst.operands[2].reg, VFP_REG_Sm);
5289 do_vfp_sp_from_reg (void)
5291 encode_arm_vfp_sp_reg (inst.operands[0].reg, VFP_REG_Sn);
5292 inst.instruction |= inst.operands[1].reg << 12;
5296 do_vfp_sp2_from_reg2 (void)
5298 constraint (inst.operands[0].imm != 2,
5299 _("only two consecutive VFP SP registers allowed here"));
5300 encode_arm_vfp_sp_reg (inst.operands[0].reg, VFP_REG_Sm);
5301 inst.instruction |= inst.operands[1].reg << 12;
5302 inst.instruction |= inst.operands[2].reg << 16;
5306 do_vfp_sp_ldst (void)
5308 encode_arm_vfp_sp_reg (inst.operands[0].reg, VFP_REG_Sd);
5309 encode_arm_cp_address (1, FALSE, TRUE, 0);
5313 do_vfp_dp_ldst (void)
5315 inst.instruction |= inst.operands[0].reg << 12;
5316 encode_arm_cp_address (1, FALSE, TRUE, 0);
5321 vfp_sp_ldstm (enum vfp_ldstm_type ldstm_type)
5323 if (inst.operands[0].writeback)
5324 inst.instruction |= WRITE_BACK;
5326 constraint (ldstm_type != VFP_LDSTMIA,
5327 _("this addressing mode requires base-register writeback"));
5328 inst.instruction |= inst.operands[0].reg << 16;
5329 encode_arm_vfp_sp_reg (inst.operands[1].reg, VFP_REG_Sd);
5330 inst.instruction |= inst.operands[1].imm;
5334 vfp_dp_ldstm (enum vfp_ldstm_type ldstm_type)
5338 if (inst.operands[0].writeback)
5339 inst.instruction |= WRITE_BACK;
5341 constraint (ldstm_type != VFP_LDSTMIA && ldstm_type != VFP_LDSTMIAX,
5342 _("this addressing mode requires base-register writeback"));
5344 inst.instruction |= inst.operands[0].reg << 16;
5345 inst.instruction |= inst.operands[1].reg << 12;
5347 count = inst.operands[1].imm << 1;
5348 if (ldstm_type == VFP_LDSTMIAX || ldstm_type == VFP_LDSTMDBX)
5351 inst.instruction |= count;
5355 do_vfp_sp_ldstmia (void)
5357 vfp_sp_ldstm (VFP_LDSTMIA);
5361 do_vfp_sp_ldstmdb (void)
5363 vfp_sp_ldstm (VFP_LDSTMDB);
5367 do_vfp_dp_ldstmia (void)
5369 vfp_dp_ldstm (VFP_LDSTMIA);
5373 do_vfp_dp_ldstmdb (void)
5375 vfp_dp_ldstm (VFP_LDSTMDB);
5379 do_vfp_xp_ldstmia (void)
5381 vfp_dp_ldstm (VFP_LDSTMIAX);
5385 do_vfp_xp_ldstmdb (void)
5387 vfp_dp_ldstm (VFP_LDSTMDBX);
5390 /* FPA instructions. Also in a logical order. */
5395 inst.instruction |= inst.operands[0].reg << 16;
5396 inst.instruction |= inst.operands[1].reg;
5400 do_fpa_ldmstm (void)
5402 inst.instruction |= inst.operands[0].reg << 12;
5403 switch (inst.operands[1].imm)
5405 case 1: inst.instruction |= CP_T_X; break;
5406 case 2: inst.instruction |= CP_T_Y; break;
5407 case 3: inst.instruction |= CP_T_Y | CP_T_X; break;
5412 if (inst.instruction & (PRE_INDEX | INDEX_UP))
5414 /* The instruction specified "ea" or "fd", so we can only accept
5415 [Rn]{!}. The instruction does not really support stacking or
5416 unstacking, so we have to emulate these by setting appropriate
5417 bits and offsets. */
5418 constraint (inst.reloc.exp.X_op != O_constant
5419 || inst.reloc.exp.X_add_number != 0,
5420 _("this instruction does not support indexing"));
5422 if ((inst.instruction & PRE_INDEX) || inst.operands[2].writeback)
5423 inst.reloc.exp.X_add_number = 12 * inst.operands[1].imm;
5425 if (!(inst.instruction & INDEX_UP))
5426 inst.reloc.exp.X_add_number = -inst.reloc.exp.X_add_number;
5428 if (!(inst.instruction & PRE_INDEX) && inst.operands[2].writeback)
5430 inst.operands[2].preind = 0;
5431 inst.operands[2].postind = 1;
5435 encode_arm_cp_address (2, TRUE, TRUE, 0);
5438 /* iWMMXt instructions: strictly in alphabetical order. */
5441 do_iwmmxt_tandorc (void)
5443 constraint (inst.operands[0].reg != REG_PC, _("only r15 allowed here"));
5447 do_iwmmxt_textrc (void)
5449 inst.instruction |= inst.operands[0].reg << 12;
5450 inst.instruction |= inst.operands[1].imm;
5454 do_iwmmxt_textrm (void)
5456 inst.instruction |= inst.operands[0].reg << 12;
5457 inst.instruction |= inst.operands[1].reg << 16;
5458 inst.instruction |= inst.operands[2].imm;
5462 do_iwmmxt_tinsr (void)
5464 inst.instruction |= inst.operands[0].reg << 16;
5465 inst.instruction |= inst.operands[1].reg << 12;
5466 inst.instruction |= inst.operands[2].imm;
5470 do_iwmmxt_tmia (void)
5472 inst.instruction |= inst.operands[0].reg << 5;
5473 inst.instruction |= inst.operands[1].reg;
5474 inst.instruction |= inst.operands[2].reg << 12;
5478 do_iwmmxt_waligni (void)
5480 inst.instruction |= inst.operands[0].reg << 12;
5481 inst.instruction |= inst.operands[1].reg << 16;
5482 inst.instruction |= inst.operands[2].reg;
5483 inst.instruction |= inst.operands[3].imm << 20;
5487 do_iwmmxt_wmov (void)
5489 /* WMOV rD, rN is an alias for WOR rD, rN, rN. */
5490 inst.instruction |= inst.operands[0].reg << 12;
5491 inst.instruction |= inst.operands[1].reg << 16;
5492 inst.instruction |= inst.operands[1].reg;
5496 do_iwmmxt_wldstbh (void)
5498 inst.instruction |= inst.operands[0].reg << 12;
5499 inst.reloc.exp.X_add_number *= 4;
5500 encode_arm_cp_address (1, TRUE, FALSE, BFD_RELOC_ARM_CP_OFF_IMM_S2);
5504 do_iwmmxt_wldstw (void)
5506 /* RIWR_RIWC clears .isreg for a control register. */
5507 if (!inst.operands[0].isreg)
5509 constraint (inst.cond != COND_ALWAYS, BAD_COND);
5510 inst.instruction |= 0xf0000000;
5513 inst.instruction |= inst.operands[0].reg << 12;
5514 encode_arm_cp_address (1, TRUE, TRUE, 0);
5518 do_iwmmxt_wldstd (void)
5520 inst.instruction |= inst.operands[0].reg << 12;
5521 encode_arm_cp_address (1, TRUE, FALSE, 0);
5525 do_iwmmxt_wshufh (void)
5527 inst.instruction |= inst.operands[0].reg << 12;
5528 inst.instruction |= inst.operands[1].reg << 16;
5529 inst.instruction |= ((inst.operands[2].imm & 0xf0) << 16);
5530 inst.instruction |= (inst.operands[2].imm & 0x0f);
5534 do_iwmmxt_wzero (void)
5536 /* WZERO reg is an alias for WANDN reg, reg, reg. */
5537 inst.instruction |= inst.operands[0].reg;
5538 inst.instruction |= inst.operands[0].reg << 12;
5539 inst.instruction |= inst.operands[0].reg << 16;
5542 /* Cirrus Maverick instructions. Simple 2-, 3-, and 4-register
5543 operations first, then control, shift, and load/store. */
5545 /* Insns like "foo X,Y,Z". */
5548 do_mav_triple (void)
5550 inst.instruction |= inst.operands[0].reg << 16;
5551 inst.instruction |= inst.operands[1].reg;
5552 inst.instruction |= inst.operands[2].reg << 12;
5555 /* Insns like "foo W,X,Y,Z".
5556 where W=MVAX[0:3] and X,Y,Z=MVFX[0:15]. */
5561 inst.instruction |= inst.operands[0].reg << 5;
5562 inst.instruction |= inst.operands[1].reg << 12;
5563 inst.instruction |= inst.operands[2].reg << 16;
5564 inst.instruction |= inst.operands[3].reg;
5567 /* cfmvsc32<cond> DSPSC,MVDX[15:0]. */
5571 inst.instruction |= inst.operands[1].reg << 12;
5574 /* Maverick shift immediate instructions.
5575 cfsh32<cond> MVFX[15:0],MVFX[15:0],Shift[6:0].
5576 cfsh64<cond> MVDX[15:0],MVDX[15:0],Shift[6:0]. */
5581 int imm = inst.operands[2].imm;
5583 inst.instruction |= inst.operands[0].reg << 12;
5584 inst.instruction |= inst.operands[1].reg << 16;
5586 /* Bits 0-3 of the insn should have bits 0-3 of the immediate.
5587 Bits 5-7 of the insn should have bits 4-6 of the immediate.
5588 Bit 4 should be 0. */
5589 imm = (imm & 0xf) | ((imm & 0x70) << 1);
5591 inst.instruction |= imm;
5594 /* XScale instructions. Also sorted arithmetic before move. */
5596 /* Xscale multiply-accumulate (argument parse)
5599 MIAxycc acc0,Rm,Rs. */
5604 inst.instruction |= inst.operands[1].reg;
5605 inst.instruction |= inst.operands[2].reg << 12;
5608 /* Xscale move-accumulator-register (argument parse)
5610 MARcc acc0,RdLo,RdHi. */
5615 inst.instruction |= inst.operands[1].reg << 12;
5616 inst.instruction |= inst.operands[2].reg << 16;
5619 /* Xscale move-register-accumulator (argument parse)
5621 MRAcc RdLo,RdHi,acc0. */
5626 constraint (inst.operands[0].reg == inst.operands[1].reg, BAD_OVERLAP);
5627 inst.instruction |= inst.operands[0].reg << 12;
5628 inst.instruction |= inst.operands[1].reg << 16;
5631 /* Encoding functions relevant only to Thumb. */
5633 /* inst.operands[i] is a shifted-register operand; encode
5634 it into inst.instruction in the format used by Thumb32. */
5637 encode_thumb32_shifted_operand (int i)
5639 unsigned int value = inst.reloc.exp.X_add_number;
5640 unsigned int shift = inst.operands[i].shift_kind;
5642 constraint (inst.operands[i].immisreg,
5643 _("shift by register not allowed in thumb mode"));
5644 inst.instruction |= inst.operands[i].reg;
5645 if (shift == SHIFT_RRX)
5646 inst.instruction |= SHIFT_ROR << 4;
5649 constraint (inst.reloc.exp.X_op != O_constant,
5650 _("expression too complex"));
5652 constraint (value > 32
5653 || (value == 32 && (shift == SHIFT_LSL
5654 || shift == SHIFT_ROR)),
5655 _("shift expression is too large"));
5659 else if (value == 32)
5662 inst.instruction |= shift << 4;
5663 inst.instruction |= (value & 0x1c) << 10;
5664 inst.instruction |= (value & 0x03) << 6;
5669 /* inst.operands[i] was set up by parse_address. Encode it into a
5670 Thumb32 format load or store instruction. Reject forms that cannot
5671 be used with such instructions. If is_t is true, reject forms that
5672 cannot be used with a T instruction; if is_d is true, reject forms
5673 that cannot be used with a D instruction. */
5676 encode_thumb32_addr_mode (int i, bfd_boolean is_t, bfd_boolean is_d)
5678 bfd_boolean is_pc = (inst.operands[i].reg == REG_PC);
5680 constraint (!inst.operands[i].isreg,
5681 _("Thumb does not support the ldr =N pseudo-operation"));
5683 inst.instruction |= inst.operands[i].reg << 16;
5684 if (inst.operands[i].immisreg)
5686 constraint (is_pc, _("cannot use register index with PC-relative addressing"));
5687 constraint (is_t || is_d, _("cannot use register index with this instruction"));
5688 constraint (inst.operands[i].negative,
5689 _("Thumb does not support negative register indexing"));
5690 constraint (inst.operands[i].postind,
5691 _("Thumb does not support register post-indexing"));
5692 constraint (inst.operands[i].writeback,
5693 _("Thumb does not support register indexing with writeback"));
5694 constraint (inst.operands[i].shifted && inst.operands[i].shift_kind != SHIFT_LSL,
5695 _("Thumb supports only LSL in shifted register indexing"));
5697 inst.instruction |= inst.operands[1].imm;
5698 if (inst.operands[i].shifted)
5700 constraint (inst.reloc.exp.X_op != O_constant,
5701 _("expression too complex"));
5702 constraint (inst.reloc.exp.X_add_number < 0
5703 || inst.reloc.exp.X_add_number > 3,
5704 _("shift out of range"));
5705 inst.instruction |= inst.reloc.exp.X_add_number << 4;
5707 inst.reloc.type = BFD_RELOC_UNUSED;
5709 else if (inst.operands[i].preind)
5711 constraint (is_pc && inst.operands[i].writeback,
5712 _("cannot use writeback with PC-relative addressing"));
5713 constraint (is_t && inst.operands[1].writeback,
5714 _("cannot use writeback with this instruction"));
5718 inst.instruction |= 0x01000000;
5719 if (inst.operands[i].writeback)
5720 inst.instruction |= 0x00200000;
5724 inst.instruction |= 0x00000c00;
5725 if (inst.operands[i].writeback)
5726 inst.instruction |= 0x00000100;
5728 inst.reloc.type = BFD_RELOC_ARM_T32_OFFSET_IMM;
5730 else if (inst.operands[i].postind)
5732 assert (inst.operands[i].writeback);
5733 constraint (is_pc, _("cannot use post-indexing with PC-relative addressing"));
5734 constraint (is_t, _("cannot use post-indexing with this instruction"));
5737 inst.instruction |= 0x00200000;
5739 inst.instruction |= 0x00000900;
5740 inst.reloc.type = BFD_RELOC_ARM_T32_OFFSET_IMM;
5742 else /* unindexed - only for coprocessor */
5743 inst.error = _("instruction does not accept unindexed addressing");
5746 /* Table of Thumb instructions which exist in both 16- and 32-bit
5747 encodings (the latter only in post-V6T2 cores). The index is the
5748 value used in the insns table below. When there is more than one
5749 possible 16-bit encoding for the instruction, this table always
5750 holds variant (1). */
5751 #define T16_32_TAB \
5752 X(adc, 4140, eb400000), \
5753 X(adcs, 4140, eb500000), \
5754 X(add, 1c00, eb000000), \
5755 X(adds, 1c00, eb100000), \
5756 X(adr, 000f, f20f0000), \
5757 X(and, 4000, ea000000), \
5758 X(ands, 4000, ea100000), \
5759 X(asr, 1000, fa40f000), \
5760 X(asrs, 1000, fa50f000), \
5761 X(bic, 4380, ea200000), \
5762 X(bics, 4380, ea300000), \
5763 X(cmn, 42c0, eb100f00), \
5764 X(cmp, 2800, ebb00f00), \
5765 X(cpsie, b660, f3af8400), \
5766 X(cpsid, b670, f3af8600), \
5767 X(cpy, 4600, ea4f0000), \
5768 X(eor, 4040, ea800000), \
5769 X(eors, 4040, ea900000), \
5770 X(ldmia, c800, e8900000), \
5771 X(ldr, 6800, f8500000), \
5772 X(ldrb, 7800, f8100000), \
5773 X(ldrh, 8800, f8300000), \
5774 X(ldrsb, 5600, f9100000), \
5775 X(ldrsh, 5e00, f9300000), \
5776 X(lsl, 0000, fa00f000), \
5777 X(lsls, 0000, fa10f000), \
5778 X(lsr, 0800, fa20f000), \
5779 X(lsrs, 0800, fa30f000), \
5780 X(mov, 2000, ea4f0000), \
5781 X(movs, 2000, ea5f0000), \
5782 X(mul, 4340, fb00f000), \
5783 X(muls, 4340, ffffffff), /* no 32b muls */ \
5784 X(mvn, 43c0, ea6f0000), \
5785 X(mvns, 43c0, ea7f0000), \
5786 X(neg, 4240, f1c00000), /* rsb #0 */ \
5787 X(negs, 4240, f1d00000), /* rsbs #0 */ \
5788 X(orr, 4300, ea400000), \
5789 X(orrs, 4300, ea500000), \
5790 X(pop, bc00, e8bd0000), /* ldmia sp!,... */ \
5791 X(push, b400, e92d0000), /* stmdb sp!,... */ \
5792 X(rev, ba00, fa90f080), \
5793 X(rev16, ba40, fa90f090), \
5794 X(revsh, bac0, fa90f0b0), \
5795 X(ror, 41c0, fa60f000), \
5796 X(rors, 41c0, fa70f000), \
5797 X(sbc, 4180, eb600000), \
5798 X(sbcs, 4180, eb700000), \
5799 X(stmia, c000, e8800000), \
5800 X(str, 6000, f8400000), \
5801 X(strb, 7000, f8000000), \
5802 X(strh, 8000, f8200000), \
5803 X(sub, 1e00, eba00000), \
5804 X(subs, 1e00, ebb00000), \
5805 X(sxtb, b240, fa4ff080), \
5806 X(sxth, b200, fa0ff080), \
5807 X(tst, 4200, ea100f00), \
5808 X(uxtb, b2c0, fa5ff080), \
5809 X(uxth, b280, fa1ff080), \
5810 X(nop, bf00, f3af8000), \
5811 X(yield, bf10, f3af8001), \
5812 X(wfe, bf20, f3af8002), \
5813 X(wfi, bf30, f3af8003), \
5814 X(sev, bf40, f3af9004), /* typo, 8004? */
5816 /* To catch errors in encoding functions, the codes are all offset by
5817 0xF800, putting them in one of the 32-bit prefix ranges, ergo undefined
5818 as 16-bit instructions. */
5819 #define X(a,b,c) T_MNEM_##a
5820 enum t16_32_codes { T16_32_OFFSET = 0xF7FF, T16_32_TAB };
5823 #define X(a,b,c) 0x##b
5824 static const unsigned short thumb_op16[] = { T16_32_TAB };
5825 #define THUMB_OP16(n) (thumb_op16[(n) - (T16_32_OFFSET + 1)])
5828 #define X(a,b,c) 0x##c
5829 static const unsigned int thumb_op32[] = { T16_32_TAB };
5830 #define THUMB_OP32(n) (thumb_op32[(n) - (T16_32_OFFSET + 1)])
5831 #define THUMB_SETS_FLAGS(n) (THUMB_OP32 (n) & 0x00100000)
5835 /* Thumb instruction encoders, in alphabetical order. */
5839 do_t_add_sub_w (void)
5843 Rd = inst.operands[0].reg;
5844 Rn = inst.operands[1].reg;
5846 constraint (Rd == 15, _("PC not allowed as destination"));
5847 inst.instruction |= (Rn << 16) | (Rd << 8);
5848 inst.reloc.type = BFD_RELOC_ARM_T32_IMM12;
5851 /* Parse an add or subtract instruction. We get here with inst.instruction
5852 equalling any of THUMB_OPCODE_add, adds, sub, or subs. */
5859 Rd = inst.operands[0].reg;
5860 Rs = (inst.operands[1].present
5861 ? inst.operands[1].reg /* Rd, Rs, foo */
5862 : inst.operands[0].reg); /* Rd, foo -> Rd, Rd, foo */
5866 if (!inst.operands[2].isreg)
5868 /* ??? Convert large immediates to addw/subw. */
5869 /* ??? 16-bit adds with small immediates. */
5870 /* For an immediate, we always generate a 32-bit opcode;
5871 section relaxation will shrink it later if possible. */
5872 inst.instruction = THUMB_OP32 (inst.instruction);
5873 inst.instruction = (inst.instruction & 0xe1ffffff) | 0x10000000;
5874 inst.instruction |= inst.operands[0].reg << 8;
5875 inst.instruction |= inst.operands[1].reg << 16;
5876 inst.reloc.type = BFD_RELOC_ARM_T32_IMMEDIATE;
5880 Rn = inst.operands[2].reg;
5881 /* See if we can do this with a 16-bit instruction. */
5882 if (!inst.operands[2].shifted && inst.size_req != 4)
5886 if (inst.instruction == T_MNEM_adds
5887 || inst.instruction == T_MNEM_subs)
5888 narrow = (current_it_mask == 0);
5890 narrow = (current_it_mask != 0);
5891 if (Rd > 7 || Rs > 7 || Rn > 7)
5896 inst.instruction = ((inst.instruction == T_MNEM_adds
5897 || inst.instruction == T_MNEM_add)
5900 inst.instruction |= Rd | (Rs << 3) | (Rn << 6);
5904 if (inst.instruction == T_MNEM_add)
5908 inst.instruction = T_OPCODE_ADD_HI;
5909 inst.instruction |= (Rd & 8) << 4;
5910 inst.instruction |= (Rd & 7);
5911 inst.instruction |= Rn << 3;
5914 /* ... because addition is commutative! */
5917 inst.instruction = T_OPCODE_ADD_HI;
5918 inst.instruction |= (Rd & 8) << 4;
5919 inst.instruction |= (Rd & 7);
5920 inst.instruction |= Rs << 3;
5925 /* If we get here, it can't be done in 16 bits. */
5926 constraint (inst.operands[2].shifted && inst.operands[2].immisreg,
5927 _("shift must be constant"));
5928 inst.instruction = THUMB_OP32 (inst.instruction);
5929 inst.instruction |= Rd << 8;
5930 inst.instruction |= Rs << 16;
5931 encode_thumb32_shifted_operand (2);
5936 constraint (inst.instruction == T_MNEM_adds
5937 || inst.instruction == T_MNEM_subs,
5940 if (!inst.operands[2].isreg) /* Rd, Rs, #imm */
5942 constraint ((Rd > 7 && (Rd != REG_SP || Rs != REG_SP))
5943 || (Rs > 7 && Rs != REG_SP && Rs != REG_PC),
5946 inst.instruction = (inst.instruction == T_MNEM_add
5948 inst.instruction |= (Rd << 4) | Rs;
5949 inst.reloc.type = BFD_RELOC_ARM_THUMB_ADD;
5953 Rn = inst.operands[2].reg;
5954 constraint (inst.operands[2].shifted, _("unshifted register required"));
5956 /* We now have Rd, Rs, and Rn set to registers. */
5957 if (Rd > 7 || Rs > 7 || Rn > 7)
5959 /* Can't do this for SUB. */
5960 constraint (inst.instruction == T_MNEM_sub, BAD_HIREG);
5961 inst.instruction = T_OPCODE_ADD_HI;
5962 inst.instruction |= (Rd & 8) << 4;
5963 inst.instruction |= (Rd & 7);
5965 inst.instruction |= Rn << 3;
5967 inst.instruction |= Rs << 3;
5969 constraint (1, _("dest must overlap one source register"));
5973 inst.instruction = (inst.instruction == T_MNEM_add
5974 ? T_OPCODE_ADD_R3 : T_OPCODE_SUB_R3);
5975 inst.instruction |= Rd | (Rs << 3) | (Rn << 6);
5983 if (unified_syntax && inst.size_req != 2)
5985 /* Always generate a 32-bit opcode;
5986 section relaxation will shrink it later if possible. */
5987 inst.instruction = THUMB_OP32 (inst.instruction);
5988 inst.instruction |= inst.operands[0].reg << 8;
5989 inst.reloc.type = BFD_RELOC_ARM_T32_ADD_PC12;
5990 inst.reloc.pc_rel = 1;
5994 inst.instruction = THUMB_OP16 (inst.instruction);
5995 inst.reloc.type = BFD_RELOC_ARM_THUMB_ADD;
5996 inst.reloc.exp.X_add_number -= 4; /* PC relative adjust. */
5997 inst.reloc.pc_rel = 1;
5999 inst.instruction |= inst.operands[0].reg << 4;
6003 /* Arithmetic instructions for which there is just one 16-bit
6004 instruction encoding, and it allows only two low registers.
6005 For maximal compatibility with ARM syntax, we allow three register
6006 operands even when Thumb-32 instructions are not available, as long
6007 as the first two are identical. For instance, both "sbc r0,r1" and
6008 "sbc r0,r0,r1" are allowed. */
6014 Rd = inst.operands[0].reg;
6015 Rs = (inst.operands[1].present
6016 ? inst.operands[1].reg /* Rd, Rs, foo */
6017 : inst.operands[0].reg); /* Rd, foo -> Rd, Rd, foo */
6018 Rn = inst.operands[2].reg;
6022 if (!inst.operands[2].isreg)
6024 /* For an immediate, we always generate a 32-bit opcode;
6025 section relaxation will shrink it later if possible. */
6026 inst.instruction = THUMB_OP32 (inst.instruction);
6027 inst.instruction = (inst.instruction & 0xe1ffffff) | 0x10000000;
6028 inst.instruction |= Rd << 8;
6029 inst.instruction |= Rs << 16;
6030 inst.reloc.type = BFD_RELOC_ARM_T32_IMMEDIATE;
6036 /* See if we can do this with a 16-bit instruction. */
6037 if (THUMB_SETS_FLAGS (inst.instruction))
6038 narrow = current_it_mask == 0;
6040 narrow = current_it_mask != 0;
6042 if (Rd > 7 || Rn > 7 || Rs > 7)
6044 if (inst.operands[2].shifted)
6046 if (inst.size_req == 4)
6052 inst.instruction = THUMB_OP16 (inst.instruction);
6053 inst.instruction |= Rd;
6054 inst.instruction |= Rn << 3;
6058 /* If we get here, it can't be done in 16 bits. */
6059 constraint (inst.operands[2].shifted
6060 && inst.operands[2].immisreg,
6061 _("shift must be constant"));
6062 inst.instruction = THUMB_OP32 (inst.instruction);
6063 inst.instruction |= Rd << 8;
6064 inst.instruction |= Rs << 16;
6065 encode_thumb32_shifted_operand (2);
6070 /* On its face this is a lie - the instruction does set the
6071 flags. However, the only supported mnemonic in this mode
6073 constraint (THUMB_SETS_FLAGS (inst.instruction), BAD_THUMB32);
6075 constraint (!inst.operands[2].isreg || inst.operands[2].shifted,
6076 _("unshifted register required"));
6077 constraint (Rd > 7 || Rs > 7 || Rn > 7, BAD_HIREG);
6078 constraint (Rd != Rs,
6079 _("dest and source1 must be the same register"));
6081 inst.instruction = THUMB_OP16 (inst.instruction);
6082 inst.instruction |= Rd;
6083 inst.instruction |= Rn << 3;
6087 /* Similarly, but for instructions where the arithmetic operation is
6088 commutative, so we can allow either of them to be different from
6089 the destination operand in a 16-bit instruction. For instance, all
6090 three of "adc r0,r1", "adc r0,r0,r1", and "adc r0,r1,r0" are
6097 Rd = inst.operands[0].reg;
6098 Rs = (inst.operands[1].present
6099 ? inst.operands[1].reg /* Rd, Rs, foo */
6100 : inst.operands[0].reg); /* Rd, foo -> Rd, Rd, foo */
6101 Rn = inst.operands[2].reg;
6105 if (!inst.operands[2].isreg)
6107 /* For an immediate, we always generate a 32-bit opcode;
6108 section relaxation will shrink it later if possible. */
6109 inst.instruction = THUMB_OP32 (inst.instruction);
6110 inst.instruction = (inst.instruction & 0xe1ffffff) | 0x10000000;
6111 inst.instruction |= Rd << 8;
6112 inst.instruction |= Rs << 16;
6113 inst.reloc.type = BFD_RELOC_ARM_T32_IMMEDIATE;
6119 /* See if we can do this with a 16-bit instruction. */
6120 if (THUMB_SETS_FLAGS (inst.instruction))
6121 narrow = current_it_mask == 0;
6123 narrow = current_it_mask != 0;
6125 if (Rd > 7 || Rn > 7 || Rs > 7)
6127 if (inst.operands[2].shifted)
6129 if (inst.size_req == 4)
6136 inst.instruction = THUMB_OP16 (inst.instruction);
6137 inst.instruction |= Rd;
6138 inst.instruction |= Rn << 3;
6143 inst.instruction = THUMB_OP16 (inst.instruction);
6144 inst.instruction |= Rd;
6145 inst.instruction |= Rs << 3;
6150 /* If we get here, it can't be done in 16 bits. */
6151 constraint (inst.operands[2].shifted
6152 && inst.operands[2].immisreg,
6153 _("shift must be constant"));
6154 inst.instruction = THUMB_OP32 (inst.instruction);
6155 inst.instruction |= Rd << 8;
6156 inst.instruction |= Rs << 16;
6157 encode_thumb32_shifted_operand (2);
6162 /* On its face this is a lie - the instruction does set the
6163 flags. However, the only supported mnemonic in this mode
6165 constraint (THUMB_SETS_FLAGS (inst.instruction), BAD_THUMB32);
6167 constraint (!inst.operands[2].isreg || inst.operands[2].shifted,
6168 _("unshifted register required"));
6169 constraint (Rd > 7 || Rs > 7 || Rn > 7, BAD_HIREG);
6171 inst.instruction = THUMB_OP16 (inst.instruction);
6172 inst.instruction |= Rd;
6175 inst.instruction |= Rn << 3;
6177 inst.instruction |= Rs << 3;
6179 constraint (1, _("dest must overlap one source register"));
6186 unsigned int msb = inst.operands[1].imm + inst.operands[2].imm;
6187 constraint (msb > 32, _("bit-field extends past end of register"));
6188 /* The instruction encoding stores the LSB and MSB,
6189 not the LSB and width. */
6190 inst.instruction |= inst.operands[0].reg << 8;
6191 inst.instruction |= (inst.operands[1].imm & 0x1c) << 10;
6192 inst.instruction |= (inst.operands[1].imm & 0x03) << 6;
6193 inst.instruction |= msb - 1;
6201 /* #0 in second position is alternative syntax for bfc, which is
6202 the same instruction but with REG_PC in the Rm field. */
6203 if (!inst.operands[1].isreg)
6204 inst.operands[1].reg = REG_PC;
6206 msb = inst.operands[2].imm + inst.operands[3].imm;
6207 constraint (msb > 32, _("bit-field extends past end of register"));
6208 /* The instruction encoding stores the LSB and MSB,
6209 not the LSB and width. */
6210 inst.instruction |= inst.operands[0].reg << 8;
6211 inst.instruction |= inst.operands[1].reg << 16;
6212 inst.instruction |= (inst.operands[2].imm & 0x1c) << 10;
6213 inst.instruction |= (inst.operands[2].imm & 0x03) << 6;
6214 inst.instruction |= msb - 1;
6220 constraint (inst.operands[2].imm + inst.operands[3].imm > 32,
6221 _("bit-field extends past end of register"));
6222 inst.instruction |= inst.operands[0].reg << 8;
6223 inst.instruction |= inst.operands[1].reg << 16;
6224 inst.instruction |= (inst.operands[2].imm & 0x1c) << 10;
6225 inst.instruction |= (inst.operands[2].imm & 0x03) << 6;
6226 inst.instruction |= inst.operands[3].imm - 1;
6229 /* ARM V5 Thumb BLX (argument parse)
6230 BLX <target_addr> which is BLX(1)
6231 BLX <Rm> which is BLX(2)
6232 Unfortunately, there are two different opcodes for this mnemonic.
6233 So, the insns[].value is not used, and the code here zaps values
6234 into inst.instruction.
6236 ??? How to take advantage of the additional two bits of displacement
6237 available in Thumb32 mode? Need new relocation? */
6242 if (inst.operands[0].isreg)
6243 /* We have a register, so this is BLX(2). */
6244 inst.instruction |= inst.operands[0].reg << 3;
6247 /* No register. This must be BLX(1). */
6248 inst.instruction = 0xf000e800;
6249 inst.reloc.type = BFD_RELOC_THUMB_PCREL_BLX;
6250 inst.reloc.pc_rel = 1;
6257 if (unified_syntax && inst.size_req != 2)
6259 if (inst.cond == COND_ALWAYS)
6261 inst.instruction = 0xf000b000;
6262 inst.reloc.type = BFD_RELOC_THUMB_PCREL_BRANCH25;
6266 assert (inst.cond != 0xF);
6267 inst.instruction = (inst.cond << 22) | 0xf0008000;
6268 inst.reloc.type = BFD_RELOC_THUMB_PCREL_BRANCH20;
6273 if (inst.cond == COND_ALWAYS)
6274 inst.reloc.type = BFD_RELOC_THUMB_PCREL_BRANCH12;
6277 inst.instruction = 0xd000 | (inst.cond << 8);
6278 inst.reloc.type = BFD_RELOC_THUMB_PCREL_BRANCH9;
6282 inst.reloc.pc_rel = 1;
6288 if (inst.operands[0].present)
6290 constraint (inst.operands[0].imm > 255,
6291 _("immediate value out of range"));
6292 inst.instruction |= inst.operands[0].imm;
6297 do_t_branch23 (void)
6299 inst.reloc.type = BFD_RELOC_THUMB_PCREL_BRANCH23;
6300 inst.reloc.pc_rel = 1;
6302 /* If the destination of the branch is a defined symbol which does not have
6303 the THUMB_FUNC attribute, then we must be calling a function which has
6304 the (interfacearm) attribute. We look for the Thumb entry point to that
6305 function and change the branch to refer to that function instead. */
6306 if ( inst.reloc.exp.X_op == O_symbol
6307 && inst.reloc.exp.X_add_symbol != NULL
6308 && S_IS_DEFINED (inst.reloc.exp.X_add_symbol)
6309 && ! THUMB_IS_FUNC (inst.reloc.exp.X_add_symbol))
6310 inst.reloc.exp.X_add_symbol =
6311 find_real_start (inst.reloc.exp.X_add_symbol);
6317 inst.instruction |= inst.operands[0].reg << 3;
6318 /* ??? FIXME: Should add a hacky reloc here if reg is REG_PC. The reloc
6319 should cause the alignment to be checked once it is known. This is
6320 because BX PC only works if the instruction is word aligned. */
6326 if (inst.operands[0].reg == REG_PC)
6327 as_tsktsk (_("use of r15 in bxj is not really useful"));
6329 inst.instruction |= inst.operands[0].reg << 16;
6335 inst.instruction |= inst.operands[0].reg << 8;
6336 inst.instruction |= inst.operands[1].reg << 16;
6337 inst.instruction |= inst.operands[1].reg;
6344 && (inst.operands[1].present || inst.size_req == 4))
6346 unsigned int imod = (inst.instruction & 0x0030) >> 4;
6347 inst.instruction = 0xf3af8000;
6348 inst.instruction |= imod << 9;
6349 inst.instruction |= inst.operands[0].imm << 5;
6350 if (inst.operands[1].present)
6351 inst.instruction |= 0x100 | inst.operands[1].imm;
6355 constraint (inst.operands[1].present,
6356 _("Thumb does not support the 2-argument "
6357 "form of this instruction"));
6358 inst.instruction |= inst.operands[0].imm;
6362 /* THUMB CPY instruction (argument parse). */
6367 if (inst.size_req == 4)
6369 inst.instruction = THUMB_OP32 (T_MNEM_mov);
6370 inst.instruction |= inst.operands[0].reg << 8;
6371 inst.instruction |= inst.operands[1].reg;
6375 inst.instruction |= (inst.operands[0].reg & 0x8) << 4;
6376 inst.instruction |= (inst.operands[0].reg & 0x7);
6377 inst.instruction |= inst.operands[1].reg << 3;
6384 constraint (inst.operands[0].reg > 7, BAD_HIREG);
6385 inst.instruction |= inst.operands[0].reg;
6386 inst.reloc.pc_rel = 1;
6387 inst.reloc.type = BFD_RELOC_THUMB_PCREL_BRANCH7;
6393 if (unified_syntax && inst.size_req == 4)
6394 inst.instruction = THUMB_OP32 (inst.instruction);
6396 inst.instruction = THUMB_OP16 (inst.instruction);
6402 unsigned int cond = inst.operands[0].imm;
6404 current_it_mask = (inst.instruction & 0xf) | 0x10;
6407 /* If the condition is a negative condition, invert the mask. */
6408 if ((cond & 0x1) == 0x0)
6410 unsigned int mask = inst.instruction & 0x000f;
6412 if ((mask & 0x7) == 0)
6413 /* no conversion needed */;
6414 else if ((mask & 0x3) == 0)
6416 else if ((mask & 0x1) == 0)
6421 inst.instruction &= 0xfff0;
6422 inst.instruction |= mask;
6425 inst.instruction |= cond << 4;
6431 /* This really doesn't seem worth it. */
6432 constraint (inst.reloc.type != BFD_RELOC_UNUSED,
6433 _("expression too complex"));
6434 constraint (inst.operands[1].writeback,
6435 _("Thumb load/store multiple does not support {reglist}^"));
6439 /* See if we can use a 16-bit instruction. */
6440 if (inst.instruction < 0xffff /* not ldmdb/stmdb */
6441 && inst.size_req != 4
6442 && inst.operands[0].reg <= 7
6443 && !(inst.operands[1].imm & ~0xff)
6444 && (inst.instruction == T_MNEM_stmia
6445 ? inst.operands[0].writeback
6446 : (inst.operands[0].writeback
6447 == !(inst.operands[1].imm & (1 << inst.operands[0].reg)))))
6449 if (inst.instruction == T_MNEM_stmia
6450 && (inst.operands[1].imm & (1 << inst.operands[0].reg))
6451 && (inst.operands[1].imm & ((1 << inst.operands[0].reg) - 1)))
6452 as_warn (_("value stored for r%d is UNPREDICTABLE"),
6453 inst.operands[0].reg);
6455 inst.instruction = THUMB_OP16 (inst.instruction);
6456 inst.instruction |= inst.operands[0].reg << 8;
6457 inst.instruction |= inst.operands[1].imm;
6461 if (inst.operands[1].imm & (1 << 13))
6462 as_warn (_("SP should not be in register list"));
6463 if (inst.instruction == T_MNEM_stmia)
6465 if (inst.operands[1].imm & (1 << 15))
6466 as_warn (_("PC should not be in register list"));
6467 if (inst.operands[1].imm & (1 << inst.operands[0].reg))
6468 as_warn (_("value stored for r%d is UNPREDICTABLE"),
6469 inst.operands[0].reg);
6473 if (inst.operands[1].imm & (1 << 14)
6474 && inst.operands[1].imm & (1 << 15))
6475 as_warn (_("LR and PC should not both be in register list"));
6476 if ((inst.operands[1].imm & (1 << inst.operands[0].reg))
6477 && inst.operands[0].writeback)
6478 as_warn (_("base register should not be in register list "
6479 "when written back"));
6481 if (inst.instruction < 0xffff)
6482 inst.instruction = THUMB_OP32 (inst.instruction);
6483 inst.instruction |= inst.operands[0].reg << 16;
6484 inst.instruction |= inst.operands[1].imm;
6485 if (inst.operands[0].writeback)
6486 inst.instruction |= WRITE_BACK;
6491 constraint (inst.operands[0].reg > 7
6492 || (inst.operands[1].imm & ~0xff), BAD_HIREG);
6493 if (inst.instruction == T_MNEM_stmia)
6495 if (!inst.operands[0].writeback)
6496 as_warn (_("this instruction will write back the base register"));
6497 if ((inst.operands[1].imm & (1 << inst.operands[0].reg))
6498 && (inst.operands[1].imm & ((1 << inst.operands[0].reg) - 1)))
6499 as_warn (_("value stored for r%d is UNPREDICTABLE"),
6500 inst.operands[0].reg);
6504 if (!inst.operands[0].writeback
6505 && !(inst.operands[1].imm & (1 << inst.operands[0].reg)))
6506 as_warn (_("this instruction will write back the base register"));
6507 else if (inst.operands[0].writeback
6508 && (inst.operands[1].imm & (1 << inst.operands[0].reg)))
6509 as_warn (_("this instruction will not write back the base register"));
6512 inst.instruction = THUMB_OP16 (inst.instruction);
6513 inst.instruction |= inst.operands[0].reg << 8;
6514 inst.instruction |= inst.operands[1].imm;
6521 constraint (!inst.operands[1].isreg || !inst.operands[1].preind
6522 || inst.operands[1].postind || inst.operands[1].writeback
6523 || inst.operands[1].immisreg || inst.operands[1].shifted
6524 || inst.operands[1].negative,
6525 _("instruction does not accept this addressing mode"));
6527 inst.instruction |= inst.operands[0].reg << 12;
6528 inst.instruction |= inst.operands[1].reg << 16;
6529 inst.reloc.type = BFD_RELOC_ARM_T32_OFFSET_U8;
6535 if (!inst.operands[1].present)
6537 constraint (inst.operands[0].reg == REG_LR,
6538 _("r14 not allowed as first register "
6539 "when second register is omitted"));
6540 inst.operands[1].reg = inst.operands[0].reg + 1;
6542 constraint (inst.operands[0].reg == inst.operands[1].reg,
6545 inst.instruction |= inst.operands[0].reg << 12;
6546 inst.instruction |= inst.operands[1].reg << 8;
6547 inst.instruction |= inst.operands[2].reg << 16;
6555 /* Generation of 16-bit instructions for anything other than
6556 Rd, [Rn, Ri] is deferred to section relaxation time. */
6557 if (inst.operands[1].isreg && inst.operands[1].immisreg
6558 && !inst.operands[1].shifted && !inst.operands[1].postind
6559 && !inst.operands[1].negative && inst.operands[0].reg <= 7
6560 && inst.operands[1].reg <= 7 && inst.operands[1].imm <= 7
6561 && inst.instruction <= 0xffff)
6563 inst.instruction = THUMB_OP16 (inst.instruction);
6567 inst.instruction = THUMB_OP32 (inst.instruction);
6568 inst.instruction |= inst.operands[0].reg << 12;
6569 encode_thumb32_addr_mode (1, /*is_t=*/FALSE, /*is_d=*/FALSE);
6573 constraint (inst.operands[0].reg > 7, BAD_HIREG);
6575 if (inst.instruction == T_MNEM_ldrsh || inst.instruction == T_MNEM_ldrsb)
6577 /* Only [Rn,Rm] is acceptable. */
6578 constraint (inst.operands[1].reg > 7 || inst.operands[1].imm > 7, BAD_HIREG);
6579 constraint (!inst.operands[1].isreg || !inst.operands[1].immisreg
6580 || inst.operands[1].postind || inst.operands[1].shifted
6581 || inst.operands[1].negative,
6582 _("Thumb does not support this addressing mode"));
6583 inst.instruction = THUMB_OP16 (inst.instruction);
6587 inst.instruction = THUMB_OP16 (inst.instruction);
6588 if (!inst.operands[1].isreg)
6589 if (move_or_literal_pool (0, /*thumb_p=*/TRUE, /*mode_3=*/FALSE))
6592 constraint (!inst.operands[1].preind
6593 || inst.operands[1].shifted
6594 || inst.operands[1].writeback,
6595 _("Thumb does not support this addressing mode"));
6596 if (inst.operands[1].reg == REG_PC || inst.operands[1].reg == REG_SP)
6598 constraint (inst.instruction & 0x0600,
6599 _("byte or halfword not valid for base register"));
6600 constraint (inst.operands[1].reg == REG_PC
6601 && !(inst.instruction & THUMB_LOAD_BIT),
6602 _("r15 based store not allowed"));
6603 constraint (inst.operands[1].immisreg,
6604 _("invalid base register for register offset"));
6606 if (inst.operands[1].reg == REG_PC)
6607 inst.instruction = T_OPCODE_LDR_PC;
6608 else if (inst.instruction & THUMB_LOAD_BIT)
6609 inst.instruction = T_OPCODE_LDR_SP;
6611 inst.instruction = T_OPCODE_STR_SP;
6613 inst.instruction |= inst.operands[0].reg << 8;
6614 inst.reloc.type = BFD_RELOC_ARM_THUMB_OFFSET;
6618 constraint (inst.operands[1].reg > 7, BAD_HIREG);
6619 if (!inst.operands[1].immisreg)
6621 /* Immediate offset. */
6622 inst.instruction |= inst.operands[0].reg;
6623 inst.instruction |= inst.operands[1].reg << 3;
6624 inst.reloc.type = BFD_RELOC_ARM_THUMB_OFFSET;
6628 /* Register offset. */
6629 constraint (inst.operands[1].imm > 7, BAD_HIREG);
6630 constraint (inst.operands[1].negative,
6631 _("Thumb does not support this addressing mode"));
6634 switch (inst.instruction)
6636 case T_OPCODE_STR_IW: inst.instruction = T_OPCODE_STR_RW; break;
6637 case T_OPCODE_STR_IH: inst.instruction = T_OPCODE_STR_RH; break;
6638 case T_OPCODE_STR_IB: inst.instruction = T_OPCODE_STR_RB; break;
6639 case T_OPCODE_LDR_IW: inst.instruction = T_OPCODE_LDR_RW; break;
6640 case T_OPCODE_LDR_IH: inst.instruction = T_OPCODE_LDR_RH; break;
6641 case T_OPCODE_LDR_IB: inst.instruction = T_OPCODE_LDR_RB; break;
6642 case 0x5600 /* ldrsb */:
6643 case 0x5e00 /* ldrsh */: break;
6647 inst.instruction |= inst.operands[0].reg;
6648 inst.instruction |= inst.operands[1].reg << 3;
6649 inst.instruction |= inst.operands[1].imm << 6;
6655 if (!inst.operands[1].present)
6657 inst.operands[1].reg = inst.operands[0].reg + 1;
6658 constraint (inst.operands[0].reg == REG_LR,
6659 _("r14 not allowed here"));
6661 inst.instruction |= inst.operands[0].reg << 12;
6662 inst.instruction |= inst.operands[1].reg << 8;
6663 encode_thumb32_addr_mode (2, /*is_t=*/FALSE, /*is_d=*/TRUE);
6670 inst.instruction |= inst.operands[0].reg << 12;
6671 encode_thumb32_addr_mode (1, /*is_t=*/TRUE, /*is_d=*/FALSE);
6677 inst.instruction |= inst.operands[0].reg << 8;
6678 inst.instruction |= inst.operands[1].reg << 16;
6679 inst.instruction |= inst.operands[2].reg;
6680 inst.instruction |= inst.operands[3].reg << 12;
6686 inst.instruction |= inst.operands[0].reg << 12;
6687 inst.instruction |= inst.operands[1].reg << 8;
6688 inst.instruction |= inst.operands[2].reg << 16;
6689 inst.instruction |= inst.operands[3].reg;
6697 int r0off = (inst.instruction == T_MNEM_mov
6698 || inst.instruction == T_MNEM_movs) ? 8 : 16;
6699 if (!inst.operands[1].isreg)
6701 /* For an immediate, we always generate a 32-bit opcode;
6702 section relaxation will shrink it later if possible. */
6703 inst.instruction = THUMB_OP32 (inst.instruction);
6704 inst.instruction = (inst.instruction & 0xe1ffffff) | 0x10000000;
6705 inst.instruction |= inst.operands[0].reg << r0off;
6706 inst.reloc.type = BFD_RELOC_ARM_T32_IMMEDIATE;
6708 else if (inst.size_req == 4
6709 || inst.operands[1].shifted
6710 || (inst.instruction == T_MNEM_movs
6711 && (inst.operands[0].reg > 7 || inst.operands[1].reg > 7)))
6713 inst.instruction = THUMB_OP32 (inst.instruction);
6714 inst.instruction |= inst.operands[0].reg << r0off;
6715 encode_thumb32_shifted_operand (1);
6718 switch (inst.instruction)
6721 inst.instruction = T_OPCODE_MOV_HR;
6722 inst.instruction |= (inst.operands[0].reg & 0x8) << 4;
6723 inst.instruction |= (inst.operands[0].reg & 0x7);
6724 inst.instruction |= inst.operands[1].reg << 3;
6728 /* We know we have low registers at this point.
6729 Generate ADD Rd, Rs, #0. */
6730 inst.instruction = T_OPCODE_ADD_I3;
6731 inst.instruction |= inst.operands[0].reg;
6732 inst.instruction |= inst.operands[1].reg << 3;
6736 if (inst.operands[0].reg <= 7 && inst.operands[1].reg <= 7)
6738 inst.instruction = T_OPCODE_CMP_LR;
6739 inst.instruction |= inst.operands[0].reg;
6740 inst.instruction |= inst.operands[1].reg << 3;
6744 inst.instruction = T_OPCODE_CMP_HR;
6745 inst.instruction |= (inst.operands[0].reg & 0x8) << 4;
6746 inst.instruction |= (inst.operands[0].reg & 0x7);
6747 inst.instruction |= inst.operands[1].reg << 3;
6754 inst.instruction = THUMB_OP16 (inst.instruction);
6755 if (inst.operands[1].isreg)
6757 if (inst.operands[0].reg < 8 && inst.operands[1].reg < 8)
6759 /* A move of two lowregs is encoded as ADD Rd, Rs, #0
6760 since a MOV instruction produces unpredictable results. */
6761 if (inst.instruction == T_OPCODE_MOV_I8)
6762 inst.instruction = T_OPCODE_ADD_I3;
6764 inst.instruction = T_OPCODE_CMP_LR;
6766 inst.instruction |= inst.operands[0].reg;
6767 inst.instruction |= inst.operands[1].reg << 3;
6771 if (inst.instruction == T_OPCODE_MOV_I8)
6772 inst.instruction = T_OPCODE_MOV_HR;
6774 inst.instruction = T_OPCODE_CMP_HR;
6780 constraint (inst.operands[0].reg > 7,
6781 _("only lo regs allowed with immediate"));
6782 inst.instruction |= inst.operands[0].reg << 8;
6783 inst.reloc.type = BFD_RELOC_ARM_THUMB_IMM;
6790 inst.instruction |= inst.operands[0].reg << 8;
6791 inst.instruction |= (inst.operands[1].imm & 0xf000) << 4;
6792 inst.instruction |= (inst.operands[1].imm & 0x0800) << 15;
6793 inst.instruction |= (inst.operands[1].imm & 0x0700) << 4;
6794 inst.instruction |= (inst.operands[1].imm & 0x00ff);
6802 int r0off = (inst.instruction == T_MNEM_mvn
6803 || inst.instruction == T_MNEM_mvns) ? 8 : 16;
6804 if (!inst.operands[1].isreg)
6806 /* For an immediate, we always generate a 32-bit opcode;
6807 section relaxation will shrink it later if possible. */
6808 if (inst.instruction < 0xffff)
6809 inst.instruction = THUMB_OP32 (inst.instruction);
6810 inst.instruction = (inst.instruction & 0xe1ffffff) | 0x10000000;
6811 inst.instruction |= inst.operands[0].reg << r0off;
6812 inst.reloc.type = BFD_RELOC_ARM_T32_IMMEDIATE;
6816 /* See if we can do this with a 16-bit instruction. */
6817 if (inst.instruction < 0xffff
6818 && THUMB_SETS_FLAGS (inst.instruction)
6819 && !inst.operands[1].shifted
6820 && inst.operands[0].reg <= 7
6821 && inst.operands[1].reg <= 7
6822 && inst.size_req != 4)
6824 inst.instruction = THUMB_OP16 (inst.instruction);
6825 inst.instruction |= inst.operands[0].reg;
6826 inst.instruction |= inst.operands[1].reg << 3;
6830 constraint (inst.operands[1].shifted
6831 && inst.operands[1].immisreg,
6832 _("shift must be constant"));
6833 if (inst.instruction < 0xffff)
6834 inst.instruction = THUMB_OP32 (inst.instruction);
6835 inst.instruction |= inst.operands[0].reg << r0off;
6836 encode_thumb32_shifted_operand (1);
6842 constraint (inst.instruction > 0xffff
6843 || inst.instruction == T_MNEM_mvns, BAD_THUMB32);
6844 constraint (!inst.operands[1].isreg || inst.operands[1].shifted,
6845 _("unshifted register required"));
6846 constraint (inst.operands[0].reg > 7 || inst.operands[1].reg > 7,
6849 inst.instruction = THUMB_OP16 (inst.instruction);
6850 inst.instruction |= inst.operands[0].reg;
6851 inst.instruction |= inst.operands[1].reg << 3;
6858 /* mrs only accepts CPSR/SPSR/CPSR_all/SPSR_all. */
6859 constraint ((inst.operands[1].imm & (PSR_c|PSR_x|PSR_s|PSR_f))
6861 _("'CPSR' or 'SPSR' expected"));
6862 inst.instruction |= inst.operands[0].reg << 8;
6863 inst.instruction |= (inst.operands[1].imm & SPSR_BIT) >> 2;
6869 constraint (!inst.operands[1].isreg,
6870 _("Thumb encoding does not support an immediate here"));
6871 inst.instruction |= (inst.operands[0].imm & SPSR_BIT) >> 2;
6872 inst.instruction |= (inst.operands[0].imm & ~SPSR_BIT) >> 8;
6873 inst.instruction |= inst.operands[1].reg << 16;
6879 if (!inst.operands[2].present)
6880 inst.operands[2].reg = inst.operands[0].reg;
6882 /* There is no 32-bit MULS and no 16-bit MUL. */
6883 if (unified_syntax && inst.instruction == T_MNEM_mul)
6885 inst.instruction = THUMB_OP32 (inst.instruction);
6886 inst.instruction |= inst.operands[0].reg << 8;
6887 inst.instruction |= inst.operands[1].reg << 16;
6888 inst.instruction |= inst.operands[2].reg << 0;
6892 constraint (!unified_syntax
6893 && inst.instruction == T_MNEM_muls, BAD_THUMB32);
6894 constraint (inst.operands[0].reg > 7 || inst.operands[1].reg > 7,
6897 inst.instruction = THUMB_OP16 (inst.instruction);
6898 inst.instruction |= inst.operands[0].reg;
6900 if (inst.operands[0].reg == inst.operands[1].reg)
6901 inst.instruction |= inst.operands[2].reg << 3;
6902 else if (inst.operands[0].reg == inst.operands[2].reg)
6903 inst.instruction |= inst.operands[1].reg << 3;
6905 constraint (1, _("dest must overlap one source register"));
6912 inst.instruction |= inst.operands[0].reg << 12;
6913 inst.instruction |= inst.operands[1].reg << 8;
6914 inst.instruction |= inst.operands[2].reg << 16;
6915 inst.instruction |= inst.operands[3].reg;
6917 if (inst.operands[0].reg == inst.operands[1].reg)
6918 as_tsktsk (_("rdhi and rdlo must be different"));
6926 if (inst.size_req == 4 || inst.operands[0].imm > 15)
6928 inst.instruction = THUMB_OP32 (inst.instruction);
6929 inst.instruction |= inst.operands[0].imm;
6933 inst.instruction = THUMB_OP16 (inst.instruction);
6934 inst.instruction |= inst.operands[0].imm << 4;
6939 constraint (inst.operands[0].present,
6940 _("Thumb does not support NOP with hints"));
6941 inst.instruction = 0x46c0;
6950 if (inst.operands[0].reg > 7 || inst.operands[1].reg > 7
6951 || !THUMB_SETS_FLAGS (inst.instruction)
6952 || inst.size_req == 4)
6954 inst.instruction = THUMB_OP32 (inst.instruction);
6955 inst.instruction |= inst.operands[0].reg << 8;
6956 inst.instruction |= inst.operands[1].reg << 16;
6960 inst.instruction = THUMB_OP16 (inst.instruction);
6961 inst.instruction |= inst.operands[0].reg;
6962 inst.instruction |= inst.operands[1].reg << 3;
6967 constraint (inst.operands[0].reg > 7 || inst.operands[1].reg > 7,
6969 constraint (THUMB_SETS_FLAGS (inst.instruction), BAD_THUMB32);
6971 inst.instruction = THUMB_OP16 (inst.instruction);
6972 inst.instruction |= inst.operands[0].reg;
6973 inst.instruction |= inst.operands[1].reg << 3;
6980 inst.instruction |= inst.operands[0].reg << 8;
6981 inst.instruction |= inst.operands[1].reg << 16;
6982 inst.instruction |= inst.operands[2].reg;
6983 if (inst.operands[3].present)
6985 unsigned int val = inst.reloc.exp.X_add_number;
6986 constraint (inst.reloc.exp.X_op != O_constant,
6987 _("expression too complex"));
6988 inst.instruction |= (val & 0x1c) << 10;
6989 inst.instruction |= (val & 0x03) << 6;
6996 if (!inst.operands[3].present)
6997 inst.instruction &= ~0x00000020;
7004 encode_thumb32_addr_mode (0, /*is_t=*/FALSE, /*is_d=*/FALSE);
7008 do_t_push_pop (void)
7012 constraint (inst.operands[0].writeback,
7013 _("push/pop do not support {reglist}^"));
7014 constraint (inst.reloc.type != BFD_RELOC_UNUSED,
7015 _("expression too complex"));
7017 mask = inst.operands[0].imm;
7018 if ((mask & ~0xff) == 0)
7019 inst.instruction = THUMB_OP16 (inst.instruction);
7020 else if ((inst.instruction == T_MNEM_push
7021 && (mask & ~0xff) == 1 << REG_LR)
7022 || (inst.instruction == T_MNEM_pop
7023 && (mask & ~0xff) == 1 << REG_PC))
7025 inst.instruction = THUMB_OP16 (inst.instruction);
7026 inst.instruction |= THUMB_PP_PC_LR;
7029 else if (unified_syntax)
7031 if (mask & (1 << 13))
7032 inst.error = _("SP not allowed in register list");
7033 if (inst.instruction == T_MNEM_push)
7035 if (mask & (1 << 15))
7036 inst.error = _("PC not allowed in register list");
7040 if (mask & (1 << 14)
7041 && mask & (1 << 15))
7042 inst.error = _("LR and PC should not both be in register list");
7044 if ((mask & (mask - 1)) == 0)
7046 /* Single register push/pop implemented as str/ldr. */
7047 if (inst.instruction == T_MNEM_push)
7048 inst.instruction = 0xf84d0d04; /* str reg, [sp, #-4]! */
7050 inst.instruction = 0xf85d0b04; /* ldr reg, [sp], #4 */
7051 mask = ffs(mask) - 1;
7055 inst.instruction = THUMB_OP32 (inst.instruction);
7059 inst.error = _("invalid register list to push/pop instruction");
7063 inst.instruction |= mask;
7069 inst.instruction |= inst.operands[0].reg << 8;
7070 inst.instruction |= inst.operands[1].reg << 16;
7076 if (inst.operands[0].reg <= 7 && inst.operands[1].reg <= 7
7077 && inst.size_req != 4)
7079 inst.instruction = THUMB_OP16 (inst.instruction);
7080 inst.instruction |= inst.operands[0].reg;
7081 inst.instruction |= inst.operands[1].reg << 3;
7083 else if (unified_syntax)
7085 inst.instruction = THUMB_OP32 (inst.instruction);
7086 inst.instruction |= inst.operands[0].reg << 8;
7087 inst.instruction |= inst.operands[1].reg << 16;
7088 inst.instruction |= inst.operands[1].reg;
7091 inst.error = BAD_HIREG;
7099 Rd = inst.operands[0].reg;
7100 Rs = (inst.operands[1].present
7101 ? inst.operands[1].reg /* Rd, Rs, foo */
7102 : inst.operands[0].reg); /* Rd, foo -> Rd, Rd, foo */
7104 inst.instruction |= Rd << 8;
7105 inst.instruction |= Rs << 16;
7106 if (!inst.operands[2].isreg)
7108 inst.instruction = (inst.instruction & 0xe1ffffff) | 0x10000000;
7109 inst.reloc.type = BFD_RELOC_ARM_T32_IMMEDIATE;
7112 encode_thumb32_shifted_operand (2);
7118 if (inst.operands[0].imm)
7119 inst.instruction |= 0x8;
7125 if (!inst.operands[1].present)
7126 inst.operands[1].reg = inst.operands[0].reg;
7130 if (inst.operands[0].reg > 7
7131 || inst.operands[1].reg > 7
7132 || !THUMB_SETS_FLAGS (inst.instruction)
7133 || (!inst.operands[2].isreg && inst.instruction == T_MNEM_rors)
7134 || (inst.operands[2].isreg && inst.operands[1].reg != inst.operands[0].reg)
7135 || inst.size_req == 4)
7137 if (inst.operands[2].isreg)
7139 inst.instruction = THUMB_OP32 (inst.instruction);
7140 inst.instruction |= inst.operands[0].reg << 8;
7141 inst.instruction |= inst.operands[1].reg << 16;
7142 inst.instruction |= inst.operands[2].reg;
7146 inst.operands[1].shifted = 1;
7147 switch (inst.instruction)
7150 case T_MNEM_asrs: inst.operands[1].shift_kind = SHIFT_ASR; break;
7152 case T_MNEM_lsls: inst.operands[1].shift_kind = SHIFT_LSL; break;
7154 case T_MNEM_lsrs: inst.operands[1].shift_kind = SHIFT_LSR; break;
7156 case T_MNEM_rors: inst.operands[1].shift_kind = SHIFT_ROR; break;
7160 inst.instruction = THUMB_OP32 (THUMB_SETS_FLAGS (inst.instruction)
7161 ? T_MNEM_movs : T_MNEM_mov);
7162 inst.instruction |= inst.operands[0].reg << 8;
7163 encode_thumb32_shifted_operand (1);
7164 /* Prevent the incorrect generation of an ARM_IMMEDIATE fixup. */
7165 inst.reloc.type = BFD_RELOC_UNUSED;
7170 if (inst.operands[2].isreg)
7172 switch (inst.instruction)
7174 case T_MNEM_asrs: inst.instruction = T_OPCODE_ASR_R; break;
7175 case T_MNEM_lsls: inst.instruction = T_OPCODE_LSL_R; break;
7176 case T_MNEM_lsrs: inst.instruction = T_OPCODE_LSR_R; break;
7177 case T_MNEM_rors: inst.instruction = T_OPCODE_ROR_R; break;
7181 inst.instruction |= inst.operands[0].reg;
7182 inst.instruction |= inst.operands[2].reg << 3;
7186 switch (inst.instruction)
7188 case T_MNEM_asrs: inst.instruction = T_OPCODE_ASR_I; break;
7189 case T_MNEM_lsls: inst.instruction = T_OPCODE_LSL_I; break;
7190 case T_MNEM_lsrs: inst.instruction = T_OPCODE_LSR_I; break;
7193 inst.reloc.type = BFD_RELOC_ARM_THUMB_SHIFT;
7194 inst.instruction |= inst.operands[0].reg;
7195 inst.instruction |= inst.operands[1].reg << 3;
7201 constraint (inst.operands[0].reg > 7
7202 || inst.operands[1].reg > 7, BAD_HIREG);
7203 constraint (THUMB_SETS_FLAGS (inst.instruction), BAD_THUMB32);
7205 if (inst.operands[2].isreg) /* Rd, {Rs,} Rn */
7207 constraint (inst.operands[2].reg > 7, BAD_HIREG);
7208 constraint (inst.operands[0].reg != inst.operands[1].reg,
7209 _("source1 and dest must be same register"));
7211 switch (inst.instruction)
7213 case T_MNEM_asr: inst.instruction = T_OPCODE_ASR_R; break;
7214 case T_MNEM_lsl: inst.instruction = T_OPCODE_LSL_R; break;
7215 case T_MNEM_lsr: inst.instruction = T_OPCODE_LSR_R; break;
7216 case T_MNEM_ror: inst.instruction = T_OPCODE_ROR_R; break;
7220 inst.instruction |= inst.operands[0].reg;
7221 inst.instruction |= inst.operands[2].reg << 3;
7225 switch (inst.instruction)
7227 case T_MNEM_asr: inst.instruction = T_OPCODE_ASR_I; break;
7228 case T_MNEM_lsl: inst.instruction = T_OPCODE_LSL_I; break;
7229 case T_MNEM_lsr: inst.instruction = T_OPCODE_LSR_I; break;
7230 case T_MNEM_ror: inst.error = _("ror #imm not supported"); return;
7233 inst.reloc.type = BFD_RELOC_ARM_THUMB_SHIFT;
7234 inst.instruction |= inst.operands[0].reg;
7235 inst.instruction |= inst.operands[1].reg << 3;
7243 inst.instruction |= inst.operands[0].reg << 8;
7244 inst.instruction |= inst.operands[1].reg << 16;
7245 inst.instruction |= inst.operands[2].reg;
7251 unsigned int value = inst.reloc.exp.X_add_number;
7252 constraint (inst.reloc.exp.X_op != O_constant,
7253 _("expression too complex"));
7254 inst.reloc.type = BFD_RELOC_UNUSED;
7255 inst.instruction |= (value & 0xf000) >> 12;
7256 inst.instruction |= (value & 0x0ff0);
7257 inst.instruction |= (value & 0x000f) << 16;
7263 inst.instruction |= inst.operands[0].reg << 8;
7264 inst.instruction |= inst.operands[1].imm - 1;
7265 inst.instruction |= inst.operands[2].reg << 16;
7267 if (inst.operands[3].present)
7269 constraint (inst.reloc.exp.X_op != O_constant,
7270 _("expression too complex"));
7272 if (inst.reloc.exp.X_add_number != 0)
7274 if (inst.operands[3].shift_kind == SHIFT_ASR)
7275 inst.instruction |= 0x00200000; /* sh bit */
7276 inst.instruction |= (inst.reloc.exp.X_add_number & 0x1c) << 10;
7277 inst.instruction |= (inst.reloc.exp.X_add_number & 0x03) << 6;
7279 inst.reloc.type = BFD_RELOC_UNUSED;
7286 inst.instruction |= inst.operands[0].reg << 8;
7287 inst.instruction |= inst.operands[1].imm - 1;
7288 inst.instruction |= inst.operands[2].reg << 16;
7294 constraint (!inst.operands[2].isreg || !inst.operands[2].preind
7295 || inst.operands[2].postind || inst.operands[2].writeback
7296 || inst.operands[2].immisreg || inst.operands[2].shifted
7297 || inst.operands[2].negative,
7298 _("instruction does not accept this addressing mode"));
7300 inst.instruction |= inst.operands[0].reg << 8;
7301 inst.instruction |= inst.operands[1].reg << 12;
7302 inst.instruction |= inst.operands[2].reg << 16;
7303 inst.reloc.type = BFD_RELOC_ARM_T32_OFFSET_U8;
7309 if (!inst.operands[2].present)
7310 inst.operands[2].reg = inst.operands[1].reg + 1;
7312 constraint (inst.operands[0].reg == inst.operands[1].reg
7313 || inst.operands[0].reg == inst.operands[2].reg
7314 || inst.operands[0].reg == inst.operands[3].reg
7315 || inst.operands[1].reg == inst.operands[2].reg,
7318 inst.instruction |= inst.operands[0].reg;
7319 inst.instruction |= inst.operands[1].reg << 12;
7320 inst.instruction |= inst.operands[2].reg << 8;
7321 inst.instruction |= inst.operands[3].reg << 16;
7327 inst.instruction |= inst.operands[0].reg << 8;
7328 inst.instruction |= inst.operands[1].reg << 16;
7329 inst.instruction |= inst.operands[2].reg;
7330 inst.instruction |= inst.operands[3].imm << 4;
7336 if (inst.instruction <= 0xffff && inst.size_req != 4
7337 && inst.operands[0].reg <= 7 && inst.operands[1].reg <= 7
7338 && (!inst.operands[2].present || inst.operands[2].imm == 0))
7340 inst.instruction = THUMB_OP16 (inst.instruction);
7341 inst.instruction |= inst.operands[0].reg;
7342 inst.instruction |= inst.operands[1].reg << 3;
7344 else if (unified_syntax)
7346 if (inst.instruction <= 0xffff)
7347 inst.instruction = THUMB_OP32 (inst.instruction);
7348 inst.instruction |= inst.operands[0].reg << 8;
7349 inst.instruction |= inst.operands[1].reg;
7350 inst.instruction |= inst.operands[2].imm << 4;
7354 constraint (inst.operands[2].present && inst.operands[2].imm != 0,
7355 _("Thumb encoding does not support rotation"));
7356 constraint (1, BAD_HIREG);
7363 inst.reloc.type = BFD_RELOC_ARM_SWI;
7371 half = (inst.instruction & 0x10) != 0;
7372 constraint (inst.operands[0].imm == 15,
7373 _("PC is not a valid index register"));
7374 constraint (!half && inst.operands[0].shifted,
7375 _("instruction does not allow shifted index"));
7376 constraint (half && !inst.operands[0].shifted,
7377 _("instruction requires shifted index"));
7378 inst.instruction |= (inst.operands[0].reg << 16) | inst.operands[0].imm;
7384 inst.instruction |= inst.operands[0].reg << 8;
7385 inst.instruction |= inst.operands[1].imm;
7386 inst.instruction |= inst.operands[2].reg << 16;
7388 if (inst.operands[3].present)
7390 constraint (inst.reloc.exp.X_op != O_constant,
7391 _("expression too complex"));
7392 if (inst.reloc.exp.X_add_number != 0)
7394 if (inst.operands[3].shift_kind == SHIFT_ASR)
7395 inst.instruction |= 0x00200000; /* sh bit */
7397 inst.instruction |= (inst.reloc.exp.X_add_number & 0x1c) << 10;
7398 inst.instruction |= (inst.reloc.exp.X_add_number & 0x03) << 6;
7400 inst.reloc.type = BFD_RELOC_UNUSED;
7407 inst.instruction |= inst.operands[0].reg << 8;
7408 inst.instruction |= inst.operands[1].imm;
7409 inst.instruction |= inst.operands[2].reg << 16;
7412 /* Overall per-instruction processing. */
7414 /* We need to be able to fix up arbitrary expressions in some statements.
7415 This is so that we can handle symbols that are an arbitrary distance from
7416 the pc. The most common cases are of the form ((+/-sym -/+ . - 8) & mask),
7417 which returns part of an address in a form which will be valid for
7418 a data instruction. We do this by pushing the expression into a symbol
7419 in the expr_section, and creating a fix for that. */
7422 fix_new_arm (fragS * frag,
7437 new_fix = fix_new_exp (frag, where, size, exp, pc_rel, reloc);
7441 new_fix = fix_new (frag, where, size, make_expr_symbol (exp), 0,
7446 /* Mark whether the fix is to a THUMB instruction, or an ARM
7448 new_fix->tc_fix_data = thumb_mode;
7452 output_inst (const char * str)
7458 as_bad ("%s -- `%s'", inst.error, str);
7464 to = frag_more (inst.size);
7466 if (thumb_mode && (inst.size > THUMB_SIZE))
7468 assert (inst.size == (2 * THUMB_SIZE));
7469 md_number_to_chars (to, inst.instruction >> 16, THUMB_SIZE);
7470 md_number_to_chars (to + THUMB_SIZE, inst.instruction, THUMB_SIZE);
7472 else if (inst.size > INSN_SIZE)
7474 assert (inst.size == (2 * INSN_SIZE));
7475 md_number_to_chars (to, inst.instruction, INSN_SIZE);
7476 md_number_to_chars (to + INSN_SIZE, inst.instruction, INSN_SIZE);
7479 md_number_to_chars (to, inst.instruction, inst.size);
7481 if (inst.reloc.type != BFD_RELOC_UNUSED)
7482 fix_new_arm (frag_now, to - frag_now->fr_literal,
7483 inst.size, & inst.reloc.exp, inst.reloc.pc_rel,
7487 dwarf2_emit_insn (inst.size);
7491 /* Tag values used in struct asm_opcode's tag field. */
7494 OT_unconditional, /* Instruction cannot be conditionalized.
7495 The ARM condition field is still 0xE. */
7496 OT_unconditionalF, /* Instruction cannot be conditionalized
7497 and carries 0xF in its ARM condition field. */
7498 OT_csuffix, /* Instruction takes a conditional suffix. */
7499 OT_cinfix3, /* Instruction takes a conditional infix,
7500 beginning at character index 3. (In
7501 unified mode, it becomes a suffix.) */
7502 OT_csuf_or_in3, /* Instruction takes either a conditional
7503 suffix or an infix at character index 3.
7504 (In unified mode, a suffix only. */
7505 OT_odd_infix_unc, /* This is the unconditional variant of an
7506 instruction that takes a conditional infix
7507 at an unusual position. In unified mode,
7508 this variant will accept a suffix. */
7509 OT_odd_infix_0 /* Values greater than or equal to OT_odd_infix_0
7510 are the conditional variants of instructions that
7511 take conditional infixes in unusual positions.
7512 The infix appears at character index
7513 (tag - OT_odd_infix_0). These are not accepted
7517 /* Subroutine of md_assemble, responsible for looking up the primary
7518 opcode from the mnemonic the user wrote. STR points to the
7519 beginning of the mnemonic.
7521 This is not simply a hash table lookup, because of conditional
7522 variants. Most instructions have conditional variants, which are
7523 expressed with a _conditional affix_ to the mnemonic. If we were
7524 to encode each conditional variant as a literal string in the opcode
7525 table, it would have approximately 20,000 entries.
7527 Most mnemonics take this affix as a suffix, and in unified syntax,
7528 'most' is upgraded to 'all'. However, in the divided syntax, some
7529 instructions take the affix as an infix, notably the s-variants of
7530 the arithmetic instructions. Of those instructions, all but six
7531 have the infix appear after the third character of the mnemonic.
7533 Accordingly, the algorithm for looking up primary opcodes given
7536 1. Look up the identifier in the opcode table.
7537 If we find a match, go to step U.
7539 2. Look up the last two characters of the identifier in the
7540 conditions table. If we find a match, look up the first N-2
7541 characters of the identifier in the opcode table. If we
7542 find a match, go to step CE.
7544 3. Look up the fourth and fifth characters of the identifier in
7545 the conditions table. If we find a match, extract those
7546 characters from the identifier, and look up the remaining
7547 characters in the opcode table. If we find a match, go
7552 U. Examine the tag field of the opcode structure, in case this is
7553 one of the six instructions with its conditional infix in an
7554 unusual place. If it is, the tag tells us where to find the
7555 infix; look it up in the conditions table and set inst.cond
7556 accordingly. Otherwise, this is an unconditional instruction.
7557 Again set inst.cond accordingly. Return the opcode structure.
7559 CE. Examine the tag field to make sure this is an instruction that
7560 should receive a conditional suffix. If it is not, fail.
7561 Otherwise, set inst.cond from the suffix we already looked up,
7562 and return the opcode structure.
7564 CM. Examine the tag field to make sure this is an instruction that
7565 should receive a conditional infix after the third character.
7566 If it is not, fail. Otherwise, undo the edits to the current
7567 line of input and proceed as for case CE. */
7569 static const struct asm_opcode *
7570 opcode_lookup (char **str)
7574 const struct asm_opcode *opcode;
7575 const struct asm_cond *cond;
7577 /* Scan up to the end of the mnemonic, which must end in white space,
7578 '.' (in unified mode only), or end of string. */
7579 for (base = end = *str; *end != '\0'; end++)
7580 if (*end == ' ' || (unified_syntax && *end == '.'))
7586 /* Handle a possible width suffix. */
7589 if (end[1] == 'w' && (end[2] == ' ' || end[2] == '\0'))
7591 else if (end[1] == 'n' && (end[2] == ' ' || end[2] == '\0'))
7601 /* Look for unaffixed or special-case affixed mnemonic. */
7602 opcode = hash_find_n (arm_ops_hsh, base, end - base);
7606 if (opcode->tag < OT_odd_infix_0)
7608 inst.cond = COND_ALWAYS;
7613 as_warn (_("conditional infixes are deprecated in unified syntax"));
7614 affix = base + (opcode->tag - OT_odd_infix_0);
7615 cond = hash_find_n (arm_cond_hsh, affix, 2);
7618 inst.cond = cond->value;
7622 /* Cannot have a conditional suffix on a mnemonic of less than two
7627 /* Look for suffixed mnemonic. */
7629 cond = hash_find_n (arm_cond_hsh, affix, 2);
7630 opcode = hash_find_n (arm_ops_hsh, base, affix - base);
7634 switch (opcode->tag)
7637 case OT_odd_infix_unc:
7638 if (!unified_syntax)
7640 /* else fall through */
7643 case OT_csuf_or_in3:
7644 inst.cond = cond->value;
7647 case OT_unconditional:
7648 case OT_unconditionalF:
7649 /* delayed diagnostic */
7650 inst.error = BAD_COND;
7651 inst.cond = COND_ALWAYS;
7659 /* Cannot have a usual-position infix on a mnemonic of less than
7660 six characters (five would be a suffix). */
7664 /* Look for infixed mnemonic in the usual position. */
7666 cond = hash_find_n (arm_cond_hsh, affix, 2);
7670 memcpy (save, affix, 2);
7671 memmove (affix, affix + 2, (end - affix) - 2);
7672 opcode = hash_find_n (arm_ops_hsh, base, (end - base) - 2);
7673 memmove (affix + 2, affix, (end - affix) - 2);
7674 memcpy (affix, save, 2);
7676 if (opcode && (opcode->tag == OT_cinfix3 || opcode->tag == OT_csuf_or_in3))
7680 as_warn (_("conditional infixes are deprecated in unified syntax"));
7682 inst.cond = cond->value;
7690 md_assemble (char *str)
7693 const struct asm_opcode * opcode;
7695 /* Align the previous label if needed. */
7696 if (last_label_seen != NULL)
7698 symbol_set_frag (last_label_seen, frag_now);
7699 S_SET_VALUE (last_label_seen, (valueT) frag_now_fix ());
7700 S_SET_SEGMENT (last_label_seen, now_seg);
7703 memset (&inst, '\0', sizeof (inst));
7704 inst.reloc.type = BFD_RELOC_UNUSED;
7706 opcode = opcode_lookup (&p);
7709 /* It wasn't an instruction, but it might be a register alias of
7710 the form alias .req reg. */
7711 if (!create_register_alias (str, p))
7712 as_bad (_("bad instruction `%s'"), str);
7719 /* Check that this instruction is supported for this CPU. */
7720 if (thumb_mode == 1 && (opcode->tvariant & cpu_variant) == 0)
7722 as_bad (_("selected processor does not support `%s'"), str);
7725 if (inst.cond != COND_ALWAYS && !unified_syntax
7726 && opcode->tencode != do_t_branch)
7728 as_bad (_("Thumb does not support conditional execution"));
7732 /* Check conditional suffixes. */
7733 if (current_it_mask)
7736 cond = current_cc ^ ((current_it_mask >> 4) & 1) ^ 1;
7737 if (cond != inst.cond)
7739 as_bad (_("incorrect condition in IT block"));
7742 current_it_mask <<= 1;
7743 current_it_mask &= 0x1f;
7745 else if (inst.cond != COND_ALWAYS && opcode->tencode != do_t_branch)
7747 as_bad (_("thumb conditional instrunction not in IT block"));
7751 mapping_state (MAP_THUMB);
7752 inst.instruction = opcode->tvalue;
7754 if (!parse_operands (p, opcode->operands))
7757 /* Clear current_it_mask at the end of an IT block. */
7758 if (current_it_mask == 0x10)
7759 current_it_mask = 0;
7763 assert (inst.instruction < 0xe800 || inst.instruction > 0xffff);
7764 inst.size = (inst.instruction > 0xffff ? 4 : 2);
7765 if (inst.size_req && inst.size_req != inst.size)
7767 as_bad (_("cannot honor width suffix -- `%s'"), str);
7774 /* Check that this instruction is supported for this CPU. */
7775 if ((opcode->avariant & cpu_variant) == 0)
7777 as_bad (_("selected processor does not support `%s'"), str);
7782 as_bad (_("width suffixes are invalid in ARM mode -- `%s'"), str);
7786 mapping_state (MAP_ARM);
7787 inst.instruction = opcode->avalue;
7788 if (opcode->tag == OT_unconditionalF)
7789 inst.instruction |= 0xF << 28;
7791 inst.instruction |= inst.cond << 28;
7792 inst.size = INSN_SIZE;
7793 if (!parse_operands (p, opcode->operands))
7799 /* Various frobbings of labels and their addresses. */
7802 arm_start_line_hook (void)
7804 last_label_seen = NULL;
7808 arm_frob_label (symbolS * sym)
7810 last_label_seen = sym;
7812 ARM_SET_THUMB (sym, thumb_mode);
7814 #if defined OBJ_COFF || defined OBJ_ELF
7815 ARM_SET_INTERWORK (sym, support_interwork);
7818 /* Note - do not allow local symbols (.Lxxx) to be labeled
7819 as Thumb functions. This is because these labels, whilst
7820 they exist inside Thumb code, are not the entry points for
7821 possible ARM->Thumb calls. Also, these labels can be used
7822 as part of a computed goto or switch statement. eg gcc
7823 can generate code that looks like this:
7835 The first instruction loads the address of the jump table.
7836 The second instruction converts a table index into a byte offset.
7837 The third instruction gets the jump address out of the table.
7838 The fourth instruction performs the jump.
7840 If the address stored at .Laaa is that of a symbol which has the
7841 Thumb_Func bit set, then the linker will arrange for this address
7842 to have the bottom bit set, which in turn would mean that the
7843 address computation performed by the third instruction would end
7844 up with the bottom bit set. Since the ARM is capable of unaligned
7845 word loads, the instruction would then load the incorrect address
7846 out of the jump table, and chaos would ensue. */
7847 if (label_is_thumb_function_name
7848 && (S_GET_NAME (sym)[0] != '.' || S_GET_NAME (sym)[1] != 'L')
7849 && (bfd_get_section_flags (stdoutput, now_seg) & SEC_CODE) != 0)
7851 /* When the address of a Thumb function is taken the bottom
7852 bit of that address should be set. This will allow
7853 interworking between Arm and Thumb functions to work
7856 THUMB_SET_FUNC (sym, 1);
7858 label_is_thumb_function_name = FALSE;
7863 arm_data_in_code (void)
7865 if (thumb_mode && ! strncmp (input_line_pointer + 1, "data:", 5))
7867 *input_line_pointer = '/';
7868 input_line_pointer += 5;
7869 *input_line_pointer = 0;
7877 arm_canonicalize_symbol_name (char * name)
7881 if (thumb_mode && (len = strlen (name)) > 5
7882 && streq (name + len - 5, "/data"))
7883 *(name + len - 5) = 0;
7888 /* Table of all register names defined by default. The user can
7889 define additional names with .req. Note that all register names
7890 should appear in both upper and lowercase variants. Some registers
7891 also have mixed-case names. */
7893 #define REGDEF(s,n,t) { #s, n, REG_TYPE_##t, TRUE }
7894 #define REGNUM(p,n,t) REGDEF(p##n, n, t)
7895 #define REGSET(p,t) \
7896 REGNUM(p, 0,t), REGNUM(p, 1,t), REGNUM(p, 2,t), REGNUM(p, 3,t), \
7897 REGNUM(p, 4,t), REGNUM(p, 5,t), REGNUM(p, 6,t), REGNUM(p, 7,t), \
7898 REGNUM(p, 8,t), REGNUM(p, 9,t), REGNUM(p,10,t), REGNUM(p,11,t), \
7899 REGNUM(p,12,t), REGNUM(p,13,t), REGNUM(p,14,t), REGNUM(p,15,t)
7901 static const struct reg_entry reg_names[] =
7903 /* ARM integer registers. */
7904 REGSET(r, RN), REGSET(R, RN),
7906 /* ATPCS synonyms. */
7907 REGDEF(a1,0,RN), REGDEF(a2,1,RN), REGDEF(a3, 2,RN), REGDEF(a4, 3,RN),
7908 REGDEF(v1,4,RN), REGDEF(v2,5,RN), REGDEF(v3, 6,RN), REGDEF(v4, 7,RN),
7909 REGDEF(v5,8,RN), REGDEF(v6,9,RN), REGDEF(v7,10,RN), REGDEF(v8,11,RN),
7911 REGDEF(A1,0,RN), REGDEF(A2,1,RN), REGDEF(A3, 2,RN), REGDEF(A4, 3,RN),
7912 REGDEF(V1,4,RN), REGDEF(V2,5,RN), REGDEF(V3, 6,RN), REGDEF(V4, 7,RN),
7913 REGDEF(V5,8,RN), REGDEF(V6,9,RN), REGDEF(V7,10,RN), REGDEF(V8,11,RN),
7915 /* Well-known aliases. */
7916 REGDEF(wr, 7,RN), REGDEF(sb, 9,RN), REGDEF(sl,10,RN), REGDEF(fp,11,RN),
7917 REGDEF(ip,12,RN), REGDEF(sp,13,RN), REGDEF(lr,14,RN), REGDEF(pc,15,RN),
7919 REGDEF(WR, 7,RN), REGDEF(SB, 9,RN), REGDEF(SL,10,RN), REGDEF(FP,11,RN),
7920 REGDEF(IP,12,RN), REGDEF(SP,13,RN), REGDEF(LR,14,RN), REGDEF(PC,15,RN),
7922 /* Coprocessor numbers. */
7923 REGSET(p, CP), REGSET(P, CP),
7925 /* Coprocessor register numbers. The "cr" variants are for backward
7927 REGSET(c, CN), REGSET(C, CN),
7928 REGSET(cr, CN), REGSET(CR, CN),
7930 /* FPA registers. */
7931 REGNUM(f,0,FN), REGNUM(f,1,FN), REGNUM(f,2,FN), REGNUM(f,3,FN),
7932 REGNUM(f,4,FN), REGNUM(f,5,FN), REGNUM(f,6,FN), REGNUM(f,7, FN),
7934 REGNUM(F,0,FN), REGNUM(F,1,FN), REGNUM(F,2,FN), REGNUM(F,3,FN),
7935 REGNUM(F,4,FN), REGNUM(F,5,FN), REGNUM(F,6,FN), REGNUM(F,7, FN),
7937 /* VFP SP registers. */
7939 REGNUM(s,16,VFS), REGNUM(s,17,VFS), REGNUM(s,18,VFS), REGNUM(s,19,VFS),
7940 REGNUM(s,20,VFS), REGNUM(s,21,VFS), REGNUM(s,22,VFS), REGNUM(s,23,VFS),
7941 REGNUM(s,24,VFS), REGNUM(s,25,VFS), REGNUM(s,26,VFS), REGNUM(s,27,VFS),
7942 REGNUM(s,28,VFS), REGNUM(s,29,VFS), REGNUM(s,30,VFS), REGNUM(s,31,VFS),
7945 REGNUM(S,16,VFS), REGNUM(S,17,VFS), REGNUM(S,18,VFS), REGNUM(S,19,VFS),
7946 REGNUM(S,20,VFS), REGNUM(S,21,VFS), REGNUM(S,22,VFS), REGNUM(S,23,VFS),
7947 REGNUM(S,24,VFS), REGNUM(S,25,VFS), REGNUM(S,26,VFS), REGNUM(S,27,VFS),
7948 REGNUM(S,28,VFS), REGNUM(S,29,VFS), REGNUM(S,30,VFS), REGNUM(S,31,VFS),
7950 /* VFP DP Registers. */
7951 REGSET(d,VFD), REGSET(D,VFS),
7953 /* VFP control registers. */
7954 REGDEF(fpsid,0,VFC), REGDEF(fpscr,1,VFC), REGDEF(fpexc,8,VFC),
7955 REGDEF(FPSID,0,VFC), REGDEF(FPSCR,1,VFC), REGDEF(FPEXC,8,VFC),
7957 /* Maverick DSP coprocessor registers. */
7958 REGSET(mvf,MVF), REGSET(mvd,MVD), REGSET(mvfx,MVFX), REGSET(mvdx,MVDX),
7959 REGSET(MVF,MVF), REGSET(MVD,MVD), REGSET(MVFX,MVFX), REGSET(MVDX,MVDX),
7961 REGNUM(mvax,0,MVAX), REGNUM(mvax,1,MVAX),
7962 REGNUM(mvax,2,MVAX), REGNUM(mvax,3,MVAX),
7963 REGDEF(dspsc,0,DSPSC),
7965 REGNUM(MVAX,0,MVAX), REGNUM(MVAX,1,MVAX),
7966 REGNUM(MVAX,2,MVAX), REGNUM(MVAX,3,MVAX),
7967 REGDEF(DSPSC,0,DSPSC),
7969 /* iWMMXt data registers - p0, c0-15. */
7970 REGSET(wr,MMXWR), REGSET(wR,MMXWR), REGSET(WR, MMXWR),
7972 /* iWMMXt control registers - p1, c0-3. */
7973 REGDEF(wcid, 0,MMXWC), REGDEF(wCID, 0,MMXWC), REGDEF(WCID, 0,MMXWC),
7974 REGDEF(wcon, 1,MMXWC), REGDEF(wCon, 1,MMXWC), REGDEF(WCON, 1,MMXWC),
7975 REGDEF(wcssf, 2,MMXWC), REGDEF(wCSSF, 2,MMXWC), REGDEF(WCSSF, 2,MMXWC),
7976 REGDEF(wcasf, 3,MMXWC), REGDEF(wCASF, 3,MMXWC), REGDEF(WCASF, 3,MMXWC),
7978 /* iWMMXt scalar (constant/offset) registers - p1, c8-11. */
7979 REGDEF(wcgr0, 8,MMXWCG), REGDEF(wCGR0, 8,MMXWCG), REGDEF(WCGR0, 8,MMXWCG),
7980 REGDEF(wcgr1, 9,MMXWCG), REGDEF(wCGR1, 9,MMXWCG), REGDEF(WCGR1, 9,MMXWCG),
7981 REGDEF(wcgr2,10,MMXWCG), REGDEF(wCGR2,10,MMXWCG), REGDEF(WCGR2,10,MMXWCG),
7982 REGDEF(wcgr3,11,MMXWCG), REGDEF(wCGR3,11,MMXWCG), REGDEF(WCGR3,11,MMXWCG),
7984 /* XScale accumulator registers. */
7985 REGNUM(acc,0,XSCALE), REGNUM(ACC,0,XSCALE),
7991 /* Table of all PSR suffixes. Bare "CPSR" and "SPSR" are handled
7992 within psr_required_here. */
7993 static const struct asm_psr psrs[] =
7995 /* Backward compatibility notation. Note that "all" is no longer
7996 truly all possible PSR bits. */
7997 {"all", PSR_c | PSR_f},
8001 /* Individual flags. */
8006 /* Combinations of flags. */
8007 {"fs", PSR_f | PSR_s},
8008 {"fx", PSR_f | PSR_x},
8009 {"fc", PSR_f | PSR_c},
8010 {"sf", PSR_s | PSR_f},
8011 {"sx", PSR_s | PSR_x},
8012 {"sc", PSR_s | PSR_c},
8013 {"xf", PSR_x | PSR_f},
8014 {"xs", PSR_x | PSR_s},
8015 {"xc", PSR_x | PSR_c},
8016 {"cf", PSR_c | PSR_f},
8017 {"cs", PSR_c | PSR_s},
8018 {"cx", PSR_c | PSR_x},
8019 {"fsx", PSR_f | PSR_s | PSR_x},
8020 {"fsc", PSR_f | PSR_s | PSR_c},
8021 {"fxs", PSR_f | PSR_x | PSR_s},
8022 {"fxc", PSR_f | PSR_x | PSR_c},
8023 {"fcs", PSR_f | PSR_c | PSR_s},
8024 {"fcx", PSR_f | PSR_c | PSR_x},
8025 {"sfx", PSR_s | PSR_f | PSR_x},
8026 {"sfc", PSR_s | PSR_f | PSR_c},
8027 {"sxf", PSR_s | PSR_x | PSR_f},
8028 {"sxc", PSR_s | PSR_x | PSR_c},
8029 {"scf", PSR_s | PSR_c | PSR_f},
8030 {"scx", PSR_s | PSR_c | PSR_x},
8031 {"xfs", PSR_x | PSR_f | PSR_s},
8032 {"xfc", PSR_x | PSR_f | PSR_c},
8033 {"xsf", PSR_x | PSR_s | PSR_f},
8034 {"xsc", PSR_x | PSR_s | PSR_c},
8035 {"xcf", PSR_x | PSR_c | PSR_f},
8036 {"xcs", PSR_x | PSR_c | PSR_s},
8037 {"cfs", PSR_c | PSR_f | PSR_s},
8038 {"cfx", PSR_c | PSR_f | PSR_x},
8039 {"csf", PSR_c | PSR_s | PSR_f},
8040 {"csx", PSR_c | PSR_s | PSR_x},
8041 {"cxf", PSR_c | PSR_x | PSR_f},
8042 {"cxs", PSR_c | PSR_x | PSR_s},
8043 {"fsxc", PSR_f | PSR_s | PSR_x | PSR_c},
8044 {"fscx", PSR_f | PSR_s | PSR_c | PSR_x},
8045 {"fxsc", PSR_f | PSR_x | PSR_s | PSR_c},
8046 {"fxcs", PSR_f | PSR_x | PSR_c | PSR_s},
8047 {"fcsx", PSR_f | PSR_c | PSR_s | PSR_x},
8048 {"fcxs", PSR_f | PSR_c | PSR_x | PSR_s},
8049 {"sfxc", PSR_s | PSR_f | PSR_x | PSR_c},
8050 {"sfcx", PSR_s | PSR_f | PSR_c | PSR_x},
8051 {"sxfc", PSR_s | PSR_x | PSR_f | PSR_c},
8052 {"sxcf", PSR_s | PSR_x | PSR_c | PSR_f},
8053 {"scfx", PSR_s | PSR_c | PSR_f | PSR_x},
8054 {"scxf", PSR_s | PSR_c | PSR_x | PSR_f},
8055 {"xfsc", PSR_x | PSR_f | PSR_s | PSR_c},
8056 {"xfcs", PSR_x | PSR_f | PSR_c | PSR_s},
8057 {"xsfc", PSR_x | PSR_s | PSR_f | PSR_c},
8058 {"xscf", PSR_x | PSR_s | PSR_c | PSR_f},
8059 {"xcfs", PSR_x | PSR_c | PSR_f | PSR_s},
8060 {"xcsf", PSR_x | PSR_c | PSR_s | PSR_f},
8061 {"cfsx", PSR_c | PSR_f | PSR_s | PSR_x},
8062 {"cfxs", PSR_c | PSR_f | PSR_x | PSR_s},
8063 {"csfx", PSR_c | PSR_s | PSR_f | PSR_x},
8064 {"csxf", PSR_c | PSR_s | PSR_x | PSR_f},
8065 {"cxfs", PSR_c | PSR_x | PSR_f | PSR_s},
8066 {"cxsf", PSR_c | PSR_x | PSR_s | PSR_f},
8069 /* Table of all shift-in-operand names. */
8070 static const struct asm_shift_name shift_names [] =
8072 { "asl", SHIFT_LSL }, { "ASL", SHIFT_LSL },
8073 { "lsl", SHIFT_LSL }, { "LSL", SHIFT_LSL },
8074 { "lsr", SHIFT_LSR }, { "LSR", SHIFT_LSR },
8075 { "asr", SHIFT_ASR }, { "ASR", SHIFT_ASR },
8076 { "ror", SHIFT_ROR }, { "ROR", SHIFT_ROR },
8077 { "rrx", SHIFT_RRX }, { "RRX", SHIFT_RRX }
8080 /* Table of all explicit relocation names. */
8082 static struct reloc_entry reloc_names[] =
8084 { "got", BFD_RELOC_ARM_GOT32 }, { "GOT", BFD_RELOC_ARM_GOT32 },
8085 { "gotoff", BFD_RELOC_ARM_GOTOFF }, { "GOTOFF", BFD_RELOC_ARM_GOTOFF },
8086 { "plt", BFD_RELOC_ARM_PLT32 }, { "PLT", BFD_RELOC_ARM_PLT32 },
8087 { "target1", BFD_RELOC_ARM_TARGET1 }, { "TARGET1", BFD_RELOC_ARM_TARGET1 },
8088 { "target2", BFD_RELOC_ARM_TARGET2 }, { "TARGET2", BFD_RELOC_ARM_TARGET2 },
8089 { "sbrel", BFD_RELOC_ARM_SBREL32 }, { "SBREL", BFD_RELOC_ARM_SBREL32 },
8090 { "tlsgd", BFD_RELOC_ARM_TLS_GD32}, { "TLSGD", BFD_RELOC_ARM_TLS_GD32},
8091 { "tlsldm", BFD_RELOC_ARM_TLS_LDM32}, { "TLSLDM", BFD_RELOC_ARM_TLS_LDM32},
8092 { "tlsldo", BFD_RELOC_ARM_TLS_LDO32}, { "TLSLDO", BFD_RELOC_ARM_TLS_LDO32},
8093 { "gottpoff",BFD_RELOC_ARM_TLS_IE32}, { "GOTTPOFF",BFD_RELOC_ARM_TLS_IE32},
8094 { "tpoff", BFD_RELOC_ARM_TLS_LE32}, { "TPOFF", BFD_RELOC_ARM_TLS_LE32}
8098 /* Table of all conditional affixes. 0xF is not defined as a condition code. */
8099 static const struct asm_cond conds[] =
8103 {"cs", 0x2}, {"hs", 0x2},
8104 {"cc", 0x3}, {"ul", 0x3}, {"lo", 0x3},
8118 /* Table of ARM-format instructions. */
8120 /* Macros for gluing together operand strings. N.B. In all cases
8121 other than OPS0, the trailing OP_stop comes from default
8122 zero-initialization of the unspecified elements of the array. */
8123 #define OPS0() { OP_stop, }
8124 #define OPS1(a) { OP_##a, }
8125 #define OPS2(a,b) { OP_##a,OP_##b, }
8126 #define OPS3(a,b,c) { OP_##a,OP_##b,OP_##c, }
8127 #define OPS4(a,b,c,d) { OP_##a,OP_##b,OP_##c,OP_##d, }
8128 #define OPS5(a,b,c,d,e) { OP_##a,OP_##b,OP_##c,OP_##d,OP_##e, }
8129 #define OPS6(a,b,c,d,e,f) { OP_##a,OP_##b,OP_##c,OP_##d,OP_##e,OP_##f, }
8131 /* These macros abstract out the exact format of the mnemonic table and
8132 save some repeated characters. */
8134 /* The normal sort of mnemonic; has a Thumb variant; takes a conditional suffix. */
8135 #define TxCE(mnem, op, top, nops, ops, ae, te) \
8136 { #mnem, OPS##nops ops, OT_csuffix, 0x##op, top, ARM_VARIANT, \
8137 THUMB_VARIANT, do_##ae, do_##te }
8139 /* Two variants of the above - TCE for a numeric Thumb opcode, tCE for
8140 a T_MNEM_xyz enumerator. */
8141 #define TCE(mnem, aop, top, nops, ops, ae, te) \
8142 TxCE(mnem, aop, 0x##top, nops, ops, ae, te)
8143 #define tCE(mnem, aop, top, nops, ops, ae, te) \
8144 TxCE(mnem, aop, T_MNEM_##top, nops, ops, ae, te)
8146 /* Second most common sort of mnemonic: has a Thumb variant, takes a conditional
8147 infix after the third character. */
8148 #define TxC3(mnem, op, top, nops, ops, ae, te) \
8149 { #mnem, OPS##nops ops, OT_cinfix3, 0x##op, top, ARM_VARIANT, \
8150 THUMB_VARIANT, do_##ae, do_##te }
8151 #define TC3(mnem, aop, top, nops, ops, ae, te) \
8152 TxC3(mnem, aop, 0x##top, nops, ops, ae, te)
8153 #define tC3(mnem, aop, top, nops, ops, ae, te) \
8154 TxC3(mnem, aop, T_MNEM_##top, nops, ops, ae, te)
8156 /* Mnemonic with a conditional infix in an unusual place. Each and every variant has to
8157 appear in the condition table. */
8158 #define TxCM_(m1, m2, m3, op, top, nops, ops, ae, te) \
8159 { #m1 #m2 #m3, OPS##nops ops, sizeof(#m2) == 1 ? OT_odd_infix_unc : OT_odd_infix_0 + sizeof(#m1) - 1, \
8160 0x##op, top, ARM_VARIANT, THUMB_VARIANT, do_##ae, do_##te }
8162 #define TxCM(m1, m2, op, top, nops, ops, ae, te) \
8163 TxCM_(m1, , m2, op, top, nops, ops, ae, te), \
8164 TxCM_(m1, eq, m2, op, top, nops, ops, ae, te), \
8165 TxCM_(m1, ne, m2, op, top, nops, ops, ae, te), \
8166 TxCM_(m1, cs, m2, op, top, nops, ops, ae, te), \
8167 TxCM_(m1, hs, m2, op, top, nops, ops, ae, te), \
8168 TxCM_(m1, cc, m2, op, top, nops, ops, ae, te), \
8169 TxCM_(m1, ul, m2, op, top, nops, ops, ae, te), \
8170 TxCM_(m1, lo, m2, op, top, nops, ops, ae, te), \
8171 TxCM_(m1, mi, m2, op, top, nops, ops, ae, te), \
8172 TxCM_(m1, pl, m2, op, top, nops, ops, ae, te), \
8173 TxCM_(m1, vs, m2, op, top, nops, ops, ae, te), \
8174 TxCM_(m1, vc, m2, op, top, nops, ops, ae, te), \
8175 TxCM_(m1, hi, m2, op, top, nops, ops, ae, te), \
8176 TxCM_(m1, ls, m2, op, top, nops, ops, ae, te), \
8177 TxCM_(m1, ge, m2, op, top, nops, ops, ae, te), \
8178 TxCM_(m1, lt, m2, op, top, nops, ops, ae, te), \
8179 TxCM_(m1, gt, m2, op, top, nops, ops, ae, te), \
8180 TxCM_(m1, le, m2, op, top, nops, ops, ae, te), \
8181 TxCM_(m1, al, m2, op, top, nops, ops, ae, te)
8183 #define TCM(m1,m2, aop, top, nops, ops, ae, te) \
8184 TxCM(m1,m2, aop, 0x##top, nops, ops, ae, te)
8185 #define tCM(m1,m2, aop, top, nops, ops, ae, te) \
8186 TxCM(m1,m2, aop, T_MNEM_##top, nops, ops, ae, te)
8188 /* Mnemonic that cannot be conditionalized. The ARM condition-code
8189 field is still 0xE. */
8190 #define TUE(mnem, op, top, nops, ops, ae, te) \
8191 { #mnem, OPS##nops ops, OT_unconditional, 0x##op, 0x##top, ARM_VARIANT, \
8192 THUMB_VARIANT, do_##ae, do_##te }
8194 /* Mnemonic that cannot be conditionalized, and bears 0xF in its ARM
8195 condition code field. */
8196 #define TUF(mnem, op, top, nops, ops, ae, te) \
8197 { #mnem, OPS##nops ops, OT_unconditionalF, 0x##op, 0x##top, ARM_VARIANT, \
8198 THUMB_VARIANT, do_##ae, do_##te }
8200 /* ARM-only variants of all the above. */
8201 #define CE(mnem, op, nops, ops, ae) \
8202 { #mnem, OPS##nops ops, OT_csuffix, 0x##op, 0x0, ARM_VARIANT, 0, do_##ae, NULL }
8204 #define C3(mnem, op, nops, ops, ae) \
8205 { #mnem, OPS##nops ops, OT_cinfix3, 0x##op, 0x0, ARM_VARIANT, 0, do_##ae, NULL }
8207 #define xCM_(m1, m2, m3, op, nops, ops, ae) \
8208 { #m1 #m2 #m3, OPS##nops ops, \
8209 sizeof(#m2) == 1 ? OT_odd_infix_unc : OT_odd_infix_0 + sizeof(#m1) - 1, \
8210 0x##op, 0x0, ARM_VARIANT, 0, do_##ae, NULL }
8212 #define CM(m1, m2, op, nops, ops, ae) \
8213 xCM_(m1, , m2, op, nops, ops, ae), \
8214 xCM_(m1, eq, m2, op, nops, ops, ae), \
8215 xCM_(m1, ne, m2, op, nops, ops, ae), \
8216 xCM_(m1, cs, m2, op, nops, ops, ae), \
8217 xCM_(m1, hs, m2, op, nops, ops, ae), \
8218 xCM_(m1, cc, m2, op, nops, ops, ae), \
8219 xCM_(m1, ul, m2, op, nops, ops, ae), \
8220 xCM_(m1, lo, m2, op, nops, ops, ae), \
8221 xCM_(m1, mi, m2, op, nops, ops, ae), \
8222 xCM_(m1, pl, m2, op, nops, ops, ae), \
8223 xCM_(m1, vs, m2, op, nops, ops, ae), \
8224 xCM_(m1, vc, m2, op, nops, ops, ae), \
8225 xCM_(m1, hi, m2, op, nops, ops, ae), \
8226 xCM_(m1, ls, m2, op, nops, ops, ae), \
8227 xCM_(m1, ge, m2, op, nops, ops, ae), \
8228 xCM_(m1, lt, m2, op, nops, ops, ae), \
8229 xCM_(m1, gt, m2, op, nops, ops, ae), \
8230 xCM_(m1, le, m2, op, nops, ops, ae), \
8231 xCM_(m1, al, m2, op, nops, ops, ae)
8233 #define UE(mnem, op, nops, ops, ae) \
8234 { #mnem, OPS##nops ops, OT_unconditional, 0x##op, 0, ARM_VARIANT, 0, do_##ae, NULL }
8236 #define UF(mnem, op, nops, ops, ae) \
8237 { #mnem, OPS##nops ops, OT_unconditionalF, 0x##op, 0, ARM_VARIANT, 0, do_##ae, NULL }
8241 /* Thumb-only, unconditional. */
8242 #define UT(mnem, op, nops, ops, te) TUE(mnem, 0, op, nops, ops, 0, te)
8244 /* ARM-only, takes either a suffix or a position-3 infix
8245 (for an FPA corner case). */
8246 #define C3E(mnem, op, nops, ops, ae) \
8247 { #mnem, OPS##nops ops, OT_csuf_or_in3, 0x##op, 0, ARM_VARIANT, 0, do_##ae, 0 }
8249 static const struct asm_opcode insns[] =
8251 #define ARM_VARIANT ARM_EXT_V1 /* Core ARM Instructions. */
8252 #define THUMB_VARIANT ARM_EXT_V4T
8253 tCE(and, 0000000, and, 3, (RR, oRR, SH), arit, t_arit3c),
8254 tC3(ands, 0100000, ands, 3, (RR, oRR, SH), arit, t_arit3c),
8255 tCE(eor, 0200000, eor, 3, (RR, oRR, SH), arit, t_arit3c),
8256 tC3(eors, 0300000, eors, 3, (RR, oRR, SH), arit, t_arit3c),
8257 tCE(sub, 0400000, sub, 3, (RR, oRR, SH), arit, t_add_sub),
8258 tC3(subs, 0500000, subs, 3, (RR, oRR, SH), arit, t_add_sub),
8259 tCE(add, 0800000, add, 3, (RR, oRR, SH), arit, t_add_sub),
8260 tC3(adds, 0900000, adds, 3, (RR, oRR, SH), arit, t_add_sub),
8261 tCE(adc, 0a00000, adc, 3, (RR, oRR, SH), arit, t_arit3c),
8262 tC3(adcs, 0b00000, adcs, 3, (RR, oRR, SH), arit, t_arit3c),
8263 tCE(sbc, 0c00000, sbc, 3, (RR, oRR, SH), arit, t_arit3),
8264 tC3(sbcs, 0d00000, sbcs, 3, (RR, oRR, SH), arit, t_arit3),
8265 tCE(orr, 1800000, orr, 3, (RR, oRR, SH), arit, t_arit3c),
8266 tC3(orrs, 1900000, orrs, 3, (RR, oRR, SH), arit, t_arit3c),
8267 tCE(bic, 1c00000, bic, 3, (RR, oRR, SH), arit, t_arit3),
8268 tC3(bics, 1d00000, bics, 3, (RR, oRR, SH), arit, t_arit3),
8270 /* The p-variants of tst/cmp/cmn/teq (below) are the pre-V6 mechanism
8271 for setting PSR flag bits. They are obsolete in V6 and do not
8272 have Thumb equivalents. */
8273 tCE(tst, 1100000, tst, 2, (RR, SH), cmp, t_mvn_tst),
8274 tC3(tsts, 1100000, tst, 2, (RR, SH), cmp, t_mvn_tst),
8275 C3(tstp, 110f000, 2, (RR, SH), cmp),
8276 tCE(cmp, 1500000, cmp, 2, (RR, SH), cmp, t_mov_cmp),
8277 tC3(cmps, 1500000, cmp, 2, (RR, SH), cmp, t_mov_cmp),
8278 C3(cmpp, 150f000, 2, (RR, SH), cmp),
8279 tCE(cmn, 1700000, cmn, 2, (RR, SH), cmp, t_mvn_tst),
8280 tC3(cmns, 1700000, cmn, 2, (RR, SH), cmp, t_mvn_tst),
8281 C3(cmnp, 170f000, 2, (RR, SH), cmp),
8283 tCE(mov, 1a00000, mov, 2, (RR, SH), mov, t_mov_cmp),
8284 tC3(movs, 1b00000, movs, 2, (RR, SH), mov, t_mov_cmp),
8285 tCE(mvn, 1e00000, mvn, 2, (RR, SH), mov, t_mvn_tst),
8286 tC3(mvns, 1f00000, mvns, 2, (RR, SH), mov, t_mvn_tst),
8288 tCE(ldr, 4100000, ldr, 2, (RR, ADDR), ldst, t_ldst),
8289 tC3(ldrb, 4500000, ldrb, 2, (RR, ADDR), ldst, t_ldst),
8290 tCE(str, 4000000, str, 2, (RR, ADDR), ldst, t_ldst),
8291 tC3(strb, 4400000, strb, 2, (RR, ADDR), ldst, t_ldst),
8293 tC3(stmia, 8800000, stmia, 2, (RRw, REGLST), ldmstm, t_ldmstm),
8294 tC3(stmea, 8800000, stmia, 2, (RRw, REGLST), ldmstm, t_ldmstm),
8295 tC3(ldmia, 8900000, ldmia, 2, (RRw, REGLST), ldmstm, t_ldmstm),
8296 tC3(ldmfd, 8900000, ldmia, 2, (RRw, REGLST), ldmstm, t_ldmstm),
8298 TCE(swi, f000000, df00, 1, (EXPi), swi, t_swi),
8299 TCE(b, a000000, e000, 1, (EXPr), branch, t_branch),
8300 TCE(bl, b000000, f000f800, 1, (EXPr), branch, t_branch23),
8303 tCE(adr, 28f0000, adr, 2, (RR, EXP), adr, t_adr),
8304 C3(adrl, 28f0000, 2, (RR, EXP), adrl),
8305 tCE(nop, 1a00000, nop, 1, (oI255c), nop, t_nop),
8307 /* Thumb-compatibility pseudo ops. */
8308 tCE(lsl, 1a00000, lsl, 3, (RR, oRR, SH), shift, t_shift),
8309 tC3(lsls, 1b00000, lsls, 3, (RR, oRR, SH), shift, t_shift),
8310 tCE(lsr, 1a00020, lsr, 3, (RR, oRR, SH), shift, t_shift),
8311 tC3(lsrs, 1b00020, lsrs, 3, (RR, oRR, SH), shift, t_shift),
8312 tCE(asr, 1a00040, asr, 3, (RR, oRR, SH), shift, t_shift),
8313 tC3(asrs, 1b00040, asrs, 3, (RR, oRR, SH), shift, t_shift),
8314 tCE(ror, 1a00060, ror, 3, (RR, oRR, SH), shift, t_shift),
8315 tC3(rors, 1b00060, rors, 3, (RR, oRR, SH), shift, t_shift),
8316 tCE(neg, 2600000, neg, 2, (RR, RR), rd_rn, t_neg),
8317 tC3(negs, 2700000, negs, 2, (RR, RR), rd_rn, t_neg),
8318 tCE(push, 92d0000, push, 1, (REGLST), push_pop, t_push_pop),
8319 tCE(pop, 8bd0000, pop, 1, (REGLST), push_pop, t_push_pop),
8321 #undef THUMB_VARIANT
8322 #define THUMB_VARIANT ARM_EXT_V6
8323 TCE(cpy, 1a00000, 4600, 2, (RR, RR), rd_rm, t_cpy),
8325 /* V1 instructions with no Thumb analogue prior to V6T2. */
8326 #undef THUMB_VARIANT
8327 #define THUMB_VARIANT ARM_EXT_V6T2
8328 TCE(rsb, 0600000, ebc00000, 3, (RR, oRR, SH), arit, t_rsb),
8329 TC3(rsbs, 0700000, ebd00000, 3, (RR, oRR, SH), arit, t_rsb),
8330 TCE(teq, 1300000, ea900f00, 2, (RR, SH), cmp, t_mvn_tst),
8331 TC3(teqs, 1300000, ea900f00, 2, (RR, SH), cmp, t_mvn_tst),
8332 C3(teqp, 130f000, 2, (RR, SH), cmp),
8334 TC3(ldrt, 4300000, f8500e00, 2, (RR, ADDR), ldstt, t_ldstt),
8335 TC3(ldrbt, 4700000, f8300e00, 2, (RR, ADDR), ldstt, t_ldstt),
8336 TC3(strt, 4200000, f8400e00, 2, (RR, ADDR), ldstt, t_ldstt),
8337 TC3(strbt, 4600000, f8200e00, 2, (RR, ADDR), ldstt, t_ldstt),
8339 TC3(stmdb, 9000000, e9000000, 2, (RRw, REGLST), ldmstm, t_ldmstm),
8340 TC3(stmfd, 9000000, e9000000, 2, (RRw, REGLST), ldmstm, t_ldmstm),
8342 TC3(ldmdb, 9100000, e9100000, 2, (RRw, REGLST), ldmstm, t_ldmstm),
8343 TC3(ldmea, 9100000, e9100000, 2, (RRw, REGLST), ldmstm, t_ldmstm),
8345 /* V1 instructions with no Thumb analogue at all. */
8346 CE(rsc, 0e00000, 3, (RR, oRR, SH), arit),
8347 C3(rscs, 0f00000, 3, (RR, oRR, SH), arit),
8349 C3(stmib, 9800000, 2, (RRw, REGLST), ldmstm),
8350 C3(stmfa, 9800000, 2, (RRw, REGLST), ldmstm),
8351 C3(stmda, 8000000, 2, (RRw, REGLST), ldmstm),
8352 C3(stmed, 8000000, 2, (RRw, REGLST), ldmstm),
8353 C3(ldmib, 9900000, 2, (RRw, REGLST), ldmstm),
8354 C3(ldmed, 9900000, 2, (RRw, REGLST), ldmstm),
8355 C3(ldmda, 8100000, 2, (RRw, REGLST), ldmstm),
8356 C3(ldmfa, 8100000, 2, (RRw, REGLST), ldmstm),
8359 #define ARM_VARIANT ARM_EXT_V2 /* ARM 2 - multiplies. */
8360 #undef THUMB_VARIANT
8361 #define THUMB_VARIANT ARM_EXT_V4T
8362 tCE(mul, 0000090, mul, 3, (RRnpc, RRnpc, oRR), mul, t_mul),
8363 tC3(muls, 0100090, muls, 3, (RRnpc, RRnpc, oRR), mul, t_mul),
8365 #undef THUMB_VARIANT
8366 #define THUMB_VARIANT ARM_EXT_V6T2
8367 TCE(mla, 0200090, fb000000, 4, (RRnpc, RRnpc, RRnpc, RRnpc), mlas, t_mla),
8368 C3(mlas, 0300090, 4, (RRnpc, RRnpc, RRnpc, RRnpc), mlas),
8370 /* Generic coprocessor instructions. */
8371 TCE(cdp, e000000, ee000000, 6, (RCP, I15b, RCN, RCN, RCN, oI7b), cdp, cdp),
8372 TCE(ldc, c100000, ec100000, 3, (RCP, RCN, ADDR), lstc, lstc),
8373 TC3(ldcl, c500000, ec500000, 3, (RCP, RCN, ADDR), lstc, lstc),
8374 TCE(stc, c000000, ec000000, 3, (RCP, RCN, ADDR), lstc, lstc),
8375 TC3(stcl, c400000, ec400000, 3, (RCP, RCN, ADDR), lstc, lstc),
8376 TCE(mcr, e000010, ee000010, 6, (RCP, I7b, RR, RCN, RCN, oI7b), co_reg, co_reg),
8377 TCE(mrc, e100010, ee100010, 6, (RCP, I7b, RR, RCN, RCN, oI7b), co_reg, co_reg),
8380 #define ARM_VARIANT ARM_EXT_V2S /* ARM 3 - swp instructions. */
8381 CE(swp, 1000090, 3, (RRnpc, RRnpc, RRnpcb), rd_rm_rn),
8382 C3(swpb, 1400090, 3, (RRnpc, RRnpc, RRnpcb), rd_rm_rn),
8385 #define ARM_VARIANT ARM_EXT_V3 /* ARM 6 Status register instructions. */
8386 TCE(mrs, 10f0000, f3ef8000, 2, (RR, PSR), mrs, t_mrs),
8387 TCE(msr, 120f000, f3808000, 2, (PSR, RR_EXi), msr, t_msr),
8390 #define ARM_VARIANT ARM_EXT_V3M /* ARM 7M long multiplies. */
8391 TCE(smull, 0c00090, fb800000, 4, (RRnpc, RRnpc, RRnpc, RRnpc), mull, t_mull),
8392 CM(smull,s, 0d00090, 4, (RRnpc, RRnpc, RRnpc, RRnpc), mull),
8393 TCE(umull, 0800090, fba00000, 4, (RRnpc, RRnpc, RRnpc, RRnpc), mull, t_mull),
8394 CM(umull,s, 0900090, 4, (RRnpc, RRnpc, RRnpc, RRnpc), mull),
8395 TCE(smlal, 0e00090, fbc00000, 4, (RRnpc, RRnpc, RRnpc, RRnpc), mull, t_mull),
8396 CM(smlal,s, 0f00090, 4, (RRnpc, RRnpc, RRnpc, RRnpc), mull),
8397 TCE(umlal, 0a00090, fbe00000, 4, (RRnpc, RRnpc, RRnpc, RRnpc), mull, t_mull),
8398 CM(umlal,s, 0b00090, 4, (RRnpc, RRnpc, RRnpc, RRnpc), mull),
8401 #define ARM_VARIANT ARM_EXT_V4 /* ARM Architecture 4. */
8402 #undef THUMB_VARIANT
8403 #define THUMB_VARIANT ARM_EXT_V4T
8404 tC3(ldrh, 01000b0, ldrh, 2, (RR, ADDR), ldstv4, t_ldst),
8405 tC3(strh, 00000b0, strh, 2, (RR, ADDR), ldstv4, t_ldst),
8406 tC3(ldrsh, 01000f0, ldrsh, 2, (RR, ADDR), ldstv4, t_ldst),
8407 tC3(ldrsb, 01000d0, ldrsb, 2, (RR, ADDR), ldstv4, t_ldst),
8408 tCM(ld,sh, 01000f0, ldrsh, 2, (RR, ADDR), ldstv4, t_ldst),
8409 tCM(ld,sb, 01000d0, ldrsb, 2, (RR, ADDR), ldstv4, t_ldst),
8412 #define ARM_VARIANT ARM_EXT_V4T|ARM_EXT_V5
8413 /* ARM Architecture 4T. */
8414 /* Note: bx (and blx) are required on V5, even if the processor does
8415 not support Thumb. */
8416 TCE(bx, 12fff10, 4700, 1, (RR), bx, t_bx),
8419 #define ARM_VARIANT ARM_EXT_V5 /* ARM Architecture 5T. */
8420 #undef THUMB_VARIANT
8421 #define THUMB_VARIANT ARM_EXT_V5T
8422 /* Note: blx has 2 variants; the .value coded here is for
8423 BLX(2). Only this variant has conditional execution. */
8424 TCE(blx, 12fff30, 4780, 1, (RR_EXr), blx, t_blx),
8425 TUE(bkpt, 1200070, be00, 1, (oIffffb), bkpt, t_bkpt),
8427 #undef THUMB_VARIANT
8428 #define THUMB_VARIANT ARM_EXT_V6T2
8429 TCE(clz, 16f0f10, fab0f080, 2, (RRnpc, RRnpc), rd_rm, t_clz),
8430 TUF(ldc2, c100000, fc100000, 3, (RCP, RCN, ADDR), lstc, lstc),
8431 TUF(ldc2l, c500000, fc500000, 3, (RCP, RCN, ADDR), lstc, lstc),
8432 TUF(stc2, c000000, fc000000, 3, (RCP, RCN, ADDR), lstc, lstc),
8433 TUF(stc2l, c400000, fc400000, 3, (RCP, RCN, ADDR), lstc, lstc),
8434 TUF(cdp2, e000000, fe000000, 6, (RCP, I15b, RCN, RCN, RCN, oI7b), cdp, cdp),
8435 TUF(mcr2, e000010, fe000010, 6, (RCP, I7b, RR, RCN, RCN, oI7b), co_reg, co_reg),
8436 TUF(mrc2, e100010, fe100010, 6, (RCP, I7b, RR, RCN, RCN, oI7b), co_reg, co_reg),
8439 #define ARM_VARIANT ARM_EXT_V5ExP /* ARM Architecture 5TExP. */
8440 TCE(smlabb, 1000080, fb100000, 4, (RRnpc, RRnpc, RRnpc, RRnpc), smla, t_mla),
8441 TCE(smlatb, 10000a0, fb100020, 4, (RRnpc, RRnpc, RRnpc, RRnpc), smla, t_mla),
8442 TCE(smlabt, 10000c0, fb100010, 4, (RRnpc, RRnpc, RRnpc, RRnpc), smla, t_mla),
8443 TCE(smlatt, 10000e0, fb100030, 4, (RRnpc, RRnpc, RRnpc, RRnpc), smla, t_mla),
8445 TCE(smlawb, 1200080, fb300000, 4, (RRnpc, RRnpc, RRnpc, RRnpc), smla, t_mla),
8446 TCE(smlawt, 12000c0, fb300010, 4, (RRnpc, RRnpc, RRnpc, RRnpc), smla, t_mla),
8448 TCE(smlalbb, 1400080, fbc00080, 4, (RRnpc, RRnpc, RRnpc, RRnpc), smlal, t_mlal),
8449 TCE(smlaltb, 14000a0, fbc000a0, 4, (RRnpc, RRnpc, RRnpc, RRnpc), smlal, t_mlal),
8450 TCE(smlalbt, 14000c0, fbc00090, 4, (RRnpc, RRnpc, RRnpc, RRnpc), smlal, t_mlal),
8451 TCE(smlaltt, 14000e0, fbc000b0, 4, (RRnpc, RRnpc, RRnpc, RRnpc), smlal, t_mlal),
8453 TCE(smulbb, 1600080, fb10f000, 3, (RRnpc, RRnpc, RRnpc), smul, t_simd),
8454 TCE(smultb, 16000a0, fb10f020, 3, (RRnpc, RRnpc, RRnpc), smul, t_simd),
8455 TCE(smulbt, 16000c0, fb10f010, 3, (RRnpc, RRnpc, RRnpc), smul, t_simd),
8456 TCE(smultt, 16000e0, fb10f030, 3, (RRnpc, RRnpc, RRnpc), smul, t_simd),
8458 TCE(smulwb, 12000a0, fb30f000, 3, (RRnpc, RRnpc, RRnpc), smul, t_simd),
8459 TCE(smulwt, 12000e0, fb30f010, 3, (RRnpc, RRnpc, RRnpc), smul, t_simd),
8461 TCE(qadd, 1000050, fa80f080, 3, (RRnpc, RRnpc, RRnpc), rd_rm_rn, rd_rm_rn),
8462 TCE(qdadd, 1400050, fa80f090, 3, (RRnpc, RRnpc, RRnpc), rd_rm_rn, rd_rm_rn),
8463 TCE(qsub, 1200050, fa80f0a0, 3, (RRnpc, RRnpc, RRnpc), rd_rm_rn, rd_rm_rn),
8464 TCE(qdsub, 1600050, fa80f0b0, 3, (RRnpc, RRnpc, RRnpc), rd_rm_rn, rd_rm_rn),
8467 #define ARM_VARIANT ARM_EXT_V5E /* ARM Architecture 5TE. */
8468 TUF(pld, 450f000, f810f000, 1, (ADDR), pld, t_pld),
8469 TC3(ldrd, 00000d0, e9500000, 3, (RRnpc, oRRnpc, ADDR), ldrd, t_ldstd),
8470 TC3(strd, 00000f0, e9400000, 3, (RRnpc, oRRnpc, ADDR), ldrd, t_ldstd),
8472 TCE(mcrr, c400000, ec400000, 5, (RCP, I15b, RRnpc, RRnpc, RCN), co_reg2c, co_reg2c),
8473 TCE(mrrc, c500000, ec500000, 5, (RCP, I15b, RRnpc, RRnpc, RCN), co_reg2c, co_reg2c),
8476 #define ARM_VARIANT ARM_EXT_V5J /* ARM Architecture 5TEJ. */
8477 TCE(bxj, 12fff20, f3c08f00, 1, (RR), bxj, t_bxj),
8480 #define ARM_VARIANT ARM_EXT_V6 /* ARM V6. */
8481 #undef THUMB_VARIANT
8482 #define THUMB_VARIANT ARM_EXT_V6
8483 TUF(cpsie, 1080000, b660, 2, (CPSF, oI31b), cpsi, t_cpsi),
8484 TUF(cpsid, 10c0000, b670, 2, (CPSF, oI31b), cpsi, t_cpsi),
8485 tCE(rev, 6bf0f30, rev, 2, (RRnpc, RRnpc), rd_rm, t_rev),
8486 tCE(rev16, 6bf0fb0, rev16, 2, (RRnpc, RRnpc), rd_rm, t_rev),
8487 tCE(revsh, 6ff0fb0, revsh, 2, (RRnpc, RRnpc), rd_rm, t_rev),
8488 tCE(sxth, 6bf0070, sxth, 3, (RRnpc, RRnpc, oROR), sxth, t_sxth),
8489 tCE(uxth, 6ff0070, uxth, 3, (RRnpc, RRnpc, oROR), sxth, t_sxth),
8490 tCE(sxtb, 6af0070, sxtb, 3, (RRnpc, RRnpc, oROR), sxth, t_sxth),
8491 tCE(uxtb, 6ef0070, uxtb, 3, (RRnpc, RRnpc, oROR), sxth, t_sxth),
8492 TUF(setend, 1010000, b650, 1, (ENDI), setend, t_setend),
8494 #undef THUMB_VARIANT
8495 #define THUMB_VARIANT ARM_EXT_V6T2
8496 TUF(cps, 1020000, f3af8100, 1, (I31b), imm0, imm0),
8497 TCE(ldrex, 1900f9f, e8500f00, 2, (RRnpc, ADDR), ldrex, t_ldrex),
8498 TUF(mcrr2, c400000, fc400000, 5, (RCP, I15b, RRnpc, RRnpc, RCN), co_reg2c, co_reg2c),
8499 TUF(mrrc2, c500000, fc500000, 5, (RCP, I15b, RRnpc, RRnpc, RCN), co_reg2c, co_reg2c),
8500 TCE(pkhbt, 6800010, eac00000, 4, (RRnpc, RRnpc, RRnpc, oSHll), pkhbt, t_pkhbt),
8501 TCE(pkhtb, 6800050, eac00020, 4, (RRnpc, RRnpc, RRnpc, oSHar), pkhtb, t_pkhtb),
8502 TCE(qadd16, 6200f10, fa90f010, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
8503 TCE(qadd8, 6200f90, fa80f010, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
8504 TCE(qaddsubx, 6200f30, faa0f010, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
8505 TCE(qsub16, 6200f70, fad0f010, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
8506 TCE(qsub8, 6200ff0, fac0f010, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
8507 TCE(qsubaddx, 6200f50, fae0f010, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
8508 TCE(sadd16, 6100f10, fa90f000, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
8509 TCE(sadd8, 6100f90, fa80f000, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
8510 TCE(saddsubx, 6100f30, faa0f000, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
8511 TCE(shadd16, 6300f10, fa90f020, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
8512 TCE(shadd8, 6300f90, fa80f020, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
8513 TCE(shaddsubx, 6300f30, faa0f020, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
8514 TCE(shsub16, 6300f70, fad0f020, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
8515 TCE(shsub8, 6300ff0, fac0f020, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
8516 TCE(shsubaddx, 6300f50, fae0f020, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
8517 TCE(ssub16, 6100f70, fad0f000, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
8518 TCE(ssub8, 6100ff0, fac0f000, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
8519 TCE(ssubaddx, 6100f50, fae0f000, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
8520 TCE(uadd16, 6500f10, fa90f040, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
8521 TCE(uadd8, 6500f90, fa80f040, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
8522 TCE(uaddsubx, 6500f30, faa0f040, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
8523 TCE(uhadd16, 6700f10, fa90f060, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
8524 TCE(uhadd8, 6700f90, fa80f060, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
8525 TCE(uhaddsubx, 6700f30, faa0f060, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
8526 TCE(uhsub16, 6700f70, fad0f060, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
8527 TCE(uhsub8, 6700ff0, fac0f060, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
8528 TCE(uhsubaddx, 6700f50, fae0f060, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
8529 TCE(uqadd16, 6600f10, fa90f050, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
8530 TCE(uqadd8, 6600f90, fa80f050, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
8531 TCE(uqaddsubx, 6600f30, faa0f050, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
8532 TCE(uqsub16, 6600f70, fad0f050, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
8533 TCE(uqsub8, 6600ff0, fac0f050, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
8534 TCE(uqsubaddx, 6600f50, fae0f050, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
8535 TCE(usub16, 6500f70, fad0f040, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
8536 TCE(usub8, 6500ff0, fac0f040, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
8537 TCE(usubaddx, 6500f50, fae0f040, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
8538 TUF(rfeia, 8900a00, e990c000, 1, (RRw), rfe, rfe),
8539 UF(rfeib, 9900a00, 1, (RRw), rfe),
8540 UF(rfeda, 8100a00, 1, (RRw), rfe),
8541 TUF(rfedb, 9100a00, e810c000, 1, (RRw), rfe, rfe),
8542 TUF(rfefd, 8900a00, e990c000, 1, (RRw), rfe, rfe),
8543 UF(rfefa, 9900a00, 1, (RRw), rfe),
8544 UF(rfeea, 8100a00, 1, (RRw), rfe),
8545 TUF(rfeed, 9100a00, e810c000, 1, (RRw), rfe, rfe),
8546 TCE(sxtah, 6b00070, fa00f080, 4, (RRnpc, RRnpc, RRnpc, oROR), sxtah, t_sxtah),
8547 TCE(sxtab16, 6800070, fa20f080, 4, (RRnpc, RRnpc, RRnpc, oROR), sxtah, t_sxtah),
8548 TCE(sxtab, 6a00070, fa40f080, 4, (RRnpc, RRnpc, RRnpc, oROR), sxtah, t_sxtah),
8549 TCE(sxtb16, 68f0070, fa2ff080, 3, (RRnpc, RRnpc, oROR), sxth, t_sxth),
8550 TCE(uxtah, 6f00070, fa10f080, 4, (RRnpc, RRnpc, RRnpc, oROR), sxtah, t_sxtah),
8551 TCE(uxtab16, 6c00070, fa30f080, 4, (RRnpc, RRnpc, RRnpc, oROR), sxtah, t_sxtah),
8552 TCE(uxtab, 6e00070, fa50f080, 4, (RRnpc, RRnpc, RRnpc, oROR), sxtah, t_sxtah),
8553 TCE(uxtb16, 6cf0070, fa3ff080, 3, (RRnpc, RRnpc, oROR), sxth, t_sxth),
8554 TCE(sel, 68000b0, faa0f080, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
8555 TCE(smlad, 7000010, fb200000, 4, (RRnpc, RRnpc, RRnpc, RRnpc),smla, t_mla),
8556 TCE(smladx, 7000030, fb200010, 4, (RRnpc, RRnpc, RRnpc, RRnpc),smla, t_mla),
8557 TCE(smlald, 7400010, fbc000c0, 4, (RRnpc, RRnpc, RRnpc, RRnpc),smlal,t_mlal),
8558 TCE(smlaldx, 7400030, fbc000d0, 4, (RRnpc, RRnpc, RRnpc, RRnpc),smlal,t_mlal),
8559 TCE(smlsd, 7000050, fb400000, 4, (RRnpc, RRnpc, RRnpc, RRnpc),smla, t_mla),
8560 TCE(smlsdx, 7000070, fb400010, 4, (RRnpc, RRnpc, RRnpc, RRnpc),smla, t_mla),
8561 TCE(smlsld, 7400050, fbd000c0, 4, (RRnpc, RRnpc, RRnpc, RRnpc),smlal,t_mlal),
8562 TCE(smlsldx, 7400070, fbd000d0, 4, (RRnpc, RRnpc, RRnpc, RRnpc),smlal,t_mlal),
8563 TCE(smmla, 7500010, fb500000, 4, (RRnpc, RRnpc, RRnpc, RRnpc),smla, t_mla),
8564 TCE(smmlar, 7500030, fb500010, 4, (RRnpc, RRnpc, RRnpc, RRnpc),smla, t_mla),
8565 TCE(smmls, 75000d0, fb600000, 4, (RRnpc, RRnpc, RRnpc, RRnpc),smla, t_mla),
8566 TCE(smmlsr, 75000f0, fb600010, 4, (RRnpc, RRnpc, RRnpc, RRnpc),smla, t_mla),
8567 TCE(smmul, 750f010, fb50f000, 3, (RRnpc, RRnpc, RRnpc), smul, t_simd),
8568 TCE(smmulr, 750f030, fb50f010, 3, (RRnpc, RRnpc, RRnpc), smul, t_simd),
8569 TCE(smuad, 700f010, fb20f000, 3, (RRnpc, RRnpc, RRnpc), smul, t_simd),
8570 TCE(smuadx, 700f030, fb20f010, 3, (RRnpc, RRnpc, RRnpc), smul, t_simd),
8571 TCE(smusd, 700f050, fb40f000, 3, (RRnpc, RRnpc, RRnpc), smul, t_simd),
8572 TCE(smusdx, 700f070, fb40f010, 3, (RRnpc, RRnpc, RRnpc), smul, t_simd),
8573 TUF(srsia, 8cd0500, e980c000, 1, (I31w), srs, srs),
8574 UF(srsib, 9cd0500, 1, (I31w), srs),
8575 UF(srsda, 84d0500, 1, (I31w), srs),
8576 TUF(srsdb, 94d0500, e800c000, 1, (I31w), srs, srs),
8577 TCE(ssat, 6a00010, f3000000, 4, (RRnpc, I32, RRnpc, oSHllar),ssat, t_ssat),
8578 TCE(ssat16, 6a00f30, f3200000, 3, (RRnpc, I16, RRnpc), ssat16, t_ssat16),
8579 TCE(strex, 1800f90, e8400000, 3, (RRnpc, RRnpc, ADDR), strex, t_strex),
8580 TCE(umaal, 0400090, fbe00060, 4, (RRnpc, RRnpc, RRnpc, RRnpc),smlal, t_mlal),
8581 TCE(usad8, 780f010, fb70f000, 3, (RRnpc, RRnpc, RRnpc), smul, t_simd),
8582 TCE(usada8, 7800010, fb700000, 4, (RRnpc, RRnpc, RRnpc, RRnpc),smla, t_mla),
8583 TCE(usat, 6e00010, f3800000, 4, (RRnpc, I31, RRnpc, oSHllar),usat, t_usat),
8584 TCE(usat16, 6e00f30, f3a00000, 3, (RRnpc, I15, RRnpc), usat16, t_usat16),
8587 #define ARM_VARIANT ARM_EXT_V6K
8588 #undef THUMB_VARIANT
8589 #define THUMB_VARIANT ARM_EXT_V6K
8590 tCE(yield, 320f001, yield, 0, (), noargs, t_hint),
8591 tCE(wfe, 320f002, wfe, 0, (), noargs, t_hint),
8592 tCE(wfi, 320f003, wfi, 0, (), noargs, t_hint),
8593 tCE(sev, 320f004, sev, 0, (), noargs, t_hint),
8595 #undef THUMB_VARIANT
8596 #define THUMB_VARIANT ARM_EXT_V6T2
8597 TCE(ldrexb, 1d00f9f, e8d00f4f, 2, (RRnpc, RRnpcb), rd_rn, rd_rn),
8598 TCE(ldrexh, 1f00f9f, e8d00f5f, 2, (RRnpc, RRnpcb), rd_rn, rd_rn),
8599 TCE(ldrexd, 1b00f9f, e8d0007f, 3, (RRnpc, oRRnpc, RRnpcb), ldrexd, t_ldrexd),
8600 TCE(strexb, 1c00f90, e8c00f40, 3, (RRnpc, RRnpc, ADDR), strex, rm_rd_rn),
8601 TCE(strexh, 1e00f90, e8c00f50, 3, (RRnpc, RRnpc, ADDR), strex, rm_rd_rn),
8602 TCE(strexd, 1a00f90, e8c00070, 4, (RRnpc, RRnpc, oRRnpc, RRnpcb), strexd, t_strexd),
8603 TUF(clrex, 57ff01f, f3bf8f2f, 0, (), noargs, noargs),
8606 #define ARM_VARIANT ARM_EXT_V6Z
8607 TCE(smi, 1600070, f7f08000, 1, (EXPi), smi, t_smi),
8610 #define ARM_VARIANT ARM_EXT_V6T2
8611 TCE(bfc, 7c0001f, f36f0000, 3, (RRnpc, I31, I32), bfc, t_bfc),
8612 TCE(bfi, 7c00010, f3600000, 4, (RRnpc, RRnpc_I0, I31, I32), bfi, t_bfi),
8613 TCE(sbfx, 7a00050, f3400000, 4, (RR, RR, I31, I32), bfx, t_bfx),
8614 TCE(ubfx, 7e00050, f3c00000, 4, (RR, RR, I31, I32), bfx, t_bfx),
8616 TCE(mls, 0600090, fb000010, 4, (RRnpc, RRnpc, RRnpc, RRnpc), mlas, t_mla),
8617 TCE(movw, 3000000, f2400000, 2, (RRnpc, Iffff), mov16, t_mov16),
8618 TCE(movt, 3400000, f2c00000, 2, (RRnpc, Iffff), mov16, t_mov16),
8619 TCE(rbit, 3ff0f30, fa90f0a0, 2, (RR, RR), rd_rm, t_rbit),
8621 TC3(ldrht, 03000b0, f8300e00, 2, (RR, ADDR), ldsttv4, t_ldstt),
8622 TC3(ldrsht, 03000f0, f9300e00, 2, (RR, ADDR), ldsttv4, t_ldstt),
8623 TC3(ldrsbt, 03000d0, f9100e00, 2, (RR, ADDR), ldsttv4, t_ldstt),
8624 TC3(strht, 02000b0, f8200e00, 2, (RR, ADDR), ldsttv4, t_ldstt),
8626 UT(cbnz, b900, 2, (RR, EXP), t_czb),
8627 UT(cbz, b100, 2, (RR, EXP), t_czb),
8628 /* ARM does not really have an IT instruction. */
8629 TUE(it, 0, bf08, 1, (COND), it, t_it),
8630 TUE(itt, 0, bf0c, 1, (COND), it, t_it),
8631 TUE(ite, 0, bf04, 1, (COND), it, t_it),
8632 TUE(ittt, 0, bf0e, 1, (COND), it, t_it),
8633 TUE(itet, 0, bf06, 1, (COND), it, t_it),
8634 TUE(itte, 0, bf0a, 1, (COND), it, t_it),
8635 TUE(itee, 0, bf02, 1, (COND), it, t_it),
8636 TUE(itttt, 0, bf0f, 1, (COND), it, t_it),
8637 TUE(itett, 0, bf07, 1, (COND), it, t_it),
8638 TUE(ittet, 0, bf0b, 1, (COND), it, t_it),
8639 TUE(iteet, 0, bf03, 1, (COND), it, t_it),
8640 TUE(ittte, 0, bf0d, 1, (COND), it, t_it),
8641 TUE(itete, 0, bf05, 1, (COND), it, t_it),
8642 TUE(ittee, 0, bf09, 1, (COND), it, t_it),
8643 TUE(iteee, 0, bf01, 1, (COND), it, t_it),
8645 /* Thumb2 only instructions. */
8647 #define ARM_VARIANT 0
8649 TCE(addw, 0, f2000000, 3, (RR, RR, EXPi), 0, t_add_sub_w),
8650 TCE(subw, 0, f2a00000, 3, (RR, RR, EXPi), 0, t_add_sub_w),
8651 TCE(tbb, 0, e8d0f000, 1, (TB), 0, t_tb),
8652 TCE(tbh, 0, e8d0f010, 1, (TB), 0, t_tb),
8655 #define ARM_VARIANT FPU_FPA_EXT_V1 /* Core FPA instruction set (V1). */
8656 CE(wfs, e200110, 1, (RR), rd),
8657 CE(rfs, e300110, 1, (RR), rd),
8658 CE(wfc, e400110, 1, (RR), rd),
8659 CE(rfc, e500110, 1, (RR), rd),
8661 C3(ldfs, c100100, 2, (RF, ADDR), rd_cpaddr),
8662 C3(ldfd, c108100, 2, (RF, ADDR), rd_cpaddr),
8663 C3(ldfe, c500100, 2, (RF, ADDR), rd_cpaddr),
8664 C3(ldfp, c508100, 2, (RF, ADDR), rd_cpaddr),
8666 C3(stfs, c000100, 2, (RF, ADDR), rd_cpaddr),
8667 C3(stfd, c008100, 2, (RF, ADDR), rd_cpaddr),
8668 C3(stfe, c400100, 2, (RF, ADDR), rd_cpaddr),
8669 C3(stfp, c408100, 2, (RF, ADDR), rd_cpaddr),
8671 C3(mvfs, e008100, 2, (RF, RF_IF), rd_rm),
8672 C3(mvfsp, e008120, 2, (RF, RF_IF), rd_rm),
8673 C3(mvfsm, e008140, 2, (RF, RF_IF), rd_rm),
8674 C3(mvfsz, e008160, 2, (RF, RF_IF), rd_rm),
8675 C3(mvfd, e008180, 2, (RF, RF_IF), rd_rm),
8676 C3(mvfdp, e0081a0, 2, (RF, RF_IF), rd_rm),
8677 C3(mvfdm, e0081c0, 2, (RF, RF_IF), rd_rm),
8678 C3(mvfdz, e0081e0, 2, (RF, RF_IF), rd_rm),
8679 C3(mvfe, e088100, 2, (RF, RF_IF), rd_rm),
8680 C3(mvfep, e088120, 2, (RF, RF_IF), rd_rm),
8681 C3(mvfem, e088140, 2, (RF, RF_IF), rd_rm),
8682 C3(mvfez, e088160, 2, (RF, RF_IF), rd_rm),
8684 C3(mnfs, e108100, 2, (RF, RF_IF), rd_rm),
8685 C3(mnfsp, e108120, 2, (RF, RF_IF), rd_rm),
8686 C3(mnfsm, e108140, 2, (RF, RF_IF), rd_rm),
8687 C3(mnfsz, e108160, 2, (RF, RF_IF), rd_rm),
8688 C3(mnfd, e108180, 2, (RF, RF_IF), rd_rm),
8689 C3(mnfdp, e1081a0, 2, (RF, RF_IF), rd_rm),
8690 C3(mnfdm, e1081c0, 2, (RF, RF_IF), rd_rm),
8691 C3(mnfdz, e1081e0, 2, (RF, RF_IF), rd_rm),
8692 C3(mnfe, e188100, 2, (RF, RF_IF), rd_rm),
8693 C3(mnfep, e188120, 2, (RF, RF_IF), rd_rm),
8694 C3(mnfem, e188140, 2, (RF, RF_IF), rd_rm),
8695 C3(mnfez, e188160, 2, (RF, RF_IF), rd_rm),
8697 C3(abss, e208100, 2, (RF, RF_IF), rd_rm),
8698 C3(abssp, e208120, 2, (RF, RF_IF), rd_rm),
8699 C3(abssm, e208140, 2, (RF, RF_IF), rd_rm),
8700 C3(abssz, e208160, 2, (RF, RF_IF), rd_rm),
8701 C3(absd, e208180, 2, (RF, RF_IF), rd_rm),
8702 C3(absdp, e2081a0, 2, (RF, RF_IF), rd_rm),
8703 C3(absdm, e2081c0, 2, (RF, RF_IF), rd_rm),
8704 C3(absdz, e2081e0, 2, (RF, RF_IF), rd_rm),
8705 C3(abse, e288100, 2, (RF, RF_IF), rd_rm),
8706 C3(absep, e288120, 2, (RF, RF_IF), rd_rm),
8707 C3(absem, e288140, 2, (RF, RF_IF), rd_rm),
8708 C3(absez, e288160, 2, (RF, RF_IF), rd_rm),
8710 C3(rnds, e308100, 2, (RF, RF_IF), rd_rm),
8711 C3(rndsp, e308120, 2, (RF, RF_IF), rd_rm),
8712 C3(rndsm, e308140, 2, (RF, RF_IF), rd_rm),
8713 C3(rndsz, e308160, 2, (RF, RF_IF), rd_rm),
8714 C3(rndd, e308180, 2, (RF, RF_IF), rd_rm),
8715 C3(rnddp, e3081a0, 2, (RF, RF_IF), rd_rm),
8716 C3(rnddm, e3081c0, 2, (RF, RF_IF), rd_rm),
8717 C3(rnddz, e3081e0, 2, (RF, RF_IF), rd_rm),
8718 C3(rnde, e388100, 2, (RF, RF_IF), rd_rm),
8719 C3(rndep, e388120, 2, (RF, RF_IF), rd_rm),
8720 C3(rndem, e388140, 2, (RF, RF_IF), rd_rm),
8721 C3(rndez, e388160, 2, (RF, RF_IF), rd_rm),
8723 C3(sqts, e408100, 2, (RF, RF_IF), rd_rm),
8724 C3(sqtsp, e408120, 2, (RF, RF_IF), rd_rm),
8725 C3(sqtsm, e408140, 2, (RF, RF_IF), rd_rm),
8726 C3(sqtsz, e408160, 2, (RF, RF_IF), rd_rm),
8727 C3(sqtd, e408180, 2, (RF, RF_IF), rd_rm),
8728 C3(sqtdp, e4081a0, 2, (RF, RF_IF), rd_rm),
8729 C3(sqtdm, e4081c0, 2, (RF, RF_IF), rd_rm),
8730 C3(sqtdz, e4081e0, 2, (RF, RF_IF), rd_rm),
8731 C3(sqte, e488100, 2, (RF, RF_IF), rd_rm),
8732 C3(sqtep, e488120, 2, (RF, RF_IF), rd_rm),
8733 C3(sqtem, e488140, 2, (RF, RF_IF), rd_rm),
8734 C3(sqtez, e488160, 2, (RF, RF_IF), rd_rm),
8736 C3(logs, e508100, 2, (RF, RF_IF), rd_rm),
8737 C3(logsp, e508120, 2, (RF, RF_IF), rd_rm),
8738 C3(logsm, e508140, 2, (RF, RF_IF), rd_rm),
8739 C3(logsz, e508160, 2, (RF, RF_IF), rd_rm),
8740 C3(logd, e508180, 2, (RF, RF_IF), rd_rm),
8741 C3(logdp, e5081a0, 2, (RF, RF_IF), rd_rm),
8742 C3(logdm, e5081c0, 2, (RF, RF_IF), rd_rm),
8743 C3(logdz, e5081e0, 2, (RF, RF_IF), rd_rm),
8744 C3(loge, e588100, 2, (RF, RF_IF), rd_rm),
8745 C3(logep, e588120, 2, (RF, RF_IF), rd_rm),
8746 C3(logem, e588140, 2, (RF, RF_IF), rd_rm),
8747 C3(logez, e588160, 2, (RF, RF_IF), rd_rm),
8749 C3(lgns, e608100, 2, (RF, RF_IF), rd_rm),
8750 C3(lgnsp, e608120, 2, (RF, RF_IF), rd_rm),
8751 C3(lgnsm, e608140, 2, (RF, RF_IF), rd_rm),
8752 C3(lgnsz, e608160, 2, (RF, RF_IF), rd_rm),
8753 C3(lgnd, e608180, 2, (RF, RF_IF), rd_rm),
8754 C3(lgndp, e6081a0, 2, (RF, RF_IF), rd_rm),
8755 C3(lgndm, e6081c0, 2, (RF, RF_IF), rd_rm),
8756 C3(lgndz, e6081e0, 2, (RF, RF_IF), rd_rm),
8757 C3(lgne, e688100, 2, (RF, RF_IF), rd_rm),
8758 C3(lgnep, e688120, 2, (RF, RF_IF), rd_rm),
8759 C3(lgnem, e688140, 2, (RF, RF_IF), rd_rm),
8760 C3(lgnez, e688160, 2, (RF, RF_IF), rd_rm),
8762 C3(exps, e708100, 2, (RF, RF_IF), rd_rm),
8763 C3(expsp, e708120, 2, (RF, RF_IF), rd_rm),
8764 C3(expsm, e708140, 2, (RF, RF_IF), rd_rm),
8765 C3(expsz, e708160, 2, (RF, RF_IF), rd_rm),
8766 C3(expd, e708180, 2, (RF, RF_IF), rd_rm),
8767 C3(expdp, e7081a0, 2, (RF, RF_IF), rd_rm),
8768 C3(expdm, e7081c0, 2, (RF, RF_IF), rd_rm),
8769 C3(expdz, e7081e0, 2, (RF, RF_IF), rd_rm),
8770 C3(expe, e788100, 2, (RF, RF_IF), rd_rm),
8771 C3(expep, e788120, 2, (RF, RF_IF), rd_rm),
8772 C3(expem, e788140, 2, (RF, RF_IF), rd_rm),
8773 C3(expdz, e788160, 2, (RF, RF_IF), rd_rm),
8775 C3(sins, e808100, 2, (RF, RF_IF), rd_rm),
8776 C3(sinsp, e808120, 2, (RF, RF_IF), rd_rm),
8777 C3(sinsm, e808140, 2, (RF, RF_IF), rd_rm),
8778 C3(sinsz, e808160, 2, (RF, RF_IF), rd_rm),
8779 C3(sind, e808180, 2, (RF, RF_IF), rd_rm),
8780 C3(sindp, e8081a0, 2, (RF, RF_IF), rd_rm),
8781 C3(sindm, e8081c0, 2, (RF, RF_IF), rd_rm),
8782 C3(sindz, e8081e0, 2, (RF, RF_IF), rd_rm),
8783 C3(sine, e888100, 2, (RF, RF_IF), rd_rm),
8784 C3(sinep, e888120, 2, (RF, RF_IF), rd_rm),
8785 C3(sinem, e888140, 2, (RF, RF_IF), rd_rm),
8786 C3(sinez, e888160, 2, (RF, RF_IF), rd_rm),
8788 C3(coss, e908100, 2, (RF, RF_IF), rd_rm),
8789 C3(cossp, e908120, 2, (RF, RF_IF), rd_rm),
8790 C3(cossm, e908140, 2, (RF, RF_IF), rd_rm),
8791 C3(cossz, e908160, 2, (RF, RF_IF), rd_rm),
8792 C3(cosd, e908180, 2, (RF, RF_IF), rd_rm),
8793 C3(cosdp, e9081a0, 2, (RF, RF_IF), rd_rm),
8794 C3(cosdm, e9081c0, 2, (RF, RF_IF), rd_rm),
8795 C3(cosdz, e9081e0, 2, (RF, RF_IF), rd_rm),
8796 C3(cose, e988100, 2, (RF, RF_IF), rd_rm),
8797 C3(cosep, e988120, 2, (RF, RF_IF), rd_rm),
8798 C3(cosem, e988140, 2, (RF, RF_IF), rd_rm),
8799 C3(cosez, e988160, 2, (RF, RF_IF), rd_rm),
8801 C3(tans, ea08100, 2, (RF, RF_IF), rd_rm),
8802 C3(tansp, ea08120, 2, (RF, RF_IF), rd_rm),
8803 C3(tansm, ea08140, 2, (RF, RF_IF), rd_rm),
8804 C3(tansz, ea08160, 2, (RF, RF_IF), rd_rm),
8805 C3(tand, ea08180, 2, (RF, RF_IF), rd_rm),
8806 C3(tandp, ea081a0, 2, (RF, RF_IF), rd_rm),
8807 C3(tandm, ea081c0, 2, (RF, RF_IF), rd_rm),
8808 C3(tandz, ea081e0, 2, (RF, RF_IF), rd_rm),
8809 C3(tane, ea88100, 2, (RF, RF_IF), rd_rm),
8810 C3(tanep, ea88120, 2, (RF, RF_IF), rd_rm),
8811 C3(tanem, ea88140, 2, (RF, RF_IF), rd_rm),
8812 C3(tanez, ea88160, 2, (RF, RF_IF), rd_rm),
8814 C3(asns, eb08100, 2, (RF, RF_IF), rd_rm),
8815 C3(asnsp, eb08120, 2, (RF, RF_IF), rd_rm),
8816 C3(asnsm, eb08140, 2, (RF, RF_IF), rd_rm),
8817 C3(asnsz, eb08160, 2, (RF, RF_IF), rd_rm),
8818 C3(asnd, eb08180, 2, (RF, RF_IF), rd_rm),
8819 C3(asndp, eb081a0, 2, (RF, RF_IF), rd_rm),
8820 C3(asndm, eb081c0, 2, (RF, RF_IF), rd_rm),
8821 C3(asndz, eb081e0, 2, (RF, RF_IF), rd_rm),
8822 C3(asne, eb88100, 2, (RF, RF_IF), rd_rm),
8823 C3(asnep, eb88120, 2, (RF, RF_IF), rd_rm),
8824 C3(asnem, eb88140, 2, (RF, RF_IF), rd_rm),
8825 C3(asnez, eb88160, 2, (RF, RF_IF), rd_rm),
8827 C3(acss, ec08100, 2, (RF, RF_IF), rd_rm),
8828 C3(acssp, ec08120, 2, (RF, RF_IF), rd_rm),
8829 C3(acssm, ec08140, 2, (RF, RF_IF), rd_rm),
8830 C3(acssz, ec08160, 2, (RF, RF_IF), rd_rm),
8831 C3(acsd, ec08180, 2, (RF, RF_IF), rd_rm),
8832 C3(acsdp, ec081a0, 2, (RF, RF_IF), rd_rm),
8833 C3(acsdm, ec081c0, 2, (RF, RF_IF), rd_rm),
8834 C3(acsdz, ec081e0, 2, (RF, RF_IF), rd_rm),
8835 C3(acse, ec88100, 2, (RF, RF_IF), rd_rm),
8836 C3(acsep, ec88120, 2, (RF, RF_IF), rd_rm),
8837 C3(acsem, ec88140, 2, (RF, RF_IF), rd_rm),
8838 C3(acsez, ec88160, 2, (RF, RF_IF), rd_rm),
8840 C3(atns, ed08100, 2, (RF, RF_IF), rd_rm),
8841 C3(atnsp, ed08120, 2, (RF, RF_IF), rd_rm),
8842 C3(atnsm, ed08140, 2, (RF, RF_IF), rd_rm),
8843 C3(atnsz, ed08160, 2, (RF, RF_IF), rd_rm),
8844 C3(atnd, ed08180, 2, (RF, RF_IF), rd_rm),
8845 C3(atndp, ed081a0, 2, (RF, RF_IF), rd_rm),
8846 C3(atndm, ed081c0, 2, (RF, RF_IF), rd_rm),
8847 C3(atndz, ed081e0, 2, (RF, RF_IF), rd_rm),
8848 C3(atne, ed88100, 2, (RF, RF_IF), rd_rm),
8849 C3(atnep, ed88120, 2, (RF, RF_IF), rd_rm),
8850 C3(atnem, ed88140, 2, (RF, RF_IF), rd_rm),
8851 C3(atnez, ed88160, 2, (RF, RF_IF), rd_rm),
8853 C3(urds, ee08100, 2, (RF, RF_IF), rd_rm),
8854 C3(urdsp, ee08120, 2, (RF, RF_IF), rd_rm),
8855 C3(urdsm, ee08140, 2, (RF, RF_IF), rd_rm),
8856 C3(urdsz, ee08160, 2, (RF, RF_IF), rd_rm),
8857 C3(urdd, ee08180, 2, (RF, RF_IF), rd_rm),
8858 C3(urddp, ee081a0, 2, (RF, RF_IF), rd_rm),
8859 C3(urddm, ee081c0, 2, (RF, RF_IF), rd_rm),
8860 C3(urddz, ee081e0, 2, (RF, RF_IF), rd_rm),
8861 C3(urde, ee88100, 2, (RF, RF_IF), rd_rm),
8862 C3(urdep, ee88120, 2, (RF, RF_IF), rd_rm),
8863 C3(urdem, ee88140, 2, (RF, RF_IF), rd_rm),
8864 C3(urdez, ee88160, 2, (RF, RF_IF), rd_rm),
8866 C3(nrms, ef08100, 2, (RF, RF_IF), rd_rm),
8867 C3(nrmsp, ef08120, 2, (RF, RF_IF), rd_rm),
8868 C3(nrmsm, ef08140, 2, (RF, RF_IF), rd_rm),
8869 C3(nrmsz, ef08160, 2, (RF, RF_IF), rd_rm),
8870 C3(nrmd, ef08180, 2, (RF, RF_IF), rd_rm),
8871 C3(nrmdp, ef081a0, 2, (RF, RF_IF), rd_rm),
8872 C3(nrmdm, ef081c0, 2, (RF, RF_IF), rd_rm),
8873 C3(nrmdz, ef081e0, 2, (RF, RF_IF), rd_rm),
8874 C3(nrme, ef88100, 2, (RF, RF_IF), rd_rm),
8875 C3(nrmep, ef88120, 2, (RF, RF_IF), rd_rm),
8876 C3(nrmem, ef88140, 2, (RF, RF_IF), rd_rm),
8877 C3(nrmez, ef88160, 2, (RF, RF_IF), rd_rm),
8879 C3(adfs, e000100, 3, (RF, RF, RF_IF), rd_rn_rm),
8880 C3(adfsp, e000120, 3, (RF, RF, RF_IF), rd_rn_rm),
8881 C3(adfsm, e000140, 3, (RF, RF, RF_IF), rd_rn_rm),
8882 C3(adfsz, e000160, 3, (RF, RF, RF_IF), rd_rn_rm),
8883 C3(adfd, e000180, 3, (RF, RF, RF_IF), rd_rn_rm),
8884 C3(adfdp, e0001a0, 3, (RF, RF, RF_IF), rd_rn_rm),
8885 C3(adfdm, e0001c0, 3, (RF, RF, RF_IF), rd_rn_rm),
8886 C3(adfdz, e0001e0, 3, (RF, RF, RF_IF), rd_rn_rm),
8887 C3(adfe, e080100, 3, (RF, RF, RF_IF), rd_rn_rm),
8888 C3(adfep, e080120, 3, (RF, RF, RF_IF), rd_rn_rm),
8889 C3(adfem, e080140, 3, (RF, RF, RF_IF), rd_rn_rm),
8890 C3(adfez, e080160, 3, (RF, RF, RF_IF), rd_rn_rm),
8892 C3(sufs, e200100, 3, (RF, RF, RF_IF), rd_rn_rm),
8893 C3(sufsp, e200120, 3, (RF, RF, RF_IF), rd_rn_rm),
8894 C3(sufsm, e200140, 3, (RF, RF, RF_IF), rd_rn_rm),
8895 C3(sufsz, e200160, 3, (RF, RF, RF_IF), rd_rn_rm),
8896 C3(sufd, e200180, 3, (RF, RF, RF_IF), rd_rn_rm),
8897 C3(sufdp, e2001a0, 3, (RF, RF, RF_IF), rd_rn_rm),
8898 C3(sufdm, e2001c0, 3, (RF, RF, RF_IF), rd_rn_rm),
8899 C3(sufdz, e2001e0, 3, (RF, RF, RF_IF), rd_rn_rm),
8900 C3(sufe, e280100, 3, (RF, RF, RF_IF), rd_rn_rm),
8901 C3(sufep, e280120, 3, (RF, RF, RF_IF), rd_rn_rm),
8902 C3(sufem, e280140, 3, (RF, RF, RF_IF), rd_rn_rm),
8903 C3(sufez, e280160, 3, (RF, RF, RF_IF), rd_rn_rm),
8905 C3(rsfs, e300100, 3, (RF, RF, RF_IF), rd_rn_rm),
8906 C3(rsfsp, e300120, 3, (RF, RF, RF_IF), rd_rn_rm),
8907 C3(rsfsm, e300140, 3, (RF, RF, RF_IF), rd_rn_rm),
8908 C3(rsfsz, e300160, 3, (RF, RF, RF_IF), rd_rn_rm),
8909 C3(rsfd, e300180, 3, (RF, RF, RF_IF), rd_rn_rm),
8910 C3(rsfdp, e3001a0, 3, (RF, RF, RF_IF), rd_rn_rm),
8911 C3(rsfdm, e3001c0, 3, (RF, RF, RF_IF), rd_rn_rm),
8912 C3(rsfdz, e3001e0, 3, (RF, RF, RF_IF), rd_rn_rm),
8913 C3(rsfe, e380100, 3, (RF, RF, RF_IF), rd_rn_rm),
8914 C3(rsfep, e380120, 3, (RF, RF, RF_IF), rd_rn_rm),
8915 C3(rsfem, e380140, 3, (RF, RF, RF_IF), rd_rn_rm),
8916 C3(rsfez, e380160, 3, (RF, RF, RF_IF), rd_rn_rm),
8918 C3(mufs, e100100, 3, (RF, RF, RF_IF), rd_rn_rm),
8919 C3(mufsp, e100120, 3, (RF, RF, RF_IF), rd_rn_rm),
8920 C3(mufsm, e100140, 3, (RF, RF, RF_IF), rd_rn_rm),
8921 C3(mufsz, e100160, 3, (RF, RF, RF_IF), rd_rn_rm),
8922 C3(mufd, e100180, 3, (RF, RF, RF_IF), rd_rn_rm),
8923 C3(mufdp, e1001a0, 3, (RF, RF, RF_IF), rd_rn_rm),
8924 C3(mufdm, e1001c0, 3, (RF, RF, RF_IF), rd_rn_rm),
8925 C3(mufdz, e1001e0, 3, (RF, RF, RF_IF), rd_rn_rm),
8926 C3(mufe, e180100, 3, (RF, RF, RF_IF), rd_rn_rm),
8927 C3(mufep, e180120, 3, (RF, RF, RF_IF), rd_rn_rm),
8928 C3(mufem, e180140, 3, (RF, RF, RF_IF), rd_rn_rm),
8929 C3(mufez, e180160, 3, (RF, RF, RF_IF), rd_rn_rm),
8931 C3(dvfs, e400100, 3, (RF, RF, RF_IF), rd_rn_rm),
8932 C3(dvfsp, e400120, 3, (RF, RF, RF_IF), rd_rn_rm),
8933 C3(dvfsm, e400140, 3, (RF, RF, RF_IF), rd_rn_rm),
8934 C3(dvfsz, e400160, 3, (RF, RF, RF_IF), rd_rn_rm),
8935 C3(dvfd, e400180, 3, (RF, RF, RF_IF), rd_rn_rm),
8936 C3(dvfdp, e4001a0, 3, (RF, RF, RF_IF), rd_rn_rm),
8937 C3(dvfdm, e4001c0, 3, (RF, RF, RF_IF), rd_rn_rm),
8938 C3(dvfdz, e4001e0, 3, (RF, RF, RF_IF), rd_rn_rm),
8939 C3(dvfe, e480100, 3, (RF, RF, RF_IF), rd_rn_rm),
8940 C3(dvfep, e480120, 3, (RF, RF, RF_IF), rd_rn_rm),
8941 C3(dvfem, e480140, 3, (RF, RF, RF_IF), rd_rn_rm),
8942 C3(dvfez, e480160, 3, (RF, RF, RF_IF), rd_rn_rm),
8944 C3(rdfs, e500100, 3, (RF, RF, RF_IF), rd_rn_rm),
8945 C3(rdfsp, e500120, 3, (RF, RF, RF_IF), rd_rn_rm),
8946 C3(rdfsm, e500140, 3, (RF, RF, RF_IF), rd_rn_rm),
8947 C3(rdfsz, e500160, 3, (RF, RF, RF_IF), rd_rn_rm),
8948 C3(rdfd, e500180, 3, (RF, RF, RF_IF), rd_rn_rm),
8949 C3(rdfdp, e5001a0, 3, (RF, RF, RF_IF), rd_rn_rm),
8950 C3(rdfdm, e5001c0, 3, (RF, RF, RF_IF), rd_rn_rm),
8951 C3(rdfdz, e5001e0, 3, (RF, RF, RF_IF), rd_rn_rm),
8952 C3(rdfe, e580100, 3, (RF, RF, RF_IF), rd_rn_rm),
8953 C3(rdfep, e580120, 3, (RF, RF, RF_IF), rd_rn_rm),
8954 C3(rdfem, e580140, 3, (RF, RF, RF_IF), rd_rn_rm),
8955 C3(rdfez, e580160, 3, (RF, RF, RF_IF), rd_rn_rm),
8957 C3(pows, e600100, 3, (RF, RF, RF_IF), rd_rn_rm),
8958 C3(powsp, e600120, 3, (RF, RF, RF_IF), rd_rn_rm),
8959 C3(powsm, e600140, 3, (RF, RF, RF_IF), rd_rn_rm),
8960 C3(powsz, e600160, 3, (RF, RF, RF_IF), rd_rn_rm),
8961 C3(powd, e600180, 3, (RF, RF, RF_IF), rd_rn_rm),
8962 C3(powdp, e6001a0, 3, (RF, RF, RF_IF), rd_rn_rm),
8963 C3(powdm, e6001c0, 3, (RF, RF, RF_IF), rd_rn_rm),
8964 C3(powdz, e6001e0, 3, (RF, RF, RF_IF), rd_rn_rm),
8965 C3(powe, e680100, 3, (RF, RF, RF_IF), rd_rn_rm),
8966 C3(powep, e680120, 3, (RF, RF, RF_IF), rd_rn_rm),
8967 C3(powem, e680140, 3, (RF, RF, RF_IF), rd_rn_rm),
8968 C3(powez, e680160, 3, (RF, RF, RF_IF), rd_rn_rm),
8970 C3(rpws, e700100, 3, (RF, RF, RF_IF), rd_rn_rm),
8971 C3(rpwsp, e700120, 3, (RF, RF, RF_IF), rd_rn_rm),
8972 C3(rpwsm, e700140, 3, (RF, RF, RF_IF), rd_rn_rm),
8973 C3(rpwsz, e700160, 3, (RF, RF, RF_IF), rd_rn_rm),
8974 C3(rpwd, e700180, 3, (RF, RF, RF_IF), rd_rn_rm),
8975 C3(rpwdp, e7001a0, 3, (RF, RF, RF_IF), rd_rn_rm),
8976 C3(rpwdm, e7001c0, 3, (RF, RF, RF_IF), rd_rn_rm),
8977 C3(rpwdz, e7001e0, 3, (RF, RF, RF_IF), rd_rn_rm),
8978 C3(rpwe, e780100, 3, (RF, RF, RF_IF), rd_rn_rm),
8979 C3(rpwep, e780120, 3, (RF, RF, RF_IF), rd_rn_rm),
8980 C3(rpwem, e780140, 3, (RF, RF, RF_IF), rd_rn_rm),
8981 C3(rpwez, e780160, 3, (RF, RF, RF_IF), rd_rn_rm),
8983 C3(rmfs, e800100, 3, (RF, RF, RF_IF), rd_rn_rm),
8984 C3(rmfsp, e800120, 3, (RF, RF, RF_IF), rd_rn_rm),
8985 C3(rmfsm, e800140, 3, (RF, RF, RF_IF), rd_rn_rm),
8986 C3(rmfsz, e800160, 3, (RF, RF, RF_IF), rd_rn_rm),
8987 C3(rmfd, e800180, 3, (RF, RF, RF_IF), rd_rn_rm),
8988 C3(rmfdp, e8001a0, 3, (RF, RF, RF_IF), rd_rn_rm),
8989 C3(rmfdm, e8001c0, 3, (RF, RF, RF_IF), rd_rn_rm),
8990 C3(rmfdz, e8001e0, 3, (RF, RF, RF_IF), rd_rn_rm),
8991 C3(rmfe, e880100, 3, (RF, RF, RF_IF), rd_rn_rm),
8992 C3(rmfep, e880120, 3, (RF, RF, RF_IF), rd_rn_rm),
8993 C3(rmfem, e880140, 3, (RF, RF, RF_IF), rd_rn_rm),
8994 C3(rmfez, e880160, 3, (RF, RF, RF_IF), rd_rn_rm),
8996 C3(fmls, e900100, 3, (RF, RF, RF_IF), rd_rn_rm),
8997 C3(fmlsp, e900120, 3, (RF, RF, RF_IF), rd_rn_rm),
8998 C3(fmlsm, e900140, 3, (RF, RF, RF_IF), rd_rn_rm),
8999 C3(fmlsz, e900160, 3, (RF, RF, RF_IF), rd_rn_rm),
9000 C3(fmld, e900180, 3, (RF, RF, RF_IF), rd_rn_rm),
9001 C3(fmldp, e9001a0, 3, (RF, RF, RF_IF), rd_rn_rm),
9002 C3(fmldm, e9001c0, 3, (RF, RF, RF_IF), rd_rn_rm),
9003 C3(fmldz, e9001e0, 3, (RF, RF, RF_IF), rd_rn_rm),
9004 C3(fmle, e980100, 3, (RF, RF, RF_IF), rd_rn_rm),
9005 C3(fmlep, e980120, 3, (RF, RF, RF_IF), rd_rn_rm),
9006 C3(fmlem, e980140, 3, (RF, RF, RF_IF), rd_rn_rm),
9007 C3(fmlez, e980160, 3, (RF, RF, RF_IF), rd_rn_rm),
9009 C3(fdvs, ea00100, 3, (RF, RF, RF_IF), rd_rn_rm),
9010 C3(fdvsp, ea00120, 3, (RF, RF, RF_IF), rd_rn_rm),
9011 C3(fdvsm, ea00140, 3, (RF, RF, RF_IF), rd_rn_rm),
9012 C3(fdvsz, ea00160, 3, (RF, RF, RF_IF), rd_rn_rm),
9013 C3(fdvd, ea00180, 3, (RF, RF, RF_IF), rd_rn_rm),
9014 C3(fdvdp, ea001a0, 3, (RF, RF, RF_IF), rd_rn_rm),
9015 C3(fdvdm, ea001c0, 3, (RF, RF, RF_IF), rd_rn_rm),
9016 C3(fdvdz, ea001e0, 3, (RF, RF, RF_IF), rd_rn_rm),
9017 C3(fdve, ea80100, 3, (RF, RF, RF_IF), rd_rn_rm),
9018 C3(fdvep, ea80120, 3, (RF, RF, RF_IF), rd_rn_rm),
9019 C3(fdvem, ea80140, 3, (RF, RF, RF_IF), rd_rn_rm),
9020 C3(fdvez, ea80160, 3, (RF, RF, RF_IF), rd_rn_rm),
9022 C3(frds, eb00100, 3, (RF, RF, RF_IF), rd_rn_rm),
9023 C3(frdsp, eb00120, 3, (RF, RF, RF_IF), rd_rn_rm),
9024 C3(frdsm, eb00140, 3, (RF, RF, RF_IF), rd_rn_rm),
9025 C3(frdsz, eb00160, 3, (RF, RF, RF_IF), rd_rn_rm),
9026 C3(frdd, eb00180, 3, (RF, RF, RF_IF), rd_rn_rm),
9027 C3(frddp, eb001a0, 3, (RF, RF, RF_IF), rd_rn_rm),
9028 C3(frddm, eb001c0, 3, (RF, RF, RF_IF), rd_rn_rm),
9029 C3(frddz, eb001e0, 3, (RF, RF, RF_IF), rd_rn_rm),
9030 C3(frde, eb80100, 3, (RF, RF, RF_IF), rd_rn_rm),
9031 C3(frdep, eb80120, 3, (RF, RF, RF_IF), rd_rn_rm),
9032 C3(frdem, eb80140, 3, (RF, RF, RF_IF), rd_rn_rm),
9033 C3(frdez, eb80160, 3, (RF, RF, RF_IF), rd_rn_rm),
9035 C3(pols, ec00100, 3, (RF, RF, RF_IF), rd_rn_rm),
9036 C3(polsp, ec00120, 3, (RF, RF, RF_IF), rd_rn_rm),
9037 C3(polsm, ec00140, 3, (RF, RF, RF_IF), rd_rn_rm),
9038 C3(polsz, ec00160, 3, (RF, RF, RF_IF), rd_rn_rm),
9039 C3(pold, ec00180, 3, (RF, RF, RF_IF), rd_rn_rm),
9040 C3(poldp, ec001a0, 3, (RF, RF, RF_IF), rd_rn_rm),
9041 C3(poldm, ec001c0, 3, (RF, RF, RF_IF), rd_rn_rm),
9042 C3(poldz, ec001e0, 3, (RF, RF, RF_IF), rd_rn_rm),
9043 C3(pole, ec80100, 3, (RF, RF, RF_IF), rd_rn_rm),
9044 C3(polep, ec80120, 3, (RF, RF, RF_IF), rd_rn_rm),
9045 C3(polem, ec80140, 3, (RF, RF, RF_IF), rd_rn_rm),
9046 C3(polez, ec80160, 3, (RF, RF, RF_IF), rd_rn_rm),
9048 CE(cmf, e90f110, 2, (RF, RF_IF), fpa_cmp),
9049 C3E(cmfe, ed0f110, 2, (RF, RF_IF), fpa_cmp),
9050 CE(cnf, eb0f110, 2, (RF, RF_IF), fpa_cmp),
9051 C3E(cnfe, ef0f110, 2, (RF, RF_IF), fpa_cmp),
9053 C3(flts, e000110, 2, (RF, RR), rn_rd),
9054 C3(fltsp, e000130, 2, (RF, RR), rn_rd),
9055 C3(fltsm, e000150, 2, (RF, RR), rn_rd),
9056 C3(fltsz, e000170, 2, (RF, RR), rn_rd),
9057 C3(fltd, e000190, 2, (RF, RR), rn_rd),
9058 C3(fltdp, e0001b0, 2, (RF, RR), rn_rd),
9059 C3(fltdm, e0001d0, 2, (RF, RR), rn_rd),
9060 C3(fltdz, e0001f0, 2, (RF, RR), rn_rd),
9061 C3(flte, e080110, 2, (RF, RR), rn_rd),
9062 C3(fltep, e080130, 2, (RF, RR), rn_rd),
9063 C3(fltem, e080150, 2, (RF, RR), rn_rd),
9064 C3(fltez, e080170, 2, (RF, RR), rn_rd),
9066 /* The implementation of the FIX instruction is broken on some
9067 assemblers, in that it accepts a precision specifier as well as a
9068 rounding specifier, despite the fact that this is meaningless.
9069 To be more compatible, we accept it as well, though of course it
9070 does not set any bits. */
9071 CE(fix, e100110, 2, (RR, RF), rd_rm),
9072 C3(fixp, e100130, 2, (RR, RF), rd_rm),
9073 C3(fixm, e100150, 2, (RR, RF), rd_rm),
9074 C3(fixz, e100170, 2, (RR, RF), rd_rm),
9075 C3(fixsp, e100130, 2, (RR, RF), rd_rm),
9076 C3(fixsm, e100150, 2, (RR, RF), rd_rm),
9077 C3(fixsz, e100170, 2, (RR, RF), rd_rm),
9078 C3(fixdp, e100130, 2, (RR, RF), rd_rm),
9079 C3(fixdm, e100150, 2, (RR, RF), rd_rm),
9080 C3(fixdz, e100170, 2, (RR, RF), rd_rm),
9081 C3(fixep, e100130, 2, (RR, RF), rd_rm),
9082 C3(fixem, e100150, 2, (RR, RF), rd_rm),
9083 C3(fixez, e100170, 2, (RR, RF), rd_rm),
9085 /* Instructions that were new with the real FPA, call them V2. */
9087 #define ARM_VARIANT FPU_FPA_EXT_V2
9088 CE(lfm, c100200, 3, (RF, I4b, ADDR), fpa_ldmstm),
9089 C3(lfmfd, c900200, 3, (RF, I4b, ADDR), fpa_ldmstm),
9090 C3(lfmea, d100200, 3, (RF, I4b, ADDR), fpa_ldmstm),
9091 CE(sfm, c000200, 3, (RF, I4b, ADDR), fpa_ldmstm),
9092 C3(sfmfd, d000200, 3, (RF, I4b, ADDR), fpa_ldmstm),
9093 C3(sfmea, c800200, 3, (RF, I4b, ADDR), fpa_ldmstm),
9096 #define ARM_VARIANT FPU_VFP_EXT_V1xD /* VFP V1xD (single precision). */
9097 /* Moves and type conversions. */
9098 CE(fcpys, eb00a40, 2, (RVS, RVS), vfp_sp_monadic),
9099 CE(fmrs, e100a10, 2, (RR, RVS), vfp_reg_from_sp),
9100 CE(fmsr, e000a10, 2, (RVS, RR), vfp_sp_from_reg),
9101 CE(fmstat, ef1fa10, 0, (), noargs),
9102 CE(fsitos, eb80ac0, 2, (RVS, RVS), vfp_sp_monadic),
9103 CE(fuitos, eb80a40, 2, (RVS, RVS), vfp_sp_monadic),
9104 CE(ftosis, ebd0a40, 2, (RVS, RVS), vfp_sp_monadic),
9105 CE(ftosizs, ebd0ac0, 2, (RVS, RVS), vfp_sp_monadic),
9106 CE(ftouis, ebc0a40, 2, (RVS, RVS), vfp_sp_monadic),
9107 CE(ftouizs, ebc0ac0, 2, (RVS, RVS), vfp_sp_monadic),
9108 CE(fmrx, ef00a10, 2, (RR, RVC), rd_rn),
9109 CE(fmxr, ee00a10, 2, (RVC, RR), rn_rd),
9111 /* Memory operations. */
9112 CE(flds, d100a00, 2, (RVS, ADDR), vfp_sp_ldst),
9113 CE(fsts, d000a00, 2, (RVS, ADDR), vfp_sp_ldst),
9114 CE(fldmias, c900a00, 2, (RRw, VRSLST), vfp_sp_ldstmia),
9115 CE(fldmfds, c900a00, 2, (RRw, VRSLST), vfp_sp_ldstmia),
9116 CE(fldmdbs, d300a00, 2, (RRw, VRSLST), vfp_sp_ldstmdb),
9117 CE(fldmeas, d300a00, 2, (RRw, VRSLST), vfp_sp_ldstmdb),
9118 CE(fldmiax, c900b00, 2, (RRw, VRDLST), vfp_xp_ldstmia),
9119 CE(fldmfdx, c900b00, 2, (RRw, VRDLST), vfp_xp_ldstmia),
9120 CE(fldmdbx, d300b00, 2, (RRw, VRDLST), vfp_xp_ldstmdb),
9121 CE(fldmeax, d300b00, 2, (RRw, VRDLST), vfp_xp_ldstmdb),
9122 CE(fstmias, c800a00, 2, (RRw, VRSLST), vfp_sp_ldstmia),
9123 CE(fstmeas, c800a00, 2, (RRw, VRSLST), vfp_sp_ldstmia),
9124 CE(fstmdbs, d200a00, 2, (RRw, VRSLST), vfp_sp_ldstmdb),
9125 CE(fstmfds, d200a00, 2, (RRw, VRSLST), vfp_sp_ldstmdb),
9126 CE(fstmiax, c800b00, 2, (RRw, VRDLST), vfp_xp_ldstmia),
9127 CE(fstmeax, c800b00, 2, (RRw, VRDLST), vfp_xp_ldstmia),
9128 CE(fstmdbx, d200b00, 2, (RRw, VRDLST), vfp_xp_ldstmdb),
9129 CE(fstmfdx, d200b00, 2, (RRw, VRDLST), vfp_xp_ldstmdb),
9131 /* Monadic operations. */
9132 CE(fabss, eb00ac0, 2, (RVS, RVS), vfp_sp_monadic),
9133 CE(fnegs, eb10a40, 2, (RVS, RVS), vfp_sp_monadic),
9134 CE(fsqrts, eb10ac0, 2, (RVS, RVS), vfp_sp_monadic),
9136 /* Dyadic operations. */
9137 CE(fadds, e300a00, 3, (RVS, RVS, RVS), vfp_sp_dyadic),
9138 CE(fsubs, e300a40, 3, (RVS, RVS, RVS), vfp_sp_dyadic),
9139 CE(fmuls, e200a00, 3, (RVS, RVS, RVS), vfp_sp_dyadic),
9140 CE(fdivs, e800a00, 3, (RVS, RVS, RVS), vfp_sp_dyadic),
9141 CE(fmacs, e000a00, 3, (RVS, RVS, RVS), vfp_sp_dyadic),
9142 CE(fmscs, e100a00, 3, (RVS, RVS, RVS), vfp_sp_dyadic),
9143 CE(fnmuls, e200a40, 3, (RVS, RVS, RVS), vfp_sp_dyadic),
9144 CE(fnmacs, e000a40, 3, (RVS, RVS, RVS), vfp_sp_dyadic),
9145 CE(fnmscs, e100a40, 3, (RVS, RVS, RVS), vfp_sp_dyadic),
9148 CE(fcmps, eb40a40, 2, (RVS, RVS), vfp_sp_monadic),
9149 CE(fcmpzs, eb50a40, 1, (RVS), vfp_sp_compare_z),
9150 CE(fcmpes, eb40ac0, 2, (RVS, RVS), vfp_sp_monadic),
9151 CE(fcmpezs, eb50ac0, 1, (RVS), vfp_sp_compare_z),
9154 #define ARM_VARIANT FPU_VFP_EXT_V1 /* VFP V1 (Double precision). */
9155 /* Moves and type conversions. */
9156 CE(fcpyd, eb00b40, 2, (RVD, RVD), rd_rm),
9157 CE(fcvtds, eb70ac0, 2, (RVD, RVS), vfp_dp_sp_cvt),
9158 CE(fcvtsd, eb70bc0, 2, (RVS, RVD), vfp_sp_dp_cvt),
9159 CE(fmdhr, e200b10, 2, (RVD, RR), rn_rd),
9160 CE(fmdlr, e000b10, 2, (RVD, RR), rn_rd),
9161 CE(fmrdh, e300b10, 2, (RR, RVD), rd_rn),
9162 CE(fmrdl, e100b10, 2, (RR, RVD), rd_rn),
9163 CE(fsitod, eb80bc0, 2, (RVD, RVS), vfp_dp_sp_cvt),
9164 CE(fuitod, eb80b40, 2, (RVD, RVS), vfp_dp_sp_cvt),
9165 CE(ftosid, ebd0b40, 2, (RVS, RVD), vfp_sp_dp_cvt),
9166 CE(ftosizd, ebd0bc0, 2, (RVS, RVD), vfp_sp_dp_cvt),
9167 CE(ftouid, ebc0b40, 2, (RVS, RVD), vfp_sp_dp_cvt),
9168 CE(ftouizd, ebc0bc0, 2, (RVS, RVD), vfp_sp_dp_cvt),
9170 /* Memory operations. */
9171 CE(fldd, d100b00, 2, (RVD, ADDR), vfp_dp_ldst),
9172 CE(fstd, d000b00, 2, (RVD, ADDR), vfp_dp_ldst),
9173 CE(fldmiad, c900b00, 2, (RRw, VRDLST), vfp_dp_ldstmia),
9174 CE(fldmfdd, c900b00, 2, (RRw, VRDLST), vfp_dp_ldstmia),
9175 CE(fldmdbd, d300b00, 2, (RRw, VRDLST), vfp_dp_ldstmdb),
9176 CE(fldmead, d300b00, 2, (RRw, VRDLST), vfp_dp_ldstmdb),
9177 CE(fstmiad, c800b00, 2, (RRw, VRDLST), vfp_dp_ldstmia),
9178 CE(fstmead, c800b00, 2, (RRw, VRDLST), vfp_dp_ldstmia),
9179 CE(fstmdbd, d200b00, 2, (RRw, VRDLST), vfp_dp_ldstmdb),
9180 CE(fstmfdd, d200b00, 2, (RRw, VRDLST), vfp_dp_ldstmdb),
9182 /* Monadic operations. */
9183 CE(fabsd, eb00bc0, 2, (RVD, RVD), rd_rm),
9184 CE(fnegd, eb10b40, 2, (RVD, RVD), rd_rm),
9185 CE(fsqrtd, eb10bc0, 2, (RVD, RVD), rd_rm),
9187 /* Dyadic operations. */
9188 CE(faddd, e300b00, 3, (RVD, RVD, RVD), rd_rn_rm),
9189 CE(fsubd, e300b40, 3, (RVD, RVD, RVD), rd_rn_rm),
9190 CE(fmuld, e200b00, 3, (RVD, RVD, RVD), rd_rn_rm),
9191 CE(fdivd, e800b00, 3, (RVD, RVD, RVD), rd_rn_rm),
9192 CE(fmacd, e000b00, 3, (RVD, RVD, RVD), rd_rn_rm),
9193 CE(fmscd, e100b00, 3, (RVD, RVD, RVD), rd_rn_rm),
9194 CE(fnmuld, e200b40, 3, (RVD, RVD, RVD), rd_rn_rm),
9195 CE(fnmacd, e000b40, 3, (RVD, RVD, RVD), rd_rn_rm),
9196 CE(fnmscd, e100b40, 3, (RVD, RVD, RVD), rd_rn_rm),
9199 CE(fcmpd, eb40b40, 2, (RVD, RVD), rd_rm),
9200 CE(fcmpzd, eb50b40, 1, (RVD), rd),
9201 CE(fcmped, eb40bc0, 2, (RVD, RVD), rd_rm),
9202 CE(fcmpezd, eb50bc0, 1, (RVD), rd),
9205 #define ARM_VARIANT FPU_VFP_EXT_V2
9206 CE(fmsrr, c400a10, 3, (VRSLST, RR, RR), vfp_sp2_from_reg2),
9207 CE(fmrrs, c500a10, 3, (RR, RR, VRSLST), vfp_reg2_from_sp2),
9208 CE(fmdrr, c400b10, 3, (RVD, RR, RR), rm_rd_rn),
9209 CE(fmrrd, c500b10, 3, (RR, RR, RVD), rd_rn_rm),
9212 #define ARM_VARIANT ARM_CEXT_XSCALE /* Intel XScale extensions. */
9213 CE(mia, e200010, 3, (RXA, RRnpc, RRnpc), xsc_mia),
9214 CE(miaph, e280010, 3, (RXA, RRnpc, RRnpc), xsc_mia),
9215 CE(miabb, e2c0010, 3, (RXA, RRnpc, RRnpc), xsc_mia),
9216 CE(miabt, e2d0010, 3, (RXA, RRnpc, RRnpc), xsc_mia),
9217 CE(miatb, e2e0010, 3, (RXA, RRnpc, RRnpc), xsc_mia),
9218 CE(miatt, e2f0010, 3, (RXA, RRnpc, RRnpc), xsc_mia),
9219 CE(mar, c400000, 3, (RXA, RRnpc, RRnpc), xsc_mar),
9220 CE(mra, c500000, 3, (RRnpc, RRnpc, RXA), xsc_mra),
9223 #define ARM_VARIANT ARM_CEXT_IWMMXT /* Intel Wireless MMX technology. */
9224 CE(tandcb, e13f130, 1, (RR), iwmmxt_tandorc),
9225 CE(tandch, e53f130, 1, (RR), iwmmxt_tandorc),
9226 CE(tandcw, e93f130, 1, (RR), iwmmxt_tandorc),
9227 CE(tbcstb, e400010, 2, (RIWR, RR), rn_rd),
9228 CE(tbcsth, e400050, 2, (RIWR, RR), rn_rd),
9229 CE(tbcstw, e400090, 2, (RIWR, RR), rn_rd),
9230 CE(textrcb, e130170, 2, (RR, I7), iwmmxt_textrc),
9231 CE(textrch, e530170, 2, (RR, I7), iwmmxt_textrc),
9232 CE(textrcw, e930170, 2, (RR, I7), iwmmxt_textrc),
9233 CE(textrmub, e100070, 3, (RR, RIWR, I7), iwmmxt_textrm),
9234 CE(textrmuh, e500070, 3, (RR, RIWR, I7), iwmmxt_textrm),
9235 CE(textrmuw, e900070, 3, (RR, RIWR, I7), iwmmxt_textrm),
9236 CE(textrmsb, e100078, 3, (RR, RIWR, I7), iwmmxt_textrm),
9237 CE(textrmsh, e500078, 3, (RR, RIWR, I7), iwmmxt_textrm),
9238 CE(textrmsw, e900078, 3, (RR, RIWR, I7), iwmmxt_textrm),
9239 CE(tinsrb, e600010, 3, (RIWR, RR, I7), iwmmxt_tinsr),
9240 CE(tinsrh, e600050, 3, (RIWR, RR, I7), iwmmxt_tinsr),
9241 CE(tinsrw, e600090, 3, (RIWR, RR, I7), iwmmxt_tinsr),
9242 CE(tmcr, e000110, 2, (RIWC, RR), rn_rd),
9243 CE(tmcrr, c400000, 3, (RIWR, RR, RR), rm_rd_rn),
9244 CE(tmia, e200010, 3, (RIWR, RR, RR), iwmmxt_tmia),
9245 CE(tmiaph, e280010, 3, (RIWR, RR, RR), iwmmxt_tmia),
9246 CE(tmiabb, e2c0010, 3, (RIWR, RR, RR), iwmmxt_tmia),
9247 CE(tmiabt, e2d0010, 3, (RIWR, RR, RR), iwmmxt_tmia),
9248 CE(tmiatb, e2e0010, 3, (RIWR, RR, RR), iwmmxt_tmia),
9249 CE(tmiatt, e2f0010, 3, (RIWR, RR, RR), iwmmxt_tmia),
9250 CE(tmovmskb, e100030, 2, (RR, RIWR), rd_rn),
9251 CE(tmovmskh, e500030, 2, (RR, RIWR), rd_rn),
9252 CE(tmovmskw, e900030, 2, (RR, RIWR), rd_rn),
9253 CE(tmrc, e100110, 2, (RR, RIWC), rd_rn),
9254 CE(tmrrc, c500000, 3, (RR, RR, RIWR), rd_rn_rm),
9255 CE(torcb, e13f150, 1, (RR), iwmmxt_tandorc),
9256 CE(torch, e53f150, 1, (RR), iwmmxt_tandorc),
9257 CE(torcw, e93f150, 1, (RR), iwmmxt_tandorc),
9258 CE(waccb, e0001c0, 2, (RIWR, RIWR), rd_rn),
9259 CE(wacch, e4001c0, 2, (RIWR, RIWR), rd_rn),
9260 CE(waccw, e8001c0, 2, (RIWR, RIWR), rd_rn),
9261 CE(waddbss, e300180, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
9262 CE(waddb, e000180, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
9263 CE(waddbus, e100180, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
9264 CE(waddhss, e700180, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
9265 CE(waddh, e400180, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
9266 CE(waddhus, e500180, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
9267 CE(waddwss, eb00180, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
9268 CE(waddw, e800180, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
9269 CE(waddwus, e900180, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
9270 CE(waligni, e000020, 4, (RIWR, RIWR, RIWR, I7), iwmmxt_waligni),
9271 CE(walignr0, e800020, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
9272 CE(walignr1, e900020, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
9273 CE(walignr2, ea00020, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
9274 CE(walignr3, eb00020, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
9275 CE(wand, e200000, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
9276 CE(wandn, e300000, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
9277 CE(wavg2b, e800000, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
9278 CE(wavg2br, e900000, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
9279 CE(wavg2h, ec00000, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
9280 CE(wavg2hr, ed00000, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
9281 CE(wcmpeqb, e000060, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
9282 CE(wcmpeqh, e400060, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
9283 CE(wcmpeqw, e800060, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
9284 CE(wcmpgtub, e100060, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
9285 CE(wcmpgtuh, e500060, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
9286 CE(wcmpgtuw, e900060, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
9287 CE(wcmpgtsb, e300060, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
9288 CE(wcmpgtsh, e700060, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
9289 CE(wcmpgtsw, eb00060, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
9290 CE(wldrb, c100000, 2, (RIWR, ADDR), iwmmxt_wldstbh),
9291 CE(wldrh, c500000, 2, (RIWR, ADDR), iwmmxt_wldstbh),
9292 CE(wldrw, c100100, 2, (RIWR_RIWC, ADDR), iwmmxt_wldstw),
9293 CE(wldrd, c500100, 2, (RIWR, ADDR), iwmmxt_wldstd),
9294 CE(wmacs, e600100, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
9295 CE(wmacsz, e700100, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
9296 CE(wmacu, e400100, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
9297 CE(wmacuz, e500100, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
9298 CE(wmadds, ea00100, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
9299 CE(wmaddu, e800100, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
9300 CE(wmaxsb, e200160, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
9301 CE(wmaxsh, e600160, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
9302 CE(wmaxsw, ea00160, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
9303 CE(wmaxub, e000160, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
9304 CE(wmaxuh, e400160, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
9305 CE(wmaxuw, e800160, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
9306 CE(wminsb, e300160, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
9307 CE(wminsh, e700160, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
9308 CE(wminsw, eb00160, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
9309 CE(wminub, e100160, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
9310 CE(wminuh, e500160, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
9311 CE(wminuw, e900160, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
9312 CE(wmov, e000000, 2, (RIWR, RIWR), iwmmxt_wmov),
9313 CE(wmulsm, e300100, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
9314 CE(wmulsl, e200100, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
9315 CE(wmulum, e100100, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
9316 CE(wmulul, e000100, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
9317 CE(wor, e000000, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
9318 CE(wpackhss, e700080, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
9319 CE(wpackhus, e500080, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
9320 CE(wpackwss, eb00080, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
9321 CE(wpackwus, e900080, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
9322 CE(wpackdss, ef00080, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
9323 CE(wpackdus, ed00080, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
9324 CE(wrorh, e700040, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
9325 CE(wrorhg, e700148, 3, (RIWR, RIWR, RIWG), rd_rn_rm),
9326 CE(wrorw, eb00040, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
9327 CE(wrorwg, eb00148, 3, (RIWR, RIWR, RIWG), rd_rn_rm),
9328 CE(wrord, ef00040, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
9329 CE(wrordg, ef00148, 3, (RIWR, RIWR, RIWG), rd_rn_rm),
9330 CE(wsadb, e000120, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
9331 CE(wsadbz, e100120, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
9332 CE(wsadh, e400120, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
9333 CE(wsadhz, e500120, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
9334 CE(wshufh, e0001e0, 3, (RIWR, RIWR, I255), iwmmxt_wshufh),
9335 CE(wsllh, e500040, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
9336 CE(wsllhg, e500148, 3, (RIWR, RIWR, RIWG), rd_rn_rm),
9337 CE(wsllw, e900040, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
9338 CE(wsllwg, e900148, 3, (RIWR, RIWR, RIWG), rd_rn_rm),
9339 CE(wslld, ed00040, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
9340 CE(wslldg, ed00148, 3, (RIWR, RIWR, RIWG), rd_rn_rm),
9341 CE(wsrah, e400040, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
9342 CE(wsrahg, e400148, 3, (RIWR, RIWR, RIWG), rd_rn_rm),
9343 CE(wsraw, e800040, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
9344 CE(wsrawg, e800148, 3, (RIWR, RIWR, RIWG), rd_rn_rm),
9345 CE(wsrad, ec00040, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
9346 CE(wsradg, ec00148, 3, (RIWR, RIWR, RIWG), rd_rn_rm),
9347 CE(wsrlh, e600040, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
9348 CE(wsrlhg, e600148, 3, (RIWR, RIWR, RIWG), rd_rn_rm),
9349 CE(wsrlw, ea00040, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
9350 CE(wsrlwg, ea00148, 3, (RIWR, RIWR, RIWG), rd_rn_rm),
9351 CE(wsrld, ee00040, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
9352 CE(wsrldg, ee00148, 3, (RIWR, RIWR, RIWG), rd_rn_rm),
9353 CE(wstrb, c000000, 2, (RIWR, ADDR), iwmmxt_wldstbh),
9354 CE(wstrh, c400000, 2, (RIWR, ADDR), iwmmxt_wldstbh),
9355 CE(wstrw, c000100, 2, (RIWR_RIWC, ADDR), iwmmxt_wldstw),
9356 CE(wstrd, c400100, 2, (RIWR, ADDR), iwmmxt_wldstd),
9357 CE(wsubbss, e3001a0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
9358 CE(wsubb, e0001a0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
9359 CE(wsubbus, e1001a0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
9360 CE(wsubhss, e7001a0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
9361 CE(wsubh, e4001a0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
9362 CE(wsubhus, e5001a0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
9363 CE(wsubwss, eb001a0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
9364 CE(wsubw, e8001a0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
9365 CE(wsubwus, e9001a0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
9366 CE(wunpckehub,e0000c0, 2, (RIWR, RIWR), rd_rn),
9367 CE(wunpckehuh,e4000c0, 2, (RIWR, RIWR), rd_rn),
9368 CE(wunpckehuw,e8000c0, 2, (RIWR, RIWR), rd_rn),
9369 CE(wunpckehsb,e2000c0, 2, (RIWR, RIWR), rd_rn),
9370 CE(wunpckehsh,e6000c0, 2, (RIWR, RIWR), rd_rn),
9371 CE(wunpckehsw,ea000c0, 2, (RIWR, RIWR), rd_rn),
9372 CE(wunpckihb, e1000c0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
9373 CE(wunpckihh, e5000c0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
9374 CE(wunpckihw, e9000c0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
9375 CE(wunpckelub,e0000e0, 2, (RIWR, RIWR), rd_rn),
9376 CE(wunpckeluh,e4000e0, 2, (RIWR, RIWR), rd_rn),
9377 CE(wunpckeluw,e8000e0, 2, (RIWR, RIWR), rd_rn),
9378 CE(wunpckelsb,e2000e0, 2, (RIWR, RIWR), rd_rn),
9379 CE(wunpckelsh,e6000e0, 2, (RIWR, RIWR), rd_rn),
9380 CE(wunpckelsw,ea000e0, 2, (RIWR, RIWR), rd_rn),
9381 CE(wunpckilb, e1000e0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
9382 CE(wunpckilh, e5000e0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
9383 CE(wunpckilw, e9000e0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
9384 CE(wxor, e100000, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
9385 CE(wzero, e300000, 1, (RIWR), iwmmxt_wzero),
9388 #define ARM_VARIANT ARM_CEXT_MAVERICK /* Cirrus Maverick instructions. */
9389 CE(cfldrs, c100400, 2, (RMF, ADDR), rd_cpaddr),
9390 CE(cfldrd, c500400, 2, (RMD, ADDR), rd_cpaddr),
9391 CE(cfldr32, c100500, 2, (RMFX, ADDR), rd_cpaddr),
9392 CE(cfldr64, c500500, 2, (RMDX, ADDR), rd_cpaddr),
9393 CE(cfstrs, c000400, 2, (RMF, ADDR), rd_cpaddr),
9394 CE(cfstrd, c400400, 2, (RMD, ADDR), rd_cpaddr),
9395 CE(cfstr32, c000500, 2, (RMFX, ADDR), rd_cpaddr),
9396 CE(cfstr64, c400500, 2, (RMDX, ADDR), rd_cpaddr),
9397 CE(cfmvsr, e000450, 2, (RMF, RR), rn_rd),
9398 CE(cfmvrs, e100450, 2, (RR, RMF), rd_rn),
9399 CE(cfmvdlr, e000410, 2, (RMD, RR), rn_rd),
9400 CE(cfmvrdl, e100410, 2, (RR, RMD), rd_rn),
9401 CE(cfmvdhr, e000430, 2, (RMD, RR), rn_rd),
9402 CE(cfmvrdh, e100430, 2, (RR, RMD), rd_rn),
9403 CE(cfmv64lr, e000510, 2, (RMDX, RR), rn_rd),
9404 CE(cfmvr64l, e100510, 2, (RR, RMDX), rd_rn),
9405 CE(cfmv64hr, e000530, 2, (RMDX, RR), rn_rd),
9406 CE(cfmvr64h, e100530, 2, (RR, RMDX), rd_rn),
9407 CE(cfmval32, e200440, 2, (RMAX, RMFX), rd_rn),
9408 CE(cfmv32al, e100440, 2, (RMFX, RMAX), rd_rn),
9409 CE(cfmvam32, e200460, 2, (RMAX, RMFX), rd_rn),
9410 CE(cfmv32am, e100460, 2, (RMFX, RMAX), rd_rn),
9411 CE(cfmvah32, e200480, 2, (RMAX, RMFX), rd_rn),
9412 CE(cfmv32ah, e100480, 2, (RMFX, RMAX), rd_rn),
9413 CE(cfmva32, e2004a0, 2, (RMAX, RMFX), rd_rn),
9414 CE(cfmv32a, e1004a0, 2, (RMFX, RMAX), rd_rn),
9415 CE(cfmva64, e2004c0, 2, (RMAX, RMDX), rd_rn),
9416 CE(cfmv64a, e1004c0, 2, (RMDX, RMAX), rd_rn),
9417 CE(cfmvsc32, e2004e0, 2, (RMDS, RMDX), mav_dspsc),
9418 CE(cfmv32sc, e1004e0, 2, (RMDX, RMDS), rd),
9419 CE(cfcpys, e000400, 2, (RMF, RMF), rd_rn),
9420 CE(cfcpyd, e000420, 2, (RMD, RMD), rd_rn),
9421 CE(cfcvtsd, e000460, 2, (RMD, RMF), rd_rn),
9422 CE(cfcvtds, e000440, 2, (RMF, RMD), rd_rn),
9423 CE(cfcvt32s, e000480, 2, (RMF, RMFX), rd_rn),
9424 CE(cfcvt32d, e0004a0, 2, (RMD, RMFX), rd_rn),
9425 CE(cfcvt64s, e0004c0, 2, (RMF, RMDX), rd_rn),
9426 CE(cfcvt64d, e0004e0, 2, (RMD, RMDX), rd_rn),
9427 CE(cfcvts32, e100580, 2, (RMFX, RMF), rd_rn),
9428 CE(cfcvtd32, e1005a0, 2, (RMFX, RMD), rd_rn),
9429 CE(cftruncs32,e1005c0, 2, (RMFX, RMF), rd_rn),
9430 CE(cftruncd32,e1005e0, 2, (RMFX, RMD), rd_rn),
9431 CE(cfrshl32, e000550, 3, (RMFX, RMFX, RR), mav_triple),
9432 CE(cfrshl64, e000570, 3, (RMDX, RMDX, RR), mav_triple),
9433 CE(cfsh32, e000500, 3, (RMFX, RMFX, I63s), mav_shift),
9434 CE(cfsh64, e200500, 3, (RMDX, RMDX, I63s), mav_shift),
9435 CE(cfcmps, e100490, 3, (RR, RMF, RMF), rd_rn_rm),
9436 CE(cfcmpd, e1004b0, 3, (RR, RMD, RMD), rd_rn_rm),
9437 CE(cfcmp32, e100590, 3, (RR, RMFX, RMFX), rd_rn_rm),
9438 CE(cfcmp64, e1005b0, 3, (RR, RMDX, RMDX), rd_rn_rm),
9439 CE(cfabss, e300400, 2, (RMF, RMF), rd_rn),
9440 CE(cfabsd, e300420, 2, (RMD, RMD), rd_rn),
9441 CE(cfnegs, e300440, 2, (RMF, RMF), rd_rn),
9442 CE(cfnegd, e300460, 2, (RMD, RMD), rd_rn),
9443 CE(cfadds, e300480, 3, (RMF, RMF, RMF), rd_rn_rm),
9444 CE(cfaddd, e3004a0, 3, (RMD, RMD, RMD), rd_rn_rm),
9445 CE(cfsubs, e3004c0, 3, (RMF, RMF, RMF), rd_rn_rm),
9446 CE(cfsubd, e3004e0, 3, (RMD, RMD, RMD), rd_rn_rm),
9447 CE(cfmuls, e100400, 3, (RMF, RMF, RMF), rd_rn_rm),
9448 CE(cfmuld, e100420, 3, (RMD, RMD, RMD), rd_rn_rm),
9449 CE(cfabs32, e300500, 2, (RMFX, RMFX), rd_rn),
9450 CE(cfabs64, e300520, 2, (RMDX, RMDX), rd_rn),
9451 CE(cfneg32, e300540, 2, (RMFX, RMFX), rd_rn),
9452 CE(cfneg64, e300560, 2, (RMDX, RMDX), rd_rn),
9453 CE(cfadd32, e300580, 3, (RMFX, RMFX, RMFX), rd_rn_rm),
9454 CE(cfadd64, e3005a0, 3, (RMDX, RMDX, RMDX), rd_rn_rm),
9455 CE(cfsub32, e3005c0, 3, (RMFX, RMFX, RMFX), rd_rn_rm),
9456 CE(cfsub64, e3005e0, 3, (RMDX, RMDX, RMDX), rd_rn_rm),
9457 CE(cfmul32, e100500, 3, (RMFX, RMFX, RMFX), rd_rn_rm),
9458 CE(cfmul64, e100520, 3, (RMDX, RMDX, RMDX), rd_rn_rm),
9459 CE(cfmac32, e100540, 3, (RMFX, RMFX, RMFX), rd_rn_rm),
9460 CE(cfmsc32, e100560, 3, (RMFX, RMFX, RMFX), rd_rn_rm),
9461 CE(cfmadd32, e000600, 4, (RMAX, RMFX, RMFX, RMFX), mav_quad),
9462 CE(cfmsub32, e100600, 4, (RMAX, RMFX, RMFX, RMFX), mav_quad),
9463 CE(cfmadda32, e200600, 4, (RMAX, RMAX, RMFX, RMFX), mav_quad),
9464 CE(cfmsuba32, e300600, 4, (RMAX, RMAX, RMFX, RMFX), mav_quad),
9467 #undef THUMB_VARIANT
9487 /* MD interface: bits in the object file. */
9489 /* Turn an integer of n bytes (in val) into a stream of bytes appropriate
9490 for use in the a.out file, and stores them in the array pointed to by buf.
9491 This knows about the endian-ness of the target machine and does
9492 THE RIGHT THING, whatever it is. Possible values for n are 1 (byte)
9493 2 (short) and 4 (long) Floating numbers are put out as a series of
9494 LITTLENUMS (shorts, here at least). */
9497 md_number_to_chars (char * buf, valueT val, int n)
9499 if (target_big_endian)
9500 number_to_chars_bigendian (buf, val, n);
9502 number_to_chars_littleendian (buf, val, n);
9506 md_chars_to_number (char * buf, int n)
9509 unsigned char * where = (unsigned char *) buf;
9511 if (target_big_endian)
9516 result |= (*where++ & 255);
9524 result |= (where[n] & 255);
9531 /* MD interface: Sections. */
9534 md_estimate_size_before_relax (fragS * fragP ATTRIBUTE_UNUSED,
9535 segT segtype ATTRIBUTE_UNUSED)
9537 as_fatal (_("md_estimate_size_before_relax\n"));
9541 /* Round up a section size to the appropriate boundary. */
9544 md_section_align (segT segment ATTRIBUTE_UNUSED,
9550 /* Round all sects to multiple of 4. */
9551 return (size + 3) & ~3;
9555 /* This is called from HANDLE_ALIGN in write.c. Fill in the contents
9556 of an rs_align_code fragment. */
9559 arm_handle_align (fragS * fragP)
9561 static char const arm_noop[4] = { 0x00, 0x00, 0xa0, 0xe1 };
9562 static char const thumb_noop[2] = { 0xc0, 0x46 };
9563 static char const arm_bigend_noop[4] = { 0xe1, 0xa0, 0x00, 0x00 };
9564 static char const thumb_bigend_noop[2] = { 0x46, 0xc0 };
9566 int bytes, fix, noop_size;
9570 if (fragP->fr_type != rs_align_code)
9573 bytes = fragP->fr_next->fr_address - fragP->fr_address - fragP->fr_fix;
9574 p = fragP->fr_literal + fragP->fr_fix;
9577 if (bytes > MAX_MEM_FOR_RS_ALIGN_CODE)
9578 bytes &= MAX_MEM_FOR_RS_ALIGN_CODE;
9580 if (fragP->tc_frag_data)
9582 if (target_big_endian)
9583 noop = thumb_bigend_noop;
9586 noop_size = sizeof (thumb_noop);
9590 if (target_big_endian)
9591 noop = arm_bigend_noop;
9594 noop_size = sizeof (arm_noop);
9597 if (bytes & (noop_size - 1))
9599 fix = bytes & (noop_size - 1);
9605 while (bytes >= noop_size)
9607 memcpy (p, noop, noop_size);
9613 fragP->fr_fix += fix;
9614 fragP->fr_var = noop_size;
9617 /* Called from md_do_align. Used to create an alignment
9618 frag in a code section. */
9621 arm_frag_align_code (int n, int max)
9625 /* We assume that there will never be a requirement
9626 to support alignments greater than 32 bytes. */
9627 if (max > MAX_MEM_FOR_RS_ALIGN_CODE)
9628 as_fatal (_("alignments greater than 32 bytes not supported in .text sections."));
9630 p = frag_var (rs_align_code,
9631 MAX_MEM_FOR_RS_ALIGN_CODE,
9633 (relax_substateT) max,
9640 /* Perform target specific initialisation of a frag. */
9643 arm_init_frag (fragS * fragP)
9645 /* Record whether this frag is in an ARM or a THUMB area. */
9646 fragP->tc_frag_data = thumb_mode;
9650 /* When we change sections we need to issue a new mapping symbol. */
9653 arm_elf_change_section (void)
9656 segment_info_type *seginfo;
9658 /* Link an unlinked unwind index table section to the .text section. */
9659 if (elf_section_type (now_seg) == SHT_ARM_EXIDX
9660 && elf_linked_to_section (now_seg) == NULL)
9661 elf_linked_to_section (now_seg) = text_section;
9663 if (!SEG_NORMAL (now_seg))
9666 flags = bfd_get_section_flags (stdoutput, now_seg);
9668 /* We can ignore sections that only contain debug info. */
9669 if ((flags & SEC_ALLOC) == 0)
9672 seginfo = seg_info (now_seg);
9673 mapstate = seginfo->tc_segment_info_data.mapstate;
9674 marked_pr_dependency = seginfo->tc_segment_info_data.marked_pr_dependency;
9678 arm_elf_section_type (const char * str, size_t len)
9680 if (len == 5 && strncmp (str, "exidx", 5) == 0)
9681 return SHT_ARM_EXIDX;
9686 /* Code to deal with unwinding tables. */
9688 static void add_unwind_adjustsp (offsetT);
9690 /* Cenerate and deferred unwind frame offset. */
9693 flush_pending_unwind (void)
9697 offset = unwind.pending_offset;
9698 unwind.pending_offset = 0;
9700 add_unwind_adjustsp (offset);
9703 /* Add an opcode to this list for this function. Two-byte opcodes should
9704 be passed as op[0] << 8 | op[1]. The list of opcodes is built in reverse
9708 add_unwind_opcode (valueT op, int length)
9710 /* Add any deferred stack adjustment. */
9711 if (unwind.pending_offset)
9712 flush_pending_unwind ();
9714 unwind.sp_restored = 0;
9716 if (unwind.opcode_count + length > unwind.opcode_alloc)
9718 unwind.opcode_alloc += ARM_OPCODE_CHUNK_SIZE;
9720 unwind.opcodes = xrealloc (unwind.opcodes,
9721 unwind.opcode_alloc);
9723 unwind.opcodes = xmalloc (unwind.opcode_alloc);
9728 unwind.opcodes[unwind.opcode_count] = op & 0xff;
9730 unwind.opcode_count++;
9734 /* Add unwind opcodes to adjust the stack pointer. */
9737 add_unwind_adjustsp (offsetT offset)
9743 /* We need at most 5 bytes to hold a 32-bit value in a uleb128. */
9748 /* Long form: 0xb2, uleb128. */
9749 /* This might not fit in a word so add the individual bytes,
9750 remembering the list is built in reverse order. */
9751 o = (valueT) ((offset - 0x204) >> 2);
9753 add_unwind_opcode (0, 1);
9755 /* Calculate the uleb128 encoding of the offset. */
9759 bytes[n] = o & 0x7f;
9767 add_unwind_opcode (bytes[n - 1], 1);
9768 add_unwind_opcode (0xb2, 1);
9770 else if (offset > 0x100)
9772 /* Two short opcodes. */
9773 add_unwind_opcode (0x3f, 1);
9774 op = (offset - 0x104) >> 2;
9775 add_unwind_opcode (op, 1);
9777 else if (offset > 0)
9780 op = (offset - 4) >> 2;
9781 add_unwind_opcode (op, 1);
9783 else if (offset < 0)
9786 while (offset > 0x100)
9788 add_unwind_opcode (0x7f, 1);
9791 op = ((offset - 4) >> 2) | 0x40;
9792 add_unwind_opcode (op, 1);
9796 /* Finish the list of unwind opcodes for this function. */
9798 finish_unwind_opcodes (void)
9804 /* Adjust sp as neccessary. */
9805 unwind.pending_offset += unwind.fp_offset - unwind.frame_size;
9806 flush_pending_unwind ();
9808 /* After restoring sp from the frame pointer. */
9809 op = 0x90 | unwind.fp_reg;
9810 add_unwind_opcode (op, 1);
9813 flush_pending_unwind ();
9817 /* Start an exception table entry. If idx is nonzero this is an index table
9821 start_unwind_section (const segT text_seg, int idx)
9823 const char * text_name;
9824 const char * prefix;
9825 const char * prefix_once;
9826 const char * group_name;
9830 size_t sec_name_len;
9837 prefix = ELF_STRING_ARM_unwind;
9838 prefix_once = ELF_STRING_ARM_unwind_once;
9839 type = SHT_ARM_EXIDX;
9843 prefix = ELF_STRING_ARM_unwind_info;
9844 prefix_once = ELF_STRING_ARM_unwind_info_once;
9845 type = SHT_PROGBITS;
9848 text_name = segment_name (text_seg);
9849 if (streq (text_name, ".text"))
9852 if (strncmp (text_name, ".gnu.linkonce.t.",
9853 strlen (".gnu.linkonce.t.")) == 0)
9855 prefix = prefix_once;
9856 text_name += strlen (".gnu.linkonce.t.");
9859 prefix_len = strlen (prefix);
9860 text_len = strlen (text_name);
9861 sec_name_len = prefix_len + text_len;
9862 sec_name = xmalloc (sec_name_len + 1);
9863 memcpy (sec_name, prefix, prefix_len);
9864 memcpy (sec_name + prefix_len, text_name, text_len);
9865 sec_name[prefix_len + text_len] = '\0';
9871 /* Handle COMDAT group. */
9872 if (prefix != prefix_once && (text_seg->flags & SEC_LINK_ONCE) != 0)
9874 group_name = elf_group_name (text_seg);
9875 if (group_name == NULL)
9877 as_bad ("Group section `%s' has no group signature",
9878 segment_name (text_seg));
9879 ignore_rest_of_line ();
9886 obj_elf_change_section (sec_name, type, flags, 0, group_name, linkonce, 0);
9888 /* Set the setion link for index tables. */
9890 elf_linked_to_section (now_seg) = text_seg;
9894 /* Start an unwind table entry. HAVE_DATA is nonzero if we have additional
9895 personality routine data. Returns zero, or the index table value for
9896 and inline entry. */
9899 create_unwind_entry (int have_data)
9904 /* The current word of data. */
9906 /* The number of bytes left in this word. */
9909 finish_unwind_opcodes ();
9911 /* Remember the current text section. */
9912 unwind.saved_seg = now_seg;
9913 unwind.saved_subseg = now_subseg;
9915 start_unwind_section (now_seg, 0);
9917 if (unwind.personality_routine == NULL)
9919 if (unwind.personality_index == -2)
9922 as_bad (_("handerdata in cantunwind frame"));
9923 return 1; /* EXIDX_CANTUNWIND. */
9926 /* Use a default personality routine if none is specified. */
9927 if (unwind.personality_index == -1)
9929 if (unwind.opcode_count > 3)
9930 unwind.personality_index = 1;
9932 unwind.personality_index = 0;
9935 /* Space for the personality routine entry. */
9936 if (unwind.personality_index == 0)
9938 if (unwind.opcode_count > 3)
9939 as_bad (_("too many unwind opcodes for personality routine 0"));
9943 /* All the data is inline in the index table. */
9946 while (unwind.opcode_count > 0)
9948 unwind.opcode_count--;
9949 data = (data << 8) | unwind.opcodes[unwind.opcode_count];
9953 /* Pad with "finish" opcodes. */
9955 data = (data << 8) | 0xb0;
9962 /* We get two opcodes "free" in the first word. */
9963 size = unwind.opcode_count - 2;
9966 /* An extra byte is required for the opcode count. */
9967 size = unwind.opcode_count + 1;
9969 size = (size + 3) >> 2;
9971 as_bad (_("too many unwind opcodes"));
9973 frag_align (2, 0, 0);
9974 record_alignment (now_seg, 2);
9975 unwind.table_entry = expr_build_dot ();
9977 /* Allocate the table entry. */
9978 ptr = frag_more ((size << 2) + 4);
9979 where = frag_now_fix () - ((size << 2) + 4);
9981 switch (unwind.personality_index)
9984 /* ??? Should this be a PLT generating relocation? */
9985 /* Custom personality routine. */
9986 fix_new (frag_now, where, 4, unwind.personality_routine, 0, 1,
9987 BFD_RELOC_ARM_PREL31);
9992 /* Set the first byte to the number of additional words. */
9997 /* ABI defined personality routines. */
9999 /* Three opcodes bytes are packed into the first word. */
10006 /* The size and first two opcode bytes go in the first word. */
10007 data = ((0x80 + unwind.personality_index) << 8) | size;
10012 /* Should never happen. */
10016 /* Pack the opcodes into words (MSB first), reversing the list at the same
10018 while (unwind.opcode_count > 0)
10022 md_number_to_chars (ptr, data, 4);
10027 unwind.opcode_count--;
10029 data = (data << 8) | unwind.opcodes[unwind.opcode_count];
10032 /* Finish off the last word. */
10035 /* Pad with "finish" opcodes. */
10037 data = (data << 8) | 0xb0;
10039 md_number_to_chars (ptr, data, 4);
10044 /* Add an empty descriptor if there is no user-specified data. */
10045 ptr = frag_more (4);
10046 md_number_to_chars (ptr, 0, 4);
10052 /* Convert REGNAME to a DWARF-2 register number. */
10055 tc_arm_regname_to_dw2regnum (const char *regname)
10057 int reg = arm_reg_parse ((char **) ®name, REG_TYPE_RN);
10065 /* Initialize the DWARF-2 unwind information for this procedure. */
10068 tc_arm_frame_initial_instructions (void)
10070 cfi_add_CFA_def_cfa (REG_SP, 0);
10072 #endif /* OBJ_ELF */
10075 /* MD interface: Symbol and relocation handling. */
10077 /* Return the address within the segment that a PC-relative fixup is
10078 relative to. For ARM, PC-relative fixups applied to instructions
10079 are generally relative to the location of the fixup plus 8 bytes.
10080 Thumb branches are offset by 4, and Thumb loads relative to PC
10081 require special handling. */
10084 md_pcrel_from_section (fixS * fixP, segT seg)
10086 offsetT base = fixP->fx_where + fixP->fx_frag->fr_address;
10088 /* If this is pc-relative and we are going to emit a relocation
10089 then we just want to put out any pipeline compensation that the linker
10090 will need. Otherwise we want to use the calculated base. */
10092 && ((fixP->fx_addsy && S_GET_SEGMENT (fixP->fx_addsy) != seg)
10093 || arm_force_relocation (fixP)))
10096 switch (fixP->fx_r_type)
10098 /* PC relative addressing on the Thumb is slightly odd as the
10099 bottom two bits of the PC are forced to zero for the
10100 calculation. This happens *after* application of the
10101 pipeline offset. However, Thumb adrl already adjusts for
10102 this, so we need not do it again. */
10103 case BFD_RELOC_ARM_THUMB_ADD:
10106 case BFD_RELOC_ARM_THUMB_OFFSET:
10107 case BFD_RELOC_ARM_T32_OFFSET_IMM:
10108 case BFD_RELOC_ARM_T32_ADD_PC12:
10109 return (base + 4) & ~3;
10111 /* Thumb branches are simply offset by +4. */
10112 case BFD_RELOC_THUMB_PCREL_BRANCH7:
10113 case BFD_RELOC_THUMB_PCREL_BRANCH9:
10114 case BFD_RELOC_THUMB_PCREL_BRANCH12:
10115 case BFD_RELOC_THUMB_PCREL_BRANCH20:
10116 case BFD_RELOC_THUMB_PCREL_BRANCH23:
10117 case BFD_RELOC_THUMB_PCREL_BRANCH25:
10118 case BFD_RELOC_THUMB_PCREL_BLX:
10121 /* ARM mode branches are offset by +8. However, the Windows CE
10122 loader expects the relocation not to take this into account. */
10123 case BFD_RELOC_ARM_PCREL_BRANCH:
10124 case BFD_RELOC_ARM_PCREL_BLX:
10125 case BFD_RELOC_ARM_PLT32:
10132 /* ARM mode loads relative to PC are also offset by +8. Unlike
10133 branches, the Windows CE loader *does* expect the relocation
10134 to take this into account. */
10135 case BFD_RELOC_ARM_OFFSET_IMM:
10136 case BFD_RELOC_ARM_OFFSET_IMM8:
10137 case BFD_RELOC_ARM_HWLITERAL:
10138 case BFD_RELOC_ARM_LITERAL:
10139 case BFD_RELOC_ARM_CP_OFF_IMM:
10143 /* Other PC-relative relocations are un-offset. */
10149 /* Under ELF we need to default _GLOBAL_OFFSET_TABLE.
10150 Otherwise we have no need to default values of symbols. */
10153 md_undefined_symbol (char * name ATTRIBUTE_UNUSED)
10156 if (name[0] == '_' && name[1] == 'G'
10157 && streq (name, GLOBAL_OFFSET_TABLE_NAME))
10161 if (symbol_find (name))
10162 as_bad ("GOT already in the symbol table");
10164 GOT_symbol = symbol_new (name, undefined_section,
10165 (valueT) 0, & zero_address_frag);
10175 /* Subroutine of md_apply_fix. Check to see if an immediate can be
10176 computed as two separate immediate values, added together. We
10177 already know that this value cannot be computed by just one ARM
10180 static unsigned int
10181 validate_immediate_twopart (unsigned int val,
10182 unsigned int * highpart)
10187 for (i = 0; i < 32; i += 2)
10188 if (((a = rotate_left (val, i)) & 0xff) != 0)
10194 * highpart = (a >> 8) | ((i + 24) << 7);
10196 else if (a & 0xff0000)
10198 if (a & 0xff000000)
10200 * highpart = (a >> 16) | ((i + 16) << 7);
10204 assert (a & 0xff000000);
10205 * highpart = (a >> 24) | ((i + 8) << 7);
10208 return (a & 0xff) | (i << 7);
10215 validate_offset_imm (unsigned int val, int hwse)
10217 if ((hwse && val > 255) || val > 4095)
10222 /* Subroutine of md_apply_fix. Do those data_ops which can take a
10223 negative immediate constant by altering the instruction. A bit of
10228 by inverting the second operand, and
10231 by negating the second operand. */
10234 negate_data_op (unsigned long * instruction,
10235 unsigned long value)
10238 unsigned long negated, inverted;
10240 negated = encode_arm_immediate (-value);
10241 inverted = encode_arm_immediate (~value);
10243 op = (*instruction >> DATA_OP_SHIFT) & 0xf;
10246 /* First negates. */
10247 case OPCODE_SUB: /* ADD <-> SUB */
10248 new_inst = OPCODE_ADD;
10253 new_inst = OPCODE_SUB;
10257 case OPCODE_CMP: /* CMP <-> CMN */
10258 new_inst = OPCODE_CMN;
10263 new_inst = OPCODE_CMP;
10267 /* Now Inverted ops. */
10268 case OPCODE_MOV: /* MOV <-> MVN */
10269 new_inst = OPCODE_MVN;
10274 new_inst = OPCODE_MOV;
10278 case OPCODE_AND: /* AND <-> BIC */
10279 new_inst = OPCODE_BIC;
10284 new_inst = OPCODE_AND;
10288 case OPCODE_ADC: /* ADC <-> SBC */
10289 new_inst = OPCODE_SBC;
10294 new_inst = OPCODE_ADC;
10298 /* We cannot do anything. */
10303 if (value == (unsigned) FAIL)
10306 *instruction &= OPCODE_MASK;
10307 *instruction |= new_inst << DATA_OP_SHIFT;
10312 md_apply_fix (fixS * fixP,
10316 offsetT value = * valP;
10318 unsigned int newimm;
10319 unsigned long temp;
10321 char * buf = fixP->fx_where + fixP->fx_frag->fr_literal;
10323 assert (fixP->fx_r_type <= BFD_RELOC_UNUSED);
10325 /* Note whether this will delete the relocation. */
10326 if (fixP->fx_addsy == 0 && !fixP->fx_pcrel)
10329 /* On a 64-bit host, silently truncate 'value' to 32 bits for
10330 consistency with the behavior on 32-bit hosts. Remember value
10332 value &= 0xffffffff;
10333 value ^= 0x80000000;
10334 value -= 0x80000000;
10337 fixP->fx_addnumber = value;
10339 /* Same treatment for fixP->fx_offset. */
10340 fixP->fx_offset &= 0xffffffff;
10341 fixP->fx_offset ^= 0x80000000;
10342 fixP->fx_offset -= 0x80000000;
10344 switch (fixP->fx_r_type)
10346 case BFD_RELOC_NONE:
10347 /* This will need to go in the object file. */
10351 case BFD_RELOC_ARM_IMMEDIATE:
10352 /* We claim that this fixup has been processed here,
10353 even if in fact we generate an error because we do
10354 not have a reloc for it, so tc_gen_reloc will reject it. */
10358 && ! S_IS_DEFINED (fixP->fx_addsy))
10360 as_bad_where (fixP->fx_file, fixP->fx_line,
10361 _("undefined symbol %s used as an immediate value"),
10362 S_GET_NAME (fixP->fx_addsy));
10366 newimm = encode_arm_immediate (value);
10367 temp = md_chars_to_number (buf, INSN_SIZE);
10369 /* If the instruction will fail, see if we can fix things up by
10370 changing the opcode. */
10371 if (newimm == (unsigned int) FAIL
10372 && (newimm = negate_data_op (&temp, value)) == (unsigned int) FAIL)
10374 as_bad_where (fixP->fx_file, fixP->fx_line,
10375 _("invalid constant (%lx) after fixup"),
10376 (unsigned long) value);
10380 newimm |= (temp & 0xfffff000);
10381 md_number_to_chars (buf, (valueT) newimm, INSN_SIZE);
10384 case BFD_RELOC_ARM_ADRL_IMMEDIATE:
10386 unsigned int highpart = 0;
10387 unsigned int newinsn = 0xe1a00000; /* nop. */
10389 newimm = encode_arm_immediate (value);
10390 temp = md_chars_to_number (buf, INSN_SIZE);
10392 /* If the instruction will fail, see if we can fix things up by
10393 changing the opcode. */
10394 if (newimm == (unsigned int) FAIL
10395 && (newimm = negate_data_op (& temp, value)) == (unsigned int) FAIL)
10397 /* No ? OK - try using two ADD instructions to generate
10399 newimm = validate_immediate_twopart (value, & highpart);
10401 /* Yes - then make sure that the second instruction is
10403 if (newimm != (unsigned int) FAIL)
10405 /* Still No ? Try using a negated value. */
10406 else if ((newimm = validate_immediate_twopart (- value, & highpart)) != (unsigned int) FAIL)
10407 temp = newinsn = (temp & OPCODE_MASK) | OPCODE_SUB << DATA_OP_SHIFT;
10408 /* Otherwise - give up. */
10411 as_bad_where (fixP->fx_file, fixP->fx_line,
10412 _("unable to compute ADRL instructions for PC offset of 0x%lx"),
10417 /* Replace the first operand in the 2nd instruction (which
10418 is the PC) with the destination register. We have
10419 already added in the PC in the first instruction and we
10420 do not want to do it again. */
10421 newinsn &= ~ 0xf0000;
10422 newinsn |= ((newinsn & 0x0f000) << 4);
10425 newimm |= (temp & 0xfffff000);
10426 md_number_to_chars (buf, (valueT) newimm, INSN_SIZE);
10428 highpart |= (newinsn & 0xfffff000);
10429 md_number_to_chars (buf + INSN_SIZE, (valueT) highpart, INSN_SIZE);
10433 case BFD_RELOC_ARM_OFFSET_IMM:
10434 case BFD_RELOC_ARM_LITERAL:
10440 if (validate_offset_imm (value, 0) == FAIL)
10442 if (fixP->fx_r_type == BFD_RELOC_ARM_LITERAL)
10443 as_bad_where (fixP->fx_file, fixP->fx_line,
10444 _("invalid literal constant: pool needs to be closer"));
10446 as_bad_where (fixP->fx_file, fixP->fx_line,
10447 _("bad immediate value for offset (%ld)"),
10452 newval = md_chars_to_number (buf, INSN_SIZE);
10453 newval &= 0xff7ff000;
10454 newval |= value | (sign ? INDEX_UP : 0);
10455 md_number_to_chars (buf, newval, INSN_SIZE);
10458 case BFD_RELOC_ARM_OFFSET_IMM8:
10459 case BFD_RELOC_ARM_HWLITERAL:
10465 if (validate_offset_imm (value, 1) == FAIL)
10467 if (fixP->fx_r_type == BFD_RELOC_ARM_HWLITERAL)
10468 as_bad_where (fixP->fx_file, fixP->fx_line,
10469 _("invalid literal constant: pool needs to be closer"));
10471 as_bad (_("bad immediate value for half-word offset (%ld)"),
10476 newval = md_chars_to_number (buf, INSN_SIZE);
10477 newval &= 0xff7ff0f0;
10478 newval |= ((value >> 4) << 8) | (value & 0xf) | (sign ? INDEX_UP : 0);
10479 md_number_to_chars (buf, newval, INSN_SIZE);
10482 case BFD_RELOC_ARM_T32_OFFSET_U8:
10483 if (value < 0 || value > 1020 || value % 4 != 0)
10484 as_bad_where (fixP->fx_file, fixP->fx_line,
10485 _("bad immediate value for offset (%ld)"), (long) value);
10488 newval = md_chars_to_number (buf+2, THUMB_SIZE);
10490 md_number_to_chars (buf+2, newval, THUMB_SIZE);
10493 case BFD_RELOC_ARM_T32_OFFSET_IMM:
10494 /* This is a complicated relocation used for all varieties of Thumb32
10495 load/store instruction with immediate offset:
10497 1110 100P u1WL NNNN XXXX YYYY iiii iiii - +/-(U) pre/post(P) 8-bit,
10498 *4, optional writeback(W)
10499 (doubleword load/store)
10501 1111 100S uTTL 1111 XXXX iiii iiii iiii - +/-(U) 12-bit PC-rel
10502 1111 100S 0TTL NNNN XXXX 1Pu1 iiii iiii - +/-(U) pre/post(P) 8-bit
10503 1111 100S 0TTL NNNN XXXX 1110 iiii iiii - positive 8-bit (T instruction)
10504 1111 100S 1TTL NNNN XXXX iiii iiii iiii - positive 12-bit
10505 1111 100S 0TTL NNNN XXXX 1100 iiii iiii - negative 8-bit
10507 Uppercase letters indicate bits that are already encoded at
10508 this point. Lowercase letters are our problem. For the
10509 second block of instructions, the secondary opcode nybble
10510 (bits 8..11) is present, and bit 23 is zero, even if this is
10511 a PC-relative operation. */
10512 newval = md_chars_to_number (buf, THUMB_SIZE);
10514 newval |= md_chars_to_number (buf+THUMB_SIZE, THUMB_SIZE);
10516 if ((newval & 0xf0000000) == 0xe0000000)
10518 /* Doubleword load/store: 8-bit offset, scaled by 4. */
10520 newval |= (1 << 23);
10523 if (value % 4 != 0)
10525 as_bad_where (fixP->fx_file, fixP->fx_line,
10526 _("offset not a multiple of 4"));
10532 as_bad_where (fixP->fx_file, fixP->fx_line,
10533 _("offset out of range"));
10538 else if ((newval & 0x000f0000) == 0x000f0000)
10540 /* PC-relative, 12-bit offset. */
10542 newval |= (1 << 23);
10545 if (value >= 0xfff)
10547 as_bad_where (fixP->fx_file, fixP->fx_line,
10548 _("offset out of range"));
10553 else if ((newval & 0x00000100) == 0x00000100)
10555 /* Writeback: 8-bit, +/- offset. */
10557 newval |= (1 << 9);
10562 as_bad_where (fixP->fx_file, fixP->fx_line,
10563 _("offset out of range"));
10568 else if ((newval & 0x00000f00) == 0x00000e00)
10570 /* T-instruction: positive 8-bit offset. */
10571 if (value < 0 || value >= 0xff)
10573 as_bad_where (fixP->fx_file, fixP->fx_line,
10574 _("offset out of range"));
10582 /* Positive 12-bit or negative 8-bit offset. */
10586 newval |= (1 << 23);
10596 as_bad_where (fixP->fx_file, fixP->fx_line,
10597 _("offset out of range"));
10604 md_number_to_chars (buf, (newval >> 16) & 0xffff, THUMB_SIZE);
10605 md_number_to_chars (buf + THUMB_SIZE, newval & 0xffff, THUMB_SIZE);
10608 case BFD_RELOC_ARM_SHIFT_IMM:
10609 newval = md_chars_to_number (buf, INSN_SIZE);
10610 if (((unsigned long) value) > 32
10612 && (((newval & 0x60) == 0) || (newval & 0x60) == 0x60)))
10614 as_bad_where (fixP->fx_file, fixP->fx_line,
10615 _("shift expression is too large"));
10620 /* Shifts of zero must be done as lsl. */
10622 else if (value == 32)
10624 newval &= 0xfffff07f;
10625 newval |= (value & 0x1f) << 7;
10626 md_number_to_chars (buf, newval, INSN_SIZE);
10629 case BFD_RELOC_ARM_T32_IMMEDIATE:
10630 case BFD_RELOC_ARM_T32_IMM12:
10631 case BFD_RELOC_ARM_T32_ADD_PC12:
10632 /* We claim that this fixup has been processed here,
10633 even if in fact we generate an error because we do
10634 not have a reloc for it, so tc_gen_reloc will reject it. */
10638 && ! S_IS_DEFINED (fixP->fx_addsy))
10640 as_bad_where (fixP->fx_file, fixP->fx_line,
10641 _("undefined symbol %s used as an immediate value"),
10642 S_GET_NAME (fixP->fx_addsy));
10646 newval = md_chars_to_number (buf, THUMB_SIZE);
10648 newval |= md_chars_to_number (buf+2, THUMB_SIZE);
10650 /* FUTURE: Implement analogue of negate_data_op for T32. */
10651 if (fixP->fx_r_type == BFD_RELOC_ARM_T32_IMMEDIATE)
10652 newimm = encode_thumb32_immediate (value);
10655 /* 12 bit immediate for addw/subw. */
10659 newval ^= 0x00a00000;
10662 newimm = (unsigned int) FAIL;
10667 if (newimm == (unsigned int)FAIL)
10669 as_bad_where (fixP->fx_file, fixP->fx_line,
10670 _("invalid constant (%lx) after fixup"),
10671 (unsigned long) value);
10675 newval |= (newimm & 0x800) << 15;
10676 newval |= (newimm & 0x700) << 4;
10677 newval |= (newimm & 0x0ff);
10679 md_number_to_chars (buf, (valueT) ((newval >> 16) & 0xffff), THUMB_SIZE);
10680 md_number_to_chars (buf+2, (valueT) (newval & 0xffff), THUMB_SIZE);
10683 case BFD_RELOC_ARM_SMI:
10684 if (((unsigned long) value) > 0xffff)
10685 as_bad_where (fixP->fx_file, fixP->fx_line,
10686 _("invalid smi expression"));
10687 newval = md_chars_to_number (buf, INSN_SIZE);
10688 newval |= (value & 0xf) | ((value & 0xfff0) << 4);
10689 md_number_to_chars (buf, newval, INSN_SIZE);
10692 case BFD_RELOC_ARM_SWI:
10693 if (fixP->tc_fix_data != 0)
10695 if (((unsigned long) value) > 0xff)
10696 as_bad_where (fixP->fx_file, fixP->fx_line,
10697 _("invalid swi expression"));
10698 newval = md_chars_to_number (buf, THUMB_SIZE);
10700 md_number_to_chars (buf, newval, THUMB_SIZE);
10704 if (((unsigned long) value) > 0x00ffffff)
10705 as_bad_where (fixP->fx_file, fixP->fx_line,
10706 _("invalid swi expression"));
10707 newval = md_chars_to_number (buf, INSN_SIZE);
10709 md_number_to_chars (buf, newval, INSN_SIZE);
10713 case BFD_RELOC_ARM_MULTI:
10714 if (((unsigned long) value) > 0xffff)
10715 as_bad_where (fixP->fx_file, fixP->fx_line,
10716 _("invalid expression in load/store multiple"));
10717 newval = value | md_chars_to_number (buf, INSN_SIZE);
10718 md_number_to_chars (buf, newval, INSN_SIZE);
10721 case BFD_RELOC_ARM_PCREL_BRANCH:
10723 case BFD_RELOC_ARM_PLT32:
10726 /* We are going to store value (shifted right by two) in the
10727 instruction, in a 24 bit, signed field. Bits 0 and 1 must be
10728 clear, and bits 26 through 32 either all clear or all set. */
10729 if (value & 0x00000003)
10730 as_bad_where (fixP->fx_file, fixP->fx_line,
10731 _("misaligned branch destination"));
10732 if ((value & (offsetT)0xfe000000) != (offsetT)0
10733 && (value & (offsetT)0xfe000000) != (offsetT)0xfe000000)
10734 as_bad_where (fixP->fx_file, fixP->fx_line,
10735 _("branch out of range"));
10737 if (fixP->fx_done || !seg->use_rela_p)
10739 newval = md_chars_to_number (buf, INSN_SIZE);
10740 newval |= (value >> 2) & 0x00ffffff;
10741 md_number_to_chars (buf, newval, INSN_SIZE);
10745 case BFD_RELOC_ARM_PCREL_BLX:
10746 /* BLX allows bit 1 to be set in the branch destination, since
10747 it targets a Thumb instruction which is only required to be
10748 aligned modulo 2. Other constraints are as for B/BL. */
10749 if (value & 0x00000001)
10750 as_bad_where (fixP->fx_file, fixP->fx_line,
10751 _("misaligned BLX destination"));
10752 if ((value & (offsetT)0xfe000000) != (offsetT)0
10753 && (value & (offsetT)0xfe000000) != (offsetT)0xfe000000)
10754 as_bad_where (fixP->fx_file, fixP->fx_line,
10755 _("branch out of range"));
10757 if (fixP->fx_done || !seg->use_rela_p)
10760 hbit = (value >> 1) & 1;
10761 value = (value >> 2) & 0x00ffffff;
10763 newval = md_chars_to_number (buf, INSN_SIZE);
10764 newval |= value | hbit << 24;
10765 md_number_to_chars (buf, newval, INSN_SIZE);
10769 case BFD_RELOC_THUMB_PCREL_BRANCH7: /* CZB */
10770 /* CZB can only branch forward. */
10772 as_bad_where (fixP->fx_file, fixP->fx_line,
10773 _("branch out of range"));
10775 if (fixP->fx_done || !seg->use_rela_p)
10777 newval = md_chars_to_number (buf, THUMB_SIZE);
10778 newval |= ((value & 0x2e) << 2) | ((value & 0x40) << 3);
10779 md_number_to_chars (buf, newval, THUMB_SIZE);
10783 case BFD_RELOC_THUMB_PCREL_BRANCH9: /* Conditional branch. */
10784 if ((value & ~0xff) && ((value & ~0xff) != ~0xff))
10785 as_bad_where (fixP->fx_file, fixP->fx_line,
10786 _("branch out of range"));
10788 if (fixP->fx_done || !seg->use_rela_p)
10790 newval = md_chars_to_number (buf, THUMB_SIZE);
10791 newval |= (value & 0x1ff) >> 1;
10792 md_number_to_chars (buf, newval, THUMB_SIZE);
10796 case BFD_RELOC_THUMB_PCREL_BRANCH12: /* Unconditional branch. */
10797 if ((value & ~0x7ff) && ((value & ~0x7ff) != ~0x7ff))
10798 as_bad_where (fixP->fx_file, fixP->fx_line,
10799 _("branch out of range"));
10801 if (fixP->fx_done || !seg->use_rela_p)
10803 newval = md_chars_to_number (buf, THUMB_SIZE);
10804 newval |= (value & 0xfff) >> 1;
10805 md_number_to_chars (buf, newval, THUMB_SIZE);
10809 case BFD_RELOC_THUMB_PCREL_BRANCH20:
10810 if ((value & ~0x1fffff) && ((value & ~0x1fffff) != ~0x1fffff))
10811 as_bad_where (fixP->fx_file, fixP->fx_line,
10812 _("conditional branch out of range"));
10814 if (fixP->fx_done || !seg->use_rela_p)
10817 addressT S, J1, J2, lo, hi;
10819 S = (value & 0x00100000) >> 20;
10820 J2 = (value & 0x00080000) >> 19;
10821 J1 = (value & 0x00040000) >> 18;
10822 hi = (value & 0x0003f000) >> 12;
10823 lo = (value & 0x00000ffe) >> 1;
10825 newval = md_chars_to_number (buf, THUMB_SIZE);
10826 newval2 = md_chars_to_number (buf + THUMB_SIZE, THUMB_SIZE);
10827 newval |= (S << 10) | hi;
10828 newval2 |= (J1 << 13) | (J2 << 11) | lo;
10829 md_number_to_chars (buf, newval, THUMB_SIZE);
10830 md_number_to_chars (buf + THUMB_SIZE, newval2, THUMB_SIZE);
10834 case BFD_RELOC_THUMB_PCREL_BLX:
10835 case BFD_RELOC_THUMB_PCREL_BRANCH23:
10836 if ((value & ~0x3fffff) && ((value & ~0x3fffff) != ~0x3fffff))
10837 as_bad_where (fixP->fx_file, fixP->fx_line,
10838 _("branch out of range"));
10840 if (fixP->fx_r_type == BFD_RELOC_THUMB_PCREL_BLX)
10841 /* For a BLX instruction, make sure that the relocation is rounded up
10842 to a word boundary. This follows the semantics of the instruction
10843 which specifies that bit 1 of the target address will come from bit
10844 1 of the base address. */
10845 value = (value + 1) & ~ 1;
10847 if (fixP->fx_done || !seg->use_rela_p)
10851 newval = md_chars_to_number (buf, THUMB_SIZE);
10852 newval2 = md_chars_to_number (buf + THUMB_SIZE, THUMB_SIZE);
10853 newval |= (value & 0x7fffff) >> 12;
10854 newval2 |= (value & 0xfff) >> 1;
10855 md_number_to_chars (buf, newval, THUMB_SIZE);
10856 md_number_to_chars (buf + THUMB_SIZE, newval2, THUMB_SIZE);
10860 case BFD_RELOC_THUMB_PCREL_BRANCH25:
10861 if ((value & ~0x1ffffff) && ((value & ~0x1ffffff) != ~0x1ffffff))
10862 as_bad_where (fixP->fx_file, fixP->fx_line,
10863 _("branch out of range"));
10865 if (fixP->fx_done || !seg->use_rela_p)
10868 addressT S, I1, I2, lo, hi;
10870 S = (value & 0x01000000) >> 24;
10871 I1 = (value & 0x00800000) >> 23;
10872 I2 = (value & 0x00400000) >> 22;
10873 hi = (value & 0x003ff000) >> 12;
10874 lo = (value & 0x00000ffe) >> 1;
10879 newval = md_chars_to_number (buf, THUMB_SIZE);
10880 newval2 = md_chars_to_number (buf + THUMB_SIZE, THUMB_SIZE);
10881 newval |= (S << 10) | hi;
10882 newval2 |= (I1 << 13) | (I2 << 11) | lo;
10883 md_number_to_chars (buf, newval, THUMB_SIZE);
10884 md_number_to_chars (buf + THUMB_SIZE, newval2, THUMB_SIZE);
10889 if (fixP->fx_done || !seg->use_rela_p)
10890 md_number_to_chars (buf, value, 1);
10894 if (fixP->fx_done || !seg->use_rela_p)
10895 md_number_to_chars (buf, value, 2);
10899 case BFD_RELOC_ARM_TLS_GD32:
10900 case BFD_RELOC_ARM_TLS_LE32:
10901 case BFD_RELOC_ARM_TLS_IE32:
10902 case BFD_RELOC_ARM_TLS_LDM32:
10903 case BFD_RELOC_ARM_TLS_LDO32:
10904 S_SET_THREAD_LOCAL (fixP->fx_addsy);
10907 case BFD_RELOC_ARM_GOT32:
10908 case BFD_RELOC_ARM_GOTOFF:
10909 case BFD_RELOC_ARM_TARGET2:
10910 if (fixP->fx_done || !seg->use_rela_p)
10911 md_number_to_chars (buf, 0, 4);
10915 case BFD_RELOC_RVA:
10917 case BFD_RELOC_ARM_TARGET1:
10918 case BFD_RELOC_ARM_ROSEGREL32:
10919 case BFD_RELOC_ARM_SBREL32:
10920 case BFD_RELOC_32_PCREL:
10921 if (fixP->fx_done || !seg->use_rela_p)
10922 md_number_to_chars (buf, value, 4);
10926 case BFD_RELOC_ARM_PREL31:
10927 if (fixP->fx_done || !seg->use_rela_p)
10929 newval = md_chars_to_number (buf, 4) & 0x80000000;
10930 if ((value ^ (value >> 1)) & 0x40000000)
10932 as_bad_where (fixP->fx_file, fixP->fx_line,
10933 _("rel31 relocation overflow"));
10935 newval |= value & 0x7fffffff;
10936 md_number_to_chars (buf, newval, 4);
10941 case BFD_RELOC_ARM_CP_OFF_IMM:
10942 if (value < -1023 || value > 1023 || (value & 3))
10943 as_bad_where (fixP->fx_file, fixP->fx_line,
10944 _("co-processor offset out of range"));
10949 newval = md_chars_to_number (buf, INSN_SIZE) & 0xff7fff00;
10950 newval |= (value >> 2) | (sign ? INDEX_UP : 0);
10952 newval &= ~WRITE_BACK;
10953 md_number_to_chars (buf, newval, INSN_SIZE);
10956 case BFD_RELOC_ARM_CP_OFF_IMM_S2:
10957 if (value < -255 || value > 255)
10958 as_bad_where (fixP->fx_file, fixP->fx_line,
10959 _("co-processor offset out of range"));
10960 goto cp_off_common;
10962 case BFD_RELOC_ARM_THUMB_OFFSET:
10963 newval = md_chars_to_number (buf, THUMB_SIZE);
10964 /* Exactly what ranges, and where the offset is inserted depends
10965 on the type of instruction, we can establish this from the
10967 switch (newval >> 12)
10969 case 4: /* PC load. */
10970 /* Thumb PC loads are somewhat odd, bit 1 of the PC is
10971 forced to zero for these loads; md_pcrel_from has already
10972 compensated for this. */
10974 as_bad_where (fixP->fx_file, fixP->fx_line,
10975 _("invalid offset, target not word aligned (0x%08lX)"),
10976 (((unsigned int) fixP->fx_frag->fr_address
10977 + (unsigned int) fixP->fx_where) & ~3) + value);
10979 if (value & ~0x3fc)
10980 as_bad_where (fixP->fx_file, fixP->fx_line,
10981 _("invalid offset, value too big (0x%08lX)"),
10984 newval |= value >> 2;
10987 case 9: /* SP load/store. */
10988 if (value & ~0x3fc)
10989 as_bad_where (fixP->fx_file, fixP->fx_line,
10990 _("invalid offset, value too big (0x%08lX)"),
10992 newval |= value >> 2;
10995 case 6: /* Word load/store. */
10997 as_bad_where (fixP->fx_file, fixP->fx_line,
10998 _("invalid offset, value too big (0x%08lX)"),
11000 newval |= value << 4; /* 6 - 2. */
11003 case 7: /* Byte load/store. */
11005 as_bad_where (fixP->fx_file, fixP->fx_line,
11006 _("invalid offset, value too big (0x%08lX)"),
11008 newval |= value << 6;
11011 case 8: /* Halfword load/store. */
11013 as_bad_where (fixP->fx_file, fixP->fx_line,
11014 _("invalid offset, value too big (0x%08lX)"),
11016 newval |= value << 5; /* 6 - 1. */
11020 as_bad_where (fixP->fx_file, fixP->fx_line,
11021 "Unable to process relocation for thumb opcode: %lx",
11022 (unsigned long) newval);
11025 md_number_to_chars (buf, newval, THUMB_SIZE);
11028 case BFD_RELOC_ARM_THUMB_ADD:
11029 /* This is a complicated relocation, since we use it for all of
11030 the following immediate relocations:
11034 9bit ADD/SUB SP word-aligned
11035 10bit ADD PC/SP word-aligned
11037 The type of instruction being processed is encoded in the
11044 newval = md_chars_to_number (buf, THUMB_SIZE);
11046 int rd = (newval >> 4) & 0xf;
11047 int rs = newval & 0xf;
11048 int subtract = !!(newval & 0x8000);
11050 /* Check for HI regs, only very restricted cases allowed:
11051 Adjusting SP, and using PC or SP to get an address. */
11052 if ((rd > 7 && (rd != REG_SP || rs != REG_SP))
11053 || (rs > 7 && rs != REG_SP && rs != REG_PC))
11054 as_bad_where (fixP->fx_file, fixP->fx_line,
11055 _("invalid Hi register with immediate"));
11057 /* If value is negative, choose the opposite instruction. */
11061 subtract = !subtract;
11063 as_bad_where (fixP->fx_file, fixP->fx_line,
11064 _("immediate value out of range"));
11069 if (value & ~0x1fc)
11070 as_bad_where (fixP->fx_file, fixP->fx_line,
11071 _("invalid immediate for stack address calculation"));
11072 newval = subtract ? T_OPCODE_SUB_ST : T_OPCODE_ADD_ST;
11073 newval |= value >> 2;
11075 else if (rs == REG_PC || rs == REG_SP)
11077 if (subtract || value & ~0x3fc)
11078 as_bad_where (fixP->fx_file, fixP->fx_line,
11079 _("invalid immediate for address calculation (value = 0x%08lX)"),
11080 (unsigned long) value);
11081 newval = (rs == REG_PC ? T_OPCODE_ADD_PC : T_OPCODE_ADD_SP);
11083 newval |= value >> 2;
11088 as_bad_where (fixP->fx_file, fixP->fx_line,
11089 _("immediate value out of range"));
11090 newval = subtract ? T_OPCODE_SUB_I8 : T_OPCODE_ADD_I8;
11091 newval |= (rd << 8) | value;
11096 as_bad_where (fixP->fx_file, fixP->fx_line,
11097 _("immediate value out of range"));
11098 newval = subtract ? T_OPCODE_SUB_I3 : T_OPCODE_ADD_I3;
11099 newval |= rd | (rs << 3) | (value << 6);
11102 md_number_to_chars (buf, newval, THUMB_SIZE);
11105 case BFD_RELOC_ARM_THUMB_IMM:
11106 newval = md_chars_to_number (buf, THUMB_SIZE);
11107 if (value < 0 || value > 255)
11108 as_bad_where (fixP->fx_file, fixP->fx_line,
11109 _("invalid immediate: %ld is too large"),
11112 md_number_to_chars (buf, newval, THUMB_SIZE);
11115 case BFD_RELOC_ARM_THUMB_SHIFT:
11116 /* 5bit shift value (0..32). LSL cannot take 32. */
11117 newval = md_chars_to_number (buf, THUMB_SIZE) & 0xf83f;
11118 temp = newval & 0xf800;
11119 if (value < 0 || value > 32 || (value == 32 && temp == T_OPCODE_LSL_I))
11120 as_bad_where (fixP->fx_file, fixP->fx_line,
11121 _("invalid shift value: %ld"), (long) value);
11122 /* Shifts of zero must be encoded as LSL. */
11124 newval = (newval & 0x003f) | T_OPCODE_LSL_I;
11125 /* Shifts of 32 are encoded as zero. */
11126 else if (value == 32)
11128 newval |= value << 6;
11129 md_number_to_chars (buf, newval, THUMB_SIZE);
11132 case BFD_RELOC_VTABLE_INHERIT:
11133 case BFD_RELOC_VTABLE_ENTRY:
11137 case BFD_RELOC_UNUSED:
11139 as_bad_where (fixP->fx_file, fixP->fx_line,
11140 _("bad relocation fixup type (%d)"), fixP->fx_r_type);
11144 /* Translate internal representation of relocation info to BFD target
11148 tc_gen_reloc (asection * section ATTRIBUTE_UNUSED,
11152 bfd_reloc_code_real_type code;
11154 reloc = xmalloc (sizeof (arelent));
11156 reloc->sym_ptr_ptr = xmalloc (sizeof (asymbol *));
11157 *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
11158 reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
11160 if (fixp->fx_pcrel)
11161 fixp->fx_offset = reloc->address;
11162 reloc->addend = fixp->fx_offset;
11164 switch (fixp->fx_r_type)
11167 if (fixp->fx_pcrel)
11169 code = BFD_RELOC_8_PCREL;
11174 if (fixp->fx_pcrel)
11176 code = BFD_RELOC_16_PCREL;
11181 if (fixp->fx_pcrel)
11183 code = BFD_RELOC_32_PCREL;
11187 case BFD_RELOC_NONE:
11188 case BFD_RELOC_ARM_PCREL_BRANCH:
11189 case BFD_RELOC_ARM_PCREL_BLX:
11190 case BFD_RELOC_RVA:
11191 case BFD_RELOC_THUMB_PCREL_BRANCH7:
11192 case BFD_RELOC_THUMB_PCREL_BRANCH9:
11193 case BFD_RELOC_THUMB_PCREL_BRANCH12:
11194 case BFD_RELOC_THUMB_PCREL_BRANCH20:
11195 case BFD_RELOC_THUMB_PCREL_BRANCH23:
11196 case BFD_RELOC_THUMB_PCREL_BRANCH25:
11197 case BFD_RELOC_THUMB_PCREL_BLX:
11198 case BFD_RELOC_VTABLE_ENTRY:
11199 case BFD_RELOC_VTABLE_INHERIT:
11200 code = fixp->fx_r_type;
11203 case BFD_RELOC_ARM_LITERAL:
11204 case BFD_RELOC_ARM_HWLITERAL:
11205 /* If this is called then the a literal has
11206 been referenced across a section boundary. */
11207 as_bad_where (fixp->fx_file, fixp->fx_line,
11208 _("literal referenced across section boundary"));
11212 case BFD_RELOC_ARM_GOT32:
11213 case BFD_RELOC_ARM_GOTOFF:
11214 case BFD_RELOC_ARM_PLT32:
11215 case BFD_RELOC_ARM_TARGET1:
11216 case BFD_RELOC_ARM_ROSEGREL32:
11217 case BFD_RELOC_ARM_SBREL32:
11218 case BFD_RELOC_ARM_PREL31:
11219 case BFD_RELOC_ARM_TARGET2:
11220 case BFD_RELOC_ARM_TLS_LE32:
11221 case BFD_RELOC_ARM_TLS_LDO32:
11222 code = fixp->fx_r_type;
11225 case BFD_RELOC_ARM_TLS_GD32:
11226 case BFD_RELOC_ARM_TLS_IE32:
11227 case BFD_RELOC_ARM_TLS_LDM32:
11228 /* BFD will include the symbol's address in the addend.
11229 But we don't want that, so subtract it out again here. */
11230 if (!S_IS_COMMON (fixp->fx_addsy))
11231 reloc->addend -= (*reloc->sym_ptr_ptr)->value;
11232 code = fixp->fx_r_type;
11236 case BFD_RELOC_ARM_IMMEDIATE:
11237 as_bad_where (fixp->fx_file, fixp->fx_line,
11238 _("internal relocation (type: IMMEDIATE) not fixed up"));
11241 case BFD_RELOC_ARM_ADRL_IMMEDIATE:
11242 as_bad_where (fixp->fx_file, fixp->fx_line,
11243 _("ADRL used for a symbol not defined in the same file"));
11246 case BFD_RELOC_ARM_OFFSET_IMM:
11247 if (fixp->fx_addsy != NULL
11248 && !S_IS_DEFINED (fixp->fx_addsy)
11249 && S_IS_LOCAL (fixp->fx_addsy))
11251 as_bad_where (fixp->fx_file, fixp->fx_line,
11252 _("undefined local label `%s'"),
11253 S_GET_NAME (fixp->fx_addsy));
11257 as_bad_where (fixp->fx_file, fixp->fx_line,
11258 _("internal_relocation (type: OFFSET_IMM) not fixed up"));
11265 switch (fixp->fx_r_type)
11267 case BFD_RELOC_NONE: type = "NONE"; break;
11268 case BFD_RELOC_ARM_OFFSET_IMM8: type = "OFFSET_IMM8"; break;
11269 case BFD_RELOC_ARM_SHIFT_IMM: type = "SHIFT_IMM"; break;
11270 case BFD_RELOC_ARM_SMI: type = "SMI"; break;
11271 case BFD_RELOC_ARM_SWI: type = "SWI"; break;
11272 case BFD_RELOC_ARM_MULTI: type = "MULTI"; break;
11273 case BFD_RELOC_ARM_CP_OFF_IMM: type = "CP_OFF_IMM"; break;
11274 case BFD_RELOC_ARM_THUMB_ADD: type = "THUMB_ADD"; break;
11275 case BFD_RELOC_ARM_THUMB_SHIFT: type = "THUMB_SHIFT"; break;
11276 case BFD_RELOC_ARM_THUMB_IMM: type = "THUMB_IMM"; break;
11277 case BFD_RELOC_ARM_THUMB_OFFSET: type = "THUMB_OFFSET"; break;
11278 default: type = _("<unknown>"); break;
11280 as_bad_where (fixp->fx_file, fixp->fx_line,
11281 _("cannot represent %s relocation in this object file format"),
11288 if ((code == BFD_RELOC_32_PCREL || code == BFD_RELOC_32)
11290 && fixp->fx_addsy == GOT_symbol)
11292 code = BFD_RELOC_ARM_GOTPC;
11293 reloc->addend = fixp->fx_offset = reloc->address;
11297 reloc->howto = bfd_reloc_type_lookup (stdoutput, code);
11299 if (reloc->howto == NULL)
11301 as_bad_where (fixp->fx_file, fixp->fx_line,
11302 _("cannot represent %s relocation in this object file format"),
11303 bfd_get_reloc_code_name (code));
11307 /* HACK: Since arm ELF uses Rel instead of Rela, encode the
11308 vtable entry to be used in the relocation's section offset. */
11309 if (fixp->fx_r_type == BFD_RELOC_VTABLE_ENTRY)
11310 reloc->address = fixp->fx_offset;
11315 /* This fix_new is called by cons via TC_CONS_FIX_NEW. */
11318 cons_fix_new_arm (fragS * frag,
11323 bfd_reloc_code_real_type type;
11327 FIXME: @@ Should look at CPU word size. */
11331 type = BFD_RELOC_8;
11334 type = BFD_RELOC_16;
11338 type = BFD_RELOC_32;
11341 type = BFD_RELOC_64;
11345 fix_new_exp (frag, where, (int) size, exp, pcrel, type);
11348 #if defined OBJ_COFF || defined OBJ_ELF
11350 arm_validate_fix (fixS * fixP)
11352 /* If the destination of the branch is a defined symbol which does not have
11353 the THUMB_FUNC attribute, then we must be calling a function which has
11354 the (interfacearm) attribute. We look for the Thumb entry point to that
11355 function and change the branch to refer to that function instead. */
11356 if (fixP->fx_r_type == BFD_RELOC_THUMB_PCREL_BRANCH23
11357 && fixP->fx_addsy != NULL
11358 && S_IS_DEFINED (fixP->fx_addsy)
11359 && ! THUMB_IS_FUNC (fixP->fx_addsy))
11361 fixP->fx_addsy = find_real_start (fixP->fx_addsy);
11367 arm_force_relocation (struct fix * fixp)
11369 #if defined (OBJ_COFF) && defined (TE_PE)
11370 if (fixp->fx_r_type == BFD_RELOC_RVA)
11374 /* Resolve these relocations even if the symbol is extern or weak. */
11375 if (fixp->fx_r_type == BFD_RELOC_ARM_IMMEDIATE
11376 || fixp->fx_r_type == BFD_RELOC_ARM_OFFSET_IMM
11377 || fixp->fx_r_type == BFD_RELOC_ARM_ADRL_IMMEDIATE)
11380 return generic_force_reloc (fixp);
11384 /* This is a little hack to help the gas/arm/adrl.s test. It prevents
11385 local labels from being added to the output symbol table when they
11386 are used with the ADRL pseudo op. The ADRL relocation should always
11387 be resolved before the binbary is emitted, so it is safe to say that
11388 it is adjustable. */
11391 arm_fix_adjustable (fixS * fixP)
11393 if (fixP->fx_r_type == BFD_RELOC_ARM_ADRL_IMMEDIATE)
11400 /* Relocations against Thumb function names must be left unadjusted,
11401 so that the linker can use this information to correctly set the
11402 bottom bit of their addresses. The MIPS version of this function
11403 also prevents relocations that are mips-16 specific, but I do not
11404 know why it does this.
11407 There is one other problem that ought to be addressed here, but
11408 which currently is not: Taking the address of a label (rather
11409 than a function) and then later jumping to that address. Such
11410 addresses also ought to have their bottom bit set (assuming that
11411 they reside in Thumb code), but at the moment they will not. */
11414 arm_fix_adjustable (fixS * fixP)
11416 if (fixP->fx_addsy == NULL)
11419 if (THUMB_IS_FUNC (fixP->fx_addsy)
11420 && fixP->fx_subsy == NULL)
11423 /* We need the symbol name for the VTABLE entries. */
11424 if ( fixP->fx_r_type == BFD_RELOC_VTABLE_INHERIT
11425 || fixP->fx_r_type == BFD_RELOC_VTABLE_ENTRY)
11428 /* Don't allow symbols to be discarded on GOT related relocs. */
11429 if (fixP->fx_r_type == BFD_RELOC_ARM_PLT32
11430 || fixP->fx_r_type == BFD_RELOC_ARM_GOT32
11431 || fixP->fx_r_type == BFD_RELOC_ARM_GOTOFF
11432 || fixP->fx_r_type == BFD_RELOC_ARM_TLS_GD32
11433 || fixP->fx_r_type == BFD_RELOC_ARM_TLS_LE32
11434 || fixP->fx_r_type == BFD_RELOC_ARM_TLS_IE32
11435 || fixP->fx_r_type == BFD_RELOC_ARM_TLS_LDM32
11436 || fixP->fx_r_type == BFD_RELOC_ARM_TLS_LDO32
11437 || fixP->fx_r_type == BFD_RELOC_ARM_TARGET2)
11444 elf32_arm_target_format (void)
11447 return (target_big_endian
11448 ? "elf32-bigarm-symbian"
11449 : "elf32-littlearm-symbian");
11450 #elif defined (TE_VXWORKS)
11451 return (target_big_endian
11452 ? "elf32-bigarm-vxworks"
11453 : "elf32-littlearm-vxworks");
11455 if (target_big_endian)
11456 return "elf32-bigarm";
11458 return "elf32-littlearm";
11463 armelf_frob_symbol (symbolS * symp,
11466 elf_frob_symbol (symp, puntp);
11470 /* MD interface: Finalization. */
11472 /* A good place to do this, although this was probably not intended
11473 for this kind of use. We need to dump the literal pool before
11474 references are made to a null symbol pointer. */
11479 literal_pool * pool;
11481 for (pool = list_of_pools; pool; pool = pool->next)
11483 /* Put it at the end of the relevent section. */
11484 subseg_set (pool->section, pool->sub_section);
11486 arm_elf_change_section ();
11492 /* Adjust the symbol table. This marks Thumb symbols as distinct from
11496 arm_adjust_symtab (void)
11501 for (sym = symbol_rootP; sym != NULL; sym = symbol_next (sym))
11503 if (ARM_IS_THUMB (sym))
11505 if (THUMB_IS_FUNC (sym))
11507 /* Mark the symbol as a Thumb function. */
11508 if ( S_GET_STORAGE_CLASS (sym) == C_STAT
11509 || S_GET_STORAGE_CLASS (sym) == C_LABEL) /* This can happen! */
11510 S_SET_STORAGE_CLASS (sym, C_THUMBSTATFUNC);
11512 else if (S_GET_STORAGE_CLASS (sym) == C_EXT)
11513 S_SET_STORAGE_CLASS (sym, C_THUMBEXTFUNC);
11515 as_bad (_("%s: unexpected function type: %d"),
11516 S_GET_NAME (sym), S_GET_STORAGE_CLASS (sym));
11518 else switch (S_GET_STORAGE_CLASS (sym))
11521 S_SET_STORAGE_CLASS (sym, C_THUMBEXT);
11524 S_SET_STORAGE_CLASS (sym, C_THUMBSTAT);
11527 S_SET_STORAGE_CLASS (sym, C_THUMBLABEL);
11535 if (ARM_IS_INTERWORK (sym))
11536 coffsymbol (symbol_get_bfdsym (sym))->native->u.syment.n_flags = 0xFF;
11543 for (sym = symbol_rootP; sym != NULL; sym = symbol_next (sym))
11545 if (ARM_IS_THUMB (sym))
11547 elf_symbol_type * elf_sym;
11549 elf_sym = elf_symbol (symbol_get_bfdsym (sym));
11550 bind = ELF_ST_BIND (elf_sym->internal_elf_sym.st_info);
11552 if (! bfd_is_arm_mapping_symbol_name (elf_sym->symbol.name))
11554 /* If it's a .thumb_func, declare it as so,
11555 otherwise tag label as .code 16. */
11556 if (THUMB_IS_FUNC (sym))
11557 elf_sym->internal_elf_sym.st_info =
11558 ELF_ST_INFO (bind, STT_ARM_TFUNC);
11560 elf_sym->internal_elf_sym.st_info =
11561 ELF_ST_INFO (bind, STT_ARM_16BIT);
11568 /* MD interface: Initialization. */
11571 set_constant_flonums (void)
11575 for (i = 0; i < NUM_FLOAT_VALS; i++)
11576 if (atof_ieee ((char *) fp_const[i], 'x', fp_values[i]) == NULL)
11586 if ( (arm_ops_hsh = hash_new ()) == NULL
11587 || (arm_cond_hsh = hash_new ()) == NULL
11588 || (arm_shift_hsh = hash_new ()) == NULL
11589 || (arm_psr_hsh = hash_new ()) == NULL
11590 || (arm_reg_hsh = hash_new ()) == NULL
11591 || (arm_reloc_hsh = hash_new ()) == NULL)
11592 as_fatal (_("virtual memory exhausted"));
11594 for (i = 0; i < sizeof (insns) / sizeof (struct asm_opcode); i++)
11595 hash_insert (arm_ops_hsh, insns[i].template, (PTR) (insns + i));
11596 for (i = 0; i < sizeof (conds) / sizeof (struct asm_cond); i++)
11597 hash_insert (arm_cond_hsh, conds[i].template, (PTR) (conds + i));
11598 for (i = 0; i < sizeof (shift_names) / sizeof (struct asm_shift_name); i++)
11599 hash_insert (arm_shift_hsh, shift_names[i].name, (PTR) (shift_names + i));
11600 for (i = 0; i < sizeof (psrs) / sizeof (struct asm_psr); i++)
11601 hash_insert (arm_psr_hsh, psrs[i].template, (PTR) (psrs + i));
11602 for (i = 0; i < sizeof (reg_names) / sizeof (struct reg_entry); i++)
11603 hash_insert (arm_reg_hsh, reg_names[i].name, (PTR) (reg_names + i));
11605 for (i = 0; i < sizeof (reloc_names) / sizeof (struct reloc_entry); i++)
11606 hash_insert (arm_reloc_hsh, reloc_names[i].name, (PTR) (reloc_names + i));
11609 set_constant_flonums ();
11611 /* Set the cpu variant based on the command-line options. We prefer
11612 -mcpu= over -march= if both are set (as for GCC); and we prefer
11613 -mfpu= over any other way of setting the floating point unit.
11614 Use of legacy options with new options are faulted. */
11615 if (legacy_cpu != -1)
11617 if (mcpu_cpu_opt != -1 || march_cpu_opt != -1)
11618 as_bad (_("use of old and new-style options to set CPU type"));
11620 mcpu_cpu_opt = legacy_cpu;
11622 else if (mcpu_cpu_opt == -1)
11623 mcpu_cpu_opt = march_cpu_opt;
11625 if (legacy_fpu != -1)
11627 if (mfpu_opt != -1)
11628 as_bad (_("use of old and new-style options to set FPU type"));
11630 mfpu_opt = legacy_fpu;
11632 else if (mfpu_opt == -1)
11634 #if !(defined (TE_LINUX) || defined (TE_NetBSD) || defined (TE_VXWORKS))
11635 /* Some environments specify a default FPU. If they don't, infer it
11636 from the processor. */
11637 if (mcpu_fpu_opt != -1)
11638 mfpu_opt = mcpu_fpu_opt;
11640 mfpu_opt = march_fpu_opt;
11642 mfpu_opt = FPU_DEFAULT;
11646 if (mfpu_opt == -1)
11648 if (mcpu_cpu_opt == -1)
11649 mfpu_opt = FPU_DEFAULT;
11650 else if (mcpu_cpu_opt & ARM_EXT_V5)
11651 mfpu_opt = FPU_ARCH_VFP_V2;
11653 mfpu_opt = FPU_ARCH_FPA;
11656 if (mcpu_cpu_opt == -1)
11657 mcpu_cpu_opt = CPU_DEFAULT;
11659 cpu_variant = mcpu_cpu_opt | mfpu_opt;
11661 #if defined OBJ_COFF || defined OBJ_ELF
11663 unsigned int flags = 0;
11665 #if defined OBJ_ELF
11666 flags = meabi_flags;
11668 switch (meabi_flags)
11670 case EF_ARM_EABI_UNKNOWN:
11672 /* Set the flags in the private structure. */
11673 if (uses_apcs_26) flags |= F_APCS26;
11674 if (support_interwork) flags |= F_INTERWORK;
11675 if (uses_apcs_float) flags |= F_APCS_FLOAT;
11676 if (pic_code) flags |= F_PIC;
11677 if ((cpu_variant & FPU_ANY) == FPU_NONE
11678 || (cpu_variant & FPU_ANY) == FPU_ARCH_VFP) /* VFP layout only. */
11679 flags |= F_SOFT_FLOAT;
11681 switch (mfloat_abi_opt)
11683 case ARM_FLOAT_ABI_SOFT:
11684 case ARM_FLOAT_ABI_SOFTFP:
11685 flags |= F_SOFT_FLOAT;
11688 case ARM_FLOAT_ABI_HARD:
11689 if (flags & F_SOFT_FLOAT)
11690 as_bad (_("hard-float conflicts with specified fpu"));
11694 /* Using VFP conventions (even if soft-float). */
11695 if (cpu_variant & FPU_VFP_EXT_NONE)
11696 flags |= F_VFP_FLOAT;
11698 #if defined OBJ_ELF
11699 if (cpu_variant & FPU_ARCH_MAVERICK)
11700 flags |= EF_ARM_MAVERICK_FLOAT;
11703 case EF_ARM_EABI_VER4:
11704 /* No additional flags to set. */
11711 bfd_set_private_flags (stdoutput, flags);
11713 /* We have run out flags in the COFF header to encode the
11714 status of ATPCS support, so instead we create a dummy,
11715 empty, debug section called .arm.atpcs. */
11720 sec = bfd_make_section (stdoutput, ".arm.atpcs");
11724 bfd_set_section_flags
11725 (stdoutput, sec, SEC_READONLY | SEC_DEBUGGING /* | SEC_HAS_CONTENTS */);
11726 bfd_set_section_size (stdoutput, sec, 0);
11727 bfd_set_section_contents (stdoutput, sec, NULL, 0, 0);
11733 /* Record the CPU type as well. */
11734 switch (cpu_variant & ARM_CPU_MASK)
11737 mach = bfd_mach_arm_2;
11740 case ARM_3: /* Also ARM_250. */
11741 mach = bfd_mach_arm_2a;
11744 case ARM_6: /* Also ARM_7. */
11745 mach = bfd_mach_arm_3;
11749 mach = bfd_mach_arm_unknown;
11753 /* Catch special cases. */
11754 if (cpu_variant & ARM_CEXT_IWMMXT)
11755 mach = bfd_mach_arm_iWMMXt;
11756 else if (cpu_variant & ARM_CEXT_XSCALE)
11757 mach = bfd_mach_arm_XScale;
11758 else if (cpu_variant & ARM_CEXT_MAVERICK)
11759 mach = bfd_mach_arm_ep9312;
11760 else if (cpu_variant & ARM_EXT_V5E)
11761 mach = bfd_mach_arm_5TE;
11762 else if (cpu_variant & ARM_EXT_V5)
11764 if (cpu_variant & ARM_EXT_V4T)
11765 mach = bfd_mach_arm_5T;
11767 mach = bfd_mach_arm_5;
11769 else if (cpu_variant & ARM_EXT_V4)
11771 if (cpu_variant & ARM_EXT_V4T)
11772 mach = bfd_mach_arm_4T;
11774 mach = bfd_mach_arm_4;
11776 else if (cpu_variant & ARM_EXT_V3M)
11777 mach = bfd_mach_arm_3M;
11779 bfd_set_arch_mach (stdoutput, TARGET_ARCH, mach);
11782 /* Command line processing. */
11785 Invocation line includes a switch not recognized by the base assembler.
11786 See if it's a processor-specific option.
11788 This routine is somewhat complicated by the need for backwards
11789 compatibility (since older releases of gcc can't be changed).
11790 The new options try to make the interface as compatible as
11793 New options (supported) are:
11795 -mcpu=<cpu name> Assemble for selected processor
11796 -march=<architecture name> Assemble for selected architecture
11797 -mfpu=<fpu architecture> Assemble for selected FPU.
11798 -EB/-mbig-endian Big-endian
11799 -EL/-mlittle-endian Little-endian
11800 -k Generate PIC code
11801 -mthumb Start in Thumb mode
11802 -mthumb-interwork Code supports ARM/Thumb interworking
11804 For now we will also provide support for:
11806 -mapcs-32 32-bit Program counter
11807 -mapcs-26 26-bit Program counter
11808 -macps-float Floats passed in FP registers
11809 -mapcs-reentrant Reentrant code
11811 (sometime these will probably be replaced with -mapcs=<list of options>
11812 and -matpcs=<list of options>)
11814 The remaining options are only supported for back-wards compatibility.
11815 Cpu variants, the arm part is optional:
11816 -m[arm]1 Currently not supported.
11817 -m[arm]2, -m[arm]250 Arm 2 and Arm 250 processor
11818 -m[arm]3 Arm 3 processor
11819 -m[arm]6[xx], Arm 6 processors
11820 -m[arm]7[xx][t][[d]m] Arm 7 processors
11821 -m[arm]8[10] Arm 8 processors
11822 -m[arm]9[20][tdmi] Arm 9 processors
11823 -mstrongarm[110[0]] StrongARM processors
11824 -mxscale XScale processors
11825 -m[arm]v[2345[t[e]]] Arm architectures
11826 -mall All (except the ARM1)
11828 -mfpa10, -mfpa11 FPA10 and 11 co-processor instructions
11829 -mfpe-old (No float load/store multiples)
11830 -mvfpxd VFP Single precision
11832 -mno-fpu Disable all floating point instructions
11834 The following CPU names are recognized:
11835 arm1, arm2, arm250, arm3, arm6, arm600, arm610, arm620,
11836 arm7, arm7m, arm7d, arm7dm, arm7di, arm7dmi, arm70, arm700,
11837 arm700i, arm710 arm710t, arm720, arm720t, arm740t, arm710c,
11838 arm7100, arm7500, arm7500fe, arm7tdmi, arm8, arm810, arm9,
11839 arm920, arm920t, arm940t, arm946, arm966, arm9tdmi, arm9e,
11840 arm10t arm10e, arm1020t, arm1020e, arm10200e,
11841 strongarm, strongarm110, strongarm1100, strongarm1110, xscale.
11845 const char * md_shortopts = "m:k";
11847 #ifdef ARM_BI_ENDIAN
11848 #define OPTION_EB (OPTION_MD_BASE + 0)
11849 #define OPTION_EL (OPTION_MD_BASE + 1)
11851 #if TARGET_BYTES_BIG_ENDIAN
11852 #define OPTION_EB (OPTION_MD_BASE + 0)
11854 #define OPTION_EL (OPTION_MD_BASE + 1)
11858 struct option md_longopts[] =
11861 {"EB", no_argument, NULL, OPTION_EB},
11864 {"EL", no_argument, NULL, OPTION_EL},
11866 {NULL, no_argument, NULL, 0}
11869 size_t md_longopts_size = sizeof (md_longopts);
11871 struct arm_option_table
11873 char *option; /* Option name to match. */
11874 char *help; /* Help information. */
11875 int *var; /* Variable to change. */
11876 int value; /* What to change it to. */
11877 char *deprecated; /* If non-null, print this message. */
11880 struct arm_option_table arm_opts[] =
11882 {"k", N_("generate PIC code"), &pic_code, 1, NULL},
11883 {"mthumb", N_("assemble Thumb code"), &thumb_mode, 1, NULL},
11884 {"mthumb-interwork", N_("support ARM/Thumb interworking"),
11885 &support_interwork, 1, NULL},
11886 {"mapcs-32", N_("code uses 32-bit program counter"), &uses_apcs_26, 0, NULL},
11887 {"mapcs-26", N_("code uses 26-bit program counter"), &uses_apcs_26, 1, NULL},
11888 {"mapcs-float", N_("floating point args are in fp regs"), &uses_apcs_float,
11890 {"mapcs-reentrant", N_("re-entrant code"), &pic_code, 1, NULL},
11891 {"matpcs", N_("code is ATPCS conformant"), &atpcs, 1, NULL},
11892 {"mbig-endian", N_("assemble for big-endian"), &target_big_endian, 1, NULL},
11893 {"mlittle-endian", N_("assemble for little-endian"), &target_big_endian, 0,
11896 /* These are recognized by the assembler, but have no affect on code. */
11897 {"mapcs-frame", N_("use frame pointer"), NULL, 0, NULL},
11898 {"mapcs-stack-check", N_("use stack size checking"), NULL, 0, NULL},
11900 /* DON'T add any new processors to this list -- we want the whole list
11901 to go away... Add them to the processors table instead. */
11902 {"marm1", NULL, &legacy_cpu, ARM_ARCH_V1, N_("use -mcpu=arm1")},
11903 {"m1", NULL, &legacy_cpu, ARM_ARCH_V1, N_("use -mcpu=arm1")},
11904 {"marm2", NULL, &legacy_cpu, ARM_ARCH_V2, N_("use -mcpu=arm2")},
11905 {"m2", NULL, &legacy_cpu, ARM_ARCH_V2, N_("use -mcpu=arm2")},
11906 {"marm250", NULL, &legacy_cpu, ARM_ARCH_V2S, N_("use -mcpu=arm250")},
11907 {"m250", NULL, &legacy_cpu, ARM_ARCH_V2S, N_("use -mcpu=arm250")},
11908 {"marm3", NULL, &legacy_cpu, ARM_ARCH_V2S, N_("use -mcpu=arm3")},
11909 {"m3", NULL, &legacy_cpu, ARM_ARCH_V2S, N_("use -mcpu=arm3")},
11910 {"marm6", NULL, &legacy_cpu, ARM_ARCH_V3, N_("use -mcpu=arm6")},
11911 {"m6", NULL, &legacy_cpu, ARM_ARCH_V3, N_("use -mcpu=arm6")},
11912 {"marm600", NULL, &legacy_cpu, ARM_ARCH_V3, N_("use -mcpu=arm600")},
11913 {"m600", NULL, &legacy_cpu, ARM_ARCH_V3, N_("use -mcpu=arm600")},
11914 {"marm610", NULL, &legacy_cpu, ARM_ARCH_V3, N_("use -mcpu=arm610")},
11915 {"m610", NULL, &legacy_cpu, ARM_ARCH_V3, N_("use -mcpu=arm610")},
11916 {"marm620", NULL, &legacy_cpu, ARM_ARCH_V3, N_("use -mcpu=arm620")},
11917 {"m620", NULL, &legacy_cpu, ARM_ARCH_V3, N_("use -mcpu=arm620")},
11918 {"marm7", NULL, &legacy_cpu, ARM_ARCH_V3, N_("use -mcpu=arm7")},
11919 {"m7", NULL, &legacy_cpu, ARM_ARCH_V3, N_("use -mcpu=arm7")},
11920 {"marm70", NULL, &legacy_cpu, ARM_ARCH_V3, N_("use -mcpu=arm70")},
11921 {"m70", NULL, &legacy_cpu, ARM_ARCH_V3, N_("use -mcpu=arm70")},
11922 {"marm700", NULL, &legacy_cpu, ARM_ARCH_V3, N_("use -mcpu=arm700")},
11923 {"m700", NULL, &legacy_cpu, ARM_ARCH_V3, N_("use -mcpu=arm700")},
11924 {"marm700i", NULL, &legacy_cpu, ARM_ARCH_V3, N_("use -mcpu=arm700i")},
11925 {"m700i", NULL, &legacy_cpu, ARM_ARCH_V3, N_("use -mcpu=arm700i")},
11926 {"marm710", NULL, &legacy_cpu, ARM_ARCH_V3, N_("use -mcpu=arm710")},
11927 {"m710", NULL, &legacy_cpu, ARM_ARCH_V3, N_("use -mcpu=arm710")},
11928 {"marm710c", NULL, &legacy_cpu, ARM_ARCH_V3, N_("use -mcpu=arm710c")},
11929 {"m710c", NULL, &legacy_cpu, ARM_ARCH_V3, N_("use -mcpu=arm710c")},
11930 {"marm720", NULL, &legacy_cpu, ARM_ARCH_V3, N_("use -mcpu=arm720")},
11931 {"m720", NULL, &legacy_cpu, ARM_ARCH_V3, N_("use -mcpu=arm720")},
11932 {"marm7d", NULL, &legacy_cpu, ARM_ARCH_V3, N_("use -mcpu=arm7d")},
11933 {"m7d", NULL, &legacy_cpu, ARM_ARCH_V3, N_("use -mcpu=arm7d")},
11934 {"marm7di", NULL, &legacy_cpu, ARM_ARCH_V3, N_("use -mcpu=arm7di")},
11935 {"m7di", NULL, &legacy_cpu, ARM_ARCH_V3, N_("use -mcpu=arm7di")},
11936 {"marm7m", NULL, &legacy_cpu, ARM_ARCH_V3M, N_("use -mcpu=arm7m")},
11937 {"m7m", NULL, &legacy_cpu, ARM_ARCH_V3M, N_("use -mcpu=arm7m")},
11938 {"marm7dm", NULL, &legacy_cpu, ARM_ARCH_V3M, N_("use -mcpu=arm7dm")},
11939 {"m7dm", NULL, &legacy_cpu, ARM_ARCH_V3M, N_("use -mcpu=arm7dm")},
11940 {"marm7dmi", NULL, &legacy_cpu, ARM_ARCH_V3M, N_("use -mcpu=arm7dmi")},
11941 {"m7dmi", NULL, &legacy_cpu, ARM_ARCH_V3M, N_("use -mcpu=arm7dmi")},
11942 {"marm7100", NULL, &legacy_cpu, ARM_ARCH_V3, N_("use -mcpu=arm7100")},
11943 {"m7100", NULL, &legacy_cpu, ARM_ARCH_V3, N_("use -mcpu=arm7100")},
11944 {"marm7500", NULL, &legacy_cpu, ARM_ARCH_V3, N_("use -mcpu=arm7500")},
11945 {"m7500", NULL, &legacy_cpu, ARM_ARCH_V3, N_("use -mcpu=arm7500")},
11946 {"marm7500fe", NULL, &legacy_cpu, ARM_ARCH_V3, N_("use -mcpu=arm7500fe")},
11947 {"m7500fe", NULL, &legacy_cpu, ARM_ARCH_V3, N_("use -mcpu=arm7500fe")},
11948 {"marm7t", NULL, &legacy_cpu, ARM_ARCH_V4T, N_("use -mcpu=arm7tdmi")},
11949 {"m7t", NULL, &legacy_cpu, ARM_ARCH_V4T, N_("use -mcpu=arm7tdmi")},
11950 {"marm7tdmi", NULL, &legacy_cpu, ARM_ARCH_V4T, N_("use -mcpu=arm7tdmi")},
11951 {"m7tdmi", NULL, &legacy_cpu, ARM_ARCH_V4T, N_("use -mcpu=arm7tdmi")},
11952 {"marm710t", NULL, &legacy_cpu, ARM_ARCH_V4T, N_("use -mcpu=arm710t")},
11953 {"m710t", NULL, &legacy_cpu, ARM_ARCH_V4T, N_("use -mcpu=arm710t")},
11954 {"marm720t", NULL, &legacy_cpu, ARM_ARCH_V4T, N_("use -mcpu=arm720t")},
11955 {"m720t", NULL, &legacy_cpu, ARM_ARCH_V4T, N_("use -mcpu=arm720t")},
11956 {"marm740t", NULL, &legacy_cpu, ARM_ARCH_V4T, N_("use -mcpu=arm740t")},
11957 {"m740t", NULL, &legacy_cpu, ARM_ARCH_V4T, N_("use -mcpu=arm740t")},
11958 {"marm8", NULL, &legacy_cpu, ARM_ARCH_V4, N_("use -mcpu=arm8")},
11959 {"m8", NULL, &legacy_cpu, ARM_ARCH_V4, N_("use -mcpu=arm8")},
11960 {"marm810", NULL, &legacy_cpu, ARM_ARCH_V4, N_("use -mcpu=arm810")},
11961 {"m810", NULL, &legacy_cpu, ARM_ARCH_V4, N_("use -mcpu=arm810")},
11962 {"marm9", NULL, &legacy_cpu, ARM_ARCH_V4T, N_("use -mcpu=arm9")},
11963 {"m9", NULL, &legacy_cpu, ARM_ARCH_V4T, N_("use -mcpu=arm9")},
11964 {"marm9tdmi", NULL, &legacy_cpu, ARM_ARCH_V4T, N_("use -mcpu=arm9tdmi")},
11965 {"m9tdmi", NULL, &legacy_cpu, ARM_ARCH_V4T, N_("use -mcpu=arm9tdmi")},
11966 {"marm920", NULL, &legacy_cpu, ARM_ARCH_V4T, N_("use -mcpu=arm920")},
11967 {"m920", NULL, &legacy_cpu, ARM_ARCH_V4T, N_("use -mcpu=arm920")},
11968 {"marm940", NULL, &legacy_cpu, ARM_ARCH_V4T, N_("use -mcpu=arm940")},
11969 {"m940", NULL, &legacy_cpu, ARM_ARCH_V4T, N_("use -mcpu=arm940")},
11970 {"mstrongarm", NULL, &legacy_cpu, ARM_ARCH_V4, N_("use -mcpu=strongarm")},
11971 {"mstrongarm110", NULL, &legacy_cpu, ARM_ARCH_V4,
11972 N_("use -mcpu=strongarm110")},
11973 {"mstrongarm1100", NULL, &legacy_cpu, ARM_ARCH_V4,
11974 N_("use -mcpu=strongarm1100")},
11975 {"mstrongarm1110", NULL, &legacy_cpu, ARM_ARCH_V4,
11976 N_("use -mcpu=strongarm1110")},
11977 {"mxscale", NULL, &legacy_cpu, ARM_ARCH_XSCALE, N_("use -mcpu=xscale")},
11978 {"miwmmxt", NULL, &legacy_cpu, ARM_ARCH_IWMMXT, N_("use -mcpu=iwmmxt")},
11979 {"mall", NULL, &legacy_cpu, ARM_ANY, N_("use -mcpu=all")},
11981 /* Architecture variants -- don't add any more to this list either. */
11982 {"mv2", NULL, &legacy_cpu, ARM_ARCH_V2, N_("use -march=armv2")},
11983 {"marmv2", NULL, &legacy_cpu, ARM_ARCH_V2, N_("use -march=armv2")},
11984 {"mv2a", NULL, &legacy_cpu, ARM_ARCH_V2S, N_("use -march=armv2a")},
11985 {"marmv2a", NULL, &legacy_cpu, ARM_ARCH_V2S, N_("use -march=armv2a")},
11986 {"mv3", NULL, &legacy_cpu, ARM_ARCH_V3, N_("use -march=armv3")},
11987 {"marmv3", NULL, &legacy_cpu, ARM_ARCH_V3, N_("use -march=armv3")},
11988 {"mv3m", NULL, &legacy_cpu, ARM_ARCH_V3M, N_("use -march=armv3m")},
11989 {"marmv3m", NULL, &legacy_cpu, ARM_ARCH_V3M, N_("use -march=armv3m")},
11990 {"mv4", NULL, &legacy_cpu, ARM_ARCH_V4, N_("use -march=armv4")},
11991 {"marmv4", NULL, &legacy_cpu, ARM_ARCH_V4, N_("use -march=armv4")},
11992 {"mv4t", NULL, &legacy_cpu, ARM_ARCH_V4T, N_("use -march=armv4t")},
11993 {"marmv4t", NULL, &legacy_cpu, ARM_ARCH_V4T, N_("use -march=armv4t")},
11994 {"mv5", NULL, &legacy_cpu, ARM_ARCH_V5, N_("use -march=armv5")},
11995 {"marmv5", NULL, &legacy_cpu, ARM_ARCH_V5, N_("use -march=armv5")},
11996 {"mv5t", NULL, &legacy_cpu, ARM_ARCH_V5T, N_("use -march=armv5t")},
11997 {"marmv5t", NULL, &legacy_cpu, ARM_ARCH_V5T, N_("use -march=armv5t")},
11998 {"mv5e", NULL, &legacy_cpu, ARM_ARCH_V5TE, N_("use -march=armv5te")},
11999 {"marmv5e", NULL, &legacy_cpu, ARM_ARCH_V5TE, N_("use -march=armv5te")},
12001 /* Floating point variants -- don't add any more to this list either. */
12002 {"mfpe-old", NULL, &legacy_fpu, FPU_ARCH_FPE, N_("use -mfpu=fpe")},
12003 {"mfpa10", NULL, &legacy_fpu, FPU_ARCH_FPA, N_("use -mfpu=fpa10")},
12004 {"mfpa11", NULL, &legacy_fpu, FPU_ARCH_FPA, N_("use -mfpu=fpa11")},
12005 {"mno-fpu", NULL, &legacy_fpu, 0,
12006 N_("use either -mfpu=softfpa or -mfpu=softvfp")},
12008 {NULL, NULL, NULL, 0, NULL}
12011 struct arm_cpu_option_table
12015 /* For some CPUs we assume an FPU unless the user explicitly sets
12020 /* This list should, at a minimum, contain all the cpu names
12021 recognized by GCC. */
12022 static struct arm_cpu_option_table arm_cpus[] =
12024 {"all", ARM_ANY, FPU_ARCH_FPA},
12025 {"arm1", ARM_ARCH_V1, FPU_ARCH_FPA},
12026 {"arm2", ARM_ARCH_V2, FPU_ARCH_FPA},
12027 {"arm250", ARM_ARCH_V2S, FPU_ARCH_FPA},
12028 {"arm3", ARM_ARCH_V2S, FPU_ARCH_FPA},
12029 {"arm6", ARM_ARCH_V3, FPU_ARCH_FPA},
12030 {"arm60", ARM_ARCH_V3, FPU_ARCH_FPA},
12031 {"arm600", ARM_ARCH_V3, FPU_ARCH_FPA},
12032 {"arm610", ARM_ARCH_V3, FPU_ARCH_FPA},
12033 {"arm620", ARM_ARCH_V3, FPU_ARCH_FPA},
12034 {"arm7", ARM_ARCH_V3, FPU_ARCH_FPA},
12035 {"arm7m", ARM_ARCH_V3M, FPU_ARCH_FPA},
12036 {"arm7d", ARM_ARCH_V3, FPU_ARCH_FPA},
12037 {"arm7dm", ARM_ARCH_V3M, FPU_ARCH_FPA},
12038 {"arm7di", ARM_ARCH_V3, FPU_ARCH_FPA},
12039 {"arm7dmi", ARM_ARCH_V3M, FPU_ARCH_FPA},
12040 {"arm70", ARM_ARCH_V3, FPU_ARCH_FPA},
12041 {"arm700", ARM_ARCH_V3, FPU_ARCH_FPA},
12042 {"arm700i", ARM_ARCH_V3, FPU_ARCH_FPA},
12043 {"arm710", ARM_ARCH_V3, FPU_ARCH_FPA},
12044 {"arm710t", ARM_ARCH_V4T, FPU_ARCH_FPA},
12045 {"arm720", ARM_ARCH_V3, FPU_ARCH_FPA},
12046 {"arm720t", ARM_ARCH_V4T, FPU_ARCH_FPA},
12047 {"arm740t", ARM_ARCH_V4T, FPU_ARCH_FPA},
12048 {"arm710c", ARM_ARCH_V3, FPU_ARCH_FPA},
12049 {"arm7100", ARM_ARCH_V3, FPU_ARCH_FPA},
12050 {"arm7500", ARM_ARCH_V3, FPU_ARCH_FPA},
12051 {"arm7500fe", ARM_ARCH_V3, FPU_ARCH_FPA},
12052 {"arm7t", ARM_ARCH_V4T, FPU_ARCH_FPA},
12053 {"arm7tdmi", ARM_ARCH_V4T, FPU_ARCH_FPA},
12054 {"arm7tdmi-s", ARM_ARCH_V4T, FPU_ARCH_FPA},
12055 {"arm8", ARM_ARCH_V4, FPU_ARCH_FPA},
12056 {"arm810", ARM_ARCH_V4, FPU_ARCH_FPA},
12057 {"strongarm", ARM_ARCH_V4, FPU_ARCH_FPA},
12058 {"strongarm1", ARM_ARCH_V4, FPU_ARCH_FPA},
12059 {"strongarm110", ARM_ARCH_V4, FPU_ARCH_FPA},
12060 {"strongarm1100", ARM_ARCH_V4, FPU_ARCH_FPA},
12061 {"strongarm1110", ARM_ARCH_V4, FPU_ARCH_FPA},
12062 {"arm9", ARM_ARCH_V4T, FPU_ARCH_FPA},
12063 {"arm920", ARM_ARCH_V4T, FPU_ARCH_FPA},
12064 {"arm920t", ARM_ARCH_V4T, FPU_ARCH_FPA},
12065 {"arm922t", ARM_ARCH_V4T, FPU_ARCH_FPA},
12066 {"arm940t", ARM_ARCH_V4T, FPU_ARCH_FPA},
12067 {"arm9tdmi", ARM_ARCH_V4T, FPU_ARCH_FPA},
12068 /* For V5 or later processors we default to using VFP; but the user
12069 should really set the FPU type explicitly. */
12070 {"arm9e-r0", ARM_ARCH_V5TExP, FPU_ARCH_VFP_V2},
12071 {"arm9e", ARM_ARCH_V5TE, FPU_ARCH_VFP_V2},
12072 {"arm926ej", ARM_ARCH_V5TEJ, FPU_ARCH_VFP_V2},
12073 {"arm926ejs", ARM_ARCH_V5TEJ, FPU_ARCH_VFP_V2},
12074 {"arm926ej-s", ARM_ARCH_V5TEJ, FPU_ARCH_VFP_V2},
12075 {"arm946e-r0", ARM_ARCH_V5TExP, FPU_ARCH_VFP_V2},
12076 {"arm946e", ARM_ARCH_V5TE, FPU_ARCH_VFP_V2},
12077 {"arm966e-r0", ARM_ARCH_V5TExP, FPU_ARCH_VFP_V2},
12078 {"arm966e", ARM_ARCH_V5TE, FPU_ARCH_VFP_V2},
12079 {"arm10t", ARM_ARCH_V5T, FPU_ARCH_VFP_V1},
12080 {"arm10e", ARM_ARCH_V5TE, FPU_ARCH_VFP_V2},
12081 {"arm1020", ARM_ARCH_V5TE, FPU_ARCH_VFP_V2},
12082 {"arm1020t", ARM_ARCH_V5T, FPU_ARCH_VFP_V1},
12083 {"arm1020e", ARM_ARCH_V5TE, FPU_ARCH_VFP_V2},
12084 {"arm1026ejs", ARM_ARCH_V5TEJ, FPU_ARCH_VFP_V2},
12085 {"arm1026ej-s", ARM_ARCH_V5TEJ, FPU_ARCH_VFP_V2},
12086 {"arm1136js", ARM_ARCH_V6, FPU_NONE},
12087 {"arm1136j-s", ARM_ARCH_V6, FPU_NONE},
12088 {"arm1136jfs", ARM_ARCH_V6, FPU_ARCH_VFP_V2},
12089 {"arm1136jf-s", ARM_ARCH_V6, FPU_ARCH_VFP_V2},
12090 {"mpcore", ARM_ARCH_V6K, FPU_ARCH_VFP_V2},
12091 {"mpcorenovfp", ARM_ARCH_V6K, FPU_NONE},
12092 {"arm1176jz-s", ARM_ARCH_V6ZK, FPU_NONE},
12093 {"arm1176jzf-s", ARM_ARCH_V6ZK, FPU_ARCH_VFP_V2},
12094 /* ??? XSCALE is really an architecture. */
12095 {"xscale", ARM_ARCH_XSCALE, FPU_ARCH_VFP_V2},
12096 /* ??? iwmmxt is not a processor. */
12097 {"iwmmxt", ARM_ARCH_IWMMXT, FPU_ARCH_VFP_V2},
12098 {"i80200", ARM_ARCH_XSCALE, FPU_ARCH_VFP_V2},
12100 {"ep9312", ARM_ARCH_V4T | ARM_CEXT_MAVERICK, FPU_ARCH_MAVERICK},
12104 struct arm_arch_option_table
12111 /* This list should, at a minimum, contain all the architecture names
12112 recognized by GCC. */
12113 static struct arm_arch_option_table arm_archs[] =
12115 {"all", ARM_ANY, FPU_ARCH_FPA},
12116 {"armv1", ARM_ARCH_V1, FPU_ARCH_FPA},
12117 {"armv2", ARM_ARCH_V2, FPU_ARCH_FPA},
12118 {"armv2a", ARM_ARCH_V2S, FPU_ARCH_FPA},
12119 {"armv2s", ARM_ARCH_V2S, FPU_ARCH_FPA},
12120 {"armv3", ARM_ARCH_V3, FPU_ARCH_FPA},
12121 {"armv3m", ARM_ARCH_V3M, FPU_ARCH_FPA},
12122 {"armv4", ARM_ARCH_V4, FPU_ARCH_FPA},
12123 {"armv4xm", ARM_ARCH_V4xM, FPU_ARCH_FPA},
12124 {"armv4t", ARM_ARCH_V4T, FPU_ARCH_FPA},
12125 {"armv4txm", ARM_ARCH_V4TxM, FPU_ARCH_FPA},
12126 {"armv5", ARM_ARCH_V5, FPU_ARCH_VFP},
12127 {"armv5t", ARM_ARCH_V5T, FPU_ARCH_VFP},
12128 {"armv5txm", ARM_ARCH_V5TxM, FPU_ARCH_VFP},
12129 {"armv5te", ARM_ARCH_V5TE, FPU_ARCH_VFP},
12130 {"armv5texp", ARM_ARCH_V5TExP, FPU_ARCH_VFP},
12131 {"armv5tej", ARM_ARCH_V5TEJ, FPU_ARCH_VFP},
12132 {"armv6", ARM_ARCH_V6, FPU_ARCH_VFP},
12133 {"armv6j", ARM_ARCH_V6, FPU_ARCH_VFP},
12134 {"armv6k", ARM_ARCH_V6K, FPU_ARCH_VFP},
12135 {"armv6z", ARM_ARCH_V6Z, FPU_ARCH_VFP},
12136 {"armv6zk", ARM_ARCH_V6ZK, FPU_ARCH_VFP},
12137 {"armv6t2", ARM_ARCH_V6T2, FPU_ARCH_VFP},
12138 {"armv6kt2", ARM_ARCH_V6KT2, FPU_ARCH_VFP},
12139 {"armv6zt2", ARM_ARCH_V6ZT2, FPU_ARCH_VFP},
12140 {"armv6zkt2", ARM_ARCH_V6ZKT2, FPU_ARCH_VFP},
12141 {"xscale", ARM_ARCH_XSCALE, FPU_ARCH_VFP},
12142 {"iwmmxt", ARM_ARCH_IWMMXT, FPU_ARCH_VFP},
12146 /* ISA extensions in the co-processor space. */
12147 struct arm_option_value_table
12153 static struct arm_option_value_table arm_extensions[] =
12155 {"maverick", ARM_CEXT_MAVERICK},
12156 {"xscale", ARM_CEXT_XSCALE},
12157 {"iwmmxt", ARM_CEXT_IWMMXT},
12161 /* This list should, at a minimum, contain all the fpu names
12162 recognized by GCC. */
12163 static struct arm_option_value_table arm_fpus[] =
12165 {"softfpa", FPU_NONE},
12166 {"fpe", FPU_ARCH_FPE},
12167 {"fpe2", FPU_ARCH_FPE},
12168 {"fpe3", FPU_ARCH_FPA}, /* Third release supports LFM/SFM. */
12169 {"fpa", FPU_ARCH_FPA},
12170 {"fpa10", FPU_ARCH_FPA},
12171 {"fpa11", FPU_ARCH_FPA},
12172 {"arm7500fe", FPU_ARCH_FPA},
12173 {"softvfp", FPU_ARCH_VFP},
12174 {"softvfp+vfp", FPU_ARCH_VFP_V2},
12175 {"vfp", FPU_ARCH_VFP_V2},
12176 {"vfp9", FPU_ARCH_VFP_V2},
12177 {"vfp10", FPU_ARCH_VFP_V2},
12178 {"vfp10-r0", FPU_ARCH_VFP_V1},
12179 {"vfpxd", FPU_ARCH_VFP_V1xD},
12180 {"arm1020t", FPU_ARCH_VFP_V1},
12181 {"arm1020e", FPU_ARCH_VFP_V2},
12182 {"arm1136jfs", FPU_ARCH_VFP_V2},
12183 {"arm1136jf-s", FPU_ARCH_VFP_V2},
12184 {"maverick", FPU_ARCH_MAVERICK},
12188 static struct arm_option_value_table arm_float_abis[] =
12190 {"hard", ARM_FLOAT_ABI_HARD},
12191 {"softfp", ARM_FLOAT_ABI_SOFTFP},
12192 {"soft", ARM_FLOAT_ABI_SOFT},
12197 /* We only know how to output GNU and ver 4 (AAELF) formats. */
12198 static struct arm_option_value_table arm_eabis[] =
12200 {"gnu", EF_ARM_EABI_UNKNOWN},
12201 {"4", EF_ARM_EABI_VER4},
12206 struct arm_long_option_table
12208 char * option; /* Substring to match. */
12209 char * help; /* Help information. */
12210 int (* func) (char * subopt); /* Function to decode sub-option. */
12211 char * deprecated; /* If non-null, print this message. */
12215 arm_parse_extension (char * str, int * opt_p)
12217 while (str != NULL && *str != 0)
12219 struct arm_option_value_table * opt;
12225 as_bad (_("invalid architectural extension"));
12230 ext = strchr (str, '+');
12233 optlen = ext - str;
12235 optlen = strlen (str);
12239 as_bad (_("missing architectural extension"));
12243 for (opt = arm_extensions; opt->name != NULL; opt++)
12244 if (strncmp (opt->name, str, optlen) == 0)
12246 *opt_p |= opt->value;
12250 if (opt->name == NULL)
12252 as_bad (_("unknown architectural extnsion `%s'"), str);
12263 arm_parse_cpu (char * str)
12265 struct arm_cpu_option_table * opt;
12266 char * ext = strchr (str, '+');
12270 optlen = ext - str;
12272 optlen = strlen (str);
12276 as_bad (_("missing cpu name `%s'"), str);
12280 for (opt = arm_cpus; opt->name != NULL; opt++)
12281 if (strncmp (opt->name, str, optlen) == 0)
12283 mcpu_cpu_opt = opt->value;
12284 mcpu_fpu_opt = opt->default_fpu;
12287 return arm_parse_extension (ext, &mcpu_cpu_opt);
12292 as_bad (_("unknown cpu `%s'"), str);
12297 arm_parse_arch (char * str)
12299 struct arm_arch_option_table *opt;
12300 char *ext = strchr (str, '+');
12304 optlen = ext - str;
12306 optlen = strlen (str);
12310 as_bad (_("missing architecture name `%s'"), str);
12315 for (opt = arm_archs; opt->name != NULL; opt++)
12316 if (streq (opt->name, str))
12318 march_cpu_opt = opt->value;
12319 march_fpu_opt = opt->default_fpu;
12322 return arm_parse_extension (ext, &march_cpu_opt);
12327 as_bad (_("unknown architecture `%s'\n"), str);
12332 arm_parse_fpu (char * str)
12334 struct arm_option_value_table * opt;
12336 for (opt = arm_fpus; opt->name != NULL; opt++)
12337 if (streq (opt->name, str))
12339 mfpu_opt = opt->value;
12343 as_bad (_("unknown floating point format `%s'\n"), str);
12348 arm_parse_float_abi (char * str)
12350 struct arm_option_value_table * opt;
12352 for (opt = arm_float_abis; opt->name != NULL; opt++)
12353 if (streq (opt->name, str))
12355 mfloat_abi_opt = opt->value;
12359 as_bad (_("unknown floating point abi `%s'\n"), str);
12365 arm_parse_eabi (char * str)
12367 struct arm_option_value_table *opt;
12369 for (opt = arm_eabis; opt->name != NULL; opt++)
12370 if (streq (opt->name, str))
12372 meabi_flags = opt->value;
12375 as_bad (_("unknown EABI `%s'\n"), str);
12380 struct arm_long_option_table arm_long_opts[] =
12382 {"mcpu=", N_("<cpu name>\t assemble for CPU <cpu name>"),
12383 arm_parse_cpu, NULL},
12384 {"march=", N_("<arch name>\t assemble for architecture <arch name>"),
12385 arm_parse_arch, NULL},
12386 {"mfpu=", N_("<fpu name>\t assemble for FPU architecture <fpu name>"),
12387 arm_parse_fpu, NULL},
12388 {"mfloat-abi=", N_("<abi>\t assemble for floating point ABI <abi>"),
12389 arm_parse_float_abi, NULL},
12391 {"meabi=", N_("<ver>\t assemble for eabi version <ver>"),
12392 arm_parse_eabi, NULL},
12394 {NULL, NULL, 0, NULL}
12398 md_parse_option (int c, char * arg)
12400 struct arm_option_table *opt;
12401 struct arm_long_option_table *lopt;
12407 target_big_endian = 1;
12413 target_big_endian = 0;
12418 /* Listing option. Just ignore these, we don't support additional
12423 for (opt = arm_opts; opt->option != NULL; opt++)
12425 if (c == opt->option[0]
12426 && ((arg == NULL && opt->option[1] == 0)
12427 || streq (arg, opt->option + 1)))
12429 #if WARN_DEPRECATED
12430 /* If the option is deprecated, tell the user. */
12431 if (opt->deprecated != NULL)
12432 as_tsktsk (_("option `-%c%s' is deprecated: %s"), c,
12433 arg ? arg : "", _(opt->deprecated));
12436 if (opt->var != NULL)
12437 *opt->var = opt->value;
12443 for (lopt = arm_long_opts; lopt->option != NULL; lopt++)
12445 /* These options are expected to have an argument. */
12446 if (c == lopt->option[0]
12448 && strncmp (arg, lopt->option + 1,
12449 strlen (lopt->option + 1)) == 0)
12451 #if WARN_DEPRECATED
12452 /* If the option is deprecated, tell the user. */
12453 if (lopt->deprecated != NULL)
12454 as_tsktsk (_("option `-%c%s' is deprecated: %s"), c, arg,
12455 _(lopt->deprecated));
12458 /* Call the sup-option parser. */
12459 return lopt->func (arg + strlen (lopt->option) - 1);
12470 md_show_usage (FILE * fp)
12472 struct arm_option_table *opt;
12473 struct arm_long_option_table *lopt;
12475 fprintf (fp, _(" ARM-specific assembler options:\n"));
12477 for (opt = arm_opts; opt->option != NULL; opt++)
12478 if (opt->help != NULL)
12479 fprintf (fp, " -%-23s%s\n", opt->option, _(opt->help));
12481 for (lopt = arm_long_opts; lopt->option != NULL; lopt++)
12482 if (lopt->help != NULL)
12483 fprintf (fp, " -%s%s\n", lopt->option, _(lopt->help));
12487 -EB assemble code for a big-endian cpu\n"));
12492 -EL assemble code for a little-endian cpu\n"));