1 /* tc-arm.c -- Assemble for the ARM
2 Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
3 2004, 2005, 2006, 2007, 2008, 2009, 2010
4 Free Software Foundation, Inc.
5 Contributed by Richard Earnshaw (rwe@pegasus.esprit.ec.org)
6 Modified by David Taylor (dtaylor@armltd.co.uk)
7 Cirrus coprocessor mods by Aldy Hernandez (aldyh@redhat.com)
8 Cirrus coprocessor fixes by Petko Manolov (petkan@nucleusys.com)
9 Cirrus coprocessor fixes by Vladimir Ivanov (vladitx@nucleusys.com)
11 This file is part of GAS, the GNU Assembler.
13 GAS is free software; you can redistribute it and/or modify
14 it under the terms of the GNU General Public License as published by
15 the Free Software Foundation; either version 3, or (at your option)
18 GAS is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 GNU General Public License for more details.
23 You should have received a copy of the GNU General Public License
24 along with GAS; see the file COPYING. If not, write to the Free
25 Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
32 #include "safe-ctype.h"
36 #include "opcode/arm.h"
40 #include "dw2gencfi.h"
43 #include "dwarf2dbg.h"
46 /* Must be at least the size of the largest unwind opcode (currently two). */
47 #define ARM_OPCODE_CHUNK_SIZE 8
49 /* This structure holds the unwinding state. */
54 symbolS
* table_entry
;
55 symbolS
* personality_routine
;
56 int personality_index
;
57 /* The segment containing the function. */
60 /* Opcodes generated from this function. */
61 unsigned char * opcodes
;
64 /* The number of bytes pushed to the stack. */
66 /* We don't add stack adjustment opcodes immediately so that we can merge
67 multiple adjustments. We can also omit the final adjustment
68 when using a frame pointer. */
69 offsetT pending_offset
;
70 /* These two fields are set by both unwind_movsp and unwind_setfp. They
71 hold the reg+offset to use when restoring sp from a frame pointer. */
74 /* Nonzero if an unwind_setfp directive has been seen. */
76 /* Nonzero if the last opcode restores sp from fp_reg. */
77 unsigned sp_restored
:1;
82 /* Results from operand parsing worker functions. */
86 PARSE_OPERAND_SUCCESS
,
88 PARSE_OPERAND_FAIL_NO_BACKTRACK
89 } parse_operand_result
;
98 /* Types of processor to assemble for. */
100 /* The code that was here used to select a default CPU depending on compiler
101 pre-defines which were only present when doing native builds, thus
102 changing gas' default behaviour depending upon the build host.
104 If you have a target that requires a default CPU option then the you
105 should define CPU_DEFAULT here. */
110 # define FPU_DEFAULT FPU_ARCH_FPA
111 # elif defined (TE_NetBSD)
113 # define FPU_DEFAULT FPU_ARCH_VFP /* Soft-float, but VFP order. */
115 /* Legacy a.out format. */
116 # define FPU_DEFAULT FPU_ARCH_FPA /* Soft-float, but FPA order. */
118 # elif defined (TE_VXWORKS)
119 # define FPU_DEFAULT FPU_ARCH_VFP /* Soft-float, VFP order. */
121 /* For backwards compatibility, default to FPA. */
122 # define FPU_DEFAULT FPU_ARCH_FPA
124 #endif /* ifndef FPU_DEFAULT */
126 #define streq(a, b) (strcmp (a, b) == 0)
128 static arm_feature_set cpu_variant
;
129 static arm_feature_set arm_arch_used
;
130 static arm_feature_set thumb_arch_used
;
132 /* Flags stored in private area of BFD structure. */
133 static int uses_apcs_26
= FALSE
;
134 static int atpcs
= FALSE
;
135 static int support_interwork
= FALSE
;
136 static int uses_apcs_float
= FALSE
;
137 static int pic_code
= FALSE
;
138 static int fix_v4bx
= FALSE
;
139 /* Warn on using deprecated features. */
140 static int warn_on_deprecated
= TRUE
;
143 /* Variables that we set while parsing command-line options. Once all
144 options have been read we re-process these values to set the real
146 static const arm_feature_set
*legacy_cpu
= NULL
;
147 static const arm_feature_set
*legacy_fpu
= NULL
;
149 static const arm_feature_set
*mcpu_cpu_opt
= NULL
;
150 static const arm_feature_set
*mcpu_fpu_opt
= NULL
;
151 static const arm_feature_set
*march_cpu_opt
= NULL
;
152 static const arm_feature_set
*march_fpu_opt
= NULL
;
153 static const arm_feature_set
*mfpu_opt
= NULL
;
154 static const arm_feature_set
*object_arch
= NULL
;
156 /* Constants for known architecture features. */
157 static const arm_feature_set fpu_default
= FPU_DEFAULT
;
158 static const arm_feature_set fpu_arch_vfp_v1
= FPU_ARCH_VFP_V1
;
159 static const arm_feature_set fpu_arch_vfp_v2
= FPU_ARCH_VFP_V2
;
160 static const arm_feature_set fpu_arch_vfp_v3
= FPU_ARCH_VFP_V3
;
161 static const arm_feature_set fpu_arch_neon_v1
= FPU_ARCH_NEON_V1
;
162 static const arm_feature_set fpu_arch_fpa
= FPU_ARCH_FPA
;
163 static const arm_feature_set fpu_any_hard
= FPU_ANY_HARD
;
164 static const arm_feature_set fpu_arch_maverick
= FPU_ARCH_MAVERICK
;
165 static const arm_feature_set fpu_endian_pure
= FPU_ARCH_ENDIAN_PURE
;
168 static const arm_feature_set cpu_default
= CPU_DEFAULT
;
171 static const arm_feature_set arm_ext_v1
= ARM_FEATURE (ARM_EXT_V1
, 0);
172 static const arm_feature_set arm_ext_v2
= ARM_FEATURE (ARM_EXT_V1
, 0);
173 static const arm_feature_set arm_ext_v2s
= ARM_FEATURE (ARM_EXT_V2S
, 0);
174 static const arm_feature_set arm_ext_v3
= ARM_FEATURE (ARM_EXT_V3
, 0);
175 static const arm_feature_set arm_ext_v3m
= ARM_FEATURE (ARM_EXT_V3M
, 0);
176 static const arm_feature_set arm_ext_v4
= ARM_FEATURE (ARM_EXT_V4
, 0);
177 static const arm_feature_set arm_ext_v4t
= ARM_FEATURE (ARM_EXT_V4T
, 0);
178 static const arm_feature_set arm_ext_v5
= ARM_FEATURE (ARM_EXT_V5
, 0);
179 static const arm_feature_set arm_ext_v4t_5
=
180 ARM_FEATURE (ARM_EXT_V4T
| ARM_EXT_V5
, 0);
181 static const arm_feature_set arm_ext_v5t
= ARM_FEATURE (ARM_EXT_V5T
, 0);
182 static const arm_feature_set arm_ext_v5e
= ARM_FEATURE (ARM_EXT_V5E
, 0);
183 static const arm_feature_set arm_ext_v5exp
= ARM_FEATURE (ARM_EXT_V5ExP
, 0);
184 static const arm_feature_set arm_ext_v5j
= ARM_FEATURE (ARM_EXT_V5J
, 0);
185 static const arm_feature_set arm_ext_v6
= ARM_FEATURE (ARM_EXT_V6
, 0);
186 static const arm_feature_set arm_ext_v6k
= ARM_FEATURE (ARM_EXT_V6K
, 0);
187 static const arm_feature_set arm_ext_v6z
= ARM_FEATURE (ARM_EXT_V6Z
, 0);
188 static const arm_feature_set arm_ext_v6t2
= ARM_FEATURE (ARM_EXT_V6T2
, 0);
189 static const arm_feature_set arm_ext_v6_notm
= ARM_FEATURE (ARM_EXT_V6_NOTM
, 0);
190 static const arm_feature_set arm_ext_v6_dsp
= ARM_FEATURE (ARM_EXT_V6_DSP
, 0);
191 static const arm_feature_set arm_ext_barrier
= ARM_FEATURE (ARM_EXT_BARRIER
, 0);
192 static const arm_feature_set arm_ext_msr
= ARM_FEATURE (ARM_EXT_THUMB_MSR
, 0);
193 static const arm_feature_set arm_ext_div
= ARM_FEATURE (ARM_EXT_DIV
, 0);
194 static const arm_feature_set arm_ext_v7
= ARM_FEATURE (ARM_EXT_V7
, 0);
195 static const arm_feature_set arm_ext_v7a
= ARM_FEATURE (ARM_EXT_V7A
, 0);
196 static const arm_feature_set arm_ext_v7r
= ARM_FEATURE (ARM_EXT_V7R
, 0);
197 static const arm_feature_set arm_ext_v7m
= ARM_FEATURE (ARM_EXT_V7M
, 0);
198 static const arm_feature_set arm_ext_m
=
199 ARM_FEATURE (ARM_EXT_V6M
| ARM_EXT_V7M
, 0);
201 static const arm_feature_set arm_arch_any
= ARM_ANY
;
202 static const arm_feature_set arm_arch_full
= ARM_FEATURE (-1, -1);
203 static const arm_feature_set arm_arch_t2
= ARM_ARCH_THUMB2
;
204 static const arm_feature_set arm_arch_none
= ARM_ARCH_NONE
;
206 static const arm_feature_set arm_cext_iwmmxt2
=
207 ARM_FEATURE (0, ARM_CEXT_IWMMXT2
);
208 static const arm_feature_set arm_cext_iwmmxt
=
209 ARM_FEATURE (0, ARM_CEXT_IWMMXT
);
210 static const arm_feature_set arm_cext_xscale
=
211 ARM_FEATURE (0, ARM_CEXT_XSCALE
);
212 static const arm_feature_set arm_cext_maverick
=
213 ARM_FEATURE (0, ARM_CEXT_MAVERICK
);
214 static const arm_feature_set fpu_fpa_ext_v1
= ARM_FEATURE (0, FPU_FPA_EXT_V1
);
215 static const arm_feature_set fpu_fpa_ext_v2
= ARM_FEATURE (0, FPU_FPA_EXT_V2
);
216 static const arm_feature_set fpu_vfp_ext_v1xd
=
217 ARM_FEATURE (0, FPU_VFP_EXT_V1xD
);
218 static const arm_feature_set fpu_vfp_ext_v1
= ARM_FEATURE (0, FPU_VFP_EXT_V1
);
219 static const arm_feature_set fpu_vfp_ext_v2
= ARM_FEATURE (0, FPU_VFP_EXT_V2
);
220 static const arm_feature_set fpu_vfp_ext_v3xd
= ARM_FEATURE (0, FPU_VFP_EXT_V3xD
);
221 static const arm_feature_set fpu_vfp_ext_v3
= ARM_FEATURE (0, FPU_VFP_EXT_V3
);
222 static const arm_feature_set fpu_vfp_ext_d32
=
223 ARM_FEATURE (0, FPU_VFP_EXT_D32
);
224 static const arm_feature_set fpu_neon_ext_v1
= ARM_FEATURE (0, FPU_NEON_EXT_V1
);
225 static const arm_feature_set fpu_vfp_v3_or_neon_ext
=
226 ARM_FEATURE (0, FPU_NEON_EXT_V1
| FPU_VFP_EXT_V3
);
227 static const arm_feature_set fpu_vfp_fp16
= ARM_FEATURE (0, FPU_VFP_EXT_FP16
);
228 static const arm_feature_set fpu_neon_ext_fma
= ARM_FEATURE (0, FPU_NEON_EXT_FMA
);
229 static const arm_feature_set fpu_vfp_ext_fma
= ARM_FEATURE (0, FPU_VFP_EXT_FMA
);
231 static int mfloat_abi_opt
= -1;
232 /* Record user cpu selection for object attributes. */
233 static arm_feature_set selected_cpu
= ARM_ARCH_NONE
;
234 /* Must be long enough to hold any of the names in arm_cpus. */
235 static char selected_cpu_name
[16];
238 static int meabi_flags
= EABI_DEFAULT
;
240 static int meabi_flags
= EF_ARM_EABI_UNKNOWN
;
243 static int attributes_set_explicitly
[NUM_KNOWN_OBJ_ATTRIBUTES
];
248 return (EF_ARM_EABI_VERSION (meabi_flags
) >= EF_ARM_EABI_VER4
);
253 /* Pre-defined "_GLOBAL_OFFSET_TABLE_" */
254 symbolS
* GOT_symbol
;
257 /* 0: assemble for ARM,
258 1: assemble for Thumb,
259 2: assemble for Thumb even though target CPU does not support thumb
261 static int thumb_mode
= 0;
262 /* A value distinct from the possible values for thumb_mode that we
263 can use to record whether thumb_mode has been copied into the
264 tc_frag_data field of a frag. */
265 #define MODE_RECORDED (1 << 4)
267 /* Specifies the intrinsic IT insn behavior mode. */
268 enum implicit_it_mode
270 IMPLICIT_IT_MODE_NEVER
= 0x00,
271 IMPLICIT_IT_MODE_ARM
= 0x01,
272 IMPLICIT_IT_MODE_THUMB
= 0x02,
273 IMPLICIT_IT_MODE_ALWAYS
= (IMPLICIT_IT_MODE_ARM
| IMPLICIT_IT_MODE_THUMB
)
275 static int implicit_it_mode
= IMPLICIT_IT_MODE_ARM
;
277 /* If unified_syntax is true, we are processing the new unified
278 ARM/Thumb syntax. Important differences from the old ARM mode:
280 - Immediate operands do not require a # prefix.
281 - Conditional affixes always appear at the end of the
282 instruction. (For backward compatibility, those instructions
283 that formerly had them in the middle, continue to accept them
285 - The IT instruction may appear, and if it does is validated
286 against subsequent conditional affixes. It does not generate
289 Important differences from the old Thumb mode:
291 - Immediate operands do not require a # prefix.
292 - Most of the V6T2 instructions are only available in unified mode.
293 - The .N and .W suffixes are recognized and honored (it is an error
294 if they cannot be honored).
295 - All instructions set the flags if and only if they have an 's' affix.
296 - Conditional affixes may be used. They are validated against
297 preceding IT instructions. Unlike ARM mode, you cannot use a
298 conditional affix except in the scope of an IT instruction. */
300 static bfd_boolean unified_syntax
= FALSE
;
315 enum neon_el_type type
;
319 #define NEON_MAX_TYPE_ELS 4
323 struct neon_type_el el
[NEON_MAX_TYPE_ELS
];
327 enum it_instruction_type
332 IF_INSIDE_IT_LAST_INSN
, /* Either outside or inside;
333 if inside, should be the last one. */
334 NEUTRAL_IT_INSN
, /* This could be either inside or outside,
335 i.e. BKPT and NOP. */
336 IT_INSN
/* The IT insn has been parsed. */
342 unsigned long instruction
;
346 /* "uncond_value" is set to the value in place of the conditional field in
347 unconditional versions of the instruction, or -1 if nothing is
350 struct neon_type vectype
;
351 /* This does not indicate an actual NEON instruction, only that
352 the mnemonic accepts neon-style type suffixes. */
354 /* Set to the opcode if the instruction needs relaxation.
355 Zero if the instruction is not relaxed. */
359 bfd_reloc_code_real_type type
;
364 enum it_instruction_type it_insn_type
;
370 struct neon_type_el vectype
;
371 unsigned present
: 1; /* Operand present. */
372 unsigned isreg
: 1; /* Operand was a register. */
373 unsigned immisreg
: 1; /* .imm field is a second register. */
374 unsigned isscalar
: 1; /* Operand is a (Neon) scalar. */
375 unsigned immisalign
: 1; /* Immediate is an alignment specifier. */
376 unsigned immisfloat
: 1; /* Immediate was parsed as a float. */
377 /* Note: we abuse "regisimm" to mean "is Neon register" in VMOV
378 instructions. This allows us to disambiguate ARM <-> vector insns. */
379 unsigned regisimm
: 1; /* 64-bit immediate, reg forms high 32 bits. */
380 unsigned isvec
: 1; /* Is a single, double or quad VFP/Neon reg. */
381 unsigned isquad
: 1; /* Operand is Neon quad-precision register. */
382 unsigned issingle
: 1; /* Operand is VFP single-precision register. */
383 unsigned hasreloc
: 1; /* Operand has relocation suffix. */
384 unsigned writeback
: 1; /* Operand has trailing ! */
385 unsigned preind
: 1; /* Preindexed address. */
386 unsigned postind
: 1; /* Postindexed address. */
387 unsigned negative
: 1; /* Index register was negated. */
388 unsigned shifted
: 1; /* Shift applied to operation. */
389 unsigned shift_kind
: 3; /* Shift operation (enum shift_kind). */
393 static struct arm_it inst
;
395 #define NUM_FLOAT_VALS 8
397 const char * fp_const
[] =
399 "0.0", "1.0", "2.0", "3.0", "4.0", "5.0", "0.5", "10.0", 0
402 /* Number of littlenums required to hold an extended precision number. */
403 #define MAX_LITTLENUMS 6
405 LITTLENUM_TYPE fp_values
[NUM_FLOAT_VALS
][MAX_LITTLENUMS
];
415 #define CP_T_X 0x00008000
416 #define CP_T_Y 0x00400000
418 #define CONDS_BIT 0x00100000
419 #define LOAD_BIT 0x00100000
421 #define DOUBLE_LOAD_FLAG 0x00000001
425 const char * template_name
;
429 #define COND_ALWAYS 0xE
433 const char * template_name
;
437 struct asm_barrier_opt
439 const char * template_name
;
443 /* The bit that distinguishes CPSR and SPSR. */
444 #define SPSR_BIT (1 << 22)
446 /* The individual PSR flag bits. */
447 #define PSR_c (1 << 16)
448 #define PSR_x (1 << 17)
449 #define PSR_s (1 << 18)
450 #define PSR_f (1 << 19)
455 bfd_reloc_code_real_type reloc
;
460 VFP_REG_Sd
, VFP_REG_Sm
, VFP_REG_Sn
,
461 VFP_REG_Dd
, VFP_REG_Dm
, VFP_REG_Dn
466 VFP_LDSTMIA
, VFP_LDSTMDB
, VFP_LDSTMIAX
, VFP_LDSTMDBX
469 /* Bits for DEFINED field in neon_typed_alias. */
470 #define NTA_HASTYPE 1
471 #define NTA_HASINDEX 2
473 struct neon_typed_alias
475 unsigned char defined
;
477 struct neon_type_el eltype
;
480 /* ARM register categories. This includes coprocessor numbers and various
481 architecture extensions' registers. */
507 /* Structure for a hash table entry for a register.
508 If TYPE is REG_TYPE_VFD or REG_TYPE_NQ, the NEON field can point to extra
509 information which states whether a vector type or index is specified (for a
510 register alias created with .dn or .qn). Otherwise NEON should be NULL. */
514 unsigned char number
;
516 unsigned char builtin
;
517 struct neon_typed_alias
* neon
;
520 /* Diagnostics used when we don't get a register of the expected type. */
521 const char * const reg_expected_msgs
[] =
523 N_("ARM register expected"),
524 N_("bad or missing co-processor number"),
525 N_("co-processor register expected"),
526 N_("FPA register expected"),
527 N_("VFP single precision register expected"),
528 N_("VFP/Neon double precision register expected"),
529 N_("Neon quad precision register expected"),
530 N_("VFP single or double precision register expected"),
531 N_("Neon double or quad precision register expected"),
532 N_("VFP single, double or Neon quad precision register expected"),
533 N_("VFP system register expected"),
534 N_("Maverick MVF register expected"),
535 N_("Maverick MVD register expected"),
536 N_("Maverick MVFX register expected"),
537 N_("Maverick MVDX register expected"),
538 N_("Maverick MVAX register expected"),
539 N_("Maverick DSPSC register expected"),
540 N_("iWMMXt data register expected"),
541 N_("iWMMXt control register expected"),
542 N_("iWMMXt scalar register expected"),
543 N_("XScale accumulator register expected"),
546 /* Some well known registers that we refer to directly elsewhere. */
551 /* ARM instructions take 4bytes in the object file, Thumb instructions
557 /* Basic string to match. */
558 const char * template_name
;
560 /* Parameters to instruction. */
561 unsigned int operands
[8];
563 /* Conditional tag - see opcode_lookup. */
564 unsigned int tag
: 4;
566 /* Basic instruction code. */
567 unsigned int avalue
: 28;
569 /* Thumb-format instruction code. */
572 /* Which architecture variant provides this instruction. */
573 const arm_feature_set
* avariant
;
574 const arm_feature_set
* tvariant
;
576 /* Function to call to encode instruction in ARM format. */
577 void (* aencode
) (void);
579 /* Function to call to encode instruction in Thumb format. */
580 void (* tencode
) (void);
583 /* Defines for various bits that we will want to toggle. */
584 #define INST_IMMEDIATE 0x02000000
585 #define OFFSET_REG 0x02000000
586 #define HWOFFSET_IMM 0x00400000
587 #define SHIFT_BY_REG 0x00000010
588 #define PRE_INDEX 0x01000000
589 #define INDEX_UP 0x00800000
590 #define WRITE_BACK 0x00200000
591 #define LDM_TYPE_2_OR_3 0x00400000
592 #define CPSI_MMOD 0x00020000
594 #define LITERAL_MASK 0xf000f000
595 #define OPCODE_MASK 0xfe1fffff
596 #define V4_STR_BIT 0x00000020
598 #define T2_SUBS_PC_LR 0xf3de8f00
600 #define DATA_OP_SHIFT 21
602 #define T2_OPCODE_MASK 0xfe1fffff
603 #define T2_DATA_OP_SHIFT 21
605 /* Codes to distinguish the arithmetic instructions. */
616 #define OPCODE_CMP 10
617 #define OPCODE_CMN 11
618 #define OPCODE_ORR 12
619 #define OPCODE_MOV 13
620 #define OPCODE_BIC 14
621 #define OPCODE_MVN 15
623 #define T2_OPCODE_AND 0
624 #define T2_OPCODE_BIC 1
625 #define T2_OPCODE_ORR 2
626 #define T2_OPCODE_ORN 3
627 #define T2_OPCODE_EOR 4
628 #define T2_OPCODE_ADD 8
629 #define T2_OPCODE_ADC 10
630 #define T2_OPCODE_SBC 11
631 #define T2_OPCODE_SUB 13
632 #define T2_OPCODE_RSB 14
634 #define T_OPCODE_MUL 0x4340
635 #define T_OPCODE_TST 0x4200
636 #define T_OPCODE_CMN 0x42c0
637 #define T_OPCODE_NEG 0x4240
638 #define T_OPCODE_MVN 0x43c0
640 #define T_OPCODE_ADD_R3 0x1800
641 #define T_OPCODE_SUB_R3 0x1a00
642 #define T_OPCODE_ADD_HI 0x4400
643 #define T_OPCODE_ADD_ST 0xb000
644 #define T_OPCODE_SUB_ST 0xb080
645 #define T_OPCODE_ADD_SP 0xa800
646 #define T_OPCODE_ADD_PC 0xa000
647 #define T_OPCODE_ADD_I8 0x3000
648 #define T_OPCODE_SUB_I8 0x3800
649 #define T_OPCODE_ADD_I3 0x1c00
650 #define T_OPCODE_SUB_I3 0x1e00
652 #define T_OPCODE_ASR_R 0x4100
653 #define T_OPCODE_LSL_R 0x4080
654 #define T_OPCODE_LSR_R 0x40c0
655 #define T_OPCODE_ROR_R 0x41c0
656 #define T_OPCODE_ASR_I 0x1000
657 #define T_OPCODE_LSL_I 0x0000
658 #define T_OPCODE_LSR_I 0x0800
660 #define T_OPCODE_MOV_I8 0x2000
661 #define T_OPCODE_CMP_I8 0x2800
662 #define T_OPCODE_CMP_LR 0x4280
663 #define T_OPCODE_MOV_HR 0x4600
664 #define T_OPCODE_CMP_HR 0x4500
666 #define T_OPCODE_LDR_PC 0x4800
667 #define T_OPCODE_LDR_SP 0x9800
668 #define T_OPCODE_STR_SP 0x9000
669 #define T_OPCODE_LDR_IW 0x6800
670 #define T_OPCODE_STR_IW 0x6000
671 #define T_OPCODE_LDR_IH 0x8800
672 #define T_OPCODE_STR_IH 0x8000
673 #define T_OPCODE_LDR_IB 0x7800
674 #define T_OPCODE_STR_IB 0x7000
675 #define T_OPCODE_LDR_RW 0x5800
676 #define T_OPCODE_STR_RW 0x5000
677 #define T_OPCODE_LDR_RH 0x5a00
678 #define T_OPCODE_STR_RH 0x5200
679 #define T_OPCODE_LDR_RB 0x5c00
680 #define T_OPCODE_STR_RB 0x5400
682 #define T_OPCODE_PUSH 0xb400
683 #define T_OPCODE_POP 0xbc00
685 #define T_OPCODE_BRANCH 0xe000
687 #define THUMB_SIZE 2 /* Size of thumb instruction. */
688 #define THUMB_PP_PC_LR 0x0100
689 #define THUMB_LOAD_BIT 0x0800
690 #define THUMB2_LOAD_BIT 0x00100000
692 #define BAD_ARGS _("bad arguments to instruction")
693 #define BAD_SP _("r13 not allowed here")
694 #define BAD_PC _("r15 not allowed here")
695 #define BAD_COND _("instruction cannot be conditional")
696 #define BAD_OVERLAP _("registers may not be the same")
697 #define BAD_HIREG _("lo register required")
698 #define BAD_THUMB32 _("instruction not supported in Thumb16 mode")
699 #define BAD_ADDR_MODE _("instruction does not accept this addressing mode");
700 #define BAD_BRANCH _("branch must be last instruction in IT block")
701 #define BAD_NOT_IT _("instruction not allowed in IT block")
702 #define BAD_FPU _("selected FPU does not support instruction")
703 #define BAD_OUT_IT _("thumb conditional instruction should be in IT block")
704 #define BAD_IT_COND _("incorrect condition in IT block")
705 #define BAD_IT_IT _("IT falling in the range of a previous IT block")
706 #define MISSING_FNSTART _("missing .fnstart before unwinding directive")
707 #define BAD_PC_ADDRESSING \
708 _("cannot use register index with PC-relative addressing")
709 #define BAD_PC_WRITEBACK \
710 _("cannot use writeback with PC-relative addressing")
712 static struct hash_control
* arm_ops_hsh
;
713 static struct hash_control
* arm_cond_hsh
;
714 static struct hash_control
* arm_shift_hsh
;
715 static struct hash_control
* arm_psr_hsh
;
716 static struct hash_control
* arm_v7m_psr_hsh
;
717 static struct hash_control
* arm_reg_hsh
;
718 static struct hash_control
* arm_reloc_hsh
;
719 static struct hash_control
* arm_barrier_opt_hsh
;
721 /* Stuff needed to resolve the label ambiguity
730 symbolS
* last_label_seen
;
731 static int label_is_thumb_function_name
= FALSE
;
733 /* Literal pool structure. Held on a per-section
734 and per-sub-section basis. */
736 #define MAX_LITERAL_POOL_SIZE 1024
737 typedef struct literal_pool
739 expressionS literals
[MAX_LITERAL_POOL_SIZE
];
740 unsigned int next_free_entry
;
745 struct literal_pool
* next
;
748 /* Pointer to a linked list of literal pools. */
749 literal_pool
* list_of_pools
= NULL
;
752 # define now_it seg_info (now_seg)->tc_segment_info_data.current_it
754 static struct current_it now_it
;
758 now_it_compatible (int cond
)
760 return (cond
& ~1) == (now_it
.cc
& ~1);
764 conditional_insn (void)
766 return inst
.cond
!= COND_ALWAYS
;
769 static int in_it_block (void);
771 static int handle_it_state (void);
773 static void force_automatic_it_block_close (void);
775 static void it_fsm_post_encode (void);
777 #define set_it_insn_type(type) \
780 inst.it_insn_type = type; \
781 if (handle_it_state () == FAIL) \
786 #define set_it_insn_type_nonvoid(type, failret) \
789 inst.it_insn_type = type; \
790 if (handle_it_state () == FAIL) \
795 #define set_it_insn_type_last() \
798 if (inst.cond == COND_ALWAYS) \
799 set_it_insn_type (IF_INSIDE_IT_LAST_INSN); \
801 set_it_insn_type (INSIDE_IT_LAST_INSN); \
807 /* This array holds the chars that always start a comment. If the
808 pre-processor is disabled, these aren't very useful. */
809 const char comment_chars
[] = "@";
811 /* This array holds the chars that only start a comment at the beginning of
812 a line. If the line seems to have the form '# 123 filename'
813 .line and .file directives will appear in the pre-processed output. */
814 /* Note that input_file.c hand checks for '#' at the beginning of the
815 first line of the input file. This is because the compiler outputs
816 #NO_APP at the beginning of its output. */
817 /* Also note that comments like this one will always work. */
818 const char line_comment_chars
[] = "#";
820 const char line_separator_chars
[] = ";";
822 /* Chars that can be used to separate mant
823 from exp in floating point numbers. */
824 const char EXP_CHARS
[] = "eE";
826 /* Chars that mean this number is a floating point constant. */
830 const char FLT_CHARS
[] = "rRsSfFdDxXeEpP";
832 /* Prefix characters that indicate the start of an immediate
834 #define is_immediate_prefix(C) ((C) == '#' || (C) == '$')
836 /* Separator character handling. */
838 #define skip_whitespace(str) do { if (*(str) == ' ') ++(str); } while (0)
841 skip_past_char (char ** str
, char c
)
852 #define skip_past_comma(str) skip_past_char (str, ',')
854 /* Arithmetic expressions (possibly involving symbols). */
856 /* Return TRUE if anything in the expression is a bignum. */
859 walk_no_bignums (symbolS
* sp
)
861 if (symbol_get_value_expression (sp
)->X_op
== O_big
)
864 if (symbol_get_value_expression (sp
)->X_add_symbol
)
866 return (walk_no_bignums (symbol_get_value_expression (sp
)->X_add_symbol
)
867 || (symbol_get_value_expression (sp
)->X_op_symbol
868 && walk_no_bignums (symbol_get_value_expression (sp
)->X_op_symbol
)));
874 static int in_my_get_expression
= 0;
876 /* Third argument to my_get_expression. */
877 #define GE_NO_PREFIX 0
878 #define GE_IMM_PREFIX 1
879 #define GE_OPT_PREFIX 2
880 /* This is a bit of a hack. Use an optional prefix, and also allow big (64-bit)
881 immediates, as can be used in Neon VMVN and VMOV immediate instructions. */
882 #define GE_OPT_PREFIX_BIG 3
885 my_get_expression (expressionS
* ep
, char ** str
, int prefix_mode
)
890 /* In unified syntax, all prefixes are optional. */
892 prefix_mode
= (prefix_mode
== GE_OPT_PREFIX_BIG
) ? prefix_mode
897 case GE_NO_PREFIX
: break;
899 if (!is_immediate_prefix (**str
))
901 inst
.error
= _("immediate expression requires a # prefix");
907 case GE_OPT_PREFIX_BIG
:
908 if (is_immediate_prefix (**str
))
914 memset (ep
, 0, sizeof (expressionS
));
916 save_in
= input_line_pointer
;
917 input_line_pointer
= *str
;
918 in_my_get_expression
= 1;
919 seg
= expression (ep
);
920 in_my_get_expression
= 0;
922 if (ep
->X_op
== O_illegal
|| ep
->X_op
== O_absent
)
924 /* We found a bad or missing expression in md_operand(). */
925 *str
= input_line_pointer
;
926 input_line_pointer
= save_in
;
927 if (inst
.error
== NULL
)
928 inst
.error
= (ep
->X_op
== O_absent
929 ? _("missing expression") :_("bad expression"));
934 if (seg
!= absolute_section
935 && seg
!= text_section
936 && seg
!= data_section
937 && seg
!= bss_section
938 && seg
!= undefined_section
)
940 inst
.error
= _("bad segment");
941 *str
= input_line_pointer
;
942 input_line_pointer
= save_in
;
947 /* Get rid of any bignums now, so that we don't generate an error for which
948 we can't establish a line number later on. Big numbers are never valid
949 in instructions, which is where this routine is always called. */
950 if (prefix_mode
!= GE_OPT_PREFIX_BIG
951 && (ep
->X_op
== O_big
953 && (walk_no_bignums (ep
->X_add_symbol
)
955 && walk_no_bignums (ep
->X_op_symbol
))))))
957 inst
.error
= _("invalid constant");
958 *str
= input_line_pointer
;
959 input_line_pointer
= save_in
;
963 *str
= input_line_pointer
;
964 input_line_pointer
= save_in
;
968 /* Turn a string in input_line_pointer into a floating point constant
969 of type TYPE, and store the appropriate bytes in *LITP. The number
970 of LITTLENUMS emitted is stored in *SIZEP. An error message is
971 returned, or NULL on OK.
973 Note that fp constants aren't represent in the normal way on the ARM.
974 In big endian mode, things are as expected. However, in little endian
975 mode fp constants are big-endian word-wise, and little-endian byte-wise
976 within the words. For example, (double) 1.1 in big endian mode is
977 the byte sequence 3f f1 99 99 99 99 99 9a, and in little endian mode is
978 the byte sequence 99 99 f1 3f 9a 99 99 99.
980 ??? The format of 12 byte floats is uncertain according to gcc's arm.h. */
983 md_atof (int type
, char * litP
, int * sizeP
)
986 LITTLENUM_TYPE words
[MAX_LITTLENUMS
];
1018 return _("Unrecognized or unsupported floating point constant");
1021 t
= atof_ieee (input_line_pointer
, type
, words
);
1023 input_line_pointer
= t
;
1024 *sizeP
= prec
* sizeof (LITTLENUM_TYPE
);
1026 if (target_big_endian
)
1028 for (i
= 0; i
< prec
; i
++)
1030 md_number_to_chars (litP
, (valueT
) words
[i
], sizeof (LITTLENUM_TYPE
));
1031 litP
+= sizeof (LITTLENUM_TYPE
);
1036 if (ARM_CPU_HAS_FEATURE (cpu_variant
, fpu_endian_pure
))
1037 for (i
= prec
- 1; i
>= 0; i
--)
1039 md_number_to_chars (litP
, (valueT
) words
[i
], sizeof (LITTLENUM_TYPE
));
1040 litP
+= sizeof (LITTLENUM_TYPE
);
1043 /* For a 4 byte float the order of elements in `words' is 1 0.
1044 For an 8 byte float the order is 1 0 3 2. */
1045 for (i
= 0; i
< prec
; i
+= 2)
1047 md_number_to_chars (litP
, (valueT
) words
[i
+ 1],
1048 sizeof (LITTLENUM_TYPE
));
1049 md_number_to_chars (litP
+ sizeof (LITTLENUM_TYPE
),
1050 (valueT
) words
[i
], sizeof (LITTLENUM_TYPE
));
1051 litP
+= 2 * sizeof (LITTLENUM_TYPE
);
1058 /* We handle all bad expressions here, so that we can report the faulty
1059 instruction in the error message. */
1061 md_operand (expressionS
* exp
)
1063 if (in_my_get_expression
)
1064 exp
->X_op
= O_illegal
;
1067 /* Immediate values. */
1069 /* Generic immediate-value read function for use in directives.
1070 Accepts anything that 'expression' can fold to a constant.
1071 *val receives the number. */
1074 immediate_for_directive (int *val
)
1077 exp
.X_op
= O_illegal
;
1079 if (is_immediate_prefix (*input_line_pointer
))
1081 input_line_pointer
++;
1085 if (exp
.X_op
!= O_constant
)
1087 as_bad (_("expected #constant"));
1088 ignore_rest_of_line ();
1091 *val
= exp
.X_add_number
;
1096 /* Register parsing. */
1098 /* Generic register parser. CCP points to what should be the
1099 beginning of a register name. If it is indeed a valid register
1100 name, advance CCP over it and return the reg_entry structure;
1101 otherwise return NULL. Does not issue diagnostics. */
1103 static struct reg_entry
*
1104 arm_reg_parse_multi (char **ccp
)
1108 struct reg_entry
*reg
;
1110 #ifdef REGISTER_PREFIX
1111 if (*start
!= REGISTER_PREFIX
)
1115 #ifdef OPTIONAL_REGISTER_PREFIX
1116 if (*start
== OPTIONAL_REGISTER_PREFIX
)
1121 if (!ISALPHA (*p
) || !is_name_beginner (*p
))
1126 while (ISALPHA (*p
) || ISDIGIT (*p
) || *p
== '_');
1128 reg
= (struct reg_entry
*) hash_find_n (arm_reg_hsh
, start
, p
- start
);
1138 arm_reg_alt_syntax (char **ccp
, char *start
, struct reg_entry
*reg
,
1139 enum arm_reg_type type
)
1141 /* Alternative syntaxes are accepted for a few register classes. */
1148 /* Generic coprocessor register names are allowed for these. */
1149 if (reg
&& reg
->type
== REG_TYPE_CN
)
1154 /* For backward compatibility, a bare number is valid here. */
1156 unsigned long processor
= strtoul (start
, ccp
, 10);
1157 if (*ccp
!= start
&& processor
<= 15)
1161 case REG_TYPE_MMXWC
:
1162 /* WC includes WCG. ??? I'm not sure this is true for all
1163 instructions that take WC registers. */
1164 if (reg
&& reg
->type
== REG_TYPE_MMXWCG
)
1175 /* As arm_reg_parse_multi, but the register must be of type TYPE, and the
1176 return value is the register number or FAIL. */
1179 arm_reg_parse (char **ccp
, enum arm_reg_type type
)
1182 struct reg_entry
*reg
= arm_reg_parse_multi (ccp
);
1185 /* Do not allow a scalar (reg+index) to parse as a register. */
1186 if (reg
&& reg
->neon
&& (reg
->neon
->defined
& NTA_HASINDEX
))
1189 if (reg
&& reg
->type
== type
)
1192 if ((ret
= arm_reg_alt_syntax (ccp
, start
, reg
, type
)) != FAIL
)
1199 /* Parse a Neon type specifier. *STR should point at the leading '.'
1200 character. Does no verification at this stage that the type fits the opcode
1207 Can all be legally parsed by this function.
1209 Fills in neon_type struct pointer with parsed information, and updates STR
1210 to point after the parsed type specifier. Returns SUCCESS if this was a legal
1211 type, FAIL if not. */
1214 parse_neon_type (struct neon_type
*type
, char **str
)
1221 while (type
->elems
< NEON_MAX_TYPE_ELS
)
1223 enum neon_el_type thistype
= NT_untyped
;
1224 unsigned thissize
= -1u;
1231 /* Just a size without an explicit type. */
1235 switch (TOLOWER (*ptr
))
1237 case 'i': thistype
= NT_integer
; break;
1238 case 'f': thistype
= NT_float
; break;
1239 case 'p': thistype
= NT_poly
; break;
1240 case 's': thistype
= NT_signed
; break;
1241 case 'u': thistype
= NT_unsigned
; break;
1243 thistype
= NT_float
;
1248 as_bad (_("unexpected character `%c' in type specifier"), *ptr
);
1254 /* .f is an abbreviation for .f32. */
1255 if (thistype
== NT_float
&& !ISDIGIT (*ptr
))
1260 thissize
= strtoul (ptr
, &ptr
, 10);
1262 if (thissize
!= 8 && thissize
!= 16 && thissize
!= 32
1265 as_bad (_("bad size %d in type specifier"), thissize
);
1273 type
->el
[type
->elems
].type
= thistype
;
1274 type
->el
[type
->elems
].size
= thissize
;
1279 /* Empty/missing type is not a successful parse. */
1280 if (type
->elems
== 0)
1288 /* Errors may be set multiple times during parsing or bit encoding
1289 (particularly in the Neon bits), but usually the earliest error which is set
1290 will be the most meaningful. Avoid overwriting it with later (cascading)
1291 errors by calling this function. */
1294 first_error (const char *err
)
1300 /* Parse a single type, e.g. ".s32", leading period included. */
1302 parse_neon_operand_type (struct neon_type_el
*vectype
, char **ccp
)
1305 struct neon_type optype
;
1309 if (parse_neon_type (&optype
, &str
) == SUCCESS
)
1311 if (optype
.elems
== 1)
1312 *vectype
= optype
.el
[0];
1315 first_error (_("only one type should be specified for operand"));
1321 first_error (_("vector type expected"));
1333 /* Special meanings for indices (which have a range of 0-7), which will fit into
1336 #define NEON_ALL_LANES 15
1337 #define NEON_INTERLEAVE_LANES 14
1339 /* Parse either a register or a scalar, with an optional type. Return the
1340 register number, and optionally fill in the actual type of the register
1341 when multiple alternatives were given (NEON_TYPE_NDQ) in *RTYPE, and
1342 type/index information in *TYPEINFO. */
1345 parse_typed_reg_or_scalar (char **ccp
, enum arm_reg_type type
,
1346 enum arm_reg_type
*rtype
,
1347 struct neon_typed_alias
*typeinfo
)
1350 struct reg_entry
*reg
= arm_reg_parse_multi (&str
);
1351 struct neon_typed_alias atype
;
1352 struct neon_type_el parsetype
;
1356 atype
.eltype
.type
= NT_invtype
;
1357 atype
.eltype
.size
= -1;
1359 /* Try alternate syntax for some types of register. Note these are mutually
1360 exclusive with the Neon syntax extensions. */
1363 int altreg
= arm_reg_alt_syntax (&str
, *ccp
, reg
, type
);
1371 /* Undo polymorphism when a set of register types may be accepted. */
1372 if ((type
== REG_TYPE_NDQ
1373 && (reg
->type
== REG_TYPE_NQ
|| reg
->type
== REG_TYPE_VFD
))
1374 || (type
== REG_TYPE_VFSD
1375 && (reg
->type
== REG_TYPE_VFS
|| reg
->type
== REG_TYPE_VFD
))
1376 || (type
== REG_TYPE_NSDQ
1377 && (reg
->type
== REG_TYPE_VFS
|| reg
->type
== REG_TYPE_VFD
1378 || reg
->type
== REG_TYPE_NQ
))
1379 || (type
== REG_TYPE_MMXWC
1380 && (reg
->type
== REG_TYPE_MMXWCG
)))
1381 type
= (enum arm_reg_type
) reg
->type
;
1383 if (type
!= reg
->type
)
1389 if (parse_neon_operand_type (&parsetype
, &str
) == SUCCESS
)
1391 if ((atype
.defined
& NTA_HASTYPE
) != 0)
1393 first_error (_("can't redefine type for operand"));
1396 atype
.defined
|= NTA_HASTYPE
;
1397 atype
.eltype
= parsetype
;
1400 if (skip_past_char (&str
, '[') == SUCCESS
)
1402 if (type
!= REG_TYPE_VFD
)
1404 first_error (_("only D registers may be indexed"));
1408 if ((atype
.defined
& NTA_HASINDEX
) != 0)
1410 first_error (_("can't change index for operand"));
1414 atype
.defined
|= NTA_HASINDEX
;
1416 if (skip_past_char (&str
, ']') == SUCCESS
)
1417 atype
.index
= NEON_ALL_LANES
;
1422 my_get_expression (&exp
, &str
, GE_NO_PREFIX
);
1424 if (exp
.X_op
!= O_constant
)
1426 first_error (_("constant expression required"));
1430 if (skip_past_char (&str
, ']') == FAIL
)
1433 atype
.index
= exp
.X_add_number
;
1448 /* Like arm_reg_parse, but allow allow the following extra features:
1449 - If RTYPE is non-zero, return the (possibly restricted) type of the
1450 register (e.g. Neon double or quad reg when either has been requested).
1451 - If this is a Neon vector type with additional type information, fill
1452 in the struct pointed to by VECTYPE (if non-NULL).
1453 This function will fault on encountering a scalar. */
1456 arm_typed_reg_parse (char **ccp
, enum arm_reg_type type
,
1457 enum arm_reg_type
*rtype
, struct neon_type_el
*vectype
)
1459 struct neon_typed_alias atype
;
1461 int reg
= parse_typed_reg_or_scalar (&str
, type
, rtype
, &atype
);
1466 /* Do not allow a scalar (reg+index) to parse as a register. */
1467 if ((atype
.defined
& NTA_HASINDEX
) != 0)
1469 first_error (_("register operand expected, but got scalar"));
1474 *vectype
= atype
.eltype
;
1481 #define NEON_SCALAR_REG(X) ((X) >> 4)
1482 #define NEON_SCALAR_INDEX(X) ((X) & 15)
1484 /* Parse a Neon scalar. Most of the time when we're parsing a scalar, we don't
1485 have enough information to be able to do a good job bounds-checking. So, we
1486 just do easy checks here, and do further checks later. */
1489 parse_scalar (char **ccp
, int elsize
, struct neon_type_el
*type
)
1493 struct neon_typed_alias atype
;
1495 reg
= parse_typed_reg_or_scalar (&str
, REG_TYPE_VFD
, NULL
, &atype
);
1497 if (reg
== FAIL
|| (atype
.defined
& NTA_HASINDEX
) == 0)
1500 if (atype
.index
== NEON_ALL_LANES
)
1502 first_error (_("scalar must have an index"));
1505 else if (atype
.index
>= 64 / elsize
)
1507 first_error (_("scalar index out of range"));
1512 *type
= atype
.eltype
;
1516 return reg
* 16 + atype
.index
;
1519 /* Parse an ARM register list. Returns the bitmask, or FAIL. */
1522 parse_reg_list (char ** strp
)
1524 char * str
= * strp
;
1528 /* We come back here if we get ranges concatenated by '+' or '|'. */
1543 if ((reg
= arm_reg_parse (&str
, REG_TYPE_RN
)) == FAIL
)
1545 first_error (_(reg_expected_msgs
[REG_TYPE_RN
]));
1555 first_error (_("bad range in register list"));
1559 for (i
= cur_reg
+ 1; i
< reg
; i
++)
1561 if (range
& (1 << i
))
1563 (_("Warning: duplicated register (r%d) in register list"),
1571 if (range
& (1 << reg
))
1572 as_tsktsk (_("Warning: duplicated register (r%d) in register list"),
1574 else if (reg
<= cur_reg
)
1575 as_tsktsk (_("Warning: register range not in ascending order"));
1580 while (skip_past_comma (&str
) != FAIL
1581 || (in_range
= 1, *str
++ == '-'));
1586 first_error (_("missing `}'"));
1594 if (my_get_expression (&exp
, &str
, GE_NO_PREFIX
))
1597 if (exp
.X_op
== O_constant
)
1599 if (exp
.X_add_number
1600 != (exp
.X_add_number
& 0x0000ffff))
1602 inst
.error
= _("invalid register mask");
1606 if ((range
& exp
.X_add_number
) != 0)
1608 int regno
= range
& exp
.X_add_number
;
1611 regno
= (1 << regno
) - 1;
1613 (_("Warning: duplicated register (r%d) in register list"),
1617 range
|= exp
.X_add_number
;
1621 if (inst
.reloc
.type
!= 0)
1623 inst
.error
= _("expression too complex");
1627 memcpy (&inst
.reloc
.exp
, &exp
, sizeof (expressionS
));
1628 inst
.reloc
.type
= BFD_RELOC_ARM_MULTI
;
1629 inst
.reloc
.pc_rel
= 0;
1633 if (*str
== '|' || *str
== '+')
1639 while (another_range
);
1645 /* Types of registers in a list. */
1654 /* Parse a VFP register list. If the string is invalid return FAIL.
1655 Otherwise return the number of registers, and set PBASE to the first
1656 register. Parses registers of type ETYPE.
1657 If REGLIST_NEON_D is used, several syntax enhancements are enabled:
1658 - Q registers can be used to specify pairs of D registers
1659 - { } can be omitted from around a singleton register list
1660 FIXME: This is not implemented, as it would require backtracking in
1663 This could be done (the meaning isn't really ambiguous), but doesn't
1664 fit in well with the current parsing framework.
1665 - 32 D registers may be used (also true for VFPv3).
1666 FIXME: Types are ignored in these register lists, which is probably a
1670 parse_vfp_reg_list (char **ccp
, unsigned int *pbase
, enum reg_list_els etype
)
1675 enum arm_reg_type regtype
= (enum arm_reg_type
) 0;
1679 unsigned long mask
= 0;
1684 inst
.error
= _("expecting {");
1693 regtype
= REG_TYPE_VFS
;
1698 regtype
= REG_TYPE_VFD
;
1701 case REGLIST_NEON_D
:
1702 regtype
= REG_TYPE_NDQ
;
1706 if (etype
!= REGLIST_VFP_S
)
1708 /* VFPv3 allows 32 D registers, except for the VFPv3-D16 variant. */
1709 if (ARM_CPU_HAS_FEATURE (cpu_variant
, fpu_vfp_ext_d32
))
1713 ARM_MERGE_FEATURE_SETS (thumb_arch_used
, thumb_arch_used
,
1716 ARM_MERGE_FEATURE_SETS (arm_arch_used
, arm_arch_used
,
1723 base_reg
= max_regs
;
1727 int setmask
= 1, addregs
= 1;
1729 new_base
= arm_typed_reg_parse (&str
, regtype
, ®type
, NULL
);
1731 if (new_base
== FAIL
)
1733 first_error (_(reg_expected_msgs
[regtype
]));
1737 if (new_base
>= max_regs
)
1739 first_error (_("register out of range in list"));
1743 /* Note: a value of 2 * n is returned for the register Q<n>. */
1744 if (regtype
== REG_TYPE_NQ
)
1750 if (new_base
< base_reg
)
1751 base_reg
= new_base
;
1753 if (mask
& (setmask
<< new_base
))
1755 first_error (_("invalid register list"));
1759 if ((mask
>> new_base
) != 0 && ! warned
)
1761 as_tsktsk (_("register list not in ascending order"));
1765 mask
|= setmask
<< new_base
;
1768 if (*str
== '-') /* We have the start of a range expression */
1774 if ((high_range
= arm_typed_reg_parse (&str
, regtype
, NULL
, NULL
))
1777 inst
.error
= gettext (reg_expected_msgs
[regtype
]);
1781 if (high_range
>= max_regs
)
1783 first_error (_("register out of range in list"));
1787 if (regtype
== REG_TYPE_NQ
)
1788 high_range
= high_range
+ 1;
1790 if (high_range
<= new_base
)
1792 inst
.error
= _("register range not in ascending order");
1796 for (new_base
+= addregs
; new_base
<= high_range
; new_base
+= addregs
)
1798 if (mask
& (setmask
<< new_base
))
1800 inst
.error
= _("invalid register list");
1804 mask
|= setmask
<< new_base
;
1809 while (skip_past_comma (&str
) != FAIL
);
1813 /* Sanity check -- should have raised a parse error above. */
1814 if (count
== 0 || count
> max_regs
)
1819 /* Final test -- the registers must be consecutive. */
1821 for (i
= 0; i
< count
; i
++)
1823 if ((mask
& (1u << i
)) == 0)
1825 inst
.error
= _("non-contiguous register range");
1835 /* True if two alias types are the same. */
1838 neon_alias_types_same (struct neon_typed_alias
*a
, struct neon_typed_alias
*b
)
1846 if (a
->defined
!= b
->defined
)
1849 if ((a
->defined
& NTA_HASTYPE
) != 0
1850 && (a
->eltype
.type
!= b
->eltype
.type
1851 || a
->eltype
.size
!= b
->eltype
.size
))
1854 if ((a
->defined
& NTA_HASINDEX
) != 0
1855 && (a
->index
!= b
->index
))
1861 /* Parse element/structure lists for Neon VLD<n> and VST<n> instructions.
1862 The base register is put in *PBASE.
1863 The lane (or one of the NEON_*_LANES constants) is placed in bits [3:0] of
1865 The register stride (minus one) is put in bit 4 of the return value.
1866 Bits [6:5] encode the list length (minus one).
1867 The type of the list elements is put in *ELTYPE, if non-NULL. */
1869 #define NEON_LANE(X) ((X) & 0xf)
1870 #define NEON_REG_STRIDE(X) ((((X) >> 4) & 1) + 1)
1871 #define NEON_REGLIST_LENGTH(X) ((((X) >> 5) & 3) + 1)
1874 parse_neon_el_struct_list (char **str
, unsigned *pbase
,
1875 struct neon_type_el
*eltype
)
1882 int leading_brace
= 0;
1883 enum arm_reg_type rtype
= REG_TYPE_NDQ
;
1885 const char *const incr_error
= _("register stride must be 1 or 2");
1886 const char *const type_error
= _("mismatched element/structure types in list");
1887 struct neon_typed_alias firsttype
;
1889 if (skip_past_char (&ptr
, '{') == SUCCESS
)
1894 struct neon_typed_alias atype
;
1895 int getreg
= parse_typed_reg_or_scalar (&ptr
, rtype
, &rtype
, &atype
);
1899 first_error (_(reg_expected_msgs
[rtype
]));
1906 if (rtype
== REG_TYPE_NQ
)
1913 else if (reg_incr
== -1)
1915 reg_incr
= getreg
- base_reg
;
1916 if (reg_incr
< 1 || reg_incr
> 2)
1918 first_error (_(incr_error
));
1922 else if (getreg
!= base_reg
+ reg_incr
* count
)
1924 first_error (_(incr_error
));
1928 if (! neon_alias_types_same (&atype
, &firsttype
))
1930 first_error (_(type_error
));
1934 /* Handle Dn-Dm or Qn-Qm syntax. Can only be used with non-indexed list
1938 struct neon_typed_alias htype
;
1939 int hireg
, dregs
= (rtype
== REG_TYPE_NQ
) ? 2 : 1;
1941 lane
= NEON_INTERLEAVE_LANES
;
1942 else if (lane
!= NEON_INTERLEAVE_LANES
)
1944 first_error (_(type_error
));
1949 else if (reg_incr
!= 1)
1951 first_error (_("don't use Rn-Rm syntax with non-unit stride"));
1955 hireg
= parse_typed_reg_or_scalar (&ptr
, rtype
, NULL
, &htype
);
1958 first_error (_(reg_expected_msgs
[rtype
]));
1961 if (! neon_alias_types_same (&htype
, &firsttype
))
1963 first_error (_(type_error
));
1966 count
+= hireg
+ dregs
- getreg
;
1970 /* If we're using Q registers, we can't use [] or [n] syntax. */
1971 if (rtype
== REG_TYPE_NQ
)
1977 if ((atype
.defined
& NTA_HASINDEX
) != 0)
1981 else if (lane
!= atype
.index
)
1983 first_error (_(type_error
));
1987 else if (lane
== -1)
1988 lane
= NEON_INTERLEAVE_LANES
;
1989 else if (lane
!= NEON_INTERLEAVE_LANES
)
1991 first_error (_(type_error
));
1996 while ((count
!= 1 || leading_brace
) && skip_past_comma (&ptr
) != FAIL
);
1998 /* No lane set by [x]. We must be interleaving structures. */
2000 lane
= NEON_INTERLEAVE_LANES
;
2003 if (lane
== -1 || base_reg
== -1 || count
< 1 || count
> 4
2004 || (count
> 1 && reg_incr
== -1))
2006 first_error (_("error parsing element/structure list"));
2010 if ((count
> 1 || leading_brace
) && skip_past_char (&ptr
, '}') == FAIL
)
2012 first_error (_("expected }"));
2020 *eltype
= firsttype
.eltype
;
2025 return lane
| ((reg_incr
- 1) << 4) | ((count
- 1) << 5);
2028 /* Parse an explicit relocation suffix on an expression. This is
2029 either nothing, or a word in parentheses. Note that if !OBJ_ELF,
2030 arm_reloc_hsh contains no entries, so this function can only
2031 succeed if there is no () after the word. Returns -1 on error,
2032 BFD_RELOC_UNUSED if there wasn't any suffix. */
2034 parse_reloc (char **str
)
2036 struct reloc_entry
*r
;
2040 return BFD_RELOC_UNUSED
;
2045 while (*q
&& *q
!= ')' && *q
!= ',')
2050 if ((r
= (struct reloc_entry
*)
2051 hash_find_n (arm_reloc_hsh
, p
, q
- p
)) == NULL
)
2058 /* Directives: register aliases. */
2060 static struct reg_entry
*
2061 insert_reg_alias (char *str
, int number
, int type
)
2063 struct reg_entry
*new_reg
;
2066 if ((new_reg
= (struct reg_entry
*) hash_find (arm_reg_hsh
, str
)) != 0)
2068 if (new_reg
->builtin
)
2069 as_warn (_("ignoring attempt to redefine built-in register '%s'"), str
);
2071 /* Only warn about a redefinition if it's not defined as the
2073 else if (new_reg
->number
!= number
|| new_reg
->type
!= type
)
2074 as_warn (_("ignoring redefinition of register alias '%s'"), str
);
2079 name
= xstrdup (str
);
2080 new_reg
= (struct reg_entry
*) xmalloc (sizeof (struct reg_entry
));
2082 new_reg
->name
= name
;
2083 new_reg
->number
= number
;
2084 new_reg
->type
= type
;
2085 new_reg
->builtin
= FALSE
;
2086 new_reg
->neon
= NULL
;
2088 if (hash_insert (arm_reg_hsh
, name
, (void *) new_reg
))
2095 insert_neon_reg_alias (char *str
, int number
, int type
,
2096 struct neon_typed_alias
*atype
)
2098 struct reg_entry
*reg
= insert_reg_alias (str
, number
, type
);
2102 first_error (_("attempt to redefine typed alias"));
2108 reg
->neon
= (struct neon_typed_alias
*)
2109 xmalloc (sizeof (struct neon_typed_alias
));
2110 *reg
->neon
= *atype
;
2114 /* Look for the .req directive. This is of the form:
2116 new_register_name .req existing_register_name
2118 If we find one, or if it looks sufficiently like one that we want to
2119 handle any error here, return TRUE. Otherwise return FALSE. */
2122 create_register_alias (char * newname
, char *p
)
2124 struct reg_entry
*old
;
2125 char *oldname
, *nbuf
;
2128 /* The input scrubber ensures that whitespace after the mnemonic is
2129 collapsed to single spaces. */
2131 if (strncmp (oldname
, " .req ", 6) != 0)
2135 if (*oldname
== '\0')
2138 old
= (struct reg_entry
*) hash_find (arm_reg_hsh
, oldname
);
2141 as_warn (_("unknown register '%s' -- .req ignored"), oldname
);
2145 /* If TC_CASE_SENSITIVE is defined, then newname already points to
2146 the desired alias name, and p points to its end. If not, then
2147 the desired alias name is in the global original_case_string. */
2148 #ifdef TC_CASE_SENSITIVE
2151 newname
= original_case_string
;
2152 nlen
= strlen (newname
);
2155 nbuf
= (char *) alloca (nlen
+ 1);
2156 memcpy (nbuf
, newname
, nlen
);
2159 /* Create aliases under the new name as stated; an all-lowercase
2160 version of the new name; and an all-uppercase version of the new
2162 if (insert_reg_alias (nbuf
, old
->number
, old
->type
) != NULL
)
2164 for (p
= nbuf
; *p
; p
++)
2167 if (strncmp (nbuf
, newname
, nlen
))
2169 /* If this attempt to create an additional alias fails, do not bother
2170 trying to create the all-lower case alias. We will fail and issue
2171 a second, duplicate error message. This situation arises when the
2172 programmer does something like:
2175 The second .req creates the "Foo" alias but then fails to create
2176 the artificial FOO alias because it has already been created by the
2178 if (insert_reg_alias (nbuf
, old
->number
, old
->type
) == NULL
)
2182 for (p
= nbuf
; *p
; p
++)
2185 if (strncmp (nbuf
, newname
, nlen
))
2186 insert_reg_alias (nbuf
, old
->number
, old
->type
);
2192 /* Create a Neon typed/indexed register alias using directives, e.g.:
2197 These typed registers can be used instead of the types specified after the
2198 Neon mnemonic, so long as all operands given have types. Types can also be
2199 specified directly, e.g.:
2200 vadd d0.s32, d1.s32, d2.s32 */
2203 create_neon_reg_alias (char *newname
, char *p
)
2205 enum arm_reg_type basetype
;
2206 struct reg_entry
*basereg
;
2207 struct reg_entry mybasereg
;
2208 struct neon_type ntype
;
2209 struct neon_typed_alias typeinfo
;
2210 char *namebuf
, *nameend
;
2213 typeinfo
.defined
= 0;
2214 typeinfo
.eltype
.type
= NT_invtype
;
2215 typeinfo
.eltype
.size
= -1;
2216 typeinfo
.index
= -1;
2220 if (strncmp (p
, " .dn ", 5) == 0)
2221 basetype
= REG_TYPE_VFD
;
2222 else if (strncmp (p
, " .qn ", 5) == 0)
2223 basetype
= REG_TYPE_NQ
;
2232 basereg
= arm_reg_parse_multi (&p
);
2234 if (basereg
&& basereg
->type
!= basetype
)
2236 as_bad (_("bad type for register"));
2240 if (basereg
== NULL
)
2243 /* Try parsing as an integer. */
2244 my_get_expression (&exp
, &p
, GE_NO_PREFIX
);
2245 if (exp
.X_op
!= O_constant
)
2247 as_bad (_("expression must be constant"));
2250 basereg
= &mybasereg
;
2251 basereg
->number
= (basetype
== REG_TYPE_NQ
) ? exp
.X_add_number
* 2
2257 typeinfo
= *basereg
->neon
;
2259 if (parse_neon_type (&ntype
, &p
) == SUCCESS
)
2261 /* We got a type. */
2262 if (typeinfo
.defined
& NTA_HASTYPE
)
2264 as_bad (_("can't redefine the type of a register alias"));
2268 typeinfo
.defined
|= NTA_HASTYPE
;
2269 if (ntype
.elems
!= 1)
2271 as_bad (_("you must specify a single type only"));
2274 typeinfo
.eltype
= ntype
.el
[0];
2277 if (skip_past_char (&p
, '[') == SUCCESS
)
2280 /* We got a scalar index. */
2282 if (typeinfo
.defined
& NTA_HASINDEX
)
2284 as_bad (_("can't redefine the index of a scalar alias"));
2288 my_get_expression (&exp
, &p
, GE_NO_PREFIX
);
2290 if (exp
.X_op
!= O_constant
)
2292 as_bad (_("scalar index must be constant"));
2296 typeinfo
.defined
|= NTA_HASINDEX
;
2297 typeinfo
.index
= exp
.X_add_number
;
2299 if (skip_past_char (&p
, ']') == FAIL
)
2301 as_bad (_("expecting ]"));
2306 namelen
= nameend
- newname
;
2307 namebuf
= (char *) alloca (namelen
+ 1);
2308 strncpy (namebuf
, newname
, namelen
);
2309 namebuf
[namelen
] = '\0';
2311 insert_neon_reg_alias (namebuf
, basereg
->number
, basetype
,
2312 typeinfo
.defined
!= 0 ? &typeinfo
: NULL
);
2314 /* Insert name in all uppercase. */
2315 for (p
= namebuf
; *p
; p
++)
2318 if (strncmp (namebuf
, newname
, namelen
))
2319 insert_neon_reg_alias (namebuf
, basereg
->number
, basetype
,
2320 typeinfo
.defined
!= 0 ? &typeinfo
: NULL
);
2322 /* Insert name in all lowercase. */
2323 for (p
= namebuf
; *p
; p
++)
2326 if (strncmp (namebuf
, newname
, namelen
))
2327 insert_neon_reg_alias (namebuf
, basereg
->number
, basetype
,
2328 typeinfo
.defined
!= 0 ? &typeinfo
: NULL
);
2333 /* Should never be called, as .req goes between the alias and the
2334 register name, not at the beginning of the line. */
2337 s_req (int a ATTRIBUTE_UNUSED
)
2339 as_bad (_("invalid syntax for .req directive"));
2343 s_dn (int a ATTRIBUTE_UNUSED
)
2345 as_bad (_("invalid syntax for .dn directive"));
2349 s_qn (int a ATTRIBUTE_UNUSED
)
2351 as_bad (_("invalid syntax for .qn directive"));
2354 /* The .unreq directive deletes an alias which was previously defined
2355 by .req. For example:
2361 s_unreq (int a ATTRIBUTE_UNUSED
)
2366 name
= input_line_pointer
;
2368 while (*input_line_pointer
!= 0
2369 && *input_line_pointer
!= ' '
2370 && *input_line_pointer
!= '\n')
2371 ++input_line_pointer
;
2373 saved_char
= *input_line_pointer
;
2374 *input_line_pointer
= 0;
2377 as_bad (_("invalid syntax for .unreq directive"));
2380 struct reg_entry
*reg
= (struct reg_entry
*) hash_find (arm_reg_hsh
,
2384 as_bad (_("unknown register alias '%s'"), name
);
2385 else if (reg
->builtin
)
2386 as_warn (_("ignoring attempt to undefine built-in register '%s'"),
2393 hash_delete (arm_reg_hsh
, name
, FALSE
);
2394 free ((char *) reg
->name
);
2399 /* Also locate the all upper case and all lower case versions.
2400 Do not complain if we cannot find one or the other as it
2401 was probably deleted above. */
2403 nbuf
= strdup (name
);
2404 for (p
= nbuf
; *p
; p
++)
2406 reg
= (struct reg_entry
*) hash_find (arm_reg_hsh
, nbuf
);
2409 hash_delete (arm_reg_hsh
, nbuf
, FALSE
);
2410 free ((char *) reg
->name
);
2416 for (p
= nbuf
; *p
; p
++)
2418 reg
= (struct reg_entry
*) hash_find (arm_reg_hsh
, nbuf
);
2421 hash_delete (arm_reg_hsh
, nbuf
, FALSE
);
2422 free ((char *) reg
->name
);
2432 *input_line_pointer
= saved_char
;
2433 demand_empty_rest_of_line ();
2436 /* Directives: Instruction set selection. */
2439 /* This code is to handle mapping symbols as defined in the ARM ELF spec.
2440 (See "Mapping symbols", section 4.5.5, ARM AAELF version 1.0).
2441 Note that previously, $a and $t has type STT_FUNC (BSF_OBJECT flag),
2442 and $d has type STT_OBJECT (BSF_OBJECT flag). Now all three are untyped. */
2444 /* Create a new mapping symbol for the transition to STATE. */
2447 make_mapping_symbol (enum mstate state
, valueT value
, fragS
*frag
)
2450 const char * symname
;
2457 type
= BSF_NO_FLAGS
;
2461 type
= BSF_NO_FLAGS
;
2465 type
= BSF_NO_FLAGS
;
2471 symbolP
= symbol_new (symname
, now_seg
, value
, frag
);
2472 symbol_get_bfdsym (symbolP
)->flags
|= type
| BSF_LOCAL
;
2477 THUMB_SET_FUNC (symbolP
, 0);
2478 ARM_SET_THUMB (symbolP
, 0);
2479 ARM_SET_INTERWORK (symbolP
, support_interwork
);
2483 THUMB_SET_FUNC (symbolP
, 1);
2484 ARM_SET_THUMB (symbolP
, 1);
2485 ARM_SET_INTERWORK (symbolP
, support_interwork
);
2493 /* Save the mapping symbols for future reference. Also check that
2494 we do not place two mapping symbols at the same offset within a
2495 frag. We'll handle overlap between frags in
2496 check_mapping_symbols.
2498 If .fill or other data filling directive generates zero sized data,
2499 the mapping symbol for the following code will have the same value
2500 as the one generated for the data filling directive. In this case,
2501 we replace the old symbol with the new one at the same address. */
2504 if (frag
->tc_frag_data
.first_map
!= NULL
)
2506 know (S_GET_VALUE (frag
->tc_frag_data
.first_map
) == 0);
2507 symbol_remove (frag
->tc_frag_data
.first_map
, &symbol_rootP
, &symbol_lastP
);
2509 frag
->tc_frag_data
.first_map
= symbolP
;
2511 if (frag
->tc_frag_data
.last_map
!= NULL
)
2513 know (S_GET_VALUE (frag
->tc_frag_data
.last_map
) <= S_GET_VALUE (symbolP
));
2514 if (S_GET_VALUE (frag
->tc_frag_data
.last_map
) == S_GET_VALUE (symbolP
))
2515 symbol_remove (frag
->tc_frag_data
.last_map
, &symbol_rootP
, &symbol_lastP
);
2517 frag
->tc_frag_data
.last_map
= symbolP
;
2520 /* We must sometimes convert a region marked as code to data during
2521 code alignment, if an odd number of bytes have to be padded. The
2522 code mapping symbol is pushed to an aligned address. */
2525 insert_data_mapping_symbol (enum mstate state
,
2526 valueT value
, fragS
*frag
, offsetT bytes
)
2528 /* If there was already a mapping symbol, remove it. */
2529 if (frag
->tc_frag_data
.last_map
!= NULL
2530 && S_GET_VALUE (frag
->tc_frag_data
.last_map
) == frag
->fr_address
+ value
)
2532 symbolS
*symp
= frag
->tc_frag_data
.last_map
;
2536 know (frag
->tc_frag_data
.first_map
== symp
);
2537 frag
->tc_frag_data
.first_map
= NULL
;
2539 frag
->tc_frag_data
.last_map
= NULL
;
2540 symbol_remove (symp
, &symbol_rootP
, &symbol_lastP
);
2543 make_mapping_symbol (MAP_DATA
, value
, frag
);
2544 make_mapping_symbol (state
, value
+ bytes
, frag
);
2547 static void mapping_state_2 (enum mstate state
, int max_chars
);
2549 /* Set the mapping state to STATE. Only call this when about to
2550 emit some STATE bytes to the file. */
2553 mapping_state (enum mstate state
)
2555 enum mstate mapstate
= seg_info (now_seg
)->tc_segment_info_data
.mapstate
;
2557 #define TRANSITION(from, to) (mapstate == (from) && state == (to))
2559 if (mapstate
== state
)
2560 /* The mapping symbol has already been emitted.
2561 There is nothing else to do. */
2563 else if (TRANSITION (MAP_UNDEFINED
, MAP_DATA
))
2564 /* This case will be evaluated later in the next else. */
2566 else if (TRANSITION (MAP_UNDEFINED
, MAP_ARM
)
2567 || TRANSITION (MAP_UNDEFINED
, MAP_THUMB
))
2569 /* Only add the symbol if the offset is > 0:
2570 if we're at the first frag, check it's size > 0;
2571 if we're not at the first frag, then for sure
2572 the offset is > 0. */
2573 struct frag
* const frag_first
= seg_info (now_seg
)->frchainP
->frch_root
;
2574 const int add_symbol
= (frag_now
!= frag_first
) || (frag_now_fix () > 0);
2577 make_mapping_symbol (MAP_DATA
, (valueT
) 0, frag_first
);
2580 mapping_state_2 (state
, 0);
2584 /* Same as mapping_state, but MAX_CHARS bytes have already been
2585 allocated. Put the mapping symbol that far back. */
2588 mapping_state_2 (enum mstate state
, int max_chars
)
2590 enum mstate mapstate
= seg_info (now_seg
)->tc_segment_info_data
.mapstate
;
2592 if (!SEG_NORMAL (now_seg
))
2595 if (mapstate
== state
)
2596 /* The mapping symbol has already been emitted.
2597 There is nothing else to do. */
2600 seg_info (now_seg
)->tc_segment_info_data
.mapstate
= state
;
2601 make_mapping_symbol (state
, (valueT
) frag_now_fix () - max_chars
, frag_now
);
2604 #define mapping_state(x) ((void)0)
2605 #define mapping_state_2(x, y) ((void)0)
2608 /* Find the real, Thumb encoded start of a Thumb function. */
2612 find_real_start (symbolS
* symbolP
)
2615 const char * name
= S_GET_NAME (symbolP
);
2616 symbolS
* new_target
;
2618 /* This definition must agree with the one in gcc/config/arm/thumb.c. */
2619 #define STUB_NAME ".real_start_of"
2624 /* The compiler may generate BL instructions to local labels because
2625 it needs to perform a branch to a far away location. These labels
2626 do not have a corresponding ".real_start_of" label. We check
2627 both for S_IS_LOCAL and for a leading dot, to give a way to bypass
2628 the ".real_start_of" convention for nonlocal branches. */
2629 if (S_IS_LOCAL (symbolP
) || name
[0] == '.')
2632 real_start
= ACONCAT ((STUB_NAME
, name
, NULL
));
2633 new_target
= symbol_find (real_start
);
2635 if (new_target
== NULL
)
2637 as_warn (_("Failed to find real start of function: %s\n"), name
);
2638 new_target
= symbolP
;
2646 opcode_select (int width
)
2653 if (!ARM_CPU_HAS_FEATURE (cpu_variant
, arm_ext_v4t
))
2654 as_bad (_("selected processor does not support THUMB opcodes"));
2657 /* No need to force the alignment, since we will have been
2658 coming from ARM mode, which is word-aligned. */
2659 record_alignment (now_seg
, 1);
2666 if (!ARM_CPU_HAS_FEATURE (cpu_variant
, arm_ext_v1
))
2667 as_bad (_("selected processor does not support ARM opcodes"));
2672 frag_align (2, 0, 0);
2674 record_alignment (now_seg
, 1);
2679 as_bad (_("invalid instruction size selected (%d)"), width
);
2684 s_arm (int ignore ATTRIBUTE_UNUSED
)
2687 demand_empty_rest_of_line ();
2691 s_thumb (int ignore ATTRIBUTE_UNUSED
)
2694 demand_empty_rest_of_line ();
2698 s_code (int unused ATTRIBUTE_UNUSED
)
2702 temp
= get_absolute_expression ();
2707 opcode_select (temp
);
2711 as_bad (_("invalid operand to .code directive (%d) (expecting 16 or 32)"), temp
);
2716 s_force_thumb (int ignore ATTRIBUTE_UNUSED
)
2718 /* If we are not already in thumb mode go into it, EVEN if
2719 the target processor does not support thumb instructions.
2720 This is used by gcc/config/arm/lib1funcs.asm for example
2721 to compile interworking support functions even if the
2722 target processor should not support interworking. */
2726 record_alignment (now_seg
, 1);
2729 demand_empty_rest_of_line ();
2733 s_thumb_func (int ignore ATTRIBUTE_UNUSED
)
2737 /* The following label is the name/address of the start of a Thumb function.
2738 We need to know this for the interworking support. */
2739 label_is_thumb_function_name
= TRUE
;
2742 /* Perform a .set directive, but also mark the alias as
2743 being a thumb function. */
2746 s_thumb_set (int equiv
)
2748 /* XXX the following is a duplicate of the code for s_set() in read.c
2749 We cannot just call that code as we need to get at the symbol that
2756 /* Especial apologies for the random logic:
2757 This just grew, and could be parsed much more simply!
2759 name
= input_line_pointer
;
2760 delim
= get_symbol_end ();
2761 end_name
= input_line_pointer
;
2764 if (*input_line_pointer
!= ',')
2767 as_bad (_("expected comma after name \"%s\""), name
);
2769 ignore_rest_of_line ();
2773 input_line_pointer
++;
2776 if (name
[0] == '.' && name
[1] == '\0')
2778 /* XXX - this should not happen to .thumb_set. */
2782 if ((symbolP
= symbol_find (name
)) == NULL
2783 && (symbolP
= md_undefined_symbol (name
)) == NULL
)
2786 /* When doing symbol listings, play games with dummy fragments living
2787 outside the normal fragment chain to record the file and line info
2789 if (listing
& LISTING_SYMBOLS
)
2791 extern struct list_info_struct
* listing_tail
;
2792 fragS
* dummy_frag
= (fragS
* ) xmalloc (sizeof (fragS
));
2794 memset (dummy_frag
, 0, sizeof (fragS
));
2795 dummy_frag
->fr_type
= rs_fill
;
2796 dummy_frag
->line
= listing_tail
;
2797 symbolP
= symbol_new (name
, undefined_section
, 0, dummy_frag
);
2798 dummy_frag
->fr_symbol
= symbolP
;
2802 symbolP
= symbol_new (name
, undefined_section
, 0, &zero_address_frag
);
2805 /* "set" symbols are local unless otherwise specified. */
2806 SF_SET_LOCAL (symbolP
);
2807 #endif /* OBJ_COFF */
2808 } /* Make a new symbol. */
2810 symbol_table_insert (symbolP
);
2815 && S_IS_DEFINED (symbolP
)
2816 && S_GET_SEGMENT (symbolP
) != reg_section
)
2817 as_bad (_("symbol `%s' already defined"), S_GET_NAME (symbolP
));
2819 pseudo_set (symbolP
);
2821 demand_empty_rest_of_line ();
2823 /* XXX Now we come to the Thumb specific bit of code. */
2825 THUMB_SET_FUNC (symbolP
, 1);
2826 ARM_SET_THUMB (symbolP
, 1);
2827 #if defined OBJ_ELF || defined OBJ_COFF
2828 ARM_SET_INTERWORK (symbolP
, support_interwork
);
2832 /* Directives: Mode selection. */
2834 /* .syntax [unified|divided] - choose the new unified syntax
2835 (same for Arm and Thumb encoding, modulo slight differences in what
2836 can be represented) or the old divergent syntax for each mode. */
2838 s_syntax (int unused ATTRIBUTE_UNUSED
)
2842 name
= input_line_pointer
;
2843 delim
= get_symbol_end ();
2845 if (!strcasecmp (name
, "unified"))
2846 unified_syntax
= TRUE
;
2847 else if (!strcasecmp (name
, "divided"))
2848 unified_syntax
= FALSE
;
2851 as_bad (_("unrecognized syntax mode \"%s\""), name
);
2854 *input_line_pointer
= delim
;
2855 demand_empty_rest_of_line ();
2858 /* Directives: sectioning and alignment. */
2860 /* Same as s_align_ptwo but align 0 => align 2. */
2863 s_align (int unused ATTRIBUTE_UNUSED
)
2868 long max_alignment
= 15;
2870 temp
= get_absolute_expression ();
2871 if (temp
> max_alignment
)
2872 as_bad (_("alignment too large: %d assumed"), temp
= max_alignment
);
2875 as_bad (_("alignment negative. 0 assumed."));
2879 if (*input_line_pointer
== ',')
2881 input_line_pointer
++;
2882 temp_fill
= get_absolute_expression ();
2894 /* Only make a frag if we HAVE to. */
2895 if (temp
&& !need_pass_2
)
2897 if (!fill_p
&& subseg_text_p (now_seg
))
2898 frag_align_code (temp
, 0);
2900 frag_align (temp
, (int) temp_fill
, 0);
2902 demand_empty_rest_of_line ();
2904 record_alignment (now_seg
, temp
);
2908 s_bss (int ignore ATTRIBUTE_UNUSED
)
2910 /* We don't support putting frags in the BSS segment, we fake it by
2911 marking in_bss, then looking at s_skip for clues. */
2912 subseg_set (bss_section
, 0);
2913 demand_empty_rest_of_line ();
2915 #ifdef md_elf_section_change_hook
2916 md_elf_section_change_hook ();
2921 s_even (int ignore ATTRIBUTE_UNUSED
)
2923 /* Never make frag if expect extra pass. */
2925 frag_align (1, 0, 0);
2927 record_alignment (now_seg
, 1);
2929 demand_empty_rest_of_line ();
2932 /* Directives: Literal pools. */
2934 static literal_pool
*
2935 find_literal_pool (void)
2937 literal_pool
* pool
;
2939 for (pool
= list_of_pools
; pool
!= NULL
; pool
= pool
->next
)
2941 if (pool
->section
== now_seg
2942 && pool
->sub_section
== now_subseg
)
2949 static literal_pool
*
2950 find_or_make_literal_pool (void)
2952 /* Next literal pool ID number. */
2953 static unsigned int latest_pool_num
= 1;
2954 literal_pool
* pool
;
2956 pool
= find_literal_pool ();
2960 /* Create a new pool. */
2961 pool
= (literal_pool
*) xmalloc (sizeof (* pool
));
2965 pool
->next_free_entry
= 0;
2966 pool
->section
= now_seg
;
2967 pool
->sub_section
= now_subseg
;
2968 pool
->next
= list_of_pools
;
2969 pool
->symbol
= NULL
;
2971 /* Add it to the list. */
2972 list_of_pools
= pool
;
2975 /* New pools, and emptied pools, will have a NULL symbol. */
2976 if (pool
->symbol
== NULL
)
2978 pool
->symbol
= symbol_create (FAKE_LABEL_NAME
, undefined_section
,
2979 (valueT
) 0, &zero_address_frag
);
2980 pool
->id
= latest_pool_num
++;
2987 /* Add the literal in the global 'inst'
2988 structure to the relevant literal pool. */
2991 add_to_lit_pool (void)
2993 literal_pool
* pool
;
2996 pool
= find_or_make_literal_pool ();
2998 /* Check if this literal value is already in the pool. */
2999 for (entry
= 0; entry
< pool
->next_free_entry
; entry
++)
3001 if ((pool
->literals
[entry
].X_op
== inst
.reloc
.exp
.X_op
)
3002 && (inst
.reloc
.exp
.X_op
== O_constant
)
3003 && (pool
->literals
[entry
].X_add_number
3004 == inst
.reloc
.exp
.X_add_number
)
3005 && (pool
->literals
[entry
].X_unsigned
3006 == inst
.reloc
.exp
.X_unsigned
))
3009 if ((pool
->literals
[entry
].X_op
== inst
.reloc
.exp
.X_op
)
3010 && (inst
.reloc
.exp
.X_op
== O_symbol
)
3011 && (pool
->literals
[entry
].X_add_number
3012 == inst
.reloc
.exp
.X_add_number
)
3013 && (pool
->literals
[entry
].X_add_symbol
3014 == inst
.reloc
.exp
.X_add_symbol
)
3015 && (pool
->literals
[entry
].X_op_symbol
3016 == inst
.reloc
.exp
.X_op_symbol
))
3020 /* Do we need to create a new entry? */
3021 if (entry
== pool
->next_free_entry
)
3023 if (entry
>= MAX_LITERAL_POOL_SIZE
)
3025 inst
.error
= _("literal pool overflow");
3029 pool
->literals
[entry
] = inst
.reloc
.exp
;
3030 pool
->next_free_entry
+= 1;
3033 inst
.reloc
.exp
.X_op
= O_symbol
;
3034 inst
.reloc
.exp
.X_add_number
= ((int) entry
) * 4;
3035 inst
.reloc
.exp
.X_add_symbol
= pool
->symbol
;
3040 /* Can't use symbol_new here, so have to create a symbol and then at
3041 a later date assign it a value. Thats what these functions do. */
3044 symbol_locate (symbolS
* symbolP
,
3045 const char * name
, /* It is copied, the caller can modify. */
3046 segT segment
, /* Segment identifier (SEG_<something>). */
3047 valueT valu
, /* Symbol value. */
3048 fragS
* frag
) /* Associated fragment. */
3050 unsigned int name_length
;
3051 char * preserved_copy_of_name
;
3053 name_length
= strlen (name
) + 1; /* +1 for \0. */
3054 obstack_grow (¬es
, name
, name_length
);
3055 preserved_copy_of_name
= (char *) obstack_finish (¬es
);
3057 #ifdef tc_canonicalize_symbol_name
3058 preserved_copy_of_name
=
3059 tc_canonicalize_symbol_name (preserved_copy_of_name
);
3062 S_SET_NAME (symbolP
, preserved_copy_of_name
);
3064 S_SET_SEGMENT (symbolP
, segment
);
3065 S_SET_VALUE (symbolP
, valu
);
3066 symbol_clear_list_pointers (symbolP
);
3068 symbol_set_frag (symbolP
, frag
);
3070 /* Link to end of symbol chain. */
3072 extern int symbol_table_frozen
;
3074 if (symbol_table_frozen
)
3078 symbol_append (symbolP
, symbol_lastP
, & symbol_rootP
, & symbol_lastP
);
3080 obj_symbol_new_hook (symbolP
);
3082 #ifdef tc_symbol_new_hook
3083 tc_symbol_new_hook (symbolP
);
3087 verify_symbol_chain (symbol_rootP
, symbol_lastP
);
3088 #endif /* DEBUG_SYMS */
3093 s_ltorg (int ignored ATTRIBUTE_UNUSED
)
3096 literal_pool
* pool
;
3099 pool
= find_literal_pool ();
3101 || pool
->symbol
== NULL
3102 || pool
->next_free_entry
== 0)
3105 mapping_state (MAP_DATA
);
3107 /* Align pool as you have word accesses.
3108 Only make a frag if we have to. */
3110 frag_align (2, 0, 0);
3112 record_alignment (now_seg
, 2);
3114 sprintf (sym_name
, "$$lit_\002%x", pool
->id
);
3116 symbol_locate (pool
->symbol
, sym_name
, now_seg
,
3117 (valueT
) frag_now_fix (), frag_now
);
3118 symbol_table_insert (pool
->symbol
);
3120 ARM_SET_THUMB (pool
->symbol
, thumb_mode
);
3122 #if defined OBJ_COFF || defined OBJ_ELF
3123 ARM_SET_INTERWORK (pool
->symbol
, support_interwork
);
3126 for (entry
= 0; entry
< pool
->next_free_entry
; entry
++)
3127 /* First output the expression in the instruction to the pool. */
3128 emit_expr (&(pool
->literals
[entry
]), 4); /* .word */
3130 /* Mark the pool as empty. */
3131 pool
->next_free_entry
= 0;
3132 pool
->symbol
= NULL
;
3136 /* Forward declarations for functions below, in the MD interface
3138 static void fix_new_arm (fragS
*, int, short, expressionS
*, int, int);
3139 static valueT
create_unwind_entry (int);
3140 static void start_unwind_section (const segT
, int);
3141 static void add_unwind_opcode (valueT
, int);
3142 static void flush_pending_unwind (void);
3144 /* Directives: Data. */
3147 s_arm_elf_cons (int nbytes
)
3151 #ifdef md_flush_pending_output
3152 md_flush_pending_output ();
3155 if (is_it_end_of_statement ())
3157 demand_empty_rest_of_line ();
3161 #ifdef md_cons_align
3162 md_cons_align (nbytes
);
3165 mapping_state (MAP_DATA
);
3169 char *base
= input_line_pointer
;
3173 if (exp
.X_op
!= O_symbol
)
3174 emit_expr (&exp
, (unsigned int) nbytes
);
3177 char *before_reloc
= input_line_pointer
;
3178 reloc
= parse_reloc (&input_line_pointer
);
3181 as_bad (_("unrecognized relocation suffix"));
3182 ignore_rest_of_line ();
3185 else if (reloc
== BFD_RELOC_UNUSED
)
3186 emit_expr (&exp
, (unsigned int) nbytes
);
3189 reloc_howto_type
*howto
= (reloc_howto_type
*)
3190 bfd_reloc_type_lookup (stdoutput
,
3191 (bfd_reloc_code_real_type
) reloc
);
3192 int size
= bfd_get_reloc_size (howto
);
3194 if (reloc
== BFD_RELOC_ARM_PLT32
)
3196 as_bad (_("(plt) is only valid on branch targets"));
3197 reloc
= BFD_RELOC_UNUSED
;
3202 as_bad (_("%s relocations do not fit in %d bytes"),
3203 howto
->name
, nbytes
);
3206 /* We've parsed an expression stopping at O_symbol.
3207 But there may be more expression left now that we
3208 have parsed the relocation marker. Parse it again.
3209 XXX Surely there is a cleaner way to do this. */
3210 char *p
= input_line_pointer
;
3212 char *save_buf
= (char *) alloca (input_line_pointer
- base
);
3213 memcpy (save_buf
, base
, input_line_pointer
- base
);
3214 memmove (base
+ (input_line_pointer
- before_reloc
),
3215 base
, before_reloc
- base
);
3217 input_line_pointer
= base
+ (input_line_pointer
-before_reloc
);
3219 memcpy (base
, save_buf
, p
- base
);
3221 offset
= nbytes
- size
;
3222 p
= frag_more ((int) nbytes
);
3223 fix_new_exp (frag_now
, p
- frag_now
->fr_literal
+ offset
,
3224 size
, &exp
, 0, (enum bfd_reloc_code_real
) reloc
);
3229 while (*input_line_pointer
++ == ',');
3231 /* Put terminator back into stream. */
3232 input_line_pointer
--;
3233 demand_empty_rest_of_line ();
3236 /* Emit an expression containing a 32-bit thumb instruction.
3237 Implementation based on put_thumb32_insn. */
3240 emit_thumb32_expr (expressionS
* exp
)
3242 expressionS exp_high
= *exp
;
3244 exp_high
.X_add_number
= (unsigned long)exp_high
.X_add_number
>> 16;
3245 emit_expr (& exp_high
, (unsigned int) THUMB_SIZE
);
3246 exp
->X_add_number
&= 0xffff;
3247 emit_expr (exp
, (unsigned int) THUMB_SIZE
);
3250 /* Guess the instruction size based on the opcode. */
3253 thumb_insn_size (int opcode
)
3255 if ((unsigned int) opcode
< 0xe800u
)
3257 else if ((unsigned int) opcode
>= 0xe8000000u
)
3264 emit_insn (expressionS
*exp
, int nbytes
)
3268 if (exp
->X_op
== O_constant
)
3273 size
= thumb_insn_size (exp
->X_add_number
);
3277 if (size
== 2 && (unsigned int)exp
->X_add_number
> 0xffffu
)
3279 as_bad (_(".inst.n operand too big. "\
3280 "Use .inst.w instead"));
3285 if (now_it
.state
== AUTOMATIC_IT_BLOCK
)
3286 set_it_insn_type_nonvoid (OUTSIDE_IT_INSN
, 0);
3288 set_it_insn_type_nonvoid (NEUTRAL_IT_INSN
, 0);
3290 if (thumb_mode
&& (size
> THUMB_SIZE
) && !target_big_endian
)
3291 emit_thumb32_expr (exp
);
3293 emit_expr (exp
, (unsigned int) size
);
3295 it_fsm_post_encode ();
3299 as_bad (_("cannot determine Thumb instruction size. " \
3300 "Use .inst.n/.inst.w instead"));
3303 as_bad (_("constant expression required"));
3308 /* Like s_arm_elf_cons but do not use md_cons_align and
3309 set the mapping state to MAP_ARM/MAP_THUMB. */
3312 s_arm_elf_inst (int nbytes
)
3314 if (is_it_end_of_statement ())
3316 demand_empty_rest_of_line ();
3320 /* Calling mapping_state () here will not change ARM/THUMB,
3321 but will ensure not to be in DATA state. */
3324 mapping_state (MAP_THUMB
);
3329 as_bad (_("width suffixes are invalid in ARM mode"));
3330 ignore_rest_of_line ();
3336 mapping_state (MAP_ARM
);
3345 if (! emit_insn (& exp
, nbytes
))
3347 ignore_rest_of_line ();
3351 while (*input_line_pointer
++ == ',');
3353 /* Put terminator back into stream. */
3354 input_line_pointer
--;
3355 demand_empty_rest_of_line ();
3358 /* Parse a .rel31 directive. */
3361 s_arm_rel31 (int ignored ATTRIBUTE_UNUSED
)
3368 if (*input_line_pointer
== '1')
3369 highbit
= 0x80000000;
3370 else if (*input_line_pointer
!= '0')
3371 as_bad (_("expected 0 or 1"));
3373 input_line_pointer
++;
3374 if (*input_line_pointer
!= ',')
3375 as_bad (_("missing comma"));
3376 input_line_pointer
++;
3378 #ifdef md_flush_pending_output
3379 md_flush_pending_output ();
3382 #ifdef md_cons_align
3386 mapping_state (MAP_DATA
);
3391 md_number_to_chars (p
, highbit
, 4);
3392 fix_new_arm (frag_now
, p
- frag_now
->fr_literal
, 4, &exp
, 1,
3393 BFD_RELOC_ARM_PREL31
);
3395 demand_empty_rest_of_line ();
3398 /* Directives: AEABI stack-unwind tables. */
3400 /* Parse an unwind_fnstart directive. Simply records the current location. */
3403 s_arm_unwind_fnstart (int ignored ATTRIBUTE_UNUSED
)
3405 demand_empty_rest_of_line ();
3406 if (unwind
.proc_start
)
3408 as_bad (_("duplicate .fnstart directive"));
3412 /* Mark the start of the function. */
3413 unwind
.proc_start
= expr_build_dot ();
3415 /* Reset the rest of the unwind info. */
3416 unwind
.opcode_count
= 0;
3417 unwind
.table_entry
= NULL
;
3418 unwind
.personality_routine
= NULL
;
3419 unwind
.personality_index
= -1;
3420 unwind
.frame_size
= 0;
3421 unwind
.fp_offset
= 0;
3422 unwind
.fp_reg
= REG_SP
;
3424 unwind
.sp_restored
= 0;
3428 /* Parse a handlerdata directive. Creates the exception handling table entry
3429 for the function. */
3432 s_arm_unwind_handlerdata (int ignored ATTRIBUTE_UNUSED
)
3434 demand_empty_rest_of_line ();
3435 if (!unwind
.proc_start
)
3436 as_bad (MISSING_FNSTART
);
3438 if (unwind
.table_entry
)
3439 as_bad (_("duplicate .handlerdata directive"));
3441 create_unwind_entry (1);
3444 /* Parse an unwind_fnend directive. Generates the index table entry. */
3447 s_arm_unwind_fnend (int ignored ATTRIBUTE_UNUSED
)
3452 unsigned int marked_pr_dependency
;
3454 demand_empty_rest_of_line ();
3456 if (!unwind
.proc_start
)
3458 as_bad (_(".fnend directive without .fnstart"));
3462 /* Add eh table entry. */
3463 if (unwind
.table_entry
== NULL
)
3464 val
= create_unwind_entry (0);
3468 /* Add index table entry. This is two words. */
3469 start_unwind_section (unwind
.saved_seg
, 1);
3470 frag_align (2, 0, 0);
3471 record_alignment (now_seg
, 2);
3473 ptr
= frag_more (8);
3474 where
= frag_now_fix () - 8;
3476 /* Self relative offset of the function start. */
3477 fix_new (frag_now
, where
, 4, unwind
.proc_start
, 0, 1,
3478 BFD_RELOC_ARM_PREL31
);
3480 /* Indicate dependency on EHABI-defined personality routines to the
3481 linker, if it hasn't been done already. */
3482 marked_pr_dependency
3483 = seg_info (now_seg
)->tc_segment_info_data
.marked_pr_dependency
;
3484 if (unwind
.personality_index
>= 0 && unwind
.personality_index
< 3
3485 && !(marked_pr_dependency
& (1 << unwind
.personality_index
)))
3487 static const char *const name
[] =
3489 "__aeabi_unwind_cpp_pr0",
3490 "__aeabi_unwind_cpp_pr1",
3491 "__aeabi_unwind_cpp_pr2"
3493 symbolS
*pr
= symbol_find_or_make (name
[unwind
.personality_index
]);
3494 fix_new (frag_now
, where
, 0, pr
, 0, 1, BFD_RELOC_NONE
);
3495 seg_info (now_seg
)->tc_segment_info_data
.marked_pr_dependency
3496 |= 1 << unwind
.personality_index
;
3500 /* Inline exception table entry. */
3501 md_number_to_chars (ptr
+ 4, val
, 4);
3503 /* Self relative offset of the table entry. */
3504 fix_new (frag_now
, where
+ 4, 4, unwind
.table_entry
, 0, 1,
3505 BFD_RELOC_ARM_PREL31
);
3507 /* Restore the original section. */
3508 subseg_set (unwind
.saved_seg
, unwind
.saved_subseg
);
3510 unwind
.proc_start
= NULL
;
3514 /* Parse an unwind_cantunwind directive. */
3517 s_arm_unwind_cantunwind (int ignored ATTRIBUTE_UNUSED
)
3519 demand_empty_rest_of_line ();
3520 if (!unwind
.proc_start
)
3521 as_bad (MISSING_FNSTART
);
3523 if (unwind
.personality_routine
|| unwind
.personality_index
!= -1)
3524 as_bad (_("personality routine specified for cantunwind frame"));
3526 unwind
.personality_index
= -2;
3530 /* Parse a personalityindex directive. */
3533 s_arm_unwind_personalityindex (int ignored ATTRIBUTE_UNUSED
)
3537 if (!unwind
.proc_start
)
3538 as_bad (MISSING_FNSTART
);
3540 if (unwind
.personality_routine
|| unwind
.personality_index
!= -1)
3541 as_bad (_("duplicate .personalityindex directive"));
3545 if (exp
.X_op
!= O_constant
3546 || exp
.X_add_number
< 0 || exp
.X_add_number
> 15)
3548 as_bad (_("bad personality routine number"));
3549 ignore_rest_of_line ();
3553 unwind
.personality_index
= exp
.X_add_number
;
3555 demand_empty_rest_of_line ();
3559 /* Parse a personality directive. */
3562 s_arm_unwind_personality (int ignored ATTRIBUTE_UNUSED
)
3566 if (!unwind
.proc_start
)
3567 as_bad (MISSING_FNSTART
);
3569 if (unwind
.personality_routine
|| unwind
.personality_index
!= -1)
3570 as_bad (_("duplicate .personality directive"));
3572 name
= input_line_pointer
;
3573 c
= get_symbol_end ();
3574 p
= input_line_pointer
;
3575 unwind
.personality_routine
= symbol_find_or_make (name
);
3577 demand_empty_rest_of_line ();
3581 /* Parse a directive saving core registers. */
3584 s_arm_unwind_save_core (void)
3590 range
= parse_reg_list (&input_line_pointer
);
3593 as_bad (_("expected register list"));
3594 ignore_rest_of_line ();
3598 demand_empty_rest_of_line ();
3600 /* Turn .unwind_movsp ip followed by .unwind_save {..., ip, ...}
3601 into .unwind_save {..., sp...}. We aren't bothered about the value of
3602 ip because it is clobbered by calls. */
3603 if (unwind
.sp_restored
&& unwind
.fp_reg
== 12
3604 && (range
& 0x3000) == 0x1000)
3606 unwind
.opcode_count
--;
3607 unwind
.sp_restored
= 0;
3608 range
= (range
| 0x2000) & ~0x1000;
3609 unwind
.pending_offset
= 0;
3615 /* See if we can use the short opcodes. These pop a block of up to 8
3616 registers starting with r4, plus maybe r14. */
3617 for (n
= 0; n
< 8; n
++)
3619 /* Break at the first non-saved register. */
3620 if ((range
& (1 << (n
+ 4))) == 0)
3623 /* See if there are any other bits set. */
3624 if (n
== 0 || (range
& (0xfff0 << n
) & 0xbff0) != 0)
3626 /* Use the long form. */
3627 op
= 0x8000 | ((range
>> 4) & 0xfff);
3628 add_unwind_opcode (op
, 2);
3632 /* Use the short form. */
3634 op
= 0xa8; /* Pop r14. */
3636 op
= 0xa0; /* Do not pop r14. */
3638 add_unwind_opcode (op
, 1);
3645 op
= 0xb100 | (range
& 0xf);
3646 add_unwind_opcode (op
, 2);
3649 /* Record the number of bytes pushed. */
3650 for (n
= 0; n
< 16; n
++)
3652 if (range
& (1 << n
))
3653 unwind
.frame_size
+= 4;
3658 /* Parse a directive saving FPA registers. */
3661 s_arm_unwind_save_fpa (int reg
)
3667 /* Get Number of registers to transfer. */
3668 if (skip_past_comma (&input_line_pointer
) != FAIL
)
3671 exp
.X_op
= O_illegal
;
3673 if (exp
.X_op
!= O_constant
)
3675 as_bad (_("expected , <constant>"));
3676 ignore_rest_of_line ();
3680 num_regs
= exp
.X_add_number
;
3682 if (num_regs
< 1 || num_regs
> 4)
3684 as_bad (_("number of registers must be in the range [1:4]"));
3685 ignore_rest_of_line ();
3689 demand_empty_rest_of_line ();
3694 op
= 0xb4 | (num_regs
- 1);
3695 add_unwind_opcode (op
, 1);
3700 op
= 0xc800 | (reg
<< 4) | (num_regs
- 1);
3701 add_unwind_opcode (op
, 2);
3703 unwind
.frame_size
+= num_regs
* 12;
3707 /* Parse a directive saving VFP registers for ARMv6 and above. */
3710 s_arm_unwind_save_vfp_armv6 (void)
3715 int num_vfpv3_regs
= 0;
3716 int num_regs_below_16
;
3718 count
= parse_vfp_reg_list (&input_line_pointer
, &start
, REGLIST_VFP_D
);
3721 as_bad (_("expected register list"));
3722 ignore_rest_of_line ();
3726 demand_empty_rest_of_line ();
3728 /* We always generate FSTMD/FLDMD-style unwinding opcodes (rather
3729 than FSTMX/FLDMX-style ones). */
3731 /* Generate opcode for (VFPv3) registers numbered in the range 16 .. 31. */
3733 num_vfpv3_regs
= count
;
3734 else if (start
+ count
> 16)
3735 num_vfpv3_regs
= start
+ count
- 16;
3737 if (num_vfpv3_regs
> 0)
3739 int start_offset
= start
> 16 ? start
- 16 : 0;
3740 op
= 0xc800 | (start_offset
<< 4) | (num_vfpv3_regs
- 1);
3741 add_unwind_opcode (op
, 2);
3744 /* Generate opcode for registers numbered in the range 0 .. 15. */
3745 num_regs_below_16
= num_vfpv3_regs
> 0 ? 16 - (int) start
: count
;
3746 gas_assert (num_regs_below_16
+ num_vfpv3_regs
== count
);
3747 if (num_regs_below_16
> 0)
3749 op
= 0xc900 | (start
<< 4) | (num_regs_below_16
- 1);
3750 add_unwind_opcode (op
, 2);
3753 unwind
.frame_size
+= count
* 8;
3757 /* Parse a directive saving VFP registers for pre-ARMv6. */
3760 s_arm_unwind_save_vfp (void)
3766 count
= parse_vfp_reg_list (&input_line_pointer
, ®
, REGLIST_VFP_D
);
3769 as_bad (_("expected register list"));
3770 ignore_rest_of_line ();
3774 demand_empty_rest_of_line ();
3779 op
= 0xb8 | (count
- 1);
3780 add_unwind_opcode (op
, 1);
3785 op
= 0xb300 | (reg
<< 4) | (count
- 1);
3786 add_unwind_opcode (op
, 2);
3788 unwind
.frame_size
+= count
* 8 + 4;
3792 /* Parse a directive saving iWMMXt data registers. */
3795 s_arm_unwind_save_mmxwr (void)
3803 if (*input_line_pointer
== '{')
3804 input_line_pointer
++;
3808 reg
= arm_reg_parse (&input_line_pointer
, REG_TYPE_MMXWR
);
3812 as_bad ("%s", _(reg_expected_msgs
[REG_TYPE_MMXWR
]));
3817 as_tsktsk (_("register list not in ascending order"));
3820 if (*input_line_pointer
== '-')
3822 input_line_pointer
++;
3823 hi_reg
= arm_reg_parse (&input_line_pointer
, REG_TYPE_MMXWR
);
3826 as_bad ("%s", _(reg_expected_msgs
[REG_TYPE_MMXWR
]));
3829 else if (reg
>= hi_reg
)
3831 as_bad (_("bad register range"));
3834 for (; reg
< hi_reg
; reg
++)
3838 while (skip_past_comma (&input_line_pointer
) != FAIL
);
3840 if (*input_line_pointer
== '}')
3841 input_line_pointer
++;
3843 demand_empty_rest_of_line ();
3845 /* Generate any deferred opcodes because we're going to be looking at
3847 flush_pending_unwind ();
3849 for (i
= 0; i
< 16; i
++)
3851 if (mask
& (1 << i
))
3852 unwind
.frame_size
+= 8;
3855 /* Attempt to combine with a previous opcode. We do this because gcc
3856 likes to output separate unwind directives for a single block of
3858 if (unwind
.opcode_count
> 0)
3860 i
= unwind
.opcodes
[unwind
.opcode_count
- 1];
3861 if ((i
& 0xf8) == 0xc0)
3864 /* Only merge if the blocks are contiguous. */
3867 if ((mask
& 0xfe00) == (1 << 9))
3869 mask
|= ((1 << (i
+ 11)) - 1) & 0xfc00;
3870 unwind
.opcode_count
--;
3873 else if (i
== 6 && unwind
.opcode_count
>= 2)
3875 i
= unwind
.opcodes
[unwind
.opcode_count
- 2];
3879 op
= 0xffff << (reg
- 1);
3881 && ((mask
& op
) == (1u << (reg
- 1))))
3883 op
= (1 << (reg
+ i
+ 1)) - 1;
3884 op
&= ~((1 << reg
) - 1);
3886 unwind
.opcode_count
-= 2;
3893 /* We want to generate opcodes in the order the registers have been
3894 saved, ie. descending order. */
3895 for (reg
= 15; reg
>= -1; reg
--)
3897 /* Save registers in blocks. */
3899 || !(mask
& (1 << reg
)))
3901 /* We found an unsaved reg. Generate opcodes to save the
3908 op
= 0xc0 | (hi_reg
- 10);
3909 add_unwind_opcode (op
, 1);
3914 op
= 0xc600 | ((reg
+ 1) << 4) | ((hi_reg
- reg
) - 1);
3915 add_unwind_opcode (op
, 2);
3924 ignore_rest_of_line ();
3928 s_arm_unwind_save_mmxwcg (void)
3935 if (*input_line_pointer
== '{')
3936 input_line_pointer
++;
3940 reg
= arm_reg_parse (&input_line_pointer
, REG_TYPE_MMXWCG
);
3944 as_bad ("%s", _(reg_expected_msgs
[REG_TYPE_MMXWCG
]));
3950 as_tsktsk (_("register list not in ascending order"));
3953 if (*input_line_pointer
== '-')
3955 input_line_pointer
++;
3956 hi_reg
= arm_reg_parse (&input_line_pointer
, REG_TYPE_MMXWCG
);
3959 as_bad ("%s", _(reg_expected_msgs
[REG_TYPE_MMXWCG
]));
3962 else if (reg
>= hi_reg
)
3964 as_bad (_("bad register range"));
3967 for (; reg
< hi_reg
; reg
++)
3971 while (skip_past_comma (&input_line_pointer
) != FAIL
);
3973 if (*input_line_pointer
== '}')
3974 input_line_pointer
++;
3976 demand_empty_rest_of_line ();
3978 /* Generate any deferred opcodes because we're going to be looking at
3980 flush_pending_unwind ();
3982 for (reg
= 0; reg
< 16; reg
++)
3984 if (mask
& (1 << reg
))
3985 unwind
.frame_size
+= 4;
3988 add_unwind_opcode (op
, 2);
3991 ignore_rest_of_line ();
3995 /* Parse an unwind_save directive.
3996 If the argument is non-zero, this is a .vsave directive. */
3999 s_arm_unwind_save (int arch_v6
)
4002 struct reg_entry
*reg
;
4003 bfd_boolean had_brace
= FALSE
;
4005 if (!unwind
.proc_start
)
4006 as_bad (MISSING_FNSTART
);
4008 /* Figure out what sort of save we have. */
4009 peek
= input_line_pointer
;
4017 reg
= arm_reg_parse_multi (&peek
);
4021 as_bad (_("register expected"));
4022 ignore_rest_of_line ();
4031 as_bad (_("FPA .unwind_save does not take a register list"));
4032 ignore_rest_of_line ();
4035 input_line_pointer
= peek
;
4036 s_arm_unwind_save_fpa (reg
->number
);
4039 case REG_TYPE_RN
: s_arm_unwind_save_core (); return;
4042 s_arm_unwind_save_vfp_armv6 ();
4044 s_arm_unwind_save_vfp ();
4046 case REG_TYPE_MMXWR
: s_arm_unwind_save_mmxwr (); return;
4047 case REG_TYPE_MMXWCG
: s_arm_unwind_save_mmxwcg (); return;
4050 as_bad (_(".unwind_save does not support this kind of register"));
4051 ignore_rest_of_line ();
4056 /* Parse an unwind_movsp directive. */
4059 s_arm_unwind_movsp (int ignored ATTRIBUTE_UNUSED
)
4065 if (!unwind
.proc_start
)
4066 as_bad (MISSING_FNSTART
);
4068 reg
= arm_reg_parse (&input_line_pointer
, REG_TYPE_RN
);
4071 as_bad ("%s", _(reg_expected_msgs
[REG_TYPE_RN
]));
4072 ignore_rest_of_line ();
4076 /* Optional constant. */
4077 if (skip_past_comma (&input_line_pointer
) != FAIL
)
4079 if (immediate_for_directive (&offset
) == FAIL
)
4085 demand_empty_rest_of_line ();
4087 if (reg
== REG_SP
|| reg
== REG_PC
)
4089 as_bad (_("SP and PC not permitted in .unwind_movsp directive"));
4093 if (unwind
.fp_reg
!= REG_SP
)
4094 as_bad (_("unexpected .unwind_movsp directive"));
4096 /* Generate opcode to restore the value. */
4098 add_unwind_opcode (op
, 1);
4100 /* Record the information for later. */
4101 unwind
.fp_reg
= reg
;
4102 unwind
.fp_offset
= unwind
.frame_size
- offset
;
4103 unwind
.sp_restored
= 1;
4106 /* Parse an unwind_pad directive. */
4109 s_arm_unwind_pad (int ignored ATTRIBUTE_UNUSED
)
4113 if (!unwind
.proc_start
)
4114 as_bad (MISSING_FNSTART
);
4116 if (immediate_for_directive (&offset
) == FAIL
)
4121 as_bad (_("stack increment must be multiple of 4"));
4122 ignore_rest_of_line ();
4126 /* Don't generate any opcodes, just record the details for later. */
4127 unwind
.frame_size
+= offset
;
4128 unwind
.pending_offset
+= offset
;
4130 demand_empty_rest_of_line ();
4133 /* Parse an unwind_setfp directive. */
4136 s_arm_unwind_setfp (int ignored ATTRIBUTE_UNUSED
)
4142 if (!unwind
.proc_start
)
4143 as_bad (MISSING_FNSTART
);
4145 fp_reg
= arm_reg_parse (&input_line_pointer
, REG_TYPE_RN
);
4146 if (skip_past_comma (&input_line_pointer
) == FAIL
)
4149 sp_reg
= arm_reg_parse (&input_line_pointer
, REG_TYPE_RN
);
4151 if (fp_reg
== FAIL
|| sp_reg
== FAIL
)
4153 as_bad (_("expected <reg>, <reg>"));
4154 ignore_rest_of_line ();
4158 /* Optional constant. */
4159 if (skip_past_comma (&input_line_pointer
) != FAIL
)
4161 if (immediate_for_directive (&offset
) == FAIL
)
4167 demand_empty_rest_of_line ();
4169 if (sp_reg
!= REG_SP
&& sp_reg
!= unwind
.fp_reg
)
4171 as_bad (_("register must be either sp or set by a previous"
4172 "unwind_movsp directive"));
4176 /* Don't generate any opcodes, just record the information for later. */
4177 unwind
.fp_reg
= fp_reg
;
4179 if (sp_reg
== REG_SP
)
4180 unwind
.fp_offset
= unwind
.frame_size
- offset
;
4182 unwind
.fp_offset
-= offset
;
4185 /* Parse an unwind_raw directive. */
4188 s_arm_unwind_raw (int ignored ATTRIBUTE_UNUSED
)
4191 /* This is an arbitrary limit. */
4192 unsigned char op
[16];
4195 if (!unwind
.proc_start
)
4196 as_bad (MISSING_FNSTART
);
4199 if (exp
.X_op
== O_constant
4200 && skip_past_comma (&input_line_pointer
) != FAIL
)
4202 unwind
.frame_size
+= exp
.X_add_number
;
4206 exp
.X_op
= O_illegal
;
4208 if (exp
.X_op
!= O_constant
)
4210 as_bad (_("expected <offset>, <opcode>"));
4211 ignore_rest_of_line ();
4217 /* Parse the opcode. */
4222 as_bad (_("unwind opcode too long"));
4223 ignore_rest_of_line ();
4225 if (exp
.X_op
!= O_constant
|| exp
.X_add_number
& ~0xff)
4227 as_bad (_("invalid unwind opcode"));
4228 ignore_rest_of_line ();
4231 op
[count
++] = exp
.X_add_number
;
4233 /* Parse the next byte. */
4234 if (skip_past_comma (&input_line_pointer
) == FAIL
)
4240 /* Add the opcode bytes in reverse order. */
4242 add_unwind_opcode (op
[count
], 1);
4244 demand_empty_rest_of_line ();
4248 /* Parse a .eabi_attribute directive. */
4251 s_arm_eabi_attribute (int ignored ATTRIBUTE_UNUSED
)
4253 int tag
= s_vendor_attribute (OBJ_ATTR_PROC
);
4255 if (tag
< NUM_KNOWN_OBJ_ATTRIBUTES
)
4256 attributes_set_explicitly
[tag
] = 1;
4258 #endif /* OBJ_ELF */
4260 static void s_arm_arch (int);
4261 static void s_arm_object_arch (int);
4262 static void s_arm_cpu (int);
4263 static void s_arm_fpu (int);
4268 pe_directive_secrel (int dummy ATTRIBUTE_UNUSED
)
4275 if (exp
.X_op
== O_symbol
)
4276 exp
.X_op
= O_secrel
;
4278 emit_expr (&exp
, 4);
4280 while (*input_line_pointer
++ == ',');
4282 input_line_pointer
--;
4283 demand_empty_rest_of_line ();
4287 /* This table describes all the machine specific pseudo-ops the assembler
4288 has to support. The fields are:
4289 pseudo-op name without dot
4290 function to call to execute this pseudo-op
4291 Integer arg to pass to the function. */
4293 const pseudo_typeS md_pseudo_table
[] =
4295 /* Never called because '.req' does not start a line. */
4296 { "req", s_req
, 0 },
4297 /* Following two are likewise never called. */
4300 { "unreq", s_unreq
, 0 },
4301 { "bss", s_bss
, 0 },
4302 { "align", s_align
, 0 },
4303 { "arm", s_arm
, 0 },
4304 { "thumb", s_thumb
, 0 },
4305 { "code", s_code
, 0 },
4306 { "force_thumb", s_force_thumb
, 0 },
4307 { "thumb_func", s_thumb_func
, 0 },
4308 { "thumb_set", s_thumb_set
, 0 },
4309 { "even", s_even
, 0 },
4310 { "ltorg", s_ltorg
, 0 },
4311 { "pool", s_ltorg
, 0 },
4312 { "syntax", s_syntax
, 0 },
4313 { "cpu", s_arm_cpu
, 0 },
4314 { "arch", s_arm_arch
, 0 },
4315 { "object_arch", s_arm_object_arch
, 0 },
4316 { "fpu", s_arm_fpu
, 0 },
4318 { "word", s_arm_elf_cons
, 4 },
4319 { "long", s_arm_elf_cons
, 4 },
4320 { "inst.n", s_arm_elf_inst
, 2 },
4321 { "inst.w", s_arm_elf_inst
, 4 },
4322 { "inst", s_arm_elf_inst
, 0 },
4323 { "rel31", s_arm_rel31
, 0 },
4324 { "fnstart", s_arm_unwind_fnstart
, 0 },
4325 { "fnend", s_arm_unwind_fnend
, 0 },
4326 { "cantunwind", s_arm_unwind_cantunwind
, 0 },
4327 { "personality", s_arm_unwind_personality
, 0 },
4328 { "personalityindex", s_arm_unwind_personalityindex
, 0 },
4329 { "handlerdata", s_arm_unwind_handlerdata
, 0 },
4330 { "save", s_arm_unwind_save
, 0 },
4331 { "vsave", s_arm_unwind_save
, 1 },
4332 { "movsp", s_arm_unwind_movsp
, 0 },
4333 { "pad", s_arm_unwind_pad
, 0 },
4334 { "setfp", s_arm_unwind_setfp
, 0 },
4335 { "unwind_raw", s_arm_unwind_raw
, 0 },
4336 { "eabi_attribute", s_arm_eabi_attribute
, 0 },
4340 /* These are used for dwarf. */
4344 /* These are used for dwarf2. */
4345 { "file", (void (*) (int)) dwarf2_directive_file
, 0 },
4346 { "loc", dwarf2_directive_loc
, 0 },
4347 { "loc_mark_labels", dwarf2_directive_loc_mark_labels
, 0 },
4349 { "extend", float_cons
, 'x' },
4350 { "ldouble", float_cons
, 'x' },
4351 { "packed", float_cons
, 'p' },
4353 {"secrel32", pe_directive_secrel
, 0},
4358 /* Parser functions used exclusively in instruction operands. */
4360 /* Generic immediate-value read function for use in insn parsing.
4361 STR points to the beginning of the immediate (the leading #);
4362 VAL receives the value; if the value is outside [MIN, MAX]
4363 issue an error. PREFIX_OPT is true if the immediate prefix is
4367 parse_immediate (char **str
, int *val
, int min
, int max
,
4368 bfd_boolean prefix_opt
)
4371 my_get_expression (&exp
, str
, prefix_opt
? GE_OPT_PREFIX
: GE_IMM_PREFIX
);
4372 if (exp
.X_op
!= O_constant
)
4374 inst
.error
= _("constant expression required");
4378 if (exp
.X_add_number
< min
|| exp
.X_add_number
> max
)
4380 inst
.error
= _("immediate value out of range");
4384 *val
= exp
.X_add_number
;
4388 /* Less-generic immediate-value read function with the possibility of loading a
4389 big (64-bit) immediate, as required by Neon VMOV, VMVN and logic immediate
4390 instructions. Puts the result directly in inst.operands[i]. */
4393 parse_big_immediate (char **str
, int i
)
4398 my_get_expression (&exp
, &ptr
, GE_OPT_PREFIX_BIG
);
4400 if (exp
.X_op
== O_constant
)
4402 inst
.operands
[i
].imm
= exp
.X_add_number
& 0xffffffff;
4403 /* If we're on a 64-bit host, then a 64-bit number can be returned using
4404 O_constant. We have to be careful not to break compilation for
4405 32-bit X_add_number, though. */
4406 if ((exp
.X_add_number
& ~0xffffffffl
) != 0)
4408 /* X >> 32 is illegal if sizeof (exp.X_add_number) == 4. */
4409 inst
.operands
[i
].reg
= ((exp
.X_add_number
>> 16) >> 16) & 0xffffffff;
4410 inst
.operands
[i
].regisimm
= 1;
4413 else if (exp
.X_op
== O_big
4414 && LITTLENUM_NUMBER_OF_BITS
* exp
.X_add_number
> 32
4415 && LITTLENUM_NUMBER_OF_BITS
* exp
.X_add_number
<= 64)
4417 unsigned parts
= 32 / LITTLENUM_NUMBER_OF_BITS
, j
, idx
= 0;
4418 /* Bignums have their least significant bits in
4419 generic_bignum[0]. Make sure we put 32 bits in imm and
4420 32 bits in reg, in a (hopefully) portable way. */
4421 gas_assert (parts
!= 0);
4422 inst
.operands
[i
].imm
= 0;
4423 for (j
= 0; j
< parts
; j
++, idx
++)
4424 inst
.operands
[i
].imm
|= generic_bignum
[idx
]
4425 << (LITTLENUM_NUMBER_OF_BITS
* j
);
4426 inst
.operands
[i
].reg
= 0;
4427 for (j
= 0; j
< parts
; j
++, idx
++)
4428 inst
.operands
[i
].reg
|= generic_bignum
[idx
]
4429 << (LITTLENUM_NUMBER_OF_BITS
* j
);
4430 inst
.operands
[i
].regisimm
= 1;
4440 /* Returns the pseudo-register number of an FPA immediate constant,
4441 or FAIL if there isn't a valid constant here. */
4444 parse_fpa_immediate (char ** str
)
4446 LITTLENUM_TYPE words
[MAX_LITTLENUMS
];
4452 /* First try and match exact strings, this is to guarantee
4453 that some formats will work even for cross assembly. */
4455 for (i
= 0; fp_const
[i
]; i
++)
4457 if (strncmp (*str
, fp_const
[i
], strlen (fp_const
[i
])) == 0)
4461 *str
+= strlen (fp_const
[i
]);
4462 if (is_end_of_line
[(unsigned char) **str
])
4468 /* Just because we didn't get a match doesn't mean that the constant
4469 isn't valid, just that it is in a format that we don't
4470 automatically recognize. Try parsing it with the standard
4471 expression routines. */
4473 memset (words
, 0, MAX_LITTLENUMS
* sizeof (LITTLENUM_TYPE
));
4475 /* Look for a raw floating point number. */
4476 if ((save_in
= atof_ieee (*str
, 'x', words
)) != NULL
4477 && is_end_of_line
[(unsigned char) *save_in
])
4479 for (i
= 0; i
< NUM_FLOAT_VALS
; i
++)
4481 for (j
= 0; j
< MAX_LITTLENUMS
; j
++)
4483 if (words
[j
] != fp_values
[i
][j
])
4487 if (j
== MAX_LITTLENUMS
)
4495 /* Try and parse a more complex expression, this will probably fail
4496 unless the code uses a floating point prefix (eg "0f"). */
4497 save_in
= input_line_pointer
;
4498 input_line_pointer
= *str
;
4499 if (expression (&exp
) == absolute_section
4500 && exp
.X_op
== O_big
4501 && exp
.X_add_number
< 0)
4503 /* FIXME: 5 = X_PRECISION, should be #define'd where we can use it.
4505 if (gen_to_words (words
, 5, (long) 15) == 0)
4507 for (i
= 0; i
< NUM_FLOAT_VALS
; i
++)
4509 for (j
= 0; j
< MAX_LITTLENUMS
; j
++)
4511 if (words
[j
] != fp_values
[i
][j
])
4515 if (j
== MAX_LITTLENUMS
)
4517 *str
= input_line_pointer
;
4518 input_line_pointer
= save_in
;
4525 *str
= input_line_pointer
;
4526 input_line_pointer
= save_in
;
4527 inst
.error
= _("invalid FPA immediate expression");
4531 /* Returns 1 if a number has "quarter-precision" float format
4532 0baBbbbbbc defgh000 00000000 00000000. */
4535 is_quarter_float (unsigned imm
)
4537 int bs
= (imm
& 0x20000000) ? 0x3e000000 : 0x40000000;
4538 return (imm
& 0x7ffff) == 0 && ((imm
& 0x7e000000) ^ bs
) == 0;
4541 /* Parse an 8-bit "quarter-precision" floating point number of the form:
4542 0baBbbbbbc defgh000 00000000 00000000.
4543 The zero and minus-zero cases need special handling, since they can't be
4544 encoded in the "quarter-precision" float format, but can nonetheless be
4545 loaded as integer constants. */
4548 parse_qfloat_immediate (char **ccp
, int *immed
)
4552 LITTLENUM_TYPE words
[MAX_LITTLENUMS
];
4553 int found_fpchar
= 0;
4555 skip_past_char (&str
, '#');
4557 /* We must not accidentally parse an integer as a floating-point number. Make
4558 sure that the value we parse is not an integer by checking for special
4559 characters '.' or 'e'.
4560 FIXME: This is a horrible hack, but doing better is tricky because type
4561 information isn't in a very usable state at parse time. */
4563 skip_whitespace (fpnum
);
4565 if (strncmp (fpnum
, "0x", 2) == 0)
4569 for (; *fpnum
!= '\0' && *fpnum
!= ' ' && *fpnum
!= '\n'; fpnum
++)
4570 if (*fpnum
== '.' || *fpnum
== 'e' || *fpnum
== 'E')
4580 if ((str
= atof_ieee (str
, 's', words
)) != NULL
)
4582 unsigned fpword
= 0;
4585 /* Our FP word must be 32 bits (single-precision FP). */
4586 for (i
= 0; i
< 32 / LITTLENUM_NUMBER_OF_BITS
; i
++)
4588 fpword
<<= LITTLENUM_NUMBER_OF_BITS
;
4592 if (is_quarter_float (fpword
) || (fpword
& 0x7fffffff) == 0)
4605 /* Shift operands. */
4608 SHIFT_LSL
, SHIFT_LSR
, SHIFT_ASR
, SHIFT_ROR
, SHIFT_RRX
4611 struct asm_shift_name
4614 enum shift_kind kind
;
4617 /* Third argument to parse_shift. */
4618 enum parse_shift_mode
4620 NO_SHIFT_RESTRICT
, /* Any kind of shift is accepted. */
4621 SHIFT_IMMEDIATE
, /* Shift operand must be an immediate. */
4622 SHIFT_LSL_OR_ASR_IMMEDIATE
, /* Shift must be LSL or ASR immediate. */
4623 SHIFT_ASR_IMMEDIATE
, /* Shift must be ASR immediate. */
4624 SHIFT_LSL_IMMEDIATE
, /* Shift must be LSL immediate. */
4627 /* Parse a <shift> specifier on an ARM data processing instruction.
4628 This has three forms:
4630 (LSL|LSR|ASL|ASR|ROR) Rs
4631 (LSL|LSR|ASL|ASR|ROR) #imm
4634 Note that ASL is assimilated to LSL in the instruction encoding, and
4635 RRX to ROR #0 (which cannot be written as such). */
4638 parse_shift (char **str
, int i
, enum parse_shift_mode mode
)
4640 const struct asm_shift_name
*shift_name
;
4641 enum shift_kind shift
;
4646 for (p
= *str
; ISALPHA (*p
); p
++)
4651 inst
.error
= _("shift expression expected");
4655 shift_name
= (const struct asm_shift_name
*) hash_find_n (arm_shift_hsh
, *str
,
4658 if (shift_name
== NULL
)
4660 inst
.error
= _("shift expression expected");
4664 shift
= shift_name
->kind
;
4668 case NO_SHIFT_RESTRICT
:
4669 case SHIFT_IMMEDIATE
: break;
4671 case SHIFT_LSL_OR_ASR_IMMEDIATE
:
4672 if (shift
!= SHIFT_LSL
&& shift
!= SHIFT_ASR
)
4674 inst
.error
= _("'LSL' or 'ASR' required");
4679 case SHIFT_LSL_IMMEDIATE
:
4680 if (shift
!= SHIFT_LSL
)
4682 inst
.error
= _("'LSL' required");
4687 case SHIFT_ASR_IMMEDIATE
:
4688 if (shift
!= SHIFT_ASR
)
4690 inst
.error
= _("'ASR' required");
4698 if (shift
!= SHIFT_RRX
)
4700 /* Whitespace can appear here if the next thing is a bare digit. */
4701 skip_whitespace (p
);
4703 if (mode
== NO_SHIFT_RESTRICT
4704 && (reg
= arm_reg_parse (&p
, REG_TYPE_RN
)) != FAIL
)
4706 inst
.operands
[i
].imm
= reg
;
4707 inst
.operands
[i
].immisreg
= 1;
4709 else if (my_get_expression (&inst
.reloc
.exp
, &p
, GE_IMM_PREFIX
))
4712 inst
.operands
[i
].shift_kind
= shift
;
4713 inst
.operands
[i
].shifted
= 1;
4718 /* Parse a <shifter_operand> for an ARM data processing instruction:
4721 #<immediate>, <rotate>
4725 where <shift> is defined by parse_shift above, and <rotate> is a
4726 multiple of 2 between 0 and 30. Validation of immediate operands
4727 is deferred to md_apply_fix. */
4730 parse_shifter_operand (char **str
, int i
)
4735 if ((value
= arm_reg_parse (str
, REG_TYPE_RN
)) != FAIL
)
4737 inst
.operands
[i
].reg
= value
;
4738 inst
.operands
[i
].isreg
= 1;
4740 /* parse_shift will override this if appropriate */
4741 inst
.reloc
.exp
.X_op
= O_constant
;
4742 inst
.reloc
.exp
.X_add_number
= 0;
4744 if (skip_past_comma (str
) == FAIL
)
4747 /* Shift operation on register. */
4748 return parse_shift (str
, i
, NO_SHIFT_RESTRICT
);
4751 if (my_get_expression (&inst
.reloc
.exp
, str
, GE_IMM_PREFIX
))
4754 if (skip_past_comma (str
) == SUCCESS
)
4756 /* #x, y -- ie explicit rotation by Y. */
4757 if (my_get_expression (&exp
, str
, GE_NO_PREFIX
))
4760 if (exp
.X_op
!= O_constant
|| inst
.reloc
.exp
.X_op
!= O_constant
)
4762 inst
.error
= _("constant expression expected");
4766 value
= exp
.X_add_number
;
4767 if (value
< 0 || value
> 30 || value
% 2 != 0)
4769 inst
.error
= _("invalid rotation");
4772 if (inst
.reloc
.exp
.X_add_number
< 0 || inst
.reloc
.exp
.X_add_number
> 255)
4774 inst
.error
= _("invalid constant");
4778 /* Convert to decoded value. md_apply_fix will put it back. */
4779 inst
.reloc
.exp
.X_add_number
4780 = (((inst
.reloc
.exp
.X_add_number
<< (32 - value
))
4781 | (inst
.reloc
.exp
.X_add_number
>> value
)) & 0xffffffff);
4784 inst
.reloc
.type
= BFD_RELOC_ARM_IMMEDIATE
;
4785 inst
.reloc
.pc_rel
= 0;
4789 /* Group relocation information. Each entry in the table contains the
4790 textual name of the relocation as may appear in assembler source
4791 and must end with a colon.
4792 Along with this textual name are the relocation codes to be used if
4793 the corresponding instruction is an ALU instruction (ADD or SUB only),
4794 an LDR, an LDRS, or an LDC. */
4796 struct group_reloc_table_entry
4807 /* Varieties of non-ALU group relocation. */
4814 static struct group_reloc_table_entry group_reloc_table
[] =
4815 { /* Program counter relative: */
4817 BFD_RELOC_ARM_ALU_PC_G0_NC
, /* ALU */
4822 BFD_RELOC_ARM_ALU_PC_G0
, /* ALU */
4823 BFD_RELOC_ARM_LDR_PC_G0
, /* LDR */
4824 BFD_RELOC_ARM_LDRS_PC_G0
, /* LDRS */
4825 BFD_RELOC_ARM_LDC_PC_G0
}, /* LDC */
4827 BFD_RELOC_ARM_ALU_PC_G1_NC
, /* ALU */
4832 BFD_RELOC_ARM_ALU_PC_G1
, /* ALU */
4833 BFD_RELOC_ARM_LDR_PC_G1
, /* LDR */
4834 BFD_RELOC_ARM_LDRS_PC_G1
, /* LDRS */
4835 BFD_RELOC_ARM_LDC_PC_G1
}, /* LDC */
4837 BFD_RELOC_ARM_ALU_PC_G2
, /* ALU */
4838 BFD_RELOC_ARM_LDR_PC_G2
, /* LDR */
4839 BFD_RELOC_ARM_LDRS_PC_G2
, /* LDRS */
4840 BFD_RELOC_ARM_LDC_PC_G2
}, /* LDC */
4841 /* Section base relative */
4843 BFD_RELOC_ARM_ALU_SB_G0_NC
, /* ALU */
4848 BFD_RELOC_ARM_ALU_SB_G0
, /* ALU */
4849 BFD_RELOC_ARM_LDR_SB_G0
, /* LDR */
4850 BFD_RELOC_ARM_LDRS_SB_G0
, /* LDRS */
4851 BFD_RELOC_ARM_LDC_SB_G0
}, /* LDC */
4853 BFD_RELOC_ARM_ALU_SB_G1_NC
, /* ALU */
4858 BFD_RELOC_ARM_ALU_SB_G1
, /* ALU */
4859 BFD_RELOC_ARM_LDR_SB_G1
, /* LDR */
4860 BFD_RELOC_ARM_LDRS_SB_G1
, /* LDRS */
4861 BFD_RELOC_ARM_LDC_SB_G1
}, /* LDC */
4863 BFD_RELOC_ARM_ALU_SB_G2
, /* ALU */
4864 BFD_RELOC_ARM_LDR_SB_G2
, /* LDR */
4865 BFD_RELOC_ARM_LDRS_SB_G2
, /* LDRS */
4866 BFD_RELOC_ARM_LDC_SB_G2
} }; /* LDC */
4868 /* Given the address of a pointer pointing to the textual name of a group
4869 relocation as may appear in assembler source, attempt to find its details
4870 in group_reloc_table. The pointer will be updated to the character after
4871 the trailing colon. On failure, FAIL will be returned; SUCCESS
4872 otherwise. On success, *entry will be updated to point at the relevant
4873 group_reloc_table entry. */
4876 find_group_reloc_table_entry (char **str
, struct group_reloc_table_entry
**out
)
4879 for (i
= 0; i
< ARRAY_SIZE (group_reloc_table
); i
++)
4881 int length
= strlen (group_reloc_table
[i
].name
);
4883 if (strncasecmp (group_reloc_table
[i
].name
, *str
, length
) == 0
4884 && (*str
)[length
] == ':')
4886 *out
= &group_reloc_table
[i
];
4887 *str
+= (length
+ 1);
4895 /* Parse a <shifter_operand> for an ARM data processing instruction
4896 (as for parse_shifter_operand) where group relocations are allowed:
4899 #<immediate>, <rotate>
4900 #:<group_reloc>:<expression>
4904 where <group_reloc> is one of the strings defined in group_reloc_table.
4905 The hashes are optional.
4907 Everything else is as for parse_shifter_operand. */
4909 static parse_operand_result
4910 parse_shifter_operand_group_reloc (char **str
, int i
)
4912 /* Determine if we have the sequence of characters #: or just :
4913 coming next. If we do, then we check for a group relocation.
4914 If we don't, punt the whole lot to parse_shifter_operand. */
4916 if (((*str
)[0] == '#' && (*str
)[1] == ':')
4917 || (*str
)[0] == ':')
4919 struct group_reloc_table_entry
*entry
;
4921 if ((*str
)[0] == '#')
4926 /* Try to parse a group relocation. Anything else is an error. */
4927 if (find_group_reloc_table_entry (str
, &entry
) == FAIL
)
4929 inst
.error
= _("unknown group relocation");
4930 return PARSE_OPERAND_FAIL_NO_BACKTRACK
;
4933 /* We now have the group relocation table entry corresponding to
4934 the name in the assembler source. Next, we parse the expression. */
4935 if (my_get_expression (&inst
.reloc
.exp
, str
, GE_NO_PREFIX
))
4936 return PARSE_OPERAND_FAIL_NO_BACKTRACK
;
4938 /* Record the relocation type (always the ALU variant here). */
4939 inst
.reloc
.type
= (bfd_reloc_code_real_type
) entry
->alu_code
;
4940 gas_assert (inst
.reloc
.type
!= 0);
4942 return PARSE_OPERAND_SUCCESS
;
4945 return parse_shifter_operand (str
, i
) == SUCCESS
4946 ? PARSE_OPERAND_SUCCESS
: PARSE_OPERAND_FAIL
;
4948 /* Never reached. */
4951 /* Parse all forms of an ARM address expression. Information is written
4952 to inst.operands[i] and/or inst.reloc.
4954 Preindexed addressing (.preind=1):
4956 [Rn, #offset] .reg=Rn .reloc.exp=offset
4957 [Rn, +/-Rm] .reg=Rn .imm=Rm .immisreg=1 .negative=0/1
4958 [Rn, +/-Rm, shift] .reg=Rn .imm=Rm .immisreg=1 .negative=0/1
4959 .shift_kind=shift .reloc.exp=shift_imm
4961 These three may have a trailing ! which causes .writeback to be set also.
4963 Postindexed addressing (.postind=1, .writeback=1):
4965 [Rn], #offset .reg=Rn .reloc.exp=offset
4966 [Rn], +/-Rm .reg=Rn .imm=Rm .immisreg=1 .negative=0/1
4967 [Rn], +/-Rm, shift .reg=Rn .imm=Rm .immisreg=1 .negative=0/1
4968 .shift_kind=shift .reloc.exp=shift_imm
4970 Unindexed addressing (.preind=0, .postind=0):
4972 [Rn], {option} .reg=Rn .imm=option .immisreg=0
4976 [Rn]{!} shorthand for [Rn,#0]{!}
4977 =immediate .isreg=0 .reloc.exp=immediate
4978 label .reg=PC .reloc.pc_rel=1 .reloc.exp=label
4980 It is the caller's responsibility to check for addressing modes not
4981 supported by the instruction, and to set inst.reloc.type. */
4983 static parse_operand_result
4984 parse_address_main (char **str
, int i
, int group_relocations
,
4985 group_reloc_type group_type
)
4990 if (skip_past_char (&p
, '[') == FAIL
)
4992 if (skip_past_char (&p
, '=') == FAIL
)
4994 /* Bare address - translate to PC-relative offset. */
4995 inst
.reloc
.pc_rel
= 1;
4996 inst
.operands
[i
].reg
= REG_PC
;
4997 inst
.operands
[i
].isreg
= 1;
4998 inst
.operands
[i
].preind
= 1;
5000 /* Otherwise a load-constant pseudo op, no special treatment needed here. */
5002 if (my_get_expression (&inst
.reloc
.exp
, &p
, GE_NO_PREFIX
))
5003 return PARSE_OPERAND_FAIL
;
5006 return PARSE_OPERAND_SUCCESS
;
5009 if ((reg
= arm_reg_parse (&p
, REG_TYPE_RN
)) == FAIL
)
5011 inst
.error
= _(reg_expected_msgs
[REG_TYPE_RN
]);
5012 return PARSE_OPERAND_FAIL
;
5014 inst
.operands
[i
].reg
= reg
;
5015 inst
.operands
[i
].isreg
= 1;
5017 if (skip_past_comma (&p
) == SUCCESS
)
5019 inst
.operands
[i
].preind
= 1;
5022 else if (*p
== '-') p
++, inst
.operands
[i
].negative
= 1;
5024 if ((reg
= arm_reg_parse (&p
, REG_TYPE_RN
)) != FAIL
)
5026 inst
.operands
[i
].imm
= reg
;
5027 inst
.operands
[i
].immisreg
= 1;
5029 if (skip_past_comma (&p
) == SUCCESS
)
5030 if (parse_shift (&p
, i
, SHIFT_IMMEDIATE
) == FAIL
)
5031 return PARSE_OPERAND_FAIL
;
5033 else if (skip_past_char (&p
, ':') == SUCCESS
)
5035 /* FIXME: '@' should be used here, but it's filtered out by generic
5036 code before we get to see it here. This may be subject to
5039 my_get_expression (&exp
, &p
, GE_NO_PREFIX
);
5040 if (exp
.X_op
!= O_constant
)
5042 inst
.error
= _("alignment must be constant");
5043 return PARSE_OPERAND_FAIL
;
5045 inst
.operands
[i
].imm
= exp
.X_add_number
<< 8;
5046 inst
.operands
[i
].immisalign
= 1;
5047 /* Alignments are not pre-indexes. */
5048 inst
.operands
[i
].preind
= 0;
5052 if (inst
.operands
[i
].negative
)
5054 inst
.operands
[i
].negative
= 0;
5058 if (group_relocations
5059 && ((*p
== '#' && *(p
+ 1) == ':') || *p
== ':'))
5061 struct group_reloc_table_entry
*entry
;
5063 /* Skip over the #: or : sequence. */
5069 /* Try to parse a group relocation. Anything else is an
5071 if (find_group_reloc_table_entry (&p
, &entry
) == FAIL
)
5073 inst
.error
= _("unknown group relocation");
5074 return PARSE_OPERAND_FAIL_NO_BACKTRACK
;
5077 /* We now have the group relocation table entry corresponding to
5078 the name in the assembler source. Next, we parse the
5080 if (my_get_expression (&inst
.reloc
.exp
, &p
, GE_NO_PREFIX
))
5081 return PARSE_OPERAND_FAIL_NO_BACKTRACK
;
5083 /* Record the relocation type. */
5087 inst
.reloc
.type
= (bfd_reloc_code_real_type
) entry
->ldr_code
;
5091 inst
.reloc
.type
= (bfd_reloc_code_real_type
) entry
->ldrs_code
;
5095 inst
.reloc
.type
= (bfd_reloc_code_real_type
) entry
->ldc_code
;
5102 if (inst
.reloc
.type
== 0)
5104 inst
.error
= _("this group relocation is not allowed on this instruction");
5105 return PARSE_OPERAND_FAIL_NO_BACKTRACK
;
5109 if (my_get_expression (&inst
.reloc
.exp
, &p
, GE_IMM_PREFIX
))
5110 return PARSE_OPERAND_FAIL
;
5114 if (skip_past_char (&p
, ']') == FAIL
)
5116 inst
.error
= _("']' expected");
5117 return PARSE_OPERAND_FAIL
;
5120 if (skip_past_char (&p
, '!') == SUCCESS
)
5121 inst
.operands
[i
].writeback
= 1;
5123 else if (skip_past_comma (&p
) == SUCCESS
)
5125 if (skip_past_char (&p
, '{') == SUCCESS
)
5127 /* [Rn], {expr} - unindexed, with option */
5128 if (parse_immediate (&p
, &inst
.operands
[i
].imm
,
5129 0, 255, TRUE
) == FAIL
)
5130 return PARSE_OPERAND_FAIL
;
5132 if (skip_past_char (&p
, '}') == FAIL
)
5134 inst
.error
= _("'}' expected at end of 'option' field");
5135 return PARSE_OPERAND_FAIL
;
5137 if (inst
.operands
[i
].preind
)
5139 inst
.error
= _("cannot combine index with option");
5140 return PARSE_OPERAND_FAIL
;
5143 return PARSE_OPERAND_SUCCESS
;
5147 inst
.operands
[i
].postind
= 1;
5148 inst
.operands
[i
].writeback
= 1;
5150 if (inst
.operands
[i
].preind
)
5152 inst
.error
= _("cannot combine pre- and post-indexing");
5153 return PARSE_OPERAND_FAIL
;
5157 else if (*p
== '-') p
++, inst
.operands
[i
].negative
= 1;
5159 if ((reg
= arm_reg_parse (&p
, REG_TYPE_RN
)) != FAIL
)
5161 /* We might be using the immediate for alignment already. If we
5162 are, OR the register number into the low-order bits. */
5163 if (inst
.operands
[i
].immisalign
)
5164 inst
.operands
[i
].imm
|= reg
;
5166 inst
.operands
[i
].imm
= reg
;
5167 inst
.operands
[i
].immisreg
= 1;
5169 if (skip_past_comma (&p
) == SUCCESS
)
5170 if (parse_shift (&p
, i
, SHIFT_IMMEDIATE
) == FAIL
)
5171 return PARSE_OPERAND_FAIL
;
5175 if (inst
.operands
[i
].negative
)
5177 inst
.operands
[i
].negative
= 0;
5180 if (my_get_expression (&inst
.reloc
.exp
, &p
, GE_IMM_PREFIX
))
5181 return PARSE_OPERAND_FAIL
;
5186 /* If at this point neither .preind nor .postind is set, we have a
5187 bare [Rn]{!}, which is shorthand for [Rn,#0]{!}. */
5188 if (inst
.operands
[i
].preind
== 0 && inst
.operands
[i
].postind
== 0)
5190 inst
.operands
[i
].preind
= 1;
5191 inst
.reloc
.exp
.X_op
= O_constant
;
5192 inst
.reloc
.exp
.X_add_number
= 0;
5195 return PARSE_OPERAND_SUCCESS
;
5199 parse_address (char **str
, int i
)
5201 return parse_address_main (str
, i
, 0, GROUP_LDR
) == PARSE_OPERAND_SUCCESS
5205 static parse_operand_result
5206 parse_address_group_reloc (char **str
, int i
, group_reloc_type type
)
5208 return parse_address_main (str
, i
, 1, type
);
5211 /* Parse an operand for a MOVW or MOVT instruction. */
5213 parse_half (char **str
)
5218 skip_past_char (&p
, '#');
5219 if (strncasecmp (p
, ":lower16:", 9) == 0)
5220 inst
.reloc
.type
= BFD_RELOC_ARM_MOVW
;
5221 else if (strncasecmp (p
, ":upper16:", 9) == 0)
5222 inst
.reloc
.type
= BFD_RELOC_ARM_MOVT
;
5224 if (inst
.reloc
.type
!= BFD_RELOC_UNUSED
)
5227 skip_whitespace (p
);
5230 if (my_get_expression (&inst
.reloc
.exp
, &p
, GE_NO_PREFIX
))
5233 if (inst
.reloc
.type
== BFD_RELOC_UNUSED
)
5235 if (inst
.reloc
.exp
.X_op
!= O_constant
)
5237 inst
.error
= _("constant expression expected");
5240 if (inst
.reloc
.exp
.X_add_number
< 0
5241 || inst
.reloc
.exp
.X_add_number
> 0xffff)
5243 inst
.error
= _("immediate value out of range");
5251 /* Miscellaneous. */
5253 /* Parse a PSR flag operand. The value returned is FAIL on syntax error,
5254 or a bitmask suitable to be or-ed into the ARM msr instruction. */
5256 parse_psr (char **str
)
5259 unsigned long psr_field
;
5260 const struct asm_psr
*psr
;
5263 /* CPSR's and SPSR's can now be lowercase. This is just a convenience
5264 feature for ease of use and backwards compatibility. */
5266 if (strncasecmp (p
, "SPSR", 4) == 0)
5267 psr_field
= SPSR_BIT
;
5268 else if (strncasecmp (p
, "CPSR", 4) == 0)
5275 while (ISALNUM (*p
) || *p
== '_');
5277 psr
= (const struct asm_psr
*) hash_find_n (arm_v7m_psr_hsh
, start
,
5289 /* A suffix follows. */
5295 while (ISALNUM (*p
) || *p
== '_');
5297 psr
= (const struct asm_psr
*) hash_find_n (arm_psr_hsh
, start
,
5302 psr_field
|= psr
->field
;
5307 goto error
; /* Garbage after "[CS]PSR". */
5309 psr_field
|= (PSR_c
| PSR_f
);
5315 inst
.error
= _("flag for {c}psr instruction expected");
5319 /* Parse the flags argument to CPSI[ED]. Returns FAIL on error, or a
5320 value suitable for splatting into the AIF field of the instruction. */
5323 parse_cps_flags (char **str
)
5332 case '\0': case ',':
5335 case 'a': case 'A': saw_a_flag
= 1; val
|= 0x4; break;
5336 case 'i': case 'I': saw_a_flag
= 1; val
|= 0x2; break;
5337 case 'f': case 'F': saw_a_flag
= 1; val
|= 0x1; break;
5340 inst
.error
= _("unrecognized CPS flag");
5345 if (saw_a_flag
== 0)
5347 inst
.error
= _("missing CPS flags");
5355 /* Parse an endian specifier ("BE" or "LE", case insensitive);
5356 returns 0 for big-endian, 1 for little-endian, FAIL for an error. */
5359 parse_endian_specifier (char **str
)
5364 if (strncasecmp (s
, "BE", 2))
5366 else if (strncasecmp (s
, "LE", 2))
5370 inst
.error
= _("valid endian specifiers are be or le");
5374 if (ISALNUM (s
[2]) || s
[2] == '_')
5376 inst
.error
= _("valid endian specifiers are be or le");
5381 return little_endian
;
5384 /* Parse a rotation specifier: ROR #0, #8, #16, #24. *val receives a
5385 value suitable for poking into the rotate field of an sxt or sxta
5386 instruction, or FAIL on error. */
5389 parse_ror (char **str
)
5394 if (strncasecmp (s
, "ROR", 3) == 0)
5398 inst
.error
= _("missing rotation field after comma");
5402 if (parse_immediate (&s
, &rot
, 0, 24, FALSE
) == FAIL
)
5407 case 0: *str
= s
; return 0x0;
5408 case 8: *str
= s
; return 0x1;
5409 case 16: *str
= s
; return 0x2;
5410 case 24: *str
= s
; return 0x3;
5413 inst
.error
= _("rotation can only be 0, 8, 16, or 24");
5418 /* Parse a conditional code (from conds[] below). The value returned is in the
5419 range 0 .. 14, or FAIL. */
5421 parse_cond (char **str
)
5424 const struct asm_cond
*c
;
5426 /* Condition codes are always 2 characters, so matching up to
5427 3 characters is sufficient. */
5432 while (ISALPHA (*q
) && n
< 3)
5434 cond
[n
] = TOLOWER (*q
);
5439 c
= (const struct asm_cond
*) hash_find_n (arm_cond_hsh
, cond
, n
);
5442 inst
.error
= _("condition required");
5450 /* Parse an option for a barrier instruction. Returns the encoding for the
5453 parse_barrier (char **str
)
5456 const struct asm_barrier_opt
*o
;
5459 while (ISALPHA (*q
))
5462 o
= (const struct asm_barrier_opt
*) hash_find_n (arm_barrier_opt_hsh
, p
,
5471 /* Parse the operands of a table branch instruction. Similar to a memory
5474 parse_tb (char **str
)
5479 if (skip_past_char (&p
, '[') == FAIL
)
5481 inst
.error
= _("'[' expected");
5485 if ((reg
= arm_reg_parse (&p
, REG_TYPE_RN
)) == FAIL
)
5487 inst
.error
= _(reg_expected_msgs
[REG_TYPE_RN
]);
5490 inst
.operands
[0].reg
= reg
;
5492 if (skip_past_comma (&p
) == FAIL
)
5494 inst
.error
= _("',' expected");
5498 if ((reg
= arm_reg_parse (&p
, REG_TYPE_RN
)) == FAIL
)
5500 inst
.error
= _(reg_expected_msgs
[REG_TYPE_RN
]);
5503 inst
.operands
[0].imm
= reg
;
5505 if (skip_past_comma (&p
) == SUCCESS
)
5507 if (parse_shift (&p
, 0, SHIFT_LSL_IMMEDIATE
) == FAIL
)
5509 if (inst
.reloc
.exp
.X_add_number
!= 1)
5511 inst
.error
= _("invalid shift");
5514 inst
.operands
[0].shifted
= 1;
5517 if (skip_past_char (&p
, ']') == FAIL
)
5519 inst
.error
= _("']' expected");
5526 /* Parse the operands of a Neon VMOV instruction. See do_neon_mov for more
5527 information on the types the operands can take and how they are encoded.
5528 Up to four operands may be read; this function handles setting the
5529 ".present" field for each read operand itself.
5530 Updates STR and WHICH_OPERAND if parsing is successful and returns SUCCESS,
5531 else returns FAIL. */
5534 parse_neon_mov (char **str
, int *which_operand
)
5536 int i
= *which_operand
, val
;
5537 enum arm_reg_type rtype
;
5539 struct neon_type_el optype
;
5541 if ((val
= parse_scalar (&ptr
, 8, &optype
)) != FAIL
)
5543 /* Case 4: VMOV<c><q>.<size> <Dn[x]>, <Rd>. */
5544 inst
.operands
[i
].reg
= val
;
5545 inst
.operands
[i
].isscalar
= 1;
5546 inst
.operands
[i
].vectype
= optype
;
5547 inst
.operands
[i
++].present
= 1;
5549 if (skip_past_comma (&ptr
) == FAIL
)
5552 if ((val
= arm_reg_parse (&ptr
, REG_TYPE_RN
)) == FAIL
)
5555 inst
.operands
[i
].reg
= val
;
5556 inst
.operands
[i
].isreg
= 1;
5557 inst
.operands
[i
].present
= 1;
5559 else if ((val
= arm_typed_reg_parse (&ptr
, REG_TYPE_NSDQ
, &rtype
, &optype
))
5562 /* Cases 0, 1, 2, 3, 5 (D only). */
5563 if (skip_past_comma (&ptr
) == FAIL
)
5566 inst
.operands
[i
].reg
= val
;
5567 inst
.operands
[i
].isreg
= 1;
5568 inst
.operands
[i
].isquad
= (rtype
== REG_TYPE_NQ
);
5569 inst
.operands
[i
].issingle
= (rtype
== REG_TYPE_VFS
);
5570 inst
.operands
[i
].isvec
= 1;
5571 inst
.operands
[i
].vectype
= optype
;
5572 inst
.operands
[i
++].present
= 1;
5574 if ((val
= arm_reg_parse (&ptr
, REG_TYPE_RN
)) != FAIL
)
5576 /* Case 5: VMOV<c><q> <Dm>, <Rd>, <Rn>.
5577 Case 13: VMOV <Sd>, <Rm> */
5578 inst
.operands
[i
].reg
= val
;
5579 inst
.operands
[i
].isreg
= 1;
5580 inst
.operands
[i
].present
= 1;
5582 if (rtype
== REG_TYPE_NQ
)
5584 first_error (_("can't use Neon quad register here"));
5587 else if (rtype
!= REG_TYPE_VFS
)
5590 if (skip_past_comma (&ptr
) == FAIL
)
5592 if ((val
= arm_reg_parse (&ptr
, REG_TYPE_RN
)) == FAIL
)
5594 inst
.operands
[i
].reg
= val
;
5595 inst
.operands
[i
].isreg
= 1;
5596 inst
.operands
[i
].present
= 1;
5599 else if ((val
= arm_typed_reg_parse (&ptr
, REG_TYPE_NSDQ
, &rtype
,
5602 /* Case 0: VMOV<c><q> <Qd>, <Qm>
5603 Case 1: VMOV<c><q> <Dd>, <Dm>
5604 Case 8: VMOV.F32 <Sd>, <Sm>
5605 Case 15: VMOV <Sd>, <Se>, <Rn>, <Rm> */
5607 inst
.operands
[i
].reg
= val
;
5608 inst
.operands
[i
].isreg
= 1;
5609 inst
.operands
[i
].isquad
= (rtype
== REG_TYPE_NQ
);
5610 inst
.operands
[i
].issingle
= (rtype
== REG_TYPE_VFS
);
5611 inst
.operands
[i
].isvec
= 1;
5612 inst
.operands
[i
].vectype
= optype
;
5613 inst
.operands
[i
].present
= 1;
5615 if (skip_past_comma (&ptr
) == SUCCESS
)
5620 if ((val
= arm_reg_parse (&ptr
, REG_TYPE_RN
)) == FAIL
)
5623 inst
.operands
[i
].reg
= val
;
5624 inst
.operands
[i
].isreg
= 1;
5625 inst
.operands
[i
++].present
= 1;
5627 if (skip_past_comma (&ptr
) == FAIL
)
5630 if ((val
= arm_reg_parse (&ptr
, REG_TYPE_RN
)) == FAIL
)
5633 inst
.operands
[i
].reg
= val
;
5634 inst
.operands
[i
].isreg
= 1;
5635 inst
.operands
[i
++].present
= 1;
5638 else if (parse_qfloat_immediate (&ptr
, &inst
.operands
[i
].imm
) == SUCCESS
)
5639 /* Case 2: VMOV<c><q>.<dt> <Qd>, #<float-imm>
5640 Case 3: VMOV<c><q>.<dt> <Dd>, #<float-imm>
5641 Case 10: VMOV.F32 <Sd>, #<imm>
5642 Case 11: VMOV.F64 <Dd>, #<imm> */
5643 inst
.operands
[i
].immisfloat
= 1;
5644 else if (parse_big_immediate (&ptr
, i
) == SUCCESS
)
5645 /* Case 2: VMOV<c><q>.<dt> <Qd>, #<imm>
5646 Case 3: VMOV<c><q>.<dt> <Dd>, #<imm> */
5650 first_error (_("expected <Rm> or <Dm> or <Qm> operand"));
5654 else if ((val
= arm_reg_parse (&ptr
, REG_TYPE_RN
)) != FAIL
)
5657 inst
.operands
[i
].reg
= val
;
5658 inst
.operands
[i
].isreg
= 1;
5659 inst
.operands
[i
++].present
= 1;
5661 if (skip_past_comma (&ptr
) == FAIL
)
5664 if ((val
= parse_scalar (&ptr
, 8, &optype
)) != FAIL
)
5666 /* Case 6: VMOV<c><q>.<dt> <Rd>, <Dn[x]> */
5667 inst
.operands
[i
].reg
= val
;
5668 inst
.operands
[i
].isscalar
= 1;
5669 inst
.operands
[i
].present
= 1;
5670 inst
.operands
[i
].vectype
= optype
;
5672 else if ((val
= arm_reg_parse (&ptr
, REG_TYPE_RN
)) != FAIL
)
5674 /* Case 7: VMOV<c><q> <Rd>, <Rn>, <Dm> */
5675 inst
.operands
[i
].reg
= val
;
5676 inst
.operands
[i
].isreg
= 1;
5677 inst
.operands
[i
++].present
= 1;
5679 if (skip_past_comma (&ptr
) == FAIL
)
5682 if ((val
= arm_typed_reg_parse (&ptr
, REG_TYPE_VFSD
, &rtype
, &optype
))
5685 first_error (_(reg_expected_msgs
[REG_TYPE_VFSD
]));
5689 inst
.operands
[i
].reg
= val
;
5690 inst
.operands
[i
].isreg
= 1;
5691 inst
.operands
[i
].isvec
= 1;
5692 inst
.operands
[i
].issingle
= (rtype
== REG_TYPE_VFS
);
5693 inst
.operands
[i
].vectype
= optype
;
5694 inst
.operands
[i
].present
= 1;
5696 if (rtype
== REG_TYPE_VFS
)
5700 if (skip_past_comma (&ptr
) == FAIL
)
5702 if ((val
= arm_typed_reg_parse (&ptr
, REG_TYPE_VFS
, NULL
,
5705 first_error (_(reg_expected_msgs
[REG_TYPE_VFS
]));
5708 inst
.operands
[i
].reg
= val
;
5709 inst
.operands
[i
].isreg
= 1;
5710 inst
.operands
[i
].isvec
= 1;
5711 inst
.operands
[i
].issingle
= 1;
5712 inst
.operands
[i
].vectype
= optype
;
5713 inst
.operands
[i
].present
= 1;
5716 else if ((val
= arm_typed_reg_parse (&ptr
, REG_TYPE_VFS
, NULL
, &optype
))
5720 inst
.operands
[i
].reg
= val
;
5721 inst
.operands
[i
].isreg
= 1;
5722 inst
.operands
[i
].isvec
= 1;
5723 inst
.operands
[i
].issingle
= 1;
5724 inst
.operands
[i
].vectype
= optype
;
5725 inst
.operands
[i
++].present
= 1;
5730 first_error (_("parse error"));
5734 /* Successfully parsed the operands. Update args. */
5740 first_error (_("expected comma"));
5744 first_error (_(reg_expected_msgs
[REG_TYPE_RN
]));
5748 /* Use this macro when the operand constraints are different
5749 for ARM and THUMB (e.g. ldrd). */
5750 #define MIX_ARM_THUMB_OPERANDS(arm_operand, thumb_operand) \
5751 ((arm_operand) | ((thumb_operand) << 16))
5753 /* Matcher codes for parse_operands. */
5754 enum operand_parse_code
5756 OP_stop
, /* end of line */
5758 OP_RR
, /* ARM register */
5759 OP_RRnpc
, /* ARM register, not r15 */
5760 OP_RRnpcsp
, /* ARM register, neither r15 nor r13 (a.k.a. 'BadReg') */
5761 OP_RRnpcb
, /* ARM register, not r15, in square brackets */
5762 OP_RRw
, /* ARM register, not r15, optional trailing ! */
5763 OP_RCP
, /* Coprocessor number */
5764 OP_RCN
, /* Coprocessor register */
5765 OP_RF
, /* FPA register */
5766 OP_RVS
, /* VFP single precision register */
5767 OP_RVD
, /* VFP double precision register (0..15) */
5768 OP_RND
, /* Neon double precision register (0..31) */
5769 OP_RNQ
, /* Neon quad precision register */
5770 OP_RVSD
, /* VFP single or double precision register */
5771 OP_RNDQ
, /* Neon double or quad precision register */
5772 OP_RNSDQ
, /* Neon single, double or quad precision register */
5773 OP_RNSC
, /* Neon scalar D[X] */
5774 OP_RVC
, /* VFP control register */
5775 OP_RMF
, /* Maverick F register */
5776 OP_RMD
, /* Maverick D register */
5777 OP_RMFX
, /* Maverick FX register */
5778 OP_RMDX
, /* Maverick DX register */
5779 OP_RMAX
, /* Maverick AX register */
5780 OP_RMDS
, /* Maverick DSPSC register */
5781 OP_RIWR
, /* iWMMXt wR register */
5782 OP_RIWC
, /* iWMMXt wC register */
5783 OP_RIWG
, /* iWMMXt wCG register */
5784 OP_RXA
, /* XScale accumulator register */
5786 OP_REGLST
, /* ARM register list */
5787 OP_VRSLST
, /* VFP single-precision register list */
5788 OP_VRDLST
, /* VFP double-precision register list */
5789 OP_VRSDLST
, /* VFP single or double-precision register list (& quad) */
5790 OP_NRDLST
, /* Neon double-precision register list (d0-d31, qN aliases) */
5791 OP_NSTRLST
, /* Neon element/structure list */
5793 OP_RNDQ_I0
, /* Neon D or Q reg, or immediate zero. */
5794 OP_RVSD_I0
, /* VFP S or D reg, or immediate zero. */
5795 OP_RR_RNSC
, /* ARM reg or Neon scalar. */
5796 OP_RNSDQ_RNSC
, /* Vector S, D or Q reg, or Neon scalar. */
5797 OP_RNDQ_RNSC
, /* Neon D or Q reg, or Neon scalar. */
5798 OP_RND_RNSC
, /* Neon D reg, or Neon scalar. */
5799 OP_VMOV
, /* Neon VMOV operands. */
5800 OP_RNDQ_Ibig
, /* Neon D or Q reg, or big immediate for logic and VMVN. */
5801 OP_RNDQ_I63b
, /* Neon D or Q reg, or immediate for shift. */
5802 OP_RIWR_I32z
, /* iWMMXt wR register, or immediate 0 .. 32 for iWMMXt2. */
5804 OP_I0
, /* immediate zero */
5805 OP_I7
, /* immediate value 0 .. 7 */
5806 OP_I15
, /* 0 .. 15 */
5807 OP_I16
, /* 1 .. 16 */
5808 OP_I16z
, /* 0 .. 16 */
5809 OP_I31
, /* 0 .. 31 */
5810 OP_I31w
, /* 0 .. 31, optional trailing ! */
5811 OP_I32
, /* 1 .. 32 */
5812 OP_I32z
, /* 0 .. 32 */
5813 OP_I63
, /* 0 .. 63 */
5814 OP_I63s
, /* -64 .. 63 */
5815 OP_I64
, /* 1 .. 64 */
5816 OP_I64z
, /* 0 .. 64 */
5817 OP_I255
, /* 0 .. 255 */
5819 OP_I4b
, /* immediate, prefix optional, 1 .. 4 */
5820 OP_I7b
, /* 0 .. 7 */
5821 OP_I15b
, /* 0 .. 15 */
5822 OP_I31b
, /* 0 .. 31 */
5824 OP_SH
, /* shifter operand */
5825 OP_SHG
, /* shifter operand with possible group relocation */
5826 OP_ADDR
, /* Memory address expression (any mode) */
5827 OP_ADDRGLDR
, /* Mem addr expr (any mode) with possible LDR group reloc */
5828 OP_ADDRGLDRS
, /* Mem addr expr (any mode) with possible LDRS group reloc */
5829 OP_ADDRGLDC
, /* Mem addr expr (any mode) with possible LDC group reloc */
5830 OP_EXP
, /* arbitrary expression */
5831 OP_EXPi
, /* same, with optional immediate prefix */
5832 OP_EXPr
, /* same, with optional relocation suffix */
5833 OP_HALF
, /* 0 .. 65535 or low/high reloc. */
5835 OP_CPSF
, /* CPS flags */
5836 OP_ENDI
, /* Endianness specifier */
5837 OP_PSR
, /* CPSR/SPSR mask for msr */
5838 OP_COND
, /* conditional code */
5839 OP_TB
, /* Table branch. */
5841 OP_RVC_PSR
, /* CPSR/SPSR mask for msr, or VFP control register. */
5842 OP_APSR_RR
, /* ARM register or "APSR_nzcv". */
5844 OP_RRnpc_I0
, /* ARM register or literal 0 */
5845 OP_RR_EXr
, /* ARM register or expression with opt. reloc suff. */
5846 OP_RR_EXi
, /* ARM register or expression with imm prefix */
5847 OP_RF_IF
, /* FPA register or immediate */
5848 OP_RIWR_RIWC
, /* iWMMXt R or C reg */
5849 OP_RIWC_RIWG
, /* iWMMXt wC or wCG reg */
5851 /* Optional operands. */
5852 OP_oI7b
, /* immediate, prefix optional, 0 .. 7 */
5853 OP_oI31b
, /* 0 .. 31 */
5854 OP_oI32b
, /* 1 .. 32 */
5855 OP_oIffffb
, /* 0 .. 65535 */
5856 OP_oI255c
, /* curly-brace enclosed, 0 .. 255 */
5858 OP_oRR
, /* ARM register */
5859 OP_oRRnpc
, /* ARM register, not the PC */
5860 OP_oRRnpcsp
, /* ARM register, neither the PC nor the SP (a.k.a. BadReg) */
5861 OP_oRRw
, /* ARM register, not r15, optional trailing ! */
5862 OP_oRND
, /* Optional Neon double precision register */
5863 OP_oRNQ
, /* Optional Neon quad precision register */
5864 OP_oRNDQ
, /* Optional Neon double or quad precision register */
5865 OP_oRNSDQ
, /* Optional single, double or quad precision vector register */
5866 OP_oSHll
, /* LSL immediate */
5867 OP_oSHar
, /* ASR immediate */
5868 OP_oSHllar
, /* LSL or ASR immediate */
5869 OP_oROR
, /* ROR 0/8/16/24 */
5870 OP_oBARRIER
, /* Option argument for a barrier instruction. */
5872 /* Some pre-defined mixed (ARM/THUMB) operands. */
5873 OP_RR_npcsp
= MIX_ARM_THUMB_OPERANDS (OP_RR
, OP_RRnpcsp
),
5874 OP_RRnpc_npcsp
= MIX_ARM_THUMB_OPERANDS (OP_RRnpc
, OP_RRnpcsp
),
5875 OP_oRRnpc_npcsp
= MIX_ARM_THUMB_OPERANDS (OP_oRRnpc
, OP_oRRnpcsp
),
5877 OP_FIRST_OPTIONAL
= OP_oI7b
5880 /* Generic instruction operand parser. This does no encoding and no
5881 semantic validation; it merely squirrels values away in the inst
5882 structure. Returns SUCCESS or FAIL depending on whether the
5883 specified grammar matched. */
5885 parse_operands (char *str
, const unsigned int *pattern
, bfd_boolean thumb
)
5887 unsigned const int *upat
= pattern
;
5888 char *backtrack_pos
= 0;
5889 const char *backtrack_error
= 0;
5890 int i
, val
, backtrack_index
= 0;
5891 enum arm_reg_type rtype
;
5892 parse_operand_result result
;
5893 unsigned int op_parse_code
;
5895 #define po_char_or_fail(chr) \
5898 if (skip_past_char (&str, chr) == FAIL) \
5903 #define po_reg_or_fail(regtype) \
5906 val = arm_typed_reg_parse (& str, regtype, & rtype, \
5907 & inst.operands[i].vectype); \
5910 first_error (_(reg_expected_msgs[regtype])); \
5913 inst.operands[i].reg = val; \
5914 inst.operands[i].isreg = 1; \
5915 inst.operands[i].isquad = (rtype == REG_TYPE_NQ); \
5916 inst.operands[i].issingle = (rtype == REG_TYPE_VFS); \
5917 inst.operands[i].isvec = (rtype == REG_TYPE_VFS \
5918 || rtype == REG_TYPE_VFD \
5919 || rtype == REG_TYPE_NQ); \
5923 #define po_reg_or_goto(regtype, label) \
5926 val = arm_typed_reg_parse (& str, regtype, & rtype, \
5927 & inst.operands[i].vectype); \
5931 inst.operands[i].reg = val; \
5932 inst.operands[i].isreg = 1; \
5933 inst.operands[i].isquad = (rtype == REG_TYPE_NQ); \
5934 inst.operands[i].issingle = (rtype == REG_TYPE_VFS); \
5935 inst.operands[i].isvec = (rtype == REG_TYPE_VFS \
5936 || rtype == REG_TYPE_VFD \
5937 || rtype == REG_TYPE_NQ); \
5941 #define po_imm_or_fail(min, max, popt) \
5944 if (parse_immediate (&str, &val, min, max, popt) == FAIL) \
5946 inst.operands[i].imm = val; \
5950 #define po_scalar_or_goto(elsz, label) \
5953 val = parse_scalar (& str, elsz, & inst.operands[i].vectype); \
5956 inst.operands[i].reg = val; \
5957 inst.operands[i].isscalar = 1; \
5961 #define po_misc_or_fail(expr) \
5969 #define po_misc_or_fail_no_backtrack(expr) \
5973 if (result == PARSE_OPERAND_FAIL_NO_BACKTRACK) \
5974 backtrack_pos = 0; \
5975 if (result != PARSE_OPERAND_SUCCESS) \
5980 skip_whitespace (str
);
5982 for (i
= 0; upat
[i
] != OP_stop
; i
++)
5984 op_parse_code
= upat
[i
];
5985 if (op_parse_code
>= 1<<16)
5986 op_parse_code
= thumb
? (op_parse_code
>> 16)
5987 : (op_parse_code
& ((1<<16)-1));
5989 if (op_parse_code
>= OP_FIRST_OPTIONAL
)
5991 /* Remember where we are in case we need to backtrack. */
5992 gas_assert (!backtrack_pos
);
5993 backtrack_pos
= str
;
5994 backtrack_error
= inst
.error
;
5995 backtrack_index
= i
;
5998 if (i
> 0 && (i
> 1 || inst
.operands
[0].present
))
5999 po_char_or_fail (',');
6001 switch (op_parse_code
)
6009 case OP_RR
: po_reg_or_fail (REG_TYPE_RN
); break;
6010 case OP_RCP
: po_reg_or_fail (REG_TYPE_CP
); break;
6011 case OP_RCN
: po_reg_or_fail (REG_TYPE_CN
); break;
6012 case OP_RF
: po_reg_or_fail (REG_TYPE_FN
); break;
6013 case OP_RVS
: po_reg_or_fail (REG_TYPE_VFS
); break;
6014 case OP_RVD
: po_reg_or_fail (REG_TYPE_VFD
); break;
6016 case OP_RND
: po_reg_or_fail (REG_TYPE_VFD
); break;
6018 po_reg_or_goto (REG_TYPE_VFC
, coproc_reg
);
6020 /* Also accept generic coprocessor regs for unknown registers. */
6022 po_reg_or_fail (REG_TYPE_CN
);
6024 case OP_RMF
: po_reg_or_fail (REG_TYPE_MVF
); break;
6025 case OP_RMD
: po_reg_or_fail (REG_TYPE_MVD
); break;
6026 case OP_RMFX
: po_reg_or_fail (REG_TYPE_MVFX
); break;
6027 case OP_RMDX
: po_reg_or_fail (REG_TYPE_MVDX
); break;
6028 case OP_RMAX
: po_reg_or_fail (REG_TYPE_MVAX
); break;
6029 case OP_RMDS
: po_reg_or_fail (REG_TYPE_DSPSC
); break;
6030 case OP_RIWR
: po_reg_or_fail (REG_TYPE_MMXWR
); break;
6031 case OP_RIWC
: po_reg_or_fail (REG_TYPE_MMXWC
); break;
6032 case OP_RIWG
: po_reg_or_fail (REG_TYPE_MMXWCG
); break;
6033 case OP_RXA
: po_reg_or_fail (REG_TYPE_XSCALE
); break;
6035 case OP_RNQ
: po_reg_or_fail (REG_TYPE_NQ
); break;
6037 case OP_RNDQ
: po_reg_or_fail (REG_TYPE_NDQ
); break;
6038 case OP_RVSD
: po_reg_or_fail (REG_TYPE_VFSD
); break;
6040 case OP_RNSDQ
: po_reg_or_fail (REG_TYPE_NSDQ
); break;
6042 /* Neon scalar. Using an element size of 8 means that some invalid
6043 scalars are accepted here, so deal with those in later code. */
6044 case OP_RNSC
: po_scalar_or_goto (8, failure
); break;
6048 po_reg_or_goto (REG_TYPE_NDQ
, try_imm0
);
6051 po_imm_or_fail (0, 0, TRUE
);
6056 po_reg_or_goto (REG_TYPE_VFSD
, try_imm0
);
6061 po_scalar_or_goto (8, try_rr
);
6064 po_reg_or_fail (REG_TYPE_RN
);
6070 po_scalar_or_goto (8, try_nsdq
);
6073 po_reg_or_fail (REG_TYPE_NSDQ
);
6079 po_scalar_or_goto (8, try_ndq
);
6082 po_reg_or_fail (REG_TYPE_NDQ
);
6088 po_scalar_or_goto (8, try_vfd
);
6091 po_reg_or_fail (REG_TYPE_VFD
);
6096 /* WARNING: parse_neon_mov can move the operand counter, i. If we're
6097 not careful then bad things might happen. */
6098 po_misc_or_fail (parse_neon_mov (&str
, &i
) == FAIL
);
6103 po_reg_or_goto (REG_TYPE_NDQ
, try_immbig
);
6106 /* There's a possibility of getting a 64-bit immediate here, so
6107 we need special handling. */
6108 if (parse_big_immediate (&str
, i
) == FAIL
)
6110 inst
.error
= _("immediate value is out of range");
6118 po_reg_or_goto (REG_TYPE_NDQ
, try_shimm
);
6121 po_imm_or_fail (0, 63, TRUE
);
6126 po_char_or_fail ('[');
6127 po_reg_or_fail (REG_TYPE_RN
);
6128 po_char_or_fail (']');
6133 po_reg_or_fail (REG_TYPE_RN
);
6134 if (skip_past_char (&str
, '!') == SUCCESS
)
6135 inst
.operands
[i
].writeback
= 1;
6139 case OP_I7
: po_imm_or_fail ( 0, 7, FALSE
); break;
6140 case OP_I15
: po_imm_or_fail ( 0, 15, FALSE
); break;
6141 case OP_I16
: po_imm_or_fail ( 1, 16, FALSE
); break;
6142 case OP_I16z
: po_imm_or_fail ( 0, 16, FALSE
); break;
6143 case OP_I31
: po_imm_or_fail ( 0, 31, FALSE
); break;
6144 case OP_I32
: po_imm_or_fail ( 1, 32, FALSE
); break;
6145 case OP_I32z
: po_imm_or_fail ( 0, 32, FALSE
); break;
6146 case OP_I63s
: po_imm_or_fail (-64, 63, FALSE
); break;
6147 case OP_I63
: po_imm_or_fail ( 0, 63, FALSE
); break;
6148 case OP_I64
: po_imm_or_fail ( 1, 64, FALSE
); break;
6149 case OP_I64z
: po_imm_or_fail ( 0, 64, FALSE
); break;
6150 case OP_I255
: po_imm_or_fail ( 0, 255, FALSE
); break;
6152 case OP_I4b
: po_imm_or_fail ( 1, 4, TRUE
); break;
6154 case OP_I7b
: po_imm_or_fail ( 0, 7, TRUE
); break;
6155 case OP_I15b
: po_imm_or_fail ( 0, 15, TRUE
); break;
6157 case OP_I31b
: po_imm_or_fail ( 0, 31, TRUE
); break;
6158 case OP_oI32b
: po_imm_or_fail ( 1, 32, TRUE
); break;
6159 case OP_oIffffb
: po_imm_or_fail ( 0, 0xffff, TRUE
); break;
6161 /* Immediate variants */
6163 po_char_or_fail ('{');
6164 po_imm_or_fail (0, 255, TRUE
);
6165 po_char_or_fail ('}');
6169 /* The expression parser chokes on a trailing !, so we have
6170 to find it first and zap it. */
6173 while (*s
&& *s
!= ',')
6178 inst
.operands
[i
].writeback
= 1;
6180 po_imm_or_fail (0, 31, TRUE
);
6188 po_misc_or_fail (my_get_expression (&inst
.reloc
.exp
, &str
,
6193 po_misc_or_fail (my_get_expression (&inst
.reloc
.exp
, &str
,
6198 po_misc_or_fail (my_get_expression (&inst
.reloc
.exp
, &str
,
6200 if (inst
.reloc
.exp
.X_op
== O_symbol
)
6202 val
= parse_reloc (&str
);
6205 inst
.error
= _("unrecognized relocation suffix");
6208 else if (val
!= BFD_RELOC_UNUSED
)
6210 inst
.operands
[i
].imm
= val
;
6211 inst
.operands
[i
].hasreloc
= 1;
6216 /* Operand for MOVW or MOVT. */
6218 po_misc_or_fail (parse_half (&str
));
6221 /* Register or expression. */
6222 case OP_RR_EXr
: po_reg_or_goto (REG_TYPE_RN
, EXPr
); break;
6223 case OP_RR_EXi
: po_reg_or_goto (REG_TYPE_RN
, EXPi
); break;
6225 /* Register or immediate. */
6226 case OP_RRnpc_I0
: po_reg_or_goto (REG_TYPE_RN
, I0
); break;
6227 I0
: po_imm_or_fail (0, 0, FALSE
); break;
6229 case OP_RF_IF
: po_reg_or_goto (REG_TYPE_FN
, IF
); break;
6231 if (!is_immediate_prefix (*str
))
6234 val
= parse_fpa_immediate (&str
);
6237 /* FPA immediates are encoded as registers 8-15.
6238 parse_fpa_immediate has already applied the offset. */
6239 inst
.operands
[i
].reg
= val
;
6240 inst
.operands
[i
].isreg
= 1;
6243 case OP_RIWR_I32z
: po_reg_or_goto (REG_TYPE_MMXWR
, I32z
); break;
6244 I32z
: po_imm_or_fail (0, 32, FALSE
); break;
6246 /* Two kinds of register. */
6249 struct reg_entry
*rege
= arm_reg_parse_multi (&str
);
6251 || (rege
->type
!= REG_TYPE_MMXWR
6252 && rege
->type
!= REG_TYPE_MMXWC
6253 && rege
->type
!= REG_TYPE_MMXWCG
))
6255 inst
.error
= _("iWMMXt data or control register expected");
6258 inst
.operands
[i
].reg
= rege
->number
;
6259 inst
.operands
[i
].isreg
= (rege
->type
== REG_TYPE_MMXWR
);
6265 struct reg_entry
*rege
= arm_reg_parse_multi (&str
);
6267 || (rege
->type
!= REG_TYPE_MMXWC
6268 && rege
->type
!= REG_TYPE_MMXWCG
))
6270 inst
.error
= _("iWMMXt control register expected");
6273 inst
.operands
[i
].reg
= rege
->number
;
6274 inst
.operands
[i
].isreg
= 1;
6279 case OP_CPSF
: val
= parse_cps_flags (&str
); break;
6280 case OP_ENDI
: val
= parse_endian_specifier (&str
); break;
6281 case OP_oROR
: val
= parse_ror (&str
); break;
6282 case OP_PSR
: val
= parse_psr (&str
); break;
6283 case OP_COND
: val
= parse_cond (&str
); break;
6284 case OP_oBARRIER
:val
= parse_barrier (&str
); break;
6287 po_reg_or_goto (REG_TYPE_VFC
, try_psr
);
6288 inst
.operands
[i
].isvec
= 1; /* Mark VFP control reg as vector. */
6291 val
= parse_psr (&str
);
6295 po_reg_or_goto (REG_TYPE_RN
, try_apsr
);
6298 /* Parse "APSR_nvzc" operand (for FMSTAT-equivalent MRS
6300 if (strncasecmp (str
, "APSR_", 5) == 0)
6307 case 'c': found
= (found
& 1) ? 16 : found
| 1; break;
6308 case 'n': found
= (found
& 2) ? 16 : found
| 2; break;
6309 case 'z': found
= (found
& 4) ? 16 : found
| 4; break;
6310 case 'v': found
= (found
& 8) ? 16 : found
| 8; break;
6311 default: found
= 16;
6315 inst
.operands
[i
].isvec
= 1;
6316 /* APSR_nzcv is encoded in instructions as if it were the REG_PC. */
6317 inst
.operands
[i
].reg
= REG_PC
;
6324 po_misc_or_fail (parse_tb (&str
));
6327 /* Register lists. */
6329 val
= parse_reg_list (&str
);
6332 inst
.operands
[1].writeback
= 1;
6338 val
= parse_vfp_reg_list (&str
, &inst
.operands
[i
].reg
, REGLIST_VFP_S
);
6342 val
= parse_vfp_reg_list (&str
, &inst
.operands
[i
].reg
, REGLIST_VFP_D
);
6346 /* Allow Q registers too. */
6347 val
= parse_vfp_reg_list (&str
, &inst
.operands
[i
].reg
,
6352 val
= parse_vfp_reg_list (&str
, &inst
.operands
[i
].reg
,
6354 inst
.operands
[i
].issingle
= 1;
6359 val
= parse_vfp_reg_list (&str
, &inst
.operands
[i
].reg
,
6364 val
= parse_neon_el_struct_list (&str
, &inst
.operands
[i
].reg
,
6365 &inst
.operands
[i
].vectype
);
6368 /* Addressing modes */
6370 po_misc_or_fail (parse_address (&str
, i
));
6374 po_misc_or_fail_no_backtrack (
6375 parse_address_group_reloc (&str
, i
, GROUP_LDR
));
6379 po_misc_or_fail_no_backtrack (
6380 parse_address_group_reloc (&str
, i
, GROUP_LDRS
));
6384 po_misc_or_fail_no_backtrack (
6385 parse_address_group_reloc (&str
, i
, GROUP_LDC
));
6389 po_misc_or_fail (parse_shifter_operand (&str
, i
));
6393 po_misc_or_fail_no_backtrack (
6394 parse_shifter_operand_group_reloc (&str
, i
));
6398 po_misc_or_fail (parse_shift (&str
, i
, SHIFT_LSL_IMMEDIATE
));
6402 po_misc_or_fail (parse_shift (&str
, i
, SHIFT_ASR_IMMEDIATE
));
6406 po_misc_or_fail (parse_shift (&str
, i
, SHIFT_LSL_OR_ASR_IMMEDIATE
));
6410 as_fatal (_("unhandled operand code %d"), op_parse_code
);
6413 /* Various value-based sanity checks and shared operations. We
6414 do not signal immediate failures for the register constraints;
6415 this allows a syntax error to take precedence. */
6416 switch (op_parse_code
)
6424 if (inst
.operands
[i
].isreg
&& inst
.operands
[i
].reg
== REG_PC
)
6425 inst
.error
= BAD_PC
;
6430 if (inst
.operands
[i
].isreg
)
6432 if (inst
.operands
[i
].reg
== REG_PC
)
6433 inst
.error
= BAD_PC
;
6434 else if (inst
.operands
[i
].reg
== REG_SP
)
6435 inst
.error
= BAD_SP
;
6454 inst
.operands
[i
].imm
= val
;
6461 /* If we get here, this operand was successfully parsed. */
6462 inst
.operands
[i
].present
= 1;
6466 inst
.error
= BAD_ARGS
;
6471 /* The parse routine should already have set inst.error, but set a
6472 default here just in case. */
6474 inst
.error
= _("syntax error");
6478 /* Do not backtrack over a trailing optional argument that
6479 absorbed some text. We will only fail again, with the
6480 'garbage following instruction' error message, which is
6481 probably less helpful than the current one. */
6482 if (backtrack_index
== i
&& backtrack_pos
!= str
6483 && upat
[i
+1] == OP_stop
)
6486 inst
.error
= _("syntax error");
6490 /* Try again, skipping the optional argument at backtrack_pos. */
6491 str
= backtrack_pos
;
6492 inst
.error
= backtrack_error
;
6493 inst
.operands
[backtrack_index
].present
= 0;
6494 i
= backtrack_index
;
6498 /* Check that we have parsed all the arguments. */
6499 if (*str
!= '\0' && !inst
.error
)
6500 inst
.error
= _("garbage following instruction");
6502 return inst
.error
? FAIL
: SUCCESS
;
6505 #undef po_char_or_fail
6506 #undef po_reg_or_fail
6507 #undef po_reg_or_goto
6508 #undef po_imm_or_fail
6509 #undef po_scalar_or_fail
6511 /* Shorthand macro for instruction encoding functions issuing errors. */
6512 #define constraint(expr, err) \
6523 /* Reject "bad registers" for Thumb-2 instructions. Many Thumb-2
6524 instructions are unpredictable if these registers are used. This
6525 is the BadReg predicate in ARM's Thumb-2 documentation. */
6526 #define reject_bad_reg(reg) \
6528 if (reg == REG_SP || reg == REG_PC) \
6530 inst.error = (reg == REG_SP) ? BAD_SP : BAD_PC; \
6535 /* If REG is R13 (the stack pointer), warn that its use is
6537 #define warn_deprecated_sp(reg) \
6539 if (warn_on_deprecated && reg == REG_SP) \
6540 as_warn (_("use of r13 is deprecated")); \
6543 /* Functions for operand encoding. ARM, then Thumb. */
6545 #define rotate_left(v, n) (v << n | v >> (32 - n))
6547 /* If VAL can be encoded in the immediate field of an ARM instruction,
6548 return the encoded form. Otherwise, return FAIL. */
6551 encode_arm_immediate (unsigned int val
)
6555 for (i
= 0; i
< 32; i
+= 2)
6556 if ((a
= rotate_left (val
, i
)) <= 0xff)
6557 return a
| (i
<< 7); /* 12-bit pack: [shift-cnt,const]. */
6562 /* If VAL can be encoded in the immediate field of a Thumb32 instruction,
6563 return the encoded form. Otherwise, return FAIL. */
6565 encode_thumb32_immediate (unsigned int val
)
6572 for (i
= 1; i
<= 24; i
++)
6575 if ((val
& ~(0xff << i
)) == 0)
6576 return ((val
>> i
) & 0x7f) | ((32 - i
) << 7);
6580 if (val
== ((a
<< 16) | a
))
6582 if (val
== ((a
<< 24) | (a
<< 16) | (a
<< 8) | a
))
6586 if (val
== ((a
<< 16) | a
))
6587 return 0x200 | (a
>> 8);
6591 /* Encode a VFP SP or DP register number into inst.instruction. */
6594 encode_arm_vfp_reg (int reg
, enum vfp_reg_pos pos
)
6596 if ((pos
== VFP_REG_Dd
|| pos
== VFP_REG_Dn
|| pos
== VFP_REG_Dm
)
6599 if (ARM_CPU_HAS_FEATURE (cpu_variant
, fpu_vfp_ext_d32
))
6602 ARM_MERGE_FEATURE_SETS (thumb_arch_used
, thumb_arch_used
,
6605 ARM_MERGE_FEATURE_SETS (arm_arch_used
, arm_arch_used
,
6610 first_error (_("D register out of range for selected VFP version"));
6618 inst
.instruction
|= ((reg
>> 1) << 12) | ((reg
& 1) << 22);
6622 inst
.instruction
|= ((reg
>> 1) << 16) | ((reg
& 1) << 7);
6626 inst
.instruction
|= ((reg
>> 1) << 0) | ((reg
& 1) << 5);
6630 inst
.instruction
|= ((reg
& 15) << 12) | ((reg
>> 4) << 22);
6634 inst
.instruction
|= ((reg
& 15) << 16) | ((reg
>> 4) << 7);
6638 inst
.instruction
|= (reg
& 15) | ((reg
>> 4) << 5);
6646 /* Encode a <shift> in an ARM-format instruction. The immediate,
6647 if any, is handled by md_apply_fix. */
6649 encode_arm_shift (int i
)
6651 if (inst
.operands
[i
].shift_kind
== SHIFT_RRX
)
6652 inst
.instruction
|= SHIFT_ROR
<< 5;
6655 inst
.instruction
|= inst
.operands
[i
].shift_kind
<< 5;
6656 if (inst
.operands
[i
].immisreg
)
6658 inst
.instruction
|= SHIFT_BY_REG
;
6659 inst
.instruction
|= inst
.operands
[i
].imm
<< 8;
6662 inst
.reloc
.type
= BFD_RELOC_ARM_SHIFT_IMM
;
6667 encode_arm_shifter_operand (int i
)
6669 if (inst
.operands
[i
].isreg
)
6671 inst
.instruction
|= inst
.operands
[i
].reg
;
6672 encode_arm_shift (i
);
6675 inst
.instruction
|= INST_IMMEDIATE
;
6678 /* Subroutine of encode_arm_addr_mode_2 and encode_arm_addr_mode_3. */
6680 encode_arm_addr_mode_common (int i
, bfd_boolean is_t
)
6682 gas_assert (inst
.operands
[i
].isreg
);
6683 inst
.instruction
|= inst
.operands
[i
].reg
<< 16;
6685 if (inst
.operands
[i
].preind
)
6689 inst
.error
= _("instruction does not accept preindexed addressing");
6692 inst
.instruction
|= PRE_INDEX
;
6693 if (inst
.operands
[i
].writeback
)
6694 inst
.instruction
|= WRITE_BACK
;
6697 else if (inst
.operands
[i
].postind
)
6699 gas_assert (inst
.operands
[i
].writeback
);
6701 inst
.instruction
|= WRITE_BACK
;
6703 else /* unindexed - only for coprocessor */
6705 inst
.error
= _("instruction does not accept unindexed addressing");
6709 if (((inst
.instruction
& WRITE_BACK
) || !(inst
.instruction
& PRE_INDEX
))
6710 && (((inst
.instruction
& 0x000f0000) >> 16)
6711 == ((inst
.instruction
& 0x0000f000) >> 12)))
6712 as_warn ((inst
.instruction
& LOAD_BIT
)
6713 ? _("destination register same as write-back base")
6714 : _("source register same as write-back base"));
6717 /* inst.operands[i] was set up by parse_address. Encode it into an
6718 ARM-format mode 2 load or store instruction. If is_t is true,
6719 reject forms that cannot be used with a T instruction (i.e. not
6722 encode_arm_addr_mode_2 (int i
, bfd_boolean is_t
)
6724 const bfd_boolean is_pc
= (inst
.operands
[i
].reg
== REG_PC
);
6726 encode_arm_addr_mode_common (i
, is_t
);
6728 if (inst
.operands
[i
].immisreg
)
6730 constraint ((inst
.operands
[i
].imm
== REG_PC
6731 || (is_pc
&& inst
.operands
[i
].writeback
)),
6733 inst
.instruction
|= INST_IMMEDIATE
; /* yes, this is backwards */
6734 inst
.instruction
|= inst
.operands
[i
].imm
;
6735 if (!inst
.operands
[i
].negative
)
6736 inst
.instruction
|= INDEX_UP
;
6737 if (inst
.operands
[i
].shifted
)
6739 if (inst
.operands
[i
].shift_kind
== SHIFT_RRX
)
6740 inst
.instruction
|= SHIFT_ROR
<< 5;
6743 inst
.instruction
|= inst
.operands
[i
].shift_kind
<< 5;
6744 inst
.reloc
.type
= BFD_RELOC_ARM_SHIFT_IMM
;
6748 else /* immediate offset in inst.reloc */
6750 if (is_pc
&& !inst
.reloc
.pc_rel
)
6752 const bfd_boolean is_load
= ((inst
.instruction
& LOAD_BIT
) != 0);
6753 /* BAD_PC_ADDRESSING Condition =
6755 which becomes !is_load || is_t. */
6756 constraint ((!is_load
|| is_t
),
6760 if (inst
.reloc
.type
== BFD_RELOC_UNUSED
)
6761 inst
.reloc
.type
= BFD_RELOC_ARM_OFFSET_IMM
;
6765 /* inst.operands[i] was set up by parse_address. Encode it into an
6766 ARM-format mode 3 load or store instruction. Reject forms that
6767 cannot be used with such instructions. If is_t is true, reject
6768 forms that cannot be used with a T instruction (i.e. not
6771 encode_arm_addr_mode_3 (int i
, bfd_boolean is_t
)
6773 if (inst
.operands
[i
].immisreg
&& inst
.operands
[i
].shifted
)
6775 inst
.error
= _("instruction does not accept scaled register index");
6779 encode_arm_addr_mode_common (i
, is_t
);
6781 if (inst
.operands
[i
].immisreg
)
6783 constraint ((inst
.operands
[i
].imm
== REG_PC
6784 || inst
.operands
[i
].reg
== REG_PC
),
6786 inst
.instruction
|= inst
.operands
[i
].imm
;
6787 if (!inst
.operands
[i
].negative
)
6788 inst
.instruction
|= INDEX_UP
;
6790 else /* immediate offset in inst.reloc */
6792 constraint ((inst
.operands
[i
].reg
== REG_PC
&& !inst
.reloc
.pc_rel
6793 && inst
.operands
[i
].writeback
),
6795 inst
.instruction
|= HWOFFSET_IMM
;
6796 if (inst
.reloc
.type
== BFD_RELOC_UNUSED
)
6797 inst
.reloc
.type
= BFD_RELOC_ARM_OFFSET_IMM8
;
6801 /* inst.operands[i] was set up by parse_address. Encode it into an
6802 ARM-format instruction. Reject all forms which cannot be encoded
6803 into a coprocessor load/store instruction. If wb_ok is false,
6804 reject use of writeback; if unind_ok is false, reject use of
6805 unindexed addressing. If reloc_override is not 0, use it instead
6806 of BFD_ARM_CP_OFF_IMM, unless the initial relocation is a group one
6807 (in which case it is preserved). */
6810 encode_arm_cp_address (int i
, int wb_ok
, int unind_ok
, int reloc_override
)
6812 inst
.instruction
|= inst
.operands
[i
].reg
<< 16;
6814 gas_assert (!(inst
.operands
[i
].preind
&& inst
.operands
[i
].postind
));
6816 if (!inst
.operands
[i
].preind
&& !inst
.operands
[i
].postind
) /* unindexed */
6818 gas_assert (!inst
.operands
[i
].writeback
);
6821 inst
.error
= _("instruction does not support unindexed addressing");
6824 inst
.instruction
|= inst
.operands
[i
].imm
;
6825 inst
.instruction
|= INDEX_UP
;
6829 if (inst
.operands
[i
].preind
)
6830 inst
.instruction
|= PRE_INDEX
;
6832 if (inst
.operands
[i
].writeback
)
6834 if (inst
.operands
[i
].reg
== REG_PC
)
6836 inst
.error
= _("pc may not be used with write-back");
6841 inst
.error
= _("instruction does not support writeback");
6844 inst
.instruction
|= WRITE_BACK
;
6848 inst
.reloc
.type
= (bfd_reloc_code_real_type
) reloc_override
;
6849 else if ((inst
.reloc
.type
< BFD_RELOC_ARM_ALU_PC_G0_NC
6850 || inst
.reloc
.type
> BFD_RELOC_ARM_LDC_SB_G2
)
6851 && inst
.reloc
.type
!= BFD_RELOC_ARM_LDR_PC_G0
)
6854 inst
.reloc
.type
= BFD_RELOC_ARM_T32_CP_OFF_IMM
;
6856 inst
.reloc
.type
= BFD_RELOC_ARM_CP_OFF_IMM
;
6862 /* inst.reloc.exp describes an "=expr" load pseudo-operation.
6863 Determine whether it can be performed with a move instruction; if
6864 it can, convert inst.instruction to that move instruction and
6865 return TRUE; if it can't, convert inst.instruction to a literal-pool
6866 load and return FALSE. If this is not a valid thing to do in the
6867 current context, set inst.error and return TRUE.
6869 inst.operands[i] describes the destination register. */
6872 move_or_literal_pool (int i
, bfd_boolean thumb_p
, bfd_boolean mode_3
)
6877 tbit
= (inst
.instruction
> 0xffff) ? THUMB2_LOAD_BIT
: THUMB_LOAD_BIT
;
6881 if ((inst
.instruction
& tbit
) == 0)
6883 inst
.error
= _("invalid pseudo operation");
6886 if (inst
.reloc
.exp
.X_op
!= O_constant
&& inst
.reloc
.exp
.X_op
!= O_symbol
)
6888 inst
.error
= _("constant expression expected");
6891 if (inst
.reloc
.exp
.X_op
== O_constant
)
6895 if (!unified_syntax
&& (inst
.reloc
.exp
.X_add_number
& ~0xFF) == 0)
6897 /* This can be done with a mov(1) instruction. */
6898 inst
.instruction
= T_OPCODE_MOV_I8
| (inst
.operands
[i
].reg
<< 8);
6899 inst
.instruction
|= inst
.reloc
.exp
.X_add_number
;
6905 int value
= encode_arm_immediate (inst
.reloc
.exp
.X_add_number
);
6908 /* This can be done with a mov instruction. */
6909 inst
.instruction
&= LITERAL_MASK
;
6910 inst
.instruction
|= INST_IMMEDIATE
| (OPCODE_MOV
<< DATA_OP_SHIFT
);
6911 inst
.instruction
|= value
& 0xfff;
6915 value
= encode_arm_immediate (~inst
.reloc
.exp
.X_add_number
);
6918 /* This can be done with a mvn instruction. */
6919 inst
.instruction
&= LITERAL_MASK
;
6920 inst
.instruction
|= INST_IMMEDIATE
| (OPCODE_MVN
<< DATA_OP_SHIFT
);
6921 inst
.instruction
|= value
& 0xfff;
6927 if (add_to_lit_pool () == FAIL
)
6929 inst
.error
= _("literal pool insertion failed");
6932 inst
.operands
[1].reg
= REG_PC
;
6933 inst
.operands
[1].isreg
= 1;
6934 inst
.operands
[1].preind
= 1;
6935 inst
.reloc
.pc_rel
= 1;
6936 inst
.reloc
.type
= (thumb_p
6937 ? BFD_RELOC_ARM_THUMB_OFFSET
6939 ? BFD_RELOC_ARM_HWLITERAL
6940 : BFD_RELOC_ARM_LITERAL
));
6944 /* Functions for instruction encoding, sorted by sub-architecture.
6945 First some generics; their names are taken from the conventional
6946 bit positions for register arguments in ARM format instructions. */
6956 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
6962 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
6963 inst
.instruction
|= inst
.operands
[1].reg
;
6969 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
6970 inst
.instruction
|= inst
.operands
[1].reg
<< 16;
6976 inst
.instruction
|= inst
.operands
[0].reg
<< 16;
6977 inst
.instruction
|= inst
.operands
[1].reg
<< 12;
6983 unsigned Rn
= inst
.operands
[2].reg
;
6984 /* Enforce restrictions on SWP instruction. */
6985 if ((inst
.instruction
& 0x0fbfffff) == 0x01000090)
6987 constraint (Rn
== inst
.operands
[0].reg
|| Rn
== inst
.operands
[1].reg
,
6988 _("Rn must not overlap other operands"));
6990 /* SWP{b} is deprecated for ARMv6* and ARMv7. */
6991 if (warn_on_deprecated
6992 && ARM_CPU_HAS_FEATURE (selected_cpu
, arm_ext_v6
))
6993 as_warn (_("swp{b} use is deprecated for this architecture"));
6996 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
6997 inst
.instruction
|= inst
.operands
[1].reg
;
6998 inst
.instruction
|= Rn
<< 16;
7004 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
7005 inst
.instruction
|= inst
.operands
[1].reg
<< 16;
7006 inst
.instruction
|= inst
.operands
[2].reg
;
7012 constraint ((inst
.operands
[2].reg
== REG_PC
), BAD_PC
);
7013 constraint (((inst
.reloc
.exp
.X_op
!= O_constant
7014 && inst
.reloc
.exp
.X_op
!= O_illegal
)
7015 || inst
.reloc
.exp
.X_add_number
!= 0),
7017 inst
.instruction
|= inst
.operands
[0].reg
;
7018 inst
.instruction
|= inst
.operands
[1].reg
<< 12;
7019 inst
.instruction
|= inst
.operands
[2].reg
<< 16;
7025 inst
.instruction
|= inst
.operands
[0].imm
;
7031 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
7032 encode_arm_cp_address (1, TRUE
, TRUE
, 0);
7035 /* ARM instructions, in alphabetical order by function name (except
7036 that wrapper functions appear immediately after the function they
7039 /* This is a pseudo-op of the form "adr rd, label" to be converted
7040 into a relative address of the form "add rd, pc, #label-.-8". */
7045 inst
.instruction
|= (inst
.operands
[0].reg
<< 12); /* Rd */
7047 /* Frag hacking will turn this into a sub instruction if the offset turns
7048 out to be negative. */
7049 inst
.reloc
.type
= BFD_RELOC_ARM_IMMEDIATE
;
7050 inst
.reloc
.pc_rel
= 1;
7051 inst
.reloc
.exp
.X_add_number
-= 8;
7054 /* This is a pseudo-op of the form "adrl rd, label" to be converted
7055 into a relative address of the form:
7056 add rd, pc, #low(label-.-8)"
7057 add rd, rd, #high(label-.-8)" */
7062 inst
.instruction
|= (inst
.operands
[0].reg
<< 12); /* Rd */
7064 /* Frag hacking will turn this into a sub instruction if the offset turns
7065 out to be negative. */
7066 inst
.reloc
.type
= BFD_RELOC_ARM_ADRL_IMMEDIATE
;
7067 inst
.reloc
.pc_rel
= 1;
7068 inst
.size
= INSN_SIZE
* 2;
7069 inst
.reloc
.exp
.X_add_number
-= 8;
7075 if (!inst
.operands
[1].present
)
7076 inst
.operands
[1].reg
= inst
.operands
[0].reg
;
7077 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
7078 inst
.instruction
|= inst
.operands
[1].reg
<< 16;
7079 encode_arm_shifter_operand (2);
7085 if (inst
.operands
[0].present
)
7087 constraint ((inst
.instruction
& 0xf0) != 0x40
7088 && inst
.operands
[0].imm
!= 0xf,
7089 _("bad barrier type"));
7090 inst
.instruction
|= inst
.operands
[0].imm
;
7093 inst
.instruction
|= 0xf;
7099 unsigned int msb
= inst
.operands
[1].imm
+ inst
.operands
[2].imm
;
7100 constraint (msb
> 32, _("bit-field extends past end of register"));
7101 /* The instruction encoding stores the LSB and MSB,
7102 not the LSB and width. */
7103 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
7104 inst
.instruction
|= inst
.operands
[1].imm
<< 7;
7105 inst
.instruction
|= (msb
- 1) << 16;
7113 /* #0 in second position is alternative syntax for bfc, which is
7114 the same instruction but with REG_PC in the Rm field. */
7115 if (!inst
.operands
[1].isreg
)
7116 inst
.operands
[1].reg
= REG_PC
;
7118 msb
= inst
.operands
[2].imm
+ inst
.operands
[3].imm
;
7119 constraint (msb
> 32, _("bit-field extends past end of register"));
7120 /* The instruction encoding stores the LSB and MSB,
7121 not the LSB and width. */
7122 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
7123 inst
.instruction
|= inst
.operands
[1].reg
;
7124 inst
.instruction
|= inst
.operands
[2].imm
<< 7;
7125 inst
.instruction
|= (msb
- 1) << 16;
7131 constraint (inst
.operands
[2].imm
+ inst
.operands
[3].imm
> 32,
7132 _("bit-field extends past end of register"));
7133 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
7134 inst
.instruction
|= inst
.operands
[1].reg
;
7135 inst
.instruction
|= inst
.operands
[2].imm
<< 7;
7136 inst
.instruction
|= (inst
.operands
[3].imm
- 1) << 16;
7139 /* ARM V5 breakpoint instruction (argument parse)
7140 BKPT <16 bit unsigned immediate>
7141 Instruction is not conditional.
7142 The bit pattern given in insns[] has the COND_ALWAYS condition,
7143 and it is an error if the caller tried to override that. */
7148 /* Top 12 of 16 bits to bits 19:8. */
7149 inst
.instruction
|= (inst
.operands
[0].imm
& 0xfff0) << 4;
7151 /* Bottom 4 of 16 bits to bits 3:0. */
7152 inst
.instruction
|= inst
.operands
[0].imm
& 0xf;
7156 encode_branch (int default_reloc
)
7158 if (inst
.operands
[0].hasreloc
)
7160 constraint (inst
.operands
[0].imm
!= BFD_RELOC_ARM_PLT32
,
7161 _("the only suffix valid here is '(plt)'"));
7162 inst
.reloc
.type
= BFD_RELOC_ARM_PLT32
;
7166 inst
.reloc
.type
= (bfd_reloc_code_real_type
) default_reloc
;
7168 inst
.reloc
.pc_rel
= 1;
7175 if (EF_ARM_EABI_VERSION (meabi_flags
) >= EF_ARM_EABI_VER4
)
7176 encode_branch (BFD_RELOC_ARM_PCREL_JUMP
);
7179 encode_branch (BFD_RELOC_ARM_PCREL_BRANCH
);
7186 if (EF_ARM_EABI_VERSION (meabi_flags
) >= EF_ARM_EABI_VER4
)
7188 if (inst
.cond
== COND_ALWAYS
)
7189 encode_branch (BFD_RELOC_ARM_PCREL_CALL
);
7191 encode_branch (BFD_RELOC_ARM_PCREL_JUMP
);
7195 encode_branch (BFD_RELOC_ARM_PCREL_BRANCH
);
7198 /* ARM V5 branch-link-exchange instruction (argument parse)
7199 BLX <target_addr> ie BLX(1)
7200 BLX{<condition>} <Rm> ie BLX(2)
7201 Unfortunately, there are two different opcodes for this mnemonic.
7202 So, the insns[].value is not used, and the code here zaps values
7203 into inst.instruction.
7204 Also, the <target_addr> can be 25 bits, hence has its own reloc. */
7209 if (inst
.operands
[0].isreg
)
7211 /* Arg is a register; the opcode provided by insns[] is correct.
7212 It is not illegal to do "blx pc", just useless. */
7213 if (inst
.operands
[0].reg
== REG_PC
)
7214 as_tsktsk (_("use of r15 in blx in ARM mode is not really useful"));
7216 inst
.instruction
|= inst
.operands
[0].reg
;
7220 /* Arg is an address; this instruction cannot be executed
7221 conditionally, and the opcode must be adjusted.
7222 We retain the BFD_RELOC_ARM_PCREL_BLX till the very end
7223 where we generate out a BFD_RELOC_ARM_PCREL_CALL instead. */
7224 constraint (inst
.cond
!= COND_ALWAYS
, BAD_COND
);
7225 inst
.instruction
= 0xfa000000;
7226 encode_branch (BFD_RELOC_ARM_PCREL_BLX
);
7233 bfd_boolean want_reloc
;
7235 if (inst
.operands
[0].reg
== REG_PC
)
7236 as_tsktsk (_("use of r15 in bx in ARM mode is not really useful"));
7238 inst
.instruction
|= inst
.operands
[0].reg
;
7239 /* Output R_ARM_V4BX relocations if is an EABI object that looks like
7240 it is for ARMv4t or earlier. */
7241 want_reloc
= !ARM_CPU_HAS_FEATURE (selected_cpu
, arm_ext_v5
);
7242 if (object_arch
&& !ARM_CPU_HAS_FEATURE (*object_arch
, arm_ext_v5
))
7246 if (EF_ARM_EABI_VERSION (meabi_flags
) < EF_ARM_EABI_VER4
)
7251 inst
.reloc
.type
= BFD_RELOC_ARM_V4BX
;
7255 /* ARM v5TEJ. Jump to Jazelle code. */
7260 if (inst
.operands
[0].reg
== REG_PC
)
7261 as_tsktsk (_("use of r15 in bxj is not really useful"));
7263 inst
.instruction
|= inst
.operands
[0].reg
;
7266 /* Co-processor data operation:
7267 CDP{cond} <coproc>, <opcode_1>, <CRd>, <CRn>, <CRm>{, <opcode_2>}
7268 CDP2 <coproc>, <opcode_1>, <CRd>, <CRn>, <CRm>{, <opcode_2>} */
7272 inst
.instruction
|= inst
.operands
[0].reg
<< 8;
7273 inst
.instruction
|= inst
.operands
[1].imm
<< 20;
7274 inst
.instruction
|= inst
.operands
[2].reg
<< 12;
7275 inst
.instruction
|= inst
.operands
[3].reg
<< 16;
7276 inst
.instruction
|= inst
.operands
[4].reg
;
7277 inst
.instruction
|= inst
.operands
[5].imm
<< 5;
7283 inst
.instruction
|= inst
.operands
[0].reg
<< 16;
7284 encode_arm_shifter_operand (1);
7287 /* Transfer between coprocessor and ARM registers.
7288 MRC{cond} <coproc>, <opcode_1>, <Rd>, <CRn>, <CRm>{, <opcode_2>}
7293 No special properties. */
7300 Rd
= inst
.operands
[2].reg
;
7303 if (inst
.instruction
== 0xee000010
7304 || inst
.instruction
== 0xfe000010)
7306 reject_bad_reg (Rd
);
7309 constraint (Rd
== REG_SP
, BAD_SP
);
7314 if (inst
.instruction
== 0xe000010)
7315 constraint (Rd
== REG_PC
, BAD_PC
);
7319 inst
.instruction
|= inst
.operands
[0].reg
<< 8;
7320 inst
.instruction
|= inst
.operands
[1].imm
<< 21;
7321 inst
.instruction
|= Rd
<< 12;
7322 inst
.instruction
|= inst
.operands
[3].reg
<< 16;
7323 inst
.instruction
|= inst
.operands
[4].reg
;
7324 inst
.instruction
|= inst
.operands
[5].imm
<< 5;
7327 /* Transfer between coprocessor register and pair of ARM registers.
7328 MCRR{cond} <coproc>, <opcode>, <Rd>, <Rn>, <CRm>.
7333 Two XScale instructions are special cases of these:
7335 MAR{cond} acc0, <RdLo>, <RdHi> == MCRR{cond} p0, #0, <RdLo>, <RdHi>, c0
7336 MRA{cond} acc0, <RdLo>, <RdHi> == MRRC{cond} p0, #0, <RdLo>, <RdHi>, c0
7338 Result unpredictable if Rd or Rn is R15. */
7345 Rd
= inst
.operands
[2].reg
;
7346 Rn
= inst
.operands
[3].reg
;
7350 reject_bad_reg (Rd
);
7351 reject_bad_reg (Rn
);
7355 constraint (Rd
== REG_PC
, BAD_PC
);
7356 constraint (Rn
== REG_PC
, BAD_PC
);
7359 inst
.instruction
|= inst
.operands
[0].reg
<< 8;
7360 inst
.instruction
|= inst
.operands
[1].imm
<< 4;
7361 inst
.instruction
|= Rd
<< 12;
7362 inst
.instruction
|= Rn
<< 16;
7363 inst
.instruction
|= inst
.operands
[4].reg
;
7369 inst
.instruction
|= inst
.operands
[0].imm
<< 6;
7370 if (inst
.operands
[1].present
)
7372 inst
.instruction
|= CPSI_MMOD
;
7373 inst
.instruction
|= inst
.operands
[1].imm
;
7380 inst
.instruction
|= inst
.operands
[0].imm
;
7386 /* There is no IT instruction in ARM mode. We
7387 process it to do the validation as if in
7388 thumb mode, just in case the code gets
7389 assembled for thumb using the unified syntax. */
7394 set_it_insn_type (IT_INSN
);
7395 now_it
.mask
= (inst
.instruction
& 0xf) | 0x10;
7396 now_it
.cc
= inst
.operands
[0].imm
;
7403 int base_reg
= inst
.operands
[0].reg
;
7404 int range
= inst
.operands
[1].imm
;
7406 inst
.instruction
|= base_reg
<< 16;
7407 inst
.instruction
|= range
;
7409 if (inst
.operands
[1].writeback
)
7410 inst
.instruction
|= LDM_TYPE_2_OR_3
;
7412 if (inst
.operands
[0].writeback
)
7414 inst
.instruction
|= WRITE_BACK
;
7415 /* Check for unpredictable uses of writeback. */
7416 if (inst
.instruction
& LOAD_BIT
)
7418 /* Not allowed in LDM type 2. */
7419 if ((inst
.instruction
& LDM_TYPE_2_OR_3
)
7420 && ((range
& (1 << REG_PC
)) == 0))
7421 as_warn (_("writeback of base register is UNPREDICTABLE"));
7422 /* Only allowed if base reg not in list for other types. */
7423 else if (range
& (1 << base_reg
))
7424 as_warn (_("writeback of base register when in register list is UNPREDICTABLE"));
7428 /* Not allowed for type 2. */
7429 if (inst
.instruction
& LDM_TYPE_2_OR_3
)
7430 as_warn (_("writeback of base register is UNPREDICTABLE"));
7431 /* Only allowed if base reg not in list, or first in list. */
7432 else if ((range
& (1 << base_reg
))
7433 && (range
& ((1 << base_reg
) - 1)))
7434 as_warn (_("if writeback register is in list, it must be the lowest reg in the list"));
7439 /* ARMv5TE load-consecutive (argument parse)
7448 constraint (inst
.operands
[0].reg
% 2 != 0,
7449 _("first destination register must be even"));
7450 constraint (inst
.operands
[1].present
7451 && inst
.operands
[1].reg
!= inst
.operands
[0].reg
+ 1,
7452 _("can only load two consecutive registers"));
7453 constraint (inst
.operands
[0].reg
== REG_LR
, _("r14 not allowed here"));
7454 constraint (!inst
.operands
[2].isreg
, _("'[' expected"));
7456 if (!inst
.operands
[1].present
)
7457 inst
.operands
[1].reg
= inst
.operands
[0].reg
+ 1;
7459 if (inst
.instruction
& LOAD_BIT
)
7461 /* encode_arm_addr_mode_3 will diagnose overlap between the base
7462 register and the first register written; we have to diagnose
7463 overlap between the base and the second register written here. */
7465 if (inst
.operands
[2].reg
== inst
.operands
[1].reg
7466 && (inst
.operands
[2].writeback
|| inst
.operands
[2].postind
))
7467 as_warn (_("base register written back, and overlaps "
7468 "second destination register"));
7470 /* For an index-register load, the index register must not overlap the
7471 destination (even if not write-back). */
7472 else if (inst
.operands
[2].immisreg
7473 && ((unsigned) inst
.operands
[2].imm
== inst
.operands
[0].reg
7474 || (unsigned) inst
.operands
[2].imm
== inst
.operands
[1].reg
))
7475 as_warn (_("index register overlaps destination register"));
7478 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
7479 encode_arm_addr_mode_3 (2, /*is_t=*/FALSE
);
7485 constraint (!inst
.operands
[1].isreg
|| !inst
.operands
[1].preind
7486 || inst
.operands
[1].postind
|| inst
.operands
[1].writeback
7487 || inst
.operands
[1].immisreg
|| inst
.operands
[1].shifted
7488 || inst
.operands
[1].negative
7489 /* This can arise if the programmer has written
7491 or if they have mistakenly used a register name as the last
7494 It is very difficult to distinguish between these two cases
7495 because "rX" might actually be a label. ie the register
7496 name has been occluded by a symbol of the same name. So we
7497 just generate a general 'bad addressing mode' type error
7498 message and leave it up to the programmer to discover the
7499 true cause and fix their mistake. */
7500 || (inst
.operands
[1].reg
== REG_PC
),
7503 constraint (inst
.reloc
.exp
.X_op
!= O_constant
7504 || inst
.reloc
.exp
.X_add_number
!= 0,
7505 _("offset must be zero in ARM encoding"));
7507 constraint ((inst
.operands
[1].reg
== REG_PC
), BAD_PC
);
7509 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
7510 inst
.instruction
|= inst
.operands
[1].reg
<< 16;
7511 inst
.reloc
.type
= BFD_RELOC_UNUSED
;
7517 constraint (inst
.operands
[0].reg
% 2 != 0,
7518 _("even register required"));
7519 constraint (inst
.operands
[1].present
7520 && inst
.operands
[1].reg
!= inst
.operands
[0].reg
+ 1,
7521 _("can only load two consecutive registers"));
7522 /* If op 1 were present and equal to PC, this function wouldn't
7523 have been called in the first place. */
7524 constraint (inst
.operands
[0].reg
== REG_LR
, _("r14 not allowed here"));
7526 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
7527 inst
.instruction
|= inst
.operands
[2].reg
<< 16;
7533 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
7534 if (!inst
.operands
[1].isreg
)
7535 if (move_or_literal_pool (0, /*thumb_p=*/FALSE
, /*mode_3=*/FALSE
))
7537 encode_arm_addr_mode_2 (1, /*is_t=*/FALSE
);
7543 /* ldrt/strt always use post-indexed addressing. Turn [Rn] into [Rn]! and
7545 if (inst
.operands
[1].preind
)
7547 constraint (inst
.reloc
.exp
.X_op
!= O_constant
7548 || inst
.reloc
.exp
.X_add_number
!= 0,
7549 _("this instruction requires a post-indexed address"));
7551 inst
.operands
[1].preind
= 0;
7552 inst
.operands
[1].postind
= 1;
7553 inst
.operands
[1].writeback
= 1;
7555 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
7556 encode_arm_addr_mode_2 (1, /*is_t=*/TRUE
);
7559 /* Halfword and signed-byte load/store operations. */
7564 constraint (inst
.operands
[0].reg
== REG_PC
, BAD_PC
);
7565 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
7566 if (!inst
.operands
[1].isreg
)
7567 if (move_or_literal_pool (0, /*thumb_p=*/FALSE
, /*mode_3=*/TRUE
))
7569 encode_arm_addr_mode_3 (1, /*is_t=*/FALSE
);
7575 /* ldrt/strt always use post-indexed addressing. Turn [Rn] into [Rn]! and
7577 if (inst
.operands
[1].preind
)
7579 constraint (inst
.reloc
.exp
.X_op
!= O_constant
7580 || inst
.reloc
.exp
.X_add_number
!= 0,
7581 _("this instruction requires a post-indexed address"));
7583 inst
.operands
[1].preind
= 0;
7584 inst
.operands
[1].postind
= 1;
7585 inst
.operands
[1].writeback
= 1;
7587 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
7588 encode_arm_addr_mode_3 (1, /*is_t=*/TRUE
);
7591 /* Co-processor register load/store.
7592 Format: <LDC|STC>{cond}[L] CP#,CRd,<address> */
7596 inst
.instruction
|= inst
.operands
[0].reg
<< 8;
7597 inst
.instruction
|= inst
.operands
[1].reg
<< 12;
7598 encode_arm_cp_address (2, TRUE
, TRUE
, 0);
7604 /* This restriction does not apply to mls (nor to mla in v6 or later). */
7605 if (inst
.operands
[0].reg
== inst
.operands
[1].reg
7606 && !ARM_CPU_HAS_FEATURE (selected_cpu
, arm_ext_v6
)
7607 && !(inst
.instruction
& 0x00400000))
7608 as_tsktsk (_("Rd and Rm should be different in mla"));
7610 inst
.instruction
|= inst
.operands
[0].reg
<< 16;
7611 inst
.instruction
|= inst
.operands
[1].reg
;
7612 inst
.instruction
|= inst
.operands
[2].reg
<< 8;
7613 inst
.instruction
|= inst
.operands
[3].reg
<< 12;
7619 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
7620 encode_arm_shifter_operand (1);
7623 /* ARM V6T2 16-bit immediate register load: MOV[WT]{cond} Rd, #<imm16>. */
7630 top
= (inst
.instruction
& 0x00400000) != 0;
7631 constraint (top
&& inst
.reloc
.type
== BFD_RELOC_ARM_MOVW
,
7632 _(":lower16: not allowed this instruction"));
7633 constraint (!top
&& inst
.reloc
.type
== BFD_RELOC_ARM_MOVT
,
7634 _(":upper16: not allowed instruction"));
7635 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
7636 if (inst
.reloc
.type
== BFD_RELOC_UNUSED
)
7638 imm
= inst
.reloc
.exp
.X_add_number
;
7639 /* The value is in two pieces: 0:11, 16:19. */
7640 inst
.instruction
|= (imm
& 0x00000fff);
7641 inst
.instruction
|= (imm
& 0x0000f000) << 4;
7645 static void do_vfp_nsyn_opcode (const char *);
7648 do_vfp_nsyn_mrs (void)
7650 if (inst
.operands
[0].isvec
)
7652 if (inst
.operands
[1].reg
!= 1)
7653 first_error (_("operand 1 must be FPSCR"));
7654 memset (&inst
.operands
[0], '\0', sizeof (inst
.operands
[0]));
7655 memset (&inst
.operands
[1], '\0', sizeof (inst
.operands
[1]));
7656 do_vfp_nsyn_opcode ("fmstat");
7658 else if (inst
.operands
[1].isvec
)
7659 do_vfp_nsyn_opcode ("fmrx");
7667 do_vfp_nsyn_msr (void)
7669 if (inst
.operands
[0].isvec
)
7670 do_vfp_nsyn_opcode ("fmxr");
7680 unsigned Rt
= inst
.operands
[0].reg
;
7682 if (thumb_mode
&& inst
.operands
[0].reg
== REG_SP
)
7684 inst
.error
= BAD_SP
;
7688 /* APSR_ sets isvec. All other refs to PC are illegal. */
7689 if (!inst
.operands
[0].isvec
&& inst
.operands
[0].reg
== REG_PC
)
7691 inst
.error
= BAD_PC
;
7695 if (inst
.operands
[1].reg
!= 1)
7696 first_error (_("operand 1 must be FPSCR"));
7698 inst
.instruction
|= (Rt
<< 12);
7704 unsigned Rt
= inst
.operands
[1].reg
;
7707 reject_bad_reg (Rt
);
7708 else if (Rt
== REG_PC
)
7710 inst
.error
= BAD_PC
;
7714 if (inst
.operands
[0].reg
!= 1)
7715 first_error (_("operand 0 must be FPSCR"));
7717 inst
.instruction
|= (Rt
<< 12);
7723 if (do_vfp_nsyn_mrs () == SUCCESS
)
7726 /* mrs only accepts CPSR/SPSR/CPSR_all/SPSR_all. */
7727 constraint ((inst
.operands
[1].imm
& (PSR_c
|PSR_x
|PSR_s
|PSR_f
))
7729 _("'CPSR' or 'SPSR' expected"));
7730 constraint (inst
.operands
[0].reg
== REG_PC
, BAD_PC
);
7731 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
7732 inst
.instruction
|= (inst
.operands
[1].imm
& SPSR_BIT
);
7735 /* Two possible forms:
7736 "{C|S}PSR_<field>, Rm",
7737 "{C|S}PSR_f, #expression". */
7742 if (do_vfp_nsyn_msr () == SUCCESS
)
7745 inst
.instruction
|= inst
.operands
[0].imm
;
7746 if (inst
.operands
[1].isreg
)
7747 inst
.instruction
|= inst
.operands
[1].reg
;
7750 inst
.instruction
|= INST_IMMEDIATE
;
7751 inst
.reloc
.type
= BFD_RELOC_ARM_IMMEDIATE
;
7752 inst
.reloc
.pc_rel
= 0;
7759 constraint (inst
.operands
[2].reg
== REG_PC
, BAD_PC
);
7761 if (!inst
.operands
[2].present
)
7762 inst
.operands
[2].reg
= inst
.operands
[0].reg
;
7763 inst
.instruction
|= inst
.operands
[0].reg
<< 16;
7764 inst
.instruction
|= inst
.operands
[1].reg
;
7765 inst
.instruction
|= inst
.operands
[2].reg
<< 8;
7767 if (inst
.operands
[0].reg
== inst
.operands
[1].reg
7768 && !ARM_CPU_HAS_FEATURE (selected_cpu
, arm_ext_v6
))
7769 as_tsktsk (_("Rd and Rm should be different in mul"));
7772 /* Long Multiply Parser
7773 UMULL RdLo, RdHi, Rm, Rs
7774 SMULL RdLo, RdHi, Rm, Rs
7775 UMLAL RdLo, RdHi, Rm, Rs
7776 SMLAL RdLo, RdHi, Rm, Rs. */
7781 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
7782 inst
.instruction
|= inst
.operands
[1].reg
<< 16;
7783 inst
.instruction
|= inst
.operands
[2].reg
;
7784 inst
.instruction
|= inst
.operands
[3].reg
<< 8;
7786 /* rdhi and rdlo must be different. */
7787 if (inst
.operands
[0].reg
== inst
.operands
[1].reg
)
7788 as_tsktsk (_("rdhi and rdlo must be different"));
7790 /* rdhi, rdlo and rm must all be different before armv6. */
7791 if ((inst
.operands
[0].reg
== inst
.operands
[2].reg
7792 || inst
.operands
[1].reg
== inst
.operands
[2].reg
)
7793 && !ARM_CPU_HAS_FEATURE (selected_cpu
, arm_ext_v6
))
7794 as_tsktsk (_("rdhi, rdlo and rm must all be different"));
7800 if (inst
.operands
[0].present
7801 || ARM_CPU_HAS_FEATURE (selected_cpu
, arm_ext_v6k
))
7803 /* Architectural NOP hints are CPSR sets with no bits selected. */
7804 inst
.instruction
&= 0xf0000000;
7805 inst
.instruction
|= 0x0320f000;
7806 if (inst
.operands
[0].present
)
7807 inst
.instruction
|= inst
.operands
[0].imm
;
7811 /* ARM V6 Pack Halfword Bottom Top instruction (argument parse).
7812 PKHBT {<cond>} <Rd>, <Rn>, <Rm> {, LSL #<shift_imm>}
7813 Condition defaults to COND_ALWAYS.
7814 Error if Rd, Rn or Rm are R15. */
7819 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
7820 inst
.instruction
|= inst
.operands
[1].reg
<< 16;
7821 inst
.instruction
|= inst
.operands
[2].reg
;
7822 if (inst
.operands
[3].present
)
7823 encode_arm_shift (3);
7826 /* ARM V6 PKHTB (Argument Parse). */
7831 if (!inst
.operands
[3].present
)
7833 /* If the shift specifier is omitted, turn the instruction
7834 into pkhbt rd, rm, rn. */
7835 inst
.instruction
&= 0xfff00010;
7836 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
7837 inst
.instruction
|= inst
.operands
[1].reg
;
7838 inst
.instruction
|= inst
.operands
[2].reg
<< 16;
7842 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
7843 inst
.instruction
|= inst
.operands
[1].reg
<< 16;
7844 inst
.instruction
|= inst
.operands
[2].reg
;
7845 encode_arm_shift (3);
7849 /* ARMv5TE: Preload-Cache
7853 Syntactically, like LDR with B=1, W=0, L=1. */
7858 constraint (!inst
.operands
[0].isreg
,
7859 _("'[' expected after PLD mnemonic"));
7860 constraint (inst
.operands
[0].postind
,
7861 _("post-indexed expression used in preload instruction"));
7862 constraint (inst
.operands
[0].writeback
,
7863 _("writeback used in preload instruction"));
7864 constraint (!inst
.operands
[0].preind
,
7865 _("unindexed addressing used in preload instruction"));
7866 encode_arm_addr_mode_2 (0, /*is_t=*/FALSE
);
7869 /* ARMv7: PLI <addr_mode> */
7873 constraint (!inst
.operands
[0].isreg
,
7874 _("'[' expected after PLI mnemonic"));
7875 constraint (inst
.operands
[0].postind
,
7876 _("post-indexed expression used in preload instruction"));
7877 constraint (inst
.operands
[0].writeback
,
7878 _("writeback used in preload instruction"));
7879 constraint (!inst
.operands
[0].preind
,
7880 _("unindexed addressing used in preload instruction"));
7881 encode_arm_addr_mode_2 (0, /*is_t=*/FALSE
);
7882 inst
.instruction
&= ~PRE_INDEX
;
7888 inst
.operands
[1] = inst
.operands
[0];
7889 memset (&inst
.operands
[0], 0, sizeof inst
.operands
[0]);
7890 inst
.operands
[0].isreg
= 1;
7891 inst
.operands
[0].writeback
= 1;
7892 inst
.operands
[0].reg
= REG_SP
;
7896 /* ARM V6 RFE (Return from Exception) loads the PC and CPSR from the
7897 word at the specified address and the following word
7899 Unconditionally executed.
7900 Error if Rn is R15. */
7905 inst
.instruction
|= inst
.operands
[0].reg
<< 16;
7906 if (inst
.operands
[0].writeback
)
7907 inst
.instruction
|= WRITE_BACK
;
7910 /* ARM V6 ssat (argument parse). */
7915 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
7916 inst
.instruction
|= (inst
.operands
[1].imm
- 1) << 16;
7917 inst
.instruction
|= inst
.operands
[2].reg
;
7919 if (inst
.operands
[3].present
)
7920 encode_arm_shift (3);
7923 /* ARM V6 usat (argument parse). */
7928 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
7929 inst
.instruction
|= inst
.operands
[1].imm
<< 16;
7930 inst
.instruction
|= inst
.operands
[2].reg
;
7932 if (inst
.operands
[3].present
)
7933 encode_arm_shift (3);
7936 /* ARM V6 ssat16 (argument parse). */
7941 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
7942 inst
.instruction
|= ((inst
.operands
[1].imm
- 1) << 16);
7943 inst
.instruction
|= inst
.operands
[2].reg
;
7949 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
7950 inst
.instruction
|= inst
.operands
[1].imm
<< 16;
7951 inst
.instruction
|= inst
.operands
[2].reg
;
7954 /* ARM V6 SETEND (argument parse). Sets the E bit in the CPSR while
7955 preserving the other bits.
7957 setend <endian_specifier>, where <endian_specifier> is either
7963 if (inst
.operands
[0].imm
)
7964 inst
.instruction
|= 0x200;
7970 unsigned int Rm
= (inst
.operands
[1].present
7971 ? inst
.operands
[1].reg
7972 : inst
.operands
[0].reg
);
7974 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
7975 inst
.instruction
|= Rm
;
7976 if (inst
.operands
[2].isreg
) /* Rd, {Rm,} Rs */
7978 inst
.instruction
|= inst
.operands
[2].reg
<< 8;
7979 inst
.instruction
|= SHIFT_BY_REG
;
7982 inst
.reloc
.type
= BFD_RELOC_ARM_SHIFT_IMM
;
7988 inst
.reloc
.type
= BFD_RELOC_ARM_SMC
;
7989 inst
.reloc
.pc_rel
= 0;
7995 inst
.reloc
.type
= BFD_RELOC_ARM_SWI
;
7996 inst
.reloc
.pc_rel
= 0;
7999 /* ARM V5E (El Segundo) signed-multiply-accumulate (argument parse)
8000 SMLAxy{cond} Rd,Rm,Rs,Rn
8001 SMLAWy{cond} Rd,Rm,Rs,Rn
8002 Error if any register is R15. */
8007 inst
.instruction
|= inst
.operands
[0].reg
<< 16;
8008 inst
.instruction
|= inst
.operands
[1].reg
;
8009 inst
.instruction
|= inst
.operands
[2].reg
<< 8;
8010 inst
.instruction
|= inst
.operands
[3].reg
<< 12;
8013 /* ARM V5E (El Segundo) signed-multiply-accumulate-long (argument parse)
8014 SMLALxy{cond} Rdlo,Rdhi,Rm,Rs
8015 Error if any register is R15.
8016 Warning if Rdlo == Rdhi. */
8021 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
8022 inst
.instruction
|= inst
.operands
[1].reg
<< 16;
8023 inst
.instruction
|= inst
.operands
[2].reg
;
8024 inst
.instruction
|= inst
.operands
[3].reg
<< 8;
8026 if (inst
.operands
[0].reg
== inst
.operands
[1].reg
)
8027 as_tsktsk (_("rdhi and rdlo must be different"));
8030 /* ARM V5E (El Segundo) signed-multiply (argument parse)
8031 SMULxy{cond} Rd,Rm,Rs
8032 Error if any register is R15. */
8037 inst
.instruction
|= inst
.operands
[0].reg
<< 16;
8038 inst
.instruction
|= inst
.operands
[1].reg
;
8039 inst
.instruction
|= inst
.operands
[2].reg
<< 8;
8042 /* ARM V6 srs (argument parse). The variable fields in the encoding are
8043 the same for both ARM and Thumb-2. */
8050 if (inst
.operands
[0].present
)
8052 reg
= inst
.operands
[0].reg
;
8053 constraint (reg
!= REG_SP
, _("SRS base register must be r13"));
8058 inst
.instruction
|= reg
<< 16;
8059 inst
.instruction
|= inst
.operands
[1].imm
;
8060 if (inst
.operands
[0].writeback
|| inst
.operands
[1].writeback
)
8061 inst
.instruction
|= WRITE_BACK
;
8064 /* ARM V6 strex (argument parse). */
8069 constraint (!inst
.operands
[2].isreg
|| !inst
.operands
[2].preind
8070 || inst
.operands
[2].postind
|| inst
.operands
[2].writeback
8071 || inst
.operands
[2].immisreg
|| inst
.operands
[2].shifted
8072 || inst
.operands
[2].negative
8073 /* See comment in do_ldrex(). */
8074 || (inst
.operands
[2].reg
== REG_PC
),
8077 constraint (inst
.operands
[0].reg
== inst
.operands
[1].reg
8078 || inst
.operands
[0].reg
== inst
.operands
[2].reg
, BAD_OVERLAP
);
8080 constraint (inst
.reloc
.exp
.X_op
!= O_constant
8081 || inst
.reloc
.exp
.X_add_number
!= 0,
8082 _("offset must be zero in ARM encoding"));
8084 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
8085 inst
.instruction
|= inst
.operands
[1].reg
;
8086 inst
.instruction
|= inst
.operands
[2].reg
<< 16;
8087 inst
.reloc
.type
= BFD_RELOC_UNUSED
;
8093 constraint (inst
.operands
[1].reg
% 2 != 0,
8094 _("even register required"));
8095 constraint (inst
.operands
[2].present
8096 && inst
.operands
[2].reg
!= inst
.operands
[1].reg
+ 1,
8097 _("can only store two consecutive registers"));
8098 /* If op 2 were present and equal to PC, this function wouldn't
8099 have been called in the first place. */
8100 constraint (inst
.operands
[1].reg
== REG_LR
, _("r14 not allowed here"));
8102 constraint (inst
.operands
[0].reg
== inst
.operands
[1].reg
8103 || inst
.operands
[0].reg
== inst
.operands
[1].reg
+ 1
8104 || inst
.operands
[0].reg
== inst
.operands
[3].reg
,
8107 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
8108 inst
.instruction
|= inst
.operands
[1].reg
;
8109 inst
.instruction
|= inst
.operands
[3].reg
<< 16;
8112 /* ARM V6 SXTAH extracts a 16-bit value from a register, sign
8113 extends it to 32-bits, and adds the result to a value in another
8114 register. You can specify a rotation by 0, 8, 16, or 24 bits
8115 before extracting the 16-bit value.
8116 SXTAH{<cond>} <Rd>, <Rn>, <Rm>{, <rotation>}
8117 Condition defaults to COND_ALWAYS.
8118 Error if any register uses R15. */
8123 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
8124 inst
.instruction
|= inst
.operands
[1].reg
<< 16;
8125 inst
.instruction
|= inst
.operands
[2].reg
;
8126 inst
.instruction
|= inst
.operands
[3].imm
<< 10;
8131 SXTH {<cond>} <Rd>, <Rm>{, <rotation>}
8132 Condition defaults to COND_ALWAYS.
8133 Error if any register uses R15. */
8138 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
8139 inst
.instruction
|= inst
.operands
[1].reg
;
8140 inst
.instruction
|= inst
.operands
[2].imm
<< 10;
8143 /* VFP instructions. In a logical order: SP variant first, monad
8144 before dyad, arithmetic then move then load/store. */
8147 do_vfp_sp_monadic (void)
8149 encode_arm_vfp_reg (inst
.operands
[0].reg
, VFP_REG_Sd
);
8150 encode_arm_vfp_reg (inst
.operands
[1].reg
, VFP_REG_Sm
);
8154 do_vfp_sp_dyadic (void)
8156 encode_arm_vfp_reg (inst
.operands
[0].reg
, VFP_REG_Sd
);
8157 encode_arm_vfp_reg (inst
.operands
[1].reg
, VFP_REG_Sn
);
8158 encode_arm_vfp_reg (inst
.operands
[2].reg
, VFP_REG_Sm
);
8162 do_vfp_sp_compare_z (void)
8164 encode_arm_vfp_reg (inst
.operands
[0].reg
, VFP_REG_Sd
);
8168 do_vfp_dp_sp_cvt (void)
8170 encode_arm_vfp_reg (inst
.operands
[0].reg
, VFP_REG_Dd
);
8171 encode_arm_vfp_reg (inst
.operands
[1].reg
, VFP_REG_Sm
);
8175 do_vfp_sp_dp_cvt (void)
8177 encode_arm_vfp_reg (inst
.operands
[0].reg
, VFP_REG_Sd
);
8178 encode_arm_vfp_reg (inst
.operands
[1].reg
, VFP_REG_Dm
);
8182 do_vfp_reg_from_sp (void)
8184 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
8185 encode_arm_vfp_reg (inst
.operands
[1].reg
, VFP_REG_Sn
);
8189 do_vfp_reg2_from_sp2 (void)
8191 constraint (inst
.operands
[2].imm
!= 2,
8192 _("only two consecutive VFP SP registers allowed here"));
8193 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
8194 inst
.instruction
|= inst
.operands
[1].reg
<< 16;
8195 encode_arm_vfp_reg (inst
.operands
[2].reg
, VFP_REG_Sm
);
8199 do_vfp_sp_from_reg (void)
8201 encode_arm_vfp_reg (inst
.operands
[0].reg
, VFP_REG_Sn
);
8202 inst
.instruction
|= inst
.operands
[1].reg
<< 12;
8206 do_vfp_sp2_from_reg2 (void)
8208 constraint (inst
.operands
[0].imm
!= 2,
8209 _("only two consecutive VFP SP registers allowed here"));
8210 encode_arm_vfp_reg (inst
.operands
[0].reg
, VFP_REG_Sm
);
8211 inst
.instruction
|= inst
.operands
[1].reg
<< 12;
8212 inst
.instruction
|= inst
.operands
[2].reg
<< 16;
8216 do_vfp_sp_ldst (void)
8218 encode_arm_vfp_reg (inst
.operands
[0].reg
, VFP_REG_Sd
);
8219 encode_arm_cp_address (1, FALSE
, TRUE
, 0);
8223 do_vfp_dp_ldst (void)
8225 encode_arm_vfp_reg (inst
.operands
[0].reg
, VFP_REG_Dd
);
8226 encode_arm_cp_address (1, FALSE
, TRUE
, 0);
8231 vfp_sp_ldstm (enum vfp_ldstm_type ldstm_type
)
8233 if (inst
.operands
[0].writeback
)
8234 inst
.instruction
|= WRITE_BACK
;
8236 constraint (ldstm_type
!= VFP_LDSTMIA
,
8237 _("this addressing mode requires base-register writeback"));
8238 inst
.instruction
|= inst
.operands
[0].reg
<< 16;
8239 encode_arm_vfp_reg (inst
.operands
[1].reg
, VFP_REG_Sd
);
8240 inst
.instruction
|= inst
.operands
[1].imm
;
8244 vfp_dp_ldstm (enum vfp_ldstm_type ldstm_type
)
8248 if (inst
.operands
[0].writeback
)
8249 inst
.instruction
|= WRITE_BACK
;
8251 constraint (ldstm_type
!= VFP_LDSTMIA
&& ldstm_type
!= VFP_LDSTMIAX
,
8252 _("this addressing mode requires base-register writeback"));
8254 inst
.instruction
|= inst
.operands
[0].reg
<< 16;
8255 encode_arm_vfp_reg (inst
.operands
[1].reg
, VFP_REG_Dd
);
8257 count
= inst
.operands
[1].imm
<< 1;
8258 if (ldstm_type
== VFP_LDSTMIAX
|| ldstm_type
== VFP_LDSTMDBX
)
8261 inst
.instruction
|= count
;
8265 do_vfp_sp_ldstmia (void)
8267 vfp_sp_ldstm (VFP_LDSTMIA
);
8271 do_vfp_sp_ldstmdb (void)
8273 vfp_sp_ldstm (VFP_LDSTMDB
);
8277 do_vfp_dp_ldstmia (void)
8279 vfp_dp_ldstm (VFP_LDSTMIA
);
8283 do_vfp_dp_ldstmdb (void)
8285 vfp_dp_ldstm (VFP_LDSTMDB
);
8289 do_vfp_xp_ldstmia (void)
8291 vfp_dp_ldstm (VFP_LDSTMIAX
);
8295 do_vfp_xp_ldstmdb (void)
8297 vfp_dp_ldstm (VFP_LDSTMDBX
);
8301 do_vfp_dp_rd_rm (void)
8303 encode_arm_vfp_reg (inst
.operands
[0].reg
, VFP_REG_Dd
);
8304 encode_arm_vfp_reg (inst
.operands
[1].reg
, VFP_REG_Dm
);
8308 do_vfp_dp_rn_rd (void)
8310 encode_arm_vfp_reg (inst
.operands
[0].reg
, VFP_REG_Dn
);
8311 encode_arm_vfp_reg (inst
.operands
[1].reg
, VFP_REG_Dd
);
8315 do_vfp_dp_rd_rn (void)
8317 encode_arm_vfp_reg (inst
.operands
[0].reg
, VFP_REG_Dd
);
8318 encode_arm_vfp_reg (inst
.operands
[1].reg
, VFP_REG_Dn
);
8322 do_vfp_dp_rd_rn_rm (void)
8324 encode_arm_vfp_reg (inst
.operands
[0].reg
, VFP_REG_Dd
);
8325 encode_arm_vfp_reg (inst
.operands
[1].reg
, VFP_REG_Dn
);
8326 encode_arm_vfp_reg (inst
.operands
[2].reg
, VFP_REG_Dm
);
8332 encode_arm_vfp_reg (inst
.operands
[0].reg
, VFP_REG_Dd
);
8336 do_vfp_dp_rm_rd_rn (void)
8338 encode_arm_vfp_reg (inst
.operands
[0].reg
, VFP_REG_Dm
);
8339 encode_arm_vfp_reg (inst
.operands
[1].reg
, VFP_REG_Dd
);
8340 encode_arm_vfp_reg (inst
.operands
[2].reg
, VFP_REG_Dn
);
8343 /* VFPv3 instructions. */
8345 do_vfp_sp_const (void)
8347 encode_arm_vfp_reg (inst
.operands
[0].reg
, VFP_REG_Sd
);
8348 inst
.instruction
|= (inst
.operands
[1].imm
& 0xf0) << 12;
8349 inst
.instruction
|= (inst
.operands
[1].imm
& 0x0f);
8353 do_vfp_dp_const (void)
8355 encode_arm_vfp_reg (inst
.operands
[0].reg
, VFP_REG_Dd
);
8356 inst
.instruction
|= (inst
.operands
[1].imm
& 0xf0) << 12;
8357 inst
.instruction
|= (inst
.operands
[1].imm
& 0x0f);
8361 vfp_conv (int srcsize
)
8363 unsigned immbits
= srcsize
- inst
.operands
[1].imm
;
8364 inst
.instruction
|= (immbits
& 1) << 5;
8365 inst
.instruction
|= (immbits
>> 1);
8369 do_vfp_sp_conv_16 (void)
8371 encode_arm_vfp_reg (inst
.operands
[0].reg
, VFP_REG_Sd
);
8376 do_vfp_dp_conv_16 (void)
8378 encode_arm_vfp_reg (inst
.operands
[0].reg
, VFP_REG_Dd
);
8383 do_vfp_sp_conv_32 (void)
8385 encode_arm_vfp_reg (inst
.operands
[0].reg
, VFP_REG_Sd
);
8390 do_vfp_dp_conv_32 (void)
8392 encode_arm_vfp_reg (inst
.operands
[0].reg
, VFP_REG_Dd
);
8396 /* FPA instructions. Also in a logical order. */
8401 inst
.instruction
|= inst
.operands
[0].reg
<< 16;
8402 inst
.instruction
|= inst
.operands
[1].reg
;
8406 do_fpa_ldmstm (void)
8408 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
8409 switch (inst
.operands
[1].imm
)
8411 case 1: inst
.instruction
|= CP_T_X
; break;
8412 case 2: inst
.instruction
|= CP_T_Y
; break;
8413 case 3: inst
.instruction
|= CP_T_Y
| CP_T_X
; break;
8418 if (inst
.instruction
& (PRE_INDEX
| INDEX_UP
))
8420 /* The instruction specified "ea" or "fd", so we can only accept
8421 [Rn]{!}. The instruction does not really support stacking or
8422 unstacking, so we have to emulate these by setting appropriate
8423 bits and offsets. */
8424 constraint (inst
.reloc
.exp
.X_op
!= O_constant
8425 || inst
.reloc
.exp
.X_add_number
!= 0,
8426 _("this instruction does not support indexing"));
8428 if ((inst
.instruction
& PRE_INDEX
) || inst
.operands
[2].writeback
)
8429 inst
.reloc
.exp
.X_add_number
= 12 * inst
.operands
[1].imm
;
8431 if (!(inst
.instruction
& INDEX_UP
))
8432 inst
.reloc
.exp
.X_add_number
= -inst
.reloc
.exp
.X_add_number
;
8434 if (!(inst
.instruction
& PRE_INDEX
) && inst
.operands
[2].writeback
)
8436 inst
.operands
[2].preind
= 0;
8437 inst
.operands
[2].postind
= 1;
8441 encode_arm_cp_address (2, TRUE
, TRUE
, 0);
8444 /* iWMMXt instructions: strictly in alphabetical order. */
8447 do_iwmmxt_tandorc (void)
8449 constraint (inst
.operands
[0].reg
!= REG_PC
, _("only r15 allowed here"));
8453 do_iwmmxt_textrc (void)
8455 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
8456 inst
.instruction
|= inst
.operands
[1].imm
;
8460 do_iwmmxt_textrm (void)
8462 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
8463 inst
.instruction
|= inst
.operands
[1].reg
<< 16;
8464 inst
.instruction
|= inst
.operands
[2].imm
;
8468 do_iwmmxt_tinsr (void)
8470 inst
.instruction
|= inst
.operands
[0].reg
<< 16;
8471 inst
.instruction
|= inst
.operands
[1].reg
<< 12;
8472 inst
.instruction
|= inst
.operands
[2].imm
;
8476 do_iwmmxt_tmia (void)
8478 inst
.instruction
|= inst
.operands
[0].reg
<< 5;
8479 inst
.instruction
|= inst
.operands
[1].reg
;
8480 inst
.instruction
|= inst
.operands
[2].reg
<< 12;
8484 do_iwmmxt_waligni (void)
8486 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
8487 inst
.instruction
|= inst
.operands
[1].reg
<< 16;
8488 inst
.instruction
|= inst
.operands
[2].reg
;
8489 inst
.instruction
|= inst
.operands
[3].imm
<< 20;
8493 do_iwmmxt_wmerge (void)
8495 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
8496 inst
.instruction
|= inst
.operands
[1].reg
<< 16;
8497 inst
.instruction
|= inst
.operands
[2].reg
;
8498 inst
.instruction
|= inst
.operands
[3].imm
<< 21;
8502 do_iwmmxt_wmov (void)
8504 /* WMOV rD, rN is an alias for WOR rD, rN, rN. */
8505 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
8506 inst
.instruction
|= inst
.operands
[1].reg
<< 16;
8507 inst
.instruction
|= inst
.operands
[1].reg
;
8511 do_iwmmxt_wldstbh (void)
8514 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
8516 reloc
= BFD_RELOC_ARM_T32_CP_OFF_IMM_S2
;
8518 reloc
= BFD_RELOC_ARM_CP_OFF_IMM_S2
;
8519 encode_arm_cp_address (1, TRUE
, FALSE
, reloc
);
8523 do_iwmmxt_wldstw (void)
8525 /* RIWR_RIWC clears .isreg for a control register. */
8526 if (!inst
.operands
[0].isreg
)
8528 constraint (inst
.cond
!= COND_ALWAYS
, BAD_COND
);
8529 inst
.instruction
|= 0xf0000000;
8532 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
8533 encode_arm_cp_address (1, TRUE
, TRUE
, 0);
8537 do_iwmmxt_wldstd (void)
8539 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
8540 if (ARM_CPU_HAS_FEATURE (cpu_variant
, arm_cext_iwmmxt2
)
8541 && inst
.operands
[1].immisreg
)
8543 inst
.instruction
&= ~0x1a000ff;
8544 inst
.instruction
|= (0xf << 28);
8545 if (inst
.operands
[1].preind
)
8546 inst
.instruction
|= PRE_INDEX
;
8547 if (!inst
.operands
[1].negative
)
8548 inst
.instruction
|= INDEX_UP
;
8549 if (inst
.operands
[1].writeback
)
8550 inst
.instruction
|= WRITE_BACK
;
8551 inst
.instruction
|= inst
.operands
[1].reg
<< 16;
8552 inst
.instruction
|= inst
.reloc
.exp
.X_add_number
<< 4;
8553 inst
.instruction
|= inst
.operands
[1].imm
;
8556 encode_arm_cp_address (1, TRUE
, FALSE
, 0);
8560 do_iwmmxt_wshufh (void)
8562 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
8563 inst
.instruction
|= inst
.operands
[1].reg
<< 16;
8564 inst
.instruction
|= ((inst
.operands
[2].imm
& 0xf0) << 16);
8565 inst
.instruction
|= (inst
.operands
[2].imm
& 0x0f);
8569 do_iwmmxt_wzero (void)
8571 /* WZERO reg is an alias for WANDN reg, reg, reg. */
8572 inst
.instruction
|= inst
.operands
[0].reg
;
8573 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
8574 inst
.instruction
|= inst
.operands
[0].reg
<< 16;
8578 do_iwmmxt_wrwrwr_or_imm5 (void)
8580 if (inst
.operands
[2].isreg
)
8583 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant
, arm_cext_iwmmxt2
),
8584 _("immediate operand requires iWMMXt2"));
8586 if (inst
.operands
[2].imm
== 0)
8588 switch ((inst
.instruction
>> 20) & 0xf)
8594 /* w...h wrd, wrn, #0 -> wrorh wrd, wrn, #16. */
8595 inst
.operands
[2].imm
= 16;
8596 inst
.instruction
= (inst
.instruction
& 0xff0fffff) | (0x7 << 20);
8602 /* w...w wrd, wrn, #0 -> wrorw wrd, wrn, #32. */
8603 inst
.operands
[2].imm
= 32;
8604 inst
.instruction
= (inst
.instruction
& 0xff0fffff) | (0xb << 20);
8611 /* w...d wrd, wrn, #0 -> wor wrd, wrn, wrn. */
8613 wrn
= (inst
.instruction
>> 16) & 0xf;
8614 inst
.instruction
&= 0xff0fff0f;
8615 inst
.instruction
|= wrn
;
8616 /* Bail out here; the instruction is now assembled. */
8621 /* Map 32 -> 0, etc. */
8622 inst
.operands
[2].imm
&= 0x1f;
8623 inst
.instruction
|= (0xf << 28) | ((inst
.operands
[2].imm
& 0x10) << 4) | (inst
.operands
[2].imm
& 0xf);
8627 /* Cirrus Maverick instructions. Simple 2-, 3-, and 4-register
8628 operations first, then control, shift, and load/store. */
8630 /* Insns like "foo X,Y,Z". */
8633 do_mav_triple (void)
8635 inst
.instruction
|= inst
.operands
[0].reg
<< 16;
8636 inst
.instruction
|= inst
.operands
[1].reg
;
8637 inst
.instruction
|= inst
.operands
[2].reg
<< 12;
8640 /* Insns like "foo W,X,Y,Z".
8641 where W=MVAX[0:3] and X,Y,Z=MVFX[0:15]. */
8646 inst
.instruction
|= inst
.operands
[0].reg
<< 5;
8647 inst
.instruction
|= inst
.operands
[1].reg
<< 12;
8648 inst
.instruction
|= inst
.operands
[2].reg
<< 16;
8649 inst
.instruction
|= inst
.operands
[3].reg
;
8652 /* cfmvsc32<cond> DSPSC,MVDX[15:0]. */
8656 inst
.instruction
|= inst
.operands
[1].reg
<< 12;
8659 /* Maverick shift immediate instructions.
8660 cfsh32<cond> MVFX[15:0],MVFX[15:0],Shift[6:0].
8661 cfsh64<cond> MVDX[15:0],MVDX[15:0],Shift[6:0]. */
8666 int imm
= inst
.operands
[2].imm
;
8668 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
8669 inst
.instruction
|= inst
.operands
[1].reg
<< 16;
8671 /* Bits 0-3 of the insn should have bits 0-3 of the immediate.
8672 Bits 5-7 of the insn should have bits 4-6 of the immediate.
8673 Bit 4 should be 0. */
8674 imm
= (imm
& 0xf) | ((imm
& 0x70) << 1);
8676 inst
.instruction
|= imm
;
8679 /* XScale instructions. Also sorted arithmetic before move. */
8681 /* Xscale multiply-accumulate (argument parse)
8684 MIAxycc acc0,Rm,Rs. */
8689 inst
.instruction
|= inst
.operands
[1].reg
;
8690 inst
.instruction
|= inst
.operands
[2].reg
<< 12;
8693 /* Xscale move-accumulator-register (argument parse)
8695 MARcc acc0,RdLo,RdHi. */
8700 inst
.instruction
|= inst
.operands
[1].reg
<< 12;
8701 inst
.instruction
|= inst
.operands
[2].reg
<< 16;
8704 /* Xscale move-register-accumulator (argument parse)
8706 MRAcc RdLo,RdHi,acc0. */
8711 constraint (inst
.operands
[0].reg
== inst
.operands
[1].reg
, BAD_OVERLAP
);
8712 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
8713 inst
.instruction
|= inst
.operands
[1].reg
<< 16;
8716 /* Encoding functions relevant only to Thumb. */
8718 /* inst.operands[i] is a shifted-register operand; encode
8719 it into inst.instruction in the format used by Thumb32. */
8722 encode_thumb32_shifted_operand (int i
)
8724 unsigned int value
= inst
.reloc
.exp
.X_add_number
;
8725 unsigned int shift
= inst
.operands
[i
].shift_kind
;
8727 constraint (inst
.operands
[i
].immisreg
,
8728 _("shift by register not allowed in thumb mode"));
8729 inst
.instruction
|= inst
.operands
[i
].reg
;
8730 if (shift
== SHIFT_RRX
)
8731 inst
.instruction
|= SHIFT_ROR
<< 4;
8734 constraint (inst
.reloc
.exp
.X_op
!= O_constant
,
8735 _("expression too complex"));
8737 constraint (value
> 32
8738 || (value
== 32 && (shift
== SHIFT_LSL
8739 || shift
== SHIFT_ROR
)),
8740 _("shift expression is too large"));
8744 else if (value
== 32)
8747 inst
.instruction
|= shift
<< 4;
8748 inst
.instruction
|= (value
& 0x1c) << 10;
8749 inst
.instruction
|= (value
& 0x03) << 6;
8754 /* inst.operands[i] was set up by parse_address. Encode it into a
8755 Thumb32 format load or store instruction. Reject forms that cannot
8756 be used with such instructions. If is_t is true, reject forms that
8757 cannot be used with a T instruction; if is_d is true, reject forms
8758 that cannot be used with a D instruction. If it is a store insn,
8762 encode_thumb32_addr_mode (int i
, bfd_boolean is_t
, bfd_boolean is_d
)
8764 const bfd_boolean is_pc
= (inst
.operands
[i
].reg
== REG_PC
);
8766 constraint (!inst
.operands
[i
].isreg
,
8767 _("Instruction does not support =N addresses"));
8769 inst
.instruction
|= inst
.operands
[i
].reg
<< 16;
8770 if (inst
.operands
[i
].immisreg
)
8772 constraint (is_pc
, BAD_PC_ADDRESSING
);
8773 constraint (is_t
|| is_d
, _("cannot use register index with this instruction"));
8774 constraint (inst
.operands
[i
].negative
,
8775 _("Thumb does not support negative register indexing"));
8776 constraint (inst
.operands
[i
].postind
,
8777 _("Thumb does not support register post-indexing"));
8778 constraint (inst
.operands
[i
].writeback
,
8779 _("Thumb does not support register indexing with writeback"));
8780 constraint (inst
.operands
[i
].shifted
&& inst
.operands
[i
].shift_kind
!= SHIFT_LSL
,
8781 _("Thumb supports only LSL in shifted register indexing"));
8783 inst
.instruction
|= inst
.operands
[i
].imm
;
8784 if (inst
.operands
[i
].shifted
)
8786 constraint (inst
.reloc
.exp
.X_op
!= O_constant
,
8787 _("expression too complex"));
8788 constraint (inst
.reloc
.exp
.X_add_number
< 0
8789 || inst
.reloc
.exp
.X_add_number
> 3,
8790 _("shift out of range"));
8791 inst
.instruction
|= inst
.reloc
.exp
.X_add_number
<< 4;
8793 inst
.reloc
.type
= BFD_RELOC_UNUSED
;
8795 else if (inst
.operands
[i
].preind
)
8797 constraint (is_pc
&& inst
.operands
[i
].writeback
, BAD_PC_WRITEBACK
);
8798 constraint (is_t
&& inst
.operands
[i
].writeback
,
8799 _("cannot use writeback with this instruction"));
8800 constraint (is_pc
&& ((inst
.instruction
& THUMB2_LOAD_BIT
) == 0)
8801 && !inst
.reloc
.pc_rel
, BAD_PC_ADDRESSING
);
8805 inst
.instruction
|= 0x01000000;
8806 if (inst
.operands
[i
].writeback
)
8807 inst
.instruction
|= 0x00200000;
8811 inst
.instruction
|= 0x00000c00;
8812 if (inst
.operands
[i
].writeback
)
8813 inst
.instruction
|= 0x00000100;
8815 inst
.reloc
.type
= BFD_RELOC_ARM_T32_OFFSET_IMM
;
8817 else if (inst
.operands
[i
].postind
)
8819 gas_assert (inst
.operands
[i
].writeback
);
8820 constraint (is_pc
, _("cannot use post-indexing with PC-relative addressing"));
8821 constraint (is_t
, _("cannot use post-indexing with this instruction"));
8824 inst
.instruction
|= 0x00200000;
8826 inst
.instruction
|= 0x00000900;
8827 inst
.reloc
.type
= BFD_RELOC_ARM_T32_OFFSET_IMM
;
8829 else /* unindexed - only for coprocessor */
8830 inst
.error
= _("instruction does not accept unindexed addressing");
8833 /* Table of Thumb instructions which exist in both 16- and 32-bit
8834 encodings (the latter only in post-V6T2 cores). The index is the
8835 value used in the insns table below. When there is more than one
8836 possible 16-bit encoding for the instruction, this table always
8838 Also contains several pseudo-instructions used during relaxation. */
8839 #define T16_32_TAB \
8840 X(_adc, 4140, eb400000), \
8841 X(_adcs, 4140, eb500000), \
8842 X(_add, 1c00, eb000000), \
8843 X(_adds, 1c00, eb100000), \
8844 X(_addi, 0000, f1000000), \
8845 X(_addis, 0000, f1100000), \
8846 X(_add_pc,000f, f20f0000), \
8847 X(_add_sp,000d, f10d0000), \
8848 X(_adr, 000f, f20f0000), \
8849 X(_and, 4000, ea000000), \
8850 X(_ands, 4000, ea100000), \
8851 X(_asr, 1000, fa40f000), \
8852 X(_asrs, 1000, fa50f000), \
8853 X(_b, e000, f000b000), \
8854 X(_bcond, d000, f0008000), \
8855 X(_bic, 4380, ea200000), \
8856 X(_bics, 4380, ea300000), \
8857 X(_cmn, 42c0, eb100f00), \
8858 X(_cmp, 2800, ebb00f00), \
8859 X(_cpsie, b660, f3af8400), \
8860 X(_cpsid, b670, f3af8600), \
8861 X(_cpy, 4600, ea4f0000), \
8862 X(_dec_sp,80dd, f1ad0d00), \
8863 X(_eor, 4040, ea800000), \
8864 X(_eors, 4040, ea900000), \
8865 X(_inc_sp,00dd, f10d0d00), \
8866 X(_ldmia, c800, e8900000), \
8867 X(_ldr, 6800, f8500000), \
8868 X(_ldrb, 7800, f8100000), \
8869 X(_ldrh, 8800, f8300000), \
8870 X(_ldrsb, 5600, f9100000), \
8871 X(_ldrsh, 5e00, f9300000), \
8872 X(_ldr_pc,4800, f85f0000), \
8873 X(_ldr_pc2,4800, f85f0000), \
8874 X(_ldr_sp,9800, f85d0000), \
8875 X(_lsl, 0000, fa00f000), \
8876 X(_lsls, 0000, fa10f000), \
8877 X(_lsr, 0800, fa20f000), \
8878 X(_lsrs, 0800, fa30f000), \
8879 X(_mov, 2000, ea4f0000), \
8880 X(_movs, 2000, ea5f0000), \
8881 X(_mul, 4340, fb00f000), \
8882 X(_muls, 4340, ffffffff), /* no 32b muls */ \
8883 X(_mvn, 43c0, ea6f0000), \
8884 X(_mvns, 43c0, ea7f0000), \
8885 X(_neg, 4240, f1c00000), /* rsb #0 */ \
8886 X(_negs, 4240, f1d00000), /* rsbs #0 */ \
8887 X(_orr, 4300, ea400000), \
8888 X(_orrs, 4300, ea500000), \
8889 X(_pop, bc00, e8bd0000), /* ldmia sp!,... */ \
8890 X(_push, b400, e92d0000), /* stmdb sp!,... */ \
8891 X(_rev, ba00, fa90f080), \
8892 X(_rev16, ba40, fa90f090), \
8893 X(_revsh, bac0, fa90f0b0), \
8894 X(_ror, 41c0, fa60f000), \
8895 X(_rors, 41c0, fa70f000), \
8896 X(_sbc, 4180, eb600000), \
8897 X(_sbcs, 4180, eb700000), \
8898 X(_stmia, c000, e8800000), \
8899 X(_str, 6000, f8400000), \
8900 X(_strb, 7000, f8000000), \
8901 X(_strh, 8000, f8200000), \
8902 X(_str_sp,9000, f84d0000), \
8903 X(_sub, 1e00, eba00000), \
8904 X(_subs, 1e00, ebb00000), \
8905 X(_subi, 8000, f1a00000), \
8906 X(_subis, 8000, f1b00000), \
8907 X(_sxtb, b240, fa4ff080), \
8908 X(_sxth, b200, fa0ff080), \
8909 X(_tst, 4200, ea100f00), \
8910 X(_uxtb, b2c0, fa5ff080), \
8911 X(_uxth, b280, fa1ff080), \
8912 X(_nop, bf00, f3af8000), \
8913 X(_yield, bf10, f3af8001), \
8914 X(_wfe, bf20, f3af8002), \
8915 X(_wfi, bf30, f3af8003), \
8916 X(_sev, bf40, f3af8004),
8918 /* To catch errors in encoding functions, the codes are all offset by
8919 0xF800, putting them in one of the 32-bit prefix ranges, ergo undefined
8920 as 16-bit instructions. */
8921 #define X(a,b,c) T_MNEM##a
8922 enum t16_32_codes
{ T16_32_OFFSET
= 0xF7FF, T16_32_TAB
};
8925 #define X(a,b,c) 0x##b
8926 static const unsigned short thumb_op16
[] = { T16_32_TAB
};
8927 #define THUMB_OP16(n) (thumb_op16[(n) - (T16_32_OFFSET + 1)])
8930 #define X(a,b,c) 0x##c
8931 static const unsigned int thumb_op32
[] = { T16_32_TAB
};
8932 #define THUMB_OP32(n) (thumb_op32[(n) - (T16_32_OFFSET + 1)])
8933 #define THUMB_SETS_FLAGS(n) (THUMB_OP32 (n) & 0x00100000)
8937 /* Thumb instruction encoders, in alphabetical order. */
8942 do_t_add_sub_w (void)
8946 Rd
= inst
.operands
[0].reg
;
8947 Rn
= inst
.operands
[1].reg
;
8949 /* If Rn is REG_PC, this is ADR; if Rn is REG_SP, then this
8950 is the SP-{plus,minus}-immediate form of the instruction. */
8952 constraint (Rd
== REG_PC
, BAD_PC
);
8954 reject_bad_reg (Rd
);
8956 inst
.instruction
|= (Rn
<< 16) | (Rd
<< 8);
8957 inst
.reloc
.type
= BFD_RELOC_ARM_T32_IMM12
;
8960 /* Parse an add or subtract instruction. We get here with inst.instruction
8961 equalling any of THUMB_OPCODE_add, adds, sub, or subs. */
8968 Rd
= inst
.operands
[0].reg
;
8969 Rs
= (inst
.operands
[1].present
8970 ? inst
.operands
[1].reg
/* Rd, Rs, foo */
8971 : inst
.operands
[0].reg
); /* Rd, foo -> Rd, Rd, foo */
8974 set_it_insn_type_last ();
8982 flags
= (inst
.instruction
== T_MNEM_adds
8983 || inst
.instruction
== T_MNEM_subs
);
8985 narrow
= !in_it_block ();
8987 narrow
= in_it_block ();
8988 if (!inst
.operands
[2].isreg
)
8992 constraint (Rd
== REG_SP
&& Rs
!= REG_SP
, BAD_SP
);
8994 add
= (inst
.instruction
== T_MNEM_add
8995 || inst
.instruction
== T_MNEM_adds
);
8997 if (inst
.size_req
!= 4)
8999 /* Attempt to use a narrow opcode, with relaxation if
9001 if (Rd
== REG_SP
&& Rs
== REG_SP
&& !flags
)
9002 opcode
= add
? T_MNEM_inc_sp
: T_MNEM_dec_sp
;
9003 else if (Rd
<= 7 && Rs
== REG_SP
&& add
&& !flags
)
9004 opcode
= T_MNEM_add_sp
;
9005 else if (Rd
<= 7 && Rs
== REG_PC
&& add
&& !flags
)
9006 opcode
= T_MNEM_add_pc
;
9007 else if (Rd
<= 7 && Rs
<= 7 && narrow
)
9010 opcode
= add
? T_MNEM_addis
: T_MNEM_subis
;
9012 opcode
= add
? T_MNEM_addi
: T_MNEM_subi
;
9016 inst
.instruction
= THUMB_OP16(opcode
);
9017 inst
.instruction
|= (Rd
<< 4) | Rs
;
9018 inst
.reloc
.type
= BFD_RELOC_ARM_THUMB_ADD
;
9019 if (inst
.size_req
!= 2)
9020 inst
.relax
= opcode
;
9023 constraint (inst
.size_req
== 2, BAD_HIREG
);
9025 if (inst
.size_req
== 4
9026 || (inst
.size_req
!= 2 && !opcode
))
9030 constraint (add
, BAD_PC
);
9031 constraint (Rs
!= REG_LR
|| inst
.instruction
!= T_MNEM_subs
,
9032 _("only SUBS PC, LR, #const allowed"));
9033 constraint (inst
.reloc
.exp
.X_op
!= O_constant
,
9034 _("expression too complex"));
9035 constraint (inst
.reloc
.exp
.X_add_number
< 0
9036 || inst
.reloc
.exp
.X_add_number
> 0xff,
9037 _("immediate value out of range"));
9038 inst
.instruction
= T2_SUBS_PC_LR
9039 | inst
.reloc
.exp
.X_add_number
;
9040 inst
.reloc
.type
= BFD_RELOC_UNUSED
;
9043 else if (Rs
== REG_PC
)
9045 /* Always use addw/subw. */
9046 inst
.instruction
= add
? 0xf20f0000 : 0xf2af0000;
9047 inst
.reloc
.type
= BFD_RELOC_ARM_T32_IMM12
;
9051 inst
.instruction
= THUMB_OP32 (inst
.instruction
);
9052 inst
.instruction
= (inst
.instruction
& 0xe1ffffff)
9055 inst
.reloc
.type
= BFD_RELOC_ARM_T32_IMMEDIATE
;
9057 inst
.reloc
.type
= BFD_RELOC_ARM_T32_ADD_IMM
;
9059 inst
.instruction
|= Rd
<< 8;
9060 inst
.instruction
|= Rs
<< 16;
9065 Rn
= inst
.operands
[2].reg
;
9066 /* See if we can do this with a 16-bit instruction. */
9067 if (!inst
.operands
[2].shifted
&& inst
.size_req
!= 4)
9069 if (Rd
> 7 || Rs
> 7 || Rn
> 7)
9074 inst
.instruction
= ((inst
.instruction
== T_MNEM_adds
9075 || inst
.instruction
== T_MNEM_add
)
9078 inst
.instruction
|= Rd
| (Rs
<< 3) | (Rn
<< 6);
9082 if (inst
.instruction
== T_MNEM_add
&& (Rd
== Rs
|| Rd
== Rn
))
9084 /* Thumb-1 cores (except v6-M) require at least one high
9085 register in a narrow non flag setting add. */
9086 if (Rd
> 7 || Rn
> 7
9087 || ARM_CPU_HAS_FEATURE (selected_cpu
, arm_ext_v6t2
)
9088 || ARM_CPU_HAS_FEATURE (selected_cpu
, arm_ext_msr
))
9095 inst
.instruction
= T_OPCODE_ADD_HI
;
9096 inst
.instruction
|= (Rd
& 8) << 4;
9097 inst
.instruction
|= (Rd
& 7);
9098 inst
.instruction
|= Rn
<< 3;
9104 constraint (Rd
== REG_PC
, BAD_PC
);
9105 constraint (Rd
== REG_SP
&& Rs
!= REG_SP
, BAD_SP
);
9106 constraint (Rs
== REG_PC
, BAD_PC
);
9107 reject_bad_reg (Rn
);
9109 /* If we get here, it can't be done in 16 bits. */
9110 constraint (inst
.operands
[2].shifted
&& inst
.operands
[2].immisreg
,
9111 _("shift must be constant"));
9112 inst
.instruction
= THUMB_OP32 (inst
.instruction
);
9113 inst
.instruction
|= Rd
<< 8;
9114 inst
.instruction
|= Rs
<< 16;
9115 encode_thumb32_shifted_operand (2);
9120 constraint (inst
.instruction
== T_MNEM_adds
9121 || inst
.instruction
== T_MNEM_subs
,
9124 if (!inst
.operands
[2].isreg
) /* Rd, Rs, #imm */
9126 constraint ((Rd
> 7 && (Rd
!= REG_SP
|| Rs
!= REG_SP
))
9127 || (Rs
> 7 && Rs
!= REG_SP
&& Rs
!= REG_PC
),
9130 inst
.instruction
= (inst
.instruction
== T_MNEM_add
9132 inst
.instruction
|= (Rd
<< 4) | Rs
;
9133 inst
.reloc
.type
= BFD_RELOC_ARM_THUMB_ADD
;
9137 Rn
= inst
.operands
[2].reg
;
9138 constraint (inst
.operands
[2].shifted
, _("unshifted register required"));
9140 /* We now have Rd, Rs, and Rn set to registers. */
9141 if (Rd
> 7 || Rs
> 7 || Rn
> 7)
9143 /* Can't do this for SUB. */
9144 constraint (inst
.instruction
== T_MNEM_sub
, BAD_HIREG
);
9145 inst
.instruction
= T_OPCODE_ADD_HI
;
9146 inst
.instruction
|= (Rd
& 8) << 4;
9147 inst
.instruction
|= (Rd
& 7);
9149 inst
.instruction
|= Rn
<< 3;
9151 inst
.instruction
|= Rs
<< 3;
9153 constraint (1, _("dest must overlap one source register"));
9157 inst
.instruction
= (inst
.instruction
== T_MNEM_add
9158 ? T_OPCODE_ADD_R3
: T_OPCODE_SUB_R3
);
9159 inst
.instruction
|= Rd
| (Rs
<< 3) | (Rn
<< 6);
9169 Rd
= inst
.operands
[0].reg
;
9170 reject_bad_reg (Rd
);
9172 if (unified_syntax
&& inst
.size_req
== 0 && Rd
<= 7)
9174 /* Defer to section relaxation. */
9175 inst
.relax
= inst
.instruction
;
9176 inst
.instruction
= THUMB_OP16 (inst
.instruction
);
9177 inst
.instruction
|= Rd
<< 4;
9179 else if (unified_syntax
&& inst
.size_req
!= 2)
9181 /* Generate a 32-bit opcode. */
9182 inst
.instruction
= THUMB_OP32 (inst
.instruction
);
9183 inst
.instruction
|= Rd
<< 8;
9184 inst
.reloc
.type
= BFD_RELOC_ARM_T32_ADD_PC12
;
9185 inst
.reloc
.pc_rel
= 1;
9189 /* Generate a 16-bit opcode. */
9190 inst
.instruction
= THUMB_OP16 (inst
.instruction
);
9191 inst
.reloc
.type
= BFD_RELOC_ARM_THUMB_ADD
;
9192 inst
.reloc
.exp
.X_add_number
-= 4; /* PC relative adjust. */
9193 inst
.reloc
.pc_rel
= 1;
9195 inst
.instruction
|= Rd
<< 4;
9199 /* Arithmetic instructions for which there is just one 16-bit
9200 instruction encoding, and it allows only two low registers.
9201 For maximal compatibility with ARM syntax, we allow three register
9202 operands even when Thumb-32 instructions are not available, as long
9203 as the first two are identical. For instance, both "sbc r0,r1" and
9204 "sbc r0,r0,r1" are allowed. */
9210 Rd
= inst
.operands
[0].reg
;
9211 Rs
= (inst
.operands
[1].present
9212 ? inst
.operands
[1].reg
/* Rd, Rs, foo */
9213 : inst
.operands
[0].reg
); /* Rd, foo -> Rd, Rd, foo */
9214 Rn
= inst
.operands
[2].reg
;
9216 reject_bad_reg (Rd
);
9217 reject_bad_reg (Rs
);
9218 if (inst
.operands
[2].isreg
)
9219 reject_bad_reg (Rn
);
9223 if (!inst
.operands
[2].isreg
)
9225 /* For an immediate, we always generate a 32-bit opcode;
9226 section relaxation will shrink it later if possible. */
9227 inst
.instruction
= THUMB_OP32 (inst
.instruction
);
9228 inst
.instruction
= (inst
.instruction
& 0xe1ffffff) | 0x10000000;
9229 inst
.instruction
|= Rd
<< 8;
9230 inst
.instruction
|= Rs
<< 16;
9231 inst
.reloc
.type
= BFD_RELOC_ARM_T32_IMMEDIATE
;
9237 /* See if we can do this with a 16-bit instruction. */
9238 if (THUMB_SETS_FLAGS (inst
.instruction
))
9239 narrow
= !in_it_block ();
9241 narrow
= in_it_block ();
9243 if (Rd
> 7 || Rn
> 7 || Rs
> 7)
9245 if (inst
.operands
[2].shifted
)
9247 if (inst
.size_req
== 4)
9253 inst
.instruction
= THUMB_OP16 (inst
.instruction
);
9254 inst
.instruction
|= Rd
;
9255 inst
.instruction
|= Rn
<< 3;
9259 /* If we get here, it can't be done in 16 bits. */
9260 constraint (inst
.operands
[2].shifted
9261 && inst
.operands
[2].immisreg
,
9262 _("shift must be constant"));
9263 inst
.instruction
= THUMB_OP32 (inst
.instruction
);
9264 inst
.instruction
|= Rd
<< 8;
9265 inst
.instruction
|= Rs
<< 16;
9266 encode_thumb32_shifted_operand (2);
9271 /* On its face this is a lie - the instruction does set the
9272 flags. However, the only supported mnemonic in this mode
9274 constraint (THUMB_SETS_FLAGS (inst
.instruction
), BAD_THUMB32
);
9276 constraint (!inst
.operands
[2].isreg
|| inst
.operands
[2].shifted
,
9277 _("unshifted register required"));
9278 constraint (Rd
> 7 || Rs
> 7 || Rn
> 7, BAD_HIREG
);
9279 constraint (Rd
!= Rs
,
9280 _("dest and source1 must be the same register"));
9282 inst
.instruction
= THUMB_OP16 (inst
.instruction
);
9283 inst
.instruction
|= Rd
;
9284 inst
.instruction
|= Rn
<< 3;
9288 /* Similarly, but for instructions where the arithmetic operation is
9289 commutative, so we can allow either of them to be different from
9290 the destination operand in a 16-bit instruction. For instance, all
9291 three of "adc r0,r1", "adc r0,r0,r1", and "adc r0,r1,r0" are
9298 Rd
= inst
.operands
[0].reg
;
9299 Rs
= (inst
.operands
[1].present
9300 ? inst
.operands
[1].reg
/* Rd, Rs, foo */
9301 : inst
.operands
[0].reg
); /* Rd, foo -> Rd, Rd, foo */
9302 Rn
= inst
.operands
[2].reg
;
9304 reject_bad_reg (Rd
);
9305 reject_bad_reg (Rs
);
9306 if (inst
.operands
[2].isreg
)
9307 reject_bad_reg (Rn
);
9311 if (!inst
.operands
[2].isreg
)
9313 /* For an immediate, we always generate a 32-bit opcode;
9314 section relaxation will shrink it later if possible. */
9315 inst
.instruction
= THUMB_OP32 (inst
.instruction
);
9316 inst
.instruction
= (inst
.instruction
& 0xe1ffffff) | 0x10000000;
9317 inst
.instruction
|= Rd
<< 8;
9318 inst
.instruction
|= Rs
<< 16;
9319 inst
.reloc
.type
= BFD_RELOC_ARM_T32_IMMEDIATE
;
9325 /* See if we can do this with a 16-bit instruction. */
9326 if (THUMB_SETS_FLAGS (inst
.instruction
))
9327 narrow
= !in_it_block ();
9329 narrow
= in_it_block ();
9331 if (Rd
> 7 || Rn
> 7 || Rs
> 7)
9333 if (inst
.operands
[2].shifted
)
9335 if (inst
.size_req
== 4)
9342 inst
.instruction
= THUMB_OP16 (inst
.instruction
);
9343 inst
.instruction
|= Rd
;
9344 inst
.instruction
|= Rn
<< 3;
9349 inst
.instruction
= THUMB_OP16 (inst
.instruction
);
9350 inst
.instruction
|= Rd
;
9351 inst
.instruction
|= Rs
<< 3;
9356 /* If we get here, it can't be done in 16 bits. */
9357 constraint (inst
.operands
[2].shifted
9358 && inst
.operands
[2].immisreg
,
9359 _("shift must be constant"));
9360 inst
.instruction
= THUMB_OP32 (inst
.instruction
);
9361 inst
.instruction
|= Rd
<< 8;
9362 inst
.instruction
|= Rs
<< 16;
9363 encode_thumb32_shifted_operand (2);
9368 /* On its face this is a lie - the instruction does set the
9369 flags. However, the only supported mnemonic in this mode
9371 constraint (THUMB_SETS_FLAGS (inst
.instruction
), BAD_THUMB32
);
9373 constraint (!inst
.operands
[2].isreg
|| inst
.operands
[2].shifted
,
9374 _("unshifted register required"));
9375 constraint (Rd
> 7 || Rs
> 7 || Rn
> 7, BAD_HIREG
);
9377 inst
.instruction
= THUMB_OP16 (inst
.instruction
);
9378 inst
.instruction
|= Rd
;
9381 inst
.instruction
|= Rn
<< 3;
9383 inst
.instruction
|= Rs
<< 3;
9385 constraint (1, _("dest must overlap one source register"));
9392 if (inst
.operands
[0].present
)
9394 constraint ((inst
.instruction
& 0xf0) != 0x40
9395 && inst
.operands
[0].imm
!= 0xf,
9396 _("bad barrier type"));
9397 inst
.instruction
|= inst
.operands
[0].imm
;
9400 inst
.instruction
|= 0xf;
9407 unsigned int msb
= inst
.operands
[1].imm
+ inst
.operands
[2].imm
;
9408 constraint (msb
> 32, _("bit-field extends past end of register"));
9409 /* The instruction encoding stores the LSB and MSB,
9410 not the LSB and width. */
9411 Rd
= inst
.operands
[0].reg
;
9412 reject_bad_reg (Rd
);
9413 inst
.instruction
|= Rd
<< 8;
9414 inst
.instruction
|= (inst
.operands
[1].imm
& 0x1c) << 10;
9415 inst
.instruction
|= (inst
.operands
[1].imm
& 0x03) << 6;
9416 inst
.instruction
|= msb
- 1;
9425 Rd
= inst
.operands
[0].reg
;
9426 reject_bad_reg (Rd
);
9428 /* #0 in second position is alternative syntax for bfc, which is
9429 the same instruction but with REG_PC in the Rm field. */
9430 if (!inst
.operands
[1].isreg
)
9434 Rn
= inst
.operands
[1].reg
;
9435 reject_bad_reg (Rn
);
9438 msb
= inst
.operands
[2].imm
+ inst
.operands
[3].imm
;
9439 constraint (msb
> 32, _("bit-field extends past end of register"));
9440 /* The instruction encoding stores the LSB and MSB,
9441 not the LSB and width. */
9442 inst
.instruction
|= Rd
<< 8;
9443 inst
.instruction
|= Rn
<< 16;
9444 inst
.instruction
|= (inst
.operands
[2].imm
& 0x1c) << 10;
9445 inst
.instruction
|= (inst
.operands
[2].imm
& 0x03) << 6;
9446 inst
.instruction
|= msb
- 1;
9454 Rd
= inst
.operands
[0].reg
;
9455 Rn
= inst
.operands
[1].reg
;
9457 reject_bad_reg (Rd
);
9458 reject_bad_reg (Rn
);
9460 constraint (inst
.operands
[2].imm
+ inst
.operands
[3].imm
> 32,
9461 _("bit-field extends past end of register"));
9462 inst
.instruction
|= Rd
<< 8;
9463 inst
.instruction
|= Rn
<< 16;
9464 inst
.instruction
|= (inst
.operands
[2].imm
& 0x1c) << 10;
9465 inst
.instruction
|= (inst
.operands
[2].imm
& 0x03) << 6;
9466 inst
.instruction
|= inst
.operands
[3].imm
- 1;
9469 /* ARM V5 Thumb BLX (argument parse)
9470 BLX <target_addr> which is BLX(1)
9471 BLX <Rm> which is BLX(2)
9472 Unfortunately, there are two different opcodes for this mnemonic.
9473 So, the insns[].value is not used, and the code here zaps values
9474 into inst.instruction.
9476 ??? How to take advantage of the additional two bits of displacement
9477 available in Thumb32 mode? Need new relocation? */
9482 set_it_insn_type_last ();
9484 if (inst
.operands
[0].isreg
)
9486 constraint (inst
.operands
[0].reg
== REG_PC
, BAD_PC
);
9487 /* We have a register, so this is BLX(2). */
9488 inst
.instruction
|= inst
.operands
[0].reg
<< 3;
9492 /* No register. This must be BLX(1). */
9493 inst
.instruction
= 0xf000e800;
9494 inst
.reloc
.type
= BFD_RELOC_THUMB_PCREL_BLX
;
9495 inst
.reloc
.pc_rel
= 1;
9506 set_it_insn_type (IF_INSIDE_IT_LAST_INSN
);
9510 /* Conditional branches inside IT blocks are encoded as unconditional
9517 if (cond
!= COND_ALWAYS
)
9518 opcode
= T_MNEM_bcond
;
9520 opcode
= inst
.instruction
;
9522 if (unified_syntax
&& inst
.size_req
== 4)
9524 inst
.instruction
= THUMB_OP32(opcode
);
9525 if (cond
== COND_ALWAYS
)
9526 inst
.reloc
.type
= BFD_RELOC_THUMB_PCREL_BRANCH25
;
9529 gas_assert (cond
!= 0xF);
9530 inst
.instruction
|= cond
<< 22;
9531 inst
.reloc
.type
= BFD_RELOC_THUMB_PCREL_BRANCH20
;
9536 inst
.instruction
= THUMB_OP16(opcode
);
9537 if (cond
== COND_ALWAYS
)
9538 inst
.reloc
.type
= BFD_RELOC_THUMB_PCREL_BRANCH12
;
9541 inst
.instruction
|= cond
<< 8;
9542 inst
.reloc
.type
= BFD_RELOC_THUMB_PCREL_BRANCH9
;
9544 /* Allow section relaxation. */
9545 if (unified_syntax
&& inst
.size_req
!= 2)
9546 inst
.relax
= opcode
;
9549 inst
.reloc
.pc_rel
= 1;
9555 constraint (inst
.cond
!= COND_ALWAYS
,
9556 _("instruction is always unconditional"));
9557 if (inst
.operands
[0].present
)
9559 constraint (inst
.operands
[0].imm
> 255,
9560 _("immediate value out of range"));
9561 inst
.instruction
|= inst
.operands
[0].imm
;
9562 set_it_insn_type (NEUTRAL_IT_INSN
);
9567 do_t_branch23 (void)
9569 set_it_insn_type_last ();
9570 inst
.reloc
.type
= BFD_RELOC_THUMB_PCREL_BRANCH23
;
9571 inst
.reloc
.pc_rel
= 1;
9573 #if defined(OBJ_COFF)
9574 /* If the destination of the branch is a defined symbol which does not have
9575 the THUMB_FUNC attribute, then we must be calling a function which has
9576 the (interfacearm) attribute. We look for the Thumb entry point to that
9577 function and change the branch to refer to that function instead. */
9578 if ( inst
.reloc
.exp
.X_op
== O_symbol
9579 && inst
.reloc
.exp
.X_add_symbol
!= NULL
9580 && S_IS_DEFINED (inst
.reloc
.exp
.X_add_symbol
)
9581 && ! THUMB_IS_FUNC (inst
.reloc
.exp
.X_add_symbol
))
9582 inst
.reloc
.exp
.X_add_symbol
=
9583 find_real_start (inst
.reloc
.exp
.X_add_symbol
);
9590 set_it_insn_type_last ();
9591 inst
.instruction
|= inst
.operands
[0].reg
<< 3;
9592 /* ??? FIXME: Should add a hacky reloc here if reg is REG_PC. The reloc
9593 should cause the alignment to be checked once it is known. This is
9594 because BX PC only works if the instruction is word aligned. */
9602 set_it_insn_type_last ();
9603 Rm
= inst
.operands
[0].reg
;
9604 reject_bad_reg (Rm
);
9605 inst
.instruction
|= Rm
<< 16;
9614 Rd
= inst
.operands
[0].reg
;
9615 Rm
= inst
.operands
[1].reg
;
9617 reject_bad_reg (Rd
);
9618 reject_bad_reg (Rm
);
9620 inst
.instruction
|= Rd
<< 8;
9621 inst
.instruction
|= Rm
<< 16;
9622 inst
.instruction
|= Rm
;
9628 set_it_insn_type (OUTSIDE_IT_INSN
);
9629 inst
.instruction
|= inst
.operands
[0].imm
;
9635 set_it_insn_type (OUTSIDE_IT_INSN
);
9637 && (inst
.operands
[1].present
|| inst
.size_req
== 4)
9638 && ARM_CPU_HAS_FEATURE (cpu_variant
, arm_ext_v6_notm
))
9640 unsigned int imod
= (inst
.instruction
& 0x0030) >> 4;
9641 inst
.instruction
= 0xf3af8000;
9642 inst
.instruction
|= imod
<< 9;
9643 inst
.instruction
|= inst
.operands
[0].imm
<< 5;
9644 if (inst
.operands
[1].present
)
9645 inst
.instruction
|= 0x100 | inst
.operands
[1].imm
;
9649 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant
, arm_ext_v1
)
9650 && (inst
.operands
[0].imm
& 4),
9651 _("selected processor does not support 'A' form "
9652 "of this instruction"));
9653 constraint (inst
.operands
[1].present
|| inst
.size_req
== 4,
9654 _("Thumb does not support the 2-argument "
9655 "form of this instruction"));
9656 inst
.instruction
|= inst
.operands
[0].imm
;
9660 /* THUMB CPY instruction (argument parse). */
9665 if (inst
.size_req
== 4)
9667 inst
.instruction
= THUMB_OP32 (T_MNEM_mov
);
9668 inst
.instruction
|= inst
.operands
[0].reg
<< 8;
9669 inst
.instruction
|= inst
.operands
[1].reg
;
9673 inst
.instruction
|= (inst
.operands
[0].reg
& 0x8) << 4;
9674 inst
.instruction
|= (inst
.operands
[0].reg
& 0x7);
9675 inst
.instruction
|= inst
.operands
[1].reg
<< 3;
9682 set_it_insn_type (OUTSIDE_IT_INSN
);
9683 constraint (inst
.operands
[0].reg
> 7, BAD_HIREG
);
9684 inst
.instruction
|= inst
.operands
[0].reg
;
9685 inst
.reloc
.pc_rel
= 1;
9686 inst
.reloc
.type
= BFD_RELOC_THUMB_PCREL_BRANCH7
;
9692 inst
.instruction
|= inst
.operands
[0].imm
;
9698 unsigned Rd
, Rn
, Rm
;
9700 Rd
= inst
.operands
[0].reg
;
9701 Rn
= (inst
.operands
[1].present
9702 ? inst
.operands
[1].reg
: Rd
);
9703 Rm
= inst
.operands
[2].reg
;
9705 reject_bad_reg (Rd
);
9706 reject_bad_reg (Rn
);
9707 reject_bad_reg (Rm
);
9709 inst
.instruction
|= Rd
<< 8;
9710 inst
.instruction
|= Rn
<< 16;
9711 inst
.instruction
|= Rm
;
9717 if (unified_syntax
&& inst
.size_req
== 4)
9718 inst
.instruction
= THUMB_OP32 (inst
.instruction
);
9720 inst
.instruction
= THUMB_OP16 (inst
.instruction
);
9726 unsigned int cond
= inst
.operands
[0].imm
;
9728 set_it_insn_type (IT_INSN
);
9729 now_it
.mask
= (inst
.instruction
& 0xf) | 0x10;
9732 /* If the condition is a negative condition, invert the mask. */
9733 if ((cond
& 0x1) == 0x0)
9735 unsigned int mask
= inst
.instruction
& 0x000f;
9737 if ((mask
& 0x7) == 0)
9738 /* no conversion needed */;
9739 else if ((mask
& 0x3) == 0)
9741 else if ((mask
& 0x1) == 0)
9746 inst
.instruction
&= 0xfff0;
9747 inst
.instruction
|= mask
;
9750 inst
.instruction
|= cond
<< 4;
9753 /* Helper function used for both push/pop and ldm/stm. */
9755 encode_thumb2_ldmstm (int base
, unsigned mask
, bfd_boolean writeback
)
9759 load
= (inst
.instruction
& (1 << 20)) != 0;
9761 if (mask
& (1 << 13))
9762 inst
.error
= _("SP not allowed in register list");
9765 if (mask
& (1 << 15))
9767 if (mask
& (1 << 14))
9768 inst
.error
= _("LR and PC should not both be in register list");
9770 set_it_insn_type_last ();
9773 if ((mask
& (1 << base
)) != 0
9775 as_warn (_("base register should not be in register list "
9776 "when written back"));
9780 if (mask
& (1 << 15))
9781 inst
.error
= _("PC not allowed in register list");
9783 if (mask
& (1 << base
))
9784 as_warn (_("value stored for r%d is UNPREDICTABLE"), base
);
9787 if ((mask
& (mask
- 1)) == 0)
9789 /* Single register transfers implemented as str/ldr. */
9792 if (inst
.instruction
& (1 << 23))
9793 inst
.instruction
= 0x00000b04; /* ia! -> [base], #4 */
9795 inst
.instruction
= 0x00000d04; /* db! -> [base, #-4]! */
9799 if (inst
.instruction
& (1 << 23))
9800 inst
.instruction
= 0x00800000; /* ia -> [base] */
9802 inst
.instruction
= 0x00000c04; /* db -> [base, #-4] */
9805 inst
.instruction
|= 0xf8400000;
9807 inst
.instruction
|= 0x00100000;
9809 mask
= ffs (mask
) - 1;
9813 inst
.instruction
|= WRITE_BACK
;
9815 inst
.instruction
|= mask
;
9816 inst
.instruction
|= base
<< 16;
9822 /* This really doesn't seem worth it. */
9823 constraint (inst
.reloc
.type
!= BFD_RELOC_UNUSED
,
9824 _("expression too complex"));
9825 constraint (inst
.operands
[1].writeback
,
9826 _("Thumb load/store multiple does not support {reglist}^"));
9834 /* See if we can use a 16-bit instruction. */
9835 if (inst
.instruction
< 0xffff /* not ldmdb/stmdb */
9836 && inst
.size_req
!= 4
9837 && !(inst
.operands
[1].imm
& ~0xff))
9839 mask
= 1 << inst
.operands
[0].reg
;
9841 if (inst
.operands
[0].reg
<= 7
9842 && (inst
.instruction
== T_MNEM_stmia
9843 ? inst
.operands
[0].writeback
9844 : (inst
.operands
[0].writeback
9845 == !(inst
.operands
[1].imm
& mask
))))
9847 if (inst
.instruction
== T_MNEM_stmia
9848 && (inst
.operands
[1].imm
& mask
)
9849 && (inst
.operands
[1].imm
& (mask
- 1)))
9850 as_warn (_("value stored for r%d is UNPREDICTABLE"),
9851 inst
.operands
[0].reg
);
9853 inst
.instruction
= THUMB_OP16 (inst
.instruction
);
9854 inst
.instruction
|= inst
.operands
[0].reg
<< 8;
9855 inst
.instruction
|= inst
.operands
[1].imm
;
9858 else if (inst
.operands
[0] .reg
== REG_SP
9859 && inst
.operands
[0].writeback
)
9861 inst
.instruction
= THUMB_OP16 (inst
.instruction
== T_MNEM_stmia
9862 ? T_MNEM_push
: T_MNEM_pop
);
9863 inst
.instruction
|= inst
.operands
[1].imm
;
9870 if (inst
.instruction
< 0xffff)
9871 inst
.instruction
= THUMB_OP32 (inst
.instruction
);
9873 encode_thumb2_ldmstm (inst
.operands
[0].reg
, inst
.operands
[1].imm
,
9874 inst
.operands
[0].writeback
);
9879 constraint (inst
.operands
[0].reg
> 7
9880 || (inst
.operands
[1].imm
& ~0xff), BAD_HIREG
);
9881 constraint (inst
.instruction
!= T_MNEM_ldmia
9882 && inst
.instruction
!= T_MNEM_stmia
,
9883 _("Thumb-2 instruction only valid in unified syntax"));
9884 if (inst
.instruction
== T_MNEM_stmia
)
9886 if (!inst
.operands
[0].writeback
)
9887 as_warn (_("this instruction will write back the base register"));
9888 if ((inst
.operands
[1].imm
& (1 << inst
.operands
[0].reg
))
9889 && (inst
.operands
[1].imm
& ((1 << inst
.operands
[0].reg
) - 1)))
9890 as_warn (_("value stored for r%d is UNPREDICTABLE"),
9891 inst
.operands
[0].reg
);
9895 if (!inst
.operands
[0].writeback
9896 && !(inst
.operands
[1].imm
& (1 << inst
.operands
[0].reg
)))
9897 as_warn (_("this instruction will write back the base register"));
9898 else if (inst
.operands
[0].writeback
9899 && (inst
.operands
[1].imm
& (1 << inst
.operands
[0].reg
)))
9900 as_warn (_("this instruction will not write back the base register"));
9903 inst
.instruction
= THUMB_OP16 (inst
.instruction
);
9904 inst
.instruction
|= inst
.operands
[0].reg
<< 8;
9905 inst
.instruction
|= inst
.operands
[1].imm
;
9912 constraint (!inst
.operands
[1].isreg
|| !inst
.operands
[1].preind
9913 || inst
.operands
[1].postind
|| inst
.operands
[1].writeback
9914 || inst
.operands
[1].immisreg
|| inst
.operands
[1].shifted
9915 || inst
.operands
[1].negative
,
9918 constraint ((inst
.operands
[1].reg
== REG_PC
), BAD_PC
);
9920 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
9921 inst
.instruction
|= inst
.operands
[1].reg
<< 16;
9922 inst
.reloc
.type
= BFD_RELOC_ARM_T32_OFFSET_U8
;
9928 if (!inst
.operands
[1].present
)
9930 constraint (inst
.operands
[0].reg
== REG_LR
,
9931 _("r14 not allowed as first register "
9932 "when second register is omitted"));
9933 inst
.operands
[1].reg
= inst
.operands
[0].reg
+ 1;
9935 constraint (inst
.operands
[0].reg
== inst
.operands
[1].reg
,
9938 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
9939 inst
.instruction
|= inst
.operands
[1].reg
<< 8;
9940 inst
.instruction
|= inst
.operands
[2].reg
<< 16;
9946 unsigned long opcode
;
9949 if (inst
.operands
[0].isreg
9950 && !inst
.operands
[0].preind
9951 && inst
.operands
[0].reg
== REG_PC
)
9952 set_it_insn_type_last ();
9954 opcode
= inst
.instruction
;
9957 if (!inst
.operands
[1].isreg
)
9959 if (opcode
<= 0xffff)
9960 inst
.instruction
= THUMB_OP32 (opcode
);
9961 if (move_or_literal_pool (0, /*thumb_p=*/TRUE
, /*mode_3=*/FALSE
))
9964 if (inst
.operands
[1].isreg
9965 && !inst
.operands
[1].writeback
9966 && !inst
.operands
[1].shifted
&& !inst
.operands
[1].postind
9967 && !inst
.operands
[1].negative
&& inst
.operands
[0].reg
<= 7
9969 && inst
.size_req
!= 4)
9971 /* Insn may have a 16-bit form. */
9972 Rn
= inst
.operands
[1].reg
;
9973 if (inst
.operands
[1].immisreg
)
9975 inst
.instruction
= THUMB_OP16 (opcode
);
9977 if (Rn
<= 7 && inst
.operands
[1].imm
<= 7)
9979 else if (opcode
!= T_MNEM_ldr
&& opcode
!= T_MNEM_str
)
9980 reject_bad_reg (inst
.operands
[1].imm
);
9982 else if ((Rn
<= 7 && opcode
!= T_MNEM_ldrsh
9983 && opcode
!= T_MNEM_ldrsb
)
9984 || ((Rn
== REG_PC
|| Rn
== REG_SP
) && opcode
== T_MNEM_ldr
)
9985 || (Rn
== REG_SP
&& opcode
== T_MNEM_str
))
9992 if (inst
.reloc
.pc_rel
)
9993 opcode
= T_MNEM_ldr_pc2
;
9995 opcode
= T_MNEM_ldr_pc
;
9999 if (opcode
== T_MNEM_ldr
)
10000 opcode
= T_MNEM_ldr_sp
;
10002 opcode
= T_MNEM_str_sp
;
10004 inst
.instruction
= inst
.operands
[0].reg
<< 8;
10008 inst
.instruction
= inst
.operands
[0].reg
;
10009 inst
.instruction
|= inst
.operands
[1].reg
<< 3;
10011 inst
.instruction
|= THUMB_OP16 (opcode
);
10012 if (inst
.size_req
== 2)
10013 inst
.reloc
.type
= BFD_RELOC_ARM_THUMB_OFFSET
;
10015 inst
.relax
= opcode
;
10019 /* Definitely a 32-bit variant. */
10021 /* Do some validations regarding addressing modes. */
10022 if (inst
.operands
[1].immisreg
&& opcode
!= T_MNEM_ldr
10023 && opcode
!= T_MNEM_str
)
10024 reject_bad_reg (inst
.operands
[1].imm
);
10026 inst
.instruction
= THUMB_OP32 (opcode
);
10027 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
10028 encode_thumb32_addr_mode (1, /*is_t=*/FALSE
, /*is_d=*/FALSE
);
10032 constraint (inst
.operands
[0].reg
> 7, BAD_HIREG
);
10034 if (inst
.instruction
== T_MNEM_ldrsh
|| inst
.instruction
== T_MNEM_ldrsb
)
10036 /* Only [Rn,Rm] is acceptable. */
10037 constraint (inst
.operands
[1].reg
> 7 || inst
.operands
[1].imm
> 7, BAD_HIREG
);
10038 constraint (!inst
.operands
[1].isreg
|| !inst
.operands
[1].immisreg
10039 || inst
.operands
[1].postind
|| inst
.operands
[1].shifted
10040 || inst
.operands
[1].negative
,
10041 _("Thumb does not support this addressing mode"));
10042 inst
.instruction
= THUMB_OP16 (inst
.instruction
);
10046 inst
.instruction
= THUMB_OP16 (inst
.instruction
);
10047 if (!inst
.operands
[1].isreg
)
10048 if (move_or_literal_pool (0, /*thumb_p=*/TRUE
, /*mode_3=*/FALSE
))
10051 constraint (!inst
.operands
[1].preind
10052 || inst
.operands
[1].shifted
10053 || inst
.operands
[1].writeback
,
10054 _("Thumb does not support this addressing mode"));
10055 if (inst
.operands
[1].reg
== REG_PC
|| inst
.operands
[1].reg
== REG_SP
)
10057 constraint (inst
.instruction
& 0x0600,
10058 _("byte or halfword not valid for base register"));
10059 constraint (inst
.operands
[1].reg
== REG_PC
10060 && !(inst
.instruction
& THUMB_LOAD_BIT
),
10061 _("r15 based store not allowed"));
10062 constraint (inst
.operands
[1].immisreg
,
10063 _("invalid base register for register offset"));
10065 if (inst
.operands
[1].reg
== REG_PC
)
10066 inst
.instruction
= T_OPCODE_LDR_PC
;
10067 else if (inst
.instruction
& THUMB_LOAD_BIT
)
10068 inst
.instruction
= T_OPCODE_LDR_SP
;
10070 inst
.instruction
= T_OPCODE_STR_SP
;
10072 inst
.instruction
|= inst
.operands
[0].reg
<< 8;
10073 inst
.reloc
.type
= BFD_RELOC_ARM_THUMB_OFFSET
;
10077 constraint (inst
.operands
[1].reg
> 7, BAD_HIREG
);
10078 if (!inst
.operands
[1].immisreg
)
10080 /* Immediate offset. */
10081 inst
.instruction
|= inst
.operands
[0].reg
;
10082 inst
.instruction
|= inst
.operands
[1].reg
<< 3;
10083 inst
.reloc
.type
= BFD_RELOC_ARM_THUMB_OFFSET
;
10087 /* Register offset. */
10088 constraint (inst
.operands
[1].imm
> 7, BAD_HIREG
);
10089 constraint (inst
.operands
[1].negative
,
10090 _("Thumb does not support this addressing mode"));
10093 switch (inst
.instruction
)
10095 case T_OPCODE_STR_IW
: inst
.instruction
= T_OPCODE_STR_RW
; break;
10096 case T_OPCODE_STR_IH
: inst
.instruction
= T_OPCODE_STR_RH
; break;
10097 case T_OPCODE_STR_IB
: inst
.instruction
= T_OPCODE_STR_RB
; break;
10098 case T_OPCODE_LDR_IW
: inst
.instruction
= T_OPCODE_LDR_RW
; break;
10099 case T_OPCODE_LDR_IH
: inst
.instruction
= T_OPCODE_LDR_RH
; break;
10100 case T_OPCODE_LDR_IB
: inst
.instruction
= T_OPCODE_LDR_RB
; break;
10101 case 0x5600 /* ldrsb */:
10102 case 0x5e00 /* ldrsh */: break;
10106 inst
.instruction
|= inst
.operands
[0].reg
;
10107 inst
.instruction
|= inst
.operands
[1].reg
<< 3;
10108 inst
.instruction
|= inst
.operands
[1].imm
<< 6;
10114 if (!inst
.operands
[1].present
)
10116 inst
.operands
[1].reg
= inst
.operands
[0].reg
+ 1;
10117 constraint (inst
.operands
[0].reg
== REG_LR
,
10118 _("r14 not allowed here"));
10120 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
10121 inst
.instruction
|= inst
.operands
[1].reg
<< 8;
10122 encode_thumb32_addr_mode (2, /*is_t=*/FALSE
, /*is_d=*/TRUE
);
10128 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
10129 encode_thumb32_addr_mode (1, /*is_t=*/TRUE
, /*is_d=*/FALSE
);
10135 unsigned Rd
, Rn
, Rm
, Ra
;
10137 Rd
= inst
.operands
[0].reg
;
10138 Rn
= inst
.operands
[1].reg
;
10139 Rm
= inst
.operands
[2].reg
;
10140 Ra
= inst
.operands
[3].reg
;
10142 reject_bad_reg (Rd
);
10143 reject_bad_reg (Rn
);
10144 reject_bad_reg (Rm
);
10145 reject_bad_reg (Ra
);
10147 inst
.instruction
|= Rd
<< 8;
10148 inst
.instruction
|= Rn
<< 16;
10149 inst
.instruction
|= Rm
;
10150 inst
.instruction
|= Ra
<< 12;
10156 unsigned RdLo
, RdHi
, Rn
, Rm
;
10158 RdLo
= inst
.operands
[0].reg
;
10159 RdHi
= inst
.operands
[1].reg
;
10160 Rn
= inst
.operands
[2].reg
;
10161 Rm
= inst
.operands
[3].reg
;
10163 reject_bad_reg (RdLo
);
10164 reject_bad_reg (RdHi
);
10165 reject_bad_reg (Rn
);
10166 reject_bad_reg (Rm
);
10168 inst
.instruction
|= RdLo
<< 12;
10169 inst
.instruction
|= RdHi
<< 8;
10170 inst
.instruction
|= Rn
<< 16;
10171 inst
.instruction
|= Rm
;
10175 do_t_mov_cmp (void)
10179 Rn
= inst
.operands
[0].reg
;
10180 Rm
= inst
.operands
[1].reg
;
10183 set_it_insn_type_last ();
10185 if (unified_syntax
)
10187 int r0off
= (inst
.instruction
== T_MNEM_mov
10188 || inst
.instruction
== T_MNEM_movs
) ? 8 : 16;
10189 unsigned long opcode
;
10190 bfd_boolean narrow
;
10191 bfd_boolean low_regs
;
10193 low_regs
= (Rn
<= 7 && Rm
<= 7);
10194 opcode
= inst
.instruction
;
10195 if (in_it_block ())
10196 narrow
= opcode
!= T_MNEM_movs
;
10198 narrow
= opcode
!= T_MNEM_movs
|| low_regs
;
10199 if (inst
.size_req
== 4
10200 || inst
.operands
[1].shifted
)
10203 /* MOVS PC, LR is encoded as SUBS PC, LR, #0. */
10204 if (opcode
== T_MNEM_movs
&& inst
.operands
[1].isreg
10205 && !inst
.operands
[1].shifted
10209 inst
.instruction
= T2_SUBS_PC_LR
;
10213 if (opcode
== T_MNEM_cmp
)
10215 constraint (Rn
== REG_PC
, BAD_PC
);
10218 /* In the Thumb-2 ISA, use of R13 as Rm is deprecated,
10220 warn_deprecated_sp (Rm
);
10221 /* R15 was documented as a valid choice for Rm in ARMv6,
10222 but as UNPREDICTABLE in ARMv7. ARM's proprietary
10223 tools reject R15, so we do too. */
10224 constraint (Rm
== REG_PC
, BAD_PC
);
10227 reject_bad_reg (Rm
);
10229 else if (opcode
== T_MNEM_mov
10230 || opcode
== T_MNEM_movs
)
10232 if (inst
.operands
[1].isreg
)
10234 if (opcode
== T_MNEM_movs
)
10236 reject_bad_reg (Rn
);
10237 reject_bad_reg (Rm
);
10239 else if ((Rn
== REG_SP
|| Rn
== REG_PC
)
10240 && (Rm
== REG_SP
|| Rm
== REG_PC
))
10241 reject_bad_reg (Rm
);
10244 reject_bad_reg (Rn
);
10247 if (!inst
.operands
[1].isreg
)
10249 /* Immediate operand. */
10250 if (!in_it_block () && opcode
== T_MNEM_mov
)
10252 if (low_regs
&& narrow
)
10254 inst
.instruction
= THUMB_OP16 (opcode
);
10255 inst
.instruction
|= Rn
<< 8;
10256 if (inst
.size_req
== 2)
10257 inst
.reloc
.type
= BFD_RELOC_ARM_THUMB_IMM
;
10259 inst
.relax
= opcode
;
10263 inst
.instruction
= THUMB_OP32 (inst
.instruction
);
10264 inst
.instruction
= (inst
.instruction
& 0xe1ffffff) | 0x10000000;
10265 inst
.instruction
|= Rn
<< r0off
;
10266 inst
.reloc
.type
= BFD_RELOC_ARM_T32_IMMEDIATE
;
10269 else if (inst
.operands
[1].shifted
&& inst
.operands
[1].immisreg
10270 && (inst
.instruction
== T_MNEM_mov
10271 || inst
.instruction
== T_MNEM_movs
))
10273 /* Register shifts are encoded as separate shift instructions. */
10274 bfd_boolean flags
= (inst
.instruction
== T_MNEM_movs
);
10276 if (in_it_block ())
10281 if (inst
.size_req
== 4)
10284 if (!low_regs
|| inst
.operands
[1].imm
> 7)
10290 switch (inst
.operands
[1].shift_kind
)
10293 opcode
= narrow
? T_OPCODE_LSL_R
: THUMB_OP32 (T_MNEM_lsl
);
10296 opcode
= narrow
? T_OPCODE_ASR_R
: THUMB_OP32 (T_MNEM_asr
);
10299 opcode
= narrow
? T_OPCODE_LSR_R
: THUMB_OP32 (T_MNEM_lsr
);
10302 opcode
= narrow
? T_OPCODE_ROR_R
: THUMB_OP32 (T_MNEM_ror
);
10308 inst
.instruction
= opcode
;
10311 inst
.instruction
|= Rn
;
10312 inst
.instruction
|= inst
.operands
[1].imm
<< 3;
10317 inst
.instruction
|= CONDS_BIT
;
10319 inst
.instruction
|= Rn
<< 8;
10320 inst
.instruction
|= Rm
<< 16;
10321 inst
.instruction
|= inst
.operands
[1].imm
;
10326 /* Some mov with immediate shift have narrow variants.
10327 Register shifts are handled above. */
10328 if (low_regs
&& inst
.operands
[1].shifted
10329 && (inst
.instruction
== T_MNEM_mov
10330 || inst
.instruction
== T_MNEM_movs
))
10332 if (in_it_block ())
10333 narrow
= (inst
.instruction
== T_MNEM_mov
);
10335 narrow
= (inst
.instruction
== T_MNEM_movs
);
10340 switch (inst
.operands
[1].shift_kind
)
10342 case SHIFT_LSL
: inst
.instruction
= T_OPCODE_LSL_I
; break;
10343 case SHIFT_LSR
: inst
.instruction
= T_OPCODE_LSR_I
; break;
10344 case SHIFT_ASR
: inst
.instruction
= T_OPCODE_ASR_I
; break;
10345 default: narrow
= FALSE
; break;
10351 inst
.instruction
|= Rn
;
10352 inst
.instruction
|= Rm
<< 3;
10353 inst
.reloc
.type
= BFD_RELOC_ARM_THUMB_SHIFT
;
10357 inst
.instruction
= THUMB_OP32 (inst
.instruction
);
10358 inst
.instruction
|= Rn
<< r0off
;
10359 encode_thumb32_shifted_operand (1);
10363 switch (inst
.instruction
)
10366 inst
.instruction
= T_OPCODE_MOV_HR
;
10367 inst
.instruction
|= (Rn
& 0x8) << 4;
10368 inst
.instruction
|= (Rn
& 0x7);
10369 inst
.instruction
|= Rm
<< 3;
10373 /* We know we have low registers at this point.
10374 Generate ADD Rd, Rs, #0. */
10375 inst
.instruction
= T_OPCODE_ADD_I3
;
10376 inst
.instruction
|= Rn
;
10377 inst
.instruction
|= Rm
<< 3;
10383 inst
.instruction
= T_OPCODE_CMP_LR
;
10384 inst
.instruction
|= Rn
;
10385 inst
.instruction
|= Rm
<< 3;
10389 inst
.instruction
= T_OPCODE_CMP_HR
;
10390 inst
.instruction
|= (Rn
& 0x8) << 4;
10391 inst
.instruction
|= (Rn
& 0x7);
10392 inst
.instruction
|= Rm
<< 3;
10399 inst
.instruction
= THUMB_OP16 (inst
.instruction
);
10401 /* PR 10443: Do not silently ignore shifted operands. */
10402 constraint (inst
.operands
[1].shifted
,
10403 _("shifts in CMP/MOV instructions are only supported in unified syntax"));
10405 if (inst
.operands
[1].isreg
)
10407 if (Rn
< 8 && Rm
< 8)
10409 /* A move of two lowregs is encoded as ADD Rd, Rs, #0
10410 since a MOV instruction produces unpredictable results. */
10411 if (inst
.instruction
== T_OPCODE_MOV_I8
)
10412 inst
.instruction
= T_OPCODE_ADD_I3
;
10414 inst
.instruction
= T_OPCODE_CMP_LR
;
10416 inst
.instruction
|= Rn
;
10417 inst
.instruction
|= Rm
<< 3;
10421 if (inst
.instruction
== T_OPCODE_MOV_I8
)
10422 inst
.instruction
= T_OPCODE_MOV_HR
;
10424 inst
.instruction
= T_OPCODE_CMP_HR
;
10430 constraint (Rn
> 7,
10431 _("only lo regs allowed with immediate"));
10432 inst
.instruction
|= Rn
<< 8;
10433 inst
.reloc
.type
= BFD_RELOC_ARM_THUMB_IMM
;
10444 top
= (inst
.instruction
& 0x00800000) != 0;
10445 if (inst
.reloc
.type
== BFD_RELOC_ARM_MOVW
)
10447 constraint (top
, _(":lower16: not allowed this instruction"));
10448 inst
.reloc
.type
= BFD_RELOC_ARM_THUMB_MOVW
;
10450 else if (inst
.reloc
.type
== BFD_RELOC_ARM_MOVT
)
10452 constraint (!top
, _(":upper16: not allowed this instruction"));
10453 inst
.reloc
.type
= BFD_RELOC_ARM_THUMB_MOVT
;
10456 Rd
= inst
.operands
[0].reg
;
10457 reject_bad_reg (Rd
);
10459 inst
.instruction
|= Rd
<< 8;
10460 if (inst
.reloc
.type
== BFD_RELOC_UNUSED
)
10462 imm
= inst
.reloc
.exp
.X_add_number
;
10463 inst
.instruction
|= (imm
& 0xf000) << 4;
10464 inst
.instruction
|= (imm
& 0x0800) << 15;
10465 inst
.instruction
|= (imm
& 0x0700) << 4;
10466 inst
.instruction
|= (imm
& 0x00ff);
10471 do_t_mvn_tst (void)
10475 Rn
= inst
.operands
[0].reg
;
10476 Rm
= inst
.operands
[1].reg
;
10478 if (inst
.instruction
== T_MNEM_cmp
10479 || inst
.instruction
== T_MNEM_cmn
)
10480 constraint (Rn
== REG_PC
, BAD_PC
);
10482 reject_bad_reg (Rn
);
10483 reject_bad_reg (Rm
);
10485 if (unified_syntax
)
10487 int r0off
= (inst
.instruction
== T_MNEM_mvn
10488 || inst
.instruction
== T_MNEM_mvns
) ? 8 : 16;
10489 bfd_boolean narrow
;
10491 if (inst
.size_req
== 4
10492 || inst
.instruction
> 0xffff
10493 || inst
.operands
[1].shifted
10494 || Rn
> 7 || Rm
> 7)
10496 else if (inst
.instruction
== T_MNEM_cmn
)
10498 else if (THUMB_SETS_FLAGS (inst
.instruction
))
10499 narrow
= !in_it_block ();
10501 narrow
= in_it_block ();
10503 if (!inst
.operands
[1].isreg
)
10505 /* For an immediate, we always generate a 32-bit opcode;
10506 section relaxation will shrink it later if possible. */
10507 if (inst
.instruction
< 0xffff)
10508 inst
.instruction
= THUMB_OP32 (inst
.instruction
);
10509 inst
.instruction
= (inst
.instruction
& 0xe1ffffff) | 0x10000000;
10510 inst
.instruction
|= Rn
<< r0off
;
10511 inst
.reloc
.type
= BFD_RELOC_ARM_T32_IMMEDIATE
;
10515 /* See if we can do this with a 16-bit instruction. */
10518 inst
.instruction
= THUMB_OP16 (inst
.instruction
);
10519 inst
.instruction
|= Rn
;
10520 inst
.instruction
|= Rm
<< 3;
10524 constraint (inst
.operands
[1].shifted
10525 && inst
.operands
[1].immisreg
,
10526 _("shift must be constant"));
10527 if (inst
.instruction
< 0xffff)
10528 inst
.instruction
= THUMB_OP32 (inst
.instruction
);
10529 inst
.instruction
|= Rn
<< r0off
;
10530 encode_thumb32_shifted_operand (1);
10536 constraint (inst
.instruction
> 0xffff
10537 || inst
.instruction
== T_MNEM_mvns
, BAD_THUMB32
);
10538 constraint (!inst
.operands
[1].isreg
|| inst
.operands
[1].shifted
,
10539 _("unshifted register required"));
10540 constraint (Rn
> 7 || Rm
> 7,
10543 inst
.instruction
= THUMB_OP16 (inst
.instruction
);
10544 inst
.instruction
|= Rn
;
10545 inst
.instruction
|= Rm
<< 3;
10555 if (do_vfp_nsyn_mrs () == SUCCESS
)
10558 flags
= inst
.operands
[1].imm
& (PSR_c
|PSR_x
|PSR_s
|PSR_f
|SPSR_BIT
);
10561 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant
, arm_ext_m
),
10562 _("selected processor does not support "
10563 "requested special purpose register"));
10567 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant
, arm_ext_v1
),
10568 _("selected processor does not support "
10569 "requested special purpose register"));
10570 /* mrs only accepts CPSR/SPSR/CPSR_all/SPSR_all. */
10571 constraint ((flags
& ~SPSR_BIT
) != (PSR_c
|PSR_f
),
10572 _("'CPSR' or 'SPSR' expected"));
10575 Rd
= inst
.operands
[0].reg
;
10576 reject_bad_reg (Rd
);
10578 inst
.instruction
|= Rd
<< 8;
10579 inst
.instruction
|= (flags
& SPSR_BIT
) >> 2;
10580 inst
.instruction
|= inst
.operands
[1].imm
& 0xff;
10589 if (do_vfp_nsyn_msr () == SUCCESS
)
10592 constraint (!inst
.operands
[1].isreg
,
10593 _("Thumb encoding does not support an immediate here"));
10594 flags
= inst
.operands
[0].imm
;
10597 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant
, arm_ext_v1
),
10598 _("selected processor does not support "
10599 "requested special purpose register"));
10603 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant
, arm_ext_m
),
10604 _("selected processor does not support "
10605 "requested special purpose register"));
10609 Rn
= inst
.operands
[1].reg
;
10610 reject_bad_reg (Rn
);
10612 inst
.instruction
|= (flags
& SPSR_BIT
) >> 2;
10613 inst
.instruction
|= (flags
& ~SPSR_BIT
) >> 8;
10614 inst
.instruction
|= (flags
& 0xff);
10615 inst
.instruction
|= Rn
<< 16;
10621 bfd_boolean narrow
;
10622 unsigned Rd
, Rn
, Rm
;
10624 if (!inst
.operands
[2].present
)
10625 inst
.operands
[2].reg
= inst
.operands
[0].reg
;
10627 Rd
= inst
.operands
[0].reg
;
10628 Rn
= inst
.operands
[1].reg
;
10629 Rm
= inst
.operands
[2].reg
;
10631 if (unified_syntax
)
10633 if (inst
.size_req
== 4
10639 else if (inst
.instruction
== T_MNEM_muls
)
10640 narrow
= !in_it_block ();
10642 narrow
= in_it_block ();
10646 constraint (inst
.instruction
== T_MNEM_muls
, BAD_THUMB32
);
10647 constraint (Rn
> 7 || Rm
> 7,
10654 /* 16-bit MULS/Conditional MUL. */
10655 inst
.instruction
= THUMB_OP16 (inst
.instruction
);
10656 inst
.instruction
|= Rd
;
10659 inst
.instruction
|= Rm
<< 3;
10661 inst
.instruction
|= Rn
<< 3;
10663 constraint (1, _("dest must overlap one source register"));
10667 constraint (inst
.instruction
!= T_MNEM_mul
,
10668 _("Thumb-2 MUL must not set flags"));
10670 inst
.instruction
= THUMB_OP32 (inst
.instruction
);
10671 inst
.instruction
|= Rd
<< 8;
10672 inst
.instruction
|= Rn
<< 16;
10673 inst
.instruction
|= Rm
<< 0;
10675 reject_bad_reg (Rd
);
10676 reject_bad_reg (Rn
);
10677 reject_bad_reg (Rm
);
10684 unsigned RdLo
, RdHi
, Rn
, Rm
;
10686 RdLo
= inst
.operands
[0].reg
;
10687 RdHi
= inst
.operands
[1].reg
;
10688 Rn
= inst
.operands
[2].reg
;
10689 Rm
= inst
.operands
[3].reg
;
10691 reject_bad_reg (RdLo
);
10692 reject_bad_reg (RdHi
);
10693 reject_bad_reg (Rn
);
10694 reject_bad_reg (Rm
);
10696 inst
.instruction
|= RdLo
<< 12;
10697 inst
.instruction
|= RdHi
<< 8;
10698 inst
.instruction
|= Rn
<< 16;
10699 inst
.instruction
|= Rm
;
10702 as_tsktsk (_("rdhi and rdlo must be different"));
10708 set_it_insn_type (NEUTRAL_IT_INSN
);
10710 if (unified_syntax
)
10712 if (inst
.size_req
== 4 || inst
.operands
[0].imm
> 15)
10714 inst
.instruction
= THUMB_OP32 (inst
.instruction
);
10715 inst
.instruction
|= inst
.operands
[0].imm
;
10719 /* PR9722: Check for Thumb2 availability before
10720 generating a thumb2 nop instruction. */
10721 if (ARM_CPU_HAS_FEATURE (selected_cpu
, arm_ext_v6t2
))
10723 inst
.instruction
= THUMB_OP16 (inst
.instruction
);
10724 inst
.instruction
|= inst
.operands
[0].imm
<< 4;
10727 inst
.instruction
= 0x46c0;
10732 constraint (inst
.operands
[0].present
,
10733 _("Thumb does not support NOP with hints"));
10734 inst
.instruction
= 0x46c0;
10741 if (unified_syntax
)
10743 bfd_boolean narrow
;
10745 if (THUMB_SETS_FLAGS (inst
.instruction
))
10746 narrow
= !in_it_block ();
10748 narrow
= in_it_block ();
10749 if (inst
.operands
[0].reg
> 7 || inst
.operands
[1].reg
> 7)
10751 if (inst
.size_req
== 4)
10756 inst
.instruction
= THUMB_OP32 (inst
.instruction
);
10757 inst
.instruction
|= inst
.operands
[0].reg
<< 8;
10758 inst
.instruction
|= inst
.operands
[1].reg
<< 16;
10762 inst
.instruction
= THUMB_OP16 (inst
.instruction
);
10763 inst
.instruction
|= inst
.operands
[0].reg
;
10764 inst
.instruction
|= inst
.operands
[1].reg
<< 3;
10769 constraint (inst
.operands
[0].reg
> 7 || inst
.operands
[1].reg
> 7,
10771 constraint (THUMB_SETS_FLAGS (inst
.instruction
), BAD_THUMB32
);
10773 inst
.instruction
= THUMB_OP16 (inst
.instruction
);
10774 inst
.instruction
|= inst
.operands
[0].reg
;
10775 inst
.instruction
|= inst
.operands
[1].reg
<< 3;
10784 Rd
= inst
.operands
[0].reg
;
10785 Rn
= inst
.operands
[1].present
? inst
.operands
[1].reg
: Rd
;
10787 reject_bad_reg (Rd
);
10788 /* Rn == REG_SP is unpredictable; Rn == REG_PC is MVN. */
10789 reject_bad_reg (Rn
);
10791 inst
.instruction
|= Rd
<< 8;
10792 inst
.instruction
|= Rn
<< 16;
10794 if (!inst
.operands
[2].isreg
)
10796 inst
.instruction
= (inst
.instruction
& 0xe1ffffff) | 0x10000000;
10797 inst
.reloc
.type
= BFD_RELOC_ARM_T32_IMMEDIATE
;
10803 Rm
= inst
.operands
[2].reg
;
10804 reject_bad_reg (Rm
);
10806 constraint (inst
.operands
[2].shifted
10807 && inst
.operands
[2].immisreg
,
10808 _("shift must be constant"));
10809 encode_thumb32_shifted_operand (2);
10816 unsigned Rd
, Rn
, Rm
;
10818 Rd
= inst
.operands
[0].reg
;
10819 Rn
= inst
.operands
[1].reg
;
10820 Rm
= inst
.operands
[2].reg
;
10822 reject_bad_reg (Rd
);
10823 reject_bad_reg (Rn
);
10824 reject_bad_reg (Rm
);
10826 inst
.instruction
|= Rd
<< 8;
10827 inst
.instruction
|= Rn
<< 16;
10828 inst
.instruction
|= Rm
;
10829 if (inst
.operands
[3].present
)
10831 unsigned int val
= inst
.reloc
.exp
.X_add_number
;
10832 constraint (inst
.reloc
.exp
.X_op
!= O_constant
,
10833 _("expression too complex"));
10834 inst
.instruction
|= (val
& 0x1c) << 10;
10835 inst
.instruction
|= (val
& 0x03) << 6;
10842 if (!inst
.operands
[3].present
)
10846 inst
.instruction
&= ~0x00000020;
10848 /* PR 10168. Swap the Rm and Rn registers. */
10849 Rtmp
= inst
.operands
[1].reg
;
10850 inst
.operands
[1].reg
= inst
.operands
[2].reg
;
10851 inst
.operands
[2].reg
= Rtmp
;
10859 if (inst
.operands
[0].immisreg
)
10860 reject_bad_reg (inst
.operands
[0].imm
);
10862 encode_thumb32_addr_mode (0, /*is_t=*/FALSE
, /*is_d=*/FALSE
);
10866 do_t_push_pop (void)
10870 constraint (inst
.operands
[0].writeback
,
10871 _("push/pop do not support {reglist}^"));
10872 constraint (inst
.reloc
.type
!= BFD_RELOC_UNUSED
,
10873 _("expression too complex"));
10875 mask
= inst
.operands
[0].imm
;
10876 if ((mask
& ~0xff) == 0)
10877 inst
.instruction
= THUMB_OP16 (inst
.instruction
) | mask
;
10878 else if ((inst
.instruction
== T_MNEM_push
10879 && (mask
& ~0xff) == 1 << REG_LR
)
10880 || (inst
.instruction
== T_MNEM_pop
10881 && (mask
& ~0xff) == 1 << REG_PC
))
10883 inst
.instruction
= THUMB_OP16 (inst
.instruction
);
10884 inst
.instruction
|= THUMB_PP_PC_LR
;
10885 inst
.instruction
|= mask
& 0xff;
10887 else if (unified_syntax
)
10889 inst
.instruction
= THUMB_OP32 (inst
.instruction
);
10890 encode_thumb2_ldmstm (13, mask
, TRUE
);
10894 inst
.error
= _("invalid register list to push/pop instruction");
10904 Rd
= inst
.operands
[0].reg
;
10905 Rm
= inst
.operands
[1].reg
;
10907 reject_bad_reg (Rd
);
10908 reject_bad_reg (Rm
);
10910 inst
.instruction
|= Rd
<< 8;
10911 inst
.instruction
|= Rm
<< 16;
10912 inst
.instruction
|= Rm
;
10920 Rd
= inst
.operands
[0].reg
;
10921 Rm
= inst
.operands
[1].reg
;
10923 reject_bad_reg (Rd
);
10924 reject_bad_reg (Rm
);
10926 if (Rd
<= 7 && Rm
<= 7
10927 && inst
.size_req
!= 4)
10929 inst
.instruction
= THUMB_OP16 (inst
.instruction
);
10930 inst
.instruction
|= Rd
;
10931 inst
.instruction
|= Rm
<< 3;
10933 else if (unified_syntax
)
10935 inst
.instruction
= THUMB_OP32 (inst
.instruction
);
10936 inst
.instruction
|= Rd
<< 8;
10937 inst
.instruction
|= Rm
<< 16;
10938 inst
.instruction
|= Rm
;
10941 inst
.error
= BAD_HIREG
;
10949 Rd
= inst
.operands
[0].reg
;
10950 Rm
= inst
.operands
[1].reg
;
10952 reject_bad_reg (Rd
);
10953 reject_bad_reg (Rm
);
10955 inst
.instruction
|= Rd
<< 8;
10956 inst
.instruction
|= Rm
;
10964 Rd
= inst
.operands
[0].reg
;
10965 Rs
= (inst
.operands
[1].present
10966 ? inst
.operands
[1].reg
/* Rd, Rs, foo */
10967 : inst
.operands
[0].reg
); /* Rd, foo -> Rd, Rd, foo */
10969 reject_bad_reg (Rd
);
10970 reject_bad_reg (Rs
);
10971 if (inst
.operands
[2].isreg
)
10972 reject_bad_reg (inst
.operands
[2].reg
);
10974 inst
.instruction
|= Rd
<< 8;
10975 inst
.instruction
|= Rs
<< 16;
10976 if (!inst
.operands
[2].isreg
)
10978 bfd_boolean narrow
;
10980 if ((inst
.instruction
& 0x00100000) != 0)
10981 narrow
= !in_it_block ();
10983 narrow
= in_it_block ();
10985 if (Rd
> 7 || Rs
> 7)
10988 if (inst
.size_req
== 4 || !unified_syntax
)
10991 if (inst
.reloc
.exp
.X_op
!= O_constant
10992 || inst
.reloc
.exp
.X_add_number
!= 0)
10995 /* Turn rsb #0 into 16-bit neg. We should probably do this via
10996 relaxation, but it doesn't seem worth the hassle. */
10999 inst
.reloc
.type
= BFD_RELOC_UNUSED
;
11000 inst
.instruction
= THUMB_OP16 (T_MNEM_negs
);
11001 inst
.instruction
|= Rs
<< 3;
11002 inst
.instruction
|= Rd
;
11006 inst
.instruction
= (inst
.instruction
& 0xe1ffffff) | 0x10000000;
11007 inst
.reloc
.type
= BFD_RELOC_ARM_T32_IMMEDIATE
;
11011 encode_thumb32_shifted_operand (2);
11017 set_it_insn_type (OUTSIDE_IT_INSN
);
11018 if (inst
.operands
[0].imm
)
11019 inst
.instruction
|= 0x8;
11025 if (!inst
.operands
[1].present
)
11026 inst
.operands
[1].reg
= inst
.operands
[0].reg
;
11028 if (unified_syntax
)
11030 bfd_boolean narrow
;
11033 switch (inst
.instruction
)
11036 case T_MNEM_asrs
: shift_kind
= SHIFT_ASR
; break;
11038 case T_MNEM_lsls
: shift_kind
= SHIFT_LSL
; break;
11040 case T_MNEM_lsrs
: shift_kind
= SHIFT_LSR
; break;
11042 case T_MNEM_rors
: shift_kind
= SHIFT_ROR
; break;
11046 if (THUMB_SETS_FLAGS (inst
.instruction
))
11047 narrow
= !in_it_block ();
11049 narrow
= in_it_block ();
11050 if (inst
.operands
[0].reg
> 7 || inst
.operands
[1].reg
> 7)
11052 if (!inst
.operands
[2].isreg
&& shift_kind
== SHIFT_ROR
)
11054 if (inst
.operands
[2].isreg
11055 && (inst
.operands
[1].reg
!= inst
.operands
[0].reg
11056 || inst
.operands
[2].reg
> 7))
11058 if (inst
.size_req
== 4)
11061 reject_bad_reg (inst
.operands
[0].reg
);
11062 reject_bad_reg (inst
.operands
[1].reg
);
11066 if (inst
.operands
[2].isreg
)
11068 reject_bad_reg (inst
.operands
[2].reg
);
11069 inst
.instruction
= THUMB_OP32 (inst
.instruction
);
11070 inst
.instruction
|= inst
.operands
[0].reg
<< 8;
11071 inst
.instruction
|= inst
.operands
[1].reg
<< 16;
11072 inst
.instruction
|= inst
.operands
[2].reg
;
11076 inst
.operands
[1].shifted
= 1;
11077 inst
.operands
[1].shift_kind
= shift_kind
;
11078 inst
.instruction
= THUMB_OP32 (THUMB_SETS_FLAGS (inst
.instruction
)
11079 ? T_MNEM_movs
: T_MNEM_mov
);
11080 inst
.instruction
|= inst
.operands
[0].reg
<< 8;
11081 encode_thumb32_shifted_operand (1);
11082 /* Prevent the incorrect generation of an ARM_IMMEDIATE fixup. */
11083 inst
.reloc
.type
= BFD_RELOC_UNUSED
;
11088 if (inst
.operands
[2].isreg
)
11090 switch (shift_kind
)
11092 case SHIFT_ASR
: inst
.instruction
= T_OPCODE_ASR_R
; break;
11093 case SHIFT_LSL
: inst
.instruction
= T_OPCODE_LSL_R
; break;
11094 case SHIFT_LSR
: inst
.instruction
= T_OPCODE_LSR_R
; break;
11095 case SHIFT_ROR
: inst
.instruction
= T_OPCODE_ROR_R
; break;
11099 inst
.instruction
|= inst
.operands
[0].reg
;
11100 inst
.instruction
|= inst
.operands
[2].reg
<< 3;
11104 switch (shift_kind
)
11106 case SHIFT_ASR
: inst
.instruction
= T_OPCODE_ASR_I
; break;
11107 case SHIFT_LSL
: inst
.instruction
= T_OPCODE_LSL_I
; break;
11108 case SHIFT_LSR
: inst
.instruction
= T_OPCODE_LSR_I
; break;
11111 inst
.reloc
.type
= BFD_RELOC_ARM_THUMB_SHIFT
;
11112 inst
.instruction
|= inst
.operands
[0].reg
;
11113 inst
.instruction
|= inst
.operands
[1].reg
<< 3;
11119 constraint (inst
.operands
[0].reg
> 7
11120 || inst
.operands
[1].reg
> 7, BAD_HIREG
);
11121 constraint (THUMB_SETS_FLAGS (inst
.instruction
), BAD_THUMB32
);
11123 if (inst
.operands
[2].isreg
) /* Rd, {Rs,} Rn */
11125 constraint (inst
.operands
[2].reg
> 7, BAD_HIREG
);
11126 constraint (inst
.operands
[0].reg
!= inst
.operands
[1].reg
,
11127 _("source1 and dest must be same register"));
11129 switch (inst
.instruction
)
11131 case T_MNEM_asr
: inst
.instruction
= T_OPCODE_ASR_R
; break;
11132 case T_MNEM_lsl
: inst
.instruction
= T_OPCODE_LSL_R
; break;
11133 case T_MNEM_lsr
: inst
.instruction
= T_OPCODE_LSR_R
; break;
11134 case T_MNEM_ror
: inst
.instruction
= T_OPCODE_ROR_R
; break;
11138 inst
.instruction
|= inst
.operands
[0].reg
;
11139 inst
.instruction
|= inst
.operands
[2].reg
<< 3;
11143 switch (inst
.instruction
)
11145 case T_MNEM_asr
: inst
.instruction
= T_OPCODE_ASR_I
; break;
11146 case T_MNEM_lsl
: inst
.instruction
= T_OPCODE_LSL_I
; break;
11147 case T_MNEM_lsr
: inst
.instruction
= T_OPCODE_LSR_I
; break;
11148 case T_MNEM_ror
: inst
.error
= _("ror #imm not supported"); return;
11151 inst
.reloc
.type
= BFD_RELOC_ARM_THUMB_SHIFT
;
11152 inst
.instruction
|= inst
.operands
[0].reg
;
11153 inst
.instruction
|= inst
.operands
[1].reg
<< 3;
11161 unsigned Rd
, Rn
, Rm
;
11163 Rd
= inst
.operands
[0].reg
;
11164 Rn
= inst
.operands
[1].reg
;
11165 Rm
= inst
.operands
[2].reg
;
11167 reject_bad_reg (Rd
);
11168 reject_bad_reg (Rn
);
11169 reject_bad_reg (Rm
);
11171 inst
.instruction
|= Rd
<< 8;
11172 inst
.instruction
|= Rn
<< 16;
11173 inst
.instruction
|= Rm
;
11179 unsigned Rd
, Rn
, Rm
;
11181 Rd
= inst
.operands
[0].reg
;
11182 Rm
= inst
.operands
[1].reg
;
11183 Rn
= inst
.operands
[2].reg
;
11185 reject_bad_reg (Rd
);
11186 reject_bad_reg (Rn
);
11187 reject_bad_reg (Rm
);
11189 inst
.instruction
|= Rd
<< 8;
11190 inst
.instruction
|= Rn
<< 16;
11191 inst
.instruction
|= Rm
;
11197 unsigned int value
= inst
.reloc
.exp
.X_add_number
;
11198 constraint (inst
.reloc
.exp
.X_op
!= O_constant
,
11199 _("expression too complex"));
11200 inst
.reloc
.type
= BFD_RELOC_UNUSED
;
11201 inst
.instruction
|= (value
& 0xf000) >> 12;
11202 inst
.instruction
|= (value
& 0x0ff0);
11203 inst
.instruction
|= (value
& 0x000f) << 16;
11207 do_t_ssat_usat (int bias
)
11211 Rd
= inst
.operands
[0].reg
;
11212 Rn
= inst
.operands
[2].reg
;
11214 reject_bad_reg (Rd
);
11215 reject_bad_reg (Rn
);
11217 inst
.instruction
|= Rd
<< 8;
11218 inst
.instruction
|= inst
.operands
[1].imm
- bias
;
11219 inst
.instruction
|= Rn
<< 16;
11221 if (inst
.operands
[3].present
)
11223 offsetT shift_amount
= inst
.reloc
.exp
.X_add_number
;
11225 inst
.reloc
.type
= BFD_RELOC_UNUSED
;
11227 constraint (inst
.reloc
.exp
.X_op
!= O_constant
,
11228 _("expression too complex"));
11230 if (shift_amount
!= 0)
11232 constraint (shift_amount
> 31,
11233 _("shift expression is too large"));
11235 if (inst
.operands
[3].shift_kind
== SHIFT_ASR
)
11236 inst
.instruction
|= 0x00200000; /* sh bit. */
11238 inst
.instruction
|= (shift_amount
& 0x1c) << 10;
11239 inst
.instruction
|= (shift_amount
& 0x03) << 6;
11247 do_t_ssat_usat (1);
11255 Rd
= inst
.operands
[0].reg
;
11256 Rn
= inst
.operands
[2].reg
;
11258 reject_bad_reg (Rd
);
11259 reject_bad_reg (Rn
);
11261 inst
.instruction
|= Rd
<< 8;
11262 inst
.instruction
|= inst
.operands
[1].imm
- 1;
11263 inst
.instruction
|= Rn
<< 16;
11269 constraint (!inst
.operands
[2].isreg
|| !inst
.operands
[2].preind
11270 || inst
.operands
[2].postind
|| inst
.operands
[2].writeback
11271 || inst
.operands
[2].immisreg
|| inst
.operands
[2].shifted
11272 || inst
.operands
[2].negative
,
11275 constraint (inst
.operands
[2].reg
== REG_PC
, BAD_PC
);
11277 inst
.instruction
|= inst
.operands
[0].reg
<< 8;
11278 inst
.instruction
|= inst
.operands
[1].reg
<< 12;
11279 inst
.instruction
|= inst
.operands
[2].reg
<< 16;
11280 inst
.reloc
.type
= BFD_RELOC_ARM_T32_OFFSET_U8
;
11286 if (!inst
.operands
[2].present
)
11287 inst
.operands
[2].reg
= inst
.operands
[1].reg
+ 1;
11289 constraint (inst
.operands
[0].reg
== inst
.operands
[1].reg
11290 || inst
.operands
[0].reg
== inst
.operands
[2].reg
11291 || inst
.operands
[0].reg
== inst
.operands
[3].reg
,
11294 inst
.instruction
|= inst
.operands
[0].reg
;
11295 inst
.instruction
|= inst
.operands
[1].reg
<< 12;
11296 inst
.instruction
|= inst
.operands
[2].reg
<< 8;
11297 inst
.instruction
|= inst
.operands
[3].reg
<< 16;
11303 unsigned Rd
, Rn
, Rm
;
11305 Rd
= inst
.operands
[0].reg
;
11306 Rn
= inst
.operands
[1].reg
;
11307 Rm
= inst
.operands
[2].reg
;
11309 reject_bad_reg (Rd
);
11310 reject_bad_reg (Rn
);
11311 reject_bad_reg (Rm
);
11313 inst
.instruction
|= Rd
<< 8;
11314 inst
.instruction
|= Rn
<< 16;
11315 inst
.instruction
|= Rm
;
11316 inst
.instruction
|= inst
.operands
[3].imm
<< 4;
11324 Rd
= inst
.operands
[0].reg
;
11325 Rm
= inst
.operands
[1].reg
;
11327 reject_bad_reg (Rd
);
11328 reject_bad_reg (Rm
);
11330 if (inst
.instruction
<= 0xffff
11331 && inst
.size_req
!= 4
11332 && Rd
<= 7 && Rm
<= 7
11333 && (!inst
.operands
[2].present
|| inst
.operands
[2].imm
== 0))
11335 inst
.instruction
= THUMB_OP16 (inst
.instruction
);
11336 inst
.instruction
|= Rd
;
11337 inst
.instruction
|= Rm
<< 3;
11339 else if (unified_syntax
)
11341 if (inst
.instruction
<= 0xffff)
11342 inst
.instruction
= THUMB_OP32 (inst
.instruction
);
11343 inst
.instruction
|= Rd
<< 8;
11344 inst
.instruction
|= Rm
;
11345 inst
.instruction
|= inst
.operands
[2].imm
<< 4;
11349 constraint (inst
.operands
[2].present
&& inst
.operands
[2].imm
!= 0,
11350 _("Thumb encoding does not support rotation"));
11351 constraint (1, BAD_HIREG
);
11358 inst
.reloc
.type
= BFD_RELOC_ARM_SWI
;
11367 half
= (inst
.instruction
& 0x10) != 0;
11368 set_it_insn_type_last ();
11369 constraint (inst
.operands
[0].immisreg
,
11370 _("instruction requires register index"));
11372 Rn
= inst
.operands
[0].reg
;
11373 Rm
= inst
.operands
[0].imm
;
11375 constraint (Rn
== REG_SP
, BAD_SP
);
11376 reject_bad_reg (Rm
);
11378 constraint (!half
&& inst
.operands
[0].shifted
,
11379 _("instruction does not allow shifted index"));
11380 inst
.instruction
|= (Rn
<< 16) | Rm
;
11386 do_t_ssat_usat (0);
11394 Rd
= inst
.operands
[0].reg
;
11395 Rn
= inst
.operands
[2].reg
;
11397 reject_bad_reg (Rd
);
11398 reject_bad_reg (Rn
);
11400 inst
.instruction
|= Rd
<< 8;
11401 inst
.instruction
|= inst
.operands
[1].imm
;
11402 inst
.instruction
|= Rn
<< 16;
11405 /* Neon instruction encoder helpers. */
11407 /* Encodings for the different types for various Neon opcodes. */
11409 /* An "invalid" code for the following tables. */
11412 struct neon_tab_entry
11415 unsigned float_or_poly
;
11416 unsigned scalar_or_imm
;
11419 /* Map overloaded Neon opcodes to their respective encodings. */
11420 #define NEON_ENC_TAB \
11421 X(vabd, 0x0000700, 0x1200d00, N_INV), \
11422 X(vmax, 0x0000600, 0x0000f00, N_INV), \
11423 X(vmin, 0x0000610, 0x0200f00, N_INV), \
11424 X(vpadd, 0x0000b10, 0x1000d00, N_INV), \
11425 X(vpmax, 0x0000a00, 0x1000f00, N_INV), \
11426 X(vpmin, 0x0000a10, 0x1200f00, N_INV), \
11427 X(vadd, 0x0000800, 0x0000d00, N_INV), \
11428 X(vsub, 0x1000800, 0x0200d00, N_INV), \
11429 X(vceq, 0x1000810, 0x0000e00, 0x1b10100), \
11430 X(vcge, 0x0000310, 0x1000e00, 0x1b10080), \
11431 X(vcgt, 0x0000300, 0x1200e00, 0x1b10000), \
11432 /* Register variants of the following two instructions are encoded as
11433 vcge / vcgt with the operands reversed. */ \
11434 X(vclt, 0x0000300, 0x1200e00, 0x1b10200), \
11435 X(vcle, 0x0000310, 0x1000e00, 0x1b10180), \
11436 X(vfma, N_INV, 0x0000c10, N_INV), \
11437 X(vfms, N_INV, 0x0200c10, N_INV), \
11438 X(vmla, 0x0000900, 0x0000d10, 0x0800040), \
11439 X(vmls, 0x1000900, 0x0200d10, 0x0800440), \
11440 X(vmul, 0x0000910, 0x1000d10, 0x0800840), \
11441 X(vmull, 0x0800c00, 0x0800e00, 0x0800a40), /* polynomial not float. */ \
11442 X(vmlal, 0x0800800, N_INV, 0x0800240), \
11443 X(vmlsl, 0x0800a00, N_INV, 0x0800640), \
11444 X(vqdmlal, 0x0800900, N_INV, 0x0800340), \
11445 X(vqdmlsl, 0x0800b00, N_INV, 0x0800740), \
11446 X(vqdmull, 0x0800d00, N_INV, 0x0800b40), \
11447 X(vqdmulh, 0x0000b00, N_INV, 0x0800c40), \
11448 X(vqrdmulh, 0x1000b00, N_INV, 0x0800d40), \
11449 X(vshl, 0x0000400, N_INV, 0x0800510), \
11450 X(vqshl, 0x0000410, N_INV, 0x0800710), \
11451 X(vand, 0x0000110, N_INV, 0x0800030), \
11452 X(vbic, 0x0100110, N_INV, 0x0800030), \
11453 X(veor, 0x1000110, N_INV, N_INV), \
11454 X(vorn, 0x0300110, N_INV, 0x0800010), \
11455 X(vorr, 0x0200110, N_INV, 0x0800010), \
11456 X(vmvn, 0x1b00580, N_INV, 0x0800030), \
11457 X(vshll, 0x1b20300, N_INV, 0x0800a10), /* max shift, immediate. */ \
11458 X(vcvt, 0x1b30600, N_INV, 0x0800e10), /* integer, fixed-point. */ \
11459 X(vdup, 0xe800b10, N_INV, 0x1b00c00), /* arm, scalar. */ \
11460 X(vld1, 0x0200000, 0x0a00000, 0x0a00c00), /* interlv, lane, dup. */ \
11461 X(vst1, 0x0000000, 0x0800000, N_INV), \
11462 X(vld2, 0x0200100, 0x0a00100, 0x0a00d00), \
11463 X(vst2, 0x0000100, 0x0800100, N_INV), \
11464 X(vld3, 0x0200200, 0x0a00200, 0x0a00e00), \
11465 X(vst3, 0x0000200, 0x0800200, N_INV), \
11466 X(vld4, 0x0200300, 0x0a00300, 0x0a00f00), \
11467 X(vst4, 0x0000300, 0x0800300, N_INV), \
11468 X(vmovn, 0x1b20200, N_INV, N_INV), \
11469 X(vtrn, 0x1b20080, N_INV, N_INV), \
11470 X(vqmovn, 0x1b20200, N_INV, N_INV), \
11471 X(vqmovun, 0x1b20240, N_INV, N_INV), \
11472 X(vnmul, 0xe200a40, 0xe200b40, N_INV), \
11473 X(vnmla, 0xe100a40, 0xe100b40, N_INV), \
11474 X(vnmls, 0xe100a00, 0xe100b00, N_INV), \
11475 X(vfnma, 0xe900a40, 0xe900b40, N_INV), \
11476 X(vfnms, 0xe900a00, 0xe900b00, N_INV), \
11477 X(vcmp, 0xeb40a40, 0xeb40b40, N_INV), \
11478 X(vcmpz, 0xeb50a40, 0xeb50b40, N_INV), \
11479 X(vcmpe, 0xeb40ac0, 0xeb40bc0, N_INV), \
11480 X(vcmpez, 0xeb50ac0, 0xeb50bc0, N_INV)
11484 #define X(OPC,I,F,S) N_MNEM_##OPC
11489 static const struct neon_tab_entry neon_enc_tab
[] =
11491 #define X(OPC,I,F,S) { (I), (F), (S) }
11496 /* Do not use these macros; instead, use NEON_ENCODE defined below. */
11497 #define NEON_ENC_INTEGER_(X) (neon_enc_tab[(X) & 0x0fffffff].integer)
11498 #define NEON_ENC_ARMREG_(X) (neon_enc_tab[(X) & 0x0fffffff].integer)
11499 #define NEON_ENC_POLY_(X) (neon_enc_tab[(X) & 0x0fffffff].float_or_poly)
11500 #define NEON_ENC_FLOAT_(X) (neon_enc_tab[(X) & 0x0fffffff].float_or_poly)
11501 #define NEON_ENC_SCALAR_(X) (neon_enc_tab[(X) & 0x0fffffff].scalar_or_imm)
11502 #define NEON_ENC_IMMED_(X) (neon_enc_tab[(X) & 0x0fffffff].scalar_or_imm)
11503 #define NEON_ENC_INTERLV_(X) (neon_enc_tab[(X) & 0x0fffffff].integer)
11504 #define NEON_ENC_LANE_(X) (neon_enc_tab[(X) & 0x0fffffff].float_or_poly)
11505 #define NEON_ENC_DUP_(X) (neon_enc_tab[(X) & 0x0fffffff].scalar_or_imm)
11506 #define NEON_ENC_SINGLE_(X) \
11507 ((neon_enc_tab[(X) & 0x0fffffff].integer) | ((X) & 0xf0000000))
11508 #define NEON_ENC_DOUBLE_(X) \
11509 ((neon_enc_tab[(X) & 0x0fffffff].float_or_poly) | ((X) & 0xf0000000))
11511 #define NEON_ENCODE(type, inst) \
11514 inst.instruction = NEON_ENC_##type##_ (inst.instruction); \
11515 inst.is_neon = 1; \
11519 #define check_neon_suffixes \
11522 if (!inst.error && inst.vectype.elems > 0 && !inst.is_neon) \
11524 as_bad (_("invalid neon suffix for non neon instruction")); \
11530 /* Define shapes for instruction operands. The following mnemonic characters
11531 are used in this table:
11533 F - VFP S<n> register
11534 D - Neon D<n> register
11535 Q - Neon Q<n> register
11539 L - D<n> register list
11541 This table is used to generate various data:
11542 - enumerations of the form NS_DDR to be used as arguments to
11544 - a table classifying shapes into single, double, quad, mixed.
11545 - a table used to drive neon_select_shape. */
11547 #define NEON_SHAPE_DEF \
11548 X(3, (D, D, D), DOUBLE), \
11549 X(3, (Q, Q, Q), QUAD), \
11550 X(3, (D, D, I), DOUBLE), \
11551 X(3, (Q, Q, I), QUAD), \
11552 X(3, (D, D, S), DOUBLE), \
11553 X(3, (Q, Q, S), QUAD), \
11554 X(2, (D, D), DOUBLE), \
11555 X(2, (Q, Q), QUAD), \
11556 X(2, (D, S), DOUBLE), \
11557 X(2, (Q, S), QUAD), \
11558 X(2, (D, R), DOUBLE), \
11559 X(2, (Q, R), QUAD), \
11560 X(2, (D, I), DOUBLE), \
11561 X(2, (Q, I), QUAD), \
11562 X(3, (D, L, D), DOUBLE), \
11563 X(2, (D, Q), MIXED), \
11564 X(2, (Q, D), MIXED), \
11565 X(3, (D, Q, I), MIXED), \
11566 X(3, (Q, D, I), MIXED), \
11567 X(3, (Q, D, D), MIXED), \
11568 X(3, (D, Q, Q), MIXED), \
11569 X(3, (Q, Q, D), MIXED), \
11570 X(3, (Q, D, S), MIXED), \
11571 X(3, (D, Q, S), MIXED), \
11572 X(4, (D, D, D, I), DOUBLE), \
11573 X(4, (Q, Q, Q, I), QUAD), \
11574 X(2, (F, F), SINGLE), \
11575 X(3, (F, F, F), SINGLE), \
11576 X(2, (F, I), SINGLE), \
11577 X(2, (F, D), MIXED), \
11578 X(2, (D, F), MIXED), \
11579 X(3, (F, F, I), MIXED), \
11580 X(4, (R, R, F, F), SINGLE), \
11581 X(4, (F, F, R, R), SINGLE), \
11582 X(3, (D, R, R), DOUBLE), \
11583 X(3, (R, R, D), DOUBLE), \
11584 X(2, (S, R), SINGLE), \
11585 X(2, (R, S), SINGLE), \
11586 X(2, (F, R), SINGLE), \
11587 X(2, (R, F), SINGLE)
11589 #define S2(A,B) NS_##A##B
11590 #define S3(A,B,C) NS_##A##B##C
11591 #define S4(A,B,C,D) NS_##A##B##C##D
11593 #define X(N, L, C) S##N L
11606 enum neon_shape_class
11614 #define X(N, L, C) SC_##C
11616 static enum neon_shape_class neon_shape_class
[] =
11634 /* Register widths of above. */
11635 static unsigned neon_shape_el_size
[] =
11646 struct neon_shape_info
11649 enum neon_shape_el el
[NEON_MAX_TYPE_ELS
];
11652 #define S2(A,B) { SE_##A, SE_##B }
11653 #define S3(A,B,C) { SE_##A, SE_##B, SE_##C }
11654 #define S4(A,B,C,D) { SE_##A, SE_##B, SE_##C, SE_##D }
11656 #define X(N, L, C) { N, S##N L }
11658 static struct neon_shape_info neon_shape_tab
[] =
11668 /* Bit masks used in type checking given instructions.
11669 'N_EQK' means the type must be the same as (or based on in some way) the key
11670 type, which itself is marked with the 'N_KEY' bit. If the 'N_EQK' bit is
11671 set, various other bits can be set as well in order to modify the meaning of
11672 the type constraint. */
11674 enum neon_type_mask
11697 N_KEY
= 0x1000000, /* Key element (main type specifier). */
11698 N_EQK
= 0x2000000, /* Given operand has the same type & size as the key. */
11699 N_VFP
= 0x4000000, /* VFP mode: operand size must match register width. */
11700 N_DBL
= 0x0000001, /* If N_EQK, this operand is twice the size. */
11701 N_HLF
= 0x0000002, /* If N_EQK, this operand is half the size. */
11702 N_SGN
= 0x0000004, /* If N_EQK, this operand is forced to be signed. */
11703 N_UNS
= 0x0000008, /* If N_EQK, this operand is forced to be unsigned. */
11704 N_INT
= 0x0000010, /* If N_EQK, this operand is forced to be integer. */
11705 N_FLT
= 0x0000020, /* If N_EQK, this operand is forced to be float. */
11706 N_SIZ
= 0x0000040, /* If N_EQK, this operand is forced to be size-only. */
11708 N_MAX_NONSPECIAL
= N_F64
11711 #define N_ALLMODS (N_DBL | N_HLF | N_SGN | N_UNS | N_INT | N_FLT | N_SIZ)
11713 #define N_SU_ALL (N_S8 | N_S16 | N_S32 | N_S64 | N_U8 | N_U16 | N_U32 | N_U64)
11714 #define N_SU_32 (N_S8 | N_S16 | N_S32 | N_U8 | N_U16 | N_U32)
11715 #define N_SU_16_64 (N_S16 | N_S32 | N_S64 | N_U16 | N_U32 | N_U64)
11716 #define N_SUF_32 (N_SU_32 | N_F32)
11717 #define N_I_ALL (N_I8 | N_I16 | N_I32 | N_I64)
11718 #define N_IF_32 (N_I8 | N_I16 | N_I32 | N_F32)
11720 /* Pass this as the first type argument to neon_check_type to ignore types
11722 #define N_IGNORE_TYPE (N_KEY | N_EQK)
11724 /* Select a "shape" for the current instruction (describing register types or
11725 sizes) from a list of alternatives. Return NS_NULL if the current instruction
11726 doesn't fit. For non-polymorphic shapes, checking is usually done as a
11727 function of operand parsing, so this function doesn't need to be called.
11728 Shapes should be listed in order of decreasing length. */
11730 static enum neon_shape
11731 neon_select_shape (enum neon_shape shape
, ...)
11734 enum neon_shape first_shape
= shape
;
11736 /* Fix missing optional operands. FIXME: we don't know at this point how
11737 many arguments we should have, so this makes the assumption that we have
11738 > 1. This is true of all current Neon opcodes, I think, but may not be
11739 true in the future. */
11740 if (!inst
.operands
[1].present
)
11741 inst
.operands
[1] = inst
.operands
[0];
11743 va_start (ap
, shape
);
11745 for (; shape
!= NS_NULL
; shape
= (enum neon_shape
) va_arg (ap
, int))
11750 for (j
= 0; j
< neon_shape_tab
[shape
].els
; j
++)
11752 if (!inst
.operands
[j
].present
)
11758 switch (neon_shape_tab
[shape
].el
[j
])
11761 if (!(inst
.operands
[j
].isreg
11762 && inst
.operands
[j
].isvec
11763 && inst
.operands
[j
].issingle
11764 && !inst
.operands
[j
].isquad
))
11769 if (!(inst
.operands
[j
].isreg
11770 && inst
.operands
[j
].isvec
11771 && !inst
.operands
[j
].isquad
11772 && !inst
.operands
[j
].issingle
))
11777 if (!(inst
.operands
[j
].isreg
11778 && !inst
.operands
[j
].isvec
))
11783 if (!(inst
.operands
[j
].isreg
11784 && inst
.operands
[j
].isvec
11785 && inst
.operands
[j
].isquad
11786 && !inst
.operands
[j
].issingle
))
11791 if (!(!inst
.operands
[j
].isreg
11792 && !inst
.operands
[j
].isscalar
))
11797 if (!(!inst
.operands
[j
].isreg
11798 && inst
.operands
[j
].isscalar
))
11814 if (shape
== NS_NULL
&& first_shape
!= NS_NULL
)
11815 first_error (_("invalid instruction shape"));
11820 /* True if SHAPE is predominantly a quadword operation (most of the time, this
11821 means the Q bit should be set). */
11824 neon_quad (enum neon_shape shape
)
11826 return neon_shape_class
[shape
] == SC_QUAD
;
11830 neon_modify_type_size (unsigned typebits
, enum neon_el_type
*g_type
,
11833 /* Allow modification to be made to types which are constrained to be
11834 based on the key element, based on bits set alongside N_EQK. */
11835 if ((typebits
& N_EQK
) != 0)
11837 if ((typebits
& N_HLF
) != 0)
11839 else if ((typebits
& N_DBL
) != 0)
11841 if ((typebits
& N_SGN
) != 0)
11842 *g_type
= NT_signed
;
11843 else if ((typebits
& N_UNS
) != 0)
11844 *g_type
= NT_unsigned
;
11845 else if ((typebits
& N_INT
) != 0)
11846 *g_type
= NT_integer
;
11847 else if ((typebits
& N_FLT
) != 0)
11848 *g_type
= NT_float
;
11849 else if ((typebits
& N_SIZ
) != 0)
11850 *g_type
= NT_untyped
;
11854 /* Return operand OPNO promoted by bits set in THISARG. KEY should be the "key"
11855 operand type, i.e. the single type specified in a Neon instruction when it
11856 is the only one given. */
11858 static struct neon_type_el
11859 neon_type_promote (struct neon_type_el
*key
, unsigned thisarg
)
11861 struct neon_type_el dest
= *key
;
11863 gas_assert ((thisarg
& N_EQK
) != 0);
11865 neon_modify_type_size (thisarg
, &dest
.type
, &dest
.size
);
11870 /* Convert Neon type and size into compact bitmask representation. */
11872 static enum neon_type_mask
11873 type_chk_of_el_type (enum neon_el_type type
, unsigned size
)
11880 case 8: return N_8
;
11881 case 16: return N_16
;
11882 case 32: return N_32
;
11883 case 64: return N_64
;
11891 case 8: return N_I8
;
11892 case 16: return N_I16
;
11893 case 32: return N_I32
;
11894 case 64: return N_I64
;
11902 case 16: return N_F16
;
11903 case 32: return N_F32
;
11904 case 64: return N_F64
;
11912 case 8: return N_P8
;
11913 case 16: return N_P16
;
11921 case 8: return N_S8
;
11922 case 16: return N_S16
;
11923 case 32: return N_S32
;
11924 case 64: return N_S64
;
11932 case 8: return N_U8
;
11933 case 16: return N_U16
;
11934 case 32: return N_U32
;
11935 case 64: return N_U64
;
11946 /* Convert compact Neon bitmask type representation to a type and size. Only
11947 handles the case where a single bit is set in the mask. */
11950 el_type_of_type_chk (enum neon_el_type
*type
, unsigned *size
,
11951 enum neon_type_mask mask
)
11953 if ((mask
& N_EQK
) != 0)
11956 if ((mask
& (N_S8
| N_U8
| N_I8
| N_8
| N_P8
)) != 0)
11958 else if ((mask
& (N_S16
| N_U16
| N_I16
| N_16
| N_P16
)) != 0)
11960 else if ((mask
& (N_S32
| N_U32
| N_I32
| N_32
| N_F32
)) != 0)
11962 else if ((mask
& (N_S64
| N_U64
| N_I64
| N_64
| N_F64
)) != 0)
11967 if ((mask
& (N_S8
| N_S16
| N_S32
| N_S64
)) != 0)
11969 else if ((mask
& (N_U8
| N_U16
| N_U32
| N_U64
)) != 0)
11970 *type
= NT_unsigned
;
11971 else if ((mask
& (N_I8
| N_I16
| N_I32
| N_I64
)) != 0)
11972 *type
= NT_integer
;
11973 else if ((mask
& (N_8
| N_16
| N_32
| N_64
)) != 0)
11974 *type
= NT_untyped
;
11975 else if ((mask
& (N_P8
| N_P16
)) != 0)
11977 else if ((mask
& (N_F32
| N_F64
)) != 0)
11985 /* Modify a bitmask of allowed types. This is only needed for type
11989 modify_types_allowed (unsigned allowed
, unsigned mods
)
11992 enum neon_el_type type
;
11998 for (i
= 1; i
<= N_MAX_NONSPECIAL
; i
<<= 1)
12000 if (el_type_of_type_chk (&type
, &size
,
12001 (enum neon_type_mask
) (allowed
& i
)) == SUCCESS
)
12003 neon_modify_type_size (mods
, &type
, &size
);
12004 destmask
|= type_chk_of_el_type (type
, size
);
12011 /* Check type and return type classification.
12012 The manual states (paraphrase): If one datatype is given, it indicates the
12014 - the second operand, if there is one
12015 - the operand, if there is no second operand
12016 - the result, if there are no operands.
12017 This isn't quite good enough though, so we use a concept of a "key" datatype
12018 which is set on a per-instruction basis, which is the one which matters when
12019 only one data type is written.
12020 Note: this function has side-effects (e.g. filling in missing operands). All
12021 Neon instructions should call it before performing bit encoding. */
12023 static struct neon_type_el
12024 neon_check_type (unsigned els
, enum neon_shape ns
, ...)
12027 unsigned i
, pass
, key_el
= 0;
12028 unsigned types
[NEON_MAX_TYPE_ELS
];
12029 enum neon_el_type k_type
= NT_invtype
;
12030 unsigned k_size
= -1u;
12031 struct neon_type_el badtype
= {NT_invtype
, -1};
12032 unsigned key_allowed
= 0;
12034 /* Optional registers in Neon instructions are always (not) in operand 1.
12035 Fill in the missing operand here, if it was omitted. */
12036 if (els
> 1 && !inst
.operands
[1].present
)
12037 inst
.operands
[1] = inst
.operands
[0];
12039 /* Suck up all the varargs. */
12041 for (i
= 0; i
< els
; i
++)
12043 unsigned thisarg
= va_arg (ap
, unsigned);
12044 if (thisarg
== N_IGNORE_TYPE
)
12049 types
[i
] = thisarg
;
12050 if ((thisarg
& N_KEY
) != 0)
12055 if (inst
.vectype
.elems
> 0)
12056 for (i
= 0; i
< els
; i
++)
12057 if (inst
.operands
[i
].vectype
.type
!= NT_invtype
)
12059 first_error (_("types specified in both the mnemonic and operands"));
12063 /* Duplicate inst.vectype elements here as necessary.
12064 FIXME: No idea if this is exactly the same as the ARM assembler,
12065 particularly when an insn takes one register and one non-register
12067 if (inst
.vectype
.elems
== 1 && els
> 1)
12070 inst
.vectype
.elems
= els
;
12071 inst
.vectype
.el
[key_el
] = inst
.vectype
.el
[0];
12072 for (j
= 0; j
< els
; j
++)
12074 inst
.vectype
.el
[j
] = neon_type_promote (&inst
.vectype
.el
[key_el
],
12077 else if (inst
.vectype
.elems
== 0 && els
> 0)
12080 /* No types were given after the mnemonic, so look for types specified
12081 after each operand. We allow some flexibility here; as long as the
12082 "key" operand has a type, we can infer the others. */
12083 for (j
= 0; j
< els
; j
++)
12084 if (inst
.operands
[j
].vectype
.type
!= NT_invtype
)
12085 inst
.vectype
.el
[j
] = inst
.operands
[j
].vectype
;
12087 if (inst
.operands
[key_el
].vectype
.type
!= NT_invtype
)
12089 for (j
= 0; j
< els
; j
++)
12090 if (inst
.operands
[j
].vectype
.type
== NT_invtype
)
12091 inst
.vectype
.el
[j
] = neon_type_promote (&inst
.vectype
.el
[key_el
],
12096 first_error (_("operand types can't be inferred"));
12100 else if (inst
.vectype
.elems
!= els
)
12102 first_error (_("type specifier has the wrong number of parts"));
12106 for (pass
= 0; pass
< 2; pass
++)
12108 for (i
= 0; i
< els
; i
++)
12110 unsigned thisarg
= types
[i
];
12111 unsigned types_allowed
= ((thisarg
& N_EQK
) != 0 && pass
!= 0)
12112 ? modify_types_allowed (key_allowed
, thisarg
) : thisarg
;
12113 enum neon_el_type g_type
= inst
.vectype
.el
[i
].type
;
12114 unsigned g_size
= inst
.vectype
.el
[i
].size
;
12116 /* Decay more-specific signed & unsigned types to sign-insensitive
12117 integer types if sign-specific variants are unavailable. */
12118 if ((g_type
== NT_signed
|| g_type
== NT_unsigned
)
12119 && (types_allowed
& N_SU_ALL
) == 0)
12120 g_type
= NT_integer
;
12122 /* If only untyped args are allowed, decay any more specific types to
12123 them. Some instructions only care about signs for some element
12124 sizes, so handle that properly. */
12125 if ((g_size
== 8 && (types_allowed
& N_8
) != 0)
12126 || (g_size
== 16 && (types_allowed
& N_16
) != 0)
12127 || (g_size
== 32 && (types_allowed
& N_32
) != 0)
12128 || (g_size
== 64 && (types_allowed
& N_64
) != 0))
12129 g_type
= NT_untyped
;
12133 if ((thisarg
& N_KEY
) != 0)
12137 key_allowed
= thisarg
& ~N_KEY
;
12142 if ((thisarg
& N_VFP
) != 0)
12144 enum neon_shape_el regshape
;
12145 unsigned regwidth
, match
;
12147 /* PR 11136: Catch the case where we are passed a shape of NS_NULL. */
12150 first_error (_("invalid instruction shape"));
12153 regshape
= neon_shape_tab
[ns
].el
[i
];
12154 regwidth
= neon_shape_el_size
[regshape
];
12156 /* In VFP mode, operands must match register widths. If we
12157 have a key operand, use its width, else use the width of
12158 the current operand. */
12164 if (regwidth
!= match
)
12166 first_error (_("operand size must match register width"));
12171 if ((thisarg
& N_EQK
) == 0)
12173 unsigned given_type
= type_chk_of_el_type (g_type
, g_size
);
12175 if ((given_type
& types_allowed
) == 0)
12177 first_error (_("bad type in Neon instruction"));
12183 enum neon_el_type mod_k_type
= k_type
;
12184 unsigned mod_k_size
= k_size
;
12185 neon_modify_type_size (thisarg
, &mod_k_type
, &mod_k_size
);
12186 if (g_type
!= mod_k_type
|| g_size
!= mod_k_size
)
12188 first_error (_("inconsistent types in Neon instruction"));
12196 return inst
.vectype
.el
[key_el
];
12199 /* Neon-style VFP instruction forwarding. */
12201 /* Thumb VFP instructions have 0xE in the condition field. */
12204 do_vfp_cond_or_thumb (void)
12209 inst
.instruction
|= 0xe0000000;
12211 inst
.instruction
|= inst
.cond
<< 28;
12214 /* Look up and encode a simple mnemonic, for use as a helper function for the
12215 Neon-style VFP syntax. This avoids duplication of bits of the insns table,
12216 etc. It is assumed that operand parsing has already been done, and that the
12217 operands are in the form expected by the given opcode (this isn't necessarily
12218 the same as the form in which they were parsed, hence some massaging must
12219 take place before this function is called).
12220 Checks current arch version against that in the looked-up opcode. */
12223 do_vfp_nsyn_opcode (const char *opname
)
12225 const struct asm_opcode
*opcode
;
12227 opcode
= (const struct asm_opcode
*) hash_find (arm_ops_hsh
, opname
);
12232 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant
,
12233 thumb_mode
? *opcode
->tvariant
: *opcode
->avariant
),
12240 inst
.instruction
= opcode
->tvalue
;
12241 opcode
->tencode ();
12245 inst
.instruction
= (inst
.cond
<< 28) | opcode
->avalue
;
12246 opcode
->aencode ();
12251 do_vfp_nsyn_add_sub (enum neon_shape rs
)
12253 int is_add
= (inst
.instruction
& 0x0fffffff) == N_MNEM_vadd
;
12258 do_vfp_nsyn_opcode ("fadds");
12260 do_vfp_nsyn_opcode ("fsubs");
12265 do_vfp_nsyn_opcode ("faddd");
12267 do_vfp_nsyn_opcode ("fsubd");
12271 /* Check operand types to see if this is a VFP instruction, and if so call
12275 try_vfp_nsyn (int args
, void (*pfn
) (enum neon_shape
))
12277 enum neon_shape rs
;
12278 struct neon_type_el et
;
12283 rs
= neon_select_shape (NS_FF
, NS_DD
, NS_NULL
);
12284 et
= neon_check_type (2, rs
,
12285 N_EQK
| N_VFP
, N_F32
| N_F64
| N_KEY
| N_VFP
);
12289 rs
= neon_select_shape (NS_FFF
, NS_DDD
, NS_NULL
);
12290 et
= neon_check_type (3, rs
,
12291 N_EQK
| N_VFP
, N_EQK
| N_VFP
, N_F32
| N_F64
| N_KEY
| N_VFP
);
12298 if (et
.type
!= NT_invtype
)
12309 do_vfp_nsyn_mla_mls (enum neon_shape rs
)
12311 int is_mla
= (inst
.instruction
& 0x0fffffff) == N_MNEM_vmla
;
12316 do_vfp_nsyn_opcode ("fmacs");
12318 do_vfp_nsyn_opcode ("fnmacs");
12323 do_vfp_nsyn_opcode ("fmacd");
12325 do_vfp_nsyn_opcode ("fnmacd");
12330 do_vfp_nsyn_fma_fms (enum neon_shape rs
)
12332 int is_fma
= (inst
.instruction
& 0x0fffffff) == N_MNEM_vfma
;
12337 do_vfp_nsyn_opcode ("ffmas");
12339 do_vfp_nsyn_opcode ("ffnmas");
12344 do_vfp_nsyn_opcode ("ffmad");
12346 do_vfp_nsyn_opcode ("ffnmad");
12351 do_vfp_nsyn_mul (enum neon_shape rs
)
12354 do_vfp_nsyn_opcode ("fmuls");
12356 do_vfp_nsyn_opcode ("fmuld");
12360 do_vfp_nsyn_abs_neg (enum neon_shape rs
)
12362 int is_neg
= (inst
.instruction
& 0x80) != 0;
12363 neon_check_type (2, rs
, N_EQK
| N_VFP
, N_F32
| N_F64
| N_VFP
| N_KEY
);
12368 do_vfp_nsyn_opcode ("fnegs");
12370 do_vfp_nsyn_opcode ("fabss");
12375 do_vfp_nsyn_opcode ("fnegd");
12377 do_vfp_nsyn_opcode ("fabsd");
12381 /* Encode single-precision (only!) VFP fldm/fstm instructions. Double precision
12382 insns belong to Neon, and are handled elsewhere. */
12385 do_vfp_nsyn_ldm_stm (int is_dbmode
)
12387 int is_ldm
= (inst
.instruction
& (1 << 20)) != 0;
12391 do_vfp_nsyn_opcode ("fldmdbs");
12393 do_vfp_nsyn_opcode ("fldmias");
12398 do_vfp_nsyn_opcode ("fstmdbs");
12400 do_vfp_nsyn_opcode ("fstmias");
12405 do_vfp_nsyn_sqrt (void)
12407 enum neon_shape rs
= neon_select_shape (NS_FF
, NS_DD
, NS_NULL
);
12408 neon_check_type (2, rs
, N_EQK
| N_VFP
, N_F32
| N_F64
| N_KEY
| N_VFP
);
12411 do_vfp_nsyn_opcode ("fsqrts");
12413 do_vfp_nsyn_opcode ("fsqrtd");
12417 do_vfp_nsyn_div (void)
12419 enum neon_shape rs
= neon_select_shape (NS_FFF
, NS_DDD
, NS_NULL
);
12420 neon_check_type (3, rs
, N_EQK
| N_VFP
, N_EQK
| N_VFP
,
12421 N_F32
| N_F64
| N_KEY
| N_VFP
);
12424 do_vfp_nsyn_opcode ("fdivs");
12426 do_vfp_nsyn_opcode ("fdivd");
12430 do_vfp_nsyn_nmul (void)
12432 enum neon_shape rs
= neon_select_shape (NS_FFF
, NS_DDD
, NS_NULL
);
12433 neon_check_type (3, rs
, N_EQK
| N_VFP
, N_EQK
| N_VFP
,
12434 N_F32
| N_F64
| N_KEY
| N_VFP
);
12438 NEON_ENCODE (SINGLE
, inst
);
12439 do_vfp_sp_dyadic ();
12443 NEON_ENCODE (DOUBLE
, inst
);
12444 do_vfp_dp_rd_rn_rm ();
12446 do_vfp_cond_or_thumb ();
12450 do_vfp_nsyn_cmp (void)
12452 if (inst
.operands
[1].isreg
)
12454 enum neon_shape rs
= neon_select_shape (NS_FF
, NS_DD
, NS_NULL
);
12455 neon_check_type (2, rs
, N_EQK
| N_VFP
, N_F32
| N_F64
| N_KEY
| N_VFP
);
12459 NEON_ENCODE (SINGLE
, inst
);
12460 do_vfp_sp_monadic ();
12464 NEON_ENCODE (DOUBLE
, inst
);
12465 do_vfp_dp_rd_rm ();
12470 enum neon_shape rs
= neon_select_shape (NS_FI
, NS_DI
, NS_NULL
);
12471 neon_check_type (2, rs
, N_F32
| N_F64
| N_KEY
| N_VFP
, N_EQK
);
12473 switch (inst
.instruction
& 0x0fffffff)
12476 inst
.instruction
+= N_MNEM_vcmpz
- N_MNEM_vcmp
;
12479 inst
.instruction
+= N_MNEM_vcmpez
- N_MNEM_vcmpe
;
12487 NEON_ENCODE (SINGLE
, inst
);
12488 do_vfp_sp_compare_z ();
12492 NEON_ENCODE (DOUBLE
, inst
);
12496 do_vfp_cond_or_thumb ();
12500 nsyn_insert_sp (void)
12502 inst
.operands
[1] = inst
.operands
[0];
12503 memset (&inst
.operands
[0], '\0', sizeof (inst
.operands
[0]));
12504 inst
.operands
[0].reg
= REG_SP
;
12505 inst
.operands
[0].isreg
= 1;
12506 inst
.operands
[0].writeback
= 1;
12507 inst
.operands
[0].present
= 1;
12511 do_vfp_nsyn_push (void)
12514 if (inst
.operands
[1].issingle
)
12515 do_vfp_nsyn_opcode ("fstmdbs");
12517 do_vfp_nsyn_opcode ("fstmdbd");
12521 do_vfp_nsyn_pop (void)
12524 if (inst
.operands
[1].issingle
)
12525 do_vfp_nsyn_opcode ("fldmias");
12527 do_vfp_nsyn_opcode ("fldmiad");
12530 /* Fix up Neon data-processing instructions, ORing in the correct bits for
12531 ARM mode or Thumb mode and moving the encoded bit 24 to bit 28. */
12534 neon_dp_fixup (struct arm_it
* insn
)
12536 unsigned int i
= insn
->instruction
;
12541 /* The U bit is at bit 24 by default. Move to bit 28 in Thumb mode. */
12552 insn
->instruction
= i
;
12555 /* Turn a size (8, 16, 32, 64) into the respective bit number minus 3
12559 neon_logbits (unsigned x
)
12561 return ffs (x
) - 4;
12564 #define LOW4(R) ((R) & 0xf)
12565 #define HI1(R) (((R) >> 4) & 1)
12567 /* Encode insns with bit pattern:
12569 |28/24|23|22 |21 20|19 16|15 12|11 8|7|6|5|4|3 0|
12570 | U |x |D |size | Rn | Rd |x x x x|N|Q|M|x| Rm |
12572 SIZE is passed in bits. -1 means size field isn't changed, in case it has a
12573 different meaning for some instruction. */
12576 neon_three_same (int isquad
, int ubit
, int size
)
12578 inst
.instruction
|= LOW4 (inst
.operands
[0].reg
) << 12;
12579 inst
.instruction
|= HI1 (inst
.operands
[0].reg
) << 22;
12580 inst
.instruction
|= LOW4 (inst
.operands
[1].reg
) << 16;
12581 inst
.instruction
|= HI1 (inst
.operands
[1].reg
) << 7;
12582 inst
.instruction
|= LOW4 (inst
.operands
[2].reg
);
12583 inst
.instruction
|= HI1 (inst
.operands
[2].reg
) << 5;
12584 inst
.instruction
|= (isquad
!= 0) << 6;
12585 inst
.instruction
|= (ubit
!= 0) << 24;
12587 inst
.instruction
|= neon_logbits (size
) << 20;
12589 neon_dp_fixup (&inst
);
12592 /* Encode instructions of the form:
12594 |28/24|23|22|21 20|19 18|17 16|15 12|11 7|6|5|4|3 0|
12595 | U |x |D |x x |size |x x | Rd |x x x x x|Q|M|x| Rm |
12597 Don't write size if SIZE == -1. */
12600 neon_two_same (int qbit
, int ubit
, int size
)
12602 inst
.instruction
|= LOW4 (inst
.operands
[0].reg
) << 12;
12603 inst
.instruction
|= HI1 (inst
.operands
[0].reg
) << 22;
12604 inst
.instruction
|= LOW4 (inst
.operands
[1].reg
);
12605 inst
.instruction
|= HI1 (inst
.operands
[1].reg
) << 5;
12606 inst
.instruction
|= (qbit
!= 0) << 6;
12607 inst
.instruction
|= (ubit
!= 0) << 24;
12610 inst
.instruction
|= neon_logbits (size
) << 18;
12612 neon_dp_fixup (&inst
);
12615 /* Neon instruction encoders, in approximate order of appearance. */
12618 do_neon_dyadic_i_su (void)
12620 enum neon_shape rs
= neon_select_shape (NS_DDD
, NS_QQQ
, NS_NULL
);
12621 struct neon_type_el et
= neon_check_type (3, rs
,
12622 N_EQK
, N_EQK
, N_SU_32
| N_KEY
);
12623 neon_three_same (neon_quad (rs
), et
.type
== NT_unsigned
, et
.size
);
12627 do_neon_dyadic_i64_su (void)
12629 enum neon_shape rs
= neon_select_shape (NS_DDD
, NS_QQQ
, NS_NULL
);
12630 struct neon_type_el et
= neon_check_type (3, rs
,
12631 N_EQK
, N_EQK
, N_SU_ALL
| N_KEY
);
12632 neon_three_same (neon_quad (rs
), et
.type
== NT_unsigned
, et
.size
);
12636 neon_imm_shift (int write_ubit
, int uval
, int isquad
, struct neon_type_el et
,
12639 unsigned size
= et
.size
>> 3;
12640 inst
.instruction
|= LOW4 (inst
.operands
[0].reg
) << 12;
12641 inst
.instruction
|= HI1 (inst
.operands
[0].reg
) << 22;
12642 inst
.instruction
|= LOW4 (inst
.operands
[1].reg
);
12643 inst
.instruction
|= HI1 (inst
.operands
[1].reg
) << 5;
12644 inst
.instruction
|= (isquad
!= 0) << 6;
12645 inst
.instruction
|= immbits
<< 16;
12646 inst
.instruction
|= (size
>> 3) << 7;
12647 inst
.instruction
|= (size
& 0x7) << 19;
12649 inst
.instruction
|= (uval
!= 0) << 24;
12651 neon_dp_fixup (&inst
);
12655 do_neon_shl_imm (void)
12657 if (!inst
.operands
[2].isreg
)
12659 enum neon_shape rs
= neon_select_shape (NS_DDI
, NS_QQI
, NS_NULL
);
12660 struct neon_type_el et
= neon_check_type (2, rs
, N_EQK
, N_KEY
| N_I_ALL
);
12661 NEON_ENCODE (IMMED
, inst
);
12662 neon_imm_shift (FALSE
, 0, neon_quad (rs
), et
, inst
.operands
[2].imm
);
12666 enum neon_shape rs
= neon_select_shape (NS_DDD
, NS_QQQ
, NS_NULL
);
12667 struct neon_type_el et
= neon_check_type (3, rs
,
12668 N_EQK
, N_SU_ALL
| N_KEY
, N_EQK
| N_SGN
);
12671 /* VSHL/VQSHL 3-register variants have syntax such as:
12673 whereas other 3-register operations encoded by neon_three_same have
12676 (i.e. with Dn & Dm reversed). Swap operands[1].reg and operands[2].reg
12678 tmp
= inst
.operands
[2].reg
;
12679 inst
.operands
[2].reg
= inst
.operands
[1].reg
;
12680 inst
.operands
[1].reg
= tmp
;
12681 NEON_ENCODE (INTEGER
, inst
);
12682 neon_three_same (neon_quad (rs
), et
.type
== NT_unsigned
, et
.size
);
12687 do_neon_qshl_imm (void)
12689 if (!inst
.operands
[2].isreg
)
12691 enum neon_shape rs
= neon_select_shape (NS_DDI
, NS_QQI
, NS_NULL
);
12692 struct neon_type_el et
= neon_check_type (2, rs
, N_EQK
, N_SU_ALL
| N_KEY
);
12694 NEON_ENCODE (IMMED
, inst
);
12695 neon_imm_shift (TRUE
, et
.type
== NT_unsigned
, neon_quad (rs
), et
,
12696 inst
.operands
[2].imm
);
12700 enum neon_shape rs
= neon_select_shape (NS_DDD
, NS_QQQ
, NS_NULL
);
12701 struct neon_type_el et
= neon_check_type (3, rs
,
12702 N_EQK
, N_SU_ALL
| N_KEY
, N_EQK
| N_SGN
);
12705 /* See note in do_neon_shl_imm. */
12706 tmp
= inst
.operands
[2].reg
;
12707 inst
.operands
[2].reg
= inst
.operands
[1].reg
;
12708 inst
.operands
[1].reg
= tmp
;
12709 NEON_ENCODE (INTEGER
, inst
);
12710 neon_three_same (neon_quad (rs
), et
.type
== NT_unsigned
, et
.size
);
12715 do_neon_rshl (void)
12717 enum neon_shape rs
= neon_select_shape (NS_DDD
, NS_QQQ
, NS_NULL
);
12718 struct neon_type_el et
= neon_check_type (3, rs
,
12719 N_EQK
, N_EQK
, N_SU_ALL
| N_KEY
);
12722 tmp
= inst
.operands
[2].reg
;
12723 inst
.operands
[2].reg
= inst
.operands
[1].reg
;
12724 inst
.operands
[1].reg
= tmp
;
12725 neon_three_same (neon_quad (rs
), et
.type
== NT_unsigned
, et
.size
);
12729 neon_cmode_for_logic_imm (unsigned immediate
, unsigned *immbits
, int size
)
12731 /* Handle .I8 pseudo-instructions. */
12734 /* Unfortunately, this will make everything apart from zero out-of-range.
12735 FIXME is this the intended semantics? There doesn't seem much point in
12736 accepting .I8 if so. */
12737 immediate
|= immediate
<< 8;
12743 if (immediate
== (immediate
& 0x000000ff))
12745 *immbits
= immediate
;
12748 else if (immediate
== (immediate
& 0x0000ff00))
12750 *immbits
= immediate
>> 8;
12753 else if (immediate
== (immediate
& 0x00ff0000))
12755 *immbits
= immediate
>> 16;
12758 else if (immediate
== (immediate
& 0xff000000))
12760 *immbits
= immediate
>> 24;
12763 if ((immediate
& 0xffff) != (immediate
>> 16))
12764 goto bad_immediate
;
12765 immediate
&= 0xffff;
12768 if (immediate
== (immediate
& 0x000000ff))
12770 *immbits
= immediate
;
12773 else if (immediate
== (immediate
& 0x0000ff00))
12775 *immbits
= immediate
>> 8;
12780 first_error (_("immediate value out of range"));
12784 /* True if IMM has form 0bAAAAAAAABBBBBBBBCCCCCCCCDDDDDDDD for bits
12788 neon_bits_same_in_bytes (unsigned imm
)
12790 return ((imm
& 0x000000ff) == 0 || (imm
& 0x000000ff) == 0x000000ff)
12791 && ((imm
& 0x0000ff00) == 0 || (imm
& 0x0000ff00) == 0x0000ff00)
12792 && ((imm
& 0x00ff0000) == 0 || (imm
& 0x00ff0000) == 0x00ff0000)
12793 && ((imm
& 0xff000000) == 0 || (imm
& 0xff000000) == 0xff000000);
12796 /* For immediate of above form, return 0bABCD. */
12799 neon_squash_bits (unsigned imm
)
12801 return (imm
& 0x01) | ((imm
& 0x0100) >> 7) | ((imm
& 0x010000) >> 14)
12802 | ((imm
& 0x01000000) >> 21);
12805 /* Compress quarter-float representation to 0b...000 abcdefgh. */
12808 neon_qfloat_bits (unsigned imm
)
12810 return ((imm
>> 19) & 0x7f) | ((imm
>> 24) & 0x80);
12813 /* Returns CMODE. IMMBITS [7:0] is set to bits suitable for inserting into
12814 the instruction. *OP is passed as the initial value of the op field, and
12815 may be set to a different value depending on the constant (i.e.
12816 "MOV I64, 0bAAAAAAAABBBB..." which uses OP = 1 despite being MOV not
12817 MVN). If the immediate looks like a repeated pattern then also
12818 try smaller element sizes. */
12821 neon_cmode_for_move_imm (unsigned immlo
, unsigned immhi
, int float_p
,
12822 unsigned *immbits
, int *op
, int size
,
12823 enum neon_el_type type
)
12825 /* Only permit float immediates (including 0.0/-0.0) if the operand type is
12827 if (type
== NT_float
&& !float_p
)
12830 if (type
== NT_float
&& is_quarter_float (immlo
) && immhi
== 0)
12832 if (size
!= 32 || *op
== 1)
12834 *immbits
= neon_qfloat_bits (immlo
);
12840 if (neon_bits_same_in_bytes (immhi
)
12841 && neon_bits_same_in_bytes (immlo
))
12845 *immbits
= (neon_squash_bits (immhi
) << 4)
12846 | neon_squash_bits (immlo
);
12851 if (immhi
!= immlo
)
12857 if (immlo
== (immlo
& 0x000000ff))
12862 else if (immlo
== (immlo
& 0x0000ff00))
12864 *immbits
= immlo
>> 8;
12867 else if (immlo
== (immlo
& 0x00ff0000))
12869 *immbits
= immlo
>> 16;
12872 else if (immlo
== (immlo
& 0xff000000))
12874 *immbits
= immlo
>> 24;
12877 else if (immlo
== ((immlo
& 0x0000ff00) | 0x000000ff))
12879 *immbits
= (immlo
>> 8) & 0xff;
12882 else if (immlo
== ((immlo
& 0x00ff0000) | 0x0000ffff))
12884 *immbits
= (immlo
>> 16) & 0xff;
12888 if ((immlo
& 0xffff) != (immlo
>> 16))
12895 if (immlo
== (immlo
& 0x000000ff))
12900 else if (immlo
== (immlo
& 0x0000ff00))
12902 *immbits
= immlo
>> 8;
12906 if ((immlo
& 0xff) != (immlo
>> 8))
12911 if (immlo
== (immlo
& 0x000000ff))
12913 /* Don't allow MVN with 8-bit immediate. */
12923 /* Write immediate bits [7:0] to the following locations:
12925 |28/24|23 19|18 16|15 4|3 0|
12926 | a |x x x x x|b c d|x x x x x x x x x x x x|e f g h|
12928 This function is used by VMOV/VMVN/VORR/VBIC. */
12931 neon_write_immbits (unsigned immbits
)
12933 inst
.instruction
|= immbits
& 0xf;
12934 inst
.instruction
|= ((immbits
>> 4) & 0x7) << 16;
12935 inst
.instruction
|= ((immbits
>> 7) & 0x1) << 24;
12938 /* Invert low-order SIZE bits of XHI:XLO. */
12941 neon_invert_size (unsigned *xlo
, unsigned *xhi
, int size
)
12943 unsigned immlo
= xlo
? *xlo
: 0;
12944 unsigned immhi
= xhi
? *xhi
: 0;
12949 immlo
= (~immlo
) & 0xff;
12953 immlo
= (~immlo
) & 0xffff;
12957 immhi
= (~immhi
) & 0xffffffff;
12958 /* fall through. */
12961 immlo
= (~immlo
) & 0xffffffff;
12976 do_neon_logic (void)
12978 if (inst
.operands
[2].present
&& inst
.operands
[2].isreg
)
12980 enum neon_shape rs
= neon_select_shape (NS_DDD
, NS_QQQ
, NS_NULL
);
12981 neon_check_type (3, rs
, N_IGNORE_TYPE
);
12982 /* U bit and size field were set as part of the bitmask. */
12983 NEON_ENCODE (INTEGER
, inst
);
12984 neon_three_same (neon_quad (rs
), 0, -1);
12988 const int three_ops_form
= (inst
.operands
[2].present
12989 && !inst
.operands
[2].isreg
);
12990 const int immoperand
= (three_ops_form
? 2 : 1);
12991 enum neon_shape rs
= (three_ops_form
12992 ? neon_select_shape (NS_DDI
, NS_QQI
, NS_NULL
)
12993 : neon_select_shape (NS_DI
, NS_QI
, NS_NULL
));
12994 struct neon_type_el et
= neon_check_type (2, rs
,
12995 N_I8
| N_I16
| N_I32
| N_I64
| N_F32
| N_KEY
, N_EQK
);
12996 enum neon_opc opcode
= (enum neon_opc
) inst
.instruction
& 0x0fffffff;
13000 if (et
.type
== NT_invtype
)
13003 if (three_ops_form
)
13004 constraint (inst
.operands
[0].reg
!= inst
.operands
[1].reg
,
13005 _("first and second operands shall be the same register"));
13007 NEON_ENCODE (IMMED
, inst
);
13009 immbits
= inst
.operands
[immoperand
].imm
;
13012 /* .i64 is a pseudo-op, so the immediate must be a repeating
13014 if (immbits
!= (inst
.operands
[immoperand
].regisimm
?
13015 inst
.operands
[immoperand
].reg
: 0))
13017 /* Set immbits to an invalid constant. */
13018 immbits
= 0xdeadbeef;
13025 cmode
= neon_cmode_for_logic_imm (immbits
, &immbits
, et
.size
);
13029 cmode
= neon_cmode_for_logic_imm (immbits
, &immbits
, et
.size
);
13033 /* Pseudo-instruction for VBIC. */
13034 neon_invert_size (&immbits
, 0, et
.size
);
13035 cmode
= neon_cmode_for_logic_imm (immbits
, &immbits
, et
.size
);
13039 /* Pseudo-instruction for VORR. */
13040 neon_invert_size (&immbits
, 0, et
.size
);
13041 cmode
= neon_cmode_for_logic_imm (immbits
, &immbits
, et
.size
);
13051 inst
.instruction
|= neon_quad (rs
) << 6;
13052 inst
.instruction
|= LOW4 (inst
.operands
[0].reg
) << 12;
13053 inst
.instruction
|= HI1 (inst
.operands
[0].reg
) << 22;
13054 inst
.instruction
|= cmode
<< 8;
13055 neon_write_immbits (immbits
);
13057 neon_dp_fixup (&inst
);
13062 do_neon_bitfield (void)
13064 enum neon_shape rs
= neon_select_shape (NS_DDD
, NS_QQQ
, NS_NULL
);
13065 neon_check_type (3, rs
, N_IGNORE_TYPE
);
13066 neon_three_same (neon_quad (rs
), 0, -1);
13070 neon_dyadic_misc (enum neon_el_type ubit_meaning
, unsigned types
,
13073 enum neon_shape rs
= neon_select_shape (NS_DDD
, NS_QQQ
, NS_NULL
);
13074 struct neon_type_el et
= neon_check_type (3, rs
, N_EQK
| destbits
, N_EQK
,
13076 if (et
.type
== NT_float
)
13078 NEON_ENCODE (FLOAT
, inst
);
13079 neon_three_same (neon_quad (rs
), 0, -1);
13083 NEON_ENCODE (INTEGER
, inst
);
13084 neon_three_same (neon_quad (rs
), et
.type
== ubit_meaning
, et
.size
);
13089 do_neon_dyadic_if_su (void)
13091 neon_dyadic_misc (NT_unsigned
, N_SUF_32
, 0);
13095 do_neon_dyadic_if_su_d (void)
13097 /* This version only allow D registers, but that constraint is enforced during
13098 operand parsing so we don't need to do anything extra here. */
13099 neon_dyadic_misc (NT_unsigned
, N_SUF_32
, 0);
13103 do_neon_dyadic_if_i_d (void)
13105 /* The "untyped" case can't happen. Do this to stop the "U" bit being
13106 affected if we specify unsigned args. */
13107 neon_dyadic_misc (NT_untyped
, N_IF_32
, 0);
13110 enum vfp_or_neon_is_neon_bits
13113 NEON_CHECK_ARCH
= 2
13116 /* Call this function if an instruction which may have belonged to the VFP or
13117 Neon instruction sets, but turned out to be a Neon instruction (due to the
13118 operand types involved, etc.). We have to check and/or fix-up a couple of
13121 - Make sure the user hasn't attempted to make a Neon instruction
13123 - Alter the value in the condition code field if necessary.
13124 - Make sure that the arch supports Neon instructions.
13126 Which of these operations take place depends on bits from enum
13127 vfp_or_neon_is_neon_bits.
13129 WARNING: This function has side effects! If NEON_CHECK_CC is used and the
13130 current instruction's condition is COND_ALWAYS, the condition field is
13131 changed to inst.uncond_value. This is necessary because instructions shared
13132 between VFP and Neon may be conditional for the VFP variants only, and the
13133 unconditional Neon version must have, e.g., 0xF in the condition field. */
13136 vfp_or_neon_is_neon (unsigned check
)
13138 /* Conditions are always legal in Thumb mode (IT blocks). */
13139 if (!thumb_mode
&& (check
& NEON_CHECK_CC
))
13141 if (inst
.cond
!= COND_ALWAYS
)
13143 first_error (_(BAD_COND
));
13146 if (inst
.uncond_value
!= -1)
13147 inst
.instruction
|= inst
.uncond_value
<< 28;
13150 if ((check
& NEON_CHECK_ARCH
)
13151 && !ARM_CPU_HAS_FEATURE (cpu_variant
, fpu_neon_ext_v1
))
13153 first_error (_(BAD_FPU
));
13161 do_neon_addsub_if_i (void)
13163 if (try_vfp_nsyn (3, do_vfp_nsyn_add_sub
) == SUCCESS
)
13166 if (vfp_or_neon_is_neon (NEON_CHECK_CC
| NEON_CHECK_ARCH
) == FAIL
)
13169 /* The "untyped" case can't happen. Do this to stop the "U" bit being
13170 affected if we specify unsigned args. */
13171 neon_dyadic_misc (NT_untyped
, N_IF_32
| N_I64
, 0);
13174 /* Swaps operands 1 and 2. If operand 1 (optional arg) was omitted, we want the
13176 V<op> A,B (A is operand 0, B is operand 2)
13181 so handle that case specially. */
13184 neon_exchange_operands (void)
13186 void *scratch
= alloca (sizeof (inst
.operands
[0]));
13187 if (inst
.operands
[1].present
)
13189 /* Swap operands[1] and operands[2]. */
13190 memcpy (scratch
, &inst
.operands
[1], sizeof (inst
.operands
[0]));
13191 inst
.operands
[1] = inst
.operands
[2];
13192 memcpy (&inst
.operands
[2], scratch
, sizeof (inst
.operands
[0]));
13196 inst
.operands
[1] = inst
.operands
[2];
13197 inst
.operands
[2] = inst
.operands
[0];
13202 neon_compare (unsigned regtypes
, unsigned immtypes
, int invert
)
13204 if (inst
.operands
[2].isreg
)
13207 neon_exchange_operands ();
13208 neon_dyadic_misc (NT_unsigned
, regtypes
, N_SIZ
);
13212 enum neon_shape rs
= neon_select_shape (NS_DDI
, NS_QQI
, NS_NULL
);
13213 struct neon_type_el et
= neon_check_type (2, rs
,
13214 N_EQK
| N_SIZ
, immtypes
| N_KEY
);
13216 NEON_ENCODE (IMMED
, inst
);
13217 inst
.instruction
|= LOW4 (inst
.operands
[0].reg
) << 12;
13218 inst
.instruction
|= HI1 (inst
.operands
[0].reg
) << 22;
13219 inst
.instruction
|= LOW4 (inst
.operands
[1].reg
);
13220 inst
.instruction
|= HI1 (inst
.operands
[1].reg
) << 5;
13221 inst
.instruction
|= neon_quad (rs
) << 6;
13222 inst
.instruction
|= (et
.type
== NT_float
) << 10;
13223 inst
.instruction
|= neon_logbits (et
.size
) << 18;
13225 neon_dp_fixup (&inst
);
13232 neon_compare (N_SUF_32
, N_S8
| N_S16
| N_S32
| N_F32
, FALSE
);
13236 do_neon_cmp_inv (void)
13238 neon_compare (N_SUF_32
, N_S8
| N_S16
| N_S32
| N_F32
, TRUE
);
13244 neon_compare (N_IF_32
, N_IF_32
, FALSE
);
13247 /* For multiply instructions, we have the possibility of 16-bit or 32-bit
13248 scalars, which are encoded in 5 bits, M : Rm.
13249 For 16-bit scalars, the register is encoded in Rm[2:0] and the index in
13250 M:Rm[3], and for 32-bit scalars, the register is encoded in Rm[3:0] and the
13254 neon_scalar_for_mul (unsigned scalar
, unsigned elsize
)
13256 unsigned regno
= NEON_SCALAR_REG (scalar
);
13257 unsigned elno
= NEON_SCALAR_INDEX (scalar
);
13262 if (regno
> 7 || elno
> 3)
13264 return regno
| (elno
<< 3);
13267 if (regno
> 15 || elno
> 1)
13269 return regno
| (elno
<< 4);
13273 first_error (_("scalar out of range for multiply instruction"));
13279 /* Encode multiply / multiply-accumulate scalar instructions. */
13282 neon_mul_mac (struct neon_type_el et
, int ubit
)
13286 /* Give a more helpful error message if we have an invalid type. */
13287 if (et
.type
== NT_invtype
)
13290 scalar
= neon_scalar_for_mul (inst
.operands
[2].reg
, et
.size
);
13291 inst
.instruction
|= LOW4 (inst
.operands
[0].reg
) << 12;
13292 inst
.instruction
|= HI1 (inst
.operands
[0].reg
) << 22;
13293 inst
.instruction
|= LOW4 (inst
.operands
[1].reg
) << 16;
13294 inst
.instruction
|= HI1 (inst
.operands
[1].reg
) << 7;
13295 inst
.instruction
|= LOW4 (scalar
);
13296 inst
.instruction
|= HI1 (scalar
) << 5;
13297 inst
.instruction
|= (et
.type
== NT_float
) << 8;
13298 inst
.instruction
|= neon_logbits (et
.size
) << 20;
13299 inst
.instruction
|= (ubit
!= 0) << 24;
13301 neon_dp_fixup (&inst
);
13305 do_neon_mac_maybe_scalar (void)
13307 if (try_vfp_nsyn (3, do_vfp_nsyn_mla_mls
) == SUCCESS
)
13310 if (vfp_or_neon_is_neon (NEON_CHECK_CC
| NEON_CHECK_ARCH
) == FAIL
)
13313 if (inst
.operands
[2].isscalar
)
13315 enum neon_shape rs
= neon_select_shape (NS_DDS
, NS_QQS
, NS_NULL
);
13316 struct neon_type_el et
= neon_check_type (3, rs
,
13317 N_EQK
, N_EQK
, N_I16
| N_I32
| N_F32
| N_KEY
);
13318 NEON_ENCODE (SCALAR
, inst
);
13319 neon_mul_mac (et
, neon_quad (rs
));
13323 /* The "untyped" case can't happen. Do this to stop the "U" bit being
13324 affected if we specify unsigned args. */
13325 neon_dyadic_misc (NT_untyped
, N_IF_32
, 0);
13330 do_neon_fmac (void)
13332 if (try_vfp_nsyn (3, do_vfp_nsyn_fma_fms
) == SUCCESS
)
13335 if (vfp_or_neon_is_neon (NEON_CHECK_CC
| NEON_CHECK_ARCH
) == FAIL
)
13338 neon_dyadic_misc (NT_untyped
, N_IF_32
, 0);
13344 enum neon_shape rs
= neon_select_shape (NS_DDD
, NS_QQQ
, NS_NULL
);
13345 struct neon_type_el et
= neon_check_type (3, rs
,
13346 N_EQK
, N_EQK
, N_8
| N_16
| N_32
| N_KEY
);
13347 neon_three_same (neon_quad (rs
), 0, et
.size
);
13350 /* VMUL with 3 registers allows the P8 type. The scalar version supports the
13351 same types as the MAC equivalents. The polynomial type for this instruction
13352 is encoded the same as the integer type. */
13357 if (try_vfp_nsyn (3, do_vfp_nsyn_mul
) == SUCCESS
)
13360 if (vfp_or_neon_is_neon (NEON_CHECK_CC
| NEON_CHECK_ARCH
) == FAIL
)
13363 if (inst
.operands
[2].isscalar
)
13364 do_neon_mac_maybe_scalar ();
13366 neon_dyadic_misc (NT_poly
, N_I8
| N_I16
| N_I32
| N_F32
| N_P8
, 0);
13370 do_neon_qdmulh (void)
13372 if (inst
.operands
[2].isscalar
)
13374 enum neon_shape rs
= neon_select_shape (NS_DDS
, NS_QQS
, NS_NULL
);
13375 struct neon_type_el et
= neon_check_type (3, rs
,
13376 N_EQK
, N_EQK
, N_S16
| N_S32
| N_KEY
);
13377 NEON_ENCODE (SCALAR
, inst
);
13378 neon_mul_mac (et
, neon_quad (rs
));
13382 enum neon_shape rs
= neon_select_shape (NS_DDD
, NS_QQQ
, NS_NULL
);
13383 struct neon_type_el et
= neon_check_type (3, rs
,
13384 N_EQK
, N_EQK
, N_S16
| N_S32
| N_KEY
);
13385 NEON_ENCODE (INTEGER
, inst
);
13386 /* The U bit (rounding) comes from bit mask. */
13387 neon_three_same (neon_quad (rs
), 0, et
.size
);
13392 do_neon_fcmp_absolute (void)
13394 enum neon_shape rs
= neon_select_shape (NS_DDD
, NS_QQQ
, NS_NULL
);
13395 neon_check_type (3, rs
, N_EQK
, N_EQK
, N_F32
| N_KEY
);
13396 /* Size field comes from bit mask. */
13397 neon_three_same (neon_quad (rs
), 1, -1);
13401 do_neon_fcmp_absolute_inv (void)
13403 neon_exchange_operands ();
13404 do_neon_fcmp_absolute ();
13408 do_neon_step (void)
13410 enum neon_shape rs
= neon_select_shape (NS_DDD
, NS_QQQ
, NS_NULL
);
13411 neon_check_type (3, rs
, N_EQK
, N_EQK
, N_F32
| N_KEY
);
13412 neon_three_same (neon_quad (rs
), 0, -1);
13416 do_neon_abs_neg (void)
13418 enum neon_shape rs
;
13419 struct neon_type_el et
;
13421 if (try_vfp_nsyn (2, do_vfp_nsyn_abs_neg
) == SUCCESS
)
13424 if (vfp_or_neon_is_neon (NEON_CHECK_CC
| NEON_CHECK_ARCH
) == FAIL
)
13427 rs
= neon_select_shape (NS_DD
, NS_QQ
, NS_NULL
);
13428 et
= neon_check_type (2, rs
, N_EQK
, N_S8
| N_S16
| N_S32
| N_F32
| N_KEY
);
13430 inst
.instruction
|= LOW4 (inst
.operands
[0].reg
) << 12;
13431 inst
.instruction
|= HI1 (inst
.operands
[0].reg
) << 22;
13432 inst
.instruction
|= LOW4 (inst
.operands
[1].reg
);
13433 inst
.instruction
|= HI1 (inst
.operands
[1].reg
) << 5;
13434 inst
.instruction
|= neon_quad (rs
) << 6;
13435 inst
.instruction
|= (et
.type
== NT_float
) << 10;
13436 inst
.instruction
|= neon_logbits (et
.size
) << 18;
13438 neon_dp_fixup (&inst
);
13444 enum neon_shape rs
= neon_select_shape (NS_DDI
, NS_QQI
, NS_NULL
);
13445 struct neon_type_el et
= neon_check_type (2, rs
,
13446 N_EQK
, N_8
| N_16
| N_32
| N_64
| N_KEY
);
13447 int imm
= inst
.operands
[2].imm
;
13448 constraint (imm
< 0 || (unsigned)imm
>= et
.size
,
13449 _("immediate out of range for insert"));
13450 neon_imm_shift (FALSE
, 0, neon_quad (rs
), et
, imm
);
13456 enum neon_shape rs
= neon_select_shape (NS_DDI
, NS_QQI
, NS_NULL
);
13457 struct neon_type_el et
= neon_check_type (2, rs
,
13458 N_EQK
, N_8
| N_16
| N_32
| N_64
| N_KEY
);
13459 int imm
= inst
.operands
[2].imm
;
13460 constraint (imm
< 1 || (unsigned)imm
> et
.size
,
13461 _("immediate out of range for insert"));
13462 neon_imm_shift (FALSE
, 0, neon_quad (rs
), et
, et
.size
- imm
);
13466 do_neon_qshlu_imm (void)
13468 enum neon_shape rs
= neon_select_shape (NS_DDI
, NS_QQI
, NS_NULL
);
13469 struct neon_type_el et
= neon_check_type (2, rs
,
13470 N_EQK
| N_UNS
, N_S8
| N_S16
| N_S32
| N_S64
| N_KEY
);
13471 int imm
= inst
.operands
[2].imm
;
13472 constraint (imm
< 0 || (unsigned)imm
>= et
.size
,
13473 _("immediate out of range for shift"));
13474 /* Only encodes the 'U present' variant of the instruction.
13475 In this case, signed types have OP (bit 8) set to 0.
13476 Unsigned types have OP set to 1. */
13477 inst
.instruction
|= (et
.type
== NT_unsigned
) << 8;
13478 /* The rest of the bits are the same as other immediate shifts. */
13479 neon_imm_shift (FALSE
, 0, neon_quad (rs
), et
, imm
);
13483 do_neon_qmovn (void)
13485 struct neon_type_el et
= neon_check_type (2, NS_DQ
,
13486 N_EQK
| N_HLF
, N_SU_16_64
| N_KEY
);
13487 /* Saturating move where operands can be signed or unsigned, and the
13488 destination has the same signedness. */
13489 NEON_ENCODE (INTEGER
, inst
);
13490 if (et
.type
== NT_unsigned
)
13491 inst
.instruction
|= 0xc0;
13493 inst
.instruction
|= 0x80;
13494 neon_two_same (0, 1, et
.size
/ 2);
13498 do_neon_qmovun (void)
13500 struct neon_type_el et
= neon_check_type (2, NS_DQ
,
13501 N_EQK
| N_HLF
| N_UNS
, N_S16
| N_S32
| N_S64
| N_KEY
);
13502 /* Saturating move with unsigned results. Operands must be signed. */
13503 NEON_ENCODE (INTEGER
, inst
);
13504 neon_two_same (0, 1, et
.size
/ 2);
13508 do_neon_rshift_sat_narrow (void)
13510 /* FIXME: Types for narrowing. If operands are signed, results can be signed
13511 or unsigned. If operands are unsigned, results must also be unsigned. */
13512 struct neon_type_el et
= neon_check_type (2, NS_DQI
,
13513 N_EQK
| N_HLF
, N_SU_16_64
| N_KEY
);
13514 int imm
= inst
.operands
[2].imm
;
13515 /* This gets the bounds check, size encoding and immediate bits calculation
13519 /* VQ{R}SHRN.I<size> <Dd>, <Qm>, #0 is a synonym for
13520 VQMOVN.I<size> <Dd>, <Qm>. */
13523 inst
.operands
[2].present
= 0;
13524 inst
.instruction
= N_MNEM_vqmovn
;
13529 constraint (imm
< 1 || (unsigned)imm
> et
.size
,
13530 _("immediate out of range"));
13531 neon_imm_shift (TRUE
, et
.type
== NT_unsigned
, 0, et
, et
.size
- imm
);
13535 do_neon_rshift_sat_narrow_u (void)
13537 /* FIXME: Types for narrowing. If operands are signed, results can be signed
13538 or unsigned. If operands are unsigned, results must also be unsigned. */
13539 struct neon_type_el et
= neon_check_type (2, NS_DQI
,
13540 N_EQK
| N_HLF
| N_UNS
, N_S16
| N_S32
| N_S64
| N_KEY
);
13541 int imm
= inst
.operands
[2].imm
;
13542 /* This gets the bounds check, size encoding and immediate bits calculation
13546 /* VQSHRUN.I<size> <Dd>, <Qm>, #0 is a synonym for
13547 VQMOVUN.I<size> <Dd>, <Qm>. */
13550 inst
.operands
[2].present
= 0;
13551 inst
.instruction
= N_MNEM_vqmovun
;
13556 constraint (imm
< 1 || (unsigned)imm
> et
.size
,
13557 _("immediate out of range"));
13558 /* FIXME: The manual is kind of unclear about what value U should have in
13559 VQ{R}SHRUN instructions, but U=0, op=0 definitely encodes VRSHR, so it
13561 neon_imm_shift (TRUE
, 1, 0, et
, et
.size
- imm
);
13565 do_neon_movn (void)
13567 struct neon_type_el et
= neon_check_type (2, NS_DQ
,
13568 N_EQK
| N_HLF
, N_I16
| N_I32
| N_I64
| N_KEY
);
13569 NEON_ENCODE (INTEGER
, inst
);
13570 neon_two_same (0, 1, et
.size
/ 2);
13574 do_neon_rshift_narrow (void)
13576 struct neon_type_el et
= neon_check_type (2, NS_DQI
,
13577 N_EQK
| N_HLF
, N_I16
| N_I32
| N_I64
| N_KEY
);
13578 int imm
= inst
.operands
[2].imm
;
13579 /* This gets the bounds check, size encoding and immediate bits calculation
13583 /* If immediate is zero then we are a pseudo-instruction for
13584 VMOVN.I<size> <Dd>, <Qm> */
13587 inst
.operands
[2].present
= 0;
13588 inst
.instruction
= N_MNEM_vmovn
;
13593 constraint (imm
< 1 || (unsigned)imm
> et
.size
,
13594 _("immediate out of range for narrowing operation"));
13595 neon_imm_shift (FALSE
, 0, 0, et
, et
.size
- imm
);
13599 do_neon_shll (void)
13601 /* FIXME: Type checking when lengthening. */
13602 struct neon_type_el et
= neon_check_type (2, NS_QDI
,
13603 N_EQK
| N_DBL
, N_I8
| N_I16
| N_I32
| N_KEY
);
13604 unsigned imm
= inst
.operands
[2].imm
;
13606 if (imm
== et
.size
)
13608 /* Maximum shift variant. */
13609 NEON_ENCODE (INTEGER
, inst
);
13610 inst
.instruction
|= LOW4 (inst
.operands
[0].reg
) << 12;
13611 inst
.instruction
|= HI1 (inst
.operands
[0].reg
) << 22;
13612 inst
.instruction
|= LOW4 (inst
.operands
[1].reg
);
13613 inst
.instruction
|= HI1 (inst
.operands
[1].reg
) << 5;
13614 inst
.instruction
|= neon_logbits (et
.size
) << 18;
13616 neon_dp_fixup (&inst
);
13620 /* A more-specific type check for non-max versions. */
13621 et
= neon_check_type (2, NS_QDI
,
13622 N_EQK
| N_DBL
, N_SU_32
| N_KEY
);
13623 NEON_ENCODE (IMMED
, inst
);
13624 neon_imm_shift (TRUE
, et
.type
== NT_unsigned
, 0, et
, imm
);
13628 /* Check the various types for the VCVT instruction, and return which version
13629 the current instruction is. */
13632 neon_cvt_flavour (enum neon_shape rs
)
13634 #define CVT_VAR(C,X,Y) \
13635 et = neon_check_type (2, rs, whole_reg | (X), whole_reg | (Y)); \
13636 if (et.type != NT_invtype) \
13638 inst.error = NULL; \
13641 struct neon_type_el et
;
13642 unsigned whole_reg
= (rs
== NS_FFI
|| rs
== NS_FD
|| rs
== NS_DF
13643 || rs
== NS_FF
) ? N_VFP
: 0;
13644 /* The instruction versions which take an immediate take one register
13645 argument, which is extended to the width of the full register. Thus the
13646 "source" and "destination" registers must have the same width. Hack that
13647 here by making the size equal to the key (wider, in this case) operand. */
13648 unsigned key
= (rs
== NS_QQI
|| rs
== NS_DDI
|| rs
== NS_FFI
) ? N_KEY
: 0;
13650 CVT_VAR (0, N_S32
, N_F32
);
13651 CVT_VAR (1, N_U32
, N_F32
);
13652 CVT_VAR (2, N_F32
, N_S32
);
13653 CVT_VAR (3, N_F32
, N_U32
);
13654 /* Half-precision conversions. */
13655 CVT_VAR (4, N_F32
, N_F16
);
13656 CVT_VAR (5, N_F16
, N_F32
);
13660 /* VFP instructions. */
13661 CVT_VAR (6, N_F32
, N_F64
);
13662 CVT_VAR (7, N_F64
, N_F32
);
13663 CVT_VAR (8, N_S32
, N_F64
| key
);
13664 CVT_VAR (9, N_U32
, N_F64
| key
);
13665 CVT_VAR (10, N_F64
| key
, N_S32
);
13666 CVT_VAR (11, N_F64
| key
, N_U32
);
13667 /* VFP instructions with bitshift. */
13668 CVT_VAR (12, N_F32
| key
, N_S16
);
13669 CVT_VAR (13, N_F32
| key
, N_U16
);
13670 CVT_VAR (14, N_F64
| key
, N_S16
);
13671 CVT_VAR (15, N_F64
| key
, N_U16
);
13672 CVT_VAR (16, N_S16
, N_F32
| key
);
13673 CVT_VAR (17, N_U16
, N_F32
| key
);
13674 CVT_VAR (18, N_S16
, N_F64
| key
);
13675 CVT_VAR (19, N_U16
, N_F64
| key
);
13681 /* Neon-syntax VFP conversions. */
13684 do_vfp_nsyn_cvt (enum neon_shape rs
, int flavour
)
13686 const char *opname
= 0;
13688 if (rs
== NS_DDI
|| rs
== NS_QQI
|| rs
== NS_FFI
)
13690 /* Conversions with immediate bitshift. */
13691 const char *enc
[] =
13715 if (flavour
>= 0 && flavour
< (int) ARRAY_SIZE (enc
))
13717 opname
= enc
[flavour
];
13718 constraint (inst
.operands
[0].reg
!= inst
.operands
[1].reg
,
13719 _("operands 0 and 1 must be the same register"));
13720 inst
.operands
[1] = inst
.operands
[2];
13721 memset (&inst
.operands
[2], '\0', sizeof (inst
.operands
[2]));
13726 /* Conversions without bitshift. */
13727 const char *enc
[] =
13743 if (flavour
>= 0 && flavour
< (int) ARRAY_SIZE (enc
))
13744 opname
= enc
[flavour
];
13748 do_vfp_nsyn_opcode (opname
);
13752 do_vfp_nsyn_cvtz (void)
13754 enum neon_shape rs
= neon_select_shape (NS_FF
, NS_FD
, NS_NULL
);
13755 int flavour
= neon_cvt_flavour (rs
);
13756 const char *enc
[] =
13770 if (flavour
>= 0 && flavour
< (int) ARRAY_SIZE (enc
) && enc
[flavour
])
13771 do_vfp_nsyn_opcode (enc
[flavour
]);
13775 do_neon_cvt_1 (bfd_boolean round_to_zero ATTRIBUTE_UNUSED
)
13777 enum neon_shape rs
= neon_select_shape (NS_DDI
, NS_QQI
, NS_FFI
, NS_DD
, NS_QQ
,
13778 NS_FD
, NS_DF
, NS_FF
, NS_QD
, NS_DQ
, NS_NULL
);
13779 int flavour
= neon_cvt_flavour (rs
);
13781 /* PR11109: Handle round-to-zero for VCVT conversions. */
13783 && ARM_CPU_HAS_FEATURE (cpu_variant
, fpu_arch_vfp_v2
)
13784 && (flavour
== 0 || flavour
== 1 || flavour
== 8 || flavour
== 9)
13785 && (rs
== NS_FD
|| rs
== NS_FF
))
13787 do_vfp_nsyn_cvtz ();
13791 /* VFP rather than Neon conversions. */
13794 do_vfp_nsyn_cvt (rs
, flavour
);
13804 unsigned enctab
[] = { 0x0000100, 0x1000100, 0x0, 0x1000000 };
13806 if (vfp_or_neon_is_neon (NEON_CHECK_CC
| NEON_CHECK_ARCH
) == FAIL
)
13809 /* Fixed-point conversion with #0 immediate is encoded as an
13810 integer conversion. */
13811 if (inst
.operands
[2].present
&& inst
.operands
[2].imm
== 0)
13813 immbits
= 32 - inst
.operands
[2].imm
;
13814 NEON_ENCODE (IMMED
, inst
);
13816 inst
.instruction
|= enctab
[flavour
];
13817 inst
.instruction
|= LOW4 (inst
.operands
[0].reg
) << 12;
13818 inst
.instruction
|= HI1 (inst
.operands
[0].reg
) << 22;
13819 inst
.instruction
|= LOW4 (inst
.operands
[1].reg
);
13820 inst
.instruction
|= HI1 (inst
.operands
[1].reg
) << 5;
13821 inst
.instruction
|= neon_quad (rs
) << 6;
13822 inst
.instruction
|= 1 << 21;
13823 inst
.instruction
|= immbits
<< 16;
13825 neon_dp_fixup (&inst
);
13833 unsigned enctab
[] = { 0x100, 0x180, 0x0, 0x080 };
13835 NEON_ENCODE (INTEGER
, inst
);
13837 if (vfp_or_neon_is_neon (NEON_CHECK_CC
| NEON_CHECK_ARCH
) == FAIL
)
13841 inst
.instruction
|= enctab
[flavour
];
13843 inst
.instruction
|= LOW4 (inst
.operands
[0].reg
) << 12;
13844 inst
.instruction
|= HI1 (inst
.operands
[0].reg
) << 22;
13845 inst
.instruction
|= LOW4 (inst
.operands
[1].reg
);
13846 inst
.instruction
|= HI1 (inst
.operands
[1].reg
) << 5;
13847 inst
.instruction
|= neon_quad (rs
) << 6;
13848 inst
.instruction
|= 2 << 18;
13850 neon_dp_fixup (&inst
);
13854 /* Half-precision conversions for Advanced SIMD -- neon. */
13859 && (inst
.vectype
.el
[0].size
!= 16 || inst
.vectype
.el
[1].size
!= 32))
13861 as_bad (_("operand size must match register width"));
13866 && ((inst
.vectype
.el
[0].size
!= 32 || inst
.vectype
.el
[1].size
!= 16)))
13868 as_bad (_("operand size must match register width"));
13873 inst
.instruction
= 0x3b60600;
13875 inst
.instruction
= 0x3b60700;
13877 inst
.instruction
|= LOW4 (inst
.operands
[0].reg
) << 12;
13878 inst
.instruction
|= HI1 (inst
.operands
[0].reg
) << 22;
13879 inst
.instruction
|= LOW4 (inst
.operands
[1].reg
);
13880 inst
.instruction
|= HI1 (inst
.operands
[1].reg
) << 5;
13881 neon_dp_fixup (&inst
);
13885 /* Some VFP conversions go here (s32 <-> f32, u32 <-> f32). */
13886 do_vfp_nsyn_cvt (rs
, flavour
);
13891 do_neon_cvtr (void)
13893 do_neon_cvt_1 (FALSE
);
13899 do_neon_cvt_1 (TRUE
);
13903 do_neon_cvtb (void)
13905 inst
.instruction
= 0xeb20a40;
13907 /* The sizes are attached to the mnemonic. */
13908 if (inst
.vectype
.el
[0].type
!= NT_invtype
13909 && inst
.vectype
.el
[0].size
== 16)
13910 inst
.instruction
|= 0x00010000;
13912 /* Programmer's syntax: the sizes are attached to the operands. */
13913 else if (inst
.operands
[0].vectype
.type
!= NT_invtype
13914 && inst
.operands
[0].vectype
.size
== 16)
13915 inst
.instruction
|= 0x00010000;
13917 encode_arm_vfp_reg (inst
.operands
[0].reg
, VFP_REG_Sd
);
13918 encode_arm_vfp_reg (inst
.operands
[1].reg
, VFP_REG_Sm
);
13919 do_vfp_cond_or_thumb ();
13924 do_neon_cvtt (void)
13927 inst
.instruction
|= 0x80;
13931 neon_move_immediate (void)
13933 enum neon_shape rs
= neon_select_shape (NS_DI
, NS_QI
, NS_NULL
);
13934 struct neon_type_el et
= neon_check_type (2, rs
,
13935 N_I8
| N_I16
| N_I32
| N_I64
| N_F32
| N_KEY
, N_EQK
);
13936 unsigned immlo
, immhi
= 0, immbits
;
13937 int op
, cmode
, float_p
;
13939 constraint (et
.type
== NT_invtype
,
13940 _("operand size must be specified for immediate VMOV"));
13942 /* We start out as an MVN instruction if OP = 1, MOV otherwise. */
13943 op
= (inst
.instruction
& (1 << 5)) != 0;
13945 immlo
= inst
.operands
[1].imm
;
13946 if (inst
.operands
[1].regisimm
)
13947 immhi
= inst
.operands
[1].reg
;
13949 constraint (et
.size
< 32 && (immlo
& ~((1 << et
.size
) - 1)) != 0,
13950 _("immediate has bits set outside the operand size"));
13952 float_p
= inst
.operands
[1].immisfloat
;
13954 if ((cmode
= neon_cmode_for_move_imm (immlo
, immhi
, float_p
, &immbits
, &op
,
13955 et
.size
, et
.type
)) == FAIL
)
13957 /* Invert relevant bits only. */
13958 neon_invert_size (&immlo
, &immhi
, et
.size
);
13959 /* Flip from VMOV/VMVN to VMVN/VMOV. Some immediate types are unavailable
13960 with one or the other; those cases are caught by
13961 neon_cmode_for_move_imm. */
13963 if ((cmode
= neon_cmode_for_move_imm (immlo
, immhi
, float_p
, &immbits
,
13964 &op
, et
.size
, et
.type
)) == FAIL
)
13966 first_error (_("immediate out of range"));
13971 inst
.instruction
&= ~(1 << 5);
13972 inst
.instruction
|= op
<< 5;
13974 inst
.instruction
|= LOW4 (inst
.operands
[0].reg
) << 12;
13975 inst
.instruction
|= HI1 (inst
.operands
[0].reg
) << 22;
13976 inst
.instruction
|= neon_quad (rs
) << 6;
13977 inst
.instruction
|= cmode
<< 8;
13979 neon_write_immbits (immbits
);
13985 if (inst
.operands
[1].isreg
)
13987 enum neon_shape rs
= neon_select_shape (NS_DD
, NS_QQ
, NS_NULL
);
13989 NEON_ENCODE (INTEGER
, inst
);
13990 inst
.instruction
|= LOW4 (inst
.operands
[0].reg
) << 12;
13991 inst
.instruction
|= HI1 (inst
.operands
[0].reg
) << 22;
13992 inst
.instruction
|= LOW4 (inst
.operands
[1].reg
);
13993 inst
.instruction
|= HI1 (inst
.operands
[1].reg
) << 5;
13994 inst
.instruction
|= neon_quad (rs
) << 6;
13998 NEON_ENCODE (IMMED
, inst
);
13999 neon_move_immediate ();
14002 neon_dp_fixup (&inst
);
14005 /* Encode instructions of form:
14007 |28/24|23|22|21 20|19 16|15 12|11 8|7|6|5|4|3 0|
14008 | U |x |D |size | Rn | Rd |x x x x|N|x|M|x| Rm | */
14011 neon_mixed_length (struct neon_type_el et
, unsigned size
)
14013 inst
.instruction
|= LOW4 (inst
.operands
[0].reg
) << 12;
14014 inst
.instruction
|= HI1 (inst
.operands
[0].reg
) << 22;
14015 inst
.instruction
|= LOW4 (inst
.operands
[1].reg
) << 16;
14016 inst
.instruction
|= HI1 (inst
.operands
[1].reg
) << 7;
14017 inst
.instruction
|= LOW4 (inst
.operands
[2].reg
);
14018 inst
.instruction
|= HI1 (inst
.operands
[2].reg
) << 5;
14019 inst
.instruction
|= (et
.type
== NT_unsigned
) << 24;
14020 inst
.instruction
|= neon_logbits (size
) << 20;
14022 neon_dp_fixup (&inst
);
14026 do_neon_dyadic_long (void)
14028 /* FIXME: Type checking for lengthening op. */
14029 struct neon_type_el et
= neon_check_type (3, NS_QDD
,
14030 N_EQK
| N_DBL
, N_EQK
, N_SU_32
| N_KEY
);
14031 neon_mixed_length (et
, et
.size
);
14035 do_neon_abal (void)
14037 struct neon_type_el et
= neon_check_type (3, NS_QDD
,
14038 N_EQK
| N_INT
| N_DBL
, N_EQK
, N_SU_32
| N_KEY
);
14039 neon_mixed_length (et
, et
.size
);
14043 neon_mac_reg_scalar_long (unsigned regtypes
, unsigned scalartypes
)
14045 if (inst
.operands
[2].isscalar
)
14047 struct neon_type_el et
= neon_check_type (3, NS_QDS
,
14048 N_EQK
| N_DBL
, N_EQK
, regtypes
| N_KEY
);
14049 NEON_ENCODE (SCALAR
, inst
);
14050 neon_mul_mac (et
, et
.type
== NT_unsigned
);
14054 struct neon_type_el et
= neon_check_type (3, NS_QDD
,
14055 N_EQK
| N_DBL
, N_EQK
, scalartypes
| N_KEY
);
14056 NEON_ENCODE (INTEGER
, inst
);
14057 neon_mixed_length (et
, et
.size
);
14062 do_neon_mac_maybe_scalar_long (void)
14064 neon_mac_reg_scalar_long (N_S16
| N_S32
| N_U16
| N_U32
, N_SU_32
);
14068 do_neon_dyadic_wide (void)
14070 struct neon_type_el et
= neon_check_type (3, NS_QQD
,
14071 N_EQK
| N_DBL
, N_EQK
| N_DBL
, N_SU_32
| N_KEY
);
14072 neon_mixed_length (et
, et
.size
);
14076 do_neon_dyadic_narrow (void)
14078 struct neon_type_el et
= neon_check_type (3, NS_QDD
,
14079 N_EQK
| N_DBL
, N_EQK
, N_I16
| N_I32
| N_I64
| N_KEY
);
14080 /* Operand sign is unimportant, and the U bit is part of the opcode,
14081 so force the operand type to integer. */
14082 et
.type
= NT_integer
;
14083 neon_mixed_length (et
, et
.size
/ 2);
14087 do_neon_mul_sat_scalar_long (void)
14089 neon_mac_reg_scalar_long (N_S16
| N_S32
, N_S16
| N_S32
);
14093 do_neon_vmull (void)
14095 if (inst
.operands
[2].isscalar
)
14096 do_neon_mac_maybe_scalar_long ();
14099 struct neon_type_el et
= neon_check_type (3, NS_QDD
,
14100 N_EQK
| N_DBL
, N_EQK
, N_SU_32
| N_P8
| N_KEY
);
14101 if (et
.type
== NT_poly
)
14102 NEON_ENCODE (POLY
, inst
);
14104 NEON_ENCODE (INTEGER
, inst
);
14105 /* For polynomial encoding, size field must be 0b00 and the U bit must be
14106 zero. Should be OK as-is. */
14107 neon_mixed_length (et
, et
.size
);
14114 enum neon_shape rs
= neon_select_shape (NS_DDDI
, NS_QQQI
, NS_NULL
);
14115 struct neon_type_el et
= neon_check_type (3, rs
,
14116 N_EQK
, N_EQK
, N_8
| N_16
| N_32
| N_64
| N_KEY
);
14117 unsigned imm
= (inst
.operands
[3].imm
* et
.size
) / 8;
14119 constraint (imm
>= (unsigned) (neon_quad (rs
) ? 16 : 8),
14120 _("shift out of range"));
14121 inst
.instruction
|= LOW4 (inst
.operands
[0].reg
) << 12;
14122 inst
.instruction
|= HI1 (inst
.operands
[0].reg
) << 22;
14123 inst
.instruction
|= LOW4 (inst
.operands
[1].reg
) << 16;
14124 inst
.instruction
|= HI1 (inst
.operands
[1].reg
) << 7;
14125 inst
.instruction
|= LOW4 (inst
.operands
[2].reg
);
14126 inst
.instruction
|= HI1 (inst
.operands
[2].reg
) << 5;
14127 inst
.instruction
|= neon_quad (rs
) << 6;
14128 inst
.instruction
|= imm
<< 8;
14130 neon_dp_fixup (&inst
);
14136 enum neon_shape rs
= neon_select_shape (NS_DD
, NS_QQ
, NS_NULL
);
14137 struct neon_type_el et
= neon_check_type (2, rs
,
14138 N_EQK
, N_8
| N_16
| N_32
| N_KEY
);
14139 unsigned op
= (inst
.instruction
>> 7) & 3;
14140 /* N (width of reversed regions) is encoded as part of the bitmask. We
14141 extract it here to check the elements to be reversed are smaller.
14142 Otherwise we'd get a reserved instruction. */
14143 unsigned elsize
= (op
== 2) ? 16 : (op
== 1) ? 32 : (op
== 0) ? 64 : 0;
14144 gas_assert (elsize
!= 0);
14145 constraint (et
.size
>= elsize
,
14146 _("elements must be smaller than reversal region"));
14147 neon_two_same (neon_quad (rs
), 1, et
.size
);
14153 if (inst
.operands
[1].isscalar
)
14155 enum neon_shape rs
= neon_select_shape (NS_DS
, NS_QS
, NS_NULL
);
14156 struct neon_type_el et
= neon_check_type (2, rs
,
14157 N_EQK
, N_8
| N_16
| N_32
| N_KEY
);
14158 unsigned sizebits
= et
.size
>> 3;
14159 unsigned dm
= NEON_SCALAR_REG (inst
.operands
[1].reg
);
14160 int logsize
= neon_logbits (et
.size
);
14161 unsigned x
= NEON_SCALAR_INDEX (inst
.operands
[1].reg
) << logsize
;
14163 if (vfp_or_neon_is_neon (NEON_CHECK_CC
) == FAIL
)
14166 NEON_ENCODE (SCALAR
, inst
);
14167 inst
.instruction
|= LOW4 (inst
.operands
[0].reg
) << 12;
14168 inst
.instruction
|= HI1 (inst
.operands
[0].reg
) << 22;
14169 inst
.instruction
|= LOW4 (dm
);
14170 inst
.instruction
|= HI1 (dm
) << 5;
14171 inst
.instruction
|= neon_quad (rs
) << 6;
14172 inst
.instruction
|= x
<< 17;
14173 inst
.instruction
|= sizebits
<< 16;
14175 neon_dp_fixup (&inst
);
14179 enum neon_shape rs
= neon_select_shape (NS_DR
, NS_QR
, NS_NULL
);
14180 struct neon_type_el et
= neon_check_type (2, rs
,
14181 N_8
| N_16
| N_32
| N_KEY
, N_EQK
);
14182 /* Duplicate ARM register to lanes of vector. */
14183 NEON_ENCODE (ARMREG
, inst
);
14186 case 8: inst
.instruction
|= 0x400000; break;
14187 case 16: inst
.instruction
|= 0x000020; break;
14188 case 32: inst
.instruction
|= 0x000000; break;
14191 inst
.instruction
|= LOW4 (inst
.operands
[1].reg
) << 12;
14192 inst
.instruction
|= LOW4 (inst
.operands
[0].reg
) << 16;
14193 inst
.instruction
|= HI1 (inst
.operands
[0].reg
) << 7;
14194 inst
.instruction
|= neon_quad (rs
) << 21;
14195 /* The encoding for this instruction is identical for the ARM and Thumb
14196 variants, except for the condition field. */
14197 do_vfp_cond_or_thumb ();
14201 /* VMOV has particularly many variations. It can be one of:
14202 0. VMOV<c><q> <Qd>, <Qm>
14203 1. VMOV<c><q> <Dd>, <Dm>
14204 (Register operations, which are VORR with Rm = Rn.)
14205 2. VMOV<c><q>.<dt> <Qd>, #<imm>
14206 3. VMOV<c><q>.<dt> <Dd>, #<imm>
14208 4. VMOV<c><q>.<size> <Dn[x]>, <Rd>
14209 (ARM register to scalar.)
14210 5. VMOV<c><q> <Dm>, <Rd>, <Rn>
14211 (Two ARM registers to vector.)
14212 6. VMOV<c><q>.<dt> <Rd>, <Dn[x]>
14213 (Scalar to ARM register.)
14214 7. VMOV<c><q> <Rd>, <Rn>, <Dm>
14215 (Vector to two ARM registers.)
14216 8. VMOV.F32 <Sd>, <Sm>
14217 9. VMOV.F64 <Dd>, <Dm>
14218 (VFP register moves.)
14219 10. VMOV.F32 <Sd>, #imm
14220 11. VMOV.F64 <Dd>, #imm
14221 (VFP float immediate load.)
14222 12. VMOV <Rd>, <Sm>
14223 (VFP single to ARM reg.)
14224 13. VMOV <Sd>, <Rm>
14225 (ARM reg to VFP single.)
14226 14. VMOV <Rd>, <Re>, <Sn>, <Sm>
14227 (Two ARM regs to two VFP singles.)
14228 15. VMOV <Sd>, <Se>, <Rn>, <Rm>
14229 (Two VFP singles to two ARM regs.)
14231 These cases can be disambiguated using neon_select_shape, except cases 1/9
14232 and 3/11 which depend on the operand type too.
14234 All the encoded bits are hardcoded by this function.
14236 Cases 4, 6 may be used with VFPv1 and above (only 32-bit transfers!).
14237 Cases 5, 7 may be used with VFPv2 and above.
14239 FIXME: Some of the checking may be a bit sloppy (in a couple of cases you
14240 can specify a type where it doesn't make sense to, and is ignored). */
14245 enum neon_shape rs
= neon_select_shape (NS_RRFF
, NS_FFRR
, NS_DRR
, NS_RRD
,
14246 NS_QQ
, NS_DD
, NS_QI
, NS_DI
, NS_SR
, NS_RS
, NS_FF
, NS_FI
, NS_RF
, NS_FR
,
14248 struct neon_type_el et
;
14249 const char *ldconst
= 0;
14253 case NS_DD
: /* case 1/9. */
14254 et
= neon_check_type (2, rs
, N_EQK
, N_F64
| N_KEY
);
14255 /* It is not an error here if no type is given. */
14257 if (et
.type
== NT_float
&& et
.size
== 64)
14259 do_vfp_nsyn_opcode ("fcpyd");
14262 /* fall through. */
14264 case NS_QQ
: /* case 0/1. */
14266 if (vfp_or_neon_is_neon (NEON_CHECK_CC
| NEON_CHECK_ARCH
) == FAIL
)
14268 /* The architecture manual I have doesn't explicitly state which
14269 value the U bit should have for register->register moves, but
14270 the equivalent VORR instruction has U = 0, so do that. */
14271 inst
.instruction
= 0x0200110;
14272 inst
.instruction
|= LOW4 (inst
.operands
[0].reg
) << 12;
14273 inst
.instruction
|= HI1 (inst
.operands
[0].reg
) << 22;
14274 inst
.instruction
|= LOW4 (inst
.operands
[1].reg
);
14275 inst
.instruction
|= HI1 (inst
.operands
[1].reg
) << 5;
14276 inst
.instruction
|= LOW4 (inst
.operands
[1].reg
) << 16;
14277 inst
.instruction
|= HI1 (inst
.operands
[1].reg
) << 7;
14278 inst
.instruction
|= neon_quad (rs
) << 6;
14280 neon_dp_fixup (&inst
);
14284 case NS_DI
: /* case 3/11. */
14285 et
= neon_check_type (2, rs
, N_EQK
, N_F64
| N_KEY
);
14287 if (et
.type
== NT_float
&& et
.size
== 64)
14289 /* case 11 (fconstd). */
14290 ldconst
= "fconstd";
14291 goto encode_fconstd
;
14293 /* fall through. */
14295 case NS_QI
: /* case 2/3. */
14296 if (vfp_or_neon_is_neon (NEON_CHECK_CC
| NEON_CHECK_ARCH
) == FAIL
)
14298 inst
.instruction
= 0x0800010;
14299 neon_move_immediate ();
14300 neon_dp_fixup (&inst
);
14303 case NS_SR
: /* case 4. */
14305 unsigned bcdebits
= 0;
14307 unsigned dn
= NEON_SCALAR_REG (inst
.operands
[0].reg
);
14308 unsigned x
= NEON_SCALAR_INDEX (inst
.operands
[0].reg
);
14310 et
= neon_check_type (2, NS_NULL
, N_8
| N_16
| N_32
| N_KEY
, N_EQK
);
14311 logsize
= neon_logbits (et
.size
);
14313 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant
, fpu_vfp_ext_v1
),
14315 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant
, fpu_neon_ext_v1
)
14316 && et
.size
!= 32, _(BAD_FPU
));
14317 constraint (et
.type
== NT_invtype
, _("bad type for scalar"));
14318 constraint (x
>= 64 / et
.size
, _("scalar index out of range"));
14322 case 8: bcdebits
= 0x8; break;
14323 case 16: bcdebits
= 0x1; break;
14324 case 32: bcdebits
= 0x0; break;
14328 bcdebits
|= x
<< logsize
;
14330 inst
.instruction
= 0xe000b10;
14331 do_vfp_cond_or_thumb ();
14332 inst
.instruction
|= LOW4 (dn
) << 16;
14333 inst
.instruction
|= HI1 (dn
) << 7;
14334 inst
.instruction
|= inst
.operands
[1].reg
<< 12;
14335 inst
.instruction
|= (bcdebits
& 3) << 5;
14336 inst
.instruction
|= (bcdebits
>> 2) << 21;
14340 case NS_DRR
: /* case 5 (fmdrr). */
14341 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant
, fpu_vfp_ext_v2
),
14344 inst
.instruction
= 0xc400b10;
14345 do_vfp_cond_or_thumb ();
14346 inst
.instruction
|= LOW4 (inst
.operands
[0].reg
);
14347 inst
.instruction
|= HI1 (inst
.operands
[0].reg
) << 5;
14348 inst
.instruction
|= inst
.operands
[1].reg
<< 12;
14349 inst
.instruction
|= inst
.operands
[2].reg
<< 16;
14352 case NS_RS
: /* case 6. */
14355 unsigned dn
= NEON_SCALAR_REG (inst
.operands
[1].reg
);
14356 unsigned x
= NEON_SCALAR_INDEX (inst
.operands
[1].reg
);
14357 unsigned abcdebits
= 0;
14359 et
= neon_check_type (2, NS_NULL
,
14360 N_EQK
, N_S8
| N_S16
| N_U8
| N_U16
| N_32
| N_KEY
);
14361 logsize
= neon_logbits (et
.size
);
14363 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant
, fpu_vfp_ext_v1
),
14365 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant
, fpu_neon_ext_v1
)
14366 && et
.size
!= 32, _(BAD_FPU
));
14367 constraint (et
.type
== NT_invtype
, _("bad type for scalar"));
14368 constraint (x
>= 64 / et
.size
, _("scalar index out of range"));
14372 case 8: abcdebits
= (et
.type
== NT_signed
) ? 0x08 : 0x18; break;
14373 case 16: abcdebits
= (et
.type
== NT_signed
) ? 0x01 : 0x11; break;
14374 case 32: abcdebits
= 0x00; break;
14378 abcdebits
|= x
<< logsize
;
14379 inst
.instruction
= 0xe100b10;
14380 do_vfp_cond_or_thumb ();
14381 inst
.instruction
|= LOW4 (dn
) << 16;
14382 inst
.instruction
|= HI1 (dn
) << 7;
14383 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
14384 inst
.instruction
|= (abcdebits
& 3) << 5;
14385 inst
.instruction
|= (abcdebits
>> 2) << 21;
14389 case NS_RRD
: /* case 7 (fmrrd). */
14390 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant
, fpu_vfp_ext_v2
),
14393 inst
.instruction
= 0xc500b10;
14394 do_vfp_cond_or_thumb ();
14395 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
14396 inst
.instruction
|= inst
.operands
[1].reg
<< 16;
14397 inst
.instruction
|= LOW4 (inst
.operands
[2].reg
);
14398 inst
.instruction
|= HI1 (inst
.operands
[2].reg
) << 5;
14401 case NS_FF
: /* case 8 (fcpys). */
14402 do_vfp_nsyn_opcode ("fcpys");
14405 case NS_FI
: /* case 10 (fconsts). */
14406 ldconst
= "fconsts";
14408 if (is_quarter_float (inst
.operands
[1].imm
))
14410 inst
.operands
[1].imm
= neon_qfloat_bits (inst
.operands
[1].imm
);
14411 do_vfp_nsyn_opcode (ldconst
);
14414 first_error (_("immediate out of range"));
14417 case NS_RF
: /* case 12 (fmrs). */
14418 do_vfp_nsyn_opcode ("fmrs");
14421 case NS_FR
: /* case 13 (fmsr). */
14422 do_vfp_nsyn_opcode ("fmsr");
14425 /* The encoders for the fmrrs and fmsrr instructions expect three operands
14426 (one of which is a list), but we have parsed four. Do some fiddling to
14427 make the operands what do_vfp_reg2_from_sp2 and do_vfp_sp2_from_reg2
14429 case NS_RRFF
: /* case 14 (fmrrs). */
14430 constraint (inst
.operands
[3].reg
!= inst
.operands
[2].reg
+ 1,
14431 _("VFP registers must be adjacent"));
14432 inst
.operands
[2].imm
= 2;
14433 memset (&inst
.operands
[3], '\0', sizeof (inst
.operands
[3]));
14434 do_vfp_nsyn_opcode ("fmrrs");
14437 case NS_FFRR
: /* case 15 (fmsrr). */
14438 constraint (inst
.operands
[1].reg
!= inst
.operands
[0].reg
+ 1,
14439 _("VFP registers must be adjacent"));
14440 inst
.operands
[1] = inst
.operands
[2];
14441 inst
.operands
[2] = inst
.operands
[3];
14442 inst
.operands
[0].imm
= 2;
14443 memset (&inst
.operands
[3], '\0', sizeof (inst
.operands
[3]));
14444 do_vfp_nsyn_opcode ("fmsrr");
14453 do_neon_rshift_round_imm (void)
14455 enum neon_shape rs
= neon_select_shape (NS_DDI
, NS_QQI
, NS_NULL
);
14456 struct neon_type_el et
= neon_check_type (2, rs
, N_EQK
, N_SU_ALL
| N_KEY
);
14457 int imm
= inst
.operands
[2].imm
;
14459 /* imm == 0 case is encoded as VMOV for V{R}SHR. */
14462 inst
.operands
[2].present
= 0;
14467 constraint (imm
< 1 || (unsigned)imm
> et
.size
,
14468 _("immediate out of range for shift"));
14469 neon_imm_shift (TRUE
, et
.type
== NT_unsigned
, neon_quad (rs
), et
,
14474 do_neon_movl (void)
14476 struct neon_type_el et
= neon_check_type (2, NS_QD
,
14477 N_EQK
| N_DBL
, N_SU_32
| N_KEY
);
14478 unsigned sizebits
= et
.size
>> 3;
14479 inst
.instruction
|= sizebits
<< 19;
14480 neon_two_same (0, et
.type
== NT_unsigned
, -1);
14486 enum neon_shape rs
= neon_select_shape (NS_DD
, NS_QQ
, NS_NULL
);
14487 struct neon_type_el et
= neon_check_type (2, rs
,
14488 N_EQK
, N_8
| N_16
| N_32
| N_KEY
);
14489 NEON_ENCODE (INTEGER
, inst
);
14490 neon_two_same (neon_quad (rs
), 1, et
.size
);
14494 do_neon_zip_uzp (void)
14496 enum neon_shape rs
= neon_select_shape (NS_DD
, NS_QQ
, NS_NULL
);
14497 struct neon_type_el et
= neon_check_type (2, rs
,
14498 N_EQK
, N_8
| N_16
| N_32
| N_KEY
);
14499 if (rs
== NS_DD
&& et
.size
== 32)
14501 /* Special case: encode as VTRN.32 <Dd>, <Dm>. */
14502 inst
.instruction
= N_MNEM_vtrn
;
14506 neon_two_same (neon_quad (rs
), 1, et
.size
);
14510 do_neon_sat_abs_neg (void)
14512 enum neon_shape rs
= neon_select_shape (NS_DD
, NS_QQ
, NS_NULL
);
14513 struct neon_type_el et
= neon_check_type (2, rs
,
14514 N_EQK
, N_S8
| N_S16
| N_S32
| N_KEY
);
14515 neon_two_same (neon_quad (rs
), 1, et
.size
);
14519 do_neon_pair_long (void)
14521 enum neon_shape rs
= neon_select_shape (NS_DD
, NS_QQ
, NS_NULL
);
14522 struct neon_type_el et
= neon_check_type (2, rs
, N_EQK
, N_SU_32
| N_KEY
);
14523 /* Unsigned is encoded in OP field (bit 7) for these instruction. */
14524 inst
.instruction
|= (et
.type
== NT_unsigned
) << 7;
14525 neon_two_same (neon_quad (rs
), 1, et
.size
);
14529 do_neon_recip_est (void)
14531 enum neon_shape rs
= neon_select_shape (NS_DD
, NS_QQ
, NS_NULL
);
14532 struct neon_type_el et
= neon_check_type (2, rs
,
14533 N_EQK
| N_FLT
, N_F32
| N_U32
| N_KEY
);
14534 inst
.instruction
|= (et
.type
== NT_float
) << 8;
14535 neon_two_same (neon_quad (rs
), 1, et
.size
);
14541 enum neon_shape rs
= neon_select_shape (NS_DD
, NS_QQ
, NS_NULL
);
14542 struct neon_type_el et
= neon_check_type (2, rs
,
14543 N_EQK
, N_S8
| N_S16
| N_S32
| N_KEY
);
14544 neon_two_same (neon_quad (rs
), 1, et
.size
);
14550 enum neon_shape rs
= neon_select_shape (NS_DD
, NS_QQ
, NS_NULL
);
14551 struct neon_type_el et
= neon_check_type (2, rs
,
14552 N_EQK
, N_I8
| N_I16
| N_I32
| N_KEY
);
14553 neon_two_same (neon_quad (rs
), 1, et
.size
);
14559 enum neon_shape rs
= neon_select_shape (NS_DD
, NS_QQ
, NS_NULL
);
14560 struct neon_type_el et
= neon_check_type (2, rs
,
14561 N_EQK
| N_INT
, N_8
| N_KEY
);
14562 neon_two_same (neon_quad (rs
), 1, et
.size
);
14568 enum neon_shape rs
= neon_select_shape (NS_DD
, NS_QQ
, NS_NULL
);
14569 neon_two_same (neon_quad (rs
), 1, -1);
14573 do_neon_tbl_tbx (void)
14575 unsigned listlenbits
;
14576 neon_check_type (3, NS_DLD
, N_EQK
, N_EQK
, N_8
| N_KEY
);
14578 if (inst
.operands
[1].imm
< 1 || inst
.operands
[1].imm
> 4)
14580 first_error (_("bad list length for table lookup"));
14584 listlenbits
= inst
.operands
[1].imm
- 1;
14585 inst
.instruction
|= LOW4 (inst
.operands
[0].reg
) << 12;
14586 inst
.instruction
|= HI1 (inst
.operands
[0].reg
) << 22;
14587 inst
.instruction
|= LOW4 (inst
.operands
[1].reg
) << 16;
14588 inst
.instruction
|= HI1 (inst
.operands
[1].reg
) << 7;
14589 inst
.instruction
|= LOW4 (inst
.operands
[2].reg
);
14590 inst
.instruction
|= HI1 (inst
.operands
[2].reg
) << 5;
14591 inst
.instruction
|= listlenbits
<< 8;
14593 neon_dp_fixup (&inst
);
14597 do_neon_ldm_stm (void)
14599 /* P, U and L bits are part of bitmask. */
14600 int is_dbmode
= (inst
.instruction
& (1 << 24)) != 0;
14601 unsigned offsetbits
= inst
.operands
[1].imm
* 2;
14603 if (inst
.operands
[1].issingle
)
14605 do_vfp_nsyn_ldm_stm (is_dbmode
);
14609 constraint (is_dbmode
&& !inst
.operands
[0].writeback
,
14610 _("writeback (!) must be used for VLDMDB and VSTMDB"));
14612 constraint (inst
.operands
[1].imm
< 1 || inst
.operands
[1].imm
> 16,
14613 _("register list must contain at least 1 and at most 16 "
14616 inst
.instruction
|= inst
.operands
[0].reg
<< 16;
14617 inst
.instruction
|= inst
.operands
[0].writeback
<< 21;
14618 inst
.instruction
|= LOW4 (inst
.operands
[1].reg
) << 12;
14619 inst
.instruction
|= HI1 (inst
.operands
[1].reg
) << 22;
14621 inst
.instruction
|= offsetbits
;
14623 do_vfp_cond_or_thumb ();
14627 do_neon_ldr_str (void)
14629 int is_ldr
= (inst
.instruction
& (1 << 20)) != 0;
14631 if (inst
.operands
[0].issingle
)
14634 do_vfp_nsyn_opcode ("flds");
14636 do_vfp_nsyn_opcode ("fsts");
14641 do_vfp_nsyn_opcode ("fldd");
14643 do_vfp_nsyn_opcode ("fstd");
14647 /* "interleave" version also handles non-interleaving register VLD1/VST1
14651 do_neon_ld_st_interleave (void)
14653 struct neon_type_el et
= neon_check_type (1, NS_NULL
,
14654 N_8
| N_16
| N_32
| N_64
);
14655 unsigned alignbits
= 0;
14657 /* The bits in this table go:
14658 0: register stride of one (0) or two (1)
14659 1,2: register list length, minus one (1, 2, 3, 4).
14660 3,4: <n> in instruction type, minus one (VLD<n> / VST<n>).
14661 We use -1 for invalid entries. */
14662 const int typetable
[] =
14664 0x7, -1, 0xa, -1, 0x6, -1, 0x2, -1, /* VLD1 / VST1. */
14665 -1, -1, 0x8, 0x9, -1, -1, 0x3, -1, /* VLD2 / VST2. */
14666 -1, -1, -1, -1, 0x4, 0x5, -1, -1, /* VLD3 / VST3. */
14667 -1, -1, -1, -1, -1, -1, 0x0, 0x1 /* VLD4 / VST4. */
14671 if (et
.type
== NT_invtype
)
14674 if (inst
.operands
[1].immisalign
)
14675 switch (inst
.operands
[1].imm
>> 8)
14677 case 64: alignbits
= 1; break;
14679 if (NEON_REGLIST_LENGTH (inst
.operands
[0].imm
) != 2
14680 && NEON_REGLIST_LENGTH (inst
.operands
[0].imm
) != 4)
14681 goto bad_alignment
;
14685 if (NEON_REGLIST_LENGTH (inst
.operands
[0].imm
) != 4)
14686 goto bad_alignment
;
14691 first_error (_("bad alignment"));
14695 inst
.instruction
|= alignbits
<< 4;
14696 inst
.instruction
|= neon_logbits (et
.size
) << 6;
14698 /* Bits [4:6] of the immediate in a list specifier encode register stride
14699 (minus 1) in bit 4, and list length in bits [5:6]. We put the <n> of
14700 VLD<n>/VST<n> in bits [9:8] of the initial bitmask. Suck it out here, look
14701 up the right value for "type" in a table based on this value and the given
14702 list style, then stick it back. */
14703 idx
= ((inst
.operands
[0].imm
>> 4) & 7)
14704 | (((inst
.instruction
>> 8) & 3) << 3);
14706 typebits
= typetable
[idx
];
14708 constraint (typebits
== -1, _("bad list type for instruction"));
14710 inst
.instruction
&= ~0xf00;
14711 inst
.instruction
|= typebits
<< 8;
14714 /* Check alignment is valid for do_neon_ld_st_lane and do_neon_ld_dup.
14715 *DO_ALIGN is set to 1 if the relevant alignment bit should be set, 0
14716 otherwise. The variable arguments are a list of pairs of legal (size, align)
14717 values, terminated with -1. */
14720 neon_alignment_bit (int size
, int align
, int *do_align
, ...)
14723 int result
= FAIL
, thissize
, thisalign
;
14725 if (!inst
.operands
[1].immisalign
)
14731 va_start (ap
, do_align
);
14735 thissize
= va_arg (ap
, int);
14736 if (thissize
== -1)
14738 thisalign
= va_arg (ap
, int);
14740 if (size
== thissize
&& align
== thisalign
)
14743 while (result
!= SUCCESS
);
14747 if (result
== SUCCESS
)
14750 first_error (_("unsupported alignment for instruction"));
14756 do_neon_ld_st_lane (void)
14758 struct neon_type_el et
= neon_check_type (1, NS_NULL
, N_8
| N_16
| N_32
);
14759 int align_good
, do_align
= 0;
14760 int logsize
= neon_logbits (et
.size
);
14761 int align
= inst
.operands
[1].imm
>> 8;
14762 int n
= (inst
.instruction
>> 8) & 3;
14763 int max_el
= 64 / et
.size
;
14765 if (et
.type
== NT_invtype
)
14768 constraint (NEON_REGLIST_LENGTH (inst
.operands
[0].imm
) != n
+ 1,
14769 _("bad list length"));
14770 constraint (NEON_LANE (inst
.operands
[0].imm
) >= max_el
,
14771 _("scalar index out of range"));
14772 constraint (n
!= 0 && NEON_REG_STRIDE (inst
.operands
[0].imm
) == 2
14774 _("stride of 2 unavailable when element size is 8"));
14778 case 0: /* VLD1 / VST1. */
14779 align_good
= neon_alignment_bit (et
.size
, align
, &do_align
, 16, 16,
14781 if (align_good
== FAIL
)
14785 unsigned alignbits
= 0;
14788 case 16: alignbits
= 0x1; break;
14789 case 32: alignbits
= 0x3; break;
14792 inst
.instruction
|= alignbits
<< 4;
14796 case 1: /* VLD2 / VST2. */
14797 align_good
= neon_alignment_bit (et
.size
, align
, &do_align
, 8, 16, 16, 32,
14799 if (align_good
== FAIL
)
14802 inst
.instruction
|= 1 << 4;
14805 case 2: /* VLD3 / VST3. */
14806 constraint (inst
.operands
[1].immisalign
,
14807 _("can't use alignment with this instruction"));
14810 case 3: /* VLD4 / VST4. */
14811 align_good
= neon_alignment_bit (et
.size
, align
, &do_align
, 8, 32,
14812 16, 64, 32, 64, 32, 128, -1);
14813 if (align_good
== FAIL
)
14817 unsigned alignbits
= 0;
14820 case 8: alignbits
= 0x1; break;
14821 case 16: alignbits
= 0x1; break;
14822 case 32: alignbits
= (align
== 64) ? 0x1 : 0x2; break;
14825 inst
.instruction
|= alignbits
<< 4;
14832 /* Reg stride of 2 is encoded in bit 5 when size==16, bit 6 when size==32. */
14833 if (n
!= 0 && NEON_REG_STRIDE (inst
.operands
[0].imm
) == 2)
14834 inst
.instruction
|= 1 << (4 + logsize
);
14836 inst
.instruction
|= NEON_LANE (inst
.operands
[0].imm
) << (logsize
+ 5);
14837 inst
.instruction
|= logsize
<< 10;
14840 /* Encode single n-element structure to all lanes VLD<n> instructions. */
14843 do_neon_ld_dup (void)
14845 struct neon_type_el et
= neon_check_type (1, NS_NULL
, N_8
| N_16
| N_32
);
14846 int align_good
, do_align
= 0;
14848 if (et
.type
== NT_invtype
)
14851 switch ((inst
.instruction
>> 8) & 3)
14853 case 0: /* VLD1. */
14854 gas_assert (NEON_REG_STRIDE (inst
.operands
[0].imm
) != 2);
14855 align_good
= neon_alignment_bit (et
.size
, inst
.operands
[1].imm
>> 8,
14856 &do_align
, 16, 16, 32, 32, -1);
14857 if (align_good
== FAIL
)
14859 switch (NEON_REGLIST_LENGTH (inst
.operands
[0].imm
))
14862 case 2: inst
.instruction
|= 1 << 5; break;
14863 default: first_error (_("bad list length")); return;
14865 inst
.instruction
|= neon_logbits (et
.size
) << 6;
14868 case 1: /* VLD2. */
14869 align_good
= neon_alignment_bit (et
.size
, inst
.operands
[1].imm
>> 8,
14870 &do_align
, 8, 16, 16, 32, 32, 64, -1);
14871 if (align_good
== FAIL
)
14873 constraint (NEON_REGLIST_LENGTH (inst
.operands
[0].imm
) != 2,
14874 _("bad list length"));
14875 if (NEON_REG_STRIDE (inst
.operands
[0].imm
) == 2)
14876 inst
.instruction
|= 1 << 5;
14877 inst
.instruction
|= neon_logbits (et
.size
) << 6;
14880 case 2: /* VLD3. */
14881 constraint (inst
.operands
[1].immisalign
,
14882 _("can't use alignment with this instruction"));
14883 constraint (NEON_REGLIST_LENGTH (inst
.operands
[0].imm
) != 3,
14884 _("bad list length"));
14885 if (NEON_REG_STRIDE (inst
.operands
[0].imm
) == 2)
14886 inst
.instruction
|= 1 << 5;
14887 inst
.instruction
|= neon_logbits (et
.size
) << 6;
14890 case 3: /* VLD4. */
14892 int align
= inst
.operands
[1].imm
>> 8;
14893 align_good
= neon_alignment_bit (et
.size
, align
, &do_align
, 8, 32,
14894 16, 64, 32, 64, 32, 128, -1);
14895 if (align_good
== FAIL
)
14897 constraint (NEON_REGLIST_LENGTH (inst
.operands
[0].imm
) != 4,
14898 _("bad list length"));
14899 if (NEON_REG_STRIDE (inst
.operands
[0].imm
) == 2)
14900 inst
.instruction
|= 1 << 5;
14901 if (et
.size
== 32 && align
== 128)
14902 inst
.instruction
|= 0x3 << 6;
14904 inst
.instruction
|= neon_logbits (et
.size
) << 6;
14911 inst
.instruction
|= do_align
<< 4;
14914 /* Disambiguate VLD<n> and VST<n> instructions, and fill in common bits (those
14915 apart from bits [11:4]. */
14918 do_neon_ldx_stx (void)
14920 if (inst
.operands
[1].isreg
)
14921 constraint (inst
.operands
[1].reg
== REG_PC
, BAD_PC
);
14923 switch (NEON_LANE (inst
.operands
[0].imm
))
14925 case NEON_INTERLEAVE_LANES
:
14926 NEON_ENCODE (INTERLV
, inst
);
14927 do_neon_ld_st_interleave ();
14930 case NEON_ALL_LANES
:
14931 NEON_ENCODE (DUP
, inst
);
14936 NEON_ENCODE (LANE
, inst
);
14937 do_neon_ld_st_lane ();
14940 /* L bit comes from bit mask. */
14941 inst
.instruction
|= LOW4 (inst
.operands
[0].reg
) << 12;
14942 inst
.instruction
|= HI1 (inst
.operands
[0].reg
) << 22;
14943 inst
.instruction
|= inst
.operands
[1].reg
<< 16;
14945 if (inst
.operands
[1].postind
)
14947 int postreg
= inst
.operands
[1].imm
& 0xf;
14948 constraint (!inst
.operands
[1].immisreg
,
14949 _("post-index must be a register"));
14950 constraint (postreg
== 0xd || postreg
== 0xf,
14951 _("bad register for post-index"));
14952 inst
.instruction
|= postreg
;
14954 else if (inst
.operands
[1].writeback
)
14956 inst
.instruction
|= 0xd;
14959 inst
.instruction
|= 0xf;
14962 inst
.instruction
|= 0xf9000000;
14964 inst
.instruction
|= 0xf4000000;
14967 /* Overall per-instruction processing. */
14969 /* We need to be able to fix up arbitrary expressions in some statements.
14970 This is so that we can handle symbols that are an arbitrary distance from
14971 the pc. The most common cases are of the form ((+/-sym -/+ . - 8) & mask),
14972 which returns part of an address in a form which will be valid for
14973 a data instruction. We do this by pushing the expression into a symbol
14974 in the expr_section, and creating a fix for that. */
14977 fix_new_arm (fragS
* frag
,
14992 new_fix
= fix_new_exp (frag
, where
, size
, exp
, pc_rel
,
14993 (enum bfd_reloc_code_real
) reloc
);
14997 new_fix
= (fixS
*) fix_new (frag
, where
, size
, make_expr_symbol (exp
), 0,
14998 pc_rel
, (enum bfd_reloc_code_real
) reloc
);
15002 /* Mark whether the fix is to a THUMB instruction, or an ARM
15004 new_fix
->tc_fix_data
= thumb_mode
;
15007 /* Create a frg for an instruction requiring relaxation. */
15009 output_relax_insn (void)
15015 /* The size of the instruction is unknown, so tie the debug info to the
15016 start of the instruction. */
15017 dwarf2_emit_insn (0);
15019 switch (inst
.reloc
.exp
.X_op
)
15022 sym
= inst
.reloc
.exp
.X_add_symbol
;
15023 offset
= inst
.reloc
.exp
.X_add_number
;
15027 offset
= inst
.reloc
.exp
.X_add_number
;
15030 sym
= make_expr_symbol (&inst
.reloc
.exp
);
15034 to
= frag_var (rs_machine_dependent
, INSN_SIZE
, THUMB_SIZE
,
15035 inst
.relax
, sym
, offset
, NULL
/*offset, opcode*/);
15036 md_number_to_chars (to
, inst
.instruction
, THUMB_SIZE
);
15039 /* Write a 32-bit thumb instruction to buf. */
15041 put_thumb32_insn (char * buf
, unsigned long insn
)
15043 md_number_to_chars (buf
, insn
>> 16, THUMB_SIZE
);
15044 md_number_to_chars (buf
+ THUMB_SIZE
, insn
, THUMB_SIZE
);
15048 output_inst (const char * str
)
15054 as_bad ("%s -- `%s'", inst
.error
, str
);
15059 output_relax_insn ();
15062 if (inst
.size
== 0)
15065 to
= frag_more (inst
.size
);
15066 /* PR 9814: Record the thumb mode into the current frag so that we know
15067 what type of NOP padding to use, if necessary. We override any previous
15068 setting so that if the mode has changed then the NOPS that we use will
15069 match the encoding of the last instruction in the frag. */
15070 frag_now
->tc_frag_data
.thumb_mode
= thumb_mode
| MODE_RECORDED
;
15072 if (thumb_mode
&& (inst
.size
> THUMB_SIZE
))
15074 gas_assert (inst
.size
== (2 * THUMB_SIZE
));
15075 put_thumb32_insn (to
, inst
.instruction
);
15077 else if (inst
.size
> INSN_SIZE
)
15079 gas_assert (inst
.size
== (2 * INSN_SIZE
));
15080 md_number_to_chars (to
, inst
.instruction
, INSN_SIZE
);
15081 md_number_to_chars (to
+ INSN_SIZE
, inst
.instruction
, INSN_SIZE
);
15084 md_number_to_chars (to
, inst
.instruction
, inst
.size
);
15086 if (inst
.reloc
.type
!= BFD_RELOC_UNUSED
)
15087 fix_new_arm (frag_now
, to
- frag_now
->fr_literal
,
15088 inst
.size
, & inst
.reloc
.exp
, inst
.reloc
.pc_rel
,
15091 dwarf2_emit_insn (inst
.size
);
15095 output_it_inst (int cond
, int mask
, char * to
)
15097 unsigned long instruction
= 0xbf00;
15100 instruction
|= mask
;
15101 instruction
|= cond
<< 4;
15105 to
= frag_more (2);
15107 dwarf2_emit_insn (2);
15111 md_number_to_chars (to
, instruction
, 2);
15116 /* Tag values used in struct asm_opcode's tag field. */
15119 OT_unconditional
, /* Instruction cannot be conditionalized.
15120 The ARM condition field is still 0xE. */
15121 OT_unconditionalF
, /* Instruction cannot be conditionalized
15122 and carries 0xF in its ARM condition field. */
15123 OT_csuffix
, /* Instruction takes a conditional suffix. */
15124 OT_csuffixF
, /* Some forms of the instruction take a conditional
15125 suffix, others place 0xF where the condition field
15127 OT_cinfix3
, /* Instruction takes a conditional infix,
15128 beginning at character index 3. (In
15129 unified mode, it becomes a suffix.) */
15130 OT_cinfix3_deprecated
, /* The same as OT_cinfix3. This is used for
15131 tsts, cmps, cmns, and teqs. */
15132 OT_cinfix3_legacy
, /* Legacy instruction takes a conditional infix at
15133 character index 3, even in unified mode. Used for
15134 legacy instructions where suffix and infix forms
15135 may be ambiguous. */
15136 OT_csuf_or_in3
, /* Instruction takes either a conditional
15137 suffix or an infix at character index 3. */
15138 OT_odd_infix_unc
, /* This is the unconditional variant of an
15139 instruction that takes a conditional infix
15140 at an unusual position. In unified mode,
15141 this variant will accept a suffix. */
15142 OT_odd_infix_0
/* Values greater than or equal to OT_odd_infix_0
15143 are the conditional variants of instructions that
15144 take conditional infixes in unusual positions.
15145 The infix appears at character index
15146 (tag - OT_odd_infix_0). These are not accepted
15147 in unified mode. */
15150 /* Subroutine of md_assemble, responsible for looking up the primary
15151 opcode from the mnemonic the user wrote. STR points to the
15152 beginning of the mnemonic.
15154 This is not simply a hash table lookup, because of conditional
15155 variants. Most instructions have conditional variants, which are
15156 expressed with a _conditional affix_ to the mnemonic. If we were
15157 to encode each conditional variant as a literal string in the opcode
15158 table, it would have approximately 20,000 entries.
15160 Most mnemonics take this affix as a suffix, and in unified syntax,
15161 'most' is upgraded to 'all'. However, in the divided syntax, some
15162 instructions take the affix as an infix, notably the s-variants of
15163 the arithmetic instructions. Of those instructions, all but six
15164 have the infix appear after the third character of the mnemonic.
15166 Accordingly, the algorithm for looking up primary opcodes given
15169 1. Look up the identifier in the opcode table.
15170 If we find a match, go to step U.
15172 2. Look up the last two characters of the identifier in the
15173 conditions table. If we find a match, look up the first N-2
15174 characters of the identifier in the opcode table. If we
15175 find a match, go to step CE.
15177 3. Look up the fourth and fifth characters of the identifier in
15178 the conditions table. If we find a match, extract those
15179 characters from the identifier, and look up the remaining
15180 characters in the opcode table. If we find a match, go
15185 U. Examine the tag field of the opcode structure, in case this is
15186 one of the six instructions with its conditional infix in an
15187 unusual place. If it is, the tag tells us where to find the
15188 infix; look it up in the conditions table and set inst.cond
15189 accordingly. Otherwise, this is an unconditional instruction.
15190 Again set inst.cond accordingly. Return the opcode structure.
15192 CE. Examine the tag field to make sure this is an instruction that
15193 should receive a conditional suffix. If it is not, fail.
15194 Otherwise, set inst.cond from the suffix we already looked up,
15195 and return the opcode structure.
15197 CM. Examine the tag field to make sure this is an instruction that
15198 should receive a conditional infix after the third character.
15199 If it is not, fail. Otherwise, undo the edits to the current
15200 line of input and proceed as for case CE. */
15202 static const struct asm_opcode
*
15203 opcode_lookup (char **str
)
15207 const struct asm_opcode
*opcode
;
15208 const struct asm_cond
*cond
;
15211 /* Scan up to the end of the mnemonic, which must end in white space,
15212 '.' (in unified mode, or for Neon/VFP instructions), or end of string. */
15213 for (base
= end
= *str
; *end
!= '\0'; end
++)
15214 if (*end
== ' ' || *end
== '.')
15220 /* Handle a possible width suffix and/or Neon type suffix. */
15225 /* The .w and .n suffixes are only valid if the unified syntax is in
15227 if (unified_syntax
&& end
[1] == 'w')
15229 else if (unified_syntax
&& end
[1] == 'n')
15234 inst
.vectype
.elems
= 0;
15236 *str
= end
+ offset
;
15238 if (end
[offset
] == '.')
15240 /* See if we have a Neon type suffix (possible in either unified or
15241 non-unified ARM syntax mode). */
15242 if (parse_neon_type (&inst
.vectype
, str
) == FAIL
)
15245 else if (end
[offset
] != '\0' && end
[offset
] != ' ')
15251 /* Look for unaffixed or special-case affixed mnemonic. */
15252 opcode
= (const struct asm_opcode
*) hash_find_n (arm_ops_hsh
, base
,
15257 if (opcode
->tag
< OT_odd_infix_0
)
15259 inst
.cond
= COND_ALWAYS
;
15263 if (warn_on_deprecated
&& unified_syntax
)
15264 as_warn (_("conditional infixes are deprecated in unified syntax"));
15265 affix
= base
+ (opcode
->tag
- OT_odd_infix_0
);
15266 cond
= (const struct asm_cond
*) hash_find_n (arm_cond_hsh
, affix
, 2);
15269 inst
.cond
= cond
->value
;
15273 /* Cannot have a conditional suffix on a mnemonic of less than two
15275 if (end
- base
< 3)
15278 /* Look for suffixed mnemonic. */
15280 cond
= (const struct asm_cond
*) hash_find_n (arm_cond_hsh
, affix
, 2);
15281 opcode
= (const struct asm_opcode
*) hash_find_n (arm_ops_hsh
, base
,
15283 if (opcode
&& cond
)
15286 switch (opcode
->tag
)
15288 case OT_cinfix3_legacy
:
15289 /* Ignore conditional suffixes matched on infix only mnemonics. */
15293 case OT_cinfix3_deprecated
:
15294 case OT_odd_infix_unc
:
15295 if (!unified_syntax
)
15297 /* else fall through */
15301 case OT_csuf_or_in3
:
15302 inst
.cond
= cond
->value
;
15305 case OT_unconditional
:
15306 case OT_unconditionalF
:
15308 inst
.cond
= cond
->value
;
15311 /* Delayed diagnostic. */
15312 inst
.error
= BAD_COND
;
15313 inst
.cond
= COND_ALWAYS
;
15322 /* Cannot have a usual-position infix on a mnemonic of less than
15323 six characters (five would be a suffix). */
15324 if (end
- base
< 6)
15327 /* Look for infixed mnemonic in the usual position. */
15329 cond
= (const struct asm_cond
*) hash_find_n (arm_cond_hsh
, affix
, 2);
15333 memcpy (save
, affix
, 2);
15334 memmove (affix
, affix
+ 2, (end
- affix
) - 2);
15335 opcode
= (const struct asm_opcode
*) hash_find_n (arm_ops_hsh
, base
,
15337 memmove (affix
+ 2, affix
, (end
- affix
) - 2);
15338 memcpy (affix
, save
, 2);
15341 && (opcode
->tag
== OT_cinfix3
15342 || opcode
->tag
== OT_cinfix3_deprecated
15343 || opcode
->tag
== OT_csuf_or_in3
15344 || opcode
->tag
== OT_cinfix3_legacy
))
15347 if (warn_on_deprecated
&& unified_syntax
15348 && (opcode
->tag
== OT_cinfix3
15349 || opcode
->tag
== OT_cinfix3_deprecated
))
15350 as_warn (_("conditional infixes are deprecated in unified syntax"));
15352 inst
.cond
= cond
->value
;
15359 /* This function generates an initial IT instruction, leaving its block
15360 virtually open for the new instructions. Eventually,
15361 the mask will be updated by now_it_add_mask () each time
15362 a new instruction needs to be included in the IT block.
15363 Finally, the block is closed with close_automatic_it_block ().
15364 The block closure can be requested either from md_assemble (),
15365 a tencode (), or due to a label hook. */
15368 new_automatic_it_block (int cond
)
15370 now_it
.state
= AUTOMATIC_IT_BLOCK
;
15371 now_it
.mask
= 0x18;
15373 now_it
.block_length
= 1;
15374 mapping_state (MAP_THUMB
);
15375 now_it
.insn
= output_it_inst (cond
, now_it
.mask
, NULL
);
15378 /* Close an automatic IT block.
15379 See comments in new_automatic_it_block (). */
15382 close_automatic_it_block (void)
15384 now_it
.mask
= 0x10;
15385 now_it
.block_length
= 0;
15388 /* Update the mask of the current automatically-generated IT
15389 instruction. See comments in new_automatic_it_block (). */
15392 now_it_add_mask (int cond
)
15394 #define CLEAR_BIT(value, nbit) ((value) & ~(1 << (nbit)))
15395 #define SET_BIT_VALUE(value, bitvalue, nbit) (CLEAR_BIT (value, nbit) \
15396 | ((bitvalue) << (nbit)))
15397 const int resulting_bit
= (cond
& 1);
15399 now_it
.mask
&= 0xf;
15400 now_it
.mask
= SET_BIT_VALUE (now_it
.mask
,
15402 (5 - now_it
.block_length
));
15403 now_it
.mask
= SET_BIT_VALUE (now_it
.mask
,
15405 ((5 - now_it
.block_length
) - 1) );
15406 output_it_inst (now_it
.cc
, now_it
.mask
, now_it
.insn
);
15409 #undef SET_BIT_VALUE
15412 /* The IT blocks handling machinery is accessed through the these functions:
15413 it_fsm_pre_encode () from md_assemble ()
15414 set_it_insn_type () optional, from the tencode functions
15415 set_it_insn_type_last () ditto
15416 in_it_block () ditto
15417 it_fsm_post_encode () from md_assemble ()
15418 force_automatic_it_block_close () from label habdling functions
15421 1) md_assemble () calls it_fsm_pre_encode () before calling tencode (),
15422 initializing the IT insn type with a generic initial value depending
15423 on the inst.condition.
15424 2) During the tencode function, two things may happen:
15425 a) The tencode function overrides the IT insn type by
15426 calling either set_it_insn_type (type) or set_it_insn_type_last ().
15427 b) The tencode function queries the IT block state by
15428 calling in_it_block () (i.e. to determine narrow/not narrow mode).
15430 Both set_it_insn_type and in_it_block run the internal FSM state
15431 handling function (handle_it_state), because: a) setting the IT insn
15432 type may incur in an invalid state (exiting the function),
15433 and b) querying the state requires the FSM to be updated.
15434 Specifically we want to avoid creating an IT block for conditional
15435 branches, so it_fsm_pre_encode is actually a guess and we can't
15436 determine whether an IT block is required until the tencode () routine
15437 has decided what type of instruction this actually it.
15438 Because of this, if set_it_insn_type and in_it_block have to be used,
15439 set_it_insn_type has to be called first.
15441 set_it_insn_type_last () is a wrapper of set_it_insn_type (type), that
15442 determines the insn IT type depending on the inst.cond code.
15443 When a tencode () routine encodes an instruction that can be
15444 either outside an IT block, or, in the case of being inside, has to be
15445 the last one, set_it_insn_type_last () will determine the proper
15446 IT instruction type based on the inst.cond code. Otherwise,
15447 set_it_insn_type can be called for overriding that logic or
15448 for covering other cases.
15450 Calling handle_it_state () may not transition the IT block state to
15451 OUTSIDE_IT_BLOCK immediatelly, since the (current) state could be
15452 still queried. Instead, if the FSM determines that the state should
15453 be transitioned to OUTSIDE_IT_BLOCK, a flag is marked to be closed
15454 after the tencode () function: that's what it_fsm_post_encode () does.
15456 Since in_it_block () calls the state handling function to get an
15457 updated state, an error may occur (due to invalid insns combination).
15458 In that case, inst.error is set.
15459 Therefore, inst.error has to be checked after the execution of
15460 the tencode () routine.
15462 3) Back in md_assemble(), it_fsm_post_encode () is called to commit
15463 any pending state change (if any) that didn't take place in
15464 handle_it_state () as explained above. */
15467 it_fsm_pre_encode (void)
15469 if (inst
.cond
!= COND_ALWAYS
)
15470 inst
.it_insn_type
= INSIDE_IT_INSN
;
15472 inst
.it_insn_type
= OUTSIDE_IT_INSN
;
15474 now_it
.state_handled
= 0;
15477 /* IT state FSM handling function. */
15480 handle_it_state (void)
15482 now_it
.state_handled
= 1;
15484 switch (now_it
.state
)
15486 case OUTSIDE_IT_BLOCK
:
15487 switch (inst
.it_insn_type
)
15489 case OUTSIDE_IT_INSN
:
15492 case INSIDE_IT_INSN
:
15493 case INSIDE_IT_LAST_INSN
:
15494 if (thumb_mode
== 0)
15497 && !(implicit_it_mode
& IMPLICIT_IT_MODE_ARM
))
15498 as_tsktsk (_("Warning: conditional outside an IT block"\
15503 if ((implicit_it_mode
& IMPLICIT_IT_MODE_THUMB
)
15504 && ARM_CPU_HAS_FEATURE (cpu_variant
, arm_arch_t2
))
15506 /* Automatically generate the IT instruction. */
15507 new_automatic_it_block (inst
.cond
);
15508 if (inst
.it_insn_type
== INSIDE_IT_LAST_INSN
)
15509 close_automatic_it_block ();
15513 inst
.error
= BAD_OUT_IT
;
15519 case IF_INSIDE_IT_LAST_INSN
:
15520 case NEUTRAL_IT_INSN
:
15524 now_it
.state
= MANUAL_IT_BLOCK
;
15525 now_it
.block_length
= 0;
15530 case AUTOMATIC_IT_BLOCK
:
15531 /* Three things may happen now:
15532 a) We should increment current it block size;
15533 b) We should close current it block (closing insn or 4 insns);
15534 c) We should close current it block and start a new one (due
15535 to incompatible conditions or
15536 4 insns-length block reached). */
15538 switch (inst
.it_insn_type
)
15540 case OUTSIDE_IT_INSN
:
15541 /* The closure of the block shall happen immediatelly,
15542 so any in_it_block () call reports the block as closed. */
15543 force_automatic_it_block_close ();
15546 case INSIDE_IT_INSN
:
15547 case INSIDE_IT_LAST_INSN
:
15548 case IF_INSIDE_IT_LAST_INSN
:
15549 now_it
.block_length
++;
15551 if (now_it
.block_length
> 4
15552 || !now_it_compatible (inst
.cond
))
15554 force_automatic_it_block_close ();
15555 if (inst
.it_insn_type
!= IF_INSIDE_IT_LAST_INSN
)
15556 new_automatic_it_block (inst
.cond
);
15560 now_it_add_mask (inst
.cond
);
15563 if (now_it
.state
== AUTOMATIC_IT_BLOCK
15564 && (inst
.it_insn_type
== INSIDE_IT_LAST_INSN
15565 || inst
.it_insn_type
== IF_INSIDE_IT_LAST_INSN
))
15566 close_automatic_it_block ();
15569 case NEUTRAL_IT_INSN
:
15570 now_it
.block_length
++;
15572 if (now_it
.block_length
> 4)
15573 force_automatic_it_block_close ();
15575 now_it_add_mask (now_it
.cc
& 1);
15579 close_automatic_it_block ();
15580 now_it
.state
= MANUAL_IT_BLOCK
;
15585 case MANUAL_IT_BLOCK
:
15587 /* Check conditional suffixes. */
15588 const int cond
= now_it
.cc
^ ((now_it
.mask
>> 4) & 1) ^ 1;
15591 now_it
.mask
&= 0x1f;
15592 is_last
= (now_it
.mask
== 0x10);
15594 switch (inst
.it_insn_type
)
15596 case OUTSIDE_IT_INSN
:
15597 inst
.error
= BAD_NOT_IT
;
15600 case INSIDE_IT_INSN
:
15601 if (cond
!= inst
.cond
)
15603 inst
.error
= BAD_IT_COND
;
15608 case INSIDE_IT_LAST_INSN
:
15609 case IF_INSIDE_IT_LAST_INSN
:
15610 if (cond
!= inst
.cond
)
15612 inst
.error
= BAD_IT_COND
;
15617 inst
.error
= BAD_BRANCH
;
15622 case NEUTRAL_IT_INSN
:
15623 /* The BKPT instruction is unconditional even in an IT block. */
15627 inst
.error
= BAD_IT_IT
;
15638 it_fsm_post_encode (void)
15642 if (!now_it
.state_handled
)
15643 handle_it_state ();
15645 is_last
= (now_it
.mask
== 0x10);
15648 now_it
.state
= OUTSIDE_IT_BLOCK
;
15654 force_automatic_it_block_close (void)
15656 if (now_it
.state
== AUTOMATIC_IT_BLOCK
)
15658 close_automatic_it_block ();
15659 now_it
.state
= OUTSIDE_IT_BLOCK
;
15667 if (!now_it
.state_handled
)
15668 handle_it_state ();
15670 return now_it
.state
!= OUTSIDE_IT_BLOCK
;
15674 md_assemble (char *str
)
15677 const struct asm_opcode
* opcode
;
15679 /* Align the previous label if needed. */
15680 if (last_label_seen
!= NULL
)
15682 symbol_set_frag (last_label_seen
, frag_now
);
15683 S_SET_VALUE (last_label_seen
, (valueT
) frag_now_fix ());
15684 S_SET_SEGMENT (last_label_seen
, now_seg
);
15687 memset (&inst
, '\0', sizeof (inst
));
15688 inst
.reloc
.type
= BFD_RELOC_UNUSED
;
15690 opcode
= opcode_lookup (&p
);
15693 /* It wasn't an instruction, but it might be a register alias of
15694 the form alias .req reg, or a Neon .dn/.qn directive. */
15695 if (! create_register_alias (str
, p
)
15696 && ! create_neon_reg_alias (str
, p
))
15697 as_bad (_("bad instruction `%s'"), str
);
15702 if (warn_on_deprecated
&& opcode
->tag
== OT_cinfix3_deprecated
)
15703 as_warn (_("s suffix on comparison instruction is deprecated"));
15705 /* The value which unconditional instructions should have in place of the
15706 condition field. */
15707 inst
.uncond_value
= (opcode
->tag
== OT_csuffixF
) ? 0xf : -1;
15711 arm_feature_set variant
;
15713 variant
= cpu_variant
;
15714 /* Only allow coprocessor instructions on Thumb-2 capable devices. */
15715 if (!ARM_CPU_HAS_FEATURE (variant
, arm_arch_t2
))
15716 ARM_CLEAR_FEATURE (variant
, variant
, fpu_any_hard
);
15717 /* Check that this instruction is supported for this CPU. */
15718 if (!opcode
->tvariant
15719 || (thumb_mode
== 1
15720 && !ARM_CPU_HAS_FEATURE (variant
, *opcode
->tvariant
)))
15722 as_bad (_("selected processor does not support `%s'"), str
);
15725 if (inst
.cond
!= COND_ALWAYS
&& !unified_syntax
15726 && opcode
->tencode
!= do_t_branch
)
15728 as_bad (_("Thumb does not support conditional execution"));
15732 if (!ARM_CPU_HAS_FEATURE (variant
, arm_ext_v6t2
))
15734 if (opcode
->tencode
!= do_t_blx
&& opcode
->tencode
!= do_t_branch23
15735 && !(ARM_CPU_HAS_FEATURE(*opcode
->tvariant
, arm_ext_msr
)
15736 || ARM_CPU_HAS_FEATURE(*opcode
->tvariant
, arm_ext_barrier
)))
15738 /* Two things are addressed here.
15739 1) Implicit require narrow instructions on Thumb-1.
15740 This avoids relaxation accidentally introducing Thumb-2
15742 2) Reject wide instructions in non Thumb-2 cores. */
15743 if (inst
.size_req
== 0)
15745 else if (inst
.size_req
== 4)
15747 as_bad (_("selected processor does not support `%s'"), str
);
15753 inst
.instruction
= opcode
->tvalue
;
15755 if (!parse_operands (p
, opcode
->operands
, /*thumb=*/TRUE
))
15757 /* Prepare the it_insn_type for those encodings that don't set
15759 it_fsm_pre_encode ();
15761 opcode
->tencode ();
15763 it_fsm_post_encode ();
15766 if (!(inst
.error
|| inst
.relax
))
15768 gas_assert (inst
.instruction
< 0xe800 || inst
.instruction
> 0xffff);
15769 inst
.size
= (inst
.instruction
> 0xffff ? 4 : 2);
15770 if (inst
.size_req
&& inst
.size_req
!= inst
.size
)
15772 as_bad (_("cannot honor width suffix -- `%s'"), str
);
15777 /* Something has gone badly wrong if we try to relax a fixed size
15779 gas_assert (inst
.size_req
== 0 || !inst
.relax
);
15781 ARM_MERGE_FEATURE_SETS (thumb_arch_used
, thumb_arch_used
,
15782 *opcode
->tvariant
);
15783 /* Many Thumb-2 instructions also have Thumb-1 variants, so explicitly
15784 set those bits when Thumb-2 32-bit instructions are seen. ie.
15785 anything other than bl/blx and v6-M instructions.
15786 This is overly pessimistic for relaxable instructions. */
15787 if (((inst
.size
== 4 && (inst
.instruction
& 0xf800e800) != 0xf000e800)
15789 && !(ARM_CPU_HAS_FEATURE (*opcode
->tvariant
, arm_ext_msr
)
15790 || ARM_CPU_HAS_FEATURE (*opcode
->tvariant
, arm_ext_barrier
)))
15791 ARM_MERGE_FEATURE_SETS (thumb_arch_used
, thumb_arch_used
,
15794 check_neon_suffixes
;
15798 mapping_state (MAP_THUMB
);
15801 else if (ARM_CPU_HAS_FEATURE (cpu_variant
, arm_ext_v1
))
15805 /* bx is allowed on v5 cores, and sometimes on v4 cores. */
15806 is_bx
= (opcode
->aencode
== do_bx
);
15808 /* Check that this instruction is supported for this CPU. */
15809 if (!(is_bx
&& fix_v4bx
)
15810 && !(opcode
->avariant
&&
15811 ARM_CPU_HAS_FEATURE (cpu_variant
, *opcode
->avariant
)))
15813 as_bad (_("selected processor does not support `%s'"), str
);
15818 as_bad (_("width suffixes are invalid in ARM mode -- `%s'"), str
);
15822 inst
.instruction
= opcode
->avalue
;
15823 if (opcode
->tag
== OT_unconditionalF
)
15824 inst
.instruction
|= 0xF << 28;
15826 inst
.instruction
|= inst
.cond
<< 28;
15827 inst
.size
= INSN_SIZE
;
15828 if (!parse_operands (p
, opcode
->operands
, /*thumb=*/FALSE
))
15830 it_fsm_pre_encode ();
15831 opcode
->aencode ();
15832 it_fsm_post_encode ();
15834 /* Arm mode bx is marked as both v4T and v5 because it's still required
15835 on a hypothetical non-thumb v5 core. */
15837 ARM_MERGE_FEATURE_SETS (arm_arch_used
, arm_arch_used
, arm_ext_v4t
);
15839 ARM_MERGE_FEATURE_SETS (arm_arch_used
, arm_arch_used
,
15840 *opcode
->avariant
);
15842 check_neon_suffixes
;
15846 mapping_state (MAP_ARM
);
15851 as_bad (_("attempt to use an ARM instruction on a Thumb-only processor "
15859 check_it_blocks_finished (void)
15864 for (sect
= stdoutput
->sections
; sect
!= NULL
; sect
= sect
->next
)
15865 if (seg_info (sect
)->tc_segment_info_data
.current_it
.state
15866 == MANUAL_IT_BLOCK
)
15868 as_warn (_("section '%s' finished with an open IT block."),
15872 if (now_it
.state
== MANUAL_IT_BLOCK
)
15873 as_warn (_("file finished with an open IT block."));
15877 /* Various frobbings of labels and their addresses. */
15880 arm_start_line_hook (void)
15882 last_label_seen
= NULL
;
15886 arm_frob_label (symbolS
* sym
)
15888 last_label_seen
= sym
;
15890 ARM_SET_THUMB (sym
, thumb_mode
);
15892 #if defined OBJ_COFF || defined OBJ_ELF
15893 ARM_SET_INTERWORK (sym
, support_interwork
);
15896 force_automatic_it_block_close ();
15898 /* Note - do not allow local symbols (.Lxxx) to be labelled
15899 as Thumb functions. This is because these labels, whilst
15900 they exist inside Thumb code, are not the entry points for
15901 possible ARM->Thumb calls. Also, these labels can be used
15902 as part of a computed goto or switch statement. eg gcc
15903 can generate code that looks like this:
15905 ldr r2, [pc, .Laaa]
15915 The first instruction loads the address of the jump table.
15916 The second instruction converts a table index into a byte offset.
15917 The third instruction gets the jump address out of the table.
15918 The fourth instruction performs the jump.
15920 If the address stored at .Laaa is that of a symbol which has the
15921 Thumb_Func bit set, then the linker will arrange for this address
15922 to have the bottom bit set, which in turn would mean that the
15923 address computation performed by the third instruction would end
15924 up with the bottom bit set. Since the ARM is capable of unaligned
15925 word loads, the instruction would then load the incorrect address
15926 out of the jump table, and chaos would ensue. */
15927 if (label_is_thumb_function_name
15928 && (S_GET_NAME (sym
)[0] != '.' || S_GET_NAME (sym
)[1] != 'L')
15929 && (bfd_get_section_flags (stdoutput
, now_seg
) & SEC_CODE
) != 0)
15931 /* When the address of a Thumb function is taken the bottom
15932 bit of that address should be set. This will allow
15933 interworking between Arm and Thumb functions to work
15936 THUMB_SET_FUNC (sym
, 1);
15938 label_is_thumb_function_name
= FALSE
;
15941 dwarf2_emit_label (sym
);
15945 arm_data_in_code (void)
15947 if (thumb_mode
&& ! strncmp (input_line_pointer
+ 1, "data:", 5))
15949 *input_line_pointer
= '/';
15950 input_line_pointer
+= 5;
15951 *input_line_pointer
= 0;
15959 arm_canonicalize_symbol_name (char * name
)
15963 if (thumb_mode
&& (len
= strlen (name
)) > 5
15964 && streq (name
+ len
- 5, "/data"))
15965 *(name
+ len
- 5) = 0;
15970 /* Table of all register names defined by default. The user can
15971 define additional names with .req. Note that all register names
15972 should appear in both upper and lowercase variants. Some registers
15973 also have mixed-case names. */
15975 #define REGDEF(s,n,t) { #s, n, REG_TYPE_##t, TRUE, 0 }
15976 #define REGNUM(p,n,t) REGDEF(p##n, n, t)
15977 #define REGNUM2(p,n,t) REGDEF(p##n, 2 * n, t)
15978 #define REGSET(p,t) \
15979 REGNUM(p, 0,t), REGNUM(p, 1,t), REGNUM(p, 2,t), REGNUM(p, 3,t), \
15980 REGNUM(p, 4,t), REGNUM(p, 5,t), REGNUM(p, 6,t), REGNUM(p, 7,t), \
15981 REGNUM(p, 8,t), REGNUM(p, 9,t), REGNUM(p,10,t), REGNUM(p,11,t), \
15982 REGNUM(p,12,t), REGNUM(p,13,t), REGNUM(p,14,t), REGNUM(p,15,t)
15983 #define REGSETH(p,t) \
15984 REGNUM(p,16,t), REGNUM(p,17,t), REGNUM(p,18,t), REGNUM(p,19,t), \
15985 REGNUM(p,20,t), REGNUM(p,21,t), REGNUM(p,22,t), REGNUM(p,23,t), \
15986 REGNUM(p,24,t), REGNUM(p,25,t), REGNUM(p,26,t), REGNUM(p,27,t), \
15987 REGNUM(p,28,t), REGNUM(p,29,t), REGNUM(p,30,t), REGNUM(p,31,t)
15988 #define REGSET2(p,t) \
15989 REGNUM2(p, 0,t), REGNUM2(p, 1,t), REGNUM2(p, 2,t), REGNUM2(p, 3,t), \
15990 REGNUM2(p, 4,t), REGNUM2(p, 5,t), REGNUM2(p, 6,t), REGNUM2(p, 7,t), \
15991 REGNUM2(p, 8,t), REGNUM2(p, 9,t), REGNUM2(p,10,t), REGNUM2(p,11,t), \
15992 REGNUM2(p,12,t), REGNUM2(p,13,t), REGNUM2(p,14,t), REGNUM2(p,15,t)
15994 static const struct reg_entry reg_names
[] =
15996 /* ARM integer registers. */
15997 REGSET(r
, RN
), REGSET(R
, RN
),
15999 /* ATPCS synonyms. */
16000 REGDEF(a1
,0,RN
), REGDEF(a2
,1,RN
), REGDEF(a3
, 2,RN
), REGDEF(a4
, 3,RN
),
16001 REGDEF(v1
,4,RN
), REGDEF(v2
,5,RN
), REGDEF(v3
, 6,RN
), REGDEF(v4
, 7,RN
),
16002 REGDEF(v5
,8,RN
), REGDEF(v6
,9,RN
), REGDEF(v7
,10,RN
), REGDEF(v8
,11,RN
),
16004 REGDEF(A1
,0,RN
), REGDEF(A2
,1,RN
), REGDEF(A3
, 2,RN
), REGDEF(A4
, 3,RN
),
16005 REGDEF(V1
,4,RN
), REGDEF(V2
,5,RN
), REGDEF(V3
, 6,RN
), REGDEF(V4
, 7,RN
),
16006 REGDEF(V5
,8,RN
), REGDEF(V6
,9,RN
), REGDEF(V7
,10,RN
), REGDEF(V8
,11,RN
),
16008 /* Well-known aliases. */
16009 REGDEF(wr
, 7,RN
), REGDEF(sb
, 9,RN
), REGDEF(sl
,10,RN
), REGDEF(fp
,11,RN
),
16010 REGDEF(ip
,12,RN
), REGDEF(sp
,13,RN
), REGDEF(lr
,14,RN
), REGDEF(pc
,15,RN
),
16012 REGDEF(WR
, 7,RN
), REGDEF(SB
, 9,RN
), REGDEF(SL
,10,RN
), REGDEF(FP
,11,RN
),
16013 REGDEF(IP
,12,RN
), REGDEF(SP
,13,RN
), REGDEF(LR
,14,RN
), REGDEF(PC
,15,RN
),
16015 /* Coprocessor numbers. */
16016 REGSET(p
, CP
), REGSET(P
, CP
),
16018 /* Coprocessor register numbers. The "cr" variants are for backward
16020 REGSET(c
, CN
), REGSET(C
, CN
),
16021 REGSET(cr
, CN
), REGSET(CR
, CN
),
16023 /* FPA registers. */
16024 REGNUM(f
,0,FN
), REGNUM(f
,1,FN
), REGNUM(f
,2,FN
), REGNUM(f
,3,FN
),
16025 REGNUM(f
,4,FN
), REGNUM(f
,5,FN
), REGNUM(f
,6,FN
), REGNUM(f
,7, FN
),
16027 REGNUM(F
,0,FN
), REGNUM(F
,1,FN
), REGNUM(F
,2,FN
), REGNUM(F
,3,FN
),
16028 REGNUM(F
,4,FN
), REGNUM(F
,5,FN
), REGNUM(F
,6,FN
), REGNUM(F
,7, FN
),
16030 /* VFP SP registers. */
16031 REGSET(s
,VFS
), REGSET(S
,VFS
),
16032 REGSETH(s
,VFS
), REGSETH(S
,VFS
),
16034 /* VFP DP Registers. */
16035 REGSET(d
,VFD
), REGSET(D
,VFD
),
16036 /* Extra Neon DP registers. */
16037 REGSETH(d
,VFD
), REGSETH(D
,VFD
),
16039 /* Neon QP registers. */
16040 REGSET2(q
,NQ
), REGSET2(Q
,NQ
),
16042 /* VFP control registers. */
16043 REGDEF(fpsid
,0,VFC
), REGDEF(fpscr
,1,VFC
), REGDEF(fpexc
,8,VFC
),
16044 REGDEF(FPSID
,0,VFC
), REGDEF(FPSCR
,1,VFC
), REGDEF(FPEXC
,8,VFC
),
16045 REGDEF(fpinst
,9,VFC
), REGDEF(fpinst2
,10,VFC
),
16046 REGDEF(FPINST
,9,VFC
), REGDEF(FPINST2
,10,VFC
),
16047 REGDEF(mvfr0
,7,VFC
), REGDEF(mvfr1
,6,VFC
),
16048 REGDEF(MVFR0
,7,VFC
), REGDEF(MVFR1
,6,VFC
),
16050 /* Maverick DSP coprocessor registers. */
16051 REGSET(mvf
,MVF
), REGSET(mvd
,MVD
), REGSET(mvfx
,MVFX
), REGSET(mvdx
,MVDX
),
16052 REGSET(MVF
,MVF
), REGSET(MVD
,MVD
), REGSET(MVFX
,MVFX
), REGSET(MVDX
,MVDX
),
16054 REGNUM(mvax
,0,MVAX
), REGNUM(mvax
,1,MVAX
),
16055 REGNUM(mvax
,2,MVAX
), REGNUM(mvax
,3,MVAX
),
16056 REGDEF(dspsc
,0,DSPSC
),
16058 REGNUM(MVAX
,0,MVAX
), REGNUM(MVAX
,1,MVAX
),
16059 REGNUM(MVAX
,2,MVAX
), REGNUM(MVAX
,3,MVAX
),
16060 REGDEF(DSPSC
,0,DSPSC
),
16062 /* iWMMXt data registers - p0, c0-15. */
16063 REGSET(wr
,MMXWR
), REGSET(wR
,MMXWR
), REGSET(WR
, MMXWR
),
16065 /* iWMMXt control registers - p1, c0-3. */
16066 REGDEF(wcid
, 0,MMXWC
), REGDEF(wCID
, 0,MMXWC
), REGDEF(WCID
, 0,MMXWC
),
16067 REGDEF(wcon
, 1,MMXWC
), REGDEF(wCon
, 1,MMXWC
), REGDEF(WCON
, 1,MMXWC
),
16068 REGDEF(wcssf
, 2,MMXWC
), REGDEF(wCSSF
, 2,MMXWC
), REGDEF(WCSSF
, 2,MMXWC
),
16069 REGDEF(wcasf
, 3,MMXWC
), REGDEF(wCASF
, 3,MMXWC
), REGDEF(WCASF
, 3,MMXWC
),
16071 /* iWMMXt scalar (constant/offset) registers - p1, c8-11. */
16072 REGDEF(wcgr0
, 8,MMXWCG
), REGDEF(wCGR0
, 8,MMXWCG
), REGDEF(WCGR0
, 8,MMXWCG
),
16073 REGDEF(wcgr1
, 9,MMXWCG
), REGDEF(wCGR1
, 9,MMXWCG
), REGDEF(WCGR1
, 9,MMXWCG
),
16074 REGDEF(wcgr2
,10,MMXWCG
), REGDEF(wCGR2
,10,MMXWCG
), REGDEF(WCGR2
,10,MMXWCG
),
16075 REGDEF(wcgr3
,11,MMXWCG
), REGDEF(wCGR3
,11,MMXWCG
), REGDEF(WCGR3
,11,MMXWCG
),
16077 /* XScale accumulator registers. */
16078 REGNUM(acc
,0,XSCALE
), REGNUM(ACC
,0,XSCALE
),
16084 /* Table of all PSR suffixes. Bare "CPSR" and "SPSR" are handled
16085 within psr_required_here. */
16086 static const struct asm_psr psrs
[] =
16088 /* Backward compatibility notation. Note that "all" is no longer
16089 truly all possible PSR bits. */
16090 {"all", PSR_c
| PSR_f
},
16094 /* Individual flags. */
16099 /* Combinations of flags. */
16100 {"fs", PSR_f
| PSR_s
},
16101 {"fx", PSR_f
| PSR_x
},
16102 {"fc", PSR_f
| PSR_c
},
16103 {"sf", PSR_s
| PSR_f
},
16104 {"sx", PSR_s
| PSR_x
},
16105 {"sc", PSR_s
| PSR_c
},
16106 {"xf", PSR_x
| PSR_f
},
16107 {"xs", PSR_x
| PSR_s
},
16108 {"xc", PSR_x
| PSR_c
},
16109 {"cf", PSR_c
| PSR_f
},
16110 {"cs", PSR_c
| PSR_s
},
16111 {"cx", PSR_c
| PSR_x
},
16112 {"fsx", PSR_f
| PSR_s
| PSR_x
},
16113 {"fsc", PSR_f
| PSR_s
| PSR_c
},
16114 {"fxs", PSR_f
| PSR_x
| PSR_s
},
16115 {"fxc", PSR_f
| PSR_x
| PSR_c
},
16116 {"fcs", PSR_f
| PSR_c
| PSR_s
},
16117 {"fcx", PSR_f
| PSR_c
| PSR_x
},
16118 {"sfx", PSR_s
| PSR_f
| PSR_x
},
16119 {"sfc", PSR_s
| PSR_f
| PSR_c
},
16120 {"sxf", PSR_s
| PSR_x
| PSR_f
},
16121 {"sxc", PSR_s
| PSR_x
| PSR_c
},
16122 {"scf", PSR_s
| PSR_c
| PSR_f
},
16123 {"scx", PSR_s
| PSR_c
| PSR_x
},
16124 {"xfs", PSR_x
| PSR_f
| PSR_s
},
16125 {"xfc", PSR_x
| PSR_f
| PSR_c
},
16126 {"xsf", PSR_x
| PSR_s
| PSR_f
},
16127 {"xsc", PSR_x
| PSR_s
| PSR_c
},
16128 {"xcf", PSR_x
| PSR_c
| PSR_f
},
16129 {"xcs", PSR_x
| PSR_c
| PSR_s
},
16130 {"cfs", PSR_c
| PSR_f
| PSR_s
},
16131 {"cfx", PSR_c
| PSR_f
| PSR_x
},
16132 {"csf", PSR_c
| PSR_s
| PSR_f
},
16133 {"csx", PSR_c
| PSR_s
| PSR_x
},
16134 {"cxf", PSR_c
| PSR_x
| PSR_f
},
16135 {"cxs", PSR_c
| PSR_x
| PSR_s
},
16136 {"fsxc", PSR_f
| PSR_s
| PSR_x
| PSR_c
},
16137 {"fscx", PSR_f
| PSR_s
| PSR_c
| PSR_x
},
16138 {"fxsc", PSR_f
| PSR_x
| PSR_s
| PSR_c
},
16139 {"fxcs", PSR_f
| PSR_x
| PSR_c
| PSR_s
},
16140 {"fcsx", PSR_f
| PSR_c
| PSR_s
| PSR_x
},
16141 {"fcxs", PSR_f
| PSR_c
| PSR_x
| PSR_s
},
16142 {"sfxc", PSR_s
| PSR_f
| PSR_x
| PSR_c
},
16143 {"sfcx", PSR_s
| PSR_f
| PSR_c
| PSR_x
},
16144 {"sxfc", PSR_s
| PSR_x
| PSR_f
| PSR_c
},
16145 {"sxcf", PSR_s
| PSR_x
| PSR_c
| PSR_f
},
16146 {"scfx", PSR_s
| PSR_c
| PSR_f
| PSR_x
},
16147 {"scxf", PSR_s
| PSR_c
| PSR_x
| PSR_f
},
16148 {"xfsc", PSR_x
| PSR_f
| PSR_s
| PSR_c
},
16149 {"xfcs", PSR_x
| PSR_f
| PSR_c
| PSR_s
},
16150 {"xsfc", PSR_x
| PSR_s
| PSR_f
| PSR_c
},
16151 {"xscf", PSR_x
| PSR_s
| PSR_c
| PSR_f
},
16152 {"xcfs", PSR_x
| PSR_c
| PSR_f
| PSR_s
},
16153 {"xcsf", PSR_x
| PSR_c
| PSR_s
| PSR_f
},
16154 {"cfsx", PSR_c
| PSR_f
| PSR_s
| PSR_x
},
16155 {"cfxs", PSR_c
| PSR_f
| PSR_x
| PSR_s
},
16156 {"csfx", PSR_c
| PSR_s
| PSR_f
| PSR_x
},
16157 {"csxf", PSR_c
| PSR_s
| PSR_x
| PSR_f
},
16158 {"cxfs", PSR_c
| PSR_x
| PSR_f
| PSR_s
},
16159 {"cxsf", PSR_c
| PSR_x
| PSR_s
| PSR_f
},
16162 /* Table of V7M psr names. */
16163 static const struct asm_psr v7m_psrs
[] =
16165 {"apsr", 0 }, {"APSR", 0 },
16166 {"iapsr", 1 }, {"IAPSR", 1 },
16167 {"eapsr", 2 }, {"EAPSR", 2 },
16168 {"psr", 3 }, {"PSR", 3 },
16169 {"xpsr", 3 }, {"XPSR", 3 }, {"xPSR", 3 },
16170 {"ipsr", 5 }, {"IPSR", 5 },
16171 {"epsr", 6 }, {"EPSR", 6 },
16172 {"iepsr", 7 }, {"IEPSR", 7 },
16173 {"msp", 8 }, {"MSP", 8 },
16174 {"psp", 9 }, {"PSP", 9 },
16175 {"primask", 16}, {"PRIMASK", 16},
16176 {"basepri", 17}, {"BASEPRI", 17},
16177 {"basepri_max", 18}, {"BASEPRI_MAX", 18},
16178 {"faultmask", 19}, {"FAULTMASK", 19},
16179 {"control", 20}, {"CONTROL", 20}
16182 /* Table of all shift-in-operand names. */
16183 static const struct asm_shift_name shift_names
[] =
16185 { "asl", SHIFT_LSL
}, { "ASL", SHIFT_LSL
},
16186 { "lsl", SHIFT_LSL
}, { "LSL", SHIFT_LSL
},
16187 { "lsr", SHIFT_LSR
}, { "LSR", SHIFT_LSR
},
16188 { "asr", SHIFT_ASR
}, { "ASR", SHIFT_ASR
},
16189 { "ror", SHIFT_ROR
}, { "ROR", SHIFT_ROR
},
16190 { "rrx", SHIFT_RRX
}, { "RRX", SHIFT_RRX
}
16193 /* Table of all explicit relocation names. */
16195 static struct reloc_entry reloc_names
[] =
16197 { "got", BFD_RELOC_ARM_GOT32
}, { "GOT", BFD_RELOC_ARM_GOT32
},
16198 { "gotoff", BFD_RELOC_ARM_GOTOFF
}, { "GOTOFF", BFD_RELOC_ARM_GOTOFF
},
16199 { "plt", BFD_RELOC_ARM_PLT32
}, { "PLT", BFD_RELOC_ARM_PLT32
},
16200 { "target1", BFD_RELOC_ARM_TARGET1
}, { "TARGET1", BFD_RELOC_ARM_TARGET1
},
16201 { "target2", BFD_RELOC_ARM_TARGET2
}, { "TARGET2", BFD_RELOC_ARM_TARGET2
},
16202 { "sbrel", BFD_RELOC_ARM_SBREL32
}, { "SBREL", BFD_RELOC_ARM_SBREL32
},
16203 { "tlsgd", BFD_RELOC_ARM_TLS_GD32
}, { "TLSGD", BFD_RELOC_ARM_TLS_GD32
},
16204 { "tlsldm", BFD_RELOC_ARM_TLS_LDM32
}, { "TLSLDM", BFD_RELOC_ARM_TLS_LDM32
},
16205 { "tlsldo", BFD_RELOC_ARM_TLS_LDO32
}, { "TLSLDO", BFD_RELOC_ARM_TLS_LDO32
},
16206 { "gottpoff",BFD_RELOC_ARM_TLS_IE32
}, { "GOTTPOFF",BFD_RELOC_ARM_TLS_IE32
},
16207 { "tpoff", BFD_RELOC_ARM_TLS_LE32
}, { "TPOFF", BFD_RELOC_ARM_TLS_LE32
},
16208 { "got_prel", BFD_RELOC_ARM_GOT_PREL
}, { "GOT_PREL", BFD_RELOC_ARM_GOT_PREL
}
16212 /* Table of all conditional affixes. 0xF is not defined as a condition code. */
16213 static const struct asm_cond conds
[] =
16217 {"cs", 0x2}, {"hs", 0x2},
16218 {"cc", 0x3}, {"ul", 0x3}, {"lo", 0x3},
16232 static struct asm_barrier_opt barrier_opt_names
[] =
16240 /* Table of ARM-format instructions. */
16242 /* Macros for gluing together operand strings. N.B. In all cases
16243 other than OPS0, the trailing OP_stop comes from default
16244 zero-initialization of the unspecified elements of the array. */
16245 #define OPS0() { OP_stop, }
16246 #define OPS1(a) { OP_##a, }
16247 #define OPS2(a,b) { OP_##a,OP_##b, }
16248 #define OPS3(a,b,c) { OP_##a,OP_##b,OP_##c, }
16249 #define OPS4(a,b,c,d) { OP_##a,OP_##b,OP_##c,OP_##d, }
16250 #define OPS5(a,b,c,d,e) { OP_##a,OP_##b,OP_##c,OP_##d,OP_##e, }
16251 #define OPS6(a,b,c,d,e,f) { OP_##a,OP_##b,OP_##c,OP_##d,OP_##e,OP_##f, }
16253 /* These macros are similar to the OPSn, but do not prepend the OP_ prefix.
16254 This is useful when mixing operands for ARM and THUMB, i.e. using the
16255 MIX_ARM_THUMB_OPERANDS macro.
16256 In order to use these macros, prefix the number of operands with _
16258 #define OPS_1(a) { a, }
16259 #define OPS_2(a,b) { a,b, }
16260 #define OPS_3(a,b,c) { a,b,c, }
16261 #define OPS_4(a,b,c,d) { a,b,c,d, }
16262 #define OPS_5(a,b,c,d,e) { a,b,c,d,e, }
16263 #define OPS_6(a,b,c,d,e,f) { a,b,c,d,e,f, }
16265 /* These macros abstract out the exact format of the mnemonic table and
16266 save some repeated characters. */
16268 /* The normal sort of mnemonic; has a Thumb variant; takes a conditional suffix. */
16269 #define TxCE(mnem, op, top, nops, ops, ae, te) \
16270 { mnem, OPS##nops ops, OT_csuffix, 0x##op, top, ARM_VARIANT, \
16271 THUMB_VARIANT, do_##ae, do_##te }
16273 /* Two variants of the above - TCE for a numeric Thumb opcode, tCE for
16274 a T_MNEM_xyz enumerator. */
16275 #define TCE(mnem, aop, top, nops, ops, ae, te) \
16276 TxCE (mnem, aop, 0x##top, nops, ops, ae, te)
16277 #define tCE(mnem, aop, top, nops, ops, ae, te) \
16278 TxCE (mnem, aop, T_MNEM##top, nops, ops, ae, te)
16280 /* Second most common sort of mnemonic: has a Thumb variant, takes a conditional
16281 infix after the third character. */
16282 #define TxC3(mnem, op, top, nops, ops, ae, te) \
16283 { mnem, OPS##nops ops, OT_cinfix3, 0x##op, top, ARM_VARIANT, \
16284 THUMB_VARIANT, do_##ae, do_##te }
16285 #define TxC3w(mnem, op, top, nops, ops, ae, te) \
16286 { mnem, OPS##nops ops, OT_cinfix3_deprecated, 0x##op, top, ARM_VARIANT, \
16287 THUMB_VARIANT, do_##ae, do_##te }
16288 #define TC3(mnem, aop, top, nops, ops, ae, te) \
16289 TxC3 (mnem, aop, 0x##top, nops, ops, ae, te)
16290 #define TC3w(mnem, aop, top, nops, ops, ae, te) \
16291 TxC3w (mnem, aop, 0x##top, nops, ops, ae, te)
16292 #define tC3(mnem, aop, top, nops, ops, ae, te) \
16293 TxC3 (mnem, aop, T_MNEM##top, nops, ops, ae, te)
16294 #define tC3w(mnem, aop, top, nops, ops, ae, te) \
16295 TxC3w (mnem, aop, T_MNEM##top, nops, ops, ae, te)
16297 /* Mnemonic with a conditional infix in an unusual place. Each and every variant has to
16298 appear in the condition table. */
16299 #define TxCM_(m1, m2, m3, op, top, nops, ops, ae, te) \
16300 { m1 #m2 m3, OPS##nops ops, sizeof (#m2) == 1 ? OT_odd_infix_unc : OT_odd_infix_0 + sizeof (m1) - 1, \
16301 0x##op, top, ARM_VARIANT, THUMB_VARIANT, do_##ae, do_##te }
16303 #define TxCM(m1, m2, op, top, nops, ops, ae, te) \
16304 TxCM_ (m1, , m2, op, top, nops, ops, ae, te), \
16305 TxCM_ (m1, eq, m2, op, top, nops, ops, ae, te), \
16306 TxCM_ (m1, ne, m2, op, top, nops, ops, ae, te), \
16307 TxCM_ (m1, cs, m2, op, top, nops, ops, ae, te), \
16308 TxCM_ (m1, hs, m2, op, top, nops, ops, ae, te), \
16309 TxCM_ (m1, cc, m2, op, top, nops, ops, ae, te), \
16310 TxCM_ (m1, ul, m2, op, top, nops, ops, ae, te), \
16311 TxCM_ (m1, lo, m2, op, top, nops, ops, ae, te), \
16312 TxCM_ (m1, mi, m2, op, top, nops, ops, ae, te), \
16313 TxCM_ (m1, pl, m2, op, top, nops, ops, ae, te), \
16314 TxCM_ (m1, vs, m2, op, top, nops, ops, ae, te), \
16315 TxCM_ (m1, vc, m2, op, top, nops, ops, ae, te), \
16316 TxCM_ (m1, hi, m2, op, top, nops, ops, ae, te), \
16317 TxCM_ (m1, ls, m2, op, top, nops, ops, ae, te), \
16318 TxCM_ (m1, ge, m2, op, top, nops, ops, ae, te), \
16319 TxCM_ (m1, lt, m2, op, top, nops, ops, ae, te), \
16320 TxCM_ (m1, gt, m2, op, top, nops, ops, ae, te), \
16321 TxCM_ (m1, le, m2, op, top, nops, ops, ae, te), \
16322 TxCM_ (m1, al, m2, op, top, nops, ops, ae, te)
16324 #define TCM(m1,m2, aop, top, nops, ops, ae, te) \
16325 TxCM (m1,m2, aop, 0x##top, nops, ops, ae, te)
16326 #define tCM(m1,m2, aop, top, nops, ops, ae, te) \
16327 TxCM (m1,m2, aop, T_MNEM##top, nops, ops, ae, te)
16329 /* Mnemonic that cannot be conditionalized. The ARM condition-code
16330 field is still 0xE. Many of the Thumb variants can be executed
16331 conditionally, so this is checked separately. */
16332 #define TUE(mnem, op, top, nops, ops, ae, te) \
16333 { mnem, OPS##nops ops, OT_unconditional, 0x##op, 0x##top, ARM_VARIANT, \
16334 THUMB_VARIANT, do_##ae, do_##te }
16336 /* Mnemonic that cannot be conditionalized, and bears 0xF in its ARM
16337 condition code field. */
16338 #define TUF(mnem, op, top, nops, ops, ae, te) \
16339 { mnem, OPS##nops ops, OT_unconditionalF, 0x##op, 0x##top, ARM_VARIANT, \
16340 THUMB_VARIANT, do_##ae, do_##te }
16342 /* ARM-only variants of all the above. */
16343 #define CE(mnem, op, nops, ops, ae) \
16344 { mnem, OPS##nops ops, OT_csuffix, 0x##op, 0x0, ARM_VARIANT, 0, do_##ae, NULL }
16346 #define C3(mnem, op, nops, ops, ae) \
16347 { #mnem, OPS##nops ops, OT_cinfix3, 0x##op, 0x0, ARM_VARIANT, 0, do_##ae, NULL }
16349 /* Legacy mnemonics that always have conditional infix after the third
16351 #define CL(mnem, op, nops, ops, ae) \
16352 { mnem, OPS##nops ops, OT_cinfix3_legacy, \
16353 0x##op, 0x0, ARM_VARIANT, 0, do_##ae, NULL }
16355 /* Coprocessor instructions. Isomorphic between Arm and Thumb-2. */
16356 #define cCE(mnem, op, nops, ops, ae) \
16357 { mnem, OPS##nops ops, OT_csuffix, 0x##op, 0xe##op, ARM_VARIANT, ARM_VARIANT, do_##ae, do_##ae }
16359 /* Legacy coprocessor instructions where conditional infix and conditional
16360 suffix are ambiguous. For consistency this includes all FPA instructions,
16361 not just the potentially ambiguous ones. */
16362 #define cCL(mnem, op, nops, ops, ae) \
16363 { mnem, OPS##nops ops, OT_cinfix3_legacy, \
16364 0x##op, 0xe##op, ARM_VARIANT, ARM_VARIANT, do_##ae, do_##ae }
16366 /* Coprocessor, takes either a suffix or a position-3 infix
16367 (for an FPA corner case). */
16368 #define C3E(mnem, op, nops, ops, ae) \
16369 { mnem, OPS##nops ops, OT_csuf_or_in3, \
16370 0x##op, 0xe##op, ARM_VARIANT, ARM_VARIANT, do_##ae, do_##ae }
16372 #define xCM_(m1, m2, m3, op, nops, ops, ae) \
16373 { m1 #m2 m3, OPS##nops ops, \
16374 sizeof (#m2) == 1 ? OT_odd_infix_unc : OT_odd_infix_0 + sizeof (m1) - 1, \
16375 0x##op, 0x0, ARM_VARIANT, 0, do_##ae, NULL }
16377 #define CM(m1, m2, op, nops, ops, ae) \
16378 xCM_ (m1, , m2, op, nops, ops, ae), \
16379 xCM_ (m1, eq, m2, op, nops, ops, ae), \
16380 xCM_ (m1, ne, m2, op, nops, ops, ae), \
16381 xCM_ (m1, cs, m2, op, nops, ops, ae), \
16382 xCM_ (m1, hs, m2, op, nops, ops, ae), \
16383 xCM_ (m1, cc, m2, op, nops, ops, ae), \
16384 xCM_ (m1, ul, m2, op, nops, ops, ae), \
16385 xCM_ (m1, lo, m2, op, nops, ops, ae), \
16386 xCM_ (m1, mi, m2, op, nops, ops, ae), \
16387 xCM_ (m1, pl, m2, op, nops, ops, ae), \
16388 xCM_ (m1, vs, m2, op, nops, ops, ae), \
16389 xCM_ (m1, vc, m2, op, nops, ops, ae), \
16390 xCM_ (m1, hi, m2, op, nops, ops, ae), \
16391 xCM_ (m1, ls, m2, op, nops, ops, ae), \
16392 xCM_ (m1, ge, m2, op, nops, ops, ae), \
16393 xCM_ (m1, lt, m2, op, nops, ops, ae), \
16394 xCM_ (m1, gt, m2, op, nops, ops, ae), \
16395 xCM_ (m1, le, m2, op, nops, ops, ae), \
16396 xCM_ (m1, al, m2, op, nops, ops, ae)
16398 #define UE(mnem, op, nops, ops, ae) \
16399 { #mnem, OPS##nops ops, OT_unconditional, 0x##op, 0, ARM_VARIANT, 0, do_##ae, NULL }
16401 #define UF(mnem, op, nops, ops, ae) \
16402 { #mnem, OPS##nops ops, OT_unconditionalF, 0x##op, 0, ARM_VARIANT, 0, do_##ae, NULL }
16404 /* Neon data-processing. ARM versions are unconditional with cond=0xf.
16405 The Thumb and ARM variants are mostly the same (bits 0-23 and 24/28), so we
16406 use the same encoding function for each. */
16407 #define NUF(mnem, op, nops, ops, enc) \
16408 { #mnem, OPS##nops ops, OT_unconditionalF, 0x##op, 0x##op, \
16409 ARM_VARIANT, THUMB_VARIANT, do_##enc, do_##enc }
16411 /* Neon data processing, version which indirects through neon_enc_tab for
16412 the various overloaded versions of opcodes. */
16413 #define nUF(mnem, op, nops, ops, enc) \
16414 { #mnem, OPS##nops ops, OT_unconditionalF, N_MNEM##op, N_MNEM##op, \
16415 ARM_VARIANT, THUMB_VARIANT, do_##enc, do_##enc }
16417 /* Neon insn with conditional suffix for the ARM version, non-overloaded
16419 #define NCE_tag(mnem, op, nops, ops, enc, tag) \
16420 { #mnem, OPS##nops ops, tag, 0x##op, 0x##op, ARM_VARIANT, \
16421 THUMB_VARIANT, do_##enc, do_##enc }
16423 #define NCE(mnem, op, nops, ops, enc) \
16424 NCE_tag (mnem, op, nops, ops, enc, OT_csuffix)
16426 #define NCEF(mnem, op, nops, ops, enc) \
16427 NCE_tag (mnem, op, nops, ops, enc, OT_csuffixF)
16429 /* Neon insn with conditional suffix for the ARM version, overloaded types. */
16430 #define nCE_tag(mnem, op, nops, ops, enc, tag) \
16431 { #mnem, OPS##nops ops, tag, N_MNEM##op, N_MNEM##op, \
16432 ARM_VARIANT, THUMB_VARIANT, do_##enc, do_##enc }
16434 #define nCE(mnem, op, nops, ops, enc) \
16435 nCE_tag (mnem, op, nops, ops, enc, OT_csuffix)
16437 #define nCEF(mnem, op, nops, ops, enc) \
16438 nCE_tag (mnem, op, nops, ops, enc, OT_csuffixF)
16442 /* Thumb-only, unconditional. */
16443 #define UT(mnem, op, nops, ops, te) TUE (mnem, 0, op, nops, ops, 0, te)
16445 static const struct asm_opcode insns
[] =
16447 #define ARM_VARIANT &arm_ext_v1 /* Core ARM Instructions. */
16448 #define THUMB_VARIANT &arm_ext_v4t
16449 tCE("and", 0000000, _and
, 3, (RR
, oRR
, SH
), arit
, t_arit3c
),
16450 tC3("ands", 0100000, _ands
, 3, (RR
, oRR
, SH
), arit
, t_arit3c
),
16451 tCE("eor", 0200000, _eor
, 3, (RR
, oRR
, SH
), arit
, t_arit3c
),
16452 tC3("eors", 0300000, _eors
, 3, (RR
, oRR
, SH
), arit
, t_arit3c
),
16453 tCE("sub", 0400000, _sub
, 3, (RR
, oRR
, SH
), arit
, t_add_sub
),
16454 tC3("subs", 0500000, _subs
, 3, (RR
, oRR
, SH
), arit
, t_add_sub
),
16455 tCE("add", 0800000, _add
, 3, (RR
, oRR
, SHG
), arit
, t_add_sub
),
16456 tC3("adds", 0900000, _adds
, 3, (RR
, oRR
, SHG
), arit
, t_add_sub
),
16457 tCE("adc", 0a00000
, _adc
, 3, (RR
, oRR
, SH
), arit
, t_arit3c
),
16458 tC3("adcs", 0b00000, _adcs
, 3, (RR
, oRR
, SH
), arit
, t_arit3c
),
16459 tCE("sbc", 0c00000
, _sbc
, 3, (RR
, oRR
, SH
), arit
, t_arit3
),
16460 tC3("sbcs", 0d00000
, _sbcs
, 3, (RR
, oRR
, SH
), arit
, t_arit3
),
16461 tCE("orr", 1800000, _orr
, 3, (RR
, oRR
, SH
), arit
, t_arit3c
),
16462 tC3("orrs", 1900000, _orrs
, 3, (RR
, oRR
, SH
), arit
, t_arit3c
),
16463 tCE("bic", 1c00000
, _bic
, 3, (RR
, oRR
, SH
), arit
, t_arit3
),
16464 tC3("bics", 1d00000
, _bics
, 3, (RR
, oRR
, SH
), arit
, t_arit3
),
16466 /* The p-variants of tst/cmp/cmn/teq (below) are the pre-V6 mechanism
16467 for setting PSR flag bits. They are obsolete in V6 and do not
16468 have Thumb equivalents. */
16469 tCE("tst", 1100000, _tst
, 2, (RR
, SH
), cmp
, t_mvn_tst
),
16470 tC3w("tsts", 1100000, _tst
, 2, (RR
, SH
), cmp
, t_mvn_tst
),
16471 CL("tstp", 110f000
, 2, (RR
, SH
), cmp
),
16472 tCE("cmp", 1500000, _cmp
, 2, (RR
, SH
), cmp
, t_mov_cmp
),
16473 tC3w("cmps", 1500000, _cmp
, 2, (RR
, SH
), cmp
, t_mov_cmp
),
16474 CL("cmpp", 150f000
, 2, (RR
, SH
), cmp
),
16475 tCE("cmn", 1700000, _cmn
, 2, (RR
, SH
), cmp
, t_mvn_tst
),
16476 tC3w("cmns", 1700000, _cmn
, 2, (RR
, SH
), cmp
, t_mvn_tst
),
16477 CL("cmnp", 170f000
, 2, (RR
, SH
), cmp
),
16479 tCE("mov", 1a00000
, _mov
, 2, (RR
, SH
), mov
, t_mov_cmp
),
16480 tC3("movs", 1b00000
, _movs
, 2, (RR
, SH
), mov
, t_mov_cmp
),
16481 tCE("mvn", 1e00000
, _mvn
, 2, (RR
, SH
), mov
, t_mvn_tst
),
16482 tC3("mvns", 1f00000
, _mvns
, 2, (RR
, SH
), mov
, t_mvn_tst
),
16484 tCE("ldr", 4100000, _ldr
, 2, (RR
, ADDRGLDR
),ldst
, t_ldst
),
16485 tC3("ldrb", 4500000, _ldrb
, 2, (RRnpc_npcsp
, ADDRGLDR
),ldst
, t_ldst
),
16486 tCE("str", 4000000, _str
, _2
, (MIX_ARM_THUMB_OPERANDS (OP_RR
,
16488 OP_ADDRGLDR
),ldst
, t_ldst
),
16489 tC3("strb", 4400000, _strb
, 2, (RRnpc_npcsp
, ADDRGLDR
),ldst
, t_ldst
),
16491 tCE("stm", 8800000, _stmia
, 2, (RRw
, REGLST
), ldmstm
, t_ldmstm
),
16492 tC3("stmia", 8800000, _stmia
, 2, (RRw
, REGLST
), ldmstm
, t_ldmstm
),
16493 tC3("stmea", 8800000, _stmia
, 2, (RRw
, REGLST
), ldmstm
, t_ldmstm
),
16494 tCE("ldm", 8900000, _ldmia
, 2, (RRw
, REGLST
), ldmstm
, t_ldmstm
),
16495 tC3("ldmia", 8900000, _ldmia
, 2, (RRw
, REGLST
), ldmstm
, t_ldmstm
),
16496 tC3("ldmfd", 8900000, _ldmia
, 2, (RRw
, REGLST
), ldmstm
, t_ldmstm
),
16498 TCE("swi", f000000
, df00
, 1, (EXPi
), swi
, t_swi
),
16499 TCE("svc", f000000
, df00
, 1, (EXPi
), swi
, t_swi
),
16500 tCE("b", a000000
, _b
, 1, (EXPr
), branch
, t_branch
),
16501 TCE("bl", b000000
, f000f800
, 1, (EXPr
), bl
, t_branch23
),
16504 tCE("adr", 28f0000
, _adr
, 2, (RR
, EXP
), adr
, t_adr
),
16505 C3(adrl
, 28f0000
, 2, (RR
, EXP
), adrl
),
16506 tCE("nop", 1a00000
, _nop
, 1, (oI255c
), nop
, t_nop
),
16508 /* Thumb-compatibility pseudo ops. */
16509 tCE("lsl", 1a00000
, _lsl
, 3, (RR
, oRR
, SH
), shift
, t_shift
),
16510 tC3("lsls", 1b00000
, _lsls
, 3, (RR
, oRR
, SH
), shift
, t_shift
),
16511 tCE("lsr", 1a00020
, _lsr
, 3, (RR
, oRR
, SH
), shift
, t_shift
),
16512 tC3("lsrs", 1b00020
, _lsrs
, 3, (RR
, oRR
, SH
), shift
, t_shift
),
16513 tCE("asr", 1a00040
, _asr
, 3, (RR
, oRR
, SH
), shift
, t_shift
),
16514 tC3("asrs", 1b00040
, _asrs
, 3, (RR
, oRR
, SH
), shift
, t_shift
),
16515 tCE("ror", 1a00060
, _ror
, 3, (RR
, oRR
, SH
), shift
, t_shift
),
16516 tC3("rors", 1b00060
, _rors
, 3, (RR
, oRR
, SH
), shift
, t_shift
),
16517 tCE("neg", 2600000, _neg
, 2, (RR
, RR
), rd_rn
, t_neg
),
16518 tC3("negs", 2700000, _negs
, 2, (RR
, RR
), rd_rn
, t_neg
),
16519 tCE("push", 92d0000
, _push
, 1, (REGLST
), push_pop
, t_push_pop
),
16520 tCE("pop", 8bd0000
, _pop
, 1, (REGLST
), push_pop
, t_push_pop
),
16522 /* These may simplify to neg. */
16523 TCE("rsb", 0600000, ebc00000
, 3, (RR
, oRR
, SH
), arit
, t_rsb
),
16524 TC3("rsbs", 0700000, ebd00000
, 3, (RR
, oRR
, SH
), arit
, t_rsb
),
16526 #undef THUMB_VARIANT
16527 #define THUMB_VARIANT & arm_ext_v6
16529 TCE("cpy", 1a00000
, 4600, 2, (RR
, RR
), rd_rm
, t_cpy
),
16531 /* V1 instructions with no Thumb analogue prior to V6T2. */
16532 #undef THUMB_VARIANT
16533 #define THUMB_VARIANT & arm_ext_v6t2
16535 TCE("teq", 1300000, ea900f00
, 2, (RR
, SH
), cmp
, t_mvn_tst
),
16536 TC3w("teqs", 1300000, ea900f00
, 2, (RR
, SH
), cmp
, t_mvn_tst
),
16537 CL("teqp", 130f000
, 2, (RR
, SH
), cmp
),
16539 TC3("ldrt", 4300000, f8500e00
, 2, (RRnpc_npcsp
, ADDR
),ldstt
, t_ldstt
),
16540 TC3("ldrbt", 4700000, f8100e00
, 2, (RRnpc_npcsp
, ADDR
),ldstt
, t_ldstt
),
16541 TC3("strt", 4200000, f8400e00
, 2, (RR_npcsp
, ADDR
), ldstt
, t_ldstt
),
16542 TC3("strbt", 4600000, f8000e00
, 2, (RRnpc_npcsp
, ADDR
),ldstt
, t_ldstt
),
16544 TC3("stmdb", 9000000, e9000000
, 2, (RRw
, REGLST
), ldmstm
, t_ldmstm
),
16545 TC3("stmfd", 9000000, e9000000
, 2, (RRw
, REGLST
), ldmstm
, t_ldmstm
),
16547 TC3("ldmdb", 9100000, e9100000
, 2, (RRw
, REGLST
), ldmstm
, t_ldmstm
),
16548 TC3("ldmea", 9100000, e9100000
, 2, (RRw
, REGLST
), ldmstm
, t_ldmstm
),
16550 /* V1 instructions with no Thumb analogue at all. */
16551 CE("rsc", 0e00000
, 3, (RR
, oRR
, SH
), arit
),
16552 C3(rscs
, 0f00000
, 3, (RR
, oRR
, SH
), arit
),
16554 C3(stmib
, 9800000, 2, (RRw
, REGLST
), ldmstm
),
16555 C3(stmfa
, 9800000, 2, (RRw
, REGLST
), ldmstm
),
16556 C3(stmda
, 8000000, 2, (RRw
, REGLST
), ldmstm
),
16557 C3(stmed
, 8000000, 2, (RRw
, REGLST
), ldmstm
),
16558 C3(ldmib
, 9900000, 2, (RRw
, REGLST
), ldmstm
),
16559 C3(ldmed
, 9900000, 2, (RRw
, REGLST
), ldmstm
),
16560 C3(ldmda
, 8100000, 2, (RRw
, REGLST
), ldmstm
),
16561 C3(ldmfa
, 8100000, 2, (RRw
, REGLST
), ldmstm
),
16564 #define ARM_VARIANT & arm_ext_v2 /* ARM 2 - multiplies. */
16565 #undef THUMB_VARIANT
16566 #define THUMB_VARIANT & arm_ext_v4t
16568 tCE("mul", 0000090, _mul
, 3, (RRnpc
, RRnpc
, oRR
), mul
, t_mul
),
16569 tC3("muls", 0100090, _muls
, 3, (RRnpc
, RRnpc
, oRR
), mul
, t_mul
),
16571 #undef THUMB_VARIANT
16572 #define THUMB_VARIANT & arm_ext_v6t2
16574 TCE("mla", 0200090, fb000000
, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
), mlas
, t_mla
),
16575 C3(mlas
, 0300090, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
), mlas
),
16577 /* Generic coprocessor instructions. */
16578 TCE("cdp", e000000
, ee000000
, 6, (RCP
, I15b
, RCN
, RCN
, RCN
, oI7b
), cdp
, cdp
),
16579 TCE("ldc", c100000
, ec100000
, 3, (RCP
, RCN
, ADDRGLDC
), lstc
, lstc
),
16580 TC3("ldcl", c500000
, ec500000
, 3, (RCP
, RCN
, ADDRGLDC
), lstc
, lstc
),
16581 TCE("stc", c000000
, ec000000
, 3, (RCP
, RCN
, ADDRGLDC
), lstc
, lstc
),
16582 TC3("stcl", c400000
, ec400000
, 3, (RCP
, RCN
, ADDRGLDC
), lstc
, lstc
),
16583 TCE("mcr", e000010
, ee000010
, 6, (RCP
, I7b
, RR
, RCN
, RCN
, oI7b
), co_reg
, co_reg
),
16584 TCE("mrc", e100010
, ee100010
, 6, (RCP
, I7b
, RR
, RCN
, RCN
, oI7b
), co_reg
, co_reg
),
16587 #define ARM_VARIANT & arm_ext_v2s /* ARM 3 - swp instructions. */
16589 CE("swp", 1000090, 3, (RRnpc
, RRnpc
, RRnpcb
), rd_rm_rn
),
16590 C3(swpb
, 1400090, 3, (RRnpc
, RRnpc
, RRnpcb
), rd_rm_rn
),
16593 #define ARM_VARIANT & arm_ext_v3 /* ARM 6 Status register instructions. */
16594 #undef THUMB_VARIANT
16595 #define THUMB_VARIANT & arm_ext_msr
16597 TCE("mrs", 10f0000
, f3ef8000
, 2, (APSR_RR
, RVC_PSR
), mrs
, t_mrs
),
16598 TCE("msr", 120f000
, f3808000
, 2, (RVC_PSR
, RR_EXi
), msr
, t_msr
),
16601 #define ARM_VARIANT & arm_ext_v3m /* ARM 7M long multiplies. */
16602 #undef THUMB_VARIANT
16603 #define THUMB_VARIANT & arm_ext_v6t2
16605 TCE("smull", 0c00090
, fb800000
, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
), mull
, t_mull
),
16606 CM("smull","s", 0d00090
, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
), mull
),
16607 TCE("umull", 0800090, fba00000
, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
), mull
, t_mull
),
16608 CM("umull","s", 0900090, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
), mull
),
16609 TCE("smlal", 0e00090
, fbc00000
, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
), mull
, t_mull
),
16610 CM("smlal","s", 0f00090
, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
), mull
),
16611 TCE("umlal", 0a00090
, fbe00000
, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
), mull
, t_mull
),
16612 CM("umlal","s", 0b00090, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
), mull
),
16615 #define ARM_VARIANT & arm_ext_v4 /* ARM Architecture 4. */
16616 #undef THUMB_VARIANT
16617 #define THUMB_VARIANT & arm_ext_v4t
16619 tC3("ldrh", 01000b0
, _ldrh
, 2, (RRnpc_npcsp
, ADDRGLDRS
), ldstv4
, t_ldst
),
16620 tC3("strh", 00000b0
, _strh
, 2, (RRnpc_npcsp
, ADDRGLDRS
), ldstv4
, t_ldst
),
16621 tC3("ldrsh", 01000f0
, _ldrsh
, 2, (RRnpc_npcsp
, ADDRGLDRS
), ldstv4
, t_ldst
),
16622 tC3("ldrsb", 01000d0
, _ldrsb
, 2, (RRnpc_npcsp
, ADDRGLDRS
), ldstv4
, t_ldst
),
16623 tCM("ld","sh", 01000f0
, _ldrsh
, 2, (RRnpc_npcsp
, ADDRGLDRS
), ldstv4
, t_ldst
),
16624 tCM("ld","sb", 01000d0
, _ldrsb
, 2, (RRnpc_npcsp
, ADDRGLDRS
), ldstv4
, t_ldst
),
16627 #define ARM_VARIANT & arm_ext_v4t_5
16629 /* ARM Architecture 4T. */
16630 /* Note: bx (and blx) are required on V5, even if the processor does
16631 not support Thumb. */
16632 TCE("bx", 12fff10
, 4700, 1, (RR
), bx
, t_bx
),
16635 #define ARM_VARIANT & arm_ext_v5 /* ARM Architecture 5T. */
16636 #undef THUMB_VARIANT
16637 #define THUMB_VARIANT & arm_ext_v5t
16639 /* Note: blx has 2 variants; the .value coded here is for
16640 BLX(2). Only this variant has conditional execution. */
16641 TCE("blx", 12fff30
, 4780, 1, (RR_EXr
), blx
, t_blx
),
16642 TUE("bkpt", 1200070, be00
, 1, (oIffffb
), bkpt
, t_bkpt
),
16644 #undef THUMB_VARIANT
16645 #define THUMB_VARIANT & arm_ext_v6t2
16647 TCE("clz", 16f0f10
, fab0f080
, 2, (RRnpc
, RRnpc
), rd_rm
, t_clz
),
16648 TUF("ldc2", c100000
, fc100000
, 3, (RCP
, RCN
, ADDRGLDC
), lstc
, lstc
),
16649 TUF("ldc2l", c500000
, fc500000
, 3, (RCP
, RCN
, ADDRGLDC
), lstc
, lstc
),
16650 TUF("stc2", c000000
, fc000000
, 3, (RCP
, RCN
, ADDRGLDC
), lstc
, lstc
),
16651 TUF("stc2l", c400000
, fc400000
, 3, (RCP
, RCN
, ADDRGLDC
), lstc
, lstc
),
16652 TUF("cdp2", e000000
, fe000000
, 6, (RCP
, I15b
, RCN
, RCN
, RCN
, oI7b
), cdp
, cdp
),
16653 TUF("mcr2", e000010
, fe000010
, 6, (RCP
, I7b
, RR
, RCN
, RCN
, oI7b
), co_reg
, co_reg
),
16654 TUF("mrc2", e100010
, fe100010
, 6, (RCP
, I7b
, RR
, RCN
, RCN
, oI7b
), co_reg
, co_reg
),
16657 #define ARM_VARIANT & arm_ext_v5exp /* ARM Architecture 5TExP. */
16658 #undef THUMB_VARIANT
16659 #define THUMB_VARIANT &arm_ext_v5exp
16661 TCE("smlabb", 1000080, fb100000
, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
), smla
, t_mla
),
16662 TCE("smlatb", 10000a0
, fb100020
, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
), smla
, t_mla
),
16663 TCE("smlabt", 10000c0
, fb100010
, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
), smla
, t_mla
),
16664 TCE("smlatt", 10000e0
, fb100030
, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
), smla
, t_mla
),
16666 TCE("smlawb", 1200080, fb300000
, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
), smla
, t_mla
),
16667 TCE("smlawt", 12000c0
, fb300010
, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
), smla
, t_mla
),
16669 TCE("smlalbb", 1400080, fbc00080
, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
), smlal
, t_mlal
),
16670 TCE("smlaltb", 14000a0
, fbc000a0
, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
), smlal
, t_mlal
),
16671 TCE("smlalbt", 14000c0
, fbc00090
, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
), smlal
, t_mlal
),
16672 TCE("smlaltt", 14000e0
, fbc000b0
, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
), smlal
, t_mlal
),
16674 TCE("smulbb", 1600080, fb10f000
, 3, (RRnpc
, RRnpc
, RRnpc
), smul
, t_simd
),
16675 TCE("smultb", 16000a0
, fb10f020
, 3, (RRnpc
, RRnpc
, RRnpc
), smul
, t_simd
),
16676 TCE("smulbt", 16000c0
, fb10f010
, 3, (RRnpc
, RRnpc
, RRnpc
), smul
, t_simd
),
16677 TCE("smultt", 16000e0
, fb10f030
, 3, (RRnpc
, RRnpc
, RRnpc
), smul
, t_simd
),
16679 TCE("smulwb", 12000a0
, fb30f000
, 3, (RRnpc
, RRnpc
, RRnpc
), smul
, t_simd
),
16680 TCE("smulwt", 12000e0
, fb30f010
, 3, (RRnpc
, RRnpc
, RRnpc
), smul
, t_simd
),
16682 TCE("qadd", 1000050, fa80f080
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rm_rn
, t_simd2
),
16683 TCE("qdadd", 1400050, fa80f090
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rm_rn
, t_simd2
),
16684 TCE("qsub", 1200050, fa80f0a0
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rm_rn
, t_simd2
),
16685 TCE("qdsub", 1600050, fa80f0b0
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rm_rn
, t_simd2
),
16688 #define ARM_VARIANT & arm_ext_v5e /* ARM Architecture 5TE. */
16689 #undef THUMB_VARIANT
16690 #define THUMB_VARIANT &arm_ext_v6t2
16692 TUF("pld", 450f000
, f810f000
, 1, (ADDR
), pld
, t_pld
),
16693 TC3("ldrd", 00000d0
, e8500000
, 3, (RRnpc_npcsp
, oRRnpc_npcsp
, ADDRGLDRS
),
16695 TC3("strd", 00000f0
, e8400000
, 3, (RRnpc_npcsp
, oRRnpc_npcsp
,
16696 ADDRGLDRS
), ldrd
, t_ldstd
),
16698 TCE("mcrr", c400000
, ec400000
, 5, (RCP
, I15b
, RRnpc
, RRnpc
, RCN
), co_reg2c
, co_reg2c
),
16699 TCE("mrrc", c500000
, ec500000
, 5, (RCP
, I15b
, RRnpc
, RRnpc
, RCN
), co_reg2c
, co_reg2c
),
16702 #define ARM_VARIANT & arm_ext_v5j /* ARM Architecture 5TEJ. */
16704 TCE("bxj", 12fff20
, f3c08f00
, 1, (RR
), bxj
, t_bxj
),
16707 #define ARM_VARIANT & arm_ext_v6 /* ARM V6. */
16708 #undef THUMB_VARIANT
16709 #define THUMB_VARIANT & arm_ext_v6
16711 TUF("cpsie", 1080000, b660
, 2, (CPSF
, oI31b
), cpsi
, t_cpsi
),
16712 TUF("cpsid", 10c0000
, b670
, 2, (CPSF
, oI31b
), cpsi
, t_cpsi
),
16713 tCE("rev", 6bf0f30
, _rev
, 2, (RRnpc
, RRnpc
), rd_rm
, t_rev
),
16714 tCE("rev16", 6bf0fb0
, _rev16
, 2, (RRnpc
, RRnpc
), rd_rm
, t_rev
),
16715 tCE("revsh", 6ff0fb0
, _revsh
, 2, (RRnpc
, RRnpc
), rd_rm
, t_rev
),
16716 tCE("sxth", 6bf0070
, _sxth
, 3, (RRnpc
, RRnpc
, oROR
), sxth
, t_sxth
),
16717 tCE("uxth", 6ff0070
, _uxth
, 3, (RRnpc
, RRnpc
, oROR
), sxth
, t_sxth
),
16718 tCE("sxtb", 6af0070
, _sxtb
, 3, (RRnpc
, RRnpc
, oROR
), sxth
, t_sxth
),
16719 tCE("uxtb", 6ef0070
, _uxtb
, 3, (RRnpc
, RRnpc
, oROR
), sxth
, t_sxth
),
16720 TUF("setend", 1010000, b650
, 1, (ENDI
), setend
, t_setend
),
16722 #undef THUMB_VARIANT
16723 #define THUMB_VARIANT & arm_ext_v6t2
16725 TCE("ldrex", 1900f9f
, e8500f00
, 2, (RRnpc_npcsp
, ADDR
), ldrex
, t_ldrex
),
16726 TCE("strex", 1800f90
, e8400000
, 3, (RRnpc_npcsp
, RRnpc_npcsp
, ADDR
),
16728 TUF("mcrr2", c400000
, fc400000
, 5, (RCP
, I15b
, RRnpc
, RRnpc
, RCN
), co_reg2c
, co_reg2c
),
16729 TUF("mrrc2", c500000
, fc500000
, 5, (RCP
, I15b
, RRnpc
, RRnpc
, RCN
), co_reg2c
, co_reg2c
),
16731 TCE("ssat", 6a00010
, f3000000
, 4, (RRnpc
, I32
, RRnpc
, oSHllar
),ssat
, t_ssat
),
16732 TCE("usat", 6e00010
, f3800000
, 4, (RRnpc
, I31
, RRnpc
, oSHllar
),usat
, t_usat
),
16734 /* ARM V6 not included in V7M. */
16735 #undef THUMB_VARIANT
16736 #define THUMB_VARIANT & arm_ext_v6_notm
16737 TUF("rfeia", 8900a00
, e990c000
, 1, (RRw
), rfe
, rfe
),
16738 UF(rfeib
, 9900a00
, 1, (RRw
), rfe
),
16739 UF(rfeda
, 8100a00
, 1, (RRw
), rfe
),
16740 TUF("rfedb", 9100a00
, e810c000
, 1, (RRw
), rfe
, rfe
),
16741 TUF("rfefd", 8900a00
, e990c000
, 1, (RRw
), rfe
, rfe
),
16742 UF(rfefa
, 9900a00
, 1, (RRw
), rfe
),
16743 UF(rfeea
, 8100a00
, 1, (RRw
), rfe
),
16744 TUF("rfeed", 9100a00
, e810c000
, 1, (RRw
), rfe
, rfe
),
16745 TUF("srsia", 8c00500
, e980c000
, 2, (oRRw
, I31w
), srs
, srs
),
16746 UF(srsib
, 9c00500
, 2, (oRRw
, I31w
), srs
),
16747 UF(srsda
, 8400500, 2, (oRRw
, I31w
), srs
),
16748 TUF("srsdb", 9400500, e800c000
, 2, (oRRw
, I31w
), srs
, srs
),
16750 /* ARM V6 not included in V7M (eg. integer SIMD). */
16751 #undef THUMB_VARIANT
16752 #define THUMB_VARIANT & arm_ext_v6_dsp
16753 TUF("cps", 1020000, f3af8100
, 1, (I31b
), imm0
, t_cps
),
16754 TCE("pkhbt", 6800010, eac00000
, 4, (RRnpc
, RRnpc
, RRnpc
, oSHll
), pkhbt
, t_pkhbt
),
16755 TCE("pkhtb", 6800050, eac00020
, 4, (RRnpc
, RRnpc
, RRnpc
, oSHar
), pkhtb
, t_pkhtb
),
16756 TCE("qadd16", 6200f10
, fa90f010
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
16757 TCE("qadd8", 6200f90
, fa80f010
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
16758 TCE("qasx", 6200f30
, faa0f010
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
16759 /* Old name for QASX. */
16760 TCE("qaddsubx", 6200f30
, faa0f010
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
16761 TCE("qsax", 6200f50
, fae0f010
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
16762 /* Old name for QSAX. */
16763 TCE("qsubaddx", 6200f50
, fae0f010
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
16764 TCE("qsub16", 6200f70
, fad0f010
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
16765 TCE("qsub8", 6200ff0
, fac0f010
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
16766 TCE("sadd16", 6100f10
, fa90f000
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
16767 TCE("sadd8", 6100f90
, fa80f000
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
16768 TCE("sasx", 6100f30
, faa0f000
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
16769 /* Old name for SASX. */
16770 TCE("saddsubx", 6100f30
, faa0f000
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
16771 TCE("shadd16", 6300f10
, fa90f020
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
16772 TCE("shadd8", 6300f90
, fa80f020
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
16773 TCE("shasx", 6300f30
, faa0f020
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
16774 /* Old name for SHASX. */
16775 TCE("shaddsubx", 6300f30
, faa0f020
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
16776 TCE("shsax", 6300f50
, fae0f020
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
16777 /* Old name for SHSAX. */
16778 TCE("shsubaddx", 6300f50
, fae0f020
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
16779 TCE("shsub16", 6300f70
, fad0f020
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
16780 TCE("shsub8", 6300ff0
, fac0f020
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
16781 TCE("ssax", 6100f50
, fae0f000
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
16782 /* Old name for SSAX. */
16783 TCE("ssubaddx", 6100f50
, fae0f000
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
16784 TCE("ssub16", 6100f70
, fad0f000
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
16785 TCE("ssub8", 6100ff0
, fac0f000
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
16786 TCE("uadd16", 6500f10
, fa90f040
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
16787 TCE("uadd8", 6500f90
, fa80f040
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
16788 TCE("uasx", 6500f30
, faa0f040
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
16789 /* Old name for UASX. */
16790 TCE("uaddsubx", 6500f30
, faa0f040
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
16791 TCE("uhadd16", 6700f10
, fa90f060
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
16792 TCE("uhadd8", 6700f90
, fa80f060
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
16793 TCE("uhasx", 6700f30
, faa0f060
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
16794 /* Old name for UHASX. */
16795 TCE("uhaddsubx", 6700f30
, faa0f060
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
16796 TCE("uhsax", 6700f50
, fae0f060
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
16797 /* Old name for UHSAX. */
16798 TCE("uhsubaddx", 6700f50
, fae0f060
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
16799 TCE("uhsub16", 6700f70
, fad0f060
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
16800 TCE("uhsub8", 6700ff0
, fac0f060
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
16801 TCE("uqadd16", 6600f10
, fa90f050
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
16802 TCE("uqadd8", 6600f90
, fa80f050
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
16803 TCE("uqasx", 6600f30
, faa0f050
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
16804 /* Old name for UQASX. */
16805 TCE("uqaddsubx", 6600f30
, faa0f050
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
16806 TCE("uqsax", 6600f50
, fae0f050
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
16807 /* Old name for UQSAX. */
16808 TCE("uqsubaddx", 6600f50
, fae0f050
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
16809 TCE("uqsub16", 6600f70
, fad0f050
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
16810 TCE("uqsub8", 6600ff0
, fac0f050
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
16811 TCE("usub16", 6500f70
, fad0f040
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
16812 TCE("usax", 6500f50
, fae0f040
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
16813 /* Old name for USAX. */
16814 TCE("usubaddx", 6500f50
, fae0f040
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
16815 TCE("usub8", 6500ff0
, fac0f040
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
16816 TCE("sxtah", 6b00070
, fa00f080
, 4, (RRnpc
, RRnpc
, RRnpc
, oROR
), sxtah
, t_sxtah
),
16817 TCE("sxtab16", 6800070, fa20f080
, 4, (RRnpc
, RRnpc
, RRnpc
, oROR
), sxtah
, t_sxtah
),
16818 TCE("sxtab", 6a00070
, fa40f080
, 4, (RRnpc
, RRnpc
, RRnpc
, oROR
), sxtah
, t_sxtah
),
16819 TCE("sxtb16", 68f0070
, fa2ff080
, 3, (RRnpc
, RRnpc
, oROR
), sxth
, t_sxth
),
16820 TCE("uxtah", 6f00070
, fa10f080
, 4, (RRnpc
, RRnpc
, RRnpc
, oROR
), sxtah
, t_sxtah
),
16821 TCE("uxtab16", 6c00070
, fa30f080
, 4, (RRnpc
, RRnpc
, RRnpc
, oROR
), sxtah
, t_sxtah
),
16822 TCE("uxtab", 6e00070
, fa50f080
, 4, (RRnpc
, RRnpc
, RRnpc
, oROR
), sxtah
, t_sxtah
),
16823 TCE("uxtb16", 6cf0070
, fa3ff080
, 3, (RRnpc
, RRnpc
, oROR
), sxth
, t_sxth
),
16824 TCE("sel", 6800fb0
, faa0f080
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
16825 TCE("smlad", 7000010, fb200000
, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
),smla
, t_mla
),
16826 TCE("smladx", 7000030, fb200010
, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
),smla
, t_mla
),
16827 TCE("smlald", 7400010, fbc000c0
, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
),smlal
,t_mlal
),
16828 TCE("smlaldx", 7400030, fbc000d0
, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
),smlal
,t_mlal
),
16829 TCE("smlsd", 7000050, fb400000
, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
),smla
, t_mla
),
16830 TCE("smlsdx", 7000070, fb400010
, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
),smla
, t_mla
),
16831 TCE("smlsld", 7400050, fbd000c0
, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
),smlal
,t_mlal
),
16832 TCE("smlsldx", 7400070, fbd000d0
, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
),smlal
,t_mlal
),
16833 TCE("smmla", 7500010, fb500000
, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
),smla
, t_mla
),
16834 TCE("smmlar", 7500030, fb500010
, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
),smla
, t_mla
),
16835 TCE("smmls", 75000d0
, fb600000
, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
),smla
, t_mla
),
16836 TCE("smmlsr", 75000f0
, fb600010
, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
),smla
, t_mla
),
16837 TCE("smmul", 750f010
, fb50f000
, 3, (RRnpc
, RRnpc
, RRnpc
), smul
, t_simd
),
16838 TCE("smmulr", 750f030
, fb50f010
, 3, (RRnpc
, RRnpc
, RRnpc
), smul
, t_simd
),
16839 TCE("smuad", 700f010
, fb20f000
, 3, (RRnpc
, RRnpc
, RRnpc
), smul
, t_simd
),
16840 TCE("smuadx", 700f030
, fb20f010
, 3, (RRnpc
, RRnpc
, RRnpc
), smul
, t_simd
),
16841 TCE("smusd", 700f050
, fb40f000
, 3, (RRnpc
, RRnpc
, RRnpc
), smul
, t_simd
),
16842 TCE("smusdx", 700f070
, fb40f010
, 3, (RRnpc
, RRnpc
, RRnpc
), smul
, t_simd
),
16843 TCE("ssat16", 6a00f30
, f3200000
, 3, (RRnpc
, I16
, RRnpc
), ssat16
, t_ssat16
),
16844 TCE("umaal", 0400090, fbe00060
, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
),smlal
, t_mlal
),
16845 TCE("usad8", 780f010
, fb70f000
, 3, (RRnpc
, RRnpc
, RRnpc
), smul
, t_simd
),
16846 TCE("usada8", 7800010, fb700000
, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
),smla
, t_mla
),
16847 TCE("usat16", 6e00f30
, f3a00000
, 3, (RRnpc
, I15
, RRnpc
), usat16
, t_usat16
),
16850 #define ARM_VARIANT & arm_ext_v6k
16851 #undef THUMB_VARIANT
16852 #define THUMB_VARIANT & arm_ext_v6k
16854 tCE("yield", 320f001
, _yield
, 0, (), noargs
, t_hint
),
16855 tCE("wfe", 320f002
, _wfe
, 0, (), noargs
, t_hint
),
16856 tCE("wfi", 320f003
, _wfi
, 0, (), noargs
, t_hint
),
16857 tCE("sev", 320f004
, _sev
, 0, (), noargs
, t_hint
),
16859 #undef THUMB_VARIANT
16860 #define THUMB_VARIANT & arm_ext_v6_notm
16861 TCE("ldrexd", 1b00f9f
, e8d0007f
, 3, (RRnpc_npcsp
, oRRnpc_npcsp
, RRnpcb
),
16863 TCE("strexd", 1a00f90
, e8c00070
, 4, (RRnpc_npcsp
, RRnpc_npcsp
, oRRnpc_npcsp
,
16864 RRnpcb
), strexd
, t_strexd
),
16866 #undef THUMB_VARIANT
16867 #define THUMB_VARIANT & arm_ext_v6t2
16868 TCE("ldrexb", 1d00f9f
, e8d00f4f
, 2, (RRnpc_npcsp
,RRnpcb
),
16870 TCE("ldrexh", 1f00f9f
, e8d00f5f
, 2, (RRnpc_npcsp
, RRnpcb
),
16872 TCE("strexb", 1c00f90
, e8c00f40
, 3, (RRnpc_npcsp
, RRnpc_npcsp
, ADDR
),
16874 TCE("strexh", 1e00f90
, e8c00f50
, 3, (RRnpc_npcsp
, RRnpc_npcsp
, ADDR
),
16876 TUF("clrex", 57ff01f
, f3bf8f2f
, 0, (), noargs
, noargs
),
16879 #define ARM_VARIANT & arm_ext_v6z
16881 TCE("smc", 1600070, f7f08000
, 1, (EXPi
), smc
, t_smc
),
16884 #define ARM_VARIANT & arm_ext_v6t2
16886 TCE("bfc", 7c0001f
, f36f0000
, 3, (RRnpc
, I31
, I32
), bfc
, t_bfc
),
16887 TCE("bfi", 7c00010
, f3600000
, 4, (RRnpc
, RRnpc_I0
, I31
, I32
), bfi
, t_bfi
),
16888 TCE("sbfx", 7a00050
, f3400000
, 4, (RR
, RR
, I31
, I32
), bfx
, t_bfx
),
16889 TCE("ubfx", 7e00050
, f3c00000
, 4, (RR
, RR
, I31
, I32
), bfx
, t_bfx
),
16891 TCE("mls", 0600090, fb000010
, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
), mlas
, t_mla
),
16892 TCE("movw", 3000000, f2400000
, 2, (RRnpc
, HALF
), mov16
, t_mov16
),
16893 TCE("movt", 3400000, f2c00000
, 2, (RRnpc
, HALF
), mov16
, t_mov16
),
16894 TCE("rbit", 6ff0f30
, fa90f0a0
, 2, (RR
, RR
), rd_rm
, t_rbit
),
16896 TC3("ldrht", 03000b0
, f8300e00
, 2, (RRnpc_npcsp
, ADDR
), ldsttv4
, t_ldstt
),
16897 TC3("ldrsht", 03000f0
, f9300e00
, 2, (RRnpc_npcsp
, ADDR
), ldsttv4
, t_ldstt
),
16898 TC3("ldrsbt", 03000d0
, f9100e00
, 2, (RRnpc_npcsp
, ADDR
), ldsttv4
, t_ldstt
),
16899 TC3("strht", 02000b0
, f8200e00
, 2, (RRnpc_npcsp
, ADDR
), ldsttv4
, t_ldstt
),
16901 UT("cbnz", b900
, 2, (RR
, EXP
), t_cbz
),
16902 UT("cbz", b100
, 2, (RR
, EXP
), t_cbz
),
16904 /* ARM does not really have an IT instruction, so always allow it.
16905 The opcode is copied from Thumb in order to allow warnings in
16906 -mimplicit-it=[never | arm] modes. */
16908 #define ARM_VARIANT & arm_ext_v1
16910 TUE("it", bf08
, bf08
, 1, (COND
), it
, t_it
),
16911 TUE("itt", bf0c
, bf0c
, 1, (COND
), it
, t_it
),
16912 TUE("ite", bf04
, bf04
, 1, (COND
), it
, t_it
),
16913 TUE("ittt", bf0e
, bf0e
, 1, (COND
), it
, t_it
),
16914 TUE("itet", bf06
, bf06
, 1, (COND
), it
, t_it
),
16915 TUE("itte", bf0a
, bf0a
, 1, (COND
), it
, t_it
),
16916 TUE("itee", bf02
, bf02
, 1, (COND
), it
, t_it
),
16917 TUE("itttt", bf0f
, bf0f
, 1, (COND
), it
, t_it
),
16918 TUE("itett", bf07
, bf07
, 1, (COND
), it
, t_it
),
16919 TUE("ittet", bf0b
, bf0b
, 1, (COND
), it
, t_it
),
16920 TUE("iteet", bf03
, bf03
, 1, (COND
), it
, t_it
),
16921 TUE("ittte", bf0d
, bf0d
, 1, (COND
), it
, t_it
),
16922 TUE("itete", bf05
, bf05
, 1, (COND
), it
, t_it
),
16923 TUE("ittee", bf09
, bf09
, 1, (COND
), it
, t_it
),
16924 TUE("iteee", bf01
, bf01
, 1, (COND
), it
, t_it
),
16925 /* ARM/Thumb-2 instructions with no Thumb-1 equivalent. */
16926 TC3("rrx", 01a00060
, ea4f0030
, 2, (RR
, RR
), rd_rm
, t_rrx
),
16927 TC3("rrxs", 01b00060
, ea5f0030
, 2, (RR
, RR
), rd_rm
, t_rrx
),
16929 /* Thumb2 only instructions. */
16931 #define ARM_VARIANT NULL
16933 TCE("addw", 0, f2000000
, 3, (RR
, RR
, EXPi
), 0, t_add_sub_w
),
16934 TCE("subw", 0, f2a00000
, 3, (RR
, RR
, EXPi
), 0, t_add_sub_w
),
16935 TCE("orn", 0, ea600000
, 3, (RR
, oRR
, SH
), 0, t_orn
),
16936 TCE("orns", 0, ea700000
, 3, (RR
, oRR
, SH
), 0, t_orn
),
16937 TCE("tbb", 0, e8d0f000
, 1, (TB
), 0, t_tb
),
16938 TCE("tbh", 0, e8d0f010
, 1, (TB
), 0, t_tb
),
16940 /* Thumb-2 hardware division instructions (R and M profiles only). */
16941 #undef THUMB_VARIANT
16942 #define THUMB_VARIANT & arm_ext_div
16944 TCE("sdiv", 0, fb90f0f0
, 3, (RR
, oRR
, RR
), 0, t_div
),
16945 TCE("udiv", 0, fbb0f0f0
, 3, (RR
, oRR
, RR
), 0, t_div
),
16947 /* ARM V6M/V7 instructions. */
16949 #define ARM_VARIANT & arm_ext_barrier
16950 #undef THUMB_VARIANT
16951 #define THUMB_VARIANT & arm_ext_barrier
16953 TUF("dmb", 57ff050
, f3bf8f50
, 1, (oBARRIER
), barrier
, t_barrier
),
16954 TUF("dsb", 57ff040
, f3bf8f40
, 1, (oBARRIER
), barrier
, t_barrier
),
16955 TUF("isb", 57ff060
, f3bf8f60
, 1, (oBARRIER
), barrier
, t_barrier
),
16957 /* ARM V7 instructions. */
16959 #define ARM_VARIANT & arm_ext_v7
16960 #undef THUMB_VARIANT
16961 #define THUMB_VARIANT & arm_ext_v7
16963 TUF("pli", 450f000
, f910f000
, 1, (ADDR
), pli
, t_pld
),
16964 TCE("dbg", 320f0f0
, f3af80f0
, 1, (I15
), dbg
, t_dbg
),
16967 #define ARM_VARIANT & fpu_fpa_ext_v1 /* Core FPA instruction set (V1). */
16969 cCE("wfs", e200110
, 1, (RR
), rd
),
16970 cCE("rfs", e300110
, 1, (RR
), rd
),
16971 cCE("wfc", e400110
, 1, (RR
), rd
),
16972 cCE("rfc", e500110
, 1, (RR
), rd
),
16974 cCL("ldfs", c100100
, 2, (RF
, ADDRGLDC
), rd_cpaddr
),
16975 cCL("ldfd", c108100
, 2, (RF
, ADDRGLDC
), rd_cpaddr
),
16976 cCL("ldfe", c500100
, 2, (RF
, ADDRGLDC
), rd_cpaddr
),
16977 cCL("ldfp", c508100
, 2, (RF
, ADDRGLDC
), rd_cpaddr
),
16979 cCL("stfs", c000100
, 2, (RF
, ADDRGLDC
), rd_cpaddr
),
16980 cCL("stfd", c008100
, 2, (RF
, ADDRGLDC
), rd_cpaddr
),
16981 cCL("stfe", c400100
, 2, (RF
, ADDRGLDC
), rd_cpaddr
),
16982 cCL("stfp", c408100
, 2, (RF
, ADDRGLDC
), rd_cpaddr
),
16984 cCL("mvfs", e008100
, 2, (RF
, RF_IF
), rd_rm
),
16985 cCL("mvfsp", e008120
, 2, (RF
, RF_IF
), rd_rm
),
16986 cCL("mvfsm", e008140
, 2, (RF
, RF_IF
), rd_rm
),
16987 cCL("mvfsz", e008160
, 2, (RF
, RF_IF
), rd_rm
),
16988 cCL("mvfd", e008180
, 2, (RF
, RF_IF
), rd_rm
),
16989 cCL("mvfdp", e0081a0
, 2, (RF
, RF_IF
), rd_rm
),
16990 cCL("mvfdm", e0081c0
, 2, (RF
, RF_IF
), rd_rm
),
16991 cCL("mvfdz", e0081e0
, 2, (RF
, RF_IF
), rd_rm
),
16992 cCL("mvfe", e088100
, 2, (RF
, RF_IF
), rd_rm
),
16993 cCL("mvfep", e088120
, 2, (RF
, RF_IF
), rd_rm
),
16994 cCL("mvfem", e088140
, 2, (RF
, RF_IF
), rd_rm
),
16995 cCL("mvfez", e088160
, 2, (RF
, RF_IF
), rd_rm
),
16997 cCL("mnfs", e108100
, 2, (RF
, RF_IF
), rd_rm
),
16998 cCL("mnfsp", e108120
, 2, (RF
, RF_IF
), rd_rm
),
16999 cCL("mnfsm", e108140
, 2, (RF
, RF_IF
), rd_rm
),
17000 cCL("mnfsz", e108160
, 2, (RF
, RF_IF
), rd_rm
),
17001 cCL("mnfd", e108180
, 2, (RF
, RF_IF
), rd_rm
),
17002 cCL("mnfdp", e1081a0
, 2, (RF
, RF_IF
), rd_rm
),
17003 cCL("mnfdm", e1081c0
, 2, (RF
, RF_IF
), rd_rm
),
17004 cCL("mnfdz", e1081e0
, 2, (RF
, RF_IF
), rd_rm
),
17005 cCL("mnfe", e188100
, 2, (RF
, RF_IF
), rd_rm
),
17006 cCL("mnfep", e188120
, 2, (RF
, RF_IF
), rd_rm
),
17007 cCL("mnfem", e188140
, 2, (RF
, RF_IF
), rd_rm
),
17008 cCL("mnfez", e188160
, 2, (RF
, RF_IF
), rd_rm
),
17010 cCL("abss", e208100
, 2, (RF
, RF_IF
), rd_rm
),
17011 cCL("abssp", e208120
, 2, (RF
, RF_IF
), rd_rm
),
17012 cCL("abssm", e208140
, 2, (RF
, RF_IF
), rd_rm
),
17013 cCL("abssz", e208160
, 2, (RF
, RF_IF
), rd_rm
),
17014 cCL("absd", e208180
, 2, (RF
, RF_IF
), rd_rm
),
17015 cCL("absdp", e2081a0
, 2, (RF
, RF_IF
), rd_rm
),
17016 cCL("absdm", e2081c0
, 2, (RF
, RF_IF
), rd_rm
),
17017 cCL("absdz", e2081e0
, 2, (RF
, RF_IF
), rd_rm
),
17018 cCL("abse", e288100
, 2, (RF
, RF_IF
), rd_rm
),
17019 cCL("absep", e288120
, 2, (RF
, RF_IF
), rd_rm
),
17020 cCL("absem", e288140
, 2, (RF
, RF_IF
), rd_rm
),
17021 cCL("absez", e288160
, 2, (RF
, RF_IF
), rd_rm
),
17023 cCL("rnds", e308100
, 2, (RF
, RF_IF
), rd_rm
),
17024 cCL("rndsp", e308120
, 2, (RF
, RF_IF
), rd_rm
),
17025 cCL("rndsm", e308140
, 2, (RF
, RF_IF
), rd_rm
),
17026 cCL("rndsz", e308160
, 2, (RF
, RF_IF
), rd_rm
),
17027 cCL("rndd", e308180
, 2, (RF
, RF_IF
), rd_rm
),
17028 cCL("rnddp", e3081a0
, 2, (RF
, RF_IF
), rd_rm
),
17029 cCL("rnddm", e3081c0
, 2, (RF
, RF_IF
), rd_rm
),
17030 cCL("rnddz", e3081e0
, 2, (RF
, RF_IF
), rd_rm
),
17031 cCL("rnde", e388100
, 2, (RF
, RF_IF
), rd_rm
),
17032 cCL("rndep", e388120
, 2, (RF
, RF_IF
), rd_rm
),
17033 cCL("rndem", e388140
, 2, (RF
, RF_IF
), rd_rm
),
17034 cCL("rndez", e388160
, 2, (RF
, RF_IF
), rd_rm
),
17036 cCL("sqts", e408100
, 2, (RF
, RF_IF
), rd_rm
),
17037 cCL("sqtsp", e408120
, 2, (RF
, RF_IF
), rd_rm
),
17038 cCL("sqtsm", e408140
, 2, (RF
, RF_IF
), rd_rm
),
17039 cCL("sqtsz", e408160
, 2, (RF
, RF_IF
), rd_rm
),
17040 cCL("sqtd", e408180
, 2, (RF
, RF_IF
), rd_rm
),
17041 cCL("sqtdp", e4081a0
, 2, (RF
, RF_IF
), rd_rm
),
17042 cCL("sqtdm", e4081c0
, 2, (RF
, RF_IF
), rd_rm
),
17043 cCL("sqtdz", e4081e0
, 2, (RF
, RF_IF
), rd_rm
),
17044 cCL("sqte", e488100
, 2, (RF
, RF_IF
), rd_rm
),
17045 cCL("sqtep", e488120
, 2, (RF
, RF_IF
), rd_rm
),
17046 cCL("sqtem", e488140
, 2, (RF
, RF_IF
), rd_rm
),
17047 cCL("sqtez", e488160
, 2, (RF
, RF_IF
), rd_rm
),
17049 cCL("logs", e508100
, 2, (RF
, RF_IF
), rd_rm
),
17050 cCL("logsp", e508120
, 2, (RF
, RF_IF
), rd_rm
),
17051 cCL("logsm", e508140
, 2, (RF
, RF_IF
), rd_rm
),
17052 cCL("logsz", e508160
, 2, (RF
, RF_IF
), rd_rm
),
17053 cCL("logd", e508180
, 2, (RF
, RF_IF
), rd_rm
),
17054 cCL("logdp", e5081a0
, 2, (RF
, RF_IF
), rd_rm
),
17055 cCL("logdm", e5081c0
, 2, (RF
, RF_IF
), rd_rm
),
17056 cCL("logdz", e5081e0
, 2, (RF
, RF_IF
), rd_rm
),
17057 cCL("loge", e588100
, 2, (RF
, RF_IF
), rd_rm
),
17058 cCL("logep", e588120
, 2, (RF
, RF_IF
), rd_rm
),
17059 cCL("logem", e588140
, 2, (RF
, RF_IF
), rd_rm
),
17060 cCL("logez", e588160
, 2, (RF
, RF_IF
), rd_rm
),
17062 cCL("lgns", e608100
, 2, (RF
, RF_IF
), rd_rm
),
17063 cCL("lgnsp", e608120
, 2, (RF
, RF_IF
), rd_rm
),
17064 cCL("lgnsm", e608140
, 2, (RF
, RF_IF
), rd_rm
),
17065 cCL("lgnsz", e608160
, 2, (RF
, RF_IF
), rd_rm
),
17066 cCL("lgnd", e608180
, 2, (RF
, RF_IF
), rd_rm
),
17067 cCL("lgndp", e6081a0
, 2, (RF
, RF_IF
), rd_rm
),
17068 cCL("lgndm", e6081c0
, 2, (RF
, RF_IF
), rd_rm
),
17069 cCL("lgndz", e6081e0
, 2, (RF
, RF_IF
), rd_rm
),
17070 cCL("lgne", e688100
, 2, (RF
, RF_IF
), rd_rm
),
17071 cCL("lgnep", e688120
, 2, (RF
, RF_IF
), rd_rm
),
17072 cCL("lgnem", e688140
, 2, (RF
, RF_IF
), rd_rm
),
17073 cCL("lgnez", e688160
, 2, (RF
, RF_IF
), rd_rm
),
17075 cCL("exps", e708100
, 2, (RF
, RF_IF
), rd_rm
),
17076 cCL("expsp", e708120
, 2, (RF
, RF_IF
), rd_rm
),
17077 cCL("expsm", e708140
, 2, (RF
, RF_IF
), rd_rm
),
17078 cCL("expsz", e708160
, 2, (RF
, RF_IF
), rd_rm
),
17079 cCL("expd", e708180
, 2, (RF
, RF_IF
), rd_rm
),
17080 cCL("expdp", e7081a0
, 2, (RF
, RF_IF
), rd_rm
),
17081 cCL("expdm", e7081c0
, 2, (RF
, RF_IF
), rd_rm
),
17082 cCL("expdz", e7081e0
, 2, (RF
, RF_IF
), rd_rm
),
17083 cCL("expe", e788100
, 2, (RF
, RF_IF
), rd_rm
),
17084 cCL("expep", e788120
, 2, (RF
, RF_IF
), rd_rm
),
17085 cCL("expem", e788140
, 2, (RF
, RF_IF
), rd_rm
),
17086 cCL("expdz", e788160
, 2, (RF
, RF_IF
), rd_rm
),
17088 cCL("sins", e808100
, 2, (RF
, RF_IF
), rd_rm
),
17089 cCL("sinsp", e808120
, 2, (RF
, RF_IF
), rd_rm
),
17090 cCL("sinsm", e808140
, 2, (RF
, RF_IF
), rd_rm
),
17091 cCL("sinsz", e808160
, 2, (RF
, RF_IF
), rd_rm
),
17092 cCL("sind", e808180
, 2, (RF
, RF_IF
), rd_rm
),
17093 cCL("sindp", e8081a0
, 2, (RF
, RF_IF
), rd_rm
),
17094 cCL("sindm", e8081c0
, 2, (RF
, RF_IF
), rd_rm
),
17095 cCL("sindz", e8081e0
, 2, (RF
, RF_IF
), rd_rm
),
17096 cCL("sine", e888100
, 2, (RF
, RF_IF
), rd_rm
),
17097 cCL("sinep", e888120
, 2, (RF
, RF_IF
), rd_rm
),
17098 cCL("sinem", e888140
, 2, (RF
, RF_IF
), rd_rm
),
17099 cCL("sinez", e888160
, 2, (RF
, RF_IF
), rd_rm
),
17101 cCL("coss", e908100
, 2, (RF
, RF_IF
), rd_rm
),
17102 cCL("cossp", e908120
, 2, (RF
, RF_IF
), rd_rm
),
17103 cCL("cossm", e908140
, 2, (RF
, RF_IF
), rd_rm
),
17104 cCL("cossz", e908160
, 2, (RF
, RF_IF
), rd_rm
),
17105 cCL("cosd", e908180
, 2, (RF
, RF_IF
), rd_rm
),
17106 cCL("cosdp", e9081a0
, 2, (RF
, RF_IF
), rd_rm
),
17107 cCL("cosdm", e9081c0
, 2, (RF
, RF_IF
), rd_rm
),
17108 cCL("cosdz", e9081e0
, 2, (RF
, RF_IF
), rd_rm
),
17109 cCL("cose", e988100
, 2, (RF
, RF_IF
), rd_rm
),
17110 cCL("cosep", e988120
, 2, (RF
, RF_IF
), rd_rm
),
17111 cCL("cosem", e988140
, 2, (RF
, RF_IF
), rd_rm
),
17112 cCL("cosez", e988160
, 2, (RF
, RF_IF
), rd_rm
),
17114 cCL("tans", ea08100
, 2, (RF
, RF_IF
), rd_rm
),
17115 cCL("tansp", ea08120
, 2, (RF
, RF_IF
), rd_rm
),
17116 cCL("tansm", ea08140
, 2, (RF
, RF_IF
), rd_rm
),
17117 cCL("tansz", ea08160
, 2, (RF
, RF_IF
), rd_rm
),
17118 cCL("tand", ea08180
, 2, (RF
, RF_IF
), rd_rm
),
17119 cCL("tandp", ea081a0
, 2, (RF
, RF_IF
), rd_rm
),
17120 cCL("tandm", ea081c0
, 2, (RF
, RF_IF
), rd_rm
),
17121 cCL("tandz", ea081e0
, 2, (RF
, RF_IF
), rd_rm
),
17122 cCL("tane", ea88100
, 2, (RF
, RF_IF
), rd_rm
),
17123 cCL("tanep", ea88120
, 2, (RF
, RF_IF
), rd_rm
),
17124 cCL("tanem", ea88140
, 2, (RF
, RF_IF
), rd_rm
),
17125 cCL("tanez", ea88160
, 2, (RF
, RF_IF
), rd_rm
),
17127 cCL("asns", eb08100
, 2, (RF
, RF_IF
), rd_rm
),
17128 cCL("asnsp", eb08120
, 2, (RF
, RF_IF
), rd_rm
),
17129 cCL("asnsm", eb08140
, 2, (RF
, RF_IF
), rd_rm
),
17130 cCL("asnsz", eb08160
, 2, (RF
, RF_IF
), rd_rm
),
17131 cCL("asnd", eb08180
, 2, (RF
, RF_IF
), rd_rm
),
17132 cCL("asndp", eb081a0
, 2, (RF
, RF_IF
), rd_rm
),
17133 cCL("asndm", eb081c0
, 2, (RF
, RF_IF
), rd_rm
),
17134 cCL("asndz", eb081e0
, 2, (RF
, RF_IF
), rd_rm
),
17135 cCL("asne", eb88100
, 2, (RF
, RF_IF
), rd_rm
),
17136 cCL("asnep", eb88120
, 2, (RF
, RF_IF
), rd_rm
),
17137 cCL("asnem", eb88140
, 2, (RF
, RF_IF
), rd_rm
),
17138 cCL("asnez", eb88160
, 2, (RF
, RF_IF
), rd_rm
),
17140 cCL("acss", ec08100
, 2, (RF
, RF_IF
), rd_rm
),
17141 cCL("acssp", ec08120
, 2, (RF
, RF_IF
), rd_rm
),
17142 cCL("acssm", ec08140
, 2, (RF
, RF_IF
), rd_rm
),
17143 cCL("acssz", ec08160
, 2, (RF
, RF_IF
), rd_rm
),
17144 cCL("acsd", ec08180
, 2, (RF
, RF_IF
), rd_rm
),
17145 cCL("acsdp", ec081a0
, 2, (RF
, RF_IF
), rd_rm
),
17146 cCL("acsdm", ec081c0
, 2, (RF
, RF_IF
), rd_rm
),
17147 cCL("acsdz", ec081e0
, 2, (RF
, RF_IF
), rd_rm
),
17148 cCL("acse", ec88100
, 2, (RF
, RF_IF
), rd_rm
),
17149 cCL("acsep", ec88120
, 2, (RF
, RF_IF
), rd_rm
),
17150 cCL("acsem", ec88140
, 2, (RF
, RF_IF
), rd_rm
),
17151 cCL("acsez", ec88160
, 2, (RF
, RF_IF
), rd_rm
),
17153 cCL("atns", ed08100
, 2, (RF
, RF_IF
), rd_rm
),
17154 cCL("atnsp", ed08120
, 2, (RF
, RF_IF
), rd_rm
),
17155 cCL("atnsm", ed08140
, 2, (RF
, RF_IF
), rd_rm
),
17156 cCL("atnsz", ed08160
, 2, (RF
, RF_IF
), rd_rm
),
17157 cCL("atnd", ed08180
, 2, (RF
, RF_IF
), rd_rm
),
17158 cCL("atndp", ed081a0
, 2, (RF
, RF_IF
), rd_rm
),
17159 cCL("atndm", ed081c0
, 2, (RF
, RF_IF
), rd_rm
),
17160 cCL("atndz", ed081e0
, 2, (RF
, RF_IF
), rd_rm
),
17161 cCL("atne", ed88100
, 2, (RF
, RF_IF
), rd_rm
),
17162 cCL("atnep", ed88120
, 2, (RF
, RF_IF
), rd_rm
),
17163 cCL("atnem", ed88140
, 2, (RF
, RF_IF
), rd_rm
),
17164 cCL("atnez", ed88160
, 2, (RF
, RF_IF
), rd_rm
),
17166 cCL("urds", ee08100
, 2, (RF
, RF_IF
), rd_rm
),
17167 cCL("urdsp", ee08120
, 2, (RF
, RF_IF
), rd_rm
),
17168 cCL("urdsm", ee08140
, 2, (RF
, RF_IF
), rd_rm
),
17169 cCL("urdsz", ee08160
, 2, (RF
, RF_IF
), rd_rm
),
17170 cCL("urdd", ee08180
, 2, (RF
, RF_IF
), rd_rm
),
17171 cCL("urddp", ee081a0
, 2, (RF
, RF_IF
), rd_rm
),
17172 cCL("urddm", ee081c0
, 2, (RF
, RF_IF
), rd_rm
),
17173 cCL("urddz", ee081e0
, 2, (RF
, RF_IF
), rd_rm
),
17174 cCL("urde", ee88100
, 2, (RF
, RF_IF
), rd_rm
),
17175 cCL("urdep", ee88120
, 2, (RF
, RF_IF
), rd_rm
),
17176 cCL("urdem", ee88140
, 2, (RF
, RF_IF
), rd_rm
),
17177 cCL("urdez", ee88160
, 2, (RF
, RF_IF
), rd_rm
),
17179 cCL("nrms", ef08100
, 2, (RF
, RF_IF
), rd_rm
),
17180 cCL("nrmsp", ef08120
, 2, (RF
, RF_IF
), rd_rm
),
17181 cCL("nrmsm", ef08140
, 2, (RF
, RF_IF
), rd_rm
),
17182 cCL("nrmsz", ef08160
, 2, (RF
, RF_IF
), rd_rm
),
17183 cCL("nrmd", ef08180
, 2, (RF
, RF_IF
), rd_rm
),
17184 cCL("nrmdp", ef081a0
, 2, (RF
, RF_IF
), rd_rm
),
17185 cCL("nrmdm", ef081c0
, 2, (RF
, RF_IF
), rd_rm
),
17186 cCL("nrmdz", ef081e0
, 2, (RF
, RF_IF
), rd_rm
),
17187 cCL("nrme", ef88100
, 2, (RF
, RF_IF
), rd_rm
),
17188 cCL("nrmep", ef88120
, 2, (RF
, RF_IF
), rd_rm
),
17189 cCL("nrmem", ef88140
, 2, (RF
, RF_IF
), rd_rm
),
17190 cCL("nrmez", ef88160
, 2, (RF
, RF_IF
), rd_rm
),
17192 cCL("adfs", e000100
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17193 cCL("adfsp", e000120
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17194 cCL("adfsm", e000140
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17195 cCL("adfsz", e000160
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17196 cCL("adfd", e000180
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17197 cCL("adfdp", e0001a0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17198 cCL("adfdm", e0001c0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17199 cCL("adfdz", e0001e0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17200 cCL("adfe", e080100
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17201 cCL("adfep", e080120
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17202 cCL("adfem", e080140
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17203 cCL("adfez", e080160
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17205 cCL("sufs", e200100
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17206 cCL("sufsp", e200120
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17207 cCL("sufsm", e200140
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17208 cCL("sufsz", e200160
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17209 cCL("sufd", e200180
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17210 cCL("sufdp", e2001a0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17211 cCL("sufdm", e2001c0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17212 cCL("sufdz", e2001e0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17213 cCL("sufe", e280100
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17214 cCL("sufep", e280120
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17215 cCL("sufem", e280140
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17216 cCL("sufez", e280160
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17218 cCL("rsfs", e300100
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17219 cCL("rsfsp", e300120
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17220 cCL("rsfsm", e300140
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17221 cCL("rsfsz", e300160
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17222 cCL("rsfd", e300180
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17223 cCL("rsfdp", e3001a0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17224 cCL("rsfdm", e3001c0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17225 cCL("rsfdz", e3001e0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17226 cCL("rsfe", e380100
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17227 cCL("rsfep", e380120
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17228 cCL("rsfem", e380140
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17229 cCL("rsfez", e380160
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17231 cCL("mufs", e100100
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17232 cCL("mufsp", e100120
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17233 cCL("mufsm", e100140
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17234 cCL("mufsz", e100160
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17235 cCL("mufd", e100180
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17236 cCL("mufdp", e1001a0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17237 cCL("mufdm", e1001c0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17238 cCL("mufdz", e1001e0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17239 cCL("mufe", e180100
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17240 cCL("mufep", e180120
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17241 cCL("mufem", e180140
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17242 cCL("mufez", e180160
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17244 cCL("dvfs", e400100
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17245 cCL("dvfsp", e400120
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17246 cCL("dvfsm", e400140
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17247 cCL("dvfsz", e400160
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17248 cCL("dvfd", e400180
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17249 cCL("dvfdp", e4001a0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17250 cCL("dvfdm", e4001c0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17251 cCL("dvfdz", e4001e0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17252 cCL("dvfe", e480100
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17253 cCL("dvfep", e480120
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17254 cCL("dvfem", e480140
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17255 cCL("dvfez", e480160
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17257 cCL("rdfs", e500100
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17258 cCL("rdfsp", e500120
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17259 cCL("rdfsm", e500140
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17260 cCL("rdfsz", e500160
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17261 cCL("rdfd", e500180
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17262 cCL("rdfdp", e5001a0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17263 cCL("rdfdm", e5001c0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17264 cCL("rdfdz", e5001e0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17265 cCL("rdfe", e580100
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17266 cCL("rdfep", e580120
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17267 cCL("rdfem", e580140
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17268 cCL("rdfez", e580160
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17270 cCL("pows", e600100
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17271 cCL("powsp", e600120
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17272 cCL("powsm", e600140
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17273 cCL("powsz", e600160
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17274 cCL("powd", e600180
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17275 cCL("powdp", e6001a0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17276 cCL("powdm", e6001c0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17277 cCL("powdz", e6001e0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17278 cCL("powe", e680100
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17279 cCL("powep", e680120
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17280 cCL("powem", e680140
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17281 cCL("powez", e680160
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17283 cCL("rpws", e700100
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17284 cCL("rpwsp", e700120
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17285 cCL("rpwsm", e700140
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17286 cCL("rpwsz", e700160
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17287 cCL("rpwd", e700180
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17288 cCL("rpwdp", e7001a0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17289 cCL("rpwdm", e7001c0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17290 cCL("rpwdz", e7001e0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17291 cCL("rpwe", e780100
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17292 cCL("rpwep", e780120
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17293 cCL("rpwem", e780140
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17294 cCL("rpwez", e780160
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17296 cCL("rmfs", e800100
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17297 cCL("rmfsp", e800120
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17298 cCL("rmfsm", e800140
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17299 cCL("rmfsz", e800160
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17300 cCL("rmfd", e800180
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17301 cCL("rmfdp", e8001a0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17302 cCL("rmfdm", e8001c0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17303 cCL("rmfdz", e8001e0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17304 cCL("rmfe", e880100
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17305 cCL("rmfep", e880120
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17306 cCL("rmfem", e880140
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17307 cCL("rmfez", e880160
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17309 cCL("fmls", e900100
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17310 cCL("fmlsp", e900120
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17311 cCL("fmlsm", e900140
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17312 cCL("fmlsz", e900160
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17313 cCL("fmld", e900180
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17314 cCL("fmldp", e9001a0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17315 cCL("fmldm", e9001c0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17316 cCL("fmldz", e9001e0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17317 cCL("fmle", e980100
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17318 cCL("fmlep", e980120
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17319 cCL("fmlem", e980140
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17320 cCL("fmlez", e980160
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17322 cCL("fdvs", ea00100
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17323 cCL("fdvsp", ea00120
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17324 cCL("fdvsm", ea00140
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17325 cCL("fdvsz", ea00160
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17326 cCL("fdvd", ea00180
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17327 cCL("fdvdp", ea001a0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17328 cCL("fdvdm", ea001c0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17329 cCL("fdvdz", ea001e0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17330 cCL("fdve", ea80100
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17331 cCL("fdvep", ea80120
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17332 cCL("fdvem", ea80140
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17333 cCL("fdvez", ea80160
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17335 cCL("frds", eb00100
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17336 cCL("frdsp", eb00120
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17337 cCL("frdsm", eb00140
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17338 cCL("frdsz", eb00160
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17339 cCL("frdd", eb00180
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17340 cCL("frddp", eb001a0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17341 cCL("frddm", eb001c0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17342 cCL("frddz", eb001e0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17343 cCL("frde", eb80100
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17344 cCL("frdep", eb80120
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17345 cCL("frdem", eb80140
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17346 cCL("frdez", eb80160
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17348 cCL("pols", ec00100
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17349 cCL("polsp", ec00120
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17350 cCL("polsm", ec00140
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17351 cCL("polsz", ec00160
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17352 cCL("pold", ec00180
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17353 cCL("poldp", ec001a0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17354 cCL("poldm", ec001c0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17355 cCL("poldz", ec001e0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17356 cCL("pole", ec80100
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17357 cCL("polep", ec80120
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17358 cCL("polem", ec80140
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17359 cCL("polez", ec80160
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
17361 cCE("cmf", e90f110
, 2, (RF
, RF_IF
), fpa_cmp
),
17362 C3E("cmfe", ed0f110
, 2, (RF
, RF_IF
), fpa_cmp
),
17363 cCE("cnf", eb0f110
, 2, (RF
, RF_IF
), fpa_cmp
),
17364 C3E("cnfe", ef0f110
, 2, (RF
, RF_IF
), fpa_cmp
),
17366 cCL("flts", e000110
, 2, (RF
, RR
), rn_rd
),
17367 cCL("fltsp", e000130
, 2, (RF
, RR
), rn_rd
),
17368 cCL("fltsm", e000150
, 2, (RF
, RR
), rn_rd
),
17369 cCL("fltsz", e000170
, 2, (RF
, RR
), rn_rd
),
17370 cCL("fltd", e000190
, 2, (RF
, RR
), rn_rd
),
17371 cCL("fltdp", e0001b0
, 2, (RF
, RR
), rn_rd
),
17372 cCL("fltdm", e0001d0
, 2, (RF
, RR
), rn_rd
),
17373 cCL("fltdz", e0001f0
, 2, (RF
, RR
), rn_rd
),
17374 cCL("flte", e080110
, 2, (RF
, RR
), rn_rd
),
17375 cCL("fltep", e080130
, 2, (RF
, RR
), rn_rd
),
17376 cCL("fltem", e080150
, 2, (RF
, RR
), rn_rd
),
17377 cCL("fltez", e080170
, 2, (RF
, RR
), rn_rd
),
17379 /* The implementation of the FIX instruction is broken on some
17380 assemblers, in that it accepts a precision specifier as well as a
17381 rounding specifier, despite the fact that this is meaningless.
17382 To be more compatible, we accept it as well, though of course it
17383 does not set any bits. */
17384 cCE("fix", e100110
, 2, (RR
, RF
), rd_rm
),
17385 cCL("fixp", e100130
, 2, (RR
, RF
), rd_rm
),
17386 cCL("fixm", e100150
, 2, (RR
, RF
), rd_rm
),
17387 cCL("fixz", e100170
, 2, (RR
, RF
), rd_rm
),
17388 cCL("fixsp", e100130
, 2, (RR
, RF
), rd_rm
),
17389 cCL("fixsm", e100150
, 2, (RR
, RF
), rd_rm
),
17390 cCL("fixsz", e100170
, 2, (RR
, RF
), rd_rm
),
17391 cCL("fixdp", e100130
, 2, (RR
, RF
), rd_rm
),
17392 cCL("fixdm", e100150
, 2, (RR
, RF
), rd_rm
),
17393 cCL("fixdz", e100170
, 2, (RR
, RF
), rd_rm
),
17394 cCL("fixep", e100130
, 2, (RR
, RF
), rd_rm
),
17395 cCL("fixem", e100150
, 2, (RR
, RF
), rd_rm
),
17396 cCL("fixez", e100170
, 2, (RR
, RF
), rd_rm
),
17398 /* Instructions that were new with the real FPA, call them V2. */
17400 #define ARM_VARIANT & fpu_fpa_ext_v2
17402 cCE("lfm", c100200
, 3, (RF
, I4b
, ADDR
), fpa_ldmstm
),
17403 cCL("lfmfd", c900200
, 3, (RF
, I4b
, ADDR
), fpa_ldmstm
),
17404 cCL("lfmea", d100200
, 3, (RF
, I4b
, ADDR
), fpa_ldmstm
),
17405 cCE("sfm", c000200
, 3, (RF
, I4b
, ADDR
), fpa_ldmstm
),
17406 cCL("sfmfd", d000200
, 3, (RF
, I4b
, ADDR
), fpa_ldmstm
),
17407 cCL("sfmea", c800200
, 3, (RF
, I4b
, ADDR
), fpa_ldmstm
),
17410 #define ARM_VARIANT & fpu_vfp_ext_v1xd /* VFP V1xD (single precision). */
17412 /* Moves and type conversions. */
17413 cCE("fcpys", eb00a40
, 2, (RVS
, RVS
), vfp_sp_monadic
),
17414 cCE("fmrs", e100a10
, 2, (RR
, RVS
), vfp_reg_from_sp
),
17415 cCE("fmsr", e000a10
, 2, (RVS
, RR
), vfp_sp_from_reg
),
17416 cCE("fmstat", ef1fa10
, 0, (), noargs
),
17417 cCE("vmrs", ef10a10
, 2, (APSR_RR
, RVC
), vmrs
),
17418 cCE("vmsr", ee10a10
, 2, (RVC
, RR
), vmsr
),
17419 cCE("fsitos", eb80ac0
, 2, (RVS
, RVS
), vfp_sp_monadic
),
17420 cCE("fuitos", eb80a40
, 2, (RVS
, RVS
), vfp_sp_monadic
),
17421 cCE("ftosis", ebd0a40
, 2, (RVS
, RVS
), vfp_sp_monadic
),
17422 cCE("ftosizs", ebd0ac0
, 2, (RVS
, RVS
), vfp_sp_monadic
),
17423 cCE("ftouis", ebc0a40
, 2, (RVS
, RVS
), vfp_sp_monadic
),
17424 cCE("ftouizs", ebc0ac0
, 2, (RVS
, RVS
), vfp_sp_monadic
),
17425 cCE("fmrx", ef00a10
, 2, (RR
, RVC
), rd_rn
),
17426 cCE("fmxr", ee00a10
, 2, (RVC
, RR
), rn_rd
),
17428 /* Memory operations. */
17429 cCE("flds", d100a00
, 2, (RVS
, ADDRGLDC
), vfp_sp_ldst
),
17430 cCE("fsts", d000a00
, 2, (RVS
, ADDRGLDC
), vfp_sp_ldst
),
17431 cCE("fldmias", c900a00
, 2, (RRw
, VRSLST
), vfp_sp_ldstmia
),
17432 cCE("fldmfds", c900a00
, 2, (RRw
, VRSLST
), vfp_sp_ldstmia
),
17433 cCE("fldmdbs", d300a00
, 2, (RRw
, VRSLST
), vfp_sp_ldstmdb
),
17434 cCE("fldmeas", d300a00
, 2, (RRw
, VRSLST
), vfp_sp_ldstmdb
),
17435 cCE("fldmiax", c900b00
, 2, (RRw
, VRDLST
), vfp_xp_ldstmia
),
17436 cCE("fldmfdx", c900b00
, 2, (RRw
, VRDLST
), vfp_xp_ldstmia
),
17437 cCE("fldmdbx", d300b00
, 2, (RRw
, VRDLST
), vfp_xp_ldstmdb
),
17438 cCE("fldmeax", d300b00
, 2, (RRw
, VRDLST
), vfp_xp_ldstmdb
),
17439 cCE("fstmias", c800a00
, 2, (RRw
, VRSLST
), vfp_sp_ldstmia
),
17440 cCE("fstmeas", c800a00
, 2, (RRw
, VRSLST
), vfp_sp_ldstmia
),
17441 cCE("fstmdbs", d200a00
, 2, (RRw
, VRSLST
), vfp_sp_ldstmdb
),
17442 cCE("fstmfds", d200a00
, 2, (RRw
, VRSLST
), vfp_sp_ldstmdb
),
17443 cCE("fstmiax", c800b00
, 2, (RRw
, VRDLST
), vfp_xp_ldstmia
),
17444 cCE("fstmeax", c800b00
, 2, (RRw
, VRDLST
), vfp_xp_ldstmia
),
17445 cCE("fstmdbx", d200b00
, 2, (RRw
, VRDLST
), vfp_xp_ldstmdb
),
17446 cCE("fstmfdx", d200b00
, 2, (RRw
, VRDLST
), vfp_xp_ldstmdb
),
17448 /* Monadic operations. */
17449 cCE("fabss", eb00ac0
, 2, (RVS
, RVS
), vfp_sp_monadic
),
17450 cCE("fnegs", eb10a40
, 2, (RVS
, RVS
), vfp_sp_monadic
),
17451 cCE("fsqrts", eb10ac0
, 2, (RVS
, RVS
), vfp_sp_monadic
),
17453 /* Dyadic operations. */
17454 cCE("fadds", e300a00
, 3, (RVS
, RVS
, RVS
), vfp_sp_dyadic
),
17455 cCE("fsubs", e300a40
, 3, (RVS
, RVS
, RVS
), vfp_sp_dyadic
),
17456 cCE("fmuls", e200a00
, 3, (RVS
, RVS
, RVS
), vfp_sp_dyadic
),
17457 cCE("fdivs", e800a00
, 3, (RVS
, RVS
, RVS
), vfp_sp_dyadic
),
17458 cCE("fmacs", e000a00
, 3, (RVS
, RVS
, RVS
), vfp_sp_dyadic
),
17459 cCE("fmscs", e100a00
, 3, (RVS
, RVS
, RVS
), vfp_sp_dyadic
),
17460 cCE("fnmuls", e200a40
, 3, (RVS
, RVS
, RVS
), vfp_sp_dyadic
),
17461 cCE("fnmacs", e000a40
, 3, (RVS
, RVS
, RVS
), vfp_sp_dyadic
),
17462 cCE("fnmscs", e100a40
, 3, (RVS
, RVS
, RVS
), vfp_sp_dyadic
),
17465 cCE("fcmps", eb40a40
, 2, (RVS
, RVS
), vfp_sp_monadic
),
17466 cCE("fcmpzs", eb50a40
, 1, (RVS
), vfp_sp_compare_z
),
17467 cCE("fcmpes", eb40ac0
, 2, (RVS
, RVS
), vfp_sp_monadic
),
17468 cCE("fcmpezs", eb50ac0
, 1, (RVS
), vfp_sp_compare_z
),
17470 /* Double precision load/store are still present on single precision
17471 implementations. */
17472 cCE("fldd", d100b00
, 2, (RVD
, ADDRGLDC
), vfp_dp_ldst
),
17473 cCE("fstd", d000b00
, 2, (RVD
, ADDRGLDC
), vfp_dp_ldst
),
17474 cCE("fldmiad", c900b00
, 2, (RRw
, VRDLST
), vfp_dp_ldstmia
),
17475 cCE("fldmfdd", c900b00
, 2, (RRw
, VRDLST
), vfp_dp_ldstmia
),
17476 cCE("fldmdbd", d300b00
, 2, (RRw
, VRDLST
), vfp_dp_ldstmdb
),
17477 cCE("fldmead", d300b00
, 2, (RRw
, VRDLST
), vfp_dp_ldstmdb
),
17478 cCE("fstmiad", c800b00
, 2, (RRw
, VRDLST
), vfp_dp_ldstmia
),
17479 cCE("fstmead", c800b00
, 2, (RRw
, VRDLST
), vfp_dp_ldstmia
),
17480 cCE("fstmdbd", d200b00
, 2, (RRw
, VRDLST
), vfp_dp_ldstmdb
),
17481 cCE("fstmfdd", d200b00
, 2, (RRw
, VRDLST
), vfp_dp_ldstmdb
),
17484 #define ARM_VARIANT & fpu_vfp_ext_v1 /* VFP V1 (Double precision). */
17486 /* Moves and type conversions. */
17487 cCE("fcpyd", eb00b40
, 2, (RVD
, RVD
), vfp_dp_rd_rm
),
17488 cCE("fcvtds", eb70ac0
, 2, (RVD
, RVS
), vfp_dp_sp_cvt
),
17489 cCE("fcvtsd", eb70bc0
, 2, (RVS
, RVD
), vfp_sp_dp_cvt
),
17490 cCE("fmdhr", e200b10
, 2, (RVD
, RR
), vfp_dp_rn_rd
),
17491 cCE("fmdlr", e000b10
, 2, (RVD
, RR
), vfp_dp_rn_rd
),
17492 cCE("fmrdh", e300b10
, 2, (RR
, RVD
), vfp_dp_rd_rn
),
17493 cCE("fmrdl", e100b10
, 2, (RR
, RVD
), vfp_dp_rd_rn
),
17494 cCE("fsitod", eb80bc0
, 2, (RVD
, RVS
), vfp_dp_sp_cvt
),
17495 cCE("fuitod", eb80b40
, 2, (RVD
, RVS
), vfp_dp_sp_cvt
),
17496 cCE("ftosid", ebd0b40
, 2, (RVS
, RVD
), vfp_sp_dp_cvt
),
17497 cCE("ftosizd", ebd0bc0
, 2, (RVS
, RVD
), vfp_sp_dp_cvt
),
17498 cCE("ftouid", ebc0b40
, 2, (RVS
, RVD
), vfp_sp_dp_cvt
),
17499 cCE("ftouizd", ebc0bc0
, 2, (RVS
, RVD
), vfp_sp_dp_cvt
),
17501 /* Monadic operations. */
17502 cCE("fabsd", eb00bc0
, 2, (RVD
, RVD
), vfp_dp_rd_rm
),
17503 cCE("fnegd", eb10b40
, 2, (RVD
, RVD
), vfp_dp_rd_rm
),
17504 cCE("fsqrtd", eb10bc0
, 2, (RVD
, RVD
), vfp_dp_rd_rm
),
17506 /* Dyadic operations. */
17507 cCE("faddd", e300b00
, 3, (RVD
, RVD
, RVD
), vfp_dp_rd_rn_rm
),
17508 cCE("fsubd", e300b40
, 3, (RVD
, RVD
, RVD
), vfp_dp_rd_rn_rm
),
17509 cCE("fmuld", e200b00
, 3, (RVD
, RVD
, RVD
), vfp_dp_rd_rn_rm
),
17510 cCE("fdivd", e800b00
, 3, (RVD
, RVD
, RVD
), vfp_dp_rd_rn_rm
),
17511 cCE("fmacd", e000b00
, 3, (RVD
, RVD
, RVD
), vfp_dp_rd_rn_rm
),
17512 cCE("fmscd", e100b00
, 3, (RVD
, RVD
, RVD
), vfp_dp_rd_rn_rm
),
17513 cCE("fnmuld", e200b40
, 3, (RVD
, RVD
, RVD
), vfp_dp_rd_rn_rm
),
17514 cCE("fnmacd", e000b40
, 3, (RVD
, RVD
, RVD
), vfp_dp_rd_rn_rm
),
17515 cCE("fnmscd", e100b40
, 3, (RVD
, RVD
, RVD
), vfp_dp_rd_rn_rm
),
17518 cCE("fcmpd", eb40b40
, 2, (RVD
, RVD
), vfp_dp_rd_rm
),
17519 cCE("fcmpzd", eb50b40
, 1, (RVD
), vfp_dp_rd
),
17520 cCE("fcmped", eb40bc0
, 2, (RVD
, RVD
), vfp_dp_rd_rm
),
17521 cCE("fcmpezd", eb50bc0
, 1, (RVD
), vfp_dp_rd
),
17524 #define ARM_VARIANT & fpu_vfp_ext_v2
17526 cCE("fmsrr", c400a10
, 3, (VRSLST
, RR
, RR
), vfp_sp2_from_reg2
),
17527 cCE("fmrrs", c500a10
, 3, (RR
, RR
, VRSLST
), vfp_reg2_from_sp2
),
17528 cCE("fmdrr", c400b10
, 3, (RVD
, RR
, RR
), vfp_dp_rm_rd_rn
),
17529 cCE("fmrrd", c500b10
, 3, (RR
, RR
, RVD
), vfp_dp_rd_rn_rm
),
17531 /* Instructions which may belong to either the Neon or VFP instruction sets.
17532 Individual encoder functions perform additional architecture checks. */
17534 #define ARM_VARIANT & fpu_vfp_ext_v1xd
17535 #undef THUMB_VARIANT
17536 #define THUMB_VARIANT & fpu_vfp_ext_v1xd
17538 /* These mnemonics are unique to VFP. */
17539 NCE(vsqrt
, 0, 2, (RVSD
, RVSD
), vfp_nsyn_sqrt
),
17540 NCE(vdiv
, 0, 3, (RVSD
, RVSD
, RVSD
), vfp_nsyn_div
),
17541 nCE(vnmul
, _vnmul
, 3, (RVSD
, RVSD
, RVSD
), vfp_nsyn_nmul
),
17542 nCE(vnmla
, _vnmla
, 3, (RVSD
, RVSD
, RVSD
), vfp_nsyn_nmul
),
17543 nCE(vnmls
, _vnmls
, 3, (RVSD
, RVSD
, RVSD
), vfp_nsyn_nmul
),
17544 nCE(vcmp
, _vcmp
, 2, (RVSD
, RVSD_I0
), vfp_nsyn_cmp
),
17545 nCE(vcmpe
, _vcmpe
, 2, (RVSD
, RVSD_I0
), vfp_nsyn_cmp
),
17546 NCE(vpush
, 0, 1, (VRSDLST
), vfp_nsyn_push
),
17547 NCE(vpop
, 0, 1, (VRSDLST
), vfp_nsyn_pop
),
17548 NCE(vcvtz
, 0, 2, (RVSD
, RVSD
), vfp_nsyn_cvtz
),
17550 /* Mnemonics shared by Neon and VFP. */
17551 nCEF(vmul
, _vmul
, 3, (RNSDQ
, oRNSDQ
, RNSDQ_RNSC
), neon_mul
),
17552 nCEF(vmla
, _vmla
, 3, (RNSDQ
, oRNSDQ
, RNSDQ_RNSC
), neon_mac_maybe_scalar
),
17553 nCEF(vmls
, _vmls
, 3, (RNSDQ
, oRNSDQ
, RNSDQ_RNSC
), neon_mac_maybe_scalar
),
17555 nCEF(vadd
, _vadd
, 3, (RNSDQ
, oRNSDQ
, RNSDQ
), neon_addsub_if_i
),
17556 nCEF(vsub
, _vsub
, 3, (RNSDQ
, oRNSDQ
, RNSDQ
), neon_addsub_if_i
),
17558 NCEF(vabs
, 1b10300
, 2, (RNSDQ
, RNSDQ
), neon_abs_neg
),
17559 NCEF(vneg
, 1b10380
, 2, (RNSDQ
, RNSDQ
), neon_abs_neg
),
17561 NCE(vldm
, c900b00
, 2, (RRw
, VRSDLST
), neon_ldm_stm
),
17562 NCE(vldmia
, c900b00
, 2, (RRw
, VRSDLST
), neon_ldm_stm
),
17563 NCE(vldmdb
, d100b00
, 2, (RRw
, VRSDLST
), neon_ldm_stm
),
17564 NCE(vstm
, c800b00
, 2, (RRw
, VRSDLST
), neon_ldm_stm
),
17565 NCE(vstmia
, c800b00
, 2, (RRw
, VRSDLST
), neon_ldm_stm
),
17566 NCE(vstmdb
, d000b00
, 2, (RRw
, VRSDLST
), neon_ldm_stm
),
17567 NCE(vldr
, d100b00
, 2, (RVSD
, ADDRGLDC
), neon_ldr_str
),
17568 NCE(vstr
, d000b00
, 2, (RVSD
, ADDRGLDC
), neon_ldr_str
),
17570 nCEF(vcvt
, _vcvt
, 3, (RNSDQ
, RNSDQ
, oI32b
), neon_cvt
),
17571 nCEF(vcvtr
, _vcvt
, 2, (RNSDQ
, RNSDQ
), neon_cvtr
),
17572 nCEF(vcvtb
, _vcvt
, 2, (RVS
, RVS
), neon_cvtb
),
17573 nCEF(vcvtt
, _vcvt
, 2, (RVS
, RVS
), neon_cvtt
),
17576 /* NOTE: All VMOV encoding is special-cased! */
17577 NCE(vmov
, 0, 1, (VMOV
), neon_mov
),
17578 NCE(vmovq
, 0, 1, (VMOV
), neon_mov
),
17580 #undef THUMB_VARIANT
17581 #define THUMB_VARIANT & fpu_neon_ext_v1
17583 #define ARM_VARIANT & fpu_neon_ext_v1
17585 /* Data processing with three registers of the same length. */
17586 /* integer ops, valid types S8 S16 S32 U8 U16 U32. */
17587 NUF(vaba
, 0000710, 3, (RNDQ
, RNDQ
, RNDQ
), neon_dyadic_i_su
),
17588 NUF(vabaq
, 0000710, 3, (RNQ
, RNQ
, RNQ
), neon_dyadic_i_su
),
17589 NUF(vhadd
, 0000000, 3, (RNDQ
, oRNDQ
, RNDQ
), neon_dyadic_i_su
),
17590 NUF(vhaddq
, 0000000, 3, (RNQ
, oRNQ
, RNQ
), neon_dyadic_i_su
),
17591 NUF(vrhadd
, 0000100, 3, (RNDQ
, oRNDQ
, RNDQ
), neon_dyadic_i_su
),
17592 NUF(vrhaddq
, 0000100, 3, (RNQ
, oRNQ
, RNQ
), neon_dyadic_i_su
),
17593 NUF(vhsub
, 0000200, 3, (RNDQ
, oRNDQ
, RNDQ
), neon_dyadic_i_su
),
17594 NUF(vhsubq
, 0000200, 3, (RNQ
, oRNQ
, RNQ
), neon_dyadic_i_su
),
17595 /* integer ops, valid types S8 S16 S32 S64 U8 U16 U32 U64. */
17596 NUF(vqadd
, 0000010, 3, (RNDQ
, oRNDQ
, RNDQ
), neon_dyadic_i64_su
),
17597 NUF(vqaddq
, 0000010, 3, (RNQ
, oRNQ
, RNQ
), neon_dyadic_i64_su
),
17598 NUF(vqsub
, 0000210, 3, (RNDQ
, oRNDQ
, RNDQ
), neon_dyadic_i64_su
),
17599 NUF(vqsubq
, 0000210, 3, (RNQ
, oRNQ
, RNQ
), neon_dyadic_i64_su
),
17600 NUF(vrshl
, 0000500, 3, (RNDQ
, oRNDQ
, RNDQ
), neon_rshl
),
17601 NUF(vrshlq
, 0000500, 3, (RNQ
, oRNQ
, RNQ
), neon_rshl
),
17602 NUF(vqrshl
, 0000510, 3, (RNDQ
, oRNDQ
, RNDQ
), neon_rshl
),
17603 NUF(vqrshlq
, 0000510, 3, (RNQ
, oRNQ
, RNQ
), neon_rshl
),
17604 /* If not immediate, fall back to neon_dyadic_i64_su.
17605 shl_imm should accept I8 I16 I32 I64,
17606 qshl_imm should accept S8 S16 S32 S64 U8 U16 U32 U64. */
17607 nUF(vshl
, _vshl
, 3, (RNDQ
, oRNDQ
, RNDQ_I63b
), neon_shl_imm
),
17608 nUF(vshlq
, _vshl
, 3, (RNQ
, oRNQ
, RNDQ_I63b
), neon_shl_imm
),
17609 nUF(vqshl
, _vqshl
, 3, (RNDQ
, oRNDQ
, RNDQ_I63b
), neon_qshl_imm
),
17610 nUF(vqshlq
, _vqshl
, 3, (RNQ
, oRNQ
, RNDQ_I63b
), neon_qshl_imm
),
17611 /* Logic ops, types optional & ignored. */
17612 nUF(vand
, _vand
, 3, (RNDQ
, oRNDQ
, RNDQ_Ibig
), neon_logic
),
17613 nUF(vandq
, _vand
, 3, (RNQ
, oRNQ
, RNDQ_Ibig
), neon_logic
),
17614 nUF(vbic
, _vbic
, 3, (RNDQ
, oRNDQ
, RNDQ_Ibig
), neon_logic
),
17615 nUF(vbicq
, _vbic
, 3, (RNQ
, oRNQ
, RNDQ_Ibig
), neon_logic
),
17616 nUF(vorr
, _vorr
, 3, (RNDQ
, oRNDQ
, RNDQ_Ibig
), neon_logic
),
17617 nUF(vorrq
, _vorr
, 3, (RNQ
, oRNQ
, RNDQ_Ibig
), neon_logic
),
17618 nUF(vorn
, _vorn
, 3, (RNDQ
, oRNDQ
, RNDQ_Ibig
), neon_logic
),
17619 nUF(vornq
, _vorn
, 3, (RNQ
, oRNQ
, RNDQ_Ibig
), neon_logic
),
17620 nUF(veor
, _veor
, 3, (RNDQ
, oRNDQ
, RNDQ
), neon_logic
),
17621 nUF(veorq
, _veor
, 3, (RNQ
, oRNQ
, RNQ
), neon_logic
),
17622 /* Bitfield ops, untyped. */
17623 NUF(vbsl
, 1100110, 3, (RNDQ
, RNDQ
, RNDQ
), neon_bitfield
),
17624 NUF(vbslq
, 1100110, 3, (RNQ
, RNQ
, RNQ
), neon_bitfield
),
17625 NUF(vbit
, 1200110, 3, (RNDQ
, RNDQ
, RNDQ
), neon_bitfield
),
17626 NUF(vbitq
, 1200110, 3, (RNQ
, RNQ
, RNQ
), neon_bitfield
),
17627 NUF(vbif
, 1300110, 3, (RNDQ
, RNDQ
, RNDQ
), neon_bitfield
),
17628 NUF(vbifq
, 1300110, 3, (RNQ
, RNQ
, RNQ
), neon_bitfield
),
17629 /* Int and float variants, types S8 S16 S32 U8 U16 U32 F32. */
17630 nUF(vabd
, _vabd
, 3, (RNDQ
, oRNDQ
, RNDQ
), neon_dyadic_if_su
),
17631 nUF(vabdq
, _vabd
, 3, (RNQ
, oRNQ
, RNQ
), neon_dyadic_if_su
),
17632 nUF(vmax
, _vmax
, 3, (RNDQ
, oRNDQ
, RNDQ
), neon_dyadic_if_su
),
17633 nUF(vmaxq
, _vmax
, 3, (RNQ
, oRNQ
, RNQ
), neon_dyadic_if_su
),
17634 nUF(vmin
, _vmin
, 3, (RNDQ
, oRNDQ
, RNDQ
), neon_dyadic_if_su
),
17635 nUF(vminq
, _vmin
, 3, (RNQ
, oRNQ
, RNQ
), neon_dyadic_if_su
),
17636 /* Comparisons. Types S8 S16 S32 U8 U16 U32 F32. Non-immediate versions fall
17637 back to neon_dyadic_if_su. */
17638 nUF(vcge
, _vcge
, 3, (RNDQ
, oRNDQ
, RNDQ_I0
), neon_cmp
),
17639 nUF(vcgeq
, _vcge
, 3, (RNQ
, oRNQ
, RNDQ_I0
), neon_cmp
),
17640 nUF(vcgt
, _vcgt
, 3, (RNDQ
, oRNDQ
, RNDQ_I0
), neon_cmp
),
17641 nUF(vcgtq
, _vcgt
, 3, (RNQ
, oRNQ
, RNDQ_I0
), neon_cmp
),
17642 nUF(vclt
, _vclt
, 3, (RNDQ
, oRNDQ
, RNDQ_I0
), neon_cmp_inv
),
17643 nUF(vcltq
, _vclt
, 3, (RNQ
, oRNQ
, RNDQ_I0
), neon_cmp_inv
),
17644 nUF(vcle
, _vcle
, 3, (RNDQ
, oRNDQ
, RNDQ_I0
), neon_cmp_inv
),
17645 nUF(vcleq
, _vcle
, 3, (RNQ
, oRNQ
, RNDQ_I0
), neon_cmp_inv
),
17646 /* Comparison. Type I8 I16 I32 F32. */
17647 nUF(vceq
, _vceq
, 3, (RNDQ
, oRNDQ
, RNDQ_I0
), neon_ceq
),
17648 nUF(vceqq
, _vceq
, 3, (RNQ
, oRNQ
, RNDQ_I0
), neon_ceq
),
17649 /* As above, D registers only. */
17650 nUF(vpmax
, _vpmax
, 3, (RND
, oRND
, RND
), neon_dyadic_if_su_d
),
17651 nUF(vpmin
, _vpmin
, 3, (RND
, oRND
, RND
), neon_dyadic_if_su_d
),
17652 /* Int and float variants, signedness unimportant. */
17653 nUF(vmlaq
, _vmla
, 3, (RNQ
, oRNQ
, RNDQ_RNSC
), neon_mac_maybe_scalar
),
17654 nUF(vmlsq
, _vmls
, 3, (RNQ
, oRNQ
, RNDQ_RNSC
), neon_mac_maybe_scalar
),
17655 nUF(vpadd
, _vpadd
, 3, (RND
, oRND
, RND
), neon_dyadic_if_i_d
),
17656 /* Add/sub take types I8 I16 I32 I64 F32. */
17657 nUF(vaddq
, _vadd
, 3, (RNQ
, oRNQ
, RNQ
), neon_addsub_if_i
),
17658 nUF(vsubq
, _vsub
, 3, (RNQ
, oRNQ
, RNQ
), neon_addsub_if_i
),
17659 /* vtst takes sizes 8, 16, 32. */
17660 NUF(vtst
, 0000810, 3, (RNDQ
, oRNDQ
, RNDQ
), neon_tst
),
17661 NUF(vtstq
, 0000810, 3, (RNQ
, oRNQ
, RNQ
), neon_tst
),
17662 /* VMUL takes I8 I16 I32 F32 P8. */
17663 nUF(vmulq
, _vmul
, 3, (RNQ
, oRNQ
, RNDQ_RNSC
), neon_mul
),
17664 /* VQD{R}MULH takes S16 S32. */
17665 nUF(vqdmulh
, _vqdmulh
, 3, (RNDQ
, oRNDQ
, RNDQ_RNSC
), neon_qdmulh
),
17666 nUF(vqdmulhq
, _vqdmulh
, 3, (RNQ
, oRNQ
, RNDQ_RNSC
), neon_qdmulh
),
17667 nUF(vqrdmulh
, _vqrdmulh
, 3, (RNDQ
, oRNDQ
, RNDQ_RNSC
), neon_qdmulh
),
17668 nUF(vqrdmulhq
, _vqrdmulh
, 3, (RNQ
, oRNQ
, RNDQ_RNSC
), neon_qdmulh
),
17669 NUF(vacge
, 0000e10
, 3, (RNDQ
, oRNDQ
, RNDQ
), neon_fcmp_absolute
),
17670 NUF(vacgeq
, 0000e10
, 3, (RNQ
, oRNQ
, RNQ
), neon_fcmp_absolute
),
17671 NUF(vacgt
, 0200e10
, 3, (RNDQ
, oRNDQ
, RNDQ
), neon_fcmp_absolute
),
17672 NUF(vacgtq
, 0200e10
, 3, (RNQ
, oRNQ
, RNQ
), neon_fcmp_absolute
),
17673 NUF(vaclt
, 0200e10
, 3, (RNDQ
, oRNDQ
, RNDQ
), neon_fcmp_absolute_inv
),
17674 NUF(vacltq
, 0200e10
, 3, (RNQ
, oRNQ
, RNQ
), neon_fcmp_absolute_inv
),
17675 NUF(vacle
, 0000e10
, 3, (RNDQ
, oRNDQ
, RNDQ
), neon_fcmp_absolute_inv
),
17676 NUF(vacleq
, 0000e10
, 3, (RNQ
, oRNQ
, RNQ
), neon_fcmp_absolute_inv
),
17677 NUF(vrecps
, 0000f10
, 3, (RNDQ
, oRNDQ
, RNDQ
), neon_step
),
17678 NUF(vrecpsq
, 0000f10
, 3, (RNQ
, oRNQ
, RNQ
), neon_step
),
17679 NUF(vrsqrts
, 0200f10
, 3, (RNDQ
, oRNDQ
, RNDQ
), neon_step
),
17680 NUF(vrsqrtsq
, 0200f10
, 3, (RNQ
, oRNQ
, RNQ
), neon_step
),
17682 /* Two address, int/float. Types S8 S16 S32 F32. */
17683 NUF(vabsq
, 1b10300
, 2, (RNQ
, RNQ
), neon_abs_neg
),
17684 NUF(vnegq
, 1b10380
, 2, (RNQ
, RNQ
), neon_abs_neg
),
17686 /* Data processing with two registers and a shift amount. */
17687 /* Right shifts, and variants with rounding.
17688 Types accepted S8 S16 S32 S64 U8 U16 U32 U64. */
17689 NUF(vshr
, 0800010, 3, (RNDQ
, oRNDQ
, I64z
), neon_rshift_round_imm
),
17690 NUF(vshrq
, 0800010, 3, (RNQ
, oRNQ
, I64z
), neon_rshift_round_imm
),
17691 NUF(vrshr
, 0800210, 3, (RNDQ
, oRNDQ
, I64z
), neon_rshift_round_imm
),
17692 NUF(vrshrq
, 0800210, 3, (RNQ
, oRNQ
, I64z
), neon_rshift_round_imm
),
17693 NUF(vsra
, 0800110, 3, (RNDQ
, oRNDQ
, I64
), neon_rshift_round_imm
),
17694 NUF(vsraq
, 0800110, 3, (RNQ
, oRNQ
, I64
), neon_rshift_round_imm
),
17695 NUF(vrsra
, 0800310, 3, (RNDQ
, oRNDQ
, I64
), neon_rshift_round_imm
),
17696 NUF(vrsraq
, 0800310, 3, (RNQ
, oRNQ
, I64
), neon_rshift_round_imm
),
17697 /* Shift and insert. Sizes accepted 8 16 32 64. */
17698 NUF(vsli
, 1800510, 3, (RNDQ
, oRNDQ
, I63
), neon_sli
),
17699 NUF(vsliq
, 1800510, 3, (RNQ
, oRNQ
, I63
), neon_sli
),
17700 NUF(vsri
, 1800410, 3, (RNDQ
, oRNDQ
, I64
), neon_sri
),
17701 NUF(vsriq
, 1800410, 3, (RNQ
, oRNQ
, I64
), neon_sri
),
17702 /* QSHL{U} immediate accepts S8 S16 S32 S64 U8 U16 U32 U64. */
17703 NUF(vqshlu
, 1800610, 3, (RNDQ
, oRNDQ
, I63
), neon_qshlu_imm
),
17704 NUF(vqshluq
, 1800610, 3, (RNQ
, oRNQ
, I63
), neon_qshlu_imm
),
17705 /* Right shift immediate, saturating & narrowing, with rounding variants.
17706 Types accepted S16 S32 S64 U16 U32 U64. */
17707 NUF(vqshrn
, 0800910, 3, (RND
, RNQ
, I32z
), neon_rshift_sat_narrow
),
17708 NUF(vqrshrn
, 0800950, 3, (RND
, RNQ
, I32z
), neon_rshift_sat_narrow
),
17709 /* As above, unsigned. Types accepted S16 S32 S64. */
17710 NUF(vqshrun
, 0800810, 3, (RND
, RNQ
, I32z
), neon_rshift_sat_narrow_u
),
17711 NUF(vqrshrun
, 0800850, 3, (RND
, RNQ
, I32z
), neon_rshift_sat_narrow_u
),
17712 /* Right shift narrowing. Types accepted I16 I32 I64. */
17713 NUF(vshrn
, 0800810, 3, (RND
, RNQ
, I32z
), neon_rshift_narrow
),
17714 NUF(vrshrn
, 0800850, 3, (RND
, RNQ
, I32z
), neon_rshift_narrow
),
17715 /* Special case. Types S8 S16 S32 U8 U16 U32. Handles max shift variant. */
17716 nUF(vshll
, _vshll
, 3, (RNQ
, RND
, I32
), neon_shll
),
17717 /* CVT with optional immediate for fixed-point variant. */
17718 nUF(vcvtq
, _vcvt
, 3, (RNQ
, RNQ
, oI32b
), neon_cvt
),
17720 nUF(vmvn
, _vmvn
, 2, (RNDQ
, RNDQ_Ibig
), neon_mvn
),
17721 nUF(vmvnq
, _vmvn
, 2, (RNQ
, RNDQ_Ibig
), neon_mvn
),
17723 /* Data processing, three registers of different lengths. */
17724 /* Dyadic, long insns. Types S8 S16 S32 U8 U16 U32. */
17725 NUF(vabal
, 0800500, 3, (RNQ
, RND
, RND
), neon_abal
),
17726 NUF(vabdl
, 0800700, 3, (RNQ
, RND
, RND
), neon_dyadic_long
),
17727 NUF(vaddl
, 0800000, 3, (RNQ
, RND
, RND
), neon_dyadic_long
),
17728 NUF(vsubl
, 0800200, 3, (RNQ
, RND
, RND
), neon_dyadic_long
),
17729 /* If not scalar, fall back to neon_dyadic_long.
17730 Vector types as above, scalar types S16 S32 U16 U32. */
17731 nUF(vmlal
, _vmlal
, 3, (RNQ
, RND
, RND_RNSC
), neon_mac_maybe_scalar_long
),
17732 nUF(vmlsl
, _vmlsl
, 3, (RNQ
, RND
, RND_RNSC
), neon_mac_maybe_scalar_long
),
17733 /* Dyadic, widening insns. Types S8 S16 S32 U8 U16 U32. */
17734 NUF(vaddw
, 0800100, 3, (RNQ
, oRNQ
, RND
), neon_dyadic_wide
),
17735 NUF(vsubw
, 0800300, 3, (RNQ
, oRNQ
, RND
), neon_dyadic_wide
),
17736 /* Dyadic, narrowing insns. Types I16 I32 I64. */
17737 NUF(vaddhn
, 0800400, 3, (RND
, RNQ
, RNQ
), neon_dyadic_narrow
),
17738 NUF(vraddhn
, 1800400, 3, (RND
, RNQ
, RNQ
), neon_dyadic_narrow
),
17739 NUF(vsubhn
, 0800600, 3, (RND
, RNQ
, RNQ
), neon_dyadic_narrow
),
17740 NUF(vrsubhn
, 1800600, 3, (RND
, RNQ
, RNQ
), neon_dyadic_narrow
),
17741 /* Saturating doubling multiplies. Types S16 S32. */
17742 nUF(vqdmlal
, _vqdmlal
, 3, (RNQ
, RND
, RND_RNSC
), neon_mul_sat_scalar_long
),
17743 nUF(vqdmlsl
, _vqdmlsl
, 3, (RNQ
, RND
, RND_RNSC
), neon_mul_sat_scalar_long
),
17744 nUF(vqdmull
, _vqdmull
, 3, (RNQ
, RND
, RND_RNSC
), neon_mul_sat_scalar_long
),
17745 /* VMULL. Vector types S8 S16 S32 U8 U16 U32 P8, scalar types
17746 S16 S32 U16 U32. */
17747 nUF(vmull
, _vmull
, 3, (RNQ
, RND
, RND_RNSC
), neon_vmull
),
17749 /* Extract. Size 8. */
17750 NUF(vext
, 0b00000, 4, (RNDQ
, oRNDQ
, RNDQ
, I15
), neon_ext
),
17751 NUF(vextq
, 0b00000, 4, (RNQ
, oRNQ
, RNQ
, I15
), neon_ext
),
17753 /* Two registers, miscellaneous. */
17754 /* Reverse. Sizes 8 16 32 (must be < size in opcode). */
17755 NUF(vrev64
, 1b00000
, 2, (RNDQ
, RNDQ
), neon_rev
),
17756 NUF(vrev64q
, 1b00000
, 2, (RNQ
, RNQ
), neon_rev
),
17757 NUF(vrev32
, 1b00080
, 2, (RNDQ
, RNDQ
), neon_rev
),
17758 NUF(vrev32q
, 1b00080
, 2, (RNQ
, RNQ
), neon_rev
),
17759 NUF(vrev16
, 1b00100
, 2, (RNDQ
, RNDQ
), neon_rev
),
17760 NUF(vrev16q
, 1b00100
, 2, (RNQ
, RNQ
), neon_rev
),
17761 /* Vector replicate. Sizes 8 16 32. */
17762 nCE(vdup
, _vdup
, 2, (RNDQ
, RR_RNSC
), neon_dup
),
17763 nCE(vdupq
, _vdup
, 2, (RNQ
, RR_RNSC
), neon_dup
),
17764 /* VMOVL. Types S8 S16 S32 U8 U16 U32. */
17765 NUF(vmovl
, 0800a10
, 2, (RNQ
, RND
), neon_movl
),
17766 /* VMOVN. Types I16 I32 I64. */
17767 nUF(vmovn
, _vmovn
, 2, (RND
, RNQ
), neon_movn
),
17768 /* VQMOVN. Types S16 S32 S64 U16 U32 U64. */
17769 nUF(vqmovn
, _vqmovn
, 2, (RND
, RNQ
), neon_qmovn
),
17770 /* VQMOVUN. Types S16 S32 S64. */
17771 nUF(vqmovun
, _vqmovun
, 2, (RND
, RNQ
), neon_qmovun
),
17772 /* VZIP / VUZP. Sizes 8 16 32. */
17773 NUF(vzip
, 1b20180
, 2, (RNDQ
, RNDQ
), neon_zip_uzp
),
17774 NUF(vzipq
, 1b20180
, 2, (RNQ
, RNQ
), neon_zip_uzp
),
17775 NUF(vuzp
, 1b20100
, 2, (RNDQ
, RNDQ
), neon_zip_uzp
),
17776 NUF(vuzpq
, 1b20100
, 2, (RNQ
, RNQ
), neon_zip_uzp
),
17777 /* VQABS / VQNEG. Types S8 S16 S32. */
17778 NUF(vqabs
, 1b00700
, 2, (RNDQ
, RNDQ
), neon_sat_abs_neg
),
17779 NUF(vqabsq
, 1b00700
, 2, (RNQ
, RNQ
), neon_sat_abs_neg
),
17780 NUF(vqneg
, 1b00780
, 2, (RNDQ
, RNDQ
), neon_sat_abs_neg
),
17781 NUF(vqnegq
, 1b00780
, 2, (RNQ
, RNQ
), neon_sat_abs_neg
),
17782 /* Pairwise, lengthening. Types S8 S16 S32 U8 U16 U32. */
17783 NUF(vpadal
, 1b00600
, 2, (RNDQ
, RNDQ
), neon_pair_long
),
17784 NUF(vpadalq
, 1b00600
, 2, (RNQ
, RNQ
), neon_pair_long
),
17785 NUF(vpaddl
, 1b00200
, 2, (RNDQ
, RNDQ
), neon_pair_long
),
17786 NUF(vpaddlq
, 1b00200
, 2, (RNQ
, RNQ
), neon_pair_long
),
17787 /* Reciprocal estimates. Types U32 F32. */
17788 NUF(vrecpe
, 1b30400
, 2, (RNDQ
, RNDQ
), neon_recip_est
),
17789 NUF(vrecpeq
, 1b30400
, 2, (RNQ
, RNQ
), neon_recip_est
),
17790 NUF(vrsqrte
, 1b30480
, 2, (RNDQ
, RNDQ
), neon_recip_est
),
17791 NUF(vrsqrteq
, 1b30480
, 2, (RNQ
, RNQ
), neon_recip_est
),
17792 /* VCLS. Types S8 S16 S32. */
17793 NUF(vcls
, 1b00400
, 2, (RNDQ
, RNDQ
), neon_cls
),
17794 NUF(vclsq
, 1b00400
, 2, (RNQ
, RNQ
), neon_cls
),
17795 /* VCLZ. Types I8 I16 I32. */
17796 NUF(vclz
, 1b00480
, 2, (RNDQ
, RNDQ
), neon_clz
),
17797 NUF(vclzq
, 1b00480
, 2, (RNQ
, RNQ
), neon_clz
),
17798 /* VCNT. Size 8. */
17799 NUF(vcnt
, 1b00500
, 2, (RNDQ
, RNDQ
), neon_cnt
),
17800 NUF(vcntq
, 1b00500
, 2, (RNQ
, RNQ
), neon_cnt
),
17801 /* Two address, untyped. */
17802 NUF(vswp
, 1b20000
, 2, (RNDQ
, RNDQ
), neon_swp
),
17803 NUF(vswpq
, 1b20000
, 2, (RNQ
, RNQ
), neon_swp
),
17804 /* VTRN. Sizes 8 16 32. */
17805 nUF(vtrn
, _vtrn
, 2, (RNDQ
, RNDQ
), neon_trn
),
17806 nUF(vtrnq
, _vtrn
, 2, (RNQ
, RNQ
), neon_trn
),
17808 /* Table lookup. Size 8. */
17809 NUF(vtbl
, 1b00800
, 3, (RND
, NRDLST
, RND
), neon_tbl_tbx
),
17810 NUF(vtbx
, 1b00840
, 3, (RND
, NRDLST
, RND
), neon_tbl_tbx
),
17812 #undef THUMB_VARIANT
17813 #define THUMB_VARIANT & fpu_vfp_v3_or_neon_ext
17815 #define ARM_VARIANT & fpu_vfp_v3_or_neon_ext
17817 /* Neon element/structure load/store. */
17818 nUF(vld1
, _vld1
, 2, (NSTRLST
, ADDR
), neon_ldx_stx
),
17819 nUF(vst1
, _vst1
, 2, (NSTRLST
, ADDR
), neon_ldx_stx
),
17820 nUF(vld2
, _vld2
, 2, (NSTRLST
, ADDR
), neon_ldx_stx
),
17821 nUF(vst2
, _vst2
, 2, (NSTRLST
, ADDR
), neon_ldx_stx
),
17822 nUF(vld3
, _vld3
, 2, (NSTRLST
, ADDR
), neon_ldx_stx
),
17823 nUF(vst3
, _vst3
, 2, (NSTRLST
, ADDR
), neon_ldx_stx
),
17824 nUF(vld4
, _vld4
, 2, (NSTRLST
, ADDR
), neon_ldx_stx
),
17825 nUF(vst4
, _vst4
, 2, (NSTRLST
, ADDR
), neon_ldx_stx
),
17827 #undef THUMB_VARIANT
17828 #define THUMB_VARIANT &fpu_vfp_ext_v3xd
17830 #define ARM_VARIANT &fpu_vfp_ext_v3xd
17831 cCE("fconsts", eb00a00
, 2, (RVS
, I255
), vfp_sp_const
),
17832 cCE("fshtos", eba0a40
, 2, (RVS
, I16z
), vfp_sp_conv_16
),
17833 cCE("fsltos", eba0ac0
, 2, (RVS
, I32
), vfp_sp_conv_32
),
17834 cCE("fuhtos", ebb0a40
, 2, (RVS
, I16z
), vfp_sp_conv_16
),
17835 cCE("fultos", ebb0ac0
, 2, (RVS
, I32
), vfp_sp_conv_32
),
17836 cCE("ftoshs", ebe0a40
, 2, (RVS
, I16z
), vfp_sp_conv_16
),
17837 cCE("ftosls", ebe0ac0
, 2, (RVS
, I32
), vfp_sp_conv_32
),
17838 cCE("ftouhs", ebf0a40
, 2, (RVS
, I16z
), vfp_sp_conv_16
),
17839 cCE("ftouls", ebf0ac0
, 2, (RVS
, I32
), vfp_sp_conv_32
),
17841 #undef THUMB_VARIANT
17842 #define THUMB_VARIANT & fpu_vfp_ext_v3
17844 #define ARM_VARIANT & fpu_vfp_ext_v3
17846 cCE("fconstd", eb00b00
, 2, (RVD
, I255
), vfp_dp_const
),
17847 cCE("fshtod", eba0b40
, 2, (RVD
, I16z
), vfp_dp_conv_16
),
17848 cCE("fsltod", eba0bc0
, 2, (RVD
, I32
), vfp_dp_conv_32
),
17849 cCE("fuhtod", ebb0b40
, 2, (RVD
, I16z
), vfp_dp_conv_16
),
17850 cCE("fultod", ebb0bc0
, 2, (RVD
, I32
), vfp_dp_conv_32
),
17851 cCE("ftoshd", ebe0b40
, 2, (RVD
, I16z
), vfp_dp_conv_16
),
17852 cCE("ftosld", ebe0bc0
, 2, (RVD
, I32
), vfp_dp_conv_32
),
17853 cCE("ftouhd", ebf0b40
, 2, (RVD
, I16z
), vfp_dp_conv_16
),
17854 cCE("ftould", ebf0bc0
, 2, (RVD
, I32
), vfp_dp_conv_32
),
17857 #define ARM_VARIANT &fpu_vfp_ext_fma
17858 #undef THUMB_VARIANT
17859 #define THUMB_VARIANT &fpu_vfp_ext_fma
17860 /* Mnemonics shared by Neon and VFP. These are included in the
17861 VFP FMA variant; NEON and VFP FMA always includes the NEON
17862 FMA instructions. */
17863 nCEF(vfma
, _vfma
, 3, (RNSDQ
, oRNSDQ
, RNSDQ
), neon_fmac
),
17864 nCEF(vfms
, _vfms
, 3, (RNSDQ
, oRNSDQ
, RNSDQ
), neon_fmac
),
17865 /* ffmas/ffmad/ffmss/ffmsd are dummy mnemonics to satisfy gas;
17866 the v form should always be used. */
17867 cCE("ffmas", ea00a00
, 3, (RVS
, RVS
, RVS
), vfp_sp_dyadic
),
17868 cCE("ffnmas", ea00a40
, 3, (RVS
, RVS
, RVS
), vfp_sp_dyadic
),
17869 cCE("ffmad", ea00b00
, 3, (RVD
, RVD
, RVD
), vfp_dp_rd_rn_rm
),
17870 cCE("ffnmad", ea00b40
, 3, (RVD
, RVD
, RVD
), vfp_dp_rd_rn_rm
),
17871 nCE(vfnma
, _vfnma
, 3, (RVSD
, RVSD
, RVSD
), vfp_nsyn_nmul
),
17872 nCE(vfnms
, _vfnms
, 3, (RVSD
, RVSD
, RVSD
), vfp_nsyn_nmul
),
17874 #undef THUMB_VARIANT
17876 #define ARM_VARIANT & arm_cext_xscale /* Intel XScale extensions. */
17878 cCE("mia", e200010
, 3, (RXA
, RRnpc
, RRnpc
), xsc_mia
),
17879 cCE("miaph", e280010
, 3, (RXA
, RRnpc
, RRnpc
), xsc_mia
),
17880 cCE("miabb", e2c0010
, 3, (RXA
, RRnpc
, RRnpc
), xsc_mia
),
17881 cCE("miabt", e2d0010
, 3, (RXA
, RRnpc
, RRnpc
), xsc_mia
),
17882 cCE("miatb", e2e0010
, 3, (RXA
, RRnpc
, RRnpc
), xsc_mia
),
17883 cCE("miatt", e2f0010
, 3, (RXA
, RRnpc
, RRnpc
), xsc_mia
),
17884 cCE("mar", c400000
, 3, (RXA
, RRnpc
, RRnpc
), xsc_mar
),
17885 cCE("mra", c500000
, 3, (RRnpc
, RRnpc
, RXA
), xsc_mra
),
17888 #define ARM_VARIANT & arm_cext_iwmmxt /* Intel Wireless MMX technology. */
17890 cCE("tandcb", e13f130
, 1, (RR
), iwmmxt_tandorc
),
17891 cCE("tandch", e53f130
, 1, (RR
), iwmmxt_tandorc
),
17892 cCE("tandcw", e93f130
, 1, (RR
), iwmmxt_tandorc
),
17893 cCE("tbcstb", e400010
, 2, (RIWR
, RR
), rn_rd
),
17894 cCE("tbcsth", e400050
, 2, (RIWR
, RR
), rn_rd
),
17895 cCE("tbcstw", e400090
, 2, (RIWR
, RR
), rn_rd
),
17896 cCE("textrcb", e130170
, 2, (RR
, I7
), iwmmxt_textrc
),
17897 cCE("textrch", e530170
, 2, (RR
, I7
), iwmmxt_textrc
),
17898 cCE("textrcw", e930170
, 2, (RR
, I7
), iwmmxt_textrc
),
17899 cCE("textrmub", e100070
, 3, (RR
, RIWR
, I7
), iwmmxt_textrm
),
17900 cCE("textrmuh", e500070
, 3, (RR
, RIWR
, I7
), iwmmxt_textrm
),
17901 cCE("textrmuw", e900070
, 3, (RR
, RIWR
, I7
), iwmmxt_textrm
),
17902 cCE("textrmsb", e100078
, 3, (RR
, RIWR
, I7
), iwmmxt_textrm
),
17903 cCE("textrmsh", e500078
, 3, (RR
, RIWR
, I7
), iwmmxt_textrm
),
17904 cCE("textrmsw", e900078
, 3, (RR
, RIWR
, I7
), iwmmxt_textrm
),
17905 cCE("tinsrb", e600010
, 3, (RIWR
, RR
, I7
), iwmmxt_tinsr
),
17906 cCE("tinsrh", e600050
, 3, (RIWR
, RR
, I7
), iwmmxt_tinsr
),
17907 cCE("tinsrw", e600090
, 3, (RIWR
, RR
, I7
), iwmmxt_tinsr
),
17908 cCE("tmcr", e000110
, 2, (RIWC_RIWG
, RR
), rn_rd
),
17909 cCE("tmcrr", c400000
, 3, (RIWR
, RR
, RR
), rm_rd_rn
),
17910 cCE("tmia", e200010
, 3, (RIWR
, RR
, RR
), iwmmxt_tmia
),
17911 cCE("tmiaph", e280010
, 3, (RIWR
, RR
, RR
), iwmmxt_tmia
),
17912 cCE("tmiabb", e2c0010
, 3, (RIWR
, RR
, RR
), iwmmxt_tmia
),
17913 cCE("tmiabt", e2d0010
, 3, (RIWR
, RR
, RR
), iwmmxt_tmia
),
17914 cCE("tmiatb", e2e0010
, 3, (RIWR
, RR
, RR
), iwmmxt_tmia
),
17915 cCE("tmiatt", e2f0010
, 3, (RIWR
, RR
, RR
), iwmmxt_tmia
),
17916 cCE("tmovmskb", e100030
, 2, (RR
, RIWR
), rd_rn
),
17917 cCE("tmovmskh", e500030
, 2, (RR
, RIWR
), rd_rn
),
17918 cCE("tmovmskw", e900030
, 2, (RR
, RIWR
), rd_rn
),
17919 cCE("tmrc", e100110
, 2, (RR
, RIWC_RIWG
), rd_rn
),
17920 cCE("tmrrc", c500000
, 3, (RR
, RR
, RIWR
), rd_rn_rm
),
17921 cCE("torcb", e13f150
, 1, (RR
), iwmmxt_tandorc
),
17922 cCE("torch", e53f150
, 1, (RR
), iwmmxt_tandorc
),
17923 cCE("torcw", e93f150
, 1, (RR
), iwmmxt_tandorc
),
17924 cCE("waccb", e0001c0
, 2, (RIWR
, RIWR
), rd_rn
),
17925 cCE("wacch", e4001c0
, 2, (RIWR
, RIWR
), rd_rn
),
17926 cCE("waccw", e8001c0
, 2, (RIWR
, RIWR
), rd_rn
),
17927 cCE("waddbss", e300180
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17928 cCE("waddb", e000180
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17929 cCE("waddbus", e100180
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17930 cCE("waddhss", e700180
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17931 cCE("waddh", e400180
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17932 cCE("waddhus", e500180
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17933 cCE("waddwss", eb00180
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17934 cCE("waddw", e800180
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17935 cCE("waddwus", e900180
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17936 cCE("waligni", e000020
, 4, (RIWR
, RIWR
, RIWR
, I7
), iwmmxt_waligni
),
17937 cCE("walignr0", e800020
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17938 cCE("walignr1", e900020
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17939 cCE("walignr2", ea00020
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17940 cCE("walignr3", eb00020
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17941 cCE("wand", e200000
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17942 cCE("wandn", e300000
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17943 cCE("wavg2b", e800000
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17944 cCE("wavg2br", e900000
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17945 cCE("wavg2h", ec00000
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17946 cCE("wavg2hr", ed00000
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17947 cCE("wcmpeqb", e000060
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17948 cCE("wcmpeqh", e400060
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17949 cCE("wcmpeqw", e800060
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17950 cCE("wcmpgtub", e100060
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17951 cCE("wcmpgtuh", e500060
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17952 cCE("wcmpgtuw", e900060
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17953 cCE("wcmpgtsb", e300060
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17954 cCE("wcmpgtsh", e700060
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17955 cCE("wcmpgtsw", eb00060
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17956 cCE("wldrb", c100000
, 2, (RIWR
, ADDR
), iwmmxt_wldstbh
),
17957 cCE("wldrh", c500000
, 2, (RIWR
, ADDR
), iwmmxt_wldstbh
),
17958 cCE("wldrw", c100100
, 2, (RIWR_RIWC
, ADDR
), iwmmxt_wldstw
),
17959 cCE("wldrd", c500100
, 2, (RIWR
, ADDR
), iwmmxt_wldstd
),
17960 cCE("wmacs", e600100
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17961 cCE("wmacsz", e700100
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17962 cCE("wmacu", e400100
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17963 cCE("wmacuz", e500100
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17964 cCE("wmadds", ea00100
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17965 cCE("wmaddu", e800100
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17966 cCE("wmaxsb", e200160
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17967 cCE("wmaxsh", e600160
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17968 cCE("wmaxsw", ea00160
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17969 cCE("wmaxub", e000160
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17970 cCE("wmaxuh", e400160
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17971 cCE("wmaxuw", e800160
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17972 cCE("wminsb", e300160
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17973 cCE("wminsh", e700160
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17974 cCE("wminsw", eb00160
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17975 cCE("wminub", e100160
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17976 cCE("wminuh", e500160
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17977 cCE("wminuw", e900160
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17978 cCE("wmov", e000000
, 2, (RIWR
, RIWR
), iwmmxt_wmov
),
17979 cCE("wmulsm", e300100
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17980 cCE("wmulsl", e200100
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17981 cCE("wmulum", e100100
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17982 cCE("wmulul", e000100
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17983 cCE("wor", e000000
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17984 cCE("wpackhss", e700080
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17985 cCE("wpackhus", e500080
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17986 cCE("wpackwss", eb00080
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17987 cCE("wpackwus", e900080
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17988 cCE("wpackdss", ef00080
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17989 cCE("wpackdus", ed00080
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17990 cCE("wrorh", e700040
, 3, (RIWR
, RIWR
, RIWR_I32z
),iwmmxt_wrwrwr_or_imm5
),
17991 cCE("wrorhg", e700148
, 3, (RIWR
, RIWR
, RIWG
), rd_rn_rm
),
17992 cCE("wrorw", eb00040
, 3, (RIWR
, RIWR
, RIWR_I32z
),iwmmxt_wrwrwr_or_imm5
),
17993 cCE("wrorwg", eb00148
, 3, (RIWR
, RIWR
, RIWG
), rd_rn_rm
),
17994 cCE("wrord", ef00040
, 3, (RIWR
, RIWR
, RIWR_I32z
),iwmmxt_wrwrwr_or_imm5
),
17995 cCE("wrordg", ef00148
, 3, (RIWR
, RIWR
, RIWG
), rd_rn_rm
),
17996 cCE("wsadb", e000120
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17997 cCE("wsadbz", e100120
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17998 cCE("wsadh", e400120
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17999 cCE("wsadhz", e500120
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
18000 cCE("wshufh", e0001e0
, 3, (RIWR
, RIWR
, I255
), iwmmxt_wshufh
),
18001 cCE("wsllh", e500040
, 3, (RIWR
, RIWR
, RIWR_I32z
),iwmmxt_wrwrwr_or_imm5
),
18002 cCE("wsllhg", e500148
, 3, (RIWR
, RIWR
, RIWG
), rd_rn_rm
),
18003 cCE("wsllw", e900040
, 3, (RIWR
, RIWR
, RIWR_I32z
),iwmmxt_wrwrwr_or_imm5
),
18004 cCE("wsllwg", e900148
, 3, (RIWR
, RIWR
, RIWG
), rd_rn_rm
),
18005 cCE("wslld", ed00040
, 3, (RIWR
, RIWR
, RIWR_I32z
),iwmmxt_wrwrwr_or_imm5
),
18006 cCE("wslldg", ed00148
, 3, (RIWR
, RIWR
, RIWG
), rd_rn_rm
),
18007 cCE("wsrah", e400040
, 3, (RIWR
, RIWR
, RIWR_I32z
),iwmmxt_wrwrwr_or_imm5
),
18008 cCE("wsrahg", e400148
, 3, (RIWR
, RIWR
, RIWG
), rd_rn_rm
),
18009 cCE("wsraw", e800040
, 3, (RIWR
, RIWR
, RIWR_I32z
),iwmmxt_wrwrwr_or_imm5
),
18010 cCE("wsrawg", e800148
, 3, (RIWR
, RIWR
, RIWG
), rd_rn_rm
),
18011 cCE("wsrad", ec00040
, 3, (RIWR
, RIWR
, RIWR_I32z
),iwmmxt_wrwrwr_or_imm5
),
18012 cCE("wsradg", ec00148
, 3, (RIWR
, RIWR
, RIWG
), rd_rn_rm
),
18013 cCE("wsrlh", e600040
, 3, (RIWR
, RIWR
, RIWR_I32z
),iwmmxt_wrwrwr_or_imm5
),
18014 cCE("wsrlhg", e600148
, 3, (RIWR
, RIWR
, RIWG
), rd_rn_rm
),
18015 cCE("wsrlw", ea00040
, 3, (RIWR
, RIWR
, RIWR_I32z
),iwmmxt_wrwrwr_or_imm5
),
18016 cCE("wsrlwg", ea00148
, 3, (RIWR
, RIWR
, RIWG
), rd_rn_rm
),
18017 cCE("wsrld", ee00040
, 3, (RIWR
, RIWR
, RIWR_I32z
),iwmmxt_wrwrwr_or_imm5
),
18018 cCE("wsrldg", ee00148
, 3, (RIWR
, RIWR
, RIWG
), rd_rn_rm
),
18019 cCE("wstrb", c000000
, 2, (RIWR
, ADDR
), iwmmxt_wldstbh
),
18020 cCE("wstrh", c400000
, 2, (RIWR
, ADDR
), iwmmxt_wldstbh
),
18021 cCE("wstrw", c000100
, 2, (RIWR_RIWC
, ADDR
), iwmmxt_wldstw
),
18022 cCE("wstrd", c400100
, 2, (RIWR
, ADDR
), iwmmxt_wldstd
),
18023 cCE("wsubbss", e3001a0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
18024 cCE("wsubb", e0001a0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
18025 cCE("wsubbus", e1001a0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
18026 cCE("wsubhss", e7001a0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
18027 cCE("wsubh", e4001a0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
18028 cCE("wsubhus", e5001a0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
18029 cCE("wsubwss", eb001a0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
18030 cCE("wsubw", e8001a0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
18031 cCE("wsubwus", e9001a0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
18032 cCE("wunpckehub",e0000c0
, 2, (RIWR
, RIWR
), rd_rn
),
18033 cCE("wunpckehuh",e4000c0
, 2, (RIWR
, RIWR
), rd_rn
),
18034 cCE("wunpckehuw",e8000c0
, 2, (RIWR
, RIWR
), rd_rn
),
18035 cCE("wunpckehsb",e2000c0
, 2, (RIWR
, RIWR
), rd_rn
),
18036 cCE("wunpckehsh",e6000c0
, 2, (RIWR
, RIWR
), rd_rn
),
18037 cCE("wunpckehsw",ea000c0
, 2, (RIWR
, RIWR
), rd_rn
),
18038 cCE("wunpckihb", e1000c0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
18039 cCE("wunpckihh", e5000c0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
18040 cCE("wunpckihw", e9000c0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
18041 cCE("wunpckelub",e0000e0
, 2, (RIWR
, RIWR
), rd_rn
),
18042 cCE("wunpckeluh",e4000e0
, 2, (RIWR
, RIWR
), rd_rn
),
18043 cCE("wunpckeluw",e8000e0
, 2, (RIWR
, RIWR
), rd_rn
),
18044 cCE("wunpckelsb",e2000e0
, 2, (RIWR
, RIWR
), rd_rn
),
18045 cCE("wunpckelsh",e6000e0
, 2, (RIWR
, RIWR
), rd_rn
),
18046 cCE("wunpckelsw",ea000e0
, 2, (RIWR
, RIWR
), rd_rn
),
18047 cCE("wunpckilb", e1000e0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
18048 cCE("wunpckilh", e5000e0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
18049 cCE("wunpckilw", e9000e0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
18050 cCE("wxor", e100000
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
18051 cCE("wzero", e300000
, 1, (RIWR
), iwmmxt_wzero
),
18054 #define ARM_VARIANT & arm_cext_iwmmxt2 /* Intel Wireless MMX technology, version 2. */
18056 cCE("torvscb", e12f190
, 1, (RR
), iwmmxt_tandorc
),
18057 cCE("torvsch", e52f190
, 1, (RR
), iwmmxt_tandorc
),
18058 cCE("torvscw", e92f190
, 1, (RR
), iwmmxt_tandorc
),
18059 cCE("wabsb", e2001c0
, 2, (RIWR
, RIWR
), rd_rn
),
18060 cCE("wabsh", e6001c0
, 2, (RIWR
, RIWR
), rd_rn
),
18061 cCE("wabsw", ea001c0
, 2, (RIWR
, RIWR
), rd_rn
),
18062 cCE("wabsdiffb", e1001c0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
18063 cCE("wabsdiffh", e5001c0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
18064 cCE("wabsdiffw", e9001c0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
18065 cCE("waddbhusl", e2001a0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
18066 cCE("waddbhusm", e6001a0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
18067 cCE("waddhc", e600180
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
18068 cCE("waddwc", ea00180
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
18069 cCE("waddsubhx", ea001a0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
18070 cCE("wavg4", e400000
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
18071 cCE("wavg4r", e500000
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
18072 cCE("wmaddsn", ee00100
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
18073 cCE("wmaddsx", eb00100
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
18074 cCE("wmaddun", ec00100
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
18075 cCE("wmaddux", e900100
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
18076 cCE("wmerge", e000080
, 4, (RIWR
, RIWR
, RIWR
, I7
), iwmmxt_wmerge
),
18077 cCE("wmiabb", e0000a0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
18078 cCE("wmiabt", e1000a0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
18079 cCE("wmiatb", e2000a0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
18080 cCE("wmiatt", e3000a0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
18081 cCE("wmiabbn", e4000a0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
18082 cCE("wmiabtn", e5000a0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
18083 cCE("wmiatbn", e6000a0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
18084 cCE("wmiattn", e7000a0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
18085 cCE("wmiawbb", e800120
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
18086 cCE("wmiawbt", e900120
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
18087 cCE("wmiawtb", ea00120
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
18088 cCE("wmiawtt", eb00120
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
18089 cCE("wmiawbbn", ec00120
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
18090 cCE("wmiawbtn", ed00120
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
18091 cCE("wmiawtbn", ee00120
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
18092 cCE("wmiawttn", ef00120
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
18093 cCE("wmulsmr", ef00100
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
18094 cCE("wmulumr", ed00100
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
18095 cCE("wmulwumr", ec000c0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
18096 cCE("wmulwsmr", ee000c0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
18097 cCE("wmulwum", ed000c0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
18098 cCE("wmulwsm", ef000c0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
18099 cCE("wmulwl", eb000c0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
18100 cCE("wqmiabb", e8000a0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
18101 cCE("wqmiabt", e9000a0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
18102 cCE("wqmiatb", ea000a0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
18103 cCE("wqmiatt", eb000a0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
18104 cCE("wqmiabbn", ec000a0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
18105 cCE("wqmiabtn", ed000a0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
18106 cCE("wqmiatbn", ee000a0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
18107 cCE("wqmiattn", ef000a0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
18108 cCE("wqmulm", e100080
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
18109 cCE("wqmulmr", e300080
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
18110 cCE("wqmulwm", ec000e0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
18111 cCE("wqmulwmr", ee000e0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
18112 cCE("wsubaddhx", ed001c0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
18115 #define ARM_VARIANT & arm_cext_maverick /* Cirrus Maverick instructions. */
18117 cCE("cfldrs", c100400
, 2, (RMF
, ADDRGLDC
), rd_cpaddr
),
18118 cCE("cfldrd", c500400
, 2, (RMD
, ADDRGLDC
), rd_cpaddr
),
18119 cCE("cfldr32", c100500
, 2, (RMFX
, ADDRGLDC
), rd_cpaddr
),
18120 cCE("cfldr64", c500500
, 2, (RMDX
, ADDRGLDC
), rd_cpaddr
),
18121 cCE("cfstrs", c000400
, 2, (RMF
, ADDRGLDC
), rd_cpaddr
),
18122 cCE("cfstrd", c400400
, 2, (RMD
, ADDRGLDC
), rd_cpaddr
),
18123 cCE("cfstr32", c000500
, 2, (RMFX
, ADDRGLDC
), rd_cpaddr
),
18124 cCE("cfstr64", c400500
, 2, (RMDX
, ADDRGLDC
), rd_cpaddr
),
18125 cCE("cfmvsr", e000450
, 2, (RMF
, RR
), rn_rd
),
18126 cCE("cfmvrs", e100450
, 2, (RR
, RMF
), rd_rn
),
18127 cCE("cfmvdlr", e000410
, 2, (RMD
, RR
), rn_rd
),
18128 cCE("cfmvrdl", e100410
, 2, (RR
, RMD
), rd_rn
),
18129 cCE("cfmvdhr", e000430
, 2, (RMD
, RR
), rn_rd
),
18130 cCE("cfmvrdh", e100430
, 2, (RR
, RMD
), rd_rn
),
18131 cCE("cfmv64lr", e000510
, 2, (RMDX
, RR
), rn_rd
),
18132 cCE("cfmvr64l", e100510
, 2, (RR
, RMDX
), rd_rn
),
18133 cCE("cfmv64hr", e000530
, 2, (RMDX
, RR
), rn_rd
),
18134 cCE("cfmvr64h", e100530
, 2, (RR
, RMDX
), rd_rn
),
18135 cCE("cfmval32", e200440
, 2, (RMAX
, RMFX
), rd_rn
),
18136 cCE("cfmv32al", e100440
, 2, (RMFX
, RMAX
), rd_rn
),
18137 cCE("cfmvam32", e200460
, 2, (RMAX
, RMFX
), rd_rn
),
18138 cCE("cfmv32am", e100460
, 2, (RMFX
, RMAX
), rd_rn
),
18139 cCE("cfmvah32", e200480
, 2, (RMAX
, RMFX
), rd_rn
),
18140 cCE("cfmv32ah", e100480
, 2, (RMFX
, RMAX
), rd_rn
),
18141 cCE("cfmva32", e2004a0
, 2, (RMAX
, RMFX
), rd_rn
),
18142 cCE("cfmv32a", e1004a0
, 2, (RMFX
, RMAX
), rd_rn
),
18143 cCE("cfmva64", e2004c0
, 2, (RMAX
, RMDX
), rd_rn
),
18144 cCE("cfmv64a", e1004c0
, 2, (RMDX
, RMAX
), rd_rn
),
18145 cCE("cfmvsc32", e2004e0
, 2, (RMDS
, RMDX
), mav_dspsc
),
18146 cCE("cfmv32sc", e1004e0
, 2, (RMDX
, RMDS
), rd
),
18147 cCE("cfcpys", e000400
, 2, (RMF
, RMF
), rd_rn
),
18148 cCE("cfcpyd", e000420
, 2, (RMD
, RMD
), rd_rn
),
18149 cCE("cfcvtsd", e000460
, 2, (RMD
, RMF
), rd_rn
),
18150 cCE("cfcvtds", e000440
, 2, (RMF
, RMD
), rd_rn
),
18151 cCE("cfcvt32s", e000480
, 2, (RMF
, RMFX
), rd_rn
),
18152 cCE("cfcvt32d", e0004a0
, 2, (RMD
, RMFX
), rd_rn
),
18153 cCE("cfcvt64s", e0004c0
, 2, (RMF
, RMDX
), rd_rn
),
18154 cCE("cfcvt64d", e0004e0
, 2, (RMD
, RMDX
), rd_rn
),
18155 cCE("cfcvts32", e100580
, 2, (RMFX
, RMF
), rd_rn
),
18156 cCE("cfcvtd32", e1005a0
, 2, (RMFX
, RMD
), rd_rn
),
18157 cCE("cftruncs32",e1005c0
, 2, (RMFX
, RMF
), rd_rn
),
18158 cCE("cftruncd32",e1005e0
, 2, (RMFX
, RMD
), rd_rn
),
18159 cCE("cfrshl32", e000550
, 3, (RMFX
, RMFX
, RR
), mav_triple
),
18160 cCE("cfrshl64", e000570
, 3, (RMDX
, RMDX
, RR
), mav_triple
),
18161 cCE("cfsh32", e000500
, 3, (RMFX
, RMFX
, I63s
), mav_shift
),
18162 cCE("cfsh64", e200500
, 3, (RMDX
, RMDX
, I63s
), mav_shift
),
18163 cCE("cfcmps", e100490
, 3, (RR
, RMF
, RMF
), rd_rn_rm
),
18164 cCE("cfcmpd", e1004b0
, 3, (RR
, RMD
, RMD
), rd_rn_rm
),
18165 cCE("cfcmp32", e100590
, 3, (RR
, RMFX
, RMFX
), rd_rn_rm
),
18166 cCE("cfcmp64", e1005b0
, 3, (RR
, RMDX
, RMDX
), rd_rn_rm
),
18167 cCE("cfabss", e300400
, 2, (RMF
, RMF
), rd_rn
),
18168 cCE("cfabsd", e300420
, 2, (RMD
, RMD
), rd_rn
),
18169 cCE("cfnegs", e300440
, 2, (RMF
, RMF
), rd_rn
),
18170 cCE("cfnegd", e300460
, 2, (RMD
, RMD
), rd_rn
),
18171 cCE("cfadds", e300480
, 3, (RMF
, RMF
, RMF
), rd_rn_rm
),
18172 cCE("cfaddd", e3004a0
, 3, (RMD
, RMD
, RMD
), rd_rn_rm
),
18173 cCE("cfsubs", e3004c0
, 3, (RMF
, RMF
, RMF
), rd_rn_rm
),
18174 cCE("cfsubd", e3004e0
, 3, (RMD
, RMD
, RMD
), rd_rn_rm
),
18175 cCE("cfmuls", e100400
, 3, (RMF
, RMF
, RMF
), rd_rn_rm
),
18176 cCE("cfmuld", e100420
, 3, (RMD
, RMD
, RMD
), rd_rn_rm
),
18177 cCE("cfabs32", e300500
, 2, (RMFX
, RMFX
), rd_rn
),
18178 cCE("cfabs64", e300520
, 2, (RMDX
, RMDX
), rd_rn
),
18179 cCE("cfneg32", e300540
, 2, (RMFX
, RMFX
), rd_rn
),
18180 cCE("cfneg64", e300560
, 2, (RMDX
, RMDX
), rd_rn
),
18181 cCE("cfadd32", e300580
, 3, (RMFX
, RMFX
, RMFX
), rd_rn_rm
),
18182 cCE("cfadd64", e3005a0
, 3, (RMDX
, RMDX
, RMDX
), rd_rn_rm
),
18183 cCE("cfsub32", e3005c0
, 3, (RMFX
, RMFX
, RMFX
), rd_rn_rm
),
18184 cCE("cfsub64", e3005e0
, 3, (RMDX
, RMDX
, RMDX
), rd_rn_rm
),
18185 cCE("cfmul32", e100500
, 3, (RMFX
, RMFX
, RMFX
), rd_rn_rm
),
18186 cCE("cfmul64", e100520
, 3, (RMDX
, RMDX
, RMDX
), rd_rn_rm
),
18187 cCE("cfmac32", e100540
, 3, (RMFX
, RMFX
, RMFX
), rd_rn_rm
),
18188 cCE("cfmsc32", e100560
, 3, (RMFX
, RMFX
, RMFX
), rd_rn_rm
),
18189 cCE("cfmadd32", e000600
, 4, (RMAX
, RMFX
, RMFX
, RMFX
), mav_quad
),
18190 cCE("cfmsub32", e100600
, 4, (RMAX
, RMFX
, RMFX
, RMFX
), mav_quad
),
18191 cCE("cfmadda32", e200600
, 4, (RMAX
, RMAX
, RMFX
, RMFX
), mav_quad
),
18192 cCE("cfmsuba32", e300600
, 4, (RMAX
, RMAX
, RMFX
, RMFX
), mav_quad
),
18195 #undef THUMB_VARIANT
18222 /* MD interface: bits in the object file. */
18224 /* Turn an integer of n bytes (in val) into a stream of bytes appropriate
18225 for use in the a.out file, and stores them in the array pointed to by buf.
18226 This knows about the endian-ness of the target machine and does
18227 THE RIGHT THING, whatever it is. Possible values for n are 1 (byte)
18228 2 (short) and 4 (long) Floating numbers are put out as a series of
18229 LITTLENUMS (shorts, here at least). */
18232 md_number_to_chars (char * buf
, valueT val
, int n
)
18234 if (target_big_endian
)
18235 number_to_chars_bigendian (buf
, val
, n
);
18237 number_to_chars_littleendian (buf
, val
, n
);
18241 md_chars_to_number (char * buf
, int n
)
18244 unsigned char * where
= (unsigned char *) buf
;
18246 if (target_big_endian
)
18251 result
|= (*where
++ & 255);
18259 result
|= (where
[n
] & 255);
18266 /* MD interface: Sections. */
18268 /* Estimate the size of a frag before relaxing. Assume everything fits in
18272 md_estimate_size_before_relax (fragS
* fragp
,
18273 segT segtype ATTRIBUTE_UNUSED
)
18279 /* Convert a machine dependent frag. */
18282 md_convert_frag (bfd
*abfd
, segT asec ATTRIBUTE_UNUSED
, fragS
*fragp
)
18284 unsigned long insn
;
18285 unsigned long old_op
;
18293 buf
= fragp
->fr_literal
+ fragp
->fr_fix
;
18295 old_op
= bfd_get_16(abfd
, buf
);
18296 if (fragp
->fr_symbol
)
18298 exp
.X_op
= O_symbol
;
18299 exp
.X_add_symbol
= fragp
->fr_symbol
;
18303 exp
.X_op
= O_constant
;
18305 exp
.X_add_number
= fragp
->fr_offset
;
18306 opcode
= fragp
->fr_subtype
;
18309 case T_MNEM_ldr_pc
:
18310 case T_MNEM_ldr_pc2
:
18311 case T_MNEM_ldr_sp
:
18312 case T_MNEM_str_sp
:
18319 if (fragp
->fr_var
== 4)
18321 insn
= THUMB_OP32 (opcode
);
18322 if ((old_op
>> 12) == 4 || (old_op
>> 12) == 9)
18324 insn
|= (old_op
& 0x700) << 4;
18328 insn
|= (old_op
& 7) << 12;
18329 insn
|= (old_op
& 0x38) << 13;
18331 insn
|= 0x00000c00;
18332 put_thumb32_insn (buf
, insn
);
18333 reloc_type
= BFD_RELOC_ARM_T32_OFFSET_IMM
;
18337 reloc_type
= BFD_RELOC_ARM_THUMB_OFFSET
;
18339 pc_rel
= (opcode
== T_MNEM_ldr_pc2
);
18342 if (fragp
->fr_var
== 4)
18344 insn
= THUMB_OP32 (opcode
);
18345 insn
|= (old_op
& 0xf0) << 4;
18346 put_thumb32_insn (buf
, insn
);
18347 reloc_type
= BFD_RELOC_ARM_T32_ADD_PC12
;
18351 reloc_type
= BFD_RELOC_ARM_THUMB_ADD
;
18352 exp
.X_add_number
-= 4;
18360 if (fragp
->fr_var
== 4)
18362 int r0off
= (opcode
== T_MNEM_mov
18363 || opcode
== T_MNEM_movs
) ? 0 : 8;
18364 insn
= THUMB_OP32 (opcode
);
18365 insn
= (insn
& 0xe1ffffff) | 0x10000000;
18366 insn
|= (old_op
& 0x700) << r0off
;
18367 put_thumb32_insn (buf
, insn
);
18368 reloc_type
= BFD_RELOC_ARM_T32_IMMEDIATE
;
18372 reloc_type
= BFD_RELOC_ARM_THUMB_IMM
;
18377 if (fragp
->fr_var
== 4)
18379 insn
= THUMB_OP32(opcode
);
18380 put_thumb32_insn (buf
, insn
);
18381 reloc_type
= BFD_RELOC_THUMB_PCREL_BRANCH25
;
18384 reloc_type
= BFD_RELOC_THUMB_PCREL_BRANCH12
;
18388 if (fragp
->fr_var
== 4)
18390 insn
= THUMB_OP32(opcode
);
18391 insn
|= (old_op
& 0xf00) << 14;
18392 put_thumb32_insn (buf
, insn
);
18393 reloc_type
= BFD_RELOC_THUMB_PCREL_BRANCH20
;
18396 reloc_type
= BFD_RELOC_THUMB_PCREL_BRANCH9
;
18399 case T_MNEM_add_sp
:
18400 case T_MNEM_add_pc
:
18401 case T_MNEM_inc_sp
:
18402 case T_MNEM_dec_sp
:
18403 if (fragp
->fr_var
== 4)
18405 /* ??? Choose between add and addw. */
18406 insn
= THUMB_OP32 (opcode
);
18407 insn
|= (old_op
& 0xf0) << 4;
18408 put_thumb32_insn (buf
, insn
);
18409 if (opcode
== T_MNEM_add_pc
)
18410 reloc_type
= BFD_RELOC_ARM_T32_IMM12
;
18412 reloc_type
= BFD_RELOC_ARM_T32_ADD_IMM
;
18415 reloc_type
= BFD_RELOC_ARM_THUMB_ADD
;
18423 if (fragp
->fr_var
== 4)
18425 insn
= THUMB_OP32 (opcode
);
18426 insn
|= (old_op
& 0xf0) << 4;
18427 insn
|= (old_op
& 0xf) << 16;
18428 put_thumb32_insn (buf
, insn
);
18429 if (insn
& (1 << 20))
18430 reloc_type
= BFD_RELOC_ARM_T32_ADD_IMM
;
18432 reloc_type
= BFD_RELOC_ARM_T32_IMMEDIATE
;
18435 reloc_type
= BFD_RELOC_ARM_THUMB_ADD
;
18441 fixp
= fix_new_exp (fragp
, fragp
->fr_fix
, fragp
->fr_var
, &exp
, pc_rel
,
18442 (enum bfd_reloc_code_real
) reloc_type
);
18443 fixp
->fx_file
= fragp
->fr_file
;
18444 fixp
->fx_line
= fragp
->fr_line
;
18445 fragp
->fr_fix
+= fragp
->fr_var
;
18448 /* Return the size of a relaxable immediate operand instruction.
18449 SHIFT and SIZE specify the form of the allowable immediate. */
18451 relax_immediate (fragS
*fragp
, int size
, int shift
)
18457 /* ??? Should be able to do better than this. */
18458 if (fragp
->fr_symbol
)
18461 low
= (1 << shift
) - 1;
18462 mask
= (1 << (shift
+ size
)) - (1 << shift
);
18463 offset
= fragp
->fr_offset
;
18464 /* Force misaligned offsets to 32-bit variant. */
18467 if (offset
& ~mask
)
18472 /* Get the address of a symbol during relaxation. */
18474 relaxed_symbol_addr (fragS
*fragp
, long stretch
)
18480 sym
= fragp
->fr_symbol
;
18481 sym_frag
= symbol_get_frag (sym
);
18482 know (S_GET_SEGMENT (sym
) != absolute_section
18483 || sym_frag
== &zero_address_frag
);
18484 addr
= S_GET_VALUE (sym
) + fragp
->fr_offset
;
18486 /* If frag has yet to be reached on this pass, assume it will
18487 move by STRETCH just as we did. If this is not so, it will
18488 be because some frag between grows, and that will force
18492 && sym_frag
->relax_marker
!= fragp
->relax_marker
)
18496 /* Adjust stretch for any alignment frag. Note that if have
18497 been expanding the earlier code, the symbol may be
18498 defined in what appears to be an earlier frag. FIXME:
18499 This doesn't handle the fr_subtype field, which specifies
18500 a maximum number of bytes to skip when doing an
18502 for (f
= fragp
; f
!= NULL
&& f
!= sym_frag
; f
= f
->fr_next
)
18504 if (f
->fr_type
== rs_align
|| f
->fr_type
== rs_align_code
)
18507 stretch
= - ((- stretch
)
18508 & ~ ((1 << (int) f
->fr_offset
) - 1));
18510 stretch
&= ~ ((1 << (int) f
->fr_offset
) - 1);
18522 /* Return the size of a relaxable adr pseudo-instruction or PC-relative
18525 relax_adr (fragS
*fragp
, asection
*sec
, long stretch
)
18530 /* Assume worst case for symbols not known to be in the same section. */
18531 if (fragp
->fr_symbol
== NULL
18532 || !S_IS_DEFINED (fragp
->fr_symbol
)
18533 || sec
!= S_GET_SEGMENT (fragp
->fr_symbol
)
18534 || S_IS_WEAK (fragp
->fr_symbol
))
18537 val
= relaxed_symbol_addr (fragp
, stretch
);
18538 addr
= fragp
->fr_address
+ fragp
->fr_fix
;
18539 addr
= (addr
+ 4) & ~3;
18540 /* Force misaligned targets to 32-bit variant. */
18544 if (val
< 0 || val
> 1020)
18549 /* Return the size of a relaxable add/sub immediate instruction. */
18551 relax_addsub (fragS
*fragp
, asection
*sec
)
18556 buf
= fragp
->fr_literal
+ fragp
->fr_fix
;
18557 op
= bfd_get_16(sec
->owner
, buf
);
18558 if ((op
& 0xf) == ((op
>> 4) & 0xf))
18559 return relax_immediate (fragp
, 8, 0);
18561 return relax_immediate (fragp
, 3, 0);
18565 /* Return the size of a relaxable branch instruction. BITS is the
18566 size of the offset field in the narrow instruction. */
18569 relax_branch (fragS
*fragp
, asection
*sec
, int bits
, long stretch
)
18575 /* Assume worst case for symbols not known to be in the same section. */
18576 if (!S_IS_DEFINED (fragp
->fr_symbol
)
18577 || sec
!= S_GET_SEGMENT (fragp
->fr_symbol
)
18578 || S_IS_WEAK (fragp
->fr_symbol
))
18582 if (S_IS_DEFINED (fragp
->fr_symbol
)
18583 && ARM_IS_FUNC (fragp
->fr_symbol
))
18587 val
= relaxed_symbol_addr (fragp
, stretch
);
18588 addr
= fragp
->fr_address
+ fragp
->fr_fix
+ 4;
18591 /* Offset is a signed value *2 */
18593 if (val
>= limit
|| val
< -limit
)
18599 /* Relax a machine dependent frag. This returns the amount by which
18600 the current size of the frag should change. */
18603 arm_relax_frag (asection
*sec
, fragS
*fragp
, long stretch
)
18608 oldsize
= fragp
->fr_var
;
18609 switch (fragp
->fr_subtype
)
18611 case T_MNEM_ldr_pc2
:
18612 newsize
= relax_adr (fragp
, sec
, stretch
);
18614 case T_MNEM_ldr_pc
:
18615 case T_MNEM_ldr_sp
:
18616 case T_MNEM_str_sp
:
18617 newsize
= relax_immediate (fragp
, 8, 2);
18621 newsize
= relax_immediate (fragp
, 5, 2);
18625 newsize
= relax_immediate (fragp
, 5, 1);
18629 newsize
= relax_immediate (fragp
, 5, 0);
18632 newsize
= relax_adr (fragp
, sec
, stretch
);
18638 newsize
= relax_immediate (fragp
, 8, 0);
18641 newsize
= relax_branch (fragp
, sec
, 11, stretch
);
18644 newsize
= relax_branch (fragp
, sec
, 8, stretch
);
18646 case T_MNEM_add_sp
:
18647 case T_MNEM_add_pc
:
18648 newsize
= relax_immediate (fragp
, 8, 2);
18650 case T_MNEM_inc_sp
:
18651 case T_MNEM_dec_sp
:
18652 newsize
= relax_immediate (fragp
, 7, 2);
18658 newsize
= relax_addsub (fragp
, sec
);
18664 fragp
->fr_var
= newsize
;
18665 /* Freeze wide instructions that are at or before the same location as
18666 in the previous pass. This avoids infinite loops.
18667 Don't freeze them unconditionally because targets may be artificially
18668 misaligned by the expansion of preceding frags. */
18669 if (stretch
<= 0 && newsize
> 2)
18671 md_convert_frag (sec
->owner
, sec
, fragp
);
18675 return newsize
- oldsize
;
18678 /* Round up a section size to the appropriate boundary. */
18681 md_section_align (segT segment ATTRIBUTE_UNUSED
,
18684 #if (defined (OBJ_AOUT) || defined (OBJ_MAYBE_AOUT))
18685 if (OUTPUT_FLAVOR
== bfd_target_aout_flavour
)
18687 /* For a.out, force the section size to be aligned. If we don't do
18688 this, BFD will align it for us, but it will not write out the
18689 final bytes of the section. This may be a bug in BFD, but it is
18690 easier to fix it here since that is how the other a.out targets
18694 align
= bfd_get_section_alignment (stdoutput
, segment
);
18695 size
= ((size
+ (1 << align
) - 1) & ((valueT
) -1 << align
));
18702 /* This is called from HANDLE_ALIGN in write.c. Fill in the contents
18703 of an rs_align_code fragment. */
18706 arm_handle_align (fragS
* fragP
)
18708 static char const arm_noop
[2][2][4] =
18711 {0x00, 0x00, 0xa0, 0xe1}, /* LE */
18712 {0xe1, 0xa0, 0x00, 0x00}, /* BE */
18715 {0x00, 0xf0, 0x20, 0xe3}, /* LE */
18716 {0xe3, 0x20, 0xf0, 0x00}, /* BE */
18719 static char const thumb_noop
[2][2][2] =
18722 {0xc0, 0x46}, /* LE */
18723 {0x46, 0xc0}, /* BE */
18726 {0x00, 0xbf}, /* LE */
18727 {0xbf, 0x00} /* BE */
18730 static char const wide_thumb_noop
[2][4] =
18731 { /* Wide Thumb-2 */
18732 {0xaf, 0xf3, 0x00, 0x80}, /* LE */
18733 {0xf3, 0xaf, 0x80, 0x00}, /* BE */
18736 unsigned bytes
, fix
, noop_size
;
18739 const char *narrow_noop
= NULL
;
18744 if (fragP
->fr_type
!= rs_align_code
)
18747 bytes
= fragP
->fr_next
->fr_address
- fragP
->fr_address
- fragP
->fr_fix
;
18748 p
= fragP
->fr_literal
+ fragP
->fr_fix
;
18751 if (bytes
> MAX_MEM_FOR_RS_ALIGN_CODE
)
18752 bytes
&= MAX_MEM_FOR_RS_ALIGN_CODE
;
18754 gas_assert ((fragP
->tc_frag_data
.thumb_mode
& MODE_RECORDED
) != 0);
18756 if (fragP
->tc_frag_data
.thumb_mode
& (~ MODE_RECORDED
))
18758 if (ARM_CPU_HAS_FEATURE (selected_cpu
, arm_ext_v6t2
))
18760 narrow_noop
= thumb_noop
[1][target_big_endian
];
18761 noop
= wide_thumb_noop
[target_big_endian
];
18764 noop
= thumb_noop
[0][target_big_endian
];
18772 noop
= arm_noop
[ARM_CPU_HAS_FEATURE (selected_cpu
, arm_ext_v6k
) != 0]
18773 [target_big_endian
];
18780 fragP
->fr_var
= noop_size
;
18782 if (bytes
& (noop_size
- 1))
18784 fix
= bytes
& (noop_size
- 1);
18786 insert_data_mapping_symbol (state
, fragP
->fr_fix
, fragP
, fix
);
18788 memset (p
, 0, fix
);
18795 if (bytes
& noop_size
)
18797 /* Insert a narrow noop. */
18798 memcpy (p
, narrow_noop
, noop_size
);
18800 bytes
-= noop_size
;
18804 /* Use wide noops for the remainder */
18808 while (bytes
>= noop_size
)
18810 memcpy (p
, noop
, noop_size
);
18812 bytes
-= noop_size
;
18816 fragP
->fr_fix
+= fix
;
18819 /* Called from md_do_align. Used to create an alignment
18820 frag in a code section. */
18823 arm_frag_align_code (int n
, int max
)
18827 /* We assume that there will never be a requirement
18828 to support alignments greater than MAX_MEM_FOR_RS_ALIGN_CODE bytes. */
18829 if (max
> MAX_MEM_FOR_RS_ALIGN_CODE
)
18834 _("alignments greater than %d bytes not supported in .text sections."),
18835 MAX_MEM_FOR_RS_ALIGN_CODE
+ 1);
18836 as_fatal ("%s", err_msg
);
18839 p
= frag_var (rs_align_code
,
18840 MAX_MEM_FOR_RS_ALIGN_CODE
,
18842 (relax_substateT
) max
,
18849 /* Perform target specific initialisation of a frag.
18850 Note - despite the name this initialisation is not done when the frag
18851 is created, but only when its type is assigned. A frag can be created
18852 and used a long time before its type is set, so beware of assuming that
18853 this initialisationis performed first. */
18857 arm_init_frag (fragS
* fragP
, int max_chars ATTRIBUTE_UNUSED
)
18859 /* Record whether this frag is in an ARM or a THUMB area. */
18860 fragP
->tc_frag_data
.thumb_mode
= thumb_mode
| MODE_RECORDED
;
18863 #else /* OBJ_ELF is defined. */
18865 arm_init_frag (fragS
* fragP
, int max_chars
)
18867 /* If the current ARM vs THUMB mode has not already
18868 been recorded into this frag then do so now. */
18869 if ((fragP
->tc_frag_data
.thumb_mode
& MODE_RECORDED
) == 0)
18871 fragP
->tc_frag_data
.thumb_mode
= thumb_mode
| MODE_RECORDED
;
18873 /* Record a mapping symbol for alignment frags. We will delete this
18874 later if the alignment ends up empty. */
18875 switch (fragP
->fr_type
)
18878 case rs_align_test
:
18880 mapping_state_2 (MAP_DATA
, max_chars
);
18882 case rs_align_code
:
18883 mapping_state_2 (thumb_mode
? MAP_THUMB
: MAP_ARM
, max_chars
);
18891 /* When we change sections we need to issue a new mapping symbol. */
18894 arm_elf_change_section (void)
18896 /* Link an unlinked unwind index table section to the .text section. */
18897 if (elf_section_type (now_seg
) == SHT_ARM_EXIDX
18898 && elf_linked_to_section (now_seg
) == NULL
)
18899 elf_linked_to_section (now_seg
) = text_section
;
18903 arm_elf_section_type (const char * str
, size_t len
)
18905 if (len
== 5 && strncmp (str
, "exidx", 5) == 0)
18906 return SHT_ARM_EXIDX
;
18911 /* Code to deal with unwinding tables. */
18913 static void add_unwind_adjustsp (offsetT
);
18915 /* Generate any deferred unwind frame offset. */
18918 flush_pending_unwind (void)
18922 offset
= unwind
.pending_offset
;
18923 unwind
.pending_offset
= 0;
18925 add_unwind_adjustsp (offset
);
18928 /* Add an opcode to this list for this function. Two-byte opcodes should
18929 be passed as op[0] << 8 | op[1]. The list of opcodes is built in reverse
18933 add_unwind_opcode (valueT op
, int length
)
18935 /* Add any deferred stack adjustment. */
18936 if (unwind
.pending_offset
)
18937 flush_pending_unwind ();
18939 unwind
.sp_restored
= 0;
18941 if (unwind
.opcode_count
+ length
> unwind
.opcode_alloc
)
18943 unwind
.opcode_alloc
+= ARM_OPCODE_CHUNK_SIZE
;
18944 if (unwind
.opcodes
)
18945 unwind
.opcodes
= (unsigned char *) xrealloc (unwind
.opcodes
,
18946 unwind
.opcode_alloc
);
18948 unwind
.opcodes
= (unsigned char *) xmalloc (unwind
.opcode_alloc
);
18953 unwind
.opcodes
[unwind
.opcode_count
] = op
& 0xff;
18955 unwind
.opcode_count
++;
18959 /* Add unwind opcodes to adjust the stack pointer. */
18962 add_unwind_adjustsp (offsetT offset
)
18966 if (offset
> 0x200)
18968 /* We need at most 5 bytes to hold a 32-bit value in a uleb128. */
18973 /* Long form: 0xb2, uleb128. */
18974 /* This might not fit in a word so add the individual bytes,
18975 remembering the list is built in reverse order. */
18976 o
= (valueT
) ((offset
- 0x204) >> 2);
18978 add_unwind_opcode (0, 1);
18980 /* Calculate the uleb128 encoding of the offset. */
18984 bytes
[n
] = o
& 0x7f;
18990 /* Add the insn. */
18992 add_unwind_opcode (bytes
[n
- 1], 1);
18993 add_unwind_opcode (0xb2, 1);
18995 else if (offset
> 0x100)
18997 /* Two short opcodes. */
18998 add_unwind_opcode (0x3f, 1);
18999 op
= (offset
- 0x104) >> 2;
19000 add_unwind_opcode (op
, 1);
19002 else if (offset
> 0)
19004 /* Short opcode. */
19005 op
= (offset
- 4) >> 2;
19006 add_unwind_opcode (op
, 1);
19008 else if (offset
< 0)
19011 while (offset
> 0x100)
19013 add_unwind_opcode (0x7f, 1);
19016 op
= ((offset
- 4) >> 2) | 0x40;
19017 add_unwind_opcode (op
, 1);
19021 /* Finish the list of unwind opcodes for this function. */
19023 finish_unwind_opcodes (void)
19027 if (unwind
.fp_used
)
19029 /* Adjust sp as necessary. */
19030 unwind
.pending_offset
+= unwind
.fp_offset
- unwind
.frame_size
;
19031 flush_pending_unwind ();
19033 /* After restoring sp from the frame pointer. */
19034 op
= 0x90 | unwind
.fp_reg
;
19035 add_unwind_opcode (op
, 1);
19038 flush_pending_unwind ();
19042 /* Start an exception table entry. If idx is nonzero this is an index table
19046 start_unwind_section (const segT text_seg
, int idx
)
19048 const char * text_name
;
19049 const char * prefix
;
19050 const char * prefix_once
;
19051 const char * group_name
;
19055 size_t sec_name_len
;
19062 prefix
= ELF_STRING_ARM_unwind
;
19063 prefix_once
= ELF_STRING_ARM_unwind_once
;
19064 type
= SHT_ARM_EXIDX
;
19068 prefix
= ELF_STRING_ARM_unwind_info
;
19069 prefix_once
= ELF_STRING_ARM_unwind_info_once
;
19070 type
= SHT_PROGBITS
;
19073 text_name
= segment_name (text_seg
);
19074 if (streq (text_name
, ".text"))
19077 if (strncmp (text_name
, ".gnu.linkonce.t.",
19078 strlen (".gnu.linkonce.t.")) == 0)
19080 prefix
= prefix_once
;
19081 text_name
+= strlen (".gnu.linkonce.t.");
19084 prefix_len
= strlen (prefix
);
19085 text_len
= strlen (text_name
);
19086 sec_name_len
= prefix_len
+ text_len
;
19087 sec_name
= (char *) xmalloc (sec_name_len
+ 1);
19088 memcpy (sec_name
, prefix
, prefix_len
);
19089 memcpy (sec_name
+ prefix_len
, text_name
, text_len
);
19090 sec_name
[prefix_len
+ text_len
] = '\0';
19096 /* Handle COMDAT group. */
19097 if (prefix
!= prefix_once
&& (text_seg
->flags
& SEC_LINK_ONCE
) != 0)
19099 group_name
= elf_group_name (text_seg
);
19100 if (group_name
== NULL
)
19102 as_bad (_("Group section `%s' has no group signature"),
19103 segment_name (text_seg
));
19104 ignore_rest_of_line ();
19107 flags
|= SHF_GROUP
;
19111 obj_elf_change_section (sec_name
, type
, flags
, 0, group_name
, linkonce
, 0);
19113 /* Set the section link for index tables. */
19115 elf_linked_to_section (now_seg
) = text_seg
;
19119 /* Start an unwind table entry. HAVE_DATA is nonzero if we have additional
19120 personality routine data. Returns zero, or the index table value for
19121 and inline entry. */
19124 create_unwind_entry (int have_data
)
19129 /* The current word of data. */
19131 /* The number of bytes left in this word. */
19134 finish_unwind_opcodes ();
19136 /* Remember the current text section. */
19137 unwind
.saved_seg
= now_seg
;
19138 unwind
.saved_subseg
= now_subseg
;
19140 start_unwind_section (now_seg
, 0);
19142 if (unwind
.personality_routine
== NULL
)
19144 if (unwind
.personality_index
== -2)
19147 as_bad (_("handlerdata in cantunwind frame"));
19148 return 1; /* EXIDX_CANTUNWIND. */
19151 /* Use a default personality routine if none is specified. */
19152 if (unwind
.personality_index
== -1)
19154 if (unwind
.opcode_count
> 3)
19155 unwind
.personality_index
= 1;
19157 unwind
.personality_index
= 0;
19160 /* Space for the personality routine entry. */
19161 if (unwind
.personality_index
== 0)
19163 if (unwind
.opcode_count
> 3)
19164 as_bad (_("too many unwind opcodes for personality routine 0"));
19168 /* All the data is inline in the index table. */
19171 while (unwind
.opcode_count
> 0)
19173 unwind
.opcode_count
--;
19174 data
= (data
<< 8) | unwind
.opcodes
[unwind
.opcode_count
];
19178 /* Pad with "finish" opcodes. */
19180 data
= (data
<< 8) | 0xb0;
19187 /* We get two opcodes "free" in the first word. */
19188 size
= unwind
.opcode_count
- 2;
19191 /* An extra byte is required for the opcode count. */
19192 size
= unwind
.opcode_count
+ 1;
19194 size
= (size
+ 3) >> 2;
19196 as_bad (_("too many unwind opcodes"));
19198 frag_align (2, 0, 0);
19199 record_alignment (now_seg
, 2);
19200 unwind
.table_entry
= expr_build_dot ();
19202 /* Allocate the table entry. */
19203 ptr
= frag_more ((size
<< 2) + 4);
19204 where
= frag_now_fix () - ((size
<< 2) + 4);
19206 switch (unwind
.personality_index
)
19209 /* ??? Should this be a PLT generating relocation? */
19210 /* Custom personality routine. */
19211 fix_new (frag_now
, where
, 4, unwind
.personality_routine
, 0, 1,
19212 BFD_RELOC_ARM_PREL31
);
19217 /* Set the first byte to the number of additional words. */
19222 /* ABI defined personality routines. */
19224 /* Three opcodes bytes are packed into the first word. */
19231 /* The size and first two opcode bytes go in the first word. */
19232 data
= ((0x80 + unwind
.personality_index
) << 8) | size
;
19237 /* Should never happen. */
19241 /* Pack the opcodes into words (MSB first), reversing the list at the same
19243 while (unwind
.opcode_count
> 0)
19247 md_number_to_chars (ptr
, data
, 4);
19252 unwind
.opcode_count
--;
19254 data
= (data
<< 8) | unwind
.opcodes
[unwind
.opcode_count
];
19257 /* Finish off the last word. */
19260 /* Pad with "finish" opcodes. */
19262 data
= (data
<< 8) | 0xb0;
19264 md_number_to_chars (ptr
, data
, 4);
19269 /* Add an empty descriptor if there is no user-specified data. */
19270 ptr
= frag_more (4);
19271 md_number_to_chars (ptr
, 0, 4);
19278 /* Initialize the DWARF-2 unwind information for this procedure. */
19281 tc_arm_frame_initial_instructions (void)
19283 cfi_add_CFA_def_cfa (REG_SP
, 0);
19285 #endif /* OBJ_ELF */
19287 /* Convert REGNAME to a DWARF-2 register number. */
19290 tc_arm_regname_to_dw2regnum (char *regname
)
19292 int reg
= arm_reg_parse (®name
, REG_TYPE_RN
);
19302 tc_pe_dwarf2_emit_offset (symbolS
*symbol
, unsigned int size
)
19306 exp
.X_op
= O_secrel
;
19307 exp
.X_add_symbol
= symbol
;
19308 exp
.X_add_number
= 0;
19309 emit_expr (&exp
, size
);
19313 /* MD interface: Symbol and relocation handling. */
19315 /* Return the address within the segment that a PC-relative fixup is
19316 relative to. For ARM, PC-relative fixups applied to instructions
19317 are generally relative to the location of the fixup plus 8 bytes.
19318 Thumb branches are offset by 4, and Thumb loads relative to PC
19319 require special handling. */
19322 md_pcrel_from_section (fixS
* fixP
, segT seg
)
19324 offsetT base
= fixP
->fx_where
+ fixP
->fx_frag
->fr_address
;
19326 /* If this is pc-relative and we are going to emit a relocation
19327 then we just want to put out any pipeline compensation that the linker
19328 will need. Otherwise we want to use the calculated base.
19329 For WinCE we skip the bias for externals as well, since this
19330 is how the MS ARM-CE assembler behaves and we want to be compatible. */
19332 && ((fixP
->fx_addsy
&& S_GET_SEGMENT (fixP
->fx_addsy
) != seg
)
19333 || (arm_force_relocation (fixP
)
19335 && !S_IS_EXTERNAL (fixP
->fx_addsy
)
19341 switch (fixP
->fx_r_type
)
19343 /* PC relative addressing on the Thumb is slightly odd as the
19344 bottom two bits of the PC are forced to zero for the
19345 calculation. This happens *after* application of the
19346 pipeline offset. However, Thumb adrl already adjusts for
19347 this, so we need not do it again. */
19348 case BFD_RELOC_ARM_THUMB_ADD
:
19351 case BFD_RELOC_ARM_THUMB_OFFSET
:
19352 case BFD_RELOC_ARM_T32_OFFSET_IMM
:
19353 case BFD_RELOC_ARM_T32_ADD_PC12
:
19354 case BFD_RELOC_ARM_T32_CP_OFF_IMM
:
19355 return (base
+ 4) & ~3;
19357 /* Thumb branches are simply offset by +4. */
19358 case BFD_RELOC_THUMB_PCREL_BRANCH7
:
19359 case BFD_RELOC_THUMB_PCREL_BRANCH9
:
19360 case BFD_RELOC_THUMB_PCREL_BRANCH12
:
19361 case BFD_RELOC_THUMB_PCREL_BRANCH20
:
19362 case BFD_RELOC_THUMB_PCREL_BRANCH25
:
19365 case BFD_RELOC_THUMB_PCREL_BRANCH23
:
19367 && (S_GET_SEGMENT (fixP
->fx_addsy
) == seg
)
19368 && (!S_IS_EXTERNAL (fixP
->fx_addsy
))
19369 && ARM_IS_FUNC (fixP
->fx_addsy
)
19370 && ARM_CPU_HAS_FEATURE (selected_cpu
, arm_ext_v5t
))
19371 base
= fixP
->fx_where
+ fixP
->fx_frag
->fr_address
;
19374 /* BLX is like branches above, but forces the low two bits of PC to
19376 case BFD_RELOC_THUMB_PCREL_BLX
:
19378 && (S_GET_SEGMENT (fixP
->fx_addsy
) == seg
)
19379 && (!S_IS_EXTERNAL (fixP
->fx_addsy
))
19380 && THUMB_IS_FUNC (fixP
->fx_addsy
)
19381 && ARM_CPU_HAS_FEATURE (selected_cpu
, arm_ext_v5t
))
19382 base
= fixP
->fx_where
+ fixP
->fx_frag
->fr_address
;
19383 return (base
+ 4) & ~3;
19385 /* ARM mode branches are offset by +8. However, the Windows CE
19386 loader expects the relocation not to take this into account. */
19387 case BFD_RELOC_ARM_PCREL_BLX
:
19389 && (S_GET_SEGMENT (fixP
->fx_addsy
) == seg
)
19390 && (!S_IS_EXTERNAL (fixP
->fx_addsy
))
19391 && ARM_IS_FUNC (fixP
->fx_addsy
)
19392 && ARM_CPU_HAS_FEATURE (selected_cpu
, arm_ext_v5t
))
19393 base
= fixP
->fx_where
+ fixP
->fx_frag
->fr_address
;
19396 case BFD_RELOC_ARM_PCREL_CALL
:
19398 && (S_GET_SEGMENT (fixP
->fx_addsy
) == seg
)
19399 && (!S_IS_EXTERNAL (fixP
->fx_addsy
))
19400 && THUMB_IS_FUNC (fixP
->fx_addsy
)
19401 && ARM_CPU_HAS_FEATURE (selected_cpu
, arm_ext_v5t
))
19402 base
= fixP
->fx_where
+ fixP
->fx_frag
->fr_address
;
19405 case BFD_RELOC_ARM_PCREL_BRANCH
:
19406 case BFD_RELOC_ARM_PCREL_JUMP
:
19407 case BFD_RELOC_ARM_PLT32
:
19409 /* When handling fixups immediately, because we have already
19410 discovered the value of a symbol, or the address of the frag involved
19411 we must account for the offset by +8, as the OS loader will never see the reloc.
19412 see fixup_segment() in write.c
19413 The S_IS_EXTERNAL test handles the case of global symbols.
19414 Those need the calculated base, not just the pipe compensation the linker will need. */
19416 && fixP
->fx_addsy
!= NULL
19417 && (S_GET_SEGMENT (fixP
->fx_addsy
) == seg
)
19418 && (S_IS_EXTERNAL (fixP
->fx_addsy
) || !arm_force_relocation (fixP
)))
19426 /* ARM mode loads relative to PC are also offset by +8. Unlike
19427 branches, the Windows CE loader *does* expect the relocation
19428 to take this into account. */
19429 case BFD_RELOC_ARM_OFFSET_IMM
:
19430 case BFD_RELOC_ARM_OFFSET_IMM8
:
19431 case BFD_RELOC_ARM_HWLITERAL
:
19432 case BFD_RELOC_ARM_LITERAL
:
19433 case BFD_RELOC_ARM_CP_OFF_IMM
:
19437 /* Other PC-relative relocations are un-offset. */
19443 /* Under ELF we need to default _GLOBAL_OFFSET_TABLE.
19444 Otherwise we have no need to default values of symbols. */
19447 md_undefined_symbol (char * name ATTRIBUTE_UNUSED
)
19450 if (name
[0] == '_' && name
[1] == 'G'
19451 && streq (name
, GLOBAL_OFFSET_TABLE_NAME
))
19455 if (symbol_find (name
))
19456 as_bad (_("GOT already in the symbol table"));
19458 GOT_symbol
= symbol_new (name
, undefined_section
,
19459 (valueT
) 0, & zero_address_frag
);
19469 /* Subroutine of md_apply_fix. Check to see if an immediate can be
19470 computed as two separate immediate values, added together. We
19471 already know that this value cannot be computed by just one ARM
19474 static unsigned int
19475 validate_immediate_twopart (unsigned int val
,
19476 unsigned int * highpart
)
19481 for (i
= 0; i
< 32; i
+= 2)
19482 if (((a
= rotate_left (val
, i
)) & 0xff) != 0)
19488 * highpart
= (a
>> 8) | ((i
+ 24) << 7);
19490 else if (a
& 0xff0000)
19492 if (a
& 0xff000000)
19494 * highpart
= (a
>> 16) | ((i
+ 16) << 7);
19498 gas_assert (a
& 0xff000000);
19499 * highpart
= (a
>> 24) | ((i
+ 8) << 7);
19502 return (a
& 0xff) | (i
<< 7);
19509 validate_offset_imm (unsigned int val
, int hwse
)
19511 if ((hwse
&& val
> 255) || val
> 4095)
19516 /* Subroutine of md_apply_fix. Do those data_ops which can take a
19517 negative immediate constant by altering the instruction. A bit of
19522 by inverting the second operand, and
19525 by negating the second operand. */
19528 negate_data_op (unsigned long * instruction
,
19529 unsigned long value
)
19532 unsigned long negated
, inverted
;
19534 negated
= encode_arm_immediate (-value
);
19535 inverted
= encode_arm_immediate (~value
);
19537 op
= (*instruction
>> DATA_OP_SHIFT
) & 0xf;
19540 /* First negates. */
19541 case OPCODE_SUB
: /* ADD <-> SUB */
19542 new_inst
= OPCODE_ADD
;
19547 new_inst
= OPCODE_SUB
;
19551 case OPCODE_CMP
: /* CMP <-> CMN */
19552 new_inst
= OPCODE_CMN
;
19557 new_inst
= OPCODE_CMP
;
19561 /* Now Inverted ops. */
19562 case OPCODE_MOV
: /* MOV <-> MVN */
19563 new_inst
= OPCODE_MVN
;
19568 new_inst
= OPCODE_MOV
;
19572 case OPCODE_AND
: /* AND <-> BIC */
19573 new_inst
= OPCODE_BIC
;
19578 new_inst
= OPCODE_AND
;
19582 case OPCODE_ADC
: /* ADC <-> SBC */
19583 new_inst
= OPCODE_SBC
;
19588 new_inst
= OPCODE_ADC
;
19592 /* We cannot do anything. */
19597 if (value
== (unsigned) FAIL
)
19600 *instruction
&= OPCODE_MASK
;
19601 *instruction
|= new_inst
<< DATA_OP_SHIFT
;
19605 /* Like negate_data_op, but for Thumb-2. */
19607 static unsigned int
19608 thumb32_negate_data_op (offsetT
*instruction
, unsigned int value
)
19612 unsigned int negated
, inverted
;
19614 negated
= encode_thumb32_immediate (-value
);
19615 inverted
= encode_thumb32_immediate (~value
);
19617 rd
= (*instruction
>> 8) & 0xf;
19618 op
= (*instruction
>> T2_DATA_OP_SHIFT
) & 0xf;
19621 /* ADD <-> SUB. Includes CMP <-> CMN. */
19622 case T2_OPCODE_SUB
:
19623 new_inst
= T2_OPCODE_ADD
;
19627 case T2_OPCODE_ADD
:
19628 new_inst
= T2_OPCODE_SUB
;
19632 /* ORR <-> ORN. Includes MOV <-> MVN. */
19633 case T2_OPCODE_ORR
:
19634 new_inst
= T2_OPCODE_ORN
;
19638 case T2_OPCODE_ORN
:
19639 new_inst
= T2_OPCODE_ORR
;
19643 /* AND <-> BIC. TST has no inverted equivalent. */
19644 case T2_OPCODE_AND
:
19645 new_inst
= T2_OPCODE_BIC
;
19652 case T2_OPCODE_BIC
:
19653 new_inst
= T2_OPCODE_AND
;
19658 case T2_OPCODE_ADC
:
19659 new_inst
= T2_OPCODE_SBC
;
19663 case T2_OPCODE_SBC
:
19664 new_inst
= T2_OPCODE_ADC
;
19668 /* We cannot do anything. */
19673 if (value
== (unsigned int)FAIL
)
19676 *instruction
&= T2_OPCODE_MASK
;
19677 *instruction
|= new_inst
<< T2_DATA_OP_SHIFT
;
19681 /* Read a 32-bit thumb instruction from buf. */
19682 static unsigned long
19683 get_thumb32_insn (char * buf
)
19685 unsigned long insn
;
19686 insn
= md_chars_to_number (buf
, THUMB_SIZE
) << 16;
19687 insn
|= md_chars_to_number (buf
+ THUMB_SIZE
, THUMB_SIZE
);
19693 /* We usually want to set the low bit on the address of thumb function
19694 symbols. In particular .word foo - . should have the low bit set.
19695 Generic code tries to fold the difference of two symbols to
19696 a constant. Prevent this and force a relocation when the first symbols
19697 is a thumb function. */
19700 arm_optimize_expr (expressionS
*l
, operatorT op
, expressionS
*r
)
19702 if (op
== O_subtract
19703 && l
->X_op
== O_symbol
19704 && r
->X_op
== O_symbol
19705 && THUMB_IS_FUNC (l
->X_add_symbol
))
19707 l
->X_op
= O_subtract
;
19708 l
->X_op_symbol
= r
->X_add_symbol
;
19709 l
->X_add_number
-= r
->X_add_number
;
19713 /* Process as normal. */
19717 /* Encode Thumb2 unconditional branches and calls. The encoding
19718 for the 2 are identical for the immediate values. */
19721 encode_thumb2_b_bl_offset (char * buf
, offsetT value
)
19723 #define T2I1I2MASK ((1 << 13) | (1 << 11))
19726 addressT S
, I1
, I2
, lo
, hi
;
19728 S
= (value
>> 24) & 0x01;
19729 I1
= (value
>> 23) & 0x01;
19730 I2
= (value
>> 22) & 0x01;
19731 hi
= (value
>> 12) & 0x3ff;
19732 lo
= (value
>> 1) & 0x7ff;
19733 newval
= md_chars_to_number (buf
, THUMB_SIZE
);
19734 newval2
= md_chars_to_number (buf
+ THUMB_SIZE
, THUMB_SIZE
);
19735 newval
|= (S
<< 10) | hi
;
19736 newval2
&= ~T2I1I2MASK
;
19737 newval2
|= (((I1
^ S
) << 13) | ((I2
^ S
) << 11) | lo
) ^ T2I1I2MASK
;
19738 md_number_to_chars (buf
, newval
, THUMB_SIZE
);
19739 md_number_to_chars (buf
+ THUMB_SIZE
, newval2
, THUMB_SIZE
);
19743 md_apply_fix (fixS
* fixP
,
19747 offsetT value
= * valP
;
19749 unsigned int newimm
;
19750 unsigned long temp
;
19752 char * buf
= fixP
->fx_where
+ fixP
->fx_frag
->fr_literal
;
19754 gas_assert (fixP
->fx_r_type
<= BFD_RELOC_UNUSED
);
19756 /* Note whether this will delete the relocation. */
19758 if (fixP
->fx_addsy
== 0 && !fixP
->fx_pcrel
)
19761 /* On a 64-bit host, silently truncate 'value' to 32 bits for
19762 consistency with the behaviour on 32-bit hosts. Remember value
19764 value
&= 0xffffffff;
19765 value
^= 0x80000000;
19766 value
-= 0x80000000;
19769 fixP
->fx_addnumber
= value
;
19771 /* Same treatment for fixP->fx_offset. */
19772 fixP
->fx_offset
&= 0xffffffff;
19773 fixP
->fx_offset
^= 0x80000000;
19774 fixP
->fx_offset
-= 0x80000000;
19776 switch (fixP
->fx_r_type
)
19778 case BFD_RELOC_NONE
:
19779 /* This will need to go in the object file. */
19783 case BFD_RELOC_ARM_IMMEDIATE
:
19784 /* We claim that this fixup has been processed here,
19785 even if in fact we generate an error because we do
19786 not have a reloc for it, so tc_gen_reloc will reject it. */
19789 if (fixP
->fx_addsy
)
19791 const char *msg
= 0;
19793 if (! S_IS_DEFINED (fixP
->fx_addsy
))
19794 msg
= _("undefined symbol %s used as an immediate value");
19795 else if (S_GET_SEGMENT (fixP
->fx_addsy
) != seg
)
19796 msg
= _("symbol %s is in a different section");
19797 else if (S_IS_WEAK (fixP
->fx_addsy
))
19798 msg
= _("symbol %s is weak and may be overridden later");
19802 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
19803 msg
, S_GET_NAME (fixP
->fx_addsy
));
19808 newimm
= encode_arm_immediate (value
);
19809 temp
= md_chars_to_number (buf
, INSN_SIZE
);
19811 /* If the instruction will fail, see if we can fix things up by
19812 changing the opcode. */
19813 if (newimm
== (unsigned int) FAIL
19814 && (newimm
= negate_data_op (&temp
, value
)) == (unsigned int) FAIL
)
19816 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
19817 _("invalid constant (%lx) after fixup"),
19818 (unsigned long) value
);
19822 newimm
|= (temp
& 0xfffff000);
19823 md_number_to_chars (buf
, (valueT
) newimm
, INSN_SIZE
);
19826 case BFD_RELOC_ARM_ADRL_IMMEDIATE
:
19828 unsigned int highpart
= 0;
19829 unsigned int newinsn
= 0xe1a00000; /* nop. */
19831 if (fixP
->fx_addsy
)
19833 const char *msg
= 0;
19835 if (! S_IS_DEFINED (fixP
->fx_addsy
))
19836 msg
= _("undefined symbol %s used as an immediate value");
19837 else if (S_GET_SEGMENT (fixP
->fx_addsy
) != seg
)
19838 msg
= _("symbol %s is in a different section");
19839 else if (S_IS_WEAK (fixP
->fx_addsy
))
19840 msg
= _("symbol %s is weak and may be overridden later");
19844 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
19845 msg
, S_GET_NAME (fixP
->fx_addsy
));
19850 newimm
= encode_arm_immediate (value
);
19851 temp
= md_chars_to_number (buf
, INSN_SIZE
);
19853 /* If the instruction will fail, see if we can fix things up by
19854 changing the opcode. */
19855 if (newimm
== (unsigned int) FAIL
19856 && (newimm
= negate_data_op (& temp
, value
)) == (unsigned int) FAIL
)
19858 /* No ? OK - try using two ADD instructions to generate
19860 newimm
= validate_immediate_twopart (value
, & highpart
);
19862 /* Yes - then make sure that the second instruction is
19864 if (newimm
!= (unsigned int) FAIL
)
19866 /* Still No ? Try using a negated value. */
19867 else if ((newimm
= validate_immediate_twopart (- value
, & highpart
)) != (unsigned int) FAIL
)
19868 temp
= newinsn
= (temp
& OPCODE_MASK
) | OPCODE_SUB
<< DATA_OP_SHIFT
;
19869 /* Otherwise - give up. */
19872 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
19873 _("unable to compute ADRL instructions for PC offset of 0x%lx"),
19878 /* Replace the first operand in the 2nd instruction (which
19879 is the PC) with the destination register. We have
19880 already added in the PC in the first instruction and we
19881 do not want to do it again. */
19882 newinsn
&= ~ 0xf0000;
19883 newinsn
|= ((newinsn
& 0x0f000) << 4);
19886 newimm
|= (temp
& 0xfffff000);
19887 md_number_to_chars (buf
, (valueT
) newimm
, INSN_SIZE
);
19889 highpart
|= (newinsn
& 0xfffff000);
19890 md_number_to_chars (buf
+ INSN_SIZE
, (valueT
) highpart
, INSN_SIZE
);
19894 case BFD_RELOC_ARM_OFFSET_IMM
:
19895 if (!fixP
->fx_done
&& seg
->use_rela_p
)
19898 case BFD_RELOC_ARM_LITERAL
:
19904 if (validate_offset_imm (value
, 0) == FAIL
)
19906 if (fixP
->fx_r_type
== BFD_RELOC_ARM_LITERAL
)
19907 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
19908 _("invalid literal constant: pool needs to be closer"));
19910 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
19911 _("bad immediate value for offset (%ld)"),
19916 newval
= md_chars_to_number (buf
, INSN_SIZE
);
19917 newval
&= 0xff7ff000;
19918 newval
|= value
| (sign
? INDEX_UP
: 0);
19919 md_number_to_chars (buf
, newval
, INSN_SIZE
);
19922 case BFD_RELOC_ARM_OFFSET_IMM8
:
19923 case BFD_RELOC_ARM_HWLITERAL
:
19929 if (validate_offset_imm (value
, 1) == FAIL
)
19931 if (fixP
->fx_r_type
== BFD_RELOC_ARM_HWLITERAL
)
19932 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
19933 _("invalid literal constant: pool needs to be closer"));
19935 as_bad (_("bad immediate value for 8-bit offset (%ld)"),
19940 newval
= md_chars_to_number (buf
, INSN_SIZE
);
19941 newval
&= 0xff7ff0f0;
19942 newval
|= ((value
>> 4) << 8) | (value
& 0xf) | (sign
? INDEX_UP
: 0);
19943 md_number_to_chars (buf
, newval
, INSN_SIZE
);
19946 case BFD_RELOC_ARM_T32_OFFSET_U8
:
19947 if (value
< 0 || value
> 1020 || value
% 4 != 0)
19948 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
19949 _("bad immediate value for offset (%ld)"), (long) value
);
19952 newval
= md_chars_to_number (buf
+2, THUMB_SIZE
);
19954 md_number_to_chars (buf
+2, newval
, THUMB_SIZE
);
19957 case BFD_RELOC_ARM_T32_OFFSET_IMM
:
19958 /* This is a complicated relocation used for all varieties of Thumb32
19959 load/store instruction with immediate offset:
19961 1110 100P u1WL NNNN XXXX YYYY iiii iiii - +/-(U) pre/post(P) 8-bit,
19962 *4, optional writeback(W)
19963 (doubleword load/store)
19965 1111 100S uTTL 1111 XXXX iiii iiii iiii - +/-(U) 12-bit PC-rel
19966 1111 100S 0TTL NNNN XXXX 1Pu1 iiii iiii - +/-(U) pre/post(P) 8-bit
19967 1111 100S 0TTL NNNN XXXX 1110 iiii iiii - positive 8-bit (T instruction)
19968 1111 100S 1TTL NNNN XXXX iiii iiii iiii - positive 12-bit
19969 1111 100S 0TTL NNNN XXXX 1100 iiii iiii - negative 8-bit
19971 Uppercase letters indicate bits that are already encoded at
19972 this point. Lowercase letters are our problem. For the
19973 second block of instructions, the secondary opcode nybble
19974 (bits 8..11) is present, and bit 23 is zero, even if this is
19975 a PC-relative operation. */
19976 newval
= md_chars_to_number (buf
, THUMB_SIZE
);
19978 newval
|= md_chars_to_number (buf
+THUMB_SIZE
, THUMB_SIZE
);
19980 if ((newval
& 0xf0000000) == 0xe0000000)
19982 /* Doubleword load/store: 8-bit offset, scaled by 4. */
19984 newval
|= (1 << 23);
19987 if (value
% 4 != 0)
19989 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
19990 _("offset not a multiple of 4"));
19996 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
19997 _("offset out of range"));
20002 else if ((newval
& 0x000f0000) == 0x000f0000)
20004 /* PC-relative, 12-bit offset. */
20006 newval
|= (1 << 23);
20011 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
20012 _("offset out of range"));
20017 else if ((newval
& 0x00000100) == 0x00000100)
20019 /* Writeback: 8-bit, +/- offset. */
20021 newval
|= (1 << 9);
20026 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
20027 _("offset out of range"));
20032 else if ((newval
& 0x00000f00) == 0x00000e00)
20034 /* T-instruction: positive 8-bit offset. */
20035 if (value
< 0 || value
> 0xff)
20037 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
20038 _("offset out of range"));
20046 /* Positive 12-bit or negative 8-bit offset. */
20050 newval
|= (1 << 23);
20060 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
20061 _("offset out of range"));
20068 md_number_to_chars (buf
, (newval
>> 16) & 0xffff, THUMB_SIZE
);
20069 md_number_to_chars (buf
+ THUMB_SIZE
, newval
& 0xffff, THUMB_SIZE
);
20072 case BFD_RELOC_ARM_SHIFT_IMM
:
20073 newval
= md_chars_to_number (buf
, INSN_SIZE
);
20074 if (((unsigned long) value
) > 32
20076 && (((newval
& 0x60) == 0) || (newval
& 0x60) == 0x60)))
20078 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
20079 _("shift expression is too large"));
20084 /* Shifts of zero must be done as lsl. */
20086 else if (value
== 32)
20088 newval
&= 0xfffff07f;
20089 newval
|= (value
& 0x1f) << 7;
20090 md_number_to_chars (buf
, newval
, INSN_SIZE
);
20093 case BFD_RELOC_ARM_T32_IMMEDIATE
:
20094 case BFD_RELOC_ARM_T32_ADD_IMM
:
20095 case BFD_RELOC_ARM_T32_IMM12
:
20096 case BFD_RELOC_ARM_T32_ADD_PC12
:
20097 /* We claim that this fixup has been processed here,
20098 even if in fact we generate an error because we do
20099 not have a reloc for it, so tc_gen_reloc will reject it. */
20103 && ! S_IS_DEFINED (fixP
->fx_addsy
))
20105 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
20106 _("undefined symbol %s used as an immediate value"),
20107 S_GET_NAME (fixP
->fx_addsy
));
20111 newval
= md_chars_to_number (buf
, THUMB_SIZE
);
20113 newval
|= md_chars_to_number (buf
+2, THUMB_SIZE
);
20116 if (fixP
->fx_r_type
== BFD_RELOC_ARM_T32_IMMEDIATE
20117 || fixP
->fx_r_type
== BFD_RELOC_ARM_T32_ADD_IMM
)
20119 newimm
= encode_thumb32_immediate (value
);
20120 if (newimm
== (unsigned int) FAIL
)
20121 newimm
= thumb32_negate_data_op (&newval
, value
);
20123 if (fixP
->fx_r_type
!= BFD_RELOC_ARM_T32_IMMEDIATE
20124 && newimm
== (unsigned int) FAIL
)
20126 /* Turn add/sum into addw/subw. */
20127 if (fixP
->fx_r_type
== BFD_RELOC_ARM_T32_ADD_IMM
)
20128 newval
= (newval
& 0xfeffffff) | 0x02000000;
20130 /* 12 bit immediate for addw/subw. */
20134 newval
^= 0x00a00000;
20137 newimm
= (unsigned int) FAIL
;
20142 if (newimm
== (unsigned int)FAIL
)
20144 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
20145 _("invalid constant (%lx) after fixup"),
20146 (unsigned long) value
);
20150 newval
|= (newimm
& 0x800) << 15;
20151 newval
|= (newimm
& 0x700) << 4;
20152 newval
|= (newimm
& 0x0ff);
20154 md_number_to_chars (buf
, (valueT
) ((newval
>> 16) & 0xffff), THUMB_SIZE
);
20155 md_number_to_chars (buf
+2, (valueT
) (newval
& 0xffff), THUMB_SIZE
);
20158 case BFD_RELOC_ARM_SMC
:
20159 if (((unsigned long) value
) > 0xffff)
20160 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
20161 _("invalid smc expression"));
20162 newval
= md_chars_to_number (buf
, INSN_SIZE
);
20163 newval
|= (value
& 0xf) | ((value
& 0xfff0) << 4);
20164 md_number_to_chars (buf
, newval
, INSN_SIZE
);
20167 case BFD_RELOC_ARM_SWI
:
20168 if (fixP
->tc_fix_data
!= 0)
20170 if (((unsigned long) value
) > 0xff)
20171 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
20172 _("invalid swi expression"));
20173 newval
= md_chars_to_number (buf
, THUMB_SIZE
);
20175 md_number_to_chars (buf
, newval
, THUMB_SIZE
);
20179 if (((unsigned long) value
) > 0x00ffffff)
20180 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
20181 _("invalid swi expression"));
20182 newval
= md_chars_to_number (buf
, INSN_SIZE
);
20184 md_number_to_chars (buf
, newval
, INSN_SIZE
);
20188 case BFD_RELOC_ARM_MULTI
:
20189 if (((unsigned long) value
) > 0xffff)
20190 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
20191 _("invalid expression in load/store multiple"));
20192 newval
= value
| md_chars_to_number (buf
, INSN_SIZE
);
20193 md_number_to_chars (buf
, newval
, INSN_SIZE
);
20197 case BFD_RELOC_ARM_PCREL_CALL
:
20199 if (ARM_CPU_HAS_FEATURE (selected_cpu
, arm_ext_v5t
)
20201 && !S_IS_EXTERNAL (fixP
->fx_addsy
)
20202 && (S_GET_SEGMENT (fixP
->fx_addsy
) == seg
)
20203 && THUMB_IS_FUNC (fixP
->fx_addsy
))
20204 /* Flip the bl to blx. This is a simple flip
20205 bit here because we generate PCREL_CALL for
20206 unconditional bls. */
20208 newval
= md_chars_to_number (buf
, INSN_SIZE
);
20209 newval
= newval
| 0x10000000;
20210 md_number_to_chars (buf
, newval
, INSN_SIZE
);
20216 goto arm_branch_common
;
20218 case BFD_RELOC_ARM_PCREL_JUMP
:
20219 if (ARM_CPU_HAS_FEATURE (selected_cpu
, arm_ext_v5t
)
20221 && !S_IS_EXTERNAL (fixP
->fx_addsy
)
20222 && (S_GET_SEGMENT (fixP
->fx_addsy
) == seg
)
20223 && THUMB_IS_FUNC (fixP
->fx_addsy
))
20225 /* This would map to a bl<cond>, b<cond>,
20226 b<always> to a Thumb function. We
20227 need to force a relocation for this particular
20229 newval
= md_chars_to_number (buf
, INSN_SIZE
);
20233 case BFD_RELOC_ARM_PLT32
:
20235 case BFD_RELOC_ARM_PCREL_BRANCH
:
20237 goto arm_branch_common
;
20239 case BFD_RELOC_ARM_PCREL_BLX
:
20242 if (ARM_CPU_HAS_FEATURE (selected_cpu
, arm_ext_v5t
)
20244 && !S_IS_EXTERNAL (fixP
->fx_addsy
)
20245 && (S_GET_SEGMENT (fixP
->fx_addsy
) == seg
)
20246 && ARM_IS_FUNC (fixP
->fx_addsy
))
20248 /* Flip the blx to a bl and warn. */
20249 const char *name
= S_GET_NAME (fixP
->fx_addsy
);
20250 newval
= 0xeb000000;
20251 as_warn_where (fixP
->fx_file
, fixP
->fx_line
,
20252 _("blx to '%s' an ARM ISA state function changed to bl"),
20254 md_number_to_chars (buf
, newval
, INSN_SIZE
);
20260 if (EF_ARM_EABI_VERSION (meabi_flags
) >= EF_ARM_EABI_VER4
)
20261 fixP
->fx_r_type
= BFD_RELOC_ARM_PCREL_CALL
;
20265 /* We are going to store value (shifted right by two) in the
20266 instruction, in a 24 bit, signed field. Bits 26 through 32 either
20267 all clear or all set and bit 0 must be clear. For B/BL bit 1 must
20268 also be be clear. */
20270 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
20271 _("misaligned branch destination"));
20272 if ((value
& (offsetT
)0xfe000000) != (offsetT
)0
20273 && (value
& (offsetT
)0xfe000000) != (offsetT
)0xfe000000)
20274 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
20275 _("branch out of range"));
20277 if (fixP
->fx_done
|| !seg
->use_rela_p
)
20279 newval
= md_chars_to_number (buf
, INSN_SIZE
);
20280 newval
|= (value
>> 2) & 0x00ffffff;
20281 /* Set the H bit on BLX instructions. */
20285 newval
|= 0x01000000;
20287 newval
&= ~0x01000000;
20289 md_number_to_chars (buf
, newval
, INSN_SIZE
);
20293 case BFD_RELOC_THUMB_PCREL_BRANCH7
: /* CBZ */
20294 /* CBZ can only branch forward. */
20296 /* Attempts to use CBZ to branch to the next instruction
20297 (which, strictly speaking, are prohibited) will be turned into
20300 FIXME: It may be better to remove the instruction completely and
20301 perform relaxation. */
20304 newval
= md_chars_to_number (buf
, THUMB_SIZE
);
20305 newval
= 0xbf00; /* NOP encoding T1 */
20306 md_number_to_chars (buf
, newval
, THUMB_SIZE
);
20311 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
20312 _("branch out of range"));
20314 if (fixP
->fx_done
|| !seg
->use_rela_p
)
20316 newval
= md_chars_to_number (buf
, THUMB_SIZE
);
20317 newval
|= ((value
& 0x3e) << 2) | ((value
& 0x40) << 3);
20318 md_number_to_chars (buf
, newval
, THUMB_SIZE
);
20323 case BFD_RELOC_THUMB_PCREL_BRANCH9
: /* Conditional branch. */
20324 if ((value
& ~0xff) && ((value
& ~0xff) != ~0xff))
20325 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
20326 _("branch out of range"));
20328 if (fixP
->fx_done
|| !seg
->use_rela_p
)
20330 newval
= md_chars_to_number (buf
, THUMB_SIZE
);
20331 newval
|= (value
& 0x1ff) >> 1;
20332 md_number_to_chars (buf
, newval
, THUMB_SIZE
);
20336 case BFD_RELOC_THUMB_PCREL_BRANCH12
: /* Unconditional branch. */
20337 if ((value
& ~0x7ff) && ((value
& ~0x7ff) != ~0x7ff))
20338 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
20339 _("branch out of range"));
20341 if (fixP
->fx_done
|| !seg
->use_rela_p
)
20343 newval
= md_chars_to_number (buf
, THUMB_SIZE
);
20344 newval
|= (value
& 0xfff) >> 1;
20345 md_number_to_chars (buf
, newval
, THUMB_SIZE
);
20349 case BFD_RELOC_THUMB_PCREL_BRANCH20
:
20351 && (S_GET_SEGMENT (fixP
->fx_addsy
) == seg
)
20352 && !S_IS_EXTERNAL (fixP
->fx_addsy
)
20353 && S_IS_DEFINED (fixP
->fx_addsy
)
20354 && ARM_IS_FUNC (fixP
->fx_addsy
)
20355 && ARM_CPU_HAS_FEATURE (selected_cpu
, arm_ext_v5t
))
20357 /* Force a relocation for a branch 20 bits wide. */
20360 if ((value
& ~0x1fffff) && ((value
& ~0x1fffff) != ~0x1fffff))
20361 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
20362 _("conditional branch out of range"));
20364 if (fixP
->fx_done
|| !seg
->use_rela_p
)
20367 addressT S
, J1
, J2
, lo
, hi
;
20369 S
= (value
& 0x00100000) >> 20;
20370 J2
= (value
& 0x00080000) >> 19;
20371 J1
= (value
& 0x00040000) >> 18;
20372 hi
= (value
& 0x0003f000) >> 12;
20373 lo
= (value
& 0x00000ffe) >> 1;
20375 newval
= md_chars_to_number (buf
, THUMB_SIZE
);
20376 newval2
= md_chars_to_number (buf
+ THUMB_SIZE
, THUMB_SIZE
);
20377 newval
|= (S
<< 10) | hi
;
20378 newval2
|= (J1
<< 13) | (J2
<< 11) | lo
;
20379 md_number_to_chars (buf
, newval
, THUMB_SIZE
);
20380 md_number_to_chars (buf
+ THUMB_SIZE
, newval2
, THUMB_SIZE
);
20384 case BFD_RELOC_THUMB_PCREL_BLX
:
20386 /* If there is a blx from a thumb state function to
20387 another thumb function flip this to a bl and warn
20391 && S_IS_DEFINED (fixP
->fx_addsy
)
20392 && !S_IS_EXTERNAL (fixP
->fx_addsy
)
20393 && (S_GET_SEGMENT (fixP
->fx_addsy
) == seg
)
20394 && THUMB_IS_FUNC (fixP
->fx_addsy
))
20396 const char *name
= S_GET_NAME (fixP
->fx_addsy
);
20397 as_warn_where (fixP
->fx_file
, fixP
->fx_line
,
20398 _("blx to Thumb func '%s' from Thumb ISA state changed to bl"),
20400 newval
= md_chars_to_number (buf
+ THUMB_SIZE
, THUMB_SIZE
);
20401 newval
= newval
| 0x1000;
20402 md_number_to_chars (buf
+THUMB_SIZE
, newval
, THUMB_SIZE
);
20403 fixP
->fx_r_type
= BFD_RELOC_THUMB_PCREL_BRANCH23
;
20408 goto thumb_bl_common
;
20410 case BFD_RELOC_THUMB_PCREL_BRANCH23
:
20412 /* A bl from Thumb state ISA to an internal ARM state function
20413 is converted to a blx. */
20415 && (S_GET_SEGMENT (fixP
->fx_addsy
) == seg
)
20416 && !S_IS_EXTERNAL (fixP
->fx_addsy
)
20417 && S_IS_DEFINED (fixP
->fx_addsy
)
20418 && ARM_IS_FUNC (fixP
->fx_addsy
)
20419 && ARM_CPU_HAS_FEATURE (selected_cpu
, arm_ext_v5t
))
20421 newval
= md_chars_to_number (buf
+ THUMB_SIZE
, THUMB_SIZE
);
20422 newval
= newval
& ~0x1000;
20423 md_number_to_chars (buf
+THUMB_SIZE
, newval
, THUMB_SIZE
);
20424 fixP
->fx_r_type
= BFD_RELOC_THUMB_PCREL_BLX
;
20431 if (EF_ARM_EABI_VERSION (meabi_flags
) >= EF_ARM_EABI_VER4
&&
20432 fixP
->fx_r_type
== BFD_RELOC_THUMB_PCREL_BLX
)
20433 fixP
->fx_r_type
= BFD_RELOC_THUMB_PCREL_BRANCH23
;
20436 if (fixP
->fx_r_type
== BFD_RELOC_THUMB_PCREL_BLX
)
20437 /* For a BLX instruction, make sure that the relocation is rounded up
20438 to a word boundary. This follows the semantics of the instruction
20439 which specifies that bit 1 of the target address will come from bit
20440 1 of the base address. */
20441 value
= (value
+ 1) & ~ 1;
20444 if ((value
& ~0x3fffff) && ((value
& ~0x3fffff) != ~0x3fffff))
20446 if (!(ARM_CPU_HAS_FEATURE (cpu_variant
, arm_arch_t2
)))
20448 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
20449 _("branch out of range"));
20451 else if ((value
& ~0x1ffffff)
20452 && ((value
& ~0x1ffffff) != ~0x1ffffff))
20454 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
20455 _("Thumb2 branch out of range"));
20459 if (fixP
->fx_done
|| !seg
->use_rela_p
)
20460 encode_thumb2_b_bl_offset (buf
, value
);
20464 case BFD_RELOC_THUMB_PCREL_BRANCH25
:
20465 if ((value
& ~0x1ffffff) && ((value
& ~0x1ffffff) != ~0x1ffffff))
20466 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
20467 _("branch out of range"));
20469 if (fixP
->fx_done
|| !seg
->use_rela_p
)
20470 encode_thumb2_b_bl_offset (buf
, value
);
20475 if (fixP
->fx_done
|| !seg
->use_rela_p
)
20476 md_number_to_chars (buf
, value
, 1);
20480 if (fixP
->fx_done
|| !seg
->use_rela_p
)
20481 md_number_to_chars (buf
, value
, 2);
20485 case BFD_RELOC_ARM_TLS_GD32
:
20486 case BFD_RELOC_ARM_TLS_LE32
:
20487 case BFD_RELOC_ARM_TLS_IE32
:
20488 case BFD_RELOC_ARM_TLS_LDM32
:
20489 case BFD_RELOC_ARM_TLS_LDO32
:
20490 S_SET_THREAD_LOCAL (fixP
->fx_addsy
);
20493 case BFD_RELOC_ARM_GOT32
:
20494 case BFD_RELOC_ARM_GOTOFF
:
20495 if (fixP
->fx_done
|| !seg
->use_rela_p
)
20496 md_number_to_chars (buf
, 0, 4);
20499 case BFD_RELOC_ARM_GOT_PREL
:
20500 if (fixP
->fx_done
|| !seg
->use_rela_p
)
20501 md_number_to_chars (buf
, value
, 4);
20504 case BFD_RELOC_ARM_TARGET2
:
20505 /* TARGET2 is not partial-inplace, so we need to write the
20506 addend here for REL targets, because it won't be written out
20507 during reloc processing later. */
20508 if (fixP
->fx_done
|| !seg
->use_rela_p
)
20509 md_number_to_chars (buf
, fixP
->fx_offset
, 4);
20513 case BFD_RELOC_RVA
:
20515 case BFD_RELOC_ARM_TARGET1
:
20516 case BFD_RELOC_ARM_ROSEGREL32
:
20517 case BFD_RELOC_ARM_SBREL32
:
20518 case BFD_RELOC_32_PCREL
:
20520 case BFD_RELOC_32_SECREL
:
20522 if (fixP
->fx_done
|| !seg
->use_rela_p
)
20524 /* For WinCE we only do this for pcrel fixups. */
20525 if (fixP
->fx_done
|| fixP
->fx_pcrel
)
20527 md_number_to_chars (buf
, value
, 4);
20531 case BFD_RELOC_ARM_PREL31
:
20532 if (fixP
->fx_done
|| !seg
->use_rela_p
)
20534 newval
= md_chars_to_number (buf
, 4) & 0x80000000;
20535 if ((value
^ (value
>> 1)) & 0x40000000)
20537 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
20538 _("rel31 relocation overflow"));
20540 newval
|= value
& 0x7fffffff;
20541 md_number_to_chars (buf
, newval
, 4);
20546 case BFD_RELOC_ARM_CP_OFF_IMM
:
20547 case BFD_RELOC_ARM_T32_CP_OFF_IMM
:
20548 if (value
< -1023 || value
> 1023 || (value
& 3))
20549 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
20550 _("co-processor offset out of range"));
20555 if (fixP
->fx_r_type
== BFD_RELOC_ARM_CP_OFF_IMM
20556 || fixP
->fx_r_type
== BFD_RELOC_ARM_CP_OFF_IMM_S2
)
20557 newval
= md_chars_to_number (buf
, INSN_SIZE
);
20559 newval
= get_thumb32_insn (buf
);
20560 newval
&= 0xff7fff00;
20561 newval
|= (value
>> 2) | (sign
? INDEX_UP
: 0);
20562 if (fixP
->fx_r_type
== BFD_RELOC_ARM_CP_OFF_IMM
20563 || fixP
->fx_r_type
== BFD_RELOC_ARM_CP_OFF_IMM_S2
)
20564 md_number_to_chars (buf
, newval
, INSN_SIZE
);
20566 put_thumb32_insn (buf
, newval
);
20569 case BFD_RELOC_ARM_CP_OFF_IMM_S2
:
20570 case BFD_RELOC_ARM_T32_CP_OFF_IMM_S2
:
20571 if (value
< -255 || value
> 255)
20572 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
20573 _("co-processor offset out of range"));
20575 goto cp_off_common
;
20577 case BFD_RELOC_ARM_THUMB_OFFSET
:
20578 newval
= md_chars_to_number (buf
, THUMB_SIZE
);
20579 /* Exactly what ranges, and where the offset is inserted depends
20580 on the type of instruction, we can establish this from the
20582 switch (newval
>> 12)
20584 case 4: /* PC load. */
20585 /* Thumb PC loads are somewhat odd, bit 1 of the PC is
20586 forced to zero for these loads; md_pcrel_from has already
20587 compensated for this. */
20589 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
20590 _("invalid offset, target not word aligned (0x%08lX)"),
20591 (((unsigned long) fixP
->fx_frag
->fr_address
20592 + (unsigned long) fixP
->fx_where
) & ~3)
20593 + (unsigned long) value
);
20595 if (value
& ~0x3fc)
20596 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
20597 _("invalid offset, value too big (0x%08lX)"),
20600 newval
|= value
>> 2;
20603 case 9: /* SP load/store. */
20604 if (value
& ~0x3fc)
20605 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
20606 _("invalid offset, value too big (0x%08lX)"),
20608 newval
|= value
>> 2;
20611 case 6: /* Word load/store. */
20613 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
20614 _("invalid offset, value too big (0x%08lX)"),
20616 newval
|= value
<< 4; /* 6 - 2. */
20619 case 7: /* Byte load/store. */
20621 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
20622 _("invalid offset, value too big (0x%08lX)"),
20624 newval
|= value
<< 6;
20627 case 8: /* Halfword load/store. */
20629 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
20630 _("invalid offset, value too big (0x%08lX)"),
20632 newval
|= value
<< 5; /* 6 - 1. */
20636 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
20637 "Unable to process relocation for thumb opcode: %lx",
20638 (unsigned long) newval
);
20641 md_number_to_chars (buf
, newval
, THUMB_SIZE
);
20644 case BFD_RELOC_ARM_THUMB_ADD
:
20645 /* This is a complicated relocation, since we use it for all of
20646 the following immediate relocations:
20650 9bit ADD/SUB SP word-aligned
20651 10bit ADD PC/SP word-aligned
20653 The type of instruction being processed is encoded in the
20660 newval
= md_chars_to_number (buf
, THUMB_SIZE
);
20662 int rd
= (newval
>> 4) & 0xf;
20663 int rs
= newval
& 0xf;
20664 int subtract
= !!(newval
& 0x8000);
20666 /* Check for HI regs, only very restricted cases allowed:
20667 Adjusting SP, and using PC or SP to get an address. */
20668 if ((rd
> 7 && (rd
!= REG_SP
|| rs
!= REG_SP
))
20669 || (rs
> 7 && rs
!= REG_SP
&& rs
!= REG_PC
))
20670 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
20671 _("invalid Hi register with immediate"));
20673 /* If value is negative, choose the opposite instruction. */
20677 subtract
= !subtract
;
20679 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
20680 _("immediate value out of range"));
20685 if (value
& ~0x1fc)
20686 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
20687 _("invalid immediate for stack address calculation"));
20688 newval
= subtract
? T_OPCODE_SUB_ST
: T_OPCODE_ADD_ST
;
20689 newval
|= value
>> 2;
20691 else if (rs
== REG_PC
|| rs
== REG_SP
)
20693 if (subtract
|| value
& ~0x3fc)
20694 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
20695 _("invalid immediate for address calculation (value = 0x%08lX)"),
20696 (unsigned long) value
);
20697 newval
= (rs
== REG_PC
? T_OPCODE_ADD_PC
: T_OPCODE_ADD_SP
);
20699 newval
|= value
>> 2;
20704 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
20705 _("immediate value out of range"));
20706 newval
= subtract
? T_OPCODE_SUB_I8
: T_OPCODE_ADD_I8
;
20707 newval
|= (rd
<< 8) | value
;
20712 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
20713 _("immediate value out of range"));
20714 newval
= subtract
? T_OPCODE_SUB_I3
: T_OPCODE_ADD_I3
;
20715 newval
|= rd
| (rs
<< 3) | (value
<< 6);
20718 md_number_to_chars (buf
, newval
, THUMB_SIZE
);
20721 case BFD_RELOC_ARM_THUMB_IMM
:
20722 newval
= md_chars_to_number (buf
, THUMB_SIZE
);
20723 if (value
< 0 || value
> 255)
20724 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
20725 _("invalid immediate: %ld is out of range"),
20728 md_number_to_chars (buf
, newval
, THUMB_SIZE
);
20731 case BFD_RELOC_ARM_THUMB_SHIFT
:
20732 /* 5bit shift value (0..32). LSL cannot take 32. */
20733 newval
= md_chars_to_number (buf
, THUMB_SIZE
) & 0xf83f;
20734 temp
= newval
& 0xf800;
20735 if (value
< 0 || value
> 32 || (value
== 32 && temp
== T_OPCODE_LSL_I
))
20736 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
20737 _("invalid shift value: %ld"), (long) value
);
20738 /* Shifts of zero must be encoded as LSL. */
20740 newval
= (newval
& 0x003f) | T_OPCODE_LSL_I
;
20741 /* Shifts of 32 are encoded as zero. */
20742 else if (value
== 32)
20744 newval
|= value
<< 6;
20745 md_number_to_chars (buf
, newval
, THUMB_SIZE
);
20748 case BFD_RELOC_VTABLE_INHERIT
:
20749 case BFD_RELOC_VTABLE_ENTRY
:
20753 case BFD_RELOC_ARM_MOVW
:
20754 case BFD_RELOC_ARM_MOVT
:
20755 case BFD_RELOC_ARM_THUMB_MOVW
:
20756 case BFD_RELOC_ARM_THUMB_MOVT
:
20757 if (fixP
->fx_done
|| !seg
->use_rela_p
)
20759 /* REL format relocations are limited to a 16-bit addend. */
20760 if (!fixP
->fx_done
)
20762 if (value
< -0x8000 || value
> 0x7fff)
20763 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
20764 _("offset out of range"));
20766 else if (fixP
->fx_r_type
== BFD_RELOC_ARM_MOVT
20767 || fixP
->fx_r_type
== BFD_RELOC_ARM_THUMB_MOVT
)
20772 if (fixP
->fx_r_type
== BFD_RELOC_ARM_THUMB_MOVW
20773 || fixP
->fx_r_type
== BFD_RELOC_ARM_THUMB_MOVT
)
20775 newval
= get_thumb32_insn (buf
);
20776 newval
&= 0xfbf08f00;
20777 newval
|= (value
& 0xf000) << 4;
20778 newval
|= (value
& 0x0800) << 15;
20779 newval
|= (value
& 0x0700) << 4;
20780 newval
|= (value
& 0x00ff);
20781 put_thumb32_insn (buf
, newval
);
20785 newval
= md_chars_to_number (buf
, 4);
20786 newval
&= 0xfff0f000;
20787 newval
|= value
& 0x0fff;
20788 newval
|= (value
& 0xf000) << 4;
20789 md_number_to_chars (buf
, newval
, 4);
20794 case BFD_RELOC_ARM_ALU_PC_G0_NC
:
20795 case BFD_RELOC_ARM_ALU_PC_G0
:
20796 case BFD_RELOC_ARM_ALU_PC_G1_NC
:
20797 case BFD_RELOC_ARM_ALU_PC_G1
:
20798 case BFD_RELOC_ARM_ALU_PC_G2
:
20799 case BFD_RELOC_ARM_ALU_SB_G0_NC
:
20800 case BFD_RELOC_ARM_ALU_SB_G0
:
20801 case BFD_RELOC_ARM_ALU_SB_G1_NC
:
20802 case BFD_RELOC_ARM_ALU_SB_G1
:
20803 case BFD_RELOC_ARM_ALU_SB_G2
:
20804 gas_assert (!fixP
->fx_done
);
20805 if (!seg
->use_rela_p
)
20808 bfd_vma encoded_addend
;
20809 bfd_vma addend_abs
= abs (value
);
20811 /* Check that the absolute value of the addend can be
20812 expressed as an 8-bit constant plus a rotation. */
20813 encoded_addend
= encode_arm_immediate (addend_abs
);
20814 if (encoded_addend
== (unsigned int) FAIL
)
20815 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
20816 _("the offset 0x%08lX is not representable"),
20817 (unsigned long) addend_abs
);
20819 /* Extract the instruction. */
20820 insn
= md_chars_to_number (buf
, INSN_SIZE
);
20822 /* If the addend is positive, use an ADD instruction.
20823 Otherwise use a SUB. Take care not to destroy the S bit. */
20824 insn
&= 0xff1fffff;
20830 /* Place the encoded addend into the first 12 bits of the
20832 insn
&= 0xfffff000;
20833 insn
|= encoded_addend
;
20835 /* Update the instruction. */
20836 md_number_to_chars (buf
, insn
, INSN_SIZE
);
20840 case BFD_RELOC_ARM_LDR_PC_G0
:
20841 case BFD_RELOC_ARM_LDR_PC_G1
:
20842 case BFD_RELOC_ARM_LDR_PC_G2
:
20843 case BFD_RELOC_ARM_LDR_SB_G0
:
20844 case BFD_RELOC_ARM_LDR_SB_G1
:
20845 case BFD_RELOC_ARM_LDR_SB_G2
:
20846 gas_assert (!fixP
->fx_done
);
20847 if (!seg
->use_rela_p
)
20850 bfd_vma addend_abs
= abs (value
);
20852 /* Check that the absolute value of the addend can be
20853 encoded in 12 bits. */
20854 if (addend_abs
>= 0x1000)
20855 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
20856 _("bad offset 0x%08lX (only 12 bits available for the magnitude)"),
20857 (unsigned long) addend_abs
);
20859 /* Extract the instruction. */
20860 insn
= md_chars_to_number (buf
, INSN_SIZE
);
20862 /* If the addend is negative, clear bit 23 of the instruction.
20863 Otherwise set it. */
20865 insn
&= ~(1 << 23);
20869 /* Place the absolute value of the addend into the first 12 bits
20870 of the instruction. */
20871 insn
&= 0xfffff000;
20872 insn
|= addend_abs
;
20874 /* Update the instruction. */
20875 md_number_to_chars (buf
, insn
, INSN_SIZE
);
20879 case BFD_RELOC_ARM_LDRS_PC_G0
:
20880 case BFD_RELOC_ARM_LDRS_PC_G1
:
20881 case BFD_RELOC_ARM_LDRS_PC_G2
:
20882 case BFD_RELOC_ARM_LDRS_SB_G0
:
20883 case BFD_RELOC_ARM_LDRS_SB_G1
:
20884 case BFD_RELOC_ARM_LDRS_SB_G2
:
20885 gas_assert (!fixP
->fx_done
);
20886 if (!seg
->use_rela_p
)
20889 bfd_vma addend_abs
= abs (value
);
20891 /* Check that the absolute value of the addend can be
20892 encoded in 8 bits. */
20893 if (addend_abs
>= 0x100)
20894 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
20895 _("bad offset 0x%08lX (only 8 bits available for the magnitude)"),
20896 (unsigned long) addend_abs
);
20898 /* Extract the instruction. */
20899 insn
= md_chars_to_number (buf
, INSN_SIZE
);
20901 /* If the addend is negative, clear bit 23 of the instruction.
20902 Otherwise set it. */
20904 insn
&= ~(1 << 23);
20908 /* Place the first four bits of the absolute value of the addend
20909 into the first 4 bits of the instruction, and the remaining
20910 four into bits 8 .. 11. */
20911 insn
&= 0xfffff0f0;
20912 insn
|= (addend_abs
& 0xf) | ((addend_abs
& 0xf0) << 4);
20914 /* Update the instruction. */
20915 md_number_to_chars (buf
, insn
, INSN_SIZE
);
20919 case BFD_RELOC_ARM_LDC_PC_G0
:
20920 case BFD_RELOC_ARM_LDC_PC_G1
:
20921 case BFD_RELOC_ARM_LDC_PC_G2
:
20922 case BFD_RELOC_ARM_LDC_SB_G0
:
20923 case BFD_RELOC_ARM_LDC_SB_G1
:
20924 case BFD_RELOC_ARM_LDC_SB_G2
:
20925 gas_assert (!fixP
->fx_done
);
20926 if (!seg
->use_rela_p
)
20929 bfd_vma addend_abs
= abs (value
);
20931 /* Check that the absolute value of the addend is a multiple of
20932 four and, when divided by four, fits in 8 bits. */
20933 if (addend_abs
& 0x3)
20934 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
20935 _("bad offset 0x%08lX (must be word-aligned)"),
20936 (unsigned long) addend_abs
);
20938 if ((addend_abs
>> 2) > 0xff)
20939 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
20940 _("bad offset 0x%08lX (must be an 8-bit number of words)"),
20941 (unsigned long) addend_abs
);
20943 /* Extract the instruction. */
20944 insn
= md_chars_to_number (buf
, INSN_SIZE
);
20946 /* If the addend is negative, clear bit 23 of the instruction.
20947 Otherwise set it. */
20949 insn
&= ~(1 << 23);
20953 /* Place the addend (divided by four) into the first eight
20954 bits of the instruction. */
20955 insn
&= 0xfffffff0;
20956 insn
|= addend_abs
>> 2;
20958 /* Update the instruction. */
20959 md_number_to_chars (buf
, insn
, INSN_SIZE
);
20963 case BFD_RELOC_ARM_V4BX
:
20964 /* This will need to go in the object file. */
20968 case BFD_RELOC_UNUSED
:
20970 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
20971 _("bad relocation fixup type (%d)"), fixP
->fx_r_type
);
20975 /* Translate internal representation of relocation info to BFD target
20979 tc_gen_reloc (asection
*section
, fixS
*fixp
)
20982 bfd_reloc_code_real_type code
;
20984 reloc
= (arelent
*) xmalloc (sizeof (arelent
));
20986 reloc
->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
20987 *reloc
->sym_ptr_ptr
= symbol_get_bfdsym (fixp
->fx_addsy
);
20988 reloc
->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
20990 if (fixp
->fx_pcrel
)
20992 if (section
->use_rela_p
)
20993 fixp
->fx_offset
-= md_pcrel_from_section (fixp
, section
);
20995 fixp
->fx_offset
= reloc
->address
;
20997 reloc
->addend
= fixp
->fx_offset
;
20999 switch (fixp
->fx_r_type
)
21002 if (fixp
->fx_pcrel
)
21004 code
= BFD_RELOC_8_PCREL
;
21009 if (fixp
->fx_pcrel
)
21011 code
= BFD_RELOC_16_PCREL
;
21016 if (fixp
->fx_pcrel
)
21018 code
= BFD_RELOC_32_PCREL
;
21022 case BFD_RELOC_ARM_MOVW
:
21023 if (fixp
->fx_pcrel
)
21025 code
= BFD_RELOC_ARM_MOVW_PCREL
;
21029 case BFD_RELOC_ARM_MOVT
:
21030 if (fixp
->fx_pcrel
)
21032 code
= BFD_RELOC_ARM_MOVT_PCREL
;
21036 case BFD_RELOC_ARM_THUMB_MOVW
:
21037 if (fixp
->fx_pcrel
)
21039 code
= BFD_RELOC_ARM_THUMB_MOVW_PCREL
;
21043 case BFD_RELOC_ARM_THUMB_MOVT
:
21044 if (fixp
->fx_pcrel
)
21046 code
= BFD_RELOC_ARM_THUMB_MOVT_PCREL
;
21050 case BFD_RELOC_NONE
:
21051 case BFD_RELOC_ARM_PCREL_BRANCH
:
21052 case BFD_RELOC_ARM_PCREL_BLX
:
21053 case BFD_RELOC_RVA
:
21054 case BFD_RELOC_THUMB_PCREL_BRANCH7
:
21055 case BFD_RELOC_THUMB_PCREL_BRANCH9
:
21056 case BFD_RELOC_THUMB_PCREL_BRANCH12
:
21057 case BFD_RELOC_THUMB_PCREL_BRANCH20
:
21058 case BFD_RELOC_THUMB_PCREL_BRANCH23
:
21059 case BFD_RELOC_THUMB_PCREL_BRANCH25
:
21060 case BFD_RELOC_VTABLE_ENTRY
:
21061 case BFD_RELOC_VTABLE_INHERIT
:
21063 case BFD_RELOC_32_SECREL
:
21065 code
= fixp
->fx_r_type
;
21068 case BFD_RELOC_THUMB_PCREL_BLX
:
21070 if (EF_ARM_EABI_VERSION (meabi_flags
) >= EF_ARM_EABI_VER4
)
21071 code
= BFD_RELOC_THUMB_PCREL_BRANCH23
;
21074 code
= BFD_RELOC_THUMB_PCREL_BLX
;
21077 case BFD_RELOC_ARM_LITERAL
:
21078 case BFD_RELOC_ARM_HWLITERAL
:
21079 /* If this is called then the a literal has
21080 been referenced across a section boundary. */
21081 as_bad_where (fixp
->fx_file
, fixp
->fx_line
,
21082 _("literal referenced across section boundary"));
21086 case BFD_RELOC_ARM_GOT32
:
21087 case BFD_RELOC_ARM_GOTOFF
:
21088 case BFD_RELOC_ARM_GOT_PREL
:
21089 case BFD_RELOC_ARM_PLT32
:
21090 case BFD_RELOC_ARM_TARGET1
:
21091 case BFD_RELOC_ARM_ROSEGREL32
:
21092 case BFD_RELOC_ARM_SBREL32
:
21093 case BFD_RELOC_ARM_PREL31
:
21094 case BFD_RELOC_ARM_TARGET2
:
21095 case BFD_RELOC_ARM_TLS_LE32
:
21096 case BFD_RELOC_ARM_TLS_LDO32
:
21097 case BFD_RELOC_ARM_PCREL_CALL
:
21098 case BFD_RELOC_ARM_PCREL_JUMP
:
21099 case BFD_RELOC_ARM_ALU_PC_G0_NC
:
21100 case BFD_RELOC_ARM_ALU_PC_G0
:
21101 case BFD_RELOC_ARM_ALU_PC_G1_NC
:
21102 case BFD_RELOC_ARM_ALU_PC_G1
:
21103 case BFD_RELOC_ARM_ALU_PC_G2
:
21104 case BFD_RELOC_ARM_LDR_PC_G0
:
21105 case BFD_RELOC_ARM_LDR_PC_G1
:
21106 case BFD_RELOC_ARM_LDR_PC_G2
:
21107 case BFD_RELOC_ARM_LDRS_PC_G0
:
21108 case BFD_RELOC_ARM_LDRS_PC_G1
:
21109 case BFD_RELOC_ARM_LDRS_PC_G2
:
21110 case BFD_RELOC_ARM_LDC_PC_G0
:
21111 case BFD_RELOC_ARM_LDC_PC_G1
:
21112 case BFD_RELOC_ARM_LDC_PC_G2
:
21113 case BFD_RELOC_ARM_ALU_SB_G0_NC
:
21114 case BFD_RELOC_ARM_ALU_SB_G0
:
21115 case BFD_RELOC_ARM_ALU_SB_G1_NC
:
21116 case BFD_RELOC_ARM_ALU_SB_G1
:
21117 case BFD_RELOC_ARM_ALU_SB_G2
:
21118 case BFD_RELOC_ARM_LDR_SB_G0
:
21119 case BFD_RELOC_ARM_LDR_SB_G1
:
21120 case BFD_RELOC_ARM_LDR_SB_G2
:
21121 case BFD_RELOC_ARM_LDRS_SB_G0
:
21122 case BFD_RELOC_ARM_LDRS_SB_G1
:
21123 case BFD_RELOC_ARM_LDRS_SB_G2
:
21124 case BFD_RELOC_ARM_LDC_SB_G0
:
21125 case BFD_RELOC_ARM_LDC_SB_G1
:
21126 case BFD_RELOC_ARM_LDC_SB_G2
:
21127 case BFD_RELOC_ARM_V4BX
:
21128 code
= fixp
->fx_r_type
;
21131 case BFD_RELOC_ARM_TLS_GD32
:
21132 case BFD_RELOC_ARM_TLS_IE32
:
21133 case BFD_RELOC_ARM_TLS_LDM32
:
21134 /* BFD will include the symbol's address in the addend.
21135 But we don't want that, so subtract it out again here. */
21136 if (!S_IS_COMMON (fixp
->fx_addsy
))
21137 reloc
->addend
-= (*reloc
->sym_ptr_ptr
)->value
;
21138 code
= fixp
->fx_r_type
;
21142 case BFD_RELOC_ARM_IMMEDIATE
:
21143 as_bad_where (fixp
->fx_file
, fixp
->fx_line
,
21144 _("internal relocation (type: IMMEDIATE) not fixed up"));
21147 case BFD_RELOC_ARM_ADRL_IMMEDIATE
:
21148 as_bad_where (fixp
->fx_file
, fixp
->fx_line
,
21149 _("ADRL used for a symbol not defined in the same file"));
21152 case BFD_RELOC_ARM_OFFSET_IMM
:
21153 if (section
->use_rela_p
)
21155 code
= fixp
->fx_r_type
;
21159 if (fixp
->fx_addsy
!= NULL
21160 && !S_IS_DEFINED (fixp
->fx_addsy
)
21161 && S_IS_LOCAL (fixp
->fx_addsy
))
21163 as_bad_where (fixp
->fx_file
, fixp
->fx_line
,
21164 _("undefined local label `%s'"),
21165 S_GET_NAME (fixp
->fx_addsy
));
21169 as_bad_where (fixp
->fx_file
, fixp
->fx_line
,
21170 _("internal_relocation (type: OFFSET_IMM) not fixed up"));
21177 switch (fixp
->fx_r_type
)
21179 case BFD_RELOC_NONE
: type
= "NONE"; break;
21180 case BFD_RELOC_ARM_OFFSET_IMM8
: type
= "OFFSET_IMM8"; break;
21181 case BFD_RELOC_ARM_SHIFT_IMM
: type
= "SHIFT_IMM"; break;
21182 case BFD_RELOC_ARM_SMC
: type
= "SMC"; break;
21183 case BFD_RELOC_ARM_SWI
: type
= "SWI"; break;
21184 case BFD_RELOC_ARM_MULTI
: type
= "MULTI"; break;
21185 case BFD_RELOC_ARM_CP_OFF_IMM
: type
= "CP_OFF_IMM"; break;
21186 case BFD_RELOC_ARM_T32_CP_OFF_IMM
: type
= "T32_CP_OFF_IMM"; break;
21187 case BFD_RELOC_ARM_THUMB_ADD
: type
= "THUMB_ADD"; break;
21188 case BFD_RELOC_ARM_THUMB_SHIFT
: type
= "THUMB_SHIFT"; break;
21189 case BFD_RELOC_ARM_THUMB_IMM
: type
= "THUMB_IMM"; break;
21190 case BFD_RELOC_ARM_THUMB_OFFSET
: type
= "THUMB_OFFSET"; break;
21191 default: type
= _("<unknown>"); break;
21193 as_bad_where (fixp
->fx_file
, fixp
->fx_line
,
21194 _("cannot represent %s relocation in this object file format"),
21201 if ((code
== BFD_RELOC_32_PCREL
|| code
== BFD_RELOC_32
)
21203 && fixp
->fx_addsy
== GOT_symbol
)
21205 code
= BFD_RELOC_ARM_GOTPC
;
21206 reloc
->addend
= fixp
->fx_offset
= reloc
->address
;
21210 reloc
->howto
= bfd_reloc_type_lookup (stdoutput
, code
);
21212 if (reloc
->howto
== NULL
)
21214 as_bad_where (fixp
->fx_file
, fixp
->fx_line
,
21215 _("cannot represent %s relocation in this object file format"),
21216 bfd_get_reloc_code_name (code
));
21220 /* HACK: Since arm ELF uses Rel instead of Rela, encode the
21221 vtable entry to be used in the relocation's section offset. */
21222 if (fixp
->fx_r_type
== BFD_RELOC_VTABLE_ENTRY
)
21223 reloc
->address
= fixp
->fx_offset
;
21228 /* This fix_new is called by cons via TC_CONS_FIX_NEW. */
21231 cons_fix_new_arm (fragS
* frag
,
21236 bfd_reloc_code_real_type type
;
21240 FIXME: @@ Should look at CPU word size. */
21244 type
= BFD_RELOC_8
;
21247 type
= BFD_RELOC_16
;
21251 type
= BFD_RELOC_32
;
21254 type
= BFD_RELOC_64
;
21259 if (exp
->X_op
== O_secrel
)
21261 exp
->X_op
= O_symbol
;
21262 type
= BFD_RELOC_32_SECREL
;
21266 fix_new_exp (frag
, where
, (int) size
, exp
, pcrel
, type
);
21269 #if defined (OBJ_COFF)
21271 arm_validate_fix (fixS
* fixP
)
21273 /* If the destination of the branch is a defined symbol which does not have
21274 the THUMB_FUNC attribute, then we must be calling a function which has
21275 the (interfacearm) attribute. We look for the Thumb entry point to that
21276 function and change the branch to refer to that function instead. */
21277 if (fixP
->fx_r_type
== BFD_RELOC_THUMB_PCREL_BRANCH23
21278 && fixP
->fx_addsy
!= NULL
21279 && S_IS_DEFINED (fixP
->fx_addsy
)
21280 && ! THUMB_IS_FUNC (fixP
->fx_addsy
))
21282 fixP
->fx_addsy
= find_real_start (fixP
->fx_addsy
);
21289 arm_force_relocation (struct fix
* fixp
)
21291 #if defined (OBJ_COFF) && defined (TE_PE)
21292 if (fixp
->fx_r_type
== BFD_RELOC_RVA
)
21296 /* In case we have a call or a branch to a function in ARM ISA mode from
21297 a thumb function or vice-versa force the relocation. These relocations
21298 are cleared off for some cores that might have blx and simple transformations
21302 switch (fixp
->fx_r_type
)
21304 case BFD_RELOC_ARM_PCREL_JUMP
:
21305 case BFD_RELOC_ARM_PCREL_CALL
:
21306 case BFD_RELOC_THUMB_PCREL_BLX
:
21307 if (THUMB_IS_FUNC (fixp
->fx_addsy
))
21311 case BFD_RELOC_ARM_PCREL_BLX
:
21312 case BFD_RELOC_THUMB_PCREL_BRANCH25
:
21313 case BFD_RELOC_THUMB_PCREL_BRANCH20
:
21314 case BFD_RELOC_THUMB_PCREL_BRANCH23
:
21315 if (ARM_IS_FUNC (fixp
->fx_addsy
))
21324 /* Resolve these relocations even if the symbol is extern or weak. */
21325 if (fixp
->fx_r_type
== BFD_RELOC_ARM_IMMEDIATE
21326 || fixp
->fx_r_type
== BFD_RELOC_ARM_OFFSET_IMM
21327 || fixp
->fx_r_type
== BFD_RELOC_ARM_ADRL_IMMEDIATE
21328 || fixp
->fx_r_type
== BFD_RELOC_ARM_T32_ADD_IMM
21329 || fixp
->fx_r_type
== BFD_RELOC_ARM_T32_IMMEDIATE
21330 || fixp
->fx_r_type
== BFD_RELOC_ARM_T32_IMM12
21331 || fixp
->fx_r_type
== BFD_RELOC_ARM_T32_ADD_PC12
)
21334 /* Always leave these relocations for the linker. */
21335 if ((fixp
->fx_r_type
>= BFD_RELOC_ARM_ALU_PC_G0_NC
21336 && fixp
->fx_r_type
<= BFD_RELOC_ARM_LDC_SB_G2
)
21337 || fixp
->fx_r_type
== BFD_RELOC_ARM_LDR_PC_G0
)
21340 /* Always generate relocations against function symbols. */
21341 if (fixp
->fx_r_type
== BFD_RELOC_32
21343 && (symbol_get_bfdsym (fixp
->fx_addsy
)->flags
& BSF_FUNCTION
))
21346 return generic_force_reloc (fixp
);
21349 #if defined (OBJ_ELF) || defined (OBJ_COFF)
21350 /* Relocations against function names must be left unadjusted,
21351 so that the linker can use this information to generate interworking
21352 stubs. The MIPS version of this function
21353 also prevents relocations that are mips-16 specific, but I do not
21354 know why it does this.
21357 There is one other problem that ought to be addressed here, but
21358 which currently is not: Taking the address of a label (rather
21359 than a function) and then later jumping to that address. Such
21360 addresses also ought to have their bottom bit set (assuming that
21361 they reside in Thumb code), but at the moment they will not. */
21364 arm_fix_adjustable (fixS
* fixP
)
21366 if (fixP
->fx_addsy
== NULL
)
21369 /* Preserve relocations against symbols with function type. */
21370 if (symbol_get_bfdsym (fixP
->fx_addsy
)->flags
& BSF_FUNCTION
)
21373 if (THUMB_IS_FUNC (fixP
->fx_addsy
)
21374 && fixP
->fx_subsy
== NULL
)
21377 /* We need the symbol name for the VTABLE entries. */
21378 if ( fixP
->fx_r_type
== BFD_RELOC_VTABLE_INHERIT
21379 || fixP
->fx_r_type
== BFD_RELOC_VTABLE_ENTRY
)
21382 /* Don't allow symbols to be discarded on GOT related relocs. */
21383 if (fixP
->fx_r_type
== BFD_RELOC_ARM_PLT32
21384 || fixP
->fx_r_type
== BFD_RELOC_ARM_GOT32
21385 || fixP
->fx_r_type
== BFD_RELOC_ARM_GOTOFF
21386 || fixP
->fx_r_type
== BFD_RELOC_ARM_TLS_GD32
21387 || fixP
->fx_r_type
== BFD_RELOC_ARM_TLS_LE32
21388 || fixP
->fx_r_type
== BFD_RELOC_ARM_TLS_IE32
21389 || fixP
->fx_r_type
== BFD_RELOC_ARM_TLS_LDM32
21390 || fixP
->fx_r_type
== BFD_RELOC_ARM_TLS_LDO32
21391 || fixP
->fx_r_type
== BFD_RELOC_ARM_TARGET2
)
21394 /* Similarly for group relocations. */
21395 if ((fixP
->fx_r_type
>= BFD_RELOC_ARM_ALU_PC_G0_NC
21396 && fixP
->fx_r_type
<= BFD_RELOC_ARM_LDC_SB_G2
)
21397 || fixP
->fx_r_type
== BFD_RELOC_ARM_LDR_PC_G0
)
21400 /* MOVW/MOVT REL relocations have limited offsets, so keep the symbols. */
21401 if (fixP
->fx_r_type
== BFD_RELOC_ARM_MOVW
21402 || fixP
->fx_r_type
== BFD_RELOC_ARM_MOVT
21403 || fixP
->fx_r_type
== BFD_RELOC_ARM_MOVW_PCREL
21404 || fixP
->fx_r_type
== BFD_RELOC_ARM_MOVT_PCREL
21405 || fixP
->fx_r_type
== BFD_RELOC_ARM_THUMB_MOVW
21406 || fixP
->fx_r_type
== BFD_RELOC_ARM_THUMB_MOVT
21407 || fixP
->fx_r_type
== BFD_RELOC_ARM_THUMB_MOVW_PCREL
21408 || fixP
->fx_r_type
== BFD_RELOC_ARM_THUMB_MOVT_PCREL
)
21413 #endif /* defined (OBJ_ELF) || defined (OBJ_COFF) */
21418 elf32_arm_target_format (void)
21421 return (target_big_endian
21422 ? "elf32-bigarm-symbian"
21423 : "elf32-littlearm-symbian");
21424 #elif defined (TE_VXWORKS)
21425 return (target_big_endian
21426 ? "elf32-bigarm-vxworks"
21427 : "elf32-littlearm-vxworks");
21429 if (target_big_endian
)
21430 return "elf32-bigarm";
21432 return "elf32-littlearm";
21437 armelf_frob_symbol (symbolS
* symp
,
21440 elf_frob_symbol (symp
, puntp
);
21444 /* MD interface: Finalization. */
21449 literal_pool
* pool
;
21451 /* Ensure that all the IT blocks are properly closed. */
21452 check_it_blocks_finished ();
21454 for (pool
= list_of_pools
; pool
; pool
= pool
->next
)
21456 /* Put it at the end of the relevant section. */
21457 subseg_set (pool
->section
, pool
->sub_section
);
21459 arm_elf_change_section ();
21466 /* Remove any excess mapping symbols generated for alignment frags in
21467 SEC. We may have created a mapping symbol before a zero byte
21468 alignment; remove it if there's a mapping symbol after the
21471 check_mapping_symbols (bfd
*abfd ATTRIBUTE_UNUSED
, asection
*sec
,
21472 void *dummy ATTRIBUTE_UNUSED
)
21474 segment_info_type
*seginfo
= seg_info (sec
);
21477 if (seginfo
== NULL
|| seginfo
->frchainP
== NULL
)
21480 for (fragp
= seginfo
->frchainP
->frch_root
;
21482 fragp
= fragp
->fr_next
)
21484 symbolS
*sym
= fragp
->tc_frag_data
.last_map
;
21485 fragS
*next
= fragp
->fr_next
;
21487 /* Variable-sized frags have been converted to fixed size by
21488 this point. But if this was variable-sized to start with,
21489 there will be a fixed-size frag after it. So don't handle
21491 if (sym
== NULL
|| next
== NULL
)
21494 if (S_GET_VALUE (sym
) < next
->fr_address
)
21495 /* Not at the end of this frag. */
21497 know (S_GET_VALUE (sym
) == next
->fr_address
);
21501 if (next
->tc_frag_data
.first_map
!= NULL
)
21503 /* Next frag starts with a mapping symbol. Discard this
21505 symbol_remove (sym
, &symbol_rootP
, &symbol_lastP
);
21509 if (next
->fr_next
== NULL
)
21511 /* This mapping symbol is at the end of the section. Discard
21513 know (next
->fr_fix
== 0 && next
->fr_var
== 0);
21514 symbol_remove (sym
, &symbol_rootP
, &symbol_lastP
);
21518 /* As long as we have empty frags without any mapping symbols,
21520 /* If the next frag is non-empty and does not start with a
21521 mapping symbol, then this mapping symbol is required. */
21522 if (next
->fr_address
!= next
->fr_next
->fr_address
)
21525 next
= next
->fr_next
;
21527 while (next
!= NULL
);
21532 /* Adjust the symbol table. This marks Thumb symbols as distinct from
21536 arm_adjust_symtab (void)
21541 for (sym
= symbol_rootP
; sym
!= NULL
; sym
= symbol_next (sym
))
21543 if (ARM_IS_THUMB (sym
))
21545 if (THUMB_IS_FUNC (sym
))
21547 /* Mark the symbol as a Thumb function. */
21548 if ( S_GET_STORAGE_CLASS (sym
) == C_STAT
21549 || S_GET_STORAGE_CLASS (sym
) == C_LABEL
) /* This can happen! */
21550 S_SET_STORAGE_CLASS (sym
, C_THUMBSTATFUNC
);
21552 else if (S_GET_STORAGE_CLASS (sym
) == C_EXT
)
21553 S_SET_STORAGE_CLASS (sym
, C_THUMBEXTFUNC
);
21555 as_bad (_("%s: unexpected function type: %d"),
21556 S_GET_NAME (sym
), S_GET_STORAGE_CLASS (sym
));
21558 else switch (S_GET_STORAGE_CLASS (sym
))
21561 S_SET_STORAGE_CLASS (sym
, C_THUMBEXT
);
21564 S_SET_STORAGE_CLASS (sym
, C_THUMBSTAT
);
21567 S_SET_STORAGE_CLASS (sym
, C_THUMBLABEL
);
21575 if (ARM_IS_INTERWORK (sym
))
21576 coffsymbol (symbol_get_bfdsym (sym
))->native
->u
.syment
.n_flags
= 0xFF;
21583 for (sym
= symbol_rootP
; sym
!= NULL
; sym
= symbol_next (sym
))
21585 if (ARM_IS_THUMB (sym
))
21587 elf_symbol_type
* elf_sym
;
21589 elf_sym
= elf_symbol (symbol_get_bfdsym (sym
));
21590 bind
= ELF_ST_BIND (elf_sym
->internal_elf_sym
.st_info
);
21592 if (! bfd_is_arm_special_symbol_name (elf_sym
->symbol
.name
,
21593 BFD_ARM_SPECIAL_SYM_TYPE_ANY
))
21595 /* If it's a .thumb_func, declare it as so,
21596 otherwise tag label as .code 16. */
21597 if (THUMB_IS_FUNC (sym
))
21598 elf_sym
->internal_elf_sym
.st_info
=
21599 ELF_ST_INFO (bind
, STT_ARM_TFUNC
);
21600 else if (EF_ARM_EABI_VERSION (meabi_flags
) < EF_ARM_EABI_VER4
)
21601 elf_sym
->internal_elf_sym
.st_info
=
21602 ELF_ST_INFO (bind
, STT_ARM_16BIT
);
21607 /* Remove any overlapping mapping symbols generated by alignment frags. */
21608 bfd_map_over_sections (stdoutput
, check_mapping_symbols
, (char *) 0);
21612 /* MD interface: Initialization. */
21615 set_constant_flonums (void)
21619 for (i
= 0; i
< NUM_FLOAT_VALS
; i
++)
21620 if (atof_ieee ((char *) fp_const
[i
], 'x', fp_values
[i
]) == NULL
)
21624 /* Auto-select Thumb mode if it's the only available instruction set for the
21625 given architecture. */
21628 autoselect_thumb_from_cpu_variant (void)
21630 if (!ARM_CPU_HAS_FEATURE (cpu_variant
, arm_ext_v1
))
21631 opcode_select (16);
21640 if ( (arm_ops_hsh
= hash_new ()) == NULL
21641 || (arm_cond_hsh
= hash_new ()) == NULL
21642 || (arm_shift_hsh
= hash_new ()) == NULL
21643 || (arm_psr_hsh
= hash_new ()) == NULL
21644 || (arm_v7m_psr_hsh
= hash_new ()) == NULL
21645 || (arm_reg_hsh
= hash_new ()) == NULL
21646 || (arm_reloc_hsh
= hash_new ()) == NULL
21647 || (arm_barrier_opt_hsh
= hash_new ()) == NULL
)
21648 as_fatal (_("virtual memory exhausted"));
21650 for (i
= 0; i
< sizeof (insns
) / sizeof (struct asm_opcode
); i
++)
21651 hash_insert (arm_ops_hsh
, insns
[i
].template_name
, (void *) (insns
+ i
));
21652 for (i
= 0; i
< sizeof (conds
) / sizeof (struct asm_cond
); i
++)
21653 hash_insert (arm_cond_hsh
, conds
[i
].template_name
, (void *) (conds
+ i
));
21654 for (i
= 0; i
< sizeof (shift_names
) / sizeof (struct asm_shift_name
); i
++)
21655 hash_insert (arm_shift_hsh
, shift_names
[i
].name
, (void *) (shift_names
+ i
));
21656 for (i
= 0; i
< sizeof (psrs
) / sizeof (struct asm_psr
); i
++)
21657 hash_insert (arm_psr_hsh
, psrs
[i
].template_name
, (void *) (psrs
+ i
));
21658 for (i
= 0; i
< sizeof (v7m_psrs
) / sizeof (struct asm_psr
); i
++)
21659 hash_insert (arm_v7m_psr_hsh
, v7m_psrs
[i
].template_name
,
21660 (void *) (v7m_psrs
+ i
));
21661 for (i
= 0; i
< sizeof (reg_names
) / sizeof (struct reg_entry
); i
++)
21662 hash_insert (arm_reg_hsh
, reg_names
[i
].name
, (void *) (reg_names
+ i
));
21664 i
< sizeof (barrier_opt_names
) / sizeof (struct asm_barrier_opt
);
21666 hash_insert (arm_barrier_opt_hsh
, barrier_opt_names
[i
].template_name
,
21667 (void *) (barrier_opt_names
+ i
));
21669 for (i
= 0; i
< sizeof (reloc_names
) / sizeof (struct reloc_entry
); i
++)
21670 hash_insert (arm_reloc_hsh
, reloc_names
[i
].name
, (void *) (reloc_names
+ i
));
21673 set_constant_flonums ();
21675 /* Set the cpu variant based on the command-line options. We prefer
21676 -mcpu= over -march= if both are set (as for GCC); and we prefer
21677 -mfpu= over any other way of setting the floating point unit.
21678 Use of legacy options with new options are faulted. */
21681 if (mcpu_cpu_opt
|| march_cpu_opt
)
21682 as_bad (_("use of old and new-style options to set CPU type"));
21684 mcpu_cpu_opt
= legacy_cpu
;
21686 else if (!mcpu_cpu_opt
)
21687 mcpu_cpu_opt
= march_cpu_opt
;
21692 as_bad (_("use of old and new-style options to set FPU type"));
21694 mfpu_opt
= legacy_fpu
;
21696 else if (!mfpu_opt
)
21698 #if !(defined (EABI_DEFAULT) || defined (TE_LINUX) \
21699 || defined (TE_NetBSD) || defined (TE_VXWORKS))
21700 /* Some environments specify a default FPU. If they don't, infer it
21701 from the processor. */
21703 mfpu_opt
= mcpu_fpu_opt
;
21705 mfpu_opt
= march_fpu_opt
;
21707 mfpu_opt
= &fpu_default
;
21713 if (mcpu_cpu_opt
!= NULL
)
21714 mfpu_opt
= &fpu_default
;
21715 else if (mcpu_fpu_opt
!= NULL
&& ARM_CPU_HAS_FEATURE (*mcpu_fpu_opt
, arm_ext_v5
))
21716 mfpu_opt
= &fpu_arch_vfp_v2
;
21718 mfpu_opt
= &fpu_arch_fpa
;
21724 mcpu_cpu_opt
= &cpu_default
;
21725 selected_cpu
= cpu_default
;
21729 selected_cpu
= *mcpu_cpu_opt
;
21731 mcpu_cpu_opt
= &arm_arch_any
;
21734 ARM_MERGE_FEATURE_SETS (cpu_variant
, *mcpu_cpu_opt
, *mfpu_opt
);
21736 autoselect_thumb_from_cpu_variant ();
21738 arm_arch_used
= thumb_arch_used
= arm_arch_none
;
21740 #if defined OBJ_COFF || defined OBJ_ELF
21742 unsigned int flags
= 0;
21744 #if defined OBJ_ELF
21745 flags
= meabi_flags
;
21747 switch (meabi_flags
)
21749 case EF_ARM_EABI_UNKNOWN
:
21751 /* Set the flags in the private structure. */
21752 if (uses_apcs_26
) flags
|= F_APCS26
;
21753 if (support_interwork
) flags
|= F_INTERWORK
;
21754 if (uses_apcs_float
) flags
|= F_APCS_FLOAT
;
21755 if (pic_code
) flags
|= F_PIC
;
21756 if (!ARM_CPU_HAS_FEATURE (cpu_variant
, fpu_any_hard
))
21757 flags
|= F_SOFT_FLOAT
;
21759 switch (mfloat_abi_opt
)
21761 case ARM_FLOAT_ABI_SOFT
:
21762 case ARM_FLOAT_ABI_SOFTFP
:
21763 flags
|= F_SOFT_FLOAT
;
21766 case ARM_FLOAT_ABI_HARD
:
21767 if (flags
& F_SOFT_FLOAT
)
21768 as_bad (_("hard-float conflicts with specified fpu"));
21772 /* Using pure-endian doubles (even if soft-float). */
21773 if (ARM_CPU_HAS_FEATURE (cpu_variant
, fpu_endian_pure
))
21774 flags
|= F_VFP_FLOAT
;
21776 #if defined OBJ_ELF
21777 if (ARM_CPU_HAS_FEATURE (cpu_variant
, fpu_arch_maverick
))
21778 flags
|= EF_ARM_MAVERICK_FLOAT
;
21781 case EF_ARM_EABI_VER4
:
21782 case EF_ARM_EABI_VER5
:
21783 /* No additional flags to set. */
21790 bfd_set_private_flags (stdoutput
, flags
);
21792 /* We have run out flags in the COFF header to encode the
21793 status of ATPCS support, so instead we create a dummy,
21794 empty, debug section called .arm.atpcs. */
21799 sec
= bfd_make_section (stdoutput
, ".arm.atpcs");
21803 bfd_set_section_flags
21804 (stdoutput
, sec
, SEC_READONLY
| SEC_DEBUGGING
/* | SEC_HAS_CONTENTS */);
21805 bfd_set_section_size (stdoutput
, sec
, 0);
21806 bfd_set_section_contents (stdoutput
, sec
, NULL
, 0, 0);
21812 /* Record the CPU type as well. */
21813 if (ARM_CPU_HAS_FEATURE (cpu_variant
, arm_cext_iwmmxt2
))
21814 mach
= bfd_mach_arm_iWMMXt2
;
21815 else if (ARM_CPU_HAS_FEATURE (cpu_variant
, arm_cext_iwmmxt
))
21816 mach
= bfd_mach_arm_iWMMXt
;
21817 else if (ARM_CPU_HAS_FEATURE (cpu_variant
, arm_cext_xscale
))
21818 mach
= bfd_mach_arm_XScale
;
21819 else if (ARM_CPU_HAS_FEATURE (cpu_variant
, arm_cext_maverick
))
21820 mach
= bfd_mach_arm_ep9312
;
21821 else if (ARM_CPU_HAS_FEATURE (cpu_variant
, arm_ext_v5e
))
21822 mach
= bfd_mach_arm_5TE
;
21823 else if (ARM_CPU_HAS_FEATURE (cpu_variant
, arm_ext_v5
))
21825 if (ARM_CPU_HAS_FEATURE (cpu_variant
, arm_ext_v4t
))
21826 mach
= bfd_mach_arm_5T
;
21828 mach
= bfd_mach_arm_5
;
21830 else if (ARM_CPU_HAS_FEATURE (cpu_variant
, arm_ext_v4
))
21832 if (ARM_CPU_HAS_FEATURE (cpu_variant
, arm_ext_v4t
))
21833 mach
= bfd_mach_arm_4T
;
21835 mach
= bfd_mach_arm_4
;
21837 else if (ARM_CPU_HAS_FEATURE (cpu_variant
, arm_ext_v3m
))
21838 mach
= bfd_mach_arm_3M
;
21839 else if (ARM_CPU_HAS_FEATURE (cpu_variant
, arm_ext_v3
))
21840 mach
= bfd_mach_arm_3
;
21841 else if (ARM_CPU_HAS_FEATURE (cpu_variant
, arm_ext_v2s
))
21842 mach
= bfd_mach_arm_2a
;
21843 else if (ARM_CPU_HAS_FEATURE (cpu_variant
, arm_ext_v2
))
21844 mach
= bfd_mach_arm_2
;
21846 mach
= bfd_mach_arm_unknown
;
21848 bfd_set_arch_mach (stdoutput
, TARGET_ARCH
, mach
);
21851 /* Command line processing. */
21854 Invocation line includes a switch not recognized by the base assembler.
21855 See if it's a processor-specific option.
21857 This routine is somewhat complicated by the need for backwards
21858 compatibility (since older releases of gcc can't be changed).
21859 The new options try to make the interface as compatible as
21862 New options (supported) are:
21864 -mcpu=<cpu name> Assemble for selected processor
21865 -march=<architecture name> Assemble for selected architecture
21866 -mfpu=<fpu architecture> Assemble for selected FPU.
21867 -EB/-mbig-endian Big-endian
21868 -EL/-mlittle-endian Little-endian
21869 -k Generate PIC code
21870 -mthumb Start in Thumb mode
21871 -mthumb-interwork Code supports ARM/Thumb interworking
21873 -m[no-]warn-deprecated Warn about deprecated features
21875 For now we will also provide support for:
21877 -mapcs-32 32-bit Program counter
21878 -mapcs-26 26-bit Program counter
21879 -macps-float Floats passed in FP registers
21880 -mapcs-reentrant Reentrant code
21882 (sometime these will probably be replaced with -mapcs=<list of options>
21883 and -matpcs=<list of options>)
21885 The remaining options are only supported for back-wards compatibility.
21886 Cpu variants, the arm part is optional:
21887 -m[arm]1 Currently not supported.
21888 -m[arm]2, -m[arm]250 Arm 2 and Arm 250 processor
21889 -m[arm]3 Arm 3 processor
21890 -m[arm]6[xx], Arm 6 processors
21891 -m[arm]7[xx][t][[d]m] Arm 7 processors
21892 -m[arm]8[10] Arm 8 processors
21893 -m[arm]9[20][tdmi] Arm 9 processors
21894 -mstrongarm[110[0]] StrongARM processors
21895 -mxscale XScale processors
21896 -m[arm]v[2345[t[e]]] Arm architectures
21897 -mall All (except the ARM1)
21899 -mfpa10, -mfpa11 FPA10 and 11 co-processor instructions
21900 -mfpe-old (No float load/store multiples)
21901 -mvfpxd VFP Single precision
21903 -mno-fpu Disable all floating point instructions
21905 The following CPU names are recognized:
21906 arm1, arm2, arm250, arm3, arm6, arm600, arm610, arm620,
21907 arm7, arm7m, arm7d, arm7dm, arm7di, arm7dmi, arm70, arm700,
21908 arm700i, arm710 arm710t, arm720, arm720t, arm740t, arm710c,
21909 arm7100, arm7500, arm7500fe, arm7tdmi, arm8, arm810, arm9,
21910 arm920, arm920t, arm940t, arm946, arm966, arm9tdmi, arm9e,
21911 arm10t arm10e, arm1020t, arm1020e, arm10200e,
21912 strongarm, strongarm110, strongarm1100, strongarm1110, xscale.
21916 const char * md_shortopts
= "m:k";
21918 #ifdef ARM_BI_ENDIAN
21919 #define OPTION_EB (OPTION_MD_BASE + 0)
21920 #define OPTION_EL (OPTION_MD_BASE + 1)
21922 #if TARGET_BYTES_BIG_ENDIAN
21923 #define OPTION_EB (OPTION_MD_BASE + 0)
21925 #define OPTION_EL (OPTION_MD_BASE + 1)
21928 #define OPTION_FIX_V4BX (OPTION_MD_BASE + 2)
21930 struct option md_longopts
[] =
21933 {"EB", no_argument
, NULL
, OPTION_EB
},
21936 {"EL", no_argument
, NULL
, OPTION_EL
},
21938 {"fix-v4bx", no_argument
, NULL
, OPTION_FIX_V4BX
},
21939 {NULL
, no_argument
, NULL
, 0}
21942 size_t md_longopts_size
= sizeof (md_longopts
);
21944 struct arm_option_table
21946 char *option
; /* Option name to match. */
21947 char *help
; /* Help information. */
21948 int *var
; /* Variable to change. */
21949 int value
; /* What to change it to. */
21950 char *deprecated
; /* If non-null, print this message. */
21953 struct arm_option_table arm_opts
[] =
21955 {"k", N_("generate PIC code"), &pic_code
, 1, NULL
},
21956 {"mthumb", N_("assemble Thumb code"), &thumb_mode
, 1, NULL
},
21957 {"mthumb-interwork", N_("support ARM/Thumb interworking"),
21958 &support_interwork
, 1, NULL
},
21959 {"mapcs-32", N_("code uses 32-bit program counter"), &uses_apcs_26
, 0, NULL
},
21960 {"mapcs-26", N_("code uses 26-bit program counter"), &uses_apcs_26
, 1, NULL
},
21961 {"mapcs-float", N_("floating point args are in fp regs"), &uses_apcs_float
,
21963 {"mapcs-reentrant", N_("re-entrant code"), &pic_code
, 1, NULL
},
21964 {"matpcs", N_("code is ATPCS conformant"), &atpcs
, 1, NULL
},
21965 {"mbig-endian", N_("assemble for big-endian"), &target_big_endian
, 1, NULL
},
21966 {"mlittle-endian", N_("assemble for little-endian"), &target_big_endian
, 0,
21969 /* These are recognized by the assembler, but have no affect on code. */
21970 {"mapcs-frame", N_("use frame pointer"), NULL
, 0, NULL
},
21971 {"mapcs-stack-check", N_("use stack size checking"), NULL
, 0, NULL
},
21973 {"mwarn-deprecated", NULL
, &warn_on_deprecated
, 1, NULL
},
21974 {"mno-warn-deprecated", N_("do not warn on use of deprecated feature"),
21975 &warn_on_deprecated
, 0, NULL
},
21976 {NULL
, NULL
, NULL
, 0, NULL
}
21979 struct arm_legacy_option_table
21981 char *option
; /* Option name to match. */
21982 const arm_feature_set
**var
; /* Variable to change. */
21983 const arm_feature_set value
; /* What to change it to. */
21984 char *deprecated
; /* If non-null, print this message. */
21987 const struct arm_legacy_option_table arm_legacy_opts
[] =
21989 /* DON'T add any new processors to this list -- we want the whole list
21990 to go away... Add them to the processors table instead. */
21991 {"marm1", &legacy_cpu
, ARM_ARCH_V1
, N_("use -mcpu=arm1")},
21992 {"m1", &legacy_cpu
, ARM_ARCH_V1
, N_("use -mcpu=arm1")},
21993 {"marm2", &legacy_cpu
, ARM_ARCH_V2
, N_("use -mcpu=arm2")},
21994 {"m2", &legacy_cpu
, ARM_ARCH_V2
, N_("use -mcpu=arm2")},
21995 {"marm250", &legacy_cpu
, ARM_ARCH_V2S
, N_("use -mcpu=arm250")},
21996 {"m250", &legacy_cpu
, ARM_ARCH_V2S
, N_("use -mcpu=arm250")},
21997 {"marm3", &legacy_cpu
, ARM_ARCH_V2S
, N_("use -mcpu=arm3")},
21998 {"m3", &legacy_cpu
, ARM_ARCH_V2S
, N_("use -mcpu=arm3")},
21999 {"marm6", &legacy_cpu
, ARM_ARCH_V3
, N_("use -mcpu=arm6")},
22000 {"m6", &legacy_cpu
, ARM_ARCH_V3
, N_("use -mcpu=arm6")},
22001 {"marm600", &legacy_cpu
, ARM_ARCH_V3
, N_("use -mcpu=arm600")},
22002 {"m600", &legacy_cpu
, ARM_ARCH_V3
, N_("use -mcpu=arm600")},
22003 {"marm610", &legacy_cpu
, ARM_ARCH_V3
, N_("use -mcpu=arm610")},
22004 {"m610", &legacy_cpu
, ARM_ARCH_V3
, N_("use -mcpu=arm610")},
22005 {"marm620", &legacy_cpu
, ARM_ARCH_V3
, N_("use -mcpu=arm620")},
22006 {"m620", &legacy_cpu
, ARM_ARCH_V3
, N_("use -mcpu=arm620")},
22007 {"marm7", &legacy_cpu
, ARM_ARCH_V3
, N_("use -mcpu=arm7")},
22008 {"m7", &legacy_cpu
, ARM_ARCH_V3
, N_("use -mcpu=arm7")},
22009 {"marm70", &legacy_cpu
, ARM_ARCH_V3
, N_("use -mcpu=arm70")},
22010 {"m70", &legacy_cpu
, ARM_ARCH_V3
, N_("use -mcpu=arm70")},
22011 {"marm700", &legacy_cpu
, ARM_ARCH_V3
, N_("use -mcpu=arm700")},
22012 {"m700", &legacy_cpu
, ARM_ARCH_V3
, N_("use -mcpu=arm700")},
22013 {"marm700i", &legacy_cpu
, ARM_ARCH_V3
, N_("use -mcpu=arm700i")},
22014 {"m700i", &legacy_cpu
, ARM_ARCH_V3
, N_("use -mcpu=arm700i")},
22015 {"marm710", &legacy_cpu
, ARM_ARCH_V3
, N_("use -mcpu=arm710")},
22016 {"m710", &legacy_cpu
, ARM_ARCH_V3
, N_("use -mcpu=arm710")},
22017 {"marm710c", &legacy_cpu
, ARM_ARCH_V3
, N_("use -mcpu=arm710c")},
22018 {"m710c", &legacy_cpu
, ARM_ARCH_V3
, N_("use -mcpu=arm710c")},
22019 {"marm720", &legacy_cpu
, ARM_ARCH_V3
, N_("use -mcpu=arm720")},
22020 {"m720", &legacy_cpu
, ARM_ARCH_V3
, N_("use -mcpu=arm720")},
22021 {"marm7d", &legacy_cpu
, ARM_ARCH_V3
, N_("use -mcpu=arm7d")},
22022 {"m7d", &legacy_cpu
, ARM_ARCH_V3
, N_("use -mcpu=arm7d")},
22023 {"marm7di", &legacy_cpu
, ARM_ARCH_V3
, N_("use -mcpu=arm7di")},
22024 {"m7di", &legacy_cpu
, ARM_ARCH_V3
, N_("use -mcpu=arm7di")},
22025 {"marm7m", &legacy_cpu
, ARM_ARCH_V3M
, N_("use -mcpu=arm7m")},
22026 {"m7m", &legacy_cpu
, ARM_ARCH_V3M
, N_("use -mcpu=arm7m")},
22027 {"marm7dm", &legacy_cpu
, ARM_ARCH_V3M
, N_("use -mcpu=arm7dm")},
22028 {"m7dm", &legacy_cpu
, ARM_ARCH_V3M
, N_("use -mcpu=arm7dm")},
22029 {"marm7dmi", &legacy_cpu
, ARM_ARCH_V3M
, N_("use -mcpu=arm7dmi")},
22030 {"m7dmi", &legacy_cpu
, ARM_ARCH_V3M
, N_("use -mcpu=arm7dmi")},
22031 {"marm7100", &legacy_cpu
, ARM_ARCH_V3
, N_("use -mcpu=arm7100")},
22032 {"m7100", &legacy_cpu
, ARM_ARCH_V3
, N_("use -mcpu=arm7100")},
22033 {"marm7500", &legacy_cpu
, ARM_ARCH_V3
, N_("use -mcpu=arm7500")},
22034 {"m7500", &legacy_cpu
, ARM_ARCH_V3
, N_("use -mcpu=arm7500")},
22035 {"marm7500fe", &legacy_cpu
, ARM_ARCH_V3
, N_("use -mcpu=arm7500fe")},
22036 {"m7500fe", &legacy_cpu
, ARM_ARCH_V3
, N_("use -mcpu=arm7500fe")},
22037 {"marm7t", &legacy_cpu
, ARM_ARCH_V4T
, N_("use -mcpu=arm7tdmi")},
22038 {"m7t", &legacy_cpu
, ARM_ARCH_V4T
, N_("use -mcpu=arm7tdmi")},
22039 {"marm7tdmi", &legacy_cpu
, ARM_ARCH_V4T
, N_("use -mcpu=arm7tdmi")},
22040 {"m7tdmi", &legacy_cpu
, ARM_ARCH_V4T
, N_("use -mcpu=arm7tdmi")},
22041 {"marm710t", &legacy_cpu
, ARM_ARCH_V4T
, N_("use -mcpu=arm710t")},
22042 {"m710t", &legacy_cpu
, ARM_ARCH_V4T
, N_("use -mcpu=arm710t")},
22043 {"marm720t", &legacy_cpu
, ARM_ARCH_V4T
, N_("use -mcpu=arm720t")},
22044 {"m720t", &legacy_cpu
, ARM_ARCH_V4T
, N_("use -mcpu=arm720t")},
22045 {"marm740t", &legacy_cpu
, ARM_ARCH_V4T
, N_("use -mcpu=arm740t")},
22046 {"m740t", &legacy_cpu
, ARM_ARCH_V4T
, N_("use -mcpu=arm740t")},
22047 {"marm8", &legacy_cpu
, ARM_ARCH_V4
, N_("use -mcpu=arm8")},
22048 {"m8", &legacy_cpu
, ARM_ARCH_V4
, N_("use -mcpu=arm8")},
22049 {"marm810", &legacy_cpu
, ARM_ARCH_V4
, N_("use -mcpu=arm810")},
22050 {"m810", &legacy_cpu
, ARM_ARCH_V4
, N_("use -mcpu=arm810")},
22051 {"marm9", &legacy_cpu
, ARM_ARCH_V4T
, N_("use -mcpu=arm9")},
22052 {"m9", &legacy_cpu
, ARM_ARCH_V4T
, N_("use -mcpu=arm9")},
22053 {"marm9tdmi", &legacy_cpu
, ARM_ARCH_V4T
, N_("use -mcpu=arm9tdmi")},
22054 {"m9tdmi", &legacy_cpu
, ARM_ARCH_V4T
, N_("use -mcpu=arm9tdmi")},
22055 {"marm920", &legacy_cpu
, ARM_ARCH_V4T
, N_("use -mcpu=arm920")},
22056 {"m920", &legacy_cpu
, ARM_ARCH_V4T
, N_("use -mcpu=arm920")},
22057 {"marm940", &legacy_cpu
, ARM_ARCH_V4T
, N_("use -mcpu=arm940")},
22058 {"m940", &legacy_cpu
, ARM_ARCH_V4T
, N_("use -mcpu=arm940")},
22059 {"mstrongarm", &legacy_cpu
, ARM_ARCH_V4
, N_("use -mcpu=strongarm")},
22060 {"mstrongarm110", &legacy_cpu
, ARM_ARCH_V4
,
22061 N_("use -mcpu=strongarm110")},
22062 {"mstrongarm1100", &legacy_cpu
, ARM_ARCH_V4
,
22063 N_("use -mcpu=strongarm1100")},
22064 {"mstrongarm1110", &legacy_cpu
, ARM_ARCH_V4
,
22065 N_("use -mcpu=strongarm1110")},
22066 {"mxscale", &legacy_cpu
, ARM_ARCH_XSCALE
, N_("use -mcpu=xscale")},
22067 {"miwmmxt", &legacy_cpu
, ARM_ARCH_IWMMXT
, N_("use -mcpu=iwmmxt")},
22068 {"mall", &legacy_cpu
, ARM_ANY
, N_("use -mcpu=all")},
22070 /* Architecture variants -- don't add any more to this list either. */
22071 {"mv2", &legacy_cpu
, ARM_ARCH_V2
, N_("use -march=armv2")},
22072 {"marmv2", &legacy_cpu
, ARM_ARCH_V2
, N_("use -march=armv2")},
22073 {"mv2a", &legacy_cpu
, ARM_ARCH_V2S
, N_("use -march=armv2a")},
22074 {"marmv2a", &legacy_cpu
, ARM_ARCH_V2S
, N_("use -march=armv2a")},
22075 {"mv3", &legacy_cpu
, ARM_ARCH_V3
, N_("use -march=armv3")},
22076 {"marmv3", &legacy_cpu
, ARM_ARCH_V3
, N_("use -march=armv3")},
22077 {"mv3m", &legacy_cpu
, ARM_ARCH_V3M
, N_("use -march=armv3m")},
22078 {"marmv3m", &legacy_cpu
, ARM_ARCH_V3M
, N_("use -march=armv3m")},
22079 {"mv4", &legacy_cpu
, ARM_ARCH_V4
, N_("use -march=armv4")},
22080 {"marmv4", &legacy_cpu
, ARM_ARCH_V4
, N_("use -march=armv4")},
22081 {"mv4t", &legacy_cpu
, ARM_ARCH_V4T
, N_("use -march=armv4t")},
22082 {"marmv4t", &legacy_cpu
, ARM_ARCH_V4T
, N_("use -march=armv4t")},
22083 {"mv5", &legacy_cpu
, ARM_ARCH_V5
, N_("use -march=armv5")},
22084 {"marmv5", &legacy_cpu
, ARM_ARCH_V5
, N_("use -march=armv5")},
22085 {"mv5t", &legacy_cpu
, ARM_ARCH_V5T
, N_("use -march=armv5t")},
22086 {"marmv5t", &legacy_cpu
, ARM_ARCH_V5T
, N_("use -march=armv5t")},
22087 {"mv5e", &legacy_cpu
, ARM_ARCH_V5TE
, N_("use -march=armv5te")},
22088 {"marmv5e", &legacy_cpu
, ARM_ARCH_V5TE
, N_("use -march=armv5te")},
22090 /* Floating point variants -- don't add any more to this list either. */
22091 {"mfpe-old", &legacy_fpu
, FPU_ARCH_FPE
, N_("use -mfpu=fpe")},
22092 {"mfpa10", &legacy_fpu
, FPU_ARCH_FPA
, N_("use -mfpu=fpa10")},
22093 {"mfpa11", &legacy_fpu
, FPU_ARCH_FPA
, N_("use -mfpu=fpa11")},
22094 {"mno-fpu", &legacy_fpu
, ARM_ARCH_NONE
,
22095 N_("use either -mfpu=softfpa or -mfpu=softvfp")},
22097 {NULL
, NULL
, ARM_ARCH_NONE
, NULL
}
22100 struct arm_cpu_option_table
22103 const arm_feature_set value
;
22104 /* For some CPUs we assume an FPU unless the user explicitly sets
22106 const arm_feature_set default_fpu
;
22107 /* The canonical name of the CPU, or NULL to use NAME converted to upper
22109 const char *canonical_name
;
22112 /* This list should, at a minimum, contain all the cpu names
22113 recognized by GCC. */
22114 static const struct arm_cpu_option_table arm_cpus
[] =
22116 {"all", ARM_ANY
, FPU_ARCH_FPA
, NULL
},
22117 {"arm1", ARM_ARCH_V1
, FPU_ARCH_FPA
, NULL
},
22118 {"arm2", ARM_ARCH_V2
, FPU_ARCH_FPA
, NULL
},
22119 {"arm250", ARM_ARCH_V2S
, FPU_ARCH_FPA
, NULL
},
22120 {"arm3", ARM_ARCH_V2S
, FPU_ARCH_FPA
, NULL
},
22121 {"arm6", ARM_ARCH_V3
, FPU_ARCH_FPA
, NULL
},
22122 {"arm60", ARM_ARCH_V3
, FPU_ARCH_FPA
, NULL
},
22123 {"arm600", ARM_ARCH_V3
, FPU_ARCH_FPA
, NULL
},
22124 {"arm610", ARM_ARCH_V3
, FPU_ARCH_FPA
, NULL
},
22125 {"arm620", ARM_ARCH_V3
, FPU_ARCH_FPA
, NULL
},
22126 {"arm7", ARM_ARCH_V3
, FPU_ARCH_FPA
, NULL
},
22127 {"arm7m", ARM_ARCH_V3M
, FPU_ARCH_FPA
, NULL
},
22128 {"arm7d", ARM_ARCH_V3
, FPU_ARCH_FPA
, NULL
},
22129 {"arm7dm", ARM_ARCH_V3M
, FPU_ARCH_FPA
, NULL
},
22130 {"arm7di", ARM_ARCH_V3
, FPU_ARCH_FPA
, NULL
},
22131 {"arm7dmi", ARM_ARCH_V3M
, FPU_ARCH_FPA
, NULL
},
22132 {"arm70", ARM_ARCH_V3
, FPU_ARCH_FPA
, NULL
},
22133 {"arm700", ARM_ARCH_V3
, FPU_ARCH_FPA
, NULL
},
22134 {"arm700i", ARM_ARCH_V3
, FPU_ARCH_FPA
, NULL
},
22135 {"arm710", ARM_ARCH_V3
, FPU_ARCH_FPA
, NULL
},
22136 {"arm710t", ARM_ARCH_V4T
, FPU_ARCH_FPA
, NULL
},
22137 {"arm720", ARM_ARCH_V3
, FPU_ARCH_FPA
, NULL
},
22138 {"arm720t", ARM_ARCH_V4T
, FPU_ARCH_FPA
, NULL
},
22139 {"arm740t", ARM_ARCH_V4T
, FPU_ARCH_FPA
, NULL
},
22140 {"arm710c", ARM_ARCH_V3
, FPU_ARCH_FPA
, NULL
},
22141 {"arm7100", ARM_ARCH_V3
, FPU_ARCH_FPA
, NULL
},
22142 {"arm7500", ARM_ARCH_V3
, FPU_ARCH_FPA
, NULL
},
22143 {"arm7500fe", ARM_ARCH_V3
, FPU_ARCH_FPA
, NULL
},
22144 {"arm7t", ARM_ARCH_V4T
, FPU_ARCH_FPA
, NULL
},
22145 {"arm7tdmi", ARM_ARCH_V4T
, FPU_ARCH_FPA
, NULL
},
22146 {"arm7tdmi-s", ARM_ARCH_V4T
, FPU_ARCH_FPA
, NULL
},
22147 {"arm8", ARM_ARCH_V4
, FPU_ARCH_FPA
, NULL
},
22148 {"arm810", ARM_ARCH_V4
, FPU_ARCH_FPA
, NULL
},
22149 {"strongarm", ARM_ARCH_V4
, FPU_ARCH_FPA
, NULL
},
22150 {"strongarm1", ARM_ARCH_V4
, FPU_ARCH_FPA
, NULL
},
22151 {"strongarm110", ARM_ARCH_V4
, FPU_ARCH_FPA
, NULL
},
22152 {"strongarm1100", ARM_ARCH_V4
, FPU_ARCH_FPA
, NULL
},
22153 {"strongarm1110", ARM_ARCH_V4
, FPU_ARCH_FPA
, NULL
},
22154 {"arm9", ARM_ARCH_V4T
, FPU_ARCH_FPA
, NULL
},
22155 {"arm920", ARM_ARCH_V4T
, FPU_ARCH_FPA
, "ARM920T"},
22156 {"arm920t", ARM_ARCH_V4T
, FPU_ARCH_FPA
, NULL
},
22157 {"arm922t", ARM_ARCH_V4T
, FPU_ARCH_FPA
, NULL
},
22158 {"arm940t", ARM_ARCH_V4T
, FPU_ARCH_FPA
, NULL
},
22159 {"arm9tdmi", ARM_ARCH_V4T
, FPU_ARCH_FPA
, NULL
},
22160 {"fa526", ARM_ARCH_V4
, FPU_ARCH_FPA
, NULL
},
22161 {"fa626", ARM_ARCH_V4
, FPU_ARCH_FPA
, NULL
},
22162 /* For V5 or later processors we default to using VFP; but the user
22163 should really set the FPU type explicitly. */
22164 {"arm9e-r0", ARM_ARCH_V5TExP
, FPU_ARCH_VFP_V2
, NULL
},
22165 {"arm9e", ARM_ARCH_V5TE
, FPU_ARCH_VFP_V2
, NULL
},
22166 {"arm926ej", ARM_ARCH_V5TEJ
, FPU_ARCH_VFP_V2
, "ARM926EJ-S"},
22167 {"arm926ejs", ARM_ARCH_V5TEJ
, FPU_ARCH_VFP_V2
, "ARM926EJ-S"},
22168 {"arm926ej-s", ARM_ARCH_V5TEJ
, FPU_ARCH_VFP_V2
, NULL
},
22169 {"arm946e-r0", ARM_ARCH_V5TExP
, FPU_ARCH_VFP_V2
, NULL
},
22170 {"arm946e", ARM_ARCH_V5TE
, FPU_ARCH_VFP_V2
, "ARM946E-S"},
22171 {"arm946e-s", ARM_ARCH_V5TE
, FPU_ARCH_VFP_V2
, NULL
},
22172 {"arm966e-r0", ARM_ARCH_V5TExP
, FPU_ARCH_VFP_V2
, NULL
},
22173 {"arm966e", ARM_ARCH_V5TE
, FPU_ARCH_VFP_V2
, "ARM966E-S"},
22174 {"arm966e-s", ARM_ARCH_V5TE
, FPU_ARCH_VFP_V2
, NULL
},
22175 {"arm968e-s", ARM_ARCH_V5TE
, FPU_ARCH_VFP_V2
, NULL
},
22176 {"arm10t", ARM_ARCH_V5T
, FPU_ARCH_VFP_V1
, NULL
},
22177 {"arm10tdmi", ARM_ARCH_V5T
, FPU_ARCH_VFP_V1
, NULL
},
22178 {"arm10e", ARM_ARCH_V5TE
, FPU_ARCH_VFP_V2
, NULL
},
22179 {"arm1020", ARM_ARCH_V5TE
, FPU_ARCH_VFP_V2
, "ARM1020E"},
22180 {"arm1020t", ARM_ARCH_V5T
, FPU_ARCH_VFP_V1
, NULL
},
22181 {"arm1020e", ARM_ARCH_V5TE
, FPU_ARCH_VFP_V2
, NULL
},
22182 {"arm1022e", ARM_ARCH_V5TE
, FPU_ARCH_VFP_V2
, NULL
},
22183 {"arm1026ejs", ARM_ARCH_V5TEJ
, FPU_ARCH_VFP_V2
, "ARM1026EJ-S"},
22184 {"arm1026ej-s", ARM_ARCH_V5TEJ
, FPU_ARCH_VFP_V2
, NULL
},
22185 {"fa626te", ARM_ARCH_V5TE
, FPU_NONE
, NULL
},
22186 {"fa726te", ARM_ARCH_V5TE
, FPU_ARCH_VFP_V2
, NULL
},
22187 {"arm1136js", ARM_ARCH_V6
, FPU_NONE
, "ARM1136J-S"},
22188 {"arm1136j-s", ARM_ARCH_V6
, FPU_NONE
, NULL
},
22189 {"arm1136jfs", ARM_ARCH_V6
, FPU_ARCH_VFP_V2
, "ARM1136JF-S"},
22190 {"arm1136jf-s", ARM_ARCH_V6
, FPU_ARCH_VFP_V2
, NULL
},
22191 {"mpcore", ARM_ARCH_V6K
, FPU_ARCH_VFP_V2
, NULL
},
22192 {"mpcorenovfp", ARM_ARCH_V6K
, FPU_NONE
, NULL
},
22193 {"arm1156t2-s", ARM_ARCH_V6T2
, FPU_NONE
, NULL
},
22194 {"arm1156t2f-s", ARM_ARCH_V6T2
, FPU_ARCH_VFP_V2
, NULL
},
22195 {"arm1176jz-s", ARM_ARCH_V6ZK
, FPU_NONE
, NULL
},
22196 {"arm1176jzf-s", ARM_ARCH_V6ZK
, FPU_ARCH_VFP_V2
, NULL
},
22197 {"cortex-a5", ARM_ARCH_V7A
, FPU_NONE
, NULL
},
22198 {"cortex-a8", ARM_ARCH_V7A
, ARM_FEATURE (0, FPU_VFP_V3
22199 | FPU_NEON_EXT_V1
),
22201 {"cortex-a9", ARM_ARCH_V7A
, ARM_FEATURE (0, FPU_VFP_V3
22202 | FPU_NEON_EXT_V1
),
22204 {"cortex-r4", ARM_ARCH_V7R
, FPU_NONE
, NULL
},
22205 {"cortex-r4f", ARM_ARCH_V7R
, FPU_ARCH_VFP_V3D16
, NULL
},
22206 {"cortex-m4", ARM_ARCH_V7EM
, FPU_NONE
, NULL
},
22207 {"cortex-m3", ARM_ARCH_V7M
, FPU_NONE
, NULL
},
22208 {"cortex-m1", ARM_ARCH_V6M
, FPU_NONE
, NULL
},
22209 {"cortex-m0", ARM_ARCH_V6M
, FPU_NONE
, NULL
},
22210 /* ??? XSCALE is really an architecture. */
22211 {"xscale", ARM_ARCH_XSCALE
, FPU_ARCH_VFP_V2
, NULL
},
22212 /* ??? iwmmxt is not a processor. */
22213 {"iwmmxt", ARM_ARCH_IWMMXT
, FPU_ARCH_VFP_V2
, NULL
},
22214 {"iwmmxt2", ARM_ARCH_IWMMXT2
,FPU_ARCH_VFP_V2
, NULL
},
22215 {"i80200", ARM_ARCH_XSCALE
, FPU_ARCH_VFP_V2
, NULL
},
22217 {"ep9312", ARM_FEATURE (ARM_AEXT_V4T
, ARM_CEXT_MAVERICK
), FPU_ARCH_MAVERICK
, "ARM920T"},
22218 {NULL
, ARM_ARCH_NONE
, ARM_ARCH_NONE
, NULL
}
22221 struct arm_arch_option_table
22224 const arm_feature_set value
;
22225 const arm_feature_set default_fpu
;
22228 /* This list should, at a minimum, contain all the architecture names
22229 recognized by GCC. */
22230 static const struct arm_arch_option_table arm_archs
[] =
22232 {"all", ARM_ANY
, FPU_ARCH_FPA
},
22233 {"armv1", ARM_ARCH_V1
, FPU_ARCH_FPA
},
22234 {"armv2", ARM_ARCH_V2
, FPU_ARCH_FPA
},
22235 {"armv2a", ARM_ARCH_V2S
, FPU_ARCH_FPA
},
22236 {"armv2s", ARM_ARCH_V2S
, FPU_ARCH_FPA
},
22237 {"armv3", ARM_ARCH_V3
, FPU_ARCH_FPA
},
22238 {"armv3m", ARM_ARCH_V3M
, FPU_ARCH_FPA
},
22239 {"armv4", ARM_ARCH_V4
, FPU_ARCH_FPA
},
22240 {"armv4xm", ARM_ARCH_V4xM
, FPU_ARCH_FPA
},
22241 {"armv4t", ARM_ARCH_V4T
, FPU_ARCH_FPA
},
22242 {"armv4txm", ARM_ARCH_V4TxM
, FPU_ARCH_FPA
},
22243 {"armv5", ARM_ARCH_V5
, FPU_ARCH_VFP
},
22244 {"armv5t", ARM_ARCH_V5T
, FPU_ARCH_VFP
},
22245 {"armv5txm", ARM_ARCH_V5TxM
, FPU_ARCH_VFP
},
22246 {"armv5te", ARM_ARCH_V5TE
, FPU_ARCH_VFP
},
22247 {"armv5texp", ARM_ARCH_V5TExP
, FPU_ARCH_VFP
},
22248 {"armv5tej", ARM_ARCH_V5TEJ
, FPU_ARCH_VFP
},
22249 {"armv6", ARM_ARCH_V6
, FPU_ARCH_VFP
},
22250 {"armv6j", ARM_ARCH_V6
, FPU_ARCH_VFP
},
22251 {"armv6k", ARM_ARCH_V6K
, FPU_ARCH_VFP
},
22252 {"armv6z", ARM_ARCH_V6Z
, FPU_ARCH_VFP
},
22253 {"armv6zk", ARM_ARCH_V6ZK
, FPU_ARCH_VFP
},
22254 {"armv6t2", ARM_ARCH_V6T2
, FPU_ARCH_VFP
},
22255 {"armv6kt2", ARM_ARCH_V6KT2
, FPU_ARCH_VFP
},
22256 {"armv6zt2", ARM_ARCH_V6ZT2
, FPU_ARCH_VFP
},
22257 {"armv6zkt2", ARM_ARCH_V6ZKT2
, FPU_ARCH_VFP
},
22258 {"armv6-m", ARM_ARCH_V6M
, FPU_ARCH_VFP
},
22259 {"armv7", ARM_ARCH_V7
, FPU_ARCH_VFP
},
22260 /* The official spelling of the ARMv7 profile variants is the dashed form.
22261 Accept the non-dashed form for compatibility with old toolchains. */
22262 {"armv7a", ARM_ARCH_V7A
, FPU_ARCH_VFP
},
22263 {"armv7r", ARM_ARCH_V7R
, FPU_ARCH_VFP
},
22264 {"armv7m", ARM_ARCH_V7M
, FPU_ARCH_VFP
},
22265 {"armv7-a", ARM_ARCH_V7A
, FPU_ARCH_VFP
},
22266 {"armv7-r", ARM_ARCH_V7R
, FPU_ARCH_VFP
},
22267 {"armv7-m", ARM_ARCH_V7M
, FPU_ARCH_VFP
},
22268 {"armv7e-m", ARM_ARCH_V7EM
, FPU_ARCH_VFP
},
22269 {"xscale", ARM_ARCH_XSCALE
, FPU_ARCH_VFP
},
22270 {"iwmmxt", ARM_ARCH_IWMMXT
, FPU_ARCH_VFP
},
22271 {"iwmmxt2", ARM_ARCH_IWMMXT2
,FPU_ARCH_VFP
},
22272 {NULL
, ARM_ARCH_NONE
, ARM_ARCH_NONE
}
22275 /* ISA extensions in the co-processor space. */
22276 struct arm_option_cpu_value_table
22279 const arm_feature_set value
;
22282 static const struct arm_option_cpu_value_table arm_extensions
[] =
22284 {"maverick", ARM_FEATURE (0, ARM_CEXT_MAVERICK
)},
22285 {"xscale", ARM_FEATURE (0, ARM_CEXT_XSCALE
)},
22286 {"iwmmxt", ARM_FEATURE (0, ARM_CEXT_IWMMXT
)},
22287 {"iwmmxt2", ARM_FEATURE (0, ARM_CEXT_IWMMXT2
)},
22288 {NULL
, ARM_ARCH_NONE
}
22291 /* This list should, at a minimum, contain all the fpu names
22292 recognized by GCC. */
22293 static const struct arm_option_cpu_value_table arm_fpus
[] =
22295 {"softfpa", FPU_NONE
},
22296 {"fpe", FPU_ARCH_FPE
},
22297 {"fpe2", FPU_ARCH_FPE
},
22298 {"fpe3", FPU_ARCH_FPA
}, /* Third release supports LFM/SFM. */
22299 {"fpa", FPU_ARCH_FPA
},
22300 {"fpa10", FPU_ARCH_FPA
},
22301 {"fpa11", FPU_ARCH_FPA
},
22302 {"arm7500fe", FPU_ARCH_FPA
},
22303 {"softvfp", FPU_ARCH_VFP
},
22304 {"softvfp+vfp", FPU_ARCH_VFP_V2
},
22305 {"vfp", FPU_ARCH_VFP_V2
},
22306 {"vfp9", FPU_ARCH_VFP_V2
},
22307 {"vfp3", FPU_ARCH_VFP_V3
}, /* For backwards compatbility. */
22308 {"vfp10", FPU_ARCH_VFP_V2
},
22309 {"vfp10-r0", FPU_ARCH_VFP_V1
},
22310 {"vfpxd", FPU_ARCH_VFP_V1xD
},
22311 {"vfpv2", FPU_ARCH_VFP_V2
},
22312 {"vfpv3", FPU_ARCH_VFP_V3
},
22313 {"vfpv3-fp16", FPU_ARCH_VFP_V3_FP16
},
22314 {"vfpv3-d16", FPU_ARCH_VFP_V3D16
},
22315 {"vfpv3-d16-fp16", FPU_ARCH_VFP_V3D16_FP16
},
22316 {"vfpv3xd", FPU_ARCH_VFP_V3xD
},
22317 {"vfpv3xd-fp16", FPU_ARCH_VFP_V3xD_FP16
},
22318 {"arm1020t", FPU_ARCH_VFP_V1
},
22319 {"arm1020e", FPU_ARCH_VFP_V2
},
22320 {"arm1136jfs", FPU_ARCH_VFP_V2
},
22321 {"arm1136jf-s", FPU_ARCH_VFP_V2
},
22322 {"maverick", FPU_ARCH_MAVERICK
},
22323 {"neon", FPU_ARCH_VFP_V3_PLUS_NEON_V1
},
22324 {"neon-fp16", FPU_ARCH_NEON_FP16
},
22325 {"vfpv4", FPU_ARCH_VFP_V4
},
22326 {"vfpv4-d16", FPU_ARCH_VFP_V4D16
},
22327 {"fpv4-sp-d16", FPU_ARCH_VFP_V4_SP_D16
},
22328 {"neon-vfpv4", FPU_ARCH_NEON_VFP_V4
},
22329 {NULL
, ARM_ARCH_NONE
}
22332 struct arm_option_value_table
22338 static const struct arm_option_value_table arm_float_abis
[] =
22340 {"hard", ARM_FLOAT_ABI_HARD
},
22341 {"softfp", ARM_FLOAT_ABI_SOFTFP
},
22342 {"soft", ARM_FLOAT_ABI_SOFT
},
22347 /* We only know how to output GNU and ver 4/5 (AAELF) formats. */
22348 static const struct arm_option_value_table arm_eabis
[] =
22350 {"gnu", EF_ARM_EABI_UNKNOWN
},
22351 {"4", EF_ARM_EABI_VER4
},
22352 {"5", EF_ARM_EABI_VER5
},
22357 struct arm_long_option_table
22359 char * option
; /* Substring to match. */
22360 char * help
; /* Help information. */
22361 int (* func
) (char * subopt
); /* Function to decode sub-option. */
22362 char * deprecated
; /* If non-null, print this message. */
22366 arm_parse_extension (char * str
, const arm_feature_set
**opt_p
)
22368 arm_feature_set
*ext_set
= (arm_feature_set
*)
22369 xmalloc (sizeof (arm_feature_set
));
22371 /* Copy the feature set, so that we can modify it. */
22372 *ext_set
= **opt_p
;
22375 while (str
!= NULL
&& *str
!= 0)
22377 const struct arm_option_cpu_value_table
* opt
;
22383 as_bad (_("invalid architectural extension"));
22388 ext
= strchr (str
, '+');
22391 optlen
= ext
- str
;
22393 optlen
= strlen (str
);
22397 as_bad (_("missing architectural extension"));
22401 for (opt
= arm_extensions
; opt
->name
!= NULL
; opt
++)
22402 if (strncmp (opt
->name
, str
, optlen
) == 0)
22404 ARM_MERGE_FEATURE_SETS (*ext_set
, *ext_set
, opt
->value
);
22408 if (opt
->name
== NULL
)
22410 as_bad (_("unknown architectural extension `%s'"), str
);
22421 arm_parse_cpu (char * str
)
22423 const struct arm_cpu_option_table
* opt
;
22424 char * ext
= strchr (str
, '+');
22428 optlen
= ext
- str
;
22430 optlen
= strlen (str
);
22434 as_bad (_("missing cpu name `%s'"), str
);
22438 for (opt
= arm_cpus
; opt
->name
!= NULL
; opt
++)
22439 if (strncmp (opt
->name
, str
, optlen
) == 0)
22441 mcpu_cpu_opt
= &opt
->value
;
22442 mcpu_fpu_opt
= &opt
->default_fpu
;
22443 if (opt
->canonical_name
)
22444 strcpy (selected_cpu_name
, opt
->canonical_name
);
22449 for (i
= 0; i
< optlen
; i
++)
22450 selected_cpu_name
[i
] = TOUPPER (opt
->name
[i
]);
22451 selected_cpu_name
[i
] = 0;
22455 return arm_parse_extension (ext
, &mcpu_cpu_opt
);
22460 as_bad (_("unknown cpu `%s'"), str
);
22465 arm_parse_arch (char * str
)
22467 const struct arm_arch_option_table
*opt
;
22468 char *ext
= strchr (str
, '+');
22472 optlen
= ext
- str
;
22474 optlen
= strlen (str
);
22478 as_bad (_("missing architecture name `%s'"), str
);
22482 for (opt
= arm_archs
; opt
->name
!= NULL
; opt
++)
22483 if (streq (opt
->name
, str
))
22485 march_cpu_opt
= &opt
->value
;
22486 march_fpu_opt
= &opt
->default_fpu
;
22487 strcpy (selected_cpu_name
, opt
->name
);
22490 return arm_parse_extension (ext
, &march_cpu_opt
);
22495 as_bad (_("unknown architecture `%s'\n"), str
);
22500 arm_parse_fpu (char * str
)
22502 const struct arm_option_cpu_value_table
* opt
;
22504 for (opt
= arm_fpus
; opt
->name
!= NULL
; opt
++)
22505 if (streq (opt
->name
, str
))
22507 mfpu_opt
= &opt
->value
;
22511 as_bad (_("unknown floating point format `%s'\n"), str
);
22516 arm_parse_float_abi (char * str
)
22518 const struct arm_option_value_table
* opt
;
22520 for (opt
= arm_float_abis
; opt
->name
!= NULL
; opt
++)
22521 if (streq (opt
->name
, str
))
22523 mfloat_abi_opt
= opt
->value
;
22527 as_bad (_("unknown floating point abi `%s'\n"), str
);
22533 arm_parse_eabi (char * str
)
22535 const struct arm_option_value_table
*opt
;
22537 for (opt
= arm_eabis
; opt
->name
!= NULL
; opt
++)
22538 if (streq (opt
->name
, str
))
22540 meabi_flags
= opt
->value
;
22543 as_bad (_("unknown EABI `%s'\n"), str
);
22549 arm_parse_it_mode (char * str
)
22551 bfd_boolean ret
= TRUE
;
22553 if (streq ("arm", str
))
22554 implicit_it_mode
= IMPLICIT_IT_MODE_ARM
;
22555 else if (streq ("thumb", str
))
22556 implicit_it_mode
= IMPLICIT_IT_MODE_THUMB
;
22557 else if (streq ("always", str
))
22558 implicit_it_mode
= IMPLICIT_IT_MODE_ALWAYS
;
22559 else if (streq ("never", str
))
22560 implicit_it_mode
= IMPLICIT_IT_MODE_NEVER
;
22563 as_bad (_("unknown implicit IT mode `%s', should be "\
22564 "arm, thumb, always, or never."), str
);
22571 struct arm_long_option_table arm_long_opts
[] =
22573 {"mcpu=", N_("<cpu name>\t assemble for CPU <cpu name>"),
22574 arm_parse_cpu
, NULL
},
22575 {"march=", N_("<arch name>\t assemble for architecture <arch name>"),
22576 arm_parse_arch
, NULL
},
22577 {"mfpu=", N_("<fpu name>\t assemble for FPU architecture <fpu name>"),
22578 arm_parse_fpu
, NULL
},
22579 {"mfloat-abi=", N_("<abi>\t assemble for floating point ABI <abi>"),
22580 arm_parse_float_abi
, NULL
},
22582 {"meabi=", N_("<ver>\t\t assemble for eabi version <ver>"),
22583 arm_parse_eabi
, NULL
},
22585 {"mimplicit-it=", N_("<mode>\t controls implicit insertion of IT instructions"),
22586 arm_parse_it_mode
, NULL
},
22587 {NULL
, NULL
, 0, NULL
}
22591 md_parse_option (int c
, char * arg
)
22593 struct arm_option_table
*opt
;
22594 const struct arm_legacy_option_table
*fopt
;
22595 struct arm_long_option_table
*lopt
;
22601 target_big_endian
= 1;
22607 target_big_endian
= 0;
22611 case OPTION_FIX_V4BX
:
22616 /* Listing option. Just ignore these, we don't support additional
22621 for (opt
= arm_opts
; opt
->option
!= NULL
; opt
++)
22623 if (c
== opt
->option
[0]
22624 && ((arg
== NULL
&& opt
->option
[1] == 0)
22625 || streq (arg
, opt
->option
+ 1)))
22627 /* If the option is deprecated, tell the user. */
22628 if (warn_on_deprecated
&& opt
->deprecated
!= NULL
)
22629 as_tsktsk (_("option `-%c%s' is deprecated: %s"), c
,
22630 arg
? arg
: "", _(opt
->deprecated
));
22632 if (opt
->var
!= NULL
)
22633 *opt
->var
= opt
->value
;
22639 for (fopt
= arm_legacy_opts
; fopt
->option
!= NULL
; fopt
++)
22641 if (c
== fopt
->option
[0]
22642 && ((arg
== NULL
&& fopt
->option
[1] == 0)
22643 || streq (arg
, fopt
->option
+ 1)))
22645 /* If the option is deprecated, tell the user. */
22646 if (warn_on_deprecated
&& fopt
->deprecated
!= NULL
)
22647 as_tsktsk (_("option `-%c%s' is deprecated: %s"), c
,
22648 arg
? arg
: "", _(fopt
->deprecated
));
22650 if (fopt
->var
!= NULL
)
22651 *fopt
->var
= &fopt
->value
;
22657 for (lopt
= arm_long_opts
; lopt
->option
!= NULL
; lopt
++)
22659 /* These options are expected to have an argument. */
22660 if (c
== lopt
->option
[0]
22662 && strncmp (arg
, lopt
->option
+ 1,
22663 strlen (lopt
->option
+ 1)) == 0)
22665 /* If the option is deprecated, tell the user. */
22666 if (warn_on_deprecated
&& lopt
->deprecated
!= NULL
)
22667 as_tsktsk (_("option `-%c%s' is deprecated: %s"), c
, arg
,
22668 _(lopt
->deprecated
));
22670 /* Call the sup-option parser. */
22671 return lopt
->func (arg
+ strlen (lopt
->option
) - 1);
22682 md_show_usage (FILE * fp
)
22684 struct arm_option_table
*opt
;
22685 struct arm_long_option_table
*lopt
;
22687 fprintf (fp
, _(" ARM-specific assembler options:\n"));
22689 for (opt
= arm_opts
; opt
->option
!= NULL
; opt
++)
22690 if (opt
->help
!= NULL
)
22691 fprintf (fp
, " -%-23s%s\n", opt
->option
, _(opt
->help
));
22693 for (lopt
= arm_long_opts
; lopt
->option
!= NULL
; lopt
++)
22694 if (lopt
->help
!= NULL
)
22695 fprintf (fp
, " -%s%s\n", lopt
->option
, _(lopt
->help
));
22699 -EB assemble code for a big-endian cpu\n"));
22704 -EL assemble code for a little-endian cpu\n"));
22708 --fix-v4bx Allow BX in ARMv4 code\n"));
22716 arm_feature_set flags
;
22717 } cpu_arch_ver_table
;
22719 /* Mapping from CPU features to EABI CPU arch values. Table must be sorted
22720 least features first. */
22721 static const cpu_arch_ver_table cpu_arch_ver
[] =
22727 {4, ARM_ARCH_V5TE
},
22728 {5, ARM_ARCH_V5TEJ
},
22732 {11, ARM_ARCH_V6M
},
22733 {8, ARM_ARCH_V6T2
},
22734 {10, ARM_ARCH_V7A
},
22735 {10, ARM_ARCH_V7R
},
22736 {10, ARM_ARCH_V7M
},
22740 /* Set an attribute if it has not already been set by the user. */
22742 aeabi_set_attribute_int (int tag
, int value
)
22745 || tag
>= NUM_KNOWN_OBJ_ATTRIBUTES
22746 || !attributes_set_explicitly
[tag
])
22747 bfd_elf_add_proc_attr_int (stdoutput
, tag
, value
);
22751 aeabi_set_attribute_string (int tag
, const char *value
)
22754 || tag
>= NUM_KNOWN_OBJ_ATTRIBUTES
22755 || !attributes_set_explicitly
[tag
])
22756 bfd_elf_add_proc_attr_string (stdoutput
, tag
, value
);
22759 /* Set the public EABI object attributes. */
22761 aeabi_set_public_attributes (void)
22764 arm_feature_set flags
;
22765 arm_feature_set tmp
;
22766 const cpu_arch_ver_table
*p
;
22768 /* Choose the architecture based on the capabilities of the requested cpu
22769 (if any) and/or the instructions actually used. */
22770 ARM_MERGE_FEATURE_SETS (flags
, arm_arch_used
, thumb_arch_used
);
22771 ARM_MERGE_FEATURE_SETS (flags
, flags
, *mfpu_opt
);
22772 ARM_MERGE_FEATURE_SETS (flags
, flags
, selected_cpu
);
22773 /*Allow the user to override the reported architecture. */
22776 ARM_CLEAR_FEATURE (flags
, flags
, arm_arch_any
);
22777 ARM_MERGE_FEATURE_SETS (flags
, flags
, *object_arch
);
22782 for (p
= cpu_arch_ver
; p
->val
; p
++)
22784 if (ARM_CPU_HAS_FEATURE (tmp
, p
->flags
))
22787 ARM_CLEAR_FEATURE (tmp
, tmp
, p
->flags
);
22791 /* The table lookup above finds the last architecture to contribute
22792 a new feature. Unfortunately, Tag13 is a subset of the union of
22793 v6T2 and v7-M, so it is never seen as contributing a new feature.
22794 We can not search for the last entry which is entirely used,
22795 because if no CPU is specified we build up only those flags
22796 actually used. Perhaps we should separate out the specified
22797 and implicit cases. Avoid taking this path for -march=all by
22798 checking for contradictory v7-A / v7-M features. */
22800 && !ARM_CPU_HAS_FEATURE (flags
, arm_ext_v7a
)
22801 && ARM_CPU_HAS_FEATURE (flags
, arm_ext_v7m
)
22802 && ARM_CPU_HAS_FEATURE (flags
, arm_ext_v6_dsp
))
22805 /* Tag_CPU_name. */
22806 if (selected_cpu_name
[0])
22810 q
= selected_cpu_name
;
22811 if (strncmp (q
, "armv", 4) == 0)
22816 for (i
= 0; q
[i
]; i
++)
22817 q
[i
] = TOUPPER (q
[i
]);
22819 aeabi_set_attribute_string (Tag_CPU_name
, q
);
22822 /* Tag_CPU_arch. */
22823 aeabi_set_attribute_int (Tag_CPU_arch
, arch
);
22825 /* Tag_CPU_arch_profile. */
22826 if (ARM_CPU_HAS_FEATURE (flags
, arm_ext_v7a
))
22827 aeabi_set_attribute_int (Tag_CPU_arch_profile
, 'A');
22828 else if (ARM_CPU_HAS_FEATURE (flags
, arm_ext_v7r
))
22829 aeabi_set_attribute_int (Tag_CPU_arch_profile
, 'R');
22830 else if (ARM_CPU_HAS_FEATURE (flags
, arm_ext_m
))
22831 aeabi_set_attribute_int (Tag_CPU_arch_profile
, 'M');
22833 /* Tag_ARM_ISA_use. */
22834 if (ARM_CPU_HAS_FEATURE (flags
, arm_ext_v1
)
22836 aeabi_set_attribute_int (Tag_ARM_ISA_use
, 1);
22838 /* Tag_THUMB_ISA_use. */
22839 if (ARM_CPU_HAS_FEATURE (flags
, arm_ext_v4t
)
22841 aeabi_set_attribute_int (Tag_THUMB_ISA_use
,
22842 ARM_CPU_HAS_FEATURE (flags
, arm_arch_t2
) ? 2 : 1);
22844 /* Tag_VFP_arch. */
22845 if (ARM_CPU_HAS_FEATURE (flags
, fpu_vfp_ext_fma
))
22846 aeabi_set_attribute_int (Tag_VFP_arch
,
22847 ARM_CPU_HAS_FEATURE (flags
, fpu_vfp_ext_d32
)
22849 else if (ARM_CPU_HAS_FEATURE (flags
, fpu_vfp_ext_d32
))
22850 aeabi_set_attribute_int (Tag_VFP_arch
, 3);
22851 else if (ARM_CPU_HAS_FEATURE (flags
, fpu_vfp_ext_v3xd
))
22852 aeabi_set_attribute_int (Tag_VFP_arch
, 4);
22853 else if (ARM_CPU_HAS_FEATURE (flags
, fpu_vfp_ext_v2
))
22854 aeabi_set_attribute_int (Tag_VFP_arch
, 2);
22855 else if (ARM_CPU_HAS_FEATURE (flags
, fpu_vfp_ext_v1
)
22856 || ARM_CPU_HAS_FEATURE (flags
, fpu_vfp_ext_v1xd
))
22857 aeabi_set_attribute_int (Tag_VFP_arch
, 1);
22859 /* Tag_WMMX_arch. */
22860 if (ARM_CPU_HAS_FEATURE (flags
, arm_cext_iwmmxt2
))
22861 aeabi_set_attribute_int (Tag_WMMX_arch
, 2);
22862 else if (ARM_CPU_HAS_FEATURE (flags
, arm_cext_iwmmxt
))
22863 aeabi_set_attribute_int (Tag_WMMX_arch
, 1);
22865 /* Tag_Advanced_SIMD_arch (formerly Tag_NEON_arch). */
22866 if (ARM_CPU_HAS_FEATURE (flags
, fpu_neon_ext_v1
))
22867 aeabi_set_attribute_int
22868 (Tag_Advanced_SIMD_arch
, (ARM_CPU_HAS_FEATURE (flags
, fpu_neon_ext_fma
)
22871 /* Tag_VFP_HP_extension (formerly Tag_NEON_FP16_arch). */
22872 if (ARM_CPU_HAS_FEATURE (flags
, fpu_vfp_fp16
))
22873 aeabi_set_attribute_int (Tag_VFP_HP_extension
, 1);
22876 /* Add the default contents for the .ARM.attributes section. */
22880 if (EF_ARM_EABI_VERSION (meabi_flags
) < EF_ARM_EABI_VER4
)
22883 aeabi_set_public_attributes ();
22885 #endif /* OBJ_ELF */
22888 /* Parse a .cpu directive. */
22891 s_arm_cpu (int ignored ATTRIBUTE_UNUSED
)
22893 const struct arm_cpu_option_table
*opt
;
22897 name
= input_line_pointer
;
22898 while (*input_line_pointer
&& !ISSPACE (*input_line_pointer
))
22899 input_line_pointer
++;
22900 saved_char
= *input_line_pointer
;
22901 *input_line_pointer
= 0;
22903 /* Skip the first "all" entry. */
22904 for (opt
= arm_cpus
+ 1; opt
->name
!= NULL
; opt
++)
22905 if (streq (opt
->name
, name
))
22907 mcpu_cpu_opt
= &opt
->value
;
22908 selected_cpu
= opt
->value
;
22909 if (opt
->canonical_name
)
22910 strcpy (selected_cpu_name
, opt
->canonical_name
);
22914 for (i
= 0; opt
->name
[i
]; i
++)
22915 selected_cpu_name
[i
] = TOUPPER (opt
->name
[i
]);
22916 selected_cpu_name
[i
] = 0;
22918 ARM_MERGE_FEATURE_SETS (cpu_variant
, *mcpu_cpu_opt
, *mfpu_opt
);
22919 *input_line_pointer
= saved_char
;
22920 demand_empty_rest_of_line ();
22923 as_bad (_("unknown cpu `%s'"), name
);
22924 *input_line_pointer
= saved_char
;
22925 ignore_rest_of_line ();
22929 /* Parse a .arch directive. */
22932 s_arm_arch (int ignored ATTRIBUTE_UNUSED
)
22934 const struct arm_arch_option_table
*opt
;
22938 name
= input_line_pointer
;
22939 while (*input_line_pointer
&& !ISSPACE (*input_line_pointer
))
22940 input_line_pointer
++;
22941 saved_char
= *input_line_pointer
;
22942 *input_line_pointer
= 0;
22944 /* Skip the first "all" entry. */
22945 for (opt
= arm_archs
+ 1; opt
->name
!= NULL
; opt
++)
22946 if (streq (opt
->name
, name
))
22948 mcpu_cpu_opt
= &opt
->value
;
22949 selected_cpu
= opt
->value
;
22950 strcpy (selected_cpu_name
, opt
->name
);
22951 ARM_MERGE_FEATURE_SETS (cpu_variant
, *mcpu_cpu_opt
, *mfpu_opt
);
22952 *input_line_pointer
= saved_char
;
22953 demand_empty_rest_of_line ();
22957 as_bad (_("unknown architecture `%s'\n"), name
);
22958 *input_line_pointer
= saved_char
;
22959 ignore_rest_of_line ();
22963 /* Parse a .object_arch directive. */
22966 s_arm_object_arch (int ignored ATTRIBUTE_UNUSED
)
22968 const struct arm_arch_option_table
*opt
;
22972 name
= input_line_pointer
;
22973 while (*input_line_pointer
&& !ISSPACE (*input_line_pointer
))
22974 input_line_pointer
++;
22975 saved_char
= *input_line_pointer
;
22976 *input_line_pointer
= 0;
22978 /* Skip the first "all" entry. */
22979 for (opt
= arm_archs
+ 1; opt
->name
!= NULL
; opt
++)
22980 if (streq (opt
->name
, name
))
22982 object_arch
= &opt
->value
;
22983 *input_line_pointer
= saved_char
;
22984 demand_empty_rest_of_line ();
22988 as_bad (_("unknown architecture `%s'\n"), name
);
22989 *input_line_pointer
= saved_char
;
22990 ignore_rest_of_line ();
22993 /* Parse a .fpu directive. */
22996 s_arm_fpu (int ignored ATTRIBUTE_UNUSED
)
22998 const struct arm_option_cpu_value_table
*opt
;
23002 name
= input_line_pointer
;
23003 while (*input_line_pointer
&& !ISSPACE (*input_line_pointer
))
23004 input_line_pointer
++;
23005 saved_char
= *input_line_pointer
;
23006 *input_line_pointer
= 0;
23008 for (opt
= arm_fpus
; opt
->name
!= NULL
; opt
++)
23009 if (streq (opt
->name
, name
))
23011 mfpu_opt
= &opt
->value
;
23012 ARM_MERGE_FEATURE_SETS (cpu_variant
, *mcpu_cpu_opt
, *mfpu_opt
);
23013 *input_line_pointer
= saved_char
;
23014 demand_empty_rest_of_line ();
23018 as_bad (_("unknown floating point format `%s'\n"), name
);
23019 *input_line_pointer
= saved_char
;
23020 ignore_rest_of_line ();
23023 /* Copy symbol information. */
23026 arm_copy_symbol_attributes (symbolS
*dest
, symbolS
*src
)
23028 ARM_GET_FLAG (dest
) = ARM_GET_FLAG (src
);
23032 /* Given a symbolic attribute NAME, return the proper integer value.
23033 Returns -1 if the attribute is not known. */
23036 arm_convert_symbolic_attribute (const char *name
)
23038 static const struct
23043 attribute_table
[] =
23045 /* When you modify this table you should
23046 also modify the list in doc/c-arm.texi. */
23047 #define T(tag) {#tag, tag}
23048 T (Tag_CPU_raw_name
),
23051 T (Tag_CPU_arch_profile
),
23052 T (Tag_ARM_ISA_use
),
23053 T (Tag_THUMB_ISA_use
),
23057 T (Tag_Advanced_SIMD_arch
),
23058 T (Tag_PCS_config
),
23059 T (Tag_ABI_PCS_R9_use
),
23060 T (Tag_ABI_PCS_RW_data
),
23061 T (Tag_ABI_PCS_RO_data
),
23062 T (Tag_ABI_PCS_GOT_use
),
23063 T (Tag_ABI_PCS_wchar_t
),
23064 T (Tag_ABI_FP_rounding
),
23065 T (Tag_ABI_FP_denormal
),
23066 T (Tag_ABI_FP_exceptions
),
23067 T (Tag_ABI_FP_user_exceptions
),
23068 T (Tag_ABI_FP_number_model
),
23069 T (Tag_ABI_align_needed
),
23070 T (Tag_ABI_align8_needed
),
23071 T (Tag_ABI_align_preserved
),
23072 T (Tag_ABI_align8_preserved
),
23073 T (Tag_ABI_enum_size
),
23074 T (Tag_ABI_HardFP_use
),
23075 T (Tag_ABI_VFP_args
),
23076 T (Tag_ABI_WMMX_args
),
23077 T (Tag_ABI_optimization_goals
),
23078 T (Tag_ABI_FP_optimization_goals
),
23079 T (Tag_compatibility
),
23080 T (Tag_CPU_unaligned_access
),
23081 T (Tag_FP_HP_extension
),
23082 T (Tag_VFP_HP_extension
),
23083 T (Tag_ABI_FP_16bit_format
),
23084 T (Tag_MPextension_use
),
23086 T (Tag_nodefaults
),
23087 T (Tag_also_compatible_with
),
23088 T (Tag_conformance
),
23090 T (Tag_Virtualization_use
),
23091 /* We deliberately do not include Tag_MPextension_use_legacy. */
23099 for (i
= 0; i
< ARRAY_SIZE (attribute_table
); i
++)
23100 if (streq (name
, attribute_table
[i
].name
))
23101 return attribute_table
[i
].tag
;
23107 /* Apply sym value for relocations only in the case that
23108 they are for local symbols and you have the respective
23109 architectural feature for blx and simple switches. */
23111 arm_apply_sym_value (struct fix
* fixP
)
23114 && ARM_CPU_HAS_FEATURE (selected_cpu
, arm_ext_v5t
)
23115 && !S_IS_EXTERNAL (fixP
->fx_addsy
))
23117 switch (fixP
->fx_r_type
)
23119 case BFD_RELOC_ARM_PCREL_BLX
:
23120 case BFD_RELOC_THUMB_PCREL_BRANCH23
:
23121 if (ARM_IS_FUNC (fixP
->fx_addsy
))
23125 case BFD_RELOC_ARM_PCREL_CALL
:
23126 case BFD_RELOC_THUMB_PCREL_BLX
:
23127 if (THUMB_IS_FUNC (fixP
->fx_addsy
))
23138 #endif /* OBJ_ELF */