1 /* tc-arm.c -- Assemble for the ARM
2 Copyright (C) 1994-2019 Free Software Foundation, Inc.
3 Contributed by Richard Earnshaw (rwe@pegasus.esprit.ec.org)
4 Modified by David Taylor (dtaylor@armltd.co.uk)
5 Cirrus coprocessor mods by Aldy Hernandez (aldyh@redhat.com)
6 Cirrus coprocessor fixes by Petko Manolov (petkan@nucleusys.com)
7 Cirrus coprocessor fixes by Vladimir Ivanov (vladitx@nucleusys.com)
9 This file is part of GAS, the GNU Assembler.
11 GAS is free software; you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation; either version 3, or (at your option)
16 GAS is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with GAS; see the file COPYING. If not, write to the Free
23 Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
30 #include "safe-ctype.h"
33 #include "libiberty.h"
34 #include "opcode/arm.h"
38 #include "dw2gencfi.h"
41 #include "dwarf2dbg.h"
44 /* Must be at least the size of the largest unwind opcode (currently two). */
45 #define ARM_OPCODE_CHUNK_SIZE 8
47 /* This structure holds the unwinding state. */
52 symbolS * table_entry;
53 symbolS * personality_routine;
54 int personality_index;
55 /* The segment containing the function. */
58 /* Opcodes generated from this function. */
59 unsigned char * opcodes;
62 /* The number of bytes pushed to the stack. */
64 /* We don't add stack adjustment opcodes immediately so that we can merge
65 multiple adjustments. We can also omit the final adjustment
66 when using a frame pointer. */
67 offsetT pending_offset;
68 /* These two fields are set by both unwind_movsp and unwind_setfp. They
69 hold the reg+offset to use when restoring sp from a frame pointer. */
72 /* Nonzero if an unwind_setfp directive has been seen. */
74 /* Nonzero if the last opcode restores sp from fp_reg. */
75 unsigned sp_restored:1;
78 /* Whether --fdpic was given. */
83 /* Results from operand parsing worker functions. */
87 PARSE_OPERAND_SUCCESS,
89 PARSE_OPERAND_FAIL_NO_BACKTRACK
90 } parse_operand_result;
99 /* Types of processor to assemble for. */
101 /* The code that was here used to select a default CPU depending on compiler
102 pre-defines which were only present when doing native builds, thus
103 changing gas' default behaviour depending upon the build host.
105 If you have a target that requires a default CPU option then the you
106 should define CPU_DEFAULT here. */
111 # define FPU_DEFAULT FPU_ARCH_FPA
112 # elif defined (TE_NetBSD)
114 # define FPU_DEFAULT FPU_ARCH_VFP /* Soft-float, but VFP order. */
116 /* Legacy a.out format. */
117 # define FPU_DEFAULT FPU_ARCH_FPA /* Soft-float, but FPA order. */
119 # elif defined (TE_VXWORKS)
120 # define FPU_DEFAULT FPU_ARCH_VFP /* Soft-float, VFP order. */
122 /* For backwards compatibility, default to FPA. */
123 # define FPU_DEFAULT FPU_ARCH_FPA
125 #endif /* ifndef FPU_DEFAULT */
127 #define streq(a, b) (strcmp (a, b) == 0)
129 /* Current set of feature bits available (CPU+FPU). Different from
130 selected_cpu + selected_fpu in case of autodetection since the CPU
131 feature bits are then all set. */
132 static arm_feature_set cpu_variant;
133 /* Feature bits used in each execution state. Used to set build attribute
134 (in particular Tag_*_ISA_use) in CPU autodetection mode. */
135 static arm_feature_set arm_arch_used;
136 static arm_feature_set thumb_arch_used;
138 /* Flags stored in private area of BFD structure. */
139 static int uses_apcs_26 = FALSE;
140 static int atpcs = FALSE;
141 static int support_interwork = FALSE;
142 static int uses_apcs_float = FALSE;
143 static int pic_code = FALSE;
144 static int fix_v4bx = FALSE;
145 /* Warn on using deprecated features. */
146 static int warn_on_deprecated = TRUE;
148 /* Understand CodeComposer Studio assembly syntax. */
149 bfd_boolean codecomposer_syntax = FALSE;
151 /* Variables that we set while parsing command-line options. Once all
152 options have been read we re-process these values to set the real
155 /* CPU and FPU feature bits set for legacy CPU and FPU options (eg. -marm1
156 instead of -mcpu=arm1). */
157 static const arm_feature_set *legacy_cpu = NULL;
158 static const arm_feature_set *legacy_fpu = NULL;
160 /* CPU, extension and FPU feature bits selected by -mcpu. */
161 static const arm_feature_set *mcpu_cpu_opt = NULL;
162 static arm_feature_set *mcpu_ext_opt = NULL;
163 static const arm_feature_set *mcpu_fpu_opt = NULL;
165 /* CPU, extension and FPU feature bits selected by -march. */
166 static const arm_feature_set *march_cpu_opt = NULL;
167 static arm_feature_set *march_ext_opt = NULL;
168 static const arm_feature_set *march_fpu_opt = NULL;
170 /* Feature bits selected by -mfpu. */
171 static const arm_feature_set *mfpu_opt = NULL;
173 /* Constants for known architecture features. */
174 static const arm_feature_set fpu_default = FPU_DEFAULT;
175 static const arm_feature_set fpu_arch_vfp_v1 ATTRIBUTE_UNUSED = FPU_ARCH_VFP_V1;
176 static const arm_feature_set fpu_arch_vfp_v2 = FPU_ARCH_VFP_V2;
177 static const arm_feature_set fpu_arch_vfp_v3 ATTRIBUTE_UNUSED = FPU_ARCH_VFP_V3;
178 static const arm_feature_set fpu_arch_neon_v1 ATTRIBUTE_UNUSED = FPU_ARCH_NEON_V1;
179 static const arm_feature_set fpu_arch_fpa = FPU_ARCH_FPA;
180 static const arm_feature_set fpu_any_hard = FPU_ANY_HARD;
182 static const arm_feature_set fpu_arch_maverick = FPU_ARCH_MAVERICK;
184 static const arm_feature_set fpu_endian_pure = FPU_ARCH_ENDIAN_PURE;
187 static const arm_feature_set cpu_default = CPU_DEFAULT;
190 static const arm_feature_set arm_ext_v1 = ARM_FEATURE_CORE_LOW (ARM_EXT_V1);
191 static const arm_feature_set arm_ext_v2 = ARM_FEATURE_CORE_LOW (ARM_EXT_V2);
192 static const arm_feature_set arm_ext_v2s = ARM_FEATURE_CORE_LOW (ARM_EXT_V2S);
193 static const arm_feature_set arm_ext_v3 = ARM_FEATURE_CORE_LOW (ARM_EXT_V3);
194 static const arm_feature_set arm_ext_v3m = ARM_FEATURE_CORE_LOW (ARM_EXT_V3M);
195 static const arm_feature_set arm_ext_v4 = ARM_FEATURE_CORE_LOW (ARM_EXT_V4);
196 static const arm_feature_set arm_ext_v4t = ARM_FEATURE_CORE_LOW (ARM_EXT_V4T);
197 static const arm_feature_set arm_ext_v5 = ARM_FEATURE_CORE_LOW (ARM_EXT_V5);
198 static const arm_feature_set arm_ext_v4t_5 =
199 ARM_FEATURE_CORE_LOW (ARM_EXT_V4T | ARM_EXT_V5);
200 static const arm_feature_set arm_ext_v5t = ARM_FEATURE_CORE_LOW (ARM_EXT_V5T);
201 static const arm_feature_set arm_ext_v5e = ARM_FEATURE_CORE_LOW (ARM_EXT_V5E);
202 static const arm_feature_set arm_ext_v5exp = ARM_FEATURE_CORE_LOW (ARM_EXT_V5ExP);
203 static const arm_feature_set arm_ext_v5j = ARM_FEATURE_CORE_LOW (ARM_EXT_V5J);
204 static const arm_feature_set arm_ext_v6 = ARM_FEATURE_CORE_LOW (ARM_EXT_V6);
205 static const arm_feature_set arm_ext_v6k = ARM_FEATURE_CORE_LOW (ARM_EXT_V6K);
206 static const arm_feature_set arm_ext_v6t2 = ARM_FEATURE_CORE_LOW (ARM_EXT_V6T2);
207 /* Only for compatability of hint instructions. */
208 static const arm_feature_set arm_ext_v6k_v6t2 =
209 ARM_FEATURE_CORE_LOW (ARM_EXT_V6K | ARM_EXT_V6T2);
210 static const arm_feature_set arm_ext_v6_notm =
211 ARM_FEATURE_CORE_LOW (ARM_EXT_V6_NOTM);
212 static const arm_feature_set arm_ext_v6_dsp =
213 ARM_FEATURE_CORE_LOW (ARM_EXT_V6_DSP);
214 static const arm_feature_set arm_ext_barrier =
215 ARM_FEATURE_CORE_LOW (ARM_EXT_BARRIER);
216 static const arm_feature_set arm_ext_msr =
217 ARM_FEATURE_CORE_LOW (ARM_EXT_THUMB_MSR);
218 static const arm_feature_set arm_ext_div = ARM_FEATURE_CORE_LOW (ARM_EXT_DIV);
219 static const arm_feature_set arm_ext_v7 = ARM_FEATURE_CORE_LOW (ARM_EXT_V7);
220 static const arm_feature_set arm_ext_v7a = ARM_FEATURE_CORE_LOW (ARM_EXT_V7A);
221 static const arm_feature_set arm_ext_v7r = ARM_FEATURE_CORE_LOW (ARM_EXT_V7R);
223 static const arm_feature_set ATTRIBUTE_UNUSED arm_ext_v7m = ARM_FEATURE_CORE_LOW (ARM_EXT_V7M);
225 static const arm_feature_set arm_ext_v8 = ARM_FEATURE_CORE_LOW (ARM_EXT_V8);
226 static const arm_feature_set arm_ext_m =
227 ARM_FEATURE_CORE (ARM_EXT_V6M | ARM_EXT_V7M,
228 ARM_EXT2_V8M | ARM_EXT2_V8M_MAIN);
229 static const arm_feature_set arm_ext_mp = ARM_FEATURE_CORE_LOW (ARM_EXT_MP);
230 static const arm_feature_set arm_ext_sec = ARM_FEATURE_CORE_LOW (ARM_EXT_SEC);
231 static const arm_feature_set arm_ext_os = ARM_FEATURE_CORE_LOW (ARM_EXT_OS);
232 static const arm_feature_set arm_ext_adiv = ARM_FEATURE_CORE_LOW (ARM_EXT_ADIV);
233 static const arm_feature_set arm_ext_virt = ARM_FEATURE_CORE_LOW (ARM_EXT_VIRT);
234 static const arm_feature_set arm_ext_pan = ARM_FEATURE_CORE_HIGH (ARM_EXT2_PAN);
235 static const arm_feature_set arm_ext_v8m = ARM_FEATURE_CORE_HIGH (ARM_EXT2_V8M);
236 static const arm_feature_set arm_ext_v8m_main =
237 ARM_FEATURE_CORE_HIGH (ARM_EXT2_V8M_MAIN);
238 static const arm_feature_set arm_ext_v8_1m_main =
239 ARM_FEATURE_CORE_HIGH (ARM_EXT2_V8_1M_MAIN);
240 /* Instructions in ARMv8-M only found in M profile architectures. */
241 static const arm_feature_set arm_ext_v8m_m_only =
242 ARM_FEATURE_CORE_HIGH (ARM_EXT2_V8M | ARM_EXT2_V8M_MAIN);
243 static const arm_feature_set arm_ext_v6t2_v8m =
244 ARM_FEATURE_CORE_HIGH (ARM_EXT2_V6T2_V8M);
245 /* Instructions shared between ARMv8-A and ARMv8-M. */
246 static const arm_feature_set arm_ext_atomics =
247 ARM_FEATURE_CORE_HIGH (ARM_EXT2_ATOMICS);
249 /* DSP instructions Tag_DSP_extension refers to. */
250 static const arm_feature_set arm_ext_dsp =
251 ARM_FEATURE_CORE_LOW (ARM_EXT_V5E | ARM_EXT_V5ExP | ARM_EXT_V6_DSP);
253 static const arm_feature_set arm_ext_ras =
254 ARM_FEATURE_CORE_HIGH (ARM_EXT2_RAS);
255 /* FP16 instructions. */
256 static const arm_feature_set arm_ext_fp16 =
257 ARM_FEATURE_CORE_HIGH (ARM_EXT2_FP16_INST);
258 static const arm_feature_set arm_ext_fp16_fml =
259 ARM_FEATURE_CORE_HIGH (ARM_EXT2_FP16_FML);
260 static const arm_feature_set arm_ext_v8_2 =
261 ARM_FEATURE_CORE_HIGH (ARM_EXT2_V8_2A);
262 static const arm_feature_set arm_ext_v8_3 =
263 ARM_FEATURE_CORE_HIGH (ARM_EXT2_V8_3A);
264 static const arm_feature_set arm_ext_sb =
265 ARM_FEATURE_CORE_HIGH (ARM_EXT2_SB);
266 static const arm_feature_set arm_ext_predres =
267 ARM_FEATURE_CORE_HIGH (ARM_EXT2_PREDRES);
269 static const arm_feature_set arm_arch_any = ARM_ANY;
271 static const arm_feature_set fpu_any = FPU_ANY;
273 static const arm_feature_set arm_arch_full ATTRIBUTE_UNUSED = ARM_FEATURE (-1, -1, -1);
274 static const arm_feature_set arm_arch_t2 = ARM_ARCH_THUMB2;
275 static const arm_feature_set arm_arch_none = ARM_ARCH_NONE;
277 static const arm_feature_set arm_cext_iwmmxt2 =
278 ARM_FEATURE_COPROC (ARM_CEXT_IWMMXT2);
279 static const arm_feature_set arm_cext_iwmmxt =
280 ARM_FEATURE_COPROC (ARM_CEXT_IWMMXT);
281 static const arm_feature_set arm_cext_xscale =
282 ARM_FEATURE_COPROC (ARM_CEXT_XSCALE);
283 static const arm_feature_set arm_cext_maverick =
284 ARM_FEATURE_COPROC (ARM_CEXT_MAVERICK);
285 static const arm_feature_set fpu_fpa_ext_v1 =
286 ARM_FEATURE_COPROC (FPU_FPA_EXT_V1);
287 static const arm_feature_set fpu_fpa_ext_v2 =
288 ARM_FEATURE_COPROC (FPU_FPA_EXT_V2);
289 static const arm_feature_set fpu_vfp_ext_v1xd =
290 ARM_FEATURE_COPROC (FPU_VFP_EXT_V1xD);
291 static const arm_feature_set fpu_vfp_ext_v1 =
292 ARM_FEATURE_COPROC (FPU_VFP_EXT_V1);
293 static const arm_feature_set fpu_vfp_ext_v2 =
294 ARM_FEATURE_COPROC (FPU_VFP_EXT_V2);
295 static const arm_feature_set fpu_vfp_ext_v3xd =
296 ARM_FEATURE_COPROC (FPU_VFP_EXT_V3xD);
297 static const arm_feature_set fpu_vfp_ext_v3 =
298 ARM_FEATURE_COPROC (FPU_VFP_EXT_V3);
299 static const arm_feature_set fpu_vfp_ext_d32 =
300 ARM_FEATURE_COPROC (FPU_VFP_EXT_D32);
301 static const arm_feature_set fpu_neon_ext_v1 =
302 ARM_FEATURE_COPROC (FPU_NEON_EXT_V1);
303 static const arm_feature_set fpu_vfp_v3_or_neon_ext =
304 ARM_FEATURE_COPROC (FPU_NEON_EXT_V1 | FPU_VFP_EXT_V3);
305 static const arm_feature_set mve_ext =
306 ARM_FEATURE_COPROC (FPU_MVE);
307 static const arm_feature_set mve_fp_ext =
308 ARM_FEATURE_COPROC (FPU_MVE_FP);
310 static const arm_feature_set fpu_vfp_fp16 =
311 ARM_FEATURE_COPROC (FPU_VFP_EXT_FP16);
312 static const arm_feature_set fpu_neon_ext_fma =
313 ARM_FEATURE_COPROC (FPU_NEON_EXT_FMA);
315 static const arm_feature_set fpu_vfp_ext_fma =
316 ARM_FEATURE_COPROC (FPU_VFP_EXT_FMA);
317 static const arm_feature_set fpu_vfp_ext_armv8 =
318 ARM_FEATURE_COPROC (FPU_VFP_EXT_ARMV8);
319 static const arm_feature_set fpu_vfp_ext_armv8xd =
320 ARM_FEATURE_COPROC (FPU_VFP_EXT_ARMV8xD);
321 static const arm_feature_set fpu_neon_ext_armv8 =
322 ARM_FEATURE_COPROC (FPU_NEON_EXT_ARMV8);
323 static const arm_feature_set fpu_crypto_ext_armv8 =
324 ARM_FEATURE_COPROC (FPU_CRYPTO_EXT_ARMV8);
325 static const arm_feature_set crc_ext_armv8 =
326 ARM_FEATURE_COPROC (CRC_EXT_ARMV8);
327 static const arm_feature_set fpu_neon_ext_v8_1 =
328 ARM_FEATURE_COPROC (FPU_NEON_EXT_RDMA);
329 static const arm_feature_set fpu_neon_ext_dotprod =
330 ARM_FEATURE_COPROC (FPU_NEON_EXT_DOTPROD);
332 static int mfloat_abi_opt = -1;
333 /* Architecture feature bits selected by the last -mcpu/-march or .cpu/.arch
335 static arm_feature_set selected_arch = ARM_ARCH_NONE;
336 /* Extension feature bits selected by the last -mcpu/-march or .arch_extension
338 static arm_feature_set selected_ext = ARM_ARCH_NONE;
339 /* Feature bits selected by the last -mcpu/-march or by the combination of the
340 last .cpu/.arch directive .arch_extension directives since that
342 static arm_feature_set selected_cpu = ARM_ARCH_NONE;
343 /* FPU feature bits selected by the last -mfpu or .fpu directive. */
344 static arm_feature_set selected_fpu = FPU_NONE;
345 /* Feature bits selected by the last .object_arch directive. */
346 static arm_feature_set selected_object_arch = ARM_ARCH_NONE;
347 /* Must be long enough to hold any of the names in arm_cpus. */
348 static char selected_cpu_name[20];
350 extern FLONUM_TYPE generic_floating_point_number;
352 /* Return if no cpu was selected on command-line. */
354 no_cpu_selected (void)
356 return ARM_FEATURE_EQUAL (selected_cpu, arm_arch_none);
361 static int meabi_flags = EABI_DEFAULT;
363 static int meabi_flags = EF_ARM_EABI_UNKNOWN;
366 static int attributes_set_explicitly[NUM_KNOWN_OBJ_ATTRIBUTES];
371 return (EF_ARM_EABI_VERSION (meabi_flags) >= EF_ARM_EABI_VER4);
376 /* Pre-defined "_GLOBAL_OFFSET_TABLE_" */
377 symbolS * GOT_symbol;
380 /* 0: assemble for ARM,
381 1: assemble for Thumb,
382 2: assemble for Thumb even though target CPU does not support thumb
384 static int thumb_mode = 0;
385 /* A value distinct from the possible values for thumb_mode that we
386 can use to record whether thumb_mode has been copied into the
387 tc_frag_data field of a frag. */
388 #define MODE_RECORDED (1 << 4)
390 /* Specifies the intrinsic IT insn behavior mode. */
391 enum implicit_it_mode
393 IMPLICIT_IT_MODE_NEVER = 0x00,
394 IMPLICIT_IT_MODE_ARM = 0x01,
395 IMPLICIT_IT_MODE_THUMB = 0x02,
396 IMPLICIT_IT_MODE_ALWAYS = (IMPLICIT_IT_MODE_ARM | IMPLICIT_IT_MODE_THUMB)
398 static int implicit_it_mode = IMPLICIT_IT_MODE_ARM;
400 /* If unified_syntax is true, we are processing the new unified
401 ARM/Thumb syntax. Important differences from the old ARM mode:
403 - Immediate operands do not require a # prefix.
404 - Conditional affixes always appear at the end of the
405 instruction. (For backward compatibility, those instructions
406 that formerly had them in the middle, continue to accept them
408 - The IT instruction may appear, and if it does is validated
409 against subsequent conditional affixes. It does not generate
412 Important differences from the old Thumb mode:
414 - Immediate operands do not require a # prefix.
415 - Most of the V6T2 instructions are only available in unified mode.
416 - The .N and .W suffixes are recognized and honored (it is an error
417 if they cannot be honored).
418 - All instructions set the flags if and only if they have an 's' affix.
419 - Conditional affixes may be used. They are validated against
420 preceding IT instructions. Unlike ARM mode, you cannot use a
421 conditional affix except in the scope of an IT instruction. */
423 static bfd_boolean unified_syntax = FALSE;
425 /* An immediate operand can start with #, and ld*, st*, pld operands
426 can contain [ and ]. We need to tell APP not to elide whitespace
427 before a [, which can appear as the first operand for pld.
428 Likewise, a { can appear as the first operand for push, pop, vld*, etc. */
429 const char arm_symbol_chars[] = "#[]{}";
444 enum neon_el_type type;
448 #define NEON_MAX_TYPE_ELS 4
452 struct neon_type_el el[NEON_MAX_TYPE_ELS];
456 enum pred_instruction_type
462 IF_INSIDE_IT_LAST_INSN, /* Either outside or inside;
463 if inside, should be the last one. */
464 NEUTRAL_IT_INSN, /* This could be either inside or outside,
465 i.e. BKPT and NOP. */
466 IT_INSN, /* The IT insn has been parsed. */
467 VPT_INSN, /* The VPT/VPST insn has been parsed. */
468 MVE_OUTSIDE_PRED_INSN , /* Instruction to indicate a MVE instruction without
469 a predication code. */
470 MVE_UNPREDICABLE_INSN /* MVE instruction that is non-predicable. */
473 /* The maximum number of operands we need. */
474 #define ARM_IT_MAX_OPERANDS 6
475 #define ARM_IT_MAX_RELOCS 3
480 unsigned long instruction;
484 /* "uncond_value" is set to the value in place of the conditional field in
485 unconditional versions of the instruction, or -1 if nothing is
488 struct neon_type vectype;
489 /* This does not indicate an actual NEON instruction, only that
490 the mnemonic accepts neon-style type suffixes. */
492 /* Set to the opcode if the instruction needs relaxation.
493 Zero if the instruction is not relaxed. */
497 bfd_reloc_code_real_type type;
500 } relocs[ARM_IT_MAX_RELOCS];
502 enum pred_instruction_type pred_insn_type;
508 struct neon_type_el vectype;
509 unsigned present : 1; /* Operand present. */
510 unsigned isreg : 1; /* Operand was a register. */
511 unsigned immisreg : 2; /* .imm field is a second register.
512 0: imm, 1: gpr, 2: MVE Q-register. */
513 unsigned isscalar : 2; /* Operand is a (SIMD) scalar:
517 unsigned immisalign : 1; /* Immediate is an alignment specifier. */
518 unsigned immisfloat : 1; /* Immediate was parsed as a float. */
519 /* Note: we abuse "regisimm" to mean "is Neon register" in VMOV
520 instructions. This allows us to disambiguate ARM <-> vector insns. */
521 unsigned regisimm : 1; /* 64-bit immediate, reg forms high 32 bits. */
522 unsigned isvec : 1; /* Is a single, double or quad VFP/Neon reg. */
523 unsigned isquad : 1; /* Operand is SIMD quad register. */
524 unsigned issingle : 1; /* Operand is VFP single-precision register. */
525 unsigned iszr : 1; /* Operand is ZR register. */
526 unsigned hasreloc : 1; /* Operand has relocation suffix. */
527 unsigned writeback : 1; /* Operand has trailing ! */
528 unsigned preind : 1; /* Preindexed address. */
529 unsigned postind : 1; /* Postindexed address. */
530 unsigned negative : 1; /* Index register was negated. */
531 unsigned shifted : 1; /* Shift applied to operation. */
532 unsigned shift_kind : 3; /* Shift operation (enum shift_kind). */
533 } operands[ARM_IT_MAX_OPERANDS];
536 static struct arm_it inst;
538 #define NUM_FLOAT_VALS 8
540 const char * fp_const[] =
542 "0.0", "1.0", "2.0", "3.0", "4.0", "5.0", "0.5", "10.0", 0
545 LITTLENUM_TYPE fp_values[NUM_FLOAT_VALS][MAX_LITTLENUMS];
555 #define CP_T_X 0x00008000
556 #define CP_T_Y 0x00400000
558 #define CONDS_BIT 0x00100000
559 #define LOAD_BIT 0x00100000
561 #define DOUBLE_LOAD_FLAG 0x00000001
565 const char * template_name;
569 #define COND_ALWAYS 0xE
573 const char * template_name;
577 struct asm_barrier_opt
579 const char * template_name;
581 const arm_feature_set arch;
584 /* The bit that distinguishes CPSR and SPSR. */
585 #define SPSR_BIT (1 << 22)
587 /* The individual PSR flag bits. */
588 #define PSR_c (1 << 16)
589 #define PSR_x (1 << 17)
590 #define PSR_s (1 << 18)
591 #define PSR_f (1 << 19)
596 bfd_reloc_code_real_type reloc;
601 VFP_REG_Sd, VFP_REG_Sm, VFP_REG_Sn,
602 VFP_REG_Dd, VFP_REG_Dm, VFP_REG_Dn
607 VFP_LDSTMIA, VFP_LDSTMDB, VFP_LDSTMIAX, VFP_LDSTMDBX
610 /* Bits for DEFINED field in neon_typed_alias. */
611 #define NTA_HASTYPE 1
612 #define NTA_HASINDEX 2
614 struct neon_typed_alias
616 unsigned char defined;
618 struct neon_type_el eltype;
621 /* ARM register categories. This includes coprocessor numbers and various
622 architecture extensions' registers. Each entry should have an error message
623 in reg_expected_msgs below. */
653 /* Structure for a hash table entry for a register.
654 If TYPE is REG_TYPE_VFD or REG_TYPE_NQ, the NEON field can point to extra
655 information which states whether a vector type or index is specified (for a
656 register alias created with .dn or .qn). Otherwise NEON should be NULL. */
662 unsigned char builtin;
663 struct neon_typed_alias * neon;
666 /* Diagnostics used when we don't get a register of the expected type. */
667 const char * const reg_expected_msgs[] =
669 [REG_TYPE_RN] = N_("ARM register expected"),
670 [REG_TYPE_CP] = N_("bad or missing co-processor number"),
671 [REG_TYPE_CN] = N_("co-processor register expected"),
672 [REG_TYPE_FN] = N_("FPA register expected"),
673 [REG_TYPE_VFS] = N_("VFP single precision register expected"),
674 [REG_TYPE_VFD] = N_("VFP/Neon double precision register expected"),
675 [REG_TYPE_NQ] = N_("Neon quad precision register expected"),
676 [REG_TYPE_VFSD] = N_("VFP single or double precision register expected"),
677 [REG_TYPE_NDQ] = N_("Neon double or quad precision register expected"),
678 [REG_TYPE_NSD] = N_("Neon single or double precision register expected"),
679 [REG_TYPE_NSDQ] = N_("VFP single, double or Neon quad precision register"
681 [REG_TYPE_VFC] = N_("VFP system register expected"),
682 [REG_TYPE_MVF] = N_("Maverick MVF register expected"),
683 [REG_TYPE_MVD] = N_("Maverick MVD register expected"),
684 [REG_TYPE_MVFX] = N_("Maverick MVFX register expected"),
685 [REG_TYPE_MVDX] = N_("Maverick MVDX register expected"),
686 [REG_TYPE_MVAX] = N_("Maverick MVAX register expected"),
687 [REG_TYPE_DSPSC] = N_("Maverick DSPSC register expected"),
688 [REG_TYPE_MMXWR] = N_("iWMMXt data register expected"),
689 [REG_TYPE_MMXWC] = N_("iWMMXt control register expected"),
690 [REG_TYPE_MMXWCG] = N_("iWMMXt scalar register expected"),
691 [REG_TYPE_XSCALE] = N_("XScale accumulator register expected"),
692 [REG_TYPE_MQ] = N_("MVE vector register expected"),
693 [REG_TYPE_RNB] = N_("")
696 /* Some well known registers that we refer to directly elsewhere. */
702 /* ARM instructions take 4bytes in the object file, Thumb instructions
708 /* Basic string to match. */
709 const char * template_name;
711 /* Parameters to instruction. */
712 unsigned int operands[8];
714 /* Conditional tag - see opcode_lookup. */
715 unsigned int tag : 4;
717 /* Basic instruction code. */
720 /* Thumb-format instruction code. */
723 /* Which architecture variant provides this instruction. */
724 const arm_feature_set * avariant;
725 const arm_feature_set * tvariant;
727 /* Function to call to encode instruction in ARM format. */
728 void (* aencode) (void);
730 /* Function to call to encode instruction in Thumb format. */
731 void (* tencode) (void);
733 /* Indicates whether this instruction may be vector predicated. */
734 unsigned int mayBeVecPred : 1;
737 /* Defines for various bits that we will want to toggle. */
738 #define INST_IMMEDIATE 0x02000000
739 #define OFFSET_REG 0x02000000
740 #define HWOFFSET_IMM 0x00400000
741 #define SHIFT_BY_REG 0x00000010
742 #define PRE_INDEX 0x01000000
743 #define INDEX_UP 0x00800000
744 #define WRITE_BACK 0x00200000
745 #define LDM_TYPE_2_OR_3 0x00400000
746 #define CPSI_MMOD 0x00020000
748 #define LITERAL_MASK 0xf000f000
749 #define OPCODE_MASK 0xfe1fffff
750 #define V4_STR_BIT 0x00000020
751 #define VLDR_VMOV_SAME 0x0040f000
753 #define T2_SUBS_PC_LR 0xf3de8f00
755 #define DATA_OP_SHIFT 21
756 #define SBIT_SHIFT 20
758 #define T2_OPCODE_MASK 0xfe1fffff
759 #define T2_DATA_OP_SHIFT 21
760 #define T2_SBIT_SHIFT 20
762 #define A_COND_MASK 0xf0000000
763 #define A_PUSH_POP_OP_MASK 0x0fff0000
765 /* Opcodes for pushing/poping registers to/from the stack. */
766 #define A1_OPCODE_PUSH 0x092d0000
767 #define A2_OPCODE_PUSH 0x052d0004
768 #define A2_OPCODE_POP 0x049d0004
770 /* Codes to distinguish the arithmetic instructions. */
781 #define OPCODE_CMP 10
782 #define OPCODE_CMN 11
783 #define OPCODE_ORR 12
784 #define OPCODE_MOV 13
785 #define OPCODE_BIC 14
786 #define OPCODE_MVN 15
788 #define T2_OPCODE_AND 0
789 #define T2_OPCODE_BIC 1
790 #define T2_OPCODE_ORR 2
791 #define T2_OPCODE_ORN 3
792 #define T2_OPCODE_EOR 4
793 #define T2_OPCODE_ADD 8
794 #define T2_OPCODE_ADC 10
795 #define T2_OPCODE_SBC 11
796 #define T2_OPCODE_SUB 13
797 #define T2_OPCODE_RSB 14
799 #define T_OPCODE_MUL 0x4340
800 #define T_OPCODE_TST 0x4200
801 #define T_OPCODE_CMN 0x42c0
802 #define T_OPCODE_NEG 0x4240
803 #define T_OPCODE_MVN 0x43c0
805 #define T_OPCODE_ADD_R3 0x1800
806 #define T_OPCODE_SUB_R3 0x1a00
807 #define T_OPCODE_ADD_HI 0x4400
808 #define T_OPCODE_ADD_ST 0xb000
809 #define T_OPCODE_SUB_ST 0xb080
810 #define T_OPCODE_ADD_SP 0xa800
811 #define T_OPCODE_ADD_PC 0xa000
812 #define T_OPCODE_ADD_I8 0x3000
813 #define T_OPCODE_SUB_I8 0x3800
814 #define T_OPCODE_ADD_I3 0x1c00
815 #define T_OPCODE_SUB_I3 0x1e00
817 #define T_OPCODE_ASR_R 0x4100
818 #define T_OPCODE_LSL_R 0x4080
819 #define T_OPCODE_LSR_R 0x40c0
820 #define T_OPCODE_ROR_R 0x41c0
821 #define T_OPCODE_ASR_I 0x1000
822 #define T_OPCODE_LSL_I 0x0000
823 #define T_OPCODE_LSR_I 0x0800
825 #define T_OPCODE_MOV_I8 0x2000
826 #define T_OPCODE_CMP_I8 0x2800
827 #define T_OPCODE_CMP_LR 0x4280
828 #define T_OPCODE_MOV_HR 0x4600
829 #define T_OPCODE_CMP_HR 0x4500
831 #define T_OPCODE_LDR_PC 0x4800
832 #define T_OPCODE_LDR_SP 0x9800
833 #define T_OPCODE_STR_SP 0x9000
834 #define T_OPCODE_LDR_IW 0x6800
835 #define T_OPCODE_STR_IW 0x6000
836 #define T_OPCODE_LDR_IH 0x8800
837 #define T_OPCODE_STR_IH 0x8000
838 #define T_OPCODE_LDR_IB 0x7800
839 #define T_OPCODE_STR_IB 0x7000
840 #define T_OPCODE_LDR_RW 0x5800
841 #define T_OPCODE_STR_RW 0x5000
842 #define T_OPCODE_LDR_RH 0x5a00
843 #define T_OPCODE_STR_RH 0x5200
844 #define T_OPCODE_LDR_RB 0x5c00
845 #define T_OPCODE_STR_RB 0x5400
847 #define T_OPCODE_PUSH 0xb400
848 #define T_OPCODE_POP 0xbc00
850 #define T_OPCODE_BRANCH 0xe000
852 #define THUMB_SIZE 2 /* Size of thumb instruction. */
853 #define THUMB_PP_PC_LR 0x0100
854 #define THUMB_LOAD_BIT 0x0800
855 #define THUMB2_LOAD_BIT 0x00100000
857 #define BAD_SYNTAX _("syntax error")
858 #define BAD_ARGS _("bad arguments to instruction")
859 #define BAD_SP _("r13 not allowed here")
860 #define BAD_PC _("r15 not allowed here")
861 #define BAD_ODD _("Odd register not allowed here")
862 #define BAD_EVEN _("Even register not allowed here")
863 #define BAD_COND _("instruction cannot be conditional")
864 #define BAD_OVERLAP _("registers may not be the same")
865 #define BAD_HIREG _("lo register required")
866 #define BAD_THUMB32 _("instruction not supported in Thumb16 mode")
867 #define BAD_ADDR_MODE _("instruction does not accept this addressing mode")
868 #define BAD_BRANCH _("branch must be last instruction in IT block")
869 #define BAD_BRANCH_OFF _("branch out of range or not a multiple of 2")
870 #define BAD_NOT_IT _("instruction not allowed in IT block")
871 #define BAD_NOT_VPT _("instruction missing MVE vector predication code")
872 #define BAD_FPU _("selected FPU does not support instruction")
873 #define BAD_OUT_IT _("thumb conditional instruction should be in IT block")
874 #define BAD_OUT_VPT \
875 _("vector predicated instruction should be in VPT/VPST block")
876 #define BAD_IT_COND _("incorrect condition in IT block")
877 #define BAD_VPT_COND _("incorrect condition in VPT/VPST block")
878 #define BAD_IT_IT _("IT falling in the range of a previous IT block")
879 #define MISSING_FNSTART _("missing .fnstart before unwinding directive")
880 #define BAD_PC_ADDRESSING \
881 _("cannot use register index with PC-relative addressing")
882 #define BAD_PC_WRITEBACK \
883 _("cannot use writeback with PC-relative addressing")
884 #define BAD_RANGE _("branch out of range")
885 #define BAD_FP16 _("selected processor does not support fp16 instruction")
886 #define UNPRED_REG(R) _("using " R " results in unpredictable behaviour")
887 #define THUMB1_RELOC_ONLY _("relocation valid in thumb1 code only")
888 #define MVE_NOT_IT _("Warning: instruction is UNPREDICTABLE in an IT " \
890 #define MVE_NOT_VPT _("Warning: instruction is UNPREDICTABLE in a VPT " \
892 #define MVE_BAD_PC _("Warning: instruction is UNPREDICTABLE with PC" \
894 #define MVE_BAD_SP _("Warning: instruction is UNPREDICTABLE with SP" \
896 #define BAD_SIMD_TYPE _("bad type in SIMD instruction")
897 #define BAD_MVE_AUTO \
898 _("GAS auto-detection mode and -march=all is deprecated for MVE, please" \
899 " use a valid -march or -mcpu option.")
900 #define BAD_MVE_SRCDEST _("Warning: 32-bit element size and same destination "\
901 "and source operands makes instruction UNPREDICTABLE")
902 #define BAD_EL_TYPE _("bad element type for instruction")
903 #define MVE_BAD_QREG _("MVE vector register Q[0..7] expected")
905 static struct hash_control * arm_ops_hsh;
906 static struct hash_control * arm_cond_hsh;
907 static struct hash_control * arm_vcond_hsh;
908 static struct hash_control * arm_shift_hsh;
909 static struct hash_control * arm_psr_hsh;
910 static struct hash_control * arm_v7m_psr_hsh;
911 static struct hash_control * arm_reg_hsh;
912 static struct hash_control * arm_reloc_hsh;
913 static struct hash_control * arm_barrier_opt_hsh;
915 /* Stuff needed to resolve the label ambiguity
924 symbolS * last_label_seen;
925 static int label_is_thumb_function_name = FALSE;
927 /* Literal pool structure. Held on a per-section
928 and per-sub-section basis. */
930 #define MAX_LITERAL_POOL_SIZE 1024
931 typedef struct literal_pool
933 expressionS literals [MAX_LITERAL_POOL_SIZE];
934 unsigned int next_free_entry;
940 struct dwarf2_line_info locs [MAX_LITERAL_POOL_SIZE];
942 struct literal_pool * next;
943 unsigned int alignment;
946 /* Pointer to a linked list of literal pools. */
947 literal_pool * list_of_pools = NULL;
949 typedef enum asmfunc_states
952 WAITING_ASMFUNC_NAME,
956 static asmfunc_states asmfunc_state = OUTSIDE_ASMFUNC;
959 # define now_pred seg_info (now_seg)->tc_segment_info_data.current_pred
961 static struct current_pred now_pred;
965 now_pred_compatible (int cond)
967 return (cond & ~1) == (now_pred.cc & ~1);
971 conditional_insn (void)
973 return inst.cond != COND_ALWAYS;
976 static int in_pred_block (void);
978 static int handle_pred_state (void);
980 static void force_automatic_it_block_close (void);
982 static void it_fsm_post_encode (void);
984 #define set_pred_insn_type(type) \
987 inst.pred_insn_type = type; \
988 if (handle_pred_state () == FAIL) \
993 #define set_pred_insn_type_nonvoid(type, failret) \
996 inst.pred_insn_type = type; \
997 if (handle_pred_state () == FAIL) \
1002 #define set_pred_insn_type_last() \
1005 if (inst.cond == COND_ALWAYS) \
1006 set_pred_insn_type (IF_INSIDE_IT_LAST_INSN); \
1008 set_pred_insn_type (INSIDE_IT_LAST_INSN); \
1012 /* Toggle value[pos]. */
1013 #define TOGGLE_BIT(value, pos) (value ^ (1 << pos))
1017 /* This array holds the chars that always start a comment. If the
1018 pre-processor is disabled, these aren't very useful. */
1019 char arm_comment_chars[] = "@";
1021 /* This array holds the chars that only start a comment at the beginning of
1022 a line. If the line seems to have the form '# 123 filename'
1023 .line and .file directives will appear in the pre-processed output. */
1024 /* Note that input_file.c hand checks for '#' at the beginning of the
1025 first line of the input file. This is because the compiler outputs
1026 #NO_APP at the beginning of its output. */
1027 /* Also note that comments like this one will always work. */
1028 const char line_comment_chars[] = "#";
1030 char arm_line_separator_chars[] = ";";
1032 /* Chars that can be used to separate mant
1033 from exp in floating point numbers. */
1034 const char EXP_CHARS[] = "eE";
1036 /* Chars that mean this number is a floating point constant. */
1037 /* As in 0f12.456 */
1038 /* or 0d1.2345e12 */
1040 const char FLT_CHARS[] = "rRsSfFdDxXeEpPHh";
1042 /* Prefix characters that indicate the start of an immediate
1044 #define is_immediate_prefix(C) ((C) == '#' || (C) == '$')
1046 /* Separator character handling. */
1048 #define skip_whitespace(str) do { if (*(str) == ' ') ++(str); } while (0)
1050 enum fp_16bit_format
1052 ARM_FP16_FORMAT_IEEE = 0x1,
1053 ARM_FP16_FORMAT_ALTERNATIVE = 0x2,
1054 ARM_FP16_FORMAT_DEFAULT = 0x3
1057 static enum fp_16bit_format fp16_format = ARM_FP16_FORMAT_DEFAULT;
1061 skip_past_char (char ** str, char c)
1063 /* PR gas/14987: Allow for whitespace before the expected character. */
1064 skip_whitespace (*str);
1075 #define skip_past_comma(str) skip_past_char (str, ',')
1077 /* Arithmetic expressions (possibly involving symbols). */
1079 /* Return TRUE if anything in the expression is a bignum. */
1082 walk_no_bignums (symbolS * sp)
1084 if (symbol_get_value_expression (sp)->X_op == O_big)
1087 if (symbol_get_value_expression (sp)->X_add_symbol)
1089 return (walk_no_bignums (symbol_get_value_expression (sp)->X_add_symbol)
1090 || (symbol_get_value_expression (sp)->X_op_symbol
1091 && walk_no_bignums (symbol_get_value_expression (sp)->X_op_symbol)));
1097 static bfd_boolean in_my_get_expression = FALSE;
1099 /* Third argument to my_get_expression. */
1100 #define GE_NO_PREFIX 0
1101 #define GE_IMM_PREFIX 1
1102 #define GE_OPT_PREFIX 2
1103 /* This is a bit of a hack. Use an optional prefix, and also allow big (64-bit)
1104 immediates, as can be used in Neon VMVN and VMOV immediate instructions. */
1105 #define GE_OPT_PREFIX_BIG 3
1108 my_get_expression (expressionS * ep, char ** str, int prefix_mode)
1112 /* In unified syntax, all prefixes are optional. */
1114 prefix_mode = (prefix_mode == GE_OPT_PREFIX_BIG) ? prefix_mode
1117 switch (prefix_mode)
1119 case GE_NO_PREFIX: break;
1121 if (!is_immediate_prefix (**str))
1123 inst.error = _("immediate expression requires a # prefix");
1129 case GE_OPT_PREFIX_BIG:
1130 if (is_immediate_prefix (**str))
1137 memset (ep, 0, sizeof (expressionS));
1139 save_in = input_line_pointer;
1140 input_line_pointer = *str;
1141 in_my_get_expression = TRUE;
1143 in_my_get_expression = FALSE;
1145 if (ep->X_op == O_illegal || ep->X_op == O_absent)
1147 /* We found a bad or missing expression in md_operand(). */
1148 *str = input_line_pointer;
1149 input_line_pointer = save_in;
1150 if (inst.error == NULL)
1151 inst.error = (ep->X_op == O_absent
1152 ? _("missing expression") :_("bad expression"));
1156 /* Get rid of any bignums now, so that we don't generate an error for which
1157 we can't establish a line number later on. Big numbers are never valid
1158 in instructions, which is where this routine is always called. */
1159 if (prefix_mode != GE_OPT_PREFIX_BIG
1160 && (ep->X_op == O_big
1161 || (ep->X_add_symbol
1162 && (walk_no_bignums (ep->X_add_symbol)
1164 && walk_no_bignums (ep->X_op_symbol))))))
1166 inst.error = _("invalid constant");
1167 *str = input_line_pointer;
1168 input_line_pointer = save_in;
1172 *str = input_line_pointer;
1173 input_line_pointer = save_in;
1177 /* Turn a string in input_line_pointer into a floating point constant
1178 of type TYPE, and store the appropriate bytes in *LITP. The number
1179 of LITTLENUMS emitted is stored in *SIZEP. An error message is
1180 returned, or NULL on OK.
1182 Note that fp constants aren't represent in the normal way on the ARM.
1183 In big endian mode, things are as expected. However, in little endian
1184 mode fp constants are big-endian word-wise, and little-endian byte-wise
1185 within the words. For example, (double) 1.1 in big endian mode is
1186 the byte sequence 3f f1 99 99 99 99 99 9a, and in little endian mode is
1187 the byte sequence 99 99 f1 3f 9a 99 99 99.
1189 ??? The format of 12 byte floats is uncertain according to gcc's arm.h. */
1192 md_atof (int type, char * litP, int * sizeP)
1195 LITTLENUM_TYPE words[MAX_LITTLENUMS];
1232 return _("Unrecognized or unsupported floating point constant");
1235 t = atof_ieee (input_line_pointer, type, words);
1237 input_line_pointer = t;
1238 *sizeP = prec * sizeof (LITTLENUM_TYPE);
1240 if (target_big_endian)
1242 for (i = 0; i < prec; i++)
1244 md_number_to_chars (litP, (valueT) words[i], sizeof (LITTLENUM_TYPE));
1245 litP += sizeof (LITTLENUM_TYPE);
1250 if (ARM_CPU_HAS_FEATURE (cpu_variant, fpu_endian_pure))
1251 for (i = prec - 1; i >= 0; i--)
1253 md_number_to_chars (litP, (valueT) words[i], sizeof (LITTLENUM_TYPE));
1254 litP += sizeof (LITTLENUM_TYPE);
1257 /* For a 4 byte float the order of elements in `words' is 1 0.
1258 For an 8 byte float the order is 1 0 3 2. */
1259 for (i = 0; i < prec; i += 2)
1261 md_number_to_chars (litP, (valueT) words[i + 1],
1262 sizeof (LITTLENUM_TYPE));
1263 md_number_to_chars (litP + sizeof (LITTLENUM_TYPE),
1264 (valueT) words[i], sizeof (LITTLENUM_TYPE));
1265 litP += 2 * sizeof (LITTLENUM_TYPE);
1272 /* We handle all bad expressions here, so that we can report the faulty
1273 instruction in the error message. */
1276 md_operand (expressionS * exp)
1278 if (in_my_get_expression)
1279 exp->X_op = O_illegal;
1282 /* Immediate values. */
1285 /* Generic immediate-value read function for use in directives.
1286 Accepts anything that 'expression' can fold to a constant.
1287 *val receives the number. */
1290 immediate_for_directive (int *val)
1293 exp.X_op = O_illegal;
1295 if (is_immediate_prefix (*input_line_pointer))
1297 input_line_pointer++;
1301 if (exp.X_op != O_constant)
1303 as_bad (_("expected #constant"));
1304 ignore_rest_of_line ();
1307 *val = exp.X_add_number;
1312 /* Register parsing. */
1314 /* Generic register parser. CCP points to what should be the
1315 beginning of a register name. If it is indeed a valid register
1316 name, advance CCP over it and return the reg_entry structure;
1317 otherwise return NULL. Does not issue diagnostics. */
1319 static struct reg_entry *
1320 arm_reg_parse_multi (char **ccp)
1324 struct reg_entry *reg;
1326 skip_whitespace (start);
1328 #ifdef REGISTER_PREFIX
1329 if (*start != REGISTER_PREFIX)
1333 #ifdef OPTIONAL_REGISTER_PREFIX
1334 if (*start == OPTIONAL_REGISTER_PREFIX)
1339 if (!ISALPHA (*p) || !is_name_beginner (*p))
1344 while (ISALPHA (*p) || ISDIGIT (*p) || *p == '_');
1346 reg = (struct reg_entry *) hash_find_n (arm_reg_hsh, start, p - start);
1356 arm_reg_alt_syntax (char **ccp, char *start, struct reg_entry *reg,
1357 enum arm_reg_type type)
1359 /* Alternative syntaxes are accepted for a few register classes. */
1366 /* Generic coprocessor register names are allowed for these. */
1367 if (reg && reg->type == REG_TYPE_CN)
1372 /* For backward compatibility, a bare number is valid here. */
1374 unsigned long processor = strtoul (start, ccp, 10);
1375 if (*ccp != start && processor <= 15)
1380 case REG_TYPE_MMXWC:
1381 /* WC includes WCG. ??? I'm not sure this is true for all
1382 instructions that take WC registers. */
1383 if (reg && reg->type == REG_TYPE_MMXWCG)
1394 /* As arm_reg_parse_multi, but the register must be of type TYPE, and the
1395 return value is the register number or FAIL. */
1398 arm_reg_parse (char **ccp, enum arm_reg_type type)
1401 struct reg_entry *reg = arm_reg_parse_multi (ccp);
1404 /* Do not allow a scalar (reg+index) to parse as a register. */
1405 if (reg && reg->neon && (reg->neon->defined & NTA_HASINDEX))
1408 if (reg && reg->type == type)
1411 if ((ret = arm_reg_alt_syntax (ccp, start, reg, type)) != FAIL)
1418 /* Parse a Neon type specifier. *STR should point at the leading '.'
1419 character. Does no verification at this stage that the type fits the opcode
1426 Can all be legally parsed by this function.
1428 Fills in neon_type struct pointer with parsed information, and updates STR
1429 to point after the parsed type specifier. Returns SUCCESS if this was a legal
1430 type, FAIL if not. */
1433 parse_neon_type (struct neon_type *type, char **str)
1440 while (type->elems < NEON_MAX_TYPE_ELS)
1442 enum neon_el_type thistype = NT_untyped;
1443 unsigned thissize = -1u;
1450 /* Just a size without an explicit type. */
1454 switch (TOLOWER (*ptr))
1456 case 'i': thistype = NT_integer; break;
1457 case 'f': thistype = NT_float; break;
1458 case 'p': thistype = NT_poly; break;
1459 case 's': thistype = NT_signed; break;
1460 case 'u': thistype = NT_unsigned; break;
1462 thistype = NT_float;
1467 as_bad (_("unexpected character `%c' in type specifier"), *ptr);
1473 /* .f is an abbreviation for .f32. */
1474 if (thistype == NT_float && !ISDIGIT (*ptr))
1479 thissize = strtoul (ptr, &ptr, 10);
1481 if (thissize != 8 && thissize != 16 && thissize != 32
1484 as_bad (_("bad size %d in type specifier"), thissize);
1492 type->el[type->elems].type = thistype;
1493 type->el[type->elems].size = thissize;
1498 /* Empty/missing type is not a successful parse. */
1499 if (type->elems == 0)
1507 /* Errors may be set multiple times during parsing or bit encoding
1508 (particularly in the Neon bits), but usually the earliest error which is set
1509 will be the most meaningful. Avoid overwriting it with later (cascading)
1510 errors by calling this function. */
1513 first_error (const char *err)
1519 /* Parse a single type, e.g. ".s32", leading period included. */
1521 parse_neon_operand_type (struct neon_type_el *vectype, char **ccp)
1524 struct neon_type optype;
1528 if (parse_neon_type (&optype, &str) == SUCCESS)
1530 if (optype.elems == 1)
1531 *vectype = optype.el[0];
1534 first_error (_("only one type should be specified for operand"));
1540 first_error (_("vector type expected"));
1552 /* Special meanings for indices (which have a range of 0-7), which will fit into
1555 #define NEON_ALL_LANES 15
1556 #define NEON_INTERLEAVE_LANES 14
1558 /* Record a use of the given feature. */
1560 record_feature_use (const arm_feature_set *feature)
1563 ARM_MERGE_FEATURE_SETS (thumb_arch_used, thumb_arch_used, *feature);
1565 ARM_MERGE_FEATURE_SETS (arm_arch_used, arm_arch_used, *feature);
1568 /* If the given feature available in the selected CPU, mark it as used.
1569 Returns TRUE iff feature is available. */
1571 mark_feature_used (const arm_feature_set *feature)
1574 /* Do not support the use of MVE only instructions when in auto-detection or
1576 if (((feature == &mve_ext) || (feature == &mve_fp_ext))
1577 && ARM_CPU_IS_ANY (cpu_variant))
1579 first_error (BAD_MVE_AUTO);
1582 /* Ensure the option is valid on the current architecture. */
1583 if (!ARM_CPU_HAS_FEATURE (cpu_variant, *feature))
1586 /* Add the appropriate architecture feature for the barrier option used.
1588 record_feature_use (feature);
1593 /* Parse either a register or a scalar, with an optional type. Return the
1594 register number, and optionally fill in the actual type of the register
1595 when multiple alternatives were given (NEON_TYPE_NDQ) in *RTYPE, and
1596 type/index information in *TYPEINFO. */
1599 parse_typed_reg_or_scalar (char **ccp, enum arm_reg_type type,
1600 enum arm_reg_type *rtype,
1601 struct neon_typed_alias *typeinfo)
1604 struct reg_entry *reg = arm_reg_parse_multi (&str);
1605 struct neon_typed_alias atype;
1606 struct neon_type_el parsetype;
1610 atype.eltype.type = NT_invtype;
1611 atype.eltype.size = -1;
1613 /* Try alternate syntax for some types of register. Note these are mutually
1614 exclusive with the Neon syntax extensions. */
1617 int altreg = arm_reg_alt_syntax (&str, *ccp, reg, type);
1625 /* Undo polymorphism when a set of register types may be accepted. */
1626 if ((type == REG_TYPE_NDQ
1627 && (reg->type == REG_TYPE_NQ || reg->type == REG_TYPE_VFD))
1628 || (type == REG_TYPE_VFSD
1629 && (reg->type == REG_TYPE_VFS || reg->type == REG_TYPE_VFD))
1630 || (type == REG_TYPE_NSDQ
1631 && (reg->type == REG_TYPE_VFS || reg->type == REG_TYPE_VFD
1632 || reg->type == REG_TYPE_NQ))
1633 || (type == REG_TYPE_NSD
1634 && (reg->type == REG_TYPE_VFS || reg->type == REG_TYPE_VFD))
1635 || (type == REG_TYPE_MMXWC
1636 && (reg->type == REG_TYPE_MMXWCG)))
1637 type = (enum arm_reg_type) reg->type;
1639 if (type == REG_TYPE_MQ)
1641 if (!ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext))
1644 if (!reg || reg->type != REG_TYPE_NQ)
1647 if (reg->number > 14 && !mark_feature_used (&fpu_vfp_ext_d32))
1649 first_error (_("expected MVE register [q0..q7]"));
1654 else if (ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext)
1655 && (type == REG_TYPE_NQ))
1659 if (type != reg->type)
1665 if (parse_neon_operand_type (&parsetype, &str) == SUCCESS)
1667 if ((atype.defined & NTA_HASTYPE) != 0)
1669 first_error (_("can't redefine type for operand"));
1672 atype.defined |= NTA_HASTYPE;
1673 atype.eltype = parsetype;
1676 if (skip_past_char (&str, '[') == SUCCESS)
1678 if (type != REG_TYPE_VFD
1679 && !(type == REG_TYPE_VFS
1680 && ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_v8_2))
1681 && !(type == REG_TYPE_NQ
1682 && ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext)))
1684 if (ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext))
1685 first_error (_("only D and Q registers may be indexed"));
1687 first_error (_("only D registers may be indexed"));
1691 if ((atype.defined & NTA_HASINDEX) != 0)
1693 first_error (_("can't change index for operand"));
1697 atype.defined |= NTA_HASINDEX;
1699 if (skip_past_char (&str, ']') == SUCCESS)
1700 atype.index = NEON_ALL_LANES;
1705 my_get_expression (&exp, &str, GE_NO_PREFIX);
1707 if (exp.X_op != O_constant)
1709 first_error (_("constant expression required"));
1713 if (skip_past_char (&str, ']') == FAIL)
1716 atype.index = exp.X_add_number;
1731 /* Like arm_reg_parse, but also allow the following extra features:
1732 - If RTYPE is non-zero, return the (possibly restricted) type of the
1733 register (e.g. Neon double or quad reg when either has been requested).
1734 - If this is a Neon vector type with additional type information, fill
1735 in the struct pointed to by VECTYPE (if non-NULL).
1736 This function will fault on encountering a scalar. */
1739 arm_typed_reg_parse (char **ccp, enum arm_reg_type type,
1740 enum arm_reg_type *rtype, struct neon_type_el *vectype)
1742 struct neon_typed_alias atype;
1744 int reg = parse_typed_reg_or_scalar (&str, type, rtype, &atype);
1749 /* Do not allow regname(... to parse as a register. */
1753 /* Do not allow a scalar (reg+index) to parse as a register. */
1754 if ((atype.defined & NTA_HASINDEX) != 0)
1756 first_error (_("register operand expected, but got scalar"));
1761 *vectype = atype.eltype;
1768 #define NEON_SCALAR_REG(X) ((X) >> 4)
1769 #define NEON_SCALAR_INDEX(X) ((X) & 15)
1771 /* Parse a Neon scalar. Most of the time when we're parsing a scalar, we don't
1772 have enough information to be able to do a good job bounds-checking. So, we
1773 just do easy checks here, and do further checks later. */
1776 parse_scalar (char **ccp, int elsize, struct neon_type_el *type, enum
1777 arm_reg_type reg_type)
1781 struct neon_typed_alias atype;
1784 reg = parse_typed_reg_or_scalar (&str, reg_type, NULL, &atype);
1802 if (reg == FAIL || (atype.defined & NTA_HASINDEX) == 0)
1805 if (reg_type != REG_TYPE_MQ && atype.index == NEON_ALL_LANES)
1807 first_error (_("scalar must have an index"));
1810 else if (atype.index >= reg_size / elsize)
1812 first_error (_("scalar index out of range"));
1817 *type = atype.eltype;
1821 return reg * 16 + atype.index;
1824 /* Types of registers in a list. */
1837 /* Parse an ARM register list. Returns the bitmask, or FAIL. */
1840 parse_reg_list (char ** strp, enum reg_list_els etype)
1846 gas_assert (etype == REGLIST_RN || etype == REGLIST_CLRM);
1848 /* We come back here if we get ranges concatenated by '+' or '|'. */
1851 skip_whitespace (str);
1864 const char apsr_str[] = "apsr";
1865 int apsr_str_len = strlen (apsr_str);
1867 reg = arm_reg_parse (&str, REGLIST_RN);
1868 if (etype == REGLIST_CLRM)
1870 if (reg == REG_SP || reg == REG_PC)
1872 else if (reg == FAIL
1873 && !strncasecmp (str, apsr_str, apsr_str_len)
1874 && !ISALPHA (*(str + apsr_str_len)))
1877 str += apsr_str_len;
1882 first_error (_("r0-r12, lr or APSR expected"));
1886 else /* etype == REGLIST_RN. */
1890 first_error (_(reg_expected_msgs[REGLIST_RN]));
1901 first_error (_("bad range in register list"));
1905 for (i = cur_reg + 1; i < reg; i++)
1907 if (range & (1 << i))
1909 (_("Warning: duplicated register (r%d) in register list"),
1917 if (range & (1 << reg))
1918 as_tsktsk (_("Warning: duplicated register (r%d) in register list"),
1920 else if (reg <= cur_reg)
1921 as_tsktsk (_("Warning: register range not in ascending order"));
1926 while (skip_past_comma (&str) != FAIL
1927 || (in_range = 1, *str++ == '-'));
1930 if (skip_past_char (&str, '}') == FAIL)
1932 first_error (_("missing `}'"));
1936 else if (etype == REGLIST_RN)
1940 if (my_get_expression (&exp, &str, GE_NO_PREFIX))
1943 if (exp.X_op == O_constant)
1945 if (exp.X_add_number
1946 != (exp.X_add_number & 0x0000ffff))
1948 inst.error = _("invalid register mask");
1952 if ((range & exp.X_add_number) != 0)
1954 int regno = range & exp.X_add_number;
1957 regno = (1 << regno) - 1;
1959 (_("Warning: duplicated register (r%d) in register list"),
1963 range |= exp.X_add_number;
1967 if (inst.relocs[0].type != 0)
1969 inst.error = _("expression too complex");
1973 memcpy (&inst.relocs[0].exp, &exp, sizeof (expressionS));
1974 inst.relocs[0].type = BFD_RELOC_ARM_MULTI;
1975 inst.relocs[0].pc_rel = 0;
1979 if (*str == '|' || *str == '+')
1985 while (another_range);
1991 /* Parse a VFP register list. If the string is invalid return FAIL.
1992 Otherwise return the number of registers, and set PBASE to the first
1993 register. Parses registers of type ETYPE.
1994 If REGLIST_NEON_D is used, several syntax enhancements are enabled:
1995 - Q registers can be used to specify pairs of D registers
1996 - { } can be omitted from around a singleton register list
1997 FIXME: This is not implemented, as it would require backtracking in
2000 This could be done (the meaning isn't really ambiguous), but doesn't
2001 fit in well with the current parsing framework.
2002 - 32 D registers may be used (also true for VFPv3).
2003 FIXME: Types are ignored in these register lists, which is probably a
2007 parse_vfp_reg_list (char **ccp, unsigned int *pbase, enum reg_list_els etype,
2008 bfd_boolean *partial_match)
2013 enum arm_reg_type regtype = (enum arm_reg_type) 0;
2017 unsigned long mask = 0;
2019 bfd_boolean vpr_seen = FALSE;
2020 bfd_boolean expect_vpr =
2021 (etype == REGLIST_VFP_S_VPR) || (etype == REGLIST_VFP_D_VPR);
2023 if (skip_past_char (&str, '{') == FAIL)
2025 inst.error = _("expecting {");
2032 case REGLIST_VFP_S_VPR:
2033 regtype = REG_TYPE_VFS;
2038 case REGLIST_VFP_D_VPR:
2039 regtype = REG_TYPE_VFD;
2042 case REGLIST_NEON_D:
2043 regtype = REG_TYPE_NDQ;
2050 if (etype != REGLIST_VFP_S && etype != REGLIST_VFP_S_VPR)
2052 /* VFPv3 allows 32 D registers, except for the VFPv3-D16 variant. */
2053 if (ARM_CPU_HAS_FEATURE (cpu_variant, fpu_vfp_ext_d32))
2057 ARM_MERGE_FEATURE_SETS (thumb_arch_used, thumb_arch_used,
2060 ARM_MERGE_FEATURE_SETS (arm_arch_used, arm_arch_used,
2067 base_reg = max_regs;
2068 *partial_match = FALSE;
2072 int setmask = 1, addregs = 1;
2073 const char vpr_str[] = "vpr";
2074 int vpr_str_len = strlen (vpr_str);
2076 new_base = arm_typed_reg_parse (&str, regtype, ®type, NULL);
2080 if (new_base == FAIL
2081 && !strncasecmp (str, vpr_str, vpr_str_len)
2082 && !ISALPHA (*(str + vpr_str_len))
2088 base_reg = 0; /* Canonicalize VPR only on d0 with 0 regs. */
2092 first_error (_("VPR expected last"));
2095 else if (new_base == FAIL)
2097 if (regtype == REG_TYPE_VFS)
2098 first_error (_("VFP single precision register or VPR "
2100 else /* regtype == REG_TYPE_VFD. */
2101 first_error (_("VFP/Neon double precision register or VPR "
2106 else if (new_base == FAIL)
2108 first_error (_(reg_expected_msgs[regtype]));
2112 *partial_match = TRUE;
2116 if (new_base >= max_regs)
2118 first_error (_("register out of range in list"));
2122 /* Note: a value of 2 * n is returned for the register Q<n>. */
2123 if (regtype == REG_TYPE_NQ)
2129 if (new_base < base_reg)
2130 base_reg = new_base;
2132 if (mask & (setmask << new_base))
2134 first_error (_("invalid register list"));
2138 if ((mask >> new_base) != 0 && ! warned && !vpr_seen)
2140 as_tsktsk (_("register list not in ascending order"));
2144 mask |= setmask << new_base;
2147 if (*str == '-') /* We have the start of a range expression */
2153 if ((high_range = arm_typed_reg_parse (&str, regtype, NULL, NULL))
2156 inst.error = gettext (reg_expected_msgs[regtype]);
2160 if (high_range >= max_regs)
2162 first_error (_("register out of range in list"));
2166 if (regtype == REG_TYPE_NQ)
2167 high_range = high_range + 1;
2169 if (high_range <= new_base)
2171 inst.error = _("register range not in ascending order");
2175 for (new_base += addregs; new_base <= high_range; new_base += addregs)
2177 if (mask & (setmask << new_base))
2179 inst.error = _("invalid register list");
2183 mask |= setmask << new_base;
2188 while (skip_past_comma (&str) != FAIL);
2192 /* Sanity check -- should have raised a parse error above. */
2193 if ((!vpr_seen && count == 0) || count > max_regs)
2198 if (expect_vpr && !vpr_seen)
2200 first_error (_("VPR expected last"));
2204 /* Final test -- the registers must be consecutive. */
2206 for (i = 0; i < count; i++)
2208 if ((mask & (1u << i)) == 0)
2210 inst.error = _("non-contiguous register range");
2220 /* True if two alias types are the same. */
2223 neon_alias_types_same (struct neon_typed_alias *a, struct neon_typed_alias *b)
2231 if (a->defined != b->defined)
2234 if ((a->defined & NTA_HASTYPE) != 0
2235 && (a->eltype.type != b->eltype.type
2236 || a->eltype.size != b->eltype.size))
2239 if ((a->defined & NTA_HASINDEX) != 0
2240 && (a->index != b->index))
2246 /* Parse element/structure lists for Neon VLD<n> and VST<n> instructions.
2247 The base register is put in *PBASE.
2248 The lane (or one of the NEON_*_LANES constants) is placed in bits [3:0] of
2250 The register stride (minus one) is put in bit 4 of the return value.
2251 Bits [6:5] encode the list length (minus one).
2252 The type of the list elements is put in *ELTYPE, if non-NULL. */
2254 #define NEON_LANE(X) ((X) & 0xf)
2255 #define NEON_REG_STRIDE(X) ((((X) >> 4) & 1) + 1)
2256 #define NEON_REGLIST_LENGTH(X) ((((X) >> 5) & 3) + 1)
2259 parse_neon_el_struct_list (char **str, unsigned *pbase,
2261 struct neon_type_el *eltype)
2268 int leading_brace = 0;
2269 enum arm_reg_type rtype = REG_TYPE_NDQ;
2270 const char *const incr_error = mve ? _("register stride must be 1") :
2271 _("register stride must be 1 or 2");
2272 const char *const type_error = _("mismatched element/structure types in list");
2273 struct neon_typed_alias firsttype;
2274 firsttype.defined = 0;
2275 firsttype.eltype.type = NT_invtype;
2276 firsttype.eltype.size = -1;
2277 firsttype.index = -1;
2279 if (skip_past_char (&ptr, '{') == SUCCESS)
2284 struct neon_typed_alias atype;
2286 rtype = REG_TYPE_MQ;
2287 int getreg = parse_typed_reg_or_scalar (&ptr, rtype, &rtype, &atype);
2291 first_error (_(reg_expected_msgs[rtype]));
2298 if (rtype == REG_TYPE_NQ)
2304 else if (reg_incr == -1)
2306 reg_incr = getreg - base_reg;
2307 if (reg_incr < 1 || reg_incr > 2)
2309 first_error (_(incr_error));
2313 else if (getreg != base_reg + reg_incr * count)
2315 first_error (_(incr_error));
2319 if (! neon_alias_types_same (&atype, &firsttype))
2321 first_error (_(type_error));
2325 /* Handle Dn-Dm or Qn-Qm syntax. Can only be used with non-indexed list
2329 struct neon_typed_alias htype;
2330 int hireg, dregs = (rtype == REG_TYPE_NQ) ? 2 : 1;
2332 lane = NEON_INTERLEAVE_LANES;
2333 else if (lane != NEON_INTERLEAVE_LANES)
2335 first_error (_(type_error));
2340 else if (reg_incr != 1)
2342 first_error (_("don't use Rn-Rm syntax with non-unit stride"));
2346 hireg = parse_typed_reg_or_scalar (&ptr, rtype, NULL, &htype);
2349 first_error (_(reg_expected_msgs[rtype]));
2352 if (! neon_alias_types_same (&htype, &firsttype))
2354 first_error (_(type_error));
2357 count += hireg + dregs - getreg;
2361 /* If we're using Q registers, we can't use [] or [n] syntax. */
2362 if (rtype == REG_TYPE_NQ)
2368 if ((atype.defined & NTA_HASINDEX) != 0)
2372 else if (lane != atype.index)
2374 first_error (_(type_error));
2378 else if (lane == -1)
2379 lane = NEON_INTERLEAVE_LANES;
2380 else if (lane != NEON_INTERLEAVE_LANES)
2382 first_error (_(type_error));
2387 while ((count != 1 || leading_brace) && skip_past_comma (&ptr) != FAIL);
2389 /* No lane set by [x]. We must be interleaving structures. */
2391 lane = NEON_INTERLEAVE_LANES;
2394 if (lane == -1 || base_reg == -1 || count < 1 || (!mve && count > 4)
2395 || (count > 1 && reg_incr == -1))
2397 first_error (_("error parsing element/structure list"));
2401 if ((count > 1 || leading_brace) && skip_past_char (&ptr, '}') == FAIL)
2403 first_error (_("expected }"));
2411 *eltype = firsttype.eltype;
2416 return lane | ((reg_incr - 1) << 4) | ((count - 1) << 5);
2419 /* Parse an explicit relocation suffix on an expression. This is
2420 either nothing, or a word in parentheses. Note that if !OBJ_ELF,
2421 arm_reloc_hsh contains no entries, so this function can only
2422 succeed if there is no () after the word. Returns -1 on error,
2423 BFD_RELOC_UNUSED if there wasn't any suffix. */
2426 parse_reloc (char **str)
2428 struct reloc_entry *r;
2432 return BFD_RELOC_UNUSED;
2437 while (*q && *q != ')' && *q != ',')
2442 if ((r = (struct reloc_entry *)
2443 hash_find_n (arm_reloc_hsh, p, q - p)) == NULL)
2450 /* Directives: register aliases. */
2452 static struct reg_entry *
2453 insert_reg_alias (char *str, unsigned number, int type)
2455 struct reg_entry *new_reg;
2458 if ((new_reg = (struct reg_entry *) hash_find (arm_reg_hsh, str)) != 0)
2460 if (new_reg->builtin)
2461 as_warn (_("ignoring attempt to redefine built-in register '%s'"), str);
2463 /* Only warn about a redefinition if it's not defined as the
2465 else if (new_reg->number != number || new_reg->type != type)
2466 as_warn (_("ignoring redefinition of register alias '%s'"), str);
2471 name = xstrdup (str);
2472 new_reg = XNEW (struct reg_entry);
2474 new_reg->name = name;
2475 new_reg->number = number;
2476 new_reg->type = type;
2477 new_reg->builtin = FALSE;
2478 new_reg->neon = NULL;
2480 if (hash_insert (arm_reg_hsh, name, (void *) new_reg))
2487 insert_neon_reg_alias (char *str, int number, int type,
2488 struct neon_typed_alias *atype)
2490 struct reg_entry *reg = insert_reg_alias (str, number, type);
2494 first_error (_("attempt to redefine typed alias"));
2500 reg->neon = XNEW (struct neon_typed_alias);
2501 *reg->neon = *atype;
2505 /* Look for the .req directive. This is of the form:
2507 new_register_name .req existing_register_name
2509 If we find one, or if it looks sufficiently like one that we want to
2510 handle any error here, return TRUE. Otherwise return FALSE. */
2513 create_register_alias (char * newname, char *p)
2515 struct reg_entry *old;
2516 char *oldname, *nbuf;
2519 /* The input scrubber ensures that whitespace after the mnemonic is
2520 collapsed to single spaces. */
2522 if (strncmp (oldname, " .req ", 6) != 0)
2526 if (*oldname == '\0')
2529 old = (struct reg_entry *) hash_find (arm_reg_hsh, oldname);
2532 as_warn (_("unknown register '%s' -- .req ignored"), oldname);
2536 /* If TC_CASE_SENSITIVE is defined, then newname already points to
2537 the desired alias name, and p points to its end. If not, then
2538 the desired alias name is in the global original_case_string. */
2539 #ifdef TC_CASE_SENSITIVE
2542 newname = original_case_string;
2543 nlen = strlen (newname);
2546 nbuf = xmemdup0 (newname, nlen);
2548 /* Create aliases under the new name as stated; an all-lowercase
2549 version of the new name; and an all-uppercase version of the new
2551 if (insert_reg_alias (nbuf, old->number, old->type) != NULL)
2553 for (p = nbuf; *p; p++)
2556 if (strncmp (nbuf, newname, nlen))
2558 /* If this attempt to create an additional alias fails, do not bother
2559 trying to create the all-lower case alias. We will fail and issue
2560 a second, duplicate error message. This situation arises when the
2561 programmer does something like:
2564 The second .req creates the "Foo" alias but then fails to create
2565 the artificial FOO alias because it has already been created by the
2567 if (insert_reg_alias (nbuf, old->number, old->type) == NULL)
2574 for (p = nbuf; *p; p++)
2577 if (strncmp (nbuf, newname, nlen))
2578 insert_reg_alias (nbuf, old->number, old->type);
2585 /* Create a Neon typed/indexed register alias using directives, e.g.:
2590 These typed registers can be used instead of the types specified after the
2591 Neon mnemonic, so long as all operands given have types. Types can also be
2592 specified directly, e.g.:
2593 vadd d0.s32, d1.s32, d2.s32 */
2596 create_neon_reg_alias (char *newname, char *p)
2598 enum arm_reg_type basetype;
2599 struct reg_entry *basereg;
2600 struct reg_entry mybasereg;
2601 struct neon_type ntype;
2602 struct neon_typed_alias typeinfo;
2603 char *namebuf, *nameend ATTRIBUTE_UNUSED;
2606 typeinfo.defined = 0;
2607 typeinfo.eltype.type = NT_invtype;
2608 typeinfo.eltype.size = -1;
2609 typeinfo.index = -1;
2613 if (strncmp (p, " .dn ", 5) == 0)
2614 basetype = REG_TYPE_VFD;
2615 else if (strncmp (p, " .qn ", 5) == 0)
2616 basetype = REG_TYPE_NQ;
2625 basereg = arm_reg_parse_multi (&p);
2627 if (basereg && basereg->type != basetype)
2629 as_bad (_("bad type for register"));
2633 if (basereg == NULL)
2636 /* Try parsing as an integer. */
2637 my_get_expression (&exp, &p, GE_NO_PREFIX);
2638 if (exp.X_op != O_constant)
2640 as_bad (_("expression must be constant"));
2643 basereg = &mybasereg;
2644 basereg->number = (basetype == REG_TYPE_NQ) ? exp.X_add_number * 2
2650 typeinfo = *basereg->neon;
2652 if (parse_neon_type (&ntype, &p) == SUCCESS)
2654 /* We got a type. */
2655 if (typeinfo.defined & NTA_HASTYPE)
2657 as_bad (_("can't redefine the type of a register alias"));
2661 typeinfo.defined |= NTA_HASTYPE;
2662 if (ntype.elems != 1)
2664 as_bad (_("you must specify a single type only"));
2667 typeinfo.eltype = ntype.el[0];
2670 if (skip_past_char (&p, '[') == SUCCESS)
2673 /* We got a scalar index. */
2675 if (typeinfo.defined & NTA_HASINDEX)
2677 as_bad (_("can't redefine the index of a scalar alias"));
2681 my_get_expression (&exp, &p, GE_NO_PREFIX);
2683 if (exp.X_op != O_constant)
2685 as_bad (_("scalar index must be constant"));
2689 typeinfo.defined |= NTA_HASINDEX;
2690 typeinfo.index = exp.X_add_number;
2692 if (skip_past_char (&p, ']') == FAIL)
2694 as_bad (_("expecting ]"));
2699 /* If TC_CASE_SENSITIVE is defined, then newname already points to
2700 the desired alias name, and p points to its end. If not, then
2701 the desired alias name is in the global original_case_string. */
2702 #ifdef TC_CASE_SENSITIVE
2703 namelen = nameend - newname;
2705 newname = original_case_string;
2706 namelen = strlen (newname);
2709 namebuf = xmemdup0 (newname, namelen);
2711 insert_neon_reg_alias (namebuf, basereg->number, basetype,
2712 typeinfo.defined != 0 ? &typeinfo : NULL);
2714 /* Insert name in all uppercase. */
2715 for (p = namebuf; *p; p++)
2718 if (strncmp (namebuf, newname, namelen))
2719 insert_neon_reg_alias (namebuf, basereg->number, basetype,
2720 typeinfo.defined != 0 ? &typeinfo : NULL);
2722 /* Insert name in all lowercase. */
2723 for (p = namebuf; *p; p++)
2726 if (strncmp (namebuf, newname, namelen))
2727 insert_neon_reg_alias (namebuf, basereg->number, basetype,
2728 typeinfo.defined != 0 ? &typeinfo : NULL);
2734 /* Should never be called, as .req goes between the alias and the
2735 register name, not at the beginning of the line. */
2738 s_req (int a ATTRIBUTE_UNUSED)
2740 as_bad (_("invalid syntax for .req directive"));
2744 s_dn (int a ATTRIBUTE_UNUSED)
2746 as_bad (_("invalid syntax for .dn directive"));
2750 s_qn (int a ATTRIBUTE_UNUSED)
2752 as_bad (_("invalid syntax for .qn directive"));
2755 /* The .unreq directive deletes an alias which was previously defined
2756 by .req. For example:
2762 s_unreq (int a ATTRIBUTE_UNUSED)
2767 name = input_line_pointer;
2769 while (*input_line_pointer != 0
2770 && *input_line_pointer != ' '
2771 && *input_line_pointer != '\n')
2772 ++input_line_pointer;
2774 saved_char = *input_line_pointer;
2775 *input_line_pointer = 0;
2778 as_bad (_("invalid syntax for .unreq directive"));
2781 struct reg_entry *reg = (struct reg_entry *) hash_find (arm_reg_hsh,
2785 as_bad (_("unknown register alias '%s'"), name);
2786 else if (reg->builtin)
2787 as_warn (_("ignoring attempt to use .unreq on fixed register name: '%s'"),
2794 hash_delete (arm_reg_hsh, name, FALSE);
2795 free ((char *) reg->name);
2800 /* Also locate the all upper case and all lower case versions.
2801 Do not complain if we cannot find one or the other as it
2802 was probably deleted above. */
2804 nbuf = strdup (name);
2805 for (p = nbuf; *p; p++)
2807 reg = (struct reg_entry *) hash_find (arm_reg_hsh, nbuf);
2810 hash_delete (arm_reg_hsh, nbuf, FALSE);
2811 free ((char *) reg->name);
2817 for (p = nbuf; *p; p++)
2819 reg = (struct reg_entry *) hash_find (arm_reg_hsh, nbuf);
2822 hash_delete (arm_reg_hsh, nbuf, FALSE);
2823 free ((char *) reg->name);
2833 *input_line_pointer = saved_char;
2834 demand_empty_rest_of_line ();
2837 /* Directives: Instruction set selection. */
2840 /* This code is to handle mapping symbols as defined in the ARM ELF spec.
2841 (See "Mapping symbols", section 4.5.5, ARM AAELF version 1.0).
2842 Note that previously, $a and $t has type STT_FUNC (BSF_OBJECT flag),
2843 and $d has type STT_OBJECT (BSF_OBJECT flag). Now all three are untyped. */
2845 /* Create a new mapping symbol for the transition to STATE. */
2848 make_mapping_symbol (enum mstate state, valueT value, fragS *frag)
2851 const char * symname;
2858 type = BSF_NO_FLAGS;
2862 type = BSF_NO_FLAGS;
2866 type = BSF_NO_FLAGS;
2872 symbolP = symbol_new (symname, now_seg, value, frag);
2873 symbol_get_bfdsym (symbolP)->flags |= type | BSF_LOCAL;
2878 THUMB_SET_FUNC (symbolP, 0);
2879 ARM_SET_THUMB (symbolP, 0);
2880 ARM_SET_INTERWORK (symbolP, support_interwork);
2884 THUMB_SET_FUNC (symbolP, 1);
2885 ARM_SET_THUMB (symbolP, 1);
2886 ARM_SET_INTERWORK (symbolP, support_interwork);
2894 /* Save the mapping symbols for future reference. Also check that
2895 we do not place two mapping symbols at the same offset within a
2896 frag. We'll handle overlap between frags in
2897 check_mapping_symbols.
2899 If .fill or other data filling directive generates zero sized data,
2900 the mapping symbol for the following code will have the same value
2901 as the one generated for the data filling directive. In this case,
2902 we replace the old symbol with the new one at the same address. */
2905 if (frag->tc_frag_data.first_map != NULL)
2907 know (S_GET_VALUE (frag->tc_frag_data.first_map) == 0);
2908 symbol_remove (frag->tc_frag_data.first_map, &symbol_rootP, &symbol_lastP);
2910 frag->tc_frag_data.first_map = symbolP;
2912 if (frag->tc_frag_data.last_map != NULL)
2914 know (S_GET_VALUE (frag->tc_frag_data.last_map) <= S_GET_VALUE (symbolP));
2915 if (S_GET_VALUE (frag->tc_frag_data.last_map) == S_GET_VALUE (symbolP))
2916 symbol_remove (frag->tc_frag_data.last_map, &symbol_rootP, &symbol_lastP);
2918 frag->tc_frag_data.last_map = symbolP;
2921 /* We must sometimes convert a region marked as code to data during
2922 code alignment, if an odd number of bytes have to be padded. The
2923 code mapping symbol is pushed to an aligned address. */
2926 insert_data_mapping_symbol (enum mstate state,
2927 valueT value, fragS *frag, offsetT bytes)
2929 /* If there was already a mapping symbol, remove it. */
2930 if (frag->tc_frag_data.last_map != NULL
2931 && S_GET_VALUE (frag->tc_frag_data.last_map) == frag->fr_address + value)
2933 symbolS *symp = frag->tc_frag_data.last_map;
2937 know (frag->tc_frag_data.first_map == symp);
2938 frag->tc_frag_data.first_map = NULL;
2940 frag->tc_frag_data.last_map = NULL;
2941 symbol_remove (symp, &symbol_rootP, &symbol_lastP);
2944 make_mapping_symbol (MAP_DATA, value, frag);
2945 make_mapping_symbol (state, value + bytes, frag);
2948 static void mapping_state_2 (enum mstate state, int max_chars);
2950 /* Set the mapping state to STATE. Only call this when about to
2951 emit some STATE bytes to the file. */
2953 #define TRANSITION(from, to) (mapstate == (from) && state == (to))
2955 mapping_state (enum mstate state)
2957 enum mstate mapstate = seg_info (now_seg)->tc_segment_info_data.mapstate;
2959 if (mapstate == state)
2960 /* The mapping symbol has already been emitted.
2961 There is nothing else to do. */
2964 if (state == MAP_ARM || state == MAP_THUMB)
2966 All ARM instructions require 4-byte alignment.
2967 (Almost) all Thumb instructions require 2-byte alignment.
2969 When emitting instructions into any section, mark the section
2972 Some Thumb instructions are alignment-sensitive modulo 4 bytes,
2973 but themselves require 2-byte alignment; this applies to some
2974 PC- relative forms. However, these cases will involve implicit
2975 literal pool generation or an explicit .align >=2, both of
2976 which will cause the section to me marked with sufficient
2977 alignment. Thus, we don't handle those cases here. */
2978 record_alignment (now_seg, state == MAP_ARM ? 2 : 1);
2980 if (TRANSITION (MAP_UNDEFINED, MAP_DATA))
2981 /* This case will be evaluated later. */
2984 mapping_state_2 (state, 0);
2987 /* Same as mapping_state, but MAX_CHARS bytes have already been
2988 allocated. Put the mapping symbol that far back. */
2991 mapping_state_2 (enum mstate state, int max_chars)
2993 enum mstate mapstate = seg_info (now_seg)->tc_segment_info_data.mapstate;
2995 if (!SEG_NORMAL (now_seg))
2998 if (mapstate == state)
2999 /* The mapping symbol has already been emitted.
3000 There is nothing else to do. */
3003 if (TRANSITION (MAP_UNDEFINED, MAP_ARM)
3004 || TRANSITION (MAP_UNDEFINED, MAP_THUMB))
3006 struct frag * const frag_first = seg_info (now_seg)->frchainP->frch_root;
3007 const int add_symbol = (frag_now != frag_first) || (frag_now_fix () > 0);
3010 make_mapping_symbol (MAP_DATA, (valueT) 0, frag_first);
3013 seg_info (now_seg)->tc_segment_info_data.mapstate = state;
3014 make_mapping_symbol (state, (valueT) frag_now_fix () - max_chars, frag_now);
3018 #define mapping_state(x) ((void)0)
3019 #define mapping_state_2(x, y) ((void)0)
3022 /* Find the real, Thumb encoded start of a Thumb function. */
3026 find_real_start (symbolS * symbolP)
3029 const char * name = S_GET_NAME (symbolP);
3030 symbolS * new_target;
3032 /* This definition must agree with the one in gcc/config/arm/thumb.c. */
3033 #define STUB_NAME ".real_start_of"
3038 /* The compiler may generate BL instructions to local labels because
3039 it needs to perform a branch to a far away location. These labels
3040 do not have a corresponding ".real_start_of" label. We check
3041 both for S_IS_LOCAL and for a leading dot, to give a way to bypass
3042 the ".real_start_of" convention for nonlocal branches. */
3043 if (S_IS_LOCAL (symbolP) || name[0] == '.')
3046 real_start = concat (STUB_NAME, name, NULL);
3047 new_target = symbol_find (real_start);
3050 if (new_target == NULL)
3052 as_warn (_("Failed to find real start of function: %s\n"), name);
3053 new_target = symbolP;
3061 opcode_select (int width)
3068 if (!ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_v4t))
3069 as_bad (_("selected processor does not support THUMB opcodes"));
3072 /* No need to force the alignment, since we will have been
3073 coming from ARM mode, which is word-aligned. */
3074 record_alignment (now_seg, 1);
3081 if (!ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_v1))
3082 as_bad (_("selected processor does not support ARM opcodes"));
3087 frag_align (2, 0, 0);
3089 record_alignment (now_seg, 1);
3094 as_bad (_("invalid instruction size selected (%d)"), width);
3099 s_arm (int ignore ATTRIBUTE_UNUSED)
3102 demand_empty_rest_of_line ();
3106 s_thumb (int ignore ATTRIBUTE_UNUSED)
3109 demand_empty_rest_of_line ();
3113 s_code (int unused ATTRIBUTE_UNUSED)
3117 temp = get_absolute_expression ();
3122 opcode_select (temp);
3126 as_bad (_("invalid operand to .code directive (%d) (expecting 16 or 32)"), temp);
3131 s_force_thumb (int ignore ATTRIBUTE_UNUSED)
3133 /* If we are not already in thumb mode go into it, EVEN if
3134 the target processor does not support thumb instructions.
3135 This is used by gcc/config/arm/lib1funcs.asm for example
3136 to compile interworking support functions even if the
3137 target processor should not support interworking. */
3141 record_alignment (now_seg, 1);
3144 demand_empty_rest_of_line ();
3148 s_thumb_func (int ignore ATTRIBUTE_UNUSED)
3152 /* The following label is the name/address of the start of a Thumb function.
3153 We need to know this for the interworking support. */
3154 label_is_thumb_function_name = TRUE;
3157 /* Perform a .set directive, but also mark the alias as
3158 being a thumb function. */
3161 s_thumb_set (int equiv)
3163 /* XXX the following is a duplicate of the code for s_set() in read.c
3164 We cannot just call that code as we need to get at the symbol that
3171 /* Especial apologies for the random logic:
3172 This just grew, and could be parsed much more simply!
3174 delim = get_symbol_name (& name);
3175 end_name = input_line_pointer;
3176 (void) restore_line_pointer (delim);
3178 if (*input_line_pointer != ',')
3181 as_bad (_("expected comma after name \"%s\""), name);
3183 ignore_rest_of_line ();
3187 input_line_pointer++;
3190 if (name[0] == '.' && name[1] == '\0')
3192 /* XXX - this should not happen to .thumb_set. */
3196 if ((symbolP = symbol_find (name)) == NULL
3197 && (symbolP = md_undefined_symbol (name)) == NULL)
3200 /* When doing symbol listings, play games with dummy fragments living
3201 outside the normal fragment chain to record the file and line info
3203 if (listing & LISTING_SYMBOLS)
3205 extern struct list_info_struct * listing_tail;
3206 fragS * dummy_frag = (fragS * ) xmalloc (sizeof (fragS));
3208 memset (dummy_frag, 0, sizeof (fragS));
3209 dummy_frag->fr_type = rs_fill;
3210 dummy_frag->line = listing_tail;
3211 symbolP = symbol_new (name, undefined_section, 0, dummy_frag);
3212 dummy_frag->fr_symbol = symbolP;
3216 symbolP = symbol_new (name, undefined_section, 0, &zero_address_frag);
3219 /* "set" symbols are local unless otherwise specified. */
3220 SF_SET_LOCAL (symbolP);
3221 #endif /* OBJ_COFF */
3222 } /* Make a new symbol. */
3224 symbol_table_insert (symbolP);
3229 && S_IS_DEFINED (symbolP)
3230 && S_GET_SEGMENT (symbolP) != reg_section)
3231 as_bad (_("symbol `%s' already defined"), S_GET_NAME (symbolP));
3233 pseudo_set (symbolP);
3235 demand_empty_rest_of_line ();
3237 /* XXX Now we come to the Thumb specific bit of code. */
3239 THUMB_SET_FUNC (symbolP, 1);
3240 ARM_SET_THUMB (symbolP, 1);
3241 #if defined OBJ_ELF || defined OBJ_COFF
3242 ARM_SET_INTERWORK (symbolP, support_interwork);
3246 /* Directives: Mode selection. */
3248 /* .syntax [unified|divided] - choose the new unified syntax
3249 (same for Arm and Thumb encoding, modulo slight differences in what
3250 can be represented) or the old divergent syntax for each mode. */
3252 s_syntax (int unused ATTRIBUTE_UNUSED)
3256 delim = get_symbol_name (& name);
3258 if (!strcasecmp (name, "unified"))
3259 unified_syntax = TRUE;
3260 else if (!strcasecmp (name, "divided"))
3261 unified_syntax = FALSE;
3264 as_bad (_("unrecognized syntax mode \"%s\""), name);
3267 (void) restore_line_pointer (delim);
3268 demand_empty_rest_of_line ();
3271 /* Directives: sectioning and alignment. */
3274 s_bss (int ignore ATTRIBUTE_UNUSED)
3276 /* We don't support putting frags in the BSS segment, we fake it by
3277 marking in_bss, then looking at s_skip for clues. */
3278 subseg_set (bss_section, 0);
3279 demand_empty_rest_of_line ();
3281 #ifdef md_elf_section_change_hook
3282 md_elf_section_change_hook ();
3287 s_even (int ignore ATTRIBUTE_UNUSED)
3289 /* Never make frag if expect extra pass. */
3291 frag_align (1, 0, 0);
3293 record_alignment (now_seg, 1);
3295 demand_empty_rest_of_line ();
3298 /* Directives: CodeComposer Studio. */
3300 /* .ref (for CodeComposer Studio syntax only). */
3302 s_ccs_ref (int unused ATTRIBUTE_UNUSED)
3304 if (codecomposer_syntax)
3305 ignore_rest_of_line ();
3307 as_bad (_(".ref pseudo-op only available with -mccs flag."));
3310 /* If name is not NULL, then it is used for marking the beginning of a
3311 function, whereas if it is NULL then it means the function end. */
3313 asmfunc_debug (const char * name)
3315 static const char * last_name = NULL;
3319 gas_assert (last_name == NULL);
3322 if (debug_type == DEBUG_STABS)
3323 stabs_generate_asm_func (name, name);
3327 gas_assert (last_name != NULL);
3329 if (debug_type == DEBUG_STABS)
3330 stabs_generate_asm_endfunc (last_name, last_name);
3337 s_ccs_asmfunc (int unused ATTRIBUTE_UNUSED)
3339 if (codecomposer_syntax)
3341 switch (asmfunc_state)
3343 case OUTSIDE_ASMFUNC:
3344 asmfunc_state = WAITING_ASMFUNC_NAME;
3347 case WAITING_ASMFUNC_NAME:
3348 as_bad (_(".asmfunc repeated."));
3351 case WAITING_ENDASMFUNC:
3352 as_bad (_(".asmfunc without function."));
3355 demand_empty_rest_of_line ();
3358 as_bad (_(".asmfunc pseudo-op only available with -mccs flag."));
3362 s_ccs_endasmfunc (int unused ATTRIBUTE_UNUSED)
3364 if (codecomposer_syntax)
3366 switch (asmfunc_state)
3368 case OUTSIDE_ASMFUNC:
3369 as_bad (_(".endasmfunc without a .asmfunc."));
3372 case WAITING_ASMFUNC_NAME:
3373 as_bad (_(".endasmfunc without function."));
3376 case WAITING_ENDASMFUNC:
3377 asmfunc_state = OUTSIDE_ASMFUNC;
3378 asmfunc_debug (NULL);
3381 demand_empty_rest_of_line ();
3384 as_bad (_(".endasmfunc pseudo-op only available with -mccs flag."));
3388 s_ccs_def (int name)
3390 if (codecomposer_syntax)
3393 as_bad (_(".def pseudo-op only available with -mccs flag."));
3396 /* Directives: Literal pools. */
3398 static literal_pool *
3399 find_literal_pool (void)
3401 literal_pool * pool;
3403 for (pool = list_of_pools; pool != NULL; pool = pool->next)
3405 if (pool->section == now_seg
3406 && pool->sub_section == now_subseg)
3413 static literal_pool *
3414 find_or_make_literal_pool (void)
3416 /* Next literal pool ID number. */
3417 static unsigned int latest_pool_num = 1;
3418 literal_pool * pool;
3420 pool = find_literal_pool ();
3424 /* Create a new pool. */
3425 pool = XNEW (literal_pool);
3429 pool->next_free_entry = 0;
3430 pool->section = now_seg;
3431 pool->sub_section = now_subseg;
3432 pool->next = list_of_pools;
3433 pool->symbol = NULL;
3434 pool->alignment = 2;
3436 /* Add it to the list. */
3437 list_of_pools = pool;
3440 /* New pools, and emptied pools, will have a NULL symbol. */
3441 if (pool->symbol == NULL)
3443 pool->symbol = symbol_create (FAKE_LABEL_NAME, undefined_section,
3444 (valueT) 0, &zero_address_frag);
3445 pool->id = latest_pool_num ++;
3452 /* Add the literal in the global 'inst'
3453 structure to the relevant literal pool. */
3456 add_to_lit_pool (unsigned int nbytes)
3458 #define PADDING_SLOT 0x1
3459 #define LIT_ENTRY_SIZE_MASK 0xFF
3460 literal_pool * pool;
3461 unsigned int entry, pool_size = 0;
3462 bfd_boolean padding_slot_p = FALSE;
3468 imm1 = inst.operands[1].imm;
3469 imm2 = (inst.operands[1].regisimm ? inst.operands[1].reg
3470 : inst.relocs[0].exp.X_unsigned ? 0
3471 : ((bfd_int64_t) inst.operands[1].imm) >> 32);
3472 if (target_big_endian)
3475 imm2 = inst.operands[1].imm;
3479 pool = find_or_make_literal_pool ();
3481 /* Check if this literal value is already in the pool. */
3482 for (entry = 0; entry < pool->next_free_entry; entry ++)
3486 if ((pool->literals[entry].X_op == inst.relocs[0].exp.X_op)
3487 && (inst.relocs[0].exp.X_op == O_constant)
3488 && (pool->literals[entry].X_add_number
3489 == inst.relocs[0].exp.X_add_number)
3490 && (pool->literals[entry].X_md == nbytes)
3491 && (pool->literals[entry].X_unsigned
3492 == inst.relocs[0].exp.X_unsigned))
3495 if ((pool->literals[entry].X_op == inst.relocs[0].exp.X_op)
3496 && (inst.relocs[0].exp.X_op == O_symbol)
3497 && (pool->literals[entry].X_add_number
3498 == inst.relocs[0].exp.X_add_number)
3499 && (pool->literals[entry].X_add_symbol
3500 == inst.relocs[0].exp.X_add_symbol)
3501 && (pool->literals[entry].X_op_symbol
3502 == inst.relocs[0].exp.X_op_symbol)
3503 && (pool->literals[entry].X_md == nbytes))
3506 else if ((nbytes == 8)
3507 && !(pool_size & 0x7)
3508 && ((entry + 1) != pool->next_free_entry)
3509 && (pool->literals[entry].X_op == O_constant)
3510 && (pool->literals[entry].X_add_number == (offsetT) imm1)
3511 && (pool->literals[entry].X_unsigned
3512 == inst.relocs[0].exp.X_unsigned)
3513 && (pool->literals[entry + 1].X_op == O_constant)
3514 && (pool->literals[entry + 1].X_add_number == (offsetT) imm2)
3515 && (pool->literals[entry + 1].X_unsigned
3516 == inst.relocs[0].exp.X_unsigned))
3519 padding_slot_p = ((pool->literals[entry].X_md >> 8) == PADDING_SLOT);
3520 if (padding_slot_p && (nbytes == 4))
3526 /* Do we need to create a new entry? */
3527 if (entry == pool->next_free_entry)
3529 if (entry >= MAX_LITERAL_POOL_SIZE)
3531 inst.error = _("literal pool overflow");
3537 /* For 8-byte entries, we align to an 8-byte boundary,
3538 and split it into two 4-byte entries, because on 32-bit
3539 host, 8-byte constants are treated as big num, thus
3540 saved in "generic_bignum" which will be overwritten
3541 by later assignments.
3543 We also need to make sure there is enough space for
3546 We also check to make sure the literal operand is a
3548 if (!(inst.relocs[0].exp.X_op == O_constant
3549 || inst.relocs[0].exp.X_op == O_big))
3551 inst.error = _("invalid type for literal pool");
3554 else if (pool_size & 0x7)
3556 if ((entry + 2) >= MAX_LITERAL_POOL_SIZE)
3558 inst.error = _("literal pool overflow");
3562 pool->literals[entry] = inst.relocs[0].exp;
3563 pool->literals[entry].X_op = O_constant;
3564 pool->literals[entry].X_add_number = 0;
3565 pool->literals[entry++].X_md = (PADDING_SLOT << 8) | 4;
3566 pool->next_free_entry += 1;
3569 else if ((entry + 1) >= MAX_LITERAL_POOL_SIZE)
3571 inst.error = _("literal pool overflow");
3575 pool->literals[entry] = inst.relocs[0].exp;
3576 pool->literals[entry].X_op = O_constant;
3577 pool->literals[entry].X_add_number = imm1;
3578 pool->literals[entry].X_unsigned = inst.relocs[0].exp.X_unsigned;
3579 pool->literals[entry++].X_md = 4;
3580 pool->literals[entry] = inst.relocs[0].exp;
3581 pool->literals[entry].X_op = O_constant;
3582 pool->literals[entry].X_add_number = imm2;
3583 pool->literals[entry].X_unsigned = inst.relocs[0].exp.X_unsigned;
3584 pool->literals[entry].X_md = 4;
3585 pool->alignment = 3;
3586 pool->next_free_entry += 1;
3590 pool->literals[entry] = inst.relocs[0].exp;
3591 pool->literals[entry].X_md = 4;
3595 /* PR ld/12974: Record the location of the first source line to reference
3596 this entry in the literal pool. If it turns out during linking that the
3597 symbol does not exist we will be able to give an accurate line number for
3598 the (first use of the) missing reference. */
3599 if (debug_type == DEBUG_DWARF2)
3600 dwarf2_where (pool->locs + entry);
3602 pool->next_free_entry += 1;
3604 else if (padding_slot_p)
3606 pool->literals[entry] = inst.relocs[0].exp;
3607 pool->literals[entry].X_md = nbytes;
3610 inst.relocs[0].exp.X_op = O_symbol;
3611 inst.relocs[0].exp.X_add_number = pool_size;
3612 inst.relocs[0].exp.X_add_symbol = pool->symbol;
3618 tc_start_label_without_colon (void)
3620 bfd_boolean ret = TRUE;
3622 if (codecomposer_syntax && asmfunc_state == WAITING_ASMFUNC_NAME)
3624 const char *label = input_line_pointer;
3626 while (!is_end_of_line[(int) label[-1]])
3631 as_bad (_("Invalid label '%s'"), label);
3635 asmfunc_debug (label);
3637 asmfunc_state = WAITING_ENDASMFUNC;
3643 /* Can't use symbol_new here, so have to create a symbol and then at
3644 a later date assign it a value. That's what these functions do. */
3647 symbol_locate (symbolS * symbolP,
3648 const char * name, /* It is copied, the caller can modify. */
3649 segT segment, /* Segment identifier (SEG_<something>). */
3650 valueT valu, /* Symbol value. */
3651 fragS * frag) /* Associated fragment. */
3654 char * preserved_copy_of_name;
3656 name_length = strlen (name) + 1; /* +1 for \0. */
3657 obstack_grow (¬es, name, name_length);
3658 preserved_copy_of_name = (char *) obstack_finish (¬es);
3660 #ifdef tc_canonicalize_symbol_name
3661 preserved_copy_of_name =
3662 tc_canonicalize_symbol_name (preserved_copy_of_name);
3665 S_SET_NAME (symbolP, preserved_copy_of_name);
3667 S_SET_SEGMENT (symbolP, segment);
3668 S_SET_VALUE (symbolP, valu);
3669 symbol_clear_list_pointers (symbolP);
3671 symbol_set_frag (symbolP, frag);
3673 /* Link to end of symbol chain. */
3675 extern int symbol_table_frozen;
3677 if (symbol_table_frozen)
3681 symbol_append (symbolP, symbol_lastP, & symbol_rootP, & symbol_lastP);
3683 obj_symbol_new_hook (symbolP);
3685 #ifdef tc_symbol_new_hook
3686 tc_symbol_new_hook (symbolP);
3690 verify_symbol_chain (symbol_rootP, symbol_lastP);
3691 #endif /* DEBUG_SYMS */
3695 s_ltorg (int ignored ATTRIBUTE_UNUSED)
3698 literal_pool * pool;
3701 pool = find_literal_pool ();
3703 || pool->symbol == NULL
3704 || pool->next_free_entry == 0)
3707 /* Align pool as you have word accesses.
3708 Only make a frag if we have to. */
3710 frag_align (pool->alignment, 0, 0);
3712 record_alignment (now_seg, 2);
3715 seg_info (now_seg)->tc_segment_info_data.mapstate = MAP_DATA;
3716 make_mapping_symbol (MAP_DATA, (valueT) frag_now_fix (), frag_now);
3718 sprintf (sym_name, "$$lit_\002%x", pool->id);
3720 symbol_locate (pool->symbol, sym_name, now_seg,
3721 (valueT) frag_now_fix (), frag_now);
3722 symbol_table_insert (pool->symbol);
3724 ARM_SET_THUMB (pool->symbol, thumb_mode);
3726 #if defined OBJ_COFF || defined OBJ_ELF
3727 ARM_SET_INTERWORK (pool->symbol, support_interwork);
3730 for (entry = 0; entry < pool->next_free_entry; entry ++)
3733 if (debug_type == DEBUG_DWARF2)
3734 dwarf2_gen_line_info (frag_now_fix (), pool->locs + entry);
3736 /* First output the expression in the instruction to the pool. */
3737 emit_expr (&(pool->literals[entry]),
3738 pool->literals[entry].X_md & LIT_ENTRY_SIZE_MASK);
3741 /* Mark the pool as empty. */
3742 pool->next_free_entry = 0;
3743 pool->symbol = NULL;
3747 /* Forward declarations for functions below, in the MD interface
3749 static void fix_new_arm (fragS *, int, short, expressionS *, int, int);
3750 static valueT create_unwind_entry (int);
3751 static void start_unwind_section (const segT, int);
3752 static void add_unwind_opcode (valueT, int);
3753 static void flush_pending_unwind (void);
3755 /* Directives: Data. */
3758 s_arm_elf_cons (int nbytes)
3762 #ifdef md_flush_pending_output
3763 md_flush_pending_output ();
3766 if (is_it_end_of_statement ())
3768 demand_empty_rest_of_line ();
3772 #ifdef md_cons_align
3773 md_cons_align (nbytes);
3776 mapping_state (MAP_DATA);
3780 char *base = input_line_pointer;
3784 if (exp.X_op != O_symbol)
3785 emit_expr (&exp, (unsigned int) nbytes);
3788 char *before_reloc = input_line_pointer;
3789 reloc = parse_reloc (&input_line_pointer);
3792 as_bad (_("unrecognized relocation suffix"));
3793 ignore_rest_of_line ();
3796 else if (reloc == BFD_RELOC_UNUSED)
3797 emit_expr (&exp, (unsigned int) nbytes);
3800 reloc_howto_type *howto = (reloc_howto_type *)
3801 bfd_reloc_type_lookup (stdoutput,
3802 (bfd_reloc_code_real_type) reloc);
3803 int size = bfd_get_reloc_size (howto);
3805 if (reloc == BFD_RELOC_ARM_PLT32)
3807 as_bad (_("(plt) is only valid on branch targets"));
3808 reloc = BFD_RELOC_UNUSED;
3813 as_bad (ngettext ("%s relocations do not fit in %d byte",
3814 "%s relocations do not fit in %d bytes",
3816 howto->name, nbytes);
3819 /* We've parsed an expression stopping at O_symbol.
3820 But there may be more expression left now that we
3821 have parsed the relocation marker. Parse it again.
3822 XXX Surely there is a cleaner way to do this. */
3823 char *p = input_line_pointer;
3825 char *save_buf = XNEWVEC (char, input_line_pointer - base);
3827 memcpy (save_buf, base, input_line_pointer - base);
3828 memmove (base + (input_line_pointer - before_reloc),
3829 base, before_reloc - base);
3831 input_line_pointer = base + (input_line_pointer-before_reloc);
3833 memcpy (base, save_buf, p - base);
3835 offset = nbytes - size;
3836 p = frag_more (nbytes);
3837 memset (p, 0, nbytes);
3838 fix_new_exp (frag_now, p - frag_now->fr_literal + offset,
3839 size, &exp, 0, (enum bfd_reloc_code_real) reloc);
3845 while (*input_line_pointer++ == ',');
3847 /* Put terminator back into stream. */
3848 input_line_pointer --;
3849 demand_empty_rest_of_line ();
3852 /* Emit an expression containing a 32-bit thumb instruction.
3853 Implementation based on put_thumb32_insn. */
3856 emit_thumb32_expr (expressionS * exp)
3858 expressionS exp_high = *exp;
3860 exp_high.X_add_number = (unsigned long)exp_high.X_add_number >> 16;
3861 emit_expr (& exp_high, (unsigned int) THUMB_SIZE);
3862 exp->X_add_number &= 0xffff;
3863 emit_expr (exp, (unsigned int) THUMB_SIZE);
3866 /* Guess the instruction size based on the opcode. */
3869 thumb_insn_size (int opcode)
3871 if ((unsigned int) opcode < 0xe800u)
3873 else if ((unsigned int) opcode >= 0xe8000000u)
3880 emit_insn (expressionS *exp, int nbytes)
3884 if (exp->X_op == O_constant)
3889 size = thumb_insn_size (exp->X_add_number);
3893 if (size == 2 && (unsigned int)exp->X_add_number > 0xffffu)
3895 as_bad (_(".inst.n operand too big. "\
3896 "Use .inst.w instead"));
3901 if (now_pred.state == AUTOMATIC_PRED_BLOCK)
3902 set_pred_insn_type_nonvoid (OUTSIDE_PRED_INSN, 0);
3904 set_pred_insn_type_nonvoid (NEUTRAL_IT_INSN, 0);
3906 if (thumb_mode && (size > THUMB_SIZE) && !target_big_endian)
3907 emit_thumb32_expr (exp);
3909 emit_expr (exp, (unsigned int) size);
3911 it_fsm_post_encode ();
3915 as_bad (_("cannot determine Thumb instruction size. " \
3916 "Use .inst.n/.inst.w instead"));
3919 as_bad (_("constant expression required"));
3924 /* Like s_arm_elf_cons but do not use md_cons_align and
3925 set the mapping state to MAP_ARM/MAP_THUMB. */
3928 s_arm_elf_inst (int nbytes)
3930 if (is_it_end_of_statement ())
3932 demand_empty_rest_of_line ();
3936 /* Calling mapping_state () here will not change ARM/THUMB,
3937 but will ensure not to be in DATA state. */
3940 mapping_state (MAP_THUMB);
3945 as_bad (_("width suffixes are invalid in ARM mode"));
3946 ignore_rest_of_line ();
3952 mapping_state (MAP_ARM);
3961 if (! emit_insn (& exp, nbytes))
3963 ignore_rest_of_line ();
3967 while (*input_line_pointer++ == ',');
3969 /* Put terminator back into stream. */
3970 input_line_pointer --;
3971 demand_empty_rest_of_line ();
3974 /* Parse a .rel31 directive. */
3977 s_arm_rel31 (int ignored ATTRIBUTE_UNUSED)
3984 if (*input_line_pointer == '1')
3985 highbit = 0x80000000;
3986 else if (*input_line_pointer != '0')
3987 as_bad (_("expected 0 or 1"));
3989 input_line_pointer++;
3990 if (*input_line_pointer != ',')
3991 as_bad (_("missing comma"));
3992 input_line_pointer++;
3994 #ifdef md_flush_pending_output
3995 md_flush_pending_output ();
3998 #ifdef md_cons_align
4002 mapping_state (MAP_DATA);
4007 md_number_to_chars (p, highbit, 4);
4008 fix_new_arm (frag_now, p - frag_now->fr_literal, 4, &exp, 1,
4009 BFD_RELOC_ARM_PREL31);
4011 demand_empty_rest_of_line ();
4014 /* Directives: AEABI stack-unwind tables. */
4016 /* Parse an unwind_fnstart directive. Simply records the current location. */
4019 s_arm_unwind_fnstart (int ignored ATTRIBUTE_UNUSED)
4021 demand_empty_rest_of_line ();
4022 if (unwind.proc_start)
4024 as_bad (_("duplicate .fnstart directive"));
4028 /* Mark the start of the function. */
4029 unwind.proc_start = expr_build_dot ();
4031 /* Reset the rest of the unwind info. */
4032 unwind.opcode_count = 0;
4033 unwind.table_entry = NULL;
4034 unwind.personality_routine = NULL;
4035 unwind.personality_index = -1;
4036 unwind.frame_size = 0;
4037 unwind.fp_offset = 0;
4038 unwind.fp_reg = REG_SP;
4040 unwind.sp_restored = 0;
4044 /* Parse a handlerdata directive. Creates the exception handling table entry
4045 for the function. */
4048 s_arm_unwind_handlerdata (int ignored ATTRIBUTE_UNUSED)
4050 demand_empty_rest_of_line ();
4051 if (!unwind.proc_start)
4052 as_bad (MISSING_FNSTART);
4054 if (unwind.table_entry)
4055 as_bad (_("duplicate .handlerdata directive"));
4057 create_unwind_entry (1);
4060 /* Parse an unwind_fnend directive. Generates the index table entry. */
4063 s_arm_unwind_fnend (int ignored ATTRIBUTE_UNUSED)
4068 unsigned int marked_pr_dependency;
4070 demand_empty_rest_of_line ();
4072 if (!unwind.proc_start)
4074 as_bad (_(".fnend directive without .fnstart"));
4078 /* Add eh table entry. */
4079 if (unwind.table_entry == NULL)
4080 val = create_unwind_entry (0);
4084 /* Add index table entry. This is two words. */
4085 start_unwind_section (unwind.saved_seg, 1);
4086 frag_align (2, 0, 0);
4087 record_alignment (now_seg, 2);
4089 ptr = frag_more (8);
4091 where = frag_now_fix () - 8;
4093 /* Self relative offset of the function start. */
4094 fix_new (frag_now, where, 4, unwind.proc_start, 0, 1,
4095 BFD_RELOC_ARM_PREL31);
4097 /* Indicate dependency on EHABI-defined personality routines to the
4098 linker, if it hasn't been done already. */
4099 marked_pr_dependency
4100 = seg_info (now_seg)->tc_segment_info_data.marked_pr_dependency;
4101 if (unwind.personality_index >= 0 && unwind.personality_index < 3
4102 && !(marked_pr_dependency & (1 << unwind.personality_index)))
4104 static const char *const name[] =
4106 "__aeabi_unwind_cpp_pr0",
4107 "__aeabi_unwind_cpp_pr1",
4108 "__aeabi_unwind_cpp_pr2"
4110 symbolS *pr = symbol_find_or_make (name[unwind.personality_index]);
4111 fix_new (frag_now, where, 0, pr, 0, 1, BFD_RELOC_NONE);
4112 seg_info (now_seg)->tc_segment_info_data.marked_pr_dependency
4113 |= 1 << unwind.personality_index;
4117 /* Inline exception table entry. */
4118 md_number_to_chars (ptr + 4, val, 4);
4120 /* Self relative offset of the table entry. */
4121 fix_new (frag_now, where + 4, 4, unwind.table_entry, 0, 1,
4122 BFD_RELOC_ARM_PREL31);
4124 /* Restore the original section. */
4125 subseg_set (unwind.saved_seg, unwind.saved_subseg);
4127 unwind.proc_start = NULL;
4131 /* Parse an unwind_cantunwind directive. */
4134 s_arm_unwind_cantunwind (int ignored ATTRIBUTE_UNUSED)
4136 demand_empty_rest_of_line ();
4137 if (!unwind.proc_start)
4138 as_bad (MISSING_FNSTART);
4140 if (unwind.personality_routine || unwind.personality_index != -1)
4141 as_bad (_("personality routine specified for cantunwind frame"));
4143 unwind.personality_index = -2;
4147 /* Parse a personalityindex directive. */
4150 s_arm_unwind_personalityindex (int ignored ATTRIBUTE_UNUSED)
4154 if (!unwind.proc_start)
4155 as_bad (MISSING_FNSTART);
4157 if (unwind.personality_routine || unwind.personality_index != -1)
4158 as_bad (_("duplicate .personalityindex directive"));
4162 if (exp.X_op != O_constant
4163 || exp.X_add_number < 0 || exp.X_add_number > 15)
4165 as_bad (_("bad personality routine number"));
4166 ignore_rest_of_line ();
4170 unwind.personality_index = exp.X_add_number;
4172 demand_empty_rest_of_line ();
4176 /* Parse a personality directive. */
4179 s_arm_unwind_personality (int ignored ATTRIBUTE_UNUSED)
4183 if (!unwind.proc_start)
4184 as_bad (MISSING_FNSTART);
4186 if (unwind.personality_routine || unwind.personality_index != -1)
4187 as_bad (_("duplicate .personality directive"));
4189 c = get_symbol_name (& name);
4190 p = input_line_pointer;
4192 ++ input_line_pointer;
4193 unwind.personality_routine = symbol_find_or_make (name);
4195 demand_empty_rest_of_line ();
4199 /* Parse a directive saving core registers. */
4202 s_arm_unwind_save_core (void)
4208 range = parse_reg_list (&input_line_pointer, REGLIST_RN);
4211 as_bad (_("expected register list"));
4212 ignore_rest_of_line ();
4216 demand_empty_rest_of_line ();
4218 /* Turn .unwind_movsp ip followed by .unwind_save {..., ip, ...}
4219 into .unwind_save {..., sp...}. We aren't bothered about the value of
4220 ip because it is clobbered by calls. */
4221 if (unwind.sp_restored && unwind.fp_reg == 12
4222 && (range & 0x3000) == 0x1000)
4224 unwind.opcode_count--;
4225 unwind.sp_restored = 0;
4226 range = (range | 0x2000) & ~0x1000;
4227 unwind.pending_offset = 0;
4233 /* See if we can use the short opcodes. These pop a block of up to 8
4234 registers starting with r4, plus maybe r14. */
4235 for (n = 0; n < 8; n++)
4237 /* Break at the first non-saved register. */
4238 if ((range & (1 << (n + 4))) == 0)
4241 /* See if there are any other bits set. */
4242 if (n == 0 || (range & (0xfff0 << n) & 0xbff0) != 0)
4244 /* Use the long form. */
4245 op = 0x8000 | ((range >> 4) & 0xfff);
4246 add_unwind_opcode (op, 2);
4250 /* Use the short form. */
4252 op = 0xa8; /* Pop r14. */
4254 op = 0xa0; /* Do not pop r14. */
4256 add_unwind_opcode (op, 1);
4263 op = 0xb100 | (range & 0xf);
4264 add_unwind_opcode (op, 2);
4267 /* Record the number of bytes pushed. */
4268 for (n = 0; n < 16; n++)
4270 if (range & (1 << n))
4271 unwind.frame_size += 4;
4276 /* Parse a directive saving FPA registers. */
4279 s_arm_unwind_save_fpa (int reg)
4285 /* Get Number of registers to transfer. */
4286 if (skip_past_comma (&input_line_pointer) != FAIL)
4289 exp.X_op = O_illegal;
4291 if (exp.X_op != O_constant)
4293 as_bad (_("expected , <constant>"));
4294 ignore_rest_of_line ();
4298 num_regs = exp.X_add_number;
4300 if (num_regs < 1 || num_regs > 4)
4302 as_bad (_("number of registers must be in the range [1:4]"));
4303 ignore_rest_of_line ();
4307 demand_empty_rest_of_line ();
4312 op = 0xb4 | (num_regs - 1);
4313 add_unwind_opcode (op, 1);
4318 op = 0xc800 | (reg << 4) | (num_regs - 1);
4319 add_unwind_opcode (op, 2);
4321 unwind.frame_size += num_regs * 12;
4325 /* Parse a directive saving VFP registers for ARMv6 and above. */
4328 s_arm_unwind_save_vfp_armv6 (void)
4333 int num_vfpv3_regs = 0;
4334 int num_regs_below_16;
4335 bfd_boolean partial_match;
4337 count = parse_vfp_reg_list (&input_line_pointer, &start, REGLIST_VFP_D,
4341 as_bad (_("expected register list"));
4342 ignore_rest_of_line ();
4346 demand_empty_rest_of_line ();
4348 /* We always generate FSTMD/FLDMD-style unwinding opcodes (rather
4349 than FSTMX/FLDMX-style ones). */
4351 /* Generate opcode for (VFPv3) registers numbered in the range 16 .. 31. */
4353 num_vfpv3_regs = count;
4354 else if (start + count > 16)
4355 num_vfpv3_regs = start + count - 16;
4357 if (num_vfpv3_regs > 0)
4359 int start_offset = start > 16 ? start - 16 : 0;
4360 op = 0xc800 | (start_offset << 4) | (num_vfpv3_regs - 1);
4361 add_unwind_opcode (op, 2);
4364 /* Generate opcode for registers numbered in the range 0 .. 15. */
4365 num_regs_below_16 = num_vfpv3_regs > 0 ? 16 - (int) start : count;
4366 gas_assert (num_regs_below_16 + num_vfpv3_regs == count);
4367 if (num_regs_below_16 > 0)
4369 op = 0xc900 | (start << 4) | (num_regs_below_16 - 1);
4370 add_unwind_opcode (op, 2);
4373 unwind.frame_size += count * 8;
4377 /* Parse a directive saving VFP registers for pre-ARMv6. */
4380 s_arm_unwind_save_vfp (void)
4385 bfd_boolean partial_match;
4387 count = parse_vfp_reg_list (&input_line_pointer, ®, REGLIST_VFP_D,
4391 as_bad (_("expected register list"));
4392 ignore_rest_of_line ();
4396 demand_empty_rest_of_line ();
4401 op = 0xb8 | (count - 1);
4402 add_unwind_opcode (op, 1);
4407 op = 0xb300 | (reg << 4) | (count - 1);
4408 add_unwind_opcode (op, 2);
4410 unwind.frame_size += count * 8 + 4;
4414 /* Parse a directive saving iWMMXt data registers. */
4417 s_arm_unwind_save_mmxwr (void)
4425 if (*input_line_pointer == '{')
4426 input_line_pointer++;
4430 reg = arm_reg_parse (&input_line_pointer, REG_TYPE_MMXWR);
4434 as_bad ("%s", _(reg_expected_msgs[REG_TYPE_MMXWR]));
4439 as_tsktsk (_("register list not in ascending order"));
4442 if (*input_line_pointer == '-')
4444 input_line_pointer++;
4445 hi_reg = arm_reg_parse (&input_line_pointer, REG_TYPE_MMXWR);
4448 as_bad ("%s", _(reg_expected_msgs[REG_TYPE_MMXWR]));
4451 else if (reg >= hi_reg)
4453 as_bad (_("bad register range"));
4456 for (; reg < hi_reg; reg++)
4460 while (skip_past_comma (&input_line_pointer) != FAIL);
4462 skip_past_char (&input_line_pointer, '}');
4464 demand_empty_rest_of_line ();
4466 /* Generate any deferred opcodes because we're going to be looking at
4468 flush_pending_unwind ();
4470 for (i = 0; i < 16; i++)
4472 if (mask & (1 << i))
4473 unwind.frame_size += 8;
4476 /* Attempt to combine with a previous opcode. We do this because gcc
4477 likes to output separate unwind directives for a single block of
4479 if (unwind.opcode_count > 0)
4481 i = unwind.opcodes[unwind.opcode_count - 1];
4482 if ((i & 0xf8) == 0xc0)
4485 /* Only merge if the blocks are contiguous. */
4488 if ((mask & 0xfe00) == (1 << 9))
4490 mask |= ((1 << (i + 11)) - 1) & 0xfc00;
4491 unwind.opcode_count--;
4494 else if (i == 6 && unwind.opcode_count >= 2)
4496 i = unwind.opcodes[unwind.opcode_count - 2];
4500 op = 0xffff << (reg - 1);
4502 && ((mask & op) == (1u << (reg - 1))))
4504 op = (1 << (reg + i + 1)) - 1;
4505 op &= ~((1 << reg) - 1);
4507 unwind.opcode_count -= 2;
4514 /* We want to generate opcodes in the order the registers have been
4515 saved, ie. descending order. */
4516 for (reg = 15; reg >= -1; reg--)
4518 /* Save registers in blocks. */
4520 || !(mask & (1 << reg)))
4522 /* We found an unsaved reg. Generate opcodes to save the
4529 op = 0xc0 | (hi_reg - 10);
4530 add_unwind_opcode (op, 1);
4535 op = 0xc600 | ((reg + 1) << 4) | ((hi_reg - reg) - 1);
4536 add_unwind_opcode (op, 2);
4545 ignore_rest_of_line ();
4549 s_arm_unwind_save_mmxwcg (void)
4556 if (*input_line_pointer == '{')
4557 input_line_pointer++;
4559 skip_whitespace (input_line_pointer);
4563 reg = arm_reg_parse (&input_line_pointer, REG_TYPE_MMXWCG);
4567 as_bad ("%s", _(reg_expected_msgs[REG_TYPE_MMXWCG]));
4573 as_tsktsk (_("register list not in ascending order"));
4576 if (*input_line_pointer == '-')
4578 input_line_pointer++;
4579 hi_reg = arm_reg_parse (&input_line_pointer, REG_TYPE_MMXWCG);
4582 as_bad ("%s", _(reg_expected_msgs[REG_TYPE_MMXWCG]));
4585 else if (reg >= hi_reg)
4587 as_bad (_("bad register range"));
4590 for (; reg < hi_reg; reg++)
4594 while (skip_past_comma (&input_line_pointer) != FAIL);
4596 skip_past_char (&input_line_pointer, '}');
4598 demand_empty_rest_of_line ();
4600 /* Generate any deferred opcodes because we're going to be looking at
4602 flush_pending_unwind ();
4604 for (reg = 0; reg < 16; reg++)
4606 if (mask & (1 << reg))
4607 unwind.frame_size += 4;
4610 add_unwind_opcode (op, 2);
4613 ignore_rest_of_line ();
4617 /* Parse an unwind_save directive.
4618 If the argument is non-zero, this is a .vsave directive. */
4621 s_arm_unwind_save (int arch_v6)
4624 struct reg_entry *reg;
4625 bfd_boolean had_brace = FALSE;
4627 if (!unwind.proc_start)
4628 as_bad (MISSING_FNSTART);
4630 /* Figure out what sort of save we have. */
4631 peek = input_line_pointer;
4639 reg = arm_reg_parse_multi (&peek);
4643 as_bad (_("register expected"));
4644 ignore_rest_of_line ();
4653 as_bad (_("FPA .unwind_save does not take a register list"));
4654 ignore_rest_of_line ();
4657 input_line_pointer = peek;
4658 s_arm_unwind_save_fpa (reg->number);
4662 s_arm_unwind_save_core ();
4667 s_arm_unwind_save_vfp_armv6 ();
4669 s_arm_unwind_save_vfp ();
4672 case REG_TYPE_MMXWR:
4673 s_arm_unwind_save_mmxwr ();
4676 case REG_TYPE_MMXWCG:
4677 s_arm_unwind_save_mmxwcg ();
4681 as_bad (_(".unwind_save does not support this kind of register"));
4682 ignore_rest_of_line ();
4687 /* Parse an unwind_movsp directive. */
4690 s_arm_unwind_movsp (int ignored ATTRIBUTE_UNUSED)
4696 if (!unwind.proc_start)
4697 as_bad (MISSING_FNSTART);
4699 reg = arm_reg_parse (&input_line_pointer, REG_TYPE_RN);
4702 as_bad ("%s", _(reg_expected_msgs[REG_TYPE_RN]));
4703 ignore_rest_of_line ();
4707 /* Optional constant. */
4708 if (skip_past_comma (&input_line_pointer) != FAIL)
4710 if (immediate_for_directive (&offset) == FAIL)
4716 demand_empty_rest_of_line ();
4718 if (reg == REG_SP || reg == REG_PC)
4720 as_bad (_("SP and PC not permitted in .unwind_movsp directive"));
4724 if (unwind.fp_reg != REG_SP)
4725 as_bad (_("unexpected .unwind_movsp directive"));
4727 /* Generate opcode to restore the value. */
4729 add_unwind_opcode (op, 1);
4731 /* Record the information for later. */
4732 unwind.fp_reg = reg;
4733 unwind.fp_offset = unwind.frame_size - offset;
4734 unwind.sp_restored = 1;
4737 /* Parse an unwind_pad directive. */
4740 s_arm_unwind_pad (int ignored ATTRIBUTE_UNUSED)
4744 if (!unwind.proc_start)
4745 as_bad (MISSING_FNSTART);
4747 if (immediate_for_directive (&offset) == FAIL)
4752 as_bad (_("stack increment must be multiple of 4"));
4753 ignore_rest_of_line ();
4757 /* Don't generate any opcodes, just record the details for later. */
4758 unwind.frame_size += offset;
4759 unwind.pending_offset += offset;
4761 demand_empty_rest_of_line ();
4764 /* Parse an unwind_setfp directive. */
4767 s_arm_unwind_setfp (int ignored ATTRIBUTE_UNUSED)
4773 if (!unwind.proc_start)
4774 as_bad (MISSING_FNSTART);
4776 fp_reg = arm_reg_parse (&input_line_pointer, REG_TYPE_RN);
4777 if (skip_past_comma (&input_line_pointer) == FAIL)
4780 sp_reg = arm_reg_parse (&input_line_pointer, REG_TYPE_RN);
4782 if (fp_reg == FAIL || sp_reg == FAIL)
4784 as_bad (_("expected <reg>, <reg>"));
4785 ignore_rest_of_line ();
4789 /* Optional constant. */
4790 if (skip_past_comma (&input_line_pointer) != FAIL)
4792 if (immediate_for_directive (&offset) == FAIL)
4798 demand_empty_rest_of_line ();
4800 if (sp_reg != REG_SP && sp_reg != unwind.fp_reg)
4802 as_bad (_("register must be either sp or set by a previous"
4803 "unwind_movsp directive"));
4807 /* Don't generate any opcodes, just record the information for later. */
4808 unwind.fp_reg = fp_reg;
4810 if (sp_reg == REG_SP)
4811 unwind.fp_offset = unwind.frame_size - offset;
4813 unwind.fp_offset -= offset;
4816 /* Parse an unwind_raw directive. */
4819 s_arm_unwind_raw (int ignored ATTRIBUTE_UNUSED)
4822 /* This is an arbitrary limit. */
4823 unsigned char op[16];
4826 if (!unwind.proc_start)
4827 as_bad (MISSING_FNSTART);
4830 if (exp.X_op == O_constant
4831 && skip_past_comma (&input_line_pointer) != FAIL)
4833 unwind.frame_size += exp.X_add_number;
4837 exp.X_op = O_illegal;
4839 if (exp.X_op != O_constant)
4841 as_bad (_("expected <offset>, <opcode>"));
4842 ignore_rest_of_line ();
4848 /* Parse the opcode. */
4853 as_bad (_("unwind opcode too long"));
4854 ignore_rest_of_line ();
4856 if (exp.X_op != O_constant || exp.X_add_number & ~0xff)
4858 as_bad (_("invalid unwind opcode"));
4859 ignore_rest_of_line ();
4862 op[count++] = exp.X_add_number;
4864 /* Parse the next byte. */
4865 if (skip_past_comma (&input_line_pointer) == FAIL)
4871 /* Add the opcode bytes in reverse order. */
4873 add_unwind_opcode (op[count], 1);
4875 demand_empty_rest_of_line ();
4879 /* Parse a .eabi_attribute directive. */
4882 s_arm_eabi_attribute (int ignored ATTRIBUTE_UNUSED)
4884 int tag = obj_elf_vendor_attribute (OBJ_ATTR_PROC);
4886 if (tag >= 0 && tag < NUM_KNOWN_OBJ_ATTRIBUTES)
4887 attributes_set_explicitly[tag] = 1;
4890 /* Emit a tls fix for the symbol. */
4893 s_arm_tls_descseq (int ignored ATTRIBUTE_UNUSED)
4897 #ifdef md_flush_pending_output
4898 md_flush_pending_output ();
4901 #ifdef md_cons_align
4905 /* Since we're just labelling the code, there's no need to define a
4908 p = obstack_next_free (&frchain_now->frch_obstack);
4909 fix_new_arm (frag_now, p - frag_now->fr_literal, 4, &exp, 0,
4910 thumb_mode ? BFD_RELOC_ARM_THM_TLS_DESCSEQ
4911 : BFD_RELOC_ARM_TLS_DESCSEQ);
4913 #endif /* OBJ_ELF */
4915 static void s_arm_arch (int);
4916 static void s_arm_object_arch (int);
4917 static void s_arm_cpu (int);
4918 static void s_arm_fpu (int);
4919 static void s_arm_arch_extension (int);
4924 pe_directive_secrel (int dummy ATTRIBUTE_UNUSED)
4931 if (exp.X_op == O_symbol)
4932 exp.X_op = O_secrel;
4934 emit_expr (&exp, 4);
4936 while (*input_line_pointer++ == ',');
4938 input_line_pointer--;
4939 demand_empty_rest_of_line ();
4944 arm_is_largest_exponent_ok (int precision)
4946 /* precision == 1 ensures that this will only return
4947 true for 16 bit floats. */
4948 return (precision == 1) && (fp16_format == ARM_FP16_FORMAT_ALTERNATIVE);
4952 set_fp16_format (int dummy ATTRIBUTE_UNUSED)
4956 enum fp_16bit_format new_format;
4958 new_format = ARM_FP16_FORMAT_DEFAULT;
4960 name = input_line_pointer;
4961 while (*input_line_pointer && !ISSPACE (*input_line_pointer))
4962 input_line_pointer++;
4964 saved_char = *input_line_pointer;
4965 *input_line_pointer = 0;
4967 if (strcasecmp (name, "ieee") == 0)
4968 new_format = ARM_FP16_FORMAT_IEEE;
4969 else if (strcasecmp (name, "alternative") == 0)
4970 new_format = ARM_FP16_FORMAT_ALTERNATIVE;
4973 as_bad (_("unrecognised float16 format \"%s\""), name);
4977 /* Only set fp16_format if it is still the default (aka not already
4979 if (fp16_format == ARM_FP16_FORMAT_DEFAULT)
4980 fp16_format = new_format;
4983 if (new_format != fp16_format)
4984 as_warn (_("float16 format cannot be set more than once, ignoring."));
4988 *input_line_pointer = saved_char;
4989 ignore_rest_of_line ();
4992 /* This table describes all the machine specific pseudo-ops the assembler
4993 has to support. The fields are:
4994 pseudo-op name without dot
4995 function to call to execute this pseudo-op
4996 Integer arg to pass to the function. */
4998 const pseudo_typeS md_pseudo_table[] =
5000 /* Never called because '.req' does not start a line. */
5001 { "req", s_req, 0 },
5002 /* Following two are likewise never called. */
5005 { "unreq", s_unreq, 0 },
5006 { "bss", s_bss, 0 },
5007 { "align", s_align_ptwo, 2 },
5008 { "arm", s_arm, 0 },
5009 { "thumb", s_thumb, 0 },
5010 { "code", s_code, 0 },
5011 { "force_thumb", s_force_thumb, 0 },
5012 { "thumb_func", s_thumb_func, 0 },
5013 { "thumb_set", s_thumb_set, 0 },
5014 { "even", s_even, 0 },
5015 { "ltorg", s_ltorg, 0 },
5016 { "pool", s_ltorg, 0 },
5017 { "syntax", s_syntax, 0 },
5018 { "cpu", s_arm_cpu, 0 },
5019 { "arch", s_arm_arch, 0 },
5020 { "object_arch", s_arm_object_arch, 0 },
5021 { "fpu", s_arm_fpu, 0 },
5022 { "arch_extension", s_arm_arch_extension, 0 },
5024 { "word", s_arm_elf_cons, 4 },
5025 { "long", s_arm_elf_cons, 4 },
5026 { "inst.n", s_arm_elf_inst, 2 },
5027 { "inst.w", s_arm_elf_inst, 4 },
5028 { "inst", s_arm_elf_inst, 0 },
5029 { "rel31", s_arm_rel31, 0 },
5030 { "fnstart", s_arm_unwind_fnstart, 0 },
5031 { "fnend", s_arm_unwind_fnend, 0 },
5032 { "cantunwind", s_arm_unwind_cantunwind, 0 },
5033 { "personality", s_arm_unwind_personality, 0 },
5034 { "personalityindex", s_arm_unwind_personalityindex, 0 },
5035 { "handlerdata", s_arm_unwind_handlerdata, 0 },
5036 { "save", s_arm_unwind_save, 0 },
5037 { "vsave", s_arm_unwind_save, 1 },
5038 { "movsp", s_arm_unwind_movsp, 0 },
5039 { "pad", s_arm_unwind_pad, 0 },
5040 { "setfp", s_arm_unwind_setfp, 0 },
5041 { "unwind_raw", s_arm_unwind_raw, 0 },
5042 { "eabi_attribute", s_arm_eabi_attribute, 0 },
5043 { "tlsdescseq", s_arm_tls_descseq, 0 },
5047 /* These are used for dwarf. */
5051 /* These are used for dwarf2. */
5052 { "file", dwarf2_directive_file, 0 },
5053 { "loc", dwarf2_directive_loc, 0 },
5054 { "loc_mark_labels", dwarf2_directive_loc_mark_labels, 0 },
5056 { "extend", float_cons, 'x' },
5057 { "ldouble", float_cons, 'x' },
5058 { "packed", float_cons, 'p' },
5060 {"secrel32", pe_directive_secrel, 0},
5063 /* These are for compatibility with CodeComposer Studio. */
5064 {"ref", s_ccs_ref, 0},
5065 {"def", s_ccs_def, 0},
5066 {"asmfunc", s_ccs_asmfunc, 0},
5067 {"endasmfunc", s_ccs_endasmfunc, 0},
5069 {"float16", float_cons, 'h' },
5070 {"float16_format", set_fp16_format, 0 },
5075 /* Parser functions used exclusively in instruction operands. */
5077 /* Generic immediate-value read function for use in insn parsing.
5078 STR points to the beginning of the immediate (the leading #);
5079 VAL receives the value; if the value is outside [MIN, MAX]
5080 issue an error. PREFIX_OPT is true if the immediate prefix is
5084 parse_immediate (char **str, int *val, int min, int max,
5085 bfd_boolean prefix_opt)
5089 my_get_expression (&exp, str, prefix_opt ? GE_OPT_PREFIX : GE_IMM_PREFIX);
5090 if (exp.X_op != O_constant)
5092 inst.error = _("constant expression required");
5096 if (exp.X_add_number < min || exp.X_add_number > max)
5098 inst.error = _("immediate value out of range");
5102 *val = exp.X_add_number;
5106 /* Less-generic immediate-value read function with the possibility of loading a
5107 big (64-bit) immediate, as required by Neon VMOV, VMVN and logic immediate
5108 instructions. Puts the result directly in inst.operands[i]. */
5111 parse_big_immediate (char **str, int i, expressionS *in_exp,
5112 bfd_boolean allow_symbol_p)
5115 expressionS *exp_p = in_exp ? in_exp : &exp;
5118 my_get_expression (exp_p, &ptr, GE_OPT_PREFIX_BIG);
5120 if (exp_p->X_op == O_constant)
5122 inst.operands[i].imm = exp_p->X_add_number & 0xffffffff;
5123 /* If we're on a 64-bit host, then a 64-bit number can be returned using
5124 O_constant. We have to be careful not to break compilation for
5125 32-bit X_add_number, though. */
5126 if ((exp_p->X_add_number & ~(offsetT)(0xffffffffU)) != 0)
5128 /* X >> 32 is illegal if sizeof (exp_p->X_add_number) == 4. */
5129 inst.operands[i].reg = (((exp_p->X_add_number >> 16) >> 16)
5131 inst.operands[i].regisimm = 1;
5134 else if (exp_p->X_op == O_big
5135 && LITTLENUM_NUMBER_OF_BITS * exp_p->X_add_number > 32)
5137 unsigned parts = 32 / LITTLENUM_NUMBER_OF_BITS, j, idx = 0;
5139 /* Bignums have their least significant bits in
5140 generic_bignum[0]. Make sure we put 32 bits in imm and
5141 32 bits in reg, in a (hopefully) portable way. */
5142 gas_assert (parts != 0);
5144 /* Make sure that the number is not too big.
5145 PR 11972: Bignums can now be sign-extended to the
5146 size of a .octa so check that the out of range bits
5147 are all zero or all one. */
5148 if (LITTLENUM_NUMBER_OF_BITS * exp_p->X_add_number > 64)
5150 LITTLENUM_TYPE m = -1;
5152 if (generic_bignum[parts * 2] != 0
5153 && generic_bignum[parts * 2] != m)
5156 for (j = parts * 2 + 1; j < (unsigned) exp_p->X_add_number; j++)
5157 if (generic_bignum[j] != generic_bignum[j-1])
5161 inst.operands[i].imm = 0;
5162 for (j = 0; j < parts; j++, idx++)
5163 inst.operands[i].imm |= generic_bignum[idx]
5164 << (LITTLENUM_NUMBER_OF_BITS * j);
5165 inst.operands[i].reg = 0;
5166 for (j = 0; j < parts; j++, idx++)
5167 inst.operands[i].reg |= generic_bignum[idx]
5168 << (LITTLENUM_NUMBER_OF_BITS * j);
5169 inst.operands[i].regisimm = 1;
5171 else if (!(exp_p->X_op == O_symbol && allow_symbol_p))
5179 /* Returns the pseudo-register number of an FPA immediate constant,
5180 or FAIL if there isn't a valid constant here. */
5183 parse_fpa_immediate (char ** str)
5185 LITTLENUM_TYPE words[MAX_LITTLENUMS];
5191 /* First try and match exact strings, this is to guarantee
5192 that some formats will work even for cross assembly. */
5194 for (i = 0; fp_const[i]; i++)
5196 if (strncmp (*str, fp_const[i], strlen (fp_const[i])) == 0)
5200 *str += strlen (fp_const[i]);
5201 if (is_end_of_line[(unsigned char) **str])
5207 /* Just because we didn't get a match doesn't mean that the constant
5208 isn't valid, just that it is in a format that we don't
5209 automatically recognize. Try parsing it with the standard
5210 expression routines. */
5212 memset (words, 0, MAX_LITTLENUMS * sizeof (LITTLENUM_TYPE));
5214 /* Look for a raw floating point number. */
5215 if ((save_in = atof_ieee (*str, 'x', words)) != NULL
5216 && is_end_of_line[(unsigned char) *save_in])
5218 for (i = 0; i < NUM_FLOAT_VALS; i++)
5220 for (j = 0; j < MAX_LITTLENUMS; j++)
5222 if (words[j] != fp_values[i][j])
5226 if (j == MAX_LITTLENUMS)
5234 /* Try and parse a more complex expression, this will probably fail
5235 unless the code uses a floating point prefix (eg "0f"). */
5236 save_in = input_line_pointer;
5237 input_line_pointer = *str;
5238 if (expression (&exp) == absolute_section
5239 && exp.X_op == O_big
5240 && exp.X_add_number < 0)
5242 /* FIXME: 5 = X_PRECISION, should be #define'd where we can use it.
5244 #define X_PRECISION 5
5245 #define E_PRECISION 15L
5246 if (gen_to_words (words, X_PRECISION, E_PRECISION) == 0)
5248 for (i = 0; i < NUM_FLOAT_VALS; i++)
5250 for (j = 0; j < MAX_LITTLENUMS; j++)
5252 if (words[j] != fp_values[i][j])
5256 if (j == MAX_LITTLENUMS)
5258 *str = input_line_pointer;
5259 input_line_pointer = save_in;
5266 *str = input_line_pointer;
5267 input_line_pointer = save_in;
5268 inst.error = _("invalid FPA immediate expression");
5272 /* Returns 1 if a number has "quarter-precision" float format
5273 0baBbbbbbc defgh000 00000000 00000000. */
5276 is_quarter_float (unsigned imm)
5278 int bs = (imm & 0x20000000) ? 0x3e000000 : 0x40000000;
5279 return (imm & 0x7ffff) == 0 && ((imm & 0x7e000000) ^ bs) == 0;
5283 /* Detect the presence of a floating point or integer zero constant,
5287 parse_ifimm_zero (char **in)
5291 if (!is_immediate_prefix (**in))
5293 /* In unified syntax, all prefixes are optional. */
5294 if (!unified_syntax)
5300 /* Accept #0x0 as a synonym for #0. */
5301 if (strncmp (*in, "0x", 2) == 0)
5304 if (parse_immediate (in, &val, 0, 0, TRUE) == FAIL)
5309 error_code = atof_generic (in, ".", EXP_CHARS,
5310 &generic_floating_point_number);
5313 && generic_floating_point_number.sign == '+'
5314 && (generic_floating_point_number.low
5315 > generic_floating_point_number.leader))
5321 /* Parse an 8-bit "quarter-precision" floating point number of the form:
5322 0baBbbbbbc defgh000 00000000 00000000.
5323 The zero and minus-zero cases need special handling, since they can't be
5324 encoded in the "quarter-precision" float format, but can nonetheless be
5325 loaded as integer constants. */
5328 parse_qfloat_immediate (char **ccp, int *immed)
5332 LITTLENUM_TYPE words[MAX_LITTLENUMS];
5333 int found_fpchar = 0;
5335 skip_past_char (&str, '#');
5337 /* We must not accidentally parse an integer as a floating-point number. Make
5338 sure that the value we parse is not an integer by checking for special
5339 characters '.' or 'e'.
5340 FIXME: This is a horrible hack, but doing better is tricky because type
5341 information isn't in a very usable state at parse time. */
5343 skip_whitespace (fpnum);
5345 if (strncmp (fpnum, "0x", 2) == 0)
5349 for (; *fpnum != '\0' && *fpnum != ' ' && *fpnum != '\n'; fpnum++)
5350 if (*fpnum == '.' || *fpnum == 'e' || *fpnum == 'E')
5360 if ((str = atof_ieee (str, 's', words)) != NULL)
5362 unsigned fpword = 0;
5365 /* Our FP word must be 32 bits (single-precision FP). */
5366 for (i = 0; i < 32 / LITTLENUM_NUMBER_OF_BITS; i++)
5368 fpword <<= LITTLENUM_NUMBER_OF_BITS;
5372 if (is_quarter_float (fpword) || (fpword & 0x7fffffff) == 0)
5385 /* Shift operands. */
5388 SHIFT_LSL, SHIFT_LSR, SHIFT_ASR, SHIFT_ROR, SHIFT_RRX, SHIFT_UXTW
5391 struct asm_shift_name
5394 enum shift_kind kind;
5397 /* Third argument to parse_shift. */
5398 enum parse_shift_mode
5400 NO_SHIFT_RESTRICT, /* Any kind of shift is accepted. */
5401 SHIFT_IMMEDIATE, /* Shift operand must be an immediate. */
5402 SHIFT_LSL_OR_ASR_IMMEDIATE, /* Shift must be LSL or ASR immediate. */
5403 SHIFT_ASR_IMMEDIATE, /* Shift must be ASR immediate. */
5404 SHIFT_LSL_IMMEDIATE, /* Shift must be LSL immediate. */
5405 SHIFT_UXTW_IMMEDIATE /* Shift must be UXTW immediate. */
5408 /* Parse a <shift> specifier on an ARM data processing instruction.
5409 This has three forms:
5411 (LSL|LSR|ASL|ASR|ROR) Rs
5412 (LSL|LSR|ASL|ASR|ROR) #imm
5415 Note that ASL is assimilated to LSL in the instruction encoding, and
5416 RRX to ROR #0 (which cannot be written as such). */
5419 parse_shift (char **str, int i, enum parse_shift_mode mode)
5421 const struct asm_shift_name *shift_name;
5422 enum shift_kind shift;
5427 for (p = *str; ISALPHA (*p); p++)
5432 inst.error = _("shift expression expected");
5436 shift_name = (const struct asm_shift_name *) hash_find_n (arm_shift_hsh, *str,
5439 if (shift_name == NULL)
5441 inst.error = _("shift expression expected");
5445 shift = shift_name->kind;
5449 case NO_SHIFT_RESTRICT:
5450 case SHIFT_IMMEDIATE:
5451 if (shift == SHIFT_UXTW)
5453 inst.error = _("'UXTW' not allowed here");
5458 case SHIFT_LSL_OR_ASR_IMMEDIATE:
5459 if (shift != SHIFT_LSL && shift != SHIFT_ASR)
5461 inst.error = _("'LSL' or 'ASR' required");
5466 case SHIFT_LSL_IMMEDIATE:
5467 if (shift != SHIFT_LSL)
5469 inst.error = _("'LSL' required");
5474 case SHIFT_ASR_IMMEDIATE:
5475 if (shift != SHIFT_ASR)
5477 inst.error = _("'ASR' required");
5481 case SHIFT_UXTW_IMMEDIATE:
5482 if (shift != SHIFT_UXTW)
5484 inst.error = _("'UXTW' required");
5492 if (shift != SHIFT_RRX)
5494 /* Whitespace can appear here if the next thing is a bare digit. */
5495 skip_whitespace (p);
5497 if (mode == NO_SHIFT_RESTRICT
5498 && (reg = arm_reg_parse (&p, REG_TYPE_RN)) != FAIL)
5500 inst.operands[i].imm = reg;
5501 inst.operands[i].immisreg = 1;
5503 else if (my_get_expression (&inst.relocs[0].exp, &p, GE_IMM_PREFIX))
5506 inst.operands[i].shift_kind = shift;
5507 inst.operands[i].shifted = 1;
5512 /* Parse a <shifter_operand> for an ARM data processing instruction:
5515 #<immediate>, <rotate>
5519 where <shift> is defined by parse_shift above, and <rotate> is a
5520 multiple of 2 between 0 and 30. Validation of immediate operands
5521 is deferred to md_apply_fix. */
5524 parse_shifter_operand (char **str, int i)
5529 if ((value = arm_reg_parse (str, REG_TYPE_RN)) != FAIL)
5531 inst.operands[i].reg = value;
5532 inst.operands[i].isreg = 1;
5534 /* parse_shift will override this if appropriate */
5535 inst.relocs[0].exp.X_op = O_constant;
5536 inst.relocs[0].exp.X_add_number = 0;
5538 if (skip_past_comma (str) == FAIL)
5541 /* Shift operation on register. */
5542 return parse_shift (str, i, NO_SHIFT_RESTRICT);
5545 if (my_get_expression (&inst.relocs[0].exp, str, GE_IMM_PREFIX))
5548 if (skip_past_comma (str) == SUCCESS)
5550 /* #x, y -- ie explicit rotation by Y. */
5551 if (my_get_expression (&exp, str, GE_NO_PREFIX))
5554 if (exp.X_op != O_constant || inst.relocs[0].exp.X_op != O_constant)
5556 inst.error = _("constant expression expected");
5560 value = exp.X_add_number;
5561 if (value < 0 || value > 30 || value % 2 != 0)
5563 inst.error = _("invalid rotation");
5566 if (inst.relocs[0].exp.X_add_number < 0
5567 || inst.relocs[0].exp.X_add_number > 255)
5569 inst.error = _("invalid constant");
5573 /* Encode as specified. */
5574 inst.operands[i].imm = inst.relocs[0].exp.X_add_number | value << 7;
5578 inst.relocs[0].type = BFD_RELOC_ARM_IMMEDIATE;
5579 inst.relocs[0].pc_rel = 0;
5583 /* Group relocation information. Each entry in the table contains the
5584 textual name of the relocation as may appear in assembler source
5585 and must end with a colon.
5586 Along with this textual name are the relocation codes to be used if
5587 the corresponding instruction is an ALU instruction (ADD or SUB only),
5588 an LDR, an LDRS, or an LDC. */
5590 struct group_reloc_table_entry
5601 /* Varieties of non-ALU group relocation. */
5609 static struct group_reloc_table_entry group_reloc_table[] =
5610 { /* Program counter relative: */
5612 BFD_RELOC_ARM_ALU_PC_G0_NC, /* ALU */
5617 BFD_RELOC_ARM_ALU_PC_G0, /* ALU */
5618 BFD_RELOC_ARM_LDR_PC_G0, /* LDR */
5619 BFD_RELOC_ARM_LDRS_PC_G0, /* LDRS */
5620 BFD_RELOC_ARM_LDC_PC_G0 }, /* LDC */
5622 BFD_RELOC_ARM_ALU_PC_G1_NC, /* ALU */
5627 BFD_RELOC_ARM_ALU_PC_G1, /* ALU */
5628 BFD_RELOC_ARM_LDR_PC_G1, /* LDR */
5629 BFD_RELOC_ARM_LDRS_PC_G1, /* LDRS */
5630 BFD_RELOC_ARM_LDC_PC_G1 }, /* LDC */
5632 BFD_RELOC_ARM_ALU_PC_G2, /* ALU */
5633 BFD_RELOC_ARM_LDR_PC_G2, /* LDR */
5634 BFD_RELOC_ARM_LDRS_PC_G2, /* LDRS */
5635 BFD_RELOC_ARM_LDC_PC_G2 }, /* LDC */
5636 /* Section base relative */
5638 BFD_RELOC_ARM_ALU_SB_G0_NC, /* ALU */
5643 BFD_RELOC_ARM_ALU_SB_G0, /* ALU */
5644 BFD_RELOC_ARM_LDR_SB_G0, /* LDR */
5645 BFD_RELOC_ARM_LDRS_SB_G0, /* LDRS */
5646 BFD_RELOC_ARM_LDC_SB_G0 }, /* LDC */
5648 BFD_RELOC_ARM_ALU_SB_G1_NC, /* ALU */
5653 BFD_RELOC_ARM_ALU_SB_G1, /* ALU */
5654 BFD_RELOC_ARM_LDR_SB_G1, /* LDR */
5655 BFD_RELOC_ARM_LDRS_SB_G1, /* LDRS */
5656 BFD_RELOC_ARM_LDC_SB_G1 }, /* LDC */
5658 BFD_RELOC_ARM_ALU_SB_G2, /* ALU */
5659 BFD_RELOC_ARM_LDR_SB_G2, /* LDR */
5660 BFD_RELOC_ARM_LDRS_SB_G2, /* LDRS */
5661 BFD_RELOC_ARM_LDC_SB_G2 }, /* LDC */
5662 /* Absolute thumb alu relocations. */
5664 BFD_RELOC_ARM_THUMB_ALU_ABS_G0_NC,/* ALU. */
5669 BFD_RELOC_ARM_THUMB_ALU_ABS_G1_NC,/* ALU. */
5674 BFD_RELOC_ARM_THUMB_ALU_ABS_G2_NC,/* ALU. */
5679 BFD_RELOC_ARM_THUMB_ALU_ABS_G3_NC,/* ALU. */
5684 /* Given the address of a pointer pointing to the textual name of a group
5685 relocation as may appear in assembler source, attempt to find its details
5686 in group_reloc_table. The pointer will be updated to the character after
5687 the trailing colon. On failure, FAIL will be returned; SUCCESS
5688 otherwise. On success, *entry will be updated to point at the relevant
5689 group_reloc_table entry. */
5692 find_group_reloc_table_entry (char **str, struct group_reloc_table_entry **out)
5695 for (i = 0; i < ARRAY_SIZE (group_reloc_table); i++)
5697 int length = strlen (group_reloc_table[i].name);
5699 if (strncasecmp (group_reloc_table[i].name, *str, length) == 0
5700 && (*str)[length] == ':')
5702 *out = &group_reloc_table[i];
5703 *str += (length + 1);
5711 /* Parse a <shifter_operand> for an ARM data processing instruction
5712 (as for parse_shifter_operand) where group relocations are allowed:
5715 #<immediate>, <rotate>
5716 #:<group_reloc>:<expression>
5720 where <group_reloc> is one of the strings defined in group_reloc_table.
5721 The hashes are optional.
5723 Everything else is as for parse_shifter_operand. */
5725 static parse_operand_result
5726 parse_shifter_operand_group_reloc (char **str, int i)
5728 /* Determine if we have the sequence of characters #: or just :
5729 coming next. If we do, then we check for a group relocation.
5730 If we don't, punt the whole lot to parse_shifter_operand. */
5732 if (((*str)[0] == '#' && (*str)[1] == ':')
5733 || (*str)[0] == ':')
5735 struct group_reloc_table_entry *entry;
5737 if ((*str)[0] == '#')
5742 /* Try to parse a group relocation. Anything else is an error. */
5743 if (find_group_reloc_table_entry (str, &entry) == FAIL)
5745 inst.error = _("unknown group relocation");
5746 return PARSE_OPERAND_FAIL_NO_BACKTRACK;
5749 /* We now have the group relocation table entry corresponding to
5750 the name in the assembler source. Next, we parse the expression. */
5751 if (my_get_expression (&inst.relocs[0].exp, str, GE_NO_PREFIX))
5752 return PARSE_OPERAND_FAIL_NO_BACKTRACK;
5754 /* Record the relocation type (always the ALU variant here). */
5755 inst.relocs[0].type = (bfd_reloc_code_real_type) entry->alu_code;
5756 gas_assert (inst.relocs[0].type != 0);
5758 return PARSE_OPERAND_SUCCESS;
5761 return parse_shifter_operand (str, i) == SUCCESS
5762 ? PARSE_OPERAND_SUCCESS : PARSE_OPERAND_FAIL;
5764 /* Never reached. */
5767 /* Parse a Neon alignment expression. Information is written to
5768 inst.operands[i]. We assume the initial ':' has been skipped.
5770 align .imm = align << 8, .immisalign=1, .preind=0 */
5771 static parse_operand_result
5772 parse_neon_alignment (char **str, int i)
5777 my_get_expression (&exp, &p, GE_NO_PREFIX);
5779 if (exp.X_op != O_constant)
5781 inst.error = _("alignment must be constant");
5782 return PARSE_OPERAND_FAIL;
5785 inst.operands[i].imm = exp.X_add_number << 8;
5786 inst.operands[i].immisalign = 1;
5787 /* Alignments are not pre-indexes. */
5788 inst.operands[i].preind = 0;
5791 return PARSE_OPERAND_SUCCESS;
5794 /* Parse all forms of an ARM address expression. Information is written
5795 to inst.operands[i] and/or inst.relocs[0].
5797 Preindexed addressing (.preind=1):
5799 [Rn, #offset] .reg=Rn .relocs[0].exp=offset
5800 [Rn, +/-Rm] .reg=Rn .imm=Rm .immisreg=1 .negative=0/1
5801 [Rn, +/-Rm, shift] .reg=Rn .imm=Rm .immisreg=1 .negative=0/1
5802 .shift_kind=shift .relocs[0].exp=shift_imm
5804 These three may have a trailing ! which causes .writeback to be set also.
5806 Postindexed addressing (.postind=1, .writeback=1):
5808 [Rn], #offset .reg=Rn .relocs[0].exp=offset
5809 [Rn], +/-Rm .reg=Rn .imm=Rm .immisreg=1 .negative=0/1
5810 [Rn], +/-Rm, shift .reg=Rn .imm=Rm .immisreg=1 .negative=0/1
5811 .shift_kind=shift .relocs[0].exp=shift_imm
5813 Unindexed addressing (.preind=0, .postind=0):
5815 [Rn], {option} .reg=Rn .imm=option .immisreg=0
5819 [Rn]{!} shorthand for [Rn,#0]{!}
5820 =immediate .isreg=0 .relocs[0].exp=immediate
5821 label .reg=PC .relocs[0].pc_rel=1 .relocs[0].exp=label
5823 It is the caller's responsibility to check for addressing modes not
5824 supported by the instruction, and to set inst.relocs[0].type. */
5826 static parse_operand_result
5827 parse_address_main (char **str, int i, int group_relocations,
5828 group_reloc_type group_type)
5833 if (skip_past_char (&p, '[') == FAIL)
5835 if (skip_past_char (&p, '=') == FAIL)
5837 /* Bare address - translate to PC-relative offset. */
5838 inst.relocs[0].pc_rel = 1;
5839 inst.operands[i].reg = REG_PC;
5840 inst.operands[i].isreg = 1;
5841 inst.operands[i].preind = 1;
5843 if (my_get_expression (&inst.relocs[0].exp, &p, GE_OPT_PREFIX_BIG))
5844 return PARSE_OPERAND_FAIL;
5846 else if (parse_big_immediate (&p, i, &inst.relocs[0].exp,
5847 /*allow_symbol_p=*/TRUE))
5848 return PARSE_OPERAND_FAIL;
5851 return PARSE_OPERAND_SUCCESS;
5854 /* PR gas/14887: Allow for whitespace after the opening bracket. */
5855 skip_whitespace (p);
5857 if (group_type == GROUP_MVE)
5859 enum arm_reg_type rtype = REG_TYPE_MQ;
5860 struct neon_type_el et;
5861 if ((reg = arm_typed_reg_parse (&p, rtype, &rtype, &et)) != FAIL)
5863 inst.operands[i].isquad = 1;
5865 else if ((reg = arm_reg_parse (&p, REG_TYPE_RN)) == FAIL)
5867 inst.error = BAD_ADDR_MODE;
5868 return PARSE_OPERAND_FAIL;
5871 else if ((reg = arm_reg_parse (&p, REG_TYPE_RN)) == FAIL)
5873 if (group_type == GROUP_MVE)
5874 inst.error = BAD_ADDR_MODE;
5876 inst.error = _(reg_expected_msgs[REG_TYPE_RN]);
5877 return PARSE_OPERAND_FAIL;
5879 inst.operands[i].reg = reg;
5880 inst.operands[i].isreg = 1;
5882 if (skip_past_comma (&p) == SUCCESS)
5884 inst.operands[i].preind = 1;
5887 else if (*p == '-') p++, inst.operands[i].negative = 1;
5889 enum arm_reg_type rtype = REG_TYPE_MQ;
5890 struct neon_type_el et;
5891 if (group_type == GROUP_MVE
5892 && (reg = arm_typed_reg_parse (&p, rtype, &rtype, &et)) != FAIL)
5894 inst.operands[i].immisreg = 2;
5895 inst.operands[i].imm = reg;
5897 if (skip_past_comma (&p) == SUCCESS)
5899 if (parse_shift (&p, i, SHIFT_UXTW_IMMEDIATE) == SUCCESS)
5901 inst.operands[i].imm |= inst.relocs[0].exp.X_add_number << 5;
5902 inst.relocs[0].exp.X_add_number = 0;
5905 return PARSE_OPERAND_FAIL;
5908 else if ((reg = arm_reg_parse (&p, REG_TYPE_RN)) != FAIL)
5910 inst.operands[i].imm = reg;
5911 inst.operands[i].immisreg = 1;
5913 if (skip_past_comma (&p) == SUCCESS)
5914 if (parse_shift (&p, i, SHIFT_IMMEDIATE) == FAIL)
5915 return PARSE_OPERAND_FAIL;
5917 else if (skip_past_char (&p, ':') == SUCCESS)
5919 /* FIXME: '@' should be used here, but it's filtered out by generic
5920 code before we get to see it here. This may be subject to
5922 parse_operand_result result = parse_neon_alignment (&p, i);
5924 if (result != PARSE_OPERAND_SUCCESS)
5929 if (inst.operands[i].negative)
5931 inst.operands[i].negative = 0;
5935 if (group_relocations
5936 && ((*p == '#' && *(p + 1) == ':') || *p == ':'))
5938 struct group_reloc_table_entry *entry;
5940 /* Skip over the #: or : sequence. */
5946 /* Try to parse a group relocation. Anything else is an
5948 if (find_group_reloc_table_entry (&p, &entry) == FAIL)
5950 inst.error = _("unknown group relocation");
5951 return PARSE_OPERAND_FAIL_NO_BACKTRACK;
5954 /* We now have the group relocation table entry corresponding to
5955 the name in the assembler source. Next, we parse the
5957 if (my_get_expression (&inst.relocs[0].exp, &p, GE_NO_PREFIX))
5958 return PARSE_OPERAND_FAIL_NO_BACKTRACK;
5960 /* Record the relocation type. */
5965 = (bfd_reloc_code_real_type) entry->ldr_code;
5970 = (bfd_reloc_code_real_type) entry->ldrs_code;
5975 = (bfd_reloc_code_real_type) entry->ldc_code;
5982 if (inst.relocs[0].type == 0)
5984 inst.error = _("this group relocation is not allowed on this instruction");
5985 return PARSE_OPERAND_FAIL_NO_BACKTRACK;
5992 if (my_get_expression (&inst.relocs[0].exp, &p, GE_IMM_PREFIX))
5993 return PARSE_OPERAND_FAIL;
5994 /* If the offset is 0, find out if it's a +0 or -0. */
5995 if (inst.relocs[0].exp.X_op == O_constant
5996 && inst.relocs[0].exp.X_add_number == 0)
5998 skip_whitespace (q);
6002 skip_whitespace (q);
6005 inst.operands[i].negative = 1;
6010 else if (skip_past_char (&p, ':') == SUCCESS)
6012 /* FIXME: '@' should be used here, but it's filtered out by generic code
6013 before we get to see it here. This may be subject to change. */
6014 parse_operand_result result = parse_neon_alignment (&p, i);
6016 if (result != PARSE_OPERAND_SUCCESS)
6020 if (skip_past_char (&p, ']') == FAIL)
6022 inst.error = _("']' expected");
6023 return PARSE_OPERAND_FAIL;
6026 if (skip_past_char (&p, '!') == SUCCESS)
6027 inst.operands[i].writeback = 1;
6029 else if (skip_past_comma (&p) == SUCCESS)
6031 if (skip_past_char (&p, '{') == SUCCESS)
6033 /* [Rn], {expr} - unindexed, with option */
6034 if (parse_immediate (&p, &inst.operands[i].imm,
6035 0, 255, TRUE) == FAIL)
6036 return PARSE_OPERAND_FAIL;
6038 if (skip_past_char (&p, '}') == FAIL)
6040 inst.error = _("'}' expected at end of 'option' field");
6041 return PARSE_OPERAND_FAIL;
6043 if (inst.operands[i].preind)
6045 inst.error = _("cannot combine index with option");
6046 return PARSE_OPERAND_FAIL;
6049 return PARSE_OPERAND_SUCCESS;
6053 inst.operands[i].postind = 1;
6054 inst.operands[i].writeback = 1;
6056 if (inst.operands[i].preind)
6058 inst.error = _("cannot combine pre- and post-indexing");
6059 return PARSE_OPERAND_FAIL;
6063 else if (*p == '-') p++, inst.operands[i].negative = 1;
6065 enum arm_reg_type rtype = REG_TYPE_MQ;
6066 struct neon_type_el et;
6067 if (group_type == GROUP_MVE
6068 && (reg = arm_typed_reg_parse (&p, rtype, &rtype, &et)) != FAIL)
6070 inst.operands[i].immisreg = 2;
6071 inst.operands[i].imm = reg;
6073 else if ((reg = arm_reg_parse (&p, REG_TYPE_RN)) != FAIL)
6075 /* We might be using the immediate for alignment already. If we
6076 are, OR the register number into the low-order bits. */
6077 if (inst.operands[i].immisalign)
6078 inst.operands[i].imm |= reg;
6080 inst.operands[i].imm = reg;
6081 inst.operands[i].immisreg = 1;
6083 if (skip_past_comma (&p) == SUCCESS)
6084 if (parse_shift (&p, i, SHIFT_IMMEDIATE) == FAIL)
6085 return PARSE_OPERAND_FAIL;
6091 if (inst.operands[i].negative)
6093 inst.operands[i].negative = 0;
6096 if (my_get_expression (&inst.relocs[0].exp, &p, GE_IMM_PREFIX))
6097 return PARSE_OPERAND_FAIL;
6098 /* If the offset is 0, find out if it's a +0 or -0. */
6099 if (inst.relocs[0].exp.X_op == O_constant
6100 && inst.relocs[0].exp.X_add_number == 0)
6102 skip_whitespace (q);
6106 skip_whitespace (q);
6109 inst.operands[i].negative = 1;
6115 /* If at this point neither .preind nor .postind is set, we have a
6116 bare [Rn]{!}, which is shorthand for [Rn,#0]{!}. */
6117 if (inst.operands[i].preind == 0 && inst.operands[i].postind == 0)
6119 inst.operands[i].preind = 1;
6120 inst.relocs[0].exp.X_op = O_constant;
6121 inst.relocs[0].exp.X_add_number = 0;
6124 return PARSE_OPERAND_SUCCESS;
6128 parse_address (char **str, int i)
6130 return parse_address_main (str, i, 0, GROUP_LDR) == PARSE_OPERAND_SUCCESS
6134 static parse_operand_result
6135 parse_address_group_reloc (char **str, int i, group_reloc_type type)
6137 return parse_address_main (str, i, 1, type);
6140 /* Parse an operand for a MOVW or MOVT instruction. */
6142 parse_half (char **str)
6147 skip_past_char (&p, '#');
6148 if (strncasecmp (p, ":lower16:", 9) == 0)
6149 inst.relocs[0].type = BFD_RELOC_ARM_MOVW;
6150 else if (strncasecmp (p, ":upper16:", 9) == 0)
6151 inst.relocs[0].type = BFD_RELOC_ARM_MOVT;
6153 if (inst.relocs[0].type != BFD_RELOC_UNUSED)
6156 skip_whitespace (p);
6159 if (my_get_expression (&inst.relocs[0].exp, &p, GE_NO_PREFIX))
6162 if (inst.relocs[0].type == BFD_RELOC_UNUSED)
6164 if (inst.relocs[0].exp.X_op != O_constant)
6166 inst.error = _("constant expression expected");
6169 if (inst.relocs[0].exp.X_add_number < 0
6170 || inst.relocs[0].exp.X_add_number > 0xffff)
6172 inst.error = _("immediate value out of range");
6180 /* Miscellaneous. */
6182 /* Parse a PSR flag operand. The value returned is FAIL on syntax error,
6183 or a bitmask suitable to be or-ed into the ARM msr instruction. */
6185 parse_psr (char **str, bfd_boolean lhs)
6188 unsigned long psr_field;
6189 const struct asm_psr *psr;
6191 bfd_boolean is_apsr = FALSE;
6192 bfd_boolean m_profile = ARM_CPU_HAS_FEATURE (selected_cpu, arm_ext_m);
6194 /* PR gas/12698: If the user has specified -march=all then m_profile will
6195 be TRUE, but we want to ignore it in this case as we are building for any
6196 CPU type, including non-m variants. */
6197 if (ARM_FEATURE_CORE_EQUAL (selected_cpu, arm_arch_any))
6200 /* CPSR's and SPSR's can now be lowercase. This is just a convenience
6201 feature for ease of use and backwards compatibility. */
6203 if (strncasecmp (p, "SPSR", 4) == 0)
6206 goto unsupported_psr;
6208 psr_field = SPSR_BIT;
6210 else if (strncasecmp (p, "CPSR", 4) == 0)
6213 goto unsupported_psr;
6217 else if (strncasecmp (p, "APSR", 4) == 0)
6219 /* APSR[_<bits>] can be used as a synonym for CPSR[_<flags>] on ARMv7-A
6220 and ARMv7-R architecture CPUs. */
6229 while (ISALNUM (*p) || *p == '_');
6231 if (strncasecmp (start, "iapsr", 5) == 0
6232 || strncasecmp (start, "eapsr", 5) == 0
6233 || strncasecmp (start, "xpsr", 4) == 0
6234 || strncasecmp (start, "psr", 3) == 0)
6235 p = start + strcspn (start, "rR") + 1;
6237 psr = (const struct asm_psr *) hash_find_n (arm_v7m_psr_hsh, start,
6243 /* If APSR is being written, a bitfield may be specified. Note that
6244 APSR itself is handled above. */
6245 if (psr->field <= 3)
6247 psr_field = psr->field;
6253 /* M-profile MSR instructions have the mask field set to "10", except
6254 *PSR variants which modify APSR, which may use a different mask (and
6255 have been handled already). Do that by setting the PSR_f field
6257 return psr->field | (lhs ? PSR_f : 0);
6260 goto unsupported_psr;
6266 /* A suffix follows. */
6272 while (ISALNUM (*p) || *p == '_');
6276 /* APSR uses a notation for bits, rather than fields. */
6277 unsigned int nzcvq_bits = 0;
6278 unsigned int g_bit = 0;
6281 for (bit = start; bit != p; bit++)
6283 switch (TOLOWER (*bit))
6286 nzcvq_bits |= (nzcvq_bits & 0x01) ? 0x20 : 0x01;
6290 nzcvq_bits |= (nzcvq_bits & 0x02) ? 0x20 : 0x02;
6294 nzcvq_bits |= (nzcvq_bits & 0x04) ? 0x20 : 0x04;
6298 nzcvq_bits |= (nzcvq_bits & 0x08) ? 0x20 : 0x08;
6302 nzcvq_bits |= (nzcvq_bits & 0x10) ? 0x20 : 0x10;
6306 g_bit |= (g_bit & 0x1) ? 0x2 : 0x1;
6310 inst.error = _("unexpected bit specified after APSR");
6315 if (nzcvq_bits == 0x1f)
6320 if (!ARM_CPU_HAS_FEATURE (selected_cpu, arm_ext_v6_dsp))
6322 inst.error = _("selected processor does not "
6323 "support DSP extension");
6330 if ((nzcvq_bits & 0x20) != 0
6331 || (nzcvq_bits != 0x1f && nzcvq_bits != 0)
6332 || (g_bit & 0x2) != 0)
6334 inst.error = _("bad bitmask specified after APSR");
6340 psr = (const struct asm_psr *) hash_find_n (arm_psr_hsh, start,
6345 psr_field |= psr->field;
6351 goto error; /* Garbage after "[CS]PSR". */
6353 /* Unadorned APSR is equivalent to APSR_nzcvq/CPSR_f (for writes). This
6354 is deprecated, but allow it anyway. */
6358 as_tsktsk (_("writing to APSR without specifying a bitmask is "
6361 else if (!m_profile)
6362 /* These bits are never right for M-profile devices: don't set them
6363 (only code paths which read/write APSR reach here). */
6364 psr_field |= (PSR_c | PSR_f);
6370 inst.error = _("selected processor does not support requested special "
6371 "purpose register");
6375 inst.error = _("flag for {c}psr instruction expected");
6380 parse_sys_vldr_vstr (char **str)
6389 {"FPSCR", 0x1, 0x0},
6390 {"FPSCR_nzcvqc", 0x2, 0x0},
6393 {"FPCXTNS", 0x6, 0x1},
6394 {"FPCXTS", 0x7, 0x1}
6396 char *op_end = strchr (*str, ',');
6397 size_t op_strlen = op_end - *str;
6399 for (i = 0; i < sizeof (sysregs) / sizeof (sysregs[0]); i++)
6401 if (!strncmp (*str, sysregs[i].name, op_strlen))
6403 val = sysregs[i].regl | (sysregs[i].regh << 3);
6412 /* Parse the flags argument to CPSI[ED]. Returns FAIL on error, or a
6413 value suitable for splatting into the AIF field of the instruction. */
6416 parse_cps_flags (char **str)
6425 case '\0': case ',':
6428 case 'a': case 'A': saw_a_flag = 1; val |= 0x4; break;
6429 case 'i': case 'I': saw_a_flag = 1; val |= 0x2; break;
6430 case 'f': case 'F': saw_a_flag = 1; val |= 0x1; break;
6433 inst.error = _("unrecognized CPS flag");
6438 if (saw_a_flag == 0)
6440 inst.error = _("missing CPS flags");
6448 /* Parse an endian specifier ("BE" or "LE", case insensitive);
6449 returns 0 for big-endian, 1 for little-endian, FAIL for an error. */
6452 parse_endian_specifier (char **str)
6457 if (strncasecmp (s, "BE", 2))
6459 else if (strncasecmp (s, "LE", 2))
6463 inst.error = _("valid endian specifiers are be or le");
6467 if (ISALNUM (s[2]) || s[2] == '_')
6469 inst.error = _("valid endian specifiers are be or le");
6474 return little_endian;
6477 /* Parse a rotation specifier: ROR #0, #8, #16, #24. *val receives a
6478 value suitable for poking into the rotate field of an sxt or sxta
6479 instruction, or FAIL on error. */
6482 parse_ror (char **str)
6487 if (strncasecmp (s, "ROR", 3) == 0)
6491 inst.error = _("missing rotation field after comma");
6495 if (parse_immediate (&s, &rot, 0, 24, FALSE) == FAIL)
6500 case 0: *str = s; return 0x0;
6501 case 8: *str = s; return 0x1;
6502 case 16: *str = s; return 0x2;
6503 case 24: *str = s; return 0x3;
6506 inst.error = _("rotation can only be 0, 8, 16, or 24");
6511 /* Parse a conditional code (from conds[] below). The value returned is in the
6512 range 0 .. 14, or FAIL. */
6514 parse_cond (char **str)
6517 const struct asm_cond *c;
6519 /* Condition codes are always 2 characters, so matching up to
6520 3 characters is sufficient. */
6525 while (ISALPHA (*q) && n < 3)
6527 cond[n] = TOLOWER (*q);
6532 c = (const struct asm_cond *) hash_find_n (arm_cond_hsh, cond, n);
6535 inst.error = _("condition required");
6543 /* Parse an option for a barrier instruction. Returns the encoding for the
6546 parse_barrier (char **str)
6549 const struct asm_barrier_opt *o;
6552 while (ISALPHA (*q))
6555 o = (const struct asm_barrier_opt *) hash_find_n (arm_barrier_opt_hsh, p,
6560 if (!mark_feature_used (&o->arch))
6567 /* Parse the operands of a table branch instruction. Similar to a memory
6570 parse_tb (char **str)
6575 if (skip_past_char (&p, '[') == FAIL)
6577 inst.error = _("'[' expected");
6581 if ((reg = arm_reg_parse (&p, REG_TYPE_RN)) == FAIL)
6583 inst.error = _(reg_expected_msgs[REG_TYPE_RN]);
6586 inst.operands[0].reg = reg;
6588 if (skip_past_comma (&p) == FAIL)
6590 inst.error = _("',' expected");
6594 if ((reg = arm_reg_parse (&p, REG_TYPE_RN)) == FAIL)
6596 inst.error = _(reg_expected_msgs[REG_TYPE_RN]);
6599 inst.operands[0].imm = reg;
6601 if (skip_past_comma (&p) == SUCCESS)
6603 if (parse_shift (&p, 0, SHIFT_LSL_IMMEDIATE) == FAIL)
6605 if (inst.relocs[0].exp.X_add_number != 1)
6607 inst.error = _("invalid shift");
6610 inst.operands[0].shifted = 1;
6613 if (skip_past_char (&p, ']') == FAIL)
6615 inst.error = _("']' expected");
6622 /* Parse the operands of a Neon VMOV instruction. See do_neon_mov for more
6623 information on the types the operands can take and how they are encoded.
6624 Up to four operands may be read; this function handles setting the
6625 ".present" field for each read operand itself.
6626 Updates STR and WHICH_OPERAND if parsing is successful and returns SUCCESS,
6627 else returns FAIL. */
6630 parse_neon_mov (char **str, int *which_operand)
6632 int i = *which_operand, val;
6633 enum arm_reg_type rtype;
6635 struct neon_type_el optype;
6637 if ((val = parse_scalar (&ptr, 8, &optype, REG_TYPE_MQ)) != FAIL)
6639 /* Cases 17 or 19. */
6640 inst.operands[i].reg = val;
6641 inst.operands[i].isvec = 1;
6642 inst.operands[i].isscalar = 2;
6643 inst.operands[i].vectype = optype;
6644 inst.operands[i++].present = 1;
6646 if (skip_past_comma (&ptr) == FAIL)
6649 if ((val = arm_reg_parse (&ptr, REG_TYPE_RN)) != FAIL)
6651 /* Case 17: VMOV<c>.<dt> <Qd[idx]>, <Rt> */
6652 inst.operands[i].reg = val;
6653 inst.operands[i].isreg = 1;
6654 inst.operands[i].present = 1;
6656 else if ((val = parse_scalar (&ptr, 8, &optype, REG_TYPE_MQ)) != FAIL)
6658 /* Case 19: VMOV<c> <Qd[idx]>, <Qd[idx2]>, <Rt>, <Rt2> */
6659 inst.operands[i].reg = val;
6660 inst.operands[i].isvec = 1;
6661 inst.operands[i].isscalar = 2;
6662 inst.operands[i].vectype = optype;
6663 inst.operands[i++].present = 1;
6665 if (skip_past_comma (&ptr) == FAIL)
6668 if ((val = arm_reg_parse (&ptr, REG_TYPE_RN)) == FAIL)
6671 inst.operands[i].reg = val;
6672 inst.operands[i].isreg = 1;
6673 inst.operands[i++].present = 1;
6675 if (skip_past_comma (&ptr) == FAIL)
6678 if ((val = arm_reg_parse (&ptr, REG_TYPE_RN)) == FAIL)
6681 inst.operands[i].reg = val;
6682 inst.operands[i].isreg = 1;
6683 inst.operands[i].present = 1;
6687 first_error (_("expected ARM or MVE vector register"));
6691 else if ((val = parse_scalar (&ptr, 8, &optype, REG_TYPE_VFD)) != FAIL)
6693 /* Case 4: VMOV<c><q>.<size> <Dn[x]>, <Rd>. */
6694 inst.operands[i].reg = val;
6695 inst.operands[i].isscalar = 1;
6696 inst.operands[i].vectype = optype;
6697 inst.operands[i++].present = 1;
6699 if (skip_past_comma (&ptr) == FAIL)
6702 if ((val = arm_reg_parse (&ptr, REG_TYPE_RN)) == FAIL)
6705 inst.operands[i].reg = val;
6706 inst.operands[i].isreg = 1;
6707 inst.operands[i].present = 1;
6709 else if (((val = arm_typed_reg_parse (&ptr, REG_TYPE_NSDQ, &rtype, &optype))
6711 || ((val = arm_typed_reg_parse (&ptr, REG_TYPE_MQ, &rtype, &optype))
6714 /* Cases 0, 1, 2, 3, 5 (D only). */
6715 if (skip_past_comma (&ptr) == FAIL)
6718 inst.operands[i].reg = val;
6719 inst.operands[i].isreg = 1;
6720 inst.operands[i].isquad = (rtype == REG_TYPE_NQ);
6721 inst.operands[i].issingle = (rtype == REG_TYPE_VFS);
6722 inst.operands[i].isvec = 1;
6723 inst.operands[i].vectype = optype;
6724 inst.operands[i++].present = 1;
6726 if ((val = arm_reg_parse (&ptr, REG_TYPE_RN)) != FAIL)
6728 /* Case 5: VMOV<c><q> <Dm>, <Rd>, <Rn>.
6729 Case 13: VMOV <Sd>, <Rm> */
6730 inst.operands[i].reg = val;
6731 inst.operands[i].isreg = 1;
6732 inst.operands[i].present = 1;
6734 if (rtype == REG_TYPE_NQ)
6736 first_error (_("can't use Neon quad register here"));
6739 else if (rtype != REG_TYPE_VFS)
6742 if (skip_past_comma (&ptr) == FAIL)
6744 if ((val = arm_reg_parse (&ptr, REG_TYPE_RN)) == FAIL)
6746 inst.operands[i].reg = val;
6747 inst.operands[i].isreg = 1;
6748 inst.operands[i].present = 1;
6751 else if ((val = arm_typed_reg_parse (&ptr, REG_TYPE_NSDQ, &rtype,
6754 /* Case 0: VMOV<c><q> <Qd>, <Qm>
6755 Case 1: VMOV<c><q> <Dd>, <Dm>
6756 Case 8: VMOV.F32 <Sd>, <Sm>
6757 Case 15: VMOV <Sd>, <Se>, <Rn>, <Rm> */
6759 inst.operands[i].reg = val;
6760 inst.operands[i].isreg = 1;
6761 inst.operands[i].isquad = (rtype == REG_TYPE_NQ);
6762 inst.operands[i].issingle = (rtype == REG_TYPE_VFS);
6763 inst.operands[i].isvec = 1;
6764 inst.operands[i].vectype = optype;
6765 inst.operands[i].present = 1;
6767 if (skip_past_comma (&ptr) == SUCCESS)
6772 if ((val = arm_reg_parse (&ptr, REG_TYPE_RN)) == FAIL)
6775 inst.operands[i].reg = val;
6776 inst.operands[i].isreg = 1;
6777 inst.operands[i++].present = 1;
6779 if (skip_past_comma (&ptr) == FAIL)
6782 if ((val = arm_reg_parse (&ptr, REG_TYPE_RN)) == FAIL)
6785 inst.operands[i].reg = val;
6786 inst.operands[i].isreg = 1;
6787 inst.operands[i].present = 1;
6790 else if (parse_qfloat_immediate (&ptr, &inst.operands[i].imm) == SUCCESS)
6791 /* Case 2: VMOV<c><q>.<dt> <Qd>, #<float-imm>
6792 Case 3: VMOV<c><q>.<dt> <Dd>, #<float-imm>
6793 Case 10: VMOV.F32 <Sd>, #<imm>
6794 Case 11: VMOV.F64 <Dd>, #<imm> */
6795 inst.operands[i].immisfloat = 1;
6796 else if (parse_big_immediate (&ptr, i, NULL, /*allow_symbol_p=*/FALSE)
6798 /* Case 2: VMOV<c><q>.<dt> <Qd>, #<imm>
6799 Case 3: VMOV<c><q>.<dt> <Dd>, #<imm> */
6803 first_error (_("expected <Rm> or <Dm> or <Qm> operand"));
6807 else if ((val = arm_reg_parse (&ptr, REG_TYPE_RN)) != FAIL)
6809 /* Cases 6, 7, 16, 18. */
6810 inst.operands[i].reg = val;
6811 inst.operands[i].isreg = 1;
6812 inst.operands[i++].present = 1;
6814 if (skip_past_comma (&ptr) == FAIL)
6817 if ((val = parse_scalar (&ptr, 8, &optype, REG_TYPE_MQ)) != FAIL)
6819 /* Case 18: VMOV<c>.<dt> <Rt>, <Qn[idx]> */
6820 inst.operands[i].reg = val;
6821 inst.operands[i].isscalar = 2;
6822 inst.operands[i].present = 1;
6823 inst.operands[i].vectype = optype;
6825 else if ((val = parse_scalar (&ptr, 8, &optype, REG_TYPE_VFD)) != FAIL)
6827 /* Case 6: VMOV<c><q>.<dt> <Rd>, <Dn[x]> */
6828 inst.operands[i].reg = val;
6829 inst.operands[i].isscalar = 1;
6830 inst.operands[i].present = 1;
6831 inst.operands[i].vectype = optype;
6833 else if ((val = arm_reg_parse (&ptr, REG_TYPE_RN)) != FAIL)
6835 inst.operands[i].reg = val;
6836 inst.operands[i].isreg = 1;
6837 inst.operands[i++].present = 1;
6839 if (skip_past_comma (&ptr) == FAIL)
6842 if ((val = arm_typed_reg_parse (&ptr, REG_TYPE_VFSD, &rtype, &optype))
6845 /* Case 7: VMOV<c><q> <Rd>, <Rn>, <Dm> */
6847 inst.operands[i].reg = val;
6848 inst.operands[i].isreg = 1;
6849 inst.operands[i].isvec = 1;
6850 inst.operands[i].issingle = (rtype == REG_TYPE_VFS);
6851 inst.operands[i].vectype = optype;
6852 inst.operands[i].present = 1;
6854 if (rtype == REG_TYPE_VFS)
6858 if (skip_past_comma (&ptr) == FAIL)
6860 if ((val = arm_typed_reg_parse (&ptr, REG_TYPE_VFS, NULL,
6863 first_error (_(reg_expected_msgs[REG_TYPE_VFS]));
6866 inst.operands[i].reg = val;
6867 inst.operands[i].isreg = 1;
6868 inst.operands[i].isvec = 1;
6869 inst.operands[i].issingle = 1;
6870 inst.operands[i].vectype = optype;
6871 inst.operands[i].present = 1;
6876 if ((val = parse_scalar (&ptr, 8, &optype, REG_TYPE_MQ))
6879 /* Case 16: VMOV<c> <Rt>, <Rt2>, <Qd[idx]>, <Qd[idx2]> */
6880 inst.operands[i].reg = val;
6881 inst.operands[i].isvec = 1;
6882 inst.operands[i].isscalar = 2;
6883 inst.operands[i].vectype = optype;
6884 inst.operands[i++].present = 1;
6886 if (skip_past_comma (&ptr) == FAIL)
6889 if ((val = parse_scalar (&ptr, 8, &optype, REG_TYPE_MQ))
6892 first_error (_(reg_expected_msgs[REG_TYPE_MQ]));
6895 inst.operands[i].reg = val;
6896 inst.operands[i].isvec = 1;
6897 inst.operands[i].isscalar = 2;
6898 inst.operands[i].vectype = optype;
6899 inst.operands[i].present = 1;
6903 first_error (_("VFP single, double or MVE vector register"
6909 else if ((val = arm_typed_reg_parse (&ptr, REG_TYPE_VFS, NULL, &optype))
6913 inst.operands[i].reg = val;
6914 inst.operands[i].isreg = 1;
6915 inst.operands[i].isvec = 1;
6916 inst.operands[i].issingle = 1;
6917 inst.operands[i].vectype = optype;
6918 inst.operands[i].present = 1;
6923 first_error (_("parse error"));
6927 /* Successfully parsed the operands. Update args. */
6933 first_error (_("expected comma"));
6937 first_error (_(reg_expected_msgs[REG_TYPE_RN]));
6941 /* Use this macro when the operand constraints are different
6942 for ARM and THUMB (e.g. ldrd). */
6943 #define MIX_ARM_THUMB_OPERANDS(arm_operand, thumb_operand) \
6944 ((arm_operand) | ((thumb_operand) << 16))
6946 /* Matcher codes for parse_operands. */
6947 enum operand_parse_code
6949 OP_stop, /* end of line */
6951 OP_RR, /* ARM register */
6952 OP_RRnpc, /* ARM register, not r15 */
6953 OP_RRnpcsp, /* ARM register, neither r15 nor r13 (a.k.a. 'BadReg') */
6954 OP_RRnpcb, /* ARM register, not r15, in square brackets */
6955 OP_RRnpctw, /* ARM register, not r15 in Thumb-state or with writeback,
6956 optional trailing ! */
6957 OP_RRw, /* ARM register, not r15, optional trailing ! */
6958 OP_RCP, /* Coprocessor number */
6959 OP_RCN, /* Coprocessor register */
6960 OP_RF, /* FPA register */
6961 OP_RVS, /* VFP single precision register */
6962 OP_RVD, /* VFP double precision register (0..15) */
6963 OP_RND, /* Neon double precision register (0..31) */
6964 OP_RNDMQ, /* Neon double precision (0..31) or MVE vector register. */
6965 OP_RNDMQR, /* Neon double precision (0..31), MVE vector or ARM register.
6967 OP_RNQ, /* Neon quad precision register */
6968 OP_RNQMQ, /* Neon quad or MVE vector register. */
6969 OP_RVSD, /* VFP single or double precision register */
6970 OP_RVSD_COND, /* VFP single, double precision register or condition code. */
6971 OP_RVSDMQ, /* VFP single, double precision or MVE vector register. */
6972 OP_RNSD, /* Neon single or double precision register */
6973 OP_RNDQ, /* Neon double or quad precision register */
6974 OP_RNDQMQ, /* Neon double, quad or MVE vector register. */
6975 OP_RNDQMQR, /* Neon double, quad, MVE vector or ARM register. */
6976 OP_RNSDQ, /* Neon single, double or quad precision register */
6977 OP_RNSC, /* Neon scalar D[X] */
6978 OP_RVC, /* VFP control register */
6979 OP_RMF, /* Maverick F register */
6980 OP_RMD, /* Maverick D register */
6981 OP_RMFX, /* Maverick FX register */
6982 OP_RMDX, /* Maverick DX register */
6983 OP_RMAX, /* Maverick AX register */
6984 OP_RMDS, /* Maverick DSPSC register */
6985 OP_RIWR, /* iWMMXt wR register */
6986 OP_RIWC, /* iWMMXt wC register */
6987 OP_RIWG, /* iWMMXt wCG register */
6988 OP_RXA, /* XScale accumulator register */
6990 OP_RNSDQMQ, /* Neon single, double or quad register or MVE vector register
6992 OP_RNSDQMQR, /* Neon single, double or quad register, MVE vector register or
6994 OP_RMQ, /* MVE vector register. */
6995 OP_RMQRZ, /* MVE vector or ARM register including ZR. */
6996 OP_RMQRR, /* MVE vector or ARM register. */
6998 /* New operands for Armv8.1-M Mainline. */
6999 OP_LR, /* ARM LR register */
7000 OP_RRe, /* ARM register, only even numbered. */
7001 OP_RRo, /* ARM register, only odd numbered, not r13 or r15. */
7002 OP_RRnpcsp_I32, /* ARM register (no BadReg) or literal 1 .. 32 */
7003 OP_RR_ZR, /* ARM register or ZR but no PC */
7005 OP_REGLST, /* ARM register list */
7006 OP_CLRMLST, /* CLRM register list */
7007 OP_VRSLST, /* VFP single-precision register list */
7008 OP_VRDLST, /* VFP double-precision register list */
7009 OP_VRSDLST, /* VFP single or double-precision register list (& quad) */
7010 OP_NRDLST, /* Neon double-precision register list (d0-d31, qN aliases) */
7011 OP_NSTRLST, /* Neon element/structure list */
7012 OP_VRSDVLST, /* VFP single or double-precision register list and VPR */
7013 OP_MSTRLST2, /* MVE vector list with two elements. */
7014 OP_MSTRLST4, /* MVE vector list with four elements. */
7016 OP_RNDQ_I0, /* Neon D or Q reg, or immediate zero. */
7017 OP_RVSD_I0, /* VFP S or D reg, or immediate zero. */
7018 OP_RSVD_FI0, /* VFP S or D reg, or floating point immediate zero. */
7019 OP_RSVDMQ_FI0, /* VFP S, D, MVE vector register or floating point immediate
7021 OP_RR_RNSC, /* ARM reg or Neon scalar. */
7022 OP_RNSD_RNSC, /* Neon S or D reg, or Neon scalar. */
7023 OP_RNSDQ_RNSC, /* Vector S, D or Q reg, or Neon scalar. */
7024 OP_RNSDQ_RNSC_MQ, /* Vector S, D or Q reg, Neon scalar or MVE vector register.
7026 OP_RNSDQ_RNSC_MQ_RR, /* Vector S, D or Q reg, or MVE vector reg , or Neon
7027 scalar, or ARM register. */
7028 OP_RNDQ_RNSC, /* Neon D or Q reg, or Neon scalar. */
7029 OP_RNDQ_RNSC_RR, /* Neon D or Q reg, Neon scalar, or ARM register. */
7030 OP_RNDQMQ_RNSC_RR, /* Neon D or Q reg, Neon scalar, MVE vector or ARM
7032 OP_RNDQMQ_RNSC, /* Neon D, Q or MVE vector reg, or Neon scalar. */
7033 OP_RND_RNSC, /* Neon D reg, or Neon scalar. */
7034 OP_VMOV, /* Neon VMOV operands. */
7035 OP_RNDQ_Ibig, /* Neon D or Q reg, or big immediate for logic and VMVN. */
7036 /* Neon D, Q or MVE vector register, or big immediate for logic and VMVN. */
7038 OP_RNDQ_I63b, /* Neon D or Q reg, or immediate for shift. */
7039 OP_RNDQMQ_I63b_RR, /* Neon D or Q reg, immediate for shift, MVE vector or
7041 OP_RIWR_I32z, /* iWMMXt wR register, or immediate 0 .. 32 for iWMMXt2. */
7042 OP_VLDR, /* VLDR operand. */
7044 OP_I0, /* immediate zero */
7045 OP_I7, /* immediate value 0 .. 7 */
7046 OP_I15, /* 0 .. 15 */
7047 OP_I16, /* 1 .. 16 */
7048 OP_I16z, /* 0 .. 16 */
7049 OP_I31, /* 0 .. 31 */
7050 OP_I31w, /* 0 .. 31, optional trailing ! */
7051 OP_I32, /* 1 .. 32 */
7052 OP_I32z, /* 0 .. 32 */
7053 OP_I48_I64, /* 48 or 64 */
7054 OP_I63, /* 0 .. 63 */
7055 OP_I63s, /* -64 .. 63 */
7056 OP_I64, /* 1 .. 64 */
7057 OP_I64z, /* 0 .. 64 */
7058 OP_I255, /* 0 .. 255 */
7060 OP_I4b, /* immediate, prefix optional, 1 .. 4 */
7061 OP_I7b, /* 0 .. 7 */
7062 OP_I15b, /* 0 .. 15 */
7063 OP_I31b, /* 0 .. 31 */
7065 OP_SH, /* shifter operand */
7066 OP_SHG, /* shifter operand with possible group relocation */
7067 OP_ADDR, /* Memory address expression (any mode) */
7068 OP_ADDRMVE, /* Memory address expression for MVE's VSTR/VLDR. */
7069 OP_ADDRGLDR, /* Mem addr expr (any mode) with possible LDR group reloc */
7070 OP_ADDRGLDRS, /* Mem addr expr (any mode) with possible LDRS group reloc */
7071 OP_ADDRGLDC, /* Mem addr expr (any mode) with possible LDC group reloc */
7072 OP_EXP, /* arbitrary expression */
7073 OP_EXPi, /* same, with optional immediate prefix */
7074 OP_EXPr, /* same, with optional relocation suffix */
7075 OP_EXPs, /* same, with optional non-first operand relocation suffix */
7076 OP_HALF, /* 0 .. 65535 or low/high reloc. */
7077 OP_IROT1, /* VCADD rotate immediate: 90, 270. */
7078 OP_IROT2, /* VCMLA rotate immediate: 0, 90, 180, 270. */
7080 OP_CPSF, /* CPS flags */
7081 OP_ENDI, /* Endianness specifier */
7082 OP_wPSR, /* CPSR/SPSR/APSR mask for msr (writing). */
7083 OP_rPSR, /* CPSR/SPSR/APSR mask for msr (reading). */
7084 OP_COND, /* conditional code */
7085 OP_TB, /* Table branch. */
7087 OP_APSR_RR, /* ARM register or "APSR_nzcv". */
7089 OP_RRnpc_I0, /* ARM register or literal 0 */
7090 OP_RR_EXr, /* ARM register or expression with opt. reloc stuff. */
7091 OP_RR_EXi, /* ARM register or expression with imm prefix */
7092 OP_RF_IF, /* FPA register or immediate */
7093 OP_RIWR_RIWC, /* iWMMXt R or C reg */
7094 OP_RIWC_RIWG, /* iWMMXt wC or wCG reg */
7096 /* Optional operands. */
7097 OP_oI7b, /* immediate, prefix optional, 0 .. 7 */
7098 OP_oI31b, /* 0 .. 31 */
7099 OP_oI32b, /* 1 .. 32 */
7100 OP_oI32z, /* 0 .. 32 */
7101 OP_oIffffb, /* 0 .. 65535 */
7102 OP_oI255c, /* curly-brace enclosed, 0 .. 255 */
7104 OP_oRR, /* ARM register */
7105 OP_oLR, /* ARM LR register */
7106 OP_oRRnpc, /* ARM register, not the PC */
7107 OP_oRRnpcsp, /* ARM register, neither the PC nor the SP (a.k.a. BadReg) */
7108 OP_oRRw, /* ARM register, not r15, optional trailing ! */
7109 OP_oRND, /* Optional Neon double precision register */
7110 OP_oRNQ, /* Optional Neon quad precision register */
7111 OP_oRNDQMQ, /* Optional Neon double, quad or MVE vector register. */
7112 OP_oRNDQ, /* Optional Neon double or quad precision register */
7113 OP_oRNSDQ, /* Optional single, double or quad precision vector register */
7114 OP_oRNSDQMQ, /* Optional single, double or quad register or MVE vector
7116 OP_oSHll, /* LSL immediate */
7117 OP_oSHar, /* ASR immediate */
7118 OP_oSHllar, /* LSL or ASR immediate */
7119 OP_oROR, /* ROR 0/8/16/24 */
7120 OP_oBARRIER_I15, /* Option argument for a barrier instruction. */
7122 OP_oRMQRZ, /* optional MVE vector or ARM register including ZR. */
7124 /* Some pre-defined mixed (ARM/THUMB) operands. */
7125 OP_RR_npcsp = MIX_ARM_THUMB_OPERANDS (OP_RR, OP_RRnpcsp),
7126 OP_RRnpc_npcsp = MIX_ARM_THUMB_OPERANDS (OP_RRnpc, OP_RRnpcsp),
7127 OP_oRRnpc_npcsp = MIX_ARM_THUMB_OPERANDS (OP_oRRnpc, OP_oRRnpcsp),
7129 OP_FIRST_OPTIONAL = OP_oI7b
7132 /* Generic instruction operand parser. This does no encoding and no
7133 semantic validation; it merely squirrels values away in the inst
7134 structure. Returns SUCCESS or FAIL depending on whether the
7135 specified grammar matched. */
7137 parse_operands (char *str, const unsigned int *pattern, bfd_boolean thumb)
7139 unsigned const int *upat = pattern;
7140 char *backtrack_pos = 0;
7141 const char *backtrack_error = 0;
7142 int i, val = 0, backtrack_index = 0;
7143 enum arm_reg_type rtype;
7144 parse_operand_result result;
7145 unsigned int op_parse_code;
7146 bfd_boolean partial_match;
7148 #define po_char_or_fail(chr) \
7151 if (skip_past_char (&str, chr) == FAIL) \
7156 #define po_reg_or_fail(regtype) \
7159 val = arm_typed_reg_parse (& str, regtype, & rtype, \
7160 & inst.operands[i].vectype); \
7163 first_error (_(reg_expected_msgs[regtype])); \
7166 inst.operands[i].reg = val; \
7167 inst.operands[i].isreg = 1; \
7168 inst.operands[i].isquad = (rtype == REG_TYPE_NQ); \
7169 inst.operands[i].issingle = (rtype == REG_TYPE_VFS); \
7170 inst.operands[i].isvec = (rtype == REG_TYPE_VFS \
7171 || rtype == REG_TYPE_VFD \
7172 || rtype == REG_TYPE_NQ); \
7173 inst.operands[i].iszr = (rtype == REG_TYPE_ZR); \
7177 #define po_reg_or_goto(regtype, label) \
7180 val = arm_typed_reg_parse (& str, regtype, & rtype, \
7181 & inst.operands[i].vectype); \
7185 inst.operands[i].reg = val; \
7186 inst.operands[i].isreg = 1; \
7187 inst.operands[i].isquad = (rtype == REG_TYPE_NQ); \
7188 inst.operands[i].issingle = (rtype == REG_TYPE_VFS); \
7189 inst.operands[i].isvec = (rtype == REG_TYPE_VFS \
7190 || rtype == REG_TYPE_VFD \
7191 || rtype == REG_TYPE_NQ); \
7192 inst.operands[i].iszr = (rtype == REG_TYPE_ZR); \
7196 #define po_imm_or_fail(min, max, popt) \
7199 if (parse_immediate (&str, &val, min, max, popt) == FAIL) \
7201 inst.operands[i].imm = val; \
7205 #define po_imm1_or_imm2_or_fail(imm1, imm2, popt) \
7209 my_get_expression (&exp, &str, popt); \
7210 if (exp.X_op != O_constant) \
7212 inst.error = _("constant expression required"); \
7215 if (exp.X_add_number != imm1 && exp.X_add_number != imm2) \
7217 inst.error = _("immediate value 48 or 64 expected"); \
7220 inst.operands[i].imm = exp.X_add_number; \
7224 #define po_scalar_or_goto(elsz, label, reg_type) \
7227 val = parse_scalar (& str, elsz, & inst.operands[i].vectype, \
7231 inst.operands[i].reg = val; \
7232 inst.operands[i].isscalar = 1; \
7236 #define po_misc_or_fail(expr) \
7244 #define po_misc_or_fail_no_backtrack(expr) \
7248 if (result == PARSE_OPERAND_FAIL_NO_BACKTRACK) \
7249 backtrack_pos = 0; \
7250 if (result != PARSE_OPERAND_SUCCESS) \
7255 #define po_barrier_or_imm(str) \
7258 val = parse_barrier (&str); \
7259 if (val == FAIL && ! ISALPHA (*str)) \
7262 /* ISB can only take SY as an option. */ \
7263 || ((inst.instruction & 0xf0) == 0x60 \
7266 inst.error = _("invalid barrier type"); \
7267 backtrack_pos = 0; \
7273 skip_whitespace (str);
7275 for (i = 0; upat[i] != OP_stop; i++)
7277 op_parse_code = upat[i];
7278 if (op_parse_code >= 1<<16)
7279 op_parse_code = thumb ? (op_parse_code >> 16)
7280 : (op_parse_code & ((1<<16)-1));
7282 if (op_parse_code >= OP_FIRST_OPTIONAL)
7284 /* Remember where we are in case we need to backtrack. */
7285 backtrack_pos = str;
7286 backtrack_error = inst.error;
7287 backtrack_index = i;
7290 if (i > 0 && (i > 1 || inst.operands[0].present))
7291 po_char_or_fail (',');
7293 switch (op_parse_code)
7305 case OP_RR: po_reg_or_fail (REG_TYPE_RN); break;
7306 case OP_RCP: po_reg_or_fail (REG_TYPE_CP); break;
7307 case OP_RCN: po_reg_or_fail (REG_TYPE_CN); break;
7308 case OP_RF: po_reg_or_fail (REG_TYPE_FN); break;
7309 case OP_RVS: po_reg_or_fail (REG_TYPE_VFS); break;
7310 case OP_RVD: po_reg_or_fail (REG_TYPE_VFD); break;
7313 po_reg_or_goto (REG_TYPE_RN, try_rndmq);
7317 po_reg_or_goto (REG_TYPE_MQ, try_rnd);
7320 case OP_RND: po_reg_or_fail (REG_TYPE_VFD); break;
7322 po_reg_or_goto (REG_TYPE_VFC, coproc_reg);
7324 /* Also accept generic coprocessor regs for unknown registers. */
7326 po_reg_or_goto (REG_TYPE_CN, vpr_po);
7328 /* Also accept P0 or p0 for VPR.P0. Since P0 is already an
7329 existing register with a value of 0, this seems like the
7330 best way to parse P0. */
7332 if (strncasecmp (str, "P0", 2) == 0)
7335 inst.operands[i].isreg = 1;
7336 inst.operands[i].reg = 13;
7341 case OP_RMF: po_reg_or_fail (REG_TYPE_MVF); break;
7342 case OP_RMD: po_reg_or_fail (REG_TYPE_MVD); break;
7343 case OP_RMFX: po_reg_or_fail (REG_TYPE_MVFX); break;
7344 case OP_RMDX: po_reg_or_fail (REG_TYPE_MVDX); break;
7345 case OP_RMAX: po_reg_or_fail (REG_TYPE_MVAX); break;
7346 case OP_RMDS: po_reg_or_fail (REG_TYPE_DSPSC); break;
7347 case OP_RIWR: po_reg_or_fail (REG_TYPE_MMXWR); break;
7348 case OP_RIWC: po_reg_or_fail (REG_TYPE_MMXWC); break;
7349 case OP_RIWG: po_reg_or_fail (REG_TYPE_MMXWCG); break;
7350 case OP_RXA: po_reg_or_fail (REG_TYPE_XSCALE); break;
7353 po_reg_or_goto (REG_TYPE_MQ, try_nq);
7356 case OP_RNQ: po_reg_or_fail (REG_TYPE_NQ); break;
7357 case OP_RNSD: po_reg_or_fail (REG_TYPE_NSD); break;
7359 po_reg_or_goto (REG_TYPE_RN, try_rndqmq);
7364 po_reg_or_goto (REG_TYPE_MQ, try_rndq);
7368 case OP_RNDQ: po_reg_or_fail (REG_TYPE_NDQ); break;
7370 po_reg_or_goto (REG_TYPE_MQ, try_rvsd);
7373 case OP_RVSD: po_reg_or_fail (REG_TYPE_VFSD); break;
7375 po_reg_or_goto (REG_TYPE_VFSD, try_cond);
7378 case OP_RNSDQ: po_reg_or_fail (REG_TYPE_NSDQ); break;
7380 po_reg_or_goto (REG_TYPE_RN, try_mq);
7385 po_reg_or_goto (REG_TYPE_MQ, try_nsdq2);
7388 po_reg_or_fail (REG_TYPE_NSDQ);
7392 po_reg_or_goto (REG_TYPE_RN, try_rmq);
7396 po_reg_or_fail (REG_TYPE_MQ);
7398 /* Neon scalar. Using an element size of 8 means that some invalid
7399 scalars are accepted here, so deal with those in later code. */
7400 case OP_RNSC: po_scalar_or_goto (8, failure, REG_TYPE_VFD); break;
7404 po_reg_or_goto (REG_TYPE_NDQ, try_imm0);
7407 po_imm_or_fail (0, 0, TRUE);
7412 po_reg_or_goto (REG_TYPE_VFSD, try_imm0);
7416 po_reg_or_goto (REG_TYPE_MQ, try_rsvd_fi0);
7421 po_reg_or_goto (REG_TYPE_VFSD, try_ifimm0);
7424 if (parse_ifimm_zero (&str))
7425 inst.operands[i].imm = 0;
7429 = _("only floating point zero is allowed as immediate value");
7437 po_scalar_or_goto (8, try_rr, REG_TYPE_VFD);
7440 po_reg_or_fail (REG_TYPE_RN);
7444 case OP_RNSDQ_RNSC_MQ_RR:
7445 po_reg_or_goto (REG_TYPE_RN, try_rnsdq_rnsc_mq);
7448 case OP_RNSDQ_RNSC_MQ:
7449 po_reg_or_goto (REG_TYPE_MQ, try_rnsdq_rnsc);
7454 po_scalar_or_goto (8, try_nsdq, REG_TYPE_VFD);
7458 po_reg_or_fail (REG_TYPE_NSDQ);
7465 po_scalar_or_goto (8, try_s_scalar, REG_TYPE_VFD);
7468 po_scalar_or_goto (4, try_nsd, REG_TYPE_VFS);
7471 po_reg_or_fail (REG_TYPE_NSD);
7475 case OP_RNDQMQ_RNSC_RR:
7476 po_reg_or_goto (REG_TYPE_MQ, try_rndq_rnsc_rr);
7479 case OP_RNDQ_RNSC_RR:
7480 po_reg_or_goto (REG_TYPE_RN, try_rndq_rnsc);
7482 case OP_RNDQMQ_RNSC:
7483 po_reg_or_goto (REG_TYPE_MQ, try_rndq_rnsc);
7488 po_scalar_or_goto (8, try_ndq, REG_TYPE_VFD);
7491 po_reg_or_fail (REG_TYPE_NDQ);
7497 po_scalar_or_goto (8, try_vfd, REG_TYPE_VFD);
7500 po_reg_or_fail (REG_TYPE_VFD);
7505 /* WARNING: parse_neon_mov can move the operand counter, i. If we're
7506 not careful then bad things might happen. */
7507 po_misc_or_fail (parse_neon_mov (&str, &i) == FAIL);
7510 case OP_RNDQMQ_Ibig:
7511 po_reg_or_goto (REG_TYPE_MQ, try_rndq_ibig);
7516 po_reg_or_goto (REG_TYPE_NDQ, try_immbig);
7519 /* There's a possibility of getting a 64-bit immediate here, so
7520 we need special handling. */
7521 if (parse_big_immediate (&str, i, NULL, /*allow_symbol_p=*/FALSE)
7524 inst.error = _("immediate value is out of range");
7530 case OP_RNDQMQ_I63b_RR:
7531 po_reg_or_goto (REG_TYPE_MQ, try_rndq_i63b_rr);
7534 po_reg_or_goto (REG_TYPE_RN, try_rndq_i63b);
7539 po_reg_or_goto (REG_TYPE_NDQ, try_shimm);
7542 po_imm_or_fail (0, 63, TRUE);
7547 po_char_or_fail ('[');
7548 po_reg_or_fail (REG_TYPE_RN);
7549 po_char_or_fail (']');
7555 po_reg_or_fail (REG_TYPE_RN);
7556 if (skip_past_char (&str, '!') == SUCCESS)
7557 inst.operands[i].writeback = 1;
7561 case OP_I7: po_imm_or_fail ( 0, 7, FALSE); break;
7562 case OP_I15: po_imm_or_fail ( 0, 15, FALSE); break;
7563 case OP_I16: po_imm_or_fail ( 1, 16, FALSE); break;
7564 case OP_I16z: po_imm_or_fail ( 0, 16, FALSE); break;
7565 case OP_I31: po_imm_or_fail ( 0, 31, FALSE); break;
7566 case OP_I32: po_imm_or_fail ( 1, 32, FALSE); break;
7567 case OP_I32z: po_imm_or_fail ( 0, 32, FALSE); break;
7568 case OP_I48_I64: po_imm1_or_imm2_or_fail (48, 64, FALSE); break;
7569 case OP_I63s: po_imm_or_fail (-64, 63, FALSE); break;
7570 case OP_I63: po_imm_or_fail ( 0, 63, FALSE); break;
7571 case OP_I64: po_imm_or_fail ( 1, 64, FALSE); break;
7572 case OP_I64z: po_imm_or_fail ( 0, 64, FALSE); break;
7573 case OP_I255: po_imm_or_fail ( 0, 255, FALSE); break;
7575 case OP_I4b: po_imm_or_fail ( 1, 4, TRUE); break;
7577 case OP_I7b: po_imm_or_fail ( 0, 7, TRUE); break;
7578 case OP_I15b: po_imm_or_fail ( 0, 15, TRUE); break;
7580 case OP_I31b: po_imm_or_fail ( 0, 31, TRUE); break;
7581 case OP_oI32b: po_imm_or_fail ( 1, 32, TRUE); break;
7582 case OP_oI32z: po_imm_or_fail ( 0, 32, TRUE); break;
7583 case OP_oIffffb: po_imm_or_fail ( 0, 0xffff, TRUE); break;
7585 /* Immediate variants */
7587 po_char_or_fail ('{');
7588 po_imm_or_fail (0, 255, TRUE);
7589 po_char_or_fail ('}');
7593 /* The expression parser chokes on a trailing !, so we have
7594 to find it first and zap it. */
7597 while (*s && *s != ',')
7602 inst.operands[i].writeback = 1;
7604 po_imm_or_fail (0, 31, TRUE);
7612 po_misc_or_fail (my_get_expression (&inst.relocs[0].exp, &str,
7617 po_misc_or_fail (my_get_expression (&inst.relocs[0].exp, &str,
7622 po_misc_or_fail (my_get_expression (&inst.relocs[0].exp, &str,
7624 if (inst.relocs[0].exp.X_op == O_symbol)
7626 val = parse_reloc (&str);
7629 inst.error = _("unrecognized relocation suffix");
7632 else if (val != BFD_RELOC_UNUSED)
7634 inst.operands[i].imm = val;
7635 inst.operands[i].hasreloc = 1;
7641 po_misc_or_fail (my_get_expression (&inst.relocs[i].exp, &str,
7643 if (inst.relocs[i].exp.X_op == O_symbol)
7645 inst.operands[i].hasreloc = 1;
7647 else if (inst.relocs[i].exp.X_op == O_constant)
7649 inst.operands[i].imm = inst.relocs[i].exp.X_add_number;
7650 inst.operands[i].hasreloc = 0;
7654 /* Operand for MOVW or MOVT. */
7656 po_misc_or_fail (parse_half (&str));
7659 /* Register or expression. */
7660 case OP_RR_EXr: po_reg_or_goto (REG_TYPE_RN, EXPr); break;
7661 case OP_RR_EXi: po_reg_or_goto (REG_TYPE_RN, EXPi); break;
7663 /* Register or immediate. */
7664 case OP_RRnpc_I0: po_reg_or_goto (REG_TYPE_RN, I0); break;
7665 I0: po_imm_or_fail (0, 0, FALSE); break;
7667 case OP_RRnpcsp_I32: po_reg_or_goto (REG_TYPE_RN, I32); break;
7668 I32: po_imm_or_fail (1, 32, FALSE); break;
7670 case OP_RF_IF: po_reg_or_goto (REG_TYPE_FN, IF); break;
7672 if (!is_immediate_prefix (*str))
7675 val = parse_fpa_immediate (&str);
7678 /* FPA immediates are encoded as registers 8-15.
7679 parse_fpa_immediate has already applied the offset. */
7680 inst.operands[i].reg = val;
7681 inst.operands[i].isreg = 1;
7684 case OP_RIWR_I32z: po_reg_or_goto (REG_TYPE_MMXWR, I32z); break;
7685 I32z: po_imm_or_fail (0, 32, FALSE); break;
7687 /* Two kinds of register. */
7690 struct reg_entry *rege = arm_reg_parse_multi (&str);
7692 || (rege->type != REG_TYPE_MMXWR
7693 && rege->type != REG_TYPE_MMXWC
7694 && rege->type != REG_TYPE_MMXWCG))
7696 inst.error = _("iWMMXt data or control register expected");
7699 inst.operands[i].reg = rege->number;
7700 inst.operands[i].isreg = (rege->type == REG_TYPE_MMXWR);
7706 struct reg_entry *rege = arm_reg_parse_multi (&str);
7708 || (rege->type != REG_TYPE_MMXWC
7709 && rege->type != REG_TYPE_MMXWCG))
7711 inst.error = _("iWMMXt control register expected");
7714 inst.operands[i].reg = rege->number;
7715 inst.operands[i].isreg = 1;
7720 case OP_CPSF: val = parse_cps_flags (&str); break;
7721 case OP_ENDI: val = parse_endian_specifier (&str); break;
7722 case OP_oROR: val = parse_ror (&str); break;
7724 case OP_COND: val = parse_cond (&str); break;
7725 case OP_oBARRIER_I15:
7726 po_barrier_or_imm (str); break;
7728 if (parse_immediate (&str, &val, 0, 15, TRUE) == FAIL)
7734 po_reg_or_goto (REG_TYPE_RNB, try_psr);
7735 if (!ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_virt))
7737 inst.error = _("Banked registers are not available with this "
7743 val = parse_psr (&str, op_parse_code == OP_wPSR);
7747 po_reg_or_goto (REG_TYPE_VFSD, try_sysreg);
7750 val = parse_sys_vldr_vstr (&str);
7754 po_reg_or_goto (REG_TYPE_RN, try_apsr);
7757 /* Parse "APSR_nvzc" operand (for FMSTAT-equivalent MRS
7759 if (strncasecmp (str, "APSR_", 5) == 0)
7766 case 'c': found = (found & 1) ? 16 : found | 1; break;
7767 case 'n': found = (found & 2) ? 16 : found | 2; break;
7768 case 'z': found = (found & 4) ? 16 : found | 4; break;
7769 case 'v': found = (found & 8) ? 16 : found | 8; break;
7770 default: found = 16;
7774 inst.operands[i].isvec = 1;
7775 /* APSR_nzcv is encoded in instructions as if it were the REG_PC. */
7776 inst.operands[i].reg = REG_PC;
7783 po_misc_or_fail (parse_tb (&str));
7786 /* Register lists. */
7788 val = parse_reg_list (&str, REGLIST_RN);
7791 inst.operands[i].writeback = 1;
7797 val = parse_reg_list (&str, REGLIST_CLRM);
7801 val = parse_vfp_reg_list (&str, &inst.operands[i].reg, REGLIST_VFP_S,
7806 val = parse_vfp_reg_list (&str, &inst.operands[i].reg, REGLIST_VFP_D,
7811 /* Allow Q registers too. */
7812 val = parse_vfp_reg_list (&str, &inst.operands[i].reg,
7813 REGLIST_NEON_D, &partial_match);
7817 val = parse_vfp_reg_list (&str, &inst.operands[i].reg,
7818 REGLIST_VFP_S, &partial_match);
7819 inst.operands[i].issingle = 1;
7824 val = parse_vfp_reg_list (&str, &inst.operands[i].reg,
7825 REGLIST_VFP_D_VPR, &partial_match);
7826 if (val == FAIL && !partial_match)
7829 val = parse_vfp_reg_list (&str, &inst.operands[i].reg,
7830 REGLIST_VFP_S_VPR, &partial_match);
7831 inst.operands[i].issingle = 1;
7836 val = parse_vfp_reg_list (&str, &inst.operands[i].reg,
7837 REGLIST_NEON_D, &partial_match);
7842 val = parse_neon_el_struct_list (&str, &inst.operands[i].reg,
7843 1, &inst.operands[i].vectype);
7844 if (val != (((op_parse_code == OP_MSTRLST2) ? 3 : 7) << 5 | 0xe))
7848 val = parse_neon_el_struct_list (&str, &inst.operands[i].reg,
7849 0, &inst.operands[i].vectype);
7852 /* Addressing modes */
7854 po_misc_or_fail (parse_address_group_reloc (&str, i, GROUP_MVE));
7858 po_misc_or_fail (parse_address (&str, i));
7862 po_misc_or_fail_no_backtrack (
7863 parse_address_group_reloc (&str, i, GROUP_LDR));
7867 po_misc_or_fail_no_backtrack (
7868 parse_address_group_reloc (&str, i, GROUP_LDRS));
7872 po_misc_or_fail_no_backtrack (
7873 parse_address_group_reloc (&str, i, GROUP_LDC));
7877 po_misc_or_fail (parse_shifter_operand (&str, i));
7881 po_misc_or_fail_no_backtrack (
7882 parse_shifter_operand_group_reloc (&str, i));
7886 po_misc_or_fail (parse_shift (&str, i, SHIFT_LSL_IMMEDIATE));
7890 po_misc_or_fail (parse_shift (&str, i, SHIFT_ASR_IMMEDIATE));
7894 po_misc_or_fail (parse_shift (&str, i, SHIFT_LSL_OR_ASR_IMMEDIATE));
7899 po_reg_or_goto (REG_TYPE_MQ, try_rr_zr);
7904 po_reg_or_goto (REG_TYPE_RN, ZR);
7907 po_reg_or_fail (REG_TYPE_ZR);
7911 as_fatal (_("unhandled operand code %d"), op_parse_code);
7914 /* Various value-based sanity checks and shared operations. We
7915 do not signal immediate failures for the register constraints;
7916 this allows a syntax error to take precedence. */
7917 switch (op_parse_code)
7925 if (inst.operands[i].isreg && inst.operands[i].reg == REG_PC)
7926 inst.error = BAD_PC;
7931 case OP_RRnpcsp_I32:
7932 if (inst.operands[i].isreg)
7934 if (inst.operands[i].reg == REG_PC)
7935 inst.error = BAD_PC;
7936 else if (inst.operands[i].reg == REG_SP
7937 /* The restriction on Rd/Rt/Rt2 on Thumb mode has been
7938 relaxed since ARMv8-A. */
7939 && !ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_v8))
7942 inst.error = BAD_SP;
7948 if (inst.operands[i].isreg
7949 && inst.operands[i].reg == REG_PC
7950 && (inst.operands[i].writeback || thumb))
7951 inst.error = BAD_PC;
7956 if (inst.operands[i].isreg)
7966 case OP_oBARRIER_I15:
7979 inst.operands[i].imm = val;
7984 if (inst.operands[i].reg != REG_LR)
7985 inst.error = _("operand must be LR register");
7991 if (!inst.operands[i].iszr && inst.operands[i].reg == REG_PC)
7992 inst.error = BAD_PC;
7996 if (inst.operands[i].isreg
7997 && (inst.operands[i].reg & 0x00000001) != 0)
7998 inst.error = BAD_ODD;
8002 if (inst.operands[i].isreg)
8004 if ((inst.operands[i].reg & 0x00000001) != 1)
8005 inst.error = BAD_EVEN;
8006 else if (inst.operands[i].reg == REG_SP)
8007 as_tsktsk (MVE_BAD_SP);
8008 else if (inst.operands[i].reg == REG_PC)
8009 inst.error = BAD_PC;
8017 /* If we get here, this operand was successfully parsed. */
8018 inst.operands[i].present = 1;
8022 inst.error = BAD_ARGS;
8027 /* The parse routine should already have set inst.error, but set a
8028 default here just in case. */
8030 inst.error = BAD_SYNTAX;
8034 /* Do not backtrack over a trailing optional argument that
8035 absorbed some text. We will only fail again, with the
8036 'garbage following instruction' error message, which is
8037 probably less helpful than the current one. */
8038 if (backtrack_index == i && backtrack_pos != str
8039 && upat[i+1] == OP_stop)
8042 inst.error = BAD_SYNTAX;
8046 /* Try again, skipping the optional argument at backtrack_pos. */
8047 str = backtrack_pos;
8048 inst.error = backtrack_error;
8049 inst.operands[backtrack_index].present = 0;
8050 i = backtrack_index;
8054 /* Check that we have parsed all the arguments. */
8055 if (*str != '\0' && !inst.error)
8056 inst.error = _("garbage following instruction");
8058 return inst.error ? FAIL : SUCCESS;
8061 #undef po_char_or_fail
8062 #undef po_reg_or_fail
8063 #undef po_reg_or_goto
8064 #undef po_imm_or_fail
8065 #undef po_scalar_or_fail
8066 #undef po_barrier_or_imm
8068 /* Shorthand macro for instruction encoding functions issuing errors. */
8069 #define constraint(expr, err) \
8080 /* Reject "bad registers" for Thumb-2 instructions. Many Thumb-2
8081 instructions are unpredictable if these registers are used. This
8082 is the BadReg predicate in ARM's Thumb-2 documentation.
8084 Before ARMv8-A, REG_PC and REG_SP were not allowed in quite a few
8085 places, while the restriction on REG_SP was relaxed since ARMv8-A. */
8086 #define reject_bad_reg(reg) \
8088 if (reg == REG_PC) \
8090 inst.error = BAD_PC; \
8093 else if (reg == REG_SP \
8094 && !ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_v8)) \
8096 inst.error = BAD_SP; \
8101 /* If REG is R13 (the stack pointer), warn that its use is
8103 #define warn_deprecated_sp(reg) \
8105 if (warn_on_deprecated && reg == REG_SP) \
8106 as_tsktsk (_("use of r13 is deprecated")); \
8109 /* Functions for operand encoding. ARM, then Thumb. */
8111 #define rotate_left(v, n) (v << (n & 31) | v >> ((32 - n) & 31))
8113 /* If the current inst is scalar ARMv8.2 fp16 instruction, do special encoding.
8115 The only binary encoding difference is the Coprocessor number. Coprocessor
8116 9 is used for half-precision calculations or conversions. The format of the
8117 instruction is the same as the equivalent Coprocessor 10 instruction that
8118 exists for Single-Precision operation. */
8121 do_scalar_fp16_v82_encode (void)
8123 if (inst.cond < COND_ALWAYS)
8124 as_warn (_("ARMv8.2 scalar fp16 instruction cannot be conditional,"
8125 " the behaviour is UNPREDICTABLE"));
8126 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_fp16),
8129 inst.instruction = (inst.instruction & 0xfffff0ff) | 0x900;
8130 mark_feature_used (&arm_ext_fp16);
8133 /* If VAL can be encoded in the immediate field of an ARM instruction,
8134 return the encoded form. Otherwise, return FAIL. */
8137 encode_arm_immediate (unsigned int val)
8144 for (i = 2; i < 32; i += 2)
8145 if ((a = rotate_left (val, i)) <= 0xff)
8146 return a | (i << 7); /* 12-bit pack: [shift-cnt,const]. */
8151 /* If VAL can be encoded in the immediate field of a Thumb32 instruction,
8152 return the encoded form. Otherwise, return FAIL. */
8154 encode_thumb32_immediate (unsigned int val)
8161 for (i = 1; i <= 24; i++)
8164 if ((val & ~(0xff << i)) == 0)
8165 return ((val >> i) & 0x7f) | ((32 - i) << 7);
8169 if (val == ((a << 16) | a))
8171 if (val == ((a << 24) | (a << 16) | (a << 8) | a))
8175 if (val == ((a << 16) | a))
8176 return 0x200 | (a >> 8);
8180 /* Encode a VFP SP or DP register number into inst.instruction. */
8183 encode_arm_vfp_reg (int reg, enum vfp_reg_pos pos)
8185 if ((pos == VFP_REG_Dd || pos == VFP_REG_Dn || pos == VFP_REG_Dm)
8188 if (ARM_CPU_HAS_FEATURE (cpu_variant, fpu_vfp_ext_d32))
8191 ARM_MERGE_FEATURE_SETS (thumb_arch_used, thumb_arch_used,
8194 ARM_MERGE_FEATURE_SETS (arm_arch_used, arm_arch_used,
8199 first_error (_("D register out of range for selected VFP version"));
8207 inst.instruction |= ((reg >> 1) << 12) | ((reg & 1) << 22);
8211 inst.instruction |= ((reg >> 1) << 16) | ((reg & 1) << 7);
8215 inst.instruction |= ((reg >> 1) << 0) | ((reg & 1) << 5);
8219 inst.instruction |= ((reg & 15) << 12) | ((reg >> 4) << 22);
8223 inst.instruction |= ((reg & 15) << 16) | ((reg >> 4) << 7);
8227 inst.instruction |= (reg & 15) | ((reg >> 4) << 5);
8235 /* Encode a <shift> in an ARM-format instruction. The immediate,
8236 if any, is handled by md_apply_fix. */
8238 encode_arm_shift (int i)
8240 /* register-shifted register. */
8241 if (inst.operands[i].immisreg)
8244 for (op_index = 0; op_index <= i; ++op_index)
8246 /* Check the operand only when it's presented. In pre-UAL syntax,
8247 if the destination register is the same as the first operand, two
8248 register form of the instruction can be used. */
8249 if (inst.operands[op_index].present && inst.operands[op_index].isreg
8250 && inst.operands[op_index].reg == REG_PC)
8251 as_warn (UNPRED_REG ("r15"));
8254 if (inst.operands[i].imm == REG_PC)
8255 as_warn (UNPRED_REG ("r15"));
8258 if (inst.operands[i].shift_kind == SHIFT_RRX)
8259 inst.instruction |= SHIFT_ROR << 5;
8262 inst.instruction |= inst.operands[i].shift_kind << 5;
8263 if (inst.operands[i].immisreg)
8265 inst.instruction |= SHIFT_BY_REG;
8266 inst.instruction |= inst.operands[i].imm << 8;
8269 inst.relocs[0].type = BFD_RELOC_ARM_SHIFT_IMM;
8274 encode_arm_shifter_operand (int i)
8276 if (inst.operands[i].isreg)
8278 inst.instruction |= inst.operands[i].reg;
8279 encode_arm_shift (i);
8283 inst.instruction |= INST_IMMEDIATE;
8284 if (inst.relocs[0].type != BFD_RELOC_ARM_IMMEDIATE)
8285 inst.instruction |= inst.operands[i].imm;
8289 /* Subroutine of encode_arm_addr_mode_2 and encode_arm_addr_mode_3. */
8291 encode_arm_addr_mode_common (int i, bfd_boolean is_t)
8294 Generate an error if the operand is not a register. */
8295 constraint (!inst.operands[i].isreg,
8296 _("Instruction does not support =N addresses"));
8298 inst.instruction |= inst.operands[i].reg << 16;
8300 if (inst.operands[i].preind)
8304 inst.error = _("instruction does not accept preindexed addressing");
8307 inst.instruction |= PRE_INDEX;
8308 if (inst.operands[i].writeback)
8309 inst.instruction |= WRITE_BACK;
8312 else if (inst.operands[i].postind)
8314 gas_assert (inst.operands[i].writeback);
8316 inst.instruction |= WRITE_BACK;
8318 else /* unindexed - only for coprocessor */
8320 inst.error = _("instruction does not accept unindexed addressing");
8324 if (((inst.instruction & WRITE_BACK) || !(inst.instruction & PRE_INDEX))
8325 && (((inst.instruction & 0x000f0000) >> 16)
8326 == ((inst.instruction & 0x0000f000) >> 12)))
8327 as_warn ((inst.instruction & LOAD_BIT)
8328 ? _("destination register same as write-back base")
8329 : _("source register same as write-back base"));
8332 /* inst.operands[i] was set up by parse_address. Encode it into an
8333 ARM-format mode 2 load or store instruction. If is_t is true,
8334 reject forms that cannot be used with a T instruction (i.e. not
8337 encode_arm_addr_mode_2 (int i, bfd_boolean is_t)
8339 const bfd_boolean is_pc = (inst.operands[i].reg == REG_PC);
8341 encode_arm_addr_mode_common (i, is_t);
8343 if (inst.operands[i].immisreg)
8345 constraint ((inst.operands[i].imm == REG_PC
8346 || (is_pc && inst.operands[i].writeback)),
8348 inst.instruction |= INST_IMMEDIATE; /* yes, this is backwards */
8349 inst.instruction |= inst.operands[i].imm;
8350 if (!inst.operands[i].negative)
8351 inst.instruction |= INDEX_UP;
8352 if (inst.operands[i].shifted)
8354 if (inst.operands[i].shift_kind == SHIFT_RRX)
8355 inst.instruction |= SHIFT_ROR << 5;
8358 inst.instruction |= inst.operands[i].shift_kind << 5;
8359 inst.relocs[0].type = BFD_RELOC_ARM_SHIFT_IMM;
8363 else /* immediate offset in inst.relocs[0] */
8365 if (is_pc && !inst.relocs[0].pc_rel)
8367 const bfd_boolean is_load = ((inst.instruction & LOAD_BIT) != 0);
8369 /* If is_t is TRUE, it's called from do_ldstt. ldrt/strt
8370 cannot use PC in addressing.
8371 PC cannot be used in writeback addressing, either. */
8372 constraint ((is_t || inst.operands[i].writeback),
8375 /* Use of PC in str is deprecated for ARMv7. */
8376 if (warn_on_deprecated
8378 && ARM_CPU_HAS_FEATURE (selected_cpu, arm_ext_v7))
8379 as_tsktsk (_("use of PC in this instruction is deprecated"));
8382 if (inst.relocs[0].type == BFD_RELOC_UNUSED)
8384 /* Prefer + for zero encoded value. */
8385 if (!inst.operands[i].negative)
8386 inst.instruction |= INDEX_UP;
8387 inst.relocs[0].type = BFD_RELOC_ARM_OFFSET_IMM;
8392 /* inst.operands[i] was set up by parse_address. Encode it into an
8393 ARM-format mode 3 load or store instruction. Reject forms that
8394 cannot be used with such instructions. If is_t is true, reject
8395 forms that cannot be used with a T instruction (i.e. not
8398 encode_arm_addr_mode_3 (int i, bfd_boolean is_t)
8400 if (inst.operands[i].immisreg && inst.operands[i].shifted)
8402 inst.error = _("instruction does not accept scaled register index");
8406 encode_arm_addr_mode_common (i, is_t);
8408 if (inst.operands[i].immisreg)
8410 constraint ((inst.operands[i].imm == REG_PC
8411 || (is_t && inst.operands[i].reg == REG_PC)),
8413 constraint (inst.operands[i].reg == REG_PC && inst.operands[i].writeback,
8415 inst.instruction |= inst.operands[i].imm;
8416 if (!inst.operands[i].negative)
8417 inst.instruction |= INDEX_UP;
8419 else /* immediate offset in inst.relocs[0] */
8421 constraint ((inst.operands[i].reg == REG_PC && !inst.relocs[0].pc_rel
8422 && inst.operands[i].writeback),
8424 inst.instruction |= HWOFFSET_IMM;
8425 if (inst.relocs[0].type == BFD_RELOC_UNUSED)
8427 /* Prefer + for zero encoded value. */
8428 if (!inst.operands[i].negative)
8429 inst.instruction |= INDEX_UP;
8431 inst.relocs[0].type = BFD_RELOC_ARM_OFFSET_IMM8;
8436 /* Write immediate bits [7:0] to the following locations:
8438 |28/24|23 19|18 16|15 4|3 0|
8439 | 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|
8441 This function is used by VMOV/VMVN/VORR/VBIC. */
8444 neon_write_immbits (unsigned immbits)
8446 inst.instruction |= immbits & 0xf;
8447 inst.instruction |= ((immbits >> 4) & 0x7) << 16;
8448 inst.instruction |= ((immbits >> 7) & 0x1) << (thumb_mode ? 28 : 24);
8451 /* Invert low-order SIZE bits of XHI:XLO. */
8454 neon_invert_size (unsigned *xlo, unsigned *xhi, int size)
8456 unsigned immlo = xlo ? *xlo : 0;
8457 unsigned immhi = xhi ? *xhi : 0;
8462 immlo = (~immlo) & 0xff;
8466 immlo = (~immlo) & 0xffff;
8470 immhi = (~immhi) & 0xffffffff;
8474 immlo = (~immlo) & 0xffffffff;
8488 /* True if IMM has form 0bAAAAAAAABBBBBBBBCCCCCCCCDDDDDDDD for bits
8492 neon_bits_same_in_bytes (unsigned imm)
8494 return ((imm & 0x000000ff) == 0 || (imm & 0x000000ff) == 0x000000ff)
8495 && ((imm & 0x0000ff00) == 0 || (imm & 0x0000ff00) == 0x0000ff00)
8496 && ((imm & 0x00ff0000) == 0 || (imm & 0x00ff0000) == 0x00ff0000)
8497 && ((imm & 0xff000000) == 0 || (imm & 0xff000000) == 0xff000000);
8500 /* For immediate of above form, return 0bABCD. */
8503 neon_squash_bits (unsigned imm)
8505 return (imm & 0x01) | ((imm & 0x0100) >> 7) | ((imm & 0x010000) >> 14)
8506 | ((imm & 0x01000000) >> 21);
8509 /* Compress quarter-float representation to 0b...000 abcdefgh. */
8512 neon_qfloat_bits (unsigned imm)
8514 return ((imm >> 19) & 0x7f) | ((imm >> 24) & 0x80);
8517 /* Returns CMODE. IMMBITS [7:0] is set to bits suitable for inserting into
8518 the instruction. *OP is passed as the initial value of the op field, and
8519 may be set to a different value depending on the constant (i.e.
8520 "MOV I64, 0bAAAAAAAABBBB..." which uses OP = 1 despite being MOV not
8521 MVN). If the immediate looks like a repeated pattern then also
8522 try smaller element sizes. */
8525 neon_cmode_for_move_imm (unsigned immlo, unsigned immhi, int float_p,
8526 unsigned *immbits, int *op, int size,
8527 enum neon_el_type type)
8529 /* Only permit float immediates (including 0.0/-0.0) if the operand type is
8531 if (type == NT_float && !float_p)
8534 if (type == NT_float && is_quarter_float (immlo) && immhi == 0)
8536 if (size != 32 || *op == 1)
8538 *immbits = neon_qfloat_bits (immlo);
8544 if (neon_bits_same_in_bytes (immhi)
8545 && neon_bits_same_in_bytes (immlo))
8549 *immbits = (neon_squash_bits (immhi) << 4)
8550 | neon_squash_bits (immlo);
8561 if (immlo == (immlo & 0x000000ff))
8566 else if (immlo == (immlo & 0x0000ff00))
8568 *immbits = immlo >> 8;
8571 else if (immlo == (immlo & 0x00ff0000))
8573 *immbits = immlo >> 16;
8576 else if (immlo == (immlo & 0xff000000))
8578 *immbits = immlo >> 24;
8581 else if (immlo == ((immlo & 0x0000ff00) | 0x000000ff))
8583 *immbits = (immlo >> 8) & 0xff;
8586 else if (immlo == ((immlo & 0x00ff0000) | 0x0000ffff))
8588 *immbits = (immlo >> 16) & 0xff;
8592 if ((immlo & 0xffff) != (immlo >> 16))
8599 if (immlo == (immlo & 0x000000ff))
8604 else if (immlo == (immlo & 0x0000ff00))
8606 *immbits = immlo >> 8;
8610 if ((immlo & 0xff) != (immlo >> 8))
8615 if (immlo == (immlo & 0x000000ff))
8617 /* Don't allow MVN with 8-bit immediate. */
8627 #if defined BFD_HOST_64_BIT
8628 /* Returns TRUE if double precision value V may be cast
8629 to single precision without loss of accuracy. */
8632 is_double_a_single (bfd_int64_t v)
8634 int exp = (int)((v >> 52) & 0x7FF);
8635 bfd_int64_t mantissa = (v & (bfd_int64_t)0xFFFFFFFFFFFFFULL);
8637 return (exp == 0 || exp == 0x7FF
8638 || (exp >= 1023 - 126 && exp <= 1023 + 127))
8639 && (mantissa & 0x1FFFFFFFl) == 0;
8642 /* Returns a double precision value casted to single precision
8643 (ignoring the least significant bits in exponent and mantissa). */
8646 double_to_single (bfd_int64_t v)
8648 int sign = (int) ((v >> 63) & 1l);
8649 int exp = (int) ((v >> 52) & 0x7FF);
8650 bfd_int64_t mantissa = (v & (bfd_int64_t)0xFFFFFFFFFFFFFULL);
8656 exp = exp - 1023 + 127;
8665 /* No denormalized numbers. */
8671 return (sign << 31) | (exp << 23) | mantissa;
8673 #endif /* BFD_HOST_64_BIT */
8682 static void do_vfp_nsyn_opcode (const char *);
8684 /* inst.relocs[0].exp describes an "=expr" load pseudo-operation.
8685 Determine whether it can be performed with a move instruction; if
8686 it can, convert inst.instruction to that move instruction and
8687 return TRUE; if it can't, convert inst.instruction to a literal-pool
8688 load and return FALSE. If this is not a valid thing to do in the
8689 current context, set inst.error and return TRUE.
8691 inst.operands[i] describes the destination register. */
8694 move_or_literal_pool (int i, enum lit_type t, bfd_boolean mode_3)
8697 bfd_boolean thumb_p = (t == CONST_THUMB);
8698 bfd_boolean arm_p = (t == CONST_ARM);
8701 tbit = (inst.instruction > 0xffff) ? THUMB2_LOAD_BIT : THUMB_LOAD_BIT;
8705 if ((inst.instruction & tbit) == 0)
8707 inst.error = _("invalid pseudo operation");
8711 if (inst.relocs[0].exp.X_op != O_constant
8712 && inst.relocs[0].exp.X_op != O_symbol
8713 && inst.relocs[0].exp.X_op != O_big)
8715 inst.error = _("constant expression expected");
8719 if (inst.relocs[0].exp.X_op == O_constant
8720 || inst.relocs[0].exp.X_op == O_big)
8722 #if defined BFD_HOST_64_BIT
8727 if (inst.relocs[0].exp.X_op == O_big)
8729 LITTLENUM_TYPE w[X_PRECISION];
8732 if (inst.relocs[0].exp.X_add_number == -1)
8734 gen_to_words (w, X_PRECISION, E_PRECISION);
8736 /* FIXME: Should we check words w[2..5] ? */
8741 #if defined BFD_HOST_64_BIT
8743 ((((((((bfd_int64_t) l[3] & LITTLENUM_MASK)
8744 << LITTLENUM_NUMBER_OF_BITS)
8745 | ((bfd_int64_t) l[2] & LITTLENUM_MASK))
8746 << LITTLENUM_NUMBER_OF_BITS)
8747 | ((bfd_int64_t) l[1] & LITTLENUM_MASK))
8748 << LITTLENUM_NUMBER_OF_BITS)
8749 | ((bfd_int64_t) l[0] & LITTLENUM_MASK));
8751 v = ((l[1] & LITTLENUM_MASK) << LITTLENUM_NUMBER_OF_BITS)
8752 | (l[0] & LITTLENUM_MASK);
8756 v = inst.relocs[0].exp.X_add_number;
8758 if (!inst.operands[i].issingle)
8762 /* LDR should not use lead in a flag-setting instruction being
8763 chosen so we do not check whether movs can be used. */
8765 if ((ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_v6t2)
8766 || ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_v6t2_v8m))
8767 && inst.operands[i].reg != 13
8768 && inst.operands[i].reg != 15)
8770 /* Check if on thumb2 it can be done with a mov.w, mvn or
8771 movw instruction. */
8772 unsigned int newimm;
8773 bfd_boolean isNegated;
8775 newimm = encode_thumb32_immediate (v);
8776 if (newimm != (unsigned int) FAIL)
8780 newimm = encode_thumb32_immediate (~v);
8781 if (newimm != (unsigned int) FAIL)
8785 /* The number can be loaded with a mov.w or mvn
8787 if (newimm != (unsigned int) FAIL
8788 && ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_v6t2))
8790 inst.instruction = (0xf04f0000 /* MOV.W. */
8791 | (inst.operands[i].reg << 8));
8792 /* Change to MOVN. */
8793 inst.instruction |= (isNegated ? 0x200000 : 0);
8794 inst.instruction |= (newimm & 0x800) << 15;
8795 inst.instruction |= (newimm & 0x700) << 4;
8796 inst.instruction |= (newimm & 0x0ff);
8799 /* The number can be loaded with a movw instruction. */
8800 else if ((v & ~0xFFFF) == 0
8801 && ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_v6t2_v8m))
8803 int imm = v & 0xFFFF;
8805 inst.instruction = 0xf2400000; /* MOVW. */
8806 inst.instruction |= (inst.operands[i].reg << 8);
8807 inst.instruction |= (imm & 0xf000) << 4;
8808 inst.instruction |= (imm & 0x0800) << 15;
8809 inst.instruction |= (imm & 0x0700) << 4;
8810 inst.instruction |= (imm & 0x00ff);
8811 /* In case this replacement is being done on Armv8-M
8812 Baseline we need to make sure to disable the
8813 instruction size check, as otherwise GAS will reject
8814 the use of this T32 instruction. */
8822 int value = encode_arm_immediate (v);
8826 /* This can be done with a mov instruction. */
8827 inst.instruction &= LITERAL_MASK;
8828 inst.instruction |= INST_IMMEDIATE | (OPCODE_MOV << DATA_OP_SHIFT);
8829 inst.instruction |= value & 0xfff;
8833 value = encode_arm_immediate (~ v);
8836 /* This can be done with a mvn instruction. */
8837 inst.instruction &= LITERAL_MASK;
8838 inst.instruction |= INST_IMMEDIATE | (OPCODE_MVN << DATA_OP_SHIFT);
8839 inst.instruction |= value & 0xfff;
8843 else if (t == CONST_VEC && ARM_CPU_HAS_FEATURE (cpu_variant, fpu_neon_ext_v1))
8846 unsigned immbits = 0;
8847 unsigned immlo = inst.operands[1].imm;
8848 unsigned immhi = inst.operands[1].regisimm
8849 ? inst.operands[1].reg
8850 : inst.relocs[0].exp.X_unsigned
8852 : ((bfd_int64_t)((int) immlo)) >> 32;
8853 int cmode = neon_cmode_for_move_imm (immlo, immhi, FALSE, &immbits,
8854 &op, 64, NT_invtype);
8858 neon_invert_size (&immlo, &immhi, 64);
8860 cmode = neon_cmode_for_move_imm (immlo, immhi, FALSE, &immbits,
8861 &op, 64, NT_invtype);
8866 inst.instruction = (inst.instruction & VLDR_VMOV_SAME)
8872 /* Fill other bits in vmov encoding for both thumb and arm. */
8874 inst.instruction |= (0x7U << 29) | (0xF << 24);
8876 inst.instruction |= (0xFU << 28) | (0x1 << 25);
8877 neon_write_immbits (immbits);
8885 /* Check if vldr Rx, =constant could be optimized to vmov Rx, #constant. */
8886 if (inst.operands[i].issingle
8887 && is_quarter_float (inst.operands[1].imm)
8888 && ARM_CPU_HAS_FEATURE (cpu_variant, fpu_vfp_ext_v3xd))
8890 inst.operands[1].imm =
8891 neon_qfloat_bits (v);
8892 do_vfp_nsyn_opcode ("fconsts");
8896 /* If our host does not support a 64-bit type then we cannot perform
8897 the following optimization. This mean that there will be a
8898 discrepancy between the output produced by an assembler built for
8899 a 32-bit-only host and the output produced from a 64-bit host, but
8900 this cannot be helped. */
8901 #if defined BFD_HOST_64_BIT
8902 else if (!inst.operands[1].issingle
8903 && ARM_CPU_HAS_FEATURE (cpu_variant, fpu_vfp_ext_v3))
8905 if (is_double_a_single (v)
8906 && is_quarter_float (double_to_single (v)))
8908 inst.operands[1].imm =
8909 neon_qfloat_bits (double_to_single (v));
8910 do_vfp_nsyn_opcode ("fconstd");
8918 if (add_to_lit_pool ((!inst.operands[i].isvec
8919 || inst.operands[i].issingle) ? 4 : 8) == FAIL)
8922 inst.operands[1].reg = REG_PC;
8923 inst.operands[1].isreg = 1;
8924 inst.operands[1].preind = 1;
8925 inst.relocs[0].pc_rel = 1;
8926 inst.relocs[0].type = (thumb_p
8927 ? BFD_RELOC_ARM_THUMB_OFFSET
8929 ? BFD_RELOC_ARM_HWLITERAL
8930 : BFD_RELOC_ARM_LITERAL));
8934 /* inst.operands[i] was set up by parse_address. Encode it into an
8935 ARM-format instruction. Reject all forms which cannot be encoded
8936 into a coprocessor load/store instruction. If wb_ok is false,
8937 reject use of writeback; if unind_ok is false, reject use of
8938 unindexed addressing. If reloc_override is not 0, use it instead
8939 of BFD_ARM_CP_OFF_IMM, unless the initial relocation is a group one
8940 (in which case it is preserved). */
8943 encode_arm_cp_address (int i, int wb_ok, int unind_ok, int reloc_override)
8945 if (!inst.operands[i].isreg)
8948 if (! inst.operands[0].isvec)
8950 inst.error = _("invalid co-processor operand");
8953 if (move_or_literal_pool (0, CONST_VEC, /*mode_3=*/FALSE))
8957 inst.instruction |= inst.operands[i].reg << 16;
8959 gas_assert (!(inst.operands[i].preind && inst.operands[i].postind));
8961 if (!inst.operands[i].preind && !inst.operands[i].postind) /* unindexed */
8963 gas_assert (!inst.operands[i].writeback);
8966 inst.error = _("instruction does not support unindexed addressing");
8969 inst.instruction |= inst.operands[i].imm;
8970 inst.instruction |= INDEX_UP;
8974 if (inst.operands[i].preind)
8975 inst.instruction |= PRE_INDEX;
8977 if (inst.operands[i].writeback)
8979 if (inst.operands[i].reg == REG_PC)
8981 inst.error = _("pc may not be used with write-back");
8986 inst.error = _("instruction does not support writeback");
8989 inst.instruction |= WRITE_BACK;
8993 inst.relocs[0].type = (bfd_reloc_code_real_type) reloc_override;
8994 else if ((inst.relocs[0].type < BFD_RELOC_ARM_ALU_PC_G0_NC
8995 || inst.relocs[0].type > BFD_RELOC_ARM_LDC_SB_G2)
8996 && inst.relocs[0].type != BFD_RELOC_ARM_LDR_PC_G0)
8999 inst.relocs[0].type = BFD_RELOC_ARM_T32_CP_OFF_IMM;
9001 inst.relocs[0].type = BFD_RELOC_ARM_CP_OFF_IMM;
9004 /* Prefer + for zero encoded value. */
9005 if (!inst.operands[i].negative)
9006 inst.instruction |= INDEX_UP;
9011 /* Functions for instruction encoding, sorted by sub-architecture.
9012 First some generics; their names are taken from the conventional
9013 bit positions for register arguments in ARM format instructions. */
9023 inst.instruction |= inst.operands[0].reg << 12;
9029 inst.instruction |= inst.operands[0].reg << 16;
9035 inst.instruction |= inst.operands[0].reg << 12;
9036 inst.instruction |= inst.operands[1].reg;
9042 inst.instruction |= inst.operands[0].reg;
9043 inst.instruction |= inst.operands[1].reg << 16;
9049 inst.instruction |= inst.operands[0].reg << 12;
9050 inst.instruction |= inst.operands[1].reg << 16;
9056 inst.instruction |= inst.operands[0].reg << 16;
9057 inst.instruction |= inst.operands[1].reg << 12;
9063 inst.instruction |= inst.operands[0].reg << 8;
9064 inst.instruction |= inst.operands[1].reg << 16;
9068 check_obsolete (const arm_feature_set *feature, const char *msg)
9070 if (ARM_CPU_IS_ANY (cpu_variant))
9072 as_tsktsk ("%s", msg);
9075 else if (ARM_CPU_HAS_FEATURE (cpu_variant, *feature))
9087 unsigned Rn = inst.operands[2].reg;
9088 /* Enforce restrictions on SWP instruction. */
9089 if ((inst.instruction & 0x0fbfffff) == 0x01000090)
9091 constraint (Rn == inst.operands[0].reg || Rn == inst.operands[1].reg,
9092 _("Rn must not overlap other operands"));
9094 /* SWP{b} is obsolete for ARMv8-A, and deprecated for ARMv6* and ARMv7.
9096 if (!check_obsolete (&arm_ext_v8,
9097 _("swp{b} use is obsoleted for ARMv8 and later"))
9098 && warn_on_deprecated
9099 && ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_v6))
9100 as_tsktsk (_("swp{b} use is deprecated for ARMv6 and ARMv7"));
9103 inst.instruction |= inst.operands[0].reg << 12;
9104 inst.instruction |= inst.operands[1].reg;
9105 inst.instruction |= Rn << 16;
9111 inst.instruction |= inst.operands[0].reg << 12;
9112 inst.instruction |= inst.operands[1].reg << 16;
9113 inst.instruction |= inst.operands[2].reg;
9119 constraint ((inst.operands[2].reg == REG_PC), BAD_PC);
9120 constraint (((inst.relocs[0].exp.X_op != O_constant
9121 && inst.relocs[0].exp.X_op != O_illegal)
9122 || inst.relocs[0].exp.X_add_number != 0),
9124 inst.instruction |= inst.operands[0].reg;
9125 inst.instruction |= inst.operands[1].reg << 12;
9126 inst.instruction |= inst.operands[2].reg << 16;
9132 inst.instruction |= inst.operands[0].imm;
9138 inst.instruction |= inst.operands[0].reg << 12;
9139 encode_arm_cp_address (1, TRUE, TRUE, 0);
9142 /* ARM instructions, in alphabetical order by function name (except
9143 that wrapper functions appear immediately after the function they
9146 /* This is a pseudo-op of the form "adr rd, label" to be converted
9147 into a relative address of the form "add rd, pc, #label-.-8". */
9152 inst.instruction |= (inst.operands[0].reg << 12); /* Rd */
9154 /* Frag hacking will turn this into a sub instruction if the offset turns
9155 out to be negative. */
9156 inst.relocs[0].type = BFD_RELOC_ARM_IMMEDIATE;
9157 inst.relocs[0].pc_rel = 1;
9158 inst.relocs[0].exp.X_add_number -= 8;
9160 if (support_interwork
9161 && inst.relocs[0].exp.X_op == O_symbol
9162 && inst.relocs[0].exp.X_add_symbol != NULL
9163 && S_IS_DEFINED (inst.relocs[0].exp.X_add_symbol)
9164 && THUMB_IS_FUNC (inst.relocs[0].exp.X_add_symbol))
9165 inst.relocs[0].exp.X_add_number |= 1;
9168 /* This is a pseudo-op of the form "adrl rd, label" to be converted
9169 into a relative address of the form:
9170 add rd, pc, #low(label-.-8)"
9171 add rd, rd, #high(label-.-8)" */
9176 inst.instruction |= (inst.operands[0].reg << 12); /* Rd */
9178 /* Frag hacking will turn this into a sub instruction if the offset turns
9179 out to be negative. */
9180 inst.relocs[0].type = BFD_RELOC_ARM_ADRL_IMMEDIATE;
9181 inst.relocs[0].pc_rel = 1;
9182 inst.size = INSN_SIZE * 2;
9183 inst.relocs[0].exp.X_add_number -= 8;
9185 if (support_interwork
9186 && inst.relocs[0].exp.X_op == O_symbol
9187 && inst.relocs[0].exp.X_add_symbol != NULL
9188 && S_IS_DEFINED (inst.relocs[0].exp.X_add_symbol)
9189 && THUMB_IS_FUNC (inst.relocs[0].exp.X_add_symbol))
9190 inst.relocs[0].exp.X_add_number |= 1;
9196 constraint (inst.relocs[0].type >= BFD_RELOC_ARM_THUMB_ALU_ABS_G0_NC
9197 && inst.relocs[0].type <= BFD_RELOC_ARM_THUMB_ALU_ABS_G3_NC ,
9199 if (!inst.operands[1].present)
9200 inst.operands[1].reg = inst.operands[0].reg;
9201 inst.instruction |= inst.operands[0].reg << 12;
9202 inst.instruction |= inst.operands[1].reg << 16;
9203 encode_arm_shifter_operand (2);
9209 if (inst.operands[0].present)
9210 inst.instruction |= inst.operands[0].imm;
9212 inst.instruction |= 0xf;
9218 unsigned int msb = inst.operands[1].imm + inst.operands[2].imm;
9219 constraint (msb > 32, _("bit-field extends past end of register"));
9220 /* The instruction encoding stores the LSB and MSB,
9221 not the LSB and width. */
9222 inst.instruction |= inst.operands[0].reg << 12;
9223 inst.instruction |= inst.operands[1].imm << 7;
9224 inst.instruction |= (msb - 1) << 16;
9232 /* #0 in second position is alternative syntax for bfc, which is
9233 the same instruction but with REG_PC in the Rm field. */
9234 if (!inst.operands[1].isreg)
9235 inst.operands[1].reg = REG_PC;
9237 msb = inst.operands[2].imm + inst.operands[3].imm;
9238 constraint (msb > 32, _("bit-field extends past end of register"));
9239 /* The instruction encoding stores the LSB and MSB,
9240 not the LSB and width. */
9241 inst.instruction |= inst.operands[0].reg << 12;
9242 inst.instruction |= inst.operands[1].reg;
9243 inst.instruction |= inst.operands[2].imm << 7;
9244 inst.instruction |= (msb - 1) << 16;
9250 constraint (inst.operands[2].imm + inst.operands[3].imm > 32,
9251 _("bit-field extends past end of register"));
9252 inst.instruction |= inst.operands[0].reg << 12;
9253 inst.instruction |= inst.operands[1].reg;
9254 inst.instruction |= inst.operands[2].imm << 7;
9255 inst.instruction |= (inst.operands[3].imm - 1) << 16;
9258 /* ARM V5 breakpoint instruction (argument parse)
9259 BKPT <16 bit unsigned immediate>
9260 Instruction is not conditional.
9261 The bit pattern given in insns[] has the COND_ALWAYS condition,
9262 and it is an error if the caller tried to override that. */
9267 /* Top 12 of 16 bits to bits 19:8. */
9268 inst.instruction |= (inst.operands[0].imm & 0xfff0) << 4;
9270 /* Bottom 4 of 16 bits to bits 3:0. */
9271 inst.instruction |= inst.operands[0].imm & 0xf;
9275 encode_branch (int default_reloc)
9277 if (inst.operands[0].hasreloc)
9279 constraint (inst.operands[0].imm != BFD_RELOC_ARM_PLT32
9280 && inst.operands[0].imm != BFD_RELOC_ARM_TLS_CALL,
9281 _("the only valid suffixes here are '(plt)' and '(tlscall)'"));
9282 inst.relocs[0].type = inst.operands[0].imm == BFD_RELOC_ARM_PLT32
9283 ? BFD_RELOC_ARM_PLT32
9284 : thumb_mode ? BFD_RELOC_ARM_THM_TLS_CALL : BFD_RELOC_ARM_TLS_CALL;
9287 inst.relocs[0].type = (bfd_reloc_code_real_type) default_reloc;
9288 inst.relocs[0].pc_rel = 1;
9295 if (EF_ARM_EABI_VERSION (meabi_flags) >= EF_ARM_EABI_VER4)
9296 encode_branch (BFD_RELOC_ARM_PCREL_JUMP);
9299 encode_branch (BFD_RELOC_ARM_PCREL_BRANCH);
9306 if (EF_ARM_EABI_VERSION (meabi_flags) >= EF_ARM_EABI_VER4)
9308 if (inst.cond == COND_ALWAYS)
9309 encode_branch (BFD_RELOC_ARM_PCREL_CALL);
9311 encode_branch (BFD_RELOC_ARM_PCREL_JUMP);
9315 encode_branch (BFD_RELOC_ARM_PCREL_BRANCH);
9318 /* ARM V5 branch-link-exchange instruction (argument parse)
9319 BLX <target_addr> ie BLX(1)
9320 BLX{<condition>} <Rm> ie BLX(2)
9321 Unfortunately, there are two different opcodes for this mnemonic.
9322 So, the insns[].value is not used, and the code here zaps values
9323 into inst.instruction.
9324 Also, the <target_addr> can be 25 bits, hence has its own reloc. */
9329 if (inst.operands[0].isreg)
9331 /* Arg is a register; the opcode provided by insns[] is correct.
9332 It is not illegal to do "blx pc", just useless. */
9333 if (inst.operands[0].reg == REG_PC)
9334 as_tsktsk (_("use of r15 in blx in ARM mode is not really useful"));
9336 inst.instruction |= inst.operands[0].reg;
9340 /* Arg is an address; this instruction cannot be executed
9341 conditionally, and the opcode must be adjusted.
9342 We retain the BFD_RELOC_ARM_PCREL_BLX till the very end
9343 where we generate out a BFD_RELOC_ARM_PCREL_CALL instead. */
9344 constraint (inst.cond != COND_ALWAYS, BAD_COND);
9345 inst.instruction = 0xfa000000;
9346 encode_branch (BFD_RELOC_ARM_PCREL_BLX);
9353 bfd_boolean want_reloc;
9355 if (inst.operands[0].reg == REG_PC)
9356 as_tsktsk (_("use of r15 in bx in ARM mode is not really useful"));
9358 inst.instruction |= inst.operands[0].reg;
9359 /* Output R_ARM_V4BX relocations if is an EABI object that looks like
9360 it is for ARMv4t or earlier. */
9361 want_reloc = !ARM_CPU_HAS_FEATURE (selected_cpu, arm_ext_v5);
9362 if (!ARM_FEATURE_ZERO (selected_object_arch)
9363 && !ARM_CPU_HAS_FEATURE (selected_object_arch, arm_ext_v5))
9367 if (EF_ARM_EABI_VERSION (meabi_flags) < EF_ARM_EABI_VER4)
9372 inst.relocs[0].type = BFD_RELOC_ARM_V4BX;
9376 /* ARM v5TEJ. Jump to Jazelle code. */
9381 if (inst.operands[0].reg == REG_PC)
9382 as_tsktsk (_("use of r15 in bxj is not really useful"));
9384 inst.instruction |= inst.operands[0].reg;
9387 /* Co-processor data operation:
9388 CDP{cond} <coproc>, <opcode_1>, <CRd>, <CRn>, <CRm>{, <opcode_2>}
9389 CDP2 <coproc>, <opcode_1>, <CRd>, <CRn>, <CRm>{, <opcode_2>} */
9393 inst.instruction |= inst.operands[0].reg << 8;
9394 inst.instruction |= inst.operands[1].imm << 20;
9395 inst.instruction |= inst.operands[2].reg << 12;
9396 inst.instruction |= inst.operands[3].reg << 16;
9397 inst.instruction |= inst.operands[4].reg;
9398 inst.instruction |= inst.operands[5].imm << 5;
9404 inst.instruction |= inst.operands[0].reg << 16;
9405 encode_arm_shifter_operand (1);
9408 /* Transfer between coprocessor and ARM registers.
9409 MRC{cond} <coproc>, <opcode_1>, <Rd>, <CRn>, <CRm>{, <opcode_2>}
9414 No special properties. */
9416 struct deprecated_coproc_regs_s
9423 arm_feature_set deprecated;
9424 arm_feature_set obsoleted;
9425 const char *dep_msg;
9426 const char *obs_msg;
9429 #define DEPR_ACCESS_V8 \
9430 N_("This coprocessor register access is deprecated in ARMv8")
9432 /* Table of all deprecated coprocessor registers. */
9433 static struct deprecated_coproc_regs_s deprecated_coproc_regs[] =
9435 {15, 0, 7, 10, 5, /* CP15DMB. */
9436 ARM_FEATURE_CORE_LOW (ARM_EXT_V8), ARM_ARCH_NONE,
9437 DEPR_ACCESS_V8, NULL},
9438 {15, 0, 7, 10, 4, /* CP15DSB. */
9439 ARM_FEATURE_CORE_LOW (ARM_EXT_V8), ARM_ARCH_NONE,
9440 DEPR_ACCESS_V8, NULL},
9441 {15, 0, 7, 5, 4, /* CP15ISB. */
9442 ARM_FEATURE_CORE_LOW (ARM_EXT_V8), ARM_ARCH_NONE,
9443 DEPR_ACCESS_V8, NULL},
9444 {14, 6, 1, 0, 0, /* TEEHBR. */
9445 ARM_FEATURE_CORE_LOW (ARM_EXT_V8), ARM_ARCH_NONE,
9446 DEPR_ACCESS_V8, NULL},
9447 {14, 6, 0, 0, 0, /* TEECR. */
9448 ARM_FEATURE_CORE_LOW (ARM_EXT_V8), ARM_ARCH_NONE,
9449 DEPR_ACCESS_V8, NULL},
9452 #undef DEPR_ACCESS_V8
9454 static const size_t deprecated_coproc_reg_count =
9455 sizeof (deprecated_coproc_regs) / sizeof (deprecated_coproc_regs[0]);
9463 Rd = inst.operands[2].reg;
9466 if (inst.instruction == 0xee000010
9467 || inst.instruction == 0xfe000010)
9469 reject_bad_reg (Rd);
9470 else if (!ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_v8))
9472 constraint (Rd == REG_SP, BAD_SP);
9477 if (inst.instruction == 0xe000010)
9478 constraint (Rd == REG_PC, BAD_PC);
9481 for (i = 0; i < deprecated_coproc_reg_count; ++i)
9483 const struct deprecated_coproc_regs_s *r =
9484 deprecated_coproc_regs + i;
9486 if (inst.operands[0].reg == r->cp
9487 && inst.operands[1].imm == r->opc1
9488 && inst.operands[3].reg == r->crn
9489 && inst.operands[4].reg == r->crm
9490 && inst.operands[5].imm == r->opc2)
9492 if (! ARM_CPU_IS_ANY (cpu_variant)
9493 && warn_on_deprecated
9494 && ARM_CPU_HAS_FEATURE (cpu_variant, r->deprecated))
9495 as_tsktsk ("%s", r->dep_msg);
9499 inst.instruction |= inst.operands[0].reg << 8;
9500 inst.instruction |= inst.operands[1].imm << 21;
9501 inst.instruction |= Rd << 12;
9502 inst.instruction |= inst.operands[3].reg << 16;
9503 inst.instruction |= inst.operands[4].reg;
9504 inst.instruction |= inst.operands[5].imm << 5;
9507 /* Transfer between coprocessor register and pair of ARM registers.
9508 MCRR{cond} <coproc>, <opcode>, <Rd>, <Rn>, <CRm>.
9513 Two XScale instructions are special cases of these:
9515 MAR{cond} acc0, <RdLo>, <RdHi> == MCRR{cond} p0, #0, <RdLo>, <RdHi>, c0
9516 MRA{cond} acc0, <RdLo>, <RdHi> == MRRC{cond} p0, #0, <RdLo>, <RdHi>, c0
9518 Result unpredictable if Rd or Rn is R15. */
9525 Rd = inst.operands[2].reg;
9526 Rn = inst.operands[3].reg;
9530 reject_bad_reg (Rd);
9531 reject_bad_reg (Rn);
9535 constraint (Rd == REG_PC, BAD_PC);
9536 constraint (Rn == REG_PC, BAD_PC);
9539 /* Only check the MRRC{2} variants. */
9540 if ((inst.instruction & 0x0FF00000) == 0x0C500000)
9542 /* If Rd == Rn, error that the operation is
9543 unpredictable (example MRRC p3,#1,r1,r1,c4). */
9544 constraint (Rd == Rn, BAD_OVERLAP);
9547 inst.instruction |= inst.operands[0].reg << 8;
9548 inst.instruction |= inst.operands[1].imm << 4;
9549 inst.instruction |= Rd << 12;
9550 inst.instruction |= Rn << 16;
9551 inst.instruction |= inst.operands[4].reg;
9557 inst.instruction |= inst.operands[0].imm << 6;
9558 if (inst.operands[1].present)
9560 inst.instruction |= CPSI_MMOD;
9561 inst.instruction |= inst.operands[1].imm;
9568 inst.instruction |= inst.operands[0].imm;
9574 unsigned Rd, Rn, Rm;
9576 Rd = inst.operands[0].reg;
9577 Rn = (inst.operands[1].present
9578 ? inst.operands[1].reg : Rd);
9579 Rm = inst.operands[2].reg;
9581 constraint ((Rd == REG_PC), BAD_PC);
9582 constraint ((Rn == REG_PC), BAD_PC);
9583 constraint ((Rm == REG_PC), BAD_PC);
9585 inst.instruction |= Rd << 16;
9586 inst.instruction |= Rn << 0;
9587 inst.instruction |= Rm << 8;
9593 /* There is no IT instruction in ARM mode. We
9594 process it to do the validation as if in
9595 thumb mode, just in case the code gets
9596 assembled for thumb using the unified syntax. */
9601 set_pred_insn_type (IT_INSN);
9602 now_pred.mask = (inst.instruction & 0xf) | 0x10;
9603 now_pred.cc = inst.operands[0].imm;
9607 /* If there is only one register in the register list,
9608 then return its register number. Otherwise return -1. */
9610 only_one_reg_in_list (int range)
9612 int i = ffs (range) - 1;
9613 return (i > 15 || range != (1 << i)) ? -1 : i;
9617 encode_ldmstm(int from_push_pop_mnem)
9619 int base_reg = inst.operands[0].reg;
9620 int range = inst.operands[1].imm;
9623 inst.instruction |= base_reg << 16;
9624 inst.instruction |= range;
9626 if (inst.operands[1].writeback)
9627 inst.instruction |= LDM_TYPE_2_OR_3;
9629 if (inst.operands[0].writeback)
9631 inst.instruction |= WRITE_BACK;
9632 /* Check for unpredictable uses of writeback. */
9633 if (inst.instruction & LOAD_BIT)
9635 /* Not allowed in LDM type 2. */
9636 if ((inst.instruction & LDM_TYPE_2_OR_3)
9637 && ((range & (1 << REG_PC)) == 0))
9638 as_warn (_("writeback of base register is UNPREDICTABLE"));
9639 /* Only allowed if base reg not in list for other types. */
9640 else if (range & (1 << base_reg))
9641 as_warn (_("writeback of base register when in register list is UNPREDICTABLE"));
9645 /* Not allowed for type 2. */
9646 if (inst.instruction & LDM_TYPE_2_OR_3)
9647 as_warn (_("writeback of base register is UNPREDICTABLE"));
9648 /* Only allowed if base reg not in list, or first in list. */
9649 else if ((range & (1 << base_reg))
9650 && (range & ((1 << base_reg) - 1)))
9651 as_warn (_("if writeback register is in list, it must be the lowest reg in the list"));
9655 /* If PUSH/POP has only one register, then use the A2 encoding. */
9656 one_reg = only_one_reg_in_list (range);
9657 if (from_push_pop_mnem && one_reg >= 0)
9659 int is_push = (inst.instruction & A_PUSH_POP_OP_MASK) == A1_OPCODE_PUSH;
9661 if (is_push && one_reg == 13 /* SP */)
9662 /* PR 22483: The A2 encoding cannot be used when
9663 pushing the stack pointer as this is UNPREDICTABLE. */
9666 inst.instruction &= A_COND_MASK;
9667 inst.instruction |= is_push ? A2_OPCODE_PUSH : A2_OPCODE_POP;
9668 inst.instruction |= one_reg << 12;
9675 encode_ldmstm (/*from_push_pop_mnem=*/FALSE);
9678 /* ARMv5TE load-consecutive (argument parse)
9687 constraint (inst.operands[0].reg % 2 != 0,
9688 _("first transfer register must be even"));
9689 constraint (inst.operands[1].present
9690 && inst.operands[1].reg != inst.operands[0].reg + 1,
9691 _("can only transfer two consecutive registers"));
9692 constraint (inst.operands[0].reg == REG_LR, _("r14 not allowed here"));
9693 constraint (!inst.operands[2].isreg, _("'[' expected"));
9695 if (!inst.operands[1].present)
9696 inst.operands[1].reg = inst.operands[0].reg + 1;
9698 /* encode_arm_addr_mode_3 will diagnose overlap between the base
9699 register and the first register written; we have to diagnose
9700 overlap between the base and the second register written here. */
9702 if (inst.operands[2].reg == inst.operands[1].reg
9703 && (inst.operands[2].writeback || inst.operands[2].postind))
9704 as_warn (_("base register written back, and overlaps "
9705 "second transfer register"));
9707 if (!(inst.instruction & V4_STR_BIT))
9709 /* For an index-register load, the index register must not overlap the
9710 destination (even if not write-back). */
9711 if (inst.operands[2].immisreg
9712 && ((unsigned) inst.operands[2].imm == inst.operands[0].reg
9713 || (unsigned) inst.operands[2].imm == inst.operands[1].reg))
9714 as_warn (_("index register overlaps transfer register"));
9716 inst.instruction |= inst.operands[0].reg << 12;
9717 encode_arm_addr_mode_3 (2, /*is_t=*/FALSE);
9723 constraint (!inst.operands[1].isreg || !inst.operands[1].preind
9724 || inst.operands[1].postind || inst.operands[1].writeback
9725 || inst.operands[1].immisreg || inst.operands[1].shifted
9726 || inst.operands[1].negative
9727 /* This can arise if the programmer has written
9729 or if they have mistakenly used a register name as the last
9732 It is very difficult to distinguish between these two cases
9733 because "rX" might actually be a label. ie the register
9734 name has been occluded by a symbol of the same name. So we
9735 just generate a general 'bad addressing mode' type error
9736 message and leave it up to the programmer to discover the
9737 true cause and fix their mistake. */
9738 || (inst.operands[1].reg == REG_PC),
9741 constraint (inst.relocs[0].exp.X_op != O_constant
9742 || inst.relocs[0].exp.X_add_number != 0,
9743 _("offset must be zero in ARM encoding"));
9745 constraint ((inst.operands[1].reg == REG_PC), BAD_PC);
9747 inst.instruction |= inst.operands[0].reg << 12;
9748 inst.instruction |= inst.operands[1].reg << 16;
9749 inst.relocs[0].type = BFD_RELOC_UNUSED;
9755 constraint (inst.operands[0].reg % 2 != 0,
9756 _("even register required"));
9757 constraint (inst.operands[1].present
9758 && inst.operands[1].reg != inst.operands[0].reg + 1,
9759 _("can only load two consecutive registers"));
9760 /* If op 1 were present and equal to PC, this function wouldn't
9761 have been called in the first place. */
9762 constraint (inst.operands[0].reg == REG_LR, _("r14 not allowed here"));
9764 inst.instruction |= inst.operands[0].reg << 12;
9765 inst.instruction |= inst.operands[2].reg << 16;
9768 /* In both ARM and thumb state 'ldr pc, #imm' with an immediate
9769 which is not a multiple of four is UNPREDICTABLE. */
9771 check_ldr_r15_aligned (void)
9773 constraint (!(inst.operands[1].immisreg)
9774 && (inst.operands[0].reg == REG_PC
9775 && inst.operands[1].reg == REG_PC
9776 && (inst.relocs[0].exp.X_add_number & 0x3)),
9777 _("ldr to register 15 must be 4-byte aligned"));
9783 inst.instruction |= inst.operands[0].reg << 12;
9784 if (!inst.operands[1].isreg)
9785 if (move_or_literal_pool (0, CONST_ARM, /*mode_3=*/FALSE))
9787 encode_arm_addr_mode_2 (1, /*is_t=*/FALSE);
9788 check_ldr_r15_aligned ();
9794 /* ldrt/strt always use post-indexed addressing. Turn [Rn] into [Rn]! and
9796 if (inst.operands[1].preind)
9798 constraint (inst.relocs[0].exp.X_op != O_constant
9799 || inst.relocs[0].exp.X_add_number != 0,
9800 _("this instruction requires a post-indexed address"));
9802 inst.operands[1].preind = 0;
9803 inst.operands[1].postind = 1;
9804 inst.operands[1].writeback = 1;
9806 inst.instruction |= inst.operands[0].reg << 12;
9807 encode_arm_addr_mode_2 (1, /*is_t=*/TRUE);
9810 /* Halfword and signed-byte load/store operations. */
9815 constraint (inst.operands[0].reg == REG_PC, BAD_PC);
9816 inst.instruction |= inst.operands[0].reg << 12;
9817 if (!inst.operands[1].isreg)
9818 if (move_or_literal_pool (0, CONST_ARM, /*mode_3=*/TRUE))
9820 encode_arm_addr_mode_3 (1, /*is_t=*/FALSE);
9826 /* ldrt/strt always use post-indexed addressing. Turn [Rn] into [Rn]! and
9828 if (inst.operands[1].preind)
9830 constraint (inst.relocs[0].exp.X_op != O_constant
9831 || inst.relocs[0].exp.X_add_number != 0,
9832 _("this instruction requires a post-indexed address"));
9834 inst.operands[1].preind = 0;
9835 inst.operands[1].postind = 1;
9836 inst.operands[1].writeback = 1;
9838 inst.instruction |= inst.operands[0].reg << 12;
9839 encode_arm_addr_mode_3 (1, /*is_t=*/TRUE);
9842 /* Co-processor register load/store.
9843 Format: <LDC|STC>{cond}[L] CP#,CRd,<address> */
9847 inst.instruction |= inst.operands[0].reg << 8;
9848 inst.instruction |= inst.operands[1].reg << 12;
9849 encode_arm_cp_address (2, TRUE, TRUE, 0);
9855 /* This restriction does not apply to mls (nor to mla in v6 or later). */
9856 if (inst.operands[0].reg == inst.operands[1].reg
9857 && !ARM_CPU_HAS_FEATURE (selected_cpu, arm_ext_v6)
9858 && !(inst.instruction & 0x00400000))
9859 as_tsktsk (_("Rd and Rm should be different in mla"));
9861 inst.instruction |= inst.operands[0].reg << 16;
9862 inst.instruction |= inst.operands[1].reg;
9863 inst.instruction |= inst.operands[2].reg << 8;
9864 inst.instruction |= inst.operands[3].reg << 12;
9870 constraint (inst.relocs[0].type >= BFD_RELOC_ARM_THUMB_ALU_ABS_G0_NC
9871 && inst.relocs[0].type <= BFD_RELOC_ARM_THUMB_ALU_ABS_G3_NC ,
9873 inst.instruction |= inst.operands[0].reg << 12;
9874 encode_arm_shifter_operand (1);
9877 /* ARM V6T2 16-bit immediate register load: MOV[WT]{cond} Rd, #<imm16>. */
9884 top = (inst.instruction & 0x00400000) != 0;
9885 constraint (top && inst.relocs[0].type == BFD_RELOC_ARM_MOVW,
9886 _(":lower16: not allowed in this instruction"));
9887 constraint (!top && inst.relocs[0].type == BFD_RELOC_ARM_MOVT,
9888 _(":upper16: not allowed in this instruction"));
9889 inst.instruction |= inst.operands[0].reg << 12;
9890 if (inst.relocs[0].type == BFD_RELOC_UNUSED)
9892 imm = inst.relocs[0].exp.X_add_number;
9893 /* The value is in two pieces: 0:11, 16:19. */
9894 inst.instruction |= (imm & 0x00000fff);
9895 inst.instruction |= (imm & 0x0000f000) << 4;
9900 do_vfp_nsyn_mrs (void)
9902 if (inst.operands[0].isvec)
9904 if (inst.operands[1].reg != 1)
9905 first_error (_("operand 1 must be FPSCR"));
9906 memset (&inst.operands[0], '\0', sizeof (inst.operands[0]));
9907 memset (&inst.operands[1], '\0', sizeof (inst.operands[1]));
9908 do_vfp_nsyn_opcode ("fmstat");
9910 else if (inst.operands[1].isvec)
9911 do_vfp_nsyn_opcode ("fmrx");
9919 do_vfp_nsyn_msr (void)
9921 if (inst.operands[0].isvec)
9922 do_vfp_nsyn_opcode ("fmxr");
9932 unsigned Rt = inst.operands[0].reg;
9934 if (thumb_mode && Rt == REG_SP)
9936 inst.error = BAD_SP;
9940 switch (inst.operands[1].reg)
9942 /* MVFR2 is only valid for Armv8-A. */
9944 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant, fpu_vfp_ext_armv8),
9948 /* Check for new Armv8.1-M Mainline changes to <spec_reg>. */
9949 case 1: /* fpscr. */
9950 constraint (!(ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext)
9951 || ARM_CPU_HAS_FEATURE (cpu_variant, fpu_vfp_ext_v1xd)),
9955 case 14: /* fpcxt_ns. */
9956 case 15: /* fpcxt_s. */
9957 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_v8_1m_main),
9958 _("selected processor does not support instruction"));
9961 case 2: /* fpscr_nzcvqc. */
9964 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_v8_1m_main)
9965 || (!ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext)
9966 && !ARM_CPU_HAS_FEATURE (cpu_variant, fpu_vfp_ext_v1xd)),
9967 _("selected processor does not support instruction"));
9968 if (inst.operands[0].reg != 2
9969 && !ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext))
9970 as_warn (_("accessing MVE system register without MVE is UNPREDICTABLE"));
9977 /* APSR_ sets isvec. All other refs to PC are illegal. */
9978 if (!inst.operands[0].isvec && Rt == REG_PC)
9980 inst.error = BAD_PC;
9984 /* If we get through parsing the register name, we just insert the number
9985 generated into the instruction without further validation. */
9986 inst.instruction |= (inst.operands[1].reg << 16);
9987 inst.instruction |= (Rt << 12);
9993 unsigned Rt = inst.operands[1].reg;
9996 reject_bad_reg (Rt);
9997 else if (Rt == REG_PC)
9999 inst.error = BAD_PC;
10003 switch (inst.operands[0].reg)
10005 /* MVFR2 is only valid for Armv8-A. */
10007 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant, fpu_vfp_ext_armv8),
10011 /* Check for new Armv8.1-M Mainline changes to <spec_reg>. */
10012 case 1: /* fpcr. */
10013 constraint (!(ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext)
10014 || ARM_CPU_HAS_FEATURE (cpu_variant, fpu_vfp_ext_v1xd)),
10018 case 14: /* fpcxt_ns. */
10019 case 15: /* fpcxt_s. */
10020 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_v8_1m_main),
10021 _("selected processor does not support instruction"));
10024 case 2: /* fpscr_nzcvqc. */
10025 case 12: /* vpr. */
10027 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_v8_1m_main)
10028 || (!ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext)
10029 && !ARM_CPU_HAS_FEATURE (cpu_variant, fpu_vfp_ext_v1xd)),
10030 _("selected processor does not support instruction"));
10031 if (inst.operands[0].reg != 2
10032 && !ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext))
10033 as_warn (_("accessing MVE system register without MVE is UNPREDICTABLE"));
10040 /* If we get through parsing the register name, we just insert the number
10041 generated into the instruction without further validation. */
10042 inst.instruction |= (inst.operands[0].reg << 16);
10043 inst.instruction |= (Rt << 12);
10051 if (do_vfp_nsyn_mrs () == SUCCESS)
10054 constraint (inst.operands[0].reg == REG_PC, BAD_PC);
10055 inst.instruction |= inst.operands[0].reg << 12;
10057 if (inst.operands[1].isreg)
10059 br = inst.operands[1].reg;
10060 if (((br & 0x200) == 0) && ((br & 0xf0000) != 0xf0000))
10061 as_bad (_("bad register for mrs"));
10065 /* mrs only accepts CPSR/SPSR/CPSR_all/SPSR_all. */
10066 constraint ((inst.operands[1].imm & (PSR_c|PSR_x|PSR_s|PSR_f))
10068 _("'APSR', 'CPSR' or 'SPSR' expected"));
10069 br = (15<<16) | (inst.operands[1].imm & SPSR_BIT);
10072 inst.instruction |= br;
10075 /* Two possible forms:
10076 "{C|S}PSR_<field>, Rm",
10077 "{C|S}PSR_f, #expression". */
10082 if (do_vfp_nsyn_msr () == SUCCESS)
10085 inst.instruction |= inst.operands[0].imm;
10086 if (inst.operands[1].isreg)
10087 inst.instruction |= inst.operands[1].reg;
10090 inst.instruction |= INST_IMMEDIATE;
10091 inst.relocs[0].type = BFD_RELOC_ARM_IMMEDIATE;
10092 inst.relocs[0].pc_rel = 0;
10099 constraint (inst.operands[2].reg == REG_PC, BAD_PC);
10101 if (!inst.operands[2].present)
10102 inst.operands[2].reg = inst.operands[0].reg;
10103 inst.instruction |= inst.operands[0].reg << 16;
10104 inst.instruction |= inst.operands[1].reg;
10105 inst.instruction |= inst.operands[2].reg << 8;
10107 if (inst.operands[0].reg == inst.operands[1].reg
10108 && !ARM_CPU_HAS_FEATURE (selected_cpu, arm_ext_v6))
10109 as_tsktsk (_("Rd and Rm should be different in mul"));
10112 /* Long Multiply Parser
10113 UMULL RdLo, RdHi, Rm, Rs
10114 SMULL RdLo, RdHi, Rm, Rs
10115 UMLAL RdLo, RdHi, Rm, Rs
10116 SMLAL RdLo, RdHi, Rm, Rs. */
10121 inst.instruction |= inst.operands[0].reg << 12;
10122 inst.instruction |= inst.operands[1].reg << 16;
10123 inst.instruction |= inst.operands[2].reg;
10124 inst.instruction |= inst.operands[3].reg << 8;
10126 /* rdhi and rdlo must be different. */
10127 if (inst.operands[0].reg == inst.operands[1].reg)
10128 as_tsktsk (_("rdhi and rdlo must be different"));
10130 /* rdhi, rdlo and rm must all be different before armv6. */
10131 if ((inst.operands[0].reg == inst.operands[2].reg
10132 || inst.operands[1].reg == inst.operands[2].reg)
10133 && !ARM_CPU_HAS_FEATURE (selected_cpu, arm_ext_v6))
10134 as_tsktsk (_("rdhi, rdlo and rm must all be different"));
10140 if (inst.operands[0].present
10141 || ARM_CPU_HAS_FEATURE (selected_cpu, arm_ext_v6k))
10143 /* Architectural NOP hints are CPSR sets with no bits selected. */
10144 inst.instruction &= 0xf0000000;
10145 inst.instruction |= 0x0320f000;
10146 if (inst.operands[0].present)
10147 inst.instruction |= inst.operands[0].imm;
10151 /* ARM V6 Pack Halfword Bottom Top instruction (argument parse).
10152 PKHBT {<cond>} <Rd>, <Rn>, <Rm> {, LSL #<shift_imm>}
10153 Condition defaults to COND_ALWAYS.
10154 Error if Rd, Rn or Rm are R15. */
10159 inst.instruction |= inst.operands[0].reg << 12;
10160 inst.instruction |= inst.operands[1].reg << 16;
10161 inst.instruction |= inst.operands[2].reg;
10162 if (inst.operands[3].present)
10163 encode_arm_shift (3);
10166 /* ARM V6 PKHTB (Argument Parse). */
10171 if (!inst.operands[3].present)
10173 /* If the shift specifier is omitted, turn the instruction
10174 into pkhbt rd, rm, rn. */
10175 inst.instruction &= 0xfff00010;
10176 inst.instruction |= inst.operands[0].reg << 12;
10177 inst.instruction |= inst.operands[1].reg;
10178 inst.instruction |= inst.operands[2].reg << 16;
10182 inst.instruction |= inst.operands[0].reg << 12;
10183 inst.instruction |= inst.operands[1].reg << 16;
10184 inst.instruction |= inst.operands[2].reg;
10185 encode_arm_shift (3);
10189 /* ARMv5TE: Preload-Cache
10190 MP Extensions: Preload for write
10194 Syntactically, like LDR with B=1, W=0, L=1. */
10199 constraint (!inst.operands[0].isreg,
10200 _("'[' expected after PLD mnemonic"));
10201 constraint (inst.operands[0].postind,
10202 _("post-indexed expression used in preload instruction"));
10203 constraint (inst.operands[0].writeback,
10204 _("writeback used in preload instruction"));
10205 constraint (!inst.operands[0].preind,
10206 _("unindexed addressing used in preload instruction"));
10207 encode_arm_addr_mode_2 (0, /*is_t=*/FALSE);
10210 /* ARMv7: PLI <addr_mode> */
10214 constraint (!inst.operands[0].isreg,
10215 _("'[' expected after PLI mnemonic"));
10216 constraint (inst.operands[0].postind,
10217 _("post-indexed expression used in preload instruction"));
10218 constraint (inst.operands[0].writeback,
10219 _("writeback used in preload instruction"));
10220 constraint (!inst.operands[0].preind,
10221 _("unindexed addressing used in preload instruction"));
10222 encode_arm_addr_mode_2 (0, /*is_t=*/FALSE);
10223 inst.instruction &= ~PRE_INDEX;
10229 constraint (inst.operands[0].writeback,
10230 _("push/pop do not support {reglist}^"));
10231 inst.operands[1] = inst.operands[0];
10232 memset (&inst.operands[0], 0, sizeof inst.operands[0]);
10233 inst.operands[0].isreg = 1;
10234 inst.operands[0].writeback = 1;
10235 inst.operands[0].reg = REG_SP;
10236 encode_ldmstm (/*from_push_pop_mnem=*/TRUE);
10239 /* ARM V6 RFE (Return from Exception) loads the PC and CPSR from the
10240 word at the specified address and the following word
10242 Unconditionally executed.
10243 Error if Rn is R15. */
10248 inst.instruction |= inst.operands[0].reg << 16;
10249 if (inst.operands[0].writeback)
10250 inst.instruction |= WRITE_BACK;
10253 /* ARM V6 ssat (argument parse). */
10258 inst.instruction |= inst.operands[0].reg << 12;
10259 inst.instruction |= (inst.operands[1].imm - 1) << 16;
10260 inst.instruction |= inst.operands[2].reg;
10262 if (inst.operands[3].present)
10263 encode_arm_shift (3);
10266 /* ARM V6 usat (argument parse). */
10271 inst.instruction |= inst.operands[0].reg << 12;
10272 inst.instruction |= inst.operands[1].imm << 16;
10273 inst.instruction |= inst.operands[2].reg;
10275 if (inst.operands[3].present)
10276 encode_arm_shift (3);
10279 /* ARM V6 ssat16 (argument parse). */
10284 inst.instruction |= inst.operands[0].reg << 12;
10285 inst.instruction |= ((inst.operands[1].imm - 1) << 16);
10286 inst.instruction |= inst.operands[2].reg;
10292 inst.instruction |= inst.operands[0].reg << 12;
10293 inst.instruction |= inst.operands[1].imm << 16;
10294 inst.instruction |= inst.operands[2].reg;
10297 /* ARM V6 SETEND (argument parse). Sets the E bit in the CPSR while
10298 preserving the other bits.
10300 setend <endian_specifier>, where <endian_specifier> is either
10306 if (warn_on_deprecated
10307 && ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_v8))
10308 as_tsktsk (_("setend use is deprecated for ARMv8"));
10310 if (inst.operands[0].imm)
10311 inst.instruction |= 0x200;
10317 unsigned int Rm = (inst.operands[1].present
10318 ? inst.operands[1].reg
10319 : inst.operands[0].reg);
10321 inst.instruction |= inst.operands[0].reg << 12;
10322 inst.instruction |= Rm;
10323 if (inst.operands[2].isreg) /* Rd, {Rm,} Rs */
10325 inst.instruction |= inst.operands[2].reg << 8;
10326 inst.instruction |= SHIFT_BY_REG;
10327 /* PR 12854: Error on extraneous shifts. */
10328 constraint (inst.operands[2].shifted,
10329 _("extraneous shift as part of operand to shift insn"));
10332 inst.relocs[0].type = BFD_RELOC_ARM_SHIFT_IMM;
10338 unsigned int value = inst.relocs[0].exp.X_add_number;
10339 constraint (value > 0xf, _("immediate too large (bigger than 0xF)"));
10341 inst.relocs[0].type = BFD_RELOC_ARM_SMC;
10342 inst.relocs[0].pc_rel = 0;
10348 inst.relocs[0].type = BFD_RELOC_ARM_HVC;
10349 inst.relocs[0].pc_rel = 0;
10355 inst.relocs[0].type = BFD_RELOC_ARM_SWI;
10356 inst.relocs[0].pc_rel = 0;
10362 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_pan),
10363 _("selected processor does not support SETPAN instruction"));
10365 inst.instruction |= ((inst.operands[0].imm & 1) << 9);
10371 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_pan),
10372 _("selected processor does not support SETPAN instruction"));
10374 inst.instruction |= (inst.operands[0].imm << 3);
10377 /* ARM V5E (El Segundo) signed-multiply-accumulate (argument parse)
10378 SMLAxy{cond} Rd,Rm,Rs,Rn
10379 SMLAWy{cond} Rd,Rm,Rs,Rn
10380 Error if any register is R15. */
10385 inst.instruction |= inst.operands[0].reg << 16;
10386 inst.instruction |= inst.operands[1].reg;
10387 inst.instruction |= inst.operands[2].reg << 8;
10388 inst.instruction |= inst.operands[3].reg << 12;
10391 /* ARM V5E (El Segundo) signed-multiply-accumulate-long (argument parse)
10392 SMLALxy{cond} Rdlo,Rdhi,Rm,Rs
10393 Error if any register is R15.
10394 Warning if Rdlo == Rdhi. */
10399 inst.instruction |= inst.operands[0].reg << 12;
10400 inst.instruction |= inst.operands[1].reg << 16;
10401 inst.instruction |= inst.operands[2].reg;
10402 inst.instruction |= inst.operands[3].reg << 8;
10404 if (inst.operands[0].reg == inst.operands[1].reg)
10405 as_tsktsk (_("rdhi and rdlo must be different"));
10408 /* ARM V5E (El Segundo) signed-multiply (argument parse)
10409 SMULxy{cond} Rd,Rm,Rs
10410 Error if any register is R15. */
10415 inst.instruction |= inst.operands[0].reg << 16;
10416 inst.instruction |= inst.operands[1].reg;
10417 inst.instruction |= inst.operands[2].reg << 8;
10420 /* ARM V6 srs (argument parse). The variable fields in the encoding are
10421 the same for both ARM and Thumb-2. */
10428 if (inst.operands[0].present)
10430 reg = inst.operands[0].reg;
10431 constraint (reg != REG_SP, _("SRS base register must be r13"));
10436 inst.instruction |= reg << 16;
10437 inst.instruction |= inst.operands[1].imm;
10438 if (inst.operands[0].writeback || inst.operands[1].writeback)
10439 inst.instruction |= WRITE_BACK;
10442 /* ARM V6 strex (argument parse). */
10447 constraint (!inst.operands[2].isreg || !inst.operands[2].preind
10448 || inst.operands[2].postind || inst.operands[2].writeback
10449 || inst.operands[2].immisreg || inst.operands[2].shifted
10450 || inst.operands[2].negative
10451 /* See comment in do_ldrex(). */
10452 || (inst.operands[2].reg == REG_PC),
10455 constraint (inst.operands[0].reg == inst.operands[1].reg
10456 || inst.operands[0].reg == inst.operands[2].reg, BAD_OVERLAP);
10458 constraint (inst.relocs[0].exp.X_op != O_constant
10459 || inst.relocs[0].exp.X_add_number != 0,
10460 _("offset must be zero in ARM encoding"));
10462 inst.instruction |= inst.operands[0].reg << 12;
10463 inst.instruction |= inst.operands[1].reg;
10464 inst.instruction |= inst.operands[2].reg << 16;
10465 inst.relocs[0].type = BFD_RELOC_UNUSED;
10469 do_t_strexbh (void)
10471 constraint (!inst.operands[2].isreg || !inst.operands[2].preind
10472 || inst.operands[2].postind || inst.operands[2].writeback
10473 || inst.operands[2].immisreg || inst.operands[2].shifted
10474 || inst.operands[2].negative,
10477 constraint (inst.operands[0].reg == inst.operands[1].reg
10478 || inst.operands[0].reg == inst.operands[2].reg, BAD_OVERLAP);
10486 constraint (inst.operands[1].reg % 2 != 0,
10487 _("even register required"));
10488 constraint (inst.operands[2].present
10489 && inst.operands[2].reg != inst.operands[1].reg + 1,
10490 _("can only store two consecutive registers"));
10491 /* If op 2 were present and equal to PC, this function wouldn't
10492 have been called in the first place. */
10493 constraint (inst.operands[1].reg == REG_LR, _("r14 not allowed here"));
10495 constraint (inst.operands[0].reg == inst.operands[1].reg
10496 || inst.operands[0].reg == inst.operands[1].reg + 1
10497 || inst.operands[0].reg == inst.operands[3].reg,
10500 inst.instruction |= inst.operands[0].reg << 12;
10501 inst.instruction |= inst.operands[1].reg;
10502 inst.instruction |= inst.operands[3].reg << 16;
10509 constraint (inst.operands[0].reg == inst.operands[1].reg
10510 || inst.operands[0].reg == inst.operands[2].reg, BAD_OVERLAP);
10518 constraint (inst.operands[0].reg == inst.operands[1].reg
10519 || inst.operands[0].reg == inst.operands[2].reg, BAD_OVERLAP);
10524 /* ARM V6 SXTAH extracts a 16-bit value from a register, sign
10525 extends it to 32-bits, and adds the result to a value in another
10526 register. You can specify a rotation by 0, 8, 16, or 24 bits
10527 before extracting the 16-bit value.
10528 SXTAH{<cond>} <Rd>, <Rn>, <Rm>{, <rotation>}
10529 Condition defaults to COND_ALWAYS.
10530 Error if any register uses R15. */
10535 inst.instruction |= inst.operands[0].reg << 12;
10536 inst.instruction |= inst.operands[1].reg << 16;
10537 inst.instruction |= inst.operands[2].reg;
10538 inst.instruction |= inst.operands[3].imm << 10;
10543 SXTH {<cond>} <Rd>, <Rm>{, <rotation>}
10544 Condition defaults to COND_ALWAYS.
10545 Error if any register uses R15. */
10550 inst.instruction |= inst.operands[0].reg << 12;
10551 inst.instruction |= inst.operands[1].reg;
10552 inst.instruction |= inst.operands[2].imm << 10;
10555 /* VFP instructions. In a logical order: SP variant first, monad
10556 before dyad, arithmetic then move then load/store. */
10559 do_vfp_sp_monadic (void)
10561 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant, fpu_vfp_ext_v1xd)
10562 && !ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext),
10565 encode_arm_vfp_reg (inst.operands[0].reg, VFP_REG_Sd);
10566 encode_arm_vfp_reg (inst.operands[1].reg, VFP_REG_Sm);
10570 do_vfp_sp_dyadic (void)
10572 encode_arm_vfp_reg (inst.operands[0].reg, VFP_REG_Sd);
10573 encode_arm_vfp_reg (inst.operands[1].reg, VFP_REG_Sn);
10574 encode_arm_vfp_reg (inst.operands[2].reg, VFP_REG_Sm);
10578 do_vfp_sp_compare_z (void)
10580 encode_arm_vfp_reg (inst.operands[0].reg, VFP_REG_Sd);
10584 do_vfp_dp_sp_cvt (void)
10586 encode_arm_vfp_reg (inst.operands[0].reg, VFP_REG_Dd);
10587 encode_arm_vfp_reg (inst.operands[1].reg, VFP_REG_Sm);
10591 do_vfp_sp_dp_cvt (void)
10593 encode_arm_vfp_reg (inst.operands[0].reg, VFP_REG_Sd);
10594 encode_arm_vfp_reg (inst.operands[1].reg, VFP_REG_Dm);
10598 do_vfp_reg_from_sp (void)
10600 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant, fpu_vfp_ext_v1xd)
10601 && !ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext),
10604 inst.instruction |= inst.operands[0].reg << 12;
10605 encode_arm_vfp_reg (inst.operands[1].reg, VFP_REG_Sn);
10609 do_vfp_reg2_from_sp2 (void)
10611 constraint (inst.operands[2].imm != 2,
10612 _("only two consecutive VFP SP registers allowed here"));
10613 inst.instruction |= inst.operands[0].reg << 12;
10614 inst.instruction |= inst.operands[1].reg << 16;
10615 encode_arm_vfp_reg (inst.operands[2].reg, VFP_REG_Sm);
10619 do_vfp_sp_from_reg (void)
10621 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant, fpu_vfp_ext_v1xd)
10622 && !ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext),
10625 encode_arm_vfp_reg (inst.operands[0].reg, VFP_REG_Sn);
10626 inst.instruction |= inst.operands[1].reg << 12;
10630 do_vfp_sp2_from_reg2 (void)
10632 constraint (inst.operands[0].imm != 2,
10633 _("only two consecutive VFP SP registers allowed here"));
10634 encode_arm_vfp_reg (inst.operands[0].reg, VFP_REG_Sm);
10635 inst.instruction |= inst.operands[1].reg << 12;
10636 inst.instruction |= inst.operands[2].reg << 16;
10640 do_vfp_sp_ldst (void)
10642 encode_arm_vfp_reg (inst.operands[0].reg, VFP_REG_Sd);
10643 encode_arm_cp_address (1, FALSE, TRUE, 0);
10647 do_vfp_dp_ldst (void)
10649 encode_arm_vfp_reg (inst.operands[0].reg, VFP_REG_Dd);
10650 encode_arm_cp_address (1, FALSE, TRUE, 0);
10655 vfp_sp_ldstm (enum vfp_ldstm_type ldstm_type)
10657 if (inst.operands[0].writeback)
10658 inst.instruction |= WRITE_BACK;
10660 constraint (ldstm_type != VFP_LDSTMIA,
10661 _("this addressing mode requires base-register writeback"));
10662 inst.instruction |= inst.operands[0].reg << 16;
10663 encode_arm_vfp_reg (inst.operands[1].reg, VFP_REG_Sd);
10664 inst.instruction |= inst.operands[1].imm;
10668 vfp_dp_ldstm (enum vfp_ldstm_type ldstm_type)
10672 if (inst.operands[0].writeback)
10673 inst.instruction |= WRITE_BACK;
10675 constraint (ldstm_type != VFP_LDSTMIA && ldstm_type != VFP_LDSTMIAX,
10676 _("this addressing mode requires base-register writeback"));
10678 inst.instruction |= inst.operands[0].reg << 16;
10679 encode_arm_vfp_reg (inst.operands[1].reg, VFP_REG_Dd);
10681 count = inst.operands[1].imm << 1;
10682 if (ldstm_type == VFP_LDSTMIAX || ldstm_type == VFP_LDSTMDBX)
10685 inst.instruction |= count;
10689 do_vfp_sp_ldstmia (void)
10691 vfp_sp_ldstm (VFP_LDSTMIA);
10695 do_vfp_sp_ldstmdb (void)
10697 vfp_sp_ldstm (VFP_LDSTMDB);
10701 do_vfp_dp_ldstmia (void)
10703 vfp_dp_ldstm (VFP_LDSTMIA);
10707 do_vfp_dp_ldstmdb (void)
10709 vfp_dp_ldstm (VFP_LDSTMDB);
10713 do_vfp_xp_ldstmia (void)
10715 vfp_dp_ldstm (VFP_LDSTMIAX);
10719 do_vfp_xp_ldstmdb (void)
10721 vfp_dp_ldstm (VFP_LDSTMDBX);
10725 do_vfp_dp_rd_rm (void)
10727 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant, fpu_vfp_ext_v1)
10728 && !ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext),
10731 encode_arm_vfp_reg (inst.operands[0].reg, VFP_REG_Dd);
10732 encode_arm_vfp_reg (inst.operands[1].reg, VFP_REG_Dm);
10736 do_vfp_dp_rn_rd (void)
10738 encode_arm_vfp_reg (inst.operands[0].reg, VFP_REG_Dn);
10739 encode_arm_vfp_reg (inst.operands[1].reg, VFP_REG_Dd);
10743 do_vfp_dp_rd_rn (void)
10745 encode_arm_vfp_reg (inst.operands[0].reg, VFP_REG_Dd);
10746 encode_arm_vfp_reg (inst.operands[1].reg, VFP_REG_Dn);
10750 do_vfp_dp_rd_rn_rm (void)
10752 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant, fpu_vfp_ext_v2)
10753 && !ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext),
10756 encode_arm_vfp_reg (inst.operands[0].reg, VFP_REG_Dd);
10757 encode_arm_vfp_reg (inst.operands[1].reg, VFP_REG_Dn);
10758 encode_arm_vfp_reg (inst.operands[2].reg, VFP_REG_Dm);
10762 do_vfp_dp_rd (void)
10764 encode_arm_vfp_reg (inst.operands[0].reg, VFP_REG_Dd);
10768 do_vfp_dp_rm_rd_rn (void)
10770 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant, fpu_vfp_ext_v2)
10771 && !ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext),
10774 encode_arm_vfp_reg (inst.operands[0].reg, VFP_REG_Dm);
10775 encode_arm_vfp_reg (inst.operands[1].reg, VFP_REG_Dd);
10776 encode_arm_vfp_reg (inst.operands[2].reg, VFP_REG_Dn);
10779 /* VFPv3 instructions. */
10781 do_vfp_sp_const (void)
10783 encode_arm_vfp_reg (inst.operands[0].reg, VFP_REG_Sd);
10784 inst.instruction |= (inst.operands[1].imm & 0xf0) << 12;
10785 inst.instruction |= (inst.operands[1].imm & 0x0f);
10789 do_vfp_dp_const (void)
10791 encode_arm_vfp_reg (inst.operands[0].reg, VFP_REG_Dd);
10792 inst.instruction |= (inst.operands[1].imm & 0xf0) << 12;
10793 inst.instruction |= (inst.operands[1].imm & 0x0f);
10797 vfp_conv (int srcsize)
10799 int immbits = srcsize - inst.operands[1].imm;
10801 if (srcsize == 16 && !(immbits >= 0 && immbits <= srcsize))
10803 /* If srcsize is 16, inst.operands[1].imm must be in the range 0-16.
10804 i.e. immbits must be in range 0 - 16. */
10805 inst.error = _("immediate value out of range, expected range [0, 16]");
10808 else if (srcsize == 32 && !(immbits >= 0 && immbits < srcsize))
10810 /* If srcsize is 32, inst.operands[1].imm must be in the range 1-32.
10811 i.e. immbits must be in range 0 - 31. */
10812 inst.error = _("immediate value out of range, expected range [1, 32]");
10816 inst.instruction |= (immbits & 1) << 5;
10817 inst.instruction |= (immbits >> 1);
10821 do_vfp_sp_conv_16 (void)
10823 encode_arm_vfp_reg (inst.operands[0].reg, VFP_REG_Sd);
10828 do_vfp_dp_conv_16 (void)
10830 encode_arm_vfp_reg (inst.operands[0].reg, VFP_REG_Dd);
10835 do_vfp_sp_conv_32 (void)
10837 encode_arm_vfp_reg (inst.operands[0].reg, VFP_REG_Sd);
10842 do_vfp_dp_conv_32 (void)
10844 encode_arm_vfp_reg (inst.operands[0].reg, VFP_REG_Dd);
10848 /* FPA instructions. Also in a logical order. */
10853 inst.instruction |= inst.operands[0].reg << 16;
10854 inst.instruction |= inst.operands[1].reg;
10858 do_fpa_ldmstm (void)
10860 inst.instruction |= inst.operands[0].reg << 12;
10861 switch (inst.operands[1].imm)
10863 case 1: inst.instruction |= CP_T_X; break;
10864 case 2: inst.instruction |= CP_T_Y; break;
10865 case 3: inst.instruction |= CP_T_Y | CP_T_X; break;
10870 if (inst.instruction & (PRE_INDEX | INDEX_UP))
10872 /* The instruction specified "ea" or "fd", so we can only accept
10873 [Rn]{!}. The instruction does not really support stacking or
10874 unstacking, so we have to emulate these by setting appropriate
10875 bits and offsets. */
10876 constraint (inst.relocs[0].exp.X_op != O_constant
10877 || inst.relocs[0].exp.X_add_number != 0,
10878 _("this instruction does not support indexing"));
10880 if ((inst.instruction & PRE_INDEX) || inst.operands[2].writeback)
10881 inst.relocs[0].exp.X_add_number = 12 * inst.operands[1].imm;
10883 if (!(inst.instruction & INDEX_UP))
10884 inst.relocs[0].exp.X_add_number = -inst.relocs[0].exp.X_add_number;
10886 if (!(inst.instruction & PRE_INDEX) && inst.operands[2].writeback)
10888 inst.operands[2].preind = 0;
10889 inst.operands[2].postind = 1;
10893 encode_arm_cp_address (2, TRUE, TRUE, 0);
10896 /* iWMMXt instructions: strictly in alphabetical order. */
10899 do_iwmmxt_tandorc (void)
10901 constraint (inst.operands[0].reg != REG_PC, _("only r15 allowed here"));
10905 do_iwmmxt_textrc (void)
10907 inst.instruction |= inst.operands[0].reg << 12;
10908 inst.instruction |= inst.operands[1].imm;
10912 do_iwmmxt_textrm (void)
10914 inst.instruction |= inst.operands[0].reg << 12;
10915 inst.instruction |= inst.operands[1].reg << 16;
10916 inst.instruction |= inst.operands[2].imm;
10920 do_iwmmxt_tinsr (void)
10922 inst.instruction |= inst.operands[0].reg << 16;
10923 inst.instruction |= inst.operands[1].reg << 12;
10924 inst.instruction |= inst.operands[2].imm;
10928 do_iwmmxt_tmia (void)
10930 inst.instruction |= inst.operands[0].reg << 5;
10931 inst.instruction |= inst.operands[1].reg;
10932 inst.instruction |= inst.operands[2].reg << 12;
10936 do_iwmmxt_waligni (void)
10938 inst.instruction |= inst.operands[0].reg << 12;
10939 inst.instruction |= inst.operands[1].reg << 16;
10940 inst.instruction |= inst.operands[2].reg;
10941 inst.instruction |= inst.operands[3].imm << 20;
10945 do_iwmmxt_wmerge (void)
10947 inst.instruction |= inst.operands[0].reg << 12;
10948 inst.instruction |= inst.operands[1].reg << 16;
10949 inst.instruction |= inst.operands[2].reg;
10950 inst.instruction |= inst.operands[3].imm << 21;
10954 do_iwmmxt_wmov (void)
10956 /* WMOV rD, rN is an alias for WOR rD, rN, rN. */
10957 inst.instruction |= inst.operands[0].reg << 12;
10958 inst.instruction |= inst.operands[1].reg << 16;
10959 inst.instruction |= inst.operands[1].reg;
10963 do_iwmmxt_wldstbh (void)
10966 inst.instruction |= inst.operands[0].reg << 12;
10968 reloc = BFD_RELOC_ARM_T32_CP_OFF_IMM_S2;
10970 reloc = BFD_RELOC_ARM_CP_OFF_IMM_S2;
10971 encode_arm_cp_address (1, TRUE, FALSE, reloc);
10975 do_iwmmxt_wldstw (void)
10977 /* RIWR_RIWC clears .isreg for a control register. */
10978 if (!inst.operands[0].isreg)
10980 constraint (inst.cond != COND_ALWAYS, BAD_COND);
10981 inst.instruction |= 0xf0000000;
10984 inst.instruction |= inst.operands[0].reg << 12;
10985 encode_arm_cp_address (1, TRUE, TRUE, 0);
10989 do_iwmmxt_wldstd (void)
10991 inst.instruction |= inst.operands[0].reg << 12;
10992 if (ARM_CPU_HAS_FEATURE (cpu_variant, arm_cext_iwmmxt2)
10993 && inst.operands[1].immisreg)
10995 inst.instruction &= ~0x1a000ff;
10996 inst.instruction |= (0xfU << 28);
10997 if (inst.operands[1].preind)
10998 inst.instruction |= PRE_INDEX;
10999 if (!inst.operands[1].negative)
11000 inst.instruction |= INDEX_UP;
11001 if (inst.operands[1].writeback)
11002 inst.instruction |= WRITE_BACK;
11003 inst.instruction |= inst.operands[1].reg << 16;
11004 inst.instruction |= inst.relocs[0].exp.X_add_number << 4;
11005 inst.instruction |= inst.operands[1].imm;
11008 encode_arm_cp_address (1, TRUE, FALSE, 0);
11012 do_iwmmxt_wshufh (void)
11014 inst.instruction |= inst.operands[0].reg << 12;
11015 inst.instruction |= inst.operands[1].reg << 16;
11016 inst.instruction |= ((inst.operands[2].imm & 0xf0) << 16);
11017 inst.instruction |= (inst.operands[2].imm & 0x0f);
11021 do_iwmmxt_wzero (void)
11023 /* WZERO reg is an alias for WANDN reg, reg, reg. */
11024 inst.instruction |= inst.operands[0].reg;
11025 inst.instruction |= inst.operands[0].reg << 12;
11026 inst.instruction |= inst.operands[0].reg << 16;
11030 do_iwmmxt_wrwrwr_or_imm5 (void)
11032 if (inst.operands[2].isreg)
11035 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant, arm_cext_iwmmxt2),
11036 _("immediate operand requires iWMMXt2"));
11038 if (inst.operands[2].imm == 0)
11040 switch ((inst.instruction >> 20) & 0xf)
11046 /* w...h wrd, wrn, #0 -> wrorh wrd, wrn, #16. */
11047 inst.operands[2].imm = 16;
11048 inst.instruction = (inst.instruction & 0xff0fffff) | (0x7 << 20);
11054 /* w...w wrd, wrn, #0 -> wrorw wrd, wrn, #32. */
11055 inst.operands[2].imm = 32;
11056 inst.instruction = (inst.instruction & 0xff0fffff) | (0xb << 20);
11063 /* w...d wrd, wrn, #0 -> wor wrd, wrn, wrn. */
11065 wrn = (inst.instruction >> 16) & 0xf;
11066 inst.instruction &= 0xff0fff0f;
11067 inst.instruction |= wrn;
11068 /* Bail out here; the instruction is now assembled. */
11073 /* Map 32 -> 0, etc. */
11074 inst.operands[2].imm &= 0x1f;
11075 inst.instruction |= (0xfU << 28) | ((inst.operands[2].imm & 0x10) << 4) | (inst.operands[2].imm & 0xf);
11079 /* Cirrus Maverick instructions. Simple 2-, 3-, and 4-register
11080 operations first, then control, shift, and load/store. */
11082 /* Insns like "foo X,Y,Z". */
11085 do_mav_triple (void)
11087 inst.instruction |= inst.operands[0].reg << 16;
11088 inst.instruction |= inst.operands[1].reg;
11089 inst.instruction |= inst.operands[2].reg << 12;
11092 /* Insns like "foo W,X,Y,Z".
11093 where W=MVAX[0:3] and X,Y,Z=MVFX[0:15]. */
11098 inst.instruction |= inst.operands[0].reg << 5;
11099 inst.instruction |= inst.operands[1].reg << 12;
11100 inst.instruction |= inst.operands[2].reg << 16;
11101 inst.instruction |= inst.operands[3].reg;
11104 /* cfmvsc32<cond> DSPSC,MVDX[15:0]. */
11106 do_mav_dspsc (void)
11108 inst.instruction |= inst.operands[1].reg << 12;
11111 /* Maverick shift immediate instructions.
11112 cfsh32<cond> MVFX[15:0],MVFX[15:0],Shift[6:0].
11113 cfsh64<cond> MVDX[15:0],MVDX[15:0],Shift[6:0]. */
11116 do_mav_shift (void)
11118 int imm = inst.operands[2].imm;
11120 inst.instruction |= inst.operands[0].reg << 12;
11121 inst.instruction |= inst.operands[1].reg << 16;
11123 /* Bits 0-3 of the insn should have bits 0-3 of the immediate.
11124 Bits 5-7 of the insn should have bits 4-6 of the immediate.
11125 Bit 4 should be 0. */
11126 imm = (imm & 0xf) | ((imm & 0x70) << 1);
11128 inst.instruction |= imm;
11131 /* XScale instructions. Also sorted arithmetic before move. */
11133 /* Xscale multiply-accumulate (argument parse)
11136 MIAxycc acc0,Rm,Rs. */
11141 inst.instruction |= inst.operands[1].reg;
11142 inst.instruction |= inst.operands[2].reg << 12;
11145 /* Xscale move-accumulator-register (argument parse)
11147 MARcc acc0,RdLo,RdHi. */
11152 inst.instruction |= inst.operands[1].reg << 12;
11153 inst.instruction |= inst.operands[2].reg << 16;
11156 /* Xscale move-register-accumulator (argument parse)
11158 MRAcc RdLo,RdHi,acc0. */
11163 constraint (inst.operands[0].reg == inst.operands[1].reg, BAD_OVERLAP);
11164 inst.instruction |= inst.operands[0].reg << 12;
11165 inst.instruction |= inst.operands[1].reg << 16;
11168 /* Encoding functions relevant only to Thumb. */
11170 /* inst.operands[i] is a shifted-register operand; encode
11171 it into inst.instruction in the format used by Thumb32. */
11174 encode_thumb32_shifted_operand (int i)
11176 unsigned int value = inst.relocs[0].exp.X_add_number;
11177 unsigned int shift = inst.operands[i].shift_kind;
11179 constraint (inst.operands[i].immisreg,
11180 _("shift by register not allowed in thumb mode"));
11181 inst.instruction |= inst.operands[i].reg;
11182 if (shift == SHIFT_RRX)
11183 inst.instruction |= SHIFT_ROR << 4;
11186 constraint (inst.relocs[0].exp.X_op != O_constant,
11187 _("expression too complex"));
11189 constraint (value > 32
11190 || (value == 32 && (shift == SHIFT_LSL
11191 || shift == SHIFT_ROR)),
11192 _("shift expression is too large"));
11196 else if (value == 32)
11199 inst.instruction |= shift << 4;
11200 inst.instruction |= (value & 0x1c) << 10;
11201 inst.instruction |= (value & 0x03) << 6;
11206 /* inst.operands[i] was set up by parse_address. Encode it into a
11207 Thumb32 format load or store instruction. Reject forms that cannot
11208 be used with such instructions. If is_t is true, reject forms that
11209 cannot be used with a T instruction; if is_d is true, reject forms
11210 that cannot be used with a D instruction. If it is a store insn,
11211 reject PC in Rn. */
11214 encode_thumb32_addr_mode (int i, bfd_boolean is_t, bfd_boolean is_d)
11216 const bfd_boolean is_pc = (inst.operands[i].reg == REG_PC);
11218 constraint (!inst.operands[i].isreg,
11219 _("Instruction does not support =N addresses"));
11221 inst.instruction |= inst.operands[i].reg << 16;
11222 if (inst.operands[i].immisreg)
11224 constraint (is_pc, BAD_PC_ADDRESSING);
11225 constraint (is_t || is_d, _("cannot use register index with this instruction"));
11226 constraint (inst.operands[i].negative,
11227 _("Thumb does not support negative register indexing"));
11228 constraint (inst.operands[i].postind,
11229 _("Thumb does not support register post-indexing"));
11230 constraint (inst.operands[i].writeback,
11231 _("Thumb does not support register indexing with writeback"));
11232 constraint (inst.operands[i].shifted && inst.operands[i].shift_kind != SHIFT_LSL,
11233 _("Thumb supports only LSL in shifted register indexing"));
11235 inst.instruction |= inst.operands[i].imm;
11236 if (inst.operands[i].shifted)
11238 constraint (inst.relocs[0].exp.X_op != O_constant,
11239 _("expression too complex"));
11240 constraint (inst.relocs[0].exp.X_add_number < 0
11241 || inst.relocs[0].exp.X_add_number > 3,
11242 _("shift out of range"));
11243 inst.instruction |= inst.relocs[0].exp.X_add_number << 4;
11245 inst.relocs[0].type = BFD_RELOC_UNUSED;
11247 else if (inst.operands[i].preind)
11249 constraint (is_pc && inst.operands[i].writeback, BAD_PC_WRITEBACK);
11250 constraint (is_t && inst.operands[i].writeback,
11251 _("cannot use writeback with this instruction"));
11252 constraint (is_pc && ((inst.instruction & THUMB2_LOAD_BIT) == 0),
11253 BAD_PC_ADDRESSING);
11257 inst.instruction |= 0x01000000;
11258 if (inst.operands[i].writeback)
11259 inst.instruction |= 0x00200000;
11263 inst.instruction |= 0x00000c00;
11264 if (inst.operands[i].writeback)
11265 inst.instruction |= 0x00000100;
11267 inst.relocs[0].type = BFD_RELOC_ARM_T32_OFFSET_IMM;
11269 else if (inst.operands[i].postind)
11271 gas_assert (inst.operands[i].writeback);
11272 constraint (is_pc, _("cannot use post-indexing with PC-relative addressing"));
11273 constraint (is_t, _("cannot use post-indexing with this instruction"));
11276 inst.instruction |= 0x00200000;
11278 inst.instruction |= 0x00000900;
11279 inst.relocs[0].type = BFD_RELOC_ARM_T32_OFFSET_IMM;
11281 else /* unindexed - only for coprocessor */
11282 inst.error = _("instruction does not accept unindexed addressing");
11285 /* Table of Thumb instructions which exist in 16- and/or 32-bit
11286 encodings (the latter only in post-V6T2 cores). The index is the
11287 value used in the insns table below. When there is more than one
11288 possible 16-bit encoding for the instruction, this table always
11290 Also contains several pseudo-instructions used during relaxation. */
11291 #define T16_32_TAB \
11292 X(_adc, 4140, eb400000), \
11293 X(_adcs, 4140, eb500000), \
11294 X(_add, 1c00, eb000000), \
11295 X(_adds, 1c00, eb100000), \
11296 X(_addi, 0000, f1000000), \
11297 X(_addis, 0000, f1100000), \
11298 X(_add_pc,000f, f20f0000), \
11299 X(_add_sp,000d, f10d0000), \
11300 X(_adr, 000f, f20f0000), \
11301 X(_and, 4000, ea000000), \
11302 X(_ands, 4000, ea100000), \
11303 X(_asr, 1000, fa40f000), \
11304 X(_asrs, 1000, fa50f000), \
11305 X(_b, e000, f000b000), \
11306 X(_bcond, d000, f0008000), \
11307 X(_bf, 0000, f040e001), \
11308 X(_bfcsel,0000, f000e001), \
11309 X(_bfx, 0000, f060e001), \
11310 X(_bfl, 0000, f000c001), \
11311 X(_bflx, 0000, f070e001), \
11312 X(_bic, 4380, ea200000), \
11313 X(_bics, 4380, ea300000), \
11314 X(_cinc, 0000, ea509000), \
11315 X(_cinv, 0000, ea50a000), \
11316 X(_cmn, 42c0, eb100f00), \
11317 X(_cmp, 2800, ebb00f00), \
11318 X(_cneg, 0000, ea50b000), \
11319 X(_cpsie, b660, f3af8400), \
11320 X(_cpsid, b670, f3af8600), \
11321 X(_cpy, 4600, ea4f0000), \
11322 X(_csel, 0000, ea508000), \
11323 X(_cset, 0000, ea5f900f), \
11324 X(_csetm, 0000, ea5fa00f), \
11325 X(_csinc, 0000, ea509000), \
11326 X(_csinv, 0000, ea50a000), \
11327 X(_csneg, 0000, ea50b000), \
11328 X(_dec_sp,80dd, f1ad0d00), \
11329 X(_dls, 0000, f040e001), \
11330 X(_dlstp, 0000, f000e001), \
11331 X(_eor, 4040, ea800000), \
11332 X(_eors, 4040, ea900000), \
11333 X(_inc_sp,00dd, f10d0d00), \
11334 X(_lctp, 0000, f00fe001), \
11335 X(_ldmia, c800, e8900000), \
11336 X(_ldr, 6800, f8500000), \
11337 X(_ldrb, 7800, f8100000), \
11338 X(_ldrh, 8800, f8300000), \
11339 X(_ldrsb, 5600, f9100000), \
11340 X(_ldrsh, 5e00, f9300000), \
11341 X(_ldr_pc,4800, f85f0000), \
11342 X(_ldr_pc2,4800, f85f0000), \
11343 X(_ldr_sp,9800, f85d0000), \
11344 X(_le, 0000, f00fc001), \
11345 X(_letp, 0000, f01fc001), \
11346 X(_lsl, 0000, fa00f000), \
11347 X(_lsls, 0000, fa10f000), \
11348 X(_lsr, 0800, fa20f000), \
11349 X(_lsrs, 0800, fa30f000), \
11350 X(_mov, 2000, ea4f0000), \
11351 X(_movs, 2000, ea5f0000), \
11352 X(_mul, 4340, fb00f000), \
11353 X(_muls, 4340, ffffffff), /* no 32b muls */ \
11354 X(_mvn, 43c0, ea6f0000), \
11355 X(_mvns, 43c0, ea7f0000), \
11356 X(_neg, 4240, f1c00000), /* rsb #0 */ \
11357 X(_negs, 4240, f1d00000), /* rsbs #0 */ \
11358 X(_orr, 4300, ea400000), \
11359 X(_orrs, 4300, ea500000), \
11360 X(_pop, bc00, e8bd0000), /* ldmia sp!,... */ \
11361 X(_push, b400, e92d0000), /* stmdb sp!,... */ \
11362 X(_rev, ba00, fa90f080), \
11363 X(_rev16, ba40, fa90f090), \
11364 X(_revsh, bac0, fa90f0b0), \
11365 X(_ror, 41c0, fa60f000), \
11366 X(_rors, 41c0, fa70f000), \
11367 X(_sbc, 4180, eb600000), \
11368 X(_sbcs, 4180, eb700000), \
11369 X(_stmia, c000, e8800000), \
11370 X(_str, 6000, f8400000), \
11371 X(_strb, 7000, f8000000), \
11372 X(_strh, 8000, f8200000), \
11373 X(_str_sp,9000, f84d0000), \
11374 X(_sub, 1e00, eba00000), \
11375 X(_subs, 1e00, ebb00000), \
11376 X(_subi, 8000, f1a00000), \
11377 X(_subis, 8000, f1b00000), \
11378 X(_sxtb, b240, fa4ff080), \
11379 X(_sxth, b200, fa0ff080), \
11380 X(_tst, 4200, ea100f00), \
11381 X(_uxtb, b2c0, fa5ff080), \
11382 X(_uxth, b280, fa1ff080), \
11383 X(_nop, bf00, f3af8000), \
11384 X(_yield, bf10, f3af8001), \
11385 X(_wfe, bf20, f3af8002), \
11386 X(_wfi, bf30, f3af8003), \
11387 X(_wls, 0000, f040c001), \
11388 X(_wlstp, 0000, f000c001), \
11389 X(_sev, bf40, f3af8004), \
11390 X(_sevl, bf50, f3af8005), \
11391 X(_udf, de00, f7f0a000)
11393 /* To catch errors in encoding functions, the codes are all offset by
11394 0xF800, putting them in one of the 32-bit prefix ranges, ergo undefined
11395 as 16-bit instructions. */
11396 #define X(a,b,c) T_MNEM##a
11397 enum t16_32_codes { T16_32_OFFSET = 0xF7FF, T16_32_TAB };
11400 #define X(a,b,c) 0x##b
11401 static const unsigned short thumb_op16[] = { T16_32_TAB };
11402 #define THUMB_OP16(n) (thumb_op16[(n) - (T16_32_OFFSET + 1)])
11405 #define X(a,b,c) 0x##c
11406 static const unsigned int thumb_op32[] = { T16_32_TAB };
11407 #define THUMB_OP32(n) (thumb_op32[(n) - (T16_32_OFFSET + 1)])
11408 #define THUMB_SETS_FLAGS(n) (THUMB_OP32 (n) & 0x00100000)
11412 /* Thumb instruction encoders, in alphabetical order. */
11414 /* ADDW or SUBW. */
11417 do_t_add_sub_w (void)
11421 Rd = inst.operands[0].reg;
11422 Rn = inst.operands[1].reg;
11424 /* If Rn is REG_PC, this is ADR; if Rn is REG_SP, then this
11425 is the SP-{plus,minus}-immediate form of the instruction. */
11427 constraint (Rd == REG_PC, BAD_PC);
11429 reject_bad_reg (Rd);
11431 inst.instruction |= (Rn << 16) | (Rd << 8);
11432 inst.relocs[0].type = BFD_RELOC_ARM_T32_IMM12;
11435 /* Parse an add or subtract instruction. We get here with inst.instruction
11436 equaling any of THUMB_OPCODE_add, adds, sub, or subs. */
11439 do_t_add_sub (void)
11443 Rd = inst.operands[0].reg;
11444 Rs = (inst.operands[1].present
11445 ? inst.operands[1].reg /* Rd, Rs, foo */
11446 : inst.operands[0].reg); /* Rd, foo -> Rd, Rd, foo */
11449 set_pred_insn_type_last ();
11451 if (unified_syntax)
11454 bfd_boolean narrow;
11457 flags = (inst.instruction == T_MNEM_adds
11458 || inst.instruction == T_MNEM_subs);
11460 narrow = !in_pred_block ();
11462 narrow = in_pred_block ();
11463 if (!inst.operands[2].isreg)
11467 if (!ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_v8))
11468 constraint (Rd == REG_SP && Rs != REG_SP, BAD_SP);
11470 add = (inst.instruction == T_MNEM_add
11471 || inst.instruction == T_MNEM_adds);
11473 if (inst.size_req != 4)
11475 /* Attempt to use a narrow opcode, with relaxation if
11477 if (Rd == REG_SP && Rs == REG_SP && !flags)
11478 opcode = add ? T_MNEM_inc_sp : T_MNEM_dec_sp;
11479 else if (Rd <= 7 && Rs == REG_SP && add && !flags)
11480 opcode = T_MNEM_add_sp;
11481 else if (Rd <= 7 && Rs == REG_PC && add && !flags)
11482 opcode = T_MNEM_add_pc;
11483 else if (Rd <= 7 && Rs <= 7 && narrow)
11486 opcode = add ? T_MNEM_addis : T_MNEM_subis;
11488 opcode = add ? T_MNEM_addi : T_MNEM_subi;
11492 inst.instruction = THUMB_OP16(opcode);
11493 inst.instruction |= (Rd << 4) | Rs;
11494 if (inst.relocs[0].type < BFD_RELOC_ARM_THUMB_ALU_ABS_G0_NC
11495 || (inst.relocs[0].type
11496 > BFD_RELOC_ARM_THUMB_ALU_ABS_G3_NC))
11498 if (inst.size_req == 2)
11499 inst.relocs[0].type = BFD_RELOC_ARM_THUMB_ADD;
11501 inst.relax = opcode;
11505 constraint (inst.size_req == 2, BAD_HIREG);
11507 if (inst.size_req == 4
11508 || (inst.size_req != 2 && !opcode))
11510 constraint ((inst.relocs[0].type
11511 >= BFD_RELOC_ARM_THUMB_ALU_ABS_G0_NC)
11512 && (inst.relocs[0].type
11513 <= BFD_RELOC_ARM_THUMB_ALU_ABS_G3_NC) ,
11514 THUMB1_RELOC_ONLY);
11517 constraint (add, BAD_PC);
11518 constraint (Rs != REG_LR || inst.instruction != T_MNEM_subs,
11519 _("only SUBS PC, LR, #const allowed"));
11520 constraint (inst.relocs[0].exp.X_op != O_constant,
11521 _("expression too complex"));
11522 constraint (inst.relocs[0].exp.X_add_number < 0
11523 || inst.relocs[0].exp.X_add_number > 0xff,
11524 _("immediate value out of range"));
11525 inst.instruction = T2_SUBS_PC_LR
11526 | inst.relocs[0].exp.X_add_number;
11527 inst.relocs[0].type = BFD_RELOC_UNUSED;
11530 else if (Rs == REG_PC)
11532 /* Always use addw/subw. */
11533 inst.instruction = add ? 0xf20f0000 : 0xf2af0000;
11534 inst.relocs[0].type = BFD_RELOC_ARM_T32_IMM12;
11538 inst.instruction = THUMB_OP32 (inst.instruction);
11539 inst.instruction = (inst.instruction & 0xe1ffffff)
11542 inst.relocs[0].type = BFD_RELOC_ARM_T32_IMMEDIATE;
11544 inst.relocs[0].type = BFD_RELOC_ARM_T32_ADD_IMM;
11546 inst.instruction |= Rd << 8;
11547 inst.instruction |= Rs << 16;
11552 unsigned int value = inst.relocs[0].exp.X_add_number;
11553 unsigned int shift = inst.operands[2].shift_kind;
11555 Rn = inst.operands[2].reg;
11556 /* See if we can do this with a 16-bit instruction. */
11557 if (!inst.operands[2].shifted && inst.size_req != 4)
11559 if (Rd > 7 || Rs > 7 || Rn > 7)
11564 inst.instruction = ((inst.instruction == T_MNEM_adds
11565 || inst.instruction == T_MNEM_add)
11567 : T_OPCODE_SUB_R3);
11568 inst.instruction |= Rd | (Rs << 3) | (Rn << 6);
11572 if (inst.instruction == T_MNEM_add && (Rd == Rs || Rd == Rn))
11574 /* Thumb-1 cores (except v6-M) require at least one high
11575 register in a narrow non flag setting add. */
11576 if (Rd > 7 || Rn > 7
11577 || ARM_CPU_HAS_FEATURE (selected_cpu, arm_ext_v6t2)
11578 || ARM_CPU_HAS_FEATURE (selected_cpu, arm_ext_msr))
11585 inst.instruction = T_OPCODE_ADD_HI;
11586 inst.instruction |= (Rd & 8) << 4;
11587 inst.instruction |= (Rd & 7);
11588 inst.instruction |= Rn << 3;
11594 constraint (Rd == REG_PC, BAD_PC);
11595 if (!ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_v8))
11596 constraint (Rd == REG_SP && Rs != REG_SP, BAD_SP);
11597 constraint (Rs == REG_PC, BAD_PC);
11598 reject_bad_reg (Rn);
11600 /* If we get here, it can't be done in 16 bits. */
11601 constraint (inst.operands[2].shifted && inst.operands[2].immisreg,
11602 _("shift must be constant"));
11603 inst.instruction = THUMB_OP32 (inst.instruction);
11604 inst.instruction |= Rd << 8;
11605 inst.instruction |= Rs << 16;
11606 constraint (Rd == REG_SP && Rs == REG_SP && value > 3,
11607 _("shift value over 3 not allowed in thumb mode"));
11608 constraint (Rd == REG_SP && Rs == REG_SP && shift != SHIFT_LSL,
11609 _("only LSL shift allowed in thumb mode"));
11610 encode_thumb32_shifted_operand (2);
11615 constraint (inst.instruction == T_MNEM_adds
11616 || inst.instruction == T_MNEM_subs,
11619 if (!inst.operands[2].isreg) /* Rd, Rs, #imm */
11621 constraint ((Rd > 7 && (Rd != REG_SP || Rs != REG_SP))
11622 || (Rs > 7 && Rs != REG_SP && Rs != REG_PC),
11625 inst.instruction = (inst.instruction == T_MNEM_add
11626 ? 0x0000 : 0x8000);
11627 inst.instruction |= (Rd << 4) | Rs;
11628 inst.relocs[0].type = BFD_RELOC_ARM_THUMB_ADD;
11632 Rn = inst.operands[2].reg;
11633 constraint (inst.operands[2].shifted, _("unshifted register required"));
11635 /* We now have Rd, Rs, and Rn set to registers. */
11636 if (Rd > 7 || Rs > 7 || Rn > 7)
11638 /* Can't do this for SUB. */
11639 constraint (inst.instruction == T_MNEM_sub, BAD_HIREG);
11640 inst.instruction = T_OPCODE_ADD_HI;
11641 inst.instruction |= (Rd & 8) << 4;
11642 inst.instruction |= (Rd & 7);
11644 inst.instruction |= Rn << 3;
11646 inst.instruction |= Rs << 3;
11648 constraint (1, _("dest must overlap one source register"));
11652 inst.instruction = (inst.instruction == T_MNEM_add
11653 ? T_OPCODE_ADD_R3 : T_OPCODE_SUB_R3);
11654 inst.instruction |= Rd | (Rs << 3) | (Rn << 6);
11664 Rd = inst.operands[0].reg;
11665 reject_bad_reg (Rd);
11667 if (unified_syntax && inst.size_req == 0 && Rd <= 7)
11669 /* Defer to section relaxation. */
11670 inst.relax = inst.instruction;
11671 inst.instruction = THUMB_OP16 (inst.instruction);
11672 inst.instruction |= Rd << 4;
11674 else if (unified_syntax && inst.size_req != 2)
11676 /* Generate a 32-bit opcode. */
11677 inst.instruction = THUMB_OP32 (inst.instruction);
11678 inst.instruction |= Rd << 8;
11679 inst.relocs[0].type = BFD_RELOC_ARM_T32_ADD_PC12;
11680 inst.relocs[0].pc_rel = 1;
11684 /* Generate a 16-bit opcode. */
11685 inst.instruction = THUMB_OP16 (inst.instruction);
11686 inst.relocs[0].type = BFD_RELOC_ARM_THUMB_ADD;
11687 inst.relocs[0].exp.X_add_number -= 4; /* PC relative adjust. */
11688 inst.relocs[0].pc_rel = 1;
11689 inst.instruction |= Rd << 4;
11692 if (inst.relocs[0].exp.X_op == O_symbol
11693 && inst.relocs[0].exp.X_add_symbol != NULL
11694 && S_IS_DEFINED (inst.relocs[0].exp.X_add_symbol)
11695 && THUMB_IS_FUNC (inst.relocs[0].exp.X_add_symbol))
11696 inst.relocs[0].exp.X_add_number += 1;
11699 /* Arithmetic instructions for which there is just one 16-bit
11700 instruction encoding, and it allows only two low registers.
11701 For maximal compatibility with ARM syntax, we allow three register
11702 operands even when Thumb-32 instructions are not available, as long
11703 as the first two are identical. For instance, both "sbc r0,r1" and
11704 "sbc r0,r0,r1" are allowed. */
11710 Rd = inst.operands[0].reg;
11711 Rs = (inst.operands[1].present
11712 ? inst.operands[1].reg /* Rd, Rs, foo */
11713 : inst.operands[0].reg); /* Rd, foo -> Rd, Rd, foo */
11714 Rn = inst.operands[2].reg;
11716 reject_bad_reg (Rd);
11717 reject_bad_reg (Rs);
11718 if (inst.operands[2].isreg)
11719 reject_bad_reg (Rn);
11721 if (unified_syntax)
11723 if (!inst.operands[2].isreg)
11725 /* For an immediate, we always generate a 32-bit opcode;
11726 section relaxation will shrink it later if possible. */
11727 inst.instruction = THUMB_OP32 (inst.instruction);
11728 inst.instruction = (inst.instruction & 0xe1ffffff) | 0x10000000;
11729 inst.instruction |= Rd << 8;
11730 inst.instruction |= Rs << 16;
11731 inst.relocs[0].type = BFD_RELOC_ARM_T32_IMMEDIATE;
11735 bfd_boolean narrow;
11737 /* See if we can do this with a 16-bit instruction. */
11738 if (THUMB_SETS_FLAGS (inst.instruction))
11739 narrow = !in_pred_block ();
11741 narrow = in_pred_block ();
11743 if (Rd > 7 || Rn > 7 || Rs > 7)
11745 if (inst.operands[2].shifted)
11747 if (inst.size_req == 4)
11753 inst.instruction = THUMB_OP16 (inst.instruction);
11754 inst.instruction |= Rd;
11755 inst.instruction |= Rn << 3;
11759 /* If we get here, it can't be done in 16 bits. */
11760 constraint (inst.operands[2].shifted
11761 && inst.operands[2].immisreg,
11762 _("shift must be constant"));
11763 inst.instruction = THUMB_OP32 (inst.instruction);
11764 inst.instruction |= Rd << 8;
11765 inst.instruction |= Rs << 16;
11766 encode_thumb32_shifted_operand (2);
11771 /* On its face this is a lie - the instruction does set the
11772 flags. However, the only supported mnemonic in this mode
11773 says it doesn't. */
11774 constraint (THUMB_SETS_FLAGS (inst.instruction), BAD_THUMB32);
11776 constraint (!inst.operands[2].isreg || inst.operands[2].shifted,
11777 _("unshifted register required"));
11778 constraint (Rd > 7 || Rs > 7 || Rn > 7, BAD_HIREG);
11779 constraint (Rd != Rs,
11780 _("dest and source1 must be the same register"));
11782 inst.instruction = THUMB_OP16 (inst.instruction);
11783 inst.instruction |= Rd;
11784 inst.instruction |= Rn << 3;
11788 /* Similarly, but for instructions where the arithmetic operation is
11789 commutative, so we can allow either of them to be different from
11790 the destination operand in a 16-bit instruction. For instance, all
11791 three of "adc r0,r1", "adc r0,r0,r1", and "adc r0,r1,r0" are
11798 Rd = inst.operands[0].reg;
11799 Rs = (inst.operands[1].present
11800 ? inst.operands[1].reg /* Rd, Rs, foo */
11801 : inst.operands[0].reg); /* Rd, foo -> Rd, Rd, foo */
11802 Rn = inst.operands[2].reg;
11804 reject_bad_reg (Rd);
11805 reject_bad_reg (Rs);
11806 if (inst.operands[2].isreg)
11807 reject_bad_reg (Rn);
11809 if (unified_syntax)
11811 if (!inst.operands[2].isreg)
11813 /* For an immediate, we always generate a 32-bit opcode;
11814 section relaxation will shrink it later if possible. */
11815 inst.instruction = THUMB_OP32 (inst.instruction);
11816 inst.instruction = (inst.instruction & 0xe1ffffff) | 0x10000000;
11817 inst.instruction |= Rd << 8;
11818 inst.instruction |= Rs << 16;
11819 inst.relocs[0].type = BFD_RELOC_ARM_T32_IMMEDIATE;
11823 bfd_boolean narrow;
11825 /* See if we can do this with a 16-bit instruction. */
11826 if (THUMB_SETS_FLAGS (inst.instruction))
11827 narrow = !in_pred_block ();
11829 narrow = in_pred_block ();
11831 if (Rd > 7 || Rn > 7 || Rs > 7)
11833 if (inst.operands[2].shifted)
11835 if (inst.size_req == 4)
11842 inst.instruction = THUMB_OP16 (inst.instruction);
11843 inst.instruction |= Rd;
11844 inst.instruction |= Rn << 3;
11849 inst.instruction = THUMB_OP16 (inst.instruction);
11850 inst.instruction |= Rd;
11851 inst.instruction |= Rs << 3;
11856 /* If we get here, it can't be done in 16 bits. */
11857 constraint (inst.operands[2].shifted
11858 && inst.operands[2].immisreg,
11859 _("shift must be constant"));
11860 inst.instruction = THUMB_OP32 (inst.instruction);
11861 inst.instruction |= Rd << 8;
11862 inst.instruction |= Rs << 16;
11863 encode_thumb32_shifted_operand (2);
11868 /* On its face this is a lie - the instruction does set the
11869 flags. However, the only supported mnemonic in this mode
11870 says it doesn't. */
11871 constraint (THUMB_SETS_FLAGS (inst.instruction), BAD_THUMB32);
11873 constraint (!inst.operands[2].isreg || inst.operands[2].shifted,
11874 _("unshifted register required"));
11875 constraint (Rd > 7 || Rs > 7 || Rn > 7, BAD_HIREG);
11877 inst.instruction = THUMB_OP16 (inst.instruction);
11878 inst.instruction |= Rd;
11881 inst.instruction |= Rn << 3;
11883 inst.instruction |= Rs << 3;
11885 constraint (1, _("dest must overlap one source register"));
11893 unsigned int msb = inst.operands[1].imm + inst.operands[2].imm;
11894 constraint (msb > 32, _("bit-field extends past end of register"));
11895 /* The instruction encoding stores the LSB and MSB,
11896 not the LSB and width. */
11897 Rd = inst.operands[0].reg;
11898 reject_bad_reg (Rd);
11899 inst.instruction |= Rd << 8;
11900 inst.instruction |= (inst.operands[1].imm & 0x1c) << 10;
11901 inst.instruction |= (inst.operands[1].imm & 0x03) << 6;
11902 inst.instruction |= msb - 1;
11911 Rd = inst.operands[0].reg;
11912 reject_bad_reg (Rd);
11914 /* #0 in second position is alternative syntax for bfc, which is
11915 the same instruction but with REG_PC in the Rm field. */
11916 if (!inst.operands[1].isreg)
11920 Rn = inst.operands[1].reg;
11921 reject_bad_reg (Rn);
11924 msb = inst.operands[2].imm + inst.operands[3].imm;
11925 constraint (msb > 32, _("bit-field extends past end of register"));
11926 /* The instruction encoding stores the LSB and MSB,
11927 not the LSB and width. */
11928 inst.instruction |= Rd << 8;
11929 inst.instruction |= Rn << 16;
11930 inst.instruction |= (inst.operands[2].imm & 0x1c) << 10;
11931 inst.instruction |= (inst.operands[2].imm & 0x03) << 6;
11932 inst.instruction |= msb - 1;
11940 Rd = inst.operands[0].reg;
11941 Rn = inst.operands[1].reg;
11943 reject_bad_reg (Rd);
11944 reject_bad_reg (Rn);
11946 constraint (inst.operands[2].imm + inst.operands[3].imm > 32,
11947 _("bit-field extends past end of register"));
11948 inst.instruction |= Rd << 8;
11949 inst.instruction |= Rn << 16;
11950 inst.instruction |= (inst.operands[2].imm & 0x1c) << 10;
11951 inst.instruction |= (inst.operands[2].imm & 0x03) << 6;
11952 inst.instruction |= inst.operands[3].imm - 1;
11955 /* ARM V5 Thumb BLX (argument parse)
11956 BLX <target_addr> which is BLX(1)
11957 BLX <Rm> which is BLX(2)
11958 Unfortunately, there are two different opcodes for this mnemonic.
11959 So, the insns[].value is not used, and the code here zaps values
11960 into inst.instruction.
11962 ??? How to take advantage of the additional two bits of displacement
11963 available in Thumb32 mode? Need new relocation? */
11968 set_pred_insn_type_last ();
11970 if (inst.operands[0].isreg)
11972 constraint (inst.operands[0].reg == REG_PC, BAD_PC);
11973 /* We have a register, so this is BLX(2). */
11974 inst.instruction |= inst.operands[0].reg << 3;
11978 /* No register. This must be BLX(1). */
11979 inst.instruction = 0xf000e800;
11980 encode_branch (BFD_RELOC_THUMB_PCREL_BLX);
11989 bfd_reloc_code_real_type reloc;
11992 set_pred_insn_type (IF_INSIDE_IT_LAST_INSN);
11994 if (in_pred_block ())
11996 /* Conditional branches inside IT blocks are encoded as unconditional
11998 cond = COND_ALWAYS;
12003 if (cond != COND_ALWAYS)
12004 opcode = T_MNEM_bcond;
12006 opcode = inst.instruction;
12009 && (inst.size_req == 4
12010 || (inst.size_req != 2
12011 && (inst.operands[0].hasreloc
12012 || inst.relocs[0].exp.X_op == O_constant))))
12014 inst.instruction = THUMB_OP32(opcode);
12015 if (cond == COND_ALWAYS)
12016 reloc = BFD_RELOC_THUMB_PCREL_BRANCH25;
12019 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_v6t2),
12020 _("selected architecture does not support "
12021 "wide conditional branch instruction"));
12023 gas_assert (cond != 0xF);
12024 inst.instruction |= cond << 22;
12025 reloc = BFD_RELOC_THUMB_PCREL_BRANCH20;
12030 inst.instruction = THUMB_OP16(opcode);
12031 if (cond == COND_ALWAYS)
12032 reloc = BFD_RELOC_THUMB_PCREL_BRANCH12;
12035 inst.instruction |= cond << 8;
12036 reloc = BFD_RELOC_THUMB_PCREL_BRANCH9;
12038 /* Allow section relaxation. */
12039 if (unified_syntax && inst.size_req != 2)
12040 inst.relax = opcode;
12042 inst.relocs[0].type = reloc;
12043 inst.relocs[0].pc_rel = 1;
12046 /* Actually do the work for Thumb state bkpt and hlt. The only difference
12047 between the two is the maximum immediate allowed - which is passed in
12050 do_t_bkpt_hlt1 (int range)
12052 constraint (inst.cond != COND_ALWAYS,
12053 _("instruction is always unconditional"));
12054 if (inst.operands[0].present)
12056 constraint (inst.operands[0].imm > range,
12057 _("immediate value out of range"));
12058 inst.instruction |= inst.operands[0].imm;
12061 set_pred_insn_type (NEUTRAL_IT_INSN);
12067 do_t_bkpt_hlt1 (63);
12073 do_t_bkpt_hlt1 (255);
12077 do_t_branch23 (void)
12079 set_pred_insn_type_last ();
12080 encode_branch (BFD_RELOC_THUMB_PCREL_BRANCH23);
12082 /* md_apply_fix blows up with 'bl foo(PLT)' where foo is defined in
12083 this file. We used to simply ignore the PLT reloc type here --
12084 the branch encoding is now needed to deal with TLSCALL relocs.
12085 So if we see a PLT reloc now, put it back to how it used to be to
12086 keep the preexisting behaviour. */
12087 if (inst.relocs[0].type == BFD_RELOC_ARM_PLT32)
12088 inst.relocs[0].type = BFD_RELOC_THUMB_PCREL_BRANCH23;
12090 #if defined(OBJ_COFF)
12091 /* If the destination of the branch is a defined symbol which does not have
12092 the THUMB_FUNC attribute, then we must be calling a function which has
12093 the (interfacearm) attribute. We look for the Thumb entry point to that
12094 function and change the branch to refer to that function instead. */
12095 if ( inst.relocs[0].exp.X_op == O_symbol
12096 && inst.relocs[0].exp.X_add_symbol != NULL
12097 && S_IS_DEFINED (inst.relocs[0].exp.X_add_symbol)
12098 && ! THUMB_IS_FUNC (inst.relocs[0].exp.X_add_symbol))
12099 inst.relocs[0].exp.X_add_symbol
12100 = find_real_start (inst.relocs[0].exp.X_add_symbol);
12107 set_pred_insn_type_last ();
12108 inst.instruction |= inst.operands[0].reg << 3;
12109 /* ??? FIXME: Should add a hacky reloc here if reg is REG_PC. The reloc
12110 should cause the alignment to be checked once it is known. This is
12111 because BX PC only works if the instruction is word aligned. */
12119 set_pred_insn_type_last ();
12120 Rm = inst.operands[0].reg;
12121 reject_bad_reg (Rm);
12122 inst.instruction |= Rm << 16;
12131 Rd = inst.operands[0].reg;
12132 Rm = inst.operands[1].reg;
12134 reject_bad_reg (Rd);
12135 reject_bad_reg (Rm);
12137 inst.instruction |= Rd << 8;
12138 inst.instruction |= Rm << 16;
12139 inst.instruction |= Rm;
12142 /* For the Armv8.1-M conditional instructions. */
12146 unsigned Rd, Rn, Rm;
12149 constraint (inst.cond != COND_ALWAYS, BAD_COND);
12151 Rd = inst.operands[0].reg;
12152 switch (inst.instruction)
12158 Rn = inst.operands[1].reg;
12159 Rm = inst.operands[2].reg;
12160 cond = inst.operands[3].imm;
12161 constraint (Rn == REG_SP, BAD_SP);
12162 constraint (Rm == REG_SP, BAD_SP);
12168 Rn = inst.operands[1].reg;
12169 cond = inst.operands[2].imm;
12170 /* Invert the last bit to invert the cond. */
12171 cond = TOGGLE_BIT (cond, 0);
12172 constraint (Rn == REG_SP, BAD_SP);
12178 cond = inst.operands[1].imm;
12179 /* Invert the last bit to invert the cond. */
12180 cond = TOGGLE_BIT (cond, 0);
12188 set_pred_insn_type (OUTSIDE_PRED_INSN);
12189 inst.instruction = THUMB_OP32 (inst.instruction);
12190 inst.instruction |= Rd << 8;
12191 inst.instruction |= Rn << 16;
12192 inst.instruction |= Rm;
12193 inst.instruction |= cond << 4;
12199 set_pred_insn_type (OUTSIDE_PRED_INSN);
12205 set_pred_insn_type (OUTSIDE_PRED_INSN);
12206 inst.instruction |= inst.operands[0].imm;
12212 set_pred_insn_type (OUTSIDE_PRED_INSN);
12214 && (inst.operands[1].present || inst.size_req == 4)
12215 && ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_v6_notm))
12217 unsigned int imod = (inst.instruction & 0x0030) >> 4;
12218 inst.instruction = 0xf3af8000;
12219 inst.instruction |= imod << 9;
12220 inst.instruction |= inst.operands[0].imm << 5;
12221 if (inst.operands[1].present)
12222 inst.instruction |= 0x100 | inst.operands[1].imm;
12226 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_v1)
12227 && (inst.operands[0].imm & 4),
12228 _("selected processor does not support 'A' form "
12229 "of this instruction"));
12230 constraint (inst.operands[1].present || inst.size_req == 4,
12231 _("Thumb does not support the 2-argument "
12232 "form of this instruction"));
12233 inst.instruction |= inst.operands[0].imm;
12237 /* THUMB CPY instruction (argument parse). */
12242 if (inst.size_req == 4)
12244 inst.instruction = THUMB_OP32 (T_MNEM_mov);
12245 inst.instruction |= inst.operands[0].reg << 8;
12246 inst.instruction |= inst.operands[1].reg;
12250 inst.instruction |= (inst.operands[0].reg & 0x8) << 4;
12251 inst.instruction |= (inst.operands[0].reg & 0x7);
12252 inst.instruction |= inst.operands[1].reg << 3;
12259 set_pred_insn_type (OUTSIDE_PRED_INSN);
12260 constraint (inst.operands[0].reg > 7, BAD_HIREG);
12261 inst.instruction |= inst.operands[0].reg;
12262 inst.relocs[0].pc_rel = 1;
12263 inst.relocs[0].type = BFD_RELOC_THUMB_PCREL_BRANCH7;
12269 inst.instruction |= inst.operands[0].imm;
12275 unsigned Rd, Rn, Rm;
12277 Rd = inst.operands[0].reg;
12278 Rn = (inst.operands[1].present
12279 ? inst.operands[1].reg : Rd);
12280 Rm = inst.operands[2].reg;
12282 reject_bad_reg (Rd);
12283 reject_bad_reg (Rn);
12284 reject_bad_reg (Rm);
12286 inst.instruction |= Rd << 8;
12287 inst.instruction |= Rn << 16;
12288 inst.instruction |= Rm;
12294 if (unified_syntax && inst.size_req == 4)
12295 inst.instruction = THUMB_OP32 (inst.instruction);
12297 inst.instruction = THUMB_OP16 (inst.instruction);
12303 unsigned int cond = inst.operands[0].imm;
12305 set_pred_insn_type (IT_INSN);
12306 now_pred.mask = (inst.instruction & 0xf) | 0x10;
12307 now_pred.cc = cond;
12308 now_pred.warn_deprecated = FALSE;
12309 now_pred.type = SCALAR_PRED;
12311 /* If the condition is a negative condition, invert the mask. */
12312 if ((cond & 0x1) == 0x0)
12314 unsigned int mask = inst.instruction & 0x000f;
12316 if ((mask & 0x7) == 0)
12318 /* No conversion needed. */
12319 now_pred.block_length = 1;
12321 else if ((mask & 0x3) == 0)
12324 now_pred.block_length = 2;
12326 else if ((mask & 0x1) == 0)
12329 now_pred.block_length = 3;
12334 now_pred.block_length = 4;
12337 inst.instruction &= 0xfff0;
12338 inst.instruction |= mask;
12341 inst.instruction |= cond << 4;
12344 /* Helper function used for both push/pop and ldm/stm. */
12346 encode_thumb2_multi (bfd_boolean do_io, int base, unsigned mask,
12347 bfd_boolean writeback)
12349 bfd_boolean load, store;
12351 gas_assert (base != -1 || !do_io);
12352 load = do_io && ((inst.instruction & (1 << 20)) != 0);
12353 store = do_io && !load;
12355 if (mask & (1 << 13))
12356 inst.error = _("SP not allowed in register list");
12358 if (do_io && (mask & (1 << base)) != 0
12360 inst.error = _("having the base register in the register list when "
12361 "using write back is UNPREDICTABLE");
12365 if (mask & (1 << 15))
12367 if (mask & (1 << 14))
12368 inst.error = _("LR and PC should not both be in register list");
12370 set_pred_insn_type_last ();
12375 if (mask & (1 << 15))
12376 inst.error = _("PC not allowed in register list");
12379 if (do_io && ((mask & (mask - 1)) == 0))
12381 /* Single register transfers implemented as str/ldr. */
12384 if (inst.instruction & (1 << 23))
12385 inst.instruction = 0x00000b04; /* ia! -> [base], #4 */
12387 inst.instruction = 0x00000d04; /* db! -> [base, #-4]! */
12391 if (inst.instruction & (1 << 23))
12392 inst.instruction = 0x00800000; /* ia -> [base] */
12394 inst.instruction = 0x00000c04; /* db -> [base, #-4] */
12397 inst.instruction |= 0xf8400000;
12399 inst.instruction |= 0x00100000;
12401 mask = ffs (mask) - 1;
12404 else if (writeback)
12405 inst.instruction |= WRITE_BACK;
12407 inst.instruction |= mask;
12409 inst.instruction |= base << 16;
12415 /* This really doesn't seem worth it. */
12416 constraint (inst.relocs[0].type != BFD_RELOC_UNUSED,
12417 _("expression too complex"));
12418 constraint (inst.operands[1].writeback,
12419 _("Thumb load/store multiple does not support {reglist}^"));
12421 if (unified_syntax)
12423 bfd_boolean narrow;
12427 /* See if we can use a 16-bit instruction. */
12428 if (inst.instruction < 0xffff /* not ldmdb/stmdb */
12429 && inst.size_req != 4
12430 && !(inst.operands[1].imm & ~0xff))
12432 mask = 1 << inst.operands[0].reg;
12434 if (inst.operands[0].reg <= 7)
12436 if (inst.instruction == T_MNEM_stmia
12437 ? inst.operands[0].writeback
12438 : (inst.operands[0].writeback
12439 == !(inst.operands[1].imm & mask)))
12441 if (inst.instruction == T_MNEM_stmia
12442 && (inst.operands[1].imm & mask)
12443 && (inst.operands[1].imm & (mask - 1)))
12444 as_warn (_("value stored for r%d is UNKNOWN"),
12445 inst.operands[0].reg);
12447 inst.instruction = THUMB_OP16 (inst.instruction);
12448 inst.instruction |= inst.operands[0].reg << 8;
12449 inst.instruction |= inst.operands[1].imm;
12452 else if ((inst.operands[1].imm & (inst.operands[1].imm-1)) == 0)
12454 /* This means 1 register in reg list one of 3 situations:
12455 1. Instruction is stmia, but without writeback.
12456 2. lmdia without writeback, but with Rn not in
12458 3. ldmia with writeback, but with Rn in reglist.
12459 Case 3 is UNPREDICTABLE behaviour, so we handle
12460 case 1 and 2 which can be converted into a 16-bit
12461 str or ldr. The SP cases are handled below. */
12462 unsigned long opcode;
12463 /* First, record an error for Case 3. */
12464 if (inst.operands[1].imm & mask
12465 && inst.operands[0].writeback)
12467 _("having the base register in the register list when "
12468 "using write back is UNPREDICTABLE");
12470 opcode = (inst.instruction == T_MNEM_stmia ? T_MNEM_str
12472 inst.instruction = THUMB_OP16 (opcode);
12473 inst.instruction |= inst.operands[0].reg << 3;
12474 inst.instruction |= (ffs (inst.operands[1].imm)-1);
12478 else if (inst.operands[0] .reg == REG_SP)
12480 if (inst.operands[0].writeback)
12483 THUMB_OP16 (inst.instruction == T_MNEM_stmia
12484 ? T_MNEM_push : T_MNEM_pop);
12485 inst.instruction |= inst.operands[1].imm;
12488 else if ((inst.operands[1].imm & (inst.operands[1].imm-1)) == 0)
12491 THUMB_OP16 (inst.instruction == T_MNEM_stmia
12492 ? T_MNEM_str_sp : T_MNEM_ldr_sp);
12493 inst.instruction |= ((ffs (inst.operands[1].imm)-1) << 8);
12501 if (inst.instruction < 0xffff)
12502 inst.instruction = THUMB_OP32 (inst.instruction);
12504 encode_thumb2_multi (TRUE /* do_io */, inst.operands[0].reg,
12505 inst.operands[1].imm,
12506 inst.operands[0].writeback);
12511 constraint (inst.operands[0].reg > 7
12512 || (inst.operands[1].imm & ~0xff), BAD_HIREG);
12513 constraint (inst.instruction != T_MNEM_ldmia
12514 && inst.instruction != T_MNEM_stmia,
12515 _("Thumb-2 instruction only valid in unified syntax"));
12516 if (inst.instruction == T_MNEM_stmia)
12518 if (!inst.operands[0].writeback)
12519 as_warn (_("this instruction will write back the base register"));
12520 if ((inst.operands[1].imm & (1 << inst.operands[0].reg))
12521 && (inst.operands[1].imm & ((1 << inst.operands[0].reg) - 1)))
12522 as_warn (_("value stored for r%d is UNKNOWN"),
12523 inst.operands[0].reg);
12527 if (!inst.operands[0].writeback
12528 && !(inst.operands[1].imm & (1 << inst.operands[0].reg)))
12529 as_warn (_("this instruction will write back the base register"));
12530 else if (inst.operands[0].writeback
12531 && (inst.operands[1].imm & (1 << inst.operands[0].reg)))
12532 as_warn (_("this instruction will not write back the base register"));
12535 inst.instruction = THUMB_OP16 (inst.instruction);
12536 inst.instruction |= inst.operands[0].reg << 8;
12537 inst.instruction |= inst.operands[1].imm;
12544 constraint (!inst.operands[1].isreg || !inst.operands[1].preind
12545 || inst.operands[1].postind || inst.operands[1].writeback
12546 || inst.operands[1].immisreg || inst.operands[1].shifted
12547 || inst.operands[1].negative,
12550 constraint ((inst.operands[1].reg == REG_PC), BAD_PC);
12552 inst.instruction |= inst.operands[0].reg << 12;
12553 inst.instruction |= inst.operands[1].reg << 16;
12554 inst.relocs[0].type = BFD_RELOC_ARM_T32_OFFSET_U8;
12560 if (!inst.operands[1].present)
12562 constraint (inst.operands[0].reg == REG_LR,
12563 _("r14 not allowed as first register "
12564 "when second register is omitted"));
12565 inst.operands[1].reg = inst.operands[0].reg + 1;
12567 constraint (inst.operands[0].reg == inst.operands[1].reg,
12570 inst.instruction |= inst.operands[0].reg << 12;
12571 inst.instruction |= inst.operands[1].reg << 8;
12572 inst.instruction |= inst.operands[2].reg << 16;
12578 unsigned long opcode;
12581 if (inst.operands[0].isreg
12582 && !inst.operands[0].preind
12583 && inst.operands[0].reg == REG_PC)
12584 set_pred_insn_type_last ();
12586 opcode = inst.instruction;
12587 if (unified_syntax)
12589 if (!inst.operands[1].isreg)
12591 if (opcode <= 0xffff)
12592 inst.instruction = THUMB_OP32 (opcode);
12593 if (move_or_literal_pool (0, CONST_THUMB, /*mode_3=*/FALSE))
12596 if (inst.operands[1].isreg
12597 && !inst.operands[1].writeback
12598 && !inst.operands[1].shifted && !inst.operands[1].postind
12599 && !inst.operands[1].negative && inst.operands[0].reg <= 7
12600 && opcode <= 0xffff
12601 && inst.size_req != 4)
12603 /* Insn may have a 16-bit form. */
12604 Rn = inst.operands[1].reg;
12605 if (inst.operands[1].immisreg)
12607 inst.instruction = THUMB_OP16 (opcode);
12609 if (Rn <= 7 && inst.operands[1].imm <= 7)
12611 else if (opcode != T_MNEM_ldr && opcode != T_MNEM_str)
12612 reject_bad_reg (inst.operands[1].imm);
12614 else if ((Rn <= 7 && opcode != T_MNEM_ldrsh
12615 && opcode != T_MNEM_ldrsb)
12616 || ((Rn == REG_PC || Rn == REG_SP) && opcode == T_MNEM_ldr)
12617 || (Rn == REG_SP && opcode == T_MNEM_str))
12624 if (inst.relocs[0].pc_rel)
12625 opcode = T_MNEM_ldr_pc2;
12627 opcode = T_MNEM_ldr_pc;
12631 if (opcode == T_MNEM_ldr)
12632 opcode = T_MNEM_ldr_sp;
12634 opcode = T_MNEM_str_sp;
12636 inst.instruction = inst.operands[0].reg << 8;
12640 inst.instruction = inst.operands[0].reg;
12641 inst.instruction |= inst.operands[1].reg << 3;
12643 inst.instruction |= THUMB_OP16 (opcode);
12644 if (inst.size_req == 2)
12645 inst.relocs[0].type = BFD_RELOC_ARM_THUMB_OFFSET;
12647 inst.relax = opcode;
12651 /* Definitely a 32-bit variant. */
12653 /* Warning for Erratum 752419. */
12654 if (opcode == T_MNEM_ldr
12655 && inst.operands[0].reg == REG_SP
12656 && inst.operands[1].writeback == 1
12657 && !inst.operands[1].immisreg)
12659 if (no_cpu_selected ()
12660 || (ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_v7)
12661 && !ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_v7a)
12662 && !ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_v7r)))
12663 as_warn (_("This instruction may be unpredictable "
12664 "if executed on M-profile cores "
12665 "with interrupts enabled."));
12668 /* Do some validations regarding addressing modes. */
12669 if (inst.operands[1].immisreg)
12670 reject_bad_reg (inst.operands[1].imm);
12672 constraint (inst.operands[1].writeback == 1
12673 && inst.operands[0].reg == inst.operands[1].reg,
12676 inst.instruction = THUMB_OP32 (opcode);
12677 inst.instruction |= inst.operands[0].reg << 12;
12678 encode_thumb32_addr_mode (1, /*is_t=*/FALSE, /*is_d=*/FALSE);
12679 check_ldr_r15_aligned ();
12683 constraint (inst.operands[0].reg > 7, BAD_HIREG);
12685 if (inst.instruction == T_MNEM_ldrsh || inst.instruction == T_MNEM_ldrsb)
12687 /* Only [Rn,Rm] is acceptable. */
12688 constraint (inst.operands[1].reg > 7 || inst.operands[1].imm > 7, BAD_HIREG);
12689 constraint (!inst.operands[1].isreg || !inst.operands[1].immisreg
12690 || inst.operands[1].postind || inst.operands[1].shifted
12691 || inst.operands[1].negative,
12692 _("Thumb does not support this addressing mode"));
12693 inst.instruction = THUMB_OP16 (inst.instruction);
12697 inst.instruction = THUMB_OP16 (inst.instruction);
12698 if (!inst.operands[1].isreg)
12699 if (move_or_literal_pool (0, CONST_THUMB, /*mode_3=*/FALSE))
12702 constraint (!inst.operands[1].preind
12703 || inst.operands[1].shifted
12704 || inst.operands[1].writeback,
12705 _("Thumb does not support this addressing mode"));
12706 if (inst.operands[1].reg == REG_PC || inst.operands[1].reg == REG_SP)
12708 constraint (inst.instruction & 0x0600,
12709 _("byte or halfword not valid for base register"));
12710 constraint (inst.operands[1].reg == REG_PC
12711 && !(inst.instruction & THUMB_LOAD_BIT),
12712 _("r15 based store not allowed"));
12713 constraint (inst.operands[1].immisreg,
12714 _("invalid base register for register offset"));
12716 if (inst.operands[1].reg == REG_PC)
12717 inst.instruction = T_OPCODE_LDR_PC;
12718 else if (inst.instruction & THUMB_LOAD_BIT)
12719 inst.instruction = T_OPCODE_LDR_SP;
12721 inst.instruction = T_OPCODE_STR_SP;
12723 inst.instruction |= inst.operands[0].reg << 8;
12724 inst.relocs[0].type = BFD_RELOC_ARM_THUMB_OFFSET;
12728 constraint (inst.operands[1].reg > 7, BAD_HIREG);
12729 if (!inst.operands[1].immisreg)
12731 /* Immediate offset. */
12732 inst.instruction |= inst.operands[0].reg;
12733 inst.instruction |= inst.operands[1].reg << 3;
12734 inst.relocs[0].type = BFD_RELOC_ARM_THUMB_OFFSET;
12738 /* Register offset. */
12739 constraint (inst.operands[1].imm > 7, BAD_HIREG);
12740 constraint (inst.operands[1].negative,
12741 _("Thumb does not support this addressing mode"));
12744 switch (inst.instruction)
12746 case T_OPCODE_STR_IW: inst.instruction = T_OPCODE_STR_RW; break;
12747 case T_OPCODE_STR_IH: inst.instruction = T_OPCODE_STR_RH; break;
12748 case T_OPCODE_STR_IB: inst.instruction = T_OPCODE_STR_RB; break;
12749 case T_OPCODE_LDR_IW: inst.instruction = T_OPCODE_LDR_RW; break;
12750 case T_OPCODE_LDR_IH: inst.instruction = T_OPCODE_LDR_RH; break;
12751 case T_OPCODE_LDR_IB: inst.instruction = T_OPCODE_LDR_RB; break;
12752 case 0x5600 /* ldrsb */:
12753 case 0x5e00 /* ldrsh */: break;
12757 inst.instruction |= inst.operands[0].reg;
12758 inst.instruction |= inst.operands[1].reg << 3;
12759 inst.instruction |= inst.operands[1].imm << 6;
12765 if (!inst.operands[1].present)
12767 inst.operands[1].reg = inst.operands[0].reg + 1;
12768 constraint (inst.operands[0].reg == REG_LR,
12769 _("r14 not allowed here"));
12770 constraint (inst.operands[0].reg == REG_R12,
12771 _("r12 not allowed here"));
12774 if (inst.operands[2].writeback
12775 && (inst.operands[0].reg == inst.operands[2].reg
12776 || inst.operands[1].reg == inst.operands[2].reg))
12777 as_warn (_("base register written back, and overlaps "
12778 "one of transfer registers"));
12780 inst.instruction |= inst.operands[0].reg << 12;
12781 inst.instruction |= inst.operands[1].reg << 8;
12782 encode_thumb32_addr_mode (2, /*is_t=*/FALSE, /*is_d=*/TRUE);
12788 inst.instruction |= inst.operands[0].reg << 12;
12789 encode_thumb32_addr_mode (1, /*is_t=*/TRUE, /*is_d=*/FALSE);
12795 unsigned Rd, Rn, Rm, Ra;
12797 Rd = inst.operands[0].reg;
12798 Rn = inst.operands[1].reg;
12799 Rm = inst.operands[2].reg;
12800 Ra = inst.operands[3].reg;
12802 reject_bad_reg (Rd);
12803 reject_bad_reg (Rn);
12804 reject_bad_reg (Rm);
12805 reject_bad_reg (Ra);
12807 inst.instruction |= Rd << 8;
12808 inst.instruction |= Rn << 16;
12809 inst.instruction |= Rm;
12810 inst.instruction |= Ra << 12;
12816 unsigned RdLo, RdHi, Rn, Rm;
12818 RdLo = inst.operands[0].reg;
12819 RdHi = inst.operands[1].reg;
12820 Rn = inst.operands[2].reg;
12821 Rm = inst.operands[3].reg;
12823 reject_bad_reg (RdLo);
12824 reject_bad_reg (RdHi);
12825 reject_bad_reg (Rn);
12826 reject_bad_reg (Rm);
12828 inst.instruction |= RdLo << 12;
12829 inst.instruction |= RdHi << 8;
12830 inst.instruction |= Rn << 16;
12831 inst.instruction |= Rm;
12835 do_t_mov_cmp (void)
12839 Rn = inst.operands[0].reg;
12840 Rm = inst.operands[1].reg;
12843 set_pred_insn_type_last ();
12845 if (unified_syntax)
12847 int r0off = (inst.instruction == T_MNEM_mov
12848 || inst.instruction == T_MNEM_movs) ? 8 : 16;
12849 unsigned long opcode;
12850 bfd_boolean narrow;
12851 bfd_boolean low_regs;
12853 low_regs = (Rn <= 7 && Rm <= 7);
12854 opcode = inst.instruction;
12855 if (in_pred_block ())
12856 narrow = opcode != T_MNEM_movs;
12858 narrow = opcode != T_MNEM_movs || low_regs;
12859 if (inst.size_req == 4
12860 || inst.operands[1].shifted)
12863 /* MOVS PC, LR is encoded as SUBS PC, LR, #0. */
12864 if (opcode == T_MNEM_movs && inst.operands[1].isreg
12865 && !inst.operands[1].shifted
12869 inst.instruction = T2_SUBS_PC_LR;
12873 if (opcode == T_MNEM_cmp)
12875 constraint (Rn == REG_PC, BAD_PC);
12878 /* In the Thumb-2 ISA, use of R13 as Rm is deprecated,
12880 warn_deprecated_sp (Rm);
12881 /* R15 was documented as a valid choice for Rm in ARMv6,
12882 but as UNPREDICTABLE in ARMv7. ARM's proprietary
12883 tools reject R15, so we do too. */
12884 constraint (Rm == REG_PC, BAD_PC);
12887 reject_bad_reg (Rm);
12889 else if (opcode == T_MNEM_mov
12890 || opcode == T_MNEM_movs)
12892 if (inst.operands[1].isreg)
12894 if (opcode == T_MNEM_movs)
12896 reject_bad_reg (Rn);
12897 reject_bad_reg (Rm);
12901 /* This is mov.n. */
12902 if ((Rn == REG_SP || Rn == REG_PC)
12903 && (Rm == REG_SP || Rm == REG_PC))
12905 as_tsktsk (_("Use of r%u as a source register is "
12906 "deprecated when r%u is the destination "
12907 "register."), Rm, Rn);
12912 /* This is mov.w. */
12913 constraint (Rn == REG_PC, BAD_PC);
12914 constraint (Rm == REG_PC, BAD_PC);
12915 if (!ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_v8))
12916 constraint (Rn == REG_SP && Rm == REG_SP, BAD_SP);
12920 reject_bad_reg (Rn);
12923 if (!inst.operands[1].isreg)
12925 /* Immediate operand. */
12926 if (!in_pred_block () && opcode == T_MNEM_mov)
12928 if (low_regs && narrow)
12930 inst.instruction = THUMB_OP16 (opcode);
12931 inst.instruction |= Rn << 8;
12932 if (inst.relocs[0].type < BFD_RELOC_ARM_THUMB_ALU_ABS_G0_NC
12933 || inst.relocs[0].type > BFD_RELOC_ARM_THUMB_ALU_ABS_G3_NC)
12935 if (inst.size_req == 2)
12936 inst.relocs[0].type = BFD_RELOC_ARM_THUMB_IMM;
12938 inst.relax = opcode;
12943 constraint ((inst.relocs[0].type
12944 >= BFD_RELOC_ARM_THUMB_ALU_ABS_G0_NC)
12945 && (inst.relocs[0].type
12946 <= BFD_RELOC_ARM_THUMB_ALU_ABS_G3_NC) ,
12947 THUMB1_RELOC_ONLY);
12949 inst.instruction = THUMB_OP32 (inst.instruction);
12950 inst.instruction = (inst.instruction & 0xe1ffffff) | 0x10000000;
12951 inst.instruction |= Rn << r0off;
12952 inst.relocs[0].type = BFD_RELOC_ARM_T32_IMMEDIATE;
12955 else if (inst.operands[1].shifted && inst.operands[1].immisreg
12956 && (inst.instruction == T_MNEM_mov
12957 || inst.instruction == T_MNEM_movs))
12959 /* Register shifts are encoded as separate shift instructions. */
12960 bfd_boolean flags = (inst.instruction == T_MNEM_movs);
12962 if (in_pred_block ())
12967 if (inst.size_req == 4)
12970 if (!low_regs || inst.operands[1].imm > 7)
12976 switch (inst.operands[1].shift_kind)
12979 opcode = narrow ? T_OPCODE_LSL_R : THUMB_OP32 (T_MNEM_lsl);
12982 opcode = narrow ? T_OPCODE_ASR_R : THUMB_OP32 (T_MNEM_asr);
12985 opcode = narrow ? T_OPCODE_LSR_R : THUMB_OP32 (T_MNEM_lsr);
12988 opcode = narrow ? T_OPCODE_ROR_R : THUMB_OP32 (T_MNEM_ror);
12994 inst.instruction = opcode;
12997 inst.instruction |= Rn;
12998 inst.instruction |= inst.operands[1].imm << 3;
13003 inst.instruction |= CONDS_BIT;
13005 inst.instruction |= Rn << 8;
13006 inst.instruction |= Rm << 16;
13007 inst.instruction |= inst.operands[1].imm;
13012 /* Some mov with immediate shift have narrow variants.
13013 Register shifts are handled above. */
13014 if (low_regs && inst.operands[1].shifted
13015 && (inst.instruction == T_MNEM_mov
13016 || inst.instruction == T_MNEM_movs))
13018 if (in_pred_block ())
13019 narrow = (inst.instruction == T_MNEM_mov);
13021 narrow = (inst.instruction == T_MNEM_movs);
13026 switch (inst.operands[1].shift_kind)
13028 case SHIFT_LSL: inst.instruction = T_OPCODE_LSL_I; break;
13029 case SHIFT_LSR: inst.instruction = T_OPCODE_LSR_I; break;
13030 case SHIFT_ASR: inst.instruction = T_OPCODE_ASR_I; break;
13031 default: narrow = FALSE; break;
13037 inst.instruction |= Rn;
13038 inst.instruction |= Rm << 3;
13039 inst.relocs[0].type = BFD_RELOC_ARM_THUMB_SHIFT;
13043 inst.instruction = THUMB_OP32 (inst.instruction);
13044 inst.instruction |= Rn << r0off;
13045 encode_thumb32_shifted_operand (1);
13049 switch (inst.instruction)
13052 /* In v4t or v5t a move of two lowregs produces unpredictable
13053 results. Don't allow this. */
13056 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_v6),
13057 "MOV Rd, Rs with two low registers is not "
13058 "permitted on this architecture");
13059 ARM_MERGE_FEATURE_SETS (thumb_arch_used, thumb_arch_used,
13063 inst.instruction = T_OPCODE_MOV_HR;
13064 inst.instruction |= (Rn & 0x8) << 4;
13065 inst.instruction |= (Rn & 0x7);
13066 inst.instruction |= Rm << 3;
13070 /* We know we have low registers at this point.
13071 Generate LSLS Rd, Rs, #0. */
13072 inst.instruction = T_OPCODE_LSL_I;
13073 inst.instruction |= Rn;
13074 inst.instruction |= Rm << 3;
13080 inst.instruction = T_OPCODE_CMP_LR;
13081 inst.instruction |= Rn;
13082 inst.instruction |= Rm << 3;
13086 inst.instruction = T_OPCODE_CMP_HR;
13087 inst.instruction |= (Rn & 0x8) << 4;
13088 inst.instruction |= (Rn & 0x7);
13089 inst.instruction |= Rm << 3;
13096 inst.instruction = THUMB_OP16 (inst.instruction);
13098 /* PR 10443: Do not silently ignore shifted operands. */
13099 constraint (inst.operands[1].shifted,
13100 _("shifts in CMP/MOV instructions are only supported in unified syntax"));
13102 if (inst.operands[1].isreg)
13104 if (Rn < 8 && Rm < 8)
13106 /* A move of two lowregs is encoded as ADD Rd, Rs, #0
13107 since a MOV instruction produces unpredictable results. */
13108 if (inst.instruction == T_OPCODE_MOV_I8)
13109 inst.instruction = T_OPCODE_ADD_I3;
13111 inst.instruction = T_OPCODE_CMP_LR;
13113 inst.instruction |= Rn;
13114 inst.instruction |= Rm << 3;
13118 if (inst.instruction == T_OPCODE_MOV_I8)
13119 inst.instruction = T_OPCODE_MOV_HR;
13121 inst.instruction = T_OPCODE_CMP_HR;
13127 constraint (Rn > 7,
13128 _("only lo regs allowed with immediate"));
13129 inst.instruction |= Rn << 8;
13130 inst.relocs[0].type = BFD_RELOC_ARM_THUMB_IMM;
13141 top = (inst.instruction & 0x00800000) != 0;
13142 if (inst.relocs[0].type == BFD_RELOC_ARM_MOVW)
13144 constraint (top, _(":lower16: not allowed in this instruction"));
13145 inst.relocs[0].type = BFD_RELOC_ARM_THUMB_MOVW;
13147 else if (inst.relocs[0].type == BFD_RELOC_ARM_MOVT)
13149 constraint (!top, _(":upper16: not allowed in this instruction"));
13150 inst.relocs[0].type = BFD_RELOC_ARM_THUMB_MOVT;
13153 Rd = inst.operands[0].reg;
13154 reject_bad_reg (Rd);
13156 inst.instruction |= Rd << 8;
13157 if (inst.relocs[0].type == BFD_RELOC_UNUSED)
13159 imm = inst.relocs[0].exp.X_add_number;
13160 inst.instruction |= (imm & 0xf000) << 4;
13161 inst.instruction |= (imm & 0x0800) << 15;
13162 inst.instruction |= (imm & 0x0700) << 4;
13163 inst.instruction |= (imm & 0x00ff);
13168 do_t_mvn_tst (void)
13172 Rn = inst.operands[0].reg;
13173 Rm = inst.operands[1].reg;
13175 if (inst.instruction == T_MNEM_cmp
13176 || inst.instruction == T_MNEM_cmn)
13177 constraint (Rn == REG_PC, BAD_PC);
13179 reject_bad_reg (Rn);
13180 reject_bad_reg (Rm);
13182 if (unified_syntax)
13184 int r0off = (inst.instruction == T_MNEM_mvn
13185 || inst.instruction == T_MNEM_mvns) ? 8 : 16;
13186 bfd_boolean narrow;
13188 if (inst.size_req == 4
13189 || inst.instruction > 0xffff
13190 || inst.operands[1].shifted
13191 || Rn > 7 || Rm > 7)
13193 else if (inst.instruction == T_MNEM_cmn
13194 || inst.instruction == T_MNEM_tst)
13196 else if (THUMB_SETS_FLAGS (inst.instruction))
13197 narrow = !in_pred_block ();
13199 narrow = in_pred_block ();
13201 if (!inst.operands[1].isreg)
13203 /* For an immediate, we always generate a 32-bit opcode;
13204 section relaxation will shrink it later if possible. */
13205 if (inst.instruction < 0xffff)
13206 inst.instruction = THUMB_OP32 (inst.instruction);
13207 inst.instruction = (inst.instruction & 0xe1ffffff) | 0x10000000;
13208 inst.instruction |= Rn << r0off;
13209 inst.relocs[0].type = BFD_RELOC_ARM_T32_IMMEDIATE;
13213 /* See if we can do this with a 16-bit instruction. */
13216 inst.instruction = THUMB_OP16 (inst.instruction);
13217 inst.instruction |= Rn;
13218 inst.instruction |= Rm << 3;
13222 constraint (inst.operands[1].shifted
13223 && inst.operands[1].immisreg,
13224 _("shift must be constant"));
13225 if (inst.instruction < 0xffff)
13226 inst.instruction = THUMB_OP32 (inst.instruction);
13227 inst.instruction |= Rn << r0off;
13228 encode_thumb32_shifted_operand (1);
13234 constraint (inst.instruction > 0xffff
13235 || inst.instruction == T_MNEM_mvns, BAD_THUMB32);
13236 constraint (!inst.operands[1].isreg || inst.operands[1].shifted,
13237 _("unshifted register required"));
13238 constraint (Rn > 7 || Rm > 7,
13241 inst.instruction = THUMB_OP16 (inst.instruction);
13242 inst.instruction |= Rn;
13243 inst.instruction |= Rm << 3;
13252 if (do_vfp_nsyn_mrs () == SUCCESS)
13255 Rd = inst.operands[0].reg;
13256 reject_bad_reg (Rd);
13257 inst.instruction |= Rd << 8;
13259 if (inst.operands[1].isreg)
13261 unsigned br = inst.operands[1].reg;
13262 if (((br & 0x200) == 0) && ((br & 0xf000) != 0xf000))
13263 as_bad (_("bad register for mrs"));
13265 inst.instruction |= br & (0xf << 16);
13266 inst.instruction |= (br & 0x300) >> 4;
13267 inst.instruction |= (br & SPSR_BIT) >> 2;
13271 int flags = inst.operands[1].imm & (PSR_c|PSR_x|PSR_s|PSR_f|SPSR_BIT);
13273 if (ARM_CPU_HAS_FEATURE (selected_cpu, arm_ext_m))
13275 /* PR gas/12698: The constraint is only applied for m_profile.
13276 If the user has specified -march=all, we want to ignore it as
13277 we are building for any CPU type, including non-m variants. */
13278 bfd_boolean m_profile =
13279 !ARM_FEATURE_CORE_EQUAL (selected_cpu, arm_arch_any);
13280 constraint ((flags != 0) && m_profile, _("selected processor does "
13281 "not support requested special purpose register"));
13284 /* mrs only accepts APSR/CPSR/SPSR/CPSR_all/SPSR_all (for non-M profile
13286 constraint ((flags & ~SPSR_BIT) != (PSR_c|PSR_f),
13287 _("'APSR', 'CPSR' or 'SPSR' expected"));
13289 inst.instruction |= (flags & SPSR_BIT) >> 2;
13290 inst.instruction |= inst.operands[1].imm & 0xff;
13291 inst.instruction |= 0xf0000;
13301 if (do_vfp_nsyn_msr () == SUCCESS)
13304 constraint (!inst.operands[1].isreg,
13305 _("Thumb encoding does not support an immediate here"));
13307 if (inst.operands[0].isreg)
13308 flags = (int)(inst.operands[0].reg);
13310 flags = inst.operands[0].imm;
13312 if (ARM_CPU_HAS_FEATURE (selected_cpu, arm_ext_m))
13314 int bits = inst.operands[0].imm & (PSR_c|PSR_x|PSR_s|PSR_f|SPSR_BIT);
13316 /* PR gas/12698: The constraint is only applied for m_profile.
13317 If the user has specified -march=all, we want to ignore it as
13318 we are building for any CPU type, including non-m variants. */
13319 bfd_boolean m_profile =
13320 !ARM_FEATURE_CORE_EQUAL (selected_cpu, arm_arch_any);
13321 constraint (((ARM_CPU_HAS_FEATURE (selected_cpu, arm_ext_v6_dsp)
13322 && (bits & ~(PSR_s | PSR_f)) != 0)
13323 || (!ARM_CPU_HAS_FEATURE (selected_cpu, arm_ext_v6_dsp)
13324 && bits != PSR_f)) && m_profile,
13325 _("selected processor does not support requested special "
13326 "purpose register"));
13329 constraint ((flags & 0xff) != 0, _("selected processor does not support "
13330 "requested special purpose register"));
13332 Rn = inst.operands[1].reg;
13333 reject_bad_reg (Rn);
13335 inst.instruction |= (flags & SPSR_BIT) >> 2;
13336 inst.instruction |= (flags & 0xf0000) >> 8;
13337 inst.instruction |= (flags & 0x300) >> 4;
13338 inst.instruction |= (flags & 0xff);
13339 inst.instruction |= Rn << 16;
13345 bfd_boolean narrow;
13346 unsigned Rd, Rn, Rm;
13348 if (!inst.operands[2].present)
13349 inst.operands[2].reg = inst.operands[0].reg;
13351 Rd = inst.operands[0].reg;
13352 Rn = inst.operands[1].reg;
13353 Rm = inst.operands[2].reg;
13355 if (unified_syntax)
13357 if (inst.size_req == 4
13363 else if (inst.instruction == T_MNEM_muls)
13364 narrow = !in_pred_block ();
13366 narrow = in_pred_block ();
13370 constraint (inst.instruction == T_MNEM_muls, BAD_THUMB32);
13371 constraint (Rn > 7 || Rm > 7,
13378 /* 16-bit MULS/Conditional MUL. */
13379 inst.instruction = THUMB_OP16 (inst.instruction);
13380 inst.instruction |= Rd;
13383 inst.instruction |= Rm << 3;
13385 inst.instruction |= Rn << 3;
13387 constraint (1, _("dest must overlap one source register"));
13391 constraint (inst.instruction != T_MNEM_mul,
13392 _("Thumb-2 MUL must not set flags"));
13394 inst.instruction = THUMB_OP32 (inst.instruction);
13395 inst.instruction |= Rd << 8;
13396 inst.instruction |= Rn << 16;
13397 inst.instruction |= Rm << 0;
13399 reject_bad_reg (Rd);
13400 reject_bad_reg (Rn);
13401 reject_bad_reg (Rm);
13408 unsigned RdLo, RdHi, Rn, Rm;
13410 RdLo = inst.operands[0].reg;
13411 RdHi = inst.operands[1].reg;
13412 Rn = inst.operands[2].reg;
13413 Rm = inst.operands[3].reg;
13415 reject_bad_reg (RdLo);
13416 reject_bad_reg (RdHi);
13417 reject_bad_reg (Rn);
13418 reject_bad_reg (Rm);
13420 inst.instruction |= RdLo << 12;
13421 inst.instruction |= RdHi << 8;
13422 inst.instruction |= Rn << 16;
13423 inst.instruction |= Rm;
13426 as_tsktsk (_("rdhi and rdlo must be different"));
13432 set_pred_insn_type (NEUTRAL_IT_INSN);
13434 if (unified_syntax)
13436 if (inst.size_req == 4 || inst.operands[0].imm > 15)
13438 inst.instruction = THUMB_OP32 (inst.instruction);
13439 inst.instruction |= inst.operands[0].imm;
13443 /* PR9722: Check for Thumb2 availability before
13444 generating a thumb2 nop instruction. */
13445 if (ARM_CPU_HAS_FEATURE (selected_cpu, arm_ext_v6t2))
13447 inst.instruction = THUMB_OP16 (inst.instruction);
13448 inst.instruction |= inst.operands[0].imm << 4;
13451 inst.instruction = 0x46c0;
13456 constraint (inst.operands[0].present,
13457 _("Thumb does not support NOP with hints"));
13458 inst.instruction = 0x46c0;
13465 if (unified_syntax)
13467 bfd_boolean narrow;
13469 if (THUMB_SETS_FLAGS (inst.instruction))
13470 narrow = !in_pred_block ();
13472 narrow = in_pred_block ();
13473 if (inst.operands[0].reg > 7 || inst.operands[1].reg > 7)
13475 if (inst.size_req == 4)
13480 inst.instruction = THUMB_OP32 (inst.instruction);
13481 inst.instruction |= inst.operands[0].reg << 8;
13482 inst.instruction |= inst.operands[1].reg << 16;
13486 inst.instruction = THUMB_OP16 (inst.instruction);
13487 inst.instruction |= inst.operands[0].reg;
13488 inst.instruction |= inst.operands[1].reg << 3;
13493 constraint (inst.operands[0].reg > 7 || inst.operands[1].reg > 7,
13495 constraint (THUMB_SETS_FLAGS (inst.instruction), BAD_THUMB32);
13497 inst.instruction = THUMB_OP16 (inst.instruction);
13498 inst.instruction |= inst.operands[0].reg;
13499 inst.instruction |= inst.operands[1].reg << 3;
13508 Rd = inst.operands[0].reg;
13509 Rn = inst.operands[1].present ? inst.operands[1].reg : Rd;
13511 reject_bad_reg (Rd);
13512 /* Rn == REG_SP is unpredictable; Rn == REG_PC is MVN. */
13513 reject_bad_reg (Rn);
13515 inst.instruction |= Rd << 8;
13516 inst.instruction |= Rn << 16;
13518 if (!inst.operands[2].isreg)
13520 inst.instruction = (inst.instruction & 0xe1ffffff) | 0x10000000;
13521 inst.relocs[0].type = BFD_RELOC_ARM_T32_IMMEDIATE;
13527 Rm = inst.operands[2].reg;
13528 reject_bad_reg (Rm);
13530 constraint (inst.operands[2].shifted
13531 && inst.operands[2].immisreg,
13532 _("shift must be constant"));
13533 encode_thumb32_shifted_operand (2);
13540 unsigned Rd, Rn, Rm;
13542 Rd = inst.operands[0].reg;
13543 Rn = inst.operands[1].reg;
13544 Rm = inst.operands[2].reg;
13546 reject_bad_reg (Rd);
13547 reject_bad_reg (Rn);
13548 reject_bad_reg (Rm);
13550 inst.instruction |= Rd << 8;
13551 inst.instruction |= Rn << 16;
13552 inst.instruction |= Rm;
13553 if (inst.operands[3].present)
13555 unsigned int val = inst.relocs[0].exp.X_add_number;
13556 constraint (inst.relocs[0].exp.X_op != O_constant,
13557 _("expression too complex"));
13558 inst.instruction |= (val & 0x1c) << 10;
13559 inst.instruction |= (val & 0x03) << 6;
13566 if (!inst.operands[3].present)
13570 inst.instruction &= ~0x00000020;
13572 /* PR 10168. Swap the Rm and Rn registers. */
13573 Rtmp = inst.operands[1].reg;
13574 inst.operands[1].reg = inst.operands[2].reg;
13575 inst.operands[2].reg = Rtmp;
13583 if (inst.operands[0].immisreg)
13584 reject_bad_reg (inst.operands[0].imm);
13586 encode_thumb32_addr_mode (0, /*is_t=*/FALSE, /*is_d=*/FALSE);
13590 do_t_push_pop (void)
13594 constraint (inst.operands[0].writeback,
13595 _("push/pop do not support {reglist}^"));
13596 constraint (inst.relocs[0].type != BFD_RELOC_UNUSED,
13597 _("expression too complex"));
13599 mask = inst.operands[0].imm;
13600 if (inst.size_req != 4 && (mask & ~0xff) == 0)
13601 inst.instruction = THUMB_OP16 (inst.instruction) | mask;
13602 else if (inst.size_req != 4
13603 && (mask & ~0xff) == (1U << (inst.instruction == T_MNEM_push
13604 ? REG_LR : REG_PC)))
13606 inst.instruction = THUMB_OP16 (inst.instruction);
13607 inst.instruction |= THUMB_PP_PC_LR;
13608 inst.instruction |= mask & 0xff;
13610 else if (unified_syntax)
13612 inst.instruction = THUMB_OP32 (inst.instruction);
13613 encode_thumb2_multi (TRUE /* do_io */, 13, mask, TRUE);
13617 inst.error = _("invalid register list to push/pop instruction");
13625 if (unified_syntax)
13626 encode_thumb2_multi (FALSE /* do_io */, -1, inst.operands[0].imm, FALSE);
13629 inst.error = _("invalid register list to push/pop instruction");
13635 do_t_vscclrm (void)
13637 if (inst.operands[0].issingle)
13639 inst.instruction |= (inst.operands[0].reg & 0x1) << 22;
13640 inst.instruction |= (inst.operands[0].reg & 0x1e) << 11;
13641 inst.instruction |= inst.operands[0].imm;
13645 inst.instruction |= (inst.operands[0].reg & 0x10) << 18;
13646 inst.instruction |= (inst.operands[0].reg & 0xf) << 12;
13647 inst.instruction |= 1 << 8;
13648 inst.instruction |= inst.operands[0].imm << 1;
13657 Rd = inst.operands[0].reg;
13658 Rm = inst.operands[1].reg;
13660 reject_bad_reg (Rd);
13661 reject_bad_reg (Rm);
13663 inst.instruction |= Rd << 8;
13664 inst.instruction |= Rm << 16;
13665 inst.instruction |= Rm;
13673 Rd = inst.operands[0].reg;
13674 Rm = inst.operands[1].reg;
13676 reject_bad_reg (Rd);
13677 reject_bad_reg (Rm);
13679 if (Rd <= 7 && Rm <= 7
13680 && inst.size_req != 4)
13682 inst.instruction = THUMB_OP16 (inst.instruction);
13683 inst.instruction |= Rd;
13684 inst.instruction |= Rm << 3;
13686 else if (unified_syntax)
13688 inst.instruction = THUMB_OP32 (inst.instruction);
13689 inst.instruction |= Rd << 8;
13690 inst.instruction |= Rm << 16;
13691 inst.instruction |= Rm;
13694 inst.error = BAD_HIREG;
13702 Rd = inst.operands[0].reg;
13703 Rm = inst.operands[1].reg;
13705 reject_bad_reg (Rd);
13706 reject_bad_reg (Rm);
13708 inst.instruction |= Rd << 8;
13709 inst.instruction |= Rm;
13717 Rd = inst.operands[0].reg;
13718 Rs = (inst.operands[1].present
13719 ? inst.operands[1].reg /* Rd, Rs, foo */
13720 : inst.operands[0].reg); /* Rd, foo -> Rd, Rd, foo */
13722 reject_bad_reg (Rd);
13723 reject_bad_reg (Rs);
13724 if (inst.operands[2].isreg)
13725 reject_bad_reg (inst.operands[2].reg);
13727 inst.instruction |= Rd << 8;
13728 inst.instruction |= Rs << 16;
13729 if (!inst.operands[2].isreg)
13731 bfd_boolean narrow;
13733 if ((inst.instruction & 0x00100000) != 0)
13734 narrow = !in_pred_block ();
13736 narrow = in_pred_block ();
13738 if (Rd > 7 || Rs > 7)
13741 if (inst.size_req == 4 || !unified_syntax)
13744 if (inst.relocs[0].exp.X_op != O_constant
13745 || inst.relocs[0].exp.X_add_number != 0)
13748 /* Turn rsb #0 into 16-bit neg. We should probably do this via
13749 relaxation, but it doesn't seem worth the hassle. */
13752 inst.relocs[0].type = BFD_RELOC_UNUSED;
13753 inst.instruction = THUMB_OP16 (T_MNEM_negs);
13754 inst.instruction |= Rs << 3;
13755 inst.instruction |= Rd;
13759 inst.instruction = (inst.instruction & 0xe1ffffff) | 0x10000000;
13760 inst.relocs[0].type = BFD_RELOC_ARM_T32_IMMEDIATE;
13764 encode_thumb32_shifted_operand (2);
13770 if (warn_on_deprecated
13771 && ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_v8))
13772 as_tsktsk (_("setend use is deprecated for ARMv8"));
13774 set_pred_insn_type (OUTSIDE_PRED_INSN);
13775 if (inst.operands[0].imm)
13776 inst.instruction |= 0x8;
13782 if (!inst.operands[1].present)
13783 inst.operands[1].reg = inst.operands[0].reg;
13785 if (unified_syntax)
13787 bfd_boolean narrow;
13790 switch (inst.instruction)
13793 case T_MNEM_asrs: shift_kind = SHIFT_ASR; break;
13795 case T_MNEM_lsls: shift_kind = SHIFT_LSL; break;
13797 case T_MNEM_lsrs: shift_kind = SHIFT_LSR; break;
13799 case T_MNEM_rors: shift_kind = SHIFT_ROR; break;
13803 if (THUMB_SETS_FLAGS (inst.instruction))
13804 narrow = !in_pred_block ();
13806 narrow = in_pred_block ();
13807 if (inst.operands[0].reg > 7 || inst.operands[1].reg > 7)
13809 if (!inst.operands[2].isreg && shift_kind == SHIFT_ROR)
13811 if (inst.operands[2].isreg
13812 && (inst.operands[1].reg != inst.operands[0].reg
13813 || inst.operands[2].reg > 7))
13815 if (inst.size_req == 4)
13818 reject_bad_reg (inst.operands[0].reg);
13819 reject_bad_reg (inst.operands[1].reg);
13823 if (inst.operands[2].isreg)
13825 reject_bad_reg (inst.operands[2].reg);
13826 inst.instruction = THUMB_OP32 (inst.instruction);
13827 inst.instruction |= inst.operands[0].reg << 8;
13828 inst.instruction |= inst.operands[1].reg << 16;
13829 inst.instruction |= inst.operands[2].reg;
13831 /* PR 12854: Error on extraneous shifts. */
13832 constraint (inst.operands[2].shifted,
13833 _("extraneous shift as part of operand to shift insn"));
13837 inst.operands[1].shifted = 1;
13838 inst.operands[1].shift_kind = shift_kind;
13839 inst.instruction = THUMB_OP32 (THUMB_SETS_FLAGS (inst.instruction)
13840 ? T_MNEM_movs : T_MNEM_mov);
13841 inst.instruction |= inst.operands[0].reg << 8;
13842 encode_thumb32_shifted_operand (1);
13843 /* Prevent the incorrect generation of an ARM_IMMEDIATE fixup. */
13844 inst.relocs[0].type = BFD_RELOC_UNUSED;
13849 if (inst.operands[2].isreg)
13851 switch (shift_kind)
13853 case SHIFT_ASR: inst.instruction = T_OPCODE_ASR_R; break;
13854 case SHIFT_LSL: inst.instruction = T_OPCODE_LSL_R; break;
13855 case SHIFT_LSR: inst.instruction = T_OPCODE_LSR_R; break;
13856 case SHIFT_ROR: inst.instruction = T_OPCODE_ROR_R; break;
13860 inst.instruction |= inst.operands[0].reg;
13861 inst.instruction |= inst.operands[2].reg << 3;
13863 /* PR 12854: Error on extraneous shifts. */
13864 constraint (inst.operands[2].shifted,
13865 _("extraneous shift as part of operand to shift insn"));
13869 switch (shift_kind)
13871 case SHIFT_ASR: inst.instruction = T_OPCODE_ASR_I; break;
13872 case SHIFT_LSL: inst.instruction = T_OPCODE_LSL_I; break;
13873 case SHIFT_LSR: inst.instruction = T_OPCODE_LSR_I; break;
13876 inst.relocs[0].type = BFD_RELOC_ARM_THUMB_SHIFT;
13877 inst.instruction |= inst.operands[0].reg;
13878 inst.instruction |= inst.operands[1].reg << 3;
13884 constraint (inst.operands[0].reg > 7
13885 || inst.operands[1].reg > 7, BAD_HIREG);
13886 constraint (THUMB_SETS_FLAGS (inst.instruction), BAD_THUMB32);
13888 if (inst.operands[2].isreg) /* Rd, {Rs,} Rn */
13890 constraint (inst.operands[2].reg > 7, BAD_HIREG);
13891 constraint (inst.operands[0].reg != inst.operands[1].reg,
13892 _("source1 and dest must be same register"));
13894 switch (inst.instruction)
13896 case T_MNEM_asr: inst.instruction = T_OPCODE_ASR_R; break;
13897 case T_MNEM_lsl: inst.instruction = T_OPCODE_LSL_R; break;
13898 case T_MNEM_lsr: inst.instruction = T_OPCODE_LSR_R; break;
13899 case T_MNEM_ror: inst.instruction = T_OPCODE_ROR_R; break;
13903 inst.instruction |= inst.operands[0].reg;
13904 inst.instruction |= inst.operands[2].reg << 3;
13906 /* PR 12854: Error on extraneous shifts. */
13907 constraint (inst.operands[2].shifted,
13908 _("extraneous shift as part of operand to shift insn"));
13912 switch (inst.instruction)
13914 case T_MNEM_asr: inst.instruction = T_OPCODE_ASR_I; break;
13915 case T_MNEM_lsl: inst.instruction = T_OPCODE_LSL_I; break;
13916 case T_MNEM_lsr: inst.instruction = T_OPCODE_LSR_I; break;
13917 case T_MNEM_ror: inst.error = _("ror #imm not supported"); return;
13920 inst.relocs[0].type = BFD_RELOC_ARM_THUMB_SHIFT;
13921 inst.instruction |= inst.operands[0].reg;
13922 inst.instruction |= inst.operands[1].reg << 3;
13930 unsigned Rd, Rn, Rm;
13932 Rd = inst.operands[0].reg;
13933 Rn = inst.operands[1].reg;
13934 Rm = inst.operands[2].reg;
13936 reject_bad_reg (Rd);
13937 reject_bad_reg (Rn);
13938 reject_bad_reg (Rm);
13940 inst.instruction |= Rd << 8;
13941 inst.instruction |= Rn << 16;
13942 inst.instruction |= Rm;
13948 unsigned Rd, Rn, Rm;
13950 Rd = inst.operands[0].reg;
13951 Rm = inst.operands[1].reg;
13952 Rn = inst.operands[2].reg;
13954 reject_bad_reg (Rd);
13955 reject_bad_reg (Rn);
13956 reject_bad_reg (Rm);
13958 inst.instruction |= Rd << 8;
13959 inst.instruction |= Rn << 16;
13960 inst.instruction |= Rm;
13966 unsigned int value = inst.relocs[0].exp.X_add_number;
13967 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_v7a),
13968 _("SMC is not permitted on this architecture"));
13969 constraint (inst.relocs[0].exp.X_op != O_constant,
13970 _("expression too complex"));
13971 constraint (value > 0xf, _("immediate too large (bigger than 0xF)"));
13973 inst.relocs[0].type = BFD_RELOC_UNUSED;
13974 inst.instruction |= (value & 0x000f) << 16;
13976 /* PR gas/15623: SMC instructions must be last in an IT block. */
13977 set_pred_insn_type_last ();
13983 unsigned int value = inst.relocs[0].exp.X_add_number;
13985 inst.relocs[0].type = BFD_RELOC_UNUSED;
13986 inst.instruction |= (value & 0x0fff);
13987 inst.instruction |= (value & 0xf000) << 4;
13991 do_t_ssat_usat (int bias)
13995 Rd = inst.operands[0].reg;
13996 Rn = inst.operands[2].reg;
13998 reject_bad_reg (Rd);
13999 reject_bad_reg (Rn);
14001 inst.instruction |= Rd << 8;
14002 inst.instruction |= inst.operands[1].imm - bias;
14003 inst.instruction |= Rn << 16;
14005 if (inst.operands[3].present)
14007 offsetT shift_amount = inst.relocs[0].exp.X_add_number;
14009 inst.relocs[0].type = BFD_RELOC_UNUSED;
14011 constraint (inst.relocs[0].exp.X_op != O_constant,
14012 _("expression too complex"));
14014 if (shift_amount != 0)
14016 constraint (shift_amount > 31,
14017 _("shift expression is too large"));
14019 if (inst.operands[3].shift_kind == SHIFT_ASR)
14020 inst.instruction |= 0x00200000; /* sh bit. */
14022 inst.instruction |= (shift_amount & 0x1c) << 10;
14023 inst.instruction |= (shift_amount & 0x03) << 6;
14031 do_t_ssat_usat (1);
14039 Rd = inst.operands[0].reg;
14040 Rn = inst.operands[2].reg;
14042 reject_bad_reg (Rd);
14043 reject_bad_reg (Rn);
14045 inst.instruction |= Rd << 8;
14046 inst.instruction |= inst.operands[1].imm - 1;
14047 inst.instruction |= Rn << 16;
14053 constraint (!inst.operands[2].isreg || !inst.operands[2].preind
14054 || inst.operands[2].postind || inst.operands[2].writeback
14055 || inst.operands[2].immisreg || inst.operands[2].shifted
14056 || inst.operands[2].negative,
14059 constraint (inst.operands[2].reg == REG_PC, BAD_PC);
14061 inst.instruction |= inst.operands[0].reg << 8;
14062 inst.instruction |= inst.operands[1].reg << 12;
14063 inst.instruction |= inst.operands[2].reg << 16;
14064 inst.relocs[0].type = BFD_RELOC_ARM_T32_OFFSET_U8;
14070 if (!inst.operands[2].present)
14071 inst.operands[2].reg = inst.operands[1].reg + 1;
14073 constraint (inst.operands[0].reg == inst.operands[1].reg
14074 || inst.operands[0].reg == inst.operands[2].reg
14075 || inst.operands[0].reg == inst.operands[3].reg,
14078 inst.instruction |= inst.operands[0].reg;
14079 inst.instruction |= inst.operands[1].reg << 12;
14080 inst.instruction |= inst.operands[2].reg << 8;
14081 inst.instruction |= inst.operands[3].reg << 16;
14087 unsigned Rd, Rn, Rm;
14089 Rd = inst.operands[0].reg;
14090 Rn = inst.operands[1].reg;
14091 Rm = inst.operands[2].reg;
14093 reject_bad_reg (Rd);
14094 reject_bad_reg (Rn);
14095 reject_bad_reg (Rm);
14097 inst.instruction |= Rd << 8;
14098 inst.instruction |= Rn << 16;
14099 inst.instruction |= Rm;
14100 inst.instruction |= inst.operands[3].imm << 4;
14108 Rd = inst.operands[0].reg;
14109 Rm = inst.operands[1].reg;
14111 reject_bad_reg (Rd);
14112 reject_bad_reg (Rm);
14114 if (inst.instruction <= 0xffff
14115 && inst.size_req != 4
14116 && Rd <= 7 && Rm <= 7
14117 && (!inst.operands[2].present || inst.operands[2].imm == 0))
14119 inst.instruction = THUMB_OP16 (inst.instruction);
14120 inst.instruction |= Rd;
14121 inst.instruction |= Rm << 3;
14123 else if (unified_syntax)
14125 if (inst.instruction <= 0xffff)
14126 inst.instruction = THUMB_OP32 (inst.instruction);
14127 inst.instruction |= Rd << 8;
14128 inst.instruction |= Rm;
14129 inst.instruction |= inst.operands[2].imm << 4;
14133 constraint (inst.operands[2].present && inst.operands[2].imm != 0,
14134 _("Thumb encoding does not support rotation"));
14135 constraint (1, BAD_HIREG);
14142 inst.relocs[0].type = BFD_RELOC_ARM_SWI;
14151 half = (inst.instruction & 0x10) != 0;
14152 set_pred_insn_type_last ();
14153 constraint (inst.operands[0].immisreg,
14154 _("instruction requires register index"));
14156 Rn = inst.operands[0].reg;
14157 Rm = inst.operands[0].imm;
14159 if (!ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_v8))
14160 constraint (Rn == REG_SP, BAD_SP);
14161 reject_bad_reg (Rm);
14163 constraint (!half && inst.operands[0].shifted,
14164 _("instruction does not allow shifted index"));
14165 inst.instruction |= (Rn << 16) | Rm;
14171 if (!inst.operands[0].present)
14172 inst.operands[0].imm = 0;
14174 if ((unsigned int) inst.operands[0].imm > 255 || inst.size_req == 4)
14176 constraint (inst.size_req == 2,
14177 _("immediate value out of range"));
14178 inst.instruction = THUMB_OP32 (inst.instruction);
14179 inst.instruction |= (inst.operands[0].imm & 0xf000u) << 4;
14180 inst.instruction |= (inst.operands[0].imm & 0x0fffu) << 0;
14184 inst.instruction = THUMB_OP16 (inst.instruction);
14185 inst.instruction |= inst.operands[0].imm;
14188 set_pred_insn_type (NEUTRAL_IT_INSN);
14195 do_t_ssat_usat (0);
14203 Rd = inst.operands[0].reg;
14204 Rn = inst.operands[2].reg;
14206 reject_bad_reg (Rd);
14207 reject_bad_reg (Rn);
14209 inst.instruction |= Rd << 8;
14210 inst.instruction |= inst.operands[1].imm;
14211 inst.instruction |= Rn << 16;
14214 /* Checking the range of the branch offset (VAL) with NBITS bits
14215 and IS_SIGNED signedness. Also checks the LSB to be 0. */
14217 v8_1_branch_value_check (int val, int nbits, int is_signed)
14219 gas_assert (nbits > 0 && nbits <= 32);
14222 int cmp = (1 << (nbits - 1));
14223 if ((val < -cmp) || (val >= cmp) || (val & 0x01))
14228 if ((val <= 0) || (val >= (1 << nbits)) || (val & 0x1))
14234 /* For branches in Armv8.1-M Mainline. */
14236 do_t_branch_future (void)
14238 unsigned long insn = inst.instruction;
14240 inst.instruction = THUMB_OP32 (inst.instruction);
14241 if (inst.operands[0].hasreloc == 0)
14243 if (v8_1_branch_value_check (inst.operands[0].imm, 5, FALSE) == FAIL)
14244 as_bad (BAD_BRANCH_OFF);
14246 inst.instruction |= ((inst.operands[0].imm & 0x1f) >> 1) << 23;
14250 inst.relocs[0].type = BFD_RELOC_THUMB_PCREL_BRANCH5;
14251 inst.relocs[0].pc_rel = 1;
14257 if (inst.operands[1].hasreloc == 0)
14259 int val = inst.operands[1].imm;
14260 if (v8_1_branch_value_check (inst.operands[1].imm, 17, TRUE) == FAIL)
14261 as_bad (BAD_BRANCH_OFF);
14263 int immA = (val & 0x0001f000) >> 12;
14264 int immB = (val & 0x00000ffc) >> 2;
14265 int immC = (val & 0x00000002) >> 1;
14266 inst.instruction |= (immA << 16) | (immB << 1) | (immC << 11);
14270 inst.relocs[1].type = BFD_RELOC_ARM_THUMB_BF17;
14271 inst.relocs[1].pc_rel = 1;
14276 if (inst.operands[1].hasreloc == 0)
14278 int val = inst.operands[1].imm;
14279 if (v8_1_branch_value_check (inst.operands[1].imm, 19, TRUE) == FAIL)
14280 as_bad (BAD_BRANCH_OFF);
14282 int immA = (val & 0x0007f000) >> 12;
14283 int immB = (val & 0x00000ffc) >> 2;
14284 int immC = (val & 0x00000002) >> 1;
14285 inst.instruction |= (immA << 16) | (immB << 1) | (immC << 11);
14289 inst.relocs[1].type = BFD_RELOC_ARM_THUMB_BF19;
14290 inst.relocs[1].pc_rel = 1;
14294 case T_MNEM_bfcsel:
14296 if (inst.operands[1].hasreloc == 0)
14298 int val = inst.operands[1].imm;
14299 int immA = (val & 0x00001000) >> 12;
14300 int immB = (val & 0x00000ffc) >> 2;
14301 int immC = (val & 0x00000002) >> 1;
14302 inst.instruction |= (immA << 16) | (immB << 1) | (immC << 11);
14306 inst.relocs[1].type = BFD_RELOC_ARM_THUMB_BF13;
14307 inst.relocs[1].pc_rel = 1;
14311 if (inst.operands[2].hasreloc == 0)
14313 constraint ((inst.operands[0].hasreloc != 0), BAD_ARGS);
14314 int val2 = inst.operands[2].imm;
14315 int val0 = inst.operands[0].imm & 0x1f;
14316 int diff = val2 - val0;
14318 inst.instruction |= 1 << 17; /* T bit. */
14319 else if (diff != 2)
14320 as_bad (_("out of range label-relative fixup value"));
14324 constraint ((inst.operands[0].hasreloc == 0), BAD_ARGS);
14325 inst.relocs[2].type = BFD_RELOC_THUMB_PCREL_BFCSEL;
14326 inst.relocs[2].pc_rel = 1;
14330 constraint (inst.cond != COND_ALWAYS, BAD_COND);
14331 inst.instruction |= (inst.operands[3].imm & 0xf) << 18;
14336 inst.instruction |= inst.operands[1].reg << 16;
14343 /* Helper function for do_t_loloop to handle relocations. */
14345 v8_1_loop_reloc (int is_le)
14347 if (inst.relocs[0].exp.X_op == O_constant)
14349 int value = inst.relocs[0].exp.X_add_number;
14350 value = (is_le) ? -value : value;
14352 if (v8_1_branch_value_check (value, 12, FALSE) == FAIL)
14353 as_bad (BAD_BRANCH_OFF);
14357 immh = (value & 0x00000ffc) >> 2;
14358 imml = (value & 0x00000002) >> 1;
14360 inst.instruction |= (imml << 11) | (immh << 1);
14364 inst.relocs[0].type = BFD_RELOC_ARM_THUMB_LOOP12;
14365 inst.relocs[0].pc_rel = 1;
14369 /* For shifts with four operands in MVE. */
14371 do_mve_scalar_shift1 (void)
14373 unsigned int value = inst.operands[2].imm;
14375 inst.instruction |= inst.operands[0].reg << 16;
14376 inst.instruction |= inst.operands[1].reg << 8;
14378 /* Setting the bit for saturation. */
14379 inst.instruction |= ((value == 64) ? 0: 1) << 7;
14381 /* Assuming Rm is already checked not to be 11x1. */
14382 constraint (inst.operands[3].reg == inst.operands[0].reg, BAD_OVERLAP);
14383 constraint (inst.operands[3].reg == inst.operands[1].reg, BAD_OVERLAP);
14384 inst.instruction |= inst.operands[3].reg << 12;
14387 /* For shifts in MVE. */
14389 do_mve_scalar_shift (void)
14391 if (!inst.operands[2].present)
14393 inst.operands[2] = inst.operands[1];
14394 inst.operands[1].reg = 0xf;
14397 inst.instruction |= inst.operands[0].reg << 16;
14398 inst.instruction |= inst.operands[1].reg << 8;
14400 if (inst.operands[2].isreg)
14402 /* Assuming Rm is already checked not to be 11x1. */
14403 constraint (inst.operands[2].reg == inst.operands[0].reg, BAD_OVERLAP);
14404 constraint (inst.operands[2].reg == inst.operands[1].reg, BAD_OVERLAP);
14405 inst.instruction |= inst.operands[2].reg << 12;
14409 /* Assuming imm is already checked as [1,32]. */
14410 unsigned int value = inst.operands[2].imm;
14411 inst.instruction |= (value & 0x1c) << 10;
14412 inst.instruction |= (value & 0x03) << 6;
14413 /* Change last 4 bits from 0xd to 0xf. */
14414 inst.instruction |= 0x2;
14418 /* MVE instruction encoder helpers. */
14419 #define M_MNEM_vabav 0xee800f01
14420 #define M_MNEM_vmladav 0xeef00e00
14421 #define M_MNEM_vmladava 0xeef00e20
14422 #define M_MNEM_vmladavx 0xeef01e00
14423 #define M_MNEM_vmladavax 0xeef01e20
14424 #define M_MNEM_vmlsdav 0xeef00e01
14425 #define M_MNEM_vmlsdava 0xeef00e21
14426 #define M_MNEM_vmlsdavx 0xeef01e01
14427 #define M_MNEM_vmlsdavax 0xeef01e21
14428 #define M_MNEM_vmullt 0xee011e00
14429 #define M_MNEM_vmullb 0xee010e00
14430 #define M_MNEM_vst20 0xfc801e00
14431 #define M_MNEM_vst21 0xfc801e20
14432 #define M_MNEM_vst40 0xfc801e01
14433 #define M_MNEM_vst41 0xfc801e21
14434 #define M_MNEM_vst42 0xfc801e41
14435 #define M_MNEM_vst43 0xfc801e61
14436 #define M_MNEM_vld20 0xfc901e00
14437 #define M_MNEM_vld21 0xfc901e20
14438 #define M_MNEM_vld40 0xfc901e01
14439 #define M_MNEM_vld41 0xfc901e21
14440 #define M_MNEM_vld42 0xfc901e41
14441 #define M_MNEM_vld43 0xfc901e61
14442 #define M_MNEM_vstrb 0xec000e00
14443 #define M_MNEM_vstrh 0xec000e10
14444 #define M_MNEM_vstrw 0xec000e40
14445 #define M_MNEM_vstrd 0xec000e50
14446 #define M_MNEM_vldrb 0xec100e00
14447 #define M_MNEM_vldrh 0xec100e10
14448 #define M_MNEM_vldrw 0xec100e40
14449 #define M_MNEM_vldrd 0xec100e50
14450 #define M_MNEM_vmovlt 0xeea01f40
14451 #define M_MNEM_vmovlb 0xeea00f40
14452 #define M_MNEM_vmovnt 0xfe311e81
14453 #define M_MNEM_vmovnb 0xfe310e81
14454 #define M_MNEM_vadc 0xee300f00
14455 #define M_MNEM_vadci 0xee301f00
14456 #define M_MNEM_vbrsr 0xfe011e60
14457 #define M_MNEM_vaddlv 0xee890f00
14458 #define M_MNEM_vaddlva 0xee890f20
14459 #define M_MNEM_vaddv 0xeef10f00
14460 #define M_MNEM_vaddva 0xeef10f20
14461 #define M_MNEM_vddup 0xee011f6e
14462 #define M_MNEM_vdwdup 0xee011f60
14463 #define M_MNEM_vidup 0xee010f6e
14464 #define M_MNEM_viwdup 0xee010f60
14465 #define M_MNEM_vmaxv 0xeee20f00
14466 #define M_MNEM_vmaxav 0xeee00f00
14467 #define M_MNEM_vminv 0xeee20f80
14468 #define M_MNEM_vminav 0xeee00f80
14469 #define M_MNEM_vmlaldav 0xee800e00
14470 #define M_MNEM_vmlaldava 0xee800e20
14471 #define M_MNEM_vmlaldavx 0xee801e00
14472 #define M_MNEM_vmlaldavax 0xee801e20
14473 #define M_MNEM_vmlsldav 0xee800e01
14474 #define M_MNEM_vmlsldava 0xee800e21
14475 #define M_MNEM_vmlsldavx 0xee801e01
14476 #define M_MNEM_vmlsldavax 0xee801e21
14477 #define M_MNEM_vrmlaldavhx 0xee801f00
14478 #define M_MNEM_vrmlaldavhax 0xee801f20
14479 #define M_MNEM_vrmlsldavh 0xfe800e01
14480 #define M_MNEM_vrmlsldavha 0xfe800e21
14481 #define M_MNEM_vrmlsldavhx 0xfe801e01
14482 #define M_MNEM_vrmlsldavhax 0xfe801e21
14483 #define M_MNEM_vqmovnt 0xee331e01
14484 #define M_MNEM_vqmovnb 0xee330e01
14485 #define M_MNEM_vqmovunt 0xee311e81
14486 #define M_MNEM_vqmovunb 0xee310e81
14487 #define M_MNEM_vshrnt 0xee801fc1
14488 #define M_MNEM_vshrnb 0xee800fc1
14489 #define M_MNEM_vrshrnt 0xfe801fc1
14490 #define M_MNEM_vqshrnt 0xee801f40
14491 #define M_MNEM_vqshrnb 0xee800f40
14492 #define M_MNEM_vqshrunt 0xee801fc0
14493 #define M_MNEM_vqshrunb 0xee800fc0
14494 #define M_MNEM_vrshrnb 0xfe800fc1
14495 #define M_MNEM_vqrshrnt 0xee801f41
14496 #define M_MNEM_vqrshrnb 0xee800f41
14497 #define M_MNEM_vqrshrunt 0xfe801fc0
14498 #define M_MNEM_vqrshrunb 0xfe800fc0
14500 /* Neon instruction encoder helpers. */
14502 /* Encodings for the different types for various Neon opcodes. */
14504 /* An "invalid" code for the following tables. */
14507 struct neon_tab_entry
14510 unsigned float_or_poly;
14511 unsigned scalar_or_imm;
14514 /* Map overloaded Neon opcodes to their respective encodings. */
14515 #define NEON_ENC_TAB \
14516 X(vabd, 0x0000700, 0x1200d00, N_INV), \
14517 X(vabdl, 0x0800700, N_INV, N_INV), \
14518 X(vmax, 0x0000600, 0x0000f00, N_INV), \
14519 X(vmin, 0x0000610, 0x0200f00, N_INV), \
14520 X(vpadd, 0x0000b10, 0x1000d00, N_INV), \
14521 X(vpmax, 0x0000a00, 0x1000f00, N_INV), \
14522 X(vpmin, 0x0000a10, 0x1200f00, N_INV), \
14523 X(vadd, 0x0000800, 0x0000d00, N_INV), \
14524 X(vaddl, 0x0800000, N_INV, N_INV), \
14525 X(vsub, 0x1000800, 0x0200d00, N_INV), \
14526 X(vsubl, 0x0800200, N_INV, N_INV), \
14527 X(vceq, 0x1000810, 0x0000e00, 0x1b10100), \
14528 X(vcge, 0x0000310, 0x1000e00, 0x1b10080), \
14529 X(vcgt, 0x0000300, 0x1200e00, 0x1b10000), \
14530 /* Register variants of the following two instructions are encoded as
14531 vcge / vcgt with the operands reversed. */ \
14532 X(vclt, 0x0000300, 0x1200e00, 0x1b10200), \
14533 X(vcle, 0x0000310, 0x1000e00, 0x1b10180), \
14534 X(vfma, N_INV, 0x0000c10, N_INV), \
14535 X(vfms, N_INV, 0x0200c10, N_INV), \
14536 X(vmla, 0x0000900, 0x0000d10, 0x0800040), \
14537 X(vmls, 0x1000900, 0x0200d10, 0x0800440), \
14538 X(vmul, 0x0000910, 0x1000d10, 0x0800840), \
14539 X(vmull, 0x0800c00, 0x0800e00, 0x0800a40), /* polynomial not float. */ \
14540 X(vmlal, 0x0800800, N_INV, 0x0800240), \
14541 X(vmlsl, 0x0800a00, N_INV, 0x0800640), \
14542 X(vqdmlal, 0x0800900, N_INV, 0x0800340), \
14543 X(vqdmlsl, 0x0800b00, N_INV, 0x0800740), \
14544 X(vqdmull, 0x0800d00, N_INV, 0x0800b40), \
14545 X(vqdmulh, 0x0000b00, N_INV, 0x0800c40), \
14546 X(vqrdmulh, 0x1000b00, N_INV, 0x0800d40), \
14547 X(vqrdmlah, 0x3000b10, N_INV, 0x0800e40), \
14548 X(vqrdmlsh, 0x3000c10, N_INV, 0x0800f40), \
14549 X(vshl, 0x0000400, N_INV, 0x0800510), \
14550 X(vqshl, 0x0000410, N_INV, 0x0800710), \
14551 X(vand, 0x0000110, N_INV, 0x0800030), \
14552 X(vbic, 0x0100110, N_INV, 0x0800030), \
14553 X(veor, 0x1000110, N_INV, N_INV), \
14554 X(vorn, 0x0300110, N_INV, 0x0800010), \
14555 X(vorr, 0x0200110, N_INV, 0x0800010), \
14556 X(vmvn, 0x1b00580, N_INV, 0x0800030), \
14557 X(vshll, 0x1b20300, N_INV, 0x0800a10), /* max shift, immediate. */ \
14558 X(vcvt, 0x1b30600, N_INV, 0x0800e10), /* integer, fixed-point. */ \
14559 X(vdup, 0xe800b10, N_INV, 0x1b00c00), /* arm, scalar. */ \
14560 X(vld1, 0x0200000, 0x0a00000, 0x0a00c00), /* interlv, lane, dup. */ \
14561 X(vst1, 0x0000000, 0x0800000, N_INV), \
14562 X(vld2, 0x0200100, 0x0a00100, 0x0a00d00), \
14563 X(vst2, 0x0000100, 0x0800100, N_INV), \
14564 X(vld3, 0x0200200, 0x0a00200, 0x0a00e00), \
14565 X(vst3, 0x0000200, 0x0800200, N_INV), \
14566 X(vld4, 0x0200300, 0x0a00300, 0x0a00f00), \
14567 X(vst4, 0x0000300, 0x0800300, N_INV), \
14568 X(vmovn, 0x1b20200, N_INV, N_INV), \
14569 X(vtrn, 0x1b20080, N_INV, N_INV), \
14570 X(vqmovn, 0x1b20200, N_INV, N_INV), \
14571 X(vqmovun, 0x1b20240, N_INV, N_INV), \
14572 X(vnmul, 0xe200a40, 0xe200b40, N_INV), \
14573 X(vnmla, 0xe100a40, 0xe100b40, N_INV), \
14574 X(vnmls, 0xe100a00, 0xe100b00, N_INV), \
14575 X(vfnma, 0xe900a40, 0xe900b40, N_INV), \
14576 X(vfnms, 0xe900a00, 0xe900b00, N_INV), \
14577 X(vcmp, 0xeb40a40, 0xeb40b40, N_INV), \
14578 X(vcmpz, 0xeb50a40, 0xeb50b40, N_INV), \
14579 X(vcmpe, 0xeb40ac0, 0xeb40bc0, N_INV), \
14580 X(vcmpez, 0xeb50ac0, 0xeb50bc0, N_INV), \
14581 X(vseleq, 0xe000a00, N_INV, N_INV), \
14582 X(vselvs, 0xe100a00, N_INV, N_INV), \
14583 X(vselge, 0xe200a00, N_INV, N_INV), \
14584 X(vselgt, 0xe300a00, N_INV, N_INV), \
14585 X(vmaxnm, 0xe800a00, 0x3000f10, N_INV), \
14586 X(vminnm, 0xe800a40, 0x3200f10, N_INV), \
14587 X(vcvta, 0xebc0a40, 0x3bb0000, N_INV), \
14588 X(vrintr, 0xeb60a40, 0x3ba0400, N_INV), \
14589 X(vrinta, 0xeb80a40, 0x3ba0400, N_INV), \
14590 X(aes, 0x3b00300, N_INV, N_INV), \
14591 X(sha3op, 0x2000c00, N_INV, N_INV), \
14592 X(sha1h, 0x3b902c0, N_INV, N_INV), \
14593 X(sha2op, 0x3ba0380, N_INV, N_INV)
14597 #define X(OPC,I,F,S) N_MNEM_##OPC
14602 static const struct neon_tab_entry neon_enc_tab[] =
14604 #define X(OPC,I,F,S) { (I), (F), (S) }
14609 /* Do not use these macros; instead, use NEON_ENCODE defined below. */
14610 #define NEON_ENC_INTEGER_(X) (neon_enc_tab[(X) & 0x0fffffff].integer)
14611 #define NEON_ENC_ARMREG_(X) (neon_enc_tab[(X) & 0x0fffffff].integer)
14612 #define NEON_ENC_POLY_(X) (neon_enc_tab[(X) & 0x0fffffff].float_or_poly)
14613 #define NEON_ENC_FLOAT_(X) (neon_enc_tab[(X) & 0x0fffffff].float_or_poly)
14614 #define NEON_ENC_SCALAR_(X) (neon_enc_tab[(X) & 0x0fffffff].scalar_or_imm)
14615 #define NEON_ENC_IMMED_(X) (neon_enc_tab[(X) & 0x0fffffff].scalar_or_imm)
14616 #define NEON_ENC_INTERLV_(X) (neon_enc_tab[(X) & 0x0fffffff].integer)
14617 #define NEON_ENC_LANE_(X) (neon_enc_tab[(X) & 0x0fffffff].float_or_poly)
14618 #define NEON_ENC_DUP_(X) (neon_enc_tab[(X) & 0x0fffffff].scalar_or_imm)
14619 #define NEON_ENC_SINGLE_(X) \
14620 ((neon_enc_tab[(X) & 0x0fffffff].integer) | ((X) & 0xf0000000))
14621 #define NEON_ENC_DOUBLE_(X) \
14622 ((neon_enc_tab[(X) & 0x0fffffff].float_or_poly) | ((X) & 0xf0000000))
14623 #define NEON_ENC_FPV8_(X) \
14624 ((neon_enc_tab[(X) & 0x0fffffff].integer) | ((X) & 0xf000000))
14626 #define NEON_ENCODE(type, inst) \
14629 inst.instruction = NEON_ENC_##type##_ (inst.instruction); \
14630 inst.is_neon = 1; \
14634 #define check_neon_suffixes \
14637 if (!inst.error && inst.vectype.elems > 0 && !inst.is_neon) \
14639 as_bad (_("invalid neon suffix for non neon instruction")); \
14645 /* Define shapes for instruction operands. The following mnemonic characters
14646 are used in this table:
14648 F - VFP S<n> register
14649 D - Neon D<n> register
14650 Q - Neon Q<n> register
14654 L - D<n> register list
14656 This table is used to generate various data:
14657 - enumerations of the form NS_DDR to be used as arguments to
14659 - a table classifying shapes into single, double, quad, mixed.
14660 - a table used to drive neon_select_shape. */
14662 #define NEON_SHAPE_DEF \
14663 X(4, (R, R, Q, Q), QUAD), \
14664 X(4, (Q, R, R, I), QUAD), \
14665 X(4, (R, R, S, S), QUAD), \
14666 X(4, (S, S, R, R), QUAD), \
14667 X(3, (Q, R, I), QUAD), \
14668 X(3, (I, Q, Q), QUAD), \
14669 X(3, (I, Q, R), QUAD), \
14670 X(3, (R, Q, Q), QUAD), \
14671 X(3, (D, D, D), DOUBLE), \
14672 X(3, (Q, Q, Q), QUAD), \
14673 X(3, (D, D, I), DOUBLE), \
14674 X(3, (Q, Q, I), QUAD), \
14675 X(3, (D, D, S), DOUBLE), \
14676 X(3, (Q, Q, S), QUAD), \
14677 X(3, (Q, Q, R), QUAD), \
14678 X(3, (R, R, Q), QUAD), \
14679 X(2, (R, Q), QUAD), \
14680 X(2, (D, D), DOUBLE), \
14681 X(2, (Q, Q), QUAD), \
14682 X(2, (D, S), DOUBLE), \
14683 X(2, (Q, S), QUAD), \
14684 X(2, (D, R), DOUBLE), \
14685 X(2, (Q, R), QUAD), \
14686 X(2, (D, I), DOUBLE), \
14687 X(2, (Q, I), QUAD), \
14688 X(3, (D, L, D), DOUBLE), \
14689 X(2, (D, Q), MIXED), \
14690 X(2, (Q, D), MIXED), \
14691 X(3, (D, Q, I), MIXED), \
14692 X(3, (Q, D, I), MIXED), \
14693 X(3, (Q, D, D), MIXED), \
14694 X(3, (D, Q, Q), MIXED), \
14695 X(3, (Q, Q, D), MIXED), \
14696 X(3, (Q, D, S), MIXED), \
14697 X(3, (D, Q, S), MIXED), \
14698 X(4, (D, D, D, I), DOUBLE), \
14699 X(4, (Q, Q, Q, I), QUAD), \
14700 X(4, (D, D, S, I), DOUBLE), \
14701 X(4, (Q, Q, S, I), QUAD), \
14702 X(2, (F, F), SINGLE), \
14703 X(3, (F, F, F), SINGLE), \
14704 X(2, (F, I), SINGLE), \
14705 X(2, (F, D), MIXED), \
14706 X(2, (D, F), MIXED), \
14707 X(3, (F, F, I), MIXED), \
14708 X(4, (R, R, F, F), SINGLE), \
14709 X(4, (F, F, R, R), SINGLE), \
14710 X(3, (D, R, R), DOUBLE), \
14711 X(3, (R, R, D), DOUBLE), \
14712 X(2, (S, R), SINGLE), \
14713 X(2, (R, S), SINGLE), \
14714 X(2, (F, R), SINGLE), \
14715 X(2, (R, F), SINGLE), \
14716 /* Used for MVE tail predicated loop instructions. */\
14717 X(2, (R, R), QUAD), \
14718 /* Half float shape supported so far. */\
14719 X (2, (H, D), MIXED), \
14720 X (2, (D, H), MIXED), \
14721 X (2, (H, F), MIXED), \
14722 X (2, (F, H), MIXED), \
14723 X (2, (H, H), HALF), \
14724 X (2, (H, R), HALF), \
14725 X (2, (R, H), HALF), \
14726 X (2, (H, I), HALF), \
14727 X (3, (H, H, H), HALF), \
14728 X (3, (H, F, I), MIXED), \
14729 X (3, (F, H, I), MIXED), \
14730 X (3, (D, H, H), MIXED), \
14731 X (3, (D, H, S), MIXED)
14733 #define S2(A,B) NS_##A##B
14734 #define S3(A,B,C) NS_##A##B##C
14735 #define S4(A,B,C,D) NS_##A##B##C##D
14737 #define X(N, L, C) S##N L
14750 enum neon_shape_class
14759 #define X(N, L, C) SC_##C
14761 static enum neon_shape_class neon_shape_class[] =
14780 /* Register widths of above. */
14781 static unsigned neon_shape_el_size[] =
14793 struct neon_shape_info
14796 enum neon_shape_el el[NEON_MAX_TYPE_ELS];
14799 #define S2(A,B) { SE_##A, SE_##B }
14800 #define S3(A,B,C) { SE_##A, SE_##B, SE_##C }
14801 #define S4(A,B,C,D) { SE_##A, SE_##B, SE_##C, SE_##D }
14803 #define X(N, L, C) { N, S##N L }
14805 static struct neon_shape_info neon_shape_tab[] =
14815 /* Bit masks used in type checking given instructions.
14816 'N_EQK' means the type must be the same as (or based on in some way) the key
14817 type, which itself is marked with the 'N_KEY' bit. If the 'N_EQK' bit is
14818 set, various other bits can be set as well in order to modify the meaning of
14819 the type constraint. */
14821 enum neon_type_mask
14845 N_KEY = 0x1000000, /* Key element (main type specifier). */
14846 N_EQK = 0x2000000, /* Given operand has the same type & size as the key. */
14847 N_VFP = 0x4000000, /* VFP mode: operand size must match register width. */
14848 N_UNT = 0x8000000, /* Must be explicitly untyped. */
14849 N_DBL = 0x0000001, /* If N_EQK, this operand is twice the size. */
14850 N_HLF = 0x0000002, /* If N_EQK, this operand is half the size. */
14851 N_SGN = 0x0000004, /* If N_EQK, this operand is forced to be signed. */
14852 N_UNS = 0x0000008, /* If N_EQK, this operand is forced to be unsigned. */
14853 N_INT = 0x0000010, /* If N_EQK, this operand is forced to be integer. */
14854 N_FLT = 0x0000020, /* If N_EQK, this operand is forced to be float. */
14855 N_SIZ = 0x0000040, /* If N_EQK, this operand is forced to be size-only. */
14857 N_MAX_NONSPECIAL = N_P64
14860 #define N_ALLMODS (N_DBL | N_HLF | N_SGN | N_UNS | N_INT | N_FLT | N_SIZ)
14862 #define N_SU_ALL (N_S8 | N_S16 | N_S32 | N_S64 | N_U8 | N_U16 | N_U32 | N_U64)
14863 #define N_SU_32 (N_S8 | N_S16 | N_S32 | N_U8 | N_U16 | N_U32)
14864 #define N_SU_16_64 (N_S16 | N_S32 | N_S64 | N_U16 | N_U32 | N_U64)
14865 #define N_S_32 (N_S8 | N_S16 | N_S32)
14866 #define N_F_16_32 (N_F16 | N_F32)
14867 #define N_SUF_32 (N_SU_32 | N_F_16_32)
14868 #define N_I_ALL (N_I8 | N_I16 | N_I32 | N_I64)
14869 #define N_IF_32 (N_I8 | N_I16 | N_I32 | N_F16 | N_F32)
14870 #define N_F_ALL (N_F16 | N_F32 | N_F64)
14871 #define N_I_MVE (N_I8 | N_I16 | N_I32)
14872 #define N_F_MVE (N_F16 | N_F32)
14873 #define N_SU_MVE (N_S8 | N_S16 | N_S32 | N_U8 | N_U16 | N_U32)
14875 /* Pass this as the first type argument to neon_check_type to ignore types
14877 #define N_IGNORE_TYPE (N_KEY | N_EQK)
14879 /* Select a "shape" for the current instruction (describing register types or
14880 sizes) from a list of alternatives. Return NS_NULL if the current instruction
14881 doesn't fit. For non-polymorphic shapes, checking is usually done as a
14882 function of operand parsing, so this function doesn't need to be called.
14883 Shapes should be listed in order of decreasing length. */
14885 static enum neon_shape
14886 neon_select_shape (enum neon_shape shape, ...)
14889 enum neon_shape first_shape = shape;
14891 /* Fix missing optional operands. FIXME: we don't know at this point how
14892 many arguments we should have, so this makes the assumption that we have
14893 > 1. This is true of all current Neon opcodes, I think, but may not be
14894 true in the future. */
14895 if (!inst.operands[1].present)
14896 inst.operands[1] = inst.operands[0];
14898 va_start (ap, shape);
14900 for (; shape != NS_NULL; shape = (enum neon_shape) va_arg (ap, int))
14905 for (j = 0; j < neon_shape_tab[shape].els; j++)
14907 if (!inst.operands[j].present)
14913 switch (neon_shape_tab[shape].el[j])
14915 /* If a .f16, .16, .u16, .s16 type specifier is given over
14916 a VFP single precision register operand, it's essentially
14917 means only half of the register is used.
14919 If the type specifier is given after the mnemonics, the
14920 information is stored in inst.vectype. If the type specifier
14921 is given after register operand, the information is stored
14922 in inst.operands[].vectype.
14924 When there is only one type specifier, and all the register
14925 operands are the same type of hardware register, the type
14926 specifier applies to all register operands.
14928 If no type specifier is given, the shape is inferred from
14929 operand information.
14932 vadd.f16 s0, s1, s2: NS_HHH
14933 vabs.f16 s0, s1: NS_HH
14934 vmov.f16 s0, r1: NS_HR
14935 vmov.f16 r0, s1: NS_RH
14936 vcvt.f16 r0, s1: NS_RH
14937 vcvt.f16.s32 s2, s2, #29: NS_HFI
14938 vcvt.f16.s32 s2, s2: NS_HF
14941 if (!(inst.operands[j].isreg
14942 && inst.operands[j].isvec
14943 && inst.operands[j].issingle
14944 && !inst.operands[j].isquad
14945 && ((inst.vectype.elems == 1
14946 && inst.vectype.el[0].size == 16)
14947 || (inst.vectype.elems > 1
14948 && inst.vectype.el[j].size == 16)
14949 || (inst.vectype.elems == 0
14950 && inst.operands[j].vectype.type != NT_invtype
14951 && inst.operands[j].vectype.size == 16))))
14956 if (!(inst.operands[j].isreg
14957 && inst.operands[j].isvec
14958 && inst.operands[j].issingle
14959 && !inst.operands[j].isquad
14960 && ((inst.vectype.elems == 1 && inst.vectype.el[0].size == 32)
14961 || (inst.vectype.elems > 1 && inst.vectype.el[j].size == 32)
14962 || (inst.vectype.elems == 0
14963 && (inst.operands[j].vectype.size == 32
14964 || inst.operands[j].vectype.type == NT_invtype)))))
14969 if (!(inst.operands[j].isreg
14970 && inst.operands[j].isvec
14971 && !inst.operands[j].isquad
14972 && !inst.operands[j].issingle))
14977 if (!(inst.operands[j].isreg
14978 && !inst.operands[j].isvec))
14983 if (!(inst.operands[j].isreg
14984 && inst.operands[j].isvec
14985 && inst.operands[j].isquad
14986 && !inst.operands[j].issingle))
14991 if (!(!inst.operands[j].isreg
14992 && !inst.operands[j].isscalar))
14997 if (!(!inst.operands[j].isreg
14998 && inst.operands[j].isscalar))
15008 if (matches && (j >= ARM_IT_MAX_OPERANDS || !inst.operands[j].present))
15009 /* We've matched all the entries in the shape table, and we don't
15010 have any left over operands which have not been matched. */
15016 if (shape == NS_NULL && first_shape != NS_NULL)
15017 first_error (_("invalid instruction shape"));
15022 /* True if SHAPE is predominantly a quadword operation (most of the time, this
15023 means the Q bit should be set). */
15026 neon_quad (enum neon_shape shape)
15028 return neon_shape_class[shape] == SC_QUAD;
15032 neon_modify_type_size (unsigned typebits, enum neon_el_type *g_type,
15035 /* Allow modification to be made to types which are constrained to be
15036 based on the key element, based on bits set alongside N_EQK. */
15037 if ((typebits & N_EQK) != 0)
15039 if ((typebits & N_HLF) != 0)
15041 else if ((typebits & N_DBL) != 0)
15043 if ((typebits & N_SGN) != 0)
15044 *g_type = NT_signed;
15045 else if ((typebits & N_UNS) != 0)
15046 *g_type = NT_unsigned;
15047 else if ((typebits & N_INT) != 0)
15048 *g_type = NT_integer;
15049 else if ((typebits & N_FLT) != 0)
15050 *g_type = NT_float;
15051 else if ((typebits & N_SIZ) != 0)
15052 *g_type = NT_untyped;
15056 /* Return operand OPNO promoted by bits set in THISARG. KEY should be the "key"
15057 operand type, i.e. the single type specified in a Neon instruction when it
15058 is the only one given. */
15060 static struct neon_type_el
15061 neon_type_promote (struct neon_type_el *key, unsigned thisarg)
15063 struct neon_type_el dest = *key;
15065 gas_assert ((thisarg & N_EQK) != 0);
15067 neon_modify_type_size (thisarg, &dest.type, &dest.size);
15072 /* Convert Neon type and size into compact bitmask representation. */
15074 static enum neon_type_mask
15075 type_chk_of_el_type (enum neon_el_type type, unsigned size)
15082 case 8: return N_8;
15083 case 16: return N_16;
15084 case 32: return N_32;
15085 case 64: return N_64;
15093 case 8: return N_I8;
15094 case 16: return N_I16;
15095 case 32: return N_I32;
15096 case 64: return N_I64;
15104 case 16: return N_F16;
15105 case 32: return N_F32;
15106 case 64: return N_F64;
15114 case 8: return N_P8;
15115 case 16: return N_P16;
15116 case 64: return N_P64;
15124 case 8: return N_S8;
15125 case 16: return N_S16;
15126 case 32: return N_S32;
15127 case 64: return N_S64;
15135 case 8: return N_U8;
15136 case 16: return N_U16;
15137 case 32: return N_U32;
15138 case 64: return N_U64;
15149 /* Convert compact Neon bitmask type representation to a type and size. Only
15150 handles the case where a single bit is set in the mask. */
15153 el_type_of_type_chk (enum neon_el_type *type, unsigned *size,
15154 enum neon_type_mask mask)
15156 if ((mask & N_EQK) != 0)
15159 if ((mask & (N_S8 | N_U8 | N_I8 | N_8 | N_P8)) != 0)
15161 else if ((mask & (N_S16 | N_U16 | N_I16 | N_16 | N_F16 | N_P16)) != 0)
15163 else if ((mask & (N_S32 | N_U32 | N_I32 | N_32 | N_F32)) != 0)
15165 else if ((mask & (N_S64 | N_U64 | N_I64 | N_64 | N_F64 | N_P64)) != 0)
15170 if ((mask & (N_S8 | N_S16 | N_S32 | N_S64)) != 0)
15172 else if ((mask & (N_U8 | N_U16 | N_U32 | N_U64)) != 0)
15173 *type = NT_unsigned;
15174 else if ((mask & (N_I8 | N_I16 | N_I32 | N_I64)) != 0)
15175 *type = NT_integer;
15176 else if ((mask & (N_8 | N_16 | N_32 | N_64)) != 0)
15177 *type = NT_untyped;
15178 else if ((mask & (N_P8 | N_P16 | N_P64)) != 0)
15180 else if ((mask & (N_F_ALL)) != 0)
15188 /* Modify a bitmask of allowed types. This is only needed for type
15192 modify_types_allowed (unsigned allowed, unsigned mods)
15195 enum neon_el_type type;
15201 for (i = 1; i <= N_MAX_NONSPECIAL; i <<= 1)
15203 if (el_type_of_type_chk (&type, &size,
15204 (enum neon_type_mask) (allowed & i)) == SUCCESS)
15206 neon_modify_type_size (mods, &type, &size);
15207 destmask |= type_chk_of_el_type (type, size);
15214 /* Check type and return type classification.
15215 The manual states (paraphrase): If one datatype is given, it indicates the
15217 - the second operand, if there is one
15218 - the operand, if there is no second operand
15219 - the result, if there are no operands.
15220 This isn't quite good enough though, so we use a concept of a "key" datatype
15221 which is set on a per-instruction basis, which is the one which matters when
15222 only one data type is written.
15223 Note: this function has side-effects (e.g. filling in missing operands). All
15224 Neon instructions should call it before performing bit encoding. */
15226 static struct neon_type_el
15227 neon_check_type (unsigned els, enum neon_shape ns, ...)
15230 unsigned i, pass, key_el = 0;
15231 unsigned types[NEON_MAX_TYPE_ELS];
15232 enum neon_el_type k_type = NT_invtype;
15233 unsigned k_size = -1u;
15234 struct neon_type_el badtype = {NT_invtype, -1};
15235 unsigned key_allowed = 0;
15237 /* Optional registers in Neon instructions are always (not) in operand 1.
15238 Fill in the missing operand here, if it was omitted. */
15239 if (els > 1 && !inst.operands[1].present)
15240 inst.operands[1] = inst.operands[0];
15242 /* Suck up all the varargs. */
15244 for (i = 0; i < els; i++)
15246 unsigned thisarg = va_arg (ap, unsigned);
15247 if (thisarg == N_IGNORE_TYPE)
15252 types[i] = thisarg;
15253 if ((thisarg & N_KEY) != 0)
15258 if (inst.vectype.elems > 0)
15259 for (i = 0; i < els; i++)
15260 if (inst.operands[i].vectype.type != NT_invtype)
15262 first_error (_("types specified in both the mnemonic and operands"));
15266 /* Duplicate inst.vectype elements here as necessary.
15267 FIXME: No idea if this is exactly the same as the ARM assembler,
15268 particularly when an insn takes one register and one non-register
15270 if (inst.vectype.elems == 1 && els > 1)
15273 inst.vectype.elems = els;
15274 inst.vectype.el[key_el] = inst.vectype.el[0];
15275 for (j = 0; j < els; j++)
15277 inst.vectype.el[j] = neon_type_promote (&inst.vectype.el[key_el],
15280 else if (inst.vectype.elems == 0 && els > 0)
15283 /* No types were given after the mnemonic, so look for types specified
15284 after each operand. We allow some flexibility here; as long as the
15285 "key" operand has a type, we can infer the others. */
15286 for (j = 0; j < els; j++)
15287 if (inst.operands[j].vectype.type != NT_invtype)
15288 inst.vectype.el[j] = inst.operands[j].vectype;
15290 if (inst.operands[key_el].vectype.type != NT_invtype)
15292 for (j = 0; j < els; j++)
15293 if (inst.operands[j].vectype.type == NT_invtype)
15294 inst.vectype.el[j] = neon_type_promote (&inst.vectype.el[key_el],
15299 first_error (_("operand types can't be inferred"));
15303 else if (inst.vectype.elems != els)
15305 first_error (_("type specifier has the wrong number of parts"));
15309 for (pass = 0; pass < 2; pass++)
15311 for (i = 0; i < els; i++)
15313 unsigned thisarg = types[i];
15314 unsigned types_allowed = ((thisarg & N_EQK) != 0 && pass != 0)
15315 ? modify_types_allowed (key_allowed, thisarg) : thisarg;
15316 enum neon_el_type g_type = inst.vectype.el[i].type;
15317 unsigned g_size = inst.vectype.el[i].size;
15319 /* Decay more-specific signed & unsigned types to sign-insensitive
15320 integer types if sign-specific variants are unavailable. */
15321 if ((g_type == NT_signed || g_type == NT_unsigned)
15322 && (types_allowed & N_SU_ALL) == 0)
15323 g_type = NT_integer;
15325 /* If only untyped args are allowed, decay any more specific types to
15326 them. Some instructions only care about signs for some element
15327 sizes, so handle that properly. */
15328 if (((types_allowed & N_UNT) == 0)
15329 && ((g_size == 8 && (types_allowed & N_8) != 0)
15330 || (g_size == 16 && (types_allowed & N_16) != 0)
15331 || (g_size == 32 && (types_allowed & N_32) != 0)
15332 || (g_size == 64 && (types_allowed & N_64) != 0)))
15333 g_type = NT_untyped;
15337 if ((thisarg & N_KEY) != 0)
15341 key_allowed = thisarg & ~N_KEY;
15343 /* Check architecture constraint on FP16 extension. */
15345 && k_type == NT_float
15346 && ! ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_fp16))
15348 inst.error = _(BAD_FP16);
15355 if ((thisarg & N_VFP) != 0)
15357 enum neon_shape_el regshape;
15358 unsigned regwidth, match;
15360 /* PR 11136: Catch the case where we are passed a shape of NS_NULL. */
15363 first_error (_("invalid instruction shape"));
15366 regshape = neon_shape_tab[ns].el[i];
15367 regwidth = neon_shape_el_size[regshape];
15369 /* In VFP mode, operands must match register widths. If we
15370 have a key operand, use its width, else use the width of
15371 the current operand. */
15377 /* FP16 will use a single precision register. */
15378 if (regwidth == 32 && match == 16)
15380 if (ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_fp16))
15384 inst.error = _(BAD_FP16);
15389 if (regwidth != match)
15391 first_error (_("operand size must match register width"));
15396 if ((thisarg & N_EQK) == 0)
15398 unsigned given_type = type_chk_of_el_type (g_type, g_size);
15400 if ((given_type & types_allowed) == 0)
15402 first_error (BAD_SIMD_TYPE);
15408 enum neon_el_type mod_k_type = k_type;
15409 unsigned mod_k_size = k_size;
15410 neon_modify_type_size (thisarg, &mod_k_type, &mod_k_size);
15411 if (g_type != mod_k_type || g_size != mod_k_size)
15413 first_error (_("inconsistent types in Neon instruction"));
15421 return inst.vectype.el[key_el];
15424 /* Neon-style VFP instruction forwarding. */
15426 /* Thumb VFP instructions have 0xE in the condition field. */
15429 do_vfp_cond_or_thumb (void)
15434 inst.instruction |= 0xe0000000;
15436 inst.instruction |= inst.cond << 28;
15439 /* Look up and encode a simple mnemonic, for use as a helper function for the
15440 Neon-style VFP syntax. This avoids duplication of bits of the insns table,
15441 etc. It is assumed that operand parsing has already been done, and that the
15442 operands are in the form expected by the given opcode (this isn't necessarily
15443 the same as the form in which they were parsed, hence some massaging must
15444 take place before this function is called).
15445 Checks current arch version against that in the looked-up opcode. */
15448 do_vfp_nsyn_opcode (const char *opname)
15450 const struct asm_opcode *opcode;
15452 opcode = (const struct asm_opcode *) hash_find (arm_ops_hsh, opname);
15457 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant,
15458 thumb_mode ? *opcode->tvariant : *opcode->avariant),
15465 inst.instruction = opcode->tvalue;
15466 opcode->tencode ();
15470 inst.instruction = (inst.cond << 28) | opcode->avalue;
15471 opcode->aencode ();
15476 do_vfp_nsyn_add_sub (enum neon_shape rs)
15478 int is_add = (inst.instruction & 0x0fffffff) == N_MNEM_vadd;
15480 if (rs == NS_FFF || rs == NS_HHH)
15483 do_vfp_nsyn_opcode ("fadds");
15485 do_vfp_nsyn_opcode ("fsubs");
15487 /* ARMv8.2 fp16 instruction. */
15489 do_scalar_fp16_v82_encode ();
15494 do_vfp_nsyn_opcode ("faddd");
15496 do_vfp_nsyn_opcode ("fsubd");
15500 /* Check operand types to see if this is a VFP instruction, and if so call
15504 try_vfp_nsyn (int args, void (*pfn) (enum neon_shape))
15506 enum neon_shape rs;
15507 struct neon_type_el et;
15512 rs = neon_select_shape (NS_HH, NS_FF, NS_DD, NS_NULL);
15513 et = neon_check_type (2, rs, N_EQK | N_VFP, N_F_ALL | N_KEY | N_VFP);
15517 rs = neon_select_shape (NS_HHH, NS_FFF, NS_DDD, NS_NULL);
15518 et = neon_check_type (3, rs, N_EQK | N_VFP, N_EQK | N_VFP,
15519 N_F_ALL | N_KEY | N_VFP);
15526 if (et.type != NT_invtype)
15537 do_vfp_nsyn_mla_mls (enum neon_shape rs)
15539 int is_mla = (inst.instruction & 0x0fffffff) == N_MNEM_vmla;
15541 if (rs == NS_FFF || rs == NS_HHH)
15544 do_vfp_nsyn_opcode ("fmacs");
15546 do_vfp_nsyn_opcode ("fnmacs");
15548 /* ARMv8.2 fp16 instruction. */
15550 do_scalar_fp16_v82_encode ();
15555 do_vfp_nsyn_opcode ("fmacd");
15557 do_vfp_nsyn_opcode ("fnmacd");
15562 do_vfp_nsyn_fma_fms (enum neon_shape rs)
15564 int is_fma = (inst.instruction & 0x0fffffff) == N_MNEM_vfma;
15566 if (rs == NS_FFF || rs == NS_HHH)
15569 do_vfp_nsyn_opcode ("ffmas");
15571 do_vfp_nsyn_opcode ("ffnmas");
15573 /* ARMv8.2 fp16 instruction. */
15575 do_scalar_fp16_v82_encode ();
15580 do_vfp_nsyn_opcode ("ffmad");
15582 do_vfp_nsyn_opcode ("ffnmad");
15587 do_vfp_nsyn_mul (enum neon_shape rs)
15589 if (rs == NS_FFF || rs == NS_HHH)
15591 do_vfp_nsyn_opcode ("fmuls");
15593 /* ARMv8.2 fp16 instruction. */
15595 do_scalar_fp16_v82_encode ();
15598 do_vfp_nsyn_opcode ("fmuld");
15602 do_vfp_nsyn_abs_neg (enum neon_shape rs)
15604 int is_neg = (inst.instruction & 0x80) != 0;
15605 neon_check_type (2, rs, N_EQK | N_VFP, N_F_ALL | N_VFP | N_KEY);
15607 if (rs == NS_FF || rs == NS_HH)
15610 do_vfp_nsyn_opcode ("fnegs");
15612 do_vfp_nsyn_opcode ("fabss");
15614 /* ARMv8.2 fp16 instruction. */
15616 do_scalar_fp16_v82_encode ();
15621 do_vfp_nsyn_opcode ("fnegd");
15623 do_vfp_nsyn_opcode ("fabsd");
15627 /* Encode single-precision (only!) VFP fldm/fstm instructions. Double precision
15628 insns belong to Neon, and are handled elsewhere. */
15631 do_vfp_nsyn_ldm_stm (int is_dbmode)
15633 int is_ldm = (inst.instruction & (1 << 20)) != 0;
15637 do_vfp_nsyn_opcode ("fldmdbs");
15639 do_vfp_nsyn_opcode ("fldmias");
15644 do_vfp_nsyn_opcode ("fstmdbs");
15646 do_vfp_nsyn_opcode ("fstmias");
15651 do_vfp_nsyn_sqrt (void)
15653 enum neon_shape rs = neon_select_shape (NS_HH, NS_FF, NS_DD, NS_NULL);
15654 neon_check_type (2, rs, N_EQK | N_VFP, N_F_ALL | N_KEY | N_VFP);
15656 if (rs == NS_FF || rs == NS_HH)
15658 do_vfp_nsyn_opcode ("fsqrts");
15660 /* ARMv8.2 fp16 instruction. */
15662 do_scalar_fp16_v82_encode ();
15665 do_vfp_nsyn_opcode ("fsqrtd");
15669 do_vfp_nsyn_div (void)
15671 enum neon_shape rs = neon_select_shape (NS_HHH, NS_FFF, NS_DDD, NS_NULL);
15672 neon_check_type (3, rs, N_EQK | N_VFP, N_EQK | N_VFP,
15673 N_F_ALL | N_KEY | N_VFP);
15675 if (rs == NS_FFF || rs == NS_HHH)
15677 do_vfp_nsyn_opcode ("fdivs");
15679 /* ARMv8.2 fp16 instruction. */
15681 do_scalar_fp16_v82_encode ();
15684 do_vfp_nsyn_opcode ("fdivd");
15688 do_vfp_nsyn_nmul (void)
15690 enum neon_shape rs = neon_select_shape (NS_HHH, NS_FFF, NS_DDD, NS_NULL);
15691 neon_check_type (3, rs, N_EQK | N_VFP, N_EQK | N_VFP,
15692 N_F_ALL | N_KEY | N_VFP);
15694 if (rs == NS_FFF || rs == NS_HHH)
15696 NEON_ENCODE (SINGLE, inst);
15697 do_vfp_sp_dyadic ();
15699 /* ARMv8.2 fp16 instruction. */
15701 do_scalar_fp16_v82_encode ();
15705 NEON_ENCODE (DOUBLE, inst);
15706 do_vfp_dp_rd_rn_rm ();
15708 do_vfp_cond_or_thumb ();
15712 /* Turn a size (8, 16, 32, 64) into the respective bit number minus 3
15716 neon_logbits (unsigned x)
15718 return ffs (x) - 4;
15721 #define LOW4(R) ((R) & 0xf)
15722 #define HI1(R) (((R) >> 4) & 1)
15725 mve_get_vcmp_vpt_cond (struct neon_type_el et)
15730 first_error (BAD_EL_TYPE);
15733 switch (inst.operands[0].imm)
15736 first_error (_("invalid condition"));
15758 /* only accept eq and ne. */
15759 if (inst.operands[0].imm > 1)
15761 first_error (_("invalid condition"));
15764 return inst.operands[0].imm;
15766 if (inst.operands[0].imm == 0x2)
15768 else if (inst.operands[0].imm == 0x8)
15772 first_error (_("invalid condition"));
15776 switch (inst.operands[0].imm)
15779 first_error (_("invalid condition"));
15795 /* Should be unreachable. */
15802 /* We are dealing with a vector predicated block. */
15803 if (inst.operands[0].present)
15805 enum neon_shape rs = neon_select_shape (NS_IQQ, NS_IQR, NS_NULL);
15806 struct neon_type_el et
15807 = neon_check_type (3, rs, N_EQK, N_KEY | N_F_MVE | N_I_MVE | N_SU_32,
15810 unsigned fcond = mve_get_vcmp_vpt_cond (et);
15812 constraint (inst.operands[1].reg > 14, MVE_BAD_QREG);
15814 if (et.type == NT_invtype)
15817 if (et.type == NT_float)
15819 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant, mve_fp_ext),
15821 constraint (et.size != 16 && et.size != 32, BAD_EL_TYPE);
15822 inst.instruction |= (et.size == 16) << 28;
15823 inst.instruction |= 0x3 << 20;
15827 constraint (et.size != 8 && et.size != 16 && et.size != 32,
15829 inst.instruction |= 1 << 28;
15830 inst.instruction |= neon_logbits (et.size) << 20;
15833 if (inst.operands[2].isquad)
15835 inst.instruction |= HI1 (inst.operands[2].reg) << 5;
15836 inst.instruction |= LOW4 (inst.operands[2].reg);
15837 inst.instruction |= (fcond & 0x2) >> 1;
15841 if (inst.operands[2].reg == REG_SP)
15842 as_tsktsk (MVE_BAD_SP);
15843 inst.instruction |= 1 << 6;
15844 inst.instruction |= (fcond & 0x2) << 4;
15845 inst.instruction |= inst.operands[2].reg;
15847 inst.instruction |= LOW4 (inst.operands[1].reg) << 16;
15848 inst.instruction |= (fcond & 0x4) << 10;
15849 inst.instruction |= (fcond & 0x1) << 7;
15852 set_pred_insn_type (VPT_INSN);
15854 now_pred.mask = ((inst.instruction & 0x00400000) >> 19)
15855 | ((inst.instruction & 0xe000) >> 13);
15856 now_pred.warn_deprecated = FALSE;
15857 now_pred.type = VECTOR_PRED;
15864 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext), BAD_FPU);
15865 if (!inst.operands[1].isreg || !inst.operands[1].isquad)
15866 first_error (_(reg_expected_msgs[REG_TYPE_MQ]));
15867 if (!inst.operands[2].present)
15868 first_error (_("MVE vector or ARM register expected"));
15869 constraint (inst.operands[1].reg > 14, MVE_BAD_QREG);
15871 /* Deal with 'else' conditional MVE's vcmp, it will be parsed as vcmpe. */
15872 if ((inst.instruction & 0xffffffff) == N_MNEM_vcmpe
15873 && inst.operands[1].isquad)
15875 inst.instruction = N_MNEM_vcmp;
15879 if (inst.cond > COND_ALWAYS)
15880 inst.pred_insn_type = INSIDE_VPT_INSN;
15882 inst.pred_insn_type = MVE_OUTSIDE_PRED_INSN;
15884 enum neon_shape rs = neon_select_shape (NS_IQQ, NS_IQR, NS_NULL);
15885 struct neon_type_el et
15886 = neon_check_type (3, rs, N_EQK, N_KEY | N_F_MVE | N_I_MVE | N_SU_32,
15889 constraint (rs == NS_IQR && inst.operands[2].reg == REG_PC
15890 && !inst.operands[2].iszr, BAD_PC);
15892 unsigned fcond = mve_get_vcmp_vpt_cond (et);
15894 inst.instruction = 0xee010f00;
15895 inst.instruction |= LOW4 (inst.operands[1].reg) << 16;
15896 inst.instruction |= (fcond & 0x4) << 10;
15897 inst.instruction |= (fcond & 0x1) << 7;
15898 if (et.type == NT_float)
15900 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant, mve_fp_ext),
15902 inst.instruction |= (et.size == 16) << 28;
15903 inst.instruction |= 0x3 << 20;
15907 inst.instruction |= 1 << 28;
15908 inst.instruction |= neon_logbits (et.size) << 20;
15910 if (inst.operands[2].isquad)
15912 inst.instruction |= HI1 (inst.operands[2].reg) << 5;
15913 inst.instruction |= (fcond & 0x2) >> 1;
15914 inst.instruction |= LOW4 (inst.operands[2].reg);
15918 if (inst.operands[2].reg == REG_SP)
15919 as_tsktsk (MVE_BAD_SP);
15920 inst.instruction |= 1 << 6;
15921 inst.instruction |= (fcond & 0x2) << 4;
15922 inst.instruction |= inst.operands[2].reg;
15930 do_mve_vmaxa_vmina (void)
15932 if (inst.cond > COND_ALWAYS)
15933 inst.pred_insn_type = INSIDE_VPT_INSN;
15935 inst.pred_insn_type = MVE_OUTSIDE_PRED_INSN;
15937 enum neon_shape rs = neon_select_shape (NS_QQ, NS_NULL);
15938 struct neon_type_el et
15939 = neon_check_type (2, rs, N_EQK, N_KEY | N_S8 | N_S16 | N_S32);
15941 inst.instruction |= HI1 (inst.operands[0].reg) << 22;
15942 inst.instruction |= neon_logbits (et.size) << 18;
15943 inst.instruction |= LOW4 (inst.operands[0].reg) << 12;
15944 inst.instruction |= HI1 (inst.operands[1].reg) << 5;
15945 inst.instruction |= LOW4 (inst.operands[1].reg);
15950 do_mve_vfmas (void)
15952 enum neon_shape rs = neon_select_shape (NS_QQR, NS_NULL);
15953 struct neon_type_el et
15954 = neon_check_type (3, rs, N_F_MVE | N_KEY, N_EQK, N_EQK);
15956 if (inst.cond > COND_ALWAYS)
15957 inst.pred_insn_type = INSIDE_VPT_INSN;
15959 inst.pred_insn_type = MVE_OUTSIDE_PRED_INSN;
15961 if (inst.operands[2].reg == REG_SP)
15962 as_tsktsk (MVE_BAD_SP);
15963 else if (inst.operands[2].reg == REG_PC)
15964 as_tsktsk (MVE_BAD_PC);
15966 inst.instruction |= (et.size == 16) << 28;
15967 inst.instruction |= HI1 (inst.operands[0].reg) << 22;
15968 inst.instruction |= LOW4 (inst.operands[1].reg) << 16;
15969 inst.instruction |= LOW4 (inst.operands[0].reg) << 12;
15970 inst.instruction |= HI1 (inst.operands[1].reg) << 7;
15971 inst.instruction |= inst.operands[2].reg;
15976 do_mve_viddup (void)
15978 if (inst.cond > COND_ALWAYS)
15979 inst.pred_insn_type = INSIDE_VPT_INSN;
15981 inst.pred_insn_type = MVE_OUTSIDE_PRED_INSN;
15983 unsigned imm = inst.relocs[0].exp.X_add_number;
15984 constraint (imm != 1 && imm != 2 && imm != 4 && imm != 8,
15985 _("immediate must be either 1, 2, 4 or 8"));
15987 enum neon_shape rs;
15988 struct neon_type_el et;
15990 if (inst.instruction == M_MNEM_vddup || inst.instruction == M_MNEM_vidup)
15992 rs = neon_select_shape (NS_QRI, NS_NULL);
15993 et = neon_check_type (2, rs, N_KEY | N_U8 | N_U16 | N_U32, N_EQK);
15998 constraint ((inst.operands[2].reg % 2) != 1, BAD_EVEN);
15999 if (inst.operands[2].reg == REG_SP)
16000 as_tsktsk (MVE_BAD_SP);
16001 else if (inst.operands[2].reg == REG_PC)
16002 first_error (BAD_PC);
16004 rs = neon_select_shape (NS_QRRI, NS_NULL);
16005 et = neon_check_type (3, rs, N_KEY | N_U8 | N_U16 | N_U32, N_EQK, N_EQK);
16006 Rm = inst.operands[2].reg >> 1;
16008 inst.instruction |= HI1 (inst.operands[0].reg) << 22;
16009 inst.instruction |= neon_logbits (et.size) << 20;
16010 inst.instruction |= inst.operands[1].reg << 16;
16011 inst.instruction |= LOW4 (inst.operands[0].reg) << 12;
16012 inst.instruction |= (imm > 2) << 7;
16013 inst.instruction |= Rm << 1;
16014 inst.instruction |= (imm == 2 || imm == 8);
16019 do_mve_vmlas (void)
16021 enum neon_shape rs = neon_select_shape (NS_QQR, NS_NULL);
16022 struct neon_type_el et
16023 = neon_check_type (3, rs, N_EQK, N_EQK, N_SU_MVE | N_KEY);
16025 if (inst.operands[2].reg == REG_PC)
16026 as_tsktsk (MVE_BAD_PC);
16027 else if (inst.operands[2].reg == REG_SP)
16028 as_tsktsk (MVE_BAD_SP);
16030 if (inst.cond > COND_ALWAYS)
16031 inst.pred_insn_type = INSIDE_VPT_INSN;
16033 inst.pred_insn_type = MVE_OUTSIDE_PRED_INSN;
16035 inst.instruction |= (et.type == NT_unsigned) << 28;
16036 inst.instruction |= HI1 (inst.operands[0].reg) << 22;
16037 inst.instruction |= neon_logbits (et.size) << 20;
16038 inst.instruction |= LOW4 (inst.operands[1].reg) << 16;
16039 inst.instruction |= LOW4 (inst.operands[0].reg) << 12;
16040 inst.instruction |= HI1 (inst.operands[1].reg) << 7;
16041 inst.instruction |= inst.operands[2].reg;
16046 do_mve_vshll (void)
16048 struct neon_type_el et
16049 = neon_check_type (2, NS_QQI, N_EQK, N_S8 | N_U8 | N_S16 | N_U16 | N_KEY);
16051 if (inst.cond > COND_ALWAYS)
16052 inst.pred_insn_type = INSIDE_VPT_INSN;
16054 inst.pred_insn_type = MVE_OUTSIDE_PRED_INSN;
16056 int imm = inst.operands[2].imm;
16057 constraint (imm < 1 || (unsigned)imm > et.size,
16058 _("immediate value out of range"));
16060 if ((unsigned)imm == et.size)
16062 inst.instruction |= neon_logbits (et.size) << 18;
16063 inst.instruction |= 0x110001;
16067 inst.instruction |= (et.size + imm) << 16;
16068 inst.instruction |= 0x800140;
16071 inst.instruction |= (et.type == NT_unsigned) << 28;
16072 inst.instruction |= HI1 (inst.operands[0].reg) << 22;
16073 inst.instruction |= LOW4 (inst.operands[0].reg) << 12;
16074 inst.instruction |= HI1 (inst.operands[1].reg) << 5;
16075 inst.instruction |= LOW4 (inst.operands[1].reg);
16080 do_mve_vshlc (void)
16082 if (inst.cond > COND_ALWAYS)
16083 inst.pred_insn_type = INSIDE_VPT_INSN;
16085 inst.pred_insn_type = MVE_OUTSIDE_PRED_INSN;
16087 if (inst.operands[1].reg == REG_PC)
16088 as_tsktsk (MVE_BAD_PC);
16089 else if (inst.operands[1].reg == REG_SP)
16090 as_tsktsk (MVE_BAD_SP);
16092 int imm = inst.operands[2].imm;
16093 constraint (imm < 1 || imm > 32, _("immediate value out of range"));
16095 inst.instruction |= HI1 (inst.operands[0].reg) << 22;
16096 inst.instruction |= (imm & 0x1f) << 16;
16097 inst.instruction |= LOW4 (inst.operands[0].reg) << 12;
16098 inst.instruction |= inst.operands[1].reg;
16103 do_mve_vshrn (void)
16106 switch (inst.instruction)
16108 case M_MNEM_vshrnt:
16109 case M_MNEM_vshrnb:
16110 case M_MNEM_vrshrnt:
16111 case M_MNEM_vrshrnb:
16112 types = N_I16 | N_I32;
16114 case M_MNEM_vqshrnt:
16115 case M_MNEM_vqshrnb:
16116 case M_MNEM_vqrshrnt:
16117 case M_MNEM_vqrshrnb:
16118 types = N_U16 | N_U32 | N_S16 | N_S32;
16120 case M_MNEM_vqshrunt:
16121 case M_MNEM_vqshrunb:
16122 case M_MNEM_vqrshrunt:
16123 case M_MNEM_vqrshrunb:
16124 types = N_S16 | N_S32;
16130 struct neon_type_el et = neon_check_type (2, NS_QQI, N_EQK, types | N_KEY);
16132 if (inst.cond > COND_ALWAYS)
16133 inst.pred_insn_type = INSIDE_VPT_INSN;
16135 inst.pred_insn_type = MVE_OUTSIDE_PRED_INSN;
16137 unsigned Qd = inst.operands[0].reg;
16138 unsigned Qm = inst.operands[1].reg;
16139 unsigned imm = inst.operands[2].imm;
16140 constraint (imm < 1 || ((unsigned) imm) > (et.size / 2),
16142 ? _("immediate operand expected in the range [1,8]")
16143 : _("immediate operand expected in the range [1,16]"));
16145 inst.instruction |= (et.type == NT_unsigned) << 28;
16146 inst.instruction |= HI1 (Qd) << 22;
16147 inst.instruction |= (et.size - imm) << 16;
16148 inst.instruction |= LOW4 (Qd) << 12;
16149 inst.instruction |= HI1 (Qm) << 5;
16150 inst.instruction |= LOW4 (Qm);
16155 do_mve_vqmovn (void)
16157 struct neon_type_el et;
16158 if (inst.instruction == M_MNEM_vqmovnt
16159 || inst.instruction == M_MNEM_vqmovnb)
16160 et = neon_check_type (2, NS_QQ, N_EQK,
16161 N_U16 | N_U32 | N_S16 | N_S32 | N_KEY);
16163 et = neon_check_type (2, NS_QQ, N_EQK, N_S16 | N_S32 | N_KEY);
16165 if (inst.cond > COND_ALWAYS)
16166 inst.pred_insn_type = INSIDE_VPT_INSN;
16168 inst.pred_insn_type = MVE_OUTSIDE_PRED_INSN;
16170 inst.instruction |= (et.type == NT_unsigned) << 28;
16171 inst.instruction |= HI1 (inst.operands[0].reg) << 22;
16172 inst.instruction |= (et.size == 32) << 18;
16173 inst.instruction |= LOW4 (inst.operands[0].reg) << 12;
16174 inst.instruction |= HI1 (inst.operands[1].reg) << 5;
16175 inst.instruction |= LOW4 (inst.operands[1].reg);
16180 do_mve_vpsel (void)
16182 neon_select_shape (NS_QQQ, NS_NULL);
16184 if (inst.cond > COND_ALWAYS)
16185 inst.pred_insn_type = INSIDE_VPT_INSN;
16187 inst.pred_insn_type = MVE_OUTSIDE_PRED_INSN;
16189 inst.instruction |= HI1 (inst.operands[0].reg) << 22;
16190 inst.instruction |= LOW4 (inst.operands[1].reg) << 16;
16191 inst.instruction |= LOW4 (inst.operands[0].reg) << 12;
16192 inst.instruction |= HI1 (inst.operands[1].reg) << 7;
16193 inst.instruction |= HI1 (inst.operands[2].reg) << 5;
16194 inst.instruction |= LOW4 (inst.operands[2].reg);
16199 do_mve_vpnot (void)
16201 if (inst.cond > COND_ALWAYS)
16202 inst.pred_insn_type = INSIDE_VPT_INSN;
16204 inst.pred_insn_type = MVE_OUTSIDE_PRED_INSN;
16208 do_mve_vmaxnma_vminnma (void)
16210 enum neon_shape rs = neon_select_shape (NS_QQ, NS_NULL);
16211 struct neon_type_el et
16212 = neon_check_type (2, rs, N_EQK, N_F_MVE | N_KEY);
16214 if (inst.cond > COND_ALWAYS)
16215 inst.pred_insn_type = INSIDE_VPT_INSN;
16217 inst.pred_insn_type = MVE_OUTSIDE_PRED_INSN;
16219 inst.instruction |= (et.size == 16) << 28;
16220 inst.instruction |= HI1 (inst.operands[0].reg) << 22;
16221 inst.instruction |= LOW4 (inst.operands[0].reg) << 12;
16222 inst.instruction |= HI1 (inst.operands[1].reg) << 5;
16223 inst.instruction |= LOW4 (inst.operands[1].reg);
16228 do_mve_vcmul (void)
16230 enum neon_shape rs = neon_select_shape (NS_QQQI, NS_NULL);
16231 struct neon_type_el et
16232 = neon_check_type (3, rs, N_EQK, N_EQK, N_F_MVE | N_KEY);
16234 if (inst.cond > COND_ALWAYS)
16235 inst.pred_insn_type = INSIDE_VPT_INSN;
16237 inst.pred_insn_type = MVE_OUTSIDE_PRED_INSN;
16239 unsigned rot = inst.relocs[0].exp.X_add_number;
16240 constraint (rot != 0 && rot != 90 && rot != 180 && rot != 270,
16241 _("immediate out of range"));
16243 if (et.size == 32 && (inst.operands[0].reg == inst.operands[1].reg
16244 || inst.operands[0].reg == inst.operands[2].reg))
16245 as_tsktsk (BAD_MVE_SRCDEST);
16247 inst.instruction |= (et.size == 32) << 28;
16248 inst.instruction |= HI1 (inst.operands[0].reg) << 22;
16249 inst.instruction |= LOW4 (inst.operands[1].reg) << 16;
16250 inst.instruction |= LOW4 (inst.operands[0].reg) << 12;
16251 inst.instruction |= (rot > 90) << 12;
16252 inst.instruction |= HI1 (inst.operands[1].reg) << 7;
16253 inst.instruction |= HI1 (inst.operands[2].reg) << 5;
16254 inst.instruction |= LOW4 (inst.operands[2].reg);
16255 inst.instruction |= (rot == 90 || rot == 270);
16259 /* To handle the Low Overhead Loop instructions
16260 in Armv8.1-M Mainline and MVE. */
16264 unsigned long insn = inst.instruction;
16266 inst.instruction = THUMB_OP32 (inst.instruction);
16268 if (insn == T_MNEM_lctp)
16271 set_pred_insn_type (MVE_OUTSIDE_PRED_INSN);
16273 if (insn == T_MNEM_wlstp || insn == T_MNEM_dlstp)
16275 struct neon_type_el et
16276 = neon_check_type (2, NS_RR, N_EQK, N_8 | N_16 | N_32 | N_64 | N_KEY);
16277 inst.instruction |= neon_logbits (et.size) << 20;
16284 constraint (!inst.operands[0].present,
16286 /* fall through. */
16289 if (!inst.operands[0].present)
16290 inst.instruction |= 1 << 21;
16292 v8_1_loop_reloc (TRUE);
16297 v8_1_loop_reloc (FALSE);
16298 /* fall through. */
16301 constraint (inst.operands[1].isreg != 1, BAD_ARGS);
16303 if (insn == T_MNEM_wlstp || insn == T_MNEM_dlstp)
16304 constraint (inst.operands[1].reg == REG_PC, BAD_PC);
16305 else if (inst.operands[1].reg == REG_PC)
16306 as_tsktsk (MVE_BAD_PC);
16307 if (inst.operands[1].reg == REG_SP)
16308 as_tsktsk (MVE_BAD_SP);
16310 inst.instruction |= (inst.operands[1].reg << 16);
16320 do_vfp_nsyn_cmp (void)
16322 enum neon_shape rs;
16323 if (!inst.operands[0].isreg)
16330 constraint (inst.operands[2].present, BAD_SYNTAX);
16331 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant, fpu_vfp_ext_v1xd),
16335 if (inst.operands[1].isreg)
16337 rs = neon_select_shape (NS_HH, NS_FF, NS_DD, NS_NULL);
16338 neon_check_type (2, rs, N_EQK | N_VFP, N_F_ALL | N_KEY | N_VFP);
16340 if (rs == NS_FF || rs == NS_HH)
16342 NEON_ENCODE (SINGLE, inst);
16343 do_vfp_sp_monadic ();
16347 NEON_ENCODE (DOUBLE, inst);
16348 do_vfp_dp_rd_rm ();
16353 rs = neon_select_shape (NS_HI, NS_FI, NS_DI, NS_NULL);
16354 neon_check_type (2, rs, N_F_ALL | N_KEY | N_VFP, N_EQK);
16356 switch (inst.instruction & 0x0fffffff)
16359 inst.instruction += N_MNEM_vcmpz - N_MNEM_vcmp;
16362 inst.instruction += N_MNEM_vcmpez - N_MNEM_vcmpe;
16368 if (rs == NS_FI || rs == NS_HI)
16370 NEON_ENCODE (SINGLE, inst);
16371 do_vfp_sp_compare_z ();
16375 NEON_ENCODE (DOUBLE, inst);
16379 do_vfp_cond_or_thumb ();
16381 /* ARMv8.2 fp16 instruction. */
16382 if (rs == NS_HI || rs == NS_HH)
16383 do_scalar_fp16_v82_encode ();
16387 nsyn_insert_sp (void)
16389 inst.operands[1] = inst.operands[0];
16390 memset (&inst.operands[0], '\0', sizeof (inst.operands[0]));
16391 inst.operands[0].reg = REG_SP;
16392 inst.operands[0].isreg = 1;
16393 inst.operands[0].writeback = 1;
16394 inst.operands[0].present = 1;
16398 do_vfp_nsyn_push (void)
16402 constraint (inst.operands[1].imm < 1 || inst.operands[1].imm > 16,
16403 _("register list must contain at least 1 and at most 16 "
16406 if (inst.operands[1].issingle)
16407 do_vfp_nsyn_opcode ("fstmdbs");
16409 do_vfp_nsyn_opcode ("fstmdbd");
16413 do_vfp_nsyn_pop (void)
16417 constraint (inst.operands[1].imm < 1 || inst.operands[1].imm > 16,
16418 _("register list must contain at least 1 and at most 16 "
16421 if (inst.operands[1].issingle)
16422 do_vfp_nsyn_opcode ("fldmias");
16424 do_vfp_nsyn_opcode ("fldmiad");
16427 /* Fix up Neon data-processing instructions, ORing in the correct bits for
16428 ARM mode or Thumb mode and moving the encoded bit 24 to bit 28. */
16431 neon_dp_fixup (struct arm_it* insn)
16433 unsigned int i = insn->instruction;
16438 /* The U bit is at bit 24 by default. Move to bit 28 in Thumb mode. */
16449 insn->instruction = i;
16453 mve_encode_qqr (int size, int U, int fp)
16455 if (inst.operands[2].reg == REG_SP)
16456 as_tsktsk (MVE_BAD_SP);
16457 else if (inst.operands[2].reg == REG_PC)
16458 as_tsktsk (MVE_BAD_PC);
16463 if (((unsigned)inst.instruction) == 0xd00)
16464 inst.instruction = 0xee300f40;
16466 else if (((unsigned)inst.instruction) == 0x200d00)
16467 inst.instruction = 0xee301f40;
16469 else if (((unsigned)inst.instruction) == 0x1000d10)
16470 inst.instruction = 0xee310e60;
16472 /* Setting size which is 1 for F16 and 0 for F32. */
16473 inst.instruction |= (size == 16) << 28;
16478 if (((unsigned)inst.instruction) == 0x800)
16479 inst.instruction = 0xee010f40;
16481 else if (((unsigned)inst.instruction) == 0x1000800)
16482 inst.instruction = 0xee011f40;
16484 else if (((unsigned)inst.instruction) == 0)
16485 inst.instruction = 0xee000f40;
16487 else if (((unsigned)inst.instruction) == 0x200)
16488 inst.instruction = 0xee001f40;
16490 else if (((unsigned)inst.instruction) == 0x900)
16491 inst.instruction = 0xee010e40;
16493 else if (((unsigned)inst.instruction) == 0x910)
16494 inst.instruction = 0xee011e60;
16496 else if (((unsigned)inst.instruction) == 0x10)
16497 inst.instruction = 0xee000f60;
16499 else if (((unsigned)inst.instruction) == 0x210)
16500 inst.instruction = 0xee001f60;
16502 else if (((unsigned)inst.instruction) == 0x3000b10)
16503 inst.instruction = 0xee000e40;
16505 else if (((unsigned)inst.instruction) == 0x0000b00)
16506 inst.instruction = 0xee010e60;
16508 else if (((unsigned)inst.instruction) == 0x1000b00)
16509 inst.instruction = 0xfe010e60;
16512 inst.instruction |= U << 28;
16514 /* Setting bits for size. */
16515 inst.instruction |= neon_logbits (size) << 20;
16517 inst.instruction |= LOW4 (inst.operands[0].reg) << 12;
16518 inst.instruction |= HI1 (inst.operands[0].reg) << 22;
16519 inst.instruction |= LOW4 (inst.operands[1].reg) << 16;
16520 inst.instruction |= HI1 (inst.operands[1].reg) << 7;
16521 inst.instruction |= inst.operands[2].reg;
16526 mve_encode_rqq (unsigned bit28, unsigned size)
16528 inst.instruction |= bit28 << 28;
16529 inst.instruction |= neon_logbits (size) << 20;
16530 inst.instruction |= LOW4 (inst.operands[1].reg) << 16;
16531 inst.instruction |= inst.operands[0].reg << 12;
16532 inst.instruction |= HI1 (inst.operands[1].reg) << 7;
16533 inst.instruction |= HI1 (inst.operands[2].reg) << 5;
16534 inst.instruction |= LOW4 (inst.operands[2].reg);
16539 mve_encode_qqq (int ubit, int size)
16542 inst.instruction |= (ubit != 0) << 28;
16543 inst.instruction |= HI1 (inst.operands[0].reg) << 22;
16544 inst.instruction |= neon_logbits (size) << 20;
16545 inst.instruction |= LOW4 (inst.operands[1].reg) << 16;
16546 inst.instruction |= LOW4 (inst.operands[0].reg) << 12;
16547 inst.instruction |= HI1 (inst.operands[1].reg) << 7;
16548 inst.instruction |= HI1 (inst.operands[2].reg) << 5;
16549 inst.instruction |= LOW4 (inst.operands[2].reg);
16555 mve_encode_rq (unsigned bit28, unsigned size)
16557 inst.instruction |= bit28 << 28;
16558 inst.instruction |= neon_logbits (size) << 18;
16559 inst.instruction |= inst.operands[0].reg << 12;
16560 inst.instruction |= LOW4 (inst.operands[1].reg);
16565 mve_encode_rrqq (unsigned U, unsigned size)
16567 constraint (inst.operands[3].reg > 14, MVE_BAD_QREG);
16569 inst.instruction |= U << 28;
16570 inst.instruction |= (inst.operands[1].reg >> 1) << 20;
16571 inst.instruction |= LOW4 (inst.operands[2].reg) << 16;
16572 inst.instruction |= (size == 32) << 16;
16573 inst.instruction |= inst.operands[0].reg << 12;
16574 inst.instruction |= HI1 (inst.operands[2].reg) << 7;
16575 inst.instruction |= inst.operands[3].reg;
16579 /* Encode insns with bit pattern:
16581 |28/24|23|22 |21 20|19 16|15 12|11 8|7|6|5|4|3 0|
16582 | U |x |D |size | Rn | Rd |x x x x|N|Q|M|x| Rm |
16584 SIZE is passed in bits. -1 means size field isn't changed, in case it has a
16585 different meaning for some instruction. */
16588 neon_three_same (int isquad, int ubit, int size)
16590 inst.instruction |= LOW4 (inst.operands[0].reg) << 12;
16591 inst.instruction |= HI1 (inst.operands[0].reg) << 22;
16592 inst.instruction |= LOW4 (inst.operands[1].reg) << 16;
16593 inst.instruction |= HI1 (inst.operands[1].reg) << 7;
16594 inst.instruction |= LOW4 (inst.operands[2].reg);
16595 inst.instruction |= HI1 (inst.operands[2].reg) << 5;
16596 inst.instruction |= (isquad != 0) << 6;
16597 inst.instruction |= (ubit != 0) << 24;
16599 inst.instruction |= neon_logbits (size) << 20;
16601 neon_dp_fixup (&inst);
16604 /* Encode instructions of the form:
16606 |28/24|23|22|21 20|19 18|17 16|15 12|11 7|6|5|4|3 0|
16607 | U |x |D |x x |size |x x | Rd |x x x x x|Q|M|x| Rm |
16609 Don't write size if SIZE == -1. */
16612 neon_two_same (int qbit, int ubit, int size)
16614 inst.instruction |= LOW4 (inst.operands[0].reg) << 12;
16615 inst.instruction |= HI1 (inst.operands[0].reg) << 22;
16616 inst.instruction |= LOW4 (inst.operands[1].reg);
16617 inst.instruction |= HI1 (inst.operands[1].reg) << 5;
16618 inst.instruction |= (qbit != 0) << 6;
16619 inst.instruction |= (ubit != 0) << 24;
16622 inst.instruction |= neon_logbits (size) << 18;
16624 neon_dp_fixup (&inst);
16627 enum vfp_or_neon_is_neon_bits
16630 NEON_CHECK_ARCH = 2,
16631 NEON_CHECK_ARCH8 = 4
16634 /* Call this function if an instruction which may have belonged to the VFP or
16635 Neon instruction sets, but turned out to be a Neon instruction (due to the
16636 operand types involved, etc.). We have to check and/or fix-up a couple of
16639 - Make sure the user hasn't attempted to make a Neon instruction
16641 - Alter the value in the condition code field if necessary.
16642 - Make sure that the arch supports Neon instructions.
16644 Which of these operations take place depends on bits from enum
16645 vfp_or_neon_is_neon_bits.
16647 WARNING: This function has side effects! If NEON_CHECK_CC is used and the
16648 current instruction's condition is COND_ALWAYS, the condition field is
16649 changed to inst.uncond_value. This is necessary because instructions shared
16650 between VFP and Neon may be conditional for the VFP variants only, and the
16651 unconditional Neon version must have, e.g., 0xF in the condition field. */
16654 vfp_or_neon_is_neon (unsigned check)
16656 /* Conditions are always legal in Thumb mode (IT blocks). */
16657 if (!thumb_mode && (check & NEON_CHECK_CC))
16659 if (inst.cond != COND_ALWAYS)
16661 first_error (_(BAD_COND));
16664 if (inst.uncond_value != -1)
16665 inst.instruction |= inst.uncond_value << 28;
16669 if (((check & NEON_CHECK_ARCH) && !mark_feature_used (&fpu_neon_ext_v1))
16670 || ((check & NEON_CHECK_ARCH8)
16671 && !mark_feature_used (&fpu_neon_ext_armv8)))
16673 first_error (_(BAD_FPU));
16681 /* Return TRUE if the SIMD instruction is available for the current
16682 cpu_variant. FP is set to TRUE if this is a SIMD floating-point
16683 instruction. CHECK contains th. CHECK contains the set of bits to pass to
16684 vfp_or_neon_is_neon for the NEON specific checks. */
16687 check_simd_pred_availability (int fp, unsigned check)
16689 if (inst.cond > COND_ALWAYS)
16691 if (!ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext))
16693 inst.error = BAD_FPU;
16696 inst.pred_insn_type = INSIDE_VPT_INSN;
16698 else if (inst.cond < COND_ALWAYS)
16700 if (ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext))
16701 inst.pred_insn_type = MVE_OUTSIDE_PRED_INSN;
16702 else if (vfp_or_neon_is_neon (check) == FAIL)
16707 if (!ARM_CPU_HAS_FEATURE (cpu_variant, fp ? mve_fp_ext : mve_ext)
16708 && vfp_or_neon_is_neon (check) == FAIL)
16711 if (ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext))
16712 inst.pred_insn_type = MVE_OUTSIDE_PRED_INSN;
16717 /* Neon instruction encoders, in approximate order of appearance. */
16720 do_neon_dyadic_i_su (void)
16722 if (!check_simd_pred_availability (FALSE, NEON_CHECK_ARCH | NEON_CHECK_CC))
16725 enum neon_shape rs;
16726 struct neon_type_el et;
16727 if (ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext))
16728 rs = neon_select_shape (NS_QQQ, NS_QQR, NS_NULL);
16730 rs = neon_select_shape (NS_DDD, NS_QQQ, NS_NULL);
16732 et = neon_check_type (3, rs, N_EQK, N_EQK, N_SU_32 | N_KEY);
16736 neon_three_same (neon_quad (rs), et.type == NT_unsigned, et.size);
16738 mve_encode_qqr (et.size, et.type == NT_unsigned, 0);
16742 do_neon_dyadic_i64_su (void)
16744 if (!check_simd_pred_availability (FALSE, NEON_CHECK_CC | NEON_CHECK_ARCH))
16746 enum neon_shape rs;
16747 struct neon_type_el et;
16748 if (ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext))
16750 rs = neon_select_shape (NS_QQR, NS_QQQ, NS_NULL);
16751 et = neon_check_type (3, rs, N_EQK, N_EQK, N_SU_MVE | N_KEY);
16755 rs = neon_select_shape (NS_DDD, NS_QQQ, NS_NULL);
16756 et = neon_check_type (3, rs, N_EQK, N_EQK, N_SU_ALL | N_KEY);
16759 mve_encode_qqr (et.size, et.type == NT_unsigned, 0);
16761 neon_three_same (neon_quad (rs), et.type == NT_unsigned, et.size);
16765 neon_imm_shift (int write_ubit, int uval, int isquad, struct neon_type_el et,
16768 unsigned size = et.size >> 3;
16769 inst.instruction |= LOW4 (inst.operands[0].reg) << 12;
16770 inst.instruction |= HI1 (inst.operands[0].reg) << 22;
16771 inst.instruction |= LOW4 (inst.operands[1].reg);
16772 inst.instruction |= HI1 (inst.operands[1].reg) << 5;
16773 inst.instruction |= (isquad != 0) << 6;
16774 inst.instruction |= immbits << 16;
16775 inst.instruction |= (size >> 3) << 7;
16776 inst.instruction |= (size & 0x7) << 19;
16778 inst.instruction |= (uval != 0) << 24;
16780 neon_dp_fixup (&inst);
16786 if (!check_simd_pred_availability (FALSE, NEON_CHECK_ARCH | NEON_CHECK_CC))
16789 if (!inst.operands[2].isreg)
16791 enum neon_shape rs;
16792 struct neon_type_el et;
16793 if (ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext))
16795 rs = neon_select_shape (NS_QQI, NS_NULL);
16796 et = neon_check_type (2, rs, N_EQK, N_KEY | N_I_MVE);
16800 rs = neon_select_shape (NS_DDI, NS_QQI, NS_NULL);
16801 et = neon_check_type (2, rs, N_EQK, N_KEY | N_I_ALL);
16803 int imm = inst.operands[2].imm;
16805 constraint (imm < 0 || (unsigned)imm >= et.size,
16806 _("immediate out of range for shift"));
16807 NEON_ENCODE (IMMED, inst);
16808 neon_imm_shift (FALSE, 0, neon_quad (rs), et, imm);
16812 enum neon_shape rs;
16813 struct neon_type_el et;
16814 if (ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext))
16816 rs = neon_select_shape (NS_QQQ, NS_QQR, NS_NULL);
16817 et = neon_check_type (3, rs, N_EQK, N_SU_MVE | N_KEY, N_EQK | N_EQK);
16821 rs = neon_select_shape (NS_DDD, NS_QQQ, NS_NULL);
16822 et = neon_check_type (3, rs, N_EQK, N_SU_ALL | N_KEY, N_EQK | N_SGN);
16828 constraint (inst.operands[0].reg != inst.operands[1].reg,
16829 _("invalid instruction shape"));
16830 if (inst.operands[2].reg == REG_SP)
16831 as_tsktsk (MVE_BAD_SP);
16832 else if (inst.operands[2].reg == REG_PC)
16833 as_tsktsk (MVE_BAD_PC);
16835 inst.instruction = 0xee311e60;
16836 inst.instruction |= (et.type == NT_unsigned) << 28;
16837 inst.instruction |= HI1 (inst.operands[0].reg) << 22;
16838 inst.instruction |= neon_logbits (et.size) << 18;
16839 inst.instruction |= LOW4 (inst.operands[0].reg) << 12;
16840 inst.instruction |= inst.operands[2].reg;
16847 /* VSHL/VQSHL 3-register variants have syntax such as:
16849 whereas other 3-register operations encoded by neon_three_same have
16852 (i.e. with Dn & Dm reversed). Swap operands[1].reg and
16853 operands[2].reg here. */
16854 tmp = inst.operands[2].reg;
16855 inst.operands[2].reg = inst.operands[1].reg;
16856 inst.operands[1].reg = tmp;
16857 NEON_ENCODE (INTEGER, inst);
16858 neon_three_same (neon_quad (rs), et.type == NT_unsigned, et.size);
16864 do_neon_qshl (void)
16866 if (!check_simd_pred_availability (FALSE, NEON_CHECK_ARCH | NEON_CHECK_CC))
16869 if (!inst.operands[2].isreg)
16871 enum neon_shape rs;
16872 struct neon_type_el et;
16873 if (ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext))
16875 rs = neon_select_shape (NS_QQI, NS_NULL);
16876 et = neon_check_type (2, rs, N_EQK, N_KEY | N_SU_MVE);
16880 rs = neon_select_shape (NS_DDI, NS_QQI, NS_NULL);
16881 et = neon_check_type (2, rs, N_EQK, N_SU_ALL | N_KEY);
16883 int imm = inst.operands[2].imm;
16885 constraint (imm < 0 || (unsigned)imm >= et.size,
16886 _("immediate out of range for shift"));
16887 NEON_ENCODE (IMMED, inst);
16888 neon_imm_shift (TRUE, et.type == NT_unsigned, neon_quad (rs), et, imm);
16892 enum neon_shape rs;
16893 struct neon_type_el et;
16895 if (ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext))
16897 rs = neon_select_shape (NS_QQQ, NS_QQR, NS_NULL);
16898 et = neon_check_type (3, rs, N_EQK, N_SU_MVE | N_KEY, N_EQK | N_EQK);
16902 rs = neon_select_shape (NS_DDD, NS_QQQ, NS_NULL);
16903 et = neon_check_type (3, rs, N_EQK, N_SU_ALL | N_KEY, N_EQK | N_SGN);
16908 constraint (inst.operands[0].reg != inst.operands[1].reg,
16909 _("invalid instruction shape"));
16910 if (inst.operands[2].reg == REG_SP)
16911 as_tsktsk (MVE_BAD_SP);
16912 else if (inst.operands[2].reg == REG_PC)
16913 as_tsktsk (MVE_BAD_PC);
16915 inst.instruction = 0xee311ee0;
16916 inst.instruction |= (et.type == NT_unsigned) << 28;
16917 inst.instruction |= HI1 (inst.operands[0].reg) << 22;
16918 inst.instruction |= neon_logbits (et.size) << 18;
16919 inst.instruction |= LOW4 (inst.operands[0].reg) << 12;
16920 inst.instruction |= inst.operands[2].reg;
16927 /* See note in do_neon_shl. */
16928 tmp = inst.operands[2].reg;
16929 inst.operands[2].reg = inst.operands[1].reg;
16930 inst.operands[1].reg = tmp;
16931 NEON_ENCODE (INTEGER, inst);
16932 neon_three_same (neon_quad (rs), et.type == NT_unsigned, et.size);
16938 do_neon_rshl (void)
16940 if (!check_simd_pred_availability (FALSE, NEON_CHECK_ARCH | NEON_CHECK_CC))
16943 enum neon_shape rs;
16944 struct neon_type_el et;
16945 if (ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext))
16947 rs = neon_select_shape (NS_QQR, NS_QQQ, NS_NULL);
16948 et = neon_check_type (3, rs, N_EQK, N_EQK, N_SU_MVE | N_KEY);
16952 rs = neon_select_shape (NS_DDD, NS_QQQ, NS_NULL);
16953 et = neon_check_type (3, rs, N_EQK, N_EQK, N_SU_ALL | N_KEY);
16960 if (inst.operands[2].reg == REG_PC)
16961 as_tsktsk (MVE_BAD_PC);
16962 else if (inst.operands[2].reg == REG_SP)
16963 as_tsktsk (MVE_BAD_SP);
16965 constraint (inst.operands[0].reg != inst.operands[1].reg,
16966 _("invalid instruction shape"));
16968 if (inst.instruction == 0x0000510)
16969 /* We are dealing with vqrshl. */
16970 inst.instruction = 0xee331ee0;
16972 /* We are dealing with vrshl. */
16973 inst.instruction = 0xee331e60;
16975 inst.instruction |= (et.type == NT_unsigned) << 28;
16976 inst.instruction |= HI1 (inst.operands[0].reg) << 22;
16977 inst.instruction |= neon_logbits (et.size) << 18;
16978 inst.instruction |= LOW4 (inst.operands[0].reg) << 12;
16979 inst.instruction |= inst.operands[2].reg;
16984 tmp = inst.operands[2].reg;
16985 inst.operands[2].reg = inst.operands[1].reg;
16986 inst.operands[1].reg = tmp;
16987 neon_three_same (neon_quad (rs), et.type == NT_unsigned, et.size);
16992 neon_cmode_for_logic_imm (unsigned immediate, unsigned *immbits, int size)
16994 /* Handle .I8 pseudo-instructions. */
16997 /* Unfortunately, this will make everything apart from zero out-of-range.
16998 FIXME is this the intended semantics? There doesn't seem much point in
16999 accepting .I8 if so. */
17000 immediate |= immediate << 8;
17006 if (immediate == (immediate & 0x000000ff))
17008 *immbits = immediate;
17011 else if (immediate == (immediate & 0x0000ff00))
17013 *immbits = immediate >> 8;
17016 else if (immediate == (immediate & 0x00ff0000))
17018 *immbits = immediate >> 16;
17021 else if (immediate == (immediate & 0xff000000))
17023 *immbits = immediate >> 24;
17026 if ((immediate & 0xffff) != (immediate >> 16))
17027 goto bad_immediate;
17028 immediate &= 0xffff;
17031 if (immediate == (immediate & 0x000000ff))
17033 *immbits = immediate;
17036 else if (immediate == (immediate & 0x0000ff00))
17038 *immbits = immediate >> 8;
17043 first_error (_("immediate value out of range"));
17048 do_neon_logic (void)
17050 if (inst.operands[2].present && inst.operands[2].isreg)
17052 enum neon_shape rs = neon_select_shape (NS_DDD, NS_QQQ, NS_NULL);
17054 && !check_simd_pred_availability (FALSE,
17055 NEON_CHECK_ARCH | NEON_CHECK_CC))
17057 else if (rs != NS_QQQ
17058 && !ARM_CPU_HAS_FEATURE (cpu_variant, fpu_neon_ext_v1))
17059 first_error (BAD_FPU);
17061 neon_check_type (3, rs, N_IGNORE_TYPE);
17062 /* U bit and size field were set as part of the bitmask. */
17063 NEON_ENCODE (INTEGER, inst);
17064 neon_three_same (neon_quad (rs), 0, -1);
17068 const int three_ops_form = (inst.operands[2].present
17069 && !inst.operands[2].isreg);
17070 const int immoperand = (three_ops_form ? 2 : 1);
17071 enum neon_shape rs = (three_ops_form
17072 ? neon_select_shape (NS_DDI, NS_QQI, NS_NULL)
17073 : neon_select_shape (NS_DI, NS_QI, NS_NULL));
17074 /* Because neon_select_shape makes the second operand a copy of the first
17075 if the second operand is not present. */
17077 && !check_simd_pred_availability (FALSE,
17078 NEON_CHECK_ARCH | NEON_CHECK_CC))
17080 else if (rs != NS_QQI
17081 && !ARM_CPU_HAS_FEATURE (cpu_variant, fpu_neon_ext_v1))
17082 first_error (BAD_FPU);
17084 struct neon_type_el et;
17085 if (ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext))
17086 et = neon_check_type (2, rs, N_I32 | N_I16 | N_KEY, N_EQK);
17088 et = neon_check_type (2, rs, N_I8 | N_I16 | N_I32 | N_I64 | N_F32
17091 if (et.type == NT_invtype)
17093 enum neon_opc opcode = (enum neon_opc) inst.instruction & 0x0fffffff;
17098 if (three_ops_form)
17099 constraint (inst.operands[0].reg != inst.operands[1].reg,
17100 _("first and second operands shall be the same register"));
17102 NEON_ENCODE (IMMED, inst);
17104 immbits = inst.operands[immoperand].imm;
17107 /* .i64 is a pseudo-op, so the immediate must be a repeating
17109 if (immbits != (inst.operands[immoperand].regisimm ?
17110 inst.operands[immoperand].reg : 0))
17112 /* Set immbits to an invalid constant. */
17113 immbits = 0xdeadbeef;
17120 cmode = neon_cmode_for_logic_imm (immbits, &immbits, et.size);
17124 cmode = neon_cmode_for_logic_imm (immbits, &immbits, et.size);
17128 /* Pseudo-instruction for VBIC. */
17129 neon_invert_size (&immbits, 0, et.size);
17130 cmode = neon_cmode_for_logic_imm (immbits, &immbits, et.size);
17134 /* Pseudo-instruction for VORR. */
17135 neon_invert_size (&immbits, 0, et.size);
17136 cmode = neon_cmode_for_logic_imm (immbits, &immbits, et.size);
17146 inst.instruction |= neon_quad (rs) << 6;
17147 inst.instruction |= LOW4 (inst.operands[0].reg) << 12;
17148 inst.instruction |= HI1 (inst.operands[0].reg) << 22;
17149 inst.instruction |= cmode << 8;
17150 neon_write_immbits (immbits);
17152 neon_dp_fixup (&inst);
17157 do_neon_bitfield (void)
17159 enum neon_shape rs = neon_select_shape (NS_DDD, NS_QQQ, NS_NULL);
17160 neon_check_type (3, rs, N_IGNORE_TYPE);
17161 neon_three_same (neon_quad (rs), 0, -1);
17165 neon_dyadic_misc (enum neon_el_type ubit_meaning, unsigned types,
17168 enum neon_shape rs = neon_select_shape (NS_DDD, NS_QQQ, NS_QQR, NS_NULL);
17169 struct neon_type_el et = neon_check_type (3, rs, N_EQK | destbits, N_EQK,
17171 if (et.type == NT_float)
17173 NEON_ENCODE (FLOAT, inst);
17175 mve_encode_qqr (et.size, 0, 1);
17177 neon_three_same (neon_quad (rs), 0, et.size == 16 ? (int) et.size : -1);
17181 NEON_ENCODE (INTEGER, inst);
17183 mve_encode_qqr (et.size, et.type == ubit_meaning, 0);
17185 neon_three_same (neon_quad (rs), et.type == ubit_meaning, et.size);
17191 do_neon_dyadic_if_su_d (void)
17193 /* This version only allow D registers, but that constraint is enforced during
17194 operand parsing so we don't need to do anything extra here. */
17195 neon_dyadic_misc (NT_unsigned, N_SUF_32, 0);
17199 do_neon_dyadic_if_i_d (void)
17201 /* The "untyped" case can't happen. Do this to stop the "U" bit being
17202 affected if we specify unsigned args. */
17203 neon_dyadic_misc (NT_untyped, N_IF_32, 0);
17207 do_mve_vstr_vldr_QI (int size, int elsize, int load)
17209 constraint (size < 32, BAD_ADDR_MODE);
17210 constraint (size != elsize, BAD_EL_TYPE);
17211 constraint (inst.operands[1].immisreg, BAD_ADDR_MODE);
17212 constraint (!inst.operands[1].preind, BAD_ADDR_MODE);
17213 constraint (load && inst.operands[0].reg == inst.operands[1].reg,
17214 _("destination register and offset register may not be the"
17217 int imm = inst.relocs[0].exp.X_add_number;
17224 constraint ((imm % (size / 8) != 0)
17225 || imm > (0x7f << neon_logbits (size)),
17226 (size == 32) ? _("immediate must be a multiple of 4 in the"
17227 " range of +/-[0,508]")
17228 : _("immediate must be a multiple of 8 in the"
17229 " range of +/-[0,1016]"));
17230 inst.instruction |= 0x11 << 24;
17231 inst.instruction |= add << 23;
17232 inst.instruction |= HI1 (inst.operands[0].reg) << 22;
17233 inst.instruction |= inst.operands[1].writeback << 21;
17234 inst.instruction |= LOW4 (inst.operands[1].reg) << 16;
17235 inst.instruction |= LOW4 (inst.operands[0].reg) << 12;
17236 inst.instruction |= 1 << 12;
17237 inst.instruction |= (size == 64) << 8;
17238 inst.instruction &= 0xffffff00;
17239 inst.instruction |= HI1 (inst.operands[1].reg) << 7;
17240 inst.instruction |= imm >> neon_logbits (size);
17244 do_mve_vstr_vldr_RQ (int size, int elsize, int load)
17246 unsigned os = inst.operands[1].imm >> 5;
17247 constraint (os != 0 && size == 8,
17248 _("can not shift offsets when accessing less than half-word"));
17249 constraint (os && os != neon_logbits (size),
17250 _("shift immediate must be 1, 2 or 3 for half-word, word"
17251 " or double-word accesses respectively"));
17252 if (inst.operands[1].reg == REG_PC)
17253 as_tsktsk (MVE_BAD_PC);
17258 constraint (elsize >= 64, BAD_EL_TYPE);
17261 constraint (elsize < 16 || elsize >= 64, BAD_EL_TYPE);
17265 constraint (elsize != size, BAD_EL_TYPE);
17270 constraint (inst.operands[1].writeback || !inst.operands[1].preind,
17274 constraint (inst.operands[0].reg == (inst.operands[1].imm & 0x1f),
17275 _("destination register and offset register may not be"
17277 constraint (size == elsize && inst.vectype.el[0].type != NT_unsigned,
17279 constraint (inst.vectype.el[0].type != NT_unsigned
17280 && inst.vectype.el[0].type != NT_signed, BAD_EL_TYPE);
17281 inst.instruction |= (inst.vectype.el[0].type == NT_unsigned) << 28;
17285 constraint (inst.vectype.el[0].type != NT_untyped, BAD_EL_TYPE);
17288 inst.instruction |= 1 << 23;
17289 inst.instruction |= HI1 (inst.operands[0].reg) << 22;
17290 inst.instruction |= inst.operands[1].reg << 16;
17291 inst.instruction |= LOW4 (inst.operands[0].reg) << 12;
17292 inst.instruction |= neon_logbits (elsize) << 7;
17293 inst.instruction |= HI1 (inst.operands[1].imm) << 5;
17294 inst.instruction |= LOW4 (inst.operands[1].imm);
17295 inst.instruction |= !!os;
17299 do_mve_vstr_vldr_RI (int size, int elsize, int load)
17301 enum neon_el_type type = inst.vectype.el[0].type;
17303 constraint (size >= 64, BAD_ADDR_MODE);
17307 constraint (elsize < 16 || elsize >= 64, BAD_EL_TYPE);
17310 constraint (elsize != size, BAD_EL_TYPE);
17317 constraint (elsize != size && type != NT_unsigned
17318 && type != NT_signed, BAD_EL_TYPE);
17322 constraint (elsize != size && type != NT_untyped, BAD_EL_TYPE);
17325 int imm = inst.relocs[0].exp.X_add_number;
17333 if ((imm % (size / 8) != 0) || imm > (0x7f << neon_logbits (size)))
17338 constraint (1, _("immediate must be in the range of +/-[0,127]"));
17341 constraint (1, _("immediate must be a multiple of 2 in the"
17342 " range of +/-[0,254]"));
17345 constraint (1, _("immediate must be a multiple of 4 in the"
17346 " range of +/-[0,508]"));
17351 if (size != elsize)
17353 constraint (inst.operands[1].reg > 7, BAD_HIREG);
17354 constraint (inst.operands[0].reg > 14,
17355 _("MVE vector register in the range [Q0..Q7] expected"));
17356 inst.instruction |= (load && type == NT_unsigned) << 28;
17357 inst.instruction |= (size == 16) << 19;
17358 inst.instruction |= neon_logbits (elsize) << 7;
17362 if (inst.operands[1].reg == REG_PC)
17363 as_tsktsk (MVE_BAD_PC);
17364 else if (inst.operands[1].reg == REG_SP && inst.operands[1].writeback)
17365 as_tsktsk (MVE_BAD_SP);
17366 inst.instruction |= 1 << 12;
17367 inst.instruction |= neon_logbits (size) << 7;
17369 inst.instruction |= inst.operands[1].preind << 24;
17370 inst.instruction |= add << 23;
17371 inst.instruction |= HI1 (inst.operands[0].reg) << 22;
17372 inst.instruction |= inst.operands[1].writeback << 21;
17373 inst.instruction |= inst.operands[1].reg << 16;
17374 inst.instruction |= LOW4 (inst.operands[0].reg) << 12;
17375 inst.instruction &= 0xffffff80;
17376 inst.instruction |= imm >> neon_logbits (size);
17381 do_mve_vstr_vldr (void)
17386 if (inst.cond > COND_ALWAYS)
17387 inst.pred_insn_type = INSIDE_VPT_INSN;
17389 inst.pred_insn_type = MVE_OUTSIDE_PRED_INSN;
17391 switch (inst.instruction)
17398 /* fall through. */
17404 /* fall through. */
17410 /* fall through. */
17416 /* fall through. */
17421 unsigned elsize = inst.vectype.el[0].size;
17423 if (inst.operands[1].isquad)
17425 /* We are dealing with [Q, imm]{!} cases. */
17426 do_mve_vstr_vldr_QI (size, elsize, load);
17430 if (inst.operands[1].immisreg == 2)
17432 /* We are dealing with [R, Q, {UXTW #os}] cases. */
17433 do_mve_vstr_vldr_RQ (size, elsize, load);
17435 else if (!inst.operands[1].immisreg)
17437 /* We are dealing with [R, Imm]{!}/[R], Imm cases. */
17438 do_mve_vstr_vldr_RI (size, elsize, load);
17441 constraint (1, BAD_ADDR_MODE);
17448 do_mve_vst_vld (void)
17450 if (!ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext))
17453 constraint (!inst.operands[1].preind || inst.relocs[0].exp.X_add_symbol != 0
17454 || inst.relocs[0].exp.X_add_number != 0
17455 || inst.operands[1].immisreg != 0,
17457 constraint (inst.vectype.el[0].size > 32, BAD_EL_TYPE);
17458 if (inst.operands[1].reg == REG_PC)
17459 as_tsktsk (MVE_BAD_PC);
17460 else if (inst.operands[1].reg == REG_SP && inst.operands[1].writeback)
17461 as_tsktsk (MVE_BAD_SP);
17464 /* These instructions are one of the "exceptions" mentioned in
17465 handle_pred_state. They are MVE instructions that are not VPT compatible
17466 and do not accept a VPT code, thus appending such a code is a syntax
17468 if (inst.cond > COND_ALWAYS)
17469 first_error (BAD_SYNTAX);
17470 /* If we append a scalar condition code we can set this to
17471 MVE_OUTSIDE_PRED_INSN as it will also lead to a syntax error. */
17472 else if (inst.cond < COND_ALWAYS)
17473 inst.pred_insn_type = MVE_OUTSIDE_PRED_INSN;
17475 inst.pred_insn_type = MVE_UNPREDICABLE_INSN;
17477 inst.instruction |= HI1 (inst.operands[0].reg) << 22;
17478 inst.instruction |= inst.operands[1].writeback << 21;
17479 inst.instruction |= inst.operands[1].reg << 16;
17480 inst.instruction |= LOW4 (inst.operands[0].reg) << 12;
17481 inst.instruction |= neon_logbits (inst.vectype.el[0].size) << 7;
17486 do_mve_vaddlv (void)
17488 enum neon_shape rs = neon_select_shape (NS_RRQ, NS_NULL);
17489 struct neon_type_el et
17490 = neon_check_type (3, rs, N_EQK, N_EQK, N_S32 | N_U32 | N_KEY);
17492 if (et.type == NT_invtype)
17493 first_error (BAD_EL_TYPE);
17495 if (inst.cond > COND_ALWAYS)
17496 inst.pred_insn_type = INSIDE_VPT_INSN;
17498 inst.pred_insn_type = MVE_OUTSIDE_PRED_INSN;
17500 constraint (inst.operands[1].reg > 14, MVE_BAD_QREG);
17502 inst.instruction |= (et.type == NT_unsigned) << 28;
17503 inst.instruction |= inst.operands[1].reg << 19;
17504 inst.instruction |= inst.operands[0].reg << 12;
17505 inst.instruction |= inst.operands[2].reg;
17510 do_neon_dyadic_if_su (void)
17512 enum neon_shape rs = neon_select_shape (NS_DDD, NS_QQQ, NS_QQR, NS_NULL);
17513 struct neon_type_el et = neon_check_type (3, rs, N_EQK , N_EQK,
17516 constraint ((inst.instruction == ((unsigned) N_MNEM_vmax)
17517 || inst.instruction == ((unsigned) N_MNEM_vmin))
17518 && et.type == NT_float
17519 && !ARM_CPU_HAS_FEATURE (cpu_variant,fpu_neon_ext_v1), BAD_FPU);
17521 if (!check_simd_pred_availability (et.type == NT_float,
17522 NEON_CHECK_ARCH | NEON_CHECK_CC))
17525 neon_dyadic_misc (NT_unsigned, N_SUF_32, 0);
17529 do_neon_addsub_if_i (void)
17531 if (ARM_CPU_HAS_FEATURE (cpu_variant, fpu_vfp_ext_v1xd)
17532 && try_vfp_nsyn (3, do_vfp_nsyn_add_sub) == SUCCESS)
17535 enum neon_shape rs = neon_select_shape (NS_DDD, NS_QQQ, NS_QQR, NS_NULL);
17536 struct neon_type_el et = neon_check_type (3, rs, N_EQK,
17537 N_EQK, N_IF_32 | N_I64 | N_KEY);
17539 constraint (rs == NS_QQR && et.size == 64, BAD_FPU);
17540 /* If we are parsing Q registers and the element types match MVE, which NEON
17541 also supports, then we must check whether this is an instruction that can
17542 be used by both MVE/NEON. This distinction can be made based on whether
17543 they are predicated or not. */
17544 if ((rs == NS_QQQ || rs == NS_QQR) && et.size != 64)
17546 if (!check_simd_pred_availability (et.type == NT_float,
17547 NEON_CHECK_ARCH | NEON_CHECK_CC))
17552 /* If they are either in a D register or are using an unsupported. */
17554 && vfp_or_neon_is_neon (NEON_CHECK_CC | NEON_CHECK_ARCH) == FAIL)
17558 /* The "untyped" case can't happen. Do this to stop the "U" bit being
17559 affected if we specify unsigned args. */
17560 neon_dyadic_misc (NT_untyped, N_IF_32 | N_I64, 0);
17563 /* Swaps operands 1 and 2. If operand 1 (optional arg) was omitted, we want the
17565 V<op> A,B (A is operand 0, B is operand 2)
17570 so handle that case specially. */
17573 neon_exchange_operands (void)
17575 if (inst.operands[1].present)
17577 void *scratch = xmalloc (sizeof (inst.operands[0]));
17579 /* Swap operands[1] and operands[2]. */
17580 memcpy (scratch, &inst.operands[1], sizeof (inst.operands[0]));
17581 inst.operands[1] = inst.operands[2];
17582 memcpy (&inst.operands[2], scratch, sizeof (inst.operands[0]));
17587 inst.operands[1] = inst.operands[2];
17588 inst.operands[2] = inst.operands[0];
17593 neon_compare (unsigned regtypes, unsigned immtypes, int invert)
17595 if (inst.operands[2].isreg)
17598 neon_exchange_operands ();
17599 neon_dyadic_misc (NT_unsigned, regtypes, N_SIZ);
17603 enum neon_shape rs = neon_select_shape (NS_DDI, NS_QQI, NS_NULL);
17604 struct neon_type_el et = neon_check_type (2, rs,
17605 N_EQK | N_SIZ, immtypes | N_KEY);
17607 NEON_ENCODE (IMMED, inst);
17608 inst.instruction |= LOW4 (inst.operands[0].reg) << 12;
17609 inst.instruction |= HI1 (inst.operands[0].reg) << 22;
17610 inst.instruction |= LOW4 (inst.operands[1].reg);
17611 inst.instruction |= HI1 (inst.operands[1].reg) << 5;
17612 inst.instruction |= neon_quad (rs) << 6;
17613 inst.instruction |= (et.type == NT_float) << 10;
17614 inst.instruction |= neon_logbits (et.size) << 18;
17616 neon_dp_fixup (&inst);
17623 neon_compare (N_SUF_32, N_S_32 | N_F_16_32, FALSE);
17627 do_neon_cmp_inv (void)
17629 neon_compare (N_SUF_32, N_S_32 | N_F_16_32, TRUE);
17635 neon_compare (N_IF_32, N_IF_32, FALSE);
17638 /* For multiply instructions, we have the possibility of 16-bit or 32-bit
17639 scalars, which are encoded in 5 bits, M : Rm.
17640 For 16-bit scalars, the register is encoded in Rm[2:0] and the index in
17641 M:Rm[3], and for 32-bit scalars, the register is encoded in Rm[3:0] and the
17644 Dot Product instructions are similar to multiply instructions except elsize
17645 should always be 32.
17647 This function translates SCALAR, which is GAS's internal encoding of indexed
17648 scalar register, to raw encoding. There is also register and index range
17649 check based on ELSIZE. */
17652 neon_scalar_for_mul (unsigned scalar, unsigned elsize)
17654 unsigned regno = NEON_SCALAR_REG (scalar);
17655 unsigned elno = NEON_SCALAR_INDEX (scalar);
17660 if (regno > 7 || elno > 3)
17662 return regno | (elno << 3);
17665 if (regno > 15 || elno > 1)
17667 return regno | (elno << 4);
17671 first_error (_("scalar out of range for multiply instruction"));
17677 /* Encode multiply / multiply-accumulate scalar instructions. */
17680 neon_mul_mac (struct neon_type_el et, int ubit)
17684 /* Give a more helpful error message if we have an invalid type. */
17685 if (et.type == NT_invtype)
17688 scalar = neon_scalar_for_mul (inst.operands[2].reg, et.size);
17689 inst.instruction |= LOW4 (inst.operands[0].reg) << 12;
17690 inst.instruction |= HI1 (inst.operands[0].reg) << 22;
17691 inst.instruction |= LOW4 (inst.operands[1].reg) << 16;
17692 inst.instruction |= HI1 (inst.operands[1].reg) << 7;
17693 inst.instruction |= LOW4 (scalar);
17694 inst.instruction |= HI1 (scalar) << 5;
17695 inst.instruction |= (et.type == NT_float) << 8;
17696 inst.instruction |= neon_logbits (et.size) << 20;
17697 inst.instruction |= (ubit != 0) << 24;
17699 neon_dp_fixup (&inst);
17703 do_neon_mac_maybe_scalar (void)
17705 if (try_vfp_nsyn (3, do_vfp_nsyn_mla_mls) == SUCCESS)
17708 if (!check_simd_pred_availability (FALSE, NEON_CHECK_CC | NEON_CHECK_ARCH))
17711 if (inst.operands[2].isscalar)
17713 constraint (ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext), BAD_FPU);
17714 enum neon_shape rs = neon_select_shape (NS_DDS, NS_QQS, NS_NULL);
17715 struct neon_type_el et = neon_check_type (3, rs,
17716 N_EQK, N_EQK, N_I16 | N_I32 | N_F_16_32 | N_KEY);
17717 NEON_ENCODE (SCALAR, inst);
17718 neon_mul_mac (et, neon_quad (rs));
17720 else if (!inst.operands[2].isvec)
17722 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext), BAD_FPU);
17724 enum neon_shape rs = neon_select_shape (NS_QQR, NS_NULL);
17725 neon_check_type (3, rs, N_EQK, N_EQK, N_SU_MVE | N_KEY);
17727 neon_dyadic_misc (NT_unsigned, N_SU_MVE, 0);
17731 constraint (ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext), BAD_FPU);
17732 /* The "untyped" case can't happen. Do this to stop the "U" bit being
17733 affected if we specify unsigned args. */
17734 neon_dyadic_misc (NT_untyped, N_IF_32, 0);
17739 do_neon_fmac (void)
17741 if (ARM_CPU_HAS_FEATURE (cpu_variant, fpu_vfp_ext_fma)
17742 && try_vfp_nsyn (3, do_vfp_nsyn_fma_fms) == SUCCESS)
17745 if (!check_simd_pred_availability (TRUE, NEON_CHECK_CC | NEON_CHECK_ARCH))
17748 if (ARM_CPU_HAS_FEATURE (cpu_variant, mve_fp_ext))
17750 enum neon_shape rs = neon_select_shape (NS_QQQ, NS_QQR, NS_NULL);
17751 struct neon_type_el et = neon_check_type (3, rs, N_F_MVE | N_KEY, N_EQK,
17756 if (inst.operands[2].reg == REG_SP)
17757 as_tsktsk (MVE_BAD_SP);
17758 else if (inst.operands[2].reg == REG_PC)
17759 as_tsktsk (MVE_BAD_PC);
17761 inst.instruction = 0xee310e40;
17762 inst.instruction |= (et.size == 16) << 28;
17763 inst.instruction |= HI1 (inst.operands[0].reg) << 22;
17764 inst.instruction |= LOW4 (inst.operands[1].reg) << 16;
17765 inst.instruction |= LOW4 (inst.operands[0].reg) << 12;
17766 inst.instruction |= HI1 (inst.operands[1].reg) << 6;
17767 inst.instruction |= inst.operands[2].reg;
17774 constraint (!inst.operands[2].isvec, BAD_FPU);
17777 neon_dyadic_misc (NT_untyped, N_IF_32, 0);
17783 enum neon_shape rs = neon_select_shape (NS_DDD, NS_QQQ, NS_NULL);
17784 struct neon_type_el et = neon_check_type (3, rs,
17785 N_EQK, N_EQK, N_8 | N_16 | N_32 | N_KEY);
17786 neon_three_same (neon_quad (rs), 0, et.size);
17789 /* VMUL with 3 registers allows the P8 type. The scalar version supports the
17790 same types as the MAC equivalents. The polynomial type for this instruction
17791 is encoded the same as the integer type. */
17796 if (try_vfp_nsyn (3, do_vfp_nsyn_mul) == SUCCESS)
17799 if (!check_simd_pred_availability (FALSE, NEON_CHECK_CC | NEON_CHECK_ARCH))
17802 if (inst.operands[2].isscalar)
17804 constraint (ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext), BAD_FPU);
17805 do_neon_mac_maybe_scalar ();
17809 if (ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext))
17811 enum neon_shape rs = neon_select_shape (NS_QQR, NS_QQQ, NS_NULL);
17812 struct neon_type_el et
17813 = neon_check_type (3, rs, N_EQK, N_EQK, N_I_MVE | N_F_MVE | N_KEY);
17814 if (et.type == NT_float)
17815 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant, mve_fp_ext),
17818 neon_dyadic_misc (NT_float, N_I_MVE | N_F_MVE, 0);
17822 constraint (!inst.operands[2].isvec, BAD_FPU);
17823 neon_dyadic_misc (NT_poly,
17824 N_I8 | N_I16 | N_I32 | N_F16 | N_F32 | N_P8, 0);
17830 do_neon_qdmulh (void)
17832 if (!check_simd_pred_availability (FALSE, NEON_CHECK_ARCH | NEON_CHECK_CC))
17835 if (inst.operands[2].isscalar)
17837 constraint (ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext), BAD_FPU);
17838 enum neon_shape rs = neon_select_shape (NS_DDS, NS_QQS, NS_NULL);
17839 struct neon_type_el et = neon_check_type (3, rs,
17840 N_EQK, N_EQK, N_S16 | N_S32 | N_KEY);
17841 NEON_ENCODE (SCALAR, inst);
17842 neon_mul_mac (et, neon_quad (rs));
17846 enum neon_shape rs;
17847 struct neon_type_el et;
17848 if (ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext))
17850 rs = neon_select_shape (NS_QQR, NS_QQQ, NS_NULL);
17851 et = neon_check_type (3, rs,
17852 N_EQK, N_EQK, N_S8 | N_S16 | N_S32 | N_KEY);
17856 rs = neon_select_shape (NS_DDD, NS_QQQ, NS_NULL);
17857 et = neon_check_type (3, rs,
17858 N_EQK, N_EQK, N_S16 | N_S32 | N_KEY);
17861 NEON_ENCODE (INTEGER, inst);
17863 mve_encode_qqr (et.size, 0, 0);
17865 /* The U bit (rounding) comes from bit mask. */
17866 neon_three_same (neon_quad (rs), 0, et.size);
17871 do_mve_vaddv (void)
17873 enum neon_shape rs = neon_select_shape (NS_RQ, NS_NULL);
17874 struct neon_type_el et
17875 = neon_check_type (2, rs, N_EQK, N_SU_32 | N_KEY);
17877 if (et.type == NT_invtype)
17878 first_error (BAD_EL_TYPE);
17880 if (inst.cond > COND_ALWAYS)
17881 inst.pred_insn_type = INSIDE_VPT_INSN;
17883 inst.pred_insn_type = MVE_OUTSIDE_PRED_INSN;
17885 constraint (inst.operands[1].reg > 14, MVE_BAD_QREG);
17887 mve_encode_rq (et.type == NT_unsigned, et.size);
17891 do_mve_vhcadd (void)
17893 enum neon_shape rs = neon_select_shape (NS_QQQI, NS_NULL);
17894 struct neon_type_el et
17895 = neon_check_type (3, rs, N_EQK, N_EQK, N_S8 | N_S16 | N_S32 | N_KEY);
17897 if (inst.cond > COND_ALWAYS)
17898 inst.pred_insn_type = INSIDE_VPT_INSN;
17900 inst.pred_insn_type = MVE_OUTSIDE_PRED_INSN;
17902 unsigned rot = inst.relocs[0].exp.X_add_number;
17903 constraint (rot != 90 && rot != 270, _("immediate out of range"));
17905 if (et.size == 32 && inst.operands[0].reg == inst.operands[2].reg)
17906 as_tsktsk (_("Warning: 32-bit element size and same first and third "
17907 "operand makes instruction UNPREDICTABLE"));
17909 mve_encode_qqq (0, et.size);
17910 inst.instruction |= (rot == 270) << 12;
17915 do_mve_vqdmull (void)
17917 enum neon_shape rs = neon_select_shape (NS_QQQ, NS_QQR, NS_NULL);
17918 struct neon_type_el et
17919 = neon_check_type (3, rs, N_EQK, N_EQK, N_S16 | N_S32 | N_KEY);
17922 && (inst.operands[0].reg == inst.operands[1].reg
17923 || (rs == NS_QQQ && inst.operands[0].reg == inst.operands[2].reg)))
17924 as_tsktsk (BAD_MVE_SRCDEST);
17926 if (inst.cond > COND_ALWAYS)
17927 inst.pred_insn_type = INSIDE_VPT_INSN;
17929 inst.pred_insn_type = MVE_OUTSIDE_PRED_INSN;
17933 mve_encode_qqq (et.size == 32, 64);
17934 inst.instruction |= 1;
17938 mve_encode_qqr (64, et.size == 32, 0);
17939 inst.instruction |= 0x3 << 5;
17946 enum neon_shape rs = neon_select_shape (NS_QQQ, NS_NULL);
17947 struct neon_type_el et
17948 = neon_check_type (3, rs, N_KEY | N_I32, N_EQK, N_EQK);
17950 if (et.type == NT_invtype)
17951 first_error (BAD_EL_TYPE);
17953 if (inst.cond > COND_ALWAYS)
17954 inst.pred_insn_type = INSIDE_VPT_INSN;
17956 inst.pred_insn_type = MVE_OUTSIDE_PRED_INSN;
17958 mve_encode_qqq (0, 64);
17962 do_mve_vbrsr (void)
17964 enum neon_shape rs = neon_select_shape (NS_QQR, NS_NULL);
17965 struct neon_type_el et
17966 = neon_check_type (3, rs, N_EQK, N_EQK, N_8 | N_16 | N_32 | N_KEY);
17968 if (inst.cond > COND_ALWAYS)
17969 inst.pred_insn_type = INSIDE_VPT_INSN;
17971 inst.pred_insn_type = MVE_OUTSIDE_PRED_INSN;
17973 mve_encode_qqr (et.size, 0, 0);
17979 neon_check_type (3, NS_QQQ, N_EQK, N_EQK, N_I32 | N_KEY);
17981 if (inst.cond > COND_ALWAYS)
17982 inst.pred_insn_type = INSIDE_VPT_INSN;
17984 inst.pred_insn_type = MVE_OUTSIDE_PRED_INSN;
17986 mve_encode_qqq (1, 64);
17990 do_mve_vmulh (void)
17992 enum neon_shape rs = neon_select_shape (NS_QQQ, NS_NULL);
17993 struct neon_type_el et
17994 = neon_check_type (3, rs, N_EQK, N_EQK, N_SU_MVE | N_KEY);
17996 if (inst.cond > COND_ALWAYS)
17997 inst.pred_insn_type = INSIDE_VPT_INSN;
17999 inst.pred_insn_type = MVE_OUTSIDE_PRED_INSN;
18001 mve_encode_qqq (et.type == NT_unsigned, et.size);
18005 do_mve_vqdmlah (void)
18007 enum neon_shape rs = neon_select_shape (NS_QQR, NS_NULL);
18008 struct neon_type_el et
18009 = neon_check_type (3, rs, N_EQK, N_EQK, N_S_32 | N_KEY);
18011 if (inst.cond > COND_ALWAYS)
18012 inst.pred_insn_type = INSIDE_VPT_INSN;
18014 inst.pred_insn_type = MVE_OUTSIDE_PRED_INSN;
18016 mve_encode_qqr (et.size, et.type == NT_unsigned, 0);
18020 do_mve_vqdmladh (void)
18022 enum neon_shape rs = neon_select_shape (NS_QQQ, NS_NULL);
18023 struct neon_type_el et
18024 = neon_check_type (3, rs, N_EQK, N_EQK, N_S8 | N_S16 | N_S32 | N_KEY);
18026 if (inst.cond > COND_ALWAYS)
18027 inst.pred_insn_type = INSIDE_VPT_INSN;
18029 inst.pred_insn_type = MVE_OUTSIDE_PRED_INSN;
18031 mve_encode_qqq (0, et.size);
18036 do_mve_vmull (void)
18039 enum neon_shape rs = neon_select_shape (NS_HHH, NS_FFF, NS_DDD, NS_DDS,
18040 NS_QQS, NS_QQQ, NS_QQR, NS_NULL);
18041 if (!ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext)
18042 && inst.cond == COND_ALWAYS
18043 && ((unsigned)inst.instruction) == M_MNEM_vmullt)
18048 struct neon_type_el et = neon_check_type (3, rs, N_EQK , N_EQK,
18049 N_SUF_32 | N_F64 | N_P8
18050 | N_P16 | N_I_MVE | N_KEY);
18051 if (((et.type == NT_poly) && et.size == 8
18052 && ARM_CPU_IS_ANY (cpu_variant))
18053 || (et.type == NT_integer) || (et.type == NT_float))
18060 constraint (rs != NS_QQQ, BAD_FPU);
18061 struct neon_type_el et = neon_check_type (3, rs, N_EQK , N_EQK,
18062 N_SU_32 | N_P8 | N_P16 | N_KEY);
18064 /* We are dealing with MVE's vmullt. */
18066 && (inst.operands[0].reg == inst.operands[1].reg
18067 || inst.operands[0].reg == inst.operands[2].reg))
18068 as_tsktsk (BAD_MVE_SRCDEST);
18070 if (inst.cond > COND_ALWAYS)
18071 inst.pred_insn_type = INSIDE_VPT_INSN;
18073 inst.pred_insn_type = MVE_OUTSIDE_PRED_INSN;
18075 if (et.type == NT_poly)
18076 mve_encode_qqq (neon_logbits (et.size), 64);
18078 mve_encode_qqq (et.type == NT_unsigned, et.size);
18083 inst.instruction = N_MNEM_vmul;
18086 inst.pred_insn_type = INSIDE_IT_INSN;
18091 do_mve_vabav (void)
18093 enum neon_shape rs = neon_select_shape (NS_RQQ, NS_NULL);
18098 if (!ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext))
18101 struct neon_type_el et = neon_check_type (2, NS_NULL, N_EQK, N_KEY | N_S8
18102 | N_S16 | N_S32 | N_U8 | N_U16
18105 if (inst.cond > COND_ALWAYS)
18106 inst.pred_insn_type = INSIDE_VPT_INSN;
18108 inst.pred_insn_type = MVE_OUTSIDE_PRED_INSN;
18110 mve_encode_rqq (et.type == NT_unsigned, et.size);
18114 do_mve_vmladav (void)
18116 enum neon_shape rs = neon_select_shape (NS_RQQ, NS_NULL);
18117 struct neon_type_el et = neon_check_type (3, rs,
18118 N_EQK, N_EQK, N_SU_MVE | N_KEY);
18120 if (et.type == NT_unsigned
18121 && (inst.instruction == M_MNEM_vmladavx
18122 || inst.instruction == M_MNEM_vmladavax
18123 || inst.instruction == M_MNEM_vmlsdav
18124 || inst.instruction == M_MNEM_vmlsdava
18125 || inst.instruction == M_MNEM_vmlsdavx
18126 || inst.instruction == M_MNEM_vmlsdavax))
18127 first_error (BAD_SIMD_TYPE);
18129 constraint (inst.operands[2].reg > 14,
18130 _("MVE vector register in the range [Q0..Q7] expected"));
18132 if (inst.cond > COND_ALWAYS)
18133 inst.pred_insn_type = INSIDE_VPT_INSN;
18135 inst.pred_insn_type = MVE_OUTSIDE_PRED_INSN;
18137 if (inst.instruction == M_MNEM_vmlsdav
18138 || inst.instruction == M_MNEM_vmlsdava
18139 || inst.instruction == M_MNEM_vmlsdavx
18140 || inst.instruction == M_MNEM_vmlsdavax)
18141 inst.instruction |= (et.size == 8) << 28;
18143 inst.instruction |= (et.size == 8) << 8;
18145 mve_encode_rqq (et.type == NT_unsigned, 64);
18146 inst.instruction |= (et.size == 32) << 16;
18150 do_mve_vmlaldav (void)
18152 enum neon_shape rs = neon_select_shape (NS_RRQQ, NS_NULL);
18153 struct neon_type_el et
18154 = neon_check_type (4, rs, N_EQK, N_EQK, N_EQK,
18155 N_S16 | N_S32 | N_U16 | N_U32 | N_KEY);
18157 if (et.type == NT_unsigned
18158 && (inst.instruction == M_MNEM_vmlsldav
18159 || inst.instruction == M_MNEM_vmlsldava
18160 || inst.instruction == M_MNEM_vmlsldavx
18161 || inst.instruction == M_MNEM_vmlsldavax))
18162 first_error (BAD_SIMD_TYPE);
18164 if (inst.cond > COND_ALWAYS)
18165 inst.pred_insn_type = INSIDE_VPT_INSN;
18167 inst.pred_insn_type = MVE_OUTSIDE_PRED_INSN;
18169 mve_encode_rrqq (et.type == NT_unsigned, et.size);
18173 do_mve_vrmlaldavh (void)
18175 struct neon_type_el et;
18176 if (inst.instruction == M_MNEM_vrmlsldavh
18177 || inst.instruction == M_MNEM_vrmlsldavha
18178 || inst.instruction == M_MNEM_vrmlsldavhx
18179 || inst.instruction == M_MNEM_vrmlsldavhax)
18181 et = neon_check_type (4, NS_RRQQ, N_EQK, N_EQK, N_EQK, N_S32 | N_KEY);
18182 if (inst.operands[1].reg == REG_SP)
18183 as_tsktsk (MVE_BAD_SP);
18187 if (inst.instruction == M_MNEM_vrmlaldavhx
18188 || inst.instruction == M_MNEM_vrmlaldavhax)
18189 et = neon_check_type (4, NS_RRQQ, N_EQK, N_EQK, N_EQK, N_S32 | N_KEY);
18191 et = neon_check_type (4, NS_RRQQ, N_EQK, N_EQK, N_EQK,
18192 N_U32 | N_S32 | N_KEY);
18193 /* vrmlaldavh's encoding with SP as the second, odd, GPR operand may alias
18194 with vmax/min instructions, making the use of SP in assembly really
18195 nonsensical, so instead of issuing a warning like we do for other uses
18196 of SP for the odd register operand we error out. */
18197 constraint (inst.operands[1].reg == REG_SP, BAD_SP);
18200 /* Make sure we still check the second operand is an odd one and that PC is
18201 disallowed. This because we are parsing for any GPR operand, to be able
18202 to distinguish between giving a warning or an error for SP as described
18204 constraint ((inst.operands[1].reg % 2) != 1, BAD_EVEN);
18205 constraint (inst.operands[1].reg == REG_PC, BAD_PC);
18207 if (inst.cond > COND_ALWAYS)
18208 inst.pred_insn_type = INSIDE_VPT_INSN;
18210 inst.pred_insn_type = MVE_OUTSIDE_PRED_INSN;
18212 mve_encode_rrqq (et.type == NT_unsigned, 0);
18217 do_mve_vmaxnmv (void)
18219 enum neon_shape rs = neon_select_shape (NS_RQ, NS_NULL);
18220 struct neon_type_el et
18221 = neon_check_type (2, rs, N_EQK, N_F_MVE | N_KEY);
18223 if (inst.cond > COND_ALWAYS)
18224 inst.pred_insn_type = INSIDE_VPT_INSN;
18226 inst.pred_insn_type = MVE_OUTSIDE_PRED_INSN;
18228 if (inst.operands[0].reg == REG_SP)
18229 as_tsktsk (MVE_BAD_SP);
18230 else if (inst.operands[0].reg == REG_PC)
18231 as_tsktsk (MVE_BAD_PC);
18233 mve_encode_rq (et.size == 16, 64);
18237 do_mve_vmaxv (void)
18239 enum neon_shape rs = neon_select_shape (NS_RQ, NS_NULL);
18240 struct neon_type_el et;
18242 if (inst.instruction == M_MNEM_vmaxv || inst.instruction == M_MNEM_vminv)
18243 et = neon_check_type (2, rs, N_EQK, N_SU_MVE | N_KEY);
18245 et = neon_check_type (2, rs, N_EQK, N_S8 | N_S16 | N_S32 | N_KEY);
18247 if (inst.cond > COND_ALWAYS)
18248 inst.pred_insn_type = INSIDE_VPT_INSN;
18250 inst.pred_insn_type = MVE_OUTSIDE_PRED_INSN;
18252 if (inst.operands[0].reg == REG_SP)
18253 as_tsktsk (MVE_BAD_SP);
18254 else if (inst.operands[0].reg == REG_PC)
18255 as_tsktsk (MVE_BAD_PC);
18257 mve_encode_rq (et.type == NT_unsigned, et.size);
18262 do_neon_qrdmlah (void)
18264 if (!check_simd_pred_availability (FALSE, NEON_CHECK_ARCH | NEON_CHECK_CC))
18266 if (!ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext))
18268 /* Check we're on the correct architecture. */
18269 if (!mark_feature_used (&fpu_neon_ext_armv8))
18271 = _("instruction form not available on this architecture.");
18272 else if (!mark_feature_used (&fpu_neon_ext_v8_1))
18274 as_warn (_("this instruction implies use of ARMv8.1 AdvSIMD."));
18275 record_feature_use (&fpu_neon_ext_v8_1);
18277 if (inst.operands[2].isscalar)
18279 enum neon_shape rs = neon_select_shape (NS_DDS, NS_QQS, NS_NULL);
18280 struct neon_type_el et = neon_check_type (3, rs,
18281 N_EQK, N_EQK, N_S16 | N_S32 | N_KEY);
18282 NEON_ENCODE (SCALAR, inst);
18283 neon_mul_mac (et, neon_quad (rs));
18287 enum neon_shape rs = neon_select_shape (NS_DDD, NS_QQQ, NS_NULL);
18288 struct neon_type_el et = neon_check_type (3, rs,
18289 N_EQK, N_EQK, N_S16 | N_S32 | N_KEY);
18290 NEON_ENCODE (INTEGER, inst);
18291 /* The U bit (rounding) comes from bit mask. */
18292 neon_three_same (neon_quad (rs), 0, et.size);
18297 enum neon_shape rs = neon_select_shape (NS_QQR, NS_NULL);
18298 struct neon_type_el et
18299 = neon_check_type (3, rs, N_EQK, N_EQK, N_S_32 | N_KEY);
18301 NEON_ENCODE (INTEGER, inst);
18302 mve_encode_qqr (et.size, et.type == NT_unsigned, 0);
18307 do_neon_fcmp_absolute (void)
18309 enum neon_shape rs = neon_select_shape (NS_DDD, NS_QQQ, NS_NULL);
18310 struct neon_type_el et = neon_check_type (3, rs, N_EQK, N_EQK,
18311 N_F_16_32 | N_KEY);
18312 /* Size field comes from bit mask. */
18313 neon_three_same (neon_quad (rs), 1, et.size == 16 ? (int) et.size : -1);
18317 do_neon_fcmp_absolute_inv (void)
18319 neon_exchange_operands ();
18320 do_neon_fcmp_absolute ();
18324 do_neon_step (void)
18326 enum neon_shape rs = neon_select_shape (NS_DDD, NS_QQQ, NS_NULL);
18327 struct neon_type_el et = neon_check_type (3, rs, N_EQK, N_EQK,
18328 N_F_16_32 | N_KEY);
18329 neon_three_same (neon_quad (rs), 0, et.size == 16 ? (int) et.size : -1);
18333 do_neon_abs_neg (void)
18335 enum neon_shape rs;
18336 struct neon_type_el et;
18338 if (try_vfp_nsyn (2, do_vfp_nsyn_abs_neg) == SUCCESS)
18341 rs = neon_select_shape (NS_DD, NS_QQ, NS_NULL);
18342 et = neon_check_type (2, rs, N_EQK, N_S_32 | N_F_16_32 | N_KEY);
18344 if (!check_simd_pred_availability (et.type == NT_float,
18345 NEON_CHECK_ARCH | NEON_CHECK_CC))
18348 inst.instruction |= LOW4 (inst.operands[0].reg) << 12;
18349 inst.instruction |= HI1 (inst.operands[0].reg) << 22;
18350 inst.instruction |= LOW4 (inst.operands[1].reg);
18351 inst.instruction |= HI1 (inst.operands[1].reg) << 5;
18352 inst.instruction |= neon_quad (rs) << 6;
18353 inst.instruction |= (et.type == NT_float) << 10;
18354 inst.instruction |= neon_logbits (et.size) << 18;
18356 neon_dp_fixup (&inst);
18362 if (!check_simd_pred_availability (FALSE, NEON_CHECK_ARCH | NEON_CHECK_CC))
18365 enum neon_shape rs;
18366 struct neon_type_el et;
18367 if (ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext))
18369 rs = neon_select_shape (NS_QQI, NS_NULL);
18370 et = neon_check_type (2, rs, N_EQK, N_8 | N_16 | N_32 | N_KEY);
18374 rs = neon_select_shape (NS_DDI, NS_QQI, NS_NULL);
18375 et = neon_check_type (2, rs, N_EQK, N_8 | N_16 | N_32 | N_64 | N_KEY);
18379 int imm = inst.operands[2].imm;
18380 constraint (imm < 0 || (unsigned)imm >= et.size,
18381 _("immediate out of range for insert"));
18382 neon_imm_shift (FALSE, 0, neon_quad (rs), et, imm);
18388 if (!check_simd_pred_availability (FALSE, NEON_CHECK_ARCH | NEON_CHECK_CC))
18391 enum neon_shape rs;
18392 struct neon_type_el et;
18393 if (ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext))
18395 rs = neon_select_shape (NS_QQI, NS_NULL);
18396 et = neon_check_type (2, rs, N_EQK, N_8 | N_16 | N_32 | N_KEY);
18400 rs = neon_select_shape (NS_DDI, NS_QQI, NS_NULL);
18401 et = neon_check_type (2, rs, N_EQK, N_8 | N_16 | N_32 | N_64 | N_KEY);
18404 int imm = inst.operands[2].imm;
18405 constraint (imm < 1 || (unsigned)imm > et.size,
18406 _("immediate out of range for insert"));
18407 neon_imm_shift (FALSE, 0, neon_quad (rs), et, et.size - imm);
18411 do_neon_qshlu_imm (void)
18413 if (!check_simd_pred_availability (FALSE, NEON_CHECK_ARCH | NEON_CHECK_CC))
18416 enum neon_shape rs;
18417 struct neon_type_el et;
18418 if (ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext))
18420 rs = neon_select_shape (NS_QQI, NS_NULL);
18421 et = neon_check_type (2, rs, N_EQK, N_S8 | N_S16 | N_S32 | N_KEY);
18425 rs = neon_select_shape (NS_DDI, NS_QQI, NS_NULL);
18426 et = neon_check_type (2, rs, N_EQK | N_UNS,
18427 N_S8 | N_S16 | N_S32 | N_S64 | N_KEY);
18430 int imm = inst.operands[2].imm;
18431 constraint (imm < 0 || (unsigned)imm >= et.size,
18432 _("immediate out of range for shift"));
18433 /* Only encodes the 'U present' variant of the instruction.
18434 In this case, signed types have OP (bit 8) set to 0.
18435 Unsigned types have OP set to 1. */
18436 inst.instruction |= (et.type == NT_unsigned) << 8;
18437 /* The rest of the bits are the same as other immediate shifts. */
18438 neon_imm_shift (FALSE, 0, neon_quad (rs), et, imm);
18442 do_neon_qmovn (void)
18444 struct neon_type_el et = neon_check_type (2, NS_DQ,
18445 N_EQK | N_HLF, N_SU_16_64 | N_KEY);
18446 /* Saturating move where operands can be signed or unsigned, and the
18447 destination has the same signedness. */
18448 NEON_ENCODE (INTEGER, inst);
18449 if (et.type == NT_unsigned)
18450 inst.instruction |= 0xc0;
18452 inst.instruction |= 0x80;
18453 neon_two_same (0, 1, et.size / 2);
18457 do_neon_qmovun (void)
18459 struct neon_type_el et = neon_check_type (2, NS_DQ,
18460 N_EQK | N_HLF | N_UNS, N_S16 | N_S32 | N_S64 | N_KEY);
18461 /* Saturating move with unsigned results. Operands must be signed. */
18462 NEON_ENCODE (INTEGER, inst);
18463 neon_two_same (0, 1, et.size / 2);
18467 do_neon_rshift_sat_narrow (void)
18469 /* FIXME: Types for narrowing. If operands are signed, results can be signed
18470 or unsigned. If operands are unsigned, results must also be unsigned. */
18471 struct neon_type_el et = neon_check_type (2, NS_DQI,
18472 N_EQK | N_HLF, N_SU_16_64 | N_KEY);
18473 int imm = inst.operands[2].imm;
18474 /* This gets the bounds check, size encoding and immediate bits calculation
18478 /* VQ{R}SHRN.I<size> <Dd>, <Qm>, #0 is a synonym for
18479 VQMOVN.I<size> <Dd>, <Qm>. */
18482 inst.operands[2].present = 0;
18483 inst.instruction = N_MNEM_vqmovn;
18488 constraint (imm < 1 || (unsigned)imm > et.size,
18489 _("immediate out of range"));
18490 neon_imm_shift (TRUE, et.type == NT_unsigned, 0, et, et.size - imm);
18494 do_neon_rshift_sat_narrow_u (void)
18496 /* FIXME: Types for narrowing. If operands are signed, results can be signed
18497 or unsigned. If operands are unsigned, results must also be unsigned. */
18498 struct neon_type_el et = neon_check_type (2, NS_DQI,
18499 N_EQK | N_HLF | N_UNS, N_S16 | N_S32 | N_S64 | N_KEY);
18500 int imm = inst.operands[2].imm;
18501 /* This gets the bounds check, size encoding and immediate bits calculation
18505 /* VQSHRUN.I<size> <Dd>, <Qm>, #0 is a synonym for
18506 VQMOVUN.I<size> <Dd>, <Qm>. */
18509 inst.operands[2].present = 0;
18510 inst.instruction = N_MNEM_vqmovun;
18515 constraint (imm < 1 || (unsigned)imm > et.size,
18516 _("immediate out of range"));
18517 /* FIXME: The manual is kind of unclear about what value U should have in
18518 VQ{R}SHRUN instructions, but U=0, op=0 definitely encodes VRSHR, so it
18520 neon_imm_shift (TRUE, 1, 0, et, et.size - imm);
18524 do_neon_movn (void)
18526 struct neon_type_el et = neon_check_type (2, NS_DQ,
18527 N_EQK | N_HLF, N_I16 | N_I32 | N_I64 | N_KEY);
18528 NEON_ENCODE (INTEGER, inst);
18529 neon_two_same (0, 1, et.size / 2);
18533 do_neon_rshift_narrow (void)
18535 struct neon_type_el et = neon_check_type (2, NS_DQI,
18536 N_EQK | N_HLF, N_I16 | N_I32 | N_I64 | N_KEY);
18537 int imm = inst.operands[2].imm;
18538 /* This gets the bounds check, size encoding and immediate bits calculation
18542 /* If immediate is zero then we are a pseudo-instruction for
18543 VMOVN.I<size> <Dd>, <Qm> */
18546 inst.operands[2].present = 0;
18547 inst.instruction = N_MNEM_vmovn;
18552 constraint (imm < 1 || (unsigned)imm > et.size,
18553 _("immediate out of range for narrowing operation"));
18554 neon_imm_shift (FALSE, 0, 0, et, et.size - imm);
18558 do_neon_shll (void)
18560 /* FIXME: Type checking when lengthening. */
18561 struct neon_type_el et = neon_check_type (2, NS_QDI,
18562 N_EQK | N_DBL, N_I8 | N_I16 | N_I32 | N_KEY);
18563 unsigned imm = inst.operands[2].imm;
18565 if (imm == et.size)
18567 /* Maximum shift variant. */
18568 NEON_ENCODE (INTEGER, inst);
18569 inst.instruction |= LOW4 (inst.operands[0].reg) << 12;
18570 inst.instruction |= HI1 (inst.operands[0].reg) << 22;
18571 inst.instruction |= LOW4 (inst.operands[1].reg);
18572 inst.instruction |= HI1 (inst.operands[1].reg) << 5;
18573 inst.instruction |= neon_logbits (et.size) << 18;
18575 neon_dp_fixup (&inst);
18579 /* A more-specific type check for non-max versions. */
18580 et = neon_check_type (2, NS_QDI,
18581 N_EQK | N_DBL, N_SU_32 | N_KEY);
18582 NEON_ENCODE (IMMED, inst);
18583 neon_imm_shift (TRUE, et.type == NT_unsigned, 0, et, imm);
18587 /* Check the various types for the VCVT instruction, and return which version
18588 the current instruction is. */
18590 #define CVT_FLAVOUR_VAR \
18591 CVT_VAR (s32_f32, N_S32, N_F32, whole_reg, "ftosls", "ftosis", "ftosizs") \
18592 CVT_VAR (u32_f32, N_U32, N_F32, whole_reg, "ftouls", "ftouis", "ftouizs") \
18593 CVT_VAR (f32_s32, N_F32, N_S32, whole_reg, "fsltos", "fsitos", NULL) \
18594 CVT_VAR (f32_u32, N_F32, N_U32, whole_reg, "fultos", "fuitos", NULL) \
18595 /* Half-precision conversions. */ \
18596 CVT_VAR (s16_f16, N_S16, N_F16 | N_KEY, whole_reg, NULL, NULL, NULL) \
18597 CVT_VAR (u16_f16, N_U16, N_F16 | N_KEY, whole_reg, NULL, NULL, NULL) \
18598 CVT_VAR (f16_s16, N_F16 | N_KEY, N_S16, whole_reg, NULL, NULL, NULL) \
18599 CVT_VAR (f16_u16, N_F16 | N_KEY, N_U16, whole_reg, NULL, NULL, NULL) \
18600 CVT_VAR (f32_f16, N_F32, N_F16, whole_reg, NULL, NULL, NULL) \
18601 CVT_VAR (f16_f32, N_F16, N_F32, whole_reg, NULL, NULL, NULL) \
18602 /* New VCVT instructions introduced by ARMv8.2 fp16 extension. \
18603 Compared with single/double precision variants, only the co-processor \
18604 field is different, so the encoding flow is reused here. */ \
18605 CVT_VAR (f16_s32, N_F16 | N_KEY, N_S32, N_VFP, "fsltos", "fsitos", NULL) \
18606 CVT_VAR (f16_u32, N_F16 | N_KEY, N_U32, N_VFP, "fultos", "fuitos", NULL) \
18607 CVT_VAR (u32_f16, N_U32, N_F16 | N_KEY, N_VFP, "ftouls", "ftouis", "ftouizs")\
18608 CVT_VAR (s32_f16, N_S32, N_F16 | N_KEY, N_VFP, "ftosls", "ftosis", "ftosizs")\
18609 /* VFP instructions. */ \
18610 CVT_VAR (f32_f64, N_F32, N_F64, N_VFP, NULL, "fcvtsd", NULL) \
18611 CVT_VAR (f64_f32, N_F64, N_F32, N_VFP, NULL, "fcvtds", NULL) \
18612 CVT_VAR (s32_f64, N_S32, N_F64 | key, N_VFP, "ftosld", "ftosid", "ftosizd") \
18613 CVT_VAR (u32_f64, N_U32, N_F64 | key, N_VFP, "ftould", "ftouid", "ftouizd") \
18614 CVT_VAR (f64_s32, N_F64 | key, N_S32, N_VFP, "fsltod", "fsitod", NULL) \
18615 CVT_VAR (f64_u32, N_F64 | key, N_U32, N_VFP, "fultod", "fuitod", NULL) \
18616 /* VFP instructions with bitshift. */ \
18617 CVT_VAR (f32_s16, N_F32 | key, N_S16, N_VFP, "fshtos", NULL, NULL) \
18618 CVT_VAR (f32_u16, N_F32 | key, N_U16, N_VFP, "fuhtos", NULL, NULL) \
18619 CVT_VAR (f64_s16, N_F64 | key, N_S16, N_VFP, "fshtod", NULL, NULL) \
18620 CVT_VAR (f64_u16, N_F64 | key, N_U16, N_VFP, "fuhtod", NULL, NULL) \
18621 CVT_VAR (s16_f32, N_S16, N_F32 | key, N_VFP, "ftoshs", NULL, NULL) \
18622 CVT_VAR (u16_f32, N_U16, N_F32 | key, N_VFP, "ftouhs", NULL, NULL) \
18623 CVT_VAR (s16_f64, N_S16, N_F64 | key, N_VFP, "ftoshd", NULL, NULL) \
18624 CVT_VAR (u16_f64, N_U16, N_F64 | key, N_VFP, "ftouhd", NULL, NULL)
18626 #define CVT_VAR(C, X, Y, R, BSN, CN, ZN) \
18627 neon_cvt_flavour_##C,
18629 /* The different types of conversions we can do. */
18630 enum neon_cvt_flavour
18633 neon_cvt_flavour_invalid,
18634 neon_cvt_flavour_first_fp = neon_cvt_flavour_f32_f64
18639 static enum neon_cvt_flavour
18640 get_neon_cvt_flavour (enum neon_shape rs)
18642 #define CVT_VAR(C,X,Y,R,BSN,CN,ZN) \
18643 et = neon_check_type (2, rs, (R) | (X), (R) | (Y)); \
18644 if (et.type != NT_invtype) \
18646 inst.error = NULL; \
18647 return (neon_cvt_flavour_##C); \
18650 struct neon_type_el et;
18651 unsigned whole_reg = (rs == NS_FFI || rs == NS_FD || rs == NS_DF
18652 || rs == NS_FF) ? N_VFP : 0;
18653 /* The instruction versions which take an immediate take one register
18654 argument, which is extended to the width of the full register. Thus the
18655 "source" and "destination" registers must have the same width. Hack that
18656 here by making the size equal to the key (wider, in this case) operand. */
18657 unsigned key = (rs == NS_QQI || rs == NS_DDI || rs == NS_FFI) ? N_KEY : 0;
18661 return neon_cvt_flavour_invalid;
18676 /* Neon-syntax VFP conversions. */
18679 do_vfp_nsyn_cvt (enum neon_shape rs, enum neon_cvt_flavour flavour)
18681 const char *opname = 0;
18683 if (rs == NS_DDI || rs == NS_QQI || rs == NS_FFI
18684 || rs == NS_FHI || rs == NS_HFI)
18686 /* Conversions with immediate bitshift. */
18687 const char *enc[] =
18689 #define CVT_VAR(C,A,B,R,BSN,CN,ZN) BSN,
18695 if (flavour < (int) ARRAY_SIZE (enc))
18697 opname = enc[flavour];
18698 constraint (inst.operands[0].reg != inst.operands[1].reg,
18699 _("operands 0 and 1 must be the same register"));
18700 inst.operands[1] = inst.operands[2];
18701 memset (&inst.operands[2], '\0', sizeof (inst.operands[2]));
18706 /* Conversions without bitshift. */
18707 const char *enc[] =
18709 #define CVT_VAR(C,A,B,R,BSN,CN,ZN) CN,
18715 if (flavour < (int) ARRAY_SIZE (enc))
18716 opname = enc[flavour];
18720 do_vfp_nsyn_opcode (opname);
18722 /* ARMv8.2 fp16 VCVT instruction. */
18723 if (flavour == neon_cvt_flavour_s32_f16
18724 || flavour == neon_cvt_flavour_u32_f16
18725 || flavour == neon_cvt_flavour_f16_u32
18726 || flavour == neon_cvt_flavour_f16_s32)
18727 do_scalar_fp16_v82_encode ();
18731 do_vfp_nsyn_cvtz (void)
18733 enum neon_shape rs = neon_select_shape (NS_FH, NS_FF, NS_FD, NS_NULL);
18734 enum neon_cvt_flavour flavour = get_neon_cvt_flavour (rs);
18735 const char *enc[] =
18737 #define CVT_VAR(C,A,B,R,BSN,CN,ZN) ZN,
18743 if (flavour < (int) ARRAY_SIZE (enc) && enc[flavour])
18744 do_vfp_nsyn_opcode (enc[flavour]);
18748 do_vfp_nsyn_cvt_fpv8 (enum neon_cvt_flavour flavour,
18749 enum neon_cvt_mode mode)
18754 /* Targets like FPv5-SP-D16 don't support FP v8 instructions with
18755 D register operands. */
18756 if (flavour == neon_cvt_flavour_s32_f64
18757 || flavour == neon_cvt_flavour_u32_f64)
18758 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant, fpu_vfp_ext_armv8),
18761 if (flavour == neon_cvt_flavour_s32_f16
18762 || flavour == neon_cvt_flavour_u32_f16)
18763 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_fp16),
18766 set_pred_insn_type (OUTSIDE_PRED_INSN);
18770 case neon_cvt_flavour_s32_f64:
18774 case neon_cvt_flavour_s32_f32:
18778 case neon_cvt_flavour_s32_f16:
18782 case neon_cvt_flavour_u32_f64:
18786 case neon_cvt_flavour_u32_f32:
18790 case neon_cvt_flavour_u32_f16:
18795 first_error (_("invalid instruction shape"));
18801 case neon_cvt_mode_a: rm = 0; break;
18802 case neon_cvt_mode_n: rm = 1; break;
18803 case neon_cvt_mode_p: rm = 2; break;
18804 case neon_cvt_mode_m: rm = 3; break;
18805 default: first_error (_("invalid rounding mode")); return;
18808 NEON_ENCODE (FPV8, inst);
18809 encode_arm_vfp_reg (inst.operands[0].reg, VFP_REG_Sd);
18810 encode_arm_vfp_reg (inst.operands[1].reg, sz == 1 ? VFP_REG_Dm : VFP_REG_Sm);
18811 inst.instruction |= sz << 8;
18813 /* ARMv8.2 fp16 VCVT instruction. */
18814 if (flavour == neon_cvt_flavour_s32_f16
18815 ||flavour == neon_cvt_flavour_u32_f16)
18816 do_scalar_fp16_v82_encode ();
18817 inst.instruction |= op << 7;
18818 inst.instruction |= rm << 16;
18819 inst.instruction |= 0xf0000000;
18820 inst.is_neon = TRUE;
18824 do_neon_cvt_1 (enum neon_cvt_mode mode)
18826 enum neon_shape rs = neon_select_shape (NS_DDI, NS_QQI, NS_FFI, NS_DD, NS_QQ,
18827 NS_FD, NS_DF, NS_FF, NS_QD, NS_DQ,
18828 NS_FH, NS_HF, NS_FHI, NS_HFI,
18830 enum neon_cvt_flavour flavour = get_neon_cvt_flavour (rs);
18832 if (flavour == neon_cvt_flavour_invalid)
18835 /* PR11109: Handle round-to-zero for VCVT conversions. */
18836 if (mode == neon_cvt_mode_z
18837 && ARM_CPU_HAS_FEATURE (cpu_variant, fpu_arch_vfp_v2)
18838 && (flavour == neon_cvt_flavour_s16_f16
18839 || flavour == neon_cvt_flavour_u16_f16
18840 || flavour == neon_cvt_flavour_s32_f32
18841 || flavour == neon_cvt_flavour_u32_f32
18842 || flavour == neon_cvt_flavour_s32_f64
18843 || flavour == neon_cvt_flavour_u32_f64)
18844 && (rs == NS_FD || rs == NS_FF))
18846 do_vfp_nsyn_cvtz ();
18850 /* ARMv8.2 fp16 VCVT conversions. */
18851 if (mode == neon_cvt_mode_z
18852 && ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_fp16)
18853 && (flavour == neon_cvt_flavour_s32_f16
18854 || flavour == neon_cvt_flavour_u32_f16)
18857 do_vfp_nsyn_cvtz ();
18858 do_scalar_fp16_v82_encode ();
18862 /* VFP rather than Neon conversions. */
18863 if (flavour >= neon_cvt_flavour_first_fp)
18865 if (mode == neon_cvt_mode_x || mode == neon_cvt_mode_z)
18866 do_vfp_nsyn_cvt (rs, flavour);
18868 do_vfp_nsyn_cvt_fpv8 (flavour, mode);
18876 if (mode == neon_cvt_mode_z
18877 && (flavour == neon_cvt_flavour_f16_s16
18878 || flavour == neon_cvt_flavour_f16_u16
18879 || flavour == neon_cvt_flavour_s16_f16
18880 || flavour == neon_cvt_flavour_u16_f16
18881 || flavour == neon_cvt_flavour_f32_u32
18882 || flavour == neon_cvt_flavour_f32_s32
18883 || flavour == neon_cvt_flavour_s32_f32
18884 || flavour == neon_cvt_flavour_u32_f32))
18886 if (!check_simd_pred_availability (TRUE,
18887 NEON_CHECK_CC | NEON_CHECK_ARCH))
18890 else if (mode == neon_cvt_mode_n)
18892 /* We are dealing with vcvt with the 'ne' condition. */
18894 inst.instruction = N_MNEM_vcvt;
18895 do_neon_cvt_1 (neon_cvt_mode_z);
18898 /* fall through. */
18902 unsigned enctab[] = {0x0000100, 0x1000100, 0x0, 0x1000000,
18903 0x0000100, 0x1000100, 0x0, 0x1000000};
18905 if ((rs != NS_QQI || !ARM_CPU_HAS_FEATURE (cpu_variant, mve_fp_ext))
18906 && vfp_or_neon_is_neon (NEON_CHECK_CC | NEON_CHECK_ARCH) == FAIL)
18909 if (ARM_CPU_HAS_FEATURE (cpu_variant, mve_fp_ext))
18911 constraint (inst.operands[2].present && inst.operands[2].imm == 0,
18912 _("immediate value out of range"));
18915 case neon_cvt_flavour_f16_s16:
18916 case neon_cvt_flavour_f16_u16:
18917 case neon_cvt_flavour_s16_f16:
18918 case neon_cvt_flavour_u16_f16:
18919 constraint (inst.operands[2].imm > 16,
18920 _("immediate value out of range"));
18922 case neon_cvt_flavour_f32_u32:
18923 case neon_cvt_flavour_f32_s32:
18924 case neon_cvt_flavour_s32_f32:
18925 case neon_cvt_flavour_u32_f32:
18926 constraint (inst.operands[2].imm > 32,
18927 _("immediate value out of range"));
18930 inst.error = BAD_FPU;
18935 /* Fixed-point conversion with #0 immediate is encoded as an
18936 integer conversion. */
18937 if (inst.operands[2].present && inst.operands[2].imm == 0)
18939 NEON_ENCODE (IMMED, inst);
18940 if (flavour != neon_cvt_flavour_invalid)
18941 inst.instruction |= enctab[flavour];
18942 inst.instruction |= LOW4 (inst.operands[0].reg) << 12;
18943 inst.instruction |= HI1 (inst.operands[0].reg) << 22;
18944 inst.instruction |= LOW4 (inst.operands[1].reg);
18945 inst.instruction |= HI1 (inst.operands[1].reg) << 5;
18946 inst.instruction |= neon_quad (rs) << 6;
18947 inst.instruction |= 1 << 21;
18948 if (flavour < neon_cvt_flavour_s16_f16)
18950 inst.instruction |= 1 << 21;
18951 immbits = 32 - inst.operands[2].imm;
18952 inst.instruction |= immbits << 16;
18956 inst.instruction |= 3 << 20;
18957 immbits = 16 - inst.operands[2].imm;
18958 inst.instruction |= immbits << 16;
18959 inst.instruction &= ~(1 << 9);
18962 neon_dp_fixup (&inst);
18967 if ((mode == neon_cvt_mode_a || mode == neon_cvt_mode_n
18968 || mode == neon_cvt_mode_m || mode == neon_cvt_mode_p)
18969 && (flavour == neon_cvt_flavour_s16_f16
18970 || flavour == neon_cvt_flavour_u16_f16
18971 || flavour == neon_cvt_flavour_s32_f32
18972 || flavour == neon_cvt_flavour_u32_f32))
18974 if (!check_simd_pred_availability (TRUE,
18975 NEON_CHECK_CC | NEON_CHECK_ARCH8))
18978 else if (mode == neon_cvt_mode_z
18979 && (flavour == neon_cvt_flavour_f16_s16
18980 || flavour == neon_cvt_flavour_f16_u16
18981 || flavour == neon_cvt_flavour_s16_f16
18982 || flavour == neon_cvt_flavour_u16_f16
18983 || flavour == neon_cvt_flavour_f32_u32
18984 || flavour == neon_cvt_flavour_f32_s32
18985 || flavour == neon_cvt_flavour_s32_f32
18986 || flavour == neon_cvt_flavour_u32_f32))
18988 if (!check_simd_pred_availability (TRUE,
18989 NEON_CHECK_CC | NEON_CHECK_ARCH))
18992 /* fall through. */
18994 if (mode != neon_cvt_mode_x && mode != neon_cvt_mode_z)
18997 NEON_ENCODE (FLOAT, inst);
18998 if (!check_simd_pred_availability (TRUE,
18999 NEON_CHECK_CC | NEON_CHECK_ARCH8))
19002 inst.instruction |= LOW4 (inst.operands[0].reg) << 12;
19003 inst.instruction |= HI1 (inst.operands[0].reg) << 22;
19004 inst.instruction |= LOW4 (inst.operands[1].reg);
19005 inst.instruction |= HI1 (inst.operands[1].reg) << 5;
19006 inst.instruction |= neon_quad (rs) << 6;
19007 inst.instruction |= (flavour == neon_cvt_flavour_u16_f16
19008 || flavour == neon_cvt_flavour_u32_f32) << 7;
19009 inst.instruction |= mode << 8;
19010 if (flavour == neon_cvt_flavour_u16_f16
19011 || flavour == neon_cvt_flavour_s16_f16)
19012 /* Mask off the original size bits and reencode them. */
19013 inst.instruction = ((inst.instruction & 0xfff3ffff) | (1 << 18));
19016 inst.instruction |= 0xfc000000;
19018 inst.instruction |= 0xf0000000;
19024 unsigned enctab[] = { 0x100, 0x180, 0x0, 0x080,
19025 0x100, 0x180, 0x0, 0x080};
19027 NEON_ENCODE (INTEGER, inst);
19029 if (!ARM_CPU_HAS_FEATURE (cpu_variant, mve_fp_ext))
19031 if (vfp_or_neon_is_neon (NEON_CHECK_CC | NEON_CHECK_ARCH) == FAIL)
19035 if (flavour != neon_cvt_flavour_invalid)
19036 inst.instruction |= enctab[flavour];
19038 inst.instruction |= LOW4 (inst.operands[0].reg) << 12;
19039 inst.instruction |= HI1 (inst.operands[0].reg) << 22;
19040 inst.instruction |= LOW4 (inst.operands[1].reg);
19041 inst.instruction |= HI1 (inst.operands[1].reg) << 5;
19042 inst.instruction |= neon_quad (rs) << 6;
19043 if (flavour >= neon_cvt_flavour_s16_f16
19044 && flavour <= neon_cvt_flavour_f16_u16)
19045 /* Half precision. */
19046 inst.instruction |= 1 << 18;
19048 inst.instruction |= 2 << 18;
19050 neon_dp_fixup (&inst);
19055 /* Half-precision conversions for Advanced SIMD -- neon. */
19058 if (vfp_or_neon_is_neon (NEON_CHECK_CC | NEON_CHECK_ARCH) == FAIL)
19062 && (inst.vectype.el[0].size != 16 || inst.vectype.el[1].size != 32))
19064 as_bad (_("operand size must match register width"));
19069 && ((inst.vectype.el[0].size != 32 || inst.vectype.el[1].size != 16)))
19071 as_bad (_("operand size must match register width"));
19076 inst.instruction = 0x3b60600;
19078 inst.instruction = 0x3b60700;
19080 inst.instruction |= LOW4 (inst.operands[0].reg) << 12;
19081 inst.instruction |= HI1 (inst.operands[0].reg) << 22;
19082 inst.instruction |= LOW4 (inst.operands[1].reg);
19083 inst.instruction |= HI1 (inst.operands[1].reg) << 5;
19084 neon_dp_fixup (&inst);
19088 /* Some VFP conversions go here (s32 <-> f32, u32 <-> f32). */
19089 if (mode == neon_cvt_mode_x || mode == neon_cvt_mode_z)
19090 do_vfp_nsyn_cvt (rs, flavour);
19092 do_vfp_nsyn_cvt_fpv8 (flavour, mode);
19097 do_neon_cvtr (void)
19099 do_neon_cvt_1 (neon_cvt_mode_x);
19105 do_neon_cvt_1 (neon_cvt_mode_z);
19109 do_neon_cvta (void)
19111 do_neon_cvt_1 (neon_cvt_mode_a);
19115 do_neon_cvtn (void)
19117 do_neon_cvt_1 (neon_cvt_mode_n);
19121 do_neon_cvtp (void)
19123 do_neon_cvt_1 (neon_cvt_mode_p);
19127 do_neon_cvtm (void)
19129 do_neon_cvt_1 (neon_cvt_mode_m);
19133 do_neon_cvttb_2 (bfd_boolean t, bfd_boolean to, bfd_boolean is_double)
19136 mark_feature_used (&fpu_vfp_ext_armv8);
19138 encode_arm_vfp_reg (inst.operands[0].reg,
19139 (is_double && !to) ? VFP_REG_Dd : VFP_REG_Sd);
19140 encode_arm_vfp_reg (inst.operands[1].reg,
19141 (is_double && to) ? VFP_REG_Dm : VFP_REG_Sm);
19142 inst.instruction |= to ? 0x10000 : 0;
19143 inst.instruction |= t ? 0x80 : 0;
19144 inst.instruction |= is_double ? 0x100 : 0;
19145 do_vfp_cond_or_thumb ();
19149 do_neon_cvttb_1 (bfd_boolean t)
19151 enum neon_shape rs = neon_select_shape (NS_HF, NS_HD, NS_FH, NS_FF, NS_FD,
19152 NS_DF, NS_DH, NS_QQ, NS_QQI, NS_NULL);
19156 else if (rs == NS_QQ || rs == NS_QQI)
19158 int single_to_half = 0;
19159 if (!check_simd_pred_availability (TRUE, NEON_CHECK_ARCH))
19162 enum neon_cvt_flavour flavour = get_neon_cvt_flavour (rs);
19164 if (ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext)
19165 && (flavour == neon_cvt_flavour_u16_f16
19166 || flavour == neon_cvt_flavour_s16_f16
19167 || flavour == neon_cvt_flavour_f16_s16
19168 || flavour == neon_cvt_flavour_f16_u16
19169 || flavour == neon_cvt_flavour_u32_f32
19170 || flavour == neon_cvt_flavour_s32_f32
19171 || flavour == neon_cvt_flavour_f32_s32
19172 || flavour == neon_cvt_flavour_f32_u32))
19175 inst.instruction = N_MNEM_vcvt;
19176 set_pred_insn_type (INSIDE_VPT_INSN);
19177 do_neon_cvt_1 (neon_cvt_mode_z);
19180 else if (rs == NS_QQ && flavour == neon_cvt_flavour_f32_f16)
19181 single_to_half = 1;
19182 else if (rs == NS_QQ && flavour != neon_cvt_flavour_f16_f32)
19184 first_error (BAD_FPU);
19188 inst.instruction = 0xee3f0e01;
19189 inst.instruction |= single_to_half << 28;
19190 inst.instruction |= HI1 (inst.operands[0].reg) << 22;
19191 inst.instruction |= LOW4 (inst.operands[0].reg) << 13;
19192 inst.instruction |= t << 12;
19193 inst.instruction |= HI1 (inst.operands[1].reg) << 5;
19194 inst.instruction |= LOW4 (inst.operands[1].reg) << 1;
19197 else if (neon_check_type (2, rs, N_F16, N_F32 | N_VFP).type != NT_invtype)
19200 do_neon_cvttb_2 (t, /*to=*/TRUE, /*is_double=*/FALSE);
19202 else if (neon_check_type (2, rs, N_F32 | N_VFP, N_F16).type != NT_invtype)
19205 do_neon_cvttb_2 (t, /*to=*/FALSE, /*is_double=*/FALSE);
19207 else if (neon_check_type (2, rs, N_F16, N_F64 | N_VFP).type != NT_invtype)
19209 /* The VCVTB and VCVTT instructions with D-register operands
19210 don't work for SP only targets. */
19211 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant, fpu_vfp_ext_armv8),
19215 do_neon_cvttb_2 (t, /*to=*/TRUE, /*is_double=*/TRUE);
19217 else if (neon_check_type (2, rs, N_F64 | N_VFP, N_F16).type != NT_invtype)
19219 /* The VCVTB and VCVTT instructions with D-register operands
19220 don't work for SP only targets. */
19221 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant, fpu_vfp_ext_armv8),
19225 do_neon_cvttb_2 (t, /*to=*/FALSE, /*is_double=*/TRUE);
19232 do_neon_cvtb (void)
19234 do_neon_cvttb_1 (FALSE);
19239 do_neon_cvtt (void)
19241 do_neon_cvttb_1 (TRUE);
19245 neon_move_immediate (void)
19247 enum neon_shape rs = neon_select_shape (NS_DI, NS_QI, NS_NULL);
19248 struct neon_type_el et = neon_check_type (2, rs,
19249 N_I8 | N_I16 | N_I32 | N_I64 | N_F32 | N_KEY, N_EQK);
19250 unsigned immlo, immhi = 0, immbits;
19251 int op, cmode, float_p;
19253 constraint (et.type == NT_invtype,
19254 _("operand size must be specified for immediate VMOV"));
19256 /* We start out as an MVN instruction if OP = 1, MOV otherwise. */
19257 op = (inst.instruction & (1 << 5)) != 0;
19259 immlo = inst.operands[1].imm;
19260 if (inst.operands[1].regisimm)
19261 immhi = inst.operands[1].reg;
19263 constraint (et.size < 32 && (immlo & ~((1 << et.size) - 1)) != 0,
19264 _("immediate has bits set outside the operand size"));
19266 float_p = inst.operands[1].immisfloat;
19268 if ((cmode = neon_cmode_for_move_imm (immlo, immhi, float_p, &immbits, &op,
19269 et.size, et.type)) == FAIL)
19271 /* Invert relevant bits only. */
19272 neon_invert_size (&immlo, &immhi, et.size);
19273 /* Flip from VMOV/VMVN to VMVN/VMOV. Some immediate types are unavailable
19274 with one or the other; those cases are caught by
19275 neon_cmode_for_move_imm. */
19277 if ((cmode = neon_cmode_for_move_imm (immlo, immhi, float_p, &immbits,
19278 &op, et.size, et.type)) == FAIL)
19280 first_error (_("immediate out of range"));
19285 inst.instruction &= ~(1 << 5);
19286 inst.instruction |= op << 5;
19288 inst.instruction |= LOW4 (inst.operands[0].reg) << 12;
19289 inst.instruction |= HI1 (inst.operands[0].reg) << 22;
19290 inst.instruction |= neon_quad (rs) << 6;
19291 inst.instruction |= cmode << 8;
19293 neon_write_immbits (immbits);
19299 if (!check_simd_pred_availability (FALSE, NEON_CHECK_CC | NEON_CHECK_ARCH))
19302 if (inst.operands[1].isreg)
19304 enum neon_shape rs;
19305 if (ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext))
19306 rs = neon_select_shape (NS_QQ, NS_NULL);
19308 rs = neon_select_shape (NS_DD, NS_QQ, NS_NULL);
19310 NEON_ENCODE (INTEGER, inst);
19311 inst.instruction |= LOW4 (inst.operands[0].reg) << 12;
19312 inst.instruction |= HI1 (inst.operands[0].reg) << 22;
19313 inst.instruction |= LOW4 (inst.operands[1].reg);
19314 inst.instruction |= HI1 (inst.operands[1].reg) << 5;
19315 inst.instruction |= neon_quad (rs) << 6;
19319 NEON_ENCODE (IMMED, inst);
19320 neon_move_immediate ();
19323 neon_dp_fixup (&inst);
19325 if (ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext))
19327 constraint (!inst.operands[1].isreg && !inst.operands[0].isquad, BAD_FPU);
19328 constraint ((inst.instruction & 0xd00) == 0xd00,
19329 _("immediate value out of range"));
19333 /* Encode instructions of form:
19335 |28/24|23|22|21 20|19 16|15 12|11 8|7|6|5|4|3 0|
19336 | U |x |D |size | Rn | Rd |x x x x|N|x|M|x| Rm | */
19339 neon_mixed_length (struct neon_type_el et, unsigned size)
19341 inst.instruction |= LOW4 (inst.operands[0].reg) << 12;
19342 inst.instruction |= HI1 (inst.operands[0].reg) << 22;
19343 inst.instruction |= LOW4 (inst.operands[1].reg) << 16;
19344 inst.instruction |= HI1 (inst.operands[1].reg) << 7;
19345 inst.instruction |= LOW4 (inst.operands[2].reg);
19346 inst.instruction |= HI1 (inst.operands[2].reg) << 5;
19347 inst.instruction |= (et.type == NT_unsigned) << 24;
19348 inst.instruction |= neon_logbits (size) << 20;
19350 neon_dp_fixup (&inst);
19354 do_neon_dyadic_long (void)
19356 enum neon_shape rs = neon_select_shape (NS_QDD, NS_QQQ, NS_QQR, NS_NULL);
19359 if (vfp_or_neon_is_neon (NEON_CHECK_ARCH | NEON_CHECK_CC) == FAIL)
19362 NEON_ENCODE (INTEGER, inst);
19363 /* FIXME: Type checking for lengthening op. */
19364 struct neon_type_el et = neon_check_type (3, NS_QDD,
19365 N_EQK | N_DBL, N_EQK, N_SU_32 | N_KEY);
19366 neon_mixed_length (et, et.size);
19368 else if (ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext)
19369 && (inst.cond == 0xf || inst.cond == 0x10))
19371 /* If parsing for MVE, vaddl/vsubl/vabdl{e,t} can only be vadd/vsub/vabd
19372 in an IT block with le/lt conditions. */
19374 if (inst.cond == 0xf)
19376 else if (inst.cond == 0x10)
19379 inst.pred_insn_type = INSIDE_IT_INSN;
19381 if (inst.instruction == N_MNEM_vaddl)
19383 inst.instruction = N_MNEM_vadd;
19384 do_neon_addsub_if_i ();
19386 else if (inst.instruction == N_MNEM_vsubl)
19388 inst.instruction = N_MNEM_vsub;
19389 do_neon_addsub_if_i ();
19391 else if (inst.instruction == N_MNEM_vabdl)
19393 inst.instruction = N_MNEM_vabd;
19394 do_neon_dyadic_if_su ();
19398 first_error (BAD_FPU);
19402 do_neon_abal (void)
19404 struct neon_type_el et = neon_check_type (3, NS_QDD,
19405 N_EQK | N_INT | N_DBL, N_EQK, N_SU_32 | N_KEY);
19406 neon_mixed_length (et, et.size);
19410 neon_mac_reg_scalar_long (unsigned regtypes, unsigned scalartypes)
19412 if (inst.operands[2].isscalar)
19414 struct neon_type_el et = neon_check_type (3, NS_QDS,
19415 N_EQK | N_DBL, N_EQK, regtypes | N_KEY);
19416 NEON_ENCODE (SCALAR, inst);
19417 neon_mul_mac (et, et.type == NT_unsigned);
19421 struct neon_type_el et = neon_check_type (3, NS_QDD,
19422 N_EQK | N_DBL, N_EQK, scalartypes | N_KEY);
19423 NEON_ENCODE (INTEGER, inst);
19424 neon_mixed_length (et, et.size);
19429 do_neon_mac_maybe_scalar_long (void)
19431 neon_mac_reg_scalar_long (N_S16 | N_S32 | N_U16 | N_U32, N_SU_32);
19434 /* Like neon_scalar_for_mul, this function generate Rm encoding from GAS's
19435 internal SCALAR. QUAD_P is 1 if it's for Q format, otherwise it's 0. */
19438 neon_scalar_for_fmac_fp16_long (unsigned scalar, unsigned quad_p)
19440 unsigned regno = NEON_SCALAR_REG (scalar);
19441 unsigned elno = NEON_SCALAR_INDEX (scalar);
19445 if (regno > 7 || elno > 3)
19448 return ((regno & 0x7)
19449 | ((elno & 0x1) << 3)
19450 | (((elno >> 1) & 0x1) << 5));
19454 if (regno > 15 || elno > 1)
19457 return (((regno & 0x1) << 5)
19458 | ((regno >> 1) & 0x7)
19459 | ((elno & 0x1) << 3));
19463 first_error (_("scalar out of range for multiply instruction"));
19468 do_neon_fmac_maybe_scalar_long (int subtype)
19470 enum neon_shape rs;
19472 /* NOTE: vfmal/vfmsl use slightly different NEON three-same encoding. 'size"
19473 field (bits[21:20]) has different meaning. For scalar index variant, it's
19474 used to differentiate add and subtract, otherwise it's with fixed value
19478 if (inst.cond != COND_ALWAYS)
19479 as_warn (_("vfmal/vfmsl with FP16 type cannot be conditional, the "
19480 "behaviour is UNPREDICTABLE"));
19482 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_fp16_fml),
19485 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant, fpu_neon_ext_armv8),
19488 /* vfmal/vfmsl are in three-same D/Q register format or the third operand can
19489 be a scalar index register. */
19490 if (inst.operands[2].isscalar)
19492 high8 = 0xfe000000;
19495 rs = neon_select_shape (NS_DHS, NS_QDS, NS_NULL);
19499 high8 = 0xfc000000;
19502 inst.instruction |= (0x1 << 23);
19503 rs = neon_select_shape (NS_DHH, NS_QDD, NS_NULL);
19506 neon_check_type (3, rs, N_EQK, N_EQK, N_KEY | N_F16);
19508 /* "opcode" from template has included "ubit", so simply pass 0 here. Also,
19509 the "S" bit in size field has been reused to differentiate vfmal and vfmsl,
19510 so we simply pass -1 as size. */
19511 unsigned quad_p = (rs == NS_QDD || rs == NS_QDS);
19512 neon_three_same (quad_p, 0, size);
19514 /* Undo neon_dp_fixup. Redo the high eight bits. */
19515 inst.instruction &= 0x00ffffff;
19516 inst.instruction |= high8;
19518 #define LOW1(R) ((R) & 0x1)
19519 #define HI4(R) (((R) >> 1) & 0xf)
19520 /* Unlike usually NEON three-same, encoding for Vn and Vm will depend on
19521 whether the instruction is in Q form and whether Vm is a scalar indexed
19523 if (inst.operands[2].isscalar)
19526 = neon_scalar_for_fmac_fp16_long (inst.operands[2].reg, quad_p);
19527 inst.instruction &= 0xffffffd0;
19528 inst.instruction |= rm;
19532 /* Redo Rn as well. */
19533 inst.instruction &= 0xfff0ff7f;
19534 inst.instruction |= HI4 (inst.operands[1].reg) << 16;
19535 inst.instruction |= LOW1 (inst.operands[1].reg) << 7;
19540 /* Redo Rn and Rm. */
19541 inst.instruction &= 0xfff0ff50;
19542 inst.instruction |= HI4 (inst.operands[1].reg) << 16;
19543 inst.instruction |= LOW1 (inst.operands[1].reg) << 7;
19544 inst.instruction |= HI4 (inst.operands[2].reg);
19545 inst.instruction |= LOW1 (inst.operands[2].reg) << 5;
19550 do_neon_vfmal (void)
19552 return do_neon_fmac_maybe_scalar_long (0);
19556 do_neon_vfmsl (void)
19558 return do_neon_fmac_maybe_scalar_long (1);
19562 do_neon_dyadic_wide (void)
19564 struct neon_type_el et = neon_check_type (3, NS_QQD,
19565 N_EQK | N_DBL, N_EQK | N_DBL, N_SU_32 | N_KEY);
19566 neon_mixed_length (et, et.size);
19570 do_neon_dyadic_narrow (void)
19572 struct neon_type_el et = neon_check_type (3, NS_QDD,
19573 N_EQK | N_DBL, N_EQK, N_I16 | N_I32 | N_I64 | N_KEY);
19574 /* Operand sign is unimportant, and the U bit is part of the opcode,
19575 so force the operand type to integer. */
19576 et.type = NT_integer;
19577 neon_mixed_length (et, et.size / 2);
19581 do_neon_mul_sat_scalar_long (void)
19583 neon_mac_reg_scalar_long (N_S16 | N_S32, N_S16 | N_S32);
19587 do_neon_vmull (void)
19589 if (inst.operands[2].isscalar)
19590 do_neon_mac_maybe_scalar_long ();
19593 struct neon_type_el et = neon_check_type (3, NS_QDD,
19594 N_EQK | N_DBL, N_EQK, N_SU_32 | N_P8 | N_P64 | N_KEY);
19596 if (et.type == NT_poly)
19597 NEON_ENCODE (POLY, inst);
19599 NEON_ENCODE (INTEGER, inst);
19601 /* For polynomial encoding the U bit must be zero, and the size must
19602 be 8 (encoded as 0b00) or, on ARMv8 or later 64 (encoded, non
19603 obviously, as 0b10). */
19606 /* Check we're on the correct architecture. */
19607 if (!mark_feature_used (&fpu_crypto_ext_armv8))
19609 _("Instruction form not available on this architecture.");
19614 neon_mixed_length (et, et.size);
19621 enum neon_shape rs = neon_select_shape (NS_DDDI, NS_QQQI, NS_NULL);
19622 struct neon_type_el et = neon_check_type (3, rs,
19623 N_EQK, N_EQK, N_8 | N_16 | N_32 | N_64 | N_KEY);
19624 unsigned imm = (inst.operands[3].imm * et.size) / 8;
19626 constraint (imm >= (unsigned) (neon_quad (rs) ? 16 : 8),
19627 _("shift out of range"));
19628 inst.instruction |= LOW4 (inst.operands[0].reg) << 12;
19629 inst.instruction |= HI1 (inst.operands[0].reg) << 22;
19630 inst.instruction |= LOW4 (inst.operands[1].reg) << 16;
19631 inst.instruction |= HI1 (inst.operands[1].reg) << 7;
19632 inst.instruction |= LOW4 (inst.operands[2].reg);
19633 inst.instruction |= HI1 (inst.operands[2].reg) << 5;
19634 inst.instruction |= neon_quad (rs) << 6;
19635 inst.instruction |= imm << 8;
19637 neon_dp_fixup (&inst);
19643 if (!check_simd_pred_availability (FALSE, NEON_CHECK_ARCH | NEON_CHECK_CC))
19646 enum neon_shape rs;
19647 if (ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext))
19648 rs = neon_select_shape (NS_QQ, NS_NULL);
19650 rs = neon_select_shape (NS_DD, NS_QQ, NS_NULL);
19652 struct neon_type_el et = neon_check_type (2, rs,
19653 N_EQK, N_8 | N_16 | N_32 | N_KEY);
19655 unsigned op = (inst.instruction >> 7) & 3;
19656 /* N (width of reversed regions) is encoded as part of the bitmask. We
19657 extract it here to check the elements to be reversed are smaller.
19658 Otherwise we'd get a reserved instruction. */
19659 unsigned elsize = (op == 2) ? 16 : (op == 1) ? 32 : (op == 0) ? 64 : 0;
19661 if (ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext) && elsize == 64
19662 && inst.operands[0].reg == inst.operands[1].reg)
19663 as_tsktsk (_("Warning: 64-bit element size and same destination and source"
19664 " operands makes instruction UNPREDICTABLE"));
19666 gas_assert (elsize != 0);
19667 constraint (et.size >= elsize,
19668 _("elements must be smaller than reversal region"));
19669 neon_two_same (neon_quad (rs), 1, et.size);
19675 if (inst.operands[1].isscalar)
19677 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant, fpu_neon_ext_v1),
19679 enum neon_shape rs = neon_select_shape (NS_DS, NS_QS, NS_NULL);
19680 struct neon_type_el et = neon_check_type (2, rs,
19681 N_EQK, N_8 | N_16 | N_32 | N_KEY);
19682 unsigned sizebits = et.size >> 3;
19683 unsigned dm = NEON_SCALAR_REG (inst.operands[1].reg);
19684 int logsize = neon_logbits (et.size);
19685 unsigned x = NEON_SCALAR_INDEX (inst.operands[1].reg) << logsize;
19687 if (vfp_or_neon_is_neon (NEON_CHECK_CC) == FAIL)
19690 NEON_ENCODE (SCALAR, inst);
19691 inst.instruction |= LOW4 (inst.operands[0].reg) << 12;
19692 inst.instruction |= HI1 (inst.operands[0].reg) << 22;
19693 inst.instruction |= LOW4 (dm);
19694 inst.instruction |= HI1 (dm) << 5;
19695 inst.instruction |= neon_quad (rs) << 6;
19696 inst.instruction |= x << 17;
19697 inst.instruction |= sizebits << 16;
19699 neon_dp_fixup (&inst);
19703 enum neon_shape rs = neon_select_shape (NS_DR, NS_QR, NS_NULL);
19704 struct neon_type_el et = neon_check_type (2, rs,
19705 N_8 | N_16 | N_32 | N_KEY, N_EQK);
19708 if (!check_simd_pred_availability (FALSE, NEON_CHECK_ARCH))
19712 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant, fpu_neon_ext_v1),
19715 if (ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext))
19717 if (inst.operands[1].reg == REG_SP)
19718 as_tsktsk (MVE_BAD_SP);
19719 else if (inst.operands[1].reg == REG_PC)
19720 as_tsktsk (MVE_BAD_PC);
19723 /* Duplicate ARM register to lanes of vector. */
19724 NEON_ENCODE (ARMREG, inst);
19727 case 8: inst.instruction |= 0x400000; break;
19728 case 16: inst.instruction |= 0x000020; break;
19729 case 32: inst.instruction |= 0x000000; break;
19732 inst.instruction |= LOW4 (inst.operands[1].reg) << 12;
19733 inst.instruction |= LOW4 (inst.operands[0].reg) << 16;
19734 inst.instruction |= HI1 (inst.operands[0].reg) << 7;
19735 inst.instruction |= neon_quad (rs) << 21;
19736 /* The encoding for this instruction is identical for the ARM and Thumb
19737 variants, except for the condition field. */
19738 do_vfp_cond_or_thumb ();
19743 do_mve_mov (int toQ)
19745 if (!ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext))
19747 if (inst.cond > COND_ALWAYS)
19748 inst.pred_insn_type = MVE_UNPREDICABLE_INSN;
19750 unsigned Rt = 0, Rt2 = 1, Q0 = 2, Q1 = 3;
19759 constraint (inst.operands[Q0].reg != inst.operands[Q1].reg + 2,
19760 _("Index one must be [2,3] and index two must be two less than"
19762 constraint (inst.operands[Rt].reg == inst.operands[Rt2].reg,
19763 _("General purpose registers may not be the same"));
19764 constraint (inst.operands[Rt].reg == REG_SP
19765 || inst.operands[Rt2].reg == REG_SP,
19767 constraint (inst.operands[Rt].reg == REG_PC
19768 || inst.operands[Rt2].reg == REG_PC,
19771 inst.instruction = 0xec000f00;
19772 inst.instruction |= HI1 (inst.operands[Q1].reg / 32) << 23;
19773 inst.instruction |= !!toQ << 20;
19774 inst.instruction |= inst.operands[Rt2].reg << 16;
19775 inst.instruction |= LOW4 (inst.operands[Q1].reg / 32) << 13;
19776 inst.instruction |= (inst.operands[Q1].reg % 4) << 4;
19777 inst.instruction |= inst.operands[Rt].reg;
19783 if (!ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext))
19786 if (inst.cond > COND_ALWAYS)
19787 inst.pred_insn_type = INSIDE_VPT_INSN;
19789 inst.pred_insn_type = MVE_OUTSIDE_PRED_INSN;
19791 struct neon_type_el et = neon_check_type (2, NS_QQ, N_EQK, N_I16 | N_I32
19794 inst.instruction |= HI1 (inst.operands[0].reg) << 22;
19795 inst.instruction |= (neon_logbits (et.size) - 1) << 18;
19796 inst.instruction |= LOW4 (inst.operands[0].reg) << 12;
19797 inst.instruction |= HI1 (inst.operands[1].reg) << 5;
19798 inst.instruction |= LOW4 (inst.operands[1].reg);
19803 /* VMOV has particularly many variations. It can be one of:
19804 0. VMOV<c><q> <Qd>, <Qm>
19805 1. VMOV<c><q> <Dd>, <Dm>
19806 (Register operations, which are VORR with Rm = Rn.)
19807 2. VMOV<c><q>.<dt> <Qd>, #<imm>
19808 3. VMOV<c><q>.<dt> <Dd>, #<imm>
19810 4. VMOV<c><q>.<size> <Dn[x]>, <Rd>
19811 (ARM register to scalar.)
19812 5. VMOV<c><q> <Dm>, <Rd>, <Rn>
19813 (Two ARM registers to vector.)
19814 6. VMOV<c><q>.<dt> <Rd>, <Dn[x]>
19815 (Scalar to ARM register.)
19816 7. VMOV<c><q> <Rd>, <Rn>, <Dm>
19817 (Vector to two ARM registers.)
19818 8. VMOV.F32 <Sd>, <Sm>
19819 9. VMOV.F64 <Dd>, <Dm>
19820 (VFP register moves.)
19821 10. VMOV.F32 <Sd>, #imm
19822 11. VMOV.F64 <Dd>, #imm
19823 (VFP float immediate load.)
19824 12. VMOV <Rd>, <Sm>
19825 (VFP single to ARM reg.)
19826 13. VMOV <Sd>, <Rm>
19827 (ARM reg to VFP single.)
19828 14. VMOV <Rd>, <Re>, <Sn>, <Sm>
19829 (Two ARM regs to two VFP singles.)
19830 15. VMOV <Sd>, <Se>, <Rn>, <Rm>
19831 (Two VFP singles to two ARM regs.)
19832 16. VMOV<c> <Rt>, <Rt2>, <Qd[idx]>, <Qd[idx2]>
19833 17. VMOV<c> <Qd[idx]>, <Qd[idx2]>, <Rt>, <Rt2>
19834 18. VMOV<c>.<dt> <Rt>, <Qn[idx]>
19835 19. VMOV<c>.<dt> <Qd[idx]>, <Rt>
19837 These cases can be disambiguated using neon_select_shape, except cases 1/9
19838 and 3/11 which depend on the operand type too.
19840 All the encoded bits are hardcoded by this function.
19842 Cases 4, 6 may be used with VFPv1 and above (only 32-bit transfers!).
19843 Cases 5, 7 may be used with VFPv2 and above.
19845 FIXME: Some of the checking may be a bit sloppy (in a couple of cases you
19846 can specify a type where it doesn't make sense to, and is ignored). */
19851 enum neon_shape rs = neon_select_shape (NS_RRSS, NS_SSRR, NS_RRFF, NS_FFRR,
19852 NS_DRR, NS_RRD, NS_QQ, NS_DD, NS_QI,
19853 NS_DI, NS_SR, NS_RS, NS_FF, NS_FI,
19854 NS_RF, NS_FR, NS_HR, NS_RH, NS_HI,
19856 struct neon_type_el et;
19857 const char *ldconst = 0;
19861 case NS_DD: /* case 1/9. */
19862 et = neon_check_type (2, rs, N_EQK, N_F64 | N_KEY);
19863 /* It is not an error here if no type is given. */
19865 if (et.type == NT_float && et.size == 64)
19867 do_vfp_nsyn_opcode ("fcpyd");
19870 /* fall through. */
19872 case NS_QQ: /* case 0/1. */
19874 if (!check_simd_pred_availability (FALSE,
19875 NEON_CHECK_CC | NEON_CHECK_ARCH))
19877 /* The architecture manual I have doesn't explicitly state which
19878 value the U bit should have for register->register moves, but
19879 the equivalent VORR instruction has U = 0, so do that. */
19880 inst.instruction = 0x0200110;
19881 inst.instruction |= LOW4 (inst.operands[0].reg) << 12;
19882 inst.instruction |= HI1 (inst.operands[0].reg) << 22;
19883 inst.instruction |= LOW4 (inst.operands[1].reg);
19884 inst.instruction |= HI1 (inst.operands[1].reg) << 5;
19885 inst.instruction |= LOW4 (inst.operands[1].reg) << 16;
19886 inst.instruction |= HI1 (inst.operands[1].reg) << 7;
19887 inst.instruction |= neon_quad (rs) << 6;
19889 neon_dp_fixup (&inst);
19893 case NS_DI: /* case 3/11. */
19894 et = neon_check_type (2, rs, N_EQK, N_F64 | N_KEY);
19896 if (et.type == NT_float && et.size == 64)
19898 /* case 11 (fconstd). */
19899 ldconst = "fconstd";
19900 goto encode_fconstd;
19902 /* fall through. */
19904 case NS_QI: /* case 2/3. */
19905 if (!check_simd_pred_availability (FALSE,
19906 NEON_CHECK_CC | NEON_CHECK_ARCH))
19908 inst.instruction = 0x0800010;
19909 neon_move_immediate ();
19910 neon_dp_fixup (&inst);
19913 case NS_SR: /* case 4. */
19915 unsigned bcdebits = 0;
19917 unsigned dn = NEON_SCALAR_REG (inst.operands[0].reg);
19918 unsigned x = NEON_SCALAR_INDEX (inst.operands[0].reg);
19920 /* .<size> is optional here, defaulting to .32. */
19921 if (inst.vectype.elems == 0
19922 && inst.operands[0].vectype.type == NT_invtype
19923 && inst.operands[1].vectype.type == NT_invtype)
19925 inst.vectype.el[0].type = NT_untyped;
19926 inst.vectype.el[0].size = 32;
19927 inst.vectype.elems = 1;
19930 et = neon_check_type (2, NS_NULL, N_8 | N_16 | N_32 | N_KEY, N_EQK);
19931 logsize = neon_logbits (et.size);
19935 if (!ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext)
19936 && vfp_or_neon_is_neon (NEON_CHECK_ARCH) == FAIL)
19941 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant, fpu_vfp_ext_v1)
19942 && !ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext),
19946 if (ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext))
19948 if (inst.operands[1].reg == REG_SP)
19949 as_tsktsk (MVE_BAD_SP);
19950 else if (inst.operands[1].reg == REG_PC)
19951 as_tsktsk (MVE_BAD_PC);
19953 unsigned size = inst.operands[0].isscalar == 1 ? 64 : 128;
19955 constraint (et.type == NT_invtype, _("bad type for scalar"));
19956 constraint (x >= size / et.size, _("scalar index out of range"));
19961 case 8: bcdebits = 0x8; break;
19962 case 16: bcdebits = 0x1; break;
19963 case 32: bcdebits = 0x0; break;
19967 bcdebits |= (x & ((1 << (3-logsize)) - 1)) << logsize;
19969 inst.instruction = 0xe000b10;
19970 do_vfp_cond_or_thumb ();
19971 inst.instruction |= LOW4 (dn) << 16;
19972 inst.instruction |= HI1 (dn) << 7;
19973 inst.instruction |= inst.operands[1].reg << 12;
19974 inst.instruction |= (bcdebits & 3) << 5;
19975 inst.instruction |= ((bcdebits >> 2) & 3) << 21;
19976 inst.instruction |= (x >> (3-logsize)) << 16;
19980 case NS_DRR: /* case 5 (fmdrr). */
19981 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant, fpu_vfp_ext_v2)
19982 && !ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext),
19985 inst.instruction = 0xc400b10;
19986 do_vfp_cond_or_thumb ();
19987 inst.instruction |= LOW4 (inst.operands[0].reg);
19988 inst.instruction |= HI1 (inst.operands[0].reg) << 5;
19989 inst.instruction |= inst.operands[1].reg << 12;
19990 inst.instruction |= inst.operands[2].reg << 16;
19993 case NS_RS: /* case 6. */
19996 unsigned dn = NEON_SCALAR_REG (inst.operands[1].reg);
19997 unsigned x = NEON_SCALAR_INDEX (inst.operands[1].reg);
19998 unsigned abcdebits = 0;
20000 /* .<dt> is optional here, defaulting to .32. */
20001 if (inst.vectype.elems == 0
20002 && inst.operands[0].vectype.type == NT_invtype
20003 && inst.operands[1].vectype.type == NT_invtype)
20005 inst.vectype.el[0].type = NT_untyped;
20006 inst.vectype.el[0].size = 32;
20007 inst.vectype.elems = 1;
20010 et = neon_check_type (2, NS_NULL,
20011 N_EQK, N_S8 | N_S16 | N_U8 | N_U16 | N_32 | N_KEY);
20012 logsize = neon_logbits (et.size);
20016 if (!ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext)
20017 && vfp_or_neon_is_neon (NEON_CHECK_CC
20018 | NEON_CHECK_ARCH) == FAIL)
20023 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant, fpu_vfp_ext_v1)
20024 && !ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext),
20028 if (ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext))
20030 if (inst.operands[0].reg == REG_SP)
20031 as_tsktsk (MVE_BAD_SP);
20032 else if (inst.operands[0].reg == REG_PC)
20033 as_tsktsk (MVE_BAD_PC);
20036 unsigned size = inst.operands[1].isscalar == 1 ? 64 : 128;
20038 constraint (et.type == NT_invtype, _("bad type for scalar"));
20039 constraint (x >= size / et.size, _("scalar index out of range"));
20043 case 8: abcdebits = (et.type == NT_signed) ? 0x08 : 0x18; break;
20044 case 16: abcdebits = (et.type == NT_signed) ? 0x01 : 0x11; break;
20045 case 32: abcdebits = 0x00; break;
20049 abcdebits |= (x & ((1 << (3-logsize)) - 1)) << logsize;
20050 inst.instruction = 0xe100b10;
20051 do_vfp_cond_or_thumb ();
20052 inst.instruction |= LOW4 (dn) << 16;
20053 inst.instruction |= HI1 (dn) << 7;
20054 inst.instruction |= inst.operands[0].reg << 12;
20055 inst.instruction |= (abcdebits & 3) << 5;
20056 inst.instruction |= (abcdebits >> 2) << 21;
20057 inst.instruction |= (x >> (3-logsize)) << 16;
20061 case NS_RRD: /* case 7 (fmrrd). */
20062 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant, fpu_vfp_ext_v2)
20063 && !ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext),
20066 inst.instruction = 0xc500b10;
20067 do_vfp_cond_or_thumb ();
20068 inst.instruction |= inst.operands[0].reg << 12;
20069 inst.instruction |= inst.operands[1].reg << 16;
20070 inst.instruction |= LOW4 (inst.operands[2].reg);
20071 inst.instruction |= HI1 (inst.operands[2].reg) << 5;
20074 case NS_FF: /* case 8 (fcpys). */
20075 do_vfp_nsyn_opcode ("fcpys");
20079 case NS_FI: /* case 10 (fconsts). */
20080 ldconst = "fconsts";
20082 if (!inst.operands[1].immisfloat)
20085 /* Immediate has to fit in 8 bits so float is enough. */
20086 float imm = (float) inst.operands[1].imm;
20087 memcpy (&new_imm, &imm, sizeof (float));
20088 /* But the assembly may have been written to provide an integer
20089 bit pattern that equates to a float, so check that the
20090 conversion has worked. */
20091 if (is_quarter_float (new_imm))
20093 if (is_quarter_float (inst.operands[1].imm))
20094 as_warn (_("immediate constant is valid both as a bit-pattern and a floating point value (using the fp value)"));
20096 inst.operands[1].imm = new_imm;
20097 inst.operands[1].immisfloat = 1;
20101 if (is_quarter_float (inst.operands[1].imm))
20103 inst.operands[1].imm = neon_qfloat_bits (inst.operands[1].imm);
20104 do_vfp_nsyn_opcode (ldconst);
20106 /* ARMv8.2 fp16 vmov.f16 instruction. */
20108 do_scalar_fp16_v82_encode ();
20111 first_error (_("immediate out of range"));
20115 case NS_RF: /* case 12 (fmrs). */
20116 do_vfp_nsyn_opcode ("fmrs");
20117 /* ARMv8.2 fp16 vmov.f16 instruction. */
20119 do_scalar_fp16_v82_encode ();
20123 case NS_FR: /* case 13 (fmsr). */
20124 do_vfp_nsyn_opcode ("fmsr");
20125 /* ARMv8.2 fp16 vmov.f16 instruction. */
20127 do_scalar_fp16_v82_encode ();
20137 /* The encoders for the fmrrs and fmsrr instructions expect three operands
20138 (one of which is a list), but we have parsed four. Do some fiddling to
20139 make the operands what do_vfp_reg2_from_sp2 and do_vfp_sp2_from_reg2
20141 case NS_RRFF: /* case 14 (fmrrs). */
20142 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant, fpu_vfp_ext_v2)
20143 && !ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext),
20145 constraint (inst.operands[3].reg != inst.operands[2].reg + 1,
20146 _("VFP registers must be adjacent"));
20147 inst.operands[2].imm = 2;
20148 memset (&inst.operands[3], '\0', sizeof (inst.operands[3]));
20149 do_vfp_nsyn_opcode ("fmrrs");
20152 case NS_FFRR: /* case 15 (fmsrr). */
20153 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant, fpu_vfp_ext_v2)
20154 && !ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext),
20156 constraint (inst.operands[1].reg != inst.operands[0].reg + 1,
20157 _("VFP registers must be adjacent"));
20158 inst.operands[1] = inst.operands[2];
20159 inst.operands[2] = inst.operands[3];
20160 inst.operands[0].imm = 2;
20161 memset (&inst.operands[3], '\0', sizeof (inst.operands[3]));
20162 do_vfp_nsyn_opcode ("fmsrr");
20166 /* neon_select_shape has determined that the instruction
20167 shape is wrong and has already set the error message. */
20178 if (!(inst.operands[0].present && inst.operands[0].isquad
20179 && inst.operands[1].present && inst.operands[1].isquad
20180 && !inst.operands[2].present))
20182 inst.instruction = 0;
20185 set_pred_insn_type (INSIDE_IT_INSN);
20190 if (!ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext))
20193 if (inst.cond != COND_ALWAYS)
20194 inst.pred_insn_type = INSIDE_VPT_INSN;
20196 struct neon_type_el et = neon_check_type (2, NS_QQ, N_EQK, N_S8 | N_U8
20197 | N_S16 | N_U16 | N_KEY);
20199 inst.instruction |= (et.type == NT_unsigned) << 28;
20200 inst.instruction |= HI1 (inst.operands[0].reg) << 22;
20201 inst.instruction |= (neon_logbits (et.size) + 1) << 19;
20202 inst.instruction |= LOW4 (inst.operands[0].reg) << 12;
20203 inst.instruction |= HI1 (inst.operands[1].reg) << 5;
20204 inst.instruction |= LOW4 (inst.operands[1].reg);
20209 do_neon_rshift_round_imm (void)
20211 if (!check_simd_pred_availability (FALSE, NEON_CHECK_ARCH | NEON_CHECK_CC))
20214 enum neon_shape rs;
20215 struct neon_type_el et;
20217 if (ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext))
20219 rs = neon_select_shape (NS_QQI, NS_NULL);
20220 et = neon_check_type (2, rs, N_EQK, N_SU_MVE | N_KEY);
20224 rs = neon_select_shape (NS_DDI, NS_QQI, NS_NULL);
20225 et = neon_check_type (2, rs, N_EQK, N_SU_ALL | N_KEY);
20227 int imm = inst.operands[2].imm;
20229 /* imm == 0 case is encoded as VMOV for V{R}SHR. */
20232 inst.operands[2].present = 0;
20237 constraint (imm < 1 || (unsigned)imm > et.size,
20238 _("immediate out of range for shift"));
20239 neon_imm_shift (TRUE, et.type == NT_unsigned, neon_quad (rs), et,
20244 do_neon_movhf (void)
20246 enum neon_shape rs = neon_select_shape (NS_HH, NS_NULL);
20247 constraint (rs != NS_HH, _("invalid suffix"));
20249 if (inst.cond != COND_ALWAYS)
20253 as_warn (_("ARMv8.2 scalar fp16 instruction cannot be conditional,"
20254 " the behaviour is UNPREDICTABLE"));
20258 inst.error = BAD_COND;
20263 do_vfp_sp_monadic ();
20266 inst.instruction |= 0xf0000000;
20270 do_neon_movl (void)
20272 struct neon_type_el et = neon_check_type (2, NS_QD,
20273 N_EQK | N_DBL, N_SU_32 | N_KEY);
20274 unsigned sizebits = et.size >> 3;
20275 inst.instruction |= sizebits << 19;
20276 neon_two_same (0, et.type == NT_unsigned, -1);
20282 enum neon_shape rs = neon_select_shape (NS_DD, NS_QQ, NS_NULL);
20283 struct neon_type_el et = neon_check_type (2, rs,
20284 N_EQK, N_8 | N_16 | N_32 | N_KEY);
20285 NEON_ENCODE (INTEGER, inst);
20286 neon_two_same (neon_quad (rs), 1, et.size);
20290 do_neon_zip_uzp (void)
20292 enum neon_shape rs = neon_select_shape (NS_DD, NS_QQ, NS_NULL);
20293 struct neon_type_el et = neon_check_type (2, rs,
20294 N_EQK, N_8 | N_16 | N_32 | N_KEY);
20295 if (rs == NS_DD && et.size == 32)
20297 /* Special case: encode as VTRN.32 <Dd>, <Dm>. */
20298 inst.instruction = N_MNEM_vtrn;
20302 neon_two_same (neon_quad (rs), 1, et.size);
20306 do_neon_sat_abs_neg (void)
20308 if (!check_simd_pred_availability (FALSE, NEON_CHECK_CC | NEON_CHECK_ARCH))
20311 enum neon_shape rs;
20312 if (ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext))
20313 rs = neon_select_shape (NS_QQ, NS_NULL);
20315 rs = neon_select_shape (NS_DD, NS_QQ, NS_NULL);
20316 struct neon_type_el et = neon_check_type (2, rs,
20317 N_EQK, N_S8 | N_S16 | N_S32 | N_KEY);
20318 neon_two_same (neon_quad (rs), 1, et.size);
20322 do_neon_pair_long (void)
20324 enum neon_shape rs = neon_select_shape (NS_DD, NS_QQ, NS_NULL);
20325 struct neon_type_el et = neon_check_type (2, rs, N_EQK, N_SU_32 | N_KEY);
20326 /* Unsigned is encoded in OP field (bit 7) for these instruction. */
20327 inst.instruction |= (et.type == NT_unsigned) << 7;
20328 neon_two_same (neon_quad (rs), 1, et.size);
20332 do_neon_recip_est (void)
20334 enum neon_shape rs = neon_select_shape (NS_DD, NS_QQ, NS_NULL);
20335 struct neon_type_el et = neon_check_type (2, rs,
20336 N_EQK | N_FLT, N_F_16_32 | N_U32 | N_KEY);
20337 inst.instruction |= (et.type == NT_float) << 8;
20338 neon_two_same (neon_quad (rs), 1, et.size);
20344 if (!check_simd_pred_availability (FALSE, NEON_CHECK_ARCH | NEON_CHECK_CC))
20347 enum neon_shape rs;
20348 if (ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext))
20349 rs = neon_select_shape (NS_QQ, NS_NULL);
20351 rs = neon_select_shape (NS_DD, NS_QQ, NS_NULL);
20353 struct neon_type_el et = neon_check_type (2, rs,
20354 N_EQK, N_S8 | N_S16 | N_S32 | N_KEY);
20355 neon_two_same (neon_quad (rs), 1, et.size);
20361 if (!check_simd_pred_availability (FALSE, NEON_CHECK_ARCH | NEON_CHECK_CC))
20364 enum neon_shape rs;
20365 if (ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext))
20366 rs = neon_select_shape (NS_QQ, NS_NULL);
20368 rs = neon_select_shape (NS_DD, NS_QQ, NS_NULL);
20370 struct neon_type_el et = neon_check_type (2, rs,
20371 N_EQK, N_I8 | N_I16 | N_I32 | N_KEY);
20372 neon_two_same (neon_quad (rs), 1, et.size);
20378 enum neon_shape rs = neon_select_shape (NS_DD, NS_QQ, NS_NULL);
20379 struct neon_type_el et = neon_check_type (2, rs,
20380 N_EQK | N_INT, N_8 | N_KEY);
20381 neon_two_same (neon_quad (rs), 1, et.size);
20387 enum neon_shape rs = neon_select_shape (NS_DD, NS_QQ, NS_NULL);
20388 neon_two_same (neon_quad (rs), 1, -1);
20392 do_neon_tbl_tbx (void)
20394 unsigned listlenbits;
20395 neon_check_type (3, NS_DLD, N_EQK, N_EQK, N_8 | N_KEY);
20397 if (inst.operands[1].imm < 1 || inst.operands[1].imm > 4)
20399 first_error (_("bad list length for table lookup"));
20403 listlenbits = inst.operands[1].imm - 1;
20404 inst.instruction |= LOW4 (inst.operands[0].reg) << 12;
20405 inst.instruction |= HI1 (inst.operands[0].reg) << 22;
20406 inst.instruction |= LOW4 (inst.operands[1].reg) << 16;
20407 inst.instruction |= HI1 (inst.operands[1].reg) << 7;
20408 inst.instruction |= LOW4 (inst.operands[2].reg);
20409 inst.instruction |= HI1 (inst.operands[2].reg) << 5;
20410 inst.instruction |= listlenbits << 8;
20412 neon_dp_fixup (&inst);
20416 do_neon_ldm_stm (void)
20418 /* P, U and L bits are part of bitmask. */
20419 int is_dbmode = (inst.instruction & (1 << 24)) != 0;
20420 unsigned offsetbits = inst.operands[1].imm * 2;
20422 if (inst.operands[1].issingle)
20424 do_vfp_nsyn_ldm_stm (is_dbmode);
20428 constraint (is_dbmode && !inst.operands[0].writeback,
20429 _("writeback (!) must be used for VLDMDB and VSTMDB"));
20431 constraint (inst.operands[1].imm < 1 || inst.operands[1].imm > 16,
20432 _("register list must contain at least 1 and at most 16 "
20435 inst.instruction |= inst.operands[0].reg << 16;
20436 inst.instruction |= inst.operands[0].writeback << 21;
20437 inst.instruction |= LOW4 (inst.operands[1].reg) << 12;
20438 inst.instruction |= HI1 (inst.operands[1].reg) << 22;
20440 inst.instruction |= offsetbits;
20442 do_vfp_cond_or_thumb ();
20446 do_neon_ldr_str (void)
20448 int is_ldr = (inst.instruction & (1 << 20)) != 0;
20450 /* Use of PC in vstr in ARM mode is deprecated in ARMv7.
20451 And is UNPREDICTABLE in thumb mode. */
20453 && inst.operands[1].reg == REG_PC
20454 && (ARM_CPU_HAS_FEATURE (selected_cpu, arm_ext_v7) || thumb_mode))
20457 inst.error = _("Use of PC here is UNPREDICTABLE");
20458 else if (warn_on_deprecated)
20459 as_tsktsk (_("Use of PC here is deprecated"));
20462 if (inst.operands[0].issingle)
20465 do_vfp_nsyn_opcode ("flds");
20467 do_vfp_nsyn_opcode ("fsts");
20469 /* ARMv8.2 vldr.16/vstr.16 instruction. */
20470 if (inst.vectype.el[0].size == 16)
20471 do_scalar_fp16_v82_encode ();
20476 do_vfp_nsyn_opcode ("fldd");
20478 do_vfp_nsyn_opcode ("fstd");
20483 do_t_vldr_vstr_sysreg (void)
20485 int fp_vldr_bitno = 20, sysreg_vldr_bitno = 20;
20486 bfd_boolean is_vldr = ((inst.instruction & (1 << fp_vldr_bitno)) != 0);
20488 /* Use of PC is UNPREDICTABLE. */
20489 if (inst.operands[1].reg == REG_PC)
20490 inst.error = _("Use of PC here is UNPREDICTABLE");
20492 if (inst.operands[1].immisreg)
20493 inst.error = _("instruction does not accept register index");
20495 if (!inst.operands[1].isreg)
20496 inst.error = _("instruction does not accept PC-relative addressing");
20498 if (abs (inst.operands[1].imm) >= (1 << 7))
20499 inst.error = _("immediate value out of range");
20501 inst.instruction = 0xec000f80;
20503 inst.instruction |= 1 << sysreg_vldr_bitno;
20504 encode_arm_cp_address (1, TRUE, FALSE, BFD_RELOC_ARM_T32_VLDR_VSTR_OFF_IMM);
20505 inst.instruction |= (inst.operands[0].imm & 0x7) << 13;
20506 inst.instruction |= (inst.operands[0].imm & 0x8) << 19;
20510 do_vldr_vstr (void)
20512 bfd_boolean sysreg_op = !inst.operands[0].isreg;
20514 /* VLDR/VSTR (System Register). */
20517 if (!mark_feature_used (&arm_ext_v8_1m_main))
20518 as_bad (_("Instruction not permitted on this architecture"));
20520 do_t_vldr_vstr_sysreg ();
20525 if (!mark_feature_used (&fpu_vfp_ext_v1xd))
20526 as_bad (_("Instruction not permitted on this architecture"));
20527 do_neon_ldr_str ();
20531 /* "interleave" version also handles non-interleaving register VLD1/VST1
20535 do_neon_ld_st_interleave (void)
20537 struct neon_type_el et = neon_check_type (1, NS_NULL,
20538 N_8 | N_16 | N_32 | N_64);
20539 unsigned alignbits = 0;
20541 /* The bits in this table go:
20542 0: register stride of one (0) or two (1)
20543 1,2: register list length, minus one (1, 2, 3, 4).
20544 3,4: <n> in instruction type, minus one (VLD<n> / VST<n>).
20545 We use -1 for invalid entries. */
20546 const int typetable[] =
20548 0x7, -1, 0xa, -1, 0x6, -1, 0x2, -1, /* VLD1 / VST1. */
20549 -1, -1, 0x8, 0x9, -1, -1, 0x3, -1, /* VLD2 / VST2. */
20550 -1, -1, -1, -1, 0x4, 0x5, -1, -1, /* VLD3 / VST3. */
20551 -1, -1, -1, -1, -1, -1, 0x0, 0x1 /* VLD4 / VST4. */
20555 if (et.type == NT_invtype)
20558 if (inst.operands[1].immisalign)
20559 switch (inst.operands[1].imm >> 8)
20561 case 64: alignbits = 1; break;
20563 if (NEON_REGLIST_LENGTH (inst.operands[0].imm) != 2
20564 && NEON_REGLIST_LENGTH (inst.operands[0].imm) != 4)
20565 goto bad_alignment;
20569 if (NEON_REGLIST_LENGTH (inst.operands[0].imm) != 4)
20570 goto bad_alignment;
20575 first_error (_("bad alignment"));
20579 inst.instruction |= alignbits << 4;
20580 inst.instruction |= neon_logbits (et.size) << 6;
20582 /* Bits [4:6] of the immediate in a list specifier encode register stride
20583 (minus 1) in bit 4, and list length in bits [5:6]. We put the <n> of
20584 VLD<n>/VST<n> in bits [9:8] of the initial bitmask. Suck it out here, look
20585 up the right value for "type" in a table based on this value and the given
20586 list style, then stick it back. */
20587 idx = ((inst.operands[0].imm >> 4) & 7)
20588 | (((inst.instruction >> 8) & 3) << 3);
20590 typebits = typetable[idx];
20592 constraint (typebits == -1, _("bad list type for instruction"));
20593 constraint (((inst.instruction >> 8) & 3) && et.size == 64,
20596 inst.instruction &= ~0xf00;
20597 inst.instruction |= typebits << 8;
20600 /* Check alignment is valid for do_neon_ld_st_lane and do_neon_ld_dup.
20601 *DO_ALIGN is set to 1 if the relevant alignment bit should be set, 0
20602 otherwise. The variable arguments are a list of pairs of legal (size, align)
20603 values, terminated with -1. */
20606 neon_alignment_bit (int size, int align, int *do_alignment, ...)
20609 int result = FAIL, thissize, thisalign;
20611 if (!inst.operands[1].immisalign)
20617 va_start (ap, do_alignment);
20621 thissize = va_arg (ap, int);
20622 if (thissize == -1)
20624 thisalign = va_arg (ap, int);
20626 if (size == thissize && align == thisalign)
20629 while (result != SUCCESS);
20633 if (result == SUCCESS)
20636 first_error (_("unsupported alignment for instruction"));
20642 do_neon_ld_st_lane (void)
20644 struct neon_type_el et = neon_check_type (1, NS_NULL, N_8 | N_16 | N_32);
20645 int align_good, do_alignment = 0;
20646 int logsize = neon_logbits (et.size);
20647 int align = inst.operands[1].imm >> 8;
20648 int n = (inst.instruction >> 8) & 3;
20649 int max_el = 64 / et.size;
20651 if (et.type == NT_invtype)
20654 constraint (NEON_REGLIST_LENGTH (inst.operands[0].imm) != n + 1,
20655 _("bad list length"));
20656 constraint (NEON_LANE (inst.operands[0].imm) >= max_el,
20657 _("scalar index out of range"));
20658 constraint (n != 0 && NEON_REG_STRIDE (inst.operands[0].imm) == 2
20660 _("stride of 2 unavailable when element size is 8"));
20664 case 0: /* VLD1 / VST1. */
20665 align_good = neon_alignment_bit (et.size, align, &do_alignment, 16, 16,
20667 if (align_good == FAIL)
20671 unsigned alignbits = 0;
20674 case 16: alignbits = 0x1; break;
20675 case 32: alignbits = 0x3; break;
20678 inst.instruction |= alignbits << 4;
20682 case 1: /* VLD2 / VST2. */
20683 align_good = neon_alignment_bit (et.size, align, &do_alignment, 8, 16,
20684 16, 32, 32, 64, -1);
20685 if (align_good == FAIL)
20688 inst.instruction |= 1 << 4;
20691 case 2: /* VLD3 / VST3. */
20692 constraint (inst.operands[1].immisalign,
20693 _("can't use alignment with this instruction"));
20696 case 3: /* VLD4 / VST4. */
20697 align_good = neon_alignment_bit (et.size, align, &do_alignment, 8, 32,
20698 16, 64, 32, 64, 32, 128, -1);
20699 if (align_good == FAIL)
20703 unsigned alignbits = 0;
20706 case 8: alignbits = 0x1; break;
20707 case 16: alignbits = 0x1; break;
20708 case 32: alignbits = (align == 64) ? 0x1 : 0x2; break;
20711 inst.instruction |= alignbits << 4;
20718 /* Reg stride of 2 is encoded in bit 5 when size==16, bit 6 when size==32. */
20719 if (n != 0 && NEON_REG_STRIDE (inst.operands[0].imm) == 2)
20720 inst.instruction |= 1 << (4 + logsize);
20722 inst.instruction |= NEON_LANE (inst.operands[0].imm) << (logsize + 5);
20723 inst.instruction |= logsize << 10;
20726 /* Encode single n-element structure to all lanes VLD<n> instructions. */
20729 do_neon_ld_dup (void)
20731 struct neon_type_el et = neon_check_type (1, NS_NULL, N_8 | N_16 | N_32);
20732 int align_good, do_alignment = 0;
20734 if (et.type == NT_invtype)
20737 switch ((inst.instruction >> 8) & 3)
20739 case 0: /* VLD1. */
20740 gas_assert (NEON_REG_STRIDE (inst.operands[0].imm) != 2);
20741 align_good = neon_alignment_bit (et.size, inst.operands[1].imm >> 8,
20742 &do_alignment, 16, 16, 32, 32, -1);
20743 if (align_good == FAIL)
20745 switch (NEON_REGLIST_LENGTH (inst.operands[0].imm))
20748 case 2: inst.instruction |= 1 << 5; break;
20749 default: first_error (_("bad list length")); return;
20751 inst.instruction |= neon_logbits (et.size) << 6;
20754 case 1: /* VLD2. */
20755 align_good = neon_alignment_bit (et.size, inst.operands[1].imm >> 8,
20756 &do_alignment, 8, 16, 16, 32, 32, 64,
20758 if (align_good == FAIL)
20760 constraint (NEON_REGLIST_LENGTH (inst.operands[0].imm) != 2,
20761 _("bad list length"));
20762 if (NEON_REG_STRIDE (inst.operands[0].imm) == 2)
20763 inst.instruction |= 1 << 5;
20764 inst.instruction |= neon_logbits (et.size) << 6;
20767 case 2: /* VLD3. */
20768 constraint (inst.operands[1].immisalign,
20769 _("can't use alignment with this instruction"));
20770 constraint (NEON_REGLIST_LENGTH (inst.operands[0].imm) != 3,
20771 _("bad list length"));
20772 if (NEON_REG_STRIDE (inst.operands[0].imm) == 2)
20773 inst.instruction |= 1 << 5;
20774 inst.instruction |= neon_logbits (et.size) << 6;
20777 case 3: /* VLD4. */
20779 int align = inst.operands[1].imm >> 8;
20780 align_good = neon_alignment_bit (et.size, align, &do_alignment, 8, 32,
20781 16, 64, 32, 64, 32, 128, -1);
20782 if (align_good == FAIL)
20784 constraint (NEON_REGLIST_LENGTH (inst.operands[0].imm) != 4,
20785 _("bad list length"));
20786 if (NEON_REG_STRIDE (inst.operands[0].imm) == 2)
20787 inst.instruction |= 1 << 5;
20788 if (et.size == 32 && align == 128)
20789 inst.instruction |= 0x3 << 6;
20791 inst.instruction |= neon_logbits (et.size) << 6;
20798 inst.instruction |= do_alignment << 4;
20801 /* Disambiguate VLD<n> and VST<n> instructions, and fill in common bits (those
20802 apart from bits [11:4]. */
20805 do_neon_ldx_stx (void)
20807 if (inst.operands[1].isreg)
20808 constraint (inst.operands[1].reg == REG_PC, BAD_PC);
20810 switch (NEON_LANE (inst.operands[0].imm))
20812 case NEON_INTERLEAVE_LANES:
20813 NEON_ENCODE (INTERLV, inst);
20814 do_neon_ld_st_interleave ();
20817 case NEON_ALL_LANES:
20818 NEON_ENCODE (DUP, inst);
20819 if (inst.instruction == N_INV)
20821 first_error ("only loads support such operands");
20828 NEON_ENCODE (LANE, inst);
20829 do_neon_ld_st_lane ();
20832 /* L bit comes from bit mask. */
20833 inst.instruction |= LOW4 (inst.operands[0].reg) << 12;
20834 inst.instruction |= HI1 (inst.operands[0].reg) << 22;
20835 inst.instruction |= inst.operands[1].reg << 16;
20837 if (inst.operands[1].postind)
20839 int postreg = inst.operands[1].imm & 0xf;
20840 constraint (!inst.operands[1].immisreg,
20841 _("post-index must be a register"));
20842 constraint (postreg == 0xd || postreg == 0xf,
20843 _("bad register for post-index"));
20844 inst.instruction |= postreg;
20848 constraint (inst.operands[1].immisreg, BAD_ADDR_MODE);
20849 constraint (inst.relocs[0].exp.X_op != O_constant
20850 || inst.relocs[0].exp.X_add_number != 0,
20853 if (inst.operands[1].writeback)
20855 inst.instruction |= 0xd;
20858 inst.instruction |= 0xf;
20862 inst.instruction |= 0xf9000000;
20864 inst.instruction |= 0xf4000000;
20869 do_vfp_nsyn_fpv8 (enum neon_shape rs)
20871 /* Targets like FPv5-SP-D16 don't support FP v8 instructions with
20872 D register operands. */
20873 if (neon_shape_class[rs] == SC_DOUBLE)
20874 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant, fpu_vfp_ext_armv8),
20877 NEON_ENCODE (FPV8, inst);
20879 if (rs == NS_FFF || rs == NS_HHH)
20881 do_vfp_sp_dyadic ();
20883 /* ARMv8.2 fp16 instruction. */
20885 do_scalar_fp16_v82_encode ();
20888 do_vfp_dp_rd_rn_rm ();
20891 inst.instruction |= 0x100;
20893 inst.instruction |= 0xf0000000;
20899 set_pred_insn_type (OUTSIDE_PRED_INSN);
20901 if (try_vfp_nsyn (3, do_vfp_nsyn_fpv8) != SUCCESS)
20902 first_error (_("invalid instruction shape"));
20908 if (!ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext))
20909 set_pred_insn_type (OUTSIDE_PRED_INSN);
20911 if (try_vfp_nsyn (3, do_vfp_nsyn_fpv8) == SUCCESS)
20914 if (!check_simd_pred_availability (TRUE, NEON_CHECK_CC | NEON_CHECK_ARCH8))
20917 neon_dyadic_misc (NT_untyped, N_F_16_32, 0);
20921 do_vrint_1 (enum neon_cvt_mode mode)
20923 enum neon_shape rs = neon_select_shape (NS_HH, NS_FF, NS_DD, NS_QQ, NS_NULL);
20924 struct neon_type_el et;
20929 /* Targets like FPv5-SP-D16 don't support FP v8 instructions with
20930 D register operands. */
20931 if (neon_shape_class[rs] == SC_DOUBLE)
20932 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant, fpu_vfp_ext_armv8),
20935 et = neon_check_type (2, rs, N_EQK | N_VFP, N_F_ALL | N_KEY
20937 if (et.type != NT_invtype)
20939 /* VFP encodings. */
20940 if (mode == neon_cvt_mode_a || mode == neon_cvt_mode_n
20941 || mode == neon_cvt_mode_p || mode == neon_cvt_mode_m)
20942 set_pred_insn_type (OUTSIDE_PRED_INSN);
20944 NEON_ENCODE (FPV8, inst);
20945 if (rs == NS_FF || rs == NS_HH)
20946 do_vfp_sp_monadic ();
20948 do_vfp_dp_rd_rm ();
20952 case neon_cvt_mode_r: inst.instruction |= 0x00000000; break;
20953 case neon_cvt_mode_z: inst.instruction |= 0x00000080; break;
20954 case neon_cvt_mode_x: inst.instruction |= 0x00010000; break;
20955 case neon_cvt_mode_a: inst.instruction |= 0xf0000000; break;
20956 case neon_cvt_mode_n: inst.instruction |= 0xf0010000; break;
20957 case neon_cvt_mode_p: inst.instruction |= 0xf0020000; break;
20958 case neon_cvt_mode_m: inst.instruction |= 0xf0030000; break;
20962 inst.instruction |= (rs == NS_DD) << 8;
20963 do_vfp_cond_or_thumb ();
20965 /* ARMv8.2 fp16 vrint instruction. */
20967 do_scalar_fp16_v82_encode ();
20971 /* Neon encodings (or something broken...). */
20973 et = neon_check_type (2, rs, N_EQK, N_F_16_32 | N_KEY);
20975 if (et.type == NT_invtype)
20978 if (!check_simd_pred_availability (TRUE,
20979 NEON_CHECK_CC | NEON_CHECK_ARCH8))
20982 NEON_ENCODE (FLOAT, inst);
20984 inst.instruction |= LOW4 (inst.operands[0].reg) << 12;
20985 inst.instruction |= HI1 (inst.operands[0].reg) << 22;
20986 inst.instruction |= LOW4 (inst.operands[1].reg);
20987 inst.instruction |= HI1 (inst.operands[1].reg) << 5;
20988 inst.instruction |= neon_quad (rs) << 6;
20989 /* Mask off the original size bits and reencode them. */
20990 inst.instruction = ((inst.instruction & 0xfff3ffff)
20991 | neon_logbits (et.size) << 18);
20995 case neon_cvt_mode_z: inst.instruction |= 3 << 7; break;
20996 case neon_cvt_mode_x: inst.instruction |= 1 << 7; break;
20997 case neon_cvt_mode_a: inst.instruction |= 2 << 7; break;
20998 case neon_cvt_mode_n: inst.instruction |= 0 << 7; break;
20999 case neon_cvt_mode_p: inst.instruction |= 7 << 7; break;
21000 case neon_cvt_mode_m: inst.instruction |= 5 << 7; break;
21001 case neon_cvt_mode_r: inst.error = _("invalid rounding mode"); break;
21006 inst.instruction |= 0xfc000000;
21008 inst.instruction |= 0xf0000000;
21015 do_vrint_1 (neon_cvt_mode_x);
21021 do_vrint_1 (neon_cvt_mode_z);
21027 do_vrint_1 (neon_cvt_mode_r);
21033 do_vrint_1 (neon_cvt_mode_a);
21039 do_vrint_1 (neon_cvt_mode_n);
21045 do_vrint_1 (neon_cvt_mode_p);
21051 do_vrint_1 (neon_cvt_mode_m);
21055 neon_scalar_for_vcmla (unsigned opnd, unsigned elsize)
21057 unsigned regno = NEON_SCALAR_REG (opnd);
21058 unsigned elno = NEON_SCALAR_INDEX (opnd);
21060 if (elsize == 16 && elno < 2 && regno < 16)
21061 return regno | (elno << 4);
21062 else if (elsize == 32 && elno == 0)
21065 first_error (_("scalar out of range"));
21072 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant, mve_fp_ext)
21073 && (!ARM_CPU_HAS_FEATURE (cpu_variant, fpu_neon_ext_armv8)
21074 || !mark_feature_used (&arm_ext_v8_3)), (BAD_FPU));
21075 constraint (inst.relocs[0].exp.X_op != O_constant,
21076 _("expression too complex"));
21077 unsigned rot = inst.relocs[0].exp.X_add_number;
21078 constraint (rot != 0 && rot != 90 && rot != 180 && rot != 270,
21079 _("immediate out of range"));
21082 if (!check_simd_pred_availability (TRUE,
21083 NEON_CHECK_ARCH8 | NEON_CHECK_CC))
21086 if (inst.operands[2].isscalar)
21088 if (ARM_CPU_HAS_FEATURE (cpu_variant, mve_fp_ext))
21089 first_error (_("invalid instruction shape"));
21090 enum neon_shape rs = neon_select_shape (NS_DDSI, NS_QQSI, NS_NULL);
21091 unsigned size = neon_check_type (3, rs, N_EQK, N_EQK,
21092 N_KEY | N_F16 | N_F32).size;
21093 unsigned m = neon_scalar_for_vcmla (inst.operands[2].reg, size);
21095 inst.instruction = 0xfe000800;
21096 inst.instruction |= LOW4 (inst.operands[0].reg) << 12;
21097 inst.instruction |= HI1 (inst.operands[0].reg) << 22;
21098 inst.instruction |= LOW4 (inst.operands[1].reg) << 16;
21099 inst.instruction |= HI1 (inst.operands[1].reg) << 7;
21100 inst.instruction |= LOW4 (m);
21101 inst.instruction |= HI1 (m) << 5;
21102 inst.instruction |= neon_quad (rs) << 6;
21103 inst.instruction |= rot << 20;
21104 inst.instruction |= (size == 32) << 23;
21108 enum neon_shape rs;
21109 if (ARM_CPU_HAS_FEATURE (cpu_variant, mve_fp_ext))
21110 rs = neon_select_shape (NS_QQQI, NS_NULL);
21112 rs = neon_select_shape (NS_DDDI, NS_QQQI, NS_NULL);
21114 unsigned size = neon_check_type (3, rs, N_EQK, N_EQK,
21115 N_KEY | N_F16 | N_F32).size;
21116 if (ARM_CPU_HAS_FEATURE (cpu_variant, mve_fp_ext) && size == 32
21117 && (inst.operands[0].reg == inst.operands[1].reg
21118 || inst.operands[0].reg == inst.operands[2].reg))
21119 as_tsktsk (BAD_MVE_SRCDEST);
21121 neon_three_same (neon_quad (rs), 0, -1);
21122 inst.instruction &= 0x00ffffff; /* Undo neon_dp_fixup. */
21123 inst.instruction |= 0xfc200800;
21124 inst.instruction |= rot << 23;
21125 inst.instruction |= (size == 32) << 20;
21132 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext)
21133 && (!ARM_CPU_HAS_FEATURE (cpu_variant, fpu_neon_ext_armv8)
21134 || !mark_feature_used (&arm_ext_v8_3)), (BAD_FPU));
21135 constraint (inst.relocs[0].exp.X_op != O_constant,
21136 _("expression too complex"));
21138 unsigned rot = inst.relocs[0].exp.X_add_number;
21139 constraint (rot != 90 && rot != 270, _("immediate out of range"));
21140 enum neon_shape rs;
21141 struct neon_type_el et;
21142 if (!ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext))
21144 rs = neon_select_shape (NS_DDDI, NS_QQQI, NS_NULL);
21145 et = neon_check_type (3, rs, N_EQK, N_EQK, N_KEY | N_F16 | N_F32);
21149 rs = neon_select_shape (NS_QQQI, NS_NULL);
21150 et = neon_check_type (3, rs, N_EQK, N_EQK, N_KEY | N_F16 | N_F32 | N_I8
21152 if (et.size == 32 && inst.operands[0].reg == inst.operands[2].reg)
21153 as_tsktsk (_("Warning: 32-bit element size and same first and third "
21154 "operand makes instruction UNPREDICTABLE"));
21157 if (et.type == NT_invtype)
21160 if (!check_simd_pred_availability (et.type == NT_float,
21161 NEON_CHECK_ARCH8 | NEON_CHECK_CC))
21164 if (et.type == NT_float)
21166 neon_three_same (neon_quad (rs), 0, -1);
21167 inst.instruction &= 0x00ffffff; /* Undo neon_dp_fixup. */
21168 inst.instruction |= 0xfc800800;
21169 inst.instruction |= (rot == 270) << 24;
21170 inst.instruction |= (et.size == 32) << 20;
21174 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext), BAD_FPU);
21175 inst.instruction = 0xfe000f00;
21176 inst.instruction |= HI1 (inst.operands[0].reg) << 22;
21177 inst.instruction |= neon_logbits (et.size) << 20;
21178 inst.instruction |= LOW4 (inst.operands[1].reg) << 16;
21179 inst.instruction |= LOW4 (inst.operands[0].reg) << 12;
21180 inst.instruction |= (rot == 270) << 12;
21181 inst.instruction |= HI1 (inst.operands[1].reg) << 7;
21182 inst.instruction |= HI1 (inst.operands[2].reg) << 5;
21183 inst.instruction |= LOW4 (inst.operands[2].reg);
21188 /* Dot Product instructions encoding support. */
21191 do_neon_dotproduct (int unsigned_p)
21193 enum neon_shape rs;
21194 unsigned scalar_oprd2 = 0;
21197 if (inst.cond != COND_ALWAYS)
21198 as_warn (_("Dot Product instructions cannot be conditional, the behaviour "
21199 "is UNPREDICTABLE"));
21201 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant, fpu_neon_ext_armv8),
21204 /* Dot Product instructions are in three-same D/Q register format or the third
21205 operand can be a scalar index register. */
21206 if (inst.operands[2].isscalar)
21208 scalar_oprd2 = neon_scalar_for_mul (inst.operands[2].reg, 32);
21209 high8 = 0xfe000000;
21210 rs = neon_select_shape (NS_DDS, NS_QQS, NS_NULL);
21214 high8 = 0xfc000000;
21215 rs = neon_select_shape (NS_DDD, NS_QQQ, NS_NULL);
21219 neon_check_type (3, rs, N_EQK, N_EQK, N_KEY | N_U8);
21221 neon_check_type (3, rs, N_EQK, N_EQK, N_KEY | N_S8);
21223 /* The "U" bit in traditional Three Same encoding is fixed to 0 for Dot
21224 Product instruction, so we pass 0 as the "ubit" parameter. And the
21225 "Size" field are fixed to 0x2, so we pass 32 as the "size" parameter. */
21226 neon_three_same (neon_quad (rs), 0, 32);
21228 /* Undo neon_dp_fixup. Dot Product instructions are using a slightly
21229 different NEON three-same encoding. */
21230 inst.instruction &= 0x00ffffff;
21231 inst.instruction |= high8;
21232 /* Encode 'U' bit which indicates signedness. */
21233 inst.instruction |= (unsigned_p ? 1 : 0) << 4;
21234 /* Re-encode operand2 if it's indexed scalar operand. What has been encoded
21235 from inst.operand[2].reg in neon_three_same is GAS's internal encoding, not
21236 the instruction encoding. */
21237 if (inst.operands[2].isscalar)
21239 inst.instruction &= 0xffffffd0;
21240 inst.instruction |= LOW4 (scalar_oprd2);
21241 inst.instruction |= HI1 (scalar_oprd2) << 5;
21245 /* Dot Product instructions for signed integer. */
21248 do_neon_dotproduct_s (void)
21250 return do_neon_dotproduct (0);
21253 /* Dot Product instructions for unsigned integer. */
21256 do_neon_dotproduct_u (void)
21258 return do_neon_dotproduct (1);
21261 /* Crypto v1 instructions. */
21263 do_crypto_2op_1 (unsigned elttype, int op)
21265 set_pred_insn_type (OUTSIDE_PRED_INSN);
21267 if (neon_check_type (2, NS_QQ, N_EQK | N_UNT, elttype | N_UNT | N_KEY).type
21273 NEON_ENCODE (INTEGER, inst);
21274 inst.instruction |= LOW4 (inst.operands[0].reg) << 12;
21275 inst.instruction |= HI1 (inst.operands[0].reg) << 22;
21276 inst.instruction |= LOW4 (inst.operands[1].reg);
21277 inst.instruction |= HI1 (inst.operands[1].reg) << 5;
21279 inst.instruction |= op << 6;
21282 inst.instruction |= 0xfc000000;
21284 inst.instruction |= 0xf0000000;
21288 do_crypto_3op_1 (int u, int op)
21290 set_pred_insn_type (OUTSIDE_PRED_INSN);
21292 if (neon_check_type (3, NS_QQQ, N_EQK | N_UNT, N_EQK | N_UNT,
21293 N_32 | N_UNT | N_KEY).type == NT_invtype)
21298 NEON_ENCODE (INTEGER, inst);
21299 neon_three_same (1, u, 8 << op);
21305 do_crypto_2op_1 (N_8, 0);
21311 do_crypto_2op_1 (N_8, 1);
21317 do_crypto_2op_1 (N_8, 2);
21323 do_crypto_2op_1 (N_8, 3);
21329 do_crypto_3op_1 (0, 0);
21335 do_crypto_3op_1 (0, 1);
21341 do_crypto_3op_1 (0, 2);
21347 do_crypto_3op_1 (0, 3);
21353 do_crypto_3op_1 (1, 0);
21359 do_crypto_3op_1 (1, 1);
21363 do_sha256su1 (void)
21365 do_crypto_3op_1 (1, 2);
21371 do_crypto_2op_1 (N_32, -1);
21377 do_crypto_2op_1 (N_32, 0);
21381 do_sha256su0 (void)
21383 do_crypto_2op_1 (N_32, 1);
21387 do_crc32_1 (unsigned int poly, unsigned int sz)
21389 unsigned int Rd = inst.operands[0].reg;
21390 unsigned int Rn = inst.operands[1].reg;
21391 unsigned int Rm = inst.operands[2].reg;
21393 set_pred_insn_type (OUTSIDE_PRED_INSN);
21394 inst.instruction |= LOW4 (Rd) << (thumb_mode ? 8 : 12);
21395 inst.instruction |= LOW4 (Rn) << 16;
21396 inst.instruction |= LOW4 (Rm);
21397 inst.instruction |= sz << (thumb_mode ? 4 : 21);
21398 inst.instruction |= poly << (thumb_mode ? 20 : 9);
21400 if (Rd == REG_PC || Rn == REG_PC || Rm == REG_PC)
21401 as_warn (UNPRED_REG ("r15"));
21443 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant, fpu_vfp_ext_armv8),
21445 neon_check_type (2, NS_FD, N_S32, N_F64);
21446 do_vfp_sp_dp_cvt ();
21447 do_vfp_cond_or_thumb ();
21451 /* Overall per-instruction processing. */
21453 /* We need to be able to fix up arbitrary expressions in some statements.
21454 This is so that we can handle symbols that are an arbitrary distance from
21455 the pc. The most common cases are of the form ((+/-sym -/+ . - 8) & mask),
21456 which returns part of an address in a form which will be valid for
21457 a data instruction. We do this by pushing the expression into a symbol
21458 in the expr_section, and creating a fix for that. */
21461 fix_new_arm (fragS * frag,
21475 /* Create an absolute valued symbol, so we have something to
21476 refer to in the object file. Unfortunately for us, gas's
21477 generic expression parsing will already have folded out
21478 any use of .set foo/.type foo %function that may have
21479 been used to set type information of the target location,
21480 that's being specified symbolically. We have to presume
21481 the user knows what they are doing. */
21485 sprintf (name, "*ABS*0x%lx", (unsigned long)exp->X_add_number);
21487 symbol = symbol_find_or_make (name);
21488 S_SET_SEGMENT (symbol, absolute_section);
21489 symbol_set_frag (symbol, &zero_address_frag);
21490 S_SET_VALUE (symbol, exp->X_add_number);
21491 exp->X_op = O_symbol;
21492 exp->X_add_symbol = symbol;
21493 exp->X_add_number = 0;
21499 new_fix = fix_new_exp (frag, where, size, exp, pc_rel,
21500 (enum bfd_reloc_code_real) reloc);
21504 new_fix = (fixS *) fix_new (frag, where, size, make_expr_symbol (exp), 0,
21505 pc_rel, (enum bfd_reloc_code_real) reloc);
21509 /* Mark whether the fix is to a THUMB instruction, or an ARM
21511 new_fix->tc_fix_data = thumb_mode;
21514 /* Create a frg for an instruction requiring relaxation. */
21516 output_relax_insn (void)
21522 /* The size of the instruction is unknown, so tie the debug info to the
21523 start of the instruction. */
21524 dwarf2_emit_insn (0);
21526 switch (inst.relocs[0].exp.X_op)
21529 sym = inst.relocs[0].exp.X_add_symbol;
21530 offset = inst.relocs[0].exp.X_add_number;
21534 offset = inst.relocs[0].exp.X_add_number;
21537 sym = make_expr_symbol (&inst.relocs[0].exp);
21541 to = frag_var (rs_machine_dependent, INSN_SIZE, THUMB_SIZE,
21542 inst.relax, sym, offset, NULL/*offset, opcode*/);
21543 md_number_to_chars (to, inst.instruction, THUMB_SIZE);
21546 /* Write a 32-bit thumb instruction to buf. */
21548 put_thumb32_insn (char * buf, unsigned long insn)
21550 md_number_to_chars (buf, insn >> 16, THUMB_SIZE);
21551 md_number_to_chars (buf + THUMB_SIZE, insn, THUMB_SIZE);
21555 output_inst (const char * str)
21561 as_bad ("%s -- `%s'", inst.error, str);
21566 output_relax_insn ();
21569 if (inst.size == 0)
21572 to = frag_more (inst.size);
21573 /* PR 9814: Record the thumb mode into the current frag so that we know
21574 what type of NOP padding to use, if necessary. We override any previous
21575 setting so that if the mode has changed then the NOPS that we use will
21576 match the encoding of the last instruction in the frag. */
21577 frag_now->tc_frag_data.thumb_mode = thumb_mode | MODE_RECORDED;
21579 if (thumb_mode && (inst.size > THUMB_SIZE))
21581 gas_assert (inst.size == (2 * THUMB_SIZE));
21582 put_thumb32_insn (to, inst.instruction);
21584 else if (inst.size > INSN_SIZE)
21586 gas_assert (inst.size == (2 * INSN_SIZE));
21587 md_number_to_chars (to, inst.instruction, INSN_SIZE);
21588 md_number_to_chars (to + INSN_SIZE, inst.instruction, INSN_SIZE);
21591 md_number_to_chars (to, inst.instruction, inst.size);
21594 for (r = 0; r < ARM_IT_MAX_RELOCS; r++)
21596 if (inst.relocs[r].type != BFD_RELOC_UNUSED)
21597 fix_new_arm (frag_now, to - frag_now->fr_literal,
21598 inst.size, & inst.relocs[r].exp, inst.relocs[r].pc_rel,
21599 inst.relocs[r].type);
21602 dwarf2_emit_insn (inst.size);
21606 output_it_inst (int cond, int mask, char * to)
21608 unsigned long instruction = 0xbf00;
21611 instruction |= mask;
21612 instruction |= cond << 4;
21616 to = frag_more (2);
21618 dwarf2_emit_insn (2);
21622 md_number_to_chars (to, instruction, 2);
21627 /* Tag values used in struct asm_opcode's tag field. */
21630 OT_unconditional, /* Instruction cannot be conditionalized.
21631 The ARM condition field is still 0xE. */
21632 OT_unconditionalF, /* Instruction cannot be conditionalized
21633 and carries 0xF in its ARM condition field. */
21634 OT_csuffix, /* Instruction takes a conditional suffix. */
21635 OT_csuffixF, /* Some forms of the instruction take a scalar
21636 conditional suffix, others place 0xF where the
21637 condition field would be, others take a vector
21638 conditional suffix. */
21639 OT_cinfix3, /* Instruction takes a conditional infix,
21640 beginning at character index 3. (In
21641 unified mode, it becomes a suffix.) */
21642 OT_cinfix3_deprecated, /* The same as OT_cinfix3. This is used for
21643 tsts, cmps, cmns, and teqs. */
21644 OT_cinfix3_legacy, /* Legacy instruction takes a conditional infix at
21645 character index 3, even in unified mode. Used for
21646 legacy instructions where suffix and infix forms
21647 may be ambiguous. */
21648 OT_csuf_or_in3, /* Instruction takes either a conditional
21649 suffix or an infix at character index 3. */
21650 OT_odd_infix_unc, /* This is the unconditional variant of an
21651 instruction that takes a conditional infix
21652 at an unusual position. In unified mode,
21653 this variant will accept a suffix. */
21654 OT_odd_infix_0 /* Values greater than or equal to OT_odd_infix_0
21655 are the conditional variants of instructions that
21656 take conditional infixes in unusual positions.
21657 The infix appears at character index
21658 (tag - OT_odd_infix_0). These are not accepted
21659 in unified mode. */
21662 /* Subroutine of md_assemble, responsible for looking up the primary
21663 opcode from the mnemonic the user wrote. STR points to the
21664 beginning of the mnemonic.
21666 This is not simply a hash table lookup, because of conditional
21667 variants. Most instructions have conditional variants, which are
21668 expressed with a _conditional affix_ to the mnemonic. If we were
21669 to encode each conditional variant as a literal string in the opcode
21670 table, it would have approximately 20,000 entries.
21672 Most mnemonics take this affix as a suffix, and in unified syntax,
21673 'most' is upgraded to 'all'. However, in the divided syntax, some
21674 instructions take the affix as an infix, notably the s-variants of
21675 the arithmetic instructions. Of those instructions, all but six
21676 have the infix appear after the third character of the mnemonic.
21678 Accordingly, the algorithm for looking up primary opcodes given
21681 1. Look up the identifier in the opcode table.
21682 If we find a match, go to step U.
21684 2. Look up the last two characters of the identifier in the
21685 conditions table. If we find a match, look up the first N-2
21686 characters of the identifier in the opcode table. If we
21687 find a match, go to step CE.
21689 3. Look up the fourth and fifth characters of the identifier in
21690 the conditions table. If we find a match, extract those
21691 characters from the identifier, and look up the remaining
21692 characters in the opcode table. If we find a match, go
21697 U. Examine the tag field of the opcode structure, in case this is
21698 one of the six instructions with its conditional infix in an
21699 unusual place. If it is, the tag tells us where to find the
21700 infix; look it up in the conditions table and set inst.cond
21701 accordingly. Otherwise, this is an unconditional instruction.
21702 Again set inst.cond accordingly. Return the opcode structure.
21704 CE. Examine the tag field to make sure this is an instruction that
21705 should receive a conditional suffix. If it is not, fail.
21706 Otherwise, set inst.cond from the suffix we already looked up,
21707 and return the opcode structure.
21709 CM. Examine the tag field to make sure this is an instruction that
21710 should receive a conditional infix after the third character.
21711 If it is not, fail. Otherwise, undo the edits to the current
21712 line of input and proceed as for case CE. */
21714 static const struct asm_opcode *
21715 opcode_lookup (char **str)
21719 const struct asm_opcode *opcode;
21720 const struct asm_cond *cond;
21723 /* Scan up to the end of the mnemonic, which must end in white space,
21724 '.' (in unified mode, or for Neon/VFP instructions), or end of string. */
21725 for (base = end = *str; *end != '\0'; end++)
21726 if (*end == ' ' || *end == '.')
21732 /* Handle a possible width suffix and/or Neon type suffix. */
21737 /* The .w and .n suffixes are only valid if the unified syntax is in
21739 if (unified_syntax && end[1] == 'w')
21741 else if (unified_syntax && end[1] == 'n')
21746 inst.vectype.elems = 0;
21748 *str = end + offset;
21750 if (end[offset] == '.')
21752 /* See if we have a Neon type suffix (possible in either unified or
21753 non-unified ARM syntax mode). */
21754 if (parse_neon_type (&inst.vectype, str) == FAIL)
21757 else if (end[offset] != '\0' && end[offset] != ' ')
21763 /* Look for unaffixed or special-case affixed mnemonic. */
21764 opcode = (const struct asm_opcode *) hash_find_n (arm_ops_hsh, base,
21769 if (opcode->tag < OT_odd_infix_0)
21771 inst.cond = COND_ALWAYS;
21775 if (warn_on_deprecated && unified_syntax)
21776 as_tsktsk (_("conditional infixes are deprecated in unified syntax"));
21777 affix = base + (opcode->tag - OT_odd_infix_0);
21778 cond = (const struct asm_cond *) hash_find_n (arm_cond_hsh, affix, 2);
21781 inst.cond = cond->value;
21784 if (ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext))
21786 /* Cannot have a conditional suffix on a mnemonic of less than a character.
21788 if (end - base < 2)
21791 cond = (const struct asm_cond *) hash_find_n (arm_vcond_hsh, affix, 1);
21792 opcode = (const struct asm_opcode *) hash_find_n (arm_ops_hsh, base,
21794 /* If this opcode can not be vector predicated then don't accept it with a
21795 vector predication code. */
21796 if (opcode && !opcode->mayBeVecPred)
21799 if (!opcode || !cond)
21801 /* Cannot have a conditional suffix on a mnemonic of less than two
21803 if (end - base < 3)
21806 /* Look for suffixed mnemonic. */
21808 cond = (const struct asm_cond *) hash_find_n (arm_cond_hsh, affix, 2);
21809 opcode = (const struct asm_opcode *) hash_find_n (arm_ops_hsh, base,
21813 if (opcode && cond)
21816 switch (opcode->tag)
21818 case OT_cinfix3_legacy:
21819 /* Ignore conditional suffixes matched on infix only mnemonics. */
21823 case OT_cinfix3_deprecated:
21824 case OT_odd_infix_unc:
21825 if (!unified_syntax)
21827 /* Fall through. */
21831 case OT_csuf_or_in3:
21832 inst.cond = cond->value;
21835 case OT_unconditional:
21836 case OT_unconditionalF:
21838 inst.cond = cond->value;
21841 /* Delayed diagnostic. */
21842 inst.error = BAD_COND;
21843 inst.cond = COND_ALWAYS;
21852 /* Cannot have a usual-position infix on a mnemonic of less than
21853 six characters (five would be a suffix). */
21854 if (end - base < 6)
21857 /* Look for infixed mnemonic in the usual position. */
21859 cond = (const struct asm_cond *) hash_find_n (arm_cond_hsh, affix, 2);
21863 memcpy (save, affix, 2);
21864 memmove (affix, affix + 2, (end - affix) - 2);
21865 opcode = (const struct asm_opcode *) hash_find_n (arm_ops_hsh, base,
21867 memmove (affix + 2, affix, (end - affix) - 2);
21868 memcpy (affix, save, 2);
21871 && (opcode->tag == OT_cinfix3
21872 || opcode->tag == OT_cinfix3_deprecated
21873 || opcode->tag == OT_csuf_or_in3
21874 || opcode->tag == OT_cinfix3_legacy))
21877 if (warn_on_deprecated && unified_syntax
21878 && (opcode->tag == OT_cinfix3
21879 || opcode->tag == OT_cinfix3_deprecated))
21880 as_tsktsk (_("conditional infixes are deprecated in unified syntax"));
21882 inst.cond = cond->value;
21889 /* This function generates an initial IT instruction, leaving its block
21890 virtually open for the new instructions. Eventually,
21891 the mask will be updated by now_pred_add_mask () each time
21892 a new instruction needs to be included in the IT block.
21893 Finally, the block is closed with close_automatic_it_block ().
21894 The block closure can be requested either from md_assemble (),
21895 a tencode (), or due to a label hook. */
21898 new_automatic_it_block (int cond)
21900 now_pred.state = AUTOMATIC_PRED_BLOCK;
21901 now_pred.mask = 0x18;
21902 now_pred.cc = cond;
21903 now_pred.block_length = 1;
21904 mapping_state (MAP_THUMB);
21905 now_pred.insn = output_it_inst (cond, now_pred.mask, NULL);
21906 now_pred.warn_deprecated = FALSE;
21907 now_pred.insn_cond = TRUE;
21910 /* Close an automatic IT block.
21911 See comments in new_automatic_it_block (). */
21914 close_automatic_it_block (void)
21916 now_pred.mask = 0x10;
21917 now_pred.block_length = 0;
21920 /* Update the mask of the current automatically-generated IT
21921 instruction. See comments in new_automatic_it_block (). */
21924 now_pred_add_mask (int cond)
21926 #define CLEAR_BIT(value, nbit) ((value) & ~(1 << (nbit)))
21927 #define SET_BIT_VALUE(value, bitvalue, nbit) (CLEAR_BIT (value, nbit) \
21928 | ((bitvalue) << (nbit)))
21929 const int resulting_bit = (cond & 1);
21931 now_pred.mask &= 0xf;
21932 now_pred.mask = SET_BIT_VALUE (now_pred.mask,
21934 (5 - now_pred.block_length));
21935 now_pred.mask = SET_BIT_VALUE (now_pred.mask,
21937 ((5 - now_pred.block_length) - 1));
21938 output_it_inst (now_pred.cc, now_pred.mask, now_pred.insn);
21941 #undef SET_BIT_VALUE
21944 /* The IT blocks handling machinery is accessed through the these functions:
21945 it_fsm_pre_encode () from md_assemble ()
21946 set_pred_insn_type () optional, from the tencode functions
21947 set_pred_insn_type_last () ditto
21948 in_pred_block () ditto
21949 it_fsm_post_encode () from md_assemble ()
21950 force_automatic_it_block_close () from label handling functions
21953 1) md_assemble () calls it_fsm_pre_encode () before calling tencode (),
21954 initializing the IT insn type with a generic initial value depending
21955 on the inst.condition.
21956 2) During the tencode function, two things may happen:
21957 a) The tencode function overrides the IT insn type by
21958 calling either set_pred_insn_type (type) or
21959 set_pred_insn_type_last ().
21960 b) The tencode function queries the IT block state by
21961 calling in_pred_block () (i.e. to determine narrow/not narrow mode).
21963 Both set_pred_insn_type and in_pred_block run the internal FSM state
21964 handling function (handle_pred_state), because: a) setting the IT insn
21965 type may incur in an invalid state (exiting the function),
21966 and b) querying the state requires the FSM to be updated.
21967 Specifically we want to avoid creating an IT block for conditional
21968 branches, so it_fsm_pre_encode is actually a guess and we can't
21969 determine whether an IT block is required until the tencode () routine
21970 has decided what type of instruction this actually it.
21971 Because of this, if set_pred_insn_type and in_pred_block have to be
21972 used, set_pred_insn_type has to be called first.
21974 set_pred_insn_type_last () is a wrapper of set_pred_insn_type (type),
21975 that determines the insn IT type depending on the inst.cond code.
21976 When a tencode () routine encodes an instruction that can be
21977 either outside an IT block, or, in the case of being inside, has to be
21978 the last one, set_pred_insn_type_last () will determine the proper
21979 IT instruction type based on the inst.cond code. Otherwise,
21980 set_pred_insn_type can be called for overriding that logic or
21981 for covering other cases.
21983 Calling handle_pred_state () may not transition the IT block state to
21984 OUTSIDE_PRED_BLOCK immediately, since the (current) state could be
21985 still queried. Instead, if the FSM determines that the state should
21986 be transitioned to OUTSIDE_PRED_BLOCK, a flag is marked to be closed
21987 after the tencode () function: that's what it_fsm_post_encode () does.
21989 Since in_pred_block () calls the state handling function to get an
21990 updated state, an error may occur (due to invalid insns combination).
21991 In that case, inst.error is set.
21992 Therefore, inst.error has to be checked after the execution of
21993 the tencode () routine.
21995 3) Back in md_assemble(), it_fsm_post_encode () is called to commit
21996 any pending state change (if any) that didn't take place in
21997 handle_pred_state () as explained above. */
22000 it_fsm_pre_encode (void)
22002 if (inst.cond != COND_ALWAYS)
22003 inst.pred_insn_type = INSIDE_IT_INSN;
22005 inst.pred_insn_type = OUTSIDE_PRED_INSN;
22007 now_pred.state_handled = 0;
22010 /* IT state FSM handling function. */
22011 /* MVE instructions and non-MVE instructions are handled differently because of
22012 the introduction of VPT blocks.
22013 Specifications say that any non-MVE instruction inside a VPT block is
22014 UNPREDICTABLE, with the exception of the BKPT instruction. Whereas most MVE
22015 instructions are deemed to be UNPREDICTABLE if inside an IT block. For the
22016 few exceptions we have MVE_UNPREDICABLE_INSN.
22017 The error messages provided depending on the different combinations possible
22018 are described in the cases below:
22019 For 'most' MVE instructions:
22020 1) In an IT block, with an IT code: syntax error
22021 2) In an IT block, with a VPT code: error: must be in a VPT block
22022 3) In an IT block, with no code: warning: UNPREDICTABLE
22023 4) In a VPT block, with an IT code: syntax error
22024 5) In a VPT block, with a VPT code: OK!
22025 6) In a VPT block, with no code: error: missing code
22026 7) Outside a pred block, with an IT code: error: syntax error
22027 8) Outside a pred block, with a VPT code: error: should be in a VPT block
22028 9) Outside a pred block, with no code: OK!
22029 For non-MVE instructions:
22030 10) In an IT block, with an IT code: OK!
22031 11) In an IT block, with a VPT code: syntax error
22032 12) In an IT block, with no code: error: missing code
22033 13) In a VPT block, with an IT code: error: should be in an IT block
22034 14) In a VPT block, with a VPT code: syntax error
22035 15) In a VPT block, with no code: UNPREDICTABLE
22036 16) Outside a pred block, with an IT code: error: should be in an IT block
22037 17) Outside a pred block, with a VPT code: syntax error
22038 18) Outside a pred block, with no code: OK!
22043 handle_pred_state (void)
22045 now_pred.state_handled = 1;
22046 now_pred.insn_cond = FALSE;
22048 switch (now_pred.state)
22050 case OUTSIDE_PRED_BLOCK:
22051 switch (inst.pred_insn_type)
22053 case MVE_UNPREDICABLE_INSN:
22054 case MVE_OUTSIDE_PRED_INSN:
22055 if (inst.cond < COND_ALWAYS)
22057 /* Case 7: Outside a pred block, with an IT code: error: syntax
22059 inst.error = BAD_SYNTAX;
22062 /* Case 9: Outside a pred block, with no code: OK! */
22064 case OUTSIDE_PRED_INSN:
22065 if (inst.cond > COND_ALWAYS)
22067 /* Case 17: Outside a pred block, with a VPT code: syntax error.
22069 inst.error = BAD_SYNTAX;
22072 /* Case 18: Outside a pred block, with no code: OK! */
22075 case INSIDE_VPT_INSN:
22076 /* Case 8: Outside a pred block, with a VPT code: error: should be in
22078 inst.error = BAD_OUT_VPT;
22081 case INSIDE_IT_INSN:
22082 case INSIDE_IT_LAST_INSN:
22083 if (inst.cond < COND_ALWAYS)
22085 /* Case 16: Outside a pred block, with an IT code: error: should
22086 be in an IT block. */
22087 if (thumb_mode == 0)
22090 && !(implicit_it_mode & IMPLICIT_IT_MODE_ARM))
22091 as_tsktsk (_("Warning: conditional outside an IT block"\
22096 if ((implicit_it_mode & IMPLICIT_IT_MODE_THUMB)
22097 && ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_v6t2))
22099 /* Automatically generate the IT instruction. */
22100 new_automatic_it_block (inst.cond);
22101 if (inst.pred_insn_type == INSIDE_IT_LAST_INSN)
22102 close_automatic_it_block ();
22106 inst.error = BAD_OUT_IT;
22112 else if (inst.cond > COND_ALWAYS)
22114 /* Case 17: Outside a pred block, with a VPT code: syntax error.
22116 inst.error = BAD_SYNTAX;
22121 case IF_INSIDE_IT_LAST_INSN:
22122 case NEUTRAL_IT_INSN:
22126 if (inst.cond != COND_ALWAYS)
22127 first_error (BAD_SYNTAX);
22128 now_pred.state = MANUAL_PRED_BLOCK;
22129 now_pred.block_length = 0;
22130 now_pred.type = VECTOR_PRED;
22134 now_pred.state = MANUAL_PRED_BLOCK;
22135 now_pred.block_length = 0;
22136 now_pred.type = SCALAR_PRED;
22141 case AUTOMATIC_PRED_BLOCK:
22142 /* Three things may happen now:
22143 a) We should increment current it block size;
22144 b) We should close current it block (closing insn or 4 insns);
22145 c) We should close current it block and start a new one (due
22146 to incompatible conditions or
22147 4 insns-length block reached). */
22149 switch (inst.pred_insn_type)
22151 case INSIDE_VPT_INSN:
22153 case MVE_UNPREDICABLE_INSN:
22154 case MVE_OUTSIDE_PRED_INSN:
22156 case OUTSIDE_PRED_INSN:
22157 /* The closure of the block shall happen immediately,
22158 so any in_pred_block () call reports the block as closed. */
22159 force_automatic_it_block_close ();
22162 case INSIDE_IT_INSN:
22163 case INSIDE_IT_LAST_INSN:
22164 case IF_INSIDE_IT_LAST_INSN:
22165 now_pred.block_length++;
22167 if (now_pred.block_length > 4
22168 || !now_pred_compatible (inst.cond))
22170 force_automatic_it_block_close ();
22171 if (inst.pred_insn_type != IF_INSIDE_IT_LAST_INSN)
22172 new_automatic_it_block (inst.cond);
22176 now_pred.insn_cond = TRUE;
22177 now_pred_add_mask (inst.cond);
22180 if (now_pred.state == AUTOMATIC_PRED_BLOCK
22181 && (inst.pred_insn_type == INSIDE_IT_LAST_INSN
22182 || inst.pred_insn_type == IF_INSIDE_IT_LAST_INSN))
22183 close_automatic_it_block ();
22186 case NEUTRAL_IT_INSN:
22187 now_pred.block_length++;
22188 now_pred.insn_cond = TRUE;
22190 if (now_pred.block_length > 4)
22191 force_automatic_it_block_close ();
22193 now_pred_add_mask (now_pred.cc & 1);
22197 close_automatic_it_block ();
22198 now_pred.state = MANUAL_PRED_BLOCK;
22203 case MANUAL_PRED_BLOCK:
22206 if (now_pred.type == SCALAR_PRED)
22208 /* Check conditional suffixes. */
22209 cond = now_pred.cc ^ ((now_pred.mask >> 4) & 1) ^ 1;
22210 now_pred.mask <<= 1;
22211 now_pred.mask &= 0x1f;
22212 is_last = (now_pred.mask == 0x10);
22216 now_pred.cc ^= (now_pred.mask >> 4);
22217 cond = now_pred.cc + 0xf;
22218 now_pred.mask <<= 1;
22219 now_pred.mask &= 0x1f;
22220 is_last = now_pred.mask == 0x10;
22222 now_pred.insn_cond = TRUE;
22224 switch (inst.pred_insn_type)
22226 case OUTSIDE_PRED_INSN:
22227 if (now_pred.type == SCALAR_PRED)
22229 if (inst.cond == COND_ALWAYS)
22231 /* Case 12: In an IT block, with no code: error: missing
22233 inst.error = BAD_NOT_IT;
22236 else if (inst.cond > COND_ALWAYS)
22238 /* Case 11: In an IT block, with a VPT code: syntax error.
22240 inst.error = BAD_SYNTAX;
22243 else if (thumb_mode)
22245 /* This is for some special cases where a non-MVE
22246 instruction is not allowed in an IT block, such as cbz,
22247 but are put into one with a condition code.
22248 You could argue this should be a syntax error, but we
22249 gave the 'not allowed in IT block' diagnostic in the
22250 past so we will keep doing so. */
22251 inst.error = BAD_NOT_IT;
22258 /* Case 15: In a VPT block, with no code: UNPREDICTABLE. */
22259 as_tsktsk (MVE_NOT_VPT);
22262 case MVE_OUTSIDE_PRED_INSN:
22263 if (now_pred.type == SCALAR_PRED)
22265 if (inst.cond == COND_ALWAYS)
22267 /* Case 3: In an IT block, with no code: warning:
22269 as_tsktsk (MVE_NOT_IT);
22272 else if (inst.cond < COND_ALWAYS)
22274 /* Case 1: In an IT block, with an IT code: syntax error.
22276 inst.error = BAD_SYNTAX;
22284 if (inst.cond < COND_ALWAYS)
22286 /* Case 4: In a VPT block, with an IT code: syntax error.
22288 inst.error = BAD_SYNTAX;
22291 else if (inst.cond == COND_ALWAYS)
22293 /* Case 6: In a VPT block, with no code: error: missing
22295 inst.error = BAD_NOT_VPT;
22303 case MVE_UNPREDICABLE_INSN:
22304 as_tsktsk (now_pred.type == SCALAR_PRED ? MVE_NOT_IT : MVE_NOT_VPT);
22306 case INSIDE_IT_INSN:
22307 if (inst.cond > COND_ALWAYS)
22309 /* Case 11: In an IT block, with a VPT code: syntax error. */
22310 /* Case 14: In a VPT block, with a VPT code: syntax error. */
22311 inst.error = BAD_SYNTAX;
22314 else if (now_pred.type == SCALAR_PRED)
22316 /* Case 10: In an IT block, with an IT code: OK! */
22317 if (cond != inst.cond)
22319 inst.error = now_pred.type == SCALAR_PRED ? BAD_IT_COND :
22326 /* Case 13: In a VPT block, with an IT code: error: should be
22328 inst.error = BAD_OUT_IT;
22333 case INSIDE_VPT_INSN:
22334 if (now_pred.type == SCALAR_PRED)
22336 /* Case 2: In an IT block, with a VPT code: error: must be in a
22338 inst.error = BAD_OUT_VPT;
22341 /* Case 5: In a VPT block, with a VPT code: OK! */
22342 else if (cond != inst.cond)
22344 inst.error = BAD_VPT_COND;
22348 case INSIDE_IT_LAST_INSN:
22349 case IF_INSIDE_IT_LAST_INSN:
22350 if (now_pred.type == VECTOR_PRED || inst.cond > COND_ALWAYS)
22352 /* Case 4: In a VPT block, with an IT code: syntax error. */
22353 /* Case 11: In an IT block, with a VPT code: syntax error. */
22354 inst.error = BAD_SYNTAX;
22357 else if (cond != inst.cond)
22359 inst.error = BAD_IT_COND;
22364 inst.error = BAD_BRANCH;
22369 case NEUTRAL_IT_INSN:
22370 /* The BKPT instruction is unconditional even in a IT or VPT
22375 if (now_pred.type == SCALAR_PRED)
22377 inst.error = BAD_IT_IT;
22380 /* fall through. */
22382 if (inst.cond == COND_ALWAYS)
22384 /* Executing a VPT/VPST instruction inside an IT block or a
22385 VPT/VPST/IT instruction inside a VPT block is UNPREDICTABLE.
22387 if (now_pred.type == SCALAR_PRED)
22388 as_tsktsk (MVE_NOT_IT);
22390 as_tsktsk (MVE_NOT_VPT);
22395 /* VPT/VPST do not accept condition codes. */
22396 inst.error = BAD_SYNTAX;
22407 struct depr_insn_mask
22409 unsigned long pattern;
22410 unsigned long mask;
22411 const char* description;
22414 /* List of 16-bit instruction patterns deprecated in an IT block in
22416 static const struct depr_insn_mask depr_it_insns[] = {
22417 { 0xc000, 0xc000, N_("Short branches, Undefined, SVC, LDM/STM") },
22418 { 0xb000, 0xb000, N_("Miscellaneous 16-bit instructions") },
22419 { 0xa000, 0xb800, N_("ADR") },
22420 { 0x4800, 0xf800, N_("Literal loads") },
22421 { 0x4478, 0xf478, N_("Hi-register ADD, MOV, CMP, BX, BLX using pc") },
22422 { 0x4487, 0xfc87, N_("Hi-register ADD, MOV, CMP using pc") },
22423 /* NOTE: 0x00dd is not the real encoding, instead, it is the 'tvalue'
22424 field in asm_opcode. 'tvalue' is used at the stage this check happen. */
22425 { 0x00dd, 0x7fff, N_("ADD/SUB sp, sp #imm") },
22430 it_fsm_post_encode (void)
22434 if (!now_pred.state_handled)
22435 handle_pred_state ();
22437 if (now_pred.insn_cond
22438 && !now_pred.warn_deprecated
22439 && warn_on_deprecated
22440 && ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_v8)
22441 && !ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_m))
22443 if (inst.instruction >= 0x10000)
22445 as_tsktsk (_("IT blocks containing 32-bit Thumb instructions are "
22446 "performance deprecated in ARMv8-A and ARMv8-R"));
22447 now_pred.warn_deprecated = TRUE;
22451 const struct depr_insn_mask *p = depr_it_insns;
22453 while (p->mask != 0)
22455 if ((inst.instruction & p->mask) == p->pattern)
22457 as_tsktsk (_("IT blocks containing 16-bit Thumb "
22458 "instructions of the following class are "
22459 "performance deprecated in ARMv8-A and "
22460 "ARMv8-R: %s"), p->description);
22461 now_pred.warn_deprecated = TRUE;
22469 if (now_pred.block_length > 1)
22471 as_tsktsk (_("IT blocks containing more than one conditional "
22472 "instruction are performance deprecated in ARMv8-A and "
22474 now_pred.warn_deprecated = TRUE;
22478 is_last = (now_pred.mask == 0x10);
22481 now_pred.state = OUTSIDE_PRED_BLOCK;
22487 force_automatic_it_block_close (void)
22489 if (now_pred.state == AUTOMATIC_PRED_BLOCK)
22491 close_automatic_it_block ();
22492 now_pred.state = OUTSIDE_PRED_BLOCK;
22498 in_pred_block (void)
22500 if (!now_pred.state_handled)
22501 handle_pred_state ();
22503 return now_pred.state != OUTSIDE_PRED_BLOCK;
22506 /* Whether OPCODE only has T32 encoding. Since this function is only used by
22507 t32_insn_ok, OPCODE enabled by v6t2 extension bit do not need to be listed
22508 here, hence the "known" in the function name. */
22511 known_t32_only_insn (const struct asm_opcode *opcode)
22513 /* Original Thumb-1 wide instruction. */
22514 if (opcode->tencode == do_t_blx
22515 || opcode->tencode == do_t_branch23
22516 || ARM_CPU_HAS_FEATURE (*opcode->tvariant, arm_ext_msr)
22517 || ARM_CPU_HAS_FEATURE (*opcode->tvariant, arm_ext_barrier))
22520 /* Wide-only instruction added to ARMv8-M Baseline. */
22521 if (ARM_CPU_HAS_FEATURE (*opcode->tvariant, arm_ext_v8m_m_only)
22522 || ARM_CPU_HAS_FEATURE (*opcode->tvariant, arm_ext_atomics)
22523 || ARM_CPU_HAS_FEATURE (*opcode->tvariant, arm_ext_v6t2_v8m)
22524 || ARM_CPU_HAS_FEATURE (*opcode->tvariant, arm_ext_div))
22530 /* Whether wide instruction variant can be used if available for a valid OPCODE
22534 t32_insn_ok (arm_feature_set arch, const struct asm_opcode *opcode)
22536 if (known_t32_only_insn (opcode))
22539 /* Instruction with narrow and wide encoding added to ARMv8-M. Availability
22540 of variant T3 of B.W is checked in do_t_branch. */
22541 if (ARM_CPU_HAS_FEATURE (arch, arm_ext_v8m)
22542 && opcode->tencode == do_t_branch)
22545 /* MOV accepts T1/T3 encodings under Baseline, T3 encoding is 32bit. */
22546 if (ARM_CPU_HAS_FEATURE (arch, arm_ext_v8m)
22547 && opcode->tencode == do_t_mov_cmp
22548 /* Make sure CMP instruction is not affected. */
22549 && opcode->aencode == do_mov)
22552 /* Wide instruction variants of all instructions with narrow *and* wide
22553 variants become available with ARMv6t2. Other opcodes are either
22554 narrow-only or wide-only and are thus available if OPCODE is valid. */
22555 if (ARM_CPU_HAS_FEATURE (arch, arm_ext_v6t2))
22558 /* OPCODE with narrow only instruction variant or wide variant not
22564 md_assemble (char *str)
22567 const struct asm_opcode * opcode;
22569 /* Align the previous label if needed. */
22570 if (last_label_seen != NULL)
22572 symbol_set_frag (last_label_seen, frag_now);
22573 S_SET_VALUE (last_label_seen, (valueT) frag_now_fix ());
22574 S_SET_SEGMENT (last_label_seen, now_seg);
22577 memset (&inst, '\0', sizeof (inst));
22579 for (r = 0; r < ARM_IT_MAX_RELOCS; r++)
22580 inst.relocs[r].type = BFD_RELOC_UNUSED;
22582 opcode = opcode_lookup (&p);
22585 /* It wasn't an instruction, but it might be a register alias of
22586 the form alias .req reg, or a Neon .dn/.qn directive. */
22587 if (! create_register_alias (str, p)
22588 && ! create_neon_reg_alias (str, p))
22589 as_bad (_("bad instruction `%s'"), str);
22594 if (warn_on_deprecated && opcode->tag == OT_cinfix3_deprecated)
22595 as_tsktsk (_("s suffix on comparison instruction is deprecated"));
22597 /* The value which unconditional instructions should have in place of the
22598 condition field. */
22599 inst.uncond_value = (opcode->tag == OT_csuffixF) ? 0xf : -1;
22603 arm_feature_set variant;
22605 variant = cpu_variant;
22606 /* Only allow coprocessor instructions on Thumb-2 capable devices. */
22607 if (!ARM_CPU_HAS_FEATURE (variant, arm_arch_t2))
22608 ARM_CLEAR_FEATURE (variant, variant, fpu_any_hard);
22609 /* Check that this instruction is supported for this CPU. */
22610 if (!opcode->tvariant
22611 || (thumb_mode == 1
22612 && !ARM_CPU_HAS_FEATURE (variant, *opcode->tvariant)))
22614 if (opcode->tencode == do_t_swi)
22615 as_bad (_("SVC is not permitted on this architecture"));
22617 as_bad (_("selected processor does not support `%s' in Thumb mode"), str);
22620 if (inst.cond != COND_ALWAYS && !unified_syntax
22621 && opcode->tencode != do_t_branch)
22623 as_bad (_("Thumb does not support conditional execution"));
22627 /* Two things are addressed here:
22628 1) Implicit require narrow instructions on Thumb-1.
22629 This avoids relaxation accidentally introducing Thumb-2
22631 2) Reject wide instructions in non Thumb-2 cores.
22633 Only instructions with narrow and wide variants need to be handled
22634 but selecting all non wide-only instructions is easier. */
22635 if (!ARM_CPU_HAS_FEATURE (variant, arm_ext_v6t2)
22636 && !t32_insn_ok (variant, opcode))
22638 if (inst.size_req == 0)
22640 else if (inst.size_req == 4)
22642 if (ARM_CPU_HAS_FEATURE (variant, arm_ext_v8m))
22643 as_bad (_("selected processor does not support 32bit wide "
22644 "variant of instruction `%s'"), str);
22646 as_bad (_("selected processor does not support `%s' in "
22647 "Thumb-2 mode"), str);
22652 inst.instruction = opcode->tvalue;
22654 if (!parse_operands (p, opcode->operands, /*thumb=*/TRUE))
22656 /* Prepare the pred_insn_type for those encodings that don't set
22658 it_fsm_pre_encode ();
22660 opcode->tencode ();
22662 it_fsm_post_encode ();
22665 if (!(inst.error || inst.relax))
22667 gas_assert (inst.instruction < 0xe800 || inst.instruction > 0xffff);
22668 inst.size = (inst.instruction > 0xffff ? 4 : 2);
22669 if (inst.size_req && inst.size_req != inst.size)
22671 as_bad (_("cannot honor width suffix -- `%s'"), str);
22676 /* Something has gone badly wrong if we try to relax a fixed size
22678 gas_assert (inst.size_req == 0 || !inst.relax);
22680 ARM_MERGE_FEATURE_SETS (thumb_arch_used, thumb_arch_used,
22681 *opcode->tvariant);
22682 /* Many Thumb-2 instructions also have Thumb-1 variants, so explicitly
22683 set those bits when Thumb-2 32-bit instructions are seen. The impact
22684 of relaxable instructions will be considered later after we finish all
22686 if (ARM_FEATURE_CORE_EQUAL (cpu_variant, arm_arch_any))
22687 variant = arm_arch_none;
22689 variant = cpu_variant;
22690 if (inst.size == 4 && !t32_insn_ok (variant, opcode))
22691 ARM_MERGE_FEATURE_SETS (thumb_arch_used, thumb_arch_used,
22694 check_neon_suffixes;
22698 mapping_state (MAP_THUMB);
22701 else if (ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_v1))
22705 /* bx is allowed on v5 cores, and sometimes on v4 cores. */
22706 is_bx = (opcode->aencode == do_bx);
22708 /* Check that this instruction is supported for this CPU. */
22709 if (!(is_bx && fix_v4bx)
22710 && !(opcode->avariant &&
22711 ARM_CPU_HAS_FEATURE (cpu_variant, *opcode->avariant)))
22713 as_bad (_("selected processor does not support `%s' in ARM mode"), str);
22718 as_bad (_("width suffixes are invalid in ARM mode -- `%s'"), str);
22722 inst.instruction = opcode->avalue;
22723 if (opcode->tag == OT_unconditionalF)
22724 inst.instruction |= 0xFU << 28;
22726 inst.instruction |= inst.cond << 28;
22727 inst.size = INSN_SIZE;
22728 if (!parse_operands (p, opcode->operands, /*thumb=*/FALSE))
22730 it_fsm_pre_encode ();
22731 opcode->aencode ();
22732 it_fsm_post_encode ();
22734 /* Arm mode bx is marked as both v4T and v5 because it's still required
22735 on a hypothetical non-thumb v5 core. */
22737 ARM_MERGE_FEATURE_SETS (arm_arch_used, arm_arch_used, arm_ext_v4t);
22739 ARM_MERGE_FEATURE_SETS (arm_arch_used, arm_arch_used,
22740 *opcode->avariant);
22742 check_neon_suffixes;
22746 mapping_state (MAP_ARM);
22751 as_bad (_("attempt to use an ARM instruction on a Thumb-only processor "
22759 check_pred_blocks_finished (void)
22764 for (sect = stdoutput->sections; sect != NULL; sect = sect->next)
22765 if (seg_info (sect)->tc_segment_info_data.current_pred.state
22766 == MANUAL_PRED_BLOCK)
22768 if (now_pred.type == SCALAR_PRED)
22769 as_warn (_("section '%s' finished with an open IT block."),
22772 as_warn (_("section '%s' finished with an open VPT/VPST block."),
22776 if (now_pred.state == MANUAL_PRED_BLOCK)
22778 if (now_pred.type == SCALAR_PRED)
22779 as_warn (_("file finished with an open IT block."));
22781 as_warn (_("file finished with an open VPT/VPST block."));
22786 /* Various frobbings of labels and their addresses. */
22789 arm_start_line_hook (void)
22791 last_label_seen = NULL;
22795 arm_frob_label (symbolS * sym)
22797 last_label_seen = sym;
22799 ARM_SET_THUMB (sym, thumb_mode);
22801 #if defined OBJ_COFF || defined OBJ_ELF
22802 ARM_SET_INTERWORK (sym, support_interwork);
22805 force_automatic_it_block_close ();
22807 /* Note - do not allow local symbols (.Lxxx) to be labelled
22808 as Thumb functions. This is because these labels, whilst
22809 they exist inside Thumb code, are not the entry points for
22810 possible ARM->Thumb calls. Also, these labels can be used
22811 as part of a computed goto or switch statement. eg gcc
22812 can generate code that looks like this:
22814 ldr r2, [pc, .Laaa]
22824 The first instruction loads the address of the jump table.
22825 The second instruction converts a table index into a byte offset.
22826 The third instruction gets the jump address out of the table.
22827 The fourth instruction performs the jump.
22829 If the address stored at .Laaa is that of a symbol which has the
22830 Thumb_Func bit set, then the linker will arrange for this address
22831 to have the bottom bit set, which in turn would mean that the
22832 address computation performed by the third instruction would end
22833 up with the bottom bit set. Since the ARM is capable of unaligned
22834 word loads, the instruction would then load the incorrect address
22835 out of the jump table, and chaos would ensue. */
22836 if (label_is_thumb_function_name
22837 && (S_GET_NAME (sym)[0] != '.' || S_GET_NAME (sym)[1] != 'L')
22838 && (bfd_get_section_flags (stdoutput, now_seg) & SEC_CODE) != 0)
22840 /* When the address of a Thumb function is taken the bottom
22841 bit of that address should be set. This will allow
22842 interworking between Arm and Thumb functions to work
22845 THUMB_SET_FUNC (sym, 1);
22847 label_is_thumb_function_name = FALSE;
22850 dwarf2_emit_label (sym);
22854 arm_data_in_code (void)
22856 if (thumb_mode && ! strncmp (input_line_pointer + 1, "data:", 5))
22858 *input_line_pointer = '/';
22859 input_line_pointer += 5;
22860 *input_line_pointer = 0;
22868 arm_canonicalize_symbol_name (char * name)
22872 if (thumb_mode && (len = strlen (name)) > 5
22873 && streq (name + len - 5, "/data"))
22874 *(name + len - 5) = 0;
22879 /* Table of all register names defined by default. The user can
22880 define additional names with .req. Note that all register names
22881 should appear in both upper and lowercase variants. Some registers
22882 also have mixed-case names. */
22884 #define REGDEF(s,n,t) { #s, n, REG_TYPE_##t, TRUE, 0 }
22885 #define REGNUM(p,n,t) REGDEF(p##n, n, t)
22886 #define REGNUM2(p,n,t) REGDEF(p##n, 2 * n, t)
22887 #define REGSET(p,t) \
22888 REGNUM(p, 0,t), REGNUM(p, 1,t), REGNUM(p, 2,t), REGNUM(p, 3,t), \
22889 REGNUM(p, 4,t), REGNUM(p, 5,t), REGNUM(p, 6,t), REGNUM(p, 7,t), \
22890 REGNUM(p, 8,t), REGNUM(p, 9,t), REGNUM(p,10,t), REGNUM(p,11,t), \
22891 REGNUM(p,12,t), REGNUM(p,13,t), REGNUM(p,14,t), REGNUM(p,15,t)
22892 #define REGSETH(p,t) \
22893 REGNUM(p,16,t), REGNUM(p,17,t), REGNUM(p,18,t), REGNUM(p,19,t), \
22894 REGNUM(p,20,t), REGNUM(p,21,t), REGNUM(p,22,t), REGNUM(p,23,t), \
22895 REGNUM(p,24,t), REGNUM(p,25,t), REGNUM(p,26,t), REGNUM(p,27,t), \
22896 REGNUM(p,28,t), REGNUM(p,29,t), REGNUM(p,30,t), REGNUM(p,31,t)
22897 #define REGSET2(p,t) \
22898 REGNUM2(p, 0,t), REGNUM2(p, 1,t), REGNUM2(p, 2,t), REGNUM2(p, 3,t), \
22899 REGNUM2(p, 4,t), REGNUM2(p, 5,t), REGNUM2(p, 6,t), REGNUM2(p, 7,t), \
22900 REGNUM2(p, 8,t), REGNUM2(p, 9,t), REGNUM2(p,10,t), REGNUM2(p,11,t), \
22901 REGNUM2(p,12,t), REGNUM2(p,13,t), REGNUM2(p,14,t), REGNUM2(p,15,t)
22902 #define SPLRBANK(base,bank,t) \
22903 REGDEF(lr_##bank, 768|((base+0)<<16), t), \
22904 REGDEF(sp_##bank, 768|((base+1)<<16), t), \
22905 REGDEF(spsr_##bank, 768|(base<<16)|SPSR_BIT, t), \
22906 REGDEF(LR_##bank, 768|((base+0)<<16), t), \
22907 REGDEF(SP_##bank, 768|((base+1)<<16), t), \
22908 REGDEF(SPSR_##bank, 768|(base<<16)|SPSR_BIT, t)
22910 static const struct reg_entry reg_names[] =
22912 /* ARM integer registers. */
22913 REGSET(r, RN), REGSET(R, RN),
22915 /* ATPCS synonyms. */
22916 REGDEF(a1,0,RN), REGDEF(a2,1,RN), REGDEF(a3, 2,RN), REGDEF(a4, 3,RN),
22917 REGDEF(v1,4,RN), REGDEF(v2,5,RN), REGDEF(v3, 6,RN), REGDEF(v4, 7,RN),
22918 REGDEF(v5,8,RN), REGDEF(v6,9,RN), REGDEF(v7,10,RN), REGDEF(v8,11,RN),
22920 REGDEF(A1,0,RN), REGDEF(A2,1,RN), REGDEF(A3, 2,RN), REGDEF(A4, 3,RN),
22921 REGDEF(V1,4,RN), REGDEF(V2,5,RN), REGDEF(V3, 6,RN), REGDEF(V4, 7,RN),
22922 REGDEF(V5,8,RN), REGDEF(V6,9,RN), REGDEF(V7,10,RN), REGDEF(V8,11,RN),
22924 /* Well-known aliases. */
22925 REGDEF(wr, 7,RN), REGDEF(sb, 9,RN), REGDEF(sl,10,RN), REGDEF(fp,11,RN),
22926 REGDEF(ip,12,RN), REGDEF(sp,13,RN), REGDEF(lr,14,RN), REGDEF(pc,15,RN),
22928 REGDEF(WR, 7,RN), REGDEF(SB, 9,RN), REGDEF(SL,10,RN), REGDEF(FP,11,RN),
22929 REGDEF(IP,12,RN), REGDEF(SP,13,RN), REGDEF(LR,14,RN), REGDEF(PC,15,RN),
22931 /* Defining the new Zero register from ARMv8.1-M. */
22935 /* Coprocessor numbers. */
22936 REGSET(p, CP), REGSET(P, CP),
22938 /* Coprocessor register numbers. The "cr" variants are for backward
22940 REGSET(c, CN), REGSET(C, CN),
22941 REGSET(cr, CN), REGSET(CR, CN),
22943 /* ARM banked registers. */
22944 REGDEF(R8_usr,512|(0<<16),RNB), REGDEF(r8_usr,512|(0<<16),RNB),
22945 REGDEF(R9_usr,512|(1<<16),RNB), REGDEF(r9_usr,512|(1<<16),RNB),
22946 REGDEF(R10_usr,512|(2<<16),RNB), REGDEF(r10_usr,512|(2<<16),RNB),
22947 REGDEF(R11_usr,512|(3<<16),RNB), REGDEF(r11_usr,512|(3<<16),RNB),
22948 REGDEF(R12_usr,512|(4<<16),RNB), REGDEF(r12_usr,512|(4<<16),RNB),
22949 REGDEF(SP_usr,512|(5<<16),RNB), REGDEF(sp_usr,512|(5<<16),RNB),
22950 REGDEF(LR_usr,512|(6<<16),RNB), REGDEF(lr_usr,512|(6<<16),RNB),
22952 REGDEF(R8_fiq,512|(8<<16),RNB), REGDEF(r8_fiq,512|(8<<16),RNB),
22953 REGDEF(R9_fiq,512|(9<<16),RNB), REGDEF(r9_fiq,512|(9<<16),RNB),
22954 REGDEF(R10_fiq,512|(10<<16),RNB), REGDEF(r10_fiq,512|(10<<16),RNB),
22955 REGDEF(R11_fiq,512|(11<<16),RNB), REGDEF(r11_fiq,512|(11<<16),RNB),
22956 REGDEF(R12_fiq,512|(12<<16),RNB), REGDEF(r12_fiq,512|(12<<16),RNB),
22957 REGDEF(SP_fiq,512|(13<<16),RNB), REGDEF(sp_fiq,512|(13<<16),RNB),
22958 REGDEF(LR_fiq,512|(14<<16),RNB), REGDEF(lr_fiq,512|(14<<16),RNB),
22959 REGDEF(SPSR_fiq,512|(14<<16)|SPSR_BIT,RNB), REGDEF(spsr_fiq,512|(14<<16)|SPSR_BIT,RNB),
22961 SPLRBANK(0,IRQ,RNB), SPLRBANK(0,irq,RNB),
22962 SPLRBANK(2,SVC,RNB), SPLRBANK(2,svc,RNB),
22963 SPLRBANK(4,ABT,RNB), SPLRBANK(4,abt,RNB),
22964 SPLRBANK(6,UND,RNB), SPLRBANK(6,und,RNB),
22965 SPLRBANK(12,MON,RNB), SPLRBANK(12,mon,RNB),
22966 REGDEF(elr_hyp,768|(14<<16),RNB), REGDEF(ELR_hyp,768|(14<<16),RNB),
22967 REGDEF(sp_hyp,768|(15<<16),RNB), REGDEF(SP_hyp,768|(15<<16),RNB),
22968 REGDEF(spsr_hyp,768|(14<<16)|SPSR_BIT,RNB),
22969 REGDEF(SPSR_hyp,768|(14<<16)|SPSR_BIT,RNB),
22971 /* FPA registers. */
22972 REGNUM(f,0,FN), REGNUM(f,1,FN), REGNUM(f,2,FN), REGNUM(f,3,FN),
22973 REGNUM(f,4,FN), REGNUM(f,5,FN), REGNUM(f,6,FN), REGNUM(f,7, FN),
22975 REGNUM(F,0,FN), REGNUM(F,1,FN), REGNUM(F,2,FN), REGNUM(F,3,FN),
22976 REGNUM(F,4,FN), REGNUM(F,5,FN), REGNUM(F,6,FN), REGNUM(F,7, FN),
22978 /* VFP SP registers. */
22979 REGSET(s,VFS), REGSET(S,VFS),
22980 REGSETH(s,VFS), REGSETH(S,VFS),
22982 /* VFP DP Registers. */
22983 REGSET(d,VFD), REGSET(D,VFD),
22984 /* Extra Neon DP registers. */
22985 REGSETH(d,VFD), REGSETH(D,VFD),
22987 /* Neon QP registers. */
22988 REGSET2(q,NQ), REGSET2(Q,NQ),
22990 /* VFP control registers. */
22991 REGDEF(fpsid,0,VFC), REGDEF(fpscr,1,VFC), REGDEF(fpexc,8,VFC),
22992 REGDEF(FPSID,0,VFC), REGDEF(FPSCR,1,VFC), REGDEF(FPEXC,8,VFC),
22993 REGDEF(fpinst,9,VFC), REGDEF(fpinst2,10,VFC),
22994 REGDEF(FPINST,9,VFC), REGDEF(FPINST2,10,VFC),
22995 REGDEF(mvfr0,7,VFC), REGDEF(mvfr1,6,VFC),
22996 REGDEF(MVFR0,7,VFC), REGDEF(MVFR1,6,VFC),
22997 REGDEF(mvfr2,5,VFC), REGDEF(MVFR2,5,VFC),
22998 REGDEF(fpscr_nzcvqc,2,VFC), REGDEF(FPSCR_nzcvqc,2,VFC),
22999 REGDEF(vpr,12,VFC), REGDEF(VPR,12,VFC),
23000 REGDEF(fpcxt_ns,14,VFC), REGDEF(FPCXT_NS,14,VFC),
23001 REGDEF(fpcxt_s,15,VFC), REGDEF(FPCXT_S,15,VFC),
23003 /* Maverick DSP coprocessor registers. */
23004 REGSET(mvf,MVF), REGSET(mvd,MVD), REGSET(mvfx,MVFX), REGSET(mvdx,MVDX),
23005 REGSET(MVF,MVF), REGSET(MVD,MVD), REGSET(MVFX,MVFX), REGSET(MVDX,MVDX),
23007 REGNUM(mvax,0,MVAX), REGNUM(mvax,1,MVAX),
23008 REGNUM(mvax,2,MVAX), REGNUM(mvax,3,MVAX),
23009 REGDEF(dspsc,0,DSPSC),
23011 REGNUM(MVAX,0,MVAX), REGNUM(MVAX,1,MVAX),
23012 REGNUM(MVAX,2,MVAX), REGNUM(MVAX,3,MVAX),
23013 REGDEF(DSPSC,0,DSPSC),
23015 /* iWMMXt data registers - p0, c0-15. */
23016 REGSET(wr,MMXWR), REGSET(wR,MMXWR), REGSET(WR, MMXWR),
23018 /* iWMMXt control registers - p1, c0-3. */
23019 REGDEF(wcid, 0,MMXWC), REGDEF(wCID, 0,MMXWC), REGDEF(WCID, 0,MMXWC),
23020 REGDEF(wcon, 1,MMXWC), REGDEF(wCon, 1,MMXWC), REGDEF(WCON, 1,MMXWC),
23021 REGDEF(wcssf, 2,MMXWC), REGDEF(wCSSF, 2,MMXWC), REGDEF(WCSSF, 2,MMXWC),
23022 REGDEF(wcasf, 3,MMXWC), REGDEF(wCASF, 3,MMXWC), REGDEF(WCASF, 3,MMXWC),
23024 /* iWMMXt scalar (constant/offset) registers - p1, c8-11. */
23025 REGDEF(wcgr0, 8,MMXWCG), REGDEF(wCGR0, 8,MMXWCG), REGDEF(WCGR0, 8,MMXWCG),
23026 REGDEF(wcgr1, 9,MMXWCG), REGDEF(wCGR1, 9,MMXWCG), REGDEF(WCGR1, 9,MMXWCG),
23027 REGDEF(wcgr2,10,MMXWCG), REGDEF(wCGR2,10,MMXWCG), REGDEF(WCGR2,10,MMXWCG),
23028 REGDEF(wcgr3,11,MMXWCG), REGDEF(wCGR3,11,MMXWCG), REGDEF(WCGR3,11,MMXWCG),
23030 /* XScale accumulator registers. */
23031 REGNUM(acc,0,XSCALE), REGNUM(ACC,0,XSCALE),
23037 /* Table of all PSR suffixes. Bare "CPSR" and "SPSR" are handled
23038 within psr_required_here. */
23039 static const struct asm_psr psrs[] =
23041 /* Backward compatibility notation. Note that "all" is no longer
23042 truly all possible PSR bits. */
23043 {"all", PSR_c | PSR_f},
23047 /* Individual flags. */
23053 /* Combinations of flags. */
23054 {"fs", PSR_f | PSR_s},
23055 {"fx", PSR_f | PSR_x},
23056 {"fc", PSR_f | PSR_c},
23057 {"sf", PSR_s | PSR_f},
23058 {"sx", PSR_s | PSR_x},
23059 {"sc", PSR_s | PSR_c},
23060 {"xf", PSR_x | PSR_f},
23061 {"xs", PSR_x | PSR_s},
23062 {"xc", PSR_x | PSR_c},
23063 {"cf", PSR_c | PSR_f},
23064 {"cs", PSR_c | PSR_s},
23065 {"cx", PSR_c | PSR_x},
23066 {"fsx", PSR_f | PSR_s | PSR_x},
23067 {"fsc", PSR_f | PSR_s | PSR_c},
23068 {"fxs", PSR_f | PSR_x | PSR_s},
23069 {"fxc", PSR_f | PSR_x | PSR_c},
23070 {"fcs", PSR_f | PSR_c | PSR_s},
23071 {"fcx", PSR_f | PSR_c | PSR_x},
23072 {"sfx", PSR_s | PSR_f | PSR_x},
23073 {"sfc", PSR_s | PSR_f | PSR_c},
23074 {"sxf", PSR_s | PSR_x | PSR_f},
23075 {"sxc", PSR_s | PSR_x | PSR_c},
23076 {"scf", PSR_s | PSR_c | PSR_f},
23077 {"scx", PSR_s | PSR_c | PSR_x},
23078 {"xfs", PSR_x | PSR_f | PSR_s},
23079 {"xfc", PSR_x | PSR_f | PSR_c},
23080 {"xsf", PSR_x | PSR_s | PSR_f},
23081 {"xsc", PSR_x | PSR_s | PSR_c},
23082 {"xcf", PSR_x | PSR_c | PSR_f},
23083 {"xcs", PSR_x | PSR_c | PSR_s},
23084 {"cfs", PSR_c | PSR_f | PSR_s},
23085 {"cfx", PSR_c | PSR_f | PSR_x},
23086 {"csf", PSR_c | PSR_s | PSR_f},
23087 {"csx", PSR_c | PSR_s | PSR_x},
23088 {"cxf", PSR_c | PSR_x | PSR_f},
23089 {"cxs", PSR_c | PSR_x | PSR_s},
23090 {"fsxc", PSR_f | PSR_s | PSR_x | PSR_c},
23091 {"fscx", PSR_f | PSR_s | PSR_c | PSR_x},
23092 {"fxsc", PSR_f | PSR_x | PSR_s | PSR_c},
23093 {"fxcs", PSR_f | PSR_x | PSR_c | PSR_s},
23094 {"fcsx", PSR_f | PSR_c | PSR_s | PSR_x},
23095 {"fcxs", PSR_f | PSR_c | PSR_x | PSR_s},
23096 {"sfxc", PSR_s | PSR_f | PSR_x | PSR_c},
23097 {"sfcx", PSR_s | PSR_f | PSR_c | PSR_x},
23098 {"sxfc", PSR_s | PSR_x | PSR_f | PSR_c},
23099 {"sxcf", PSR_s | PSR_x | PSR_c | PSR_f},
23100 {"scfx", PSR_s | PSR_c | PSR_f | PSR_x},
23101 {"scxf", PSR_s | PSR_c | PSR_x | PSR_f},
23102 {"xfsc", PSR_x | PSR_f | PSR_s | PSR_c},
23103 {"xfcs", PSR_x | PSR_f | PSR_c | PSR_s},
23104 {"xsfc", PSR_x | PSR_s | PSR_f | PSR_c},
23105 {"xscf", PSR_x | PSR_s | PSR_c | PSR_f},
23106 {"xcfs", PSR_x | PSR_c | PSR_f | PSR_s},
23107 {"xcsf", PSR_x | PSR_c | PSR_s | PSR_f},
23108 {"cfsx", PSR_c | PSR_f | PSR_s | PSR_x},
23109 {"cfxs", PSR_c | PSR_f | PSR_x | PSR_s},
23110 {"csfx", PSR_c | PSR_s | PSR_f | PSR_x},
23111 {"csxf", PSR_c | PSR_s | PSR_x | PSR_f},
23112 {"cxfs", PSR_c | PSR_x | PSR_f | PSR_s},
23113 {"cxsf", PSR_c | PSR_x | PSR_s | PSR_f},
23116 /* Table of V7M psr names. */
23117 static const struct asm_psr v7m_psrs[] =
23119 {"apsr", 0x0 }, {"APSR", 0x0 },
23120 {"iapsr", 0x1 }, {"IAPSR", 0x1 },
23121 {"eapsr", 0x2 }, {"EAPSR", 0x2 },
23122 {"psr", 0x3 }, {"PSR", 0x3 },
23123 {"xpsr", 0x3 }, {"XPSR", 0x3 }, {"xPSR", 3 },
23124 {"ipsr", 0x5 }, {"IPSR", 0x5 },
23125 {"epsr", 0x6 }, {"EPSR", 0x6 },
23126 {"iepsr", 0x7 }, {"IEPSR", 0x7 },
23127 {"msp", 0x8 }, {"MSP", 0x8 },
23128 {"psp", 0x9 }, {"PSP", 0x9 },
23129 {"msplim", 0xa }, {"MSPLIM", 0xa },
23130 {"psplim", 0xb }, {"PSPLIM", 0xb },
23131 {"primask", 0x10}, {"PRIMASK", 0x10},
23132 {"basepri", 0x11}, {"BASEPRI", 0x11},
23133 {"basepri_max", 0x12}, {"BASEPRI_MAX", 0x12},
23134 {"faultmask", 0x13}, {"FAULTMASK", 0x13},
23135 {"control", 0x14}, {"CONTROL", 0x14},
23136 {"msp_ns", 0x88}, {"MSP_NS", 0x88},
23137 {"psp_ns", 0x89}, {"PSP_NS", 0x89},
23138 {"msplim_ns", 0x8a}, {"MSPLIM_NS", 0x8a},
23139 {"psplim_ns", 0x8b}, {"PSPLIM_NS", 0x8b},
23140 {"primask_ns", 0x90}, {"PRIMASK_NS", 0x90},
23141 {"basepri_ns", 0x91}, {"BASEPRI_NS", 0x91},
23142 {"faultmask_ns", 0x93}, {"FAULTMASK_NS", 0x93},
23143 {"control_ns", 0x94}, {"CONTROL_NS", 0x94},
23144 {"sp_ns", 0x98}, {"SP_NS", 0x98 }
23147 /* Table of all shift-in-operand names. */
23148 static const struct asm_shift_name shift_names [] =
23150 { "asl", SHIFT_LSL }, { "ASL", SHIFT_LSL },
23151 { "lsl", SHIFT_LSL }, { "LSL", SHIFT_LSL },
23152 { "lsr", SHIFT_LSR }, { "LSR", SHIFT_LSR },
23153 { "asr", SHIFT_ASR }, { "ASR", SHIFT_ASR },
23154 { "ror", SHIFT_ROR }, { "ROR", SHIFT_ROR },
23155 { "rrx", SHIFT_RRX }, { "RRX", SHIFT_RRX },
23156 { "uxtw", SHIFT_UXTW}, { "UXTW", SHIFT_UXTW}
23159 /* Table of all explicit relocation names. */
23161 static struct reloc_entry reloc_names[] =
23163 { "got", BFD_RELOC_ARM_GOT32 }, { "GOT", BFD_RELOC_ARM_GOT32 },
23164 { "gotoff", BFD_RELOC_ARM_GOTOFF }, { "GOTOFF", BFD_RELOC_ARM_GOTOFF },
23165 { "plt", BFD_RELOC_ARM_PLT32 }, { "PLT", BFD_RELOC_ARM_PLT32 },
23166 { "target1", BFD_RELOC_ARM_TARGET1 }, { "TARGET1", BFD_RELOC_ARM_TARGET1 },
23167 { "target2", BFD_RELOC_ARM_TARGET2 }, { "TARGET2", BFD_RELOC_ARM_TARGET2 },
23168 { "sbrel", BFD_RELOC_ARM_SBREL32 }, { "SBREL", BFD_RELOC_ARM_SBREL32 },
23169 { "tlsgd", BFD_RELOC_ARM_TLS_GD32}, { "TLSGD", BFD_RELOC_ARM_TLS_GD32},
23170 { "tlsldm", BFD_RELOC_ARM_TLS_LDM32}, { "TLSLDM", BFD_RELOC_ARM_TLS_LDM32},
23171 { "tlsldo", BFD_RELOC_ARM_TLS_LDO32}, { "TLSLDO", BFD_RELOC_ARM_TLS_LDO32},
23172 { "gottpoff",BFD_RELOC_ARM_TLS_IE32}, { "GOTTPOFF",BFD_RELOC_ARM_TLS_IE32},
23173 { "tpoff", BFD_RELOC_ARM_TLS_LE32}, { "TPOFF", BFD_RELOC_ARM_TLS_LE32},
23174 { "got_prel", BFD_RELOC_ARM_GOT_PREL}, { "GOT_PREL", BFD_RELOC_ARM_GOT_PREL},
23175 { "tlsdesc", BFD_RELOC_ARM_TLS_GOTDESC},
23176 { "TLSDESC", BFD_RELOC_ARM_TLS_GOTDESC},
23177 { "tlscall", BFD_RELOC_ARM_TLS_CALL},
23178 { "TLSCALL", BFD_RELOC_ARM_TLS_CALL},
23179 { "tlsdescseq", BFD_RELOC_ARM_TLS_DESCSEQ},
23180 { "TLSDESCSEQ", BFD_RELOC_ARM_TLS_DESCSEQ},
23181 { "gotfuncdesc", BFD_RELOC_ARM_GOTFUNCDESC },
23182 { "GOTFUNCDESC", BFD_RELOC_ARM_GOTFUNCDESC },
23183 { "gotofffuncdesc", BFD_RELOC_ARM_GOTOFFFUNCDESC },
23184 { "GOTOFFFUNCDESC", BFD_RELOC_ARM_GOTOFFFUNCDESC },
23185 { "funcdesc", BFD_RELOC_ARM_FUNCDESC },
23186 { "FUNCDESC", BFD_RELOC_ARM_FUNCDESC },
23187 { "tlsgd_fdpic", BFD_RELOC_ARM_TLS_GD32_FDPIC }, { "TLSGD_FDPIC", BFD_RELOC_ARM_TLS_GD32_FDPIC },
23188 { "tlsldm_fdpic", BFD_RELOC_ARM_TLS_LDM32_FDPIC }, { "TLSLDM_FDPIC", BFD_RELOC_ARM_TLS_LDM32_FDPIC },
23189 { "gottpoff_fdpic", BFD_RELOC_ARM_TLS_IE32_FDPIC }, { "GOTTPOFF_FDIC", BFD_RELOC_ARM_TLS_IE32_FDPIC },
23193 /* Table of all conditional affixes. */
23194 static const struct asm_cond conds[] =
23198 {"cs", 0x2}, {"hs", 0x2},
23199 {"cc", 0x3}, {"ul", 0x3}, {"lo", 0x3},
23212 static const struct asm_cond vconds[] =
23218 #define UL_BARRIER(L,U,CODE,FEAT) \
23219 { L, CODE, ARM_FEATURE_CORE_LOW (FEAT) }, \
23220 { U, CODE, ARM_FEATURE_CORE_LOW (FEAT) }
23222 static struct asm_barrier_opt barrier_opt_names[] =
23224 UL_BARRIER ("sy", "SY", 0xf, ARM_EXT_BARRIER),
23225 UL_BARRIER ("st", "ST", 0xe, ARM_EXT_BARRIER),
23226 UL_BARRIER ("ld", "LD", 0xd, ARM_EXT_V8),
23227 UL_BARRIER ("ish", "ISH", 0xb, ARM_EXT_BARRIER),
23228 UL_BARRIER ("sh", "SH", 0xb, ARM_EXT_BARRIER),
23229 UL_BARRIER ("ishst", "ISHST", 0xa, ARM_EXT_BARRIER),
23230 UL_BARRIER ("shst", "SHST", 0xa, ARM_EXT_BARRIER),
23231 UL_BARRIER ("ishld", "ISHLD", 0x9, ARM_EXT_V8),
23232 UL_BARRIER ("un", "UN", 0x7, ARM_EXT_BARRIER),
23233 UL_BARRIER ("nsh", "NSH", 0x7, ARM_EXT_BARRIER),
23234 UL_BARRIER ("unst", "UNST", 0x6, ARM_EXT_BARRIER),
23235 UL_BARRIER ("nshst", "NSHST", 0x6, ARM_EXT_BARRIER),
23236 UL_BARRIER ("nshld", "NSHLD", 0x5, ARM_EXT_V8),
23237 UL_BARRIER ("osh", "OSH", 0x3, ARM_EXT_BARRIER),
23238 UL_BARRIER ("oshst", "OSHST", 0x2, ARM_EXT_BARRIER),
23239 UL_BARRIER ("oshld", "OSHLD", 0x1, ARM_EXT_V8)
23244 /* Table of ARM-format instructions. */
23246 /* Macros for gluing together operand strings. N.B. In all cases
23247 other than OPS0, the trailing OP_stop comes from default
23248 zero-initialization of the unspecified elements of the array. */
23249 #define OPS0() { OP_stop, }
23250 #define OPS1(a) { OP_##a, }
23251 #define OPS2(a,b) { OP_##a,OP_##b, }
23252 #define OPS3(a,b,c) { OP_##a,OP_##b,OP_##c, }
23253 #define OPS4(a,b,c,d) { OP_##a,OP_##b,OP_##c,OP_##d, }
23254 #define OPS5(a,b,c,d,e) { OP_##a,OP_##b,OP_##c,OP_##d,OP_##e, }
23255 #define OPS6(a,b,c,d,e,f) { OP_##a,OP_##b,OP_##c,OP_##d,OP_##e,OP_##f, }
23257 /* These macros are similar to the OPSn, but do not prepend the OP_ prefix.
23258 This is useful when mixing operands for ARM and THUMB, i.e. using the
23259 MIX_ARM_THUMB_OPERANDS macro.
23260 In order to use these macros, prefix the number of operands with _
23262 #define OPS_1(a) { a, }
23263 #define OPS_2(a,b) { a,b, }
23264 #define OPS_3(a,b,c) { a,b,c, }
23265 #define OPS_4(a,b,c,d) { a,b,c,d, }
23266 #define OPS_5(a,b,c,d,e) { a,b,c,d,e, }
23267 #define OPS_6(a,b,c,d,e,f) { a,b,c,d,e,f, }
23269 /* These macros abstract out the exact format of the mnemonic table and
23270 save some repeated characters. */
23272 /* The normal sort of mnemonic; has a Thumb variant; takes a conditional suffix. */
23273 #define TxCE(mnem, op, top, nops, ops, ae, te) \
23274 { mnem, OPS##nops ops, OT_csuffix, 0x##op, top, ARM_VARIANT, \
23275 THUMB_VARIANT, do_##ae, do_##te, 0 }
23277 /* Two variants of the above - TCE for a numeric Thumb opcode, tCE for
23278 a T_MNEM_xyz enumerator. */
23279 #define TCE(mnem, aop, top, nops, ops, ae, te) \
23280 TxCE (mnem, aop, 0x##top, nops, ops, ae, te)
23281 #define tCE(mnem, aop, top, nops, ops, ae, te) \
23282 TxCE (mnem, aop, T_MNEM##top, nops, ops, ae, te)
23284 /* Second most common sort of mnemonic: has a Thumb variant, takes a conditional
23285 infix after the third character. */
23286 #define TxC3(mnem, op, top, nops, ops, ae, te) \
23287 { mnem, OPS##nops ops, OT_cinfix3, 0x##op, top, ARM_VARIANT, \
23288 THUMB_VARIANT, do_##ae, do_##te, 0 }
23289 #define TxC3w(mnem, op, top, nops, ops, ae, te) \
23290 { mnem, OPS##nops ops, OT_cinfix3_deprecated, 0x##op, top, ARM_VARIANT, \
23291 THUMB_VARIANT, do_##ae, do_##te, 0 }
23292 #define TC3(mnem, aop, top, nops, ops, ae, te) \
23293 TxC3 (mnem, aop, 0x##top, nops, ops, ae, te)
23294 #define TC3w(mnem, aop, top, nops, ops, ae, te) \
23295 TxC3w (mnem, aop, 0x##top, nops, ops, ae, te)
23296 #define tC3(mnem, aop, top, nops, ops, ae, te) \
23297 TxC3 (mnem, aop, T_MNEM##top, nops, ops, ae, te)
23298 #define tC3w(mnem, aop, top, nops, ops, ae, te) \
23299 TxC3w (mnem, aop, T_MNEM##top, nops, ops, ae, te)
23301 /* Mnemonic that cannot be conditionalized. The ARM condition-code
23302 field is still 0xE. Many of the Thumb variants can be executed
23303 conditionally, so this is checked separately. */
23304 #define TUE(mnem, op, top, nops, ops, ae, te) \
23305 { mnem, OPS##nops ops, OT_unconditional, 0x##op, 0x##top, ARM_VARIANT, \
23306 THUMB_VARIANT, do_##ae, do_##te, 0 }
23308 /* Same as TUE but the encoding function for ARM and Thumb modes is the same.
23309 Used by mnemonics that have very minimal differences in the encoding for
23310 ARM and Thumb variants and can be handled in a common function. */
23311 #define TUEc(mnem, op, top, nops, ops, en) \
23312 { mnem, OPS##nops ops, OT_unconditional, 0x##op, 0x##top, ARM_VARIANT, \
23313 THUMB_VARIANT, do_##en, do_##en, 0 }
23315 /* Mnemonic that cannot be conditionalized, and bears 0xF in its ARM
23316 condition code field. */
23317 #define TUF(mnem, op, top, nops, ops, ae, te) \
23318 { mnem, OPS##nops ops, OT_unconditionalF, 0x##op, 0x##top, ARM_VARIANT, \
23319 THUMB_VARIANT, do_##ae, do_##te, 0 }
23321 /* ARM-only variants of all the above. */
23322 #define CE(mnem, op, nops, ops, ae) \
23323 { mnem, OPS##nops ops, OT_csuffix, 0x##op, 0x0, ARM_VARIANT, 0, do_##ae, NULL, 0 }
23325 #define C3(mnem, op, nops, ops, ae) \
23326 { #mnem, OPS##nops ops, OT_cinfix3, 0x##op, 0x0, ARM_VARIANT, 0, do_##ae, NULL, 0 }
23328 /* Thumb-only variants of TCE and TUE. */
23329 #define ToC(mnem, top, nops, ops, te) \
23330 { mnem, OPS##nops ops, OT_csuffix, 0x0, 0x##top, 0, THUMB_VARIANT, NULL, \
23333 #define ToU(mnem, top, nops, ops, te) \
23334 { mnem, OPS##nops ops, OT_unconditional, 0x0, 0x##top, 0, THUMB_VARIANT, \
23337 /* T_MNEM_xyz enumerator variants of ToC. */
23338 #define toC(mnem, top, nops, ops, te) \
23339 { mnem, OPS##nops ops, OT_csuffix, 0x0, T_MNEM##top, 0, THUMB_VARIANT, NULL, \
23342 /* T_MNEM_xyz enumerator variants of ToU. */
23343 #define toU(mnem, top, nops, ops, te) \
23344 { mnem, OPS##nops ops, OT_unconditional, 0x0, T_MNEM##top, 0, THUMB_VARIANT, \
23347 /* Legacy mnemonics that always have conditional infix after the third
23349 #define CL(mnem, op, nops, ops, ae) \
23350 { mnem, OPS##nops ops, OT_cinfix3_legacy, \
23351 0x##op, 0x0, ARM_VARIANT, 0, do_##ae, NULL, 0 }
23353 /* Coprocessor instructions. Isomorphic between Arm and Thumb-2. */
23354 #define cCE(mnem, op, nops, ops, ae) \
23355 { mnem, OPS##nops ops, OT_csuffix, 0x##op, 0xe##op, ARM_VARIANT, ARM_VARIANT, do_##ae, do_##ae, 0 }
23357 /* mov instructions that are shared between coprocessor and MVE. */
23358 #define mcCE(mnem, op, nops, ops, ae) \
23359 { #mnem, OPS##nops ops, OT_csuffix, 0x##op, 0xe##op, ARM_VARIANT, THUMB_VARIANT, do_##ae, do_##ae, 0 }
23361 /* Legacy coprocessor instructions where conditional infix and conditional
23362 suffix are ambiguous. For consistency this includes all FPA instructions,
23363 not just the potentially ambiguous ones. */
23364 #define cCL(mnem, op, nops, ops, ae) \
23365 { mnem, OPS##nops ops, OT_cinfix3_legacy, \
23366 0x##op, 0xe##op, ARM_VARIANT, ARM_VARIANT, do_##ae, do_##ae, 0 }
23368 /* Coprocessor, takes either a suffix or a position-3 infix
23369 (for an FPA corner case). */
23370 #define C3E(mnem, op, nops, ops, ae) \
23371 { mnem, OPS##nops ops, OT_csuf_or_in3, \
23372 0x##op, 0xe##op, ARM_VARIANT, ARM_VARIANT, do_##ae, do_##ae, 0 }
23374 #define xCM_(m1, m2, m3, op, nops, ops, ae) \
23375 { m1 #m2 m3, OPS##nops ops, \
23376 sizeof (#m2) == 1 ? OT_odd_infix_unc : OT_odd_infix_0 + sizeof (m1) - 1, \
23377 0x##op, 0x0, ARM_VARIANT, 0, do_##ae, NULL, 0 }
23379 #define CM(m1, m2, op, nops, ops, ae) \
23380 xCM_ (m1, , m2, op, nops, ops, ae), \
23381 xCM_ (m1, eq, m2, op, nops, ops, ae), \
23382 xCM_ (m1, ne, m2, op, nops, ops, ae), \
23383 xCM_ (m1, cs, m2, op, nops, ops, ae), \
23384 xCM_ (m1, hs, m2, op, nops, ops, ae), \
23385 xCM_ (m1, cc, m2, op, nops, ops, ae), \
23386 xCM_ (m1, ul, m2, op, nops, ops, ae), \
23387 xCM_ (m1, lo, m2, op, nops, ops, ae), \
23388 xCM_ (m1, mi, m2, op, nops, ops, ae), \
23389 xCM_ (m1, pl, m2, op, nops, ops, ae), \
23390 xCM_ (m1, vs, m2, op, nops, ops, ae), \
23391 xCM_ (m1, vc, m2, op, nops, ops, ae), \
23392 xCM_ (m1, hi, m2, op, nops, ops, ae), \
23393 xCM_ (m1, ls, m2, op, nops, ops, ae), \
23394 xCM_ (m1, ge, m2, op, nops, ops, ae), \
23395 xCM_ (m1, lt, m2, op, nops, ops, ae), \
23396 xCM_ (m1, gt, m2, op, nops, ops, ae), \
23397 xCM_ (m1, le, m2, op, nops, ops, ae), \
23398 xCM_ (m1, al, m2, op, nops, ops, ae)
23400 #define UE(mnem, op, nops, ops, ae) \
23401 { #mnem, OPS##nops ops, OT_unconditional, 0x##op, 0, ARM_VARIANT, 0, do_##ae, NULL, 0 }
23403 #define UF(mnem, op, nops, ops, ae) \
23404 { #mnem, OPS##nops ops, OT_unconditionalF, 0x##op, 0, ARM_VARIANT, 0, do_##ae, NULL, 0 }
23406 /* Neon data-processing. ARM versions are unconditional with cond=0xf.
23407 The Thumb and ARM variants are mostly the same (bits 0-23 and 24/28), so we
23408 use the same encoding function for each. */
23409 #define NUF(mnem, op, nops, ops, enc) \
23410 { #mnem, OPS##nops ops, OT_unconditionalF, 0x##op, 0x##op, \
23411 ARM_VARIANT, THUMB_VARIANT, do_##enc, do_##enc, 0 }
23413 /* Neon data processing, version which indirects through neon_enc_tab for
23414 the various overloaded versions of opcodes. */
23415 #define nUF(mnem, op, nops, ops, enc) \
23416 { #mnem, OPS##nops ops, OT_unconditionalF, N_MNEM##op, N_MNEM##op, \
23417 ARM_VARIANT, THUMB_VARIANT, do_##enc, do_##enc, 0 }
23419 /* Neon insn with conditional suffix for the ARM version, non-overloaded
23421 #define NCE_tag(mnem, op, nops, ops, enc, tag, mve_p) \
23422 { #mnem, OPS##nops ops, tag, 0x##op, 0x##op, ARM_VARIANT, \
23423 THUMB_VARIANT, do_##enc, do_##enc, mve_p }
23425 #define NCE(mnem, op, nops, ops, enc) \
23426 NCE_tag (mnem, op, nops, ops, enc, OT_csuffix, 0)
23428 #define NCEF(mnem, op, nops, ops, enc) \
23429 NCE_tag (mnem, op, nops, ops, enc, OT_csuffixF, 0)
23431 /* Neon insn with conditional suffix for the ARM version, overloaded types. */
23432 #define nCE_tag(mnem, op, nops, ops, enc, tag, mve_p) \
23433 { #mnem, OPS##nops ops, tag, N_MNEM##op, N_MNEM##op, \
23434 ARM_VARIANT, THUMB_VARIANT, do_##enc, do_##enc, mve_p }
23436 #define nCE(mnem, op, nops, ops, enc) \
23437 nCE_tag (mnem, op, nops, ops, enc, OT_csuffix, 0)
23439 #define nCEF(mnem, op, nops, ops, enc) \
23440 nCE_tag (mnem, op, nops, ops, enc, OT_csuffixF, 0)
23443 #define mCEF(mnem, op, nops, ops, enc) \
23444 { #mnem, OPS##nops ops, OT_csuffixF, M_MNEM##op, M_MNEM##op, \
23445 ARM_VARIANT, THUMB_VARIANT, do_##enc, do_##enc, 1 }
23448 /* nCEF but for MVE predicated instructions. */
23449 #define mnCEF(mnem, op, nops, ops, enc) \
23450 nCE_tag (mnem, op, nops, ops, enc, OT_csuffixF, 1)
23452 /* nCE but for MVE predicated instructions. */
23453 #define mnCE(mnem, op, nops, ops, enc) \
23454 nCE_tag (mnem, op, nops, ops, enc, OT_csuffix, 1)
23456 /* NUF but for potentially MVE predicated instructions. */
23457 #define MNUF(mnem, op, nops, ops, enc) \
23458 { #mnem, OPS##nops ops, OT_unconditionalF, 0x##op, 0x##op, \
23459 ARM_VARIANT, THUMB_VARIANT, do_##enc, do_##enc, 1 }
23461 /* nUF but for potentially MVE predicated instructions. */
23462 #define mnUF(mnem, op, nops, ops, enc) \
23463 { #mnem, OPS##nops ops, OT_unconditionalF, N_MNEM##op, N_MNEM##op, \
23464 ARM_VARIANT, THUMB_VARIANT, do_##enc, do_##enc, 1 }
23466 /* ToC but for potentially MVE predicated instructions. */
23467 #define mToC(mnem, top, nops, ops, te) \
23468 { mnem, OPS##nops ops, OT_csuffix, 0x0, 0x##top, 0, THUMB_VARIANT, NULL, \
23471 /* NCE but for MVE predicated instructions. */
23472 #define MNCE(mnem, op, nops, ops, enc) \
23473 NCE_tag (mnem, op, nops, ops, enc, OT_csuffix, 1)
23475 /* NCEF but for MVE predicated instructions. */
23476 #define MNCEF(mnem, op, nops, ops, enc) \
23477 NCE_tag (mnem, op, nops, ops, enc, OT_csuffixF, 1)
23480 static const struct asm_opcode insns[] =
23482 #define ARM_VARIANT & arm_ext_v1 /* Core ARM Instructions. */
23483 #define THUMB_VARIANT & arm_ext_v4t
23484 tCE("and", 0000000, _and, 3, (RR, oRR, SH), arit, t_arit3c),
23485 tC3("ands", 0100000, _ands, 3, (RR, oRR, SH), arit, t_arit3c),
23486 tCE("eor", 0200000, _eor, 3, (RR, oRR, SH), arit, t_arit3c),
23487 tC3("eors", 0300000, _eors, 3, (RR, oRR, SH), arit, t_arit3c),
23488 tCE("sub", 0400000, _sub, 3, (RR, oRR, SH), arit, t_add_sub),
23489 tC3("subs", 0500000, _subs, 3, (RR, oRR, SH), arit, t_add_sub),
23490 tCE("add", 0800000, _add, 3, (RR, oRR, SHG), arit, t_add_sub),
23491 tC3("adds", 0900000, _adds, 3, (RR, oRR, SHG), arit, t_add_sub),
23492 tCE("adc", 0a00000, _adc, 3, (RR, oRR, SH), arit, t_arit3c),
23493 tC3("adcs", 0b00000, _adcs, 3, (RR, oRR, SH), arit, t_arit3c),
23494 tCE("sbc", 0c00000, _sbc, 3, (RR, oRR, SH), arit, t_arit3),
23495 tC3("sbcs", 0d00000, _sbcs, 3, (RR, oRR, SH), arit, t_arit3),
23496 tCE("orr", 1800000, _orr, 3, (RR, oRR, SH), arit, t_arit3c),
23497 tC3("orrs", 1900000, _orrs, 3, (RR, oRR, SH), arit, t_arit3c),
23498 tCE("bic", 1c00000, _bic, 3, (RR, oRR, SH), arit, t_arit3),
23499 tC3("bics", 1d00000, _bics, 3, (RR, oRR, SH), arit, t_arit3),
23501 /* The p-variants of tst/cmp/cmn/teq (below) are the pre-V6 mechanism
23502 for setting PSR flag bits. They are obsolete in V6 and do not
23503 have Thumb equivalents. */
23504 tCE("tst", 1100000, _tst, 2, (RR, SH), cmp, t_mvn_tst),
23505 tC3w("tsts", 1100000, _tst, 2, (RR, SH), cmp, t_mvn_tst),
23506 CL("tstp", 110f000, 2, (RR, SH), cmp),
23507 tCE("cmp", 1500000, _cmp, 2, (RR, SH), cmp, t_mov_cmp),
23508 tC3w("cmps", 1500000, _cmp, 2, (RR, SH), cmp, t_mov_cmp),
23509 CL("cmpp", 150f000, 2, (RR, SH), cmp),
23510 tCE("cmn", 1700000, _cmn, 2, (RR, SH), cmp, t_mvn_tst),
23511 tC3w("cmns", 1700000, _cmn, 2, (RR, SH), cmp, t_mvn_tst),
23512 CL("cmnp", 170f000, 2, (RR, SH), cmp),
23514 tCE("mov", 1a00000, _mov, 2, (RR, SH), mov, t_mov_cmp),
23515 tC3("movs", 1b00000, _movs, 2, (RR, SHG), mov, t_mov_cmp),
23516 tCE("mvn", 1e00000, _mvn, 2, (RR, SH), mov, t_mvn_tst),
23517 tC3("mvns", 1f00000, _mvns, 2, (RR, SH), mov, t_mvn_tst),
23519 tCE("ldr", 4100000, _ldr, 2, (RR, ADDRGLDR),ldst, t_ldst),
23520 tC3("ldrb", 4500000, _ldrb, 2, (RRnpc_npcsp, ADDRGLDR),ldst, t_ldst),
23521 tCE("str", 4000000, _str, _2, (MIX_ARM_THUMB_OPERANDS (OP_RR,
23523 OP_ADDRGLDR),ldst, t_ldst),
23524 tC3("strb", 4400000, _strb, 2, (RRnpc_npcsp, ADDRGLDR),ldst, t_ldst),
23526 tCE("stm", 8800000, _stmia, 2, (RRw, REGLST), ldmstm, t_ldmstm),
23527 tC3("stmia", 8800000, _stmia, 2, (RRw, REGLST), ldmstm, t_ldmstm),
23528 tC3("stmea", 8800000, _stmia, 2, (RRw, REGLST), ldmstm, t_ldmstm),
23529 tCE("ldm", 8900000, _ldmia, 2, (RRw, REGLST), ldmstm, t_ldmstm),
23530 tC3("ldmia", 8900000, _ldmia, 2, (RRw, REGLST), ldmstm, t_ldmstm),
23531 tC3("ldmfd", 8900000, _ldmia, 2, (RRw, REGLST), ldmstm, t_ldmstm),
23533 tCE("b", a000000, _b, 1, (EXPr), branch, t_branch),
23534 TCE("bl", b000000, f000f800, 1, (EXPr), bl, t_branch23),
23537 tCE("adr", 28f0000, _adr, 2, (RR, EXP), adr, t_adr),
23538 C3(adrl, 28f0000, 2, (RR, EXP), adrl),
23539 tCE("nop", 1a00000, _nop, 1, (oI255c), nop, t_nop),
23540 tCE("udf", 7f000f0, _udf, 1, (oIffffb), bkpt, t_udf),
23542 /* Thumb-compatibility pseudo ops. */
23543 tCE("lsl", 1a00000, _lsl, 3, (RR, oRR, SH), shift, t_shift),
23544 tC3("lsls", 1b00000, _lsls, 3, (RR, oRR, SH), shift, t_shift),
23545 tCE("lsr", 1a00020, _lsr, 3, (RR, oRR, SH), shift, t_shift),
23546 tC3("lsrs", 1b00020, _lsrs, 3, (RR, oRR, SH), shift, t_shift),
23547 tCE("asr", 1a00040, _asr, 3, (RR, oRR, SH), shift, t_shift),
23548 tC3("asrs", 1b00040, _asrs, 3, (RR, oRR, SH), shift, t_shift),
23549 tCE("ror", 1a00060, _ror, 3, (RR, oRR, SH), shift, t_shift),
23550 tC3("rors", 1b00060, _rors, 3, (RR, oRR, SH), shift, t_shift),
23551 tCE("neg", 2600000, _neg, 2, (RR, RR), rd_rn, t_neg),
23552 tC3("negs", 2700000, _negs, 2, (RR, RR), rd_rn, t_neg),
23553 tCE("push", 92d0000, _push, 1, (REGLST), push_pop, t_push_pop),
23554 tCE("pop", 8bd0000, _pop, 1, (REGLST), push_pop, t_push_pop),
23556 /* These may simplify to neg. */
23557 TCE("rsb", 0600000, ebc00000, 3, (RR, oRR, SH), arit, t_rsb),
23558 TC3("rsbs", 0700000, ebd00000, 3, (RR, oRR, SH), arit, t_rsb),
23560 #undef THUMB_VARIANT
23561 #define THUMB_VARIANT & arm_ext_os
23563 TCE("swi", f000000, df00, 1, (EXPi), swi, t_swi),
23564 TCE("svc", f000000, df00, 1, (EXPi), swi, t_swi),
23566 #undef THUMB_VARIANT
23567 #define THUMB_VARIANT & arm_ext_v6
23569 TCE("cpy", 1a00000, 4600, 2, (RR, RR), rd_rm, t_cpy),
23571 /* V1 instructions with no Thumb analogue prior to V6T2. */
23572 #undef THUMB_VARIANT
23573 #define THUMB_VARIANT & arm_ext_v6t2
23575 TCE("teq", 1300000, ea900f00, 2, (RR, SH), cmp, t_mvn_tst),
23576 TC3w("teqs", 1300000, ea900f00, 2, (RR, SH), cmp, t_mvn_tst),
23577 CL("teqp", 130f000, 2, (RR, SH), cmp),
23579 TC3("ldrt", 4300000, f8500e00, 2, (RRnpc_npcsp, ADDR),ldstt, t_ldstt),
23580 TC3("ldrbt", 4700000, f8100e00, 2, (RRnpc_npcsp, ADDR),ldstt, t_ldstt),
23581 TC3("strt", 4200000, f8400e00, 2, (RR_npcsp, ADDR), ldstt, t_ldstt),
23582 TC3("strbt", 4600000, f8000e00, 2, (RRnpc_npcsp, ADDR),ldstt, t_ldstt),
23584 TC3("stmdb", 9000000, e9000000, 2, (RRw, REGLST), ldmstm, t_ldmstm),
23585 TC3("stmfd", 9000000, e9000000, 2, (RRw, REGLST), ldmstm, t_ldmstm),
23587 TC3("ldmdb", 9100000, e9100000, 2, (RRw, REGLST), ldmstm, t_ldmstm),
23588 TC3("ldmea", 9100000, e9100000, 2, (RRw, REGLST), ldmstm, t_ldmstm),
23590 /* V1 instructions with no Thumb analogue at all. */
23591 CE("rsc", 0e00000, 3, (RR, oRR, SH), arit),
23592 C3(rscs, 0f00000, 3, (RR, oRR, SH), arit),
23594 C3(stmib, 9800000, 2, (RRw, REGLST), ldmstm),
23595 C3(stmfa, 9800000, 2, (RRw, REGLST), ldmstm),
23596 C3(stmda, 8000000, 2, (RRw, REGLST), ldmstm),
23597 C3(stmed, 8000000, 2, (RRw, REGLST), ldmstm),
23598 C3(ldmib, 9900000, 2, (RRw, REGLST), ldmstm),
23599 C3(ldmed, 9900000, 2, (RRw, REGLST), ldmstm),
23600 C3(ldmda, 8100000, 2, (RRw, REGLST), ldmstm),
23601 C3(ldmfa, 8100000, 2, (RRw, REGLST), ldmstm),
23604 #define ARM_VARIANT & arm_ext_v2 /* ARM 2 - multiplies. */
23605 #undef THUMB_VARIANT
23606 #define THUMB_VARIANT & arm_ext_v4t
23608 tCE("mul", 0000090, _mul, 3, (RRnpc, RRnpc, oRR), mul, t_mul),
23609 tC3("muls", 0100090, _muls, 3, (RRnpc, RRnpc, oRR), mul, t_mul),
23611 #undef THUMB_VARIANT
23612 #define THUMB_VARIANT & arm_ext_v6t2
23614 TCE("mla", 0200090, fb000000, 4, (RRnpc, RRnpc, RRnpc, RRnpc), mlas, t_mla),
23615 C3(mlas, 0300090, 4, (RRnpc, RRnpc, RRnpc, RRnpc), mlas),
23617 /* Generic coprocessor instructions. */
23618 TCE("cdp", e000000, ee000000, 6, (RCP, I15b, RCN, RCN, RCN, oI7b), cdp, cdp),
23619 TCE("ldc", c100000, ec100000, 3, (RCP, RCN, ADDRGLDC), lstc, lstc),
23620 TC3("ldcl", c500000, ec500000, 3, (RCP, RCN, ADDRGLDC), lstc, lstc),
23621 TCE("stc", c000000, ec000000, 3, (RCP, RCN, ADDRGLDC), lstc, lstc),
23622 TC3("stcl", c400000, ec400000, 3, (RCP, RCN, ADDRGLDC), lstc, lstc),
23623 TCE("mcr", e000010, ee000010, 6, (RCP, I7b, RR, RCN, RCN, oI7b), co_reg, co_reg),
23624 TCE("mrc", e100010, ee100010, 6, (RCP, I7b, APSR_RR, RCN, RCN, oI7b), co_reg, co_reg),
23627 #define ARM_VARIANT & arm_ext_v2s /* ARM 3 - swp instructions. */
23629 CE("swp", 1000090, 3, (RRnpc, RRnpc, RRnpcb), rd_rm_rn),
23630 C3(swpb, 1400090, 3, (RRnpc, RRnpc, RRnpcb), rd_rm_rn),
23633 #define ARM_VARIANT & arm_ext_v3 /* ARM 6 Status register instructions. */
23634 #undef THUMB_VARIANT
23635 #define THUMB_VARIANT & arm_ext_msr
23637 TCE("mrs", 1000000, f3e08000, 2, (RRnpc, rPSR), mrs, t_mrs),
23638 TCE("msr", 120f000, f3808000, 2, (wPSR, RR_EXi), msr, t_msr),
23641 #define ARM_VARIANT & arm_ext_v3m /* ARM 7M long multiplies. */
23642 #undef THUMB_VARIANT
23643 #define THUMB_VARIANT & arm_ext_v6t2
23645 TCE("smull", 0c00090, fb800000, 4, (RRnpc, RRnpc, RRnpc, RRnpc), mull, t_mull),
23646 CM("smull","s", 0d00090, 4, (RRnpc, RRnpc, RRnpc, RRnpc), mull),
23647 TCE("umull", 0800090, fba00000, 4, (RRnpc, RRnpc, RRnpc, RRnpc), mull, t_mull),
23648 CM("umull","s", 0900090, 4, (RRnpc, RRnpc, RRnpc, RRnpc), mull),
23649 TCE("smlal", 0e00090, fbc00000, 4, (RRnpc, RRnpc, RRnpc, RRnpc), mull, t_mull),
23650 CM("smlal","s", 0f00090, 4, (RRnpc, RRnpc, RRnpc, RRnpc), mull),
23651 TCE("umlal", 0a00090, fbe00000, 4, (RRnpc, RRnpc, RRnpc, RRnpc), mull, t_mull),
23652 CM("umlal","s", 0b00090, 4, (RRnpc, RRnpc, RRnpc, RRnpc), mull),
23655 #define ARM_VARIANT & arm_ext_v4 /* ARM Architecture 4. */
23656 #undef THUMB_VARIANT
23657 #define THUMB_VARIANT & arm_ext_v4t
23659 tC3("ldrh", 01000b0, _ldrh, 2, (RRnpc_npcsp, ADDRGLDRS), ldstv4, t_ldst),
23660 tC3("strh", 00000b0, _strh, 2, (RRnpc_npcsp, ADDRGLDRS), ldstv4, t_ldst),
23661 tC3("ldrsh", 01000f0, _ldrsh, 2, (RRnpc_npcsp, ADDRGLDRS), ldstv4, t_ldst),
23662 tC3("ldrsb", 01000d0, _ldrsb, 2, (RRnpc_npcsp, ADDRGLDRS), ldstv4, t_ldst),
23663 tC3("ldsh", 01000f0, _ldrsh, 2, (RRnpc_npcsp, ADDRGLDRS), ldstv4, t_ldst),
23664 tC3("ldsb", 01000d0, _ldrsb, 2, (RRnpc_npcsp, ADDRGLDRS), ldstv4, t_ldst),
23667 #define ARM_VARIANT & arm_ext_v4t_5
23669 /* ARM Architecture 4T. */
23670 /* Note: bx (and blx) are required on V5, even if the processor does
23671 not support Thumb. */
23672 TCE("bx", 12fff10, 4700, 1, (RR), bx, t_bx),
23675 #define ARM_VARIANT & arm_ext_v5 /* ARM Architecture 5T. */
23676 #undef THUMB_VARIANT
23677 #define THUMB_VARIANT & arm_ext_v5t
23679 /* Note: blx has 2 variants; the .value coded here is for
23680 BLX(2). Only this variant has conditional execution. */
23681 TCE("blx", 12fff30, 4780, 1, (RR_EXr), blx, t_blx),
23682 TUE("bkpt", 1200070, be00, 1, (oIffffb), bkpt, t_bkpt),
23684 #undef THUMB_VARIANT
23685 #define THUMB_VARIANT & arm_ext_v6t2
23687 TCE("clz", 16f0f10, fab0f080, 2, (RRnpc, RRnpc), rd_rm, t_clz),
23688 TUF("ldc2", c100000, fc100000, 3, (RCP, RCN, ADDRGLDC), lstc, lstc),
23689 TUF("ldc2l", c500000, fc500000, 3, (RCP, RCN, ADDRGLDC), lstc, lstc),
23690 TUF("stc2", c000000, fc000000, 3, (RCP, RCN, ADDRGLDC), lstc, lstc),
23691 TUF("stc2l", c400000, fc400000, 3, (RCP, RCN, ADDRGLDC), lstc, lstc),
23692 TUF("cdp2", e000000, fe000000, 6, (RCP, I15b, RCN, RCN, RCN, oI7b), cdp, cdp),
23693 TUF("mcr2", e000010, fe000010, 6, (RCP, I7b, RR, RCN, RCN, oI7b), co_reg, co_reg),
23694 TUF("mrc2", e100010, fe100010, 6, (RCP, I7b, RR, RCN, RCN, oI7b), co_reg, co_reg),
23697 #define ARM_VARIANT & arm_ext_v5exp /* ARM Architecture 5TExP. */
23698 #undef THUMB_VARIANT
23699 #define THUMB_VARIANT & arm_ext_v5exp
23701 TCE("smlabb", 1000080, fb100000, 4, (RRnpc, RRnpc, RRnpc, RRnpc), smla, t_mla),
23702 TCE("smlatb", 10000a0, fb100020, 4, (RRnpc, RRnpc, RRnpc, RRnpc), smla, t_mla),
23703 TCE("smlabt", 10000c0, fb100010, 4, (RRnpc, RRnpc, RRnpc, RRnpc), smla, t_mla),
23704 TCE("smlatt", 10000e0, fb100030, 4, (RRnpc, RRnpc, RRnpc, RRnpc), smla, t_mla),
23706 TCE("smlawb", 1200080, fb300000, 4, (RRnpc, RRnpc, RRnpc, RRnpc), smla, t_mla),
23707 TCE("smlawt", 12000c0, fb300010, 4, (RRnpc, RRnpc, RRnpc, RRnpc), smla, t_mla),
23709 TCE("smlalbb", 1400080, fbc00080, 4, (RRnpc, RRnpc, RRnpc, RRnpc), smlal, t_mlal),
23710 TCE("smlaltb", 14000a0, fbc000a0, 4, (RRnpc, RRnpc, RRnpc, RRnpc), smlal, t_mlal),
23711 TCE("smlalbt", 14000c0, fbc00090, 4, (RRnpc, RRnpc, RRnpc, RRnpc), smlal, t_mlal),
23712 TCE("smlaltt", 14000e0, fbc000b0, 4, (RRnpc, RRnpc, RRnpc, RRnpc), smlal, t_mlal),
23714 TCE("smulbb", 1600080, fb10f000, 3, (RRnpc, RRnpc, RRnpc), smul, t_simd),
23715 TCE("smultb", 16000a0, fb10f020, 3, (RRnpc, RRnpc, RRnpc), smul, t_simd),
23716 TCE("smulbt", 16000c0, fb10f010, 3, (RRnpc, RRnpc, RRnpc), smul, t_simd),
23717 TCE("smultt", 16000e0, fb10f030, 3, (RRnpc, RRnpc, RRnpc), smul, t_simd),
23719 TCE("smulwb", 12000a0, fb30f000, 3, (RRnpc, RRnpc, RRnpc), smul, t_simd),
23720 TCE("smulwt", 12000e0, fb30f010, 3, (RRnpc, RRnpc, RRnpc), smul, t_simd),
23722 TCE("qadd", 1000050, fa80f080, 3, (RRnpc, RRnpc, RRnpc), rd_rm_rn, t_simd2),
23723 TCE("qdadd", 1400050, fa80f090, 3, (RRnpc, RRnpc, RRnpc), rd_rm_rn, t_simd2),
23724 TCE("qsub", 1200050, fa80f0a0, 3, (RRnpc, RRnpc, RRnpc), rd_rm_rn, t_simd2),
23725 TCE("qdsub", 1600050, fa80f0b0, 3, (RRnpc, RRnpc, RRnpc), rd_rm_rn, t_simd2),
23728 #define ARM_VARIANT & arm_ext_v5e /* ARM Architecture 5TE. */
23729 #undef THUMB_VARIANT
23730 #define THUMB_VARIANT & arm_ext_v6t2
23732 TUF("pld", 450f000, f810f000, 1, (ADDR), pld, t_pld),
23733 TC3("ldrd", 00000d0, e8500000, 3, (RRnpc_npcsp, oRRnpc_npcsp, ADDRGLDRS),
23735 TC3("strd", 00000f0, e8400000, 3, (RRnpc_npcsp, oRRnpc_npcsp,
23736 ADDRGLDRS), ldrd, t_ldstd),
23738 TCE("mcrr", c400000, ec400000, 5, (RCP, I15b, RRnpc, RRnpc, RCN), co_reg2c, co_reg2c),
23739 TCE("mrrc", c500000, ec500000, 5, (RCP, I15b, RRnpc, RRnpc, RCN), co_reg2c, co_reg2c),
23742 #define ARM_VARIANT & arm_ext_v5j /* ARM Architecture 5TEJ. */
23744 TCE("bxj", 12fff20, f3c08f00, 1, (RR), bxj, t_bxj),
23747 #define ARM_VARIANT & arm_ext_v6 /* ARM V6. */
23748 #undef THUMB_VARIANT
23749 #define THUMB_VARIANT & arm_ext_v6
23751 TUF("cpsie", 1080000, b660, 2, (CPSF, oI31b), cpsi, t_cpsi),
23752 TUF("cpsid", 10c0000, b670, 2, (CPSF, oI31b), cpsi, t_cpsi),
23753 tCE("rev", 6bf0f30, _rev, 2, (RRnpc, RRnpc), rd_rm, t_rev),
23754 tCE("rev16", 6bf0fb0, _rev16, 2, (RRnpc, RRnpc), rd_rm, t_rev),
23755 tCE("revsh", 6ff0fb0, _revsh, 2, (RRnpc, RRnpc), rd_rm, t_rev),
23756 tCE("sxth", 6bf0070, _sxth, 3, (RRnpc, RRnpc, oROR), sxth, t_sxth),
23757 tCE("uxth", 6ff0070, _uxth, 3, (RRnpc, RRnpc, oROR), sxth, t_sxth),
23758 tCE("sxtb", 6af0070, _sxtb, 3, (RRnpc, RRnpc, oROR), sxth, t_sxth),
23759 tCE("uxtb", 6ef0070, _uxtb, 3, (RRnpc, RRnpc, oROR), sxth, t_sxth),
23760 TUF("setend", 1010000, b650, 1, (ENDI), setend, t_setend),
23762 #undef THUMB_VARIANT
23763 #define THUMB_VARIANT & arm_ext_v6t2_v8m
23765 TCE("ldrex", 1900f9f, e8500f00, 2, (RRnpc_npcsp, ADDR), ldrex, t_ldrex),
23766 TCE("strex", 1800f90, e8400000, 3, (RRnpc_npcsp, RRnpc_npcsp, ADDR),
23768 #undef THUMB_VARIANT
23769 #define THUMB_VARIANT & arm_ext_v6t2
23771 TUF("mcrr2", c400000, fc400000, 5, (RCP, I15b, RRnpc, RRnpc, RCN), co_reg2c, co_reg2c),
23772 TUF("mrrc2", c500000, fc500000, 5, (RCP, I15b, RRnpc, RRnpc, RCN), co_reg2c, co_reg2c),
23774 TCE("ssat", 6a00010, f3000000, 4, (RRnpc, I32, RRnpc, oSHllar),ssat, t_ssat),
23775 TCE("usat", 6e00010, f3800000, 4, (RRnpc, I31, RRnpc, oSHllar),usat, t_usat),
23777 /* ARM V6 not included in V7M. */
23778 #undef THUMB_VARIANT
23779 #define THUMB_VARIANT & arm_ext_v6_notm
23780 TUF("rfeia", 8900a00, e990c000, 1, (RRw), rfe, rfe),
23781 TUF("rfe", 8900a00, e990c000, 1, (RRw), rfe, rfe),
23782 UF(rfeib, 9900a00, 1, (RRw), rfe),
23783 UF(rfeda, 8100a00, 1, (RRw), rfe),
23784 TUF("rfedb", 9100a00, e810c000, 1, (RRw), rfe, rfe),
23785 TUF("rfefd", 8900a00, e990c000, 1, (RRw), rfe, rfe),
23786 UF(rfefa, 8100a00, 1, (RRw), rfe),
23787 TUF("rfeea", 9100a00, e810c000, 1, (RRw), rfe, rfe),
23788 UF(rfeed, 9900a00, 1, (RRw), rfe),
23789 TUF("srsia", 8c00500, e980c000, 2, (oRRw, I31w), srs, srs),
23790 TUF("srs", 8c00500, e980c000, 2, (oRRw, I31w), srs, srs),
23791 TUF("srsea", 8c00500, e980c000, 2, (oRRw, I31w), srs, srs),
23792 UF(srsib, 9c00500, 2, (oRRw, I31w), srs),
23793 UF(srsfa, 9c00500, 2, (oRRw, I31w), srs),
23794 UF(srsda, 8400500, 2, (oRRw, I31w), srs),
23795 UF(srsed, 8400500, 2, (oRRw, I31w), srs),
23796 TUF("srsdb", 9400500, e800c000, 2, (oRRw, I31w), srs, srs),
23797 TUF("srsfd", 9400500, e800c000, 2, (oRRw, I31w), srs, srs),
23798 TUF("cps", 1020000, f3af8100, 1, (I31b), imm0, t_cps),
23800 /* ARM V6 not included in V7M (eg. integer SIMD). */
23801 #undef THUMB_VARIANT
23802 #define THUMB_VARIANT & arm_ext_v6_dsp
23803 TCE("pkhbt", 6800010, eac00000, 4, (RRnpc, RRnpc, RRnpc, oSHll), pkhbt, t_pkhbt),
23804 TCE("pkhtb", 6800050, eac00020, 4, (RRnpc, RRnpc, RRnpc, oSHar), pkhtb, t_pkhtb),
23805 TCE("qadd16", 6200f10, fa90f010, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
23806 TCE("qadd8", 6200f90, fa80f010, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
23807 TCE("qasx", 6200f30, faa0f010, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
23808 /* Old name for QASX. */
23809 TCE("qaddsubx",6200f30, faa0f010, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
23810 TCE("qsax", 6200f50, fae0f010, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
23811 /* Old name for QSAX. */
23812 TCE("qsubaddx",6200f50, fae0f010, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
23813 TCE("qsub16", 6200f70, fad0f010, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
23814 TCE("qsub8", 6200ff0, fac0f010, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
23815 TCE("sadd16", 6100f10, fa90f000, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
23816 TCE("sadd8", 6100f90, fa80f000, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
23817 TCE("sasx", 6100f30, faa0f000, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
23818 /* Old name for SASX. */
23819 TCE("saddsubx",6100f30, faa0f000, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
23820 TCE("shadd16", 6300f10, fa90f020, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
23821 TCE("shadd8", 6300f90, fa80f020, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
23822 TCE("shasx", 6300f30, faa0f020, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
23823 /* Old name for SHASX. */
23824 TCE("shaddsubx", 6300f30, faa0f020, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
23825 TCE("shsax", 6300f50, fae0f020, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
23826 /* Old name for SHSAX. */
23827 TCE("shsubaddx", 6300f50, fae0f020, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
23828 TCE("shsub16", 6300f70, fad0f020, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
23829 TCE("shsub8", 6300ff0, fac0f020, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
23830 TCE("ssax", 6100f50, fae0f000, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
23831 /* Old name for SSAX. */
23832 TCE("ssubaddx",6100f50, fae0f000, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
23833 TCE("ssub16", 6100f70, fad0f000, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
23834 TCE("ssub8", 6100ff0, fac0f000, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
23835 TCE("uadd16", 6500f10, fa90f040, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
23836 TCE("uadd8", 6500f90, fa80f040, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
23837 TCE("uasx", 6500f30, faa0f040, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
23838 /* Old name for UASX. */
23839 TCE("uaddsubx",6500f30, faa0f040, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
23840 TCE("uhadd16", 6700f10, fa90f060, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
23841 TCE("uhadd8", 6700f90, fa80f060, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
23842 TCE("uhasx", 6700f30, faa0f060, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
23843 /* Old name for UHASX. */
23844 TCE("uhaddsubx", 6700f30, faa0f060, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
23845 TCE("uhsax", 6700f50, fae0f060, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
23846 /* Old name for UHSAX. */
23847 TCE("uhsubaddx", 6700f50, fae0f060, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
23848 TCE("uhsub16", 6700f70, fad0f060, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
23849 TCE("uhsub8", 6700ff0, fac0f060, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
23850 TCE("uqadd16", 6600f10, fa90f050, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
23851 TCE("uqadd8", 6600f90, fa80f050, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
23852 TCE("uqasx", 6600f30, faa0f050, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
23853 /* Old name for UQASX. */
23854 TCE("uqaddsubx", 6600f30, faa0f050, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
23855 TCE("uqsax", 6600f50, fae0f050, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
23856 /* Old name for UQSAX. */
23857 TCE("uqsubaddx", 6600f50, fae0f050, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
23858 TCE("uqsub16", 6600f70, fad0f050, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
23859 TCE("uqsub8", 6600ff0, fac0f050, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
23860 TCE("usub16", 6500f70, fad0f040, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
23861 TCE("usax", 6500f50, fae0f040, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
23862 /* Old name for USAX. */
23863 TCE("usubaddx",6500f50, fae0f040, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
23864 TCE("usub8", 6500ff0, fac0f040, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
23865 TCE("sxtah", 6b00070, fa00f080, 4, (RRnpc, RRnpc, RRnpc, oROR), sxtah, t_sxtah),
23866 TCE("sxtab16", 6800070, fa20f080, 4, (RRnpc, RRnpc, RRnpc, oROR), sxtah, t_sxtah),
23867 TCE("sxtab", 6a00070, fa40f080, 4, (RRnpc, RRnpc, RRnpc, oROR), sxtah, t_sxtah),
23868 TCE("sxtb16", 68f0070, fa2ff080, 3, (RRnpc, RRnpc, oROR), sxth, t_sxth),
23869 TCE("uxtah", 6f00070, fa10f080, 4, (RRnpc, RRnpc, RRnpc, oROR), sxtah, t_sxtah),
23870 TCE("uxtab16", 6c00070, fa30f080, 4, (RRnpc, RRnpc, RRnpc, oROR), sxtah, t_sxtah),
23871 TCE("uxtab", 6e00070, fa50f080, 4, (RRnpc, RRnpc, RRnpc, oROR), sxtah, t_sxtah),
23872 TCE("uxtb16", 6cf0070, fa3ff080, 3, (RRnpc, RRnpc, oROR), sxth, t_sxth),
23873 TCE("sel", 6800fb0, faa0f080, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
23874 TCE("smlad", 7000010, fb200000, 4, (RRnpc, RRnpc, RRnpc, RRnpc),smla, t_mla),
23875 TCE("smladx", 7000030, fb200010, 4, (RRnpc, RRnpc, RRnpc, RRnpc),smla, t_mla),
23876 TCE("smlald", 7400010, fbc000c0, 4, (RRnpc, RRnpc, RRnpc, RRnpc),smlal,t_mlal),
23877 TCE("smlaldx", 7400030, fbc000d0, 4, (RRnpc, RRnpc, RRnpc, RRnpc),smlal,t_mlal),
23878 TCE("smlsd", 7000050, fb400000, 4, (RRnpc, RRnpc, RRnpc, RRnpc),smla, t_mla),
23879 TCE("smlsdx", 7000070, fb400010, 4, (RRnpc, RRnpc, RRnpc, RRnpc),smla, t_mla),
23880 TCE("smlsld", 7400050, fbd000c0, 4, (RRnpc, RRnpc, RRnpc, RRnpc),smlal,t_mlal),
23881 TCE("smlsldx", 7400070, fbd000d0, 4, (RRnpc, RRnpc, RRnpc, RRnpc),smlal,t_mlal),
23882 TCE("smmla", 7500010, fb500000, 4, (RRnpc, RRnpc, RRnpc, RRnpc),smla, t_mla),
23883 TCE("smmlar", 7500030, fb500010, 4, (RRnpc, RRnpc, RRnpc, RRnpc),smla, t_mla),
23884 TCE("smmls", 75000d0, fb600000, 4, (RRnpc, RRnpc, RRnpc, RRnpc),smla, t_mla),
23885 TCE("smmlsr", 75000f0, fb600010, 4, (RRnpc, RRnpc, RRnpc, RRnpc),smla, t_mla),
23886 TCE("smmul", 750f010, fb50f000, 3, (RRnpc, RRnpc, RRnpc), smul, t_simd),
23887 TCE("smmulr", 750f030, fb50f010, 3, (RRnpc, RRnpc, RRnpc), smul, t_simd),
23888 TCE("smuad", 700f010, fb20f000, 3, (RRnpc, RRnpc, RRnpc), smul, t_simd),
23889 TCE("smuadx", 700f030, fb20f010, 3, (RRnpc, RRnpc, RRnpc), smul, t_simd),
23890 TCE("smusd", 700f050, fb40f000, 3, (RRnpc, RRnpc, RRnpc), smul, t_simd),
23891 TCE("smusdx", 700f070, fb40f010, 3, (RRnpc, RRnpc, RRnpc), smul, t_simd),
23892 TCE("ssat16", 6a00f30, f3200000, 3, (RRnpc, I16, RRnpc), ssat16, t_ssat16),
23893 TCE("umaal", 0400090, fbe00060, 4, (RRnpc, RRnpc, RRnpc, RRnpc),smlal, t_mlal),
23894 TCE("usad8", 780f010, fb70f000, 3, (RRnpc, RRnpc, RRnpc), smul, t_simd),
23895 TCE("usada8", 7800010, fb700000, 4, (RRnpc, RRnpc, RRnpc, RRnpc),smla, t_mla),
23896 TCE("usat16", 6e00f30, f3a00000, 3, (RRnpc, I15, RRnpc), usat16, t_usat16),
23899 #define ARM_VARIANT & arm_ext_v6k_v6t2
23900 #undef THUMB_VARIANT
23901 #define THUMB_VARIANT & arm_ext_v6k_v6t2
23903 tCE("yield", 320f001, _yield, 0, (), noargs, t_hint),
23904 tCE("wfe", 320f002, _wfe, 0, (), noargs, t_hint),
23905 tCE("wfi", 320f003, _wfi, 0, (), noargs, t_hint),
23906 tCE("sev", 320f004, _sev, 0, (), noargs, t_hint),
23908 #undef THUMB_VARIANT
23909 #define THUMB_VARIANT & arm_ext_v6_notm
23910 TCE("ldrexd", 1b00f9f, e8d0007f, 3, (RRnpc_npcsp, oRRnpc_npcsp, RRnpcb),
23912 TCE("strexd", 1a00f90, e8c00070, 4, (RRnpc_npcsp, RRnpc_npcsp, oRRnpc_npcsp,
23913 RRnpcb), strexd, t_strexd),
23915 #undef THUMB_VARIANT
23916 #define THUMB_VARIANT & arm_ext_v6t2_v8m
23917 TCE("ldrexb", 1d00f9f, e8d00f4f, 2, (RRnpc_npcsp,RRnpcb),
23919 TCE("ldrexh", 1f00f9f, e8d00f5f, 2, (RRnpc_npcsp, RRnpcb),
23921 TCE("strexb", 1c00f90, e8c00f40, 3, (RRnpc_npcsp, RRnpc_npcsp, ADDR),
23923 TCE("strexh", 1e00f90, e8c00f50, 3, (RRnpc_npcsp, RRnpc_npcsp, ADDR),
23925 TUF("clrex", 57ff01f, f3bf8f2f, 0, (), noargs, noargs),
23928 #define ARM_VARIANT & arm_ext_sec
23929 #undef THUMB_VARIANT
23930 #define THUMB_VARIANT & arm_ext_sec
23932 TCE("smc", 1600070, f7f08000, 1, (EXPi), smc, t_smc),
23935 #define ARM_VARIANT & arm_ext_virt
23936 #undef THUMB_VARIANT
23937 #define THUMB_VARIANT & arm_ext_virt
23939 TCE("hvc", 1400070, f7e08000, 1, (EXPi), hvc, t_hvc),
23940 TCE("eret", 160006e, f3de8f00, 0, (), noargs, noargs),
23943 #define ARM_VARIANT & arm_ext_pan
23944 #undef THUMB_VARIANT
23945 #define THUMB_VARIANT & arm_ext_pan
23947 TUF("setpan", 1100000, b610, 1, (I7), setpan, t_setpan),
23950 #define ARM_VARIANT & arm_ext_v6t2
23951 #undef THUMB_VARIANT
23952 #define THUMB_VARIANT & arm_ext_v6t2
23954 TCE("bfc", 7c0001f, f36f0000, 3, (RRnpc, I31, I32), bfc, t_bfc),
23955 TCE("bfi", 7c00010, f3600000, 4, (RRnpc, RRnpc_I0, I31, I32), bfi, t_bfi),
23956 TCE("sbfx", 7a00050, f3400000, 4, (RR, RR, I31, I32), bfx, t_bfx),
23957 TCE("ubfx", 7e00050, f3c00000, 4, (RR, RR, I31, I32), bfx, t_bfx),
23959 TCE("mls", 0600090, fb000010, 4, (RRnpc, RRnpc, RRnpc, RRnpc), mlas, t_mla),
23960 TCE("rbit", 6ff0f30, fa90f0a0, 2, (RR, RR), rd_rm, t_rbit),
23962 TC3("ldrht", 03000b0, f8300e00, 2, (RRnpc_npcsp, ADDR), ldsttv4, t_ldstt),
23963 TC3("ldrsht", 03000f0, f9300e00, 2, (RRnpc_npcsp, ADDR), ldsttv4, t_ldstt),
23964 TC3("ldrsbt", 03000d0, f9100e00, 2, (RRnpc_npcsp, ADDR), ldsttv4, t_ldstt),
23965 TC3("strht", 02000b0, f8200e00, 2, (RRnpc_npcsp, ADDR), ldsttv4, t_ldstt),
23968 #define ARM_VARIANT & arm_ext_v3
23969 #undef THUMB_VARIANT
23970 #define THUMB_VARIANT & arm_ext_v6t2
23972 TUE("csdb", 320f014, f3af8014, 0, (), noargs, t_csdb),
23973 TUF("ssbb", 57ff040, f3bf8f40, 0, (), noargs, t_csdb),
23974 TUF("pssbb", 57ff044, f3bf8f44, 0, (), noargs, t_csdb),
23977 #define ARM_VARIANT & arm_ext_v6t2
23978 #undef THUMB_VARIANT
23979 #define THUMB_VARIANT & arm_ext_v6t2_v8m
23980 TCE("movw", 3000000, f2400000, 2, (RRnpc, HALF), mov16, t_mov16),
23981 TCE("movt", 3400000, f2c00000, 2, (RRnpc, HALF), mov16, t_mov16),
23983 /* Thumb-only instructions. */
23985 #define ARM_VARIANT NULL
23986 TUE("cbnz", 0, b900, 2, (RR, EXP), 0, t_cbz),
23987 TUE("cbz", 0, b100, 2, (RR, EXP), 0, t_cbz),
23989 /* ARM does not really have an IT instruction, so always allow it.
23990 The opcode is copied from Thumb in order to allow warnings in
23991 -mimplicit-it=[never | arm] modes. */
23993 #define ARM_VARIANT & arm_ext_v1
23994 #undef THUMB_VARIANT
23995 #define THUMB_VARIANT & arm_ext_v6t2
23997 TUE("it", bf08, bf08, 1, (COND), it, t_it),
23998 TUE("itt", bf0c, bf0c, 1, (COND), it, t_it),
23999 TUE("ite", bf04, bf04, 1, (COND), it, t_it),
24000 TUE("ittt", bf0e, bf0e, 1, (COND), it, t_it),
24001 TUE("itet", bf06, bf06, 1, (COND), it, t_it),
24002 TUE("itte", bf0a, bf0a, 1, (COND), it, t_it),
24003 TUE("itee", bf02, bf02, 1, (COND), it, t_it),
24004 TUE("itttt", bf0f, bf0f, 1, (COND), it, t_it),
24005 TUE("itett", bf07, bf07, 1, (COND), it, t_it),
24006 TUE("ittet", bf0b, bf0b, 1, (COND), it, t_it),
24007 TUE("iteet", bf03, bf03, 1, (COND), it, t_it),
24008 TUE("ittte", bf0d, bf0d, 1, (COND), it, t_it),
24009 TUE("itete", bf05, bf05, 1, (COND), it, t_it),
24010 TUE("ittee", bf09, bf09, 1, (COND), it, t_it),
24011 TUE("iteee", bf01, bf01, 1, (COND), it, t_it),
24012 /* ARM/Thumb-2 instructions with no Thumb-1 equivalent. */
24013 TC3("rrx", 01a00060, ea4f0030, 2, (RR, RR), rd_rm, t_rrx),
24014 TC3("rrxs", 01b00060, ea5f0030, 2, (RR, RR), rd_rm, t_rrx),
24016 /* Thumb2 only instructions. */
24018 #define ARM_VARIANT NULL
24020 TCE("addw", 0, f2000000, 3, (RR, RR, EXPi), 0, t_add_sub_w),
24021 TCE("subw", 0, f2a00000, 3, (RR, RR, EXPi), 0, t_add_sub_w),
24022 TCE("orn", 0, ea600000, 3, (RR, oRR, SH), 0, t_orn),
24023 TCE("orns", 0, ea700000, 3, (RR, oRR, SH), 0, t_orn),
24024 TCE("tbb", 0, e8d0f000, 1, (TB), 0, t_tb),
24025 TCE("tbh", 0, e8d0f010, 1, (TB), 0, t_tb),
24027 /* Hardware division instructions. */
24029 #define ARM_VARIANT & arm_ext_adiv
24030 #undef THUMB_VARIANT
24031 #define THUMB_VARIANT & arm_ext_div
24033 TCE("sdiv", 710f010, fb90f0f0, 3, (RR, oRR, RR), div, t_div),
24034 TCE("udiv", 730f010, fbb0f0f0, 3, (RR, oRR, RR), div, t_div),
24036 /* ARM V6M/V7 instructions. */
24038 #define ARM_VARIANT & arm_ext_barrier
24039 #undef THUMB_VARIANT
24040 #define THUMB_VARIANT & arm_ext_barrier
24042 TUF("dmb", 57ff050, f3bf8f50, 1, (oBARRIER_I15), barrier, barrier),
24043 TUF("dsb", 57ff040, f3bf8f40, 1, (oBARRIER_I15), barrier, barrier),
24044 TUF("isb", 57ff060, f3bf8f60, 1, (oBARRIER_I15), barrier, barrier),
24046 /* ARM V7 instructions. */
24048 #define ARM_VARIANT & arm_ext_v7
24049 #undef THUMB_VARIANT
24050 #define THUMB_VARIANT & arm_ext_v7
24052 TUF("pli", 450f000, f910f000, 1, (ADDR), pli, t_pld),
24053 TCE("dbg", 320f0f0, f3af80f0, 1, (I15), dbg, t_dbg),
24056 #define ARM_VARIANT & arm_ext_mp
24057 #undef THUMB_VARIANT
24058 #define THUMB_VARIANT & arm_ext_mp
24060 TUF("pldw", 410f000, f830f000, 1, (ADDR), pld, t_pld),
24062 /* AArchv8 instructions. */
24064 #define ARM_VARIANT & arm_ext_v8
24066 /* Instructions shared between armv8-a and armv8-m. */
24067 #undef THUMB_VARIANT
24068 #define THUMB_VARIANT & arm_ext_atomics
24070 TCE("lda", 1900c9f, e8d00faf, 2, (RRnpc, RRnpcb), rd_rn, rd_rn),
24071 TCE("ldab", 1d00c9f, e8d00f8f, 2, (RRnpc, RRnpcb), rd_rn, rd_rn),
24072 TCE("ldah", 1f00c9f, e8d00f9f, 2, (RRnpc, RRnpcb), rd_rn, rd_rn),
24073 TCE("stl", 180fc90, e8c00faf, 2, (RRnpc, RRnpcb), rm_rn, rd_rn),
24074 TCE("stlb", 1c0fc90, e8c00f8f, 2, (RRnpc, RRnpcb), rm_rn, rd_rn),
24075 TCE("stlh", 1e0fc90, e8c00f9f, 2, (RRnpc, RRnpcb), rm_rn, rd_rn),
24076 TCE("ldaex", 1900e9f, e8d00fef, 2, (RRnpc, RRnpcb), rd_rn, rd_rn),
24077 TCE("ldaexb", 1d00e9f, e8d00fcf, 2, (RRnpc,RRnpcb), rd_rn, rd_rn),
24078 TCE("ldaexh", 1f00e9f, e8d00fdf, 2, (RRnpc, RRnpcb), rd_rn, rd_rn),
24079 TCE("stlex", 1800e90, e8c00fe0, 3, (RRnpc, RRnpc, RRnpcb),
24081 TCE("stlexb", 1c00e90, e8c00fc0, 3, (RRnpc, RRnpc, RRnpcb),
24083 TCE("stlexh", 1e00e90, e8c00fd0, 3, (RRnpc, RRnpc, RRnpcb),
24085 #undef THUMB_VARIANT
24086 #define THUMB_VARIANT & arm_ext_v8
24088 tCE("sevl", 320f005, _sevl, 0, (), noargs, t_hint),
24089 TCE("ldaexd", 1b00e9f, e8d000ff, 3, (RRnpc, oRRnpc, RRnpcb),
24091 TCE("stlexd", 1a00e90, e8c000f0, 4, (RRnpc, RRnpc, oRRnpc, RRnpcb),
24094 /* Defined in V8 but is in undefined encoding space for earlier
24095 architectures. However earlier architectures are required to treat
24096 this instuction as a semihosting trap as well. Hence while not explicitly
24097 defined as such, it is in fact correct to define the instruction for all
24099 #undef THUMB_VARIANT
24100 #define THUMB_VARIANT & arm_ext_v1
24102 #define ARM_VARIANT & arm_ext_v1
24103 TUE("hlt", 1000070, ba80, 1, (oIffffb), bkpt, t_hlt),
24105 /* ARMv8 T32 only. */
24107 #define ARM_VARIANT NULL
24108 TUF("dcps1", 0, f78f8001, 0, (), noargs, noargs),
24109 TUF("dcps2", 0, f78f8002, 0, (), noargs, noargs),
24110 TUF("dcps3", 0, f78f8003, 0, (), noargs, noargs),
24112 /* FP for ARMv8. */
24114 #define ARM_VARIANT & fpu_vfp_ext_armv8xd
24115 #undef THUMB_VARIANT
24116 #define THUMB_VARIANT & fpu_vfp_ext_armv8xd
24118 nUF(vseleq, _vseleq, 3, (RVSD, RVSD, RVSD), vsel),
24119 nUF(vselvs, _vselvs, 3, (RVSD, RVSD, RVSD), vsel),
24120 nUF(vselge, _vselge, 3, (RVSD, RVSD, RVSD), vsel),
24121 nUF(vselgt, _vselgt, 3, (RVSD, RVSD, RVSD), vsel),
24122 nCE(vrintr, _vrintr, 2, (RNSDQ, oRNSDQ), vrintr),
24123 mnCE(vrintz, _vrintr, 2, (RNSDQMQ, oRNSDQMQ), vrintz),
24124 mnCE(vrintx, _vrintr, 2, (RNSDQMQ, oRNSDQMQ), vrintx),
24125 mnUF(vrinta, _vrinta, 2, (RNSDQMQ, oRNSDQMQ), vrinta),
24126 mnUF(vrintn, _vrinta, 2, (RNSDQMQ, oRNSDQMQ), vrintn),
24127 mnUF(vrintp, _vrinta, 2, (RNSDQMQ, oRNSDQMQ), vrintp),
24128 mnUF(vrintm, _vrinta, 2, (RNSDQMQ, oRNSDQMQ), vrintm),
24130 /* Crypto v1 extensions. */
24132 #define ARM_VARIANT & fpu_crypto_ext_armv8
24133 #undef THUMB_VARIANT
24134 #define THUMB_VARIANT & fpu_crypto_ext_armv8
24136 nUF(aese, _aes, 2, (RNQ, RNQ), aese),
24137 nUF(aesd, _aes, 2, (RNQ, RNQ), aesd),
24138 nUF(aesmc, _aes, 2, (RNQ, RNQ), aesmc),
24139 nUF(aesimc, _aes, 2, (RNQ, RNQ), aesimc),
24140 nUF(sha1c, _sha3op, 3, (RNQ, RNQ, RNQ), sha1c),
24141 nUF(sha1p, _sha3op, 3, (RNQ, RNQ, RNQ), sha1p),
24142 nUF(sha1m, _sha3op, 3, (RNQ, RNQ, RNQ), sha1m),
24143 nUF(sha1su0, _sha3op, 3, (RNQ, RNQ, RNQ), sha1su0),
24144 nUF(sha256h, _sha3op, 3, (RNQ, RNQ, RNQ), sha256h),
24145 nUF(sha256h2, _sha3op, 3, (RNQ, RNQ, RNQ), sha256h2),
24146 nUF(sha256su1, _sha3op, 3, (RNQ, RNQ, RNQ), sha256su1),
24147 nUF(sha1h, _sha1h, 2, (RNQ, RNQ), sha1h),
24148 nUF(sha1su1, _sha2op, 2, (RNQ, RNQ), sha1su1),
24149 nUF(sha256su0, _sha2op, 2, (RNQ, RNQ), sha256su0),
24152 #define ARM_VARIANT & crc_ext_armv8
24153 #undef THUMB_VARIANT
24154 #define THUMB_VARIANT & crc_ext_armv8
24155 TUEc("crc32b", 1000040, fac0f080, 3, (RR, oRR, RR), crc32b),
24156 TUEc("crc32h", 1200040, fac0f090, 3, (RR, oRR, RR), crc32h),
24157 TUEc("crc32w", 1400040, fac0f0a0, 3, (RR, oRR, RR), crc32w),
24158 TUEc("crc32cb",1000240, fad0f080, 3, (RR, oRR, RR), crc32cb),
24159 TUEc("crc32ch",1200240, fad0f090, 3, (RR, oRR, RR), crc32ch),
24160 TUEc("crc32cw",1400240, fad0f0a0, 3, (RR, oRR, RR), crc32cw),
24162 /* ARMv8.2 RAS extension. */
24164 #define ARM_VARIANT & arm_ext_ras
24165 #undef THUMB_VARIANT
24166 #define THUMB_VARIANT & arm_ext_ras
24167 TUE ("esb", 320f010, f3af8010, 0, (), noargs, noargs),
24170 #define ARM_VARIANT & arm_ext_v8_3
24171 #undef THUMB_VARIANT
24172 #define THUMB_VARIANT & arm_ext_v8_3
24173 NCE (vjcvt, eb90bc0, 2, (RVS, RVD), vjcvt),
24176 #define ARM_VARIANT & fpu_neon_ext_dotprod
24177 #undef THUMB_VARIANT
24178 #define THUMB_VARIANT & fpu_neon_ext_dotprod
24179 NUF (vsdot, d00, 3, (RNDQ, RNDQ, RNDQ_RNSC), neon_dotproduct_s),
24180 NUF (vudot, d00, 3, (RNDQ, RNDQ, RNDQ_RNSC), neon_dotproduct_u),
24183 #define ARM_VARIANT & fpu_fpa_ext_v1 /* Core FPA instruction set (V1). */
24184 #undef THUMB_VARIANT
24185 #define THUMB_VARIANT NULL
24187 cCE("wfs", e200110, 1, (RR), rd),
24188 cCE("rfs", e300110, 1, (RR), rd),
24189 cCE("wfc", e400110, 1, (RR), rd),
24190 cCE("rfc", e500110, 1, (RR), rd),
24192 cCL("ldfs", c100100, 2, (RF, ADDRGLDC), rd_cpaddr),
24193 cCL("ldfd", c108100, 2, (RF, ADDRGLDC), rd_cpaddr),
24194 cCL("ldfe", c500100, 2, (RF, ADDRGLDC), rd_cpaddr),
24195 cCL("ldfp", c508100, 2, (RF, ADDRGLDC), rd_cpaddr),
24197 cCL("stfs", c000100, 2, (RF, ADDRGLDC), rd_cpaddr),
24198 cCL("stfd", c008100, 2, (RF, ADDRGLDC), rd_cpaddr),
24199 cCL("stfe", c400100, 2, (RF, ADDRGLDC), rd_cpaddr),
24200 cCL("stfp", c408100, 2, (RF, ADDRGLDC), rd_cpaddr),
24202 cCL("mvfs", e008100, 2, (RF, RF_IF), rd_rm),
24203 cCL("mvfsp", e008120, 2, (RF, RF_IF), rd_rm),
24204 cCL("mvfsm", e008140, 2, (RF, RF_IF), rd_rm),
24205 cCL("mvfsz", e008160, 2, (RF, RF_IF), rd_rm),
24206 cCL("mvfd", e008180, 2, (RF, RF_IF), rd_rm),
24207 cCL("mvfdp", e0081a0, 2, (RF, RF_IF), rd_rm),
24208 cCL("mvfdm", e0081c0, 2, (RF, RF_IF), rd_rm),
24209 cCL("mvfdz", e0081e0, 2, (RF, RF_IF), rd_rm),
24210 cCL("mvfe", e088100, 2, (RF, RF_IF), rd_rm),
24211 cCL("mvfep", e088120, 2, (RF, RF_IF), rd_rm),
24212 cCL("mvfem", e088140, 2, (RF, RF_IF), rd_rm),
24213 cCL("mvfez", e088160, 2, (RF, RF_IF), rd_rm),
24215 cCL("mnfs", e108100, 2, (RF, RF_IF), rd_rm),
24216 cCL("mnfsp", e108120, 2, (RF, RF_IF), rd_rm),
24217 cCL("mnfsm", e108140, 2, (RF, RF_IF), rd_rm),
24218 cCL("mnfsz", e108160, 2, (RF, RF_IF), rd_rm),
24219 cCL("mnfd", e108180, 2, (RF, RF_IF), rd_rm),
24220 cCL("mnfdp", e1081a0, 2, (RF, RF_IF), rd_rm),
24221 cCL("mnfdm", e1081c0, 2, (RF, RF_IF), rd_rm),
24222 cCL("mnfdz", e1081e0, 2, (RF, RF_IF), rd_rm),
24223 cCL("mnfe", e188100, 2, (RF, RF_IF), rd_rm),
24224 cCL("mnfep", e188120, 2, (RF, RF_IF), rd_rm),
24225 cCL("mnfem", e188140, 2, (RF, RF_IF), rd_rm),
24226 cCL("mnfez", e188160, 2, (RF, RF_IF), rd_rm),
24228 cCL("abss", e208100, 2, (RF, RF_IF), rd_rm),
24229 cCL("abssp", e208120, 2, (RF, RF_IF), rd_rm),
24230 cCL("abssm", e208140, 2, (RF, RF_IF), rd_rm),
24231 cCL("abssz", e208160, 2, (RF, RF_IF), rd_rm),
24232 cCL("absd", e208180, 2, (RF, RF_IF), rd_rm),
24233 cCL("absdp", e2081a0, 2, (RF, RF_IF), rd_rm),
24234 cCL("absdm", e2081c0, 2, (RF, RF_IF), rd_rm),
24235 cCL("absdz", e2081e0, 2, (RF, RF_IF), rd_rm),
24236 cCL("abse", e288100, 2, (RF, RF_IF), rd_rm),
24237 cCL("absep", e288120, 2, (RF, RF_IF), rd_rm),
24238 cCL("absem", e288140, 2, (RF, RF_IF), rd_rm),
24239 cCL("absez", e288160, 2, (RF, RF_IF), rd_rm),
24241 cCL("rnds", e308100, 2, (RF, RF_IF), rd_rm),
24242 cCL("rndsp", e308120, 2, (RF, RF_IF), rd_rm),
24243 cCL("rndsm", e308140, 2, (RF, RF_IF), rd_rm),
24244 cCL("rndsz", e308160, 2, (RF, RF_IF), rd_rm),
24245 cCL("rndd", e308180, 2, (RF, RF_IF), rd_rm),
24246 cCL("rnddp", e3081a0, 2, (RF, RF_IF), rd_rm),
24247 cCL("rnddm", e3081c0, 2, (RF, RF_IF), rd_rm),
24248 cCL("rnddz", e3081e0, 2, (RF, RF_IF), rd_rm),
24249 cCL("rnde", e388100, 2, (RF, RF_IF), rd_rm),
24250 cCL("rndep", e388120, 2, (RF, RF_IF), rd_rm),
24251 cCL("rndem", e388140, 2, (RF, RF_IF), rd_rm),
24252 cCL("rndez", e388160, 2, (RF, RF_IF), rd_rm),
24254 cCL("sqts", e408100, 2, (RF, RF_IF), rd_rm),
24255 cCL("sqtsp", e408120, 2, (RF, RF_IF), rd_rm),
24256 cCL("sqtsm", e408140, 2, (RF, RF_IF), rd_rm),
24257 cCL("sqtsz", e408160, 2, (RF, RF_IF), rd_rm),
24258 cCL("sqtd", e408180, 2, (RF, RF_IF), rd_rm),
24259 cCL("sqtdp", e4081a0, 2, (RF, RF_IF), rd_rm),
24260 cCL("sqtdm", e4081c0, 2, (RF, RF_IF), rd_rm),
24261 cCL("sqtdz", e4081e0, 2, (RF, RF_IF), rd_rm),
24262 cCL("sqte", e488100, 2, (RF, RF_IF), rd_rm),
24263 cCL("sqtep", e488120, 2, (RF, RF_IF), rd_rm),
24264 cCL("sqtem", e488140, 2, (RF, RF_IF), rd_rm),
24265 cCL("sqtez", e488160, 2, (RF, RF_IF), rd_rm),
24267 cCL("logs", e508100, 2, (RF, RF_IF), rd_rm),
24268 cCL("logsp", e508120, 2, (RF, RF_IF), rd_rm),
24269 cCL("logsm", e508140, 2, (RF, RF_IF), rd_rm),
24270 cCL("logsz", e508160, 2, (RF, RF_IF), rd_rm),
24271 cCL("logd", e508180, 2, (RF, RF_IF), rd_rm),
24272 cCL("logdp", e5081a0, 2, (RF, RF_IF), rd_rm),
24273 cCL("logdm", e5081c0, 2, (RF, RF_IF), rd_rm),
24274 cCL("logdz", e5081e0, 2, (RF, RF_IF), rd_rm),
24275 cCL("loge", e588100, 2, (RF, RF_IF), rd_rm),
24276 cCL("logep", e588120, 2, (RF, RF_IF), rd_rm),
24277 cCL("logem", e588140, 2, (RF, RF_IF), rd_rm),
24278 cCL("logez", e588160, 2, (RF, RF_IF), rd_rm),
24280 cCL("lgns", e608100, 2, (RF, RF_IF), rd_rm),
24281 cCL("lgnsp", e608120, 2, (RF, RF_IF), rd_rm),
24282 cCL("lgnsm", e608140, 2, (RF, RF_IF), rd_rm),
24283 cCL("lgnsz", e608160, 2, (RF, RF_IF), rd_rm),
24284 cCL("lgnd", e608180, 2, (RF, RF_IF), rd_rm),
24285 cCL("lgndp", e6081a0, 2, (RF, RF_IF), rd_rm),
24286 cCL("lgndm", e6081c0, 2, (RF, RF_IF), rd_rm),
24287 cCL("lgndz", e6081e0, 2, (RF, RF_IF), rd_rm),
24288 cCL("lgne", e688100, 2, (RF, RF_IF), rd_rm),
24289 cCL("lgnep", e688120, 2, (RF, RF_IF), rd_rm),
24290 cCL("lgnem", e688140, 2, (RF, RF_IF), rd_rm),
24291 cCL("lgnez", e688160, 2, (RF, RF_IF), rd_rm),
24293 cCL("exps", e708100, 2, (RF, RF_IF), rd_rm),
24294 cCL("expsp", e708120, 2, (RF, RF_IF), rd_rm),
24295 cCL("expsm", e708140, 2, (RF, RF_IF), rd_rm),
24296 cCL("expsz", e708160, 2, (RF, RF_IF), rd_rm),
24297 cCL("expd", e708180, 2, (RF, RF_IF), rd_rm),
24298 cCL("expdp", e7081a0, 2, (RF, RF_IF), rd_rm),
24299 cCL("expdm", e7081c0, 2, (RF, RF_IF), rd_rm),
24300 cCL("expdz", e7081e0, 2, (RF, RF_IF), rd_rm),
24301 cCL("expe", e788100, 2, (RF, RF_IF), rd_rm),
24302 cCL("expep", e788120, 2, (RF, RF_IF), rd_rm),
24303 cCL("expem", e788140, 2, (RF, RF_IF), rd_rm),
24304 cCL("expdz", e788160, 2, (RF, RF_IF), rd_rm),
24306 cCL("sins", e808100, 2, (RF, RF_IF), rd_rm),
24307 cCL("sinsp", e808120, 2, (RF, RF_IF), rd_rm),
24308 cCL("sinsm", e808140, 2, (RF, RF_IF), rd_rm),
24309 cCL("sinsz", e808160, 2, (RF, RF_IF), rd_rm),
24310 cCL("sind", e808180, 2, (RF, RF_IF), rd_rm),
24311 cCL("sindp", e8081a0, 2, (RF, RF_IF), rd_rm),
24312 cCL("sindm", e8081c0, 2, (RF, RF_IF), rd_rm),
24313 cCL("sindz", e8081e0, 2, (RF, RF_IF), rd_rm),
24314 cCL("sine", e888100, 2, (RF, RF_IF), rd_rm),
24315 cCL("sinep", e888120, 2, (RF, RF_IF), rd_rm),
24316 cCL("sinem", e888140, 2, (RF, RF_IF), rd_rm),
24317 cCL("sinez", e888160, 2, (RF, RF_IF), rd_rm),
24319 cCL("coss", e908100, 2, (RF, RF_IF), rd_rm),
24320 cCL("cossp", e908120, 2, (RF, RF_IF), rd_rm),
24321 cCL("cossm", e908140, 2, (RF, RF_IF), rd_rm),
24322 cCL("cossz", e908160, 2, (RF, RF_IF), rd_rm),
24323 cCL("cosd", e908180, 2, (RF, RF_IF), rd_rm),
24324 cCL("cosdp", e9081a0, 2, (RF, RF_IF), rd_rm),
24325 cCL("cosdm", e9081c0, 2, (RF, RF_IF), rd_rm),
24326 cCL("cosdz", e9081e0, 2, (RF, RF_IF), rd_rm),
24327 cCL("cose", e988100, 2, (RF, RF_IF), rd_rm),
24328 cCL("cosep", e988120, 2, (RF, RF_IF), rd_rm),
24329 cCL("cosem", e988140, 2, (RF, RF_IF), rd_rm),
24330 cCL("cosez", e988160, 2, (RF, RF_IF), rd_rm),
24332 cCL("tans", ea08100, 2, (RF, RF_IF), rd_rm),
24333 cCL("tansp", ea08120, 2, (RF, RF_IF), rd_rm),
24334 cCL("tansm", ea08140, 2, (RF, RF_IF), rd_rm),
24335 cCL("tansz", ea08160, 2, (RF, RF_IF), rd_rm),
24336 cCL("tand", ea08180, 2, (RF, RF_IF), rd_rm),
24337 cCL("tandp", ea081a0, 2, (RF, RF_IF), rd_rm),
24338 cCL("tandm", ea081c0, 2, (RF, RF_IF), rd_rm),
24339 cCL("tandz", ea081e0, 2, (RF, RF_IF), rd_rm),
24340 cCL("tane", ea88100, 2, (RF, RF_IF), rd_rm),
24341 cCL("tanep", ea88120, 2, (RF, RF_IF), rd_rm),
24342 cCL("tanem", ea88140, 2, (RF, RF_IF), rd_rm),
24343 cCL("tanez", ea88160, 2, (RF, RF_IF), rd_rm),
24345 cCL("asns", eb08100, 2, (RF, RF_IF), rd_rm),
24346 cCL("asnsp", eb08120, 2, (RF, RF_IF), rd_rm),
24347 cCL("asnsm", eb08140, 2, (RF, RF_IF), rd_rm),
24348 cCL("asnsz", eb08160, 2, (RF, RF_IF), rd_rm),
24349 cCL("asnd", eb08180, 2, (RF, RF_IF), rd_rm),
24350 cCL("asndp", eb081a0, 2, (RF, RF_IF), rd_rm),
24351 cCL("asndm", eb081c0, 2, (RF, RF_IF), rd_rm),
24352 cCL("asndz", eb081e0, 2, (RF, RF_IF), rd_rm),
24353 cCL("asne", eb88100, 2, (RF, RF_IF), rd_rm),
24354 cCL("asnep", eb88120, 2, (RF, RF_IF), rd_rm),
24355 cCL("asnem", eb88140, 2, (RF, RF_IF), rd_rm),
24356 cCL("asnez", eb88160, 2, (RF, RF_IF), rd_rm),
24358 cCL("acss", ec08100, 2, (RF, RF_IF), rd_rm),
24359 cCL("acssp", ec08120, 2, (RF, RF_IF), rd_rm),
24360 cCL("acssm", ec08140, 2, (RF, RF_IF), rd_rm),
24361 cCL("acssz", ec08160, 2, (RF, RF_IF), rd_rm),
24362 cCL("acsd", ec08180, 2, (RF, RF_IF), rd_rm),
24363 cCL("acsdp", ec081a0, 2, (RF, RF_IF), rd_rm),
24364 cCL("acsdm", ec081c0, 2, (RF, RF_IF), rd_rm),
24365 cCL("acsdz", ec081e0, 2, (RF, RF_IF), rd_rm),
24366 cCL("acse", ec88100, 2, (RF, RF_IF), rd_rm),
24367 cCL("acsep", ec88120, 2, (RF, RF_IF), rd_rm),
24368 cCL("acsem", ec88140, 2, (RF, RF_IF), rd_rm),
24369 cCL("acsez", ec88160, 2, (RF, RF_IF), rd_rm),
24371 cCL("atns", ed08100, 2, (RF, RF_IF), rd_rm),
24372 cCL("atnsp", ed08120, 2, (RF, RF_IF), rd_rm),
24373 cCL("atnsm", ed08140, 2, (RF, RF_IF), rd_rm),
24374 cCL("atnsz", ed08160, 2, (RF, RF_IF), rd_rm),
24375 cCL("atnd", ed08180, 2, (RF, RF_IF), rd_rm),
24376 cCL("atndp", ed081a0, 2, (RF, RF_IF), rd_rm),
24377 cCL("atndm", ed081c0, 2, (RF, RF_IF), rd_rm),
24378 cCL("atndz", ed081e0, 2, (RF, RF_IF), rd_rm),
24379 cCL("atne", ed88100, 2, (RF, RF_IF), rd_rm),
24380 cCL("atnep", ed88120, 2, (RF, RF_IF), rd_rm),
24381 cCL("atnem", ed88140, 2, (RF, RF_IF), rd_rm),
24382 cCL("atnez", ed88160, 2, (RF, RF_IF), rd_rm),
24384 cCL("urds", ee08100, 2, (RF, RF_IF), rd_rm),
24385 cCL("urdsp", ee08120, 2, (RF, RF_IF), rd_rm),
24386 cCL("urdsm", ee08140, 2, (RF, RF_IF), rd_rm),
24387 cCL("urdsz", ee08160, 2, (RF, RF_IF), rd_rm),
24388 cCL("urdd", ee08180, 2, (RF, RF_IF), rd_rm),
24389 cCL("urddp", ee081a0, 2, (RF, RF_IF), rd_rm),
24390 cCL("urddm", ee081c0, 2, (RF, RF_IF), rd_rm),
24391 cCL("urddz", ee081e0, 2, (RF, RF_IF), rd_rm),
24392 cCL("urde", ee88100, 2, (RF, RF_IF), rd_rm),
24393 cCL("urdep", ee88120, 2, (RF, RF_IF), rd_rm),
24394 cCL("urdem", ee88140, 2, (RF, RF_IF), rd_rm),
24395 cCL("urdez", ee88160, 2, (RF, RF_IF), rd_rm),
24397 cCL("nrms", ef08100, 2, (RF, RF_IF), rd_rm),
24398 cCL("nrmsp", ef08120, 2, (RF, RF_IF), rd_rm),
24399 cCL("nrmsm", ef08140, 2, (RF, RF_IF), rd_rm),
24400 cCL("nrmsz", ef08160, 2, (RF, RF_IF), rd_rm),
24401 cCL("nrmd", ef08180, 2, (RF, RF_IF), rd_rm),
24402 cCL("nrmdp", ef081a0, 2, (RF, RF_IF), rd_rm),
24403 cCL("nrmdm", ef081c0, 2, (RF, RF_IF), rd_rm),
24404 cCL("nrmdz", ef081e0, 2, (RF, RF_IF), rd_rm),
24405 cCL("nrme", ef88100, 2, (RF, RF_IF), rd_rm),
24406 cCL("nrmep", ef88120, 2, (RF, RF_IF), rd_rm),
24407 cCL("nrmem", ef88140, 2, (RF, RF_IF), rd_rm),
24408 cCL("nrmez", ef88160, 2, (RF, RF_IF), rd_rm),
24410 cCL("adfs", e000100, 3, (RF, RF, RF_IF), rd_rn_rm),
24411 cCL("adfsp", e000120, 3, (RF, RF, RF_IF), rd_rn_rm),
24412 cCL("adfsm", e000140, 3, (RF, RF, RF_IF), rd_rn_rm),
24413 cCL("adfsz", e000160, 3, (RF, RF, RF_IF), rd_rn_rm),
24414 cCL("adfd", e000180, 3, (RF, RF, RF_IF), rd_rn_rm),
24415 cCL("adfdp", e0001a0, 3, (RF, RF, RF_IF), rd_rn_rm),
24416 cCL("adfdm", e0001c0, 3, (RF, RF, RF_IF), rd_rn_rm),
24417 cCL("adfdz", e0001e0, 3, (RF, RF, RF_IF), rd_rn_rm),
24418 cCL("adfe", e080100, 3, (RF, RF, RF_IF), rd_rn_rm),
24419 cCL("adfep", e080120, 3, (RF, RF, RF_IF), rd_rn_rm),
24420 cCL("adfem", e080140, 3, (RF, RF, RF_IF), rd_rn_rm),
24421 cCL("adfez", e080160, 3, (RF, RF, RF_IF), rd_rn_rm),
24423 cCL("sufs", e200100, 3, (RF, RF, RF_IF), rd_rn_rm),
24424 cCL("sufsp", e200120, 3, (RF, RF, RF_IF), rd_rn_rm),
24425 cCL("sufsm", e200140, 3, (RF, RF, RF_IF), rd_rn_rm),
24426 cCL("sufsz", e200160, 3, (RF, RF, RF_IF), rd_rn_rm),
24427 cCL("sufd", e200180, 3, (RF, RF, RF_IF), rd_rn_rm),
24428 cCL("sufdp", e2001a0, 3, (RF, RF, RF_IF), rd_rn_rm),
24429 cCL("sufdm", e2001c0, 3, (RF, RF, RF_IF), rd_rn_rm),
24430 cCL("sufdz", e2001e0, 3, (RF, RF, RF_IF), rd_rn_rm),
24431 cCL("sufe", e280100, 3, (RF, RF, RF_IF), rd_rn_rm),
24432 cCL("sufep", e280120, 3, (RF, RF, RF_IF), rd_rn_rm),
24433 cCL("sufem", e280140, 3, (RF, RF, RF_IF), rd_rn_rm),
24434 cCL("sufez", e280160, 3, (RF, RF, RF_IF), rd_rn_rm),
24436 cCL("rsfs", e300100, 3, (RF, RF, RF_IF), rd_rn_rm),
24437 cCL("rsfsp", e300120, 3, (RF, RF, RF_IF), rd_rn_rm),
24438 cCL("rsfsm", e300140, 3, (RF, RF, RF_IF), rd_rn_rm),
24439 cCL("rsfsz", e300160, 3, (RF, RF, RF_IF), rd_rn_rm),
24440 cCL("rsfd", e300180, 3, (RF, RF, RF_IF), rd_rn_rm),
24441 cCL("rsfdp", e3001a0, 3, (RF, RF, RF_IF), rd_rn_rm),
24442 cCL("rsfdm", e3001c0, 3, (RF, RF, RF_IF), rd_rn_rm),
24443 cCL("rsfdz", e3001e0, 3, (RF, RF, RF_IF), rd_rn_rm),
24444 cCL("rsfe", e380100, 3, (RF, RF, RF_IF), rd_rn_rm),
24445 cCL("rsfep", e380120, 3, (RF, RF, RF_IF), rd_rn_rm),
24446 cCL("rsfem", e380140, 3, (RF, RF, RF_IF), rd_rn_rm),
24447 cCL("rsfez", e380160, 3, (RF, RF, RF_IF), rd_rn_rm),
24449 cCL("mufs", e100100, 3, (RF, RF, RF_IF), rd_rn_rm),
24450 cCL("mufsp", e100120, 3, (RF, RF, RF_IF), rd_rn_rm),
24451 cCL("mufsm", e100140, 3, (RF, RF, RF_IF), rd_rn_rm),
24452 cCL("mufsz", e100160, 3, (RF, RF, RF_IF), rd_rn_rm),
24453 cCL("mufd", e100180, 3, (RF, RF, RF_IF), rd_rn_rm),
24454 cCL("mufdp", e1001a0, 3, (RF, RF, RF_IF), rd_rn_rm),
24455 cCL("mufdm", e1001c0, 3, (RF, RF, RF_IF), rd_rn_rm),
24456 cCL("mufdz", e1001e0, 3, (RF, RF, RF_IF), rd_rn_rm),
24457 cCL("mufe", e180100, 3, (RF, RF, RF_IF), rd_rn_rm),
24458 cCL("mufep", e180120, 3, (RF, RF, RF_IF), rd_rn_rm),
24459 cCL("mufem", e180140, 3, (RF, RF, RF_IF), rd_rn_rm),
24460 cCL("mufez", e180160, 3, (RF, RF, RF_IF), rd_rn_rm),
24462 cCL("dvfs", e400100, 3, (RF, RF, RF_IF), rd_rn_rm),
24463 cCL("dvfsp", e400120, 3, (RF, RF, RF_IF), rd_rn_rm),
24464 cCL("dvfsm", e400140, 3, (RF, RF, RF_IF), rd_rn_rm),
24465 cCL("dvfsz", e400160, 3, (RF, RF, RF_IF), rd_rn_rm),
24466 cCL("dvfd", e400180, 3, (RF, RF, RF_IF), rd_rn_rm),
24467 cCL("dvfdp", e4001a0, 3, (RF, RF, RF_IF), rd_rn_rm),
24468 cCL("dvfdm", e4001c0, 3, (RF, RF, RF_IF), rd_rn_rm),
24469 cCL("dvfdz", e4001e0, 3, (RF, RF, RF_IF), rd_rn_rm),
24470 cCL("dvfe", e480100, 3, (RF, RF, RF_IF), rd_rn_rm),
24471 cCL("dvfep", e480120, 3, (RF, RF, RF_IF), rd_rn_rm),
24472 cCL("dvfem", e480140, 3, (RF, RF, RF_IF), rd_rn_rm),
24473 cCL("dvfez", e480160, 3, (RF, RF, RF_IF), rd_rn_rm),
24475 cCL("rdfs", e500100, 3, (RF, RF, RF_IF), rd_rn_rm),
24476 cCL("rdfsp", e500120, 3, (RF, RF, RF_IF), rd_rn_rm),
24477 cCL("rdfsm", e500140, 3, (RF, RF, RF_IF), rd_rn_rm),
24478 cCL("rdfsz", e500160, 3, (RF, RF, RF_IF), rd_rn_rm),
24479 cCL("rdfd", e500180, 3, (RF, RF, RF_IF), rd_rn_rm),
24480 cCL("rdfdp", e5001a0, 3, (RF, RF, RF_IF), rd_rn_rm),
24481 cCL("rdfdm", e5001c0, 3, (RF, RF, RF_IF), rd_rn_rm),
24482 cCL("rdfdz", e5001e0, 3, (RF, RF, RF_IF), rd_rn_rm),
24483 cCL("rdfe", e580100, 3, (RF, RF, RF_IF), rd_rn_rm),
24484 cCL("rdfep", e580120, 3, (RF, RF, RF_IF), rd_rn_rm),
24485 cCL("rdfem", e580140, 3, (RF, RF, RF_IF), rd_rn_rm),
24486 cCL("rdfez", e580160, 3, (RF, RF, RF_IF), rd_rn_rm),
24488 cCL("pows", e600100, 3, (RF, RF, RF_IF), rd_rn_rm),
24489 cCL("powsp", e600120, 3, (RF, RF, RF_IF), rd_rn_rm),
24490 cCL("powsm", e600140, 3, (RF, RF, RF_IF), rd_rn_rm),
24491 cCL("powsz", e600160, 3, (RF, RF, RF_IF), rd_rn_rm),
24492 cCL("powd", e600180, 3, (RF, RF, RF_IF), rd_rn_rm),
24493 cCL("powdp", e6001a0, 3, (RF, RF, RF_IF), rd_rn_rm),
24494 cCL("powdm", e6001c0, 3, (RF, RF, RF_IF), rd_rn_rm),
24495 cCL("powdz", e6001e0, 3, (RF, RF, RF_IF), rd_rn_rm),
24496 cCL("powe", e680100, 3, (RF, RF, RF_IF), rd_rn_rm),
24497 cCL("powep", e680120, 3, (RF, RF, RF_IF), rd_rn_rm),
24498 cCL("powem", e680140, 3, (RF, RF, RF_IF), rd_rn_rm),
24499 cCL("powez", e680160, 3, (RF, RF, RF_IF), rd_rn_rm),
24501 cCL("rpws", e700100, 3, (RF, RF, RF_IF), rd_rn_rm),
24502 cCL("rpwsp", e700120, 3, (RF, RF, RF_IF), rd_rn_rm),
24503 cCL("rpwsm", e700140, 3, (RF, RF, RF_IF), rd_rn_rm),
24504 cCL("rpwsz", e700160, 3, (RF, RF, RF_IF), rd_rn_rm),
24505 cCL("rpwd", e700180, 3, (RF, RF, RF_IF), rd_rn_rm),
24506 cCL("rpwdp", e7001a0, 3, (RF, RF, RF_IF), rd_rn_rm),
24507 cCL("rpwdm", e7001c0, 3, (RF, RF, RF_IF), rd_rn_rm),
24508 cCL("rpwdz", e7001e0, 3, (RF, RF, RF_IF), rd_rn_rm),
24509 cCL("rpwe", e780100, 3, (RF, RF, RF_IF), rd_rn_rm),
24510 cCL("rpwep", e780120, 3, (RF, RF, RF_IF), rd_rn_rm),
24511 cCL("rpwem", e780140, 3, (RF, RF, RF_IF), rd_rn_rm),
24512 cCL("rpwez", e780160, 3, (RF, RF, RF_IF), rd_rn_rm),
24514 cCL("rmfs", e800100, 3, (RF, RF, RF_IF), rd_rn_rm),
24515 cCL("rmfsp", e800120, 3, (RF, RF, RF_IF), rd_rn_rm),
24516 cCL("rmfsm", e800140, 3, (RF, RF, RF_IF), rd_rn_rm),
24517 cCL("rmfsz", e800160, 3, (RF, RF, RF_IF), rd_rn_rm),
24518 cCL("rmfd", e800180, 3, (RF, RF, RF_IF), rd_rn_rm),
24519 cCL("rmfdp", e8001a0, 3, (RF, RF, RF_IF), rd_rn_rm),
24520 cCL("rmfdm", e8001c0, 3, (RF, RF, RF_IF), rd_rn_rm),
24521 cCL("rmfdz", e8001e0, 3, (RF, RF, RF_IF), rd_rn_rm),
24522 cCL("rmfe", e880100, 3, (RF, RF, RF_IF), rd_rn_rm),
24523 cCL("rmfep", e880120, 3, (RF, RF, RF_IF), rd_rn_rm),
24524 cCL("rmfem", e880140, 3, (RF, RF, RF_IF), rd_rn_rm),
24525 cCL("rmfez", e880160, 3, (RF, RF, RF_IF), rd_rn_rm),
24527 cCL("fmls", e900100, 3, (RF, RF, RF_IF), rd_rn_rm),
24528 cCL("fmlsp", e900120, 3, (RF, RF, RF_IF), rd_rn_rm),
24529 cCL("fmlsm", e900140, 3, (RF, RF, RF_IF), rd_rn_rm),
24530 cCL("fmlsz", e900160, 3, (RF, RF, RF_IF), rd_rn_rm),
24531 cCL("fmld", e900180, 3, (RF, RF, RF_IF), rd_rn_rm),
24532 cCL("fmldp", e9001a0, 3, (RF, RF, RF_IF), rd_rn_rm),
24533 cCL("fmldm", e9001c0, 3, (RF, RF, RF_IF), rd_rn_rm),
24534 cCL("fmldz", e9001e0, 3, (RF, RF, RF_IF), rd_rn_rm),
24535 cCL("fmle", e980100, 3, (RF, RF, RF_IF), rd_rn_rm),
24536 cCL("fmlep", e980120, 3, (RF, RF, RF_IF), rd_rn_rm),
24537 cCL("fmlem", e980140, 3, (RF, RF, RF_IF), rd_rn_rm),
24538 cCL("fmlez", e980160, 3, (RF, RF, RF_IF), rd_rn_rm),
24540 cCL("fdvs", ea00100, 3, (RF, RF, RF_IF), rd_rn_rm),
24541 cCL("fdvsp", ea00120, 3, (RF, RF, RF_IF), rd_rn_rm),
24542 cCL("fdvsm", ea00140, 3, (RF, RF, RF_IF), rd_rn_rm),
24543 cCL("fdvsz", ea00160, 3, (RF, RF, RF_IF), rd_rn_rm),
24544 cCL("fdvd", ea00180, 3, (RF, RF, RF_IF), rd_rn_rm),
24545 cCL("fdvdp", ea001a0, 3, (RF, RF, RF_IF), rd_rn_rm),
24546 cCL("fdvdm", ea001c0, 3, (RF, RF, RF_IF), rd_rn_rm),
24547 cCL("fdvdz", ea001e0, 3, (RF, RF, RF_IF), rd_rn_rm),
24548 cCL("fdve", ea80100, 3, (RF, RF, RF_IF), rd_rn_rm),
24549 cCL("fdvep", ea80120, 3, (RF, RF, RF_IF), rd_rn_rm),
24550 cCL("fdvem", ea80140, 3, (RF, RF, RF_IF), rd_rn_rm),
24551 cCL("fdvez", ea80160, 3, (RF, RF, RF_IF), rd_rn_rm),
24553 cCL("frds", eb00100, 3, (RF, RF, RF_IF), rd_rn_rm),
24554 cCL("frdsp", eb00120, 3, (RF, RF, RF_IF), rd_rn_rm),
24555 cCL("frdsm", eb00140, 3, (RF, RF, RF_IF), rd_rn_rm),
24556 cCL("frdsz", eb00160, 3, (RF, RF, RF_IF), rd_rn_rm),
24557 cCL("frdd", eb00180, 3, (RF, RF, RF_IF), rd_rn_rm),
24558 cCL("frddp", eb001a0, 3, (RF, RF, RF_IF), rd_rn_rm),
24559 cCL("frddm", eb001c0, 3, (RF, RF, RF_IF), rd_rn_rm),
24560 cCL("frddz", eb001e0, 3, (RF, RF, RF_IF), rd_rn_rm),
24561 cCL("frde", eb80100, 3, (RF, RF, RF_IF), rd_rn_rm),
24562 cCL("frdep", eb80120, 3, (RF, RF, RF_IF), rd_rn_rm),
24563 cCL("frdem", eb80140, 3, (RF, RF, RF_IF), rd_rn_rm),
24564 cCL("frdez", eb80160, 3, (RF, RF, RF_IF), rd_rn_rm),
24566 cCL("pols", ec00100, 3, (RF, RF, RF_IF), rd_rn_rm),
24567 cCL("polsp", ec00120, 3, (RF, RF, RF_IF), rd_rn_rm),
24568 cCL("polsm", ec00140, 3, (RF, RF, RF_IF), rd_rn_rm),
24569 cCL("polsz", ec00160, 3, (RF, RF, RF_IF), rd_rn_rm),
24570 cCL("pold", ec00180, 3, (RF, RF, RF_IF), rd_rn_rm),
24571 cCL("poldp", ec001a0, 3, (RF, RF, RF_IF), rd_rn_rm),
24572 cCL("poldm", ec001c0, 3, (RF, RF, RF_IF), rd_rn_rm),
24573 cCL("poldz", ec001e0, 3, (RF, RF, RF_IF), rd_rn_rm),
24574 cCL("pole", ec80100, 3, (RF, RF, RF_IF), rd_rn_rm),
24575 cCL("polep", ec80120, 3, (RF, RF, RF_IF), rd_rn_rm),
24576 cCL("polem", ec80140, 3, (RF, RF, RF_IF), rd_rn_rm),
24577 cCL("polez", ec80160, 3, (RF, RF, RF_IF), rd_rn_rm),
24579 cCE("cmf", e90f110, 2, (RF, RF_IF), fpa_cmp),
24580 C3E("cmfe", ed0f110, 2, (RF, RF_IF), fpa_cmp),
24581 cCE("cnf", eb0f110, 2, (RF, RF_IF), fpa_cmp),
24582 C3E("cnfe", ef0f110, 2, (RF, RF_IF), fpa_cmp),
24584 cCL("flts", e000110, 2, (RF, RR), rn_rd),
24585 cCL("fltsp", e000130, 2, (RF, RR), rn_rd),
24586 cCL("fltsm", e000150, 2, (RF, RR), rn_rd),
24587 cCL("fltsz", e000170, 2, (RF, RR), rn_rd),
24588 cCL("fltd", e000190, 2, (RF, RR), rn_rd),
24589 cCL("fltdp", e0001b0, 2, (RF, RR), rn_rd),
24590 cCL("fltdm", e0001d0, 2, (RF, RR), rn_rd),
24591 cCL("fltdz", e0001f0, 2, (RF, RR), rn_rd),
24592 cCL("flte", e080110, 2, (RF, RR), rn_rd),
24593 cCL("fltep", e080130, 2, (RF, RR), rn_rd),
24594 cCL("fltem", e080150, 2, (RF, RR), rn_rd),
24595 cCL("fltez", e080170, 2, (RF, RR), rn_rd),
24597 /* The implementation of the FIX instruction is broken on some
24598 assemblers, in that it accepts a precision specifier as well as a
24599 rounding specifier, despite the fact that this is meaningless.
24600 To be more compatible, we accept it as well, though of course it
24601 does not set any bits. */
24602 cCE("fix", e100110, 2, (RR, RF), rd_rm),
24603 cCL("fixp", e100130, 2, (RR, RF), rd_rm),
24604 cCL("fixm", e100150, 2, (RR, RF), rd_rm),
24605 cCL("fixz", e100170, 2, (RR, RF), rd_rm),
24606 cCL("fixsp", e100130, 2, (RR, RF), rd_rm),
24607 cCL("fixsm", e100150, 2, (RR, RF), rd_rm),
24608 cCL("fixsz", e100170, 2, (RR, RF), rd_rm),
24609 cCL("fixdp", e100130, 2, (RR, RF), rd_rm),
24610 cCL("fixdm", e100150, 2, (RR, RF), rd_rm),
24611 cCL("fixdz", e100170, 2, (RR, RF), rd_rm),
24612 cCL("fixep", e100130, 2, (RR, RF), rd_rm),
24613 cCL("fixem", e100150, 2, (RR, RF), rd_rm),
24614 cCL("fixez", e100170, 2, (RR, RF), rd_rm),
24616 /* Instructions that were new with the real FPA, call them V2. */
24618 #define ARM_VARIANT & fpu_fpa_ext_v2
24620 cCE("lfm", c100200, 3, (RF, I4b, ADDR), fpa_ldmstm),
24621 cCL("lfmfd", c900200, 3, (RF, I4b, ADDR), fpa_ldmstm),
24622 cCL("lfmea", d100200, 3, (RF, I4b, ADDR), fpa_ldmstm),
24623 cCE("sfm", c000200, 3, (RF, I4b, ADDR), fpa_ldmstm),
24624 cCL("sfmfd", d000200, 3, (RF, I4b, ADDR), fpa_ldmstm),
24625 cCL("sfmea", c800200, 3, (RF, I4b, ADDR), fpa_ldmstm),
24628 #define ARM_VARIANT & fpu_vfp_ext_v1xd /* VFP V1xD (single precision). */
24629 #undef THUMB_VARIANT
24630 #define THUMB_VARIANT & arm_ext_v6t2
24631 mcCE(vmrs, ef00a10, 2, (APSR_RR, RVC), vmrs),
24632 mcCE(vmsr, ee00a10, 2, (RVC, RR), vmsr),
24633 #undef THUMB_VARIANT
24635 /* Moves and type conversions. */
24636 cCE("fmstat", ef1fa10, 0, (), noargs),
24637 cCE("fsitos", eb80ac0, 2, (RVS, RVS), vfp_sp_monadic),
24638 cCE("fuitos", eb80a40, 2, (RVS, RVS), vfp_sp_monadic),
24639 cCE("ftosis", ebd0a40, 2, (RVS, RVS), vfp_sp_monadic),
24640 cCE("ftosizs", ebd0ac0, 2, (RVS, RVS), vfp_sp_monadic),
24641 cCE("ftouis", ebc0a40, 2, (RVS, RVS), vfp_sp_monadic),
24642 cCE("ftouizs", ebc0ac0, 2, (RVS, RVS), vfp_sp_monadic),
24643 cCE("fmrx", ef00a10, 2, (RR, RVC), rd_rn),
24644 cCE("fmxr", ee00a10, 2, (RVC, RR), rn_rd),
24646 /* Memory operations. */
24647 cCE("flds", d100a00, 2, (RVS, ADDRGLDC), vfp_sp_ldst),
24648 cCE("fsts", d000a00, 2, (RVS, ADDRGLDC), vfp_sp_ldst),
24649 cCE("fldmias", c900a00, 2, (RRnpctw, VRSLST), vfp_sp_ldstmia),
24650 cCE("fldmfds", c900a00, 2, (RRnpctw, VRSLST), vfp_sp_ldstmia),
24651 cCE("fldmdbs", d300a00, 2, (RRnpctw, VRSLST), vfp_sp_ldstmdb),
24652 cCE("fldmeas", d300a00, 2, (RRnpctw, VRSLST), vfp_sp_ldstmdb),
24653 cCE("fldmiax", c900b00, 2, (RRnpctw, VRDLST), vfp_xp_ldstmia),
24654 cCE("fldmfdx", c900b00, 2, (RRnpctw, VRDLST), vfp_xp_ldstmia),
24655 cCE("fldmdbx", d300b00, 2, (RRnpctw, VRDLST), vfp_xp_ldstmdb),
24656 cCE("fldmeax", d300b00, 2, (RRnpctw, VRDLST), vfp_xp_ldstmdb),
24657 cCE("fstmias", c800a00, 2, (RRnpctw, VRSLST), vfp_sp_ldstmia),
24658 cCE("fstmeas", c800a00, 2, (RRnpctw, VRSLST), vfp_sp_ldstmia),
24659 cCE("fstmdbs", d200a00, 2, (RRnpctw, VRSLST), vfp_sp_ldstmdb),
24660 cCE("fstmfds", d200a00, 2, (RRnpctw, VRSLST), vfp_sp_ldstmdb),
24661 cCE("fstmiax", c800b00, 2, (RRnpctw, VRDLST), vfp_xp_ldstmia),
24662 cCE("fstmeax", c800b00, 2, (RRnpctw, VRDLST), vfp_xp_ldstmia),
24663 cCE("fstmdbx", d200b00, 2, (RRnpctw, VRDLST), vfp_xp_ldstmdb),
24664 cCE("fstmfdx", d200b00, 2, (RRnpctw, VRDLST), vfp_xp_ldstmdb),
24666 /* Monadic operations. */
24667 cCE("fabss", eb00ac0, 2, (RVS, RVS), vfp_sp_monadic),
24668 cCE("fnegs", eb10a40, 2, (RVS, RVS), vfp_sp_monadic),
24669 cCE("fsqrts", eb10ac0, 2, (RVS, RVS), vfp_sp_monadic),
24671 /* Dyadic operations. */
24672 cCE("fadds", e300a00, 3, (RVS, RVS, RVS), vfp_sp_dyadic),
24673 cCE("fsubs", e300a40, 3, (RVS, RVS, RVS), vfp_sp_dyadic),
24674 cCE("fmuls", e200a00, 3, (RVS, RVS, RVS), vfp_sp_dyadic),
24675 cCE("fdivs", e800a00, 3, (RVS, RVS, RVS), vfp_sp_dyadic),
24676 cCE("fmacs", e000a00, 3, (RVS, RVS, RVS), vfp_sp_dyadic),
24677 cCE("fmscs", e100a00, 3, (RVS, RVS, RVS), vfp_sp_dyadic),
24678 cCE("fnmuls", e200a40, 3, (RVS, RVS, RVS), vfp_sp_dyadic),
24679 cCE("fnmacs", e000a40, 3, (RVS, RVS, RVS), vfp_sp_dyadic),
24680 cCE("fnmscs", e100a40, 3, (RVS, RVS, RVS), vfp_sp_dyadic),
24683 cCE("fcmps", eb40a40, 2, (RVS, RVS), vfp_sp_monadic),
24684 cCE("fcmpzs", eb50a40, 1, (RVS), vfp_sp_compare_z),
24685 cCE("fcmpes", eb40ac0, 2, (RVS, RVS), vfp_sp_monadic),
24686 cCE("fcmpezs", eb50ac0, 1, (RVS), vfp_sp_compare_z),
24688 /* Double precision load/store are still present on single precision
24689 implementations. */
24690 cCE("fldd", d100b00, 2, (RVD, ADDRGLDC), vfp_dp_ldst),
24691 cCE("fstd", d000b00, 2, (RVD, ADDRGLDC), vfp_dp_ldst),
24692 cCE("fldmiad", c900b00, 2, (RRnpctw, VRDLST), vfp_dp_ldstmia),
24693 cCE("fldmfdd", c900b00, 2, (RRnpctw, VRDLST), vfp_dp_ldstmia),
24694 cCE("fldmdbd", d300b00, 2, (RRnpctw, VRDLST), vfp_dp_ldstmdb),
24695 cCE("fldmead", d300b00, 2, (RRnpctw, VRDLST), vfp_dp_ldstmdb),
24696 cCE("fstmiad", c800b00, 2, (RRnpctw, VRDLST), vfp_dp_ldstmia),
24697 cCE("fstmead", c800b00, 2, (RRnpctw, VRDLST), vfp_dp_ldstmia),
24698 cCE("fstmdbd", d200b00, 2, (RRnpctw, VRDLST), vfp_dp_ldstmdb),
24699 cCE("fstmfdd", d200b00, 2, (RRnpctw, VRDLST), vfp_dp_ldstmdb),
24702 #define ARM_VARIANT & fpu_vfp_ext_v1 /* VFP V1 (Double precision). */
24704 /* Moves and type conversions. */
24705 cCE("fcvtds", eb70ac0, 2, (RVD, RVS), vfp_dp_sp_cvt),
24706 cCE("fcvtsd", eb70bc0, 2, (RVS, RVD), vfp_sp_dp_cvt),
24707 cCE("fmdhr", e200b10, 2, (RVD, RR), vfp_dp_rn_rd),
24708 cCE("fmdlr", e000b10, 2, (RVD, RR), vfp_dp_rn_rd),
24709 cCE("fmrdh", e300b10, 2, (RR, RVD), vfp_dp_rd_rn),
24710 cCE("fmrdl", e100b10, 2, (RR, RVD), vfp_dp_rd_rn),
24711 cCE("fsitod", eb80bc0, 2, (RVD, RVS), vfp_dp_sp_cvt),
24712 cCE("fuitod", eb80b40, 2, (RVD, RVS), vfp_dp_sp_cvt),
24713 cCE("ftosid", ebd0b40, 2, (RVS, RVD), vfp_sp_dp_cvt),
24714 cCE("ftosizd", ebd0bc0, 2, (RVS, RVD), vfp_sp_dp_cvt),
24715 cCE("ftouid", ebc0b40, 2, (RVS, RVD), vfp_sp_dp_cvt),
24716 cCE("ftouizd", ebc0bc0, 2, (RVS, RVD), vfp_sp_dp_cvt),
24718 /* Monadic operations. */
24719 cCE("fabsd", eb00bc0, 2, (RVD, RVD), vfp_dp_rd_rm),
24720 cCE("fnegd", eb10b40, 2, (RVD, RVD), vfp_dp_rd_rm),
24721 cCE("fsqrtd", eb10bc0, 2, (RVD, RVD), vfp_dp_rd_rm),
24723 /* Dyadic operations. */
24724 cCE("faddd", e300b00, 3, (RVD, RVD, RVD), vfp_dp_rd_rn_rm),
24725 cCE("fsubd", e300b40, 3, (RVD, RVD, RVD), vfp_dp_rd_rn_rm),
24726 cCE("fmuld", e200b00, 3, (RVD, RVD, RVD), vfp_dp_rd_rn_rm),
24727 cCE("fdivd", e800b00, 3, (RVD, RVD, RVD), vfp_dp_rd_rn_rm),
24728 cCE("fmacd", e000b00, 3, (RVD, RVD, RVD), vfp_dp_rd_rn_rm),
24729 cCE("fmscd", e100b00, 3, (RVD, RVD, RVD), vfp_dp_rd_rn_rm),
24730 cCE("fnmuld", e200b40, 3, (RVD, RVD, RVD), vfp_dp_rd_rn_rm),
24731 cCE("fnmacd", e000b40, 3, (RVD, RVD, RVD), vfp_dp_rd_rn_rm),
24732 cCE("fnmscd", e100b40, 3, (RVD, RVD, RVD), vfp_dp_rd_rn_rm),
24735 cCE("fcmpd", eb40b40, 2, (RVD, RVD), vfp_dp_rd_rm),
24736 cCE("fcmpzd", eb50b40, 1, (RVD), vfp_dp_rd),
24737 cCE("fcmped", eb40bc0, 2, (RVD, RVD), vfp_dp_rd_rm),
24738 cCE("fcmpezd", eb50bc0, 1, (RVD), vfp_dp_rd),
24740 /* Instructions which may belong to either the Neon or VFP instruction sets.
24741 Individual encoder functions perform additional architecture checks. */
24743 #define ARM_VARIANT & fpu_vfp_ext_v1xd
24744 #undef THUMB_VARIANT
24745 #define THUMB_VARIANT & fpu_vfp_ext_v1xd
24747 /* These mnemonics are unique to VFP. */
24748 NCE(vsqrt, 0, 2, (RVSD, RVSD), vfp_nsyn_sqrt),
24749 NCE(vdiv, 0, 3, (RVSD, RVSD, RVSD), vfp_nsyn_div),
24750 nCE(vnmul, _vnmul, 3, (RVSD, RVSD, RVSD), vfp_nsyn_nmul),
24751 nCE(vnmla, _vnmla, 3, (RVSD, RVSD, RVSD), vfp_nsyn_nmul),
24752 nCE(vnmls, _vnmls, 3, (RVSD, RVSD, RVSD), vfp_nsyn_nmul),
24753 NCE(vpush, 0, 1, (VRSDLST), vfp_nsyn_push),
24754 NCE(vpop, 0, 1, (VRSDLST), vfp_nsyn_pop),
24755 NCE(vcvtz, 0, 2, (RVSD, RVSD), vfp_nsyn_cvtz),
24757 /* Mnemonics shared by Neon and VFP. */
24758 nCEF(vmls, _vmls, 3, (RNSDQ, oRNSDQ, RNSDQ_RNSC), neon_mac_maybe_scalar),
24760 NCE(vldm, c900b00, 2, (RRnpctw, VRSDLST), neon_ldm_stm),
24761 NCE(vldmia, c900b00, 2, (RRnpctw, VRSDLST), neon_ldm_stm),
24762 NCE(vldmdb, d100b00, 2, (RRnpctw, VRSDLST), neon_ldm_stm),
24763 NCE(vstm, c800b00, 2, (RRnpctw, VRSDLST), neon_ldm_stm),
24764 NCE(vstmia, c800b00, 2, (RRnpctw, VRSDLST), neon_ldm_stm),
24765 NCE(vstmdb, d000b00, 2, (RRnpctw, VRSDLST), neon_ldm_stm),
24767 mnCEF(vcvt, _vcvt, 3, (RNSDQMQ, RNSDQMQ, oI32z), neon_cvt),
24768 nCEF(vcvtr, _vcvt, 2, (RNSDQ, RNSDQ), neon_cvtr),
24769 MNCEF(vcvtb, eb20a40, 3, (RVSDMQ, RVSDMQ, oI32b), neon_cvtb),
24770 MNCEF(vcvtt, eb20a40, 3, (RVSDMQ, RVSDMQ, oI32b), neon_cvtt),
24773 /* NOTE: All VMOV encoding is special-cased! */
24774 NCE(vmovq, 0, 1, (VMOV), neon_mov),
24776 #undef THUMB_VARIANT
24777 /* Could be either VLDR/VSTR or VLDR/VSTR (system register) which are guarded
24778 by different feature bits. Since we are setting the Thumb guard, we can
24779 require Thumb-1 which makes it a nop guard and set the right feature bit in
24780 do_vldr_vstr (). */
24781 #define THUMB_VARIANT & arm_ext_v4t
24782 NCE(vldr, d100b00, 2, (VLDR, ADDRGLDC), vldr_vstr),
24783 NCE(vstr, d000b00, 2, (VLDR, ADDRGLDC), vldr_vstr),
24786 #define ARM_VARIANT & arm_ext_fp16
24787 #undef THUMB_VARIANT
24788 #define THUMB_VARIANT & arm_ext_fp16
24789 /* New instructions added from v8.2, allowing the extraction and insertion of
24790 the upper 16 bits of a 32-bit vector register. */
24791 NCE (vmovx, eb00a40, 2, (RVS, RVS), neon_movhf),
24792 NCE (vins, eb00ac0, 2, (RVS, RVS), neon_movhf),
24794 /* New backported fma/fms instructions optional in v8.2. */
24795 NCE (vfmal, 810, 3, (RNDQ, RNSD, RNSD_RNSC), neon_vfmal),
24796 NCE (vfmsl, 810, 3, (RNDQ, RNSD, RNSD_RNSC), neon_vfmsl),
24798 #undef THUMB_VARIANT
24799 #define THUMB_VARIANT & fpu_neon_ext_v1
24801 #define ARM_VARIANT & fpu_neon_ext_v1
24803 /* Data processing with three registers of the same length. */
24804 /* integer ops, valid types S8 S16 S32 U8 U16 U32. */
24805 NUF(vaba, 0000710, 3, (RNDQ, RNDQ, RNDQ), neon_dyadic_i_su),
24806 NUF(vabaq, 0000710, 3, (RNQ, RNQ, RNQ), neon_dyadic_i_su),
24807 NUF(vhaddq, 0000000, 3, (RNQ, oRNQ, RNQ), neon_dyadic_i_su),
24808 NUF(vrhaddq, 0000100, 3, (RNQ, oRNQ, RNQ), neon_dyadic_i_su),
24809 NUF(vhsubq, 0000200, 3, (RNQ, oRNQ, RNQ), neon_dyadic_i_su),
24810 /* integer ops, valid types S8 S16 S32 S64 U8 U16 U32 U64. */
24811 NUF(vqaddq, 0000010, 3, (RNQ, oRNQ, RNQ), neon_dyadic_i64_su),
24812 NUF(vqsubq, 0000210, 3, (RNQ, oRNQ, RNQ), neon_dyadic_i64_su),
24813 NUF(vrshlq, 0000500, 3, (RNQ, oRNQ, RNQ), neon_rshl),
24814 NUF(vqrshlq, 0000510, 3, (RNQ, oRNQ, RNQ), neon_rshl),
24815 /* If not immediate, fall back to neon_dyadic_i64_su.
24816 shl should accept I8 I16 I32 I64,
24817 qshl should accept S8 S16 S32 S64 U8 U16 U32 U64. */
24818 nUF(vshlq, _vshl, 3, (RNQ, oRNQ, RNDQ_I63b), neon_shl),
24819 nUF(vqshlq, _vqshl, 3, (RNQ, oRNQ, RNDQ_I63b), neon_qshl),
24820 /* Logic ops, types optional & ignored. */
24821 nUF(vandq, _vand, 3, (RNQ, oRNQ, RNDQ_Ibig), neon_logic),
24822 nUF(vbicq, _vbic, 3, (RNQ, oRNQ, RNDQ_Ibig), neon_logic),
24823 nUF(vorrq, _vorr, 3, (RNQ, oRNQ, RNDQ_Ibig), neon_logic),
24824 nUF(vornq, _vorn, 3, (RNQ, oRNQ, RNDQ_Ibig), neon_logic),
24825 nUF(veorq, _veor, 3, (RNQ, oRNQ, RNQ), neon_logic),
24826 /* Bitfield ops, untyped. */
24827 NUF(vbsl, 1100110, 3, (RNDQ, RNDQ, RNDQ), neon_bitfield),
24828 NUF(vbslq, 1100110, 3, (RNQ, RNQ, RNQ), neon_bitfield),
24829 NUF(vbit, 1200110, 3, (RNDQ, RNDQ, RNDQ), neon_bitfield),
24830 NUF(vbitq, 1200110, 3, (RNQ, RNQ, RNQ), neon_bitfield),
24831 NUF(vbif, 1300110, 3, (RNDQ, RNDQ, RNDQ), neon_bitfield),
24832 NUF(vbifq, 1300110, 3, (RNQ, RNQ, RNQ), neon_bitfield),
24833 /* Int and float variants, types S8 S16 S32 U8 U16 U32 F16 F32. */
24834 nUF(vabdq, _vabd, 3, (RNQ, oRNQ, RNQ), neon_dyadic_if_su),
24835 nUF(vmaxq, _vmax, 3, (RNQ, oRNQ, RNQ), neon_dyadic_if_su),
24836 nUF(vminq, _vmin, 3, (RNQ, oRNQ, RNQ), neon_dyadic_if_su),
24837 /* Comparisons. Types S8 S16 S32 U8 U16 U32 F32. Non-immediate versions fall
24838 back to neon_dyadic_if_su. */
24839 nUF(vcge, _vcge, 3, (RNDQ, oRNDQ, RNDQ_I0), neon_cmp),
24840 nUF(vcgeq, _vcge, 3, (RNQ, oRNQ, RNDQ_I0), neon_cmp),
24841 nUF(vcgt, _vcgt, 3, (RNDQ, oRNDQ, RNDQ_I0), neon_cmp),
24842 nUF(vcgtq, _vcgt, 3, (RNQ, oRNQ, RNDQ_I0), neon_cmp),
24843 nUF(vclt, _vclt, 3, (RNDQ, oRNDQ, RNDQ_I0), neon_cmp_inv),
24844 nUF(vcltq, _vclt, 3, (RNQ, oRNQ, RNDQ_I0), neon_cmp_inv),
24845 nUF(vcle, _vcle, 3, (RNDQ, oRNDQ, RNDQ_I0), neon_cmp_inv),
24846 nUF(vcleq, _vcle, 3, (RNQ, oRNQ, RNDQ_I0), neon_cmp_inv),
24847 /* Comparison. Type I8 I16 I32 F32. */
24848 nUF(vceq, _vceq, 3, (RNDQ, oRNDQ, RNDQ_I0), neon_ceq),
24849 nUF(vceqq, _vceq, 3, (RNQ, oRNQ, RNDQ_I0), neon_ceq),
24850 /* As above, D registers only. */
24851 nUF(vpmax, _vpmax, 3, (RND, oRND, RND), neon_dyadic_if_su_d),
24852 nUF(vpmin, _vpmin, 3, (RND, oRND, RND), neon_dyadic_if_su_d),
24853 /* Int and float variants, signedness unimportant. */
24854 nUF(vmlaq, _vmla, 3, (RNQ, oRNQ, RNDQ_RNSC), neon_mac_maybe_scalar),
24855 nUF(vmlsq, _vmls, 3, (RNQ, oRNQ, RNDQ_RNSC), neon_mac_maybe_scalar),
24856 nUF(vpadd, _vpadd, 3, (RND, oRND, RND), neon_dyadic_if_i_d),
24857 /* Add/sub take types I8 I16 I32 I64 F32. */
24858 nUF(vaddq, _vadd, 3, (RNQ, oRNQ, RNQ), neon_addsub_if_i),
24859 nUF(vsubq, _vsub, 3, (RNQ, oRNQ, RNQ), neon_addsub_if_i),
24860 /* vtst takes sizes 8, 16, 32. */
24861 NUF(vtst, 0000810, 3, (RNDQ, oRNDQ, RNDQ), neon_tst),
24862 NUF(vtstq, 0000810, 3, (RNQ, oRNQ, RNQ), neon_tst),
24863 /* VMUL takes I8 I16 I32 F32 P8. */
24864 nUF(vmulq, _vmul, 3, (RNQ, oRNQ, RNDQ_RNSC), neon_mul),
24865 /* VQD{R}MULH takes S16 S32. */
24866 nUF(vqdmulhq, _vqdmulh, 3, (RNQ, oRNQ, RNDQ_RNSC), neon_qdmulh),
24867 nUF(vqrdmulhq, _vqrdmulh, 3, (RNQ, oRNQ, RNDQ_RNSC), neon_qdmulh),
24868 NUF(vacge, 0000e10, 3, (RNDQ, oRNDQ, RNDQ), neon_fcmp_absolute),
24869 NUF(vacgeq, 0000e10, 3, (RNQ, oRNQ, RNQ), neon_fcmp_absolute),
24870 NUF(vacgt, 0200e10, 3, (RNDQ, oRNDQ, RNDQ), neon_fcmp_absolute),
24871 NUF(vacgtq, 0200e10, 3, (RNQ, oRNQ, RNQ), neon_fcmp_absolute),
24872 NUF(vaclt, 0200e10, 3, (RNDQ, oRNDQ, RNDQ), neon_fcmp_absolute_inv),
24873 NUF(vacltq, 0200e10, 3, (RNQ, oRNQ, RNQ), neon_fcmp_absolute_inv),
24874 NUF(vacle, 0000e10, 3, (RNDQ, oRNDQ, RNDQ), neon_fcmp_absolute_inv),
24875 NUF(vacleq, 0000e10, 3, (RNQ, oRNQ, RNQ), neon_fcmp_absolute_inv),
24876 NUF(vrecps, 0000f10, 3, (RNDQ, oRNDQ, RNDQ), neon_step),
24877 NUF(vrecpsq, 0000f10, 3, (RNQ, oRNQ, RNQ), neon_step),
24878 NUF(vrsqrts, 0200f10, 3, (RNDQ, oRNDQ, RNDQ), neon_step),
24879 NUF(vrsqrtsq, 0200f10, 3, (RNQ, oRNQ, RNQ), neon_step),
24880 /* ARM v8.1 extension. */
24881 nUF (vqrdmlahq, _vqrdmlah, 3, (RNQ, oRNQ, RNDQ_RNSC), neon_qrdmlah),
24882 nUF (vqrdmlsh, _vqrdmlsh, 3, (RNDQ, oRNDQ, RNDQ_RNSC), neon_qrdmlah),
24883 nUF (vqrdmlshq, _vqrdmlsh, 3, (RNQ, oRNQ, RNDQ_RNSC), neon_qrdmlah),
24885 /* Two address, int/float. Types S8 S16 S32 F32. */
24886 NUF(vabsq, 1b10300, 2, (RNQ, RNQ), neon_abs_neg),
24887 NUF(vnegq, 1b10380, 2, (RNQ, RNQ), neon_abs_neg),
24889 /* Data processing with two registers and a shift amount. */
24890 /* Right shifts, and variants with rounding.
24891 Types accepted S8 S16 S32 S64 U8 U16 U32 U64. */
24892 NUF(vshrq, 0800010, 3, (RNQ, oRNQ, I64z), neon_rshift_round_imm),
24893 NUF(vrshrq, 0800210, 3, (RNQ, oRNQ, I64z), neon_rshift_round_imm),
24894 NUF(vsra, 0800110, 3, (RNDQ, oRNDQ, I64), neon_rshift_round_imm),
24895 NUF(vsraq, 0800110, 3, (RNQ, oRNQ, I64), neon_rshift_round_imm),
24896 NUF(vrsra, 0800310, 3, (RNDQ, oRNDQ, I64), neon_rshift_round_imm),
24897 NUF(vrsraq, 0800310, 3, (RNQ, oRNQ, I64), neon_rshift_round_imm),
24898 /* Shift and insert. Sizes accepted 8 16 32 64. */
24899 NUF(vsliq, 1800510, 3, (RNQ, oRNQ, I63), neon_sli),
24900 NUF(vsriq, 1800410, 3, (RNQ, oRNQ, I64), neon_sri),
24901 /* QSHL{U} immediate accepts S8 S16 S32 S64 U8 U16 U32 U64. */
24902 NUF(vqshluq, 1800610, 3, (RNQ, oRNQ, I63), neon_qshlu_imm),
24903 /* Right shift immediate, saturating & narrowing, with rounding variants.
24904 Types accepted S16 S32 S64 U16 U32 U64. */
24905 NUF(vqshrn, 0800910, 3, (RND, RNQ, I32z), neon_rshift_sat_narrow),
24906 NUF(vqrshrn, 0800950, 3, (RND, RNQ, I32z), neon_rshift_sat_narrow),
24907 /* As above, unsigned. Types accepted S16 S32 S64. */
24908 NUF(vqshrun, 0800810, 3, (RND, RNQ, I32z), neon_rshift_sat_narrow_u),
24909 NUF(vqrshrun, 0800850, 3, (RND, RNQ, I32z), neon_rshift_sat_narrow_u),
24910 /* Right shift narrowing. Types accepted I16 I32 I64. */
24911 NUF(vshrn, 0800810, 3, (RND, RNQ, I32z), neon_rshift_narrow),
24912 NUF(vrshrn, 0800850, 3, (RND, RNQ, I32z), neon_rshift_narrow),
24913 /* Special case. Types S8 S16 S32 U8 U16 U32. Handles max shift variant. */
24914 nUF(vshll, _vshll, 3, (RNQ, RND, I32), neon_shll),
24915 /* CVT with optional immediate for fixed-point variant. */
24916 nUF(vcvtq, _vcvt, 3, (RNQ, RNQ, oI32b), neon_cvt),
24918 nUF(vmvnq, _vmvn, 2, (RNQ, RNDQ_Ibig), neon_mvn),
24920 /* Data processing, three registers of different lengths. */
24921 /* Dyadic, long insns. Types S8 S16 S32 U8 U16 U32. */
24922 NUF(vabal, 0800500, 3, (RNQ, RND, RND), neon_abal),
24923 /* If not scalar, fall back to neon_dyadic_long.
24924 Vector types as above, scalar types S16 S32 U16 U32. */
24925 nUF(vmlal, _vmlal, 3, (RNQ, RND, RND_RNSC), neon_mac_maybe_scalar_long),
24926 nUF(vmlsl, _vmlsl, 3, (RNQ, RND, RND_RNSC), neon_mac_maybe_scalar_long),
24927 /* Dyadic, widening insns. Types S8 S16 S32 U8 U16 U32. */
24928 NUF(vaddw, 0800100, 3, (RNQ, oRNQ, RND), neon_dyadic_wide),
24929 NUF(vsubw, 0800300, 3, (RNQ, oRNQ, RND), neon_dyadic_wide),
24930 /* Dyadic, narrowing insns. Types I16 I32 I64. */
24931 NUF(vaddhn, 0800400, 3, (RND, RNQ, RNQ), neon_dyadic_narrow),
24932 NUF(vraddhn, 1800400, 3, (RND, RNQ, RNQ), neon_dyadic_narrow),
24933 NUF(vsubhn, 0800600, 3, (RND, RNQ, RNQ), neon_dyadic_narrow),
24934 NUF(vrsubhn, 1800600, 3, (RND, RNQ, RNQ), neon_dyadic_narrow),
24935 /* Saturating doubling multiplies. Types S16 S32. */
24936 nUF(vqdmlal, _vqdmlal, 3, (RNQ, RND, RND_RNSC), neon_mul_sat_scalar_long),
24937 nUF(vqdmlsl, _vqdmlsl, 3, (RNQ, RND, RND_RNSC), neon_mul_sat_scalar_long),
24938 nUF(vqdmull, _vqdmull, 3, (RNQ, RND, RND_RNSC), neon_mul_sat_scalar_long),
24939 /* VMULL. Vector types S8 S16 S32 U8 U16 U32 P8, scalar types
24940 S16 S32 U16 U32. */
24941 nUF(vmull, _vmull, 3, (RNQ, RND, RND_RNSC), neon_vmull),
24943 /* Extract. Size 8. */
24944 NUF(vext, 0b00000, 4, (RNDQ, oRNDQ, RNDQ, I15), neon_ext),
24945 NUF(vextq, 0b00000, 4, (RNQ, oRNQ, RNQ, I15), neon_ext),
24947 /* Two registers, miscellaneous. */
24948 /* Reverse. Sizes 8 16 32 (must be < size in opcode). */
24949 NUF(vrev64q, 1b00000, 2, (RNQ, RNQ), neon_rev),
24950 NUF(vrev32q, 1b00080, 2, (RNQ, RNQ), neon_rev),
24951 NUF(vrev16q, 1b00100, 2, (RNQ, RNQ), neon_rev),
24952 /* Vector replicate. Sizes 8 16 32. */
24953 nCE(vdupq, _vdup, 2, (RNQ, RR_RNSC), neon_dup),
24954 /* VMOVL. Types S8 S16 S32 U8 U16 U32. */
24955 NUF(vmovl, 0800a10, 2, (RNQ, RND), neon_movl),
24956 /* VMOVN. Types I16 I32 I64. */
24957 nUF(vmovn, _vmovn, 2, (RND, RNQ), neon_movn),
24958 /* VQMOVN. Types S16 S32 S64 U16 U32 U64. */
24959 nUF(vqmovn, _vqmovn, 2, (RND, RNQ), neon_qmovn),
24960 /* VQMOVUN. Types S16 S32 S64. */
24961 nUF(vqmovun, _vqmovun, 2, (RND, RNQ), neon_qmovun),
24962 /* VZIP / VUZP. Sizes 8 16 32. */
24963 NUF(vzip, 1b20180, 2, (RNDQ, RNDQ), neon_zip_uzp),
24964 NUF(vzipq, 1b20180, 2, (RNQ, RNQ), neon_zip_uzp),
24965 NUF(vuzp, 1b20100, 2, (RNDQ, RNDQ), neon_zip_uzp),
24966 NUF(vuzpq, 1b20100, 2, (RNQ, RNQ), neon_zip_uzp),
24967 /* VQABS / VQNEG. Types S8 S16 S32. */
24968 NUF(vqabsq, 1b00700, 2, (RNQ, RNQ), neon_sat_abs_neg),
24969 NUF(vqnegq, 1b00780, 2, (RNQ, RNQ), neon_sat_abs_neg),
24970 /* Pairwise, lengthening. Types S8 S16 S32 U8 U16 U32. */
24971 NUF(vpadal, 1b00600, 2, (RNDQ, RNDQ), neon_pair_long),
24972 NUF(vpadalq, 1b00600, 2, (RNQ, RNQ), neon_pair_long),
24973 NUF(vpaddl, 1b00200, 2, (RNDQ, RNDQ), neon_pair_long),
24974 NUF(vpaddlq, 1b00200, 2, (RNQ, RNQ), neon_pair_long),
24975 /* Reciprocal estimates. Types U32 F16 F32. */
24976 NUF(vrecpe, 1b30400, 2, (RNDQ, RNDQ), neon_recip_est),
24977 NUF(vrecpeq, 1b30400, 2, (RNQ, RNQ), neon_recip_est),
24978 NUF(vrsqrte, 1b30480, 2, (RNDQ, RNDQ), neon_recip_est),
24979 NUF(vrsqrteq, 1b30480, 2, (RNQ, RNQ), neon_recip_est),
24980 /* VCLS. Types S8 S16 S32. */
24981 NUF(vclsq, 1b00400, 2, (RNQ, RNQ), neon_cls),
24982 /* VCLZ. Types I8 I16 I32. */
24983 NUF(vclzq, 1b00480, 2, (RNQ, RNQ), neon_clz),
24984 /* VCNT. Size 8. */
24985 NUF(vcnt, 1b00500, 2, (RNDQ, RNDQ), neon_cnt),
24986 NUF(vcntq, 1b00500, 2, (RNQ, RNQ), neon_cnt),
24987 /* Two address, untyped. */
24988 NUF(vswp, 1b20000, 2, (RNDQ, RNDQ), neon_swp),
24989 NUF(vswpq, 1b20000, 2, (RNQ, RNQ), neon_swp),
24990 /* VTRN. Sizes 8 16 32. */
24991 nUF(vtrn, _vtrn, 2, (RNDQ, RNDQ), neon_trn),
24992 nUF(vtrnq, _vtrn, 2, (RNQ, RNQ), neon_trn),
24994 /* Table lookup. Size 8. */
24995 NUF(vtbl, 1b00800, 3, (RND, NRDLST, RND), neon_tbl_tbx),
24996 NUF(vtbx, 1b00840, 3, (RND, NRDLST, RND), neon_tbl_tbx),
24998 #undef THUMB_VARIANT
24999 #define THUMB_VARIANT & fpu_vfp_v3_or_neon_ext
25001 #define ARM_VARIANT & fpu_vfp_v3_or_neon_ext
25003 /* Neon element/structure load/store. */
25004 nUF(vld1, _vld1, 2, (NSTRLST, ADDR), neon_ldx_stx),
25005 nUF(vst1, _vst1, 2, (NSTRLST, ADDR), neon_ldx_stx),
25006 nUF(vld2, _vld2, 2, (NSTRLST, ADDR), neon_ldx_stx),
25007 nUF(vst2, _vst2, 2, (NSTRLST, ADDR), neon_ldx_stx),
25008 nUF(vld3, _vld3, 2, (NSTRLST, ADDR), neon_ldx_stx),
25009 nUF(vst3, _vst3, 2, (NSTRLST, ADDR), neon_ldx_stx),
25010 nUF(vld4, _vld4, 2, (NSTRLST, ADDR), neon_ldx_stx),
25011 nUF(vst4, _vst4, 2, (NSTRLST, ADDR), neon_ldx_stx),
25013 #undef THUMB_VARIANT
25014 #define THUMB_VARIANT & fpu_vfp_ext_v3xd
25016 #define ARM_VARIANT & fpu_vfp_ext_v3xd
25017 cCE("fconsts", eb00a00, 2, (RVS, I255), vfp_sp_const),
25018 cCE("fshtos", eba0a40, 2, (RVS, I16z), vfp_sp_conv_16),
25019 cCE("fsltos", eba0ac0, 2, (RVS, I32), vfp_sp_conv_32),
25020 cCE("fuhtos", ebb0a40, 2, (RVS, I16z), vfp_sp_conv_16),
25021 cCE("fultos", ebb0ac0, 2, (RVS, I32), vfp_sp_conv_32),
25022 cCE("ftoshs", ebe0a40, 2, (RVS, I16z), vfp_sp_conv_16),
25023 cCE("ftosls", ebe0ac0, 2, (RVS, I32), vfp_sp_conv_32),
25024 cCE("ftouhs", ebf0a40, 2, (RVS, I16z), vfp_sp_conv_16),
25025 cCE("ftouls", ebf0ac0, 2, (RVS, I32), vfp_sp_conv_32),
25027 #undef THUMB_VARIANT
25028 #define THUMB_VARIANT & fpu_vfp_ext_v3
25030 #define ARM_VARIANT & fpu_vfp_ext_v3
25032 cCE("fconstd", eb00b00, 2, (RVD, I255), vfp_dp_const),
25033 cCE("fshtod", eba0b40, 2, (RVD, I16z), vfp_dp_conv_16),
25034 cCE("fsltod", eba0bc0, 2, (RVD, I32), vfp_dp_conv_32),
25035 cCE("fuhtod", ebb0b40, 2, (RVD, I16z), vfp_dp_conv_16),
25036 cCE("fultod", ebb0bc0, 2, (RVD, I32), vfp_dp_conv_32),
25037 cCE("ftoshd", ebe0b40, 2, (RVD, I16z), vfp_dp_conv_16),
25038 cCE("ftosld", ebe0bc0, 2, (RVD, I32), vfp_dp_conv_32),
25039 cCE("ftouhd", ebf0b40, 2, (RVD, I16z), vfp_dp_conv_16),
25040 cCE("ftould", ebf0bc0, 2, (RVD, I32), vfp_dp_conv_32),
25043 #define ARM_VARIANT & fpu_vfp_ext_fma
25044 #undef THUMB_VARIANT
25045 #define THUMB_VARIANT & fpu_vfp_ext_fma
25046 /* Mnemonics shared by Neon, VFP and MVE. These are included in the
25047 VFP FMA variant; NEON and VFP FMA always includes the NEON
25048 FMA instructions. */
25049 mnCEF(vfma, _vfma, 3, (RNSDQMQ, oRNSDQMQ, RNSDQMQR), neon_fmac),
25050 mnCEF(vfms, _vfms, 3, (RNSDQMQ, oRNSDQMQ, RNSDQMQ), neon_fmac),
25052 /* ffmas/ffmad/ffmss/ffmsd are dummy mnemonics to satisfy gas;
25053 the v form should always be used. */
25054 cCE("ffmas", ea00a00, 3, (RVS, RVS, RVS), vfp_sp_dyadic),
25055 cCE("ffnmas", ea00a40, 3, (RVS, RVS, RVS), vfp_sp_dyadic),
25056 cCE("ffmad", ea00b00, 3, (RVD, RVD, RVD), vfp_dp_rd_rn_rm),
25057 cCE("ffnmad", ea00b40, 3, (RVD, RVD, RVD), vfp_dp_rd_rn_rm),
25058 nCE(vfnma, _vfnma, 3, (RVSD, RVSD, RVSD), vfp_nsyn_nmul),
25059 nCE(vfnms, _vfnms, 3, (RVSD, RVSD, RVSD), vfp_nsyn_nmul),
25061 #undef THUMB_VARIANT
25063 #define ARM_VARIANT & arm_cext_xscale /* Intel XScale extensions. */
25065 cCE("mia", e200010, 3, (RXA, RRnpc, RRnpc), xsc_mia),
25066 cCE("miaph", e280010, 3, (RXA, RRnpc, RRnpc), xsc_mia),
25067 cCE("miabb", e2c0010, 3, (RXA, RRnpc, RRnpc), xsc_mia),
25068 cCE("miabt", e2d0010, 3, (RXA, RRnpc, RRnpc), xsc_mia),
25069 cCE("miatb", e2e0010, 3, (RXA, RRnpc, RRnpc), xsc_mia),
25070 cCE("miatt", e2f0010, 3, (RXA, RRnpc, RRnpc), xsc_mia),
25071 cCE("mar", c400000, 3, (RXA, RRnpc, RRnpc), xsc_mar),
25072 cCE("mra", c500000, 3, (RRnpc, RRnpc, RXA), xsc_mra),
25075 #define ARM_VARIANT & arm_cext_iwmmxt /* Intel Wireless MMX technology. */
25077 cCE("tandcb", e13f130, 1, (RR), iwmmxt_tandorc),
25078 cCE("tandch", e53f130, 1, (RR), iwmmxt_tandorc),
25079 cCE("tandcw", e93f130, 1, (RR), iwmmxt_tandorc),
25080 cCE("tbcstb", e400010, 2, (RIWR, RR), rn_rd),
25081 cCE("tbcsth", e400050, 2, (RIWR, RR), rn_rd),
25082 cCE("tbcstw", e400090, 2, (RIWR, RR), rn_rd),
25083 cCE("textrcb", e130170, 2, (RR, I7), iwmmxt_textrc),
25084 cCE("textrch", e530170, 2, (RR, I7), iwmmxt_textrc),
25085 cCE("textrcw", e930170, 2, (RR, I7), iwmmxt_textrc),
25086 cCE("textrmub",e100070, 3, (RR, RIWR, I7), iwmmxt_textrm),
25087 cCE("textrmuh",e500070, 3, (RR, RIWR, I7), iwmmxt_textrm),
25088 cCE("textrmuw",e900070, 3, (RR, RIWR, I7), iwmmxt_textrm),
25089 cCE("textrmsb",e100078, 3, (RR, RIWR, I7), iwmmxt_textrm),
25090 cCE("textrmsh",e500078, 3, (RR, RIWR, I7), iwmmxt_textrm),
25091 cCE("textrmsw",e900078, 3, (RR, RIWR, I7), iwmmxt_textrm),
25092 cCE("tinsrb", e600010, 3, (RIWR, RR, I7), iwmmxt_tinsr),
25093 cCE("tinsrh", e600050, 3, (RIWR, RR, I7), iwmmxt_tinsr),
25094 cCE("tinsrw", e600090, 3, (RIWR, RR, I7), iwmmxt_tinsr),
25095 cCE("tmcr", e000110, 2, (RIWC_RIWG, RR), rn_rd),
25096 cCE("tmcrr", c400000, 3, (RIWR, RR, RR), rm_rd_rn),
25097 cCE("tmia", e200010, 3, (RIWR, RR, RR), iwmmxt_tmia),
25098 cCE("tmiaph", e280010, 3, (RIWR, RR, RR), iwmmxt_tmia),
25099 cCE("tmiabb", e2c0010, 3, (RIWR, RR, RR), iwmmxt_tmia),
25100 cCE("tmiabt", e2d0010, 3, (RIWR, RR, RR), iwmmxt_tmia),
25101 cCE("tmiatb", e2e0010, 3, (RIWR, RR, RR), iwmmxt_tmia),
25102 cCE("tmiatt", e2f0010, 3, (RIWR, RR, RR), iwmmxt_tmia),
25103 cCE("tmovmskb",e100030, 2, (RR, RIWR), rd_rn),
25104 cCE("tmovmskh",e500030, 2, (RR, RIWR), rd_rn),
25105 cCE("tmovmskw",e900030, 2, (RR, RIWR), rd_rn),
25106 cCE("tmrc", e100110, 2, (RR, RIWC_RIWG), rd_rn),
25107 cCE("tmrrc", c500000, 3, (RR, RR, RIWR), rd_rn_rm),
25108 cCE("torcb", e13f150, 1, (RR), iwmmxt_tandorc),
25109 cCE("torch", e53f150, 1, (RR), iwmmxt_tandorc),
25110 cCE("torcw", e93f150, 1, (RR), iwmmxt_tandorc),
25111 cCE("waccb", e0001c0, 2, (RIWR, RIWR), rd_rn),
25112 cCE("wacch", e4001c0, 2, (RIWR, RIWR), rd_rn),
25113 cCE("waccw", e8001c0, 2, (RIWR, RIWR), rd_rn),
25114 cCE("waddbss", e300180, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25115 cCE("waddb", e000180, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25116 cCE("waddbus", e100180, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25117 cCE("waddhss", e700180, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25118 cCE("waddh", e400180, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25119 cCE("waddhus", e500180, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25120 cCE("waddwss", eb00180, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25121 cCE("waddw", e800180, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25122 cCE("waddwus", e900180, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25123 cCE("waligni", e000020, 4, (RIWR, RIWR, RIWR, I7), iwmmxt_waligni),
25124 cCE("walignr0",e800020, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25125 cCE("walignr1",e900020, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25126 cCE("walignr2",ea00020, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25127 cCE("walignr3",eb00020, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25128 cCE("wand", e200000, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25129 cCE("wandn", e300000, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25130 cCE("wavg2b", e800000, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25131 cCE("wavg2br", e900000, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25132 cCE("wavg2h", ec00000, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25133 cCE("wavg2hr", ed00000, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25134 cCE("wcmpeqb", e000060, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25135 cCE("wcmpeqh", e400060, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25136 cCE("wcmpeqw", e800060, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25137 cCE("wcmpgtub",e100060, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25138 cCE("wcmpgtuh",e500060, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25139 cCE("wcmpgtuw",e900060, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25140 cCE("wcmpgtsb",e300060, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25141 cCE("wcmpgtsh",e700060, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25142 cCE("wcmpgtsw",eb00060, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25143 cCE("wldrb", c100000, 2, (RIWR, ADDR), iwmmxt_wldstbh),
25144 cCE("wldrh", c500000, 2, (RIWR, ADDR), iwmmxt_wldstbh),
25145 cCE("wldrw", c100100, 2, (RIWR_RIWC, ADDR), iwmmxt_wldstw),
25146 cCE("wldrd", c500100, 2, (RIWR, ADDR), iwmmxt_wldstd),
25147 cCE("wmacs", e600100, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25148 cCE("wmacsz", e700100, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25149 cCE("wmacu", e400100, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25150 cCE("wmacuz", e500100, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25151 cCE("wmadds", ea00100, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25152 cCE("wmaddu", e800100, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25153 cCE("wmaxsb", e200160, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25154 cCE("wmaxsh", e600160, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25155 cCE("wmaxsw", ea00160, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25156 cCE("wmaxub", e000160, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25157 cCE("wmaxuh", e400160, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25158 cCE("wmaxuw", e800160, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25159 cCE("wminsb", e300160, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25160 cCE("wminsh", e700160, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25161 cCE("wminsw", eb00160, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25162 cCE("wminub", e100160, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25163 cCE("wminuh", e500160, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25164 cCE("wminuw", e900160, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25165 cCE("wmov", e000000, 2, (RIWR, RIWR), iwmmxt_wmov),
25166 cCE("wmulsm", e300100, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25167 cCE("wmulsl", e200100, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25168 cCE("wmulum", e100100, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25169 cCE("wmulul", e000100, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25170 cCE("wor", e000000, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25171 cCE("wpackhss",e700080, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25172 cCE("wpackhus",e500080, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25173 cCE("wpackwss",eb00080, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25174 cCE("wpackwus",e900080, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25175 cCE("wpackdss",ef00080, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25176 cCE("wpackdus",ed00080, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25177 cCE("wrorh", e700040, 3, (RIWR, RIWR, RIWR_I32z),iwmmxt_wrwrwr_or_imm5),
25178 cCE("wrorhg", e700148, 3, (RIWR, RIWR, RIWG), rd_rn_rm),
25179 cCE("wrorw", eb00040, 3, (RIWR, RIWR, RIWR_I32z),iwmmxt_wrwrwr_or_imm5),
25180 cCE("wrorwg", eb00148, 3, (RIWR, RIWR, RIWG), rd_rn_rm),
25181 cCE("wrord", ef00040, 3, (RIWR, RIWR, RIWR_I32z),iwmmxt_wrwrwr_or_imm5),
25182 cCE("wrordg", ef00148, 3, (RIWR, RIWR, RIWG), rd_rn_rm),
25183 cCE("wsadb", e000120, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25184 cCE("wsadbz", e100120, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25185 cCE("wsadh", e400120, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25186 cCE("wsadhz", e500120, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25187 cCE("wshufh", e0001e0, 3, (RIWR, RIWR, I255), iwmmxt_wshufh),
25188 cCE("wsllh", e500040, 3, (RIWR, RIWR, RIWR_I32z),iwmmxt_wrwrwr_or_imm5),
25189 cCE("wsllhg", e500148, 3, (RIWR, RIWR, RIWG), rd_rn_rm),
25190 cCE("wsllw", e900040, 3, (RIWR, RIWR, RIWR_I32z),iwmmxt_wrwrwr_or_imm5),
25191 cCE("wsllwg", e900148, 3, (RIWR, RIWR, RIWG), rd_rn_rm),
25192 cCE("wslld", ed00040, 3, (RIWR, RIWR, RIWR_I32z),iwmmxt_wrwrwr_or_imm5),
25193 cCE("wslldg", ed00148, 3, (RIWR, RIWR, RIWG), rd_rn_rm),
25194 cCE("wsrah", e400040, 3, (RIWR, RIWR, RIWR_I32z),iwmmxt_wrwrwr_or_imm5),
25195 cCE("wsrahg", e400148, 3, (RIWR, RIWR, RIWG), rd_rn_rm),
25196 cCE("wsraw", e800040, 3, (RIWR, RIWR, RIWR_I32z),iwmmxt_wrwrwr_or_imm5),
25197 cCE("wsrawg", e800148, 3, (RIWR, RIWR, RIWG), rd_rn_rm),
25198 cCE("wsrad", ec00040, 3, (RIWR, RIWR, RIWR_I32z),iwmmxt_wrwrwr_or_imm5),
25199 cCE("wsradg", ec00148, 3, (RIWR, RIWR, RIWG), rd_rn_rm),
25200 cCE("wsrlh", e600040, 3, (RIWR, RIWR, RIWR_I32z),iwmmxt_wrwrwr_or_imm5),
25201 cCE("wsrlhg", e600148, 3, (RIWR, RIWR, RIWG), rd_rn_rm),
25202 cCE("wsrlw", ea00040, 3, (RIWR, RIWR, RIWR_I32z),iwmmxt_wrwrwr_or_imm5),
25203 cCE("wsrlwg", ea00148, 3, (RIWR, RIWR, RIWG), rd_rn_rm),
25204 cCE("wsrld", ee00040, 3, (RIWR, RIWR, RIWR_I32z),iwmmxt_wrwrwr_or_imm5),
25205 cCE("wsrldg", ee00148, 3, (RIWR, RIWR, RIWG), rd_rn_rm),
25206 cCE("wstrb", c000000, 2, (RIWR, ADDR), iwmmxt_wldstbh),
25207 cCE("wstrh", c400000, 2, (RIWR, ADDR), iwmmxt_wldstbh),
25208 cCE("wstrw", c000100, 2, (RIWR_RIWC, ADDR), iwmmxt_wldstw),
25209 cCE("wstrd", c400100, 2, (RIWR, ADDR), iwmmxt_wldstd),
25210 cCE("wsubbss", e3001a0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25211 cCE("wsubb", e0001a0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25212 cCE("wsubbus", e1001a0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25213 cCE("wsubhss", e7001a0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25214 cCE("wsubh", e4001a0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25215 cCE("wsubhus", e5001a0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25216 cCE("wsubwss", eb001a0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25217 cCE("wsubw", e8001a0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25218 cCE("wsubwus", e9001a0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25219 cCE("wunpckehub",e0000c0, 2, (RIWR, RIWR), rd_rn),
25220 cCE("wunpckehuh",e4000c0, 2, (RIWR, RIWR), rd_rn),
25221 cCE("wunpckehuw",e8000c0, 2, (RIWR, RIWR), rd_rn),
25222 cCE("wunpckehsb",e2000c0, 2, (RIWR, RIWR), rd_rn),
25223 cCE("wunpckehsh",e6000c0, 2, (RIWR, RIWR), rd_rn),
25224 cCE("wunpckehsw",ea000c0, 2, (RIWR, RIWR), rd_rn),
25225 cCE("wunpckihb", e1000c0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25226 cCE("wunpckihh", e5000c0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25227 cCE("wunpckihw", e9000c0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25228 cCE("wunpckelub",e0000e0, 2, (RIWR, RIWR), rd_rn),
25229 cCE("wunpckeluh",e4000e0, 2, (RIWR, RIWR), rd_rn),
25230 cCE("wunpckeluw",e8000e0, 2, (RIWR, RIWR), rd_rn),
25231 cCE("wunpckelsb",e2000e0, 2, (RIWR, RIWR), rd_rn),
25232 cCE("wunpckelsh",e6000e0, 2, (RIWR, RIWR), rd_rn),
25233 cCE("wunpckelsw",ea000e0, 2, (RIWR, RIWR), rd_rn),
25234 cCE("wunpckilb", e1000e0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25235 cCE("wunpckilh", e5000e0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25236 cCE("wunpckilw", e9000e0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25237 cCE("wxor", e100000, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25238 cCE("wzero", e300000, 1, (RIWR), iwmmxt_wzero),
25241 #define ARM_VARIANT & arm_cext_iwmmxt2 /* Intel Wireless MMX technology, version 2. */
25243 cCE("torvscb", e12f190, 1, (RR), iwmmxt_tandorc),
25244 cCE("torvsch", e52f190, 1, (RR), iwmmxt_tandorc),
25245 cCE("torvscw", e92f190, 1, (RR), iwmmxt_tandorc),
25246 cCE("wabsb", e2001c0, 2, (RIWR, RIWR), rd_rn),
25247 cCE("wabsh", e6001c0, 2, (RIWR, RIWR), rd_rn),
25248 cCE("wabsw", ea001c0, 2, (RIWR, RIWR), rd_rn),
25249 cCE("wabsdiffb", e1001c0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25250 cCE("wabsdiffh", e5001c0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25251 cCE("wabsdiffw", e9001c0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25252 cCE("waddbhusl", e2001a0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25253 cCE("waddbhusm", e6001a0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25254 cCE("waddhc", e600180, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25255 cCE("waddwc", ea00180, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25256 cCE("waddsubhx", ea001a0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25257 cCE("wavg4", e400000, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25258 cCE("wavg4r", e500000, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25259 cCE("wmaddsn", ee00100, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25260 cCE("wmaddsx", eb00100, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25261 cCE("wmaddun", ec00100, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25262 cCE("wmaddux", e900100, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25263 cCE("wmerge", e000080, 4, (RIWR, RIWR, RIWR, I7), iwmmxt_wmerge),
25264 cCE("wmiabb", e0000a0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25265 cCE("wmiabt", e1000a0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25266 cCE("wmiatb", e2000a0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25267 cCE("wmiatt", e3000a0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25268 cCE("wmiabbn", e4000a0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25269 cCE("wmiabtn", e5000a0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25270 cCE("wmiatbn", e6000a0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25271 cCE("wmiattn", e7000a0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25272 cCE("wmiawbb", e800120, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25273 cCE("wmiawbt", e900120, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25274 cCE("wmiawtb", ea00120, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25275 cCE("wmiawtt", eb00120, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25276 cCE("wmiawbbn", ec00120, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25277 cCE("wmiawbtn", ed00120, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25278 cCE("wmiawtbn", ee00120, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25279 cCE("wmiawttn", ef00120, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25280 cCE("wmulsmr", ef00100, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25281 cCE("wmulumr", ed00100, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25282 cCE("wmulwumr", ec000c0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25283 cCE("wmulwsmr", ee000c0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25284 cCE("wmulwum", ed000c0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25285 cCE("wmulwsm", ef000c0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25286 cCE("wmulwl", eb000c0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25287 cCE("wqmiabb", e8000a0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25288 cCE("wqmiabt", e9000a0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25289 cCE("wqmiatb", ea000a0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25290 cCE("wqmiatt", eb000a0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25291 cCE("wqmiabbn", ec000a0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25292 cCE("wqmiabtn", ed000a0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25293 cCE("wqmiatbn", ee000a0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25294 cCE("wqmiattn", ef000a0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25295 cCE("wqmulm", e100080, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25296 cCE("wqmulmr", e300080, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25297 cCE("wqmulwm", ec000e0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25298 cCE("wqmulwmr", ee000e0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25299 cCE("wsubaddhx", ed001c0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25302 #define ARM_VARIANT & arm_cext_maverick /* Cirrus Maverick instructions. */
25304 cCE("cfldrs", c100400, 2, (RMF, ADDRGLDC), rd_cpaddr),
25305 cCE("cfldrd", c500400, 2, (RMD, ADDRGLDC), rd_cpaddr),
25306 cCE("cfldr32", c100500, 2, (RMFX, ADDRGLDC), rd_cpaddr),
25307 cCE("cfldr64", c500500, 2, (RMDX, ADDRGLDC), rd_cpaddr),
25308 cCE("cfstrs", c000400, 2, (RMF, ADDRGLDC), rd_cpaddr),
25309 cCE("cfstrd", c400400, 2, (RMD, ADDRGLDC), rd_cpaddr),
25310 cCE("cfstr32", c000500, 2, (RMFX, ADDRGLDC), rd_cpaddr),
25311 cCE("cfstr64", c400500, 2, (RMDX, ADDRGLDC), rd_cpaddr),
25312 cCE("cfmvsr", e000450, 2, (RMF, RR), rn_rd),
25313 cCE("cfmvrs", e100450, 2, (RR, RMF), rd_rn),
25314 cCE("cfmvdlr", e000410, 2, (RMD, RR), rn_rd),
25315 cCE("cfmvrdl", e100410, 2, (RR, RMD), rd_rn),
25316 cCE("cfmvdhr", e000430, 2, (RMD, RR), rn_rd),
25317 cCE("cfmvrdh", e100430, 2, (RR, RMD), rd_rn),
25318 cCE("cfmv64lr",e000510, 2, (RMDX, RR), rn_rd),
25319 cCE("cfmvr64l",e100510, 2, (RR, RMDX), rd_rn),
25320 cCE("cfmv64hr",e000530, 2, (RMDX, RR), rn_rd),
25321 cCE("cfmvr64h",e100530, 2, (RR, RMDX), rd_rn),
25322 cCE("cfmval32",e200440, 2, (RMAX, RMFX), rd_rn),
25323 cCE("cfmv32al",e100440, 2, (RMFX, RMAX), rd_rn),
25324 cCE("cfmvam32",e200460, 2, (RMAX, RMFX), rd_rn),
25325 cCE("cfmv32am",e100460, 2, (RMFX, RMAX), rd_rn),
25326 cCE("cfmvah32",e200480, 2, (RMAX, RMFX), rd_rn),
25327 cCE("cfmv32ah",e100480, 2, (RMFX, RMAX), rd_rn),
25328 cCE("cfmva32", e2004a0, 2, (RMAX, RMFX), rd_rn),
25329 cCE("cfmv32a", e1004a0, 2, (RMFX, RMAX), rd_rn),
25330 cCE("cfmva64", e2004c0, 2, (RMAX, RMDX), rd_rn),
25331 cCE("cfmv64a", e1004c0, 2, (RMDX, RMAX), rd_rn),
25332 cCE("cfmvsc32",e2004e0, 2, (RMDS, RMDX), mav_dspsc),
25333 cCE("cfmv32sc",e1004e0, 2, (RMDX, RMDS), rd),
25334 cCE("cfcpys", e000400, 2, (RMF, RMF), rd_rn),
25335 cCE("cfcpyd", e000420, 2, (RMD, RMD), rd_rn),
25336 cCE("cfcvtsd", e000460, 2, (RMD, RMF), rd_rn),
25337 cCE("cfcvtds", e000440, 2, (RMF, RMD), rd_rn),
25338 cCE("cfcvt32s",e000480, 2, (RMF, RMFX), rd_rn),
25339 cCE("cfcvt32d",e0004a0, 2, (RMD, RMFX), rd_rn),
25340 cCE("cfcvt64s",e0004c0, 2, (RMF, RMDX), rd_rn),
25341 cCE("cfcvt64d",e0004e0, 2, (RMD, RMDX), rd_rn),
25342 cCE("cfcvts32",e100580, 2, (RMFX, RMF), rd_rn),
25343 cCE("cfcvtd32",e1005a0, 2, (RMFX, RMD), rd_rn),
25344 cCE("cftruncs32",e1005c0, 2, (RMFX, RMF), rd_rn),
25345 cCE("cftruncd32",e1005e0, 2, (RMFX, RMD), rd_rn),
25346 cCE("cfrshl32",e000550, 3, (RMFX, RMFX, RR), mav_triple),
25347 cCE("cfrshl64",e000570, 3, (RMDX, RMDX, RR), mav_triple),
25348 cCE("cfsh32", e000500, 3, (RMFX, RMFX, I63s), mav_shift),
25349 cCE("cfsh64", e200500, 3, (RMDX, RMDX, I63s), mav_shift),
25350 cCE("cfcmps", e100490, 3, (RR, RMF, RMF), rd_rn_rm),
25351 cCE("cfcmpd", e1004b0, 3, (RR, RMD, RMD), rd_rn_rm),
25352 cCE("cfcmp32", e100590, 3, (RR, RMFX, RMFX), rd_rn_rm),
25353 cCE("cfcmp64", e1005b0, 3, (RR, RMDX, RMDX), rd_rn_rm),
25354 cCE("cfabss", e300400, 2, (RMF, RMF), rd_rn),
25355 cCE("cfabsd", e300420, 2, (RMD, RMD), rd_rn),
25356 cCE("cfnegs", e300440, 2, (RMF, RMF), rd_rn),
25357 cCE("cfnegd", e300460, 2, (RMD, RMD), rd_rn),
25358 cCE("cfadds", e300480, 3, (RMF, RMF, RMF), rd_rn_rm),
25359 cCE("cfaddd", e3004a0, 3, (RMD, RMD, RMD), rd_rn_rm),
25360 cCE("cfsubs", e3004c0, 3, (RMF, RMF, RMF), rd_rn_rm),
25361 cCE("cfsubd", e3004e0, 3, (RMD, RMD, RMD), rd_rn_rm),
25362 cCE("cfmuls", e100400, 3, (RMF, RMF, RMF), rd_rn_rm),
25363 cCE("cfmuld", e100420, 3, (RMD, RMD, RMD), rd_rn_rm),
25364 cCE("cfabs32", e300500, 2, (RMFX, RMFX), rd_rn),
25365 cCE("cfabs64", e300520, 2, (RMDX, RMDX), rd_rn),
25366 cCE("cfneg32", e300540, 2, (RMFX, RMFX), rd_rn),
25367 cCE("cfneg64", e300560, 2, (RMDX, RMDX), rd_rn),
25368 cCE("cfadd32", e300580, 3, (RMFX, RMFX, RMFX), rd_rn_rm),
25369 cCE("cfadd64", e3005a0, 3, (RMDX, RMDX, RMDX), rd_rn_rm),
25370 cCE("cfsub32", e3005c0, 3, (RMFX, RMFX, RMFX), rd_rn_rm),
25371 cCE("cfsub64", e3005e0, 3, (RMDX, RMDX, RMDX), rd_rn_rm),
25372 cCE("cfmul32", e100500, 3, (RMFX, RMFX, RMFX), rd_rn_rm),
25373 cCE("cfmul64", e100520, 3, (RMDX, RMDX, RMDX), rd_rn_rm),
25374 cCE("cfmac32", e100540, 3, (RMFX, RMFX, RMFX), rd_rn_rm),
25375 cCE("cfmsc32", e100560, 3, (RMFX, RMFX, RMFX), rd_rn_rm),
25376 cCE("cfmadd32",e000600, 4, (RMAX, RMFX, RMFX, RMFX), mav_quad),
25377 cCE("cfmsub32",e100600, 4, (RMAX, RMFX, RMFX, RMFX), mav_quad),
25378 cCE("cfmadda32", e200600, 4, (RMAX, RMAX, RMFX, RMFX), mav_quad),
25379 cCE("cfmsuba32", e300600, 4, (RMAX, RMAX, RMFX, RMFX), mav_quad),
25381 /* ARMv8.5-A instructions. */
25383 #define ARM_VARIANT & arm_ext_sb
25384 #undef THUMB_VARIANT
25385 #define THUMB_VARIANT & arm_ext_sb
25386 TUF("sb", 57ff070, f3bf8f70, 0, (), noargs, noargs),
25389 #define ARM_VARIANT & arm_ext_predres
25390 #undef THUMB_VARIANT
25391 #define THUMB_VARIANT & arm_ext_predres
25392 CE("cfprctx", e070f93, 1, (RRnpc), rd),
25393 CE("dvprctx", e070fb3, 1, (RRnpc), rd),
25394 CE("cpprctx", e070ff3, 1, (RRnpc), rd),
25396 /* ARMv8-M instructions. */
25398 #define ARM_VARIANT NULL
25399 #undef THUMB_VARIANT
25400 #define THUMB_VARIANT & arm_ext_v8m
25401 ToU("sg", e97fe97f, 0, (), noargs),
25402 ToC("blxns", 4784, 1, (RRnpc), t_blx),
25403 ToC("bxns", 4704, 1, (RRnpc), t_bx),
25404 ToC("tt", e840f000, 2, (RRnpc, RRnpc), tt),
25405 ToC("ttt", e840f040, 2, (RRnpc, RRnpc), tt),
25406 ToC("tta", e840f080, 2, (RRnpc, RRnpc), tt),
25407 ToC("ttat", e840f0c0, 2, (RRnpc, RRnpc), tt),
25409 /* FP for ARMv8-M Mainline. Enabled for ARMv8-M Mainline because the
25410 instructions behave as nop if no VFP is present. */
25411 #undef THUMB_VARIANT
25412 #define THUMB_VARIANT & arm_ext_v8m_main
25413 ToC("vlldm", ec300a00, 1, (RRnpc), rn),
25414 ToC("vlstm", ec200a00, 1, (RRnpc), rn),
25416 /* Armv8.1-M Mainline instructions. */
25417 #undef THUMB_VARIANT
25418 #define THUMB_VARIANT & arm_ext_v8_1m_main
25419 toU("cinc", _cinc, 3, (RRnpcsp, RR_ZR, COND), t_cond),
25420 toU("cinv", _cinv, 3, (RRnpcsp, RR_ZR, COND), t_cond),
25421 toU("cneg", _cneg, 3, (RRnpcsp, RR_ZR, COND), t_cond),
25422 toU("csel", _csel, 4, (RRnpcsp, RR_ZR, RR_ZR, COND), t_cond),
25423 toU("csetm", _csetm, 2, (RRnpcsp, COND), t_cond),
25424 toU("cset", _cset, 2, (RRnpcsp, COND), t_cond),
25425 toU("csinc", _csinc, 4, (RRnpcsp, RR_ZR, RR_ZR, COND), t_cond),
25426 toU("csinv", _csinv, 4, (RRnpcsp, RR_ZR, RR_ZR, COND), t_cond),
25427 toU("csneg", _csneg, 4, (RRnpcsp, RR_ZR, RR_ZR, COND), t_cond),
25429 toC("bf", _bf, 2, (EXPs, EXPs), t_branch_future),
25430 toU("bfcsel", _bfcsel, 4, (EXPs, EXPs, EXPs, COND), t_branch_future),
25431 toC("bfx", _bfx, 2, (EXPs, RRnpcsp), t_branch_future),
25432 toC("bfl", _bfl, 2, (EXPs, EXPs), t_branch_future),
25433 toC("bflx", _bflx, 2, (EXPs, RRnpcsp), t_branch_future),
25435 toU("dls", _dls, 2, (LR, RRnpcsp), t_loloop),
25436 toU("wls", _wls, 3, (LR, RRnpcsp, EXP), t_loloop),
25437 toU("le", _le, 2, (oLR, EXP), t_loloop),
25439 ToC("clrm", e89f0000, 1, (CLRMLST), t_clrm),
25440 ToC("vscclrm", ec9f0a00, 1, (VRSDVLST), t_vscclrm),
25442 #undef THUMB_VARIANT
25443 #define THUMB_VARIANT & mve_ext
25444 ToC("lsll", ea50010d, 3, (RRe, RRo, RRnpcsp_I32), mve_scalar_shift),
25445 ToC("lsrl", ea50011f, 3, (RRe, RRo, I32), mve_scalar_shift),
25446 ToC("asrl", ea50012d, 3, (RRe, RRo, RRnpcsp_I32), mve_scalar_shift),
25447 ToC("uqrshll", ea51010d, 4, (RRe, RRo, I48_I64, RRnpcsp), mve_scalar_shift1),
25448 ToC("sqrshrl", ea51012d, 4, (RRe, RRo, I48_I64, RRnpcsp), mve_scalar_shift1),
25449 ToC("uqshll", ea51010f, 3, (RRe, RRo, I32), mve_scalar_shift),
25450 ToC("urshrl", ea51011f, 3, (RRe, RRo, I32), mve_scalar_shift),
25451 ToC("srshrl", ea51012f, 3, (RRe, RRo, I32), mve_scalar_shift),
25452 ToC("sqshll", ea51013f, 3, (RRe, RRo, I32), mve_scalar_shift),
25453 ToC("uqrshl", ea500f0d, 2, (RRnpcsp, RRnpcsp), mve_scalar_shift),
25454 ToC("sqrshr", ea500f2d, 2, (RRnpcsp, RRnpcsp), mve_scalar_shift),
25455 ToC("uqshl", ea500f0f, 2, (RRnpcsp, I32), mve_scalar_shift),
25456 ToC("urshr", ea500f1f, 2, (RRnpcsp, I32), mve_scalar_shift),
25457 ToC("srshr", ea500f2f, 2, (RRnpcsp, I32), mve_scalar_shift),
25458 ToC("sqshl", ea500f3f, 2, (RRnpcsp, I32), mve_scalar_shift),
25460 ToC("vpt", ee410f00, 3, (COND, RMQ, RMQRZ), mve_vpt),
25461 ToC("vptt", ee018f00, 3, (COND, RMQ, RMQRZ), mve_vpt),
25462 ToC("vpte", ee418f00, 3, (COND, RMQ, RMQRZ), mve_vpt),
25463 ToC("vpttt", ee014f00, 3, (COND, RMQ, RMQRZ), mve_vpt),
25464 ToC("vptte", ee01cf00, 3, (COND, RMQ, RMQRZ), mve_vpt),
25465 ToC("vptet", ee41cf00, 3, (COND, RMQ, RMQRZ), mve_vpt),
25466 ToC("vptee", ee414f00, 3, (COND, RMQ, RMQRZ), mve_vpt),
25467 ToC("vptttt", ee012f00, 3, (COND, RMQ, RMQRZ), mve_vpt),
25468 ToC("vpttte", ee016f00, 3, (COND, RMQ, RMQRZ), mve_vpt),
25469 ToC("vpttet", ee01ef00, 3, (COND, RMQ, RMQRZ), mve_vpt),
25470 ToC("vpttee", ee01af00, 3, (COND, RMQ, RMQRZ), mve_vpt),
25471 ToC("vptett", ee41af00, 3, (COND, RMQ, RMQRZ), mve_vpt),
25472 ToC("vptete", ee41ef00, 3, (COND, RMQ, RMQRZ), mve_vpt),
25473 ToC("vpteet", ee416f00, 3, (COND, RMQ, RMQRZ), mve_vpt),
25474 ToC("vpteee", ee412f00, 3, (COND, RMQ, RMQRZ), mve_vpt),
25476 ToC("vpst", fe710f4d, 0, (), mve_vpt),
25477 ToC("vpstt", fe318f4d, 0, (), mve_vpt),
25478 ToC("vpste", fe718f4d, 0, (), mve_vpt),
25479 ToC("vpsttt", fe314f4d, 0, (), mve_vpt),
25480 ToC("vpstte", fe31cf4d, 0, (), mve_vpt),
25481 ToC("vpstet", fe71cf4d, 0, (), mve_vpt),
25482 ToC("vpstee", fe714f4d, 0, (), mve_vpt),
25483 ToC("vpstttt", fe312f4d, 0, (), mve_vpt),
25484 ToC("vpsttte", fe316f4d, 0, (), mve_vpt),
25485 ToC("vpsttet", fe31ef4d, 0, (), mve_vpt),
25486 ToC("vpsttee", fe31af4d, 0, (), mve_vpt),
25487 ToC("vpstett", fe71af4d, 0, (), mve_vpt),
25488 ToC("vpstete", fe71ef4d, 0, (), mve_vpt),
25489 ToC("vpsteet", fe716f4d, 0, (), mve_vpt),
25490 ToC("vpsteee", fe712f4d, 0, (), mve_vpt),
25492 /* MVE and MVE FP only. */
25493 mToC("vhcadd", ee000f00, 4, (RMQ, RMQ, RMQ, EXPi), mve_vhcadd),
25494 mCEF(vadc, _vadc, 3, (RMQ, RMQ, RMQ), mve_vadc),
25495 mCEF(vadci, _vadci, 3, (RMQ, RMQ, RMQ), mve_vadc),
25496 mToC("vsbc", fe300f00, 3, (RMQ, RMQ, RMQ), mve_vsbc),
25497 mToC("vsbci", fe301f00, 3, (RMQ, RMQ, RMQ), mve_vsbc),
25498 mCEF(vmullb, _vmullb, 3, (RMQ, RMQ, RMQ), mve_vmull),
25499 mCEF(vabav, _vabav, 3, (RRnpcsp, RMQ, RMQ), mve_vabav),
25500 mCEF(vmladav, _vmladav, 3, (RRe, RMQ, RMQ), mve_vmladav),
25501 mCEF(vmladava, _vmladava, 3, (RRe, RMQ, RMQ), mve_vmladav),
25502 mCEF(vmladavx, _vmladavx, 3, (RRe, RMQ, RMQ), mve_vmladav),
25503 mCEF(vmladavax, _vmladavax, 3, (RRe, RMQ, RMQ), mve_vmladav),
25504 mCEF(vmlav, _vmladav, 3, (RRe, RMQ, RMQ), mve_vmladav),
25505 mCEF(vmlava, _vmladava, 3, (RRe, RMQ, RMQ), mve_vmladav),
25506 mCEF(vmlsdav, _vmlsdav, 3, (RRe, RMQ, RMQ), mve_vmladav),
25507 mCEF(vmlsdava, _vmlsdava, 3, (RRe, RMQ, RMQ), mve_vmladav),
25508 mCEF(vmlsdavx, _vmlsdavx, 3, (RRe, RMQ, RMQ), mve_vmladav),
25509 mCEF(vmlsdavax, _vmlsdavax, 3, (RRe, RMQ, RMQ), mve_vmladav),
25511 mCEF(vst20, _vst20, 2, (MSTRLST2, ADDRMVE), mve_vst_vld),
25512 mCEF(vst21, _vst21, 2, (MSTRLST2, ADDRMVE), mve_vst_vld),
25513 mCEF(vst40, _vst40, 2, (MSTRLST4, ADDRMVE), mve_vst_vld),
25514 mCEF(vst41, _vst41, 2, (MSTRLST4, ADDRMVE), mve_vst_vld),
25515 mCEF(vst42, _vst42, 2, (MSTRLST4, ADDRMVE), mve_vst_vld),
25516 mCEF(vst43, _vst43, 2, (MSTRLST4, ADDRMVE), mve_vst_vld),
25517 mCEF(vld20, _vld20, 2, (MSTRLST2, ADDRMVE), mve_vst_vld),
25518 mCEF(vld21, _vld21, 2, (MSTRLST2, ADDRMVE), mve_vst_vld),
25519 mCEF(vld40, _vld40, 2, (MSTRLST4, ADDRMVE), mve_vst_vld),
25520 mCEF(vld41, _vld41, 2, (MSTRLST4, ADDRMVE), mve_vst_vld),
25521 mCEF(vld42, _vld42, 2, (MSTRLST4, ADDRMVE), mve_vst_vld),
25522 mCEF(vld43, _vld43, 2, (MSTRLST4, ADDRMVE), mve_vst_vld),
25523 mCEF(vstrb, _vstrb, 2, (RMQ, ADDRMVE), mve_vstr_vldr),
25524 mCEF(vstrh, _vstrh, 2, (RMQ, ADDRMVE), mve_vstr_vldr),
25525 mCEF(vstrw, _vstrw, 2, (RMQ, ADDRMVE), mve_vstr_vldr),
25526 mCEF(vstrd, _vstrd, 2, (RMQ, ADDRMVE), mve_vstr_vldr),
25527 mCEF(vldrb, _vldrb, 2, (RMQ, ADDRMVE), mve_vstr_vldr),
25528 mCEF(vldrh, _vldrh, 2, (RMQ, ADDRMVE), mve_vstr_vldr),
25529 mCEF(vldrw, _vldrw, 2, (RMQ, ADDRMVE), mve_vstr_vldr),
25530 mCEF(vldrd, _vldrd, 2, (RMQ, ADDRMVE), mve_vstr_vldr),
25532 mCEF(vmovnt, _vmovnt, 2, (RMQ, RMQ), mve_movn),
25533 mCEF(vmovnb, _vmovnb, 2, (RMQ, RMQ), mve_movn),
25534 mCEF(vbrsr, _vbrsr, 3, (RMQ, RMQ, RR), mve_vbrsr),
25535 mCEF(vaddlv, _vaddlv, 3, (RRe, RRo, RMQ), mve_vaddlv),
25536 mCEF(vaddlva, _vaddlva, 3, (RRe, RRo, RMQ), mve_vaddlv),
25537 mCEF(vaddv, _vaddv, 2, (RRe, RMQ), mve_vaddv),
25538 mCEF(vaddva, _vaddva, 2, (RRe, RMQ), mve_vaddv),
25539 mCEF(vddup, _vddup, 3, (RMQ, RRe, EXPi), mve_viddup),
25540 mCEF(vdwdup, _vdwdup, 4, (RMQ, RRe, RR, EXPi), mve_viddup),
25541 mCEF(vidup, _vidup, 3, (RMQ, RRe, EXPi), mve_viddup),
25542 mCEF(viwdup, _viwdup, 4, (RMQ, RRe, RR, EXPi), mve_viddup),
25543 mToC("vmaxa", ee330e81, 2, (RMQ, RMQ), mve_vmaxa_vmina),
25544 mToC("vmina", ee331e81, 2, (RMQ, RMQ), mve_vmaxa_vmina),
25545 mCEF(vmaxv, _vmaxv, 2, (RR, RMQ), mve_vmaxv),
25546 mCEF(vmaxav, _vmaxav, 2, (RR, RMQ), mve_vmaxv),
25547 mCEF(vminv, _vminv, 2, (RR, RMQ), mve_vmaxv),
25548 mCEF(vminav, _vminav, 2, (RR, RMQ), mve_vmaxv),
25550 mCEF(vmlaldav, _vmlaldav, 4, (RRe, RRo, RMQ, RMQ), mve_vmlaldav),
25551 mCEF(vmlaldava, _vmlaldava, 4, (RRe, RRo, RMQ, RMQ), mve_vmlaldav),
25552 mCEF(vmlaldavx, _vmlaldavx, 4, (RRe, RRo, RMQ, RMQ), mve_vmlaldav),
25553 mCEF(vmlaldavax, _vmlaldavax, 4, (RRe, RRo, RMQ, RMQ), mve_vmlaldav),
25554 mCEF(vmlalv, _vmlaldav, 4, (RRe, RRo, RMQ, RMQ), mve_vmlaldav),
25555 mCEF(vmlalva, _vmlaldava, 4, (RRe, RRo, RMQ, RMQ), mve_vmlaldav),
25556 mCEF(vmlsldav, _vmlsldav, 4, (RRe, RRo, RMQ, RMQ), mve_vmlaldav),
25557 mCEF(vmlsldava, _vmlsldava, 4, (RRe, RRo, RMQ, RMQ), mve_vmlaldav),
25558 mCEF(vmlsldavx, _vmlsldavx, 4, (RRe, RRo, RMQ, RMQ), mve_vmlaldav),
25559 mCEF(vmlsldavax, _vmlsldavax, 4, (RRe, RRo, RMQ, RMQ), mve_vmlaldav),
25560 mToC("vrmlaldavh", ee800f00, 4, (RRe, RR, RMQ, RMQ), mve_vrmlaldavh),
25561 mToC("vrmlaldavha",ee800f20, 4, (RRe, RR, RMQ, RMQ), mve_vrmlaldavh),
25562 mCEF(vrmlaldavhx, _vrmlaldavhx, 4, (RRe, RR, RMQ, RMQ), mve_vrmlaldavh),
25563 mCEF(vrmlaldavhax, _vrmlaldavhax, 4, (RRe, RR, RMQ, RMQ), mve_vrmlaldavh),
25564 mToC("vrmlalvh", ee800f00, 4, (RRe, RR, RMQ, RMQ), mve_vrmlaldavh),
25565 mToC("vrmlalvha", ee800f20, 4, (RRe, RR, RMQ, RMQ), mve_vrmlaldavh),
25566 mCEF(vrmlsldavh, _vrmlsldavh, 4, (RRe, RR, RMQ, RMQ), mve_vrmlaldavh),
25567 mCEF(vrmlsldavha, _vrmlsldavha, 4, (RRe, RR, RMQ, RMQ), mve_vrmlaldavh),
25568 mCEF(vrmlsldavhx, _vrmlsldavhx, 4, (RRe, RR, RMQ, RMQ), mve_vrmlaldavh),
25569 mCEF(vrmlsldavhax, _vrmlsldavhax, 4, (RRe, RR, RMQ, RMQ), mve_vrmlaldavh),
25571 mToC("vmlas", ee011e40, 3, (RMQ, RMQ, RR), mve_vmlas),
25572 mToC("vmulh", ee010e01, 3, (RMQ, RMQ, RMQ), mve_vmulh),
25573 mToC("vrmulh", ee011e01, 3, (RMQ, RMQ, RMQ), mve_vmulh),
25574 mToC("vpnot", fe310f4d, 0, (), mve_vpnot),
25575 mToC("vpsel", fe310f01, 3, (RMQ, RMQ, RMQ), mve_vpsel),
25577 mToC("vqdmladh", ee000e00, 3, (RMQ, RMQ, RMQ), mve_vqdmladh),
25578 mToC("vqdmladhx", ee001e00, 3, (RMQ, RMQ, RMQ), mve_vqdmladh),
25579 mToC("vqrdmladh", ee000e01, 3, (RMQ, RMQ, RMQ), mve_vqdmladh),
25580 mToC("vqrdmladhx",ee001e01, 3, (RMQ, RMQ, RMQ), mve_vqdmladh),
25581 mToC("vqdmlsdh", fe000e00, 3, (RMQ, RMQ, RMQ), mve_vqdmladh),
25582 mToC("vqdmlsdhx", fe001e00, 3, (RMQ, RMQ, RMQ), mve_vqdmladh),
25583 mToC("vqrdmlsdh", fe000e01, 3, (RMQ, RMQ, RMQ), mve_vqdmladh),
25584 mToC("vqrdmlsdhx",fe001e01, 3, (RMQ, RMQ, RMQ), mve_vqdmladh),
25585 mToC("vqdmlah", ee000e60, 3, (RMQ, RMQ, RR), mve_vqdmlah),
25586 mToC("vqdmlash", ee001e60, 3, (RMQ, RMQ, RR), mve_vqdmlah),
25587 mToC("vqrdmlash", ee001e40, 3, (RMQ, RMQ, RR), mve_vqdmlah),
25588 mToC("vqdmullt", ee301f00, 3, (RMQ, RMQ, RMQRR), mve_vqdmull),
25589 mToC("vqdmullb", ee300f00, 3, (RMQ, RMQ, RMQRR), mve_vqdmull),
25590 mCEF(vqmovnt, _vqmovnt, 2, (RMQ, RMQ), mve_vqmovn),
25591 mCEF(vqmovnb, _vqmovnb, 2, (RMQ, RMQ), mve_vqmovn),
25592 mCEF(vqmovunt, _vqmovunt, 2, (RMQ, RMQ), mve_vqmovn),
25593 mCEF(vqmovunb, _vqmovunb, 2, (RMQ, RMQ), mve_vqmovn),
25595 mCEF(vshrnt, _vshrnt, 3, (RMQ, RMQ, I32z), mve_vshrn),
25596 mCEF(vshrnb, _vshrnb, 3, (RMQ, RMQ, I32z), mve_vshrn),
25597 mCEF(vrshrnt, _vrshrnt, 3, (RMQ, RMQ, I32z), mve_vshrn),
25598 mCEF(vrshrnb, _vrshrnb, 3, (RMQ, RMQ, I32z), mve_vshrn),
25599 mCEF(vqshrnt, _vqrshrnt, 3, (RMQ, RMQ, I32z), mve_vshrn),
25600 mCEF(vqshrnb, _vqrshrnb, 3, (RMQ, RMQ, I32z), mve_vshrn),
25601 mCEF(vqshrunt, _vqrshrunt, 3, (RMQ, RMQ, I32z), mve_vshrn),
25602 mCEF(vqshrunb, _vqrshrunb, 3, (RMQ, RMQ, I32z), mve_vshrn),
25603 mCEF(vqrshrnt, _vqrshrnt, 3, (RMQ, RMQ, I32z), mve_vshrn),
25604 mCEF(vqrshrnb, _vqrshrnb, 3, (RMQ, RMQ, I32z), mve_vshrn),
25605 mCEF(vqrshrunt, _vqrshrunt, 3, (RMQ, RMQ, I32z), mve_vshrn),
25606 mCEF(vqrshrunb, _vqrshrunb, 3, (RMQ, RMQ, I32z), mve_vshrn),
25608 mToC("vshlc", eea00fc0, 3, (RMQ, RR, I32z), mve_vshlc),
25609 mToC("vshllt", ee201e00, 3, (RMQ, RMQ, I32), mve_vshll),
25610 mToC("vshllb", ee200e00, 3, (RMQ, RMQ, I32), mve_vshll),
25612 toU("dlstp", _dlstp, 2, (LR, RR), t_loloop),
25613 toU("wlstp", _wlstp, 3, (LR, RR, EXP), t_loloop),
25614 toU("letp", _letp, 2, (LR, EXP), t_loloop),
25615 toU("lctp", _lctp, 0, (), t_loloop),
25617 #undef THUMB_VARIANT
25618 #define THUMB_VARIANT & mve_fp_ext
25619 mToC("vcmul", ee300e00, 4, (RMQ, RMQ, RMQ, EXPi), mve_vcmul),
25620 mToC("vfmas", ee311e40, 3, (RMQ, RMQ, RR), mve_vfmas),
25621 mToC("vmaxnma", ee3f0e81, 2, (RMQ, RMQ), mve_vmaxnma_vminnma),
25622 mToC("vminnma", ee3f1e81, 2, (RMQ, RMQ), mve_vmaxnma_vminnma),
25623 mToC("vmaxnmv", eeee0f00, 2, (RR, RMQ), mve_vmaxnmv),
25624 mToC("vmaxnmav",eeec0f00, 2, (RR, RMQ), mve_vmaxnmv),
25625 mToC("vminnmv", eeee0f80, 2, (RR, RMQ), mve_vmaxnmv),
25626 mToC("vminnmav",eeec0f80, 2, (RR, RMQ), mve_vmaxnmv),
25629 #define ARM_VARIANT & fpu_vfp_ext_v1
25630 #undef THUMB_VARIANT
25631 #define THUMB_VARIANT & arm_ext_v6t2
25632 mnCEF(vmla, _vmla, 3, (RNSDQMQ, oRNSDQMQ, RNSDQ_RNSC_MQ_RR), neon_mac_maybe_scalar),
25633 mnCEF(vmul, _vmul, 3, (RNSDQMQ, oRNSDQMQ, RNSDQ_RNSC_MQ_RR), neon_mul),
25635 mcCE(fcpyd, eb00b40, 2, (RVD, RVD), vfp_dp_rd_rm),
25638 #define ARM_VARIANT & fpu_vfp_ext_v1xd
25640 MNCE(vmov, 0, 1, (VMOV), neon_mov),
25641 mcCE(fmrs, e100a10, 2, (RR, RVS), vfp_reg_from_sp),
25642 mcCE(fmsr, e000a10, 2, (RVS, RR), vfp_sp_from_reg),
25643 mcCE(fcpys, eb00a40, 2, (RVS, RVS), vfp_sp_monadic),
25645 mCEF(vmullt, _vmullt, 3, (RNSDQMQ, oRNSDQMQ, RNSDQ_RNSC_MQ), mve_vmull),
25646 mnCEF(vadd, _vadd, 3, (RNSDQMQ, oRNSDQMQ, RNSDQMQR), neon_addsub_if_i),
25647 mnCEF(vsub, _vsub, 3, (RNSDQMQ, oRNSDQMQ, RNSDQMQR), neon_addsub_if_i),
25649 MNCEF(vabs, 1b10300, 2, (RNSDQMQ, RNSDQMQ), neon_abs_neg),
25650 MNCEF(vneg, 1b10380, 2, (RNSDQMQ, RNSDQMQ), neon_abs_neg),
25652 mCEF(vmovlt, _vmovlt, 1, (VMOV), mve_movl),
25653 mCEF(vmovlb, _vmovlb, 1, (VMOV), mve_movl),
25655 mnCE(vcmp, _vcmp, 3, (RVSD_COND, RSVDMQ_FI0, oRMQRZ), vfp_nsyn_cmp),
25656 mnCE(vcmpe, _vcmpe, 3, (RVSD_COND, RSVDMQ_FI0, oRMQRZ), vfp_nsyn_cmp),
25659 #define ARM_VARIANT & fpu_vfp_ext_v2
25661 mcCE(fmsrr, c400a10, 3, (VRSLST, RR, RR), vfp_sp2_from_reg2),
25662 mcCE(fmrrs, c500a10, 3, (RR, RR, VRSLST), vfp_reg2_from_sp2),
25663 mcCE(fmdrr, c400b10, 3, (RVD, RR, RR), vfp_dp_rm_rd_rn),
25664 mcCE(fmrrd, c500b10, 3, (RR, RR, RVD), vfp_dp_rd_rn_rm),
25667 #define ARM_VARIANT & fpu_vfp_ext_armv8xd
25668 mnUF(vcvta, _vcvta, 2, (RNSDQMQ, oRNSDQMQ), neon_cvta),
25669 mnUF(vcvtp, _vcvta, 2, (RNSDQMQ, oRNSDQMQ), neon_cvtp),
25670 mnUF(vcvtn, _vcvta, 3, (RNSDQMQ, oRNSDQMQ, oI32z), neon_cvtn),
25671 mnUF(vcvtm, _vcvta, 2, (RNSDQMQ, oRNSDQMQ), neon_cvtm),
25672 mnUF(vmaxnm, _vmaxnm, 3, (RNSDQMQ, oRNSDQMQ, RNSDQMQ), vmaxnm),
25673 mnUF(vminnm, _vminnm, 3, (RNSDQMQ, oRNSDQMQ, RNSDQMQ), vmaxnm),
25676 #define ARM_VARIANT & fpu_neon_ext_v1
25677 mnUF(vabd, _vabd, 3, (RNDQMQ, oRNDQMQ, RNDQMQ), neon_dyadic_if_su),
25678 mnUF(vabdl, _vabdl, 3, (RNQMQ, RNDMQ, RNDMQ), neon_dyadic_long),
25679 mnUF(vaddl, _vaddl, 3, (RNQMQ, RNDMQ, RNDMQR), neon_dyadic_long),
25680 mnUF(vsubl, _vsubl, 3, (RNQMQ, RNDMQ, RNDMQR), neon_dyadic_long),
25681 mnUF(vand, _vand, 3, (RNDQMQ, oRNDQMQ, RNDQMQ_Ibig), neon_logic),
25682 mnUF(vbic, _vbic, 3, (RNDQMQ, oRNDQMQ, RNDQMQ_Ibig), neon_logic),
25683 mnUF(vorr, _vorr, 3, (RNDQMQ, oRNDQMQ, RNDQMQ_Ibig), neon_logic),
25684 mnUF(vorn, _vorn, 3, (RNDQMQ, oRNDQMQ, RNDQMQ_Ibig), neon_logic),
25685 mnUF(veor, _veor, 3, (RNDQMQ, oRNDQMQ, RNDQMQ), neon_logic),
25686 MNUF(vcls, 1b00400, 2, (RNDQMQ, RNDQMQ), neon_cls),
25687 MNUF(vclz, 1b00480, 2, (RNDQMQ, RNDQMQ), neon_clz),
25688 mnCE(vdup, _vdup, 2, (RNDQMQ, RR_RNSC), neon_dup),
25689 MNUF(vhadd, 00000000, 3, (RNDQMQ, oRNDQMQ, RNDQMQR), neon_dyadic_i_su),
25690 MNUF(vrhadd, 00000100, 3, (RNDQMQ, oRNDQMQ, RNDQMQ), neon_dyadic_i_su),
25691 MNUF(vhsub, 00000200, 3, (RNDQMQ, oRNDQMQ, RNDQMQR), neon_dyadic_i_su),
25692 mnUF(vmin, _vmin, 3, (RNDQMQ, oRNDQMQ, RNDQMQ), neon_dyadic_if_su),
25693 mnUF(vmax, _vmax, 3, (RNDQMQ, oRNDQMQ, RNDQMQ), neon_dyadic_if_su),
25694 MNUF(vqadd, 0000010, 3, (RNDQMQ, oRNDQMQ, RNDQMQR), neon_dyadic_i64_su),
25695 MNUF(vqsub, 0000210, 3, (RNDQMQ, oRNDQMQ, RNDQMQR), neon_dyadic_i64_su),
25696 mnUF(vmvn, _vmvn, 2, (RNDQMQ, RNDQMQ_Ibig), neon_mvn),
25697 MNUF(vqabs, 1b00700, 2, (RNDQMQ, RNDQMQ), neon_sat_abs_neg),
25698 MNUF(vqneg, 1b00780, 2, (RNDQMQ, RNDQMQ), neon_sat_abs_neg),
25699 mnUF(vqrdmlah, _vqrdmlah,3, (RNDQMQ, oRNDQMQ, RNDQ_RNSC_RR), neon_qrdmlah),
25700 mnUF(vqdmulh, _vqdmulh, 3, (RNDQMQ, oRNDQMQ, RNDQMQ_RNSC_RR), neon_qdmulh),
25701 mnUF(vqrdmulh, _vqrdmulh,3, (RNDQMQ, oRNDQMQ, RNDQMQ_RNSC_RR), neon_qdmulh),
25702 MNUF(vqrshl, 0000510, 3, (RNDQMQ, oRNDQMQ, RNDQMQR), neon_rshl),
25703 MNUF(vrshl, 0000500, 3, (RNDQMQ, oRNDQMQ, RNDQMQR), neon_rshl),
25704 MNUF(vshr, 0800010, 3, (RNDQMQ, oRNDQMQ, I64z), neon_rshift_round_imm),
25705 MNUF(vrshr, 0800210, 3, (RNDQMQ, oRNDQMQ, I64z), neon_rshift_round_imm),
25706 MNUF(vsli, 1800510, 3, (RNDQMQ, oRNDQMQ, I63), neon_sli),
25707 MNUF(vsri, 1800410, 3, (RNDQMQ, oRNDQMQ, I64z), neon_sri),
25708 MNUF(vrev64, 1b00000, 2, (RNDQMQ, RNDQMQ), neon_rev),
25709 MNUF(vrev32, 1b00080, 2, (RNDQMQ, RNDQMQ), neon_rev),
25710 MNUF(vrev16, 1b00100, 2, (RNDQMQ, RNDQMQ), neon_rev),
25711 mnUF(vshl, _vshl, 3, (RNDQMQ, oRNDQMQ, RNDQMQ_I63b_RR), neon_shl),
25712 mnUF(vqshl, _vqshl, 3, (RNDQMQ, oRNDQMQ, RNDQMQ_I63b_RR), neon_qshl),
25713 MNUF(vqshlu, 1800610, 3, (RNDQMQ, oRNDQMQ, I63), neon_qshlu_imm),
25716 #define ARM_VARIANT & arm_ext_v8_3
25717 #undef THUMB_VARIANT
25718 #define THUMB_VARIANT & arm_ext_v6t2_v8m
25719 MNUF (vcadd, 0, 4, (RNDQMQ, RNDQMQ, RNDQMQ, EXPi), vcadd),
25720 MNUF (vcmla, 0, 4, (RNDQMQ, RNDQMQ, RNDQMQ_RNSC, EXPi), vcmla),
25723 #undef THUMB_VARIANT
25755 /* MD interface: bits in the object file. */
25757 /* Turn an integer of n bytes (in val) into a stream of bytes appropriate
25758 for use in the a.out file, and stores them in the array pointed to by buf.
25759 This knows about the endian-ness of the target machine and does
25760 THE RIGHT THING, whatever it is. Possible values for n are 1 (byte)
25761 2 (short) and 4 (long) Floating numbers are put out as a series of
25762 LITTLENUMS (shorts, here at least). */
25765 md_number_to_chars (char * buf, valueT val, int n)
25767 if (target_big_endian)
25768 number_to_chars_bigendian (buf, val, n);
25770 number_to_chars_littleendian (buf, val, n);
25774 md_chars_to_number (char * buf, int n)
25777 unsigned char * where = (unsigned char *) buf;
25779 if (target_big_endian)
25784 result |= (*where++ & 255);
25792 result |= (where[n] & 255);
25799 /* MD interface: Sections. */
25801 /* Calculate the maximum variable size (i.e., excluding fr_fix)
25802 that an rs_machine_dependent frag may reach. */
25805 arm_frag_max_var (fragS *fragp)
25807 /* We only use rs_machine_dependent for variable-size Thumb instructions,
25808 which are either THUMB_SIZE (2) or INSN_SIZE (4).
25810 Note that we generate relaxable instructions even for cases that don't
25811 really need it, like an immediate that's a trivial constant. So we're
25812 overestimating the instruction size for some of those cases. Rather
25813 than putting more intelligence here, it would probably be better to
25814 avoid generating a relaxation frag in the first place when it can be
25815 determined up front that a short instruction will suffice. */
25817 gas_assert (fragp->fr_type == rs_machine_dependent);
25821 /* Estimate the size of a frag before relaxing. Assume everything fits in
25825 md_estimate_size_before_relax (fragS * fragp,
25826 segT segtype ATTRIBUTE_UNUSED)
25832 /* Convert a machine dependent frag. */
25835 md_convert_frag (bfd *abfd, segT asec ATTRIBUTE_UNUSED, fragS *fragp)
25837 unsigned long insn;
25838 unsigned long old_op;
25846 buf = fragp->fr_literal + fragp->fr_fix;
25848 old_op = bfd_get_16(abfd, buf);
25849 if (fragp->fr_symbol)
25851 exp.X_op = O_symbol;
25852 exp.X_add_symbol = fragp->fr_symbol;
25856 exp.X_op = O_constant;
25858 exp.X_add_number = fragp->fr_offset;
25859 opcode = fragp->fr_subtype;
25862 case T_MNEM_ldr_pc:
25863 case T_MNEM_ldr_pc2:
25864 case T_MNEM_ldr_sp:
25865 case T_MNEM_str_sp:
25872 if (fragp->fr_var == 4)
25874 insn = THUMB_OP32 (opcode);
25875 if ((old_op >> 12) == 4 || (old_op >> 12) == 9)
25877 insn |= (old_op & 0x700) << 4;
25881 insn |= (old_op & 7) << 12;
25882 insn |= (old_op & 0x38) << 13;
25884 insn |= 0x00000c00;
25885 put_thumb32_insn (buf, insn);
25886 reloc_type = BFD_RELOC_ARM_T32_OFFSET_IMM;
25890 reloc_type = BFD_RELOC_ARM_THUMB_OFFSET;
25892 pc_rel = (opcode == T_MNEM_ldr_pc2);
25895 if (fragp->fr_var == 4)
25897 insn = THUMB_OP32 (opcode);
25898 insn |= (old_op & 0xf0) << 4;
25899 put_thumb32_insn (buf, insn);
25900 reloc_type = BFD_RELOC_ARM_T32_ADD_PC12;
25904 reloc_type = BFD_RELOC_ARM_THUMB_ADD;
25905 exp.X_add_number -= 4;
25913 if (fragp->fr_var == 4)
25915 int r0off = (opcode == T_MNEM_mov
25916 || opcode == T_MNEM_movs) ? 0 : 8;
25917 insn = THUMB_OP32 (opcode);
25918 insn = (insn & 0xe1ffffff) | 0x10000000;
25919 insn |= (old_op & 0x700) << r0off;
25920 put_thumb32_insn (buf, insn);
25921 reloc_type = BFD_RELOC_ARM_T32_IMMEDIATE;
25925 reloc_type = BFD_RELOC_ARM_THUMB_IMM;
25930 if (fragp->fr_var == 4)
25932 insn = THUMB_OP32(opcode);
25933 put_thumb32_insn (buf, insn);
25934 reloc_type = BFD_RELOC_THUMB_PCREL_BRANCH25;
25937 reloc_type = BFD_RELOC_THUMB_PCREL_BRANCH12;
25941 if (fragp->fr_var == 4)
25943 insn = THUMB_OP32(opcode);
25944 insn |= (old_op & 0xf00) << 14;
25945 put_thumb32_insn (buf, insn);
25946 reloc_type = BFD_RELOC_THUMB_PCREL_BRANCH20;
25949 reloc_type = BFD_RELOC_THUMB_PCREL_BRANCH9;
25952 case T_MNEM_add_sp:
25953 case T_MNEM_add_pc:
25954 case T_MNEM_inc_sp:
25955 case T_MNEM_dec_sp:
25956 if (fragp->fr_var == 4)
25958 /* ??? Choose between add and addw. */
25959 insn = THUMB_OP32 (opcode);
25960 insn |= (old_op & 0xf0) << 4;
25961 put_thumb32_insn (buf, insn);
25962 if (opcode == T_MNEM_add_pc)
25963 reloc_type = BFD_RELOC_ARM_T32_IMM12;
25965 reloc_type = BFD_RELOC_ARM_T32_ADD_IMM;
25968 reloc_type = BFD_RELOC_ARM_THUMB_ADD;
25976 if (fragp->fr_var == 4)
25978 insn = THUMB_OP32 (opcode);
25979 insn |= (old_op & 0xf0) << 4;
25980 insn |= (old_op & 0xf) << 16;
25981 put_thumb32_insn (buf, insn);
25982 if (insn & (1 << 20))
25983 reloc_type = BFD_RELOC_ARM_T32_ADD_IMM;
25985 reloc_type = BFD_RELOC_ARM_T32_IMMEDIATE;
25988 reloc_type = BFD_RELOC_ARM_THUMB_ADD;
25994 fixp = fix_new_exp (fragp, fragp->fr_fix, fragp->fr_var, &exp, pc_rel,
25995 (enum bfd_reloc_code_real) reloc_type);
25996 fixp->fx_file = fragp->fr_file;
25997 fixp->fx_line = fragp->fr_line;
25998 fragp->fr_fix += fragp->fr_var;
26000 /* Set whether we use thumb-2 ISA based on final relaxation results. */
26001 if (thumb_mode && fragp->fr_var == 4 && no_cpu_selected ()
26002 && !ARM_CPU_HAS_FEATURE (thumb_arch_used, arm_arch_t2))
26003 ARM_MERGE_FEATURE_SETS (arm_arch_used, thumb_arch_used, arm_ext_v6t2);
26006 /* Return the size of a relaxable immediate operand instruction.
26007 SHIFT and SIZE specify the form of the allowable immediate. */
26009 relax_immediate (fragS *fragp, int size, int shift)
26015 /* ??? Should be able to do better than this. */
26016 if (fragp->fr_symbol)
26019 low = (1 << shift) - 1;
26020 mask = (1 << (shift + size)) - (1 << shift);
26021 offset = fragp->fr_offset;
26022 /* Force misaligned offsets to 32-bit variant. */
26025 if (offset & ~mask)
26030 /* Get the address of a symbol during relaxation. */
26032 relaxed_symbol_addr (fragS *fragp, long stretch)
26038 sym = fragp->fr_symbol;
26039 sym_frag = symbol_get_frag (sym);
26040 know (S_GET_SEGMENT (sym) != absolute_section
26041 || sym_frag == &zero_address_frag);
26042 addr = S_GET_VALUE (sym) + fragp->fr_offset;
26044 /* If frag has yet to be reached on this pass, assume it will
26045 move by STRETCH just as we did. If this is not so, it will
26046 be because some frag between grows, and that will force
26050 && sym_frag->relax_marker != fragp->relax_marker)
26054 /* Adjust stretch for any alignment frag. Note that if have
26055 been expanding the earlier code, the symbol may be
26056 defined in what appears to be an earlier frag. FIXME:
26057 This doesn't handle the fr_subtype field, which specifies
26058 a maximum number of bytes to skip when doing an
26060 for (f = fragp; f != NULL && f != sym_frag; f = f->fr_next)
26062 if (f->fr_type == rs_align || f->fr_type == rs_align_code)
26065 stretch = - ((- stretch)
26066 & ~ ((1 << (int) f->fr_offset) - 1));
26068 stretch &= ~ ((1 << (int) f->fr_offset) - 1);
26080 /* Return the size of a relaxable adr pseudo-instruction or PC-relative
26083 relax_adr (fragS *fragp, asection *sec, long stretch)
26088 /* Assume worst case for symbols not known to be in the same section. */
26089 if (fragp->fr_symbol == NULL
26090 || !S_IS_DEFINED (fragp->fr_symbol)
26091 || sec != S_GET_SEGMENT (fragp->fr_symbol)
26092 || S_IS_WEAK (fragp->fr_symbol))
26095 val = relaxed_symbol_addr (fragp, stretch);
26096 addr = fragp->fr_address + fragp->fr_fix;
26097 addr = (addr + 4) & ~3;
26098 /* Force misaligned targets to 32-bit variant. */
26102 if (val < 0 || val > 1020)
26107 /* Return the size of a relaxable add/sub immediate instruction. */
26109 relax_addsub (fragS *fragp, asection *sec)
26114 buf = fragp->fr_literal + fragp->fr_fix;
26115 op = bfd_get_16(sec->owner, buf);
26116 if ((op & 0xf) == ((op >> 4) & 0xf))
26117 return relax_immediate (fragp, 8, 0);
26119 return relax_immediate (fragp, 3, 0);
26122 /* Return TRUE iff the definition of symbol S could be pre-empted
26123 (overridden) at link or load time. */
26125 symbol_preemptible (symbolS *s)
26127 /* Weak symbols can always be pre-empted. */
26131 /* Non-global symbols cannot be pre-empted. */
26132 if (! S_IS_EXTERNAL (s))
26136 /* In ELF, a global symbol can be marked protected, or private. In that
26137 case it can't be pre-empted (other definitions in the same link unit
26138 would violate the ODR). */
26139 if (ELF_ST_VISIBILITY (S_GET_OTHER (s)) > STV_DEFAULT)
26143 /* Other global symbols might be pre-empted. */
26147 /* Return the size of a relaxable branch instruction. BITS is the
26148 size of the offset field in the narrow instruction. */
26151 relax_branch (fragS *fragp, asection *sec, int bits, long stretch)
26157 /* Assume worst case for symbols not known to be in the same section. */
26158 if (!S_IS_DEFINED (fragp->fr_symbol)
26159 || sec != S_GET_SEGMENT (fragp->fr_symbol)
26160 || S_IS_WEAK (fragp->fr_symbol))
26164 /* A branch to a function in ARM state will require interworking. */
26165 if (S_IS_DEFINED (fragp->fr_symbol)
26166 && ARM_IS_FUNC (fragp->fr_symbol))
26170 if (symbol_preemptible (fragp->fr_symbol))
26173 val = relaxed_symbol_addr (fragp, stretch);
26174 addr = fragp->fr_address + fragp->fr_fix + 4;
26177 /* Offset is a signed value *2 */
26179 if (val >= limit || val < -limit)
26185 /* Relax a machine dependent frag. This returns the amount by which
26186 the current size of the frag should change. */
26189 arm_relax_frag (asection *sec, fragS *fragp, long stretch)
26194 oldsize = fragp->fr_var;
26195 switch (fragp->fr_subtype)
26197 case T_MNEM_ldr_pc2:
26198 newsize = relax_adr (fragp, sec, stretch);
26200 case T_MNEM_ldr_pc:
26201 case T_MNEM_ldr_sp:
26202 case T_MNEM_str_sp:
26203 newsize = relax_immediate (fragp, 8, 2);
26207 newsize = relax_immediate (fragp, 5, 2);
26211 newsize = relax_immediate (fragp, 5, 1);
26215 newsize = relax_immediate (fragp, 5, 0);
26218 newsize = relax_adr (fragp, sec, stretch);
26224 newsize = relax_immediate (fragp, 8, 0);
26227 newsize = relax_branch (fragp, sec, 11, stretch);
26230 newsize = relax_branch (fragp, sec, 8, stretch);
26232 case T_MNEM_add_sp:
26233 case T_MNEM_add_pc:
26234 newsize = relax_immediate (fragp, 8, 2);
26236 case T_MNEM_inc_sp:
26237 case T_MNEM_dec_sp:
26238 newsize = relax_immediate (fragp, 7, 2);
26244 newsize = relax_addsub (fragp, sec);
26250 fragp->fr_var = newsize;
26251 /* Freeze wide instructions that are at or before the same location as
26252 in the previous pass. This avoids infinite loops.
26253 Don't freeze them unconditionally because targets may be artificially
26254 misaligned by the expansion of preceding frags. */
26255 if (stretch <= 0 && newsize > 2)
26257 md_convert_frag (sec->owner, sec, fragp);
26261 return newsize - oldsize;
26264 /* Round up a section size to the appropriate boundary. */
26267 md_section_align (segT segment ATTRIBUTE_UNUSED,
26273 /* This is called from HANDLE_ALIGN in write.c. Fill in the contents
26274 of an rs_align_code fragment. */
26277 arm_handle_align (fragS * fragP)
26279 static unsigned char const arm_noop[2][2][4] =
26282 {0x00, 0x00, 0xa0, 0xe1}, /* LE */
26283 {0xe1, 0xa0, 0x00, 0x00}, /* BE */
26286 {0x00, 0xf0, 0x20, 0xe3}, /* LE */
26287 {0xe3, 0x20, 0xf0, 0x00}, /* BE */
26290 static unsigned char const thumb_noop[2][2][2] =
26293 {0xc0, 0x46}, /* LE */
26294 {0x46, 0xc0}, /* BE */
26297 {0x00, 0xbf}, /* LE */
26298 {0xbf, 0x00} /* BE */
26301 static unsigned char const wide_thumb_noop[2][4] =
26302 { /* Wide Thumb-2 */
26303 {0xaf, 0xf3, 0x00, 0x80}, /* LE */
26304 {0xf3, 0xaf, 0x80, 0x00}, /* BE */
26307 unsigned bytes, fix, noop_size;
26309 const unsigned char * noop;
26310 const unsigned char *narrow_noop = NULL;
26315 if (fragP->fr_type != rs_align_code)
26318 bytes = fragP->fr_next->fr_address - fragP->fr_address - fragP->fr_fix;
26319 p = fragP->fr_literal + fragP->fr_fix;
26322 if (bytes > MAX_MEM_FOR_RS_ALIGN_CODE)
26323 bytes &= MAX_MEM_FOR_RS_ALIGN_CODE;
26325 gas_assert ((fragP->tc_frag_data.thumb_mode & MODE_RECORDED) != 0);
26327 if (fragP->tc_frag_data.thumb_mode & (~ MODE_RECORDED))
26329 if (ARM_CPU_HAS_FEATURE (selected_cpu_name[0]
26330 ? selected_cpu : arm_arch_none, arm_ext_v6t2))
26332 narrow_noop = thumb_noop[1][target_big_endian];
26333 noop = wide_thumb_noop[target_big_endian];
26336 noop = thumb_noop[0][target_big_endian];
26344 noop = arm_noop[ARM_CPU_HAS_FEATURE (selected_cpu_name[0]
26345 ? selected_cpu : arm_arch_none,
26347 [target_big_endian];
26354 fragP->fr_var = noop_size;
26356 if (bytes & (noop_size - 1))
26358 fix = bytes & (noop_size - 1);
26360 insert_data_mapping_symbol (state, fragP->fr_fix, fragP, fix);
26362 memset (p, 0, fix);
26369 if (bytes & noop_size)
26371 /* Insert a narrow noop. */
26372 memcpy (p, narrow_noop, noop_size);
26374 bytes -= noop_size;
26378 /* Use wide noops for the remainder */
26382 while (bytes >= noop_size)
26384 memcpy (p, noop, noop_size);
26386 bytes -= noop_size;
26390 fragP->fr_fix += fix;
26393 /* Called from md_do_align. Used to create an alignment
26394 frag in a code section. */
26397 arm_frag_align_code (int n, int max)
26401 /* We assume that there will never be a requirement
26402 to support alignments greater than MAX_MEM_FOR_RS_ALIGN_CODE bytes. */
26403 if (max > MAX_MEM_FOR_RS_ALIGN_CODE)
26408 _("alignments greater than %d bytes not supported in .text sections."),
26409 MAX_MEM_FOR_RS_ALIGN_CODE + 1);
26410 as_fatal ("%s", err_msg);
26413 p = frag_var (rs_align_code,
26414 MAX_MEM_FOR_RS_ALIGN_CODE,
26416 (relax_substateT) max,
26423 /* Perform target specific initialisation of a frag.
26424 Note - despite the name this initialisation is not done when the frag
26425 is created, but only when its type is assigned. A frag can be created
26426 and used a long time before its type is set, so beware of assuming that
26427 this initialisation is performed first. */
26431 arm_init_frag (fragS * fragP, int max_chars ATTRIBUTE_UNUSED)
26433 /* Record whether this frag is in an ARM or a THUMB area. */
26434 fragP->tc_frag_data.thumb_mode = thumb_mode | MODE_RECORDED;
26437 #else /* OBJ_ELF is defined. */
26439 arm_init_frag (fragS * fragP, int max_chars)
26441 bfd_boolean frag_thumb_mode;
26443 /* If the current ARM vs THUMB mode has not already
26444 been recorded into this frag then do so now. */
26445 if ((fragP->tc_frag_data.thumb_mode & MODE_RECORDED) == 0)
26446 fragP->tc_frag_data.thumb_mode = thumb_mode | MODE_RECORDED;
26448 /* PR 21809: Do not set a mapping state for debug sections
26449 - it just confuses other tools. */
26450 if (bfd_get_section_flags (NULL, now_seg) & SEC_DEBUGGING)
26453 frag_thumb_mode = fragP->tc_frag_data.thumb_mode ^ MODE_RECORDED;
26455 /* Record a mapping symbol for alignment frags. We will delete this
26456 later if the alignment ends up empty. */
26457 switch (fragP->fr_type)
26460 case rs_align_test:
26462 mapping_state_2 (MAP_DATA, max_chars);
26464 case rs_align_code:
26465 mapping_state_2 (frag_thumb_mode ? MAP_THUMB : MAP_ARM, max_chars);
26472 /* When we change sections we need to issue a new mapping symbol. */
26475 arm_elf_change_section (void)
26477 /* Link an unlinked unwind index table section to the .text section. */
26478 if (elf_section_type (now_seg) == SHT_ARM_EXIDX
26479 && elf_linked_to_section (now_seg) == NULL)
26480 elf_linked_to_section (now_seg) = text_section;
26484 arm_elf_section_type (const char * str, size_t len)
26486 if (len == 5 && strncmp (str, "exidx", 5) == 0)
26487 return SHT_ARM_EXIDX;
26492 /* Code to deal with unwinding tables. */
26494 static void add_unwind_adjustsp (offsetT);
26496 /* Generate any deferred unwind frame offset. */
26499 flush_pending_unwind (void)
26503 offset = unwind.pending_offset;
26504 unwind.pending_offset = 0;
26506 add_unwind_adjustsp (offset);
26509 /* Add an opcode to this list for this function. Two-byte opcodes should
26510 be passed as op[0] << 8 | op[1]. The list of opcodes is built in reverse
26514 add_unwind_opcode (valueT op, int length)
26516 /* Add any deferred stack adjustment. */
26517 if (unwind.pending_offset)
26518 flush_pending_unwind ();
26520 unwind.sp_restored = 0;
26522 if (unwind.opcode_count + length > unwind.opcode_alloc)
26524 unwind.opcode_alloc += ARM_OPCODE_CHUNK_SIZE;
26525 if (unwind.opcodes)
26526 unwind.opcodes = XRESIZEVEC (unsigned char, unwind.opcodes,
26527 unwind.opcode_alloc);
26529 unwind.opcodes = XNEWVEC (unsigned char, unwind.opcode_alloc);
26534 unwind.opcodes[unwind.opcode_count] = op & 0xff;
26536 unwind.opcode_count++;
26540 /* Add unwind opcodes to adjust the stack pointer. */
26543 add_unwind_adjustsp (offsetT offset)
26547 if (offset > 0x200)
26549 /* We need at most 5 bytes to hold a 32-bit value in a uleb128. */
26554 /* Long form: 0xb2, uleb128. */
26555 /* This might not fit in a word so add the individual bytes,
26556 remembering the list is built in reverse order. */
26557 o = (valueT) ((offset - 0x204) >> 2);
26559 add_unwind_opcode (0, 1);
26561 /* Calculate the uleb128 encoding of the offset. */
26565 bytes[n] = o & 0x7f;
26571 /* Add the insn. */
26573 add_unwind_opcode (bytes[n - 1], 1);
26574 add_unwind_opcode (0xb2, 1);
26576 else if (offset > 0x100)
26578 /* Two short opcodes. */
26579 add_unwind_opcode (0x3f, 1);
26580 op = (offset - 0x104) >> 2;
26581 add_unwind_opcode (op, 1);
26583 else if (offset > 0)
26585 /* Short opcode. */
26586 op = (offset - 4) >> 2;
26587 add_unwind_opcode (op, 1);
26589 else if (offset < 0)
26592 while (offset > 0x100)
26594 add_unwind_opcode (0x7f, 1);
26597 op = ((offset - 4) >> 2) | 0x40;
26598 add_unwind_opcode (op, 1);
26602 /* Finish the list of unwind opcodes for this function. */
26605 finish_unwind_opcodes (void)
26609 if (unwind.fp_used)
26611 /* Adjust sp as necessary. */
26612 unwind.pending_offset += unwind.fp_offset - unwind.frame_size;
26613 flush_pending_unwind ();
26615 /* After restoring sp from the frame pointer. */
26616 op = 0x90 | unwind.fp_reg;
26617 add_unwind_opcode (op, 1);
26620 flush_pending_unwind ();
26624 /* Start an exception table entry. If idx is nonzero this is an index table
26628 start_unwind_section (const segT text_seg, int idx)
26630 const char * text_name;
26631 const char * prefix;
26632 const char * prefix_once;
26633 const char * group_name;
26641 prefix = ELF_STRING_ARM_unwind;
26642 prefix_once = ELF_STRING_ARM_unwind_once;
26643 type = SHT_ARM_EXIDX;
26647 prefix = ELF_STRING_ARM_unwind_info;
26648 prefix_once = ELF_STRING_ARM_unwind_info_once;
26649 type = SHT_PROGBITS;
26652 text_name = segment_name (text_seg);
26653 if (streq (text_name, ".text"))
26656 if (strncmp (text_name, ".gnu.linkonce.t.",
26657 strlen (".gnu.linkonce.t.")) == 0)
26659 prefix = prefix_once;
26660 text_name += strlen (".gnu.linkonce.t.");
26663 sec_name = concat (prefix, text_name, (char *) NULL);
26669 /* Handle COMDAT group. */
26670 if (prefix != prefix_once && (text_seg->flags & SEC_LINK_ONCE) != 0)
26672 group_name = elf_group_name (text_seg);
26673 if (group_name == NULL)
26675 as_bad (_("Group section `%s' has no group signature"),
26676 segment_name (text_seg));
26677 ignore_rest_of_line ();
26680 flags |= SHF_GROUP;
26684 obj_elf_change_section (sec_name, type, 0, flags, 0, group_name,
26687 /* Set the section link for index tables. */
26689 elf_linked_to_section (now_seg) = text_seg;
26693 /* Start an unwind table entry. HAVE_DATA is nonzero if we have additional
26694 personality routine data. Returns zero, or the index table value for
26695 an inline entry. */
26698 create_unwind_entry (int have_data)
26703 /* The current word of data. */
26705 /* The number of bytes left in this word. */
26708 finish_unwind_opcodes ();
26710 /* Remember the current text section. */
26711 unwind.saved_seg = now_seg;
26712 unwind.saved_subseg = now_subseg;
26714 start_unwind_section (now_seg, 0);
26716 if (unwind.personality_routine == NULL)
26718 if (unwind.personality_index == -2)
26721 as_bad (_("handlerdata in cantunwind frame"));
26722 return 1; /* EXIDX_CANTUNWIND. */
26725 /* Use a default personality routine if none is specified. */
26726 if (unwind.personality_index == -1)
26728 if (unwind.opcode_count > 3)
26729 unwind.personality_index = 1;
26731 unwind.personality_index = 0;
26734 /* Space for the personality routine entry. */
26735 if (unwind.personality_index == 0)
26737 if (unwind.opcode_count > 3)
26738 as_bad (_("too many unwind opcodes for personality routine 0"));
26742 /* All the data is inline in the index table. */
26745 while (unwind.opcode_count > 0)
26747 unwind.opcode_count--;
26748 data = (data << 8) | unwind.opcodes[unwind.opcode_count];
26752 /* Pad with "finish" opcodes. */
26754 data = (data << 8) | 0xb0;
26761 /* We get two opcodes "free" in the first word. */
26762 size = unwind.opcode_count - 2;
26766 /* PR 16765: Missing or misplaced unwind directives can trigger this. */
26767 if (unwind.personality_index != -1)
26769 as_bad (_("attempt to recreate an unwind entry"));
26773 /* An extra byte is required for the opcode count. */
26774 size = unwind.opcode_count + 1;
26777 size = (size + 3) >> 2;
26779 as_bad (_("too many unwind opcodes"));
26781 frag_align (2, 0, 0);
26782 record_alignment (now_seg, 2);
26783 unwind.table_entry = expr_build_dot ();
26785 /* Allocate the table entry. */
26786 ptr = frag_more ((size << 2) + 4);
26787 /* PR 13449: Zero the table entries in case some of them are not used. */
26788 memset (ptr, 0, (size << 2) + 4);
26789 where = frag_now_fix () - ((size << 2) + 4);
26791 switch (unwind.personality_index)
26794 /* ??? Should this be a PLT generating relocation? */
26795 /* Custom personality routine. */
26796 fix_new (frag_now, where, 4, unwind.personality_routine, 0, 1,
26797 BFD_RELOC_ARM_PREL31);
26802 /* Set the first byte to the number of additional words. */
26803 data = size > 0 ? size - 1 : 0;
26807 /* ABI defined personality routines. */
26809 /* Three opcodes bytes are packed into the first word. */
26816 /* The size and first two opcode bytes go in the first word. */
26817 data = ((0x80 + unwind.personality_index) << 8) | size;
26822 /* Should never happen. */
26826 /* Pack the opcodes into words (MSB first), reversing the list at the same
26828 while (unwind.opcode_count > 0)
26832 md_number_to_chars (ptr, data, 4);
26837 unwind.opcode_count--;
26839 data = (data << 8) | unwind.opcodes[unwind.opcode_count];
26842 /* Finish off the last word. */
26845 /* Pad with "finish" opcodes. */
26847 data = (data << 8) | 0xb0;
26849 md_number_to_chars (ptr, data, 4);
26854 /* Add an empty descriptor if there is no user-specified data. */
26855 ptr = frag_more (4);
26856 md_number_to_chars (ptr, 0, 4);
26863 /* Initialize the DWARF-2 unwind information for this procedure. */
26866 tc_arm_frame_initial_instructions (void)
26868 cfi_add_CFA_def_cfa (REG_SP, 0);
26870 #endif /* OBJ_ELF */
26872 /* Convert REGNAME to a DWARF-2 register number. */
26875 tc_arm_regname_to_dw2regnum (char *regname)
26877 int reg = arm_reg_parse (®name, REG_TYPE_RN);
26881 /* PR 16694: Allow VFP registers as well. */
26882 reg = arm_reg_parse (®name, REG_TYPE_VFS);
26886 reg = arm_reg_parse (®name, REG_TYPE_VFD);
26895 tc_pe_dwarf2_emit_offset (symbolS *symbol, unsigned int size)
26899 exp.X_op = O_secrel;
26900 exp.X_add_symbol = symbol;
26901 exp.X_add_number = 0;
26902 emit_expr (&exp, size);
26906 /* MD interface: Symbol and relocation handling. */
26908 /* Return the address within the segment that a PC-relative fixup is
26909 relative to. For ARM, PC-relative fixups applied to instructions
26910 are generally relative to the location of the fixup plus 8 bytes.
26911 Thumb branches are offset by 4, and Thumb loads relative to PC
26912 require special handling. */
26915 md_pcrel_from_section (fixS * fixP, segT seg)
26917 offsetT base = fixP->fx_where + fixP->fx_frag->fr_address;
26919 /* If this is pc-relative and we are going to emit a relocation
26920 then we just want to put out any pipeline compensation that the linker
26921 will need. Otherwise we want to use the calculated base.
26922 For WinCE we skip the bias for externals as well, since this
26923 is how the MS ARM-CE assembler behaves and we want to be compatible. */
26925 && ((fixP->fx_addsy && S_GET_SEGMENT (fixP->fx_addsy) != seg)
26926 || (arm_force_relocation (fixP)
26928 && !S_IS_EXTERNAL (fixP->fx_addsy)
26934 switch (fixP->fx_r_type)
26936 /* PC relative addressing on the Thumb is slightly odd as the
26937 bottom two bits of the PC are forced to zero for the
26938 calculation. This happens *after* application of the
26939 pipeline offset. However, Thumb adrl already adjusts for
26940 this, so we need not do it again. */
26941 case BFD_RELOC_ARM_THUMB_ADD:
26944 case BFD_RELOC_ARM_THUMB_OFFSET:
26945 case BFD_RELOC_ARM_T32_OFFSET_IMM:
26946 case BFD_RELOC_ARM_T32_ADD_PC12:
26947 case BFD_RELOC_ARM_T32_CP_OFF_IMM:
26948 return (base + 4) & ~3;
26950 /* Thumb branches are simply offset by +4. */
26951 case BFD_RELOC_THUMB_PCREL_BRANCH5:
26952 case BFD_RELOC_THUMB_PCREL_BRANCH7:
26953 case BFD_RELOC_THUMB_PCREL_BRANCH9:
26954 case BFD_RELOC_THUMB_PCREL_BRANCH12:
26955 case BFD_RELOC_THUMB_PCREL_BRANCH20:
26956 case BFD_RELOC_THUMB_PCREL_BRANCH25:
26957 case BFD_RELOC_THUMB_PCREL_BFCSEL:
26958 case BFD_RELOC_ARM_THUMB_BF17:
26959 case BFD_RELOC_ARM_THUMB_BF19:
26960 case BFD_RELOC_ARM_THUMB_BF13:
26961 case BFD_RELOC_ARM_THUMB_LOOP12:
26964 case BFD_RELOC_THUMB_PCREL_BRANCH23:
26966 && (S_GET_SEGMENT (fixP->fx_addsy) == seg)
26967 && !S_FORCE_RELOC (fixP->fx_addsy, TRUE)
26968 && ARM_IS_FUNC (fixP->fx_addsy)
26969 && ARM_CPU_HAS_FEATURE (selected_cpu, arm_ext_v5t))
26970 base = fixP->fx_where + fixP->fx_frag->fr_address;
26973 /* BLX is like branches above, but forces the low two bits of PC to
26975 case BFD_RELOC_THUMB_PCREL_BLX:
26977 && (S_GET_SEGMENT (fixP->fx_addsy) == seg)
26978 && !S_FORCE_RELOC (fixP->fx_addsy, TRUE)
26979 && THUMB_IS_FUNC (fixP->fx_addsy)
26980 && ARM_CPU_HAS_FEATURE (selected_cpu, arm_ext_v5t))
26981 base = fixP->fx_where + fixP->fx_frag->fr_address;
26982 return (base + 4) & ~3;
26984 /* ARM mode branches are offset by +8. However, the Windows CE
26985 loader expects the relocation not to take this into account. */
26986 case BFD_RELOC_ARM_PCREL_BLX:
26988 && (S_GET_SEGMENT (fixP->fx_addsy) == seg)
26989 && !S_FORCE_RELOC (fixP->fx_addsy, TRUE)
26990 && ARM_IS_FUNC (fixP->fx_addsy)
26991 && ARM_CPU_HAS_FEATURE (selected_cpu, arm_ext_v5t))
26992 base = fixP->fx_where + fixP->fx_frag->fr_address;
26995 case BFD_RELOC_ARM_PCREL_CALL:
26997 && (S_GET_SEGMENT (fixP->fx_addsy) == seg)
26998 && !S_FORCE_RELOC (fixP->fx_addsy, TRUE)
26999 && THUMB_IS_FUNC (fixP->fx_addsy)
27000 && ARM_CPU_HAS_FEATURE (selected_cpu, arm_ext_v5t))
27001 base = fixP->fx_where + fixP->fx_frag->fr_address;
27004 case BFD_RELOC_ARM_PCREL_BRANCH:
27005 case BFD_RELOC_ARM_PCREL_JUMP:
27006 case BFD_RELOC_ARM_PLT32:
27008 /* When handling fixups immediately, because we have already
27009 discovered the value of a symbol, or the address of the frag involved
27010 we must account for the offset by +8, as the OS loader will never see the reloc.
27011 see fixup_segment() in write.c
27012 The S_IS_EXTERNAL test handles the case of global symbols.
27013 Those need the calculated base, not just the pipe compensation the linker will need. */
27015 && fixP->fx_addsy != NULL
27016 && (S_GET_SEGMENT (fixP->fx_addsy) == seg)
27017 && (S_IS_EXTERNAL (fixP->fx_addsy) || !arm_force_relocation (fixP)))
27025 /* ARM mode loads relative to PC are also offset by +8. Unlike
27026 branches, the Windows CE loader *does* expect the relocation
27027 to take this into account. */
27028 case BFD_RELOC_ARM_OFFSET_IMM:
27029 case BFD_RELOC_ARM_OFFSET_IMM8:
27030 case BFD_RELOC_ARM_HWLITERAL:
27031 case BFD_RELOC_ARM_LITERAL:
27032 case BFD_RELOC_ARM_CP_OFF_IMM:
27036 /* Other PC-relative relocations are un-offset. */
27042 static bfd_boolean flag_warn_syms = TRUE;
27045 arm_tc_equal_in_insn (int c ATTRIBUTE_UNUSED, char * name)
27047 /* PR 18347 - Warn if the user attempts to create a symbol with the same
27048 name as an ARM instruction. Whilst strictly speaking it is allowed, it
27049 does mean that the resulting code might be very confusing to the reader.
27050 Also this warning can be triggered if the user omits an operand before
27051 an immediate address, eg:
27055 GAS treats this as an assignment of the value of the symbol foo to a
27056 symbol LDR, and so (without this code) it will not issue any kind of
27057 warning or error message.
27059 Note - ARM instructions are case-insensitive but the strings in the hash
27060 table are all stored in lower case, so we must first ensure that name is
27062 if (flag_warn_syms && arm_ops_hsh)
27064 char * nbuf = strdup (name);
27067 for (p = nbuf; *p; p++)
27069 if (hash_find (arm_ops_hsh, nbuf) != NULL)
27071 static struct hash_control * already_warned = NULL;
27073 if (already_warned == NULL)
27074 already_warned = hash_new ();
27075 /* Only warn about the symbol once. To keep the code
27076 simple we let hash_insert do the lookup for us. */
27077 if (hash_insert (already_warned, nbuf, NULL) == NULL)
27078 as_warn (_("[-mwarn-syms]: Assignment makes a symbol match an ARM instruction: %s"), name);
27087 /* Under ELF we need to default _GLOBAL_OFFSET_TABLE.
27088 Otherwise we have no need to default values of symbols. */
27091 md_undefined_symbol (char * name ATTRIBUTE_UNUSED)
27094 if (name[0] == '_' && name[1] == 'G'
27095 && streq (name, GLOBAL_OFFSET_TABLE_NAME))
27099 if (symbol_find (name))
27100 as_bad (_("GOT already in the symbol table"));
27102 GOT_symbol = symbol_new (name, undefined_section,
27103 (valueT) 0, & zero_address_frag);
27113 /* Subroutine of md_apply_fix. Check to see if an immediate can be
27114 computed as two separate immediate values, added together. We
27115 already know that this value cannot be computed by just one ARM
27118 static unsigned int
27119 validate_immediate_twopart (unsigned int val,
27120 unsigned int * highpart)
27125 for (i = 0; i < 32; i += 2)
27126 if (((a = rotate_left (val, i)) & 0xff) != 0)
27132 * highpart = (a >> 8) | ((i + 24) << 7);
27134 else if (a & 0xff0000)
27136 if (a & 0xff000000)
27138 * highpart = (a >> 16) | ((i + 16) << 7);
27142 gas_assert (a & 0xff000000);
27143 * highpart = (a >> 24) | ((i + 8) << 7);
27146 return (a & 0xff) | (i << 7);
27153 validate_offset_imm (unsigned int val, int hwse)
27155 if ((hwse && val > 255) || val > 4095)
27160 /* Subroutine of md_apply_fix. Do those data_ops which can take a
27161 negative immediate constant by altering the instruction. A bit of
27166 by inverting the second operand, and
27169 by negating the second operand. */
27172 negate_data_op (unsigned long * instruction,
27173 unsigned long value)
27176 unsigned long negated, inverted;
27178 negated = encode_arm_immediate (-value);
27179 inverted = encode_arm_immediate (~value);
27181 op = (*instruction >> DATA_OP_SHIFT) & 0xf;
27184 /* First negates. */
27185 case OPCODE_SUB: /* ADD <-> SUB */
27186 new_inst = OPCODE_ADD;
27191 new_inst = OPCODE_SUB;
27195 case OPCODE_CMP: /* CMP <-> CMN */
27196 new_inst = OPCODE_CMN;
27201 new_inst = OPCODE_CMP;
27205 /* Now Inverted ops. */
27206 case OPCODE_MOV: /* MOV <-> MVN */
27207 new_inst = OPCODE_MVN;
27212 new_inst = OPCODE_MOV;
27216 case OPCODE_AND: /* AND <-> BIC */
27217 new_inst = OPCODE_BIC;
27222 new_inst = OPCODE_AND;
27226 case OPCODE_ADC: /* ADC <-> SBC */
27227 new_inst = OPCODE_SBC;
27232 new_inst = OPCODE_ADC;
27236 /* We cannot do anything. */
27241 if (value == (unsigned) FAIL)
27244 *instruction &= OPCODE_MASK;
27245 *instruction |= new_inst << DATA_OP_SHIFT;
27249 /* Like negate_data_op, but for Thumb-2. */
27251 static unsigned int
27252 thumb32_negate_data_op (offsetT *instruction, unsigned int value)
27256 unsigned int negated, inverted;
27258 negated = encode_thumb32_immediate (-value);
27259 inverted = encode_thumb32_immediate (~value);
27261 rd = (*instruction >> 8) & 0xf;
27262 op = (*instruction >> T2_DATA_OP_SHIFT) & 0xf;
27265 /* ADD <-> SUB. Includes CMP <-> CMN. */
27266 case T2_OPCODE_SUB:
27267 new_inst = T2_OPCODE_ADD;
27271 case T2_OPCODE_ADD:
27272 new_inst = T2_OPCODE_SUB;
27276 /* ORR <-> ORN. Includes MOV <-> MVN. */
27277 case T2_OPCODE_ORR:
27278 new_inst = T2_OPCODE_ORN;
27282 case T2_OPCODE_ORN:
27283 new_inst = T2_OPCODE_ORR;
27287 /* AND <-> BIC. TST has no inverted equivalent. */
27288 case T2_OPCODE_AND:
27289 new_inst = T2_OPCODE_BIC;
27296 case T2_OPCODE_BIC:
27297 new_inst = T2_OPCODE_AND;
27302 case T2_OPCODE_ADC:
27303 new_inst = T2_OPCODE_SBC;
27307 case T2_OPCODE_SBC:
27308 new_inst = T2_OPCODE_ADC;
27312 /* We cannot do anything. */
27317 if (value == (unsigned int)FAIL)
27320 *instruction &= T2_OPCODE_MASK;
27321 *instruction |= new_inst << T2_DATA_OP_SHIFT;
27325 /* Read a 32-bit thumb instruction from buf. */
27327 static unsigned long
27328 get_thumb32_insn (char * buf)
27330 unsigned long insn;
27331 insn = md_chars_to_number (buf, THUMB_SIZE) << 16;
27332 insn |= md_chars_to_number (buf + THUMB_SIZE, THUMB_SIZE);
27337 /* We usually want to set the low bit on the address of thumb function
27338 symbols. In particular .word foo - . should have the low bit set.
27339 Generic code tries to fold the difference of two symbols to
27340 a constant. Prevent this and force a relocation when the first symbols
27341 is a thumb function. */
27344 arm_optimize_expr (expressionS *l, operatorT op, expressionS *r)
27346 if (op == O_subtract
27347 && l->X_op == O_symbol
27348 && r->X_op == O_symbol
27349 && THUMB_IS_FUNC (l->X_add_symbol))
27351 l->X_op = O_subtract;
27352 l->X_op_symbol = r->X_add_symbol;
27353 l->X_add_number -= r->X_add_number;
27357 /* Process as normal. */
27361 /* Encode Thumb2 unconditional branches and calls. The encoding
27362 for the 2 are identical for the immediate values. */
27365 encode_thumb2_b_bl_offset (char * buf, offsetT value)
27367 #define T2I1I2MASK ((1 << 13) | (1 << 11))
27370 addressT S, I1, I2, lo, hi;
27372 S = (value >> 24) & 0x01;
27373 I1 = (value >> 23) & 0x01;
27374 I2 = (value >> 22) & 0x01;
27375 hi = (value >> 12) & 0x3ff;
27376 lo = (value >> 1) & 0x7ff;
27377 newval = md_chars_to_number (buf, THUMB_SIZE);
27378 newval2 = md_chars_to_number (buf + THUMB_SIZE, THUMB_SIZE);
27379 newval |= (S << 10) | hi;
27380 newval2 &= ~T2I1I2MASK;
27381 newval2 |= (((I1 ^ S) << 13) | ((I2 ^ S) << 11) | lo) ^ T2I1I2MASK;
27382 md_number_to_chars (buf, newval, THUMB_SIZE);
27383 md_number_to_chars (buf + THUMB_SIZE, newval2, THUMB_SIZE);
27387 md_apply_fix (fixS * fixP,
27391 offsetT value = * valP;
27393 unsigned int newimm;
27394 unsigned long temp;
27396 char * buf = fixP->fx_where + fixP->fx_frag->fr_literal;
27398 gas_assert (fixP->fx_r_type <= BFD_RELOC_UNUSED);
27400 /* Note whether this will delete the relocation. */
27402 if (fixP->fx_addsy == 0 && !fixP->fx_pcrel)
27405 /* On a 64-bit host, silently truncate 'value' to 32 bits for
27406 consistency with the behaviour on 32-bit hosts. Remember value
27408 value &= 0xffffffff;
27409 value ^= 0x80000000;
27410 value -= 0x80000000;
27413 fixP->fx_addnumber = value;
27415 /* Same treatment for fixP->fx_offset. */
27416 fixP->fx_offset &= 0xffffffff;
27417 fixP->fx_offset ^= 0x80000000;
27418 fixP->fx_offset -= 0x80000000;
27420 switch (fixP->fx_r_type)
27422 case BFD_RELOC_NONE:
27423 /* This will need to go in the object file. */
27427 case BFD_RELOC_ARM_IMMEDIATE:
27428 /* We claim that this fixup has been processed here,
27429 even if in fact we generate an error because we do
27430 not have a reloc for it, so tc_gen_reloc will reject it. */
27433 if (fixP->fx_addsy)
27435 const char *msg = 0;
27437 if (! S_IS_DEFINED (fixP->fx_addsy))
27438 msg = _("undefined symbol %s used as an immediate value");
27439 else if (S_GET_SEGMENT (fixP->fx_addsy) != seg)
27440 msg = _("symbol %s is in a different section");
27441 else if (S_IS_WEAK (fixP->fx_addsy))
27442 msg = _("symbol %s is weak and may be overridden later");
27446 as_bad_where (fixP->fx_file, fixP->fx_line,
27447 msg, S_GET_NAME (fixP->fx_addsy));
27452 temp = md_chars_to_number (buf, INSN_SIZE);
27454 /* If the offset is negative, we should use encoding A2 for ADR. */
27455 if ((temp & 0xfff0000) == 0x28f0000 && value < 0)
27456 newimm = negate_data_op (&temp, value);
27459 newimm = encode_arm_immediate (value);
27461 /* If the instruction will fail, see if we can fix things up by
27462 changing the opcode. */
27463 if (newimm == (unsigned int) FAIL)
27464 newimm = negate_data_op (&temp, value);
27465 /* MOV accepts both ARM modified immediate (A1 encoding) and
27466 UINT16 (A2 encoding) when possible, MOVW only accepts UINT16.
27467 When disassembling, MOV is preferred when there is no encoding
27469 if (newimm == (unsigned int) FAIL
27470 && ((temp >> DATA_OP_SHIFT) & 0xf) == OPCODE_MOV
27471 && ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_v6t2)
27472 && !((temp >> SBIT_SHIFT) & 0x1)
27473 && value >= 0 && value <= 0xffff)
27475 /* Clear bits[23:20] to change encoding from A1 to A2. */
27476 temp &= 0xff0fffff;
27477 /* Encoding high 4bits imm. Code below will encode the remaining
27479 temp |= (value & 0x0000f000) << 4;
27480 newimm = value & 0x00000fff;
27484 if (newimm == (unsigned int) FAIL)
27486 as_bad_where (fixP->fx_file, fixP->fx_line,
27487 _("invalid constant (%lx) after fixup"),
27488 (unsigned long) value);
27492 newimm |= (temp & 0xfffff000);
27493 md_number_to_chars (buf, (valueT) newimm, INSN_SIZE);
27496 case BFD_RELOC_ARM_ADRL_IMMEDIATE:
27498 unsigned int highpart = 0;
27499 unsigned int newinsn = 0xe1a00000; /* nop. */
27501 if (fixP->fx_addsy)
27503 const char *msg = 0;
27505 if (! S_IS_DEFINED (fixP->fx_addsy))
27506 msg = _("undefined symbol %s used as an immediate value");
27507 else if (S_GET_SEGMENT (fixP->fx_addsy) != seg)
27508 msg = _("symbol %s is in a different section");
27509 else if (S_IS_WEAK (fixP->fx_addsy))
27510 msg = _("symbol %s is weak and may be overridden later");
27514 as_bad_where (fixP->fx_file, fixP->fx_line,
27515 msg, S_GET_NAME (fixP->fx_addsy));
27520 newimm = encode_arm_immediate (value);
27521 temp = md_chars_to_number (buf, INSN_SIZE);
27523 /* If the instruction will fail, see if we can fix things up by
27524 changing the opcode. */
27525 if (newimm == (unsigned int) FAIL
27526 && (newimm = negate_data_op (& temp, value)) == (unsigned int) FAIL)
27528 /* No ? OK - try using two ADD instructions to generate
27530 newimm = validate_immediate_twopart (value, & highpart);
27532 /* Yes - then make sure that the second instruction is
27534 if (newimm != (unsigned int) FAIL)
27536 /* Still No ? Try using a negated value. */
27537 else if ((newimm = validate_immediate_twopart (- value, & highpart)) != (unsigned int) FAIL)
27538 temp = newinsn = (temp & OPCODE_MASK) | OPCODE_SUB << DATA_OP_SHIFT;
27539 /* Otherwise - give up. */
27542 as_bad_where (fixP->fx_file, fixP->fx_line,
27543 _("unable to compute ADRL instructions for PC offset of 0x%lx"),
27548 /* Replace the first operand in the 2nd instruction (which
27549 is the PC) with the destination register. We have
27550 already added in the PC in the first instruction and we
27551 do not want to do it again. */
27552 newinsn &= ~ 0xf0000;
27553 newinsn |= ((newinsn & 0x0f000) << 4);
27556 newimm |= (temp & 0xfffff000);
27557 md_number_to_chars (buf, (valueT) newimm, INSN_SIZE);
27559 highpart |= (newinsn & 0xfffff000);
27560 md_number_to_chars (buf + INSN_SIZE, (valueT) highpart, INSN_SIZE);
27564 case BFD_RELOC_ARM_OFFSET_IMM:
27565 if (!fixP->fx_done && seg->use_rela_p)
27567 /* Fall through. */
27569 case BFD_RELOC_ARM_LITERAL:
27575 if (validate_offset_imm (value, 0) == FAIL)
27577 if (fixP->fx_r_type == BFD_RELOC_ARM_LITERAL)
27578 as_bad_where (fixP->fx_file, fixP->fx_line,
27579 _("invalid literal constant: pool needs to be closer"));
27581 as_bad_where (fixP->fx_file, fixP->fx_line,
27582 _("bad immediate value for offset (%ld)"),
27587 newval = md_chars_to_number (buf, INSN_SIZE);
27589 newval &= 0xfffff000;
27592 newval &= 0xff7ff000;
27593 newval |= value | (sign ? INDEX_UP : 0);
27595 md_number_to_chars (buf, newval, INSN_SIZE);
27598 case BFD_RELOC_ARM_OFFSET_IMM8:
27599 case BFD_RELOC_ARM_HWLITERAL:
27605 if (validate_offset_imm (value, 1) == FAIL)
27607 if (fixP->fx_r_type == BFD_RELOC_ARM_HWLITERAL)
27608 as_bad_where (fixP->fx_file, fixP->fx_line,
27609 _("invalid literal constant: pool needs to be closer"));
27611 as_bad_where (fixP->fx_file, fixP->fx_line,
27612 _("bad immediate value for 8-bit offset (%ld)"),
27617 newval = md_chars_to_number (buf, INSN_SIZE);
27619 newval &= 0xfffff0f0;
27622 newval &= 0xff7ff0f0;
27623 newval |= ((value >> 4) << 8) | (value & 0xf) | (sign ? INDEX_UP : 0);
27625 md_number_to_chars (buf, newval, INSN_SIZE);
27628 case BFD_RELOC_ARM_T32_OFFSET_U8:
27629 if (value < 0 || value > 1020 || value % 4 != 0)
27630 as_bad_where (fixP->fx_file, fixP->fx_line,
27631 _("bad immediate value for offset (%ld)"), (long) value);
27634 newval = md_chars_to_number (buf+2, THUMB_SIZE);
27636 md_number_to_chars (buf+2, newval, THUMB_SIZE);
27639 case BFD_RELOC_ARM_T32_OFFSET_IMM:
27640 /* This is a complicated relocation used for all varieties of Thumb32
27641 load/store instruction with immediate offset:
27643 1110 100P u1WL NNNN XXXX YYYY iiii iiii - +/-(U) pre/post(P) 8-bit,
27644 *4, optional writeback(W)
27645 (doubleword load/store)
27647 1111 100S uTTL 1111 XXXX iiii iiii iiii - +/-(U) 12-bit PC-rel
27648 1111 100S 0TTL NNNN XXXX 1Pu1 iiii iiii - +/-(U) pre/post(P) 8-bit
27649 1111 100S 0TTL NNNN XXXX 1110 iiii iiii - positive 8-bit (T instruction)
27650 1111 100S 1TTL NNNN XXXX iiii iiii iiii - positive 12-bit
27651 1111 100S 0TTL NNNN XXXX 1100 iiii iiii - negative 8-bit
27653 Uppercase letters indicate bits that are already encoded at
27654 this point. Lowercase letters are our problem. For the
27655 second block of instructions, the secondary opcode nybble
27656 (bits 8..11) is present, and bit 23 is zero, even if this is
27657 a PC-relative operation. */
27658 newval = md_chars_to_number (buf, THUMB_SIZE);
27660 newval |= md_chars_to_number (buf+THUMB_SIZE, THUMB_SIZE);
27662 if ((newval & 0xf0000000) == 0xe0000000)
27664 /* Doubleword load/store: 8-bit offset, scaled by 4. */
27666 newval |= (1 << 23);
27669 if (value % 4 != 0)
27671 as_bad_where (fixP->fx_file, fixP->fx_line,
27672 _("offset not a multiple of 4"));
27678 as_bad_where (fixP->fx_file, fixP->fx_line,
27679 _("offset out of range"));
27684 else if ((newval & 0x000f0000) == 0x000f0000)
27686 /* PC-relative, 12-bit offset. */
27688 newval |= (1 << 23);
27693 as_bad_where (fixP->fx_file, fixP->fx_line,
27694 _("offset out of range"));
27699 else if ((newval & 0x00000100) == 0x00000100)
27701 /* Writeback: 8-bit, +/- offset. */
27703 newval |= (1 << 9);
27708 as_bad_where (fixP->fx_file, fixP->fx_line,
27709 _("offset out of range"));
27714 else if ((newval & 0x00000f00) == 0x00000e00)
27716 /* T-instruction: positive 8-bit offset. */
27717 if (value < 0 || value > 0xff)
27719 as_bad_where (fixP->fx_file, fixP->fx_line,
27720 _("offset out of range"));
27728 /* Positive 12-bit or negative 8-bit offset. */
27732 newval |= (1 << 23);
27742 as_bad_where (fixP->fx_file, fixP->fx_line,
27743 _("offset out of range"));
27750 md_number_to_chars (buf, (newval >> 16) & 0xffff, THUMB_SIZE);
27751 md_number_to_chars (buf + THUMB_SIZE, newval & 0xffff, THUMB_SIZE);
27754 case BFD_RELOC_ARM_SHIFT_IMM:
27755 newval = md_chars_to_number (buf, INSN_SIZE);
27756 if (((unsigned long) value) > 32
27758 && (((newval & 0x60) == 0) || (newval & 0x60) == 0x60)))
27760 as_bad_where (fixP->fx_file, fixP->fx_line,
27761 _("shift expression is too large"));
27766 /* Shifts of zero must be done as lsl. */
27768 else if (value == 32)
27770 newval &= 0xfffff07f;
27771 newval |= (value & 0x1f) << 7;
27772 md_number_to_chars (buf, newval, INSN_SIZE);
27775 case BFD_RELOC_ARM_T32_IMMEDIATE:
27776 case BFD_RELOC_ARM_T32_ADD_IMM:
27777 case BFD_RELOC_ARM_T32_IMM12:
27778 case BFD_RELOC_ARM_T32_ADD_PC12:
27779 /* We claim that this fixup has been processed here,
27780 even if in fact we generate an error because we do
27781 not have a reloc for it, so tc_gen_reloc will reject it. */
27785 && ! S_IS_DEFINED (fixP->fx_addsy))
27787 as_bad_where (fixP->fx_file, fixP->fx_line,
27788 _("undefined symbol %s used as an immediate value"),
27789 S_GET_NAME (fixP->fx_addsy));
27793 newval = md_chars_to_number (buf, THUMB_SIZE);
27795 newval |= md_chars_to_number (buf+2, THUMB_SIZE);
27798 if ((fixP->fx_r_type == BFD_RELOC_ARM_T32_IMMEDIATE
27799 /* ARMv8-M Baseline MOV will reach here, but it doesn't support
27800 Thumb2 modified immediate encoding (T2). */
27801 && ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_v6t2))
27802 || fixP->fx_r_type == BFD_RELOC_ARM_T32_ADD_IMM)
27804 newimm = encode_thumb32_immediate (value);
27805 if (newimm == (unsigned int) FAIL)
27806 newimm = thumb32_negate_data_op (&newval, value);
27808 if (newimm == (unsigned int) FAIL)
27810 if (fixP->fx_r_type != BFD_RELOC_ARM_T32_IMMEDIATE)
27812 /* Turn add/sum into addw/subw. */
27813 if (fixP->fx_r_type == BFD_RELOC_ARM_T32_ADD_IMM)
27814 newval = (newval & 0xfeffffff) | 0x02000000;
27815 /* No flat 12-bit imm encoding for addsw/subsw. */
27816 if ((newval & 0x00100000) == 0)
27818 /* 12 bit immediate for addw/subw. */
27822 newval ^= 0x00a00000;
27825 newimm = (unsigned int) FAIL;
27832 /* MOV accepts both Thumb2 modified immediate (T2 encoding) and
27833 UINT16 (T3 encoding), MOVW only accepts UINT16. When
27834 disassembling, MOV is preferred when there is no encoding
27836 if (((newval >> T2_DATA_OP_SHIFT) & 0xf) == T2_OPCODE_ORR
27837 /* NOTE: MOV uses the ORR opcode in Thumb 2 mode
27838 but with the Rn field [19:16] set to 1111. */
27839 && (((newval >> 16) & 0xf) == 0xf)
27840 && ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_v6t2_v8m)
27841 && !((newval >> T2_SBIT_SHIFT) & 0x1)
27842 && value >= 0 && value <= 0xffff)
27844 /* Toggle bit[25] to change encoding from T2 to T3. */
27846 /* Clear bits[19:16]. */
27847 newval &= 0xfff0ffff;
27848 /* Encoding high 4bits imm. Code below will encode the
27849 remaining low 12bits. */
27850 newval |= (value & 0x0000f000) << 4;
27851 newimm = value & 0x00000fff;
27856 if (newimm == (unsigned int)FAIL)
27858 as_bad_where (fixP->fx_file, fixP->fx_line,
27859 _("invalid constant (%lx) after fixup"),
27860 (unsigned long) value);
27864 newval |= (newimm & 0x800) << 15;
27865 newval |= (newimm & 0x700) << 4;
27866 newval |= (newimm & 0x0ff);
27868 md_number_to_chars (buf, (valueT) ((newval >> 16) & 0xffff), THUMB_SIZE);
27869 md_number_to_chars (buf+2, (valueT) (newval & 0xffff), THUMB_SIZE);
27872 case BFD_RELOC_ARM_SMC:
27873 if (((unsigned long) value) > 0xf)
27874 as_bad_where (fixP->fx_file, fixP->fx_line,
27875 _("invalid smc expression"));
27877 newval = md_chars_to_number (buf, INSN_SIZE);
27878 newval |= (value & 0xf);
27879 md_number_to_chars (buf, newval, INSN_SIZE);
27882 case BFD_RELOC_ARM_HVC:
27883 if (((unsigned long) value) > 0xffff)
27884 as_bad_where (fixP->fx_file, fixP->fx_line,
27885 _("invalid hvc expression"));
27886 newval = md_chars_to_number (buf, INSN_SIZE);
27887 newval |= (value & 0xf) | ((value & 0xfff0) << 4);
27888 md_number_to_chars (buf, newval, INSN_SIZE);
27891 case BFD_RELOC_ARM_SWI:
27892 if (fixP->tc_fix_data != 0)
27894 if (((unsigned long) value) > 0xff)
27895 as_bad_where (fixP->fx_file, fixP->fx_line,
27896 _("invalid swi expression"));
27897 newval = md_chars_to_number (buf, THUMB_SIZE);
27899 md_number_to_chars (buf, newval, THUMB_SIZE);
27903 if (((unsigned long) value) > 0x00ffffff)
27904 as_bad_where (fixP->fx_file, fixP->fx_line,
27905 _("invalid swi expression"));
27906 newval = md_chars_to_number (buf, INSN_SIZE);
27908 md_number_to_chars (buf, newval, INSN_SIZE);
27912 case BFD_RELOC_ARM_MULTI:
27913 if (((unsigned long) value) > 0xffff)
27914 as_bad_where (fixP->fx_file, fixP->fx_line,
27915 _("invalid expression in load/store multiple"));
27916 newval = value | md_chars_to_number (buf, INSN_SIZE);
27917 md_number_to_chars (buf, newval, INSN_SIZE);
27921 case BFD_RELOC_ARM_PCREL_CALL:
27923 if (ARM_CPU_HAS_FEATURE (selected_cpu, arm_ext_v5t)
27925 && !S_FORCE_RELOC (fixP->fx_addsy, TRUE)
27926 && (S_GET_SEGMENT (fixP->fx_addsy) == seg)
27927 && THUMB_IS_FUNC (fixP->fx_addsy))
27928 /* Flip the bl to blx. This is a simple flip
27929 bit here because we generate PCREL_CALL for
27930 unconditional bls. */
27932 newval = md_chars_to_number (buf, INSN_SIZE);
27933 newval = newval | 0x10000000;
27934 md_number_to_chars (buf, newval, INSN_SIZE);
27940 goto arm_branch_common;
27942 case BFD_RELOC_ARM_PCREL_JUMP:
27943 if (ARM_CPU_HAS_FEATURE (selected_cpu, arm_ext_v5t)
27945 && !S_FORCE_RELOC (fixP->fx_addsy, TRUE)
27946 && (S_GET_SEGMENT (fixP->fx_addsy) == seg)
27947 && THUMB_IS_FUNC (fixP->fx_addsy))
27949 /* This would map to a bl<cond>, b<cond>,
27950 b<always> to a Thumb function. We
27951 need to force a relocation for this particular
27953 newval = md_chars_to_number (buf, INSN_SIZE);
27956 /* Fall through. */
27958 case BFD_RELOC_ARM_PLT32:
27960 case BFD_RELOC_ARM_PCREL_BRANCH:
27962 goto arm_branch_common;
27964 case BFD_RELOC_ARM_PCREL_BLX:
27967 if (ARM_CPU_HAS_FEATURE (selected_cpu, arm_ext_v5t)
27969 && !S_FORCE_RELOC (fixP->fx_addsy, TRUE)
27970 && (S_GET_SEGMENT (fixP->fx_addsy) == seg)
27971 && ARM_IS_FUNC (fixP->fx_addsy))
27973 /* Flip the blx to a bl and warn. */
27974 const char *name = S_GET_NAME (fixP->fx_addsy);
27975 newval = 0xeb000000;
27976 as_warn_where (fixP->fx_file, fixP->fx_line,
27977 _("blx to '%s' an ARM ISA state function changed to bl"),
27979 md_number_to_chars (buf, newval, INSN_SIZE);
27985 if (EF_ARM_EABI_VERSION (meabi_flags) >= EF_ARM_EABI_VER4)
27986 fixP->fx_r_type = BFD_RELOC_ARM_PCREL_CALL;
27990 /* We are going to store value (shifted right by two) in the
27991 instruction, in a 24 bit, signed field. Bits 26 through 32 either
27992 all clear or all set and bit 0 must be clear. For B/BL bit 1 must
27995 as_bad_where (fixP->fx_file, fixP->fx_line,
27996 _("misaligned branch destination"));
27997 if ((value & (offsetT)0xfe000000) != (offsetT)0
27998 && (value & (offsetT)0xfe000000) != (offsetT)0xfe000000)
27999 as_bad_where (fixP->fx_file, fixP->fx_line, BAD_RANGE);
28001 if (fixP->fx_done || !seg->use_rela_p)
28003 newval = md_chars_to_number (buf, INSN_SIZE);
28004 newval |= (value >> 2) & 0x00ffffff;
28005 /* Set the H bit on BLX instructions. */
28009 newval |= 0x01000000;
28011 newval &= ~0x01000000;
28013 md_number_to_chars (buf, newval, INSN_SIZE);
28017 case BFD_RELOC_THUMB_PCREL_BRANCH7: /* CBZ */
28018 /* CBZ can only branch forward. */
28020 /* Attempts to use CBZ to branch to the next instruction
28021 (which, strictly speaking, are prohibited) will be turned into
28024 FIXME: It may be better to remove the instruction completely and
28025 perform relaxation. */
28028 newval = md_chars_to_number (buf, THUMB_SIZE);
28029 newval = 0xbf00; /* NOP encoding T1 */
28030 md_number_to_chars (buf, newval, THUMB_SIZE);
28035 as_bad_where (fixP->fx_file, fixP->fx_line, BAD_RANGE);
28037 if (fixP->fx_done || !seg->use_rela_p)
28039 newval = md_chars_to_number (buf, THUMB_SIZE);
28040 newval |= ((value & 0x3e) << 2) | ((value & 0x40) << 3);
28041 md_number_to_chars (buf, newval, THUMB_SIZE);
28046 case BFD_RELOC_THUMB_PCREL_BRANCH9: /* Conditional branch. */
28047 if ((value & ~0xff) && ((value & ~0xff) != ~0xff))
28048 as_bad_where (fixP->fx_file, fixP->fx_line, BAD_RANGE);
28050 if (fixP->fx_done || !seg->use_rela_p)
28052 newval = md_chars_to_number (buf, THUMB_SIZE);
28053 newval |= (value & 0x1ff) >> 1;
28054 md_number_to_chars (buf, newval, THUMB_SIZE);
28058 case BFD_RELOC_THUMB_PCREL_BRANCH12: /* Unconditional branch. */
28059 if ((value & ~0x7ff) && ((value & ~0x7ff) != ~0x7ff))
28060 as_bad_where (fixP->fx_file, fixP->fx_line, BAD_RANGE);
28062 if (fixP->fx_done || !seg->use_rela_p)
28064 newval = md_chars_to_number (buf, THUMB_SIZE);
28065 newval |= (value & 0xfff) >> 1;
28066 md_number_to_chars (buf, newval, THUMB_SIZE);
28070 case BFD_RELOC_THUMB_PCREL_BRANCH20:
28072 && (S_GET_SEGMENT (fixP->fx_addsy) == seg)
28073 && !S_FORCE_RELOC (fixP->fx_addsy, TRUE)
28074 && ARM_IS_FUNC (fixP->fx_addsy)
28075 && ARM_CPU_HAS_FEATURE (selected_cpu, arm_ext_v5t))
28077 /* Force a relocation for a branch 20 bits wide. */
28080 if ((value & ~0x1fffff) && ((value & ~0x0fffff) != ~0x0fffff))
28081 as_bad_where (fixP->fx_file, fixP->fx_line,
28082 _("conditional branch out of range"));
28084 if (fixP->fx_done || !seg->use_rela_p)
28087 addressT S, J1, J2, lo, hi;
28089 S = (value & 0x00100000) >> 20;
28090 J2 = (value & 0x00080000) >> 19;
28091 J1 = (value & 0x00040000) >> 18;
28092 hi = (value & 0x0003f000) >> 12;
28093 lo = (value & 0x00000ffe) >> 1;
28095 newval = md_chars_to_number (buf, THUMB_SIZE);
28096 newval2 = md_chars_to_number (buf + THUMB_SIZE, THUMB_SIZE);
28097 newval |= (S << 10) | hi;
28098 newval2 |= (J1 << 13) | (J2 << 11) | lo;
28099 md_number_to_chars (buf, newval, THUMB_SIZE);
28100 md_number_to_chars (buf + THUMB_SIZE, newval2, THUMB_SIZE);
28104 case BFD_RELOC_THUMB_PCREL_BLX:
28105 /* If there is a blx from a thumb state function to
28106 another thumb function flip this to a bl and warn
28110 && !S_FORCE_RELOC (fixP->fx_addsy, TRUE)
28111 && (S_GET_SEGMENT (fixP->fx_addsy) == seg)
28112 && THUMB_IS_FUNC (fixP->fx_addsy))
28114 const char *name = S_GET_NAME (fixP->fx_addsy);
28115 as_warn_where (fixP->fx_file, fixP->fx_line,
28116 _("blx to Thumb func '%s' from Thumb ISA state changed to bl"),
28118 newval = md_chars_to_number (buf + THUMB_SIZE, THUMB_SIZE);
28119 newval = newval | 0x1000;
28120 md_number_to_chars (buf+THUMB_SIZE, newval, THUMB_SIZE);
28121 fixP->fx_r_type = BFD_RELOC_THUMB_PCREL_BRANCH23;
28126 goto thumb_bl_common;
28128 case BFD_RELOC_THUMB_PCREL_BRANCH23:
28129 /* A bl from Thumb state ISA to an internal ARM state function
28130 is converted to a blx. */
28132 && (S_GET_SEGMENT (fixP->fx_addsy) == seg)
28133 && !S_FORCE_RELOC (fixP->fx_addsy, TRUE)
28134 && ARM_IS_FUNC (fixP->fx_addsy)
28135 && ARM_CPU_HAS_FEATURE (selected_cpu, arm_ext_v5t))
28137 newval = md_chars_to_number (buf + THUMB_SIZE, THUMB_SIZE);
28138 newval = newval & ~0x1000;
28139 md_number_to_chars (buf+THUMB_SIZE, newval, THUMB_SIZE);
28140 fixP->fx_r_type = BFD_RELOC_THUMB_PCREL_BLX;
28146 if (fixP->fx_r_type == BFD_RELOC_THUMB_PCREL_BLX)
28147 /* For a BLX instruction, make sure that the relocation is rounded up
28148 to a word boundary. This follows the semantics of the instruction
28149 which specifies that bit 1 of the target address will come from bit
28150 1 of the base address. */
28151 value = (value + 3) & ~ 3;
28154 if (EF_ARM_EABI_VERSION (meabi_flags) >= EF_ARM_EABI_VER4
28155 && fixP->fx_r_type == BFD_RELOC_THUMB_PCREL_BLX)
28156 fixP->fx_r_type = BFD_RELOC_THUMB_PCREL_BRANCH23;
28159 if ((value & ~0x3fffff) && ((value & ~0x3fffff) != ~0x3fffff))
28161 if (!(ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_v6t2)))
28162 as_bad_where (fixP->fx_file, fixP->fx_line, BAD_RANGE);
28163 else if ((value & ~0x1ffffff)
28164 && ((value & ~0x1ffffff) != ~0x1ffffff))
28165 as_bad_where (fixP->fx_file, fixP->fx_line,
28166 _("Thumb2 branch out of range"));
28169 if (fixP->fx_done || !seg->use_rela_p)
28170 encode_thumb2_b_bl_offset (buf, value);
28174 case BFD_RELOC_THUMB_PCREL_BRANCH25:
28175 if ((value & ~0x0ffffff) && ((value & ~0x0ffffff) != ~0x0ffffff))
28176 as_bad_where (fixP->fx_file, fixP->fx_line, BAD_RANGE);
28178 if (fixP->fx_done || !seg->use_rela_p)
28179 encode_thumb2_b_bl_offset (buf, value);
28184 if (fixP->fx_done || !seg->use_rela_p)
28189 if (fixP->fx_done || !seg->use_rela_p)
28190 md_number_to_chars (buf, value, 2);
28194 case BFD_RELOC_ARM_TLS_CALL:
28195 case BFD_RELOC_ARM_THM_TLS_CALL:
28196 case BFD_RELOC_ARM_TLS_DESCSEQ:
28197 case BFD_RELOC_ARM_THM_TLS_DESCSEQ:
28198 case BFD_RELOC_ARM_TLS_GOTDESC:
28199 case BFD_RELOC_ARM_TLS_GD32:
28200 case BFD_RELOC_ARM_TLS_LE32:
28201 case BFD_RELOC_ARM_TLS_IE32:
28202 case BFD_RELOC_ARM_TLS_LDM32:
28203 case BFD_RELOC_ARM_TLS_LDO32:
28204 S_SET_THREAD_LOCAL (fixP->fx_addsy);
28207 /* Same handling as above, but with the arm_fdpic guard. */
28208 case BFD_RELOC_ARM_TLS_GD32_FDPIC:
28209 case BFD_RELOC_ARM_TLS_IE32_FDPIC:
28210 case BFD_RELOC_ARM_TLS_LDM32_FDPIC:
28213 S_SET_THREAD_LOCAL (fixP->fx_addsy);
28217 as_bad_where (fixP->fx_file, fixP->fx_line,
28218 _("Relocation supported only in FDPIC mode"));
28222 case BFD_RELOC_ARM_GOT32:
28223 case BFD_RELOC_ARM_GOTOFF:
28226 case BFD_RELOC_ARM_GOT_PREL:
28227 if (fixP->fx_done || !seg->use_rela_p)
28228 md_number_to_chars (buf, value, 4);
28231 case BFD_RELOC_ARM_TARGET2:
28232 /* TARGET2 is not partial-inplace, so we need to write the
28233 addend here for REL targets, because it won't be written out
28234 during reloc processing later. */
28235 if (fixP->fx_done || !seg->use_rela_p)
28236 md_number_to_chars (buf, fixP->fx_offset, 4);
28239 /* Relocations for FDPIC. */
28240 case BFD_RELOC_ARM_GOTFUNCDESC:
28241 case BFD_RELOC_ARM_GOTOFFFUNCDESC:
28242 case BFD_RELOC_ARM_FUNCDESC:
28245 if (fixP->fx_done || !seg->use_rela_p)
28246 md_number_to_chars (buf, 0, 4);
28250 as_bad_where (fixP->fx_file, fixP->fx_line,
28251 _("Relocation supported only in FDPIC mode"));
28256 case BFD_RELOC_RVA:
28258 case BFD_RELOC_ARM_TARGET1:
28259 case BFD_RELOC_ARM_ROSEGREL32:
28260 case BFD_RELOC_ARM_SBREL32:
28261 case BFD_RELOC_32_PCREL:
28263 case BFD_RELOC_32_SECREL:
28265 if (fixP->fx_done || !seg->use_rela_p)
28267 /* For WinCE we only do this for pcrel fixups. */
28268 if (fixP->fx_done || fixP->fx_pcrel)
28270 md_number_to_chars (buf, value, 4);
28274 case BFD_RELOC_ARM_PREL31:
28275 if (fixP->fx_done || !seg->use_rela_p)
28277 newval = md_chars_to_number (buf, 4) & 0x80000000;
28278 if ((value ^ (value >> 1)) & 0x40000000)
28280 as_bad_where (fixP->fx_file, fixP->fx_line,
28281 _("rel31 relocation overflow"));
28283 newval |= value & 0x7fffffff;
28284 md_number_to_chars (buf, newval, 4);
28289 case BFD_RELOC_ARM_CP_OFF_IMM:
28290 case BFD_RELOC_ARM_T32_CP_OFF_IMM:
28291 case BFD_RELOC_ARM_T32_VLDR_VSTR_OFF_IMM:
28292 if (fixP->fx_r_type == BFD_RELOC_ARM_CP_OFF_IMM)
28293 newval = md_chars_to_number (buf, INSN_SIZE);
28295 newval = get_thumb32_insn (buf);
28296 if ((newval & 0x0f200f00) == 0x0d000900)
28298 /* This is a fp16 vstr/vldr. The immediate offset in the mnemonic
28299 has permitted values that are multiples of 2, in the range 0
28301 if (value < -510 || value > 510 || (value & 1))
28302 as_bad_where (fixP->fx_file, fixP->fx_line,
28303 _("co-processor offset out of range"));
28305 else if ((newval & 0xfe001f80) == 0xec000f80)
28307 if (value < -511 || value > 512 || (value & 3))
28308 as_bad_where (fixP->fx_file, fixP->fx_line,
28309 _("co-processor offset out of range"));
28311 else if (value < -1023 || value > 1023 || (value & 3))
28312 as_bad_where (fixP->fx_file, fixP->fx_line,
28313 _("co-processor offset out of range"));
28318 if (fixP->fx_r_type == BFD_RELOC_ARM_CP_OFF_IMM
28319 || fixP->fx_r_type == BFD_RELOC_ARM_CP_OFF_IMM_S2)
28320 newval = md_chars_to_number (buf, INSN_SIZE);
28322 newval = get_thumb32_insn (buf);
28325 if (fixP->fx_r_type == BFD_RELOC_ARM_T32_VLDR_VSTR_OFF_IMM)
28326 newval &= 0xffffff80;
28328 newval &= 0xffffff00;
28332 if (fixP->fx_r_type == BFD_RELOC_ARM_T32_VLDR_VSTR_OFF_IMM)
28333 newval &= 0xff7fff80;
28335 newval &= 0xff7fff00;
28336 if ((newval & 0x0f200f00) == 0x0d000900)
28338 /* This is a fp16 vstr/vldr.
28340 It requires the immediate offset in the instruction is shifted
28341 left by 1 to be a half-word offset.
28343 Here, left shift by 1 first, and later right shift by 2
28344 should get the right offset. */
28347 newval |= (value >> 2) | (sign ? INDEX_UP : 0);
28349 if (fixP->fx_r_type == BFD_RELOC_ARM_CP_OFF_IMM
28350 || fixP->fx_r_type == BFD_RELOC_ARM_CP_OFF_IMM_S2)
28351 md_number_to_chars (buf, newval, INSN_SIZE);
28353 put_thumb32_insn (buf, newval);
28356 case BFD_RELOC_ARM_CP_OFF_IMM_S2:
28357 case BFD_RELOC_ARM_T32_CP_OFF_IMM_S2:
28358 if (value < -255 || value > 255)
28359 as_bad_where (fixP->fx_file, fixP->fx_line,
28360 _("co-processor offset out of range"));
28362 goto cp_off_common;
28364 case BFD_RELOC_ARM_THUMB_OFFSET:
28365 newval = md_chars_to_number (buf, THUMB_SIZE);
28366 /* Exactly what ranges, and where the offset is inserted depends
28367 on the type of instruction, we can establish this from the
28369 switch (newval >> 12)
28371 case 4: /* PC load. */
28372 /* Thumb PC loads are somewhat odd, bit 1 of the PC is
28373 forced to zero for these loads; md_pcrel_from has already
28374 compensated for this. */
28376 as_bad_where (fixP->fx_file, fixP->fx_line,
28377 _("invalid offset, target not word aligned (0x%08lX)"),
28378 (((unsigned long) fixP->fx_frag->fr_address
28379 + (unsigned long) fixP->fx_where) & ~3)
28380 + (unsigned long) value);
28382 if (value & ~0x3fc)
28383 as_bad_where (fixP->fx_file, fixP->fx_line,
28384 _("invalid offset, value too big (0x%08lX)"),
28387 newval |= value >> 2;
28390 case 9: /* SP load/store. */
28391 if (value & ~0x3fc)
28392 as_bad_where (fixP->fx_file, fixP->fx_line,
28393 _("invalid offset, value too big (0x%08lX)"),
28395 newval |= value >> 2;
28398 case 6: /* Word load/store. */
28400 as_bad_where (fixP->fx_file, fixP->fx_line,
28401 _("invalid offset, value too big (0x%08lX)"),
28403 newval |= value << 4; /* 6 - 2. */
28406 case 7: /* Byte load/store. */
28408 as_bad_where (fixP->fx_file, fixP->fx_line,
28409 _("invalid offset, value too big (0x%08lX)"),
28411 newval |= value << 6;
28414 case 8: /* Halfword load/store. */
28416 as_bad_where (fixP->fx_file, fixP->fx_line,
28417 _("invalid offset, value too big (0x%08lX)"),
28419 newval |= value << 5; /* 6 - 1. */
28423 as_bad_where (fixP->fx_file, fixP->fx_line,
28424 "Unable to process relocation for thumb opcode: %lx",
28425 (unsigned long) newval);
28428 md_number_to_chars (buf, newval, THUMB_SIZE);
28431 case BFD_RELOC_ARM_THUMB_ADD:
28432 /* This is a complicated relocation, since we use it for all of
28433 the following immediate relocations:
28437 9bit ADD/SUB SP word-aligned
28438 10bit ADD PC/SP word-aligned
28440 The type of instruction being processed is encoded in the
28447 newval = md_chars_to_number (buf, THUMB_SIZE);
28449 int rd = (newval >> 4) & 0xf;
28450 int rs = newval & 0xf;
28451 int subtract = !!(newval & 0x8000);
28453 /* Check for HI regs, only very restricted cases allowed:
28454 Adjusting SP, and using PC or SP to get an address. */
28455 if ((rd > 7 && (rd != REG_SP || rs != REG_SP))
28456 || (rs > 7 && rs != REG_SP && rs != REG_PC))
28457 as_bad_where (fixP->fx_file, fixP->fx_line,
28458 _("invalid Hi register with immediate"));
28460 /* If value is negative, choose the opposite instruction. */
28464 subtract = !subtract;
28466 as_bad_where (fixP->fx_file, fixP->fx_line,
28467 _("immediate value out of range"));
28472 if (value & ~0x1fc)
28473 as_bad_where (fixP->fx_file, fixP->fx_line,
28474 _("invalid immediate for stack address calculation"));
28475 newval = subtract ? T_OPCODE_SUB_ST : T_OPCODE_ADD_ST;
28476 newval |= value >> 2;
28478 else if (rs == REG_PC || rs == REG_SP)
28480 /* PR gas/18541. If the addition is for a defined symbol
28481 within range of an ADR instruction then accept it. */
28484 && fixP->fx_addsy != NULL)
28488 if (! S_IS_DEFINED (fixP->fx_addsy)
28489 || S_GET_SEGMENT (fixP->fx_addsy) != seg
28490 || S_IS_WEAK (fixP->fx_addsy))
28492 as_bad_where (fixP->fx_file, fixP->fx_line,
28493 _("address calculation needs a strongly defined nearby symbol"));
28497 offsetT v = fixP->fx_where + fixP->fx_frag->fr_address;
28499 /* Round up to the next 4-byte boundary. */
28504 v = S_GET_VALUE (fixP->fx_addsy) - v;
28508 as_bad_where (fixP->fx_file, fixP->fx_line,
28509 _("symbol too far away"));
28519 if (subtract || value & ~0x3fc)
28520 as_bad_where (fixP->fx_file, fixP->fx_line,
28521 _("invalid immediate for address calculation (value = 0x%08lX)"),
28522 (unsigned long) (subtract ? - value : value));
28523 newval = (rs == REG_PC ? T_OPCODE_ADD_PC : T_OPCODE_ADD_SP);
28525 newval |= value >> 2;
28530 as_bad_where (fixP->fx_file, fixP->fx_line,
28531 _("immediate value out of range"));
28532 newval = subtract ? T_OPCODE_SUB_I8 : T_OPCODE_ADD_I8;
28533 newval |= (rd << 8) | value;
28538 as_bad_where (fixP->fx_file, fixP->fx_line,
28539 _("immediate value out of range"));
28540 newval = subtract ? T_OPCODE_SUB_I3 : T_OPCODE_ADD_I3;
28541 newval |= rd | (rs << 3) | (value << 6);
28544 md_number_to_chars (buf, newval, THUMB_SIZE);
28547 case BFD_RELOC_ARM_THUMB_IMM:
28548 newval = md_chars_to_number (buf, THUMB_SIZE);
28549 if (value < 0 || value > 255)
28550 as_bad_where (fixP->fx_file, fixP->fx_line,
28551 _("invalid immediate: %ld is out of range"),
28554 md_number_to_chars (buf, newval, THUMB_SIZE);
28557 case BFD_RELOC_ARM_THUMB_SHIFT:
28558 /* 5bit shift value (0..32). LSL cannot take 32. */
28559 newval = md_chars_to_number (buf, THUMB_SIZE) & 0xf83f;
28560 temp = newval & 0xf800;
28561 if (value < 0 || value > 32 || (value == 32 && temp == T_OPCODE_LSL_I))
28562 as_bad_where (fixP->fx_file, fixP->fx_line,
28563 _("invalid shift value: %ld"), (long) value);
28564 /* Shifts of zero must be encoded as LSL. */
28566 newval = (newval & 0x003f) | T_OPCODE_LSL_I;
28567 /* Shifts of 32 are encoded as zero. */
28568 else if (value == 32)
28570 newval |= value << 6;
28571 md_number_to_chars (buf, newval, THUMB_SIZE);
28574 case BFD_RELOC_VTABLE_INHERIT:
28575 case BFD_RELOC_VTABLE_ENTRY:
28579 case BFD_RELOC_ARM_MOVW:
28580 case BFD_RELOC_ARM_MOVT:
28581 case BFD_RELOC_ARM_THUMB_MOVW:
28582 case BFD_RELOC_ARM_THUMB_MOVT:
28583 if (fixP->fx_done || !seg->use_rela_p)
28585 /* REL format relocations are limited to a 16-bit addend. */
28586 if (!fixP->fx_done)
28588 if (value < -0x8000 || value > 0x7fff)
28589 as_bad_where (fixP->fx_file, fixP->fx_line,
28590 _("offset out of range"));
28592 else if (fixP->fx_r_type == BFD_RELOC_ARM_MOVT
28593 || fixP->fx_r_type == BFD_RELOC_ARM_THUMB_MOVT)
28598 if (fixP->fx_r_type == BFD_RELOC_ARM_THUMB_MOVW
28599 || fixP->fx_r_type == BFD_RELOC_ARM_THUMB_MOVT)
28601 newval = get_thumb32_insn (buf);
28602 newval &= 0xfbf08f00;
28603 newval |= (value & 0xf000) << 4;
28604 newval |= (value & 0x0800) << 15;
28605 newval |= (value & 0x0700) << 4;
28606 newval |= (value & 0x00ff);
28607 put_thumb32_insn (buf, newval);
28611 newval = md_chars_to_number (buf, 4);
28612 newval &= 0xfff0f000;
28613 newval |= value & 0x0fff;
28614 newval |= (value & 0xf000) << 4;
28615 md_number_to_chars (buf, newval, 4);
28620 case BFD_RELOC_ARM_THUMB_ALU_ABS_G0_NC:
28621 case BFD_RELOC_ARM_THUMB_ALU_ABS_G1_NC:
28622 case BFD_RELOC_ARM_THUMB_ALU_ABS_G2_NC:
28623 case BFD_RELOC_ARM_THUMB_ALU_ABS_G3_NC:
28624 gas_assert (!fixP->fx_done);
28627 bfd_boolean is_mov;
28628 bfd_vma encoded_addend = value;
28630 /* Check that addend can be encoded in instruction. */
28631 if (!seg->use_rela_p && (value < 0 || value > 255))
28632 as_bad_where (fixP->fx_file, fixP->fx_line,
28633 _("the offset 0x%08lX is not representable"),
28634 (unsigned long) encoded_addend);
28636 /* Extract the instruction. */
28637 insn = md_chars_to_number (buf, THUMB_SIZE);
28638 is_mov = (insn & 0xf800) == 0x2000;
28643 if (!seg->use_rela_p)
28644 insn |= encoded_addend;
28650 /* Extract the instruction. */
28651 /* Encoding is the following
28656 /* The following conditions must be true :
28661 rd = (insn >> 4) & 0xf;
28663 if ((insn & 0x8000) || (rd != rs) || rd > 7)
28664 as_bad_where (fixP->fx_file, fixP->fx_line,
28665 _("Unable to process relocation for thumb opcode: %lx"),
28666 (unsigned long) insn);
28668 /* Encode as ADD immediate8 thumb 1 code. */
28669 insn = 0x3000 | (rd << 8);
28671 /* Place the encoded addend into the first 8 bits of the
28673 if (!seg->use_rela_p)
28674 insn |= encoded_addend;
28677 /* Update the instruction. */
28678 md_number_to_chars (buf, insn, THUMB_SIZE);
28682 case BFD_RELOC_ARM_ALU_PC_G0_NC:
28683 case BFD_RELOC_ARM_ALU_PC_G0:
28684 case BFD_RELOC_ARM_ALU_PC_G1_NC:
28685 case BFD_RELOC_ARM_ALU_PC_G1:
28686 case BFD_RELOC_ARM_ALU_PC_G2:
28687 case BFD_RELOC_ARM_ALU_SB_G0_NC:
28688 case BFD_RELOC_ARM_ALU_SB_G0:
28689 case BFD_RELOC_ARM_ALU_SB_G1_NC:
28690 case BFD_RELOC_ARM_ALU_SB_G1:
28691 case BFD_RELOC_ARM_ALU_SB_G2:
28692 gas_assert (!fixP->fx_done);
28693 if (!seg->use_rela_p)
28696 bfd_vma encoded_addend;
28697 bfd_vma addend_abs = llabs (value);
28699 /* Check that the absolute value of the addend can be
28700 expressed as an 8-bit constant plus a rotation. */
28701 encoded_addend = encode_arm_immediate (addend_abs);
28702 if (encoded_addend == (unsigned int) FAIL)
28703 as_bad_where (fixP->fx_file, fixP->fx_line,
28704 _("the offset 0x%08lX is not representable"),
28705 (unsigned long) addend_abs);
28707 /* Extract the instruction. */
28708 insn = md_chars_to_number (buf, INSN_SIZE);
28710 /* If the addend is positive, use an ADD instruction.
28711 Otherwise use a SUB. Take care not to destroy the S bit. */
28712 insn &= 0xff1fffff;
28718 /* Place the encoded addend into the first 12 bits of the
28720 insn &= 0xfffff000;
28721 insn |= encoded_addend;
28723 /* Update the instruction. */
28724 md_number_to_chars (buf, insn, INSN_SIZE);
28728 case BFD_RELOC_ARM_LDR_PC_G0:
28729 case BFD_RELOC_ARM_LDR_PC_G1:
28730 case BFD_RELOC_ARM_LDR_PC_G2:
28731 case BFD_RELOC_ARM_LDR_SB_G0:
28732 case BFD_RELOC_ARM_LDR_SB_G1:
28733 case BFD_RELOC_ARM_LDR_SB_G2:
28734 gas_assert (!fixP->fx_done);
28735 if (!seg->use_rela_p)
28738 bfd_vma addend_abs = llabs (value);
28740 /* Check that the absolute value of the addend can be
28741 encoded in 12 bits. */
28742 if (addend_abs >= 0x1000)
28743 as_bad_where (fixP->fx_file, fixP->fx_line,
28744 _("bad offset 0x%08lX (only 12 bits available for the magnitude)"),
28745 (unsigned long) addend_abs);
28747 /* Extract the instruction. */
28748 insn = md_chars_to_number (buf, INSN_SIZE);
28750 /* If the addend is negative, clear bit 23 of the instruction.
28751 Otherwise set it. */
28753 insn &= ~(1 << 23);
28757 /* Place the absolute value of the addend into the first 12 bits
28758 of the instruction. */
28759 insn &= 0xfffff000;
28760 insn |= addend_abs;
28762 /* Update the instruction. */
28763 md_number_to_chars (buf, insn, INSN_SIZE);
28767 case BFD_RELOC_ARM_LDRS_PC_G0:
28768 case BFD_RELOC_ARM_LDRS_PC_G1:
28769 case BFD_RELOC_ARM_LDRS_PC_G2:
28770 case BFD_RELOC_ARM_LDRS_SB_G0:
28771 case BFD_RELOC_ARM_LDRS_SB_G1:
28772 case BFD_RELOC_ARM_LDRS_SB_G2:
28773 gas_assert (!fixP->fx_done);
28774 if (!seg->use_rela_p)
28777 bfd_vma addend_abs = llabs (value);
28779 /* Check that the absolute value of the addend can be
28780 encoded in 8 bits. */
28781 if (addend_abs >= 0x100)
28782 as_bad_where (fixP->fx_file, fixP->fx_line,
28783 _("bad offset 0x%08lX (only 8 bits available for the magnitude)"),
28784 (unsigned long) addend_abs);
28786 /* Extract the instruction. */
28787 insn = md_chars_to_number (buf, INSN_SIZE);
28789 /* If the addend is negative, clear bit 23 of the instruction.
28790 Otherwise set it. */
28792 insn &= ~(1 << 23);
28796 /* Place the first four bits of the absolute value of the addend
28797 into the first 4 bits of the instruction, and the remaining
28798 four into bits 8 .. 11. */
28799 insn &= 0xfffff0f0;
28800 insn |= (addend_abs & 0xf) | ((addend_abs & 0xf0) << 4);
28802 /* Update the instruction. */
28803 md_number_to_chars (buf, insn, INSN_SIZE);
28807 case BFD_RELOC_ARM_LDC_PC_G0:
28808 case BFD_RELOC_ARM_LDC_PC_G1:
28809 case BFD_RELOC_ARM_LDC_PC_G2:
28810 case BFD_RELOC_ARM_LDC_SB_G0:
28811 case BFD_RELOC_ARM_LDC_SB_G1:
28812 case BFD_RELOC_ARM_LDC_SB_G2:
28813 gas_assert (!fixP->fx_done);
28814 if (!seg->use_rela_p)
28817 bfd_vma addend_abs = llabs (value);
28819 /* Check that the absolute value of the addend is a multiple of
28820 four and, when divided by four, fits in 8 bits. */
28821 if (addend_abs & 0x3)
28822 as_bad_where (fixP->fx_file, fixP->fx_line,
28823 _("bad offset 0x%08lX (must be word-aligned)"),
28824 (unsigned long) addend_abs);
28826 if ((addend_abs >> 2) > 0xff)
28827 as_bad_where (fixP->fx_file, fixP->fx_line,
28828 _("bad offset 0x%08lX (must be an 8-bit number of words)"),
28829 (unsigned long) addend_abs);
28831 /* Extract the instruction. */
28832 insn = md_chars_to_number (buf, INSN_SIZE);
28834 /* If the addend is negative, clear bit 23 of the instruction.
28835 Otherwise set it. */
28837 insn &= ~(1 << 23);
28841 /* Place the addend (divided by four) into the first eight
28842 bits of the instruction. */
28843 insn &= 0xfffffff0;
28844 insn |= addend_abs >> 2;
28846 /* Update the instruction. */
28847 md_number_to_chars (buf, insn, INSN_SIZE);
28851 case BFD_RELOC_THUMB_PCREL_BRANCH5:
28853 && (S_GET_SEGMENT (fixP->fx_addsy) == seg)
28854 && !S_FORCE_RELOC (fixP->fx_addsy, TRUE)
28855 && ARM_IS_FUNC (fixP->fx_addsy)
28856 && ARM_CPU_HAS_FEATURE (selected_cpu, arm_ext_v8_1m_main))
28858 /* Force a relocation for a branch 5 bits wide. */
28861 if (v8_1_branch_value_check (value, 5, FALSE) == FAIL)
28862 as_bad_where (fixP->fx_file, fixP->fx_line,
28865 if (fixP->fx_done || !seg->use_rela_p)
28867 addressT boff = value >> 1;
28869 newval = md_chars_to_number (buf, THUMB_SIZE);
28870 newval |= (boff << 7);
28871 md_number_to_chars (buf, newval, THUMB_SIZE);
28875 case BFD_RELOC_THUMB_PCREL_BFCSEL:
28877 && (S_GET_SEGMENT (fixP->fx_addsy) == seg)
28878 && !S_FORCE_RELOC (fixP->fx_addsy, TRUE)
28879 && ARM_IS_FUNC (fixP->fx_addsy)
28880 && ARM_CPU_HAS_FEATURE (selected_cpu, arm_ext_v8_1m_main))
28884 if ((value & ~0x7f) && ((value & ~0x3f) != ~0x3f))
28885 as_bad_where (fixP->fx_file, fixP->fx_line,
28886 _("branch out of range"));
28888 if (fixP->fx_done || !seg->use_rela_p)
28890 newval = md_chars_to_number (buf, THUMB_SIZE);
28892 addressT boff = ((newval & 0x0780) >> 7) << 1;
28893 addressT diff = value - boff;
28897 newval |= 1 << 1; /* T bit. */
28899 else if (diff != 2)
28901 as_bad_where (fixP->fx_file, fixP->fx_line,
28902 _("out of range label-relative fixup value"));
28904 md_number_to_chars (buf, newval, THUMB_SIZE);
28908 case BFD_RELOC_ARM_THUMB_BF17:
28910 && (S_GET_SEGMENT (fixP->fx_addsy) == seg)
28911 && !S_FORCE_RELOC (fixP->fx_addsy, TRUE)
28912 && ARM_IS_FUNC (fixP->fx_addsy)
28913 && ARM_CPU_HAS_FEATURE (selected_cpu, arm_ext_v8_1m_main))
28915 /* Force a relocation for a branch 17 bits wide. */
28919 if (v8_1_branch_value_check (value, 17, TRUE) == FAIL)
28920 as_bad_where (fixP->fx_file, fixP->fx_line,
28923 if (fixP->fx_done || !seg->use_rela_p)
28926 addressT immA, immB, immC;
28928 immA = (value & 0x0001f000) >> 12;
28929 immB = (value & 0x00000ffc) >> 2;
28930 immC = (value & 0x00000002) >> 1;
28932 newval = md_chars_to_number (buf, THUMB_SIZE);
28933 newval2 = md_chars_to_number (buf + THUMB_SIZE, THUMB_SIZE);
28935 newval2 |= (immC << 11) | (immB << 1);
28936 md_number_to_chars (buf, newval, THUMB_SIZE);
28937 md_number_to_chars (buf + THUMB_SIZE, newval2, THUMB_SIZE);
28941 case BFD_RELOC_ARM_THUMB_BF19:
28943 && (S_GET_SEGMENT (fixP->fx_addsy) == seg)
28944 && !S_FORCE_RELOC (fixP->fx_addsy, TRUE)
28945 && ARM_IS_FUNC (fixP->fx_addsy)
28946 && ARM_CPU_HAS_FEATURE (selected_cpu, arm_ext_v8_1m_main))
28948 /* Force a relocation for a branch 19 bits wide. */
28952 if (v8_1_branch_value_check (value, 19, TRUE) == FAIL)
28953 as_bad_where (fixP->fx_file, fixP->fx_line,
28956 if (fixP->fx_done || !seg->use_rela_p)
28959 addressT immA, immB, immC;
28961 immA = (value & 0x0007f000) >> 12;
28962 immB = (value & 0x00000ffc) >> 2;
28963 immC = (value & 0x00000002) >> 1;
28965 newval = md_chars_to_number (buf, THUMB_SIZE);
28966 newval2 = md_chars_to_number (buf + THUMB_SIZE, THUMB_SIZE);
28968 newval2 |= (immC << 11) | (immB << 1);
28969 md_number_to_chars (buf, newval, THUMB_SIZE);
28970 md_number_to_chars (buf + THUMB_SIZE, newval2, THUMB_SIZE);
28974 case BFD_RELOC_ARM_THUMB_BF13:
28976 && (S_GET_SEGMENT (fixP->fx_addsy) == seg)
28977 && !S_FORCE_RELOC (fixP->fx_addsy, TRUE)
28978 && ARM_IS_FUNC (fixP->fx_addsy)
28979 && ARM_CPU_HAS_FEATURE (selected_cpu, arm_ext_v8_1m_main))
28981 /* Force a relocation for a branch 13 bits wide. */
28985 if (v8_1_branch_value_check (value, 13, TRUE) == FAIL)
28986 as_bad_where (fixP->fx_file, fixP->fx_line,
28989 if (fixP->fx_done || !seg->use_rela_p)
28992 addressT immA, immB, immC;
28994 immA = (value & 0x00001000) >> 12;
28995 immB = (value & 0x00000ffc) >> 2;
28996 immC = (value & 0x00000002) >> 1;
28998 newval = md_chars_to_number (buf, THUMB_SIZE);
28999 newval2 = md_chars_to_number (buf + THUMB_SIZE, THUMB_SIZE);
29001 newval2 |= (immC << 11) | (immB << 1);
29002 md_number_to_chars (buf, newval, THUMB_SIZE);
29003 md_number_to_chars (buf + THUMB_SIZE, newval2, THUMB_SIZE);
29007 case BFD_RELOC_ARM_THUMB_LOOP12:
29009 && (S_GET_SEGMENT (fixP->fx_addsy) == seg)
29010 && !S_FORCE_RELOC (fixP->fx_addsy, TRUE)
29011 && ARM_IS_FUNC (fixP->fx_addsy)
29012 && ARM_CPU_HAS_FEATURE (selected_cpu, arm_ext_v8_1m_main))
29014 /* Force a relocation for a branch 12 bits wide. */
29018 bfd_vma insn = get_thumb32_insn (buf);
29019 /* le lr, <label>, le <label> or letp lr, <label> */
29020 if (((insn & 0xffffffff) == 0xf00fc001)
29021 || ((insn & 0xffffffff) == 0xf02fc001)
29022 || ((insn & 0xffffffff) == 0xf01fc001))
29025 if (v8_1_branch_value_check (value, 12, FALSE) == FAIL)
29026 as_bad_where (fixP->fx_file, fixP->fx_line,
29028 if (fixP->fx_done || !seg->use_rela_p)
29030 addressT imml, immh;
29032 immh = (value & 0x00000ffc) >> 2;
29033 imml = (value & 0x00000002) >> 1;
29035 newval = md_chars_to_number (buf + THUMB_SIZE, THUMB_SIZE);
29036 newval |= (imml << 11) | (immh << 1);
29037 md_number_to_chars (buf + THUMB_SIZE, newval, THUMB_SIZE);
29041 case BFD_RELOC_ARM_V4BX:
29042 /* This will need to go in the object file. */
29046 case BFD_RELOC_UNUSED:
29048 as_bad_where (fixP->fx_file, fixP->fx_line,
29049 _("bad relocation fixup type (%d)"), fixP->fx_r_type);
29053 /* Translate internal representation of relocation info to BFD target
29057 tc_gen_reloc (asection *section, fixS *fixp)
29060 bfd_reloc_code_real_type code;
29062 reloc = XNEW (arelent);
29064 reloc->sym_ptr_ptr = XNEW (asymbol *);
29065 *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
29066 reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
29068 if (fixp->fx_pcrel)
29070 if (section->use_rela_p)
29071 fixp->fx_offset -= md_pcrel_from_section (fixp, section);
29073 fixp->fx_offset = reloc->address;
29075 reloc->addend = fixp->fx_offset;
29077 switch (fixp->fx_r_type)
29080 if (fixp->fx_pcrel)
29082 code = BFD_RELOC_8_PCREL;
29085 /* Fall through. */
29088 if (fixp->fx_pcrel)
29090 code = BFD_RELOC_16_PCREL;
29093 /* Fall through. */
29096 if (fixp->fx_pcrel)
29098 code = BFD_RELOC_32_PCREL;
29101 /* Fall through. */
29103 case BFD_RELOC_ARM_MOVW:
29104 if (fixp->fx_pcrel)
29106 code = BFD_RELOC_ARM_MOVW_PCREL;
29109 /* Fall through. */
29111 case BFD_RELOC_ARM_MOVT:
29112 if (fixp->fx_pcrel)
29114 code = BFD_RELOC_ARM_MOVT_PCREL;
29117 /* Fall through. */
29119 case BFD_RELOC_ARM_THUMB_MOVW:
29120 if (fixp->fx_pcrel)
29122 code = BFD_RELOC_ARM_THUMB_MOVW_PCREL;
29125 /* Fall through. */
29127 case BFD_RELOC_ARM_THUMB_MOVT:
29128 if (fixp->fx_pcrel)
29130 code = BFD_RELOC_ARM_THUMB_MOVT_PCREL;
29133 /* Fall through. */
29135 case BFD_RELOC_NONE:
29136 case BFD_RELOC_ARM_PCREL_BRANCH:
29137 case BFD_RELOC_ARM_PCREL_BLX:
29138 case BFD_RELOC_RVA:
29139 case BFD_RELOC_THUMB_PCREL_BRANCH7:
29140 case BFD_RELOC_THUMB_PCREL_BRANCH9:
29141 case BFD_RELOC_THUMB_PCREL_BRANCH12:
29142 case BFD_RELOC_THUMB_PCREL_BRANCH20:
29143 case BFD_RELOC_THUMB_PCREL_BRANCH23:
29144 case BFD_RELOC_THUMB_PCREL_BRANCH25:
29145 case BFD_RELOC_VTABLE_ENTRY:
29146 case BFD_RELOC_VTABLE_INHERIT:
29148 case BFD_RELOC_32_SECREL:
29150 code = fixp->fx_r_type;
29153 case BFD_RELOC_THUMB_PCREL_BLX:
29155 if (EF_ARM_EABI_VERSION (meabi_flags) >= EF_ARM_EABI_VER4)
29156 code = BFD_RELOC_THUMB_PCREL_BRANCH23;
29159 code = BFD_RELOC_THUMB_PCREL_BLX;
29162 case BFD_RELOC_ARM_LITERAL:
29163 case BFD_RELOC_ARM_HWLITERAL:
29164 /* If this is called then the a literal has
29165 been referenced across a section boundary. */
29166 as_bad_where (fixp->fx_file, fixp->fx_line,
29167 _("literal referenced across section boundary"));
29171 case BFD_RELOC_ARM_TLS_CALL:
29172 case BFD_RELOC_ARM_THM_TLS_CALL:
29173 case BFD_RELOC_ARM_TLS_DESCSEQ:
29174 case BFD_RELOC_ARM_THM_TLS_DESCSEQ:
29175 case BFD_RELOC_ARM_GOT32:
29176 case BFD_RELOC_ARM_GOTOFF:
29177 case BFD_RELOC_ARM_GOT_PREL:
29178 case BFD_RELOC_ARM_PLT32:
29179 case BFD_RELOC_ARM_TARGET1:
29180 case BFD_RELOC_ARM_ROSEGREL32:
29181 case BFD_RELOC_ARM_SBREL32:
29182 case BFD_RELOC_ARM_PREL31:
29183 case BFD_RELOC_ARM_TARGET2:
29184 case BFD_RELOC_ARM_TLS_LDO32:
29185 case BFD_RELOC_ARM_PCREL_CALL:
29186 case BFD_RELOC_ARM_PCREL_JUMP:
29187 case BFD_RELOC_ARM_ALU_PC_G0_NC:
29188 case BFD_RELOC_ARM_ALU_PC_G0:
29189 case BFD_RELOC_ARM_ALU_PC_G1_NC:
29190 case BFD_RELOC_ARM_ALU_PC_G1:
29191 case BFD_RELOC_ARM_ALU_PC_G2:
29192 case BFD_RELOC_ARM_LDR_PC_G0:
29193 case BFD_RELOC_ARM_LDR_PC_G1:
29194 case BFD_RELOC_ARM_LDR_PC_G2:
29195 case BFD_RELOC_ARM_LDRS_PC_G0:
29196 case BFD_RELOC_ARM_LDRS_PC_G1:
29197 case BFD_RELOC_ARM_LDRS_PC_G2:
29198 case BFD_RELOC_ARM_LDC_PC_G0:
29199 case BFD_RELOC_ARM_LDC_PC_G1:
29200 case BFD_RELOC_ARM_LDC_PC_G2:
29201 case BFD_RELOC_ARM_ALU_SB_G0_NC:
29202 case BFD_RELOC_ARM_ALU_SB_G0:
29203 case BFD_RELOC_ARM_ALU_SB_G1_NC:
29204 case BFD_RELOC_ARM_ALU_SB_G1:
29205 case BFD_RELOC_ARM_ALU_SB_G2:
29206 case BFD_RELOC_ARM_LDR_SB_G0:
29207 case BFD_RELOC_ARM_LDR_SB_G1:
29208 case BFD_RELOC_ARM_LDR_SB_G2:
29209 case BFD_RELOC_ARM_LDRS_SB_G0:
29210 case BFD_RELOC_ARM_LDRS_SB_G1:
29211 case BFD_RELOC_ARM_LDRS_SB_G2:
29212 case BFD_RELOC_ARM_LDC_SB_G0:
29213 case BFD_RELOC_ARM_LDC_SB_G1:
29214 case BFD_RELOC_ARM_LDC_SB_G2:
29215 case BFD_RELOC_ARM_V4BX:
29216 case BFD_RELOC_ARM_THUMB_ALU_ABS_G0_NC:
29217 case BFD_RELOC_ARM_THUMB_ALU_ABS_G1_NC:
29218 case BFD_RELOC_ARM_THUMB_ALU_ABS_G2_NC:
29219 case BFD_RELOC_ARM_THUMB_ALU_ABS_G3_NC:
29220 case BFD_RELOC_ARM_GOTFUNCDESC:
29221 case BFD_RELOC_ARM_GOTOFFFUNCDESC:
29222 case BFD_RELOC_ARM_FUNCDESC:
29223 case BFD_RELOC_ARM_THUMB_BF17:
29224 case BFD_RELOC_ARM_THUMB_BF19:
29225 case BFD_RELOC_ARM_THUMB_BF13:
29226 code = fixp->fx_r_type;
29229 case BFD_RELOC_ARM_TLS_GOTDESC:
29230 case BFD_RELOC_ARM_TLS_GD32:
29231 case BFD_RELOC_ARM_TLS_GD32_FDPIC:
29232 case BFD_RELOC_ARM_TLS_LE32:
29233 case BFD_RELOC_ARM_TLS_IE32:
29234 case BFD_RELOC_ARM_TLS_IE32_FDPIC:
29235 case BFD_RELOC_ARM_TLS_LDM32:
29236 case BFD_RELOC_ARM_TLS_LDM32_FDPIC:
29237 /* BFD will include the symbol's address in the addend.
29238 But we don't want that, so subtract it out again here. */
29239 if (!S_IS_COMMON (fixp->fx_addsy))
29240 reloc->addend -= (*reloc->sym_ptr_ptr)->value;
29241 code = fixp->fx_r_type;
29245 case BFD_RELOC_ARM_IMMEDIATE:
29246 as_bad_where (fixp->fx_file, fixp->fx_line,
29247 _("internal relocation (type: IMMEDIATE) not fixed up"));
29250 case BFD_RELOC_ARM_ADRL_IMMEDIATE:
29251 as_bad_where (fixp->fx_file, fixp->fx_line,
29252 _("ADRL used for a symbol not defined in the same file"));
29255 case BFD_RELOC_THUMB_PCREL_BRANCH5:
29256 case BFD_RELOC_THUMB_PCREL_BFCSEL:
29257 case BFD_RELOC_ARM_THUMB_LOOP12:
29258 as_bad_where (fixp->fx_file, fixp->fx_line,
29259 _("%s used for a symbol not defined in the same file"),
29260 bfd_get_reloc_code_name (fixp->fx_r_type));
29263 case BFD_RELOC_ARM_OFFSET_IMM:
29264 if (section->use_rela_p)
29266 code = fixp->fx_r_type;
29270 if (fixp->fx_addsy != NULL
29271 && !S_IS_DEFINED (fixp->fx_addsy)
29272 && S_IS_LOCAL (fixp->fx_addsy))
29274 as_bad_where (fixp->fx_file, fixp->fx_line,
29275 _("undefined local label `%s'"),
29276 S_GET_NAME (fixp->fx_addsy));
29280 as_bad_where (fixp->fx_file, fixp->fx_line,
29281 _("internal_relocation (type: OFFSET_IMM) not fixed up"));
29288 switch (fixp->fx_r_type)
29290 case BFD_RELOC_NONE: type = "NONE"; break;
29291 case BFD_RELOC_ARM_OFFSET_IMM8: type = "OFFSET_IMM8"; break;
29292 case BFD_RELOC_ARM_SHIFT_IMM: type = "SHIFT_IMM"; break;
29293 case BFD_RELOC_ARM_SMC: type = "SMC"; break;
29294 case BFD_RELOC_ARM_SWI: type = "SWI"; break;
29295 case BFD_RELOC_ARM_MULTI: type = "MULTI"; break;
29296 case BFD_RELOC_ARM_CP_OFF_IMM: type = "CP_OFF_IMM"; break;
29297 case BFD_RELOC_ARM_T32_OFFSET_IMM: type = "T32_OFFSET_IMM"; break;
29298 case BFD_RELOC_ARM_T32_CP_OFF_IMM: type = "T32_CP_OFF_IMM"; break;
29299 case BFD_RELOC_ARM_THUMB_ADD: type = "THUMB_ADD"; break;
29300 case BFD_RELOC_ARM_THUMB_SHIFT: type = "THUMB_SHIFT"; break;
29301 case BFD_RELOC_ARM_THUMB_IMM: type = "THUMB_IMM"; break;
29302 case BFD_RELOC_ARM_THUMB_OFFSET: type = "THUMB_OFFSET"; break;
29303 default: type = _("<unknown>"); break;
29305 as_bad_where (fixp->fx_file, fixp->fx_line,
29306 _("cannot represent %s relocation in this object file format"),
29313 if ((code == BFD_RELOC_32_PCREL || code == BFD_RELOC_32)
29315 && fixp->fx_addsy == GOT_symbol)
29317 code = BFD_RELOC_ARM_GOTPC;
29318 reloc->addend = fixp->fx_offset = reloc->address;
29322 reloc->howto = bfd_reloc_type_lookup (stdoutput, code);
29324 if (reloc->howto == NULL)
29326 as_bad_where (fixp->fx_file, fixp->fx_line,
29327 _("cannot represent %s relocation in this object file format"),
29328 bfd_get_reloc_code_name (code));
29332 /* HACK: Since arm ELF uses Rel instead of Rela, encode the
29333 vtable entry to be used in the relocation's section offset. */
29334 if (fixp->fx_r_type == BFD_RELOC_VTABLE_ENTRY)
29335 reloc->address = fixp->fx_offset;
29340 /* This fix_new is called by cons via TC_CONS_FIX_NEW. */
29343 cons_fix_new_arm (fragS * frag,
29347 bfd_reloc_code_real_type reloc)
29352 FIXME: @@ Should look at CPU word size. */
29356 reloc = BFD_RELOC_8;
29359 reloc = BFD_RELOC_16;
29363 reloc = BFD_RELOC_32;
29366 reloc = BFD_RELOC_64;
29371 if (exp->X_op == O_secrel)
29373 exp->X_op = O_symbol;
29374 reloc = BFD_RELOC_32_SECREL;
29378 fix_new_exp (frag, where, size, exp, pcrel, reloc);
29381 #if defined (OBJ_COFF)
29383 arm_validate_fix (fixS * fixP)
29385 /* If the destination of the branch is a defined symbol which does not have
29386 the THUMB_FUNC attribute, then we must be calling a function which has
29387 the (interfacearm) attribute. We look for the Thumb entry point to that
29388 function and change the branch to refer to that function instead. */
29389 if (fixP->fx_r_type == BFD_RELOC_THUMB_PCREL_BRANCH23
29390 && fixP->fx_addsy != NULL
29391 && S_IS_DEFINED (fixP->fx_addsy)
29392 && ! THUMB_IS_FUNC (fixP->fx_addsy))
29394 fixP->fx_addsy = find_real_start (fixP->fx_addsy);
29401 arm_force_relocation (struct fix * fixp)
29403 #if defined (OBJ_COFF) && defined (TE_PE)
29404 if (fixp->fx_r_type == BFD_RELOC_RVA)
29408 /* In case we have a call or a branch to a function in ARM ISA mode from
29409 a thumb function or vice-versa force the relocation. These relocations
29410 are cleared off for some cores that might have blx and simple transformations
29414 switch (fixp->fx_r_type)
29416 case BFD_RELOC_ARM_PCREL_JUMP:
29417 case BFD_RELOC_ARM_PCREL_CALL:
29418 case BFD_RELOC_THUMB_PCREL_BLX:
29419 if (THUMB_IS_FUNC (fixp->fx_addsy))
29423 case BFD_RELOC_ARM_PCREL_BLX:
29424 case BFD_RELOC_THUMB_PCREL_BRANCH25:
29425 case BFD_RELOC_THUMB_PCREL_BRANCH20:
29426 case BFD_RELOC_THUMB_PCREL_BRANCH23:
29427 if (ARM_IS_FUNC (fixp->fx_addsy))
29436 /* Resolve these relocations even if the symbol is extern or weak.
29437 Technically this is probably wrong due to symbol preemption.
29438 In practice these relocations do not have enough range to be useful
29439 at dynamic link time, and some code (e.g. in the Linux kernel)
29440 expects these references to be resolved. */
29441 if (fixp->fx_r_type == BFD_RELOC_ARM_IMMEDIATE
29442 || fixp->fx_r_type == BFD_RELOC_ARM_OFFSET_IMM
29443 || fixp->fx_r_type == BFD_RELOC_ARM_OFFSET_IMM8
29444 || fixp->fx_r_type == BFD_RELOC_ARM_ADRL_IMMEDIATE
29445 || fixp->fx_r_type == BFD_RELOC_ARM_CP_OFF_IMM
29446 || fixp->fx_r_type == BFD_RELOC_ARM_CP_OFF_IMM_S2
29447 || fixp->fx_r_type == BFD_RELOC_ARM_THUMB_OFFSET
29448 || fixp->fx_r_type == BFD_RELOC_ARM_T32_ADD_IMM
29449 || fixp->fx_r_type == BFD_RELOC_ARM_T32_IMMEDIATE
29450 || fixp->fx_r_type == BFD_RELOC_ARM_T32_IMM12
29451 || fixp->fx_r_type == BFD_RELOC_ARM_T32_OFFSET_IMM
29452 || fixp->fx_r_type == BFD_RELOC_ARM_T32_ADD_PC12
29453 || fixp->fx_r_type == BFD_RELOC_ARM_T32_CP_OFF_IMM
29454 || fixp->fx_r_type == BFD_RELOC_ARM_T32_CP_OFF_IMM_S2)
29457 /* Always leave these relocations for the linker. */
29458 if ((fixp->fx_r_type >= BFD_RELOC_ARM_ALU_PC_G0_NC
29459 && fixp->fx_r_type <= BFD_RELOC_ARM_LDC_SB_G2)
29460 || fixp->fx_r_type == BFD_RELOC_ARM_LDR_PC_G0)
29463 /* Always generate relocations against function symbols. */
29464 if (fixp->fx_r_type == BFD_RELOC_32
29466 && (symbol_get_bfdsym (fixp->fx_addsy)->flags & BSF_FUNCTION))
29469 return generic_force_reloc (fixp);
29472 #if defined (OBJ_ELF) || defined (OBJ_COFF)
29473 /* Relocations against function names must be left unadjusted,
29474 so that the linker can use this information to generate interworking
29475 stubs. The MIPS version of this function
29476 also prevents relocations that are mips-16 specific, but I do not
29477 know why it does this.
29480 There is one other problem that ought to be addressed here, but
29481 which currently is not: Taking the address of a label (rather
29482 than a function) and then later jumping to that address. Such
29483 addresses also ought to have their bottom bit set (assuming that
29484 they reside in Thumb code), but at the moment they will not. */
29487 arm_fix_adjustable (fixS * fixP)
29489 if (fixP->fx_addsy == NULL)
29492 /* Preserve relocations against symbols with function type. */
29493 if (symbol_get_bfdsym (fixP->fx_addsy)->flags & BSF_FUNCTION)
29496 if (THUMB_IS_FUNC (fixP->fx_addsy)
29497 && fixP->fx_subsy == NULL)
29500 /* We need the symbol name for the VTABLE entries. */
29501 if ( fixP->fx_r_type == BFD_RELOC_VTABLE_INHERIT
29502 || fixP->fx_r_type == BFD_RELOC_VTABLE_ENTRY)
29505 /* Don't allow symbols to be discarded on GOT related relocs. */
29506 if (fixP->fx_r_type == BFD_RELOC_ARM_PLT32
29507 || fixP->fx_r_type == BFD_RELOC_ARM_GOT32
29508 || fixP->fx_r_type == BFD_RELOC_ARM_GOTOFF
29509 || fixP->fx_r_type == BFD_RELOC_ARM_TLS_GD32
29510 || fixP->fx_r_type == BFD_RELOC_ARM_TLS_GD32_FDPIC
29511 || fixP->fx_r_type == BFD_RELOC_ARM_TLS_LE32
29512 || fixP->fx_r_type == BFD_RELOC_ARM_TLS_IE32
29513 || fixP->fx_r_type == BFD_RELOC_ARM_TLS_IE32_FDPIC
29514 || fixP->fx_r_type == BFD_RELOC_ARM_TLS_LDM32
29515 || fixP->fx_r_type == BFD_RELOC_ARM_TLS_LDM32_FDPIC
29516 || fixP->fx_r_type == BFD_RELOC_ARM_TLS_LDO32
29517 || fixP->fx_r_type == BFD_RELOC_ARM_TLS_GOTDESC
29518 || fixP->fx_r_type == BFD_RELOC_ARM_TLS_CALL
29519 || fixP->fx_r_type == BFD_RELOC_ARM_THM_TLS_CALL
29520 || fixP->fx_r_type == BFD_RELOC_ARM_TLS_DESCSEQ
29521 || fixP->fx_r_type == BFD_RELOC_ARM_THM_TLS_DESCSEQ
29522 || fixP->fx_r_type == BFD_RELOC_ARM_TARGET2)
29525 /* Similarly for group relocations. */
29526 if ((fixP->fx_r_type >= BFD_RELOC_ARM_ALU_PC_G0_NC
29527 && fixP->fx_r_type <= BFD_RELOC_ARM_LDC_SB_G2)
29528 || fixP->fx_r_type == BFD_RELOC_ARM_LDR_PC_G0)
29531 /* MOVW/MOVT REL relocations have limited offsets, so keep the symbols. */
29532 if (fixP->fx_r_type == BFD_RELOC_ARM_MOVW
29533 || fixP->fx_r_type == BFD_RELOC_ARM_MOVT
29534 || fixP->fx_r_type == BFD_RELOC_ARM_MOVW_PCREL
29535 || fixP->fx_r_type == BFD_RELOC_ARM_MOVT_PCREL
29536 || fixP->fx_r_type == BFD_RELOC_ARM_THUMB_MOVW
29537 || fixP->fx_r_type == BFD_RELOC_ARM_THUMB_MOVT
29538 || fixP->fx_r_type == BFD_RELOC_ARM_THUMB_MOVW_PCREL
29539 || fixP->fx_r_type == BFD_RELOC_ARM_THUMB_MOVT_PCREL)
29542 /* BFD_RELOC_ARM_THUMB_ALU_ABS_Gx_NC relocations have VERY limited
29543 offsets, so keep these symbols. */
29544 if (fixP->fx_r_type >= BFD_RELOC_ARM_THUMB_ALU_ABS_G0_NC
29545 && fixP->fx_r_type <= BFD_RELOC_ARM_THUMB_ALU_ABS_G3_NC)
29550 #endif /* defined (OBJ_ELF) || defined (OBJ_COFF) */
29554 elf32_arm_target_format (void)
29557 return (target_big_endian
29558 ? "elf32-bigarm-symbian"
29559 : "elf32-littlearm-symbian");
29560 #elif defined (TE_VXWORKS)
29561 return (target_big_endian
29562 ? "elf32-bigarm-vxworks"
29563 : "elf32-littlearm-vxworks");
29564 #elif defined (TE_NACL)
29565 return (target_big_endian
29566 ? "elf32-bigarm-nacl"
29567 : "elf32-littlearm-nacl");
29571 if (target_big_endian)
29572 return "elf32-bigarm-fdpic";
29574 return "elf32-littlearm-fdpic";
29578 if (target_big_endian)
29579 return "elf32-bigarm";
29581 return "elf32-littlearm";
29587 armelf_frob_symbol (symbolS * symp,
29590 elf_frob_symbol (symp, puntp);
29594 /* MD interface: Finalization. */
29599 literal_pool * pool;
29601 /* Ensure that all the predication blocks are properly closed. */
29602 check_pred_blocks_finished ();
29604 for (pool = list_of_pools; pool; pool = pool->next)
29606 /* Put it at the end of the relevant section. */
29607 subseg_set (pool->section, pool->sub_section);
29609 arm_elf_change_section ();
29616 /* Remove any excess mapping symbols generated for alignment frags in
29617 SEC. We may have created a mapping symbol before a zero byte
29618 alignment; remove it if there's a mapping symbol after the
29621 check_mapping_symbols (bfd *abfd ATTRIBUTE_UNUSED, asection *sec,
29622 void *dummy ATTRIBUTE_UNUSED)
29624 segment_info_type *seginfo = seg_info (sec);
29627 if (seginfo == NULL || seginfo->frchainP == NULL)
29630 for (fragp = seginfo->frchainP->frch_root;
29632 fragp = fragp->fr_next)
29634 symbolS *sym = fragp->tc_frag_data.last_map;
29635 fragS *next = fragp->fr_next;
29637 /* Variable-sized frags have been converted to fixed size by
29638 this point. But if this was variable-sized to start with,
29639 there will be a fixed-size frag after it. So don't handle
29641 if (sym == NULL || next == NULL)
29644 if (S_GET_VALUE (sym) < next->fr_address)
29645 /* Not at the end of this frag. */
29647 know (S_GET_VALUE (sym) == next->fr_address);
29651 if (next->tc_frag_data.first_map != NULL)
29653 /* Next frag starts with a mapping symbol. Discard this
29655 symbol_remove (sym, &symbol_rootP, &symbol_lastP);
29659 if (next->fr_next == NULL)
29661 /* This mapping symbol is at the end of the section. Discard
29663 know (next->fr_fix == 0 && next->fr_var == 0);
29664 symbol_remove (sym, &symbol_rootP, &symbol_lastP);
29668 /* As long as we have empty frags without any mapping symbols,
29670 /* If the next frag is non-empty and does not start with a
29671 mapping symbol, then this mapping symbol is required. */
29672 if (next->fr_address != next->fr_next->fr_address)
29675 next = next->fr_next;
29677 while (next != NULL);
29682 /* Adjust the symbol table. This marks Thumb symbols as distinct from
29686 arm_adjust_symtab (void)
29691 for (sym = symbol_rootP; sym != NULL; sym = symbol_next (sym))
29693 if (ARM_IS_THUMB (sym))
29695 if (THUMB_IS_FUNC (sym))
29697 /* Mark the symbol as a Thumb function. */
29698 if ( S_GET_STORAGE_CLASS (sym) == C_STAT
29699 || S_GET_STORAGE_CLASS (sym) == C_LABEL) /* This can happen! */
29700 S_SET_STORAGE_CLASS (sym, C_THUMBSTATFUNC);
29702 else if (S_GET_STORAGE_CLASS (sym) == C_EXT)
29703 S_SET_STORAGE_CLASS (sym, C_THUMBEXTFUNC);
29705 as_bad (_("%s: unexpected function type: %d"),
29706 S_GET_NAME (sym), S_GET_STORAGE_CLASS (sym));
29708 else switch (S_GET_STORAGE_CLASS (sym))
29711 S_SET_STORAGE_CLASS (sym, C_THUMBEXT);
29714 S_SET_STORAGE_CLASS (sym, C_THUMBSTAT);
29717 S_SET_STORAGE_CLASS (sym, C_THUMBLABEL);
29725 if (ARM_IS_INTERWORK (sym))
29726 coffsymbol (symbol_get_bfdsym (sym))->native->u.syment.n_flags = 0xFF;
29733 for (sym = symbol_rootP; sym != NULL; sym = symbol_next (sym))
29735 if (ARM_IS_THUMB (sym))
29737 elf_symbol_type * elf_sym;
29739 elf_sym = elf_symbol (symbol_get_bfdsym (sym));
29740 bind = ELF_ST_BIND (elf_sym->internal_elf_sym.st_info);
29742 if (! bfd_is_arm_special_symbol_name (elf_sym->symbol.name,
29743 BFD_ARM_SPECIAL_SYM_TYPE_ANY))
29745 /* If it's a .thumb_func, declare it as so,
29746 otherwise tag label as .code 16. */
29747 if (THUMB_IS_FUNC (sym))
29748 ARM_SET_SYM_BRANCH_TYPE (elf_sym->internal_elf_sym.st_target_internal,
29749 ST_BRANCH_TO_THUMB);
29750 else if (EF_ARM_EABI_VERSION (meabi_flags) < EF_ARM_EABI_VER4)
29751 elf_sym->internal_elf_sym.st_info =
29752 ELF_ST_INFO (bind, STT_ARM_16BIT);
29757 /* Remove any overlapping mapping symbols generated by alignment frags. */
29758 bfd_map_over_sections (stdoutput, check_mapping_symbols, (char *) 0);
29759 /* Now do generic ELF adjustments. */
29760 elf_adjust_symtab ();
29764 /* MD interface: Initialization. */
29767 set_constant_flonums (void)
29771 for (i = 0; i < NUM_FLOAT_VALS; i++)
29772 if (atof_ieee ((char *) fp_const[i], 'x', fp_values[i]) == NULL)
29776 /* Auto-select Thumb mode if it's the only available instruction set for the
29777 given architecture. */
29780 autoselect_thumb_from_cpu_variant (void)
29782 if (!ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_v1))
29783 opcode_select (16);
29792 if ( (arm_ops_hsh = hash_new ()) == NULL
29793 || (arm_cond_hsh = hash_new ()) == NULL
29794 || (arm_vcond_hsh = hash_new ()) == NULL
29795 || (arm_shift_hsh = hash_new ()) == NULL
29796 || (arm_psr_hsh = hash_new ()) == NULL
29797 || (arm_v7m_psr_hsh = hash_new ()) == NULL
29798 || (arm_reg_hsh = hash_new ()) == NULL
29799 || (arm_reloc_hsh = hash_new ()) == NULL
29800 || (arm_barrier_opt_hsh = hash_new ()) == NULL)
29801 as_fatal (_("virtual memory exhausted"));
29803 for (i = 0; i < sizeof (insns) / sizeof (struct asm_opcode); i++)
29804 hash_insert (arm_ops_hsh, insns[i].template_name, (void *) (insns + i));
29805 for (i = 0; i < sizeof (conds) / sizeof (struct asm_cond); i++)
29806 hash_insert (arm_cond_hsh, conds[i].template_name, (void *) (conds + i));
29807 for (i = 0; i < sizeof (vconds) / sizeof (struct asm_cond); i++)
29808 hash_insert (arm_vcond_hsh, vconds[i].template_name, (void *) (vconds + i));
29809 for (i = 0; i < sizeof (shift_names) / sizeof (struct asm_shift_name); i++)
29810 hash_insert (arm_shift_hsh, shift_names[i].name, (void *) (shift_names + i));
29811 for (i = 0; i < sizeof (psrs) / sizeof (struct asm_psr); i++)
29812 hash_insert (arm_psr_hsh, psrs[i].template_name, (void *) (psrs + i));
29813 for (i = 0; i < sizeof (v7m_psrs) / sizeof (struct asm_psr); i++)
29814 hash_insert (arm_v7m_psr_hsh, v7m_psrs[i].template_name,
29815 (void *) (v7m_psrs + i));
29816 for (i = 0; i < sizeof (reg_names) / sizeof (struct reg_entry); i++)
29817 hash_insert (arm_reg_hsh, reg_names[i].name, (void *) (reg_names + i));
29819 i < sizeof (barrier_opt_names) / sizeof (struct asm_barrier_opt);
29821 hash_insert (arm_barrier_opt_hsh, barrier_opt_names[i].template_name,
29822 (void *) (barrier_opt_names + i));
29824 for (i = 0; i < ARRAY_SIZE (reloc_names); i++)
29826 struct reloc_entry * entry = reloc_names + i;
29828 if (arm_is_eabi() && entry->reloc == BFD_RELOC_ARM_PLT32)
29829 /* This makes encode_branch() use the EABI versions of this relocation. */
29830 entry->reloc = BFD_RELOC_UNUSED;
29832 hash_insert (arm_reloc_hsh, entry->name, (void *) entry);
29836 set_constant_flonums ();
29838 /* Set the cpu variant based on the command-line options. We prefer
29839 -mcpu= over -march= if both are set (as for GCC); and we prefer
29840 -mfpu= over any other way of setting the floating point unit.
29841 Use of legacy options with new options are faulted. */
29844 if (mcpu_cpu_opt || march_cpu_opt)
29845 as_bad (_("use of old and new-style options to set CPU type"));
29847 selected_arch = *legacy_cpu;
29849 else if (mcpu_cpu_opt)
29851 selected_arch = *mcpu_cpu_opt;
29852 selected_ext = *mcpu_ext_opt;
29854 else if (march_cpu_opt)
29856 selected_arch = *march_cpu_opt;
29857 selected_ext = *march_ext_opt;
29859 ARM_MERGE_FEATURE_SETS (selected_cpu, selected_arch, selected_ext);
29864 as_bad (_("use of old and new-style options to set FPU type"));
29866 selected_fpu = *legacy_fpu;
29869 selected_fpu = *mfpu_opt;
29872 #if !(defined (EABI_DEFAULT) || defined (TE_LINUX) \
29873 || defined (TE_NetBSD) || defined (TE_VXWORKS))
29874 /* Some environments specify a default FPU. If they don't, infer it
29875 from the processor. */
29877 selected_fpu = *mcpu_fpu_opt;
29878 else if (march_fpu_opt)
29879 selected_fpu = *march_fpu_opt;
29881 selected_fpu = fpu_default;
29885 if (ARM_FEATURE_ZERO (selected_fpu))
29887 if (!no_cpu_selected ())
29888 selected_fpu = fpu_default;
29890 selected_fpu = fpu_arch_fpa;
29894 if (ARM_FEATURE_ZERO (selected_arch))
29896 selected_arch = cpu_default;
29897 selected_cpu = selected_arch;
29899 ARM_MERGE_FEATURE_SETS (cpu_variant, selected_cpu, selected_fpu);
29901 /* Autodection of feature mode: allow all features in cpu_variant but leave
29902 selected_cpu unset. It will be set in aeabi_set_public_attributes ()
29903 after all instruction have been processed and we can decide what CPU
29904 should be selected. */
29905 if (ARM_FEATURE_ZERO (selected_arch))
29906 ARM_MERGE_FEATURE_SETS (cpu_variant, arm_arch_any, selected_fpu);
29908 ARM_MERGE_FEATURE_SETS (cpu_variant, selected_cpu, selected_fpu);
29911 autoselect_thumb_from_cpu_variant ();
29913 arm_arch_used = thumb_arch_used = arm_arch_none;
29915 #if defined OBJ_COFF || defined OBJ_ELF
29917 unsigned int flags = 0;
29919 #if defined OBJ_ELF
29920 flags = meabi_flags;
29922 switch (meabi_flags)
29924 case EF_ARM_EABI_UNKNOWN:
29926 /* Set the flags in the private structure. */
29927 if (uses_apcs_26) flags |= F_APCS26;
29928 if (support_interwork) flags |= F_INTERWORK;
29929 if (uses_apcs_float) flags |= F_APCS_FLOAT;
29930 if (pic_code) flags |= F_PIC;
29931 if (!ARM_CPU_HAS_FEATURE (cpu_variant, fpu_any_hard))
29932 flags |= F_SOFT_FLOAT;
29934 switch (mfloat_abi_opt)
29936 case ARM_FLOAT_ABI_SOFT:
29937 case ARM_FLOAT_ABI_SOFTFP:
29938 flags |= F_SOFT_FLOAT;
29941 case ARM_FLOAT_ABI_HARD:
29942 if (flags & F_SOFT_FLOAT)
29943 as_bad (_("hard-float conflicts with specified fpu"));
29947 /* Using pure-endian doubles (even if soft-float). */
29948 if (ARM_CPU_HAS_FEATURE (cpu_variant, fpu_endian_pure))
29949 flags |= F_VFP_FLOAT;
29951 #if defined OBJ_ELF
29952 if (ARM_CPU_HAS_FEATURE (cpu_variant, fpu_arch_maverick))
29953 flags |= EF_ARM_MAVERICK_FLOAT;
29956 case EF_ARM_EABI_VER4:
29957 case EF_ARM_EABI_VER5:
29958 /* No additional flags to set. */
29965 bfd_set_private_flags (stdoutput, flags);
29967 /* We have run out flags in the COFF header to encode the
29968 status of ATPCS support, so instead we create a dummy,
29969 empty, debug section called .arm.atpcs. */
29974 sec = bfd_make_section (stdoutput, ".arm.atpcs");
29978 bfd_set_section_flags
29979 (stdoutput, sec, SEC_READONLY | SEC_DEBUGGING /* | SEC_HAS_CONTENTS */);
29980 bfd_set_section_size (stdoutput, sec, 0);
29981 bfd_set_section_contents (stdoutput, sec, NULL, 0, 0);
29987 /* Record the CPU type as well. */
29988 if (ARM_CPU_HAS_FEATURE (cpu_variant, arm_cext_iwmmxt2))
29989 mach = bfd_mach_arm_iWMMXt2;
29990 else if (ARM_CPU_HAS_FEATURE (cpu_variant, arm_cext_iwmmxt))
29991 mach = bfd_mach_arm_iWMMXt;
29992 else if (ARM_CPU_HAS_FEATURE (cpu_variant, arm_cext_xscale))
29993 mach = bfd_mach_arm_XScale;
29994 else if (ARM_CPU_HAS_FEATURE (cpu_variant, arm_cext_maverick))
29995 mach = bfd_mach_arm_ep9312;
29996 else if (ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_v5e))
29997 mach = bfd_mach_arm_5TE;
29998 else if (ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_v5))
30000 if (ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_v4t))
30001 mach = bfd_mach_arm_5T;
30003 mach = bfd_mach_arm_5;
30005 else if (ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_v4))
30007 if (ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_v4t))
30008 mach = bfd_mach_arm_4T;
30010 mach = bfd_mach_arm_4;
30012 else if (ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_v3m))
30013 mach = bfd_mach_arm_3M;
30014 else if (ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_v3))
30015 mach = bfd_mach_arm_3;
30016 else if (ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_v2s))
30017 mach = bfd_mach_arm_2a;
30018 else if (ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_v2))
30019 mach = bfd_mach_arm_2;
30021 mach = bfd_mach_arm_unknown;
30023 bfd_set_arch_mach (stdoutput, TARGET_ARCH, mach);
30026 /* Command line processing. */
30029 Invocation line includes a switch not recognized by the base assembler.
30030 See if it's a processor-specific option.
30032 This routine is somewhat complicated by the need for backwards
30033 compatibility (since older releases of gcc can't be changed).
30034 The new options try to make the interface as compatible as
30037 New options (supported) are:
30039 -mcpu=<cpu name> Assemble for selected processor
30040 -march=<architecture name> Assemble for selected architecture
30041 -mfpu=<fpu architecture> Assemble for selected FPU.
30042 -EB/-mbig-endian Big-endian
30043 -EL/-mlittle-endian Little-endian
30044 -k Generate PIC code
30045 -mthumb Start in Thumb mode
30046 -mthumb-interwork Code supports ARM/Thumb interworking
30048 -m[no-]warn-deprecated Warn about deprecated features
30049 -m[no-]warn-syms Warn when symbols match instructions
30051 For now we will also provide support for:
30053 -mapcs-32 32-bit Program counter
30054 -mapcs-26 26-bit Program counter
30055 -macps-float Floats passed in FP registers
30056 -mapcs-reentrant Reentrant code
30058 (sometime these will probably be replaced with -mapcs=<list of options>
30059 and -matpcs=<list of options>)
30061 The remaining options are only supported for back-wards compatibility.
30062 Cpu variants, the arm part is optional:
30063 -m[arm]1 Currently not supported.
30064 -m[arm]2, -m[arm]250 Arm 2 and Arm 250 processor
30065 -m[arm]3 Arm 3 processor
30066 -m[arm]6[xx], Arm 6 processors
30067 -m[arm]7[xx][t][[d]m] Arm 7 processors
30068 -m[arm]8[10] Arm 8 processors
30069 -m[arm]9[20][tdmi] Arm 9 processors
30070 -mstrongarm[110[0]] StrongARM processors
30071 -mxscale XScale processors
30072 -m[arm]v[2345[t[e]]] Arm architectures
30073 -mall All (except the ARM1)
30075 -mfpa10, -mfpa11 FPA10 and 11 co-processor instructions
30076 -mfpe-old (No float load/store multiples)
30077 -mvfpxd VFP Single precision
30079 -mno-fpu Disable all floating point instructions
30081 The following CPU names are recognized:
30082 arm1, arm2, arm250, arm3, arm6, arm600, arm610, arm620,
30083 arm7, arm7m, arm7d, arm7dm, arm7di, arm7dmi, arm70, arm700,
30084 arm700i, arm710 arm710t, arm720, arm720t, arm740t, arm710c,
30085 arm7100, arm7500, arm7500fe, arm7tdmi, arm8, arm810, arm9,
30086 arm920, arm920t, arm940t, arm946, arm966, arm9tdmi, arm9e,
30087 arm10t arm10e, arm1020t, arm1020e, arm10200e,
30088 strongarm, strongarm110, strongarm1100, strongarm1110, xscale.
30092 const char * md_shortopts = "m:k";
30094 #ifdef ARM_BI_ENDIAN
30095 #define OPTION_EB (OPTION_MD_BASE + 0)
30096 #define OPTION_EL (OPTION_MD_BASE + 1)
30098 #if TARGET_BYTES_BIG_ENDIAN
30099 #define OPTION_EB (OPTION_MD_BASE + 0)
30101 #define OPTION_EL (OPTION_MD_BASE + 1)
30104 #define OPTION_FIX_V4BX (OPTION_MD_BASE + 2)
30105 #define OPTION_FDPIC (OPTION_MD_BASE + 3)
30107 struct option md_longopts[] =
30110 {"EB", no_argument, NULL, OPTION_EB},
30113 {"EL", no_argument, NULL, OPTION_EL},
30115 {"fix-v4bx", no_argument, NULL, OPTION_FIX_V4BX},
30117 {"fdpic", no_argument, NULL, OPTION_FDPIC},
30119 {NULL, no_argument, NULL, 0}
30122 size_t md_longopts_size = sizeof (md_longopts);
30124 struct arm_option_table
30126 const char * option; /* Option name to match. */
30127 const char * help; /* Help information. */
30128 int * var; /* Variable to change. */
30129 int value; /* What to change it to. */
30130 const char * deprecated; /* If non-null, print this message. */
30133 struct arm_option_table arm_opts[] =
30135 {"k", N_("generate PIC code"), &pic_code, 1, NULL},
30136 {"mthumb", N_("assemble Thumb code"), &thumb_mode, 1, NULL},
30137 {"mthumb-interwork", N_("support ARM/Thumb interworking"),
30138 &support_interwork, 1, NULL},
30139 {"mapcs-32", N_("code uses 32-bit program counter"), &uses_apcs_26, 0, NULL},
30140 {"mapcs-26", N_("code uses 26-bit program counter"), &uses_apcs_26, 1, NULL},
30141 {"mapcs-float", N_("floating point args are in fp regs"), &uses_apcs_float,
30143 {"mapcs-reentrant", N_("re-entrant code"), &pic_code, 1, NULL},
30144 {"matpcs", N_("code is ATPCS conformant"), &atpcs, 1, NULL},
30145 {"mbig-endian", N_("assemble for big-endian"), &target_big_endian, 1, NULL},
30146 {"mlittle-endian", N_("assemble for little-endian"), &target_big_endian, 0,
30149 /* These are recognized by the assembler, but have no affect on code. */
30150 {"mapcs-frame", N_("use frame pointer"), NULL, 0, NULL},
30151 {"mapcs-stack-check", N_("use stack size checking"), NULL, 0, NULL},
30153 {"mwarn-deprecated", NULL, &warn_on_deprecated, 1, NULL},
30154 {"mno-warn-deprecated", N_("do not warn on use of deprecated feature"),
30155 &warn_on_deprecated, 0, NULL},
30156 {"mwarn-syms", N_("warn about symbols that match instruction names [default]"), (int *) (& flag_warn_syms), TRUE, NULL},
30157 {"mno-warn-syms", N_("disable warnings about symobls that match instructions"), (int *) (& flag_warn_syms), FALSE, NULL},
30158 {NULL, NULL, NULL, 0, NULL}
30161 struct arm_legacy_option_table
30163 const char * option; /* Option name to match. */
30164 const arm_feature_set ** var; /* Variable to change. */
30165 const arm_feature_set value; /* What to change it to. */
30166 const char * deprecated; /* If non-null, print this message. */
30169 const struct arm_legacy_option_table arm_legacy_opts[] =
30171 /* DON'T add any new processors to this list -- we want the whole list
30172 to go away... Add them to the processors table instead. */
30173 {"marm1", &legacy_cpu, ARM_ARCH_V1, N_("use -mcpu=arm1")},
30174 {"m1", &legacy_cpu, ARM_ARCH_V1, N_("use -mcpu=arm1")},
30175 {"marm2", &legacy_cpu, ARM_ARCH_V2, N_("use -mcpu=arm2")},
30176 {"m2", &legacy_cpu, ARM_ARCH_V2, N_("use -mcpu=arm2")},
30177 {"marm250", &legacy_cpu, ARM_ARCH_V2S, N_("use -mcpu=arm250")},
30178 {"m250", &legacy_cpu, ARM_ARCH_V2S, N_("use -mcpu=arm250")},
30179 {"marm3", &legacy_cpu, ARM_ARCH_V2S, N_("use -mcpu=arm3")},
30180 {"m3", &legacy_cpu, ARM_ARCH_V2S, N_("use -mcpu=arm3")},
30181 {"marm6", &legacy_cpu, ARM_ARCH_V3, N_("use -mcpu=arm6")},
30182 {"m6", &legacy_cpu, ARM_ARCH_V3, N_("use -mcpu=arm6")},
30183 {"marm600", &legacy_cpu, ARM_ARCH_V3, N_("use -mcpu=arm600")},
30184 {"m600", &legacy_cpu, ARM_ARCH_V3, N_("use -mcpu=arm600")},
30185 {"marm610", &legacy_cpu, ARM_ARCH_V3, N_("use -mcpu=arm610")},
30186 {"m610", &legacy_cpu, ARM_ARCH_V3, N_("use -mcpu=arm610")},
30187 {"marm620", &legacy_cpu, ARM_ARCH_V3, N_("use -mcpu=arm620")},
30188 {"m620", &legacy_cpu, ARM_ARCH_V3, N_("use -mcpu=arm620")},
30189 {"marm7", &legacy_cpu, ARM_ARCH_V3, N_("use -mcpu=arm7")},
30190 {"m7", &legacy_cpu, ARM_ARCH_V3, N_("use -mcpu=arm7")},
30191 {"marm70", &legacy_cpu, ARM_ARCH_V3, N_("use -mcpu=arm70")},
30192 {"m70", &legacy_cpu, ARM_ARCH_V3, N_("use -mcpu=arm70")},
30193 {"marm700", &legacy_cpu, ARM_ARCH_V3, N_("use -mcpu=arm700")},
30194 {"m700", &legacy_cpu, ARM_ARCH_V3, N_("use -mcpu=arm700")},
30195 {"marm700i", &legacy_cpu, ARM_ARCH_V3, N_("use -mcpu=arm700i")},
30196 {"m700i", &legacy_cpu, ARM_ARCH_V3, N_("use -mcpu=arm700i")},
30197 {"marm710", &legacy_cpu, ARM_ARCH_V3, N_("use -mcpu=arm710")},
30198 {"m710", &legacy_cpu, ARM_ARCH_V3, N_("use -mcpu=arm710")},
30199 {"marm710c", &legacy_cpu, ARM_ARCH_V3, N_("use -mcpu=arm710c")},
30200 {"m710c", &legacy_cpu, ARM_ARCH_V3, N_("use -mcpu=arm710c")},
30201 {"marm720", &legacy_cpu, ARM_ARCH_V3, N_("use -mcpu=arm720")},
30202 {"m720", &legacy_cpu, ARM_ARCH_V3, N_("use -mcpu=arm720")},
30203 {"marm7d", &legacy_cpu, ARM_ARCH_V3, N_("use -mcpu=arm7d")},
30204 {"m7d", &legacy_cpu, ARM_ARCH_V3, N_("use -mcpu=arm7d")},
30205 {"marm7di", &legacy_cpu, ARM_ARCH_V3, N_("use -mcpu=arm7di")},
30206 {"m7di", &legacy_cpu, ARM_ARCH_V3, N_("use -mcpu=arm7di")},
30207 {"marm7m", &legacy_cpu, ARM_ARCH_V3M, N_("use -mcpu=arm7m")},
30208 {"m7m", &legacy_cpu, ARM_ARCH_V3M, N_("use -mcpu=arm7m")},
30209 {"marm7dm", &legacy_cpu, ARM_ARCH_V3M, N_("use -mcpu=arm7dm")},
30210 {"m7dm", &legacy_cpu, ARM_ARCH_V3M, N_("use -mcpu=arm7dm")},
30211 {"marm7dmi", &legacy_cpu, ARM_ARCH_V3M, N_("use -mcpu=arm7dmi")},
30212 {"m7dmi", &legacy_cpu, ARM_ARCH_V3M, N_("use -mcpu=arm7dmi")},
30213 {"marm7100", &legacy_cpu, ARM_ARCH_V3, N_("use -mcpu=arm7100")},
30214 {"m7100", &legacy_cpu, ARM_ARCH_V3, N_("use -mcpu=arm7100")},
30215 {"marm7500", &legacy_cpu, ARM_ARCH_V3, N_("use -mcpu=arm7500")},
30216 {"m7500", &legacy_cpu, ARM_ARCH_V3, N_("use -mcpu=arm7500")},
30217 {"marm7500fe", &legacy_cpu, ARM_ARCH_V3, N_("use -mcpu=arm7500fe")},
30218 {"m7500fe", &legacy_cpu, ARM_ARCH_V3, N_("use -mcpu=arm7500fe")},
30219 {"marm7t", &legacy_cpu, ARM_ARCH_V4T, N_("use -mcpu=arm7tdmi")},
30220 {"m7t", &legacy_cpu, ARM_ARCH_V4T, N_("use -mcpu=arm7tdmi")},
30221 {"marm7tdmi", &legacy_cpu, ARM_ARCH_V4T, N_("use -mcpu=arm7tdmi")},
30222 {"m7tdmi", &legacy_cpu, ARM_ARCH_V4T, N_("use -mcpu=arm7tdmi")},
30223 {"marm710t", &legacy_cpu, ARM_ARCH_V4T, N_("use -mcpu=arm710t")},
30224 {"m710t", &legacy_cpu, ARM_ARCH_V4T, N_("use -mcpu=arm710t")},
30225 {"marm720t", &legacy_cpu, ARM_ARCH_V4T, N_("use -mcpu=arm720t")},
30226 {"m720t", &legacy_cpu, ARM_ARCH_V4T, N_("use -mcpu=arm720t")},
30227 {"marm740t", &legacy_cpu, ARM_ARCH_V4T, N_("use -mcpu=arm740t")},
30228 {"m740t", &legacy_cpu, ARM_ARCH_V4T, N_("use -mcpu=arm740t")},
30229 {"marm8", &legacy_cpu, ARM_ARCH_V4, N_("use -mcpu=arm8")},
30230 {"m8", &legacy_cpu, ARM_ARCH_V4, N_("use -mcpu=arm8")},
30231 {"marm810", &legacy_cpu, ARM_ARCH_V4, N_("use -mcpu=arm810")},
30232 {"m810", &legacy_cpu, ARM_ARCH_V4, N_("use -mcpu=arm810")},
30233 {"marm9", &legacy_cpu, ARM_ARCH_V4T, N_("use -mcpu=arm9")},
30234 {"m9", &legacy_cpu, ARM_ARCH_V4T, N_("use -mcpu=arm9")},
30235 {"marm9tdmi", &legacy_cpu, ARM_ARCH_V4T, N_("use -mcpu=arm9tdmi")},
30236 {"m9tdmi", &legacy_cpu, ARM_ARCH_V4T, N_("use -mcpu=arm9tdmi")},
30237 {"marm920", &legacy_cpu, ARM_ARCH_V4T, N_("use -mcpu=arm920")},
30238 {"m920", &legacy_cpu, ARM_ARCH_V4T, N_("use -mcpu=arm920")},
30239 {"marm940", &legacy_cpu, ARM_ARCH_V4T, N_("use -mcpu=arm940")},
30240 {"m940", &legacy_cpu, ARM_ARCH_V4T, N_("use -mcpu=arm940")},
30241 {"mstrongarm", &legacy_cpu, ARM_ARCH_V4, N_("use -mcpu=strongarm")},
30242 {"mstrongarm110", &legacy_cpu, ARM_ARCH_V4,
30243 N_("use -mcpu=strongarm110")},
30244 {"mstrongarm1100", &legacy_cpu, ARM_ARCH_V4,
30245 N_("use -mcpu=strongarm1100")},
30246 {"mstrongarm1110", &legacy_cpu, ARM_ARCH_V4,
30247 N_("use -mcpu=strongarm1110")},
30248 {"mxscale", &legacy_cpu, ARM_ARCH_XSCALE, N_("use -mcpu=xscale")},
30249 {"miwmmxt", &legacy_cpu, ARM_ARCH_IWMMXT, N_("use -mcpu=iwmmxt")},
30250 {"mall", &legacy_cpu, ARM_ANY, N_("use -mcpu=all")},
30252 /* Architecture variants -- don't add any more to this list either. */
30253 {"mv2", &legacy_cpu, ARM_ARCH_V2, N_("use -march=armv2")},
30254 {"marmv2", &legacy_cpu, ARM_ARCH_V2, N_("use -march=armv2")},
30255 {"mv2a", &legacy_cpu, ARM_ARCH_V2S, N_("use -march=armv2a")},
30256 {"marmv2a", &legacy_cpu, ARM_ARCH_V2S, N_("use -march=armv2a")},
30257 {"mv3", &legacy_cpu, ARM_ARCH_V3, N_("use -march=armv3")},
30258 {"marmv3", &legacy_cpu, ARM_ARCH_V3, N_("use -march=armv3")},
30259 {"mv3m", &legacy_cpu, ARM_ARCH_V3M, N_("use -march=armv3m")},
30260 {"marmv3m", &legacy_cpu, ARM_ARCH_V3M, N_("use -march=armv3m")},
30261 {"mv4", &legacy_cpu, ARM_ARCH_V4, N_("use -march=armv4")},
30262 {"marmv4", &legacy_cpu, ARM_ARCH_V4, N_("use -march=armv4")},
30263 {"mv4t", &legacy_cpu, ARM_ARCH_V4T, N_("use -march=armv4t")},
30264 {"marmv4t", &legacy_cpu, ARM_ARCH_V4T, N_("use -march=armv4t")},
30265 {"mv5", &legacy_cpu, ARM_ARCH_V5, N_("use -march=armv5")},
30266 {"marmv5", &legacy_cpu, ARM_ARCH_V5, N_("use -march=armv5")},
30267 {"mv5t", &legacy_cpu, ARM_ARCH_V5T, N_("use -march=armv5t")},
30268 {"marmv5t", &legacy_cpu, ARM_ARCH_V5T, N_("use -march=armv5t")},
30269 {"mv5e", &legacy_cpu, ARM_ARCH_V5TE, N_("use -march=armv5te")},
30270 {"marmv5e", &legacy_cpu, ARM_ARCH_V5TE, N_("use -march=armv5te")},
30272 /* Floating point variants -- don't add any more to this list either. */
30273 {"mfpe-old", &legacy_fpu, FPU_ARCH_FPE, N_("use -mfpu=fpe")},
30274 {"mfpa10", &legacy_fpu, FPU_ARCH_FPA, N_("use -mfpu=fpa10")},
30275 {"mfpa11", &legacy_fpu, FPU_ARCH_FPA, N_("use -mfpu=fpa11")},
30276 {"mno-fpu", &legacy_fpu, ARM_ARCH_NONE,
30277 N_("use either -mfpu=softfpa or -mfpu=softvfp")},
30279 {NULL, NULL, ARM_ARCH_NONE, NULL}
30282 struct arm_cpu_option_table
30286 const arm_feature_set value;
30287 const arm_feature_set ext;
30288 /* For some CPUs we assume an FPU unless the user explicitly sets
30290 const arm_feature_set default_fpu;
30291 /* The canonical name of the CPU, or NULL to use NAME converted to upper
30293 const char * canonical_name;
30296 /* This list should, at a minimum, contain all the cpu names
30297 recognized by GCC. */
30298 #define ARM_CPU_OPT(N, CN, V, E, DF) { N, sizeof (N) - 1, V, E, DF, CN }
30300 static const struct arm_cpu_option_table arm_cpus[] =
30302 ARM_CPU_OPT ("all", NULL, ARM_ANY,
30305 ARM_CPU_OPT ("arm1", NULL, ARM_ARCH_V1,
30308 ARM_CPU_OPT ("arm2", NULL, ARM_ARCH_V2,
30311 ARM_CPU_OPT ("arm250", NULL, ARM_ARCH_V2S,
30314 ARM_CPU_OPT ("arm3", NULL, ARM_ARCH_V2S,
30317 ARM_CPU_OPT ("arm6", NULL, ARM_ARCH_V3,
30320 ARM_CPU_OPT ("arm60", NULL, ARM_ARCH_V3,
30323 ARM_CPU_OPT ("arm600", NULL, ARM_ARCH_V3,
30326 ARM_CPU_OPT ("arm610", NULL, ARM_ARCH_V3,
30329 ARM_CPU_OPT ("arm620", NULL, ARM_ARCH_V3,
30332 ARM_CPU_OPT ("arm7", NULL, ARM_ARCH_V3,
30335 ARM_CPU_OPT ("arm7m", NULL, ARM_ARCH_V3M,
30338 ARM_CPU_OPT ("arm7d", NULL, ARM_ARCH_V3,
30341 ARM_CPU_OPT ("arm7dm", NULL, ARM_ARCH_V3M,
30344 ARM_CPU_OPT ("arm7di", NULL, ARM_ARCH_V3,
30347 ARM_CPU_OPT ("arm7dmi", NULL, ARM_ARCH_V3M,
30350 ARM_CPU_OPT ("arm70", NULL, ARM_ARCH_V3,
30353 ARM_CPU_OPT ("arm700", NULL, ARM_ARCH_V3,
30356 ARM_CPU_OPT ("arm700i", NULL, ARM_ARCH_V3,
30359 ARM_CPU_OPT ("arm710", NULL, ARM_ARCH_V3,
30362 ARM_CPU_OPT ("arm710t", NULL, ARM_ARCH_V4T,
30365 ARM_CPU_OPT ("arm720", NULL, ARM_ARCH_V3,
30368 ARM_CPU_OPT ("arm720t", NULL, ARM_ARCH_V4T,
30371 ARM_CPU_OPT ("arm740t", NULL, ARM_ARCH_V4T,
30374 ARM_CPU_OPT ("arm710c", NULL, ARM_ARCH_V3,
30377 ARM_CPU_OPT ("arm7100", NULL, ARM_ARCH_V3,
30380 ARM_CPU_OPT ("arm7500", NULL, ARM_ARCH_V3,
30383 ARM_CPU_OPT ("arm7500fe", NULL, ARM_ARCH_V3,
30386 ARM_CPU_OPT ("arm7t", NULL, ARM_ARCH_V4T,
30389 ARM_CPU_OPT ("arm7tdmi", NULL, ARM_ARCH_V4T,
30392 ARM_CPU_OPT ("arm7tdmi-s", NULL, ARM_ARCH_V4T,
30395 ARM_CPU_OPT ("arm8", NULL, ARM_ARCH_V4,
30398 ARM_CPU_OPT ("arm810", NULL, ARM_ARCH_V4,
30401 ARM_CPU_OPT ("strongarm", NULL, ARM_ARCH_V4,
30404 ARM_CPU_OPT ("strongarm1", NULL, ARM_ARCH_V4,
30407 ARM_CPU_OPT ("strongarm110", NULL, ARM_ARCH_V4,
30410 ARM_CPU_OPT ("strongarm1100", NULL, ARM_ARCH_V4,
30413 ARM_CPU_OPT ("strongarm1110", NULL, ARM_ARCH_V4,
30416 ARM_CPU_OPT ("arm9", NULL, ARM_ARCH_V4T,
30419 ARM_CPU_OPT ("arm920", "ARM920T", ARM_ARCH_V4T,
30422 ARM_CPU_OPT ("arm920t", NULL, ARM_ARCH_V4T,
30425 ARM_CPU_OPT ("arm922t", NULL, ARM_ARCH_V4T,
30428 ARM_CPU_OPT ("arm940t", NULL, ARM_ARCH_V4T,
30431 ARM_CPU_OPT ("arm9tdmi", NULL, ARM_ARCH_V4T,
30434 ARM_CPU_OPT ("fa526", NULL, ARM_ARCH_V4,
30437 ARM_CPU_OPT ("fa626", NULL, ARM_ARCH_V4,
30441 /* For V5 or later processors we default to using VFP; but the user
30442 should really set the FPU type explicitly. */
30443 ARM_CPU_OPT ("arm9e-r0", NULL, ARM_ARCH_V5TExP,
30446 ARM_CPU_OPT ("arm9e", NULL, ARM_ARCH_V5TE,
30449 ARM_CPU_OPT ("arm926ej", "ARM926EJ-S", ARM_ARCH_V5TEJ,
30452 ARM_CPU_OPT ("arm926ejs", "ARM926EJ-S", ARM_ARCH_V5TEJ,
30455 ARM_CPU_OPT ("arm926ej-s", NULL, ARM_ARCH_V5TEJ,
30458 ARM_CPU_OPT ("arm946e-r0", NULL, ARM_ARCH_V5TExP,
30461 ARM_CPU_OPT ("arm946e", "ARM946E-S", ARM_ARCH_V5TE,
30464 ARM_CPU_OPT ("arm946e-s", NULL, ARM_ARCH_V5TE,
30467 ARM_CPU_OPT ("arm966e-r0", NULL, ARM_ARCH_V5TExP,
30470 ARM_CPU_OPT ("arm966e", "ARM966E-S", ARM_ARCH_V5TE,
30473 ARM_CPU_OPT ("arm966e-s", NULL, ARM_ARCH_V5TE,
30476 ARM_CPU_OPT ("arm968e-s", NULL, ARM_ARCH_V5TE,
30479 ARM_CPU_OPT ("arm10t", NULL, ARM_ARCH_V5T,
30482 ARM_CPU_OPT ("arm10tdmi", NULL, ARM_ARCH_V5T,
30485 ARM_CPU_OPT ("arm10e", NULL, ARM_ARCH_V5TE,
30488 ARM_CPU_OPT ("arm1020", "ARM1020E", ARM_ARCH_V5TE,
30491 ARM_CPU_OPT ("arm1020t", NULL, ARM_ARCH_V5T,
30494 ARM_CPU_OPT ("arm1020e", NULL, ARM_ARCH_V5TE,
30497 ARM_CPU_OPT ("arm1022e", NULL, ARM_ARCH_V5TE,
30500 ARM_CPU_OPT ("arm1026ejs", "ARM1026EJ-S", ARM_ARCH_V5TEJ,
30503 ARM_CPU_OPT ("arm1026ej-s", NULL, ARM_ARCH_V5TEJ,
30506 ARM_CPU_OPT ("fa606te", NULL, ARM_ARCH_V5TE,
30509 ARM_CPU_OPT ("fa616te", NULL, ARM_ARCH_V5TE,
30512 ARM_CPU_OPT ("fa626te", NULL, ARM_ARCH_V5TE,
30515 ARM_CPU_OPT ("fmp626", NULL, ARM_ARCH_V5TE,
30518 ARM_CPU_OPT ("fa726te", NULL, ARM_ARCH_V5TE,
30521 ARM_CPU_OPT ("arm1136js", "ARM1136J-S", ARM_ARCH_V6,
30524 ARM_CPU_OPT ("arm1136j-s", NULL, ARM_ARCH_V6,
30527 ARM_CPU_OPT ("arm1136jfs", "ARM1136JF-S", ARM_ARCH_V6,
30530 ARM_CPU_OPT ("arm1136jf-s", NULL, ARM_ARCH_V6,
30533 ARM_CPU_OPT ("mpcore", "MPCore", ARM_ARCH_V6K,
30536 ARM_CPU_OPT ("mpcorenovfp", "MPCore", ARM_ARCH_V6K,
30539 ARM_CPU_OPT ("arm1156t2-s", NULL, ARM_ARCH_V6T2,
30542 ARM_CPU_OPT ("arm1156t2f-s", NULL, ARM_ARCH_V6T2,
30545 ARM_CPU_OPT ("arm1176jz-s", NULL, ARM_ARCH_V6KZ,
30548 ARM_CPU_OPT ("arm1176jzf-s", NULL, ARM_ARCH_V6KZ,
30551 ARM_CPU_OPT ("cortex-a5", "Cortex-A5", ARM_ARCH_V7A,
30552 ARM_FEATURE_CORE_LOW (ARM_EXT_MP | ARM_EXT_SEC),
30554 ARM_CPU_OPT ("cortex-a7", "Cortex-A7", ARM_ARCH_V7VE,
30556 FPU_ARCH_NEON_VFP_V4),
30557 ARM_CPU_OPT ("cortex-a8", "Cortex-A8", ARM_ARCH_V7A,
30558 ARM_FEATURE_CORE_LOW (ARM_EXT_SEC),
30559 ARM_FEATURE_COPROC (FPU_VFP_V3 | FPU_NEON_EXT_V1)),
30560 ARM_CPU_OPT ("cortex-a9", "Cortex-A9", ARM_ARCH_V7A,
30561 ARM_FEATURE_CORE_LOW (ARM_EXT_MP | ARM_EXT_SEC),
30562 ARM_FEATURE_COPROC (FPU_VFP_V3 | FPU_NEON_EXT_V1)),
30563 ARM_CPU_OPT ("cortex-a12", "Cortex-A12", ARM_ARCH_V7VE,
30565 FPU_ARCH_NEON_VFP_V4),
30566 ARM_CPU_OPT ("cortex-a15", "Cortex-A15", ARM_ARCH_V7VE,
30568 FPU_ARCH_NEON_VFP_V4),
30569 ARM_CPU_OPT ("cortex-a17", "Cortex-A17", ARM_ARCH_V7VE,
30571 FPU_ARCH_NEON_VFP_V4),
30572 ARM_CPU_OPT ("cortex-a32", "Cortex-A32", ARM_ARCH_V8A,
30573 ARM_FEATURE_COPROC (CRC_EXT_ARMV8),
30574 FPU_ARCH_CRYPTO_NEON_VFP_ARMV8),
30575 ARM_CPU_OPT ("cortex-a35", "Cortex-A35", ARM_ARCH_V8A,
30576 ARM_FEATURE_COPROC (CRC_EXT_ARMV8),
30577 FPU_ARCH_CRYPTO_NEON_VFP_ARMV8),
30578 ARM_CPU_OPT ("cortex-a53", "Cortex-A53", ARM_ARCH_V8A,
30579 ARM_FEATURE_COPROC (CRC_EXT_ARMV8),
30580 FPU_ARCH_CRYPTO_NEON_VFP_ARMV8),
30581 ARM_CPU_OPT ("cortex-a55", "Cortex-A55", ARM_ARCH_V8_2A,
30582 ARM_FEATURE_CORE_HIGH (ARM_EXT2_FP16_INST),
30583 FPU_ARCH_CRYPTO_NEON_VFP_ARMV8_DOTPROD),
30584 ARM_CPU_OPT ("cortex-a57", "Cortex-A57", ARM_ARCH_V8A,
30585 ARM_FEATURE_COPROC (CRC_EXT_ARMV8),
30586 FPU_ARCH_CRYPTO_NEON_VFP_ARMV8),
30587 ARM_CPU_OPT ("cortex-a72", "Cortex-A72", ARM_ARCH_V8A,
30588 ARM_FEATURE_COPROC (CRC_EXT_ARMV8),
30589 FPU_ARCH_CRYPTO_NEON_VFP_ARMV8),
30590 ARM_CPU_OPT ("cortex-a73", "Cortex-A73", ARM_ARCH_V8A,
30591 ARM_FEATURE_COPROC (CRC_EXT_ARMV8),
30592 FPU_ARCH_CRYPTO_NEON_VFP_ARMV8),
30593 ARM_CPU_OPT ("cortex-a75", "Cortex-A75", ARM_ARCH_V8_2A,
30594 ARM_FEATURE_CORE_HIGH (ARM_EXT2_FP16_INST),
30595 FPU_ARCH_CRYPTO_NEON_VFP_ARMV8_DOTPROD),
30596 ARM_CPU_OPT ("cortex-a76", "Cortex-A76", ARM_ARCH_V8_2A,
30597 ARM_FEATURE_CORE_HIGH (ARM_EXT2_FP16_INST),
30598 FPU_ARCH_CRYPTO_NEON_VFP_ARMV8_DOTPROD),
30599 ARM_CPU_OPT ("ares", "Ares", ARM_ARCH_V8_2A,
30600 ARM_FEATURE_CORE_HIGH (ARM_EXT2_FP16_INST),
30601 FPU_ARCH_CRYPTO_NEON_VFP_ARMV8_DOTPROD),
30602 ARM_CPU_OPT ("cortex-r4", "Cortex-R4", ARM_ARCH_V7R,
30605 ARM_CPU_OPT ("cortex-r4f", "Cortex-R4F", ARM_ARCH_V7R,
30607 FPU_ARCH_VFP_V3D16),
30608 ARM_CPU_OPT ("cortex-r5", "Cortex-R5", ARM_ARCH_V7R,
30609 ARM_FEATURE_CORE_LOW (ARM_EXT_ADIV),
30611 ARM_CPU_OPT ("cortex-r7", "Cortex-R7", ARM_ARCH_V7R,
30612 ARM_FEATURE_CORE_LOW (ARM_EXT_ADIV),
30613 FPU_ARCH_VFP_V3D16),
30614 ARM_CPU_OPT ("cortex-r8", "Cortex-R8", ARM_ARCH_V7R,
30615 ARM_FEATURE_CORE_LOW (ARM_EXT_ADIV),
30616 FPU_ARCH_VFP_V3D16),
30617 ARM_CPU_OPT ("cortex-r52", "Cortex-R52", ARM_ARCH_V8R,
30618 ARM_FEATURE_COPROC (CRC_EXT_ARMV8),
30619 FPU_ARCH_NEON_VFP_ARMV8),
30620 ARM_CPU_OPT ("cortex-m33", "Cortex-M33", ARM_ARCH_V8M_MAIN,
30621 ARM_FEATURE_CORE_LOW (ARM_EXT_V5ExP | ARM_EXT_V6_DSP),
30623 ARM_CPU_OPT ("cortex-m23", "Cortex-M23", ARM_ARCH_V8M_BASE,
30626 ARM_CPU_OPT ("cortex-m7", "Cortex-M7", ARM_ARCH_V7EM,
30629 ARM_CPU_OPT ("cortex-m4", "Cortex-M4", ARM_ARCH_V7EM,
30632 ARM_CPU_OPT ("cortex-m3", "Cortex-M3", ARM_ARCH_V7M,
30635 ARM_CPU_OPT ("cortex-m1", "Cortex-M1", ARM_ARCH_V6SM,
30638 ARM_CPU_OPT ("cortex-m0", "Cortex-M0", ARM_ARCH_V6SM,
30641 ARM_CPU_OPT ("cortex-m0plus", "Cortex-M0+", ARM_ARCH_V6SM,
30644 ARM_CPU_OPT ("exynos-m1", "Samsung Exynos M1", ARM_ARCH_V8A,
30645 ARM_FEATURE_COPROC (CRC_EXT_ARMV8),
30646 FPU_ARCH_CRYPTO_NEON_VFP_ARMV8),
30647 ARM_CPU_OPT ("neoverse-n1", "Neoverse N1", ARM_ARCH_V8_2A,
30648 ARM_FEATURE_CORE_HIGH (ARM_EXT2_FP16_INST),
30649 FPU_ARCH_CRYPTO_NEON_VFP_ARMV8_DOTPROD),
30650 /* ??? XSCALE is really an architecture. */
30651 ARM_CPU_OPT ("xscale", NULL, ARM_ARCH_XSCALE,
30655 /* ??? iwmmxt is not a processor. */
30656 ARM_CPU_OPT ("iwmmxt", NULL, ARM_ARCH_IWMMXT,
30659 ARM_CPU_OPT ("iwmmxt2", NULL, ARM_ARCH_IWMMXT2,
30662 ARM_CPU_OPT ("i80200", NULL, ARM_ARCH_XSCALE,
30667 ARM_CPU_OPT ("ep9312", "ARM920T",
30668 ARM_FEATURE_LOW (ARM_AEXT_V4T, ARM_CEXT_MAVERICK),
30669 ARM_ARCH_NONE, FPU_ARCH_MAVERICK),
30671 /* Marvell processors. */
30672 ARM_CPU_OPT ("marvell-pj4", NULL, ARM_ARCH_V7A,
30673 ARM_FEATURE_CORE_LOW (ARM_EXT_MP | ARM_EXT_SEC),
30674 FPU_ARCH_VFP_V3D16),
30675 ARM_CPU_OPT ("marvell-whitney", NULL, ARM_ARCH_V7A,
30676 ARM_FEATURE_CORE_LOW (ARM_EXT_MP | ARM_EXT_SEC),
30677 FPU_ARCH_NEON_VFP_V4),
30679 /* APM X-Gene family. */
30680 ARM_CPU_OPT ("xgene1", "APM X-Gene 1", ARM_ARCH_V8A,
30682 FPU_ARCH_CRYPTO_NEON_VFP_ARMV8),
30683 ARM_CPU_OPT ("xgene2", "APM X-Gene 2", ARM_ARCH_V8A,
30684 ARM_FEATURE_COPROC (CRC_EXT_ARMV8),
30685 FPU_ARCH_CRYPTO_NEON_VFP_ARMV8),
30687 { NULL, 0, ARM_ARCH_NONE, ARM_ARCH_NONE, ARM_ARCH_NONE, NULL }
30691 struct arm_ext_table
30695 const arm_feature_set merge;
30696 const arm_feature_set clear;
30699 struct arm_arch_option_table
30703 const arm_feature_set value;
30704 const arm_feature_set default_fpu;
30705 const struct arm_ext_table * ext_table;
30708 /* Used to add support for +E and +noE extension. */
30709 #define ARM_EXT(E, M, C) { E, sizeof (E) - 1, M, C }
30710 /* Used to add support for a +E extension. */
30711 #define ARM_ADD(E, M) { E, sizeof(E) - 1, M, ARM_ARCH_NONE }
30712 /* Used to add support for a +noE extension. */
30713 #define ARM_REMOVE(E, C) { E, sizeof(E) -1, ARM_ARCH_NONE, C }
30715 #define ALL_FP ARM_FEATURE (0, ARM_EXT2_FP16_INST | ARM_EXT2_FP16_FML, \
30716 ~0 & ~FPU_ENDIAN_PURE)
30718 static const struct arm_ext_table armv5te_ext_table[] =
30720 ARM_EXT ("fp", FPU_ARCH_VFP_V2, ALL_FP),
30721 { NULL, 0, ARM_ARCH_NONE, ARM_ARCH_NONE }
30724 static const struct arm_ext_table armv7_ext_table[] =
30726 ARM_EXT ("fp", FPU_ARCH_VFP_V3D16, ALL_FP),
30727 { NULL, 0, ARM_ARCH_NONE, ARM_ARCH_NONE }
30730 static const struct arm_ext_table armv7ve_ext_table[] =
30732 ARM_EXT ("fp", FPU_ARCH_VFP_V4D16, ALL_FP),
30733 ARM_ADD ("vfpv3-d16", FPU_ARCH_VFP_V3D16),
30734 ARM_ADD ("vfpv3", FPU_ARCH_VFP_V3),
30735 ARM_ADD ("vfpv3-d16-fp16", FPU_ARCH_VFP_V3D16_FP16),
30736 ARM_ADD ("vfpv3-fp16", FPU_ARCH_VFP_V3_FP16),
30737 ARM_ADD ("vfpv4-d16", FPU_ARCH_VFP_V4D16), /* Alias for +fp. */
30738 ARM_ADD ("vfpv4", FPU_ARCH_VFP_V4),
30740 ARM_EXT ("simd", FPU_ARCH_NEON_VFP_V4,
30741 ARM_FEATURE_COPROC (FPU_NEON_EXT_V1 | FPU_NEON_EXT_FMA)),
30743 /* Aliases for +simd. */
30744 ARM_ADD ("neon-vfpv4", FPU_ARCH_NEON_VFP_V4),
30746 ARM_ADD ("neon", FPU_ARCH_VFP_V3_PLUS_NEON_V1),
30747 ARM_ADD ("neon-vfpv3", FPU_ARCH_VFP_V3_PLUS_NEON_V1),
30748 ARM_ADD ("neon-fp16", FPU_ARCH_NEON_FP16),
30750 { NULL, 0, ARM_ARCH_NONE, ARM_ARCH_NONE }
30753 static const struct arm_ext_table armv7a_ext_table[] =
30755 ARM_EXT ("fp", FPU_ARCH_VFP_V3D16, ALL_FP),
30756 ARM_ADD ("vfpv3-d16", FPU_ARCH_VFP_V3D16), /* Alias for +fp. */
30757 ARM_ADD ("vfpv3", FPU_ARCH_VFP_V3),
30758 ARM_ADD ("vfpv3-d16-fp16", FPU_ARCH_VFP_V3D16_FP16),
30759 ARM_ADD ("vfpv3-fp16", FPU_ARCH_VFP_V3_FP16),
30760 ARM_ADD ("vfpv4-d16", FPU_ARCH_VFP_V4D16),
30761 ARM_ADD ("vfpv4", FPU_ARCH_VFP_V4),
30763 ARM_EXT ("simd", FPU_ARCH_VFP_V3_PLUS_NEON_V1,
30764 ARM_FEATURE_COPROC (FPU_NEON_EXT_V1 | FPU_NEON_EXT_FMA)),
30766 /* Aliases for +simd. */
30767 ARM_ADD ("neon", FPU_ARCH_VFP_V3_PLUS_NEON_V1),
30768 ARM_ADD ("neon-vfpv3", FPU_ARCH_VFP_V3_PLUS_NEON_V1),
30770 ARM_ADD ("neon-fp16", FPU_ARCH_NEON_FP16),
30771 ARM_ADD ("neon-vfpv4", FPU_ARCH_NEON_VFP_V4),
30773 ARM_ADD ("mp", ARM_FEATURE_CORE_LOW (ARM_EXT_MP)),
30774 ARM_ADD ("sec", ARM_FEATURE_CORE_LOW (ARM_EXT_SEC)),
30775 { NULL, 0, ARM_ARCH_NONE, ARM_ARCH_NONE }
30778 static const struct arm_ext_table armv7r_ext_table[] =
30780 ARM_ADD ("fp.sp", FPU_ARCH_VFP_V3xD),
30781 ARM_ADD ("vfpv3xd", FPU_ARCH_VFP_V3xD), /* Alias for +fp.sp. */
30782 ARM_EXT ("fp", FPU_ARCH_VFP_V3D16, ALL_FP),
30783 ARM_ADD ("vfpv3-d16", FPU_ARCH_VFP_V3D16), /* Alias for +fp. */
30784 ARM_ADD ("vfpv3xd-fp16", FPU_ARCH_VFP_V3xD_FP16),
30785 ARM_ADD ("vfpv3-d16-fp16", FPU_ARCH_VFP_V3D16_FP16),
30786 ARM_EXT ("idiv", ARM_FEATURE_CORE_LOW (ARM_EXT_ADIV | ARM_EXT_DIV),
30787 ARM_FEATURE_CORE_LOW (ARM_EXT_ADIV | ARM_EXT_DIV)),
30788 { NULL, 0, ARM_ARCH_NONE, ARM_ARCH_NONE }
30791 static const struct arm_ext_table armv7em_ext_table[] =
30793 ARM_EXT ("fp", FPU_ARCH_VFP_V4_SP_D16, ALL_FP),
30794 /* Alias for +fp, used to be known as fpv4-sp-d16. */
30795 ARM_ADD ("vfpv4-sp-d16", FPU_ARCH_VFP_V4_SP_D16),
30796 ARM_ADD ("fpv5", FPU_ARCH_VFP_V5_SP_D16),
30797 ARM_ADD ("fp.dp", FPU_ARCH_VFP_V5D16),
30798 ARM_ADD ("fpv5-d16", FPU_ARCH_VFP_V5D16),
30799 { NULL, 0, ARM_ARCH_NONE, ARM_ARCH_NONE }
30802 static const struct arm_ext_table armv8a_ext_table[] =
30804 ARM_ADD ("crc", ARCH_CRC_ARMV8),
30805 ARM_ADD ("simd", FPU_ARCH_NEON_VFP_ARMV8),
30806 ARM_EXT ("crypto", FPU_ARCH_CRYPTO_NEON_VFP_ARMV8,
30807 ARM_FEATURE_COPROC (FPU_CRYPTO_ARMV8)),
30809 /* Armv8-a does not allow an FP implementation without SIMD, so the user
30810 should use the +simd option to turn on FP. */
30811 ARM_REMOVE ("fp", ALL_FP),
30812 ARM_ADD ("sb", ARM_FEATURE_CORE_HIGH (ARM_EXT2_SB)),
30813 ARM_ADD ("predres", ARM_FEATURE_CORE_HIGH (ARM_EXT2_PREDRES)),
30814 { NULL, 0, ARM_ARCH_NONE, ARM_ARCH_NONE }
30818 static const struct arm_ext_table armv81a_ext_table[] =
30820 ARM_ADD ("simd", FPU_ARCH_NEON_VFP_ARMV8_1),
30821 ARM_EXT ("crypto", FPU_ARCH_CRYPTO_NEON_VFP_ARMV8_1,
30822 ARM_FEATURE_COPROC (FPU_CRYPTO_ARMV8)),
30824 /* Armv8-a does not allow an FP implementation without SIMD, so the user
30825 should use the +simd option to turn on FP. */
30826 ARM_REMOVE ("fp", ALL_FP),
30827 ARM_ADD ("sb", ARM_FEATURE_CORE_HIGH (ARM_EXT2_SB)),
30828 ARM_ADD ("predres", ARM_FEATURE_CORE_HIGH (ARM_EXT2_PREDRES)),
30829 { NULL, 0, ARM_ARCH_NONE, ARM_ARCH_NONE }
30832 static const struct arm_ext_table armv82a_ext_table[] =
30834 ARM_ADD ("simd", FPU_ARCH_NEON_VFP_ARMV8_1),
30835 ARM_ADD ("fp16", FPU_ARCH_NEON_VFP_ARMV8_2_FP16),
30836 ARM_ADD ("fp16fml", FPU_ARCH_NEON_VFP_ARMV8_2_FP16FML),
30837 ARM_EXT ("crypto", FPU_ARCH_CRYPTO_NEON_VFP_ARMV8_1,
30838 ARM_FEATURE_COPROC (FPU_CRYPTO_ARMV8)),
30839 ARM_ADD ("dotprod", FPU_ARCH_DOTPROD_NEON_VFP_ARMV8),
30841 /* Armv8-a does not allow an FP implementation without SIMD, so the user
30842 should use the +simd option to turn on FP. */
30843 ARM_REMOVE ("fp", ALL_FP),
30844 ARM_ADD ("sb", ARM_FEATURE_CORE_HIGH (ARM_EXT2_SB)),
30845 ARM_ADD ("predres", ARM_FEATURE_CORE_HIGH (ARM_EXT2_PREDRES)),
30846 { NULL, 0, ARM_ARCH_NONE, ARM_ARCH_NONE }
30849 static const struct arm_ext_table armv84a_ext_table[] =
30851 ARM_ADD ("simd", FPU_ARCH_DOTPROD_NEON_VFP_ARMV8),
30852 ARM_ADD ("fp16", FPU_ARCH_NEON_VFP_ARMV8_4_FP16FML),
30853 ARM_EXT ("crypto", FPU_ARCH_CRYPTO_NEON_VFP_ARMV8_4,
30854 ARM_FEATURE_COPROC (FPU_CRYPTO_ARMV8)),
30856 /* Armv8-a does not allow an FP implementation without SIMD, so the user
30857 should use the +simd option to turn on FP. */
30858 ARM_REMOVE ("fp", ALL_FP),
30859 ARM_ADD ("sb", ARM_FEATURE_CORE_HIGH (ARM_EXT2_SB)),
30860 ARM_ADD ("predres", ARM_FEATURE_CORE_HIGH (ARM_EXT2_PREDRES)),
30861 { NULL, 0, ARM_ARCH_NONE, ARM_ARCH_NONE }
30864 static const struct arm_ext_table armv85a_ext_table[] =
30866 ARM_ADD ("simd", FPU_ARCH_DOTPROD_NEON_VFP_ARMV8),
30867 ARM_ADD ("fp16", FPU_ARCH_NEON_VFP_ARMV8_4_FP16FML),
30868 ARM_EXT ("crypto", FPU_ARCH_CRYPTO_NEON_VFP_ARMV8_4,
30869 ARM_FEATURE_COPROC (FPU_CRYPTO_ARMV8)),
30871 /* Armv8-a does not allow an FP implementation without SIMD, so the user
30872 should use the +simd option to turn on FP. */
30873 ARM_REMOVE ("fp", ALL_FP),
30874 { NULL, 0, ARM_ARCH_NONE, ARM_ARCH_NONE }
30877 static const struct arm_ext_table armv8m_main_ext_table[] =
30879 ARM_EXT ("dsp", ARM_FEATURE_CORE_LOW (ARM_EXT_V5ExP | ARM_EXT_V6_DSP),
30880 ARM_FEATURE_CORE_LOW (ARM_EXT_V5ExP | ARM_EXT_V6_DSP)),
30881 ARM_EXT ("fp", FPU_ARCH_VFP_V5_SP_D16, ALL_FP),
30882 ARM_ADD ("fp.dp", FPU_ARCH_VFP_V5D16),
30883 { NULL, 0, ARM_ARCH_NONE, ARM_ARCH_NONE }
30886 static const struct arm_ext_table armv8_1m_main_ext_table[] =
30888 ARM_EXT ("dsp", ARM_FEATURE_CORE_LOW (ARM_EXT_V5ExP | ARM_EXT_V6_DSP),
30889 ARM_FEATURE_CORE_LOW (ARM_EXT_V5ExP | ARM_EXT_V6_DSP)),
30891 ARM_FEATURE (0, ARM_EXT2_FP16_INST,
30892 FPU_VFP_V5_SP_D16 | FPU_VFP_EXT_FP16 | FPU_VFP_EXT_FMA),
30895 ARM_FEATURE (0, ARM_EXT2_FP16_INST,
30896 FPU_VFP_V5D16 | FPU_VFP_EXT_FP16 | FPU_VFP_EXT_FMA)),
30897 ARM_EXT ("mve", ARM_FEATURE_COPROC (FPU_MVE),
30898 ARM_FEATURE_COPROC (FPU_MVE | FPU_MVE_FP)),
30900 ARM_FEATURE (0, ARM_EXT2_FP16_INST,
30901 FPU_MVE | FPU_MVE_FP | FPU_VFP_V5_SP_D16 |
30902 FPU_VFP_EXT_FP16 | FPU_VFP_EXT_FMA)),
30903 { NULL, 0, ARM_ARCH_NONE, ARM_ARCH_NONE }
30906 static const struct arm_ext_table armv8r_ext_table[] =
30908 ARM_ADD ("crc", ARCH_CRC_ARMV8),
30909 ARM_ADD ("simd", FPU_ARCH_NEON_VFP_ARMV8),
30910 ARM_EXT ("crypto", FPU_ARCH_CRYPTO_NEON_VFP_ARMV8,
30911 ARM_FEATURE_COPROC (FPU_CRYPTO_ARMV8)),
30912 ARM_REMOVE ("fp", ALL_FP),
30913 ARM_ADD ("fp.sp", FPU_ARCH_VFP_V5_SP_D16),
30914 { NULL, 0, ARM_ARCH_NONE, ARM_ARCH_NONE }
30917 /* This list should, at a minimum, contain all the architecture names
30918 recognized by GCC. */
30919 #define ARM_ARCH_OPT(N, V, DF) { N, sizeof (N) - 1, V, DF, NULL }
30920 #define ARM_ARCH_OPT2(N, V, DF, ext) \
30921 { N, sizeof (N) - 1, V, DF, ext##_ext_table }
30923 static const struct arm_arch_option_table arm_archs[] =
30925 ARM_ARCH_OPT ("all", ARM_ANY, FPU_ARCH_FPA),
30926 ARM_ARCH_OPT ("armv1", ARM_ARCH_V1, FPU_ARCH_FPA),
30927 ARM_ARCH_OPT ("armv2", ARM_ARCH_V2, FPU_ARCH_FPA),
30928 ARM_ARCH_OPT ("armv2a", ARM_ARCH_V2S, FPU_ARCH_FPA),
30929 ARM_ARCH_OPT ("armv2s", ARM_ARCH_V2S, FPU_ARCH_FPA),
30930 ARM_ARCH_OPT ("armv3", ARM_ARCH_V3, FPU_ARCH_FPA),
30931 ARM_ARCH_OPT ("armv3m", ARM_ARCH_V3M, FPU_ARCH_FPA),
30932 ARM_ARCH_OPT ("armv4", ARM_ARCH_V4, FPU_ARCH_FPA),
30933 ARM_ARCH_OPT ("armv4xm", ARM_ARCH_V4xM, FPU_ARCH_FPA),
30934 ARM_ARCH_OPT ("armv4t", ARM_ARCH_V4T, FPU_ARCH_FPA),
30935 ARM_ARCH_OPT ("armv4txm", ARM_ARCH_V4TxM, FPU_ARCH_FPA),
30936 ARM_ARCH_OPT ("armv5", ARM_ARCH_V5, FPU_ARCH_VFP),
30937 ARM_ARCH_OPT ("armv5t", ARM_ARCH_V5T, FPU_ARCH_VFP),
30938 ARM_ARCH_OPT ("armv5txm", ARM_ARCH_V5TxM, FPU_ARCH_VFP),
30939 ARM_ARCH_OPT2 ("armv5te", ARM_ARCH_V5TE, FPU_ARCH_VFP, armv5te),
30940 ARM_ARCH_OPT2 ("armv5texp", ARM_ARCH_V5TExP, FPU_ARCH_VFP, armv5te),
30941 ARM_ARCH_OPT2 ("armv5tej", ARM_ARCH_V5TEJ, FPU_ARCH_VFP, armv5te),
30942 ARM_ARCH_OPT2 ("armv6", ARM_ARCH_V6, FPU_ARCH_VFP, armv5te),
30943 ARM_ARCH_OPT2 ("armv6j", ARM_ARCH_V6, FPU_ARCH_VFP, armv5te),
30944 ARM_ARCH_OPT2 ("armv6k", ARM_ARCH_V6K, FPU_ARCH_VFP, armv5te),
30945 ARM_ARCH_OPT2 ("armv6z", ARM_ARCH_V6Z, FPU_ARCH_VFP, armv5te),
30946 /* The official spelling of this variant is ARMv6KZ, the name "armv6zk" is
30947 kept to preserve existing behaviour. */
30948 ARM_ARCH_OPT2 ("armv6kz", ARM_ARCH_V6KZ, FPU_ARCH_VFP, armv5te),
30949 ARM_ARCH_OPT2 ("armv6zk", ARM_ARCH_V6KZ, FPU_ARCH_VFP, armv5te),
30950 ARM_ARCH_OPT2 ("armv6t2", ARM_ARCH_V6T2, FPU_ARCH_VFP, armv5te),
30951 ARM_ARCH_OPT2 ("armv6kt2", ARM_ARCH_V6KT2, FPU_ARCH_VFP, armv5te),
30952 ARM_ARCH_OPT2 ("armv6zt2", ARM_ARCH_V6ZT2, FPU_ARCH_VFP, armv5te),
30953 /* The official spelling of this variant is ARMv6KZ, the name "armv6zkt2" is
30954 kept to preserve existing behaviour. */
30955 ARM_ARCH_OPT2 ("armv6kzt2", ARM_ARCH_V6KZT2, FPU_ARCH_VFP, armv5te),
30956 ARM_ARCH_OPT2 ("armv6zkt2", ARM_ARCH_V6KZT2, FPU_ARCH_VFP, armv5te),
30957 ARM_ARCH_OPT ("armv6-m", ARM_ARCH_V6M, FPU_ARCH_VFP),
30958 ARM_ARCH_OPT ("armv6s-m", ARM_ARCH_V6SM, FPU_ARCH_VFP),
30959 ARM_ARCH_OPT2 ("armv7", ARM_ARCH_V7, FPU_ARCH_VFP, armv7),
30960 /* The official spelling of the ARMv7 profile variants is the dashed form.
30961 Accept the non-dashed form for compatibility with old toolchains. */
30962 ARM_ARCH_OPT2 ("armv7a", ARM_ARCH_V7A, FPU_ARCH_VFP, armv7a),
30963 ARM_ARCH_OPT2 ("armv7ve", ARM_ARCH_V7VE, FPU_ARCH_VFP, armv7ve),
30964 ARM_ARCH_OPT2 ("armv7r", ARM_ARCH_V7R, FPU_ARCH_VFP, armv7r),
30965 ARM_ARCH_OPT ("armv7m", ARM_ARCH_V7M, FPU_ARCH_VFP),
30966 ARM_ARCH_OPT2 ("armv7-a", ARM_ARCH_V7A, FPU_ARCH_VFP, armv7a),
30967 ARM_ARCH_OPT2 ("armv7-r", ARM_ARCH_V7R, FPU_ARCH_VFP, armv7r),
30968 ARM_ARCH_OPT ("armv7-m", ARM_ARCH_V7M, FPU_ARCH_VFP),
30969 ARM_ARCH_OPT2 ("armv7e-m", ARM_ARCH_V7EM, FPU_ARCH_VFP, armv7em),
30970 ARM_ARCH_OPT ("armv8-m.base", ARM_ARCH_V8M_BASE, FPU_ARCH_VFP),
30971 ARM_ARCH_OPT2 ("armv8-m.main", ARM_ARCH_V8M_MAIN, FPU_ARCH_VFP,
30973 ARM_ARCH_OPT2 ("armv8.1-m.main", ARM_ARCH_V8_1M_MAIN, FPU_ARCH_VFP,
30975 ARM_ARCH_OPT2 ("armv8-a", ARM_ARCH_V8A, FPU_ARCH_VFP, armv8a),
30976 ARM_ARCH_OPT2 ("armv8.1-a", ARM_ARCH_V8_1A, FPU_ARCH_VFP, armv81a),
30977 ARM_ARCH_OPT2 ("armv8.2-a", ARM_ARCH_V8_2A, FPU_ARCH_VFP, armv82a),
30978 ARM_ARCH_OPT2 ("armv8.3-a", ARM_ARCH_V8_3A, FPU_ARCH_VFP, armv82a),
30979 ARM_ARCH_OPT2 ("armv8-r", ARM_ARCH_V8R, FPU_ARCH_VFP, armv8r),
30980 ARM_ARCH_OPT2 ("armv8.4-a", ARM_ARCH_V8_4A, FPU_ARCH_VFP, armv84a),
30981 ARM_ARCH_OPT2 ("armv8.5-a", ARM_ARCH_V8_5A, FPU_ARCH_VFP, armv85a),
30982 ARM_ARCH_OPT ("xscale", ARM_ARCH_XSCALE, FPU_ARCH_VFP),
30983 ARM_ARCH_OPT ("iwmmxt", ARM_ARCH_IWMMXT, FPU_ARCH_VFP),
30984 ARM_ARCH_OPT ("iwmmxt2", ARM_ARCH_IWMMXT2, FPU_ARCH_VFP),
30985 { NULL, 0, ARM_ARCH_NONE, ARM_ARCH_NONE, NULL }
30987 #undef ARM_ARCH_OPT
30989 /* ISA extensions in the co-processor and main instruction set space. */
30991 struct arm_option_extension_value_table
30995 const arm_feature_set merge_value;
30996 const arm_feature_set clear_value;
30997 /* List of architectures for which an extension is available. ARM_ARCH_NONE
30998 indicates that an extension is available for all architectures while
30999 ARM_ANY marks an empty entry. */
31000 const arm_feature_set allowed_archs[2];
31003 /* The following table must be in alphabetical order with a NULL last entry. */
31005 #define ARM_EXT_OPT(N, M, C, AA) { N, sizeof (N) - 1, M, C, { AA, ARM_ANY } }
31006 #define ARM_EXT_OPT2(N, M, C, AA1, AA2) { N, sizeof (N) - 1, M, C, {AA1, AA2} }
31008 /* DEPRECATED: Refrain from using this table to add any new extensions, instead
31009 use the context sensitive approach using arm_ext_table's. */
31010 static const struct arm_option_extension_value_table arm_extensions[] =
31012 ARM_EXT_OPT ("crc", ARCH_CRC_ARMV8, ARM_FEATURE_COPROC (CRC_EXT_ARMV8),
31013 ARM_FEATURE_CORE_LOW (ARM_EXT_V8)),
31014 ARM_EXT_OPT ("crypto", FPU_ARCH_CRYPTO_NEON_VFP_ARMV8,
31015 ARM_FEATURE_COPROC (FPU_CRYPTO_ARMV8),
31016 ARM_FEATURE_CORE_LOW (ARM_EXT_V8)),
31017 ARM_EXT_OPT ("dotprod", FPU_ARCH_DOTPROD_NEON_VFP_ARMV8,
31018 ARM_FEATURE_COPROC (FPU_NEON_EXT_DOTPROD),
31020 ARM_EXT_OPT ("dsp", ARM_FEATURE_CORE_LOW (ARM_EXT_V5ExP | ARM_EXT_V6_DSP),
31021 ARM_FEATURE_CORE_LOW (ARM_EXT_V5ExP | ARM_EXT_V6_DSP),
31022 ARM_FEATURE_CORE (ARM_EXT_V7M, ARM_EXT2_V8M)),
31023 ARM_EXT_OPT ("fp", FPU_ARCH_VFP_ARMV8, ARM_FEATURE_COPROC (FPU_VFP_ARMV8),
31024 ARM_FEATURE_CORE_LOW (ARM_EXT_V8)),
31025 ARM_EXT_OPT ("fp16", ARM_FEATURE_CORE_HIGH (ARM_EXT2_FP16_INST),
31026 ARM_FEATURE_CORE_HIGH (ARM_EXT2_FP16_INST),
31028 ARM_EXT_OPT ("fp16fml", ARM_FEATURE_CORE_HIGH (ARM_EXT2_FP16_INST
31029 | ARM_EXT2_FP16_FML),
31030 ARM_FEATURE_CORE_HIGH (ARM_EXT2_FP16_INST
31031 | ARM_EXT2_FP16_FML),
31033 ARM_EXT_OPT2 ("idiv", ARM_FEATURE_CORE_LOW (ARM_EXT_ADIV | ARM_EXT_DIV),
31034 ARM_FEATURE_CORE_LOW (ARM_EXT_ADIV | ARM_EXT_DIV),
31035 ARM_FEATURE_CORE_LOW (ARM_EXT_V7A),
31036 ARM_FEATURE_CORE_LOW (ARM_EXT_V7R)),
31037 /* Duplicate entry for the purpose of allowing ARMv7 to match in presence of
31038 Thumb divide instruction. Due to this having the same name as the
31039 previous entry, this will be ignored when doing command-line parsing and
31040 only considered by build attribute selection code. */
31041 ARM_EXT_OPT ("idiv", ARM_FEATURE_CORE_LOW (ARM_EXT_DIV),
31042 ARM_FEATURE_CORE_LOW (ARM_EXT_DIV),
31043 ARM_FEATURE_CORE_LOW (ARM_EXT_V7)),
31044 ARM_EXT_OPT ("iwmmxt",ARM_FEATURE_COPROC (ARM_CEXT_IWMMXT),
31045 ARM_FEATURE_COPROC (ARM_CEXT_IWMMXT), ARM_ARCH_NONE),
31046 ARM_EXT_OPT ("iwmmxt2", ARM_FEATURE_COPROC (ARM_CEXT_IWMMXT2),
31047 ARM_FEATURE_COPROC (ARM_CEXT_IWMMXT2), ARM_ARCH_NONE),
31048 ARM_EXT_OPT ("maverick", ARM_FEATURE_COPROC (ARM_CEXT_MAVERICK),
31049 ARM_FEATURE_COPROC (ARM_CEXT_MAVERICK), ARM_ARCH_NONE),
31050 ARM_EXT_OPT2 ("mp", ARM_FEATURE_CORE_LOW (ARM_EXT_MP),
31051 ARM_FEATURE_CORE_LOW (ARM_EXT_MP),
31052 ARM_FEATURE_CORE_LOW (ARM_EXT_V7A),
31053 ARM_FEATURE_CORE_LOW (ARM_EXT_V7R)),
31054 ARM_EXT_OPT ("os", ARM_FEATURE_CORE_LOW (ARM_EXT_OS),
31055 ARM_FEATURE_CORE_LOW (ARM_EXT_OS),
31056 ARM_FEATURE_CORE_LOW (ARM_EXT_V6M)),
31057 ARM_EXT_OPT ("pan", ARM_FEATURE_CORE_HIGH (ARM_EXT2_PAN),
31058 ARM_FEATURE (ARM_EXT_V8, ARM_EXT2_PAN, 0),
31059 ARM_FEATURE_CORE_HIGH (ARM_EXT2_V8A)),
31060 ARM_EXT_OPT ("predres", ARM_FEATURE_CORE_HIGH (ARM_EXT2_PREDRES),
31061 ARM_FEATURE_CORE_HIGH (ARM_EXT2_PREDRES),
31063 ARM_EXT_OPT ("ras", ARM_FEATURE_CORE_HIGH (ARM_EXT2_RAS),
31064 ARM_FEATURE (ARM_EXT_V8, ARM_EXT2_RAS, 0),
31065 ARM_FEATURE_CORE_HIGH (ARM_EXT2_V8A)),
31066 ARM_EXT_OPT ("rdma", FPU_ARCH_NEON_VFP_ARMV8_1,
31067 ARM_FEATURE_COPROC (FPU_NEON_ARMV8 | FPU_NEON_EXT_RDMA),
31068 ARM_FEATURE_CORE_HIGH (ARM_EXT2_V8A)),
31069 ARM_EXT_OPT ("sb", ARM_FEATURE_CORE_HIGH (ARM_EXT2_SB),
31070 ARM_FEATURE_CORE_HIGH (ARM_EXT2_SB),
31072 ARM_EXT_OPT2 ("sec", ARM_FEATURE_CORE_LOW (ARM_EXT_SEC),
31073 ARM_FEATURE_CORE_LOW (ARM_EXT_SEC),
31074 ARM_FEATURE_CORE_LOW (ARM_EXT_V6K),
31075 ARM_FEATURE_CORE_LOW (ARM_EXT_V7A)),
31076 ARM_EXT_OPT ("simd", FPU_ARCH_NEON_VFP_ARMV8,
31077 ARM_FEATURE_COPROC (FPU_NEON_ARMV8),
31078 ARM_FEATURE_CORE_LOW (ARM_EXT_V8)),
31079 ARM_EXT_OPT ("virt", ARM_FEATURE_CORE_LOW (ARM_EXT_VIRT | ARM_EXT_ADIV
31081 ARM_FEATURE_CORE_LOW (ARM_EXT_VIRT),
31082 ARM_FEATURE_CORE_LOW (ARM_EXT_V7A)),
31083 ARM_EXT_OPT ("xscale",ARM_FEATURE_COPROC (ARM_CEXT_XSCALE),
31084 ARM_FEATURE_COPROC (ARM_CEXT_XSCALE), ARM_ARCH_NONE),
31085 { NULL, 0, ARM_ARCH_NONE, ARM_ARCH_NONE, { ARM_ARCH_NONE, ARM_ARCH_NONE } }
31089 /* ISA floating-point and Advanced SIMD extensions. */
31090 struct arm_option_fpu_value_table
31093 const arm_feature_set value;
31096 /* This list should, at a minimum, contain all the fpu names
31097 recognized by GCC. */
31098 static const struct arm_option_fpu_value_table arm_fpus[] =
31100 {"softfpa", FPU_NONE},
31101 {"fpe", FPU_ARCH_FPE},
31102 {"fpe2", FPU_ARCH_FPE},
31103 {"fpe3", FPU_ARCH_FPA}, /* Third release supports LFM/SFM. */
31104 {"fpa", FPU_ARCH_FPA},
31105 {"fpa10", FPU_ARCH_FPA},
31106 {"fpa11", FPU_ARCH_FPA},
31107 {"arm7500fe", FPU_ARCH_FPA},
31108 {"softvfp", FPU_ARCH_VFP},
31109 {"softvfp+vfp", FPU_ARCH_VFP_V2},
31110 {"vfp", FPU_ARCH_VFP_V2},
31111 {"vfp9", FPU_ARCH_VFP_V2},
31112 {"vfp3", FPU_ARCH_VFP_V3}, /* Undocumented, use vfpv3. */
31113 {"vfp10", FPU_ARCH_VFP_V2},
31114 {"vfp10-r0", FPU_ARCH_VFP_V1},
31115 {"vfpxd", FPU_ARCH_VFP_V1xD},
31116 {"vfpv2", FPU_ARCH_VFP_V2},
31117 {"vfpv3", FPU_ARCH_VFP_V3},
31118 {"vfpv3-fp16", FPU_ARCH_VFP_V3_FP16},
31119 {"vfpv3-d16", FPU_ARCH_VFP_V3D16},
31120 {"vfpv3-d16-fp16", FPU_ARCH_VFP_V3D16_FP16},
31121 {"vfpv3xd", FPU_ARCH_VFP_V3xD},
31122 {"vfpv3xd-fp16", FPU_ARCH_VFP_V3xD_FP16},
31123 {"arm1020t", FPU_ARCH_VFP_V1},
31124 {"arm1020e", FPU_ARCH_VFP_V2},
31125 {"arm1136jfs", FPU_ARCH_VFP_V2}, /* Undocumented, use arm1136jf-s. */
31126 {"arm1136jf-s", FPU_ARCH_VFP_V2},
31127 {"maverick", FPU_ARCH_MAVERICK},
31128 {"neon", FPU_ARCH_VFP_V3_PLUS_NEON_V1},
31129 {"neon-vfpv3", FPU_ARCH_VFP_V3_PLUS_NEON_V1},
31130 {"neon-fp16", FPU_ARCH_NEON_FP16},
31131 {"vfpv4", FPU_ARCH_VFP_V4},
31132 {"vfpv4-d16", FPU_ARCH_VFP_V4D16},
31133 {"fpv4-sp-d16", FPU_ARCH_VFP_V4_SP_D16},
31134 {"fpv5-d16", FPU_ARCH_VFP_V5D16},
31135 {"fpv5-sp-d16", FPU_ARCH_VFP_V5_SP_D16},
31136 {"neon-vfpv4", FPU_ARCH_NEON_VFP_V4},
31137 {"fp-armv8", FPU_ARCH_VFP_ARMV8},
31138 {"neon-fp-armv8", FPU_ARCH_NEON_VFP_ARMV8},
31139 {"crypto-neon-fp-armv8",
31140 FPU_ARCH_CRYPTO_NEON_VFP_ARMV8},
31141 {"neon-fp-armv8.1", FPU_ARCH_NEON_VFP_ARMV8_1},
31142 {"crypto-neon-fp-armv8.1",
31143 FPU_ARCH_CRYPTO_NEON_VFP_ARMV8_1},
31144 {NULL, ARM_ARCH_NONE}
31147 struct arm_option_value_table
31153 static const struct arm_option_value_table arm_float_abis[] =
31155 {"hard", ARM_FLOAT_ABI_HARD},
31156 {"softfp", ARM_FLOAT_ABI_SOFTFP},
31157 {"soft", ARM_FLOAT_ABI_SOFT},
31162 /* We only know how to output GNU and ver 4/5 (AAELF) formats. */
31163 static const struct arm_option_value_table arm_eabis[] =
31165 {"gnu", EF_ARM_EABI_UNKNOWN},
31166 {"4", EF_ARM_EABI_VER4},
31167 {"5", EF_ARM_EABI_VER5},
31172 struct arm_long_option_table
31174 const char * option; /* Substring to match. */
31175 const char * help; /* Help information. */
31176 int (* func) (const char * subopt); /* Function to decode sub-option. */
31177 const char * deprecated; /* If non-null, print this message. */
31181 arm_parse_extension (const char *str, const arm_feature_set *opt_set,
31182 arm_feature_set *ext_set,
31183 const struct arm_ext_table *ext_table)
31185 /* We insist on extensions being specified in alphabetical order, and with
31186 extensions being added before being removed. We achieve this by having
31187 the global ARM_EXTENSIONS table in alphabetical order, and using the
31188 ADDING_VALUE variable to indicate whether we are adding an extension (1)
31189 or removing it (0) and only allowing it to change in the order
31191 const struct arm_option_extension_value_table * opt = NULL;
31192 const arm_feature_set arm_any = ARM_ANY;
31193 int adding_value = -1;
31195 while (str != NULL && *str != 0)
31202 as_bad (_("invalid architectural extension"));
31207 ext = strchr (str, '+');
31212 len = strlen (str);
31214 if (len >= 2 && strncmp (str, "no", 2) == 0)
31216 if (adding_value != 0)
31219 opt = arm_extensions;
31227 if (adding_value == -1)
31230 opt = arm_extensions;
31232 else if (adding_value != 1)
31234 as_bad (_("must specify extensions to add before specifying "
31235 "those to remove"));
31242 as_bad (_("missing architectural extension"));
31246 gas_assert (adding_value != -1);
31247 gas_assert (opt != NULL);
31249 if (ext_table != NULL)
31251 const struct arm_ext_table * ext_opt = ext_table;
31252 bfd_boolean found = FALSE;
31253 for (; ext_opt->name != NULL; ext_opt++)
31254 if (ext_opt->name_len == len
31255 && strncmp (ext_opt->name, str, len) == 0)
31259 if (ARM_FEATURE_ZERO (ext_opt->merge))
31260 /* TODO: Option not supported. When we remove the
31261 legacy table this case should error out. */
31264 ARM_MERGE_FEATURE_SETS (*ext_set, *ext_set, ext_opt->merge);
31268 if (ARM_FEATURE_ZERO (ext_opt->clear))
31269 /* TODO: Option not supported. When we remove the
31270 legacy table this case should error out. */
31272 ARM_CLEAR_FEATURE (*ext_set, *ext_set, ext_opt->clear);
31284 /* Scan over the options table trying to find an exact match. */
31285 for (; opt->name != NULL; opt++)
31286 if (opt->name_len == len && strncmp (opt->name, str, len) == 0)
31288 int i, nb_allowed_archs =
31289 sizeof (opt->allowed_archs) / sizeof (opt->allowed_archs[0]);
31290 /* Check we can apply the extension to this architecture. */
31291 for (i = 0; i < nb_allowed_archs; i++)
31294 if (ARM_FEATURE_EQUAL (opt->allowed_archs[i], arm_any))
31296 if (ARM_FSET_CPU_SUBSET (opt->allowed_archs[i], *opt_set))
31299 if (i == nb_allowed_archs)
31301 as_bad (_("extension does not apply to the base architecture"));
31305 /* Add or remove the extension. */
31307 ARM_MERGE_FEATURE_SETS (*ext_set, *ext_set, opt->merge_value);
31309 ARM_CLEAR_FEATURE (*ext_set, *ext_set, opt->clear_value);
31311 /* Allowing Thumb division instructions for ARMv7 in autodetection
31312 rely on this break so that duplicate extensions (extensions
31313 with the same name as a previous extension in the list) are not
31314 considered for command-line parsing. */
31318 if (opt->name == NULL)
31320 /* Did we fail to find an extension because it wasn't specified in
31321 alphabetical order, or because it does not exist? */
31323 for (opt = arm_extensions; opt->name != NULL; opt++)
31324 if (opt->name_len == len && strncmp (opt->name, str, len) == 0)
31327 if (opt->name == NULL)
31328 as_bad (_("unknown architectural extension `%s'"), str);
31330 as_bad (_("architectural extensions must be specified in "
31331 "alphabetical order"));
31337 /* We should skip the extension we've just matched the next time
31349 arm_parse_fp16_opt (const char *str)
31351 if (strcasecmp (str, "ieee") == 0)
31352 fp16_format = ARM_FP16_FORMAT_IEEE;
31353 else if (strcasecmp (str, "alternative") == 0)
31354 fp16_format = ARM_FP16_FORMAT_ALTERNATIVE;
31357 as_bad (_("unrecognised float16 format \"%s\""), str);
31365 arm_parse_cpu (const char *str)
31367 const struct arm_cpu_option_table *opt;
31368 const char *ext = strchr (str, '+');
31374 len = strlen (str);
31378 as_bad (_("missing cpu name `%s'"), str);
31382 for (opt = arm_cpus; opt->name != NULL; opt++)
31383 if (opt->name_len == len && strncmp (opt->name, str, len) == 0)
31385 mcpu_cpu_opt = &opt->value;
31386 if (mcpu_ext_opt == NULL)
31387 mcpu_ext_opt = XNEW (arm_feature_set);
31388 *mcpu_ext_opt = opt->ext;
31389 mcpu_fpu_opt = &opt->default_fpu;
31390 if (opt->canonical_name)
31392 gas_assert (sizeof selected_cpu_name > strlen (opt->canonical_name));
31393 strcpy (selected_cpu_name, opt->canonical_name);
31399 if (len >= sizeof selected_cpu_name)
31400 len = (sizeof selected_cpu_name) - 1;
31402 for (i = 0; i < len; i++)
31403 selected_cpu_name[i] = TOUPPER (opt->name[i]);
31404 selected_cpu_name[i] = 0;
31408 return arm_parse_extension (ext, mcpu_cpu_opt, mcpu_ext_opt, NULL);
31413 as_bad (_("unknown cpu `%s'"), str);
31418 arm_parse_arch (const char *str)
31420 const struct arm_arch_option_table *opt;
31421 const char *ext = strchr (str, '+');
31427 len = strlen (str);
31431 as_bad (_("missing architecture name `%s'"), str);
31435 for (opt = arm_archs; opt->name != NULL; opt++)
31436 if (opt->name_len == len && strncmp (opt->name, str, len) == 0)
31438 march_cpu_opt = &opt->value;
31439 if (march_ext_opt == NULL)
31440 march_ext_opt = XNEW (arm_feature_set);
31441 *march_ext_opt = arm_arch_none;
31442 march_fpu_opt = &opt->default_fpu;
31443 strcpy (selected_cpu_name, opt->name);
31446 return arm_parse_extension (ext, march_cpu_opt, march_ext_opt,
31452 as_bad (_("unknown architecture `%s'\n"), str);
31457 arm_parse_fpu (const char * str)
31459 const struct arm_option_fpu_value_table * opt;
31461 for (opt = arm_fpus; opt->name != NULL; opt++)
31462 if (streq (opt->name, str))
31464 mfpu_opt = &opt->value;
31468 as_bad (_("unknown floating point format `%s'\n"), str);
31473 arm_parse_float_abi (const char * str)
31475 const struct arm_option_value_table * opt;
31477 for (opt = arm_float_abis; opt->name != NULL; opt++)
31478 if (streq (opt->name, str))
31480 mfloat_abi_opt = opt->value;
31484 as_bad (_("unknown floating point abi `%s'\n"), str);
31490 arm_parse_eabi (const char * str)
31492 const struct arm_option_value_table *opt;
31494 for (opt = arm_eabis; opt->name != NULL; opt++)
31495 if (streq (opt->name, str))
31497 meabi_flags = opt->value;
31500 as_bad (_("unknown EABI `%s'\n"), str);
31506 arm_parse_it_mode (const char * str)
31508 bfd_boolean ret = TRUE;
31510 if (streq ("arm", str))
31511 implicit_it_mode = IMPLICIT_IT_MODE_ARM;
31512 else if (streq ("thumb", str))
31513 implicit_it_mode = IMPLICIT_IT_MODE_THUMB;
31514 else if (streq ("always", str))
31515 implicit_it_mode = IMPLICIT_IT_MODE_ALWAYS;
31516 else if (streq ("never", str))
31517 implicit_it_mode = IMPLICIT_IT_MODE_NEVER;
31520 as_bad (_("unknown implicit IT mode `%s', should be "\
31521 "arm, thumb, always, or never."), str);
31529 arm_ccs_mode (const char * unused ATTRIBUTE_UNUSED)
31531 codecomposer_syntax = TRUE;
31532 arm_comment_chars[0] = ';';
31533 arm_line_separator_chars[0] = 0;
31537 struct arm_long_option_table arm_long_opts[] =
31539 {"mcpu=", N_("<cpu name>\t assemble for CPU <cpu name>"),
31540 arm_parse_cpu, NULL},
31541 {"march=", N_("<arch name>\t assemble for architecture <arch name>"),
31542 arm_parse_arch, NULL},
31543 {"mfpu=", N_("<fpu name>\t assemble for FPU architecture <fpu name>"),
31544 arm_parse_fpu, NULL},
31545 {"mfloat-abi=", N_("<abi>\t assemble for floating point ABI <abi>"),
31546 arm_parse_float_abi, NULL},
31548 {"meabi=", N_("<ver>\t\t assemble for eabi version <ver>"),
31549 arm_parse_eabi, NULL},
31551 {"mimplicit-it=", N_("<mode>\t controls implicit insertion of IT instructions"),
31552 arm_parse_it_mode, NULL},
31553 {"mccs", N_("\t\t\t TI CodeComposer Studio syntax compatibility mode"),
31554 arm_ccs_mode, NULL},
31556 N_("[ieee|alternative]\n\
31557 set the encoding for half precision floating point "
31558 "numbers to IEEE\n\
31559 or Arm alternative format."),
31560 arm_parse_fp16_opt, NULL },
31561 {NULL, NULL, 0, NULL}
31565 md_parse_option (int c, const char * arg)
31567 struct arm_option_table *opt;
31568 const struct arm_legacy_option_table *fopt;
31569 struct arm_long_option_table *lopt;
31575 target_big_endian = 1;
31581 target_big_endian = 0;
31585 case OPTION_FIX_V4BX:
31593 #endif /* OBJ_ELF */
31596 /* Listing option. Just ignore these, we don't support additional
31601 for (opt = arm_opts; opt->option != NULL; opt++)
31603 if (c == opt->option[0]
31604 && ((arg == NULL && opt->option[1] == 0)
31605 || streq (arg, opt->option + 1)))
31607 /* If the option is deprecated, tell the user. */
31608 if (warn_on_deprecated && opt->deprecated != NULL)
31609 as_tsktsk (_("option `-%c%s' is deprecated: %s"), c,
31610 arg ? arg : "", _(opt->deprecated));
31612 if (opt->var != NULL)
31613 *opt->var = opt->value;
31619 for (fopt = arm_legacy_opts; fopt->option != NULL; fopt++)
31621 if (c == fopt->option[0]
31622 && ((arg == NULL && fopt->option[1] == 0)
31623 || streq (arg, fopt->option + 1)))
31625 /* If the option is deprecated, tell the user. */
31626 if (warn_on_deprecated && fopt->deprecated != NULL)
31627 as_tsktsk (_("option `-%c%s' is deprecated: %s"), c,
31628 arg ? arg : "", _(fopt->deprecated));
31630 if (fopt->var != NULL)
31631 *fopt->var = &fopt->value;
31637 for (lopt = arm_long_opts; lopt->option != NULL; lopt++)
31639 /* These options are expected to have an argument. */
31640 if (c == lopt->option[0]
31642 && strncmp (arg, lopt->option + 1,
31643 strlen (lopt->option + 1)) == 0)
31645 /* If the option is deprecated, tell the user. */
31646 if (warn_on_deprecated && lopt->deprecated != NULL)
31647 as_tsktsk (_("option `-%c%s' is deprecated: %s"), c, arg,
31648 _(lopt->deprecated));
31650 /* Call the sup-option parser. */
31651 return lopt->func (arg + strlen (lopt->option) - 1);
31662 md_show_usage (FILE * fp)
31664 struct arm_option_table *opt;
31665 struct arm_long_option_table *lopt;
31667 fprintf (fp, _(" ARM-specific assembler options:\n"));
31669 for (opt = arm_opts; opt->option != NULL; opt++)
31670 if (opt->help != NULL)
31671 fprintf (fp, " -%-23s%s\n", opt->option, _(opt->help));
31673 for (lopt = arm_long_opts; lopt->option != NULL; lopt++)
31674 if (lopt->help != NULL)
31675 fprintf (fp, " -%s%s\n", lopt->option, _(lopt->help));
31679 -EB assemble code for a big-endian cpu\n"));
31684 -EL assemble code for a little-endian cpu\n"));
31688 --fix-v4bx Allow BX in ARMv4 code\n"));
31692 --fdpic generate an FDPIC object file\n"));
31693 #endif /* OBJ_ELF */
31701 arm_feature_set flags;
31702 } cpu_arch_ver_table;
31704 /* Mapping from CPU features to EABI CPU arch values. Table must be sorted
31705 chronologically for architectures, with an exception for ARMv6-M and
31706 ARMv6S-M due to legacy reasons. No new architecture should have a
31707 special case. This allows for build attribute selection results to be
31708 stable when new architectures are added. */
31709 static const cpu_arch_ver_table cpu_arch_ver[] =
31711 {TAG_CPU_ARCH_PRE_V4, ARM_ARCH_V1},
31712 {TAG_CPU_ARCH_PRE_V4, ARM_ARCH_V2},
31713 {TAG_CPU_ARCH_PRE_V4, ARM_ARCH_V2S},
31714 {TAG_CPU_ARCH_PRE_V4, ARM_ARCH_V3},
31715 {TAG_CPU_ARCH_PRE_V4, ARM_ARCH_V3M},
31716 {TAG_CPU_ARCH_V4, ARM_ARCH_V4xM},
31717 {TAG_CPU_ARCH_V4, ARM_ARCH_V4},
31718 {TAG_CPU_ARCH_V4T, ARM_ARCH_V4TxM},
31719 {TAG_CPU_ARCH_V4T, ARM_ARCH_V4T},
31720 {TAG_CPU_ARCH_V5T, ARM_ARCH_V5xM},
31721 {TAG_CPU_ARCH_V5T, ARM_ARCH_V5},
31722 {TAG_CPU_ARCH_V5T, ARM_ARCH_V5TxM},
31723 {TAG_CPU_ARCH_V5T, ARM_ARCH_V5T},
31724 {TAG_CPU_ARCH_V5TE, ARM_ARCH_V5TExP},
31725 {TAG_CPU_ARCH_V5TE, ARM_ARCH_V5TE},
31726 {TAG_CPU_ARCH_V5TEJ, ARM_ARCH_V5TEJ},
31727 {TAG_CPU_ARCH_V6, ARM_ARCH_V6},
31728 {TAG_CPU_ARCH_V6KZ, ARM_ARCH_V6Z},
31729 {TAG_CPU_ARCH_V6KZ, ARM_ARCH_V6KZ},
31730 {TAG_CPU_ARCH_V6K, ARM_ARCH_V6K},
31731 {TAG_CPU_ARCH_V6T2, ARM_ARCH_V6T2},
31732 {TAG_CPU_ARCH_V6T2, ARM_ARCH_V6KT2},
31733 {TAG_CPU_ARCH_V6T2, ARM_ARCH_V6ZT2},
31734 {TAG_CPU_ARCH_V6T2, ARM_ARCH_V6KZT2},
31736 /* When assembling a file with only ARMv6-M or ARMv6S-M instruction, GNU as
31737 always selected build attributes to match those of ARMv6-M
31738 (resp. ARMv6S-M). However, due to these architectures being a strict
31739 subset of ARMv7-M in terms of instructions available, ARMv7-M attributes
31740 would be selected when fully respecting chronology of architectures.
31741 It is thus necessary to make a special case of ARMv6-M and ARMv6S-M and
31742 move them before ARMv7 architectures. */
31743 {TAG_CPU_ARCH_V6_M, ARM_ARCH_V6M},
31744 {TAG_CPU_ARCH_V6S_M, ARM_ARCH_V6SM},
31746 {TAG_CPU_ARCH_V7, ARM_ARCH_V7},
31747 {TAG_CPU_ARCH_V7, ARM_ARCH_V7A},
31748 {TAG_CPU_ARCH_V7, ARM_ARCH_V7R},
31749 {TAG_CPU_ARCH_V7, ARM_ARCH_V7M},
31750 {TAG_CPU_ARCH_V7, ARM_ARCH_V7VE},
31751 {TAG_CPU_ARCH_V7E_M, ARM_ARCH_V7EM},
31752 {TAG_CPU_ARCH_V8, ARM_ARCH_V8A},
31753 {TAG_CPU_ARCH_V8, ARM_ARCH_V8_1A},
31754 {TAG_CPU_ARCH_V8, ARM_ARCH_V8_2A},
31755 {TAG_CPU_ARCH_V8, ARM_ARCH_V8_3A},
31756 {TAG_CPU_ARCH_V8M_BASE, ARM_ARCH_V8M_BASE},
31757 {TAG_CPU_ARCH_V8M_MAIN, ARM_ARCH_V8M_MAIN},
31758 {TAG_CPU_ARCH_V8R, ARM_ARCH_V8R},
31759 {TAG_CPU_ARCH_V8, ARM_ARCH_V8_4A},
31760 {TAG_CPU_ARCH_V8, ARM_ARCH_V8_5A},
31761 {TAG_CPU_ARCH_V8_1M_MAIN, ARM_ARCH_V8_1M_MAIN},
31762 {-1, ARM_ARCH_NONE}
31765 /* Set an attribute if it has not already been set by the user. */
31768 aeabi_set_attribute_int (int tag, int value)
31771 || tag >= NUM_KNOWN_OBJ_ATTRIBUTES
31772 || !attributes_set_explicitly[tag])
31773 bfd_elf_add_proc_attr_int (stdoutput, tag, value);
31777 aeabi_set_attribute_string (int tag, const char *value)
31780 || tag >= NUM_KNOWN_OBJ_ATTRIBUTES
31781 || !attributes_set_explicitly[tag])
31782 bfd_elf_add_proc_attr_string (stdoutput, tag, value);
31785 /* Return whether features in the *NEEDED feature set are available via
31786 extensions for the architecture whose feature set is *ARCH_FSET. */
31789 have_ext_for_needed_feat_p (const arm_feature_set *arch_fset,
31790 const arm_feature_set *needed)
31792 int i, nb_allowed_archs;
31793 arm_feature_set ext_fset;
31794 const struct arm_option_extension_value_table *opt;
31796 ext_fset = arm_arch_none;
31797 for (opt = arm_extensions; opt->name != NULL; opt++)
31799 /* Extension does not provide any feature we need. */
31800 if (!ARM_CPU_HAS_FEATURE (*needed, opt->merge_value))
31804 sizeof (opt->allowed_archs) / sizeof (opt->allowed_archs[0]);
31805 for (i = 0; i < nb_allowed_archs; i++)
31808 if (ARM_FEATURE_EQUAL (opt->allowed_archs[i], arm_arch_any))
31811 /* Extension is available, add it. */
31812 if (ARM_FSET_CPU_SUBSET (opt->allowed_archs[i], *arch_fset))
31813 ARM_MERGE_FEATURE_SETS (ext_fset, ext_fset, opt->merge_value);
31817 /* Can we enable all features in *needed? */
31818 return ARM_FSET_CPU_SUBSET (*needed, ext_fset);
31821 /* Select value for Tag_CPU_arch and Tag_CPU_arch_profile build attributes for
31822 a given architecture feature set *ARCH_EXT_FSET including extension feature
31823 set *EXT_FSET. Selection logic used depend on EXACT_MATCH:
31824 - if true, check for an exact match of the architecture modulo extensions;
31825 - otherwise, select build attribute value of the first superset
31826 architecture released so that results remains stable when new architectures
31828 For -march/-mcpu=all the build attribute value of the most featureful
31829 architecture is returned. Tag_CPU_arch_profile result is returned in
31833 get_aeabi_cpu_arch_from_fset (const arm_feature_set *arch_ext_fset,
31834 const arm_feature_set *ext_fset,
31835 char *profile, int exact_match)
31837 arm_feature_set arch_fset;
31838 const cpu_arch_ver_table *p_ver, *p_ver_ret = NULL;
31840 /* Select most featureful architecture with all its extensions if building
31841 for -march=all as the feature sets used to set build attributes. */
31842 if (ARM_FEATURE_EQUAL (*arch_ext_fset, arm_arch_any))
31844 /* Force revisiting of decision for each new architecture. */
31845 gas_assert (MAX_TAG_CPU_ARCH <= TAG_CPU_ARCH_V8_1M_MAIN);
31847 return TAG_CPU_ARCH_V8;
31850 ARM_CLEAR_FEATURE (arch_fset, *arch_ext_fset, *ext_fset);
31852 for (p_ver = cpu_arch_ver; p_ver->val != -1; p_ver++)
31854 arm_feature_set known_arch_fset;
31856 ARM_CLEAR_FEATURE (known_arch_fset, p_ver->flags, fpu_any);
31859 /* Base architecture match user-specified architecture and
31860 extensions, eg. ARMv6S-M matching -march=armv6-m+os. */
31861 if (ARM_FEATURE_EQUAL (*arch_ext_fset, known_arch_fset))
31866 /* Base architecture match user-specified architecture only
31867 (eg. ARMv6-M in the same case as above). Record it in case we
31868 find a match with above condition. */
31869 else if (p_ver_ret == NULL
31870 && ARM_FEATURE_EQUAL (arch_fset, known_arch_fset))
31876 /* Architecture has all features wanted. */
31877 if (ARM_FSET_CPU_SUBSET (arch_fset, known_arch_fset))
31879 arm_feature_set added_fset;
31881 /* Compute features added by this architecture over the one
31882 recorded in p_ver_ret. */
31883 if (p_ver_ret != NULL)
31884 ARM_CLEAR_FEATURE (added_fset, known_arch_fset,
31886 /* First architecture that match incl. with extensions, or the
31887 only difference in features over the recorded match is
31888 features that were optional and are now mandatory. */
31889 if (p_ver_ret == NULL
31890 || ARM_FSET_CPU_SUBSET (added_fset, arch_fset))
31896 else if (p_ver_ret == NULL)
31898 arm_feature_set needed_ext_fset;
31900 ARM_CLEAR_FEATURE (needed_ext_fset, arch_fset, known_arch_fset);
31902 /* Architecture has all features needed when using some
31903 extensions. Record it and continue searching in case there
31904 exist an architecture providing all needed features without
31905 the need for extensions (eg. ARMv6S-M Vs ARMv6-M with
31907 if (have_ext_for_needed_feat_p (&known_arch_fset,
31914 if (p_ver_ret == NULL)
31918 /* Tag_CPU_arch_profile. */
31919 if (ARM_CPU_HAS_FEATURE (p_ver_ret->flags, arm_ext_v7a)
31920 || ARM_CPU_HAS_FEATURE (p_ver_ret->flags, arm_ext_v8)
31921 || (ARM_CPU_HAS_FEATURE (p_ver_ret->flags, arm_ext_atomics)
31922 && !ARM_CPU_HAS_FEATURE (p_ver_ret->flags, arm_ext_v8m_m_only)))
31924 else if (ARM_CPU_HAS_FEATURE (p_ver_ret->flags, arm_ext_v7r))
31926 else if (ARM_CPU_HAS_FEATURE (p_ver_ret->flags, arm_ext_m))
31930 return p_ver_ret->val;
31933 /* Set the public EABI object attributes. */
31936 aeabi_set_public_attributes (void)
31938 char profile = '\0';
31941 int fp16_optional = 0;
31942 int skip_exact_match = 0;
31943 arm_feature_set flags, flags_arch, flags_ext;
31945 /* Autodetection mode, choose the architecture based the instructions
31947 if (no_cpu_selected ())
31949 ARM_MERGE_FEATURE_SETS (flags, arm_arch_used, thumb_arch_used);
31951 if (ARM_CPU_HAS_FEATURE (arm_arch_used, arm_arch_any))
31952 ARM_MERGE_FEATURE_SETS (flags, flags, arm_ext_v1);
31954 if (ARM_CPU_HAS_FEATURE (thumb_arch_used, arm_arch_any))
31955 ARM_MERGE_FEATURE_SETS (flags, flags, arm_ext_v4t);
31957 /* Code run during relaxation relies on selected_cpu being set. */
31958 ARM_CLEAR_FEATURE (flags_arch, flags, fpu_any);
31959 flags_ext = arm_arch_none;
31960 ARM_CLEAR_FEATURE (selected_arch, flags_arch, flags_ext);
31961 selected_ext = flags_ext;
31962 selected_cpu = flags;
31964 /* Otherwise, choose the architecture based on the capabilities of the
31968 ARM_MERGE_FEATURE_SETS (flags_arch, selected_arch, selected_ext);
31969 ARM_CLEAR_FEATURE (flags_arch, flags_arch, fpu_any);
31970 flags_ext = selected_ext;
31971 flags = selected_cpu;
31973 ARM_MERGE_FEATURE_SETS (flags, flags, selected_fpu);
31975 /* Allow the user to override the reported architecture. */
31976 if (!ARM_FEATURE_ZERO (selected_object_arch))
31978 ARM_CLEAR_FEATURE (flags_arch, selected_object_arch, fpu_any);
31979 flags_ext = arm_arch_none;
31982 skip_exact_match = ARM_FEATURE_EQUAL (selected_cpu, arm_arch_any);
31984 /* When this function is run again after relaxation has happened there is no
31985 way to determine whether an architecture or CPU was specified by the user:
31986 - selected_cpu is set above for relaxation to work;
31987 - march_cpu_opt is not set if only -mcpu or .cpu is used;
31988 - mcpu_cpu_opt is set to arm_arch_any for autodetection.
31989 Therefore, if not in -march=all case we first try an exact match and fall
31990 back to autodetection. */
31991 if (!skip_exact_match)
31992 arch = get_aeabi_cpu_arch_from_fset (&flags_arch, &flags_ext, &profile, 1);
31994 arch = get_aeabi_cpu_arch_from_fset (&flags_arch, &flags_ext, &profile, 0);
31996 as_bad (_("no architecture contains all the instructions used\n"));
31998 /* Tag_CPU_name. */
31999 if (selected_cpu_name[0])
32003 q = selected_cpu_name;
32004 if (strncmp (q, "armv", 4) == 0)
32009 for (i = 0; q[i]; i++)
32010 q[i] = TOUPPER (q[i]);
32012 aeabi_set_attribute_string (Tag_CPU_name, q);
32015 /* Tag_CPU_arch. */
32016 aeabi_set_attribute_int (Tag_CPU_arch, arch);
32018 /* Tag_CPU_arch_profile. */
32019 if (profile != '\0')
32020 aeabi_set_attribute_int (Tag_CPU_arch_profile, profile);
32022 /* Tag_DSP_extension. */
32023 if (ARM_CPU_HAS_FEATURE (selected_ext, arm_ext_dsp))
32024 aeabi_set_attribute_int (Tag_DSP_extension, 1);
32026 ARM_CLEAR_FEATURE (flags_arch, flags, fpu_any);
32027 /* Tag_ARM_ISA_use. */
32028 if (ARM_CPU_HAS_FEATURE (flags, arm_ext_v1)
32029 || ARM_FEATURE_ZERO (flags_arch))
32030 aeabi_set_attribute_int (Tag_ARM_ISA_use, 1);
32032 /* Tag_THUMB_ISA_use. */
32033 if (ARM_CPU_HAS_FEATURE (flags, arm_ext_v4t)
32034 || ARM_FEATURE_ZERO (flags_arch))
32038 if (!ARM_CPU_HAS_FEATURE (flags, arm_ext_v8)
32039 && ARM_CPU_HAS_FEATURE (flags, arm_ext_v8m_m_only))
32041 else if (ARM_CPU_HAS_FEATURE (flags, arm_arch_t2))
32045 aeabi_set_attribute_int (Tag_THUMB_ISA_use, thumb_isa_use);
32048 /* Tag_VFP_arch. */
32049 if (ARM_CPU_HAS_FEATURE (flags, fpu_vfp_ext_armv8xd))
32050 aeabi_set_attribute_int (Tag_VFP_arch,
32051 ARM_CPU_HAS_FEATURE (flags, fpu_vfp_ext_d32)
32053 else if (ARM_CPU_HAS_FEATURE (flags, fpu_vfp_ext_fma))
32054 aeabi_set_attribute_int (Tag_VFP_arch,
32055 ARM_CPU_HAS_FEATURE (flags, fpu_vfp_ext_d32)
32057 else if (ARM_CPU_HAS_FEATURE (flags, fpu_vfp_ext_d32))
32060 aeabi_set_attribute_int (Tag_VFP_arch, 3);
32062 else if (ARM_CPU_HAS_FEATURE (flags, fpu_vfp_ext_v3xd))
32064 aeabi_set_attribute_int (Tag_VFP_arch, 4);
32067 else if (ARM_CPU_HAS_FEATURE (flags, fpu_vfp_ext_v2))
32068 aeabi_set_attribute_int (Tag_VFP_arch, 2);
32069 else if (ARM_CPU_HAS_FEATURE (flags, fpu_vfp_ext_v1)
32070 || ARM_CPU_HAS_FEATURE (flags, fpu_vfp_ext_v1xd))
32071 aeabi_set_attribute_int (Tag_VFP_arch, 1);
32073 /* Tag_ABI_HardFP_use. */
32074 if (ARM_CPU_HAS_FEATURE (flags, fpu_vfp_ext_v1xd)
32075 && !ARM_CPU_HAS_FEATURE (flags, fpu_vfp_ext_v1))
32076 aeabi_set_attribute_int (Tag_ABI_HardFP_use, 1);
32078 /* Tag_WMMX_arch. */
32079 if (ARM_CPU_HAS_FEATURE (flags, arm_cext_iwmmxt2))
32080 aeabi_set_attribute_int (Tag_WMMX_arch, 2);
32081 else if (ARM_CPU_HAS_FEATURE (flags, arm_cext_iwmmxt))
32082 aeabi_set_attribute_int (Tag_WMMX_arch, 1);
32084 /* Tag_Advanced_SIMD_arch (formerly Tag_NEON_arch). */
32085 if (ARM_CPU_HAS_FEATURE (flags, fpu_neon_ext_v8_1))
32086 aeabi_set_attribute_int (Tag_Advanced_SIMD_arch, 4);
32087 else if (ARM_CPU_HAS_FEATURE (flags, fpu_neon_ext_armv8))
32088 aeabi_set_attribute_int (Tag_Advanced_SIMD_arch, 3);
32089 else if (ARM_CPU_HAS_FEATURE (flags, fpu_neon_ext_v1))
32091 if (ARM_CPU_HAS_FEATURE (flags, fpu_neon_ext_fma))
32093 aeabi_set_attribute_int (Tag_Advanced_SIMD_arch, 2);
32097 aeabi_set_attribute_int (Tag_Advanced_SIMD_arch, 1);
32102 if (ARM_CPU_HAS_FEATURE (flags, mve_fp_ext))
32103 aeabi_set_attribute_int (Tag_MVE_arch, 2);
32104 else if (ARM_CPU_HAS_FEATURE (flags, mve_ext))
32105 aeabi_set_attribute_int (Tag_MVE_arch, 1);
32107 /* Tag_VFP_HP_extension (formerly Tag_NEON_FP16_arch). */
32108 if (ARM_CPU_HAS_FEATURE (flags, fpu_vfp_fp16) && fp16_optional)
32109 aeabi_set_attribute_int (Tag_VFP_HP_extension, 1);
32113 We set Tag_DIV_use to two when integer divide instructions have been used
32114 in ARM state, or when Thumb integer divide instructions have been used,
32115 but we have no architecture profile set, nor have we any ARM instructions.
32117 For ARMv8-A and ARMv8-M we set the tag to 0 as integer divide is implied
32118 by the base architecture.
32120 For new architectures we will have to check these tests. */
32121 gas_assert (arch <= TAG_CPU_ARCH_V8_1M_MAIN);
32122 if (ARM_CPU_HAS_FEATURE (flags, arm_ext_v8)
32123 || ARM_CPU_HAS_FEATURE (flags, arm_ext_v8m))
32124 aeabi_set_attribute_int (Tag_DIV_use, 0);
32125 else if (ARM_CPU_HAS_FEATURE (flags, arm_ext_adiv)
32126 || (profile == '\0'
32127 && ARM_CPU_HAS_FEATURE (flags, arm_ext_div)
32128 && !ARM_CPU_HAS_FEATURE (arm_arch_used, arm_arch_any)))
32129 aeabi_set_attribute_int (Tag_DIV_use, 2);
32131 /* Tag_MP_extension_use. */
32132 if (ARM_CPU_HAS_FEATURE (flags, arm_ext_mp))
32133 aeabi_set_attribute_int (Tag_MPextension_use, 1);
32135 /* Tag Virtualization_use. */
32136 if (ARM_CPU_HAS_FEATURE (flags, arm_ext_sec))
32138 if (ARM_CPU_HAS_FEATURE (flags, arm_ext_virt))
32141 aeabi_set_attribute_int (Tag_Virtualization_use, virt_sec);
32143 if (fp16_format != ARM_FP16_FORMAT_DEFAULT)
32144 aeabi_set_attribute_int (Tag_ABI_FP_16bit_format, fp16_format);
32147 /* Post relaxation hook. Recompute ARM attributes now that relaxation is
32148 finished and free extension feature bits which will not be used anymore. */
32151 arm_md_post_relax (void)
32153 aeabi_set_public_attributes ();
32154 XDELETE (mcpu_ext_opt);
32155 mcpu_ext_opt = NULL;
32156 XDELETE (march_ext_opt);
32157 march_ext_opt = NULL;
32160 /* Add the default contents for the .ARM.attributes section. */
32165 if (EF_ARM_EABI_VERSION (meabi_flags) < EF_ARM_EABI_VER4)
32168 aeabi_set_public_attributes ();
32170 #endif /* OBJ_ELF */
32172 /* Parse a .cpu directive. */
32175 s_arm_cpu (int ignored ATTRIBUTE_UNUSED)
32177 const struct arm_cpu_option_table *opt;
32181 name = input_line_pointer;
32182 while (*input_line_pointer && !ISSPACE (*input_line_pointer))
32183 input_line_pointer++;
32184 saved_char = *input_line_pointer;
32185 *input_line_pointer = 0;
32187 /* Skip the first "all" entry. */
32188 for (opt = arm_cpus + 1; opt->name != NULL; opt++)
32189 if (streq (opt->name, name))
32191 selected_arch = opt->value;
32192 selected_ext = opt->ext;
32193 ARM_MERGE_FEATURE_SETS (selected_cpu, selected_arch, selected_ext);
32194 if (opt->canonical_name)
32195 strcpy (selected_cpu_name, opt->canonical_name);
32199 for (i = 0; opt->name[i]; i++)
32200 selected_cpu_name[i] = TOUPPER (opt->name[i]);
32202 selected_cpu_name[i] = 0;
32204 ARM_MERGE_FEATURE_SETS (cpu_variant, selected_cpu, selected_fpu);
32206 *input_line_pointer = saved_char;
32207 demand_empty_rest_of_line ();
32210 as_bad (_("unknown cpu `%s'"), name);
32211 *input_line_pointer = saved_char;
32212 ignore_rest_of_line ();
32215 /* Parse a .arch directive. */
32218 s_arm_arch (int ignored ATTRIBUTE_UNUSED)
32220 const struct arm_arch_option_table *opt;
32224 name = input_line_pointer;
32225 while (*input_line_pointer && !ISSPACE (*input_line_pointer))
32226 input_line_pointer++;
32227 saved_char = *input_line_pointer;
32228 *input_line_pointer = 0;
32230 /* Skip the first "all" entry. */
32231 for (opt = arm_archs + 1; opt->name != NULL; opt++)
32232 if (streq (opt->name, name))
32234 selected_arch = opt->value;
32235 selected_ext = arm_arch_none;
32236 selected_cpu = selected_arch;
32237 strcpy (selected_cpu_name, opt->name);
32238 ARM_MERGE_FEATURE_SETS (cpu_variant, selected_cpu, selected_fpu);
32239 *input_line_pointer = saved_char;
32240 demand_empty_rest_of_line ();
32244 as_bad (_("unknown architecture `%s'\n"), name);
32245 *input_line_pointer = saved_char;
32246 ignore_rest_of_line ();
32249 /* Parse a .object_arch directive. */
32252 s_arm_object_arch (int ignored ATTRIBUTE_UNUSED)
32254 const struct arm_arch_option_table *opt;
32258 name = input_line_pointer;
32259 while (*input_line_pointer && !ISSPACE (*input_line_pointer))
32260 input_line_pointer++;
32261 saved_char = *input_line_pointer;
32262 *input_line_pointer = 0;
32264 /* Skip the first "all" entry. */
32265 for (opt = arm_archs + 1; opt->name != NULL; opt++)
32266 if (streq (opt->name, name))
32268 selected_object_arch = opt->value;
32269 *input_line_pointer = saved_char;
32270 demand_empty_rest_of_line ();
32274 as_bad (_("unknown architecture `%s'\n"), name);
32275 *input_line_pointer = saved_char;
32276 ignore_rest_of_line ();
32279 /* Parse a .arch_extension directive. */
32282 s_arm_arch_extension (int ignored ATTRIBUTE_UNUSED)
32284 const struct arm_option_extension_value_table *opt;
32287 int adding_value = 1;
32289 name = input_line_pointer;
32290 while (*input_line_pointer && !ISSPACE (*input_line_pointer))
32291 input_line_pointer++;
32292 saved_char = *input_line_pointer;
32293 *input_line_pointer = 0;
32295 if (strlen (name) >= 2
32296 && strncmp (name, "no", 2) == 0)
32302 for (opt = arm_extensions; opt->name != NULL; opt++)
32303 if (streq (opt->name, name))
32305 int i, nb_allowed_archs =
32306 sizeof (opt->allowed_archs) / sizeof (opt->allowed_archs[i]);
32307 for (i = 0; i < nb_allowed_archs; i++)
32310 if (ARM_CPU_IS_ANY (opt->allowed_archs[i]))
32312 if (ARM_FSET_CPU_SUBSET (opt->allowed_archs[i], selected_arch))
32316 if (i == nb_allowed_archs)
32318 as_bad (_("architectural extension `%s' is not allowed for the "
32319 "current base architecture"), name);
32324 ARM_MERGE_FEATURE_SETS (selected_ext, selected_ext,
32327 ARM_CLEAR_FEATURE (selected_ext, selected_ext, opt->clear_value);
32329 ARM_MERGE_FEATURE_SETS (selected_cpu, selected_arch, selected_ext);
32330 ARM_MERGE_FEATURE_SETS (cpu_variant, selected_cpu, selected_fpu);
32331 *input_line_pointer = saved_char;
32332 demand_empty_rest_of_line ();
32333 /* Allowing Thumb division instructions for ARMv7 in autodetection rely
32334 on this return so that duplicate extensions (extensions with the
32335 same name as a previous extension in the list) are not considered
32336 for command-line parsing. */
32340 if (opt->name == NULL)
32341 as_bad (_("unknown architecture extension `%s'\n"), name);
32343 *input_line_pointer = saved_char;
32344 ignore_rest_of_line ();
32347 /* Parse a .fpu directive. */
32350 s_arm_fpu (int ignored ATTRIBUTE_UNUSED)
32352 const struct arm_option_fpu_value_table *opt;
32356 name = input_line_pointer;
32357 while (*input_line_pointer && !ISSPACE (*input_line_pointer))
32358 input_line_pointer++;
32359 saved_char = *input_line_pointer;
32360 *input_line_pointer = 0;
32362 for (opt = arm_fpus; opt->name != NULL; opt++)
32363 if (streq (opt->name, name))
32365 selected_fpu = opt->value;
32366 #ifndef CPU_DEFAULT
32367 if (no_cpu_selected ())
32368 ARM_MERGE_FEATURE_SETS (cpu_variant, arm_arch_any, selected_fpu);
32371 ARM_MERGE_FEATURE_SETS (cpu_variant, selected_cpu, selected_fpu);
32372 *input_line_pointer = saved_char;
32373 demand_empty_rest_of_line ();
32377 as_bad (_("unknown floating point format `%s'\n"), name);
32378 *input_line_pointer = saved_char;
32379 ignore_rest_of_line ();
32382 /* Copy symbol information. */
32385 arm_copy_symbol_attributes (symbolS *dest, symbolS *src)
32387 ARM_GET_FLAG (dest) = ARM_GET_FLAG (src);
32391 /* Given a symbolic attribute NAME, return the proper integer value.
32392 Returns -1 if the attribute is not known. */
32395 arm_convert_symbolic_attribute (const char *name)
32397 static const struct
32402 attribute_table[] =
32404 /* When you modify this table you should
32405 also modify the list in doc/c-arm.texi. */
32406 #define T(tag) {#tag, tag}
32407 T (Tag_CPU_raw_name),
32410 T (Tag_CPU_arch_profile),
32411 T (Tag_ARM_ISA_use),
32412 T (Tag_THUMB_ISA_use),
32416 T (Tag_Advanced_SIMD_arch),
32417 T (Tag_PCS_config),
32418 T (Tag_ABI_PCS_R9_use),
32419 T (Tag_ABI_PCS_RW_data),
32420 T (Tag_ABI_PCS_RO_data),
32421 T (Tag_ABI_PCS_GOT_use),
32422 T (Tag_ABI_PCS_wchar_t),
32423 T (Tag_ABI_FP_rounding),
32424 T (Tag_ABI_FP_denormal),
32425 T (Tag_ABI_FP_exceptions),
32426 T (Tag_ABI_FP_user_exceptions),
32427 T (Tag_ABI_FP_number_model),
32428 T (Tag_ABI_align_needed),
32429 T (Tag_ABI_align8_needed),
32430 T (Tag_ABI_align_preserved),
32431 T (Tag_ABI_align8_preserved),
32432 T (Tag_ABI_enum_size),
32433 T (Tag_ABI_HardFP_use),
32434 T (Tag_ABI_VFP_args),
32435 T (Tag_ABI_WMMX_args),
32436 T (Tag_ABI_optimization_goals),
32437 T (Tag_ABI_FP_optimization_goals),
32438 T (Tag_compatibility),
32439 T (Tag_CPU_unaligned_access),
32440 T (Tag_FP_HP_extension),
32441 T (Tag_VFP_HP_extension),
32442 T (Tag_ABI_FP_16bit_format),
32443 T (Tag_MPextension_use),
32445 T (Tag_nodefaults),
32446 T (Tag_also_compatible_with),
32447 T (Tag_conformance),
32449 T (Tag_Virtualization_use),
32450 T (Tag_DSP_extension),
32452 /* We deliberately do not include Tag_MPextension_use_legacy. */
32460 for (i = 0; i < ARRAY_SIZE (attribute_table); i++)
32461 if (streq (name, attribute_table[i].name))
32462 return attribute_table[i].tag;
32467 /* Apply sym value for relocations only in the case that they are for
32468 local symbols in the same segment as the fixup and you have the
32469 respective architectural feature for blx and simple switches. */
32472 arm_apply_sym_value (struct fix * fixP, segT this_seg)
32475 && ARM_CPU_HAS_FEATURE (selected_cpu, arm_ext_v5t)
32476 /* PR 17444: If the local symbol is in a different section then a reloc
32477 will always be generated for it, so applying the symbol value now
32478 will result in a double offset being stored in the relocation. */
32479 && (S_GET_SEGMENT (fixP->fx_addsy) == this_seg)
32480 && !S_FORCE_RELOC (fixP->fx_addsy, TRUE))
32482 switch (fixP->fx_r_type)
32484 case BFD_RELOC_ARM_PCREL_BLX:
32485 case BFD_RELOC_THUMB_PCREL_BRANCH23:
32486 if (ARM_IS_FUNC (fixP->fx_addsy))
32490 case BFD_RELOC_ARM_PCREL_CALL:
32491 case BFD_RELOC_THUMB_PCREL_BLX:
32492 if (THUMB_IS_FUNC (fixP->fx_addsy))
32503 #endif /* OBJ_ELF */