1 /* tc-arm.c -- Assemble for the ARM
2 Copyright (C) 1994-2019 Free Software Foundation, Inc.
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"
39 #include "dw2gencfi.h"
42 #include "dwarf2dbg.h"
45 /* Must be at least the size of the largest unwind opcode (currently two). */
46 #define ARM_OPCODE_CHUNK_SIZE 8
48 /* This structure holds the unwinding state. */
53 symbolS * table_entry;
54 symbolS * personality_routine;
55 int personality_index;
56 /* The segment containing the function. */
59 /* Opcodes generated from this function. */
60 unsigned char * opcodes;
63 /* The number of bytes pushed to the stack. */
65 /* We don't add stack adjustment opcodes immediately so that we can merge
66 multiple adjustments. We can also omit the final adjustment
67 when using a frame pointer. */
68 offsetT pending_offset;
69 /* These two fields are set by both unwind_movsp and unwind_setfp. They
70 hold the reg+offset to use when restoring sp from a frame pointer. */
73 /* Nonzero if an unwind_setfp directive has been seen. */
75 /* Nonzero if the last opcode restores sp from fp_reg. */
76 unsigned sp_restored:1;
79 /* Whether --fdpic was given. */
84 /* Results from operand parsing worker functions. */
88 PARSE_OPERAND_SUCCESS,
90 PARSE_OPERAND_FAIL_NO_BACKTRACK
91 } parse_operand_result;
100 /* Types of processor to assemble for. */
102 /* The code that was here used to select a default CPU depending on compiler
103 pre-defines which were only present when doing native builds, thus
104 changing gas' default behaviour depending upon the build host.
106 If you have a target that requires a default CPU option then the you
107 should define CPU_DEFAULT here. */
112 # define FPU_DEFAULT FPU_ARCH_FPA
113 # elif defined (TE_NetBSD)
115 # define FPU_DEFAULT FPU_ARCH_VFP /* Soft-float, but VFP order. */
117 /* Legacy a.out format. */
118 # define FPU_DEFAULT FPU_ARCH_FPA /* Soft-float, but FPA order. */
120 # elif defined (TE_VXWORKS)
121 # define FPU_DEFAULT FPU_ARCH_VFP /* Soft-float, VFP order. */
123 /* For backwards compatibility, default to FPA. */
124 # define FPU_DEFAULT FPU_ARCH_FPA
126 #endif /* ifndef FPU_DEFAULT */
128 #define streq(a, b) (strcmp (a, b) == 0)
130 /* Current set of feature bits available (CPU+FPU). Different from
131 selected_cpu + selected_fpu in case of autodetection since the CPU
132 feature bits are then all set. */
133 static arm_feature_set cpu_variant;
134 /* Feature bits used in each execution state. Used to set build attribute
135 (in particular Tag_*_ISA_use) in CPU autodetection mode. */
136 static arm_feature_set arm_arch_used;
137 static arm_feature_set thumb_arch_used;
139 /* Flags stored in private area of BFD structure. */
140 static int uses_apcs_26 = FALSE;
141 static int atpcs = FALSE;
142 static int support_interwork = FALSE;
143 static int uses_apcs_float = FALSE;
144 static int pic_code = FALSE;
145 static int fix_v4bx = FALSE;
146 /* Warn on using deprecated features. */
147 static int warn_on_deprecated = TRUE;
149 /* Understand CodeComposer Studio assembly syntax. */
150 bfd_boolean codecomposer_syntax = FALSE;
152 /* Variables that we set while parsing command-line options. Once all
153 options have been read we re-process these values to set the real
156 /* CPU and FPU feature bits set for legacy CPU and FPU options (eg. -marm1
157 instead of -mcpu=arm1). */
158 static const arm_feature_set *legacy_cpu = NULL;
159 static const arm_feature_set *legacy_fpu = NULL;
161 /* CPU, extension and FPU feature bits selected by -mcpu. */
162 static const arm_feature_set *mcpu_cpu_opt = NULL;
163 static arm_feature_set *mcpu_ext_opt = NULL;
164 static const arm_feature_set *mcpu_fpu_opt = NULL;
166 /* CPU, extension and FPU feature bits selected by -march. */
167 static const arm_feature_set *march_cpu_opt = NULL;
168 static arm_feature_set *march_ext_opt = NULL;
169 static const arm_feature_set *march_fpu_opt = NULL;
171 /* Feature bits selected by -mfpu. */
172 static const arm_feature_set *mfpu_opt = NULL;
174 /* Constants for known architecture features. */
175 static const arm_feature_set fpu_default = FPU_DEFAULT;
176 static const arm_feature_set fpu_arch_vfp_v1 ATTRIBUTE_UNUSED = FPU_ARCH_VFP_V1;
177 static const arm_feature_set fpu_arch_vfp_v2 = FPU_ARCH_VFP_V2;
178 static const arm_feature_set fpu_arch_vfp_v3 ATTRIBUTE_UNUSED = FPU_ARCH_VFP_V3;
179 static const arm_feature_set fpu_arch_neon_v1 ATTRIBUTE_UNUSED = FPU_ARCH_NEON_V1;
180 static const arm_feature_set fpu_arch_fpa = FPU_ARCH_FPA;
181 static const arm_feature_set fpu_any_hard = FPU_ANY_HARD;
183 static const arm_feature_set fpu_arch_maverick = FPU_ARCH_MAVERICK;
185 static const arm_feature_set fpu_endian_pure = FPU_ARCH_ENDIAN_PURE;
188 static const arm_feature_set cpu_default = CPU_DEFAULT;
191 static const arm_feature_set arm_ext_v1 = ARM_FEATURE_CORE_LOW (ARM_EXT_V1);
192 static const arm_feature_set arm_ext_v2 = ARM_FEATURE_CORE_LOW (ARM_EXT_V2);
193 static const arm_feature_set arm_ext_v2s = ARM_FEATURE_CORE_LOW (ARM_EXT_V2S);
194 static const arm_feature_set arm_ext_v3 = ARM_FEATURE_CORE_LOW (ARM_EXT_V3);
195 static const arm_feature_set arm_ext_v3m = ARM_FEATURE_CORE_LOW (ARM_EXT_V3M);
196 static const arm_feature_set arm_ext_v4 = ARM_FEATURE_CORE_LOW (ARM_EXT_V4);
197 static const arm_feature_set arm_ext_v4t = ARM_FEATURE_CORE_LOW (ARM_EXT_V4T);
198 static const arm_feature_set arm_ext_v5 = ARM_FEATURE_CORE_LOW (ARM_EXT_V5);
199 static const arm_feature_set arm_ext_v4t_5 =
200 ARM_FEATURE_CORE_LOW (ARM_EXT_V4T | ARM_EXT_V5);
201 static const arm_feature_set arm_ext_v5t = ARM_FEATURE_CORE_LOW (ARM_EXT_V5T);
202 static const arm_feature_set arm_ext_v5e = ARM_FEATURE_CORE_LOW (ARM_EXT_V5E);
203 static const arm_feature_set arm_ext_v5exp = ARM_FEATURE_CORE_LOW (ARM_EXT_V5ExP);
204 static const arm_feature_set arm_ext_v5j = ARM_FEATURE_CORE_LOW (ARM_EXT_V5J);
205 static const arm_feature_set arm_ext_v6 = ARM_FEATURE_CORE_LOW (ARM_EXT_V6);
206 static const arm_feature_set arm_ext_v6k = ARM_FEATURE_CORE_LOW (ARM_EXT_V6K);
207 static const arm_feature_set arm_ext_v6t2 = ARM_FEATURE_CORE_LOW (ARM_EXT_V6T2);
208 /* Only for compatability of hint instructions. */
209 static const arm_feature_set arm_ext_v6k_v6t2 =
210 ARM_FEATURE_CORE_LOW (ARM_EXT_V6K | ARM_EXT_V6T2);
211 static const arm_feature_set arm_ext_v6_notm =
212 ARM_FEATURE_CORE_LOW (ARM_EXT_V6_NOTM);
213 static const arm_feature_set arm_ext_v6_dsp =
214 ARM_FEATURE_CORE_LOW (ARM_EXT_V6_DSP);
215 static const arm_feature_set arm_ext_barrier =
216 ARM_FEATURE_CORE_LOW (ARM_EXT_BARRIER);
217 static const arm_feature_set arm_ext_msr =
218 ARM_FEATURE_CORE_LOW (ARM_EXT_THUMB_MSR);
219 static const arm_feature_set arm_ext_div = ARM_FEATURE_CORE_LOW (ARM_EXT_DIV);
220 static const arm_feature_set arm_ext_v7 = ARM_FEATURE_CORE_LOW (ARM_EXT_V7);
221 static const arm_feature_set arm_ext_v7a = ARM_FEATURE_CORE_LOW (ARM_EXT_V7A);
222 static const arm_feature_set arm_ext_v7r = ARM_FEATURE_CORE_LOW (ARM_EXT_V7R);
224 static const arm_feature_set ATTRIBUTE_UNUSED arm_ext_v7m = ARM_FEATURE_CORE_LOW (ARM_EXT_V7M);
226 static const arm_feature_set arm_ext_v8 = ARM_FEATURE_CORE_LOW (ARM_EXT_V8);
227 static const arm_feature_set arm_ext_m =
228 ARM_FEATURE_CORE (ARM_EXT_V6M | ARM_EXT_V7M,
229 ARM_EXT2_V8M | ARM_EXT2_V8M_MAIN);
230 static const arm_feature_set arm_ext_mp = ARM_FEATURE_CORE_LOW (ARM_EXT_MP);
231 static const arm_feature_set arm_ext_sec = ARM_FEATURE_CORE_LOW (ARM_EXT_SEC);
232 static const arm_feature_set arm_ext_os = ARM_FEATURE_CORE_LOW (ARM_EXT_OS);
233 static const arm_feature_set arm_ext_adiv = ARM_FEATURE_CORE_LOW (ARM_EXT_ADIV);
234 static const arm_feature_set arm_ext_virt = ARM_FEATURE_CORE_LOW (ARM_EXT_VIRT);
235 static const arm_feature_set arm_ext_pan = ARM_FEATURE_CORE_HIGH (ARM_EXT2_PAN);
236 static const arm_feature_set arm_ext_v8m = ARM_FEATURE_CORE_HIGH (ARM_EXT2_V8M);
237 static const arm_feature_set arm_ext_v8m_main =
238 ARM_FEATURE_CORE_HIGH (ARM_EXT2_V8M_MAIN);
239 static const arm_feature_set arm_ext_v8_1m_main =
240 ARM_FEATURE_CORE_HIGH (ARM_EXT2_V8_1M_MAIN);
241 /* Instructions in ARMv8-M only found in M profile architectures. */
242 static const arm_feature_set arm_ext_v8m_m_only =
243 ARM_FEATURE_CORE_HIGH (ARM_EXT2_V8M | ARM_EXT2_V8M_MAIN);
244 static const arm_feature_set arm_ext_v6t2_v8m =
245 ARM_FEATURE_CORE_HIGH (ARM_EXT2_V6T2_V8M);
246 /* Instructions shared between ARMv8-A and ARMv8-M. */
247 static const arm_feature_set arm_ext_atomics =
248 ARM_FEATURE_CORE_HIGH (ARM_EXT2_ATOMICS);
250 /* DSP instructions Tag_DSP_extension refers to. */
251 static const arm_feature_set arm_ext_dsp =
252 ARM_FEATURE_CORE_LOW (ARM_EXT_V5E | ARM_EXT_V5ExP | ARM_EXT_V6_DSP);
254 static const arm_feature_set arm_ext_ras =
255 ARM_FEATURE_CORE_HIGH (ARM_EXT2_RAS);
256 /* FP16 instructions. */
257 static const arm_feature_set arm_ext_fp16 =
258 ARM_FEATURE_CORE_HIGH (ARM_EXT2_FP16_INST);
259 static const arm_feature_set arm_ext_fp16_fml =
260 ARM_FEATURE_CORE_HIGH (ARM_EXT2_FP16_FML);
261 static const arm_feature_set arm_ext_v8_2 =
262 ARM_FEATURE_CORE_HIGH (ARM_EXT2_V8_2A);
263 static const arm_feature_set arm_ext_v8_3 =
264 ARM_FEATURE_CORE_HIGH (ARM_EXT2_V8_3A);
265 static const arm_feature_set arm_ext_sb =
266 ARM_FEATURE_CORE_HIGH (ARM_EXT2_SB);
267 static const arm_feature_set arm_ext_predres =
268 ARM_FEATURE_CORE_HIGH (ARM_EXT2_PREDRES);
270 static const arm_feature_set arm_arch_any = ARM_ANY;
272 static const arm_feature_set fpu_any = FPU_ANY;
274 static const arm_feature_set arm_arch_full ATTRIBUTE_UNUSED = ARM_FEATURE (-1, -1, -1);
275 static const arm_feature_set arm_arch_t2 = ARM_ARCH_THUMB2;
276 static const arm_feature_set arm_arch_none = ARM_ARCH_NONE;
278 static const arm_feature_set arm_cext_iwmmxt2 =
279 ARM_FEATURE_COPROC (ARM_CEXT_IWMMXT2);
280 static const arm_feature_set arm_cext_iwmmxt =
281 ARM_FEATURE_COPROC (ARM_CEXT_IWMMXT);
282 static const arm_feature_set arm_cext_xscale =
283 ARM_FEATURE_COPROC (ARM_CEXT_XSCALE);
284 static const arm_feature_set arm_cext_maverick =
285 ARM_FEATURE_COPROC (ARM_CEXT_MAVERICK);
286 static const arm_feature_set fpu_fpa_ext_v1 =
287 ARM_FEATURE_COPROC (FPU_FPA_EXT_V1);
288 static const arm_feature_set fpu_fpa_ext_v2 =
289 ARM_FEATURE_COPROC (FPU_FPA_EXT_V2);
290 static const arm_feature_set fpu_vfp_ext_v1xd =
291 ARM_FEATURE_COPROC (FPU_VFP_EXT_V1xD);
292 static const arm_feature_set fpu_vfp_ext_v1 =
293 ARM_FEATURE_COPROC (FPU_VFP_EXT_V1);
294 static const arm_feature_set fpu_vfp_ext_v2 =
295 ARM_FEATURE_COPROC (FPU_VFP_EXT_V2);
296 static const arm_feature_set fpu_vfp_ext_v3xd =
297 ARM_FEATURE_COPROC (FPU_VFP_EXT_V3xD);
298 static const arm_feature_set fpu_vfp_ext_v3 =
299 ARM_FEATURE_COPROC (FPU_VFP_EXT_V3);
300 static const arm_feature_set fpu_vfp_ext_d32 =
301 ARM_FEATURE_COPROC (FPU_VFP_EXT_D32);
302 static const arm_feature_set fpu_neon_ext_v1 =
303 ARM_FEATURE_COPROC (FPU_NEON_EXT_V1);
304 static const arm_feature_set fpu_vfp_v3_or_neon_ext =
305 ARM_FEATURE_COPROC (FPU_NEON_EXT_V1 | FPU_VFP_EXT_V3);
306 static const arm_feature_set mve_ext =
307 ARM_FEATURE_COPROC (FPU_MVE);
308 static const arm_feature_set mve_fp_ext =
309 ARM_FEATURE_COPROC (FPU_MVE_FP);
311 static const arm_feature_set fpu_vfp_fp16 =
312 ARM_FEATURE_COPROC (FPU_VFP_EXT_FP16);
313 static const arm_feature_set fpu_neon_ext_fma =
314 ARM_FEATURE_COPROC (FPU_NEON_EXT_FMA);
316 static const arm_feature_set fpu_vfp_ext_fma =
317 ARM_FEATURE_COPROC (FPU_VFP_EXT_FMA);
318 static const arm_feature_set fpu_vfp_ext_armv8 =
319 ARM_FEATURE_COPROC (FPU_VFP_EXT_ARMV8);
320 static const arm_feature_set fpu_vfp_ext_armv8xd =
321 ARM_FEATURE_COPROC (FPU_VFP_EXT_ARMV8xD);
322 static const arm_feature_set fpu_neon_ext_armv8 =
323 ARM_FEATURE_COPROC (FPU_NEON_EXT_ARMV8);
324 static const arm_feature_set fpu_crypto_ext_armv8 =
325 ARM_FEATURE_COPROC (FPU_CRYPTO_EXT_ARMV8);
326 static const arm_feature_set crc_ext_armv8 =
327 ARM_FEATURE_COPROC (CRC_EXT_ARMV8);
328 static const arm_feature_set fpu_neon_ext_v8_1 =
329 ARM_FEATURE_COPROC (FPU_NEON_EXT_RDMA);
330 static const arm_feature_set fpu_neon_ext_dotprod =
331 ARM_FEATURE_COPROC (FPU_NEON_EXT_DOTPROD);
333 static int mfloat_abi_opt = -1;
334 /* Architecture feature bits selected by the last -mcpu/-march or .cpu/.arch
336 static arm_feature_set selected_arch = ARM_ARCH_NONE;
337 /* Extension feature bits selected by the last -mcpu/-march or .arch_extension
339 static arm_feature_set selected_ext = ARM_ARCH_NONE;
340 /* Feature bits selected by the last -mcpu/-march or by the combination of the
341 last .cpu/.arch directive .arch_extension directives since that
343 static arm_feature_set selected_cpu = ARM_ARCH_NONE;
344 /* FPU feature bits selected by the last -mfpu or .fpu directive. */
345 static arm_feature_set selected_fpu = FPU_NONE;
346 /* Feature bits selected by the last .object_arch directive. */
347 static arm_feature_set selected_object_arch = ARM_ARCH_NONE;
348 /* Must be long enough to hold any of the names in arm_cpus. */
349 static char selected_cpu_name[20];
351 extern FLONUM_TYPE generic_floating_point_number;
353 /* Return if no cpu was selected on command-line. */
355 no_cpu_selected (void)
357 return ARM_FEATURE_EQUAL (selected_cpu, arm_arch_none);
362 static int meabi_flags = EABI_DEFAULT;
364 static int meabi_flags = EF_ARM_EABI_UNKNOWN;
367 static int attributes_set_explicitly[NUM_KNOWN_OBJ_ATTRIBUTES];
372 return (EF_ARM_EABI_VERSION (meabi_flags) >= EF_ARM_EABI_VER4);
377 /* Pre-defined "_GLOBAL_OFFSET_TABLE_" */
378 symbolS * GOT_symbol;
381 /* 0: assemble for ARM,
382 1: assemble for Thumb,
383 2: assemble for Thumb even though target CPU does not support thumb
385 static int thumb_mode = 0;
386 /* A value distinct from the possible values for thumb_mode that we
387 can use to record whether thumb_mode has been copied into the
388 tc_frag_data field of a frag. */
389 #define MODE_RECORDED (1 << 4)
391 /* Specifies the intrinsic IT insn behavior mode. */
392 enum implicit_it_mode
394 IMPLICIT_IT_MODE_NEVER = 0x00,
395 IMPLICIT_IT_MODE_ARM = 0x01,
396 IMPLICIT_IT_MODE_THUMB = 0x02,
397 IMPLICIT_IT_MODE_ALWAYS = (IMPLICIT_IT_MODE_ARM | IMPLICIT_IT_MODE_THUMB)
399 static int implicit_it_mode = IMPLICIT_IT_MODE_ARM;
401 /* If unified_syntax is true, we are processing the new unified
402 ARM/Thumb syntax. Important differences from the old ARM mode:
404 - Immediate operands do not require a # prefix.
405 - Conditional affixes always appear at the end of the
406 instruction. (For backward compatibility, those instructions
407 that formerly had them in the middle, continue to accept them
409 - The IT instruction may appear, and if it does is validated
410 against subsequent conditional affixes. It does not generate
413 Important differences from the old Thumb mode:
415 - Immediate operands do not require a # prefix.
416 - Most of the V6T2 instructions are only available in unified mode.
417 - The .N and .W suffixes are recognized and honored (it is an error
418 if they cannot be honored).
419 - All instructions set the flags if and only if they have an 's' affix.
420 - Conditional affixes may be used. They are validated against
421 preceding IT instructions. Unlike ARM mode, you cannot use a
422 conditional affix except in the scope of an IT instruction. */
424 static bfd_boolean unified_syntax = FALSE;
426 /* An immediate operand can start with #, and ld*, st*, pld operands
427 can contain [ and ]. We need to tell APP not to elide whitespace
428 before a [, which can appear as the first operand for pld.
429 Likewise, a { can appear as the first operand for push, pop, vld*, etc. */
430 const char arm_symbol_chars[] = "#[]{}";
445 enum neon_el_type type;
449 #define NEON_MAX_TYPE_ELS 4
453 struct neon_type_el el[NEON_MAX_TYPE_ELS];
457 enum pred_instruction_type
463 IF_INSIDE_IT_LAST_INSN, /* Either outside or inside;
464 if inside, should be the last one. */
465 NEUTRAL_IT_INSN, /* This could be either inside or outside,
466 i.e. BKPT and NOP. */
467 IT_INSN, /* The IT insn has been parsed. */
468 VPT_INSN, /* The VPT/VPST insn has been parsed. */
469 MVE_OUTSIDE_PRED_INSN , /* Instruction to indicate a MVE instruction without
470 a predication code. */
471 MVE_UNPREDICABLE_INSN /* MVE instruction that is non-predicable. */
474 /* The maximum number of operands we need. */
475 #define ARM_IT_MAX_OPERANDS 6
476 #define ARM_IT_MAX_RELOCS 3
481 unsigned long instruction;
485 /* "uncond_value" is set to the value in place of the conditional field in
486 unconditional versions of the instruction, or -1 if nothing is
489 struct neon_type vectype;
490 /* This does not indicate an actual NEON instruction, only that
491 the mnemonic accepts neon-style type suffixes. */
493 /* Set to the opcode if the instruction needs relaxation.
494 Zero if the instruction is not relaxed. */
498 bfd_reloc_code_real_type type;
501 } relocs[ARM_IT_MAX_RELOCS];
503 enum pred_instruction_type pred_insn_type;
509 struct neon_type_el vectype;
510 unsigned present : 1; /* Operand present. */
511 unsigned isreg : 1; /* Operand was a register. */
512 unsigned immisreg : 2; /* .imm field is a second register.
513 0: imm, 1: gpr, 2: MVE Q-register. */
514 unsigned isscalar : 2; /* Operand is a (SIMD) scalar:
518 unsigned immisalign : 1; /* Immediate is an alignment specifier. */
519 unsigned immisfloat : 1; /* Immediate was parsed as a float. */
520 /* Note: we abuse "regisimm" to mean "is Neon register" in VMOV
521 instructions. This allows us to disambiguate ARM <-> vector insns. */
522 unsigned regisimm : 1; /* 64-bit immediate, reg forms high 32 bits. */
523 unsigned isvec : 1; /* Is a single, double or quad VFP/Neon reg. */
524 unsigned isquad : 1; /* Operand is SIMD quad register. */
525 unsigned issingle : 1; /* Operand is VFP single-precision register. */
526 unsigned iszr : 1; /* Operand is ZR register. */
527 unsigned hasreloc : 1; /* Operand has relocation suffix. */
528 unsigned writeback : 1; /* Operand has trailing ! */
529 unsigned preind : 1; /* Preindexed address. */
530 unsigned postind : 1; /* Postindexed address. */
531 unsigned negative : 1; /* Index register was negated. */
532 unsigned shifted : 1; /* Shift applied to operation. */
533 unsigned shift_kind : 3; /* Shift operation (enum shift_kind). */
534 } operands[ARM_IT_MAX_OPERANDS];
537 static struct arm_it inst;
539 #define NUM_FLOAT_VALS 8
541 const char * fp_const[] =
543 "0.0", "1.0", "2.0", "3.0", "4.0", "5.0", "0.5", "10.0", 0
546 LITTLENUM_TYPE fp_values[NUM_FLOAT_VALS][MAX_LITTLENUMS];
556 #define CP_T_X 0x00008000
557 #define CP_T_Y 0x00400000
559 #define CONDS_BIT 0x00100000
560 #define LOAD_BIT 0x00100000
562 #define DOUBLE_LOAD_FLAG 0x00000001
566 const char * template_name;
570 #define COND_ALWAYS 0xE
574 const char * template_name;
578 struct asm_barrier_opt
580 const char * template_name;
582 const arm_feature_set arch;
585 /* The bit that distinguishes CPSR and SPSR. */
586 #define SPSR_BIT (1 << 22)
588 /* The individual PSR flag bits. */
589 #define PSR_c (1 << 16)
590 #define PSR_x (1 << 17)
591 #define PSR_s (1 << 18)
592 #define PSR_f (1 << 19)
597 bfd_reloc_code_real_type reloc;
602 VFP_REG_Sd, VFP_REG_Sm, VFP_REG_Sn,
603 VFP_REG_Dd, VFP_REG_Dm, VFP_REG_Dn
608 VFP_LDSTMIA, VFP_LDSTMDB, VFP_LDSTMIAX, VFP_LDSTMDBX
611 /* Bits for DEFINED field in neon_typed_alias. */
612 #define NTA_HASTYPE 1
613 #define NTA_HASINDEX 2
615 struct neon_typed_alias
617 unsigned char defined;
619 struct neon_type_el eltype;
622 /* ARM register categories. This includes coprocessor numbers and various
623 architecture extensions' registers. Each entry should have an error message
624 in reg_expected_msgs below. */
654 /* Structure for a hash table entry for a register.
655 If TYPE is REG_TYPE_VFD or REG_TYPE_NQ, the NEON field can point to extra
656 information which states whether a vector type or index is specified (for a
657 register alias created with .dn or .qn). Otherwise NEON should be NULL. */
663 unsigned char builtin;
664 struct neon_typed_alias * neon;
667 /* Diagnostics used when we don't get a register of the expected type. */
668 const char * const reg_expected_msgs[] =
670 [REG_TYPE_RN] = N_("ARM register expected"),
671 [REG_TYPE_CP] = N_("bad or missing co-processor number"),
672 [REG_TYPE_CN] = N_("co-processor register expected"),
673 [REG_TYPE_FN] = N_("FPA register expected"),
674 [REG_TYPE_VFS] = N_("VFP single precision register expected"),
675 [REG_TYPE_VFD] = N_("VFP/Neon double precision register expected"),
676 [REG_TYPE_NQ] = N_("Neon quad precision register expected"),
677 [REG_TYPE_VFSD] = N_("VFP single or double precision register expected"),
678 [REG_TYPE_NDQ] = N_("Neon double or quad precision register expected"),
679 [REG_TYPE_NSD] = N_("Neon single or double precision register expected"),
680 [REG_TYPE_NSDQ] = N_("VFP single, double or Neon quad precision register"
682 [REG_TYPE_VFC] = N_("VFP system register expected"),
683 [REG_TYPE_MVF] = N_("Maverick MVF register expected"),
684 [REG_TYPE_MVD] = N_("Maverick MVD register expected"),
685 [REG_TYPE_MVFX] = N_("Maverick MVFX register expected"),
686 [REG_TYPE_MVDX] = N_("Maverick MVDX register expected"),
687 [REG_TYPE_MVAX] = N_("Maverick MVAX register expected"),
688 [REG_TYPE_DSPSC] = N_("Maverick DSPSC register expected"),
689 [REG_TYPE_MMXWR] = N_("iWMMXt data register expected"),
690 [REG_TYPE_MMXWC] = N_("iWMMXt control register expected"),
691 [REG_TYPE_MMXWCG] = N_("iWMMXt scalar register expected"),
692 [REG_TYPE_XSCALE] = N_("XScale accumulator register expected"),
693 [REG_TYPE_MQ] = N_("MVE vector register expected"),
694 [REG_TYPE_RNB] = N_("")
697 /* Some well known registers that we refer to directly elsewhere. */
703 /* ARM instructions take 4bytes in the object file, Thumb instructions
709 /* Basic string to match. */
710 const char * template_name;
712 /* Parameters to instruction. */
713 unsigned int operands[8];
715 /* Conditional tag - see opcode_lookup. */
716 unsigned int tag : 4;
718 /* Basic instruction code. */
721 /* Thumb-format instruction code. */
724 /* Which architecture variant provides this instruction. */
725 const arm_feature_set * avariant;
726 const arm_feature_set * tvariant;
728 /* Function to call to encode instruction in ARM format. */
729 void (* aencode) (void);
731 /* Function to call to encode instruction in Thumb format. */
732 void (* tencode) (void);
734 /* Indicates whether this instruction may be vector predicated. */
735 unsigned int mayBeVecPred : 1;
738 /* Defines for various bits that we will want to toggle. */
739 #define INST_IMMEDIATE 0x02000000
740 #define OFFSET_REG 0x02000000
741 #define HWOFFSET_IMM 0x00400000
742 #define SHIFT_BY_REG 0x00000010
743 #define PRE_INDEX 0x01000000
744 #define INDEX_UP 0x00800000
745 #define WRITE_BACK 0x00200000
746 #define LDM_TYPE_2_OR_3 0x00400000
747 #define CPSI_MMOD 0x00020000
749 #define LITERAL_MASK 0xf000f000
750 #define OPCODE_MASK 0xfe1fffff
751 #define V4_STR_BIT 0x00000020
752 #define VLDR_VMOV_SAME 0x0040f000
754 #define T2_SUBS_PC_LR 0xf3de8f00
756 #define DATA_OP_SHIFT 21
757 #define SBIT_SHIFT 20
759 #define T2_OPCODE_MASK 0xfe1fffff
760 #define T2_DATA_OP_SHIFT 21
761 #define T2_SBIT_SHIFT 20
763 #define A_COND_MASK 0xf0000000
764 #define A_PUSH_POP_OP_MASK 0x0fff0000
766 /* Opcodes for pushing/poping registers to/from the stack. */
767 #define A1_OPCODE_PUSH 0x092d0000
768 #define A2_OPCODE_PUSH 0x052d0004
769 #define A2_OPCODE_POP 0x049d0004
771 /* Codes to distinguish the arithmetic instructions. */
782 #define OPCODE_CMP 10
783 #define OPCODE_CMN 11
784 #define OPCODE_ORR 12
785 #define OPCODE_MOV 13
786 #define OPCODE_BIC 14
787 #define OPCODE_MVN 15
789 #define T2_OPCODE_AND 0
790 #define T2_OPCODE_BIC 1
791 #define T2_OPCODE_ORR 2
792 #define T2_OPCODE_ORN 3
793 #define T2_OPCODE_EOR 4
794 #define T2_OPCODE_ADD 8
795 #define T2_OPCODE_ADC 10
796 #define T2_OPCODE_SBC 11
797 #define T2_OPCODE_SUB 13
798 #define T2_OPCODE_RSB 14
800 #define T_OPCODE_MUL 0x4340
801 #define T_OPCODE_TST 0x4200
802 #define T_OPCODE_CMN 0x42c0
803 #define T_OPCODE_NEG 0x4240
804 #define T_OPCODE_MVN 0x43c0
806 #define T_OPCODE_ADD_R3 0x1800
807 #define T_OPCODE_SUB_R3 0x1a00
808 #define T_OPCODE_ADD_HI 0x4400
809 #define T_OPCODE_ADD_ST 0xb000
810 #define T_OPCODE_SUB_ST 0xb080
811 #define T_OPCODE_ADD_SP 0xa800
812 #define T_OPCODE_ADD_PC 0xa000
813 #define T_OPCODE_ADD_I8 0x3000
814 #define T_OPCODE_SUB_I8 0x3800
815 #define T_OPCODE_ADD_I3 0x1c00
816 #define T_OPCODE_SUB_I3 0x1e00
818 #define T_OPCODE_ASR_R 0x4100
819 #define T_OPCODE_LSL_R 0x4080
820 #define T_OPCODE_LSR_R 0x40c0
821 #define T_OPCODE_ROR_R 0x41c0
822 #define T_OPCODE_ASR_I 0x1000
823 #define T_OPCODE_LSL_I 0x0000
824 #define T_OPCODE_LSR_I 0x0800
826 #define T_OPCODE_MOV_I8 0x2000
827 #define T_OPCODE_CMP_I8 0x2800
828 #define T_OPCODE_CMP_LR 0x4280
829 #define T_OPCODE_MOV_HR 0x4600
830 #define T_OPCODE_CMP_HR 0x4500
832 #define T_OPCODE_LDR_PC 0x4800
833 #define T_OPCODE_LDR_SP 0x9800
834 #define T_OPCODE_STR_SP 0x9000
835 #define T_OPCODE_LDR_IW 0x6800
836 #define T_OPCODE_STR_IW 0x6000
837 #define T_OPCODE_LDR_IH 0x8800
838 #define T_OPCODE_STR_IH 0x8000
839 #define T_OPCODE_LDR_IB 0x7800
840 #define T_OPCODE_STR_IB 0x7000
841 #define T_OPCODE_LDR_RW 0x5800
842 #define T_OPCODE_STR_RW 0x5000
843 #define T_OPCODE_LDR_RH 0x5a00
844 #define T_OPCODE_STR_RH 0x5200
845 #define T_OPCODE_LDR_RB 0x5c00
846 #define T_OPCODE_STR_RB 0x5400
848 #define T_OPCODE_PUSH 0xb400
849 #define T_OPCODE_POP 0xbc00
851 #define T_OPCODE_BRANCH 0xe000
853 #define THUMB_SIZE 2 /* Size of thumb instruction. */
854 #define THUMB_PP_PC_LR 0x0100
855 #define THUMB_LOAD_BIT 0x0800
856 #define THUMB2_LOAD_BIT 0x00100000
858 #define BAD_SYNTAX _("syntax error")
859 #define BAD_ARGS _("bad arguments to instruction")
860 #define BAD_SP _("r13 not allowed here")
861 #define BAD_PC _("r15 not allowed here")
862 #define BAD_ODD _("Odd register not allowed here")
863 #define BAD_EVEN _("Even register not allowed here")
864 #define BAD_COND _("instruction cannot be conditional")
865 #define BAD_OVERLAP _("registers may not be the same")
866 #define BAD_HIREG _("lo register required")
867 #define BAD_THUMB32 _("instruction not supported in Thumb16 mode")
868 #define BAD_ADDR_MODE _("instruction does not accept this addressing mode")
869 #define BAD_BRANCH _("branch must be last instruction in IT block")
870 #define BAD_BRANCH_OFF _("branch out of range or not a multiple of 2")
871 #define BAD_NOT_IT _("instruction not allowed in IT block")
872 #define BAD_NOT_VPT _("instruction missing MVE vector predication code")
873 #define BAD_FPU _("selected FPU does not support instruction")
874 #define BAD_OUT_IT _("thumb conditional instruction should be in IT block")
875 #define BAD_OUT_VPT \
876 _("vector predicated instruction should be in VPT/VPST block")
877 #define BAD_IT_COND _("incorrect condition in IT block")
878 #define BAD_VPT_COND _("incorrect condition in VPT/VPST block")
879 #define BAD_IT_IT _("IT falling in the range of a previous IT block")
880 #define MISSING_FNSTART _("missing .fnstart before unwinding directive")
881 #define BAD_PC_ADDRESSING \
882 _("cannot use register index with PC-relative addressing")
883 #define BAD_PC_WRITEBACK \
884 _("cannot use writeback with PC-relative addressing")
885 #define BAD_RANGE _("branch out of range")
886 #define BAD_FP16 _("selected processor does not support fp16 instruction")
887 #define UNPRED_REG(R) _("using " R " results in unpredictable behaviour")
888 #define THUMB1_RELOC_ONLY _("relocation valid in thumb1 code only")
889 #define MVE_NOT_IT _("Warning: instruction is UNPREDICTABLE in an IT " \
891 #define MVE_NOT_VPT _("Warning: instruction is UNPREDICTABLE in a VPT " \
893 #define MVE_BAD_PC _("Warning: instruction is UNPREDICTABLE with PC" \
895 #define MVE_BAD_SP _("Warning: instruction is UNPREDICTABLE with SP" \
897 #define BAD_SIMD_TYPE _("bad type in SIMD instruction")
898 #define BAD_MVE_AUTO \
899 _("GAS auto-detection mode and -march=all is deprecated for MVE, please" \
900 " use a valid -march or -mcpu option.")
901 #define BAD_MVE_SRCDEST _("Warning: 32-bit element size and same destination "\
902 "and source operands makes instruction UNPREDICTABLE")
903 #define BAD_EL_TYPE _("bad element type for instruction")
904 #define MVE_BAD_QREG _("MVE vector register Q[0..7] expected")
906 static struct hash_control * arm_ops_hsh;
907 static struct hash_control * arm_cond_hsh;
908 static struct hash_control * arm_vcond_hsh;
909 static struct hash_control * arm_shift_hsh;
910 static struct hash_control * arm_psr_hsh;
911 static struct hash_control * arm_v7m_psr_hsh;
912 static struct hash_control * arm_reg_hsh;
913 static struct hash_control * arm_reloc_hsh;
914 static struct hash_control * arm_barrier_opt_hsh;
916 /* Stuff needed to resolve the label ambiguity
925 symbolS * last_label_seen;
926 static int label_is_thumb_function_name = FALSE;
928 /* Literal pool structure. Held on a per-section
929 and per-sub-section basis. */
931 #define MAX_LITERAL_POOL_SIZE 1024
932 typedef struct literal_pool
934 expressionS literals [MAX_LITERAL_POOL_SIZE];
935 unsigned int next_free_entry;
941 struct dwarf2_line_info locs [MAX_LITERAL_POOL_SIZE];
943 struct literal_pool * next;
944 unsigned int alignment;
947 /* Pointer to a linked list of literal pools. */
948 literal_pool * list_of_pools = NULL;
950 typedef enum asmfunc_states
953 WAITING_ASMFUNC_NAME,
957 static asmfunc_states asmfunc_state = OUTSIDE_ASMFUNC;
960 # define now_pred seg_info (now_seg)->tc_segment_info_data.current_pred
962 static struct current_pred now_pred;
966 now_pred_compatible (int cond)
968 return (cond & ~1) == (now_pred.cc & ~1);
972 conditional_insn (void)
974 return inst.cond != COND_ALWAYS;
977 static int in_pred_block (void);
979 static int handle_pred_state (void);
981 static void force_automatic_it_block_close (void);
983 static void it_fsm_post_encode (void);
985 #define set_pred_insn_type(type) \
988 inst.pred_insn_type = type; \
989 if (handle_pred_state () == FAIL) \
994 #define set_pred_insn_type_nonvoid(type, failret) \
997 inst.pred_insn_type = type; \
998 if (handle_pred_state () == FAIL) \
1003 #define set_pred_insn_type_last() \
1006 if (inst.cond == COND_ALWAYS) \
1007 set_pred_insn_type (IF_INSIDE_IT_LAST_INSN); \
1009 set_pred_insn_type (INSIDE_IT_LAST_INSN); \
1013 /* Toggle value[pos]. */
1014 #define TOGGLE_BIT(value, pos) (value ^ (1 << pos))
1018 /* This array holds the chars that always start a comment. If the
1019 pre-processor is disabled, these aren't very useful. */
1020 char arm_comment_chars[] = "@";
1022 /* This array holds the chars that only start a comment at the beginning of
1023 a line. If the line seems to have the form '# 123 filename'
1024 .line and .file directives will appear in the pre-processed output. */
1025 /* Note that input_file.c hand checks for '#' at the beginning of the
1026 first line of the input file. This is because the compiler outputs
1027 #NO_APP at the beginning of its output. */
1028 /* Also note that comments like this one will always work. */
1029 const char line_comment_chars[] = "#";
1031 char arm_line_separator_chars[] = ";";
1033 /* Chars that can be used to separate mant
1034 from exp in floating point numbers. */
1035 const char EXP_CHARS[] = "eE";
1037 /* Chars that mean this number is a floating point constant. */
1038 /* As in 0f12.456 */
1039 /* or 0d1.2345e12 */
1041 const char FLT_CHARS[] = "rRsSfFdDxXeEpPHh";
1043 /* Prefix characters that indicate the start of an immediate
1045 #define is_immediate_prefix(C) ((C) == '#' || (C) == '$')
1047 /* Separator character handling. */
1049 #define skip_whitespace(str) do { if (*(str) == ' ') ++(str); } while (0)
1051 enum fp_16bit_format
1053 ARM_FP16_FORMAT_IEEE = 0x1,
1054 ARM_FP16_FORMAT_ALTERNATIVE = 0x2,
1055 ARM_FP16_FORMAT_DEFAULT = 0x3
1058 static enum fp_16bit_format fp16_format = ARM_FP16_FORMAT_DEFAULT;
1062 skip_past_char (char ** str, char c)
1064 /* PR gas/14987: Allow for whitespace before the expected character. */
1065 skip_whitespace (*str);
1076 #define skip_past_comma(str) skip_past_char (str, ',')
1078 /* Arithmetic expressions (possibly involving symbols). */
1080 /* Return TRUE if anything in the expression is a bignum. */
1083 walk_no_bignums (symbolS * sp)
1085 if (symbol_get_value_expression (sp)->X_op == O_big)
1088 if (symbol_get_value_expression (sp)->X_add_symbol)
1090 return (walk_no_bignums (symbol_get_value_expression (sp)->X_add_symbol)
1091 || (symbol_get_value_expression (sp)->X_op_symbol
1092 && walk_no_bignums (symbol_get_value_expression (sp)->X_op_symbol)));
1098 static bfd_boolean in_my_get_expression = FALSE;
1100 /* Third argument to my_get_expression. */
1101 #define GE_NO_PREFIX 0
1102 #define GE_IMM_PREFIX 1
1103 #define GE_OPT_PREFIX 2
1104 /* This is a bit of a hack. Use an optional prefix, and also allow big (64-bit)
1105 immediates, as can be used in Neon VMVN and VMOV immediate instructions. */
1106 #define GE_OPT_PREFIX_BIG 3
1109 my_get_expression (expressionS * ep, char ** str, int prefix_mode)
1113 /* In unified syntax, all prefixes are optional. */
1115 prefix_mode = (prefix_mode == GE_OPT_PREFIX_BIG) ? prefix_mode
1118 switch (prefix_mode)
1120 case GE_NO_PREFIX: break;
1122 if (!is_immediate_prefix (**str))
1124 inst.error = _("immediate expression requires a # prefix");
1130 case GE_OPT_PREFIX_BIG:
1131 if (is_immediate_prefix (**str))
1138 memset (ep, 0, sizeof (expressionS));
1140 save_in = input_line_pointer;
1141 input_line_pointer = *str;
1142 in_my_get_expression = TRUE;
1144 in_my_get_expression = FALSE;
1146 if (ep->X_op == O_illegal || ep->X_op == O_absent)
1148 /* We found a bad or missing expression in md_operand(). */
1149 *str = input_line_pointer;
1150 input_line_pointer = save_in;
1151 if (inst.error == NULL)
1152 inst.error = (ep->X_op == O_absent
1153 ? _("missing expression") :_("bad expression"));
1157 /* Get rid of any bignums now, so that we don't generate an error for which
1158 we can't establish a line number later on. Big numbers are never valid
1159 in instructions, which is where this routine is always called. */
1160 if (prefix_mode != GE_OPT_PREFIX_BIG
1161 && (ep->X_op == O_big
1162 || (ep->X_add_symbol
1163 && (walk_no_bignums (ep->X_add_symbol)
1165 && walk_no_bignums (ep->X_op_symbol))))))
1167 inst.error = _("invalid constant");
1168 *str = input_line_pointer;
1169 input_line_pointer = save_in;
1173 *str = input_line_pointer;
1174 input_line_pointer = save_in;
1178 /* Turn a string in input_line_pointer into a floating point constant
1179 of type TYPE, and store the appropriate bytes in *LITP. The number
1180 of LITTLENUMS emitted is stored in *SIZEP. An error message is
1181 returned, or NULL on OK.
1183 Note that fp constants aren't represent in the normal way on the ARM.
1184 In big endian mode, things are as expected. However, in little endian
1185 mode fp constants are big-endian word-wise, and little-endian byte-wise
1186 within the words. For example, (double) 1.1 in big endian mode is
1187 the byte sequence 3f f1 99 99 99 99 99 9a, and in little endian mode is
1188 the byte sequence 99 99 f1 3f 9a 99 99 99.
1190 ??? The format of 12 byte floats is uncertain according to gcc's arm.h. */
1193 md_atof (int type, char * litP, int * sizeP)
1196 LITTLENUM_TYPE words[MAX_LITTLENUMS];
1233 return _("Unrecognized or unsupported floating point constant");
1236 t = atof_ieee (input_line_pointer, type, words);
1238 input_line_pointer = t;
1239 *sizeP = prec * sizeof (LITTLENUM_TYPE);
1241 if (target_big_endian || prec == 1)
1242 for (i = 0; i < prec; i++)
1244 md_number_to_chars (litP, (valueT) words[i], sizeof (LITTLENUM_TYPE));
1245 litP += sizeof (LITTLENUM_TYPE);
1247 else if (ARM_CPU_HAS_FEATURE (cpu_variant, fpu_endian_pure))
1248 for (i = prec - 1; i >= 0; i--)
1250 md_number_to_chars (litP, (valueT) words[i], sizeof (LITTLENUM_TYPE));
1251 litP += sizeof (LITTLENUM_TYPE);
1254 /* For a 4 byte float the order of elements in `words' is 1 0.
1255 For an 8 byte float the order is 1 0 3 2. */
1256 for (i = 0; i < prec; i += 2)
1258 md_number_to_chars (litP, (valueT) words[i + 1],
1259 sizeof (LITTLENUM_TYPE));
1260 md_number_to_chars (litP + sizeof (LITTLENUM_TYPE),
1261 (valueT) words[i], sizeof (LITTLENUM_TYPE));
1262 litP += 2 * sizeof (LITTLENUM_TYPE);
1268 /* We handle all bad expressions here, so that we can report the faulty
1269 instruction in the error message. */
1272 md_operand (expressionS * exp)
1274 if (in_my_get_expression)
1275 exp->X_op = O_illegal;
1278 /* Immediate values. */
1281 /* Generic immediate-value read function for use in directives.
1282 Accepts anything that 'expression' can fold to a constant.
1283 *val receives the number. */
1286 immediate_for_directive (int *val)
1289 exp.X_op = O_illegal;
1291 if (is_immediate_prefix (*input_line_pointer))
1293 input_line_pointer++;
1297 if (exp.X_op != O_constant)
1299 as_bad (_("expected #constant"));
1300 ignore_rest_of_line ();
1303 *val = exp.X_add_number;
1308 /* Register parsing. */
1310 /* Generic register parser. CCP points to what should be the
1311 beginning of a register name. If it is indeed a valid register
1312 name, advance CCP over it and return the reg_entry structure;
1313 otherwise return NULL. Does not issue diagnostics. */
1315 static struct reg_entry *
1316 arm_reg_parse_multi (char **ccp)
1320 struct reg_entry *reg;
1322 skip_whitespace (start);
1324 #ifdef REGISTER_PREFIX
1325 if (*start != REGISTER_PREFIX)
1329 #ifdef OPTIONAL_REGISTER_PREFIX
1330 if (*start == OPTIONAL_REGISTER_PREFIX)
1335 if (!ISALPHA (*p) || !is_name_beginner (*p))
1340 while (ISALPHA (*p) || ISDIGIT (*p) || *p == '_');
1342 reg = (struct reg_entry *) hash_find_n (arm_reg_hsh, start, p - start);
1352 arm_reg_alt_syntax (char **ccp, char *start, struct reg_entry *reg,
1353 enum arm_reg_type type)
1355 /* Alternative syntaxes are accepted for a few register classes. */
1362 /* Generic coprocessor register names are allowed for these. */
1363 if (reg && reg->type == REG_TYPE_CN)
1368 /* For backward compatibility, a bare number is valid here. */
1370 unsigned long processor = strtoul (start, ccp, 10);
1371 if (*ccp != start && processor <= 15)
1376 case REG_TYPE_MMXWC:
1377 /* WC includes WCG. ??? I'm not sure this is true for all
1378 instructions that take WC registers. */
1379 if (reg && reg->type == REG_TYPE_MMXWCG)
1390 /* As arm_reg_parse_multi, but the register must be of type TYPE, and the
1391 return value is the register number or FAIL. */
1394 arm_reg_parse (char **ccp, enum arm_reg_type type)
1397 struct reg_entry *reg = arm_reg_parse_multi (ccp);
1400 /* Do not allow a scalar (reg+index) to parse as a register. */
1401 if (reg && reg->neon && (reg->neon->defined & NTA_HASINDEX))
1404 if (reg && reg->type == type)
1407 if ((ret = arm_reg_alt_syntax (ccp, start, reg, type)) != FAIL)
1414 /* Parse a Neon type specifier. *STR should point at the leading '.'
1415 character. Does no verification at this stage that the type fits the opcode
1422 Can all be legally parsed by this function.
1424 Fills in neon_type struct pointer with parsed information, and updates STR
1425 to point after the parsed type specifier. Returns SUCCESS if this was a legal
1426 type, FAIL if not. */
1429 parse_neon_type (struct neon_type *type, char **str)
1436 while (type->elems < NEON_MAX_TYPE_ELS)
1438 enum neon_el_type thistype = NT_untyped;
1439 unsigned thissize = -1u;
1446 /* Just a size without an explicit type. */
1450 switch (TOLOWER (*ptr))
1452 case 'i': thistype = NT_integer; break;
1453 case 'f': thistype = NT_float; break;
1454 case 'p': thistype = NT_poly; break;
1455 case 's': thistype = NT_signed; break;
1456 case 'u': thistype = NT_unsigned; break;
1458 thistype = NT_float;
1463 as_bad (_("unexpected character `%c' in type specifier"), *ptr);
1469 /* .f is an abbreviation for .f32. */
1470 if (thistype == NT_float && !ISDIGIT (*ptr))
1475 thissize = strtoul (ptr, &ptr, 10);
1477 if (thissize != 8 && thissize != 16 && thissize != 32
1480 as_bad (_("bad size %d in type specifier"), thissize);
1488 type->el[type->elems].type = thistype;
1489 type->el[type->elems].size = thissize;
1494 /* Empty/missing type is not a successful parse. */
1495 if (type->elems == 0)
1503 /* Errors may be set multiple times during parsing or bit encoding
1504 (particularly in the Neon bits), but usually the earliest error which is set
1505 will be the most meaningful. Avoid overwriting it with later (cascading)
1506 errors by calling this function. */
1509 first_error (const char *err)
1515 /* Parse a single type, e.g. ".s32", leading period included. */
1517 parse_neon_operand_type (struct neon_type_el *vectype, char **ccp)
1520 struct neon_type optype;
1524 if (parse_neon_type (&optype, &str) == SUCCESS)
1526 if (optype.elems == 1)
1527 *vectype = optype.el[0];
1530 first_error (_("only one type should be specified for operand"));
1536 first_error (_("vector type expected"));
1548 /* Special meanings for indices (which have a range of 0-7), which will fit into
1551 #define NEON_ALL_LANES 15
1552 #define NEON_INTERLEAVE_LANES 14
1554 /* Record a use of the given feature. */
1556 record_feature_use (const arm_feature_set *feature)
1559 ARM_MERGE_FEATURE_SETS (thumb_arch_used, thumb_arch_used, *feature);
1561 ARM_MERGE_FEATURE_SETS (arm_arch_used, arm_arch_used, *feature);
1564 /* If the given feature available in the selected CPU, mark it as used.
1565 Returns TRUE iff feature is available. */
1567 mark_feature_used (const arm_feature_set *feature)
1570 /* Do not support the use of MVE only instructions when in auto-detection or
1572 if (((feature == &mve_ext) || (feature == &mve_fp_ext))
1573 && ARM_CPU_IS_ANY (cpu_variant))
1575 first_error (BAD_MVE_AUTO);
1578 /* Ensure the option is valid on the current architecture. */
1579 if (!ARM_CPU_HAS_FEATURE (cpu_variant, *feature))
1582 /* Add the appropriate architecture feature for the barrier option used.
1584 record_feature_use (feature);
1589 /* Parse either a register or a scalar, with an optional type. Return the
1590 register number, and optionally fill in the actual type of the register
1591 when multiple alternatives were given (NEON_TYPE_NDQ) in *RTYPE, and
1592 type/index information in *TYPEINFO. */
1595 parse_typed_reg_or_scalar (char **ccp, enum arm_reg_type type,
1596 enum arm_reg_type *rtype,
1597 struct neon_typed_alias *typeinfo)
1600 struct reg_entry *reg = arm_reg_parse_multi (&str);
1601 struct neon_typed_alias atype;
1602 struct neon_type_el parsetype;
1606 atype.eltype.type = NT_invtype;
1607 atype.eltype.size = -1;
1609 /* Try alternate syntax for some types of register. Note these are mutually
1610 exclusive with the Neon syntax extensions. */
1613 int altreg = arm_reg_alt_syntax (&str, *ccp, reg, type);
1621 /* Undo polymorphism when a set of register types may be accepted. */
1622 if ((type == REG_TYPE_NDQ
1623 && (reg->type == REG_TYPE_NQ || reg->type == REG_TYPE_VFD))
1624 || (type == REG_TYPE_VFSD
1625 && (reg->type == REG_TYPE_VFS || reg->type == REG_TYPE_VFD))
1626 || (type == REG_TYPE_NSDQ
1627 && (reg->type == REG_TYPE_VFS || reg->type == REG_TYPE_VFD
1628 || reg->type == REG_TYPE_NQ))
1629 || (type == REG_TYPE_NSD
1630 && (reg->type == REG_TYPE_VFS || reg->type == REG_TYPE_VFD))
1631 || (type == REG_TYPE_MMXWC
1632 && (reg->type == REG_TYPE_MMXWCG)))
1633 type = (enum arm_reg_type) reg->type;
1635 if (type == REG_TYPE_MQ)
1637 if (!ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext))
1640 if (!reg || reg->type != REG_TYPE_NQ)
1643 if (reg->number > 14 && !mark_feature_used (&fpu_vfp_ext_d32))
1645 first_error (_("expected MVE register [q0..q7]"));
1650 else if (ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext)
1651 && (type == REG_TYPE_NQ))
1655 if (type != reg->type)
1661 if (parse_neon_operand_type (&parsetype, &str) == SUCCESS)
1663 if ((atype.defined & NTA_HASTYPE) != 0)
1665 first_error (_("can't redefine type for operand"));
1668 atype.defined |= NTA_HASTYPE;
1669 atype.eltype = parsetype;
1672 if (skip_past_char (&str, '[') == SUCCESS)
1674 if (type != REG_TYPE_VFD
1675 && !(type == REG_TYPE_VFS
1676 && ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_v8_2))
1677 && !(type == REG_TYPE_NQ
1678 && ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext)))
1680 if (ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext))
1681 first_error (_("only D and Q registers may be indexed"));
1683 first_error (_("only D registers may be indexed"));
1687 if ((atype.defined & NTA_HASINDEX) != 0)
1689 first_error (_("can't change index for operand"));
1693 atype.defined |= NTA_HASINDEX;
1695 if (skip_past_char (&str, ']') == SUCCESS)
1696 atype.index = NEON_ALL_LANES;
1701 my_get_expression (&exp, &str, GE_NO_PREFIX);
1703 if (exp.X_op != O_constant)
1705 first_error (_("constant expression required"));
1709 if (skip_past_char (&str, ']') == FAIL)
1712 atype.index = exp.X_add_number;
1727 /* Like arm_reg_parse, but also allow the following extra features:
1728 - If RTYPE is non-zero, return the (possibly restricted) type of the
1729 register (e.g. Neon double or quad reg when either has been requested).
1730 - If this is a Neon vector type with additional type information, fill
1731 in the struct pointed to by VECTYPE (if non-NULL).
1732 This function will fault on encountering a scalar. */
1735 arm_typed_reg_parse (char **ccp, enum arm_reg_type type,
1736 enum arm_reg_type *rtype, struct neon_type_el *vectype)
1738 struct neon_typed_alias atype;
1740 int reg = parse_typed_reg_or_scalar (&str, type, rtype, &atype);
1745 /* Do not allow regname(... to parse as a register. */
1749 /* Do not allow a scalar (reg+index) to parse as a register. */
1750 if ((atype.defined & NTA_HASINDEX) != 0)
1752 first_error (_("register operand expected, but got scalar"));
1757 *vectype = atype.eltype;
1764 #define NEON_SCALAR_REG(X) ((X) >> 4)
1765 #define NEON_SCALAR_INDEX(X) ((X) & 15)
1767 /* Parse a Neon scalar. Most of the time when we're parsing a scalar, we don't
1768 have enough information to be able to do a good job bounds-checking. So, we
1769 just do easy checks here, and do further checks later. */
1772 parse_scalar (char **ccp, int elsize, struct neon_type_el *type, enum
1773 arm_reg_type reg_type)
1777 struct neon_typed_alias atype;
1780 reg = parse_typed_reg_or_scalar (&str, reg_type, NULL, &atype);
1798 if (reg == FAIL || (atype.defined & NTA_HASINDEX) == 0)
1801 if (reg_type != REG_TYPE_MQ && atype.index == NEON_ALL_LANES)
1803 first_error (_("scalar must have an index"));
1806 else if (atype.index >= reg_size / elsize)
1808 first_error (_("scalar index out of range"));
1813 *type = atype.eltype;
1817 return reg * 16 + atype.index;
1820 /* Types of registers in a list. */
1833 /* Parse an ARM register list. Returns the bitmask, or FAIL. */
1836 parse_reg_list (char ** strp, enum reg_list_els etype)
1842 gas_assert (etype == REGLIST_RN || etype == REGLIST_CLRM);
1844 /* We come back here if we get ranges concatenated by '+' or '|'. */
1847 skip_whitespace (str);
1860 const char apsr_str[] = "apsr";
1861 int apsr_str_len = strlen (apsr_str);
1863 reg = arm_reg_parse (&str, REGLIST_RN);
1864 if (etype == REGLIST_CLRM)
1866 if (reg == REG_SP || reg == REG_PC)
1868 else if (reg == FAIL
1869 && !strncasecmp (str, apsr_str, apsr_str_len)
1870 && !ISALPHA (*(str + apsr_str_len)))
1873 str += apsr_str_len;
1878 first_error (_("r0-r12, lr or APSR expected"));
1882 else /* etype == REGLIST_RN. */
1886 first_error (_(reg_expected_msgs[REGLIST_RN]));
1897 first_error (_("bad range in register list"));
1901 for (i = cur_reg + 1; i < reg; i++)
1903 if (range & (1 << i))
1905 (_("Warning: duplicated register (r%d) in register list"),
1913 if (range & (1 << reg))
1914 as_tsktsk (_("Warning: duplicated register (r%d) in register list"),
1916 else if (reg <= cur_reg)
1917 as_tsktsk (_("Warning: register range not in ascending order"));
1922 while (skip_past_comma (&str) != FAIL
1923 || (in_range = 1, *str++ == '-'));
1926 if (skip_past_char (&str, '}') == FAIL)
1928 first_error (_("missing `}'"));
1932 else if (etype == REGLIST_RN)
1936 if (my_get_expression (&exp, &str, GE_NO_PREFIX))
1939 if (exp.X_op == O_constant)
1941 if (exp.X_add_number
1942 != (exp.X_add_number & 0x0000ffff))
1944 inst.error = _("invalid register mask");
1948 if ((range & exp.X_add_number) != 0)
1950 int regno = range & exp.X_add_number;
1953 regno = (1 << regno) - 1;
1955 (_("Warning: duplicated register (r%d) in register list"),
1959 range |= exp.X_add_number;
1963 if (inst.relocs[0].type != 0)
1965 inst.error = _("expression too complex");
1969 memcpy (&inst.relocs[0].exp, &exp, sizeof (expressionS));
1970 inst.relocs[0].type = BFD_RELOC_ARM_MULTI;
1971 inst.relocs[0].pc_rel = 0;
1975 if (*str == '|' || *str == '+')
1981 while (another_range);
1987 /* Parse a VFP register list. If the string is invalid return FAIL.
1988 Otherwise return the number of registers, and set PBASE to the first
1989 register. Parses registers of type ETYPE.
1990 If REGLIST_NEON_D is used, several syntax enhancements are enabled:
1991 - Q registers can be used to specify pairs of D registers
1992 - { } can be omitted from around a singleton register list
1993 FIXME: This is not implemented, as it would require backtracking in
1996 This could be done (the meaning isn't really ambiguous), but doesn't
1997 fit in well with the current parsing framework.
1998 - 32 D registers may be used (also true for VFPv3).
1999 FIXME: Types are ignored in these register lists, which is probably a
2003 parse_vfp_reg_list (char **ccp, unsigned int *pbase, enum reg_list_els etype,
2004 bfd_boolean *partial_match)
2009 enum arm_reg_type regtype = (enum arm_reg_type) 0;
2013 unsigned long mask = 0;
2015 bfd_boolean vpr_seen = FALSE;
2016 bfd_boolean expect_vpr =
2017 (etype == REGLIST_VFP_S_VPR) || (etype == REGLIST_VFP_D_VPR);
2019 if (skip_past_char (&str, '{') == FAIL)
2021 inst.error = _("expecting {");
2028 case REGLIST_VFP_S_VPR:
2029 regtype = REG_TYPE_VFS;
2034 case REGLIST_VFP_D_VPR:
2035 regtype = REG_TYPE_VFD;
2038 case REGLIST_NEON_D:
2039 regtype = REG_TYPE_NDQ;
2046 if (etype != REGLIST_VFP_S && etype != REGLIST_VFP_S_VPR)
2048 /* VFPv3 allows 32 D registers, except for the VFPv3-D16 variant. */
2049 if (ARM_CPU_HAS_FEATURE (cpu_variant, fpu_vfp_ext_d32))
2053 ARM_MERGE_FEATURE_SETS (thumb_arch_used, thumb_arch_used,
2056 ARM_MERGE_FEATURE_SETS (arm_arch_used, arm_arch_used,
2063 base_reg = max_regs;
2064 *partial_match = FALSE;
2068 int setmask = 1, addregs = 1;
2069 const char vpr_str[] = "vpr";
2070 int vpr_str_len = strlen (vpr_str);
2072 new_base = arm_typed_reg_parse (&str, regtype, ®type, NULL);
2076 if (new_base == FAIL
2077 && !strncasecmp (str, vpr_str, vpr_str_len)
2078 && !ISALPHA (*(str + vpr_str_len))
2084 base_reg = 0; /* Canonicalize VPR only on d0 with 0 regs. */
2088 first_error (_("VPR expected last"));
2091 else if (new_base == FAIL)
2093 if (regtype == REG_TYPE_VFS)
2094 first_error (_("VFP single precision register or VPR "
2096 else /* regtype == REG_TYPE_VFD. */
2097 first_error (_("VFP/Neon double precision register or VPR "
2102 else if (new_base == FAIL)
2104 first_error (_(reg_expected_msgs[regtype]));
2108 *partial_match = TRUE;
2112 if (new_base >= max_regs)
2114 first_error (_("register out of range in list"));
2118 /* Note: a value of 2 * n is returned for the register Q<n>. */
2119 if (regtype == REG_TYPE_NQ)
2125 if (new_base < base_reg)
2126 base_reg = new_base;
2128 if (mask & (setmask << new_base))
2130 first_error (_("invalid register list"));
2134 if ((mask >> new_base) != 0 && ! warned && !vpr_seen)
2136 as_tsktsk (_("register list not in ascending order"));
2140 mask |= setmask << new_base;
2143 if (*str == '-') /* We have the start of a range expression */
2149 if ((high_range = arm_typed_reg_parse (&str, regtype, NULL, NULL))
2152 inst.error = gettext (reg_expected_msgs[regtype]);
2156 if (high_range >= max_regs)
2158 first_error (_("register out of range in list"));
2162 if (regtype == REG_TYPE_NQ)
2163 high_range = high_range + 1;
2165 if (high_range <= new_base)
2167 inst.error = _("register range not in ascending order");
2171 for (new_base += addregs; new_base <= high_range; new_base += addregs)
2173 if (mask & (setmask << new_base))
2175 inst.error = _("invalid register list");
2179 mask |= setmask << new_base;
2184 while (skip_past_comma (&str) != FAIL);
2188 /* Sanity check -- should have raised a parse error above. */
2189 if ((!vpr_seen && count == 0) || count > max_regs)
2194 if (expect_vpr && !vpr_seen)
2196 first_error (_("VPR expected last"));
2200 /* Final test -- the registers must be consecutive. */
2202 for (i = 0; i < count; i++)
2204 if ((mask & (1u << i)) == 0)
2206 inst.error = _("non-contiguous register range");
2216 /* True if two alias types are the same. */
2219 neon_alias_types_same (struct neon_typed_alias *a, struct neon_typed_alias *b)
2227 if (a->defined != b->defined)
2230 if ((a->defined & NTA_HASTYPE) != 0
2231 && (a->eltype.type != b->eltype.type
2232 || a->eltype.size != b->eltype.size))
2235 if ((a->defined & NTA_HASINDEX) != 0
2236 && (a->index != b->index))
2242 /* Parse element/structure lists for Neon VLD<n> and VST<n> instructions.
2243 The base register is put in *PBASE.
2244 The lane (or one of the NEON_*_LANES constants) is placed in bits [3:0] of
2246 The register stride (minus one) is put in bit 4 of the return value.
2247 Bits [6:5] encode the list length (minus one).
2248 The type of the list elements is put in *ELTYPE, if non-NULL. */
2250 #define NEON_LANE(X) ((X) & 0xf)
2251 #define NEON_REG_STRIDE(X) ((((X) >> 4) & 1) + 1)
2252 #define NEON_REGLIST_LENGTH(X) ((((X) >> 5) & 3) + 1)
2255 parse_neon_el_struct_list (char **str, unsigned *pbase,
2257 struct neon_type_el *eltype)
2264 int leading_brace = 0;
2265 enum arm_reg_type rtype = REG_TYPE_NDQ;
2266 const char *const incr_error = mve ? _("register stride must be 1") :
2267 _("register stride must be 1 or 2");
2268 const char *const type_error = _("mismatched element/structure types in list");
2269 struct neon_typed_alias firsttype;
2270 firsttype.defined = 0;
2271 firsttype.eltype.type = NT_invtype;
2272 firsttype.eltype.size = -1;
2273 firsttype.index = -1;
2275 if (skip_past_char (&ptr, '{') == SUCCESS)
2280 struct neon_typed_alias atype;
2282 rtype = REG_TYPE_MQ;
2283 int getreg = parse_typed_reg_or_scalar (&ptr, rtype, &rtype, &atype);
2287 first_error (_(reg_expected_msgs[rtype]));
2294 if (rtype == REG_TYPE_NQ)
2300 else if (reg_incr == -1)
2302 reg_incr = getreg - base_reg;
2303 if (reg_incr < 1 || reg_incr > 2)
2305 first_error (_(incr_error));
2309 else if (getreg != base_reg + reg_incr * count)
2311 first_error (_(incr_error));
2315 if (! neon_alias_types_same (&atype, &firsttype))
2317 first_error (_(type_error));
2321 /* Handle Dn-Dm or Qn-Qm syntax. Can only be used with non-indexed list
2325 struct neon_typed_alias htype;
2326 int hireg, dregs = (rtype == REG_TYPE_NQ) ? 2 : 1;
2328 lane = NEON_INTERLEAVE_LANES;
2329 else if (lane != NEON_INTERLEAVE_LANES)
2331 first_error (_(type_error));
2336 else if (reg_incr != 1)
2338 first_error (_("don't use Rn-Rm syntax with non-unit stride"));
2342 hireg = parse_typed_reg_or_scalar (&ptr, rtype, NULL, &htype);
2345 first_error (_(reg_expected_msgs[rtype]));
2348 if (! neon_alias_types_same (&htype, &firsttype))
2350 first_error (_(type_error));
2353 count += hireg + dregs - getreg;
2357 /* If we're using Q registers, we can't use [] or [n] syntax. */
2358 if (rtype == REG_TYPE_NQ)
2364 if ((atype.defined & NTA_HASINDEX) != 0)
2368 else if (lane != atype.index)
2370 first_error (_(type_error));
2374 else if (lane == -1)
2375 lane = NEON_INTERLEAVE_LANES;
2376 else if (lane != NEON_INTERLEAVE_LANES)
2378 first_error (_(type_error));
2383 while ((count != 1 || leading_brace) && skip_past_comma (&ptr) != FAIL);
2385 /* No lane set by [x]. We must be interleaving structures. */
2387 lane = NEON_INTERLEAVE_LANES;
2390 if (lane == -1 || base_reg == -1 || count < 1 || (!mve && count > 4)
2391 || (count > 1 && reg_incr == -1))
2393 first_error (_("error parsing element/structure list"));
2397 if ((count > 1 || leading_brace) && skip_past_char (&ptr, '}') == FAIL)
2399 first_error (_("expected }"));
2407 *eltype = firsttype.eltype;
2412 return lane | ((reg_incr - 1) << 4) | ((count - 1) << 5);
2415 /* Parse an explicit relocation suffix on an expression. This is
2416 either nothing, or a word in parentheses. Note that if !OBJ_ELF,
2417 arm_reloc_hsh contains no entries, so this function can only
2418 succeed if there is no () after the word. Returns -1 on error,
2419 BFD_RELOC_UNUSED if there wasn't any suffix. */
2422 parse_reloc (char **str)
2424 struct reloc_entry *r;
2428 return BFD_RELOC_UNUSED;
2433 while (*q && *q != ')' && *q != ',')
2438 if ((r = (struct reloc_entry *)
2439 hash_find_n (arm_reloc_hsh, p, q - p)) == NULL)
2446 /* Directives: register aliases. */
2448 static struct reg_entry *
2449 insert_reg_alias (char *str, unsigned number, int type)
2451 struct reg_entry *new_reg;
2454 if ((new_reg = (struct reg_entry *) hash_find (arm_reg_hsh, str)) != 0)
2456 if (new_reg->builtin)
2457 as_warn (_("ignoring attempt to redefine built-in register '%s'"), str);
2459 /* Only warn about a redefinition if it's not defined as the
2461 else if (new_reg->number != number || new_reg->type != type)
2462 as_warn (_("ignoring redefinition of register alias '%s'"), str);
2467 name = xstrdup (str);
2468 new_reg = XNEW (struct reg_entry);
2470 new_reg->name = name;
2471 new_reg->number = number;
2472 new_reg->type = type;
2473 new_reg->builtin = FALSE;
2474 new_reg->neon = NULL;
2476 if (hash_insert (arm_reg_hsh, name, (void *) new_reg))
2483 insert_neon_reg_alias (char *str, int number, int type,
2484 struct neon_typed_alias *atype)
2486 struct reg_entry *reg = insert_reg_alias (str, number, type);
2490 first_error (_("attempt to redefine typed alias"));
2496 reg->neon = XNEW (struct neon_typed_alias);
2497 *reg->neon = *atype;
2501 /* Look for the .req directive. This is of the form:
2503 new_register_name .req existing_register_name
2505 If we find one, or if it looks sufficiently like one that we want to
2506 handle any error here, return TRUE. Otherwise return FALSE. */
2509 create_register_alias (char * newname, char *p)
2511 struct reg_entry *old;
2512 char *oldname, *nbuf;
2515 /* The input scrubber ensures that whitespace after the mnemonic is
2516 collapsed to single spaces. */
2518 if (strncmp (oldname, " .req ", 6) != 0)
2522 if (*oldname == '\0')
2525 old = (struct reg_entry *) hash_find (arm_reg_hsh, oldname);
2528 as_warn (_("unknown register '%s' -- .req ignored"), oldname);
2532 /* If TC_CASE_SENSITIVE is defined, then newname already points to
2533 the desired alias name, and p points to its end. If not, then
2534 the desired alias name is in the global original_case_string. */
2535 #ifdef TC_CASE_SENSITIVE
2538 newname = original_case_string;
2539 nlen = strlen (newname);
2542 nbuf = xmemdup0 (newname, nlen);
2544 /* Create aliases under the new name as stated; an all-lowercase
2545 version of the new name; and an all-uppercase version of the new
2547 if (insert_reg_alias (nbuf, old->number, old->type) != NULL)
2549 for (p = nbuf; *p; p++)
2552 if (strncmp (nbuf, newname, nlen))
2554 /* If this attempt to create an additional alias fails, do not bother
2555 trying to create the all-lower case alias. We will fail and issue
2556 a second, duplicate error message. This situation arises when the
2557 programmer does something like:
2560 The second .req creates the "Foo" alias but then fails to create
2561 the artificial FOO alias because it has already been created by the
2563 if (insert_reg_alias (nbuf, old->number, old->type) == NULL)
2570 for (p = nbuf; *p; p++)
2573 if (strncmp (nbuf, newname, nlen))
2574 insert_reg_alias (nbuf, old->number, old->type);
2581 /* Create a Neon typed/indexed register alias using directives, e.g.:
2586 These typed registers can be used instead of the types specified after the
2587 Neon mnemonic, so long as all operands given have types. Types can also be
2588 specified directly, e.g.:
2589 vadd d0.s32, d1.s32, d2.s32 */
2592 create_neon_reg_alias (char *newname, char *p)
2594 enum arm_reg_type basetype;
2595 struct reg_entry *basereg;
2596 struct reg_entry mybasereg;
2597 struct neon_type ntype;
2598 struct neon_typed_alias typeinfo;
2599 char *namebuf, *nameend ATTRIBUTE_UNUSED;
2602 typeinfo.defined = 0;
2603 typeinfo.eltype.type = NT_invtype;
2604 typeinfo.eltype.size = -1;
2605 typeinfo.index = -1;
2609 if (strncmp (p, " .dn ", 5) == 0)
2610 basetype = REG_TYPE_VFD;
2611 else if (strncmp (p, " .qn ", 5) == 0)
2612 basetype = REG_TYPE_NQ;
2621 basereg = arm_reg_parse_multi (&p);
2623 if (basereg && basereg->type != basetype)
2625 as_bad (_("bad type for register"));
2629 if (basereg == NULL)
2632 /* Try parsing as an integer. */
2633 my_get_expression (&exp, &p, GE_NO_PREFIX);
2634 if (exp.X_op != O_constant)
2636 as_bad (_("expression must be constant"));
2639 basereg = &mybasereg;
2640 basereg->number = (basetype == REG_TYPE_NQ) ? exp.X_add_number * 2
2646 typeinfo = *basereg->neon;
2648 if (parse_neon_type (&ntype, &p) == SUCCESS)
2650 /* We got a type. */
2651 if (typeinfo.defined & NTA_HASTYPE)
2653 as_bad (_("can't redefine the type of a register alias"));
2657 typeinfo.defined |= NTA_HASTYPE;
2658 if (ntype.elems != 1)
2660 as_bad (_("you must specify a single type only"));
2663 typeinfo.eltype = ntype.el[0];
2666 if (skip_past_char (&p, '[') == SUCCESS)
2669 /* We got a scalar index. */
2671 if (typeinfo.defined & NTA_HASINDEX)
2673 as_bad (_("can't redefine the index of a scalar alias"));
2677 my_get_expression (&exp, &p, GE_NO_PREFIX);
2679 if (exp.X_op != O_constant)
2681 as_bad (_("scalar index must be constant"));
2685 typeinfo.defined |= NTA_HASINDEX;
2686 typeinfo.index = exp.X_add_number;
2688 if (skip_past_char (&p, ']') == FAIL)
2690 as_bad (_("expecting ]"));
2695 /* If TC_CASE_SENSITIVE is defined, then newname already points to
2696 the desired alias name, and p points to its end. If not, then
2697 the desired alias name is in the global original_case_string. */
2698 #ifdef TC_CASE_SENSITIVE
2699 namelen = nameend - newname;
2701 newname = original_case_string;
2702 namelen = strlen (newname);
2705 namebuf = xmemdup0 (newname, namelen);
2707 insert_neon_reg_alias (namebuf, basereg->number, basetype,
2708 typeinfo.defined != 0 ? &typeinfo : NULL);
2710 /* Insert name in all uppercase. */
2711 for (p = namebuf; *p; p++)
2714 if (strncmp (namebuf, newname, namelen))
2715 insert_neon_reg_alias (namebuf, basereg->number, basetype,
2716 typeinfo.defined != 0 ? &typeinfo : NULL);
2718 /* Insert name in all lowercase. */
2719 for (p = namebuf; *p; p++)
2722 if (strncmp (namebuf, newname, namelen))
2723 insert_neon_reg_alias (namebuf, basereg->number, basetype,
2724 typeinfo.defined != 0 ? &typeinfo : NULL);
2730 /* Should never be called, as .req goes between the alias and the
2731 register name, not at the beginning of the line. */
2734 s_req (int a ATTRIBUTE_UNUSED)
2736 as_bad (_("invalid syntax for .req directive"));
2740 s_dn (int a ATTRIBUTE_UNUSED)
2742 as_bad (_("invalid syntax for .dn directive"));
2746 s_qn (int a ATTRIBUTE_UNUSED)
2748 as_bad (_("invalid syntax for .qn directive"));
2751 /* The .unreq directive deletes an alias which was previously defined
2752 by .req. For example:
2758 s_unreq (int a ATTRIBUTE_UNUSED)
2763 name = input_line_pointer;
2765 while (*input_line_pointer != 0
2766 && *input_line_pointer != ' '
2767 && *input_line_pointer != '\n')
2768 ++input_line_pointer;
2770 saved_char = *input_line_pointer;
2771 *input_line_pointer = 0;
2774 as_bad (_("invalid syntax for .unreq directive"));
2777 struct reg_entry *reg = (struct reg_entry *) hash_find (arm_reg_hsh,
2781 as_bad (_("unknown register alias '%s'"), name);
2782 else if (reg->builtin)
2783 as_warn (_("ignoring attempt to use .unreq on fixed register name: '%s'"),
2790 hash_delete (arm_reg_hsh, name, FALSE);
2791 free ((char *) reg->name);
2796 /* Also locate the all upper case and all lower case versions.
2797 Do not complain if we cannot find one or the other as it
2798 was probably deleted above. */
2800 nbuf = strdup (name);
2801 for (p = nbuf; *p; p++)
2803 reg = (struct reg_entry *) hash_find (arm_reg_hsh, nbuf);
2806 hash_delete (arm_reg_hsh, nbuf, FALSE);
2807 free ((char *) reg->name);
2813 for (p = nbuf; *p; p++)
2815 reg = (struct reg_entry *) hash_find (arm_reg_hsh, nbuf);
2818 hash_delete (arm_reg_hsh, nbuf, FALSE);
2819 free ((char *) reg->name);
2829 *input_line_pointer = saved_char;
2830 demand_empty_rest_of_line ();
2833 /* Directives: Instruction set selection. */
2836 /* This code is to handle mapping symbols as defined in the ARM ELF spec.
2837 (See "Mapping symbols", section 4.5.5, ARM AAELF version 1.0).
2838 Note that previously, $a and $t has type STT_FUNC (BSF_OBJECT flag),
2839 and $d has type STT_OBJECT (BSF_OBJECT flag). Now all three are untyped. */
2841 /* Create a new mapping symbol for the transition to STATE. */
2844 make_mapping_symbol (enum mstate state, valueT value, fragS *frag)
2847 const char * symname;
2854 type = BSF_NO_FLAGS;
2858 type = BSF_NO_FLAGS;
2862 type = BSF_NO_FLAGS;
2868 symbolP = symbol_new (symname, now_seg, value, frag);
2869 symbol_get_bfdsym (symbolP)->flags |= type | BSF_LOCAL;
2874 THUMB_SET_FUNC (symbolP, 0);
2875 ARM_SET_THUMB (symbolP, 0);
2876 ARM_SET_INTERWORK (symbolP, support_interwork);
2880 THUMB_SET_FUNC (symbolP, 1);
2881 ARM_SET_THUMB (symbolP, 1);
2882 ARM_SET_INTERWORK (symbolP, support_interwork);
2890 /* Save the mapping symbols for future reference. Also check that
2891 we do not place two mapping symbols at the same offset within a
2892 frag. We'll handle overlap between frags in
2893 check_mapping_symbols.
2895 If .fill or other data filling directive generates zero sized data,
2896 the mapping symbol for the following code will have the same value
2897 as the one generated for the data filling directive. In this case,
2898 we replace the old symbol with the new one at the same address. */
2901 if (frag->tc_frag_data.first_map != NULL)
2903 know (S_GET_VALUE (frag->tc_frag_data.first_map) == 0);
2904 symbol_remove (frag->tc_frag_data.first_map, &symbol_rootP, &symbol_lastP);
2906 frag->tc_frag_data.first_map = symbolP;
2908 if (frag->tc_frag_data.last_map != NULL)
2910 know (S_GET_VALUE (frag->tc_frag_data.last_map) <= S_GET_VALUE (symbolP));
2911 if (S_GET_VALUE (frag->tc_frag_data.last_map) == S_GET_VALUE (symbolP))
2912 symbol_remove (frag->tc_frag_data.last_map, &symbol_rootP, &symbol_lastP);
2914 frag->tc_frag_data.last_map = symbolP;
2917 /* We must sometimes convert a region marked as code to data during
2918 code alignment, if an odd number of bytes have to be padded. The
2919 code mapping symbol is pushed to an aligned address. */
2922 insert_data_mapping_symbol (enum mstate state,
2923 valueT value, fragS *frag, offsetT bytes)
2925 /* If there was already a mapping symbol, remove it. */
2926 if (frag->tc_frag_data.last_map != NULL
2927 && S_GET_VALUE (frag->tc_frag_data.last_map) == frag->fr_address + value)
2929 symbolS *symp = frag->tc_frag_data.last_map;
2933 know (frag->tc_frag_data.first_map == symp);
2934 frag->tc_frag_data.first_map = NULL;
2936 frag->tc_frag_data.last_map = NULL;
2937 symbol_remove (symp, &symbol_rootP, &symbol_lastP);
2940 make_mapping_symbol (MAP_DATA, value, frag);
2941 make_mapping_symbol (state, value + bytes, frag);
2944 static void mapping_state_2 (enum mstate state, int max_chars);
2946 /* Set the mapping state to STATE. Only call this when about to
2947 emit some STATE bytes to the file. */
2949 #define TRANSITION(from, to) (mapstate == (from) && state == (to))
2951 mapping_state (enum mstate state)
2953 enum mstate mapstate = seg_info (now_seg)->tc_segment_info_data.mapstate;
2955 if (mapstate == state)
2956 /* The mapping symbol has already been emitted.
2957 There is nothing else to do. */
2960 if (state == MAP_ARM || state == MAP_THUMB)
2962 All ARM instructions require 4-byte alignment.
2963 (Almost) all Thumb instructions require 2-byte alignment.
2965 When emitting instructions into any section, mark the section
2968 Some Thumb instructions are alignment-sensitive modulo 4 bytes,
2969 but themselves require 2-byte alignment; this applies to some
2970 PC- relative forms. However, these cases will involve implicit
2971 literal pool generation or an explicit .align >=2, both of
2972 which will cause the section to me marked with sufficient
2973 alignment. Thus, we don't handle those cases here. */
2974 record_alignment (now_seg, state == MAP_ARM ? 2 : 1);
2976 if (TRANSITION (MAP_UNDEFINED, MAP_DATA))
2977 /* This case will be evaluated later. */
2980 mapping_state_2 (state, 0);
2983 /* Same as mapping_state, but MAX_CHARS bytes have already been
2984 allocated. Put the mapping symbol that far back. */
2987 mapping_state_2 (enum mstate state, int max_chars)
2989 enum mstate mapstate = seg_info (now_seg)->tc_segment_info_data.mapstate;
2991 if (!SEG_NORMAL (now_seg))
2994 if (mapstate == state)
2995 /* The mapping symbol has already been emitted.
2996 There is nothing else to do. */
2999 if (TRANSITION (MAP_UNDEFINED, MAP_ARM)
3000 || TRANSITION (MAP_UNDEFINED, MAP_THUMB))
3002 struct frag * const frag_first = seg_info (now_seg)->frchainP->frch_root;
3003 const int add_symbol = (frag_now != frag_first) || (frag_now_fix () > 0);
3006 make_mapping_symbol (MAP_DATA, (valueT) 0, frag_first);
3009 seg_info (now_seg)->tc_segment_info_data.mapstate = state;
3010 make_mapping_symbol (state, (valueT) frag_now_fix () - max_chars, frag_now);
3014 #define mapping_state(x) ((void)0)
3015 #define mapping_state_2(x, y) ((void)0)
3018 /* Find the real, Thumb encoded start of a Thumb function. */
3022 find_real_start (symbolS * symbolP)
3025 const char * name = S_GET_NAME (symbolP);
3026 symbolS * new_target;
3028 /* This definition must agree with the one in gcc/config/arm/thumb.c. */
3029 #define STUB_NAME ".real_start_of"
3034 /* The compiler may generate BL instructions to local labels because
3035 it needs to perform a branch to a far away location. These labels
3036 do not have a corresponding ".real_start_of" label. We check
3037 both for S_IS_LOCAL and for a leading dot, to give a way to bypass
3038 the ".real_start_of" convention for nonlocal branches. */
3039 if (S_IS_LOCAL (symbolP) || name[0] == '.')
3042 real_start = concat (STUB_NAME, name, NULL);
3043 new_target = symbol_find (real_start);
3046 if (new_target == NULL)
3048 as_warn (_("Failed to find real start of function: %s\n"), name);
3049 new_target = symbolP;
3057 opcode_select (int width)
3064 if (!ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_v4t))
3065 as_bad (_("selected processor does not support THUMB opcodes"));
3068 /* No need to force the alignment, since we will have been
3069 coming from ARM mode, which is word-aligned. */
3070 record_alignment (now_seg, 1);
3077 if (!ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_v1))
3078 as_bad (_("selected processor does not support ARM opcodes"));
3083 frag_align (2, 0, 0);
3085 record_alignment (now_seg, 1);
3090 as_bad (_("invalid instruction size selected (%d)"), width);
3095 s_arm (int ignore ATTRIBUTE_UNUSED)
3098 demand_empty_rest_of_line ();
3102 s_thumb (int ignore ATTRIBUTE_UNUSED)
3105 demand_empty_rest_of_line ();
3109 s_code (int unused ATTRIBUTE_UNUSED)
3113 temp = get_absolute_expression ();
3118 opcode_select (temp);
3122 as_bad (_("invalid operand to .code directive (%d) (expecting 16 or 32)"), temp);
3127 s_force_thumb (int ignore ATTRIBUTE_UNUSED)
3129 /* If we are not already in thumb mode go into it, EVEN if
3130 the target processor does not support thumb instructions.
3131 This is used by gcc/config/arm/lib1funcs.asm for example
3132 to compile interworking support functions even if the
3133 target processor should not support interworking. */
3137 record_alignment (now_seg, 1);
3140 demand_empty_rest_of_line ();
3144 s_thumb_func (int ignore ATTRIBUTE_UNUSED)
3148 /* The following label is the name/address of the start of a Thumb function.
3149 We need to know this for the interworking support. */
3150 label_is_thumb_function_name = TRUE;
3153 /* Perform a .set directive, but also mark the alias as
3154 being a thumb function. */
3157 s_thumb_set (int equiv)
3159 /* XXX the following is a duplicate of the code for s_set() in read.c
3160 We cannot just call that code as we need to get at the symbol that
3167 /* Especial apologies for the random logic:
3168 This just grew, and could be parsed much more simply!
3170 delim = get_symbol_name (& name);
3171 end_name = input_line_pointer;
3172 (void) restore_line_pointer (delim);
3174 if (*input_line_pointer != ',')
3177 as_bad (_("expected comma after name \"%s\""), name);
3179 ignore_rest_of_line ();
3183 input_line_pointer++;
3186 if (name[0] == '.' && name[1] == '\0')
3188 /* XXX - this should not happen to .thumb_set. */
3192 if ((symbolP = symbol_find (name)) == NULL
3193 && (symbolP = md_undefined_symbol (name)) == NULL)
3196 /* When doing symbol listings, play games with dummy fragments living
3197 outside the normal fragment chain to record the file and line info
3199 if (listing & LISTING_SYMBOLS)
3201 extern struct list_info_struct * listing_tail;
3202 fragS * dummy_frag = (fragS * ) xmalloc (sizeof (fragS));
3204 memset (dummy_frag, 0, sizeof (fragS));
3205 dummy_frag->fr_type = rs_fill;
3206 dummy_frag->line = listing_tail;
3207 symbolP = symbol_new (name, undefined_section, 0, dummy_frag);
3208 dummy_frag->fr_symbol = symbolP;
3212 symbolP = symbol_new (name, undefined_section, 0, &zero_address_frag);
3215 /* "set" symbols are local unless otherwise specified. */
3216 SF_SET_LOCAL (symbolP);
3217 #endif /* OBJ_COFF */
3218 } /* Make a new symbol. */
3220 symbol_table_insert (symbolP);
3225 && S_IS_DEFINED (symbolP)
3226 && S_GET_SEGMENT (symbolP) != reg_section)
3227 as_bad (_("symbol `%s' already defined"), S_GET_NAME (symbolP));
3229 pseudo_set (symbolP);
3231 demand_empty_rest_of_line ();
3233 /* XXX Now we come to the Thumb specific bit of code. */
3235 THUMB_SET_FUNC (symbolP, 1);
3236 ARM_SET_THUMB (symbolP, 1);
3237 #if defined OBJ_ELF || defined OBJ_COFF
3238 ARM_SET_INTERWORK (symbolP, support_interwork);
3242 /* Directives: Mode selection. */
3244 /* .syntax [unified|divided] - choose the new unified syntax
3245 (same for Arm and Thumb encoding, modulo slight differences in what
3246 can be represented) or the old divergent syntax for each mode. */
3248 s_syntax (int unused ATTRIBUTE_UNUSED)
3252 delim = get_symbol_name (& name);
3254 if (!strcasecmp (name, "unified"))
3255 unified_syntax = TRUE;
3256 else if (!strcasecmp (name, "divided"))
3257 unified_syntax = FALSE;
3260 as_bad (_("unrecognized syntax mode \"%s\""), name);
3263 (void) restore_line_pointer (delim);
3264 demand_empty_rest_of_line ();
3267 /* Directives: sectioning and alignment. */
3270 s_bss (int ignore ATTRIBUTE_UNUSED)
3272 /* We don't support putting frags in the BSS segment, we fake it by
3273 marking in_bss, then looking at s_skip for clues. */
3274 subseg_set (bss_section, 0);
3275 demand_empty_rest_of_line ();
3277 #ifdef md_elf_section_change_hook
3278 md_elf_section_change_hook ();
3283 s_even (int ignore ATTRIBUTE_UNUSED)
3285 /* Never make frag if expect extra pass. */
3287 frag_align (1, 0, 0);
3289 record_alignment (now_seg, 1);
3291 demand_empty_rest_of_line ();
3294 /* Directives: CodeComposer Studio. */
3296 /* .ref (for CodeComposer Studio syntax only). */
3298 s_ccs_ref (int unused ATTRIBUTE_UNUSED)
3300 if (codecomposer_syntax)
3301 ignore_rest_of_line ();
3303 as_bad (_(".ref pseudo-op only available with -mccs flag."));
3306 /* If name is not NULL, then it is used for marking the beginning of a
3307 function, whereas if it is NULL then it means the function end. */
3309 asmfunc_debug (const char * name)
3311 static const char * last_name = NULL;
3315 gas_assert (last_name == NULL);
3318 if (debug_type == DEBUG_STABS)
3319 stabs_generate_asm_func (name, name);
3323 gas_assert (last_name != NULL);
3325 if (debug_type == DEBUG_STABS)
3326 stabs_generate_asm_endfunc (last_name, last_name);
3333 s_ccs_asmfunc (int unused ATTRIBUTE_UNUSED)
3335 if (codecomposer_syntax)
3337 switch (asmfunc_state)
3339 case OUTSIDE_ASMFUNC:
3340 asmfunc_state = WAITING_ASMFUNC_NAME;
3343 case WAITING_ASMFUNC_NAME:
3344 as_bad (_(".asmfunc repeated."));
3347 case WAITING_ENDASMFUNC:
3348 as_bad (_(".asmfunc without function."));
3351 demand_empty_rest_of_line ();
3354 as_bad (_(".asmfunc pseudo-op only available with -mccs flag."));
3358 s_ccs_endasmfunc (int unused ATTRIBUTE_UNUSED)
3360 if (codecomposer_syntax)
3362 switch (asmfunc_state)
3364 case OUTSIDE_ASMFUNC:
3365 as_bad (_(".endasmfunc without a .asmfunc."));
3368 case WAITING_ASMFUNC_NAME:
3369 as_bad (_(".endasmfunc without function."));
3372 case WAITING_ENDASMFUNC:
3373 asmfunc_state = OUTSIDE_ASMFUNC;
3374 asmfunc_debug (NULL);
3377 demand_empty_rest_of_line ();
3380 as_bad (_(".endasmfunc pseudo-op only available with -mccs flag."));
3384 s_ccs_def (int name)
3386 if (codecomposer_syntax)
3389 as_bad (_(".def pseudo-op only available with -mccs flag."));
3392 /* Directives: Literal pools. */
3394 static literal_pool *
3395 find_literal_pool (void)
3397 literal_pool * pool;
3399 for (pool = list_of_pools; pool != NULL; pool = pool->next)
3401 if (pool->section == now_seg
3402 && pool->sub_section == now_subseg)
3409 static literal_pool *
3410 find_or_make_literal_pool (void)
3412 /* Next literal pool ID number. */
3413 static unsigned int latest_pool_num = 1;
3414 literal_pool * pool;
3416 pool = find_literal_pool ();
3420 /* Create a new pool. */
3421 pool = XNEW (literal_pool);
3425 pool->next_free_entry = 0;
3426 pool->section = now_seg;
3427 pool->sub_section = now_subseg;
3428 pool->next = list_of_pools;
3429 pool->symbol = NULL;
3430 pool->alignment = 2;
3432 /* Add it to the list. */
3433 list_of_pools = pool;
3436 /* New pools, and emptied pools, will have a NULL symbol. */
3437 if (pool->symbol == NULL)
3439 pool->symbol = symbol_create (FAKE_LABEL_NAME, undefined_section,
3440 (valueT) 0, &zero_address_frag);
3441 pool->id = latest_pool_num ++;
3448 /* Add the literal in the global 'inst'
3449 structure to the relevant literal pool. */
3452 add_to_lit_pool (unsigned int nbytes)
3454 #define PADDING_SLOT 0x1
3455 #define LIT_ENTRY_SIZE_MASK 0xFF
3456 literal_pool * pool;
3457 unsigned int entry, pool_size = 0;
3458 bfd_boolean padding_slot_p = FALSE;
3464 imm1 = inst.operands[1].imm;
3465 imm2 = (inst.operands[1].regisimm ? inst.operands[1].reg
3466 : inst.relocs[0].exp.X_unsigned ? 0
3467 : ((bfd_int64_t) inst.operands[1].imm) >> 32);
3468 if (target_big_endian)
3471 imm2 = inst.operands[1].imm;
3475 pool = find_or_make_literal_pool ();
3477 /* Check if this literal value is already in the pool. */
3478 for (entry = 0; entry < pool->next_free_entry; entry ++)
3482 if ((pool->literals[entry].X_op == inst.relocs[0].exp.X_op)
3483 && (inst.relocs[0].exp.X_op == O_constant)
3484 && (pool->literals[entry].X_add_number
3485 == inst.relocs[0].exp.X_add_number)
3486 && (pool->literals[entry].X_md == nbytes)
3487 && (pool->literals[entry].X_unsigned
3488 == inst.relocs[0].exp.X_unsigned))
3491 if ((pool->literals[entry].X_op == inst.relocs[0].exp.X_op)
3492 && (inst.relocs[0].exp.X_op == O_symbol)
3493 && (pool->literals[entry].X_add_number
3494 == inst.relocs[0].exp.X_add_number)
3495 && (pool->literals[entry].X_add_symbol
3496 == inst.relocs[0].exp.X_add_symbol)
3497 && (pool->literals[entry].X_op_symbol
3498 == inst.relocs[0].exp.X_op_symbol)
3499 && (pool->literals[entry].X_md == nbytes))
3502 else if ((nbytes == 8)
3503 && !(pool_size & 0x7)
3504 && ((entry + 1) != pool->next_free_entry)
3505 && (pool->literals[entry].X_op == O_constant)
3506 && (pool->literals[entry].X_add_number == (offsetT) imm1)
3507 && (pool->literals[entry].X_unsigned
3508 == inst.relocs[0].exp.X_unsigned)
3509 && (pool->literals[entry + 1].X_op == O_constant)
3510 && (pool->literals[entry + 1].X_add_number == (offsetT) imm2)
3511 && (pool->literals[entry + 1].X_unsigned
3512 == inst.relocs[0].exp.X_unsigned))
3515 padding_slot_p = ((pool->literals[entry].X_md >> 8) == PADDING_SLOT);
3516 if (padding_slot_p && (nbytes == 4))
3522 /* Do we need to create a new entry? */
3523 if (entry == pool->next_free_entry)
3525 if (entry >= MAX_LITERAL_POOL_SIZE)
3527 inst.error = _("literal pool overflow");
3533 /* For 8-byte entries, we align to an 8-byte boundary,
3534 and split it into two 4-byte entries, because on 32-bit
3535 host, 8-byte constants are treated as big num, thus
3536 saved in "generic_bignum" which will be overwritten
3537 by later assignments.
3539 We also need to make sure there is enough space for
3542 We also check to make sure the literal operand is a
3544 if (!(inst.relocs[0].exp.X_op == O_constant
3545 || inst.relocs[0].exp.X_op == O_big))
3547 inst.error = _("invalid type for literal pool");
3550 else if (pool_size & 0x7)
3552 if ((entry + 2) >= MAX_LITERAL_POOL_SIZE)
3554 inst.error = _("literal pool overflow");
3558 pool->literals[entry] = inst.relocs[0].exp;
3559 pool->literals[entry].X_op = O_constant;
3560 pool->literals[entry].X_add_number = 0;
3561 pool->literals[entry++].X_md = (PADDING_SLOT << 8) | 4;
3562 pool->next_free_entry += 1;
3565 else if ((entry + 1) >= MAX_LITERAL_POOL_SIZE)
3567 inst.error = _("literal pool overflow");
3571 pool->literals[entry] = inst.relocs[0].exp;
3572 pool->literals[entry].X_op = O_constant;
3573 pool->literals[entry].X_add_number = imm1;
3574 pool->literals[entry].X_unsigned = inst.relocs[0].exp.X_unsigned;
3575 pool->literals[entry++].X_md = 4;
3576 pool->literals[entry] = inst.relocs[0].exp;
3577 pool->literals[entry].X_op = O_constant;
3578 pool->literals[entry].X_add_number = imm2;
3579 pool->literals[entry].X_unsigned = inst.relocs[0].exp.X_unsigned;
3580 pool->literals[entry].X_md = 4;
3581 pool->alignment = 3;
3582 pool->next_free_entry += 1;
3586 pool->literals[entry] = inst.relocs[0].exp;
3587 pool->literals[entry].X_md = 4;
3591 /* PR ld/12974: Record the location of the first source line to reference
3592 this entry in the literal pool. If it turns out during linking that the
3593 symbol does not exist we will be able to give an accurate line number for
3594 the (first use of the) missing reference. */
3595 if (debug_type == DEBUG_DWARF2)
3596 dwarf2_where (pool->locs + entry);
3598 pool->next_free_entry += 1;
3600 else if (padding_slot_p)
3602 pool->literals[entry] = inst.relocs[0].exp;
3603 pool->literals[entry].X_md = nbytes;
3606 inst.relocs[0].exp.X_op = O_symbol;
3607 inst.relocs[0].exp.X_add_number = pool_size;
3608 inst.relocs[0].exp.X_add_symbol = pool->symbol;
3614 tc_start_label_without_colon (void)
3616 bfd_boolean ret = TRUE;
3618 if (codecomposer_syntax && asmfunc_state == WAITING_ASMFUNC_NAME)
3620 const char *label = input_line_pointer;
3622 while (!is_end_of_line[(int) label[-1]])
3627 as_bad (_("Invalid label '%s'"), label);
3631 asmfunc_debug (label);
3633 asmfunc_state = WAITING_ENDASMFUNC;
3639 /* Can't use symbol_new here, so have to create a symbol and then at
3640 a later date assign it a value. That's what these functions do. */
3643 symbol_locate (symbolS * symbolP,
3644 const char * name, /* It is copied, the caller can modify. */
3645 segT segment, /* Segment identifier (SEG_<something>). */
3646 valueT valu, /* Symbol value. */
3647 fragS * frag) /* Associated fragment. */
3650 char * preserved_copy_of_name;
3652 name_length = strlen (name) + 1; /* +1 for \0. */
3653 obstack_grow (¬es, name, name_length);
3654 preserved_copy_of_name = (char *) obstack_finish (¬es);
3656 #ifdef tc_canonicalize_symbol_name
3657 preserved_copy_of_name =
3658 tc_canonicalize_symbol_name (preserved_copy_of_name);
3661 S_SET_NAME (symbolP, preserved_copy_of_name);
3663 S_SET_SEGMENT (symbolP, segment);
3664 S_SET_VALUE (symbolP, valu);
3665 symbol_clear_list_pointers (symbolP);
3667 symbol_set_frag (symbolP, frag);
3669 /* Link to end of symbol chain. */
3671 extern int symbol_table_frozen;
3673 if (symbol_table_frozen)
3677 symbol_append (symbolP, symbol_lastP, & symbol_rootP, & symbol_lastP);
3679 obj_symbol_new_hook (symbolP);
3681 #ifdef tc_symbol_new_hook
3682 tc_symbol_new_hook (symbolP);
3686 verify_symbol_chain (symbol_rootP, symbol_lastP);
3687 #endif /* DEBUG_SYMS */
3691 s_ltorg (int ignored ATTRIBUTE_UNUSED)
3694 literal_pool * pool;
3697 pool = find_literal_pool ();
3699 || pool->symbol == NULL
3700 || pool->next_free_entry == 0)
3703 /* Align pool as you have word accesses.
3704 Only make a frag if we have to. */
3706 frag_align (pool->alignment, 0, 0);
3708 record_alignment (now_seg, 2);
3711 seg_info (now_seg)->tc_segment_info_data.mapstate = MAP_DATA;
3712 make_mapping_symbol (MAP_DATA, (valueT) frag_now_fix (), frag_now);
3714 sprintf (sym_name, "$$lit_\002%x", pool->id);
3716 symbol_locate (pool->symbol, sym_name, now_seg,
3717 (valueT) frag_now_fix (), frag_now);
3718 symbol_table_insert (pool->symbol);
3720 ARM_SET_THUMB (pool->symbol, thumb_mode);
3722 #if defined OBJ_COFF || defined OBJ_ELF
3723 ARM_SET_INTERWORK (pool->symbol, support_interwork);
3726 for (entry = 0; entry < pool->next_free_entry; entry ++)
3729 if (debug_type == DEBUG_DWARF2)
3730 dwarf2_gen_line_info (frag_now_fix (), pool->locs + entry);
3732 /* First output the expression in the instruction to the pool. */
3733 emit_expr (&(pool->literals[entry]),
3734 pool->literals[entry].X_md & LIT_ENTRY_SIZE_MASK);
3737 /* Mark the pool as empty. */
3738 pool->next_free_entry = 0;
3739 pool->symbol = NULL;
3743 /* Forward declarations for functions below, in the MD interface
3745 static void fix_new_arm (fragS *, int, short, expressionS *, int, int);
3746 static valueT create_unwind_entry (int);
3747 static void start_unwind_section (const segT, int);
3748 static void add_unwind_opcode (valueT, int);
3749 static void flush_pending_unwind (void);
3751 /* Directives: Data. */
3754 s_arm_elf_cons (int nbytes)
3758 #ifdef md_flush_pending_output
3759 md_flush_pending_output ();
3762 if (is_it_end_of_statement ())
3764 demand_empty_rest_of_line ();
3768 #ifdef md_cons_align
3769 md_cons_align (nbytes);
3772 mapping_state (MAP_DATA);
3776 char *base = input_line_pointer;
3780 if (exp.X_op != O_symbol)
3781 emit_expr (&exp, (unsigned int) nbytes);
3784 char *before_reloc = input_line_pointer;
3785 reloc = parse_reloc (&input_line_pointer);
3788 as_bad (_("unrecognized relocation suffix"));
3789 ignore_rest_of_line ();
3792 else if (reloc == BFD_RELOC_UNUSED)
3793 emit_expr (&exp, (unsigned int) nbytes);
3796 reloc_howto_type *howto = (reloc_howto_type *)
3797 bfd_reloc_type_lookup (stdoutput,
3798 (bfd_reloc_code_real_type) reloc);
3799 int size = bfd_get_reloc_size (howto);
3801 if (reloc == BFD_RELOC_ARM_PLT32)
3803 as_bad (_("(plt) is only valid on branch targets"));
3804 reloc = BFD_RELOC_UNUSED;
3809 as_bad (ngettext ("%s relocations do not fit in %d byte",
3810 "%s relocations do not fit in %d bytes",
3812 howto->name, nbytes);
3815 /* We've parsed an expression stopping at O_symbol.
3816 But there may be more expression left now that we
3817 have parsed the relocation marker. Parse it again.
3818 XXX Surely there is a cleaner way to do this. */
3819 char *p = input_line_pointer;
3821 char *save_buf = XNEWVEC (char, input_line_pointer - base);
3823 memcpy (save_buf, base, input_line_pointer - base);
3824 memmove (base + (input_line_pointer - before_reloc),
3825 base, before_reloc - base);
3827 input_line_pointer = base + (input_line_pointer-before_reloc);
3829 memcpy (base, save_buf, p - base);
3831 offset = nbytes - size;
3832 p = frag_more (nbytes);
3833 memset (p, 0, nbytes);
3834 fix_new_exp (frag_now, p - frag_now->fr_literal + offset,
3835 size, &exp, 0, (enum bfd_reloc_code_real) reloc);
3841 while (*input_line_pointer++ == ',');
3843 /* Put terminator back into stream. */
3844 input_line_pointer --;
3845 demand_empty_rest_of_line ();
3848 /* Emit an expression containing a 32-bit thumb instruction.
3849 Implementation based on put_thumb32_insn. */
3852 emit_thumb32_expr (expressionS * exp)
3854 expressionS exp_high = *exp;
3856 exp_high.X_add_number = (unsigned long)exp_high.X_add_number >> 16;
3857 emit_expr (& exp_high, (unsigned int) THUMB_SIZE);
3858 exp->X_add_number &= 0xffff;
3859 emit_expr (exp, (unsigned int) THUMB_SIZE);
3862 /* Guess the instruction size based on the opcode. */
3865 thumb_insn_size (int opcode)
3867 if ((unsigned int) opcode < 0xe800u)
3869 else if ((unsigned int) opcode >= 0xe8000000u)
3876 emit_insn (expressionS *exp, int nbytes)
3880 if (exp->X_op == O_constant)
3885 size = thumb_insn_size (exp->X_add_number);
3889 if (size == 2 && (unsigned int)exp->X_add_number > 0xffffu)
3891 as_bad (_(".inst.n operand too big. "\
3892 "Use .inst.w instead"));
3897 if (now_pred.state == AUTOMATIC_PRED_BLOCK)
3898 set_pred_insn_type_nonvoid (OUTSIDE_PRED_INSN, 0);
3900 set_pred_insn_type_nonvoid (NEUTRAL_IT_INSN, 0);
3902 if (thumb_mode && (size > THUMB_SIZE) && !target_big_endian)
3903 emit_thumb32_expr (exp);
3905 emit_expr (exp, (unsigned int) size);
3907 it_fsm_post_encode ();
3911 as_bad (_("cannot determine Thumb instruction size. " \
3912 "Use .inst.n/.inst.w instead"));
3915 as_bad (_("constant expression required"));
3920 /* Like s_arm_elf_cons but do not use md_cons_align and
3921 set the mapping state to MAP_ARM/MAP_THUMB. */
3924 s_arm_elf_inst (int nbytes)
3926 if (is_it_end_of_statement ())
3928 demand_empty_rest_of_line ();
3932 /* Calling mapping_state () here will not change ARM/THUMB,
3933 but will ensure not to be in DATA state. */
3936 mapping_state (MAP_THUMB);
3941 as_bad (_("width suffixes are invalid in ARM mode"));
3942 ignore_rest_of_line ();
3948 mapping_state (MAP_ARM);
3957 if (! emit_insn (& exp, nbytes))
3959 ignore_rest_of_line ();
3963 while (*input_line_pointer++ == ',');
3965 /* Put terminator back into stream. */
3966 input_line_pointer --;
3967 demand_empty_rest_of_line ();
3970 /* Parse a .rel31 directive. */
3973 s_arm_rel31 (int ignored ATTRIBUTE_UNUSED)
3980 if (*input_line_pointer == '1')
3981 highbit = 0x80000000;
3982 else if (*input_line_pointer != '0')
3983 as_bad (_("expected 0 or 1"));
3985 input_line_pointer++;
3986 if (*input_line_pointer != ',')
3987 as_bad (_("missing comma"));
3988 input_line_pointer++;
3990 #ifdef md_flush_pending_output
3991 md_flush_pending_output ();
3994 #ifdef md_cons_align
3998 mapping_state (MAP_DATA);
4003 md_number_to_chars (p, highbit, 4);
4004 fix_new_arm (frag_now, p - frag_now->fr_literal, 4, &exp, 1,
4005 BFD_RELOC_ARM_PREL31);
4007 demand_empty_rest_of_line ();
4010 /* Directives: AEABI stack-unwind tables. */
4012 /* Parse an unwind_fnstart directive. Simply records the current location. */
4015 s_arm_unwind_fnstart (int ignored ATTRIBUTE_UNUSED)
4017 demand_empty_rest_of_line ();
4018 if (unwind.proc_start)
4020 as_bad (_("duplicate .fnstart directive"));
4024 /* Mark the start of the function. */
4025 unwind.proc_start = expr_build_dot ();
4027 /* Reset the rest of the unwind info. */
4028 unwind.opcode_count = 0;
4029 unwind.table_entry = NULL;
4030 unwind.personality_routine = NULL;
4031 unwind.personality_index = -1;
4032 unwind.frame_size = 0;
4033 unwind.fp_offset = 0;
4034 unwind.fp_reg = REG_SP;
4036 unwind.sp_restored = 0;
4040 /* Parse a handlerdata directive. Creates the exception handling table entry
4041 for the function. */
4044 s_arm_unwind_handlerdata (int ignored ATTRIBUTE_UNUSED)
4046 demand_empty_rest_of_line ();
4047 if (!unwind.proc_start)
4048 as_bad (MISSING_FNSTART);
4050 if (unwind.table_entry)
4051 as_bad (_("duplicate .handlerdata directive"));
4053 create_unwind_entry (1);
4056 /* Parse an unwind_fnend directive. Generates the index table entry. */
4059 s_arm_unwind_fnend (int ignored ATTRIBUTE_UNUSED)
4064 unsigned int marked_pr_dependency;
4066 demand_empty_rest_of_line ();
4068 if (!unwind.proc_start)
4070 as_bad (_(".fnend directive without .fnstart"));
4074 /* Add eh table entry. */
4075 if (unwind.table_entry == NULL)
4076 val = create_unwind_entry (0);
4080 /* Add index table entry. This is two words. */
4081 start_unwind_section (unwind.saved_seg, 1);
4082 frag_align (2, 0, 0);
4083 record_alignment (now_seg, 2);
4085 ptr = frag_more (8);
4087 where = frag_now_fix () - 8;
4089 /* Self relative offset of the function start. */
4090 fix_new (frag_now, where, 4, unwind.proc_start, 0, 1,
4091 BFD_RELOC_ARM_PREL31);
4093 /* Indicate dependency on EHABI-defined personality routines to the
4094 linker, if it hasn't been done already. */
4095 marked_pr_dependency
4096 = seg_info (now_seg)->tc_segment_info_data.marked_pr_dependency;
4097 if (unwind.personality_index >= 0 && unwind.personality_index < 3
4098 && !(marked_pr_dependency & (1 << unwind.personality_index)))
4100 static const char *const name[] =
4102 "__aeabi_unwind_cpp_pr0",
4103 "__aeabi_unwind_cpp_pr1",
4104 "__aeabi_unwind_cpp_pr2"
4106 symbolS *pr = symbol_find_or_make (name[unwind.personality_index]);
4107 fix_new (frag_now, where, 0, pr, 0, 1, BFD_RELOC_NONE);
4108 seg_info (now_seg)->tc_segment_info_data.marked_pr_dependency
4109 |= 1 << unwind.personality_index;
4113 /* Inline exception table entry. */
4114 md_number_to_chars (ptr + 4, val, 4);
4116 /* Self relative offset of the table entry. */
4117 fix_new (frag_now, where + 4, 4, unwind.table_entry, 0, 1,
4118 BFD_RELOC_ARM_PREL31);
4120 /* Restore the original section. */
4121 subseg_set (unwind.saved_seg, unwind.saved_subseg);
4123 unwind.proc_start = NULL;
4127 /* Parse an unwind_cantunwind directive. */
4130 s_arm_unwind_cantunwind (int ignored ATTRIBUTE_UNUSED)
4132 demand_empty_rest_of_line ();
4133 if (!unwind.proc_start)
4134 as_bad (MISSING_FNSTART);
4136 if (unwind.personality_routine || unwind.personality_index != -1)
4137 as_bad (_("personality routine specified for cantunwind frame"));
4139 unwind.personality_index = -2;
4143 /* Parse a personalityindex directive. */
4146 s_arm_unwind_personalityindex (int ignored ATTRIBUTE_UNUSED)
4150 if (!unwind.proc_start)
4151 as_bad (MISSING_FNSTART);
4153 if (unwind.personality_routine || unwind.personality_index != -1)
4154 as_bad (_("duplicate .personalityindex directive"));
4158 if (exp.X_op != O_constant
4159 || exp.X_add_number < 0 || exp.X_add_number > 15)
4161 as_bad (_("bad personality routine number"));
4162 ignore_rest_of_line ();
4166 unwind.personality_index = exp.X_add_number;
4168 demand_empty_rest_of_line ();
4172 /* Parse a personality directive. */
4175 s_arm_unwind_personality (int ignored ATTRIBUTE_UNUSED)
4179 if (!unwind.proc_start)
4180 as_bad (MISSING_FNSTART);
4182 if (unwind.personality_routine || unwind.personality_index != -1)
4183 as_bad (_("duplicate .personality directive"));
4185 c = get_symbol_name (& name);
4186 p = input_line_pointer;
4188 ++ input_line_pointer;
4189 unwind.personality_routine = symbol_find_or_make (name);
4191 demand_empty_rest_of_line ();
4195 /* Parse a directive saving core registers. */
4198 s_arm_unwind_save_core (void)
4204 range = parse_reg_list (&input_line_pointer, REGLIST_RN);
4207 as_bad (_("expected register list"));
4208 ignore_rest_of_line ();
4212 demand_empty_rest_of_line ();
4214 /* Turn .unwind_movsp ip followed by .unwind_save {..., ip, ...}
4215 into .unwind_save {..., sp...}. We aren't bothered about the value of
4216 ip because it is clobbered by calls. */
4217 if (unwind.sp_restored && unwind.fp_reg == 12
4218 && (range & 0x3000) == 0x1000)
4220 unwind.opcode_count--;
4221 unwind.sp_restored = 0;
4222 range = (range | 0x2000) & ~0x1000;
4223 unwind.pending_offset = 0;
4229 /* See if we can use the short opcodes. These pop a block of up to 8
4230 registers starting with r4, plus maybe r14. */
4231 for (n = 0; n < 8; n++)
4233 /* Break at the first non-saved register. */
4234 if ((range & (1 << (n + 4))) == 0)
4237 /* See if there are any other bits set. */
4238 if (n == 0 || (range & (0xfff0 << n) & 0xbff0) != 0)
4240 /* Use the long form. */
4241 op = 0x8000 | ((range >> 4) & 0xfff);
4242 add_unwind_opcode (op, 2);
4246 /* Use the short form. */
4248 op = 0xa8; /* Pop r14. */
4250 op = 0xa0; /* Do not pop r14. */
4252 add_unwind_opcode (op, 1);
4259 op = 0xb100 | (range & 0xf);
4260 add_unwind_opcode (op, 2);
4263 /* Record the number of bytes pushed. */
4264 for (n = 0; n < 16; n++)
4266 if (range & (1 << n))
4267 unwind.frame_size += 4;
4272 /* Parse a directive saving FPA registers. */
4275 s_arm_unwind_save_fpa (int reg)
4281 /* Get Number of registers to transfer. */
4282 if (skip_past_comma (&input_line_pointer) != FAIL)
4285 exp.X_op = O_illegal;
4287 if (exp.X_op != O_constant)
4289 as_bad (_("expected , <constant>"));
4290 ignore_rest_of_line ();
4294 num_regs = exp.X_add_number;
4296 if (num_regs < 1 || num_regs > 4)
4298 as_bad (_("number of registers must be in the range [1:4]"));
4299 ignore_rest_of_line ();
4303 demand_empty_rest_of_line ();
4308 op = 0xb4 | (num_regs - 1);
4309 add_unwind_opcode (op, 1);
4314 op = 0xc800 | (reg << 4) | (num_regs - 1);
4315 add_unwind_opcode (op, 2);
4317 unwind.frame_size += num_regs * 12;
4321 /* Parse a directive saving VFP registers for ARMv6 and above. */
4324 s_arm_unwind_save_vfp_armv6 (void)
4329 int num_vfpv3_regs = 0;
4330 int num_regs_below_16;
4331 bfd_boolean partial_match;
4333 count = parse_vfp_reg_list (&input_line_pointer, &start, REGLIST_VFP_D,
4337 as_bad (_("expected register list"));
4338 ignore_rest_of_line ();
4342 demand_empty_rest_of_line ();
4344 /* We always generate FSTMD/FLDMD-style unwinding opcodes (rather
4345 than FSTMX/FLDMX-style ones). */
4347 /* Generate opcode for (VFPv3) registers numbered in the range 16 .. 31. */
4349 num_vfpv3_regs = count;
4350 else if (start + count > 16)
4351 num_vfpv3_regs = start + count - 16;
4353 if (num_vfpv3_regs > 0)
4355 int start_offset = start > 16 ? start - 16 : 0;
4356 op = 0xc800 | (start_offset << 4) | (num_vfpv3_regs - 1);
4357 add_unwind_opcode (op, 2);
4360 /* Generate opcode for registers numbered in the range 0 .. 15. */
4361 num_regs_below_16 = num_vfpv3_regs > 0 ? 16 - (int) start : count;
4362 gas_assert (num_regs_below_16 + num_vfpv3_regs == count);
4363 if (num_regs_below_16 > 0)
4365 op = 0xc900 | (start << 4) | (num_regs_below_16 - 1);
4366 add_unwind_opcode (op, 2);
4369 unwind.frame_size += count * 8;
4373 /* Parse a directive saving VFP registers for pre-ARMv6. */
4376 s_arm_unwind_save_vfp (void)
4381 bfd_boolean partial_match;
4383 count = parse_vfp_reg_list (&input_line_pointer, ®, REGLIST_VFP_D,
4387 as_bad (_("expected register list"));
4388 ignore_rest_of_line ();
4392 demand_empty_rest_of_line ();
4397 op = 0xb8 | (count - 1);
4398 add_unwind_opcode (op, 1);
4403 op = 0xb300 | (reg << 4) | (count - 1);
4404 add_unwind_opcode (op, 2);
4406 unwind.frame_size += count * 8 + 4;
4410 /* Parse a directive saving iWMMXt data registers. */
4413 s_arm_unwind_save_mmxwr (void)
4421 if (*input_line_pointer == '{')
4422 input_line_pointer++;
4426 reg = arm_reg_parse (&input_line_pointer, REG_TYPE_MMXWR);
4430 as_bad ("%s", _(reg_expected_msgs[REG_TYPE_MMXWR]));
4435 as_tsktsk (_("register list not in ascending order"));
4438 if (*input_line_pointer == '-')
4440 input_line_pointer++;
4441 hi_reg = arm_reg_parse (&input_line_pointer, REG_TYPE_MMXWR);
4444 as_bad ("%s", _(reg_expected_msgs[REG_TYPE_MMXWR]));
4447 else if (reg >= hi_reg)
4449 as_bad (_("bad register range"));
4452 for (; reg < hi_reg; reg++)
4456 while (skip_past_comma (&input_line_pointer) != FAIL);
4458 skip_past_char (&input_line_pointer, '}');
4460 demand_empty_rest_of_line ();
4462 /* Generate any deferred opcodes because we're going to be looking at
4464 flush_pending_unwind ();
4466 for (i = 0; i < 16; i++)
4468 if (mask & (1 << i))
4469 unwind.frame_size += 8;
4472 /* Attempt to combine with a previous opcode. We do this because gcc
4473 likes to output separate unwind directives for a single block of
4475 if (unwind.opcode_count > 0)
4477 i = unwind.opcodes[unwind.opcode_count - 1];
4478 if ((i & 0xf8) == 0xc0)
4481 /* Only merge if the blocks are contiguous. */
4484 if ((mask & 0xfe00) == (1 << 9))
4486 mask |= ((1 << (i + 11)) - 1) & 0xfc00;
4487 unwind.opcode_count--;
4490 else if (i == 6 && unwind.opcode_count >= 2)
4492 i = unwind.opcodes[unwind.opcode_count - 2];
4496 op = 0xffff << (reg - 1);
4498 && ((mask & op) == (1u << (reg - 1))))
4500 op = (1 << (reg + i + 1)) - 1;
4501 op &= ~((1 << reg) - 1);
4503 unwind.opcode_count -= 2;
4510 /* We want to generate opcodes in the order the registers have been
4511 saved, ie. descending order. */
4512 for (reg = 15; reg >= -1; reg--)
4514 /* Save registers in blocks. */
4516 || !(mask & (1 << reg)))
4518 /* We found an unsaved reg. Generate opcodes to save the
4525 op = 0xc0 | (hi_reg - 10);
4526 add_unwind_opcode (op, 1);
4531 op = 0xc600 | ((reg + 1) << 4) | ((hi_reg - reg) - 1);
4532 add_unwind_opcode (op, 2);
4541 ignore_rest_of_line ();
4545 s_arm_unwind_save_mmxwcg (void)
4552 if (*input_line_pointer == '{')
4553 input_line_pointer++;
4555 skip_whitespace (input_line_pointer);
4559 reg = arm_reg_parse (&input_line_pointer, REG_TYPE_MMXWCG);
4563 as_bad ("%s", _(reg_expected_msgs[REG_TYPE_MMXWCG]));
4569 as_tsktsk (_("register list not in ascending order"));
4572 if (*input_line_pointer == '-')
4574 input_line_pointer++;
4575 hi_reg = arm_reg_parse (&input_line_pointer, REG_TYPE_MMXWCG);
4578 as_bad ("%s", _(reg_expected_msgs[REG_TYPE_MMXWCG]));
4581 else if (reg >= hi_reg)
4583 as_bad (_("bad register range"));
4586 for (; reg < hi_reg; reg++)
4590 while (skip_past_comma (&input_line_pointer) != FAIL);
4592 skip_past_char (&input_line_pointer, '}');
4594 demand_empty_rest_of_line ();
4596 /* Generate any deferred opcodes because we're going to be looking at
4598 flush_pending_unwind ();
4600 for (reg = 0; reg < 16; reg++)
4602 if (mask & (1 << reg))
4603 unwind.frame_size += 4;
4606 add_unwind_opcode (op, 2);
4609 ignore_rest_of_line ();
4613 /* Parse an unwind_save directive.
4614 If the argument is non-zero, this is a .vsave directive. */
4617 s_arm_unwind_save (int arch_v6)
4620 struct reg_entry *reg;
4621 bfd_boolean had_brace = FALSE;
4623 if (!unwind.proc_start)
4624 as_bad (MISSING_FNSTART);
4626 /* Figure out what sort of save we have. */
4627 peek = input_line_pointer;
4635 reg = arm_reg_parse_multi (&peek);
4639 as_bad (_("register expected"));
4640 ignore_rest_of_line ();
4649 as_bad (_("FPA .unwind_save does not take a register list"));
4650 ignore_rest_of_line ();
4653 input_line_pointer = peek;
4654 s_arm_unwind_save_fpa (reg->number);
4658 s_arm_unwind_save_core ();
4663 s_arm_unwind_save_vfp_armv6 ();
4665 s_arm_unwind_save_vfp ();
4668 case REG_TYPE_MMXWR:
4669 s_arm_unwind_save_mmxwr ();
4672 case REG_TYPE_MMXWCG:
4673 s_arm_unwind_save_mmxwcg ();
4677 as_bad (_(".unwind_save does not support this kind of register"));
4678 ignore_rest_of_line ();
4683 /* Parse an unwind_movsp directive. */
4686 s_arm_unwind_movsp (int ignored ATTRIBUTE_UNUSED)
4692 if (!unwind.proc_start)
4693 as_bad (MISSING_FNSTART);
4695 reg = arm_reg_parse (&input_line_pointer, REG_TYPE_RN);
4698 as_bad ("%s", _(reg_expected_msgs[REG_TYPE_RN]));
4699 ignore_rest_of_line ();
4703 /* Optional constant. */
4704 if (skip_past_comma (&input_line_pointer) != FAIL)
4706 if (immediate_for_directive (&offset) == FAIL)
4712 demand_empty_rest_of_line ();
4714 if (reg == REG_SP || reg == REG_PC)
4716 as_bad (_("SP and PC not permitted in .unwind_movsp directive"));
4720 if (unwind.fp_reg != REG_SP)
4721 as_bad (_("unexpected .unwind_movsp directive"));
4723 /* Generate opcode to restore the value. */
4725 add_unwind_opcode (op, 1);
4727 /* Record the information for later. */
4728 unwind.fp_reg = reg;
4729 unwind.fp_offset = unwind.frame_size - offset;
4730 unwind.sp_restored = 1;
4733 /* Parse an unwind_pad directive. */
4736 s_arm_unwind_pad (int ignored ATTRIBUTE_UNUSED)
4740 if (!unwind.proc_start)
4741 as_bad (MISSING_FNSTART);
4743 if (immediate_for_directive (&offset) == FAIL)
4748 as_bad (_("stack increment must be multiple of 4"));
4749 ignore_rest_of_line ();
4753 /* Don't generate any opcodes, just record the details for later. */
4754 unwind.frame_size += offset;
4755 unwind.pending_offset += offset;
4757 demand_empty_rest_of_line ();
4760 /* Parse an unwind_setfp directive. */
4763 s_arm_unwind_setfp (int ignored ATTRIBUTE_UNUSED)
4769 if (!unwind.proc_start)
4770 as_bad (MISSING_FNSTART);
4772 fp_reg = arm_reg_parse (&input_line_pointer, REG_TYPE_RN);
4773 if (skip_past_comma (&input_line_pointer) == FAIL)
4776 sp_reg = arm_reg_parse (&input_line_pointer, REG_TYPE_RN);
4778 if (fp_reg == FAIL || sp_reg == FAIL)
4780 as_bad (_("expected <reg>, <reg>"));
4781 ignore_rest_of_line ();
4785 /* Optional constant. */
4786 if (skip_past_comma (&input_line_pointer) != FAIL)
4788 if (immediate_for_directive (&offset) == FAIL)
4794 demand_empty_rest_of_line ();
4796 if (sp_reg != REG_SP && sp_reg != unwind.fp_reg)
4798 as_bad (_("register must be either sp or set by a previous"
4799 "unwind_movsp directive"));
4803 /* Don't generate any opcodes, just record the information for later. */
4804 unwind.fp_reg = fp_reg;
4806 if (sp_reg == REG_SP)
4807 unwind.fp_offset = unwind.frame_size - offset;
4809 unwind.fp_offset -= offset;
4812 /* Parse an unwind_raw directive. */
4815 s_arm_unwind_raw (int ignored ATTRIBUTE_UNUSED)
4818 /* This is an arbitrary limit. */
4819 unsigned char op[16];
4822 if (!unwind.proc_start)
4823 as_bad (MISSING_FNSTART);
4826 if (exp.X_op == O_constant
4827 && skip_past_comma (&input_line_pointer) != FAIL)
4829 unwind.frame_size += exp.X_add_number;
4833 exp.X_op = O_illegal;
4835 if (exp.X_op != O_constant)
4837 as_bad (_("expected <offset>, <opcode>"));
4838 ignore_rest_of_line ();
4844 /* Parse the opcode. */
4849 as_bad (_("unwind opcode too long"));
4850 ignore_rest_of_line ();
4852 if (exp.X_op != O_constant || exp.X_add_number & ~0xff)
4854 as_bad (_("invalid unwind opcode"));
4855 ignore_rest_of_line ();
4858 op[count++] = exp.X_add_number;
4860 /* Parse the next byte. */
4861 if (skip_past_comma (&input_line_pointer) == FAIL)
4867 /* Add the opcode bytes in reverse order. */
4869 add_unwind_opcode (op[count], 1);
4871 demand_empty_rest_of_line ();
4875 /* Parse a .eabi_attribute directive. */
4878 s_arm_eabi_attribute (int ignored ATTRIBUTE_UNUSED)
4880 int tag = obj_elf_vendor_attribute (OBJ_ATTR_PROC);
4882 if (tag >= 0 && tag < NUM_KNOWN_OBJ_ATTRIBUTES)
4883 attributes_set_explicitly[tag] = 1;
4886 /* Emit a tls fix for the symbol. */
4889 s_arm_tls_descseq (int ignored ATTRIBUTE_UNUSED)
4893 #ifdef md_flush_pending_output
4894 md_flush_pending_output ();
4897 #ifdef md_cons_align
4901 /* Since we're just labelling the code, there's no need to define a
4904 p = obstack_next_free (&frchain_now->frch_obstack);
4905 fix_new_arm (frag_now, p - frag_now->fr_literal, 4, &exp, 0,
4906 thumb_mode ? BFD_RELOC_ARM_THM_TLS_DESCSEQ
4907 : BFD_RELOC_ARM_TLS_DESCSEQ);
4909 #endif /* OBJ_ELF */
4911 static void s_arm_arch (int);
4912 static void s_arm_object_arch (int);
4913 static void s_arm_cpu (int);
4914 static void s_arm_fpu (int);
4915 static void s_arm_arch_extension (int);
4920 pe_directive_secrel (int dummy ATTRIBUTE_UNUSED)
4927 if (exp.X_op == O_symbol)
4928 exp.X_op = O_secrel;
4930 emit_expr (&exp, 4);
4932 while (*input_line_pointer++ == ',');
4934 input_line_pointer--;
4935 demand_empty_rest_of_line ();
4940 arm_is_largest_exponent_ok (int precision)
4942 /* precision == 1 ensures that this will only return
4943 true for 16 bit floats. */
4944 return (precision == 1) && (fp16_format == ARM_FP16_FORMAT_ALTERNATIVE);
4948 set_fp16_format (int dummy ATTRIBUTE_UNUSED)
4952 enum fp_16bit_format new_format;
4954 new_format = ARM_FP16_FORMAT_DEFAULT;
4956 name = input_line_pointer;
4957 while (*input_line_pointer && !ISSPACE (*input_line_pointer))
4958 input_line_pointer++;
4960 saved_char = *input_line_pointer;
4961 *input_line_pointer = 0;
4963 if (strcasecmp (name, "ieee") == 0)
4964 new_format = ARM_FP16_FORMAT_IEEE;
4965 else if (strcasecmp (name, "alternative") == 0)
4966 new_format = ARM_FP16_FORMAT_ALTERNATIVE;
4969 as_bad (_("unrecognised float16 format \"%s\""), name);
4973 /* Only set fp16_format if it is still the default (aka not already
4975 if (fp16_format == ARM_FP16_FORMAT_DEFAULT)
4976 fp16_format = new_format;
4979 if (new_format != fp16_format)
4980 as_warn (_("float16 format cannot be set more than once, ignoring."));
4984 *input_line_pointer = saved_char;
4985 ignore_rest_of_line ();
4988 /* This table describes all the machine specific pseudo-ops the assembler
4989 has to support. The fields are:
4990 pseudo-op name without dot
4991 function to call to execute this pseudo-op
4992 Integer arg to pass to the function. */
4994 const pseudo_typeS md_pseudo_table[] =
4996 /* Never called because '.req' does not start a line. */
4997 { "req", s_req, 0 },
4998 /* Following two are likewise never called. */
5001 { "unreq", s_unreq, 0 },
5002 { "bss", s_bss, 0 },
5003 { "align", s_align_ptwo, 2 },
5004 { "arm", s_arm, 0 },
5005 { "thumb", s_thumb, 0 },
5006 { "code", s_code, 0 },
5007 { "force_thumb", s_force_thumb, 0 },
5008 { "thumb_func", s_thumb_func, 0 },
5009 { "thumb_set", s_thumb_set, 0 },
5010 { "even", s_even, 0 },
5011 { "ltorg", s_ltorg, 0 },
5012 { "pool", s_ltorg, 0 },
5013 { "syntax", s_syntax, 0 },
5014 { "cpu", s_arm_cpu, 0 },
5015 { "arch", s_arm_arch, 0 },
5016 { "object_arch", s_arm_object_arch, 0 },
5017 { "fpu", s_arm_fpu, 0 },
5018 { "arch_extension", s_arm_arch_extension, 0 },
5020 { "word", s_arm_elf_cons, 4 },
5021 { "long", s_arm_elf_cons, 4 },
5022 { "inst.n", s_arm_elf_inst, 2 },
5023 { "inst.w", s_arm_elf_inst, 4 },
5024 { "inst", s_arm_elf_inst, 0 },
5025 { "rel31", s_arm_rel31, 0 },
5026 { "fnstart", s_arm_unwind_fnstart, 0 },
5027 { "fnend", s_arm_unwind_fnend, 0 },
5028 { "cantunwind", s_arm_unwind_cantunwind, 0 },
5029 { "personality", s_arm_unwind_personality, 0 },
5030 { "personalityindex", s_arm_unwind_personalityindex, 0 },
5031 { "handlerdata", s_arm_unwind_handlerdata, 0 },
5032 { "save", s_arm_unwind_save, 0 },
5033 { "vsave", s_arm_unwind_save, 1 },
5034 { "movsp", s_arm_unwind_movsp, 0 },
5035 { "pad", s_arm_unwind_pad, 0 },
5036 { "setfp", s_arm_unwind_setfp, 0 },
5037 { "unwind_raw", s_arm_unwind_raw, 0 },
5038 { "eabi_attribute", s_arm_eabi_attribute, 0 },
5039 { "tlsdescseq", s_arm_tls_descseq, 0 },
5043 /* These are used for dwarf. */
5047 /* These are used for dwarf2. */
5048 { "file", dwarf2_directive_file, 0 },
5049 { "loc", dwarf2_directive_loc, 0 },
5050 { "loc_mark_labels", dwarf2_directive_loc_mark_labels, 0 },
5052 { "extend", float_cons, 'x' },
5053 { "ldouble", float_cons, 'x' },
5054 { "packed", float_cons, 'p' },
5056 {"secrel32", pe_directive_secrel, 0},
5059 /* These are for compatibility with CodeComposer Studio. */
5060 {"ref", s_ccs_ref, 0},
5061 {"def", s_ccs_def, 0},
5062 {"asmfunc", s_ccs_asmfunc, 0},
5063 {"endasmfunc", s_ccs_endasmfunc, 0},
5065 {"float16", float_cons, 'h' },
5066 {"float16_format", set_fp16_format, 0 },
5071 /* Parser functions used exclusively in instruction operands. */
5073 /* Generic immediate-value read function for use in insn parsing.
5074 STR points to the beginning of the immediate (the leading #);
5075 VAL receives the value; if the value is outside [MIN, MAX]
5076 issue an error. PREFIX_OPT is true if the immediate prefix is
5080 parse_immediate (char **str, int *val, int min, int max,
5081 bfd_boolean prefix_opt)
5085 my_get_expression (&exp, str, prefix_opt ? GE_OPT_PREFIX : GE_IMM_PREFIX);
5086 if (exp.X_op != O_constant)
5088 inst.error = _("constant expression required");
5092 if (exp.X_add_number < min || exp.X_add_number > max)
5094 inst.error = _("immediate value out of range");
5098 *val = exp.X_add_number;
5102 /* Less-generic immediate-value read function with the possibility of loading a
5103 big (64-bit) immediate, as required by Neon VMOV, VMVN and logic immediate
5104 instructions. Puts the result directly in inst.operands[i]. */
5107 parse_big_immediate (char **str, int i, expressionS *in_exp,
5108 bfd_boolean allow_symbol_p)
5111 expressionS *exp_p = in_exp ? in_exp : &exp;
5114 my_get_expression (exp_p, &ptr, GE_OPT_PREFIX_BIG);
5116 if (exp_p->X_op == O_constant)
5118 inst.operands[i].imm = exp_p->X_add_number & 0xffffffff;
5119 /* If we're on a 64-bit host, then a 64-bit number can be returned using
5120 O_constant. We have to be careful not to break compilation for
5121 32-bit X_add_number, though. */
5122 if ((exp_p->X_add_number & ~(offsetT)(0xffffffffU)) != 0)
5124 /* X >> 32 is illegal if sizeof (exp_p->X_add_number) == 4. */
5125 inst.operands[i].reg = (((exp_p->X_add_number >> 16) >> 16)
5127 inst.operands[i].regisimm = 1;
5130 else if (exp_p->X_op == O_big
5131 && LITTLENUM_NUMBER_OF_BITS * exp_p->X_add_number > 32)
5133 unsigned parts = 32 / LITTLENUM_NUMBER_OF_BITS, j, idx = 0;
5135 /* Bignums have their least significant bits in
5136 generic_bignum[0]. Make sure we put 32 bits in imm and
5137 32 bits in reg, in a (hopefully) portable way. */
5138 gas_assert (parts != 0);
5140 /* Make sure that the number is not too big.
5141 PR 11972: Bignums can now be sign-extended to the
5142 size of a .octa so check that the out of range bits
5143 are all zero or all one. */
5144 if (LITTLENUM_NUMBER_OF_BITS * exp_p->X_add_number > 64)
5146 LITTLENUM_TYPE m = -1;
5148 if (generic_bignum[parts * 2] != 0
5149 && generic_bignum[parts * 2] != m)
5152 for (j = parts * 2 + 1; j < (unsigned) exp_p->X_add_number; j++)
5153 if (generic_bignum[j] != generic_bignum[j-1])
5157 inst.operands[i].imm = 0;
5158 for (j = 0; j < parts; j++, idx++)
5159 inst.operands[i].imm |= generic_bignum[idx]
5160 << (LITTLENUM_NUMBER_OF_BITS * j);
5161 inst.operands[i].reg = 0;
5162 for (j = 0; j < parts; j++, idx++)
5163 inst.operands[i].reg |= generic_bignum[idx]
5164 << (LITTLENUM_NUMBER_OF_BITS * j);
5165 inst.operands[i].regisimm = 1;
5167 else if (!(exp_p->X_op == O_symbol && allow_symbol_p))
5175 /* Returns the pseudo-register number of an FPA immediate constant,
5176 or FAIL if there isn't a valid constant here. */
5179 parse_fpa_immediate (char ** str)
5181 LITTLENUM_TYPE words[MAX_LITTLENUMS];
5187 /* First try and match exact strings, this is to guarantee
5188 that some formats will work even for cross assembly. */
5190 for (i = 0; fp_const[i]; i++)
5192 if (strncmp (*str, fp_const[i], strlen (fp_const[i])) == 0)
5196 *str += strlen (fp_const[i]);
5197 if (is_end_of_line[(unsigned char) **str])
5203 /* Just because we didn't get a match doesn't mean that the constant
5204 isn't valid, just that it is in a format that we don't
5205 automatically recognize. Try parsing it with the standard
5206 expression routines. */
5208 memset (words, 0, MAX_LITTLENUMS * sizeof (LITTLENUM_TYPE));
5210 /* Look for a raw floating point number. */
5211 if ((save_in = atof_ieee (*str, 'x', words)) != NULL
5212 && is_end_of_line[(unsigned char) *save_in])
5214 for (i = 0; i < NUM_FLOAT_VALS; i++)
5216 for (j = 0; j < MAX_LITTLENUMS; j++)
5218 if (words[j] != fp_values[i][j])
5222 if (j == MAX_LITTLENUMS)
5230 /* Try and parse a more complex expression, this will probably fail
5231 unless the code uses a floating point prefix (eg "0f"). */
5232 save_in = input_line_pointer;
5233 input_line_pointer = *str;
5234 if (expression (&exp) == absolute_section
5235 && exp.X_op == O_big
5236 && exp.X_add_number < 0)
5238 /* FIXME: 5 = X_PRECISION, should be #define'd where we can use it.
5240 #define X_PRECISION 5
5241 #define E_PRECISION 15L
5242 if (gen_to_words (words, X_PRECISION, E_PRECISION) == 0)
5244 for (i = 0; i < NUM_FLOAT_VALS; i++)
5246 for (j = 0; j < MAX_LITTLENUMS; j++)
5248 if (words[j] != fp_values[i][j])
5252 if (j == MAX_LITTLENUMS)
5254 *str = input_line_pointer;
5255 input_line_pointer = save_in;
5262 *str = input_line_pointer;
5263 input_line_pointer = save_in;
5264 inst.error = _("invalid FPA immediate expression");
5268 /* Returns 1 if a number has "quarter-precision" float format
5269 0baBbbbbbc defgh000 00000000 00000000. */
5272 is_quarter_float (unsigned imm)
5274 int bs = (imm & 0x20000000) ? 0x3e000000 : 0x40000000;
5275 return (imm & 0x7ffff) == 0 && ((imm & 0x7e000000) ^ bs) == 0;
5279 /* Detect the presence of a floating point or integer zero constant,
5283 parse_ifimm_zero (char **in)
5287 if (!is_immediate_prefix (**in))
5289 /* In unified syntax, all prefixes are optional. */
5290 if (!unified_syntax)
5296 /* Accept #0x0 as a synonym for #0. */
5297 if (strncmp (*in, "0x", 2) == 0)
5300 if (parse_immediate (in, &val, 0, 0, TRUE) == FAIL)
5305 error_code = atof_generic (in, ".", EXP_CHARS,
5306 &generic_floating_point_number);
5309 && generic_floating_point_number.sign == '+'
5310 && (generic_floating_point_number.low
5311 > generic_floating_point_number.leader))
5317 /* Parse an 8-bit "quarter-precision" floating point number of the form:
5318 0baBbbbbbc defgh000 00000000 00000000.
5319 The zero and minus-zero cases need special handling, since they can't be
5320 encoded in the "quarter-precision" float format, but can nonetheless be
5321 loaded as integer constants. */
5324 parse_qfloat_immediate (char **ccp, int *immed)
5328 LITTLENUM_TYPE words[MAX_LITTLENUMS];
5329 int found_fpchar = 0;
5331 skip_past_char (&str, '#');
5333 /* We must not accidentally parse an integer as a floating-point number. Make
5334 sure that the value we parse is not an integer by checking for special
5335 characters '.' or 'e'.
5336 FIXME: This is a horrible hack, but doing better is tricky because type
5337 information isn't in a very usable state at parse time. */
5339 skip_whitespace (fpnum);
5341 if (strncmp (fpnum, "0x", 2) == 0)
5345 for (; *fpnum != '\0' && *fpnum != ' ' && *fpnum != '\n'; fpnum++)
5346 if (*fpnum == '.' || *fpnum == 'e' || *fpnum == 'E')
5356 if ((str = atof_ieee (str, 's', words)) != NULL)
5358 unsigned fpword = 0;
5361 /* Our FP word must be 32 bits (single-precision FP). */
5362 for (i = 0; i < 32 / LITTLENUM_NUMBER_OF_BITS; i++)
5364 fpword <<= LITTLENUM_NUMBER_OF_BITS;
5368 if (is_quarter_float (fpword) || (fpword & 0x7fffffff) == 0)
5381 /* Shift operands. */
5384 SHIFT_LSL, SHIFT_LSR, SHIFT_ASR, SHIFT_ROR, SHIFT_RRX, SHIFT_UXTW
5387 struct asm_shift_name
5390 enum shift_kind kind;
5393 /* Third argument to parse_shift. */
5394 enum parse_shift_mode
5396 NO_SHIFT_RESTRICT, /* Any kind of shift is accepted. */
5397 SHIFT_IMMEDIATE, /* Shift operand must be an immediate. */
5398 SHIFT_LSL_OR_ASR_IMMEDIATE, /* Shift must be LSL or ASR immediate. */
5399 SHIFT_ASR_IMMEDIATE, /* Shift must be ASR immediate. */
5400 SHIFT_LSL_IMMEDIATE, /* Shift must be LSL immediate. */
5401 SHIFT_UXTW_IMMEDIATE /* Shift must be UXTW immediate. */
5404 /* Parse a <shift> specifier on an ARM data processing instruction.
5405 This has three forms:
5407 (LSL|LSR|ASL|ASR|ROR) Rs
5408 (LSL|LSR|ASL|ASR|ROR) #imm
5411 Note that ASL is assimilated to LSL in the instruction encoding, and
5412 RRX to ROR #0 (which cannot be written as such). */
5415 parse_shift (char **str, int i, enum parse_shift_mode mode)
5417 const struct asm_shift_name *shift_name;
5418 enum shift_kind shift;
5423 for (p = *str; ISALPHA (*p); p++)
5428 inst.error = _("shift expression expected");
5432 shift_name = (const struct asm_shift_name *) hash_find_n (arm_shift_hsh, *str,
5435 if (shift_name == NULL)
5437 inst.error = _("shift expression expected");
5441 shift = shift_name->kind;
5445 case NO_SHIFT_RESTRICT:
5446 case SHIFT_IMMEDIATE:
5447 if (shift == SHIFT_UXTW)
5449 inst.error = _("'UXTW' not allowed here");
5454 case SHIFT_LSL_OR_ASR_IMMEDIATE:
5455 if (shift != SHIFT_LSL && shift != SHIFT_ASR)
5457 inst.error = _("'LSL' or 'ASR' required");
5462 case SHIFT_LSL_IMMEDIATE:
5463 if (shift != SHIFT_LSL)
5465 inst.error = _("'LSL' required");
5470 case SHIFT_ASR_IMMEDIATE:
5471 if (shift != SHIFT_ASR)
5473 inst.error = _("'ASR' required");
5477 case SHIFT_UXTW_IMMEDIATE:
5478 if (shift != SHIFT_UXTW)
5480 inst.error = _("'UXTW' required");
5488 if (shift != SHIFT_RRX)
5490 /* Whitespace can appear here if the next thing is a bare digit. */
5491 skip_whitespace (p);
5493 if (mode == NO_SHIFT_RESTRICT
5494 && (reg = arm_reg_parse (&p, REG_TYPE_RN)) != FAIL)
5496 inst.operands[i].imm = reg;
5497 inst.operands[i].immisreg = 1;
5499 else if (my_get_expression (&inst.relocs[0].exp, &p, GE_IMM_PREFIX))
5502 inst.operands[i].shift_kind = shift;
5503 inst.operands[i].shifted = 1;
5508 /* Parse a <shifter_operand> for an ARM data processing instruction:
5511 #<immediate>, <rotate>
5515 where <shift> is defined by parse_shift above, and <rotate> is a
5516 multiple of 2 between 0 and 30. Validation of immediate operands
5517 is deferred to md_apply_fix. */
5520 parse_shifter_operand (char **str, int i)
5525 if ((value = arm_reg_parse (str, REG_TYPE_RN)) != FAIL)
5527 inst.operands[i].reg = value;
5528 inst.operands[i].isreg = 1;
5530 /* parse_shift will override this if appropriate */
5531 inst.relocs[0].exp.X_op = O_constant;
5532 inst.relocs[0].exp.X_add_number = 0;
5534 if (skip_past_comma (str) == FAIL)
5537 /* Shift operation on register. */
5538 return parse_shift (str, i, NO_SHIFT_RESTRICT);
5541 if (my_get_expression (&inst.relocs[0].exp, str, GE_IMM_PREFIX))
5544 if (skip_past_comma (str) == SUCCESS)
5546 /* #x, y -- ie explicit rotation by Y. */
5547 if (my_get_expression (&exp, str, GE_NO_PREFIX))
5550 if (exp.X_op != O_constant || inst.relocs[0].exp.X_op != O_constant)
5552 inst.error = _("constant expression expected");
5556 value = exp.X_add_number;
5557 if (value < 0 || value > 30 || value % 2 != 0)
5559 inst.error = _("invalid rotation");
5562 if (inst.relocs[0].exp.X_add_number < 0
5563 || inst.relocs[0].exp.X_add_number > 255)
5565 inst.error = _("invalid constant");
5569 /* Encode as specified. */
5570 inst.operands[i].imm = inst.relocs[0].exp.X_add_number | value << 7;
5574 inst.relocs[0].type = BFD_RELOC_ARM_IMMEDIATE;
5575 inst.relocs[0].pc_rel = 0;
5579 /* Group relocation information. Each entry in the table contains the
5580 textual name of the relocation as may appear in assembler source
5581 and must end with a colon.
5582 Along with this textual name are the relocation codes to be used if
5583 the corresponding instruction is an ALU instruction (ADD or SUB only),
5584 an LDR, an LDRS, or an LDC. */
5586 struct group_reloc_table_entry
5597 /* Varieties of non-ALU group relocation. */
5605 static struct group_reloc_table_entry group_reloc_table[] =
5606 { /* Program counter relative: */
5608 BFD_RELOC_ARM_ALU_PC_G0_NC, /* ALU */
5613 BFD_RELOC_ARM_ALU_PC_G0, /* ALU */
5614 BFD_RELOC_ARM_LDR_PC_G0, /* LDR */
5615 BFD_RELOC_ARM_LDRS_PC_G0, /* LDRS */
5616 BFD_RELOC_ARM_LDC_PC_G0 }, /* LDC */
5618 BFD_RELOC_ARM_ALU_PC_G1_NC, /* ALU */
5623 BFD_RELOC_ARM_ALU_PC_G1, /* ALU */
5624 BFD_RELOC_ARM_LDR_PC_G1, /* LDR */
5625 BFD_RELOC_ARM_LDRS_PC_G1, /* LDRS */
5626 BFD_RELOC_ARM_LDC_PC_G1 }, /* LDC */
5628 BFD_RELOC_ARM_ALU_PC_G2, /* ALU */
5629 BFD_RELOC_ARM_LDR_PC_G2, /* LDR */
5630 BFD_RELOC_ARM_LDRS_PC_G2, /* LDRS */
5631 BFD_RELOC_ARM_LDC_PC_G2 }, /* LDC */
5632 /* Section base relative */
5634 BFD_RELOC_ARM_ALU_SB_G0_NC, /* ALU */
5639 BFD_RELOC_ARM_ALU_SB_G0, /* ALU */
5640 BFD_RELOC_ARM_LDR_SB_G0, /* LDR */
5641 BFD_RELOC_ARM_LDRS_SB_G0, /* LDRS */
5642 BFD_RELOC_ARM_LDC_SB_G0 }, /* LDC */
5644 BFD_RELOC_ARM_ALU_SB_G1_NC, /* ALU */
5649 BFD_RELOC_ARM_ALU_SB_G1, /* ALU */
5650 BFD_RELOC_ARM_LDR_SB_G1, /* LDR */
5651 BFD_RELOC_ARM_LDRS_SB_G1, /* LDRS */
5652 BFD_RELOC_ARM_LDC_SB_G1 }, /* LDC */
5654 BFD_RELOC_ARM_ALU_SB_G2, /* ALU */
5655 BFD_RELOC_ARM_LDR_SB_G2, /* LDR */
5656 BFD_RELOC_ARM_LDRS_SB_G2, /* LDRS */
5657 BFD_RELOC_ARM_LDC_SB_G2 }, /* LDC */
5658 /* Absolute thumb alu relocations. */
5660 BFD_RELOC_ARM_THUMB_ALU_ABS_G0_NC,/* ALU. */
5665 BFD_RELOC_ARM_THUMB_ALU_ABS_G1_NC,/* ALU. */
5670 BFD_RELOC_ARM_THUMB_ALU_ABS_G2_NC,/* ALU. */
5675 BFD_RELOC_ARM_THUMB_ALU_ABS_G3_NC,/* ALU. */
5680 /* Given the address of a pointer pointing to the textual name of a group
5681 relocation as may appear in assembler source, attempt to find its details
5682 in group_reloc_table. The pointer will be updated to the character after
5683 the trailing colon. On failure, FAIL will be returned; SUCCESS
5684 otherwise. On success, *entry will be updated to point at the relevant
5685 group_reloc_table entry. */
5688 find_group_reloc_table_entry (char **str, struct group_reloc_table_entry **out)
5691 for (i = 0; i < ARRAY_SIZE (group_reloc_table); i++)
5693 int length = strlen (group_reloc_table[i].name);
5695 if (strncasecmp (group_reloc_table[i].name, *str, length) == 0
5696 && (*str)[length] == ':')
5698 *out = &group_reloc_table[i];
5699 *str += (length + 1);
5707 /* Parse a <shifter_operand> for an ARM data processing instruction
5708 (as for parse_shifter_operand) where group relocations are allowed:
5711 #<immediate>, <rotate>
5712 #:<group_reloc>:<expression>
5716 where <group_reloc> is one of the strings defined in group_reloc_table.
5717 The hashes are optional.
5719 Everything else is as for parse_shifter_operand. */
5721 static parse_operand_result
5722 parse_shifter_operand_group_reloc (char **str, int i)
5724 /* Determine if we have the sequence of characters #: or just :
5725 coming next. If we do, then we check for a group relocation.
5726 If we don't, punt the whole lot to parse_shifter_operand. */
5728 if (((*str)[0] == '#' && (*str)[1] == ':')
5729 || (*str)[0] == ':')
5731 struct group_reloc_table_entry *entry;
5733 if ((*str)[0] == '#')
5738 /* Try to parse a group relocation. Anything else is an error. */
5739 if (find_group_reloc_table_entry (str, &entry) == FAIL)
5741 inst.error = _("unknown group relocation");
5742 return PARSE_OPERAND_FAIL_NO_BACKTRACK;
5745 /* We now have the group relocation table entry corresponding to
5746 the name in the assembler source. Next, we parse the expression. */
5747 if (my_get_expression (&inst.relocs[0].exp, str, GE_NO_PREFIX))
5748 return PARSE_OPERAND_FAIL_NO_BACKTRACK;
5750 /* Record the relocation type (always the ALU variant here). */
5751 inst.relocs[0].type = (bfd_reloc_code_real_type) entry->alu_code;
5752 gas_assert (inst.relocs[0].type != 0);
5754 return PARSE_OPERAND_SUCCESS;
5757 return parse_shifter_operand (str, i) == SUCCESS
5758 ? PARSE_OPERAND_SUCCESS : PARSE_OPERAND_FAIL;
5760 /* Never reached. */
5763 /* Parse a Neon alignment expression. Information is written to
5764 inst.operands[i]. We assume the initial ':' has been skipped.
5766 align .imm = align << 8, .immisalign=1, .preind=0 */
5767 static parse_operand_result
5768 parse_neon_alignment (char **str, int i)
5773 my_get_expression (&exp, &p, GE_NO_PREFIX);
5775 if (exp.X_op != O_constant)
5777 inst.error = _("alignment must be constant");
5778 return PARSE_OPERAND_FAIL;
5781 inst.operands[i].imm = exp.X_add_number << 8;
5782 inst.operands[i].immisalign = 1;
5783 /* Alignments are not pre-indexes. */
5784 inst.operands[i].preind = 0;
5787 return PARSE_OPERAND_SUCCESS;
5790 /* Parse all forms of an ARM address expression. Information is written
5791 to inst.operands[i] and/or inst.relocs[0].
5793 Preindexed addressing (.preind=1):
5795 [Rn, #offset] .reg=Rn .relocs[0].exp=offset
5796 [Rn, +/-Rm] .reg=Rn .imm=Rm .immisreg=1 .negative=0/1
5797 [Rn, +/-Rm, shift] .reg=Rn .imm=Rm .immisreg=1 .negative=0/1
5798 .shift_kind=shift .relocs[0].exp=shift_imm
5800 These three may have a trailing ! which causes .writeback to be set also.
5802 Postindexed addressing (.postind=1, .writeback=1):
5804 [Rn], #offset .reg=Rn .relocs[0].exp=offset
5805 [Rn], +/-Rm .reg=Rn .imm=Rm .immisreg=1 .negative=0/1
5806 [Rn], +/-Rm, shift .reg=Rn .imm=Rm .immisreg=1 .negative=0/1
5807 .shift_kind=shift .relocs[0].exp=shift_imm
5809 Unindexed addressing (.preind=0, .postind=0):
5811 [Rn], {option} .reg=Rn .imm=option .immisreg=0
5815 [Rn]{!} shorthand for [Rn,#0]{!}
5816 =immediate .isreg=0 .relocs[0].exp=immediate
5817 label .reg=PC .relocs[0].pc_rel=1 .relocs[0].exp=label
5819 It is the caller's responsibility to check for addressing modes not
5820 supported by the instruction, and to set inst.relocs[0].type. */
5822 static parse_operand_result
5823 parse_address_main (char **str, int i, int group_relocations,
5824 group_reloc_type group_type)
5829 if (skip_past_char (&p, '[') == FAIL)
5831 if (skip_past_char (&p, '=') == FAIL)
5833 /* Bare address - translate to PC-relative offset. */
5834 inst.relocs[0].pc_rel = 1;
5835 inst.operands[i].reg = REG_PC;
5836 inst.operands[i].isreg = 1;
5837 inst.operands[i].preind = 1;
5839 if (my_get_expression (&inst.relocs[0].exp, &p, GE_OPT_PREFIX_BIG))
5840 return PARSE_OPERAND_FAIL;
5842 else if (parse_big_immediate (&p, i, &inst.relocs[0].exp,
5843 /*allow_symbol_p=*/TRUE))
5844 return PARSE_OPERAND_FAIL;
5847 return PARSE_OPERAND_SUCCESS;
5850 /* PR gas/14887: Allow for whitespace after the opening bracket. */
5851 skip_whitespace (p);
5853 if (group_type == GROUP_MVE)
5855 enum arm_reg_type rtype = REG_TYPE_MQ;
5856 struct neon_type_el et;
5857 if ((reg = arm_typed_reg_parse (&p, rtype, &rtype, &et)) != FAIL)
5859 inst.operands[i].isquad = 1;
5861 else if ((reg = arm_reg_parse (&p, REG_TYPE_RN)) == FAIL)
5863 inst.error = BAD_ADDR_MODE;
5864 return PARSE_OPERAND_FAIL;
5867 else if ((reg = arm_reg_parse (&p, REG_TYPE_RN)) == FAIL)
5869 if (group_type == GROUP_MVE)
5870 inst.error = BAD_ADDR_MODE;
5872 inst.error = _(reg_expected_msgs[REG_TYPE_RN]);
5873 return PARSE_OPERAND_FAIL;
5875 inst.operands[i].reg = reg;
5876 inst.operands[i].isreg = 1;
5878 if (skip_past_comma (&p) == SUCCESS)
5880 inst.operands[i].preind = 1;
5883 else if (*p == '-') p++, inst.operands[i].negative = 1;
5885 enum arm_reg_type rtype = REG_TYPE_MQ;
5886 struct neon_type_el et;
5887 if (group_type == GROUP_MVE
5888 && (reg = arm_typed_reg_parse (&p, rtype, &rtype, &et)) != FAIL)
5890 inst.operands[i].immisreg = 2;
5891 inst.operands[i].imm = reg;
5893 if (skip_past_comma (&p) == SUCCESS)
5895 if (parse_shift (&p, i, SHIFT_UXTW_IMMEDIATE) == SUCCESS)
5897 inst.operands[i].imm |= inst.relocs[0].exp.X_add_number << 5;
5898 inst.relocs[0].exp.X_add_number = 0;
5901 return PARSE_OPERAND_FAIL;
5904 else if ((reg = arm_reg_parse (&p, REG_TYPE_RN)) != FAIL)
5906 inst.operands[i].imm = reg;
5907 inst.operands[i].immisreg = 1;
5909 if (skip_past_comma (&p) == SUCCESS)
5910 if (parse_shift (&p, i, SHIFT_IMMEDIATE) == FAIL)
5911 return PARSE_OPERAND_FAIL;
5913 else if (skip_past_char (&p, ':') == SUCCESS)
5915 /* FIXME: '@' should be used here, but it's filtered out by generic
5916 code before we get to see it here. This may be subject to
5918 parse_operand_result result = parse_neon_alignment (&p, i);
5920 if (result != PARSE_OPERAND_SUCCESS)
5925 if (inst.operands[i].negative)
5927 inst.operands[i].negative = 0;
5931 if (group_relocations
5932 && ((*p == '#' && *(p + 1) == ':') || *p == ':'))
5934 struct group_reloc_table_entry *entry;
5936 /* Skip over the #: or : sequence. */
5942 /* Try to parse a group relocation. Anything else is an
5944 if (find_group_reloc_table_entry (&p, &entry) == FAIL)
5946 inst.error = _("unknown group relocation");
5947 return PARSE_OPERAND_FAIL_NO_BACKTRACK;
5950 /* We now have the group relocation table entry corresponding to
5951 the name in the assembler source. Next, we parse the
5953 if (my_get_expression (&inst.relocs[0].exp, &p, GE_NO_PREFIX))
5954 return PARSE_OPERAND_FAIL_NO_BACKTRACK;
5956 /* Record the relocation type. */
5961 = (bfd_reloc_code_real_type) entry->ldr_code;
5966 = (bfd_reloc_code_real_type) entry->ldrs_code;
5971 = (bfd_reloc_code_real_type) entry->ldc_code;
5978 if (inst.relocs[0].type == 0)
5980 inst.error = _("this group relocation is not allowed on this instruction");
5981 return PARSE_OPERAND_FAIL_NO_BACKTRACK;
5988 if (my_get_expression (&inst.relocs[0].exp, &p, GE_IMM_PREFIX))
5989 return PARSE_OPERAND_FAIL;
5990 /* If the offset is 0, find out if it's a +0 or -0. */
5991 if (inst.relocs[0].exp.X_op == O_constant
5992 && inst.relocs[0].exp.X_add_number == 0)
5994 skip_whitespace (q);
5998 skip_whitespace (q);
6001 inst.operands[i].negative = 1;
6006 else if (skip_past_char (&p, ':') == SUCCESS)
6008 /* FIXME: '@' should be used here, but it's filtered out by generic code
6009 before we get to see it here. This may be subject to change. */
6010 parse_operand_result result = parse_neon_alignment (&p, i);
6012 if (result != PARSE_OPERAND_SUCCESS)
6016 if (skip_past_char (&p, ']') == FAIL)
6018 inst.error = _("']' expected");
6019 return PARSE_OPERAND_FAIL;
6022 if (skip_past_char (&p, '!') == SUCCESS)
6023 inst.operands[i].writeback = 1;
6025 else if (skip_past_comma (&p) == SUCCESS)
6027 if (skip_past_char (&p, '{') == SUCCESS)
6029 /* [Rn], {expr} - unindexed, with option */
6030 if (parse_immediate (&p, &inst.operands[i].imm,
6031 0, 255, TRUE) == FAIL)
6032 return PARSE_OPERAND_FAIL;
6034 if (skip_past_char (&p, '}') == FAIL)
6036 inst.error = _("'}' expected at end of 'option' field");
6037 return PARSE_OPERAND_FAIL;
6039 if (inst.operands[i].preind)
6041 inst.error = _("cannot combine index with option");
6042 return PARSE_OPERAND_FAIL;
6045 return PARSE_OPERAND_SUCCESS;
6049 inst.operands[i].postind = 1;
6050 inst.operands[i].writeback = 1;
6052 if (inst.operands[i].preind)
6054 inst.error = _("cannot combine pre- and post-indexing");
6055 return PARSE_OPERAND_FAIL;
6059 else if (*p == '-') p++, inst.operands[i].negative = 1;
6061 enum arm_reg_type rtype = REG_TYPE_MQ;
6062 struct neon_type_el et;
6063 if (group_type == GROUP_MVE
6064 && (reg = arm_typed_reg_parse (&p, rtype, &rtype, &et)) != FAIL)
6066 inst.operands[i].immisreg = 2;
6067 inst.operands[i].imm = reg;
6069 else if ((reg = arm_reg_parse (&p, REG_TYPE_RN)) != FAIL)
6071 /* We might be using the immediate for alignment already. If we
6072 are, OR the register number into the low-order bits. */
6073 if (inst.operands[i].immisalign)
6074 inst.operands[i].imm |= reg;
6076 inst.operands[i].imm = reg;
6077 inst.operands[i].immisreg = 1;
6079 if (skip_past_comma (&p) == SUCCESS)
6080 if (parse_shift (&p, i, SHIFT_IMMEDIATE) == FAIL)
6081 return PARSE_OPERAND_FAIL;
6087 if (inst.operands[i].negative)
6089 inst.operands[i].negative = 0;
6092 if (my_get_expression (&inst.relocs[0].exp, &p, GE_IMM_PREFIX))
6093 return PARSE_OPERAND_FAIL;
6094 /* If the offset is 0, find out if it's a +0 or -0. */
6095 if (inst.relocs[0].exp.X_op == O_constant
6096 && inst.relocs[0].exp.X_add_number == 0)
6098 skip_whitespace (q);
6102 skip_whitespace (q);
6105 inst.operands[i].negative = 1;
6111 /* If at this point neither .preind nor .postind is set, we have a
6112 bare [Rn]{!}, which is shorthand for [Rn,#0]{!}. */
6113 if (inst.operands[i].preind == 0 && inst.operands[i].postind == 0)
6115 inst.operands[i].preind = 1;
6116 inst.relocs[0].exp.X_op = O_constant;
6117 inst.relocs[0].exp.X_add_number = 0;
6120 return PARSE_OPERAND_SUCCESS;
6124 parse_address (char **str, int i)
6126 return parse_address_main (str, i, 0, GROUP_LDR) == PARSE_OPERAND_SUCCESS
6130 static parse_operand_result
6131 parse_address_group_reloc (char **str, int i, group_reloc_type type)
6133 return parse_address_main (str, i, 1, type);
6136 /* Parse an operand for a MOVW or MOVT instruction. */
6138 parse_half (char **str)
6143 skip_past_char (&p, '#');
6144 if (strncasecmp (p, ":lower16:", 9) == 0)
6145 inst.relocs[0].type = BFD_RELOC_ARM_MOVW;
6146 else if (strncasecmp (p, ":upper16:", 9) == 0)
6147 inst.relocs[0].type = BFD_RELOC_ARM_MOVT;
6149 if (inst.relocs[0].type != BFD_RELOC_UNUSED)
6152 skip_whitespace (p);
6155 if (my_get_expression (&inst.relocs[0].exp, &p, GE_NO_PREFIX))
6158 if (inst.relocs[0].type == BFD_RELOC_UNUSED)
6160 if (inst.relocs[0].exp.X_op != O_constant)
6162 inst.error = _("constant expression expected");
6165 if (inst.relocs[0].exp.X_add_number < 0
6166 || inst.relocs[0].exp.X_add_number > 0xffff)
6168 inst.error = _("immediate value out of range");
6176 /* Miscellaneous. */
6178 /* Parse a PSR flag operand. The value returned is FAIL on syntax error,
6179 or a bitmask suitable to be or-ed into the ARM msr instruction. */
6181 parse_psr (char **str, bfd_boolean lhs)
6184 unsigned long psr_field;
6185 const struct asm_psr *psr;
6187 bfd_boolean is_apsr = FALSE;
6188 bfd_boolean m_profile = ARM_CPU_HAS_FEATURE (selected_cpu, arm_ext_m);
6190 /* PR gas/12698: If the user has specified -march=all then m_profile will
6191 be TRUE, but we want to ignore it in this case as we are building for any
6192 CPU type, including non-m variants. */
6193 if (ARM_FEATURE_CORE_EQUAL (selected_cpu, arm_arch_any))
6196 /* CPSR's and SPSR's can now be lowercase. This is just a convenience
6197 feature for ease of use and backwards compatibility. */
6199 if (strncasecmp (p, "SPSR", 4) == 0)
6202 goto unsupported_psr;
6204 psr_field = SPSR_BIT;
6206 else if (strncasecmp (p, "CPSR", 4) == 0)
6209 goto unsupported_psr;
6213 else if (strncasecmp (p, "APSR", 4) == 0)
6215 /* APSR[_<bits>] can be used as a synonym for CPSR[_<flags>] on ARMv7-A
6216 and ARMv7-R architecture CPUs. */
6225 while (ISALNUM (*p) || *p == '_');
6227 if (strncasecmp (start, "iapsr", 5) == 0
6228 || strncasecmp (start, "eapsr", 5) == 0
6229 || strncasecmp (start, "xpsr", 4) == 0
6230 || strncasecmp (start, "psr", 3) == 0)
6231 p = start + strcspn (start, "rR") + 1;
6233 psr = (const struct asm_psr *) hash_find_n (arm_v7m_psr_hsh, start,
6239 /* If APSR is being written, a bitfield may be specified. Note that
6240 APSR itself is handled above. */
6241 if (psr->field <= 3)
6243 psr_field = psr->field;
6249 /* M-profile MSR instructions have the mask field set to "10", except
6250 *PSR variants which modify APSR, which may use a different mask (and
6251 have been handled already). Do that by setting the PSR_f field
6253 return psr->field | (lhs ? PSR_f : 0);
6256 goto unsupported_psr;
6262 /* A suffix follows. */
6268 while (ISALNUM (*p) || *p == '_');
6272 /* APSR uses a notation for bits, rather than fields. */
6273 unsigned int nzcvq_bits = 0;
6274 unsigned int g_bit = 0;
6277 for (bit = start; bit != p; bit++)
6279 switch (TOLOWER (*bit))
6282 nzcvq_bits |= (nzcvq_bits & 0x01) ? 0x20 : 0x01;
6286 nzcvq_bits |= (nzcvq_bits & 0x02) ? 0x20 : 0x02;
6290 nzcvq_bits |= (nzcvq_bits & 0x04) ? 0x20 : 0x04;
6294 nzcvq_bits |= (nzcvq_bits & 0x08) ? 0x20 : 0x08;
6298 nzcvq_bits |= (nzcvq_bits & 0x10) ? 0x20 : 0x10;
6302 g_bit |= (g_bit & 0x1) ? 0x2 : 0x1;
6306 inst.error = _("unexpected bit specified after APSR");
6311 if (nzcvq_bits == 0x1f)
6316 if (!ARM_CPU_HAS_FEATURE (selected_cpu, arm_ext_v6_dsp))
6318 inst.error = _("selected processor does not "
6319 "support DSP extension");
6326 if ((nzcvq_bits & 0x20) != 0
6327 || (nzcvq_bits != 0x1f && nzcvq_bits != 0)
6328 || (g_bit & 0x2) != 0)
6330 inst.error = _("bad bitmask specified after APSR");
6336 psr = (const struct asm_psr *) hash_find_n (arm_psr_hsh, start,
6341 psr_field |= psr->field;
6347 goto error; /* Garbage after "[CS]PSR". */
6349 /* Unadorned APSR is equivalent to APSR_nzcvq/CPSR_f (for writes). This
6350 is deprecated, but allow it anyway. */
6354 as_tsktsk (_("writing to APSR without specifying a bitmask is "
6357 else if (!m_profile)
6358 /* These bits are never right for M-profile devices: don't set them
6359 (only code paths which read/write APSR reach here). */
6360 psr_field |= (PSR_c | PSR_f);
6366 inst.error = _("selected processor does not support requested special "
6367 "purpose register");
6371 inst.error = _("flag for {c}psr instruction expected");
6376 parse_sys_vldr_vstr (char **str)
6385 {"FPSCR", 0x1, 0x0},
6386 {"FPSCR_nzcvqc", 0x2, 0x0},
6389 {"FPCXTNS", 0x6, 0x1},
6390 {"FPCXTS", 0x7, 0x1}
6392 char *op_end = strchr (*str, ',');
6393 size_t op_strlen = op_end - *str;
6395 for (i = 0; i < sizeof (sysregs) / sizeof (sysregs[0]); i++)
6397 if (!strncmp (*str, sysregs[i].name, op_strlen))
6399 val = sysregs[i].regl | (sysregs[i].regh << 3);
6408 /* Parse the flags argument to CPSI[ED]. Returns FAIL on error, or a
6409 value suitable for splatting into the AIF field of the instruction. */
6412 parse_cps_flags (char **str)
6421 case '\0': case ',':
6424 case 'a': case 'A': saw_a_flag = 1; val |= 0x4; break;
6425 case 'i': case 'I': saw_a_flag = 1; val |= 0x2; break;
6426 case 'f': case 'F': saw_a_flag = 1; val |= 0x1; break;
6429 inst.error = _("unrecognized CPS flag");
6434 if (saw_a_flag == 0)
6436 inst.error = _("missing CPS flags");
6444 /* Parse an endian specifier ("BE" or "LE", case insensitive);
6445 returns 0 for big-endian, 1 for little-endian, FAIL for an error. */
6448 parse_endian_specifier (char **str)
6453 if (strncasecmp (s, "BE", 2))
6455 else if (strncasecmp (s, "LE", 2))
6459 inst.error = _("valid endian specifiers are be or le");
6463 if (ISALNUM (s[2]) || s[2] == '_')
6465 inst.error = _("valid endian specifiers are be or le");
6470 return little_endian;
6473 /* Parse a rotation specifier: ROR #0, #8, #16, #24. *val receives a
6474 value suitable for poking into the rotate field of an sxt or sxta
6475 instruction, or FAIL on error. */
6478 parse_ror (char **str)
6483 if (strncasecmp (s, "ROR", 3) == 0)
6487 inst.error = _("missing rotation field after comma");
6491 if (parse_immediate (&s, &rot, 0, 24, FALSE) == FAIL)
6496 case 0: *str = s; return 0x0;
6497 case 8: *str = s; return 0x1;
6498 case 16: *str = s; return 0x2;
6499 case 24: *str = s; return 0x3;
6502 inst.error = _("rotation can only be 0, 8, 16, or 24");
6507 /* Parse a conditional code (from conds[] below). The value returned is in the
6508 range 0 .. 14, or FAIL. */
6510 parse_cond (char **str)
6513 const struct asm_cond *c;
6515 /* Condition codes are always 2 characters, so matching up to
6516 3 characters is sufficient. */
6521 while (ISALPHA (*q) && n < 3)
6523 cond[n] = TOLOWER (*q);
6528 c = (const struct asm_cond *) hash_find_n (arm_cond_hsh, cond, n);
6531 inst.error = _("condition required");
6539 /* Parse an option for a barrier instruction. Returns the encoding for the
6542 parse_barrier (char **str)
6545 const struct asm_barrier_opt *o;
6548 while (ISALPHA (*q))
6551 o = (const struct asm_barrier_opt *) hash_find_n (arm_barrier_opt_hsh, p,
6556 if (!mark_feature_used (&o->arch))
6563 /* Parse the operands of a table branch instruction. Similar to a memory
6566 parse_tb (char **str)
6571 if (skip_past_char (&p, '[') == FAIL)
6573 inst.error = _("'[' expected");
6577 if ((reg = arm_reg_parse (&p, REG_TYPE_RN)) == FAIL)
6579 inst.error = _(reg_expected_msgs[REG_TYPE_RN]);
6582 inst.operands[0].reg = reg;
6584 if (skip_past_comma (&p) == FAIL)
6586 inst.error = _("',' expected");
6590 if ((reg = arm_reg_parse (&p, REG_TYPE_RN)) == FAIL)
6592 inst.error = _(reg_expected_msgs[REG_TYPE_RN]);
6595 inst.operands[0].imm = reg;
6597 if (skip_past_comma (&p) == SUCCESS)
6599 if (parse_shift (&p, 0, SHIFT_LSL_IMMEDIATE) == FAIL)
6601 if (inst.relocs[0].exp.X_add_number != 1)
6603 inst.error = _("invalid shift");
6606 inst.operands[0].shifted = 1;
6609 if (skip_past_char (&p, ']') == FAIL)
6611 inst.error = _("']' expected");
6618 /* Parse the operands of a Neon VMOV instruction. See do_neon_mov for more
6619 information on the types the operands can take and how they are encoded.
6620 Up to four operands may be read; this function handles setting the
6621 ".present" field for each read operand itself.
6622 Updates STR and WHICH_OPERAND if parsing is successful and returns SUCCESS,
6623 else returns FAIL. */
6626 parse_neon_mov (char **str, int *which_operand)
6628 int i = *which_operand, val;
6629 enum arm_reg_type rtype;
6631 struct neon_type_el optype;
6633 if ((val = parse_scalar (&ptr, 8, &optype, REG_TYPE_MQ)) != FAIL)
6635 /* Cases 17 or 19. */
6636 inst.operands[i].reg = val;
6637 inst.operands[i].isvec = 1;
6638 inst.operands[i].isscalar = 2;
6639 inst.operands[i].vectype = optype;
6640 inst.operands[i++].present = 1;
6642 if (skip_past_comma (&ptr) == FAIL)
6645 if ((val = arm_reg_parse (&ptr, REG_TYPE_RN)) != FAIL)
6647 /* Case 17: VMOV<c>.<dt> <Qd[idx]>, <Rt> */
6648 inst.operands[i].reg = val;
6649 inst.operands[i].isreg = 1;
6650 inst.operands[i].present = 1;
6652 else if ((val = parse_scalar (&ptr, 8, &optype, REG_TYPE_MQ)) != FAIL)
6654 /* Case 19: VMOV<c> <Qd[idx]>, <Qd[idx2]>, <Rt>, <Rt2> */
6655 inst.operands[i].reg = val;
6656 inst.operands[i].isvec = 1;
6657 inst.operands[i].isscalar = 2;
6658 inst.operands[i].vectype = optype;
6659 inst.operands[i++].present = 1;
6661 if (skip_past_comma (&ptr) == FAIL)
6664 if ((val = arm_reg_parse (&ptr, REG_TYPE_RN)) == FAIL)
6667 inst.operands[i].reg = val;
6668 inst.operands[i].isreg = 1;
6669 inst.operands[i++].present = 1;
6671 if (skip_past_comma (&ptr) == FAIL)
6674 if ((val = arm_reg_parse (&ptr, REG_TYPE_RN)) == FAIL)
6677 inst.operands[i].reg = val;
6678 inst.operands[i].isreg = 1;
6679 inst.operands[i].present = 1;
6683 first_error (_("expected ARM or MVE vector register"));
6687 else if ((val = parse_scalar (&ptr, 8, &optype, REG_TYPE_VFD)) != FAIL)
6689 /* Case 4: VMOV<c><q>.<size> <Dn[x]>, <Rd>. */
6690 inst.operands[i].reg = val;
6691 inst.operands[i].isscalar = 1;
6692 inst.operands[i].vectype = optype;
6693 inst.operands[i++].present = 1;
6695 if (skip_past_comma (&ptr) == FAIL)
6698 if ((val = arm_reg_parse (&ptr, REG_TYPE_RN)) == FAIL)
6701 inst.operands[i].reg = val;
6702 inst.operands[i].isreg = 1;
6703 inst.operands[i].present = 1;
6705 else if (((val = arm_typed_reg_parse (&ptr, REG_TYPE_NSDQ, &rtype, &optype))
6707 || ((val = arm_typed_reg_parse (&ptr, REG_TYPE_MQ, &rtype, &optype))
6710 /* Cases 0, 1, 2, 3, 5 (D only). */
6711 if (skip_past_comma (&ptr) == FAIL)
6714 inst.operands[i].reg = val;
6715 inst.operands[i].isreg = 1;
6716 inst.operands[i].isquad = (rtype == REG_TYPE_NQ);
6717 inst.operands[i].issingle = (rtype == REG_TYPE_VFS);
6718 inst.operands[i].isvec = 1;
6719 inst.operands[i].vectype = optype;
6720 inst.operands[i++].present = 1;
6722 if ((val = arm_reg_parse (&ptr, REG_TYPE_RN)) != FAIL)
6724 /* Case 5: VMOV<c><q> <Dm>, <Rd>, <Rn>.
6725 Case 13: VMOV <Sd>, <Rm> */
6726 inst.operands[i].reg = val;
6727 inst.operands[i].isreg = 1;
6728 inst.operands[i].present = 1;
6730 if (rtype == REG_TYPE_NQ)
6732 first_error (_("can't use Neon quad register here"));
6735 else if (rtype != REG_TYPE_VFS)
6738 if (skip_past_comma (&ptr) == FAIL)
6740 if ((val = arm_reg_parse (&ptr, REG_TYPE_RN)) == FAIL)
6742 inst.operands[i].reg = val;
6743 inst.operands[i].isreg = 1;
6744 inst.operands[i].present = 1;
6747 else if (((val = arm_typed_reg_parse (&ptr, REG_TYPE_NSDQ, &rtype,
6749 || ((val = arm_typed_reg_parse (&ptr, REG_TYPE_MQ, &rtype,
6752 /* Case 0: VMOV<c><q> <Qd>, <Qm>
6753 Case 1: VMOV<c><q> <Dd>, <Dm>
6754 Case 8: VMOV.F32 <Sd>, <Sm>
6755 Case 15: VMOV <Sd>, <Se>, <Rn>, <Rm> */
6757 inst.operands[i].reg = val;
6758 inst.operands[i].isreg = 1;
6759 inst.operands[i].isquad = (rtype == REG_TYPE_NQ);
6760 inst.operands[i].issingle = (rtype == REG_TYPE_VFS);
6761 inst.operands[i].isvec = 1;
6762 inst.operands[i].vectype = optype;
6763 inst.operands[i].present = 1;
6765 if (skip_past_comma (&ptr) == SUCCESS)
6770 if ((val = arm_reg_parse (&ptr, REG_TYPE_RN)) == FAIL)
6773 inst.operands[i].reg = val;
6774 inst.operands[i].isreg = 1;
6775 inst.operands[i++].present = 1;
6777 if (skip_past_comma (&ptr) == FAIL)
6780 if ((val = arm_reg_parse (&ptr, REG_TYPE_RN)) == FAIL)
6783 inst.operands[i].reg = val;
6784 inst.operands[i].isreg = 1;
6785 inst.operands[i].present = 1;
6788 else if (parse_qfloat_immediate (&ptr, &inst.operands[i].imm) == SUCCESS)
6789 /* Case 2: VMOV<c><q>.<dt> <Qd>, #<float-imm>
6790 Case 3: VMOV<c><q>.<dt> <Dd>, #<float-imm>
6791 Case 10: VMOV.F32 <Sd>, #<imm>
6792 Case 11: VMOV.F64 <Dd>, #<imm> */
6793 inst.operands[i].immisfloat = 1;
6794 else if (parse_big_immediate (&ptr, i, NULL, /*allow_symbol_p=*/FALSE)
6796 /* Case 2: VMOV<c><q>.<dt> <Qd>, #<imm>
6797 Case 3: VMOV<c><q>.<dt> <Dd>, #<imm> */
6801 first_error (_("expected <Rm> or <Dm> or <Qm> operand"));
6805 else if ((val = arm_reg_parse (&ptr, REG_TYPE_RN)) != FAIL)
6807 /* Cases 6, 7, 16, 18. */
6808 inst.operands[i].reg = val;
6809 inst.operands[i].isreg = 1;
6810 inst.operands[i++].present = 1;
6812 if (skip_past_comma (&ptr) == FAIL)
6815 if ((val = parse_scalar (&ptr, 8, &optype, REG_TYPE_MQ)) != FAIL)
6817 /* Case 18: VMOV<c>.<dt> <Rt>, <Qn[idx]> */
6818 inst.operands[i].reg = val;
6819 inst.operands[i].isscalar = 2;
6820 inst.operands[i].present = 1;
6821 inst.operands[i].vectype = optype;
6823 else if ((val = parse_scalar (&ptr, 8, &optype, REG_TYPE_VFD)) != FAIL)
6825 /* Case 6: VMOV<c><q>.<dt> <Rd>, <Dn[x]> */
6826 inst.operands[i].reg = val;
6827 inst.operands[i].isscalar = 1;
6828 inst.operands[i].present = 1;
6829 inst.operands[i].vectype = optype;
6831 else if ((val = arm_reg_parse (&ptr, REG_TYPE_RN)) != FAIL)
6833 inst.operands[i].reg = val;
6834 inst.operands[i].isreg = 1;
6835 inst.operands[i++].present = 1;
6837 if (skip_past_comma (&ptr) == FAIL)
6840 if ((val = arm_typed_reg_parse (&ptr, REG_TYPE_VFSD, &rtype, &optype))
6843 /* Case 7: VMOV<c><q> <Rd>, <Rn>, <Dm> */
6845 inst.operands[i].reg = val;
6846 inst.operands[i].isreg = 1;
6847 inst.operands[i].isvec = 1;
6848 inst.operands[i].issingle = (rtype == REG_TYPE_VFS);
6849 inst.operands[i].vectype = optype;
6850 inst.operands[i].present = 1;
6852 if (rtype == REG_TYPE_VFS)
6856 if (skip_past_comma (&ptr) == FAIL)
6858 if ((val = arm_typed_reg_parse (&ptr, REG_TYPE_VFS, NULL,
6861 first_error (_(reg_expected_msgs[REG_TYPE_VFS]));
6864 inst.operands[i].reg = val;
6865 inst.operands[i].isreg = 1;
6866 inst.operands[i].isvec = 1;
6867 inst.operands[i].issingle = 1;
6868 inst.operands[i].vectype = optype;
6869 inst.operands[i].present = 1;
6874 if ((val = parse_scalar (&ptr, 8, &optype, REG_TYPE_MQ))
6877 /* Case 16: VMOV<c> <Rt>, <Rt2>, <Qd[idx]>, <Qd[idx2]> */
6878 inst.operands[i].reg = val;
6879 inst.operands[i].isvec = 1;
6880 inst.operands[i].isscalar = 2;
6881 inst.operands[i].vectype = optype;
6882 inst.operands[i++].present = 1;
6884 if (skip_past_comma (&ptr) == FAIL)
6887 if ((val = parse_scalar (&ptr, 8, &optype, REG_TYPE_MQ))
6890 first_error (_(reg_expected_msgs[REG_TYPE_MQ]));
6893 inst.operands[i].reg = val;
6894 inst.operands[i].isvec = 1;
6895 inst.operands[i].isscalar = 2;
6896 inst.operands[i].vectype = optype;
6897 inst.operands[i].present = 1;
6901 first_error (_("VFP single, double or MVE vector register"
6907 else if ((val = arm_typed_reg_parse (&ptr, REG_TYPE_VFS, NULL, &optype))
6911 inst.operands[i].reg = val;
6912 inst.operands[i].isreg = 1;
6913 inst.operands[i].isvec = 1;
6914 inst.operands[i].issingle = 1;
6915 inst.operands[i].vectype = optype;
6916 inst.operands[i].present = 1;
6921 first_error (_("parse error"));
6925 /* Successfully parsed the operands. Update args. */
6931 first_error (_("expected comma"));
6935 first_error (_(reg_expected_msgs[REG_TYPE_RN]));
6939 /* Use this macro when the operand constraints are different
6940 for ARM and THUMB (e.g. ldrd). */
6941 #define MIX_ARM_THUMB_OPERANDS(arm_operand, thumb_operand) \
6942 ((arm_operand) | ((thumb_operand) << 16))
6944 /* Matcher codes for parse_operands. */
6945 enum operand_parse_code
6947 OP_stop, /* end of line */
6949 OP_RR, /* ARM register */
6950 OP_RRnpc, /* ARM register, not r15 */
6951 OP_RRnpcsp, /* ARM register, neither r15 nor r13 (a.k.a. 'BadReg') */
6952 OP_RRnpcb, /* ARM register, not r15, in square brackets */
6953 OP_RRnpctw, /* ARM register, not r15 in Thumb-state or with writeback,
6954 optional trailing ! */
6955 OP_RRw, /* ARM register, not r15, optional trailing ! */
6956 OP_RCP, /* Coprocessor number */
6957 OP_RCN, /* Coprocessor register */
6958 OP_RF, /* FPA register */
6959 OP_RVS, /* VFP single precision register */
6960 OP_RVD, /* VFP double precision register (0..15) */
6961 OP_RND, /* Neon double precision register (0..31) */
6962 OP_RNDMQ, /* Neon double precision (0..31) or MVE vector register. */
6963 OP_RNDMQR, /* Neon double precision (0..31), MVE vector or ARM register.
6965 OP_RNQ, /* Neon quad precision register */
6966 OP_RNQMQ, /* Neon quad or MVE vector register. */
6967 OP_RVSD, /* VFP single or double precision register */
6968 OP_RVSD_COND, /* VFP single, double precision register or condition code. */
6969 OP_RVSDMQ, /* VFP single, double precision or MVE vector register. */
6970 OP_RNSD, /* Neon single or double precision register */
6971 OP_RNDQ, /* Neon double or quad precision register */
6972 OP_RNDQMQ, /* Neon double, quad or MVE vector register. */
6973 OP_RNDQMQR, /* Neon double, quad, MVE vector or ARM register. */
6974 OP_RNSDQ, /* Neon single, double or quad precision register */
6975 OP_RNSC, /* Neon scalar D[X] */
6976 OP_RVC, /* VFP control register */
6977 OP_RMF, /* Maverick F register */
6978 OP_RMD, /* Maverick D register */
6979 OP_RMFX, /* Maverick FX register */
6980 OP_RMDX, /* Maverick DX register */
6981 OP_RMAX, /* Maverick AX register */
6982 OP_RMDS, /* Maverick DSPSC register */
6983 OP_RIWR, /* iWMMXt wR register */
6984 OP_RIWC, /* iWMMXt wC register */
6985 OP_RIWG, /* iWMMXt wCG register */
6986 OP_RXA, /* XScale accumulator register */
6988 OP_RNSDQMQ, /* Neon single, double or quad register or MVE vector register
6990 OP_RNSDQMQR, /* Neon single, double or quad register, MVE vector register or
6992 OP_RMQ, /* MVE vector register. */
6993 OP_RMQRZ, /* MVE vector or ARM register including ZR. */
6994 OP_RMQRR, /* MVE vector or ARM register. */
6996 /* New operands for Armv8.1-M Mainline. */
6997 OP_LR, /* ARM LR register */
6998 OP_RRe, /* ARM register, only even numbered. */
6999 OP_RRo, /* ARM register, only odd numbered, not r13 or r15. */
7000 OP_RRnpcsp_I32, /* ARM register (no BadReg) or literal 1 .. 32 */
7001 OP_RR_ZR, /* ARM register or ZR but no PC */
7003 OP_REGLST, /* ARM register list */
7004 OP_CLRMLST, /* CLRM register list */
7005 OP_VRSLST, /* VFP single-precision register list */
7006 OP_VRDLST, /* VFP double-precision register list */
7007 OP_VRSDLST, /* VFP single or double-precision register list (& quad) */
7008 OP_NRDLST, /* Neon double-precision register list (d0-d31, qN aliases) */
7009 OP_NSTRLST, /* Neon element/structure list */
7010 OP_VRSDVLST, /* VFP single or double-precision register list and VPR */
7011 OP_MSTRLST2, /* MVE vector list with two elements. */
7012 OP_MSTRLST4, /* MVE vector list with four elements. */
7014 OP_RNDQ_I0, /* Neon D or Q reg, or immediate zero. */
7015 OP_RVSD_I0, /* VFP S or D reg, or immediate zero. */
7016 OP_RSVD_FI0, /* VFP S or D reg, or floating point immediate zero. */
7017 OP_RSVDMQ_FI0, /* VFP S, D, MVE vector register or floating point immediate
7019 OP_RR_RNSC, /* ARM reg or Neon scalar. */
7020 OP_RNSD_RNSC, /* Neon S or D reg, or Neon scalar. */
7021 OP_RNSDQ_RNSC, /* Vector S, D or Q reg, or Neon scalar. */
7022 OP_RNSDQ_RNSC_MQ, /* Vector S, D or Q reg, Neon scalar or MVE vector register.
7024 OP_RNSDQ_RNSC_MQ_RR, /* Vector S, D or Q reg, or MVE vector reg , or Neon
7025 scalar, or ARM register. */
7026 OP_RNDQ_RNSC, /* Neon D or Q reg, or Neon scalar. */
7027 OP_RNDQ_RNSC_RR, /* Neon D or Q reg, Neon scalar, or ARM register. */
7028 OP_RNDQMQ_RNSC_RR, /* Neon D or Q reg, Neon scalar, MVE vector or ARM
7030 OP_RNDQMQ_RNSC, /* Neon D, Q or MVE vector reg, or Neon scalar. */
7031 OP_RND_RNSC, /* Neon D reg, or Neon scalar. */
7032 OP_VMOV, /* Neon VMOV operands. */
7033 OP_RNDQ_Ibig, /* Neon D or Q reg, or big immediate for logic and VMVN. */
7034 /* Neon D, Q or MVE vector register, or big immediate for logic and VMVN. */
7036 OP_RNDQ_I63b, /* Neon D or Q reg, or immediate for shift. */
7037 OP_RNDQMQ_I63b_RR, /* Neon D or Q reg, immediate for shift, MVE vector or
7039 OP_RIWR_I32z, /* iWMMXt wR register, or immediate 0 .. 32 for iWMMXt2. */
7040 OP_VLDR, /* VLDR operand. */
7042 OP_I0, /* immediate zero */
7043 OP_I7, /* immediate value 0 .. 7 */
7044 OP_I15, /* 0 .. 15 */
7045 OP_I16, /* 1 .. 16 */
7046 OP_I16z, /* 0 .. 16 */
7047 OP_I31, /* 0 .. 31 */
7048 OP_I31w, /* 0 .. 31, optional trailing ! */
7049 OP_I32, /* 1 .. 32 */
7050 OP_I32z, /* 0 .. 32 */
7051 OP_I48_I64, /* 48 or 64 */
7052 OP_I63, /* 0 .. 63 */
7053 OP_I63s, /* -64 .. 63 */
7054 OP_I64, /* 1 .. 64 */
7055 OP_I64z, /* 0 .. 64 */
7056 OP_I255, /* 0 .. 255 */
7058 OP_I4b, /* immediate, prefix optional, 1 .. 4 */
7059 OP_I7b, /* 0 .. 7 */
7060 OP_I15b, /* 0 .. 15 */
7061 OP_I31b, /* 0 .. 31 */
7063 OP_SH, /* shifter operand */
7064 OP_SHG, /* shifter operand with possible group relocation */
7065 OP_ADDR, /* Memory address expression (any mode) */
7066 OP_ADDRMVE, /* Memory address expression for MVE's VSTR/VLDR. */
7067 OP_ADDRGLDR, /* Mem addr expr (any mode) with possible LDR group reloc */
7068 OP_ADDRGLDRS, /* Mem addr expr (any mode) with possible LDRS group reloc */
7069 OP_ADDRGLDC, /* Mem addr expr (any mode) with possible LDC group reloc */
7070 OP_EXP, /* arbitrary expression */
7071 OP_EXPi, /* same, with optional immediate prefix */
7072 OP_EXPr, /* same, with optional relocation suffix */
7073 OP_EXPs, /* same, with optional non-first operand relocation suffix */
7074 OP_HALF, /* 0 .. 65535 or low/high reloc. */
7075 OP_IROT1, /* VCADD rotate immediate: 90, 270. */
7076 OP_IROT2, /* VCMLA rotate immediate: 0, 90, 180, 270. */
7078 OP_CPSF, /* CPS flags */
7079 OP_ENDI, /* Endianness specifier */
7080 OP_wPSR, /* CPSR/SPSR/APSR mask for msr (writing). */
7081 OP_rPSR, /* CPSR/SPSR/APSR mask for msr (reading). */
7082 OP_COND, /* conditional code */
7083 OP_TB, /* Table branch. */
7085 OP_APSR_RR, /* ARM register or "APSR_nzcv". */
7087 OP_RRnpc_I0, /* ARM register or literal 0 */
7088 OP_RR_EXr, /* ARM register or expression with opt. reloc stuff. */
7089 OP_RR_EXi, /* ARM register or expression with imm prefix */
7090 OP_RF_IF, /* FPA register or immediate */
7091 OP_RIWR_RIWC, /* iWMMXt R or C reg */
7092 OP_RIWC_RIWG, /* iWMMXt wC or wCG reg */
7094 /* Optional operands. */
7095 OP_oI7b, /* immediate, prefix optional, 0 .. 7 */
7096 OP_oI31b, /* 0 .. 31 */
7097 OP_oI32b, /* 1 .. 32 */
7098 OP_oI32z, /* 0 .. 32 */
7099 OP_oIffffb, /* 0 .. 65535 */
7100 OP_oI255c, /* curly-brace enclosed, 0 .. 255 */
7102 OP_oRR, /* ARM register */
7103 OP_oLR, /* ARM LR register */
7104 OP_oRRnpc, /* ARM register, not the PC */
7105 OP_oRRnpcsp, /* ARM register, neither the PC nor the SP (a.k.a. BadReg) */
7106 OP_oRRw, /* ARM register, not r15, optional trailing ! */
7107 OP_oRND, /* Optional Neon double precision register */
7108 OP_oRNQ, /* Optional Neon quad precision register */
7109 OP_oRNDQMQ, /* Optional Neon double, quad or MVE vector register. */
7110 OP_oRNDQ, /* Optional Neon double or quad precision register */
7111 OP_oRNSDQ, /* Optional single, double or quad precision vector register */
7112 OP_oRNSDQMQ, /* Optional single, double or quad register or MVE vector
7114 OP_oSHll, /* LSL immediate */
7115 OP_oSHar, /* ASR immediate */
7116 OP_oSHllar, /* LSL or ASR immediate */
7117 OP_oROR, /* ROR 0/8/16/24 */
7118 OP_oBARRIER_I15, /* Option argument for a barrier instruction. */
7120 OP_oRMQRZ, /* optional MVE vector or ARM register including ZR. */
7122 /* Some pre-defined mixed (ARM/THUMB) operands. */
7123 OP_RR_npcsp = MIX_ARM_THUMB_OPERANDS (OP_RR, OP_RRnpcsp),
7124 OP_RRnpc_npcsp = MIX_ARM_THUMB_OPERANDS (OP_RRnpc, OP_RRnpcsp),
7125 OP_oRRnpc_npcsp = MIX_ARM_THUMB_OPERANDS (OP_oRRnpc, OP_oRRnpcsp),
7127 OP_FIRST_OPTIONAL = OP_oI7b
7130 /* Generic instruction operand parser. This does no encoding and no
7131 semantic validation; it merely squirrels values away in the inst
7132 structure. Returns SUCCESS or FAIL depending on whether the
7133 specified grammar matched. */
7135 parse_operands (char *str, const unsigned int *pattern, bfd_boolean thumb)
7137 unsigned const int *upat = pattern;
7138 char *backtrack_pos = 0;
7139 const char *backtrack_error = 0;
7140 int i, val = 0, backtrack_index = 0;
7141 enum arm_reg_type rtype;
7142 parse_operand_result result;
7143 unsigned int op_parse_code;
7144 bfd_boolean partial_match;
7146 #define po_char_or_fail(chr) \
7149 if (skip_past_char (&str, chr) == FAIL) \
7154 #define po_reg_or_fail(regtype) \
7157 val = arm_typed_reg_parse (& str, regtype, & rtype, \
7158 & inst.operands[i].vectype); \
7161 first_error (_(reg_expected_msgs[regtype])); \
7164 inst.operands[i].reg = val; \
7165 inst.operands[i].isreg = 1; \
7166 inst.operands[i].isquad = (rtype == REG_TYPE_NQ); \
7167 inst.operands[i].issingle = (rtype == REG_TYPE_VFS); \
7168 inst.operands[i].isvec = (rtype == REG_TYPE_VFS \
7169 || rtype == REG_TYPE_VFD \
7170 || rtype == REG_TYPE_NQ); \
7171 inst.operands[i].iszr = (rtype == REG_TYPE_ZR); \
7175 #define po_reg_or_goto(regtype, label) \
7178 val = arm_typed_reg_parse (& str, regtype, & rtype, \
7179 & inst.operands[i].vectype); \
7183 inst.operands[i].reg = val; \
7184 inst.operands[i].isreg = 1; \
7185 inst.operands[i].isquad = (rtype == REG_TYPE_NQ); \
7186 inst.operands[i].issingle = (rtype == REG_TYPE_VFS); \
7187 inst.operands[i].isvec = (rtype == REG_TYPE_VFS \
7188 || rtype == REG_TYPE_VFD \
7189 || rtype == REG_TYPE_NQ); \
7190 inst.operands[i].iszr = (rtype == REG_TYPE_ZR); \
7194 #define po_imm_or_fail(min, max, popt) \
7197 if (parse_immediate (&str, &val, min, max, popt) == FAIL) \
7199 inst.operands[i].imm = val; \
7203 #define po_imm1_or_imm2_or_fail(imm1, imm2, popt) \
7207 my_get_expression (&exp, &str, popt); \
7208 if (exp.X_op != O_constant) \
7210 inst.error = _("constant expression required"); \
7213 if (exp.X_add_number != imm1 && exp.X_add_number != imm2) \
7215 inst.error = _("immediate value 48 or 64 expected"); \
7218 inst.operands[i].imm = exp.X_add_number; \
7222 #define po_scalar_or_goto(elsz, label, reg_type) \
7225 val = parse_scalar (& str, elsz, & inst.operands[i].vectype, \
7229 inst.operands[i].reg = val; \
7230 inst.operands[i].isscalar = 1; \
7234 #define po_misc_or_fail(expr) \
7242 #define po_misc_or_fail_no_backtrack(expr) \
7246 if (result == PARSE_OPERAND_FAIL_NO_BACKTRACK) \
7247 backtrack_pos = 0; \
7248 if (result != PARSE_OPERAND_SUCCESS) \
7253 #define po_barrier_or_imm(str) \
7256 val = parse_barrier (&str); \
7257 if (val == FAIL && ! ISALPHA (*str)) \
7260 /* ISB can only take SY as an option. */ \
7261 || ((inst.instruction & 0xf0) == 0x60 \
7264 inst.error = _("invalid barrier type"); \
7265 backtrack_pos = 0; \
7271 skip_whitespace (str);
7273 for (i = 0; upat[i] != OP_stop; i++)
7275 op_parse_code = upat[i];
7276 if (op_parse_code >= 1<<16)
7277 op_parse_code = thumb ? (op_parse_code >> 16)
7278 : (op_parse_code & ((1<<16)-1));
7280 if (op_parse_code >= OP_FIRST_OPTIONAL)
7282 /* Remember where we are in case we need to backtrack. */
7283 backtrack_pos = str;
7284 backtrack_error = inst.error;
7285 backtrack_index = i;
7288 if (i > 0 && (i > 1 || inst.operands[0].present))
7289 po_char_or_fail (',');
7291 switch (op_parse_code)
7303 case OP_RR: po_reg_or_fail (REG_TYPE_RN); break;
7304 case OP_RCP: po_reg_or_fail (REG_TYPE_CP); break;
7305 case OP_RCN: po_reg_or_fail (REG_TYPE_CN); break;
7306 case OP_RF: po_reg_or_fail (REG_TYPE_FN); break;
7307 case OP_RVS: po_reg_or_fail (REG_TYPE_VFS); break;
7308 case OP_RVD: po_reg_or_fail (REG_TYPE_VFD); break;
7311 po_reg_or_goto (REG_TYPE_RN, try_rndmq);
7315 po_reg_or_goto (REG_TYPE_MQ, try_rnd);
7318 case OP_RND: po_reg_or_fail (REG_TYPE_VFD); break;
7320 po_reg_or_goto (REG_TYPE_VFC, coproc_reg);
7322 /* Also accept generic coprocessor regs for unknown registers. */
7324 po_reg_or_goto (REG_TYPE_CN, vpr_po);
7326 /* Also accept P0 or p0 for VPR.P0. Since P0 is already an
7327 existing register with a value of 0, this seems like the
7328 best way to parse P0. */
7330 if (strncasecmp (str, "P0", 2) == 0)
7333 inst.operands[i].isreg = 1;
7334 inst.operands[i].reg = 13;
7339 case OP_RMF: po_reg_or_fail (REG_TYPE_MVF); break;
7340 case OP_RMD: po_reg_or_fail (REG_TYPE_MVD); break;
7341 case OP_RMFX: po_reg_or_fail (REG_TYPE_MVFX); break;
7342 case OP_RMDX: po_reg_or_fail (REG_TYPE_MVDX); break;
7343 case OP_RMAX: po_reg_or_fail (REG_TYPE_MVAX); break;
7344 case OP_RMDS: po_reg_or_fail (REG_TYPE_DSPSC); break;
7345 case OP_RIWR: po_reg_or_fail (REG_TYPE_MMXWR); break;
7346 case OP_RIWC: po_reg_or_fail (REG_TYPE_MMXWC); break;
7347 case OP_RIWG: po_reg_or_fail (REG_TYPE_MMXWCG); break;
7348 case OP_RXA: po_reg_or_fail (REG_TYPE_XSCALE); break;
7351 po_reg_or_goto (REG_TYPE_MQ, try_nq);
7354 case OP_RNQ: po_reg_or_fail (REG_TYPE_NQ); break;
7355 case OP_RNSD: po_reg_or_fail (REG_TYPE_NSD); break;
7357 po_reg_or_goto (REG_TYPE_RN, try_rndqmq);
7362 po_reg_or_goto (REG_TYPE_MQ, try_rndq);
7366 case OP_RNDQ: po_reg_or_fail (REG_TYPE_NDQ); break;
7368 po_reg_or_goto (REG_TYPE_MQ, try_rvsd);
7371 case OP_RVSD: po_reg_or_fail (REG_TYPE_VFSD); break;
7373 po_reg_or_goto (REG_TYPE_VFSD, try_cond);
7376 case OP_RNSDQ: po_reg_or_fail (REG_TYPE_NSDQ); break;
7378 po_reg_or_goto (REG_TYPE_RN, try_mq);
7383 po_reg_or_goto (REG_TYPE_MQ, try_nsdq2);
7386 po_reg_or_fail (REG_TYPE_NSDQ);
7390 po_reg_or_goto (REG_TYPE_RN, try_rmq);
7394 po_reg_or_fail (REG_TYPE_MQ);
7396 /* Neon scalar. Using an element size of 8 means that some invalid
7397 scalars are accepted here, so deal with those in later code. */
7398 case OP_RNSC: po_scalar_or_goto (8, failure, REG_TYPE_VFD); break;
7402 po_reg_or_goto (REG_TYPE_NDQ, try_imm0);
7405 po_imm_or_fail (0, 0, TRUE);
7410 po_reg_or_goto (REG_TYPE_VFSD, try_imm0);
7414 po_reg_or_goto (REG_TYPE_MQ, try_rsvd_fi0);
7419 po_reg_or_goto (REG_TYPE_VFSD, try_ifimm0);
7422 if (parse_ifimm_zero (&str))
7423 inst.operands[i].imm = 0;
7427 = _("only floating point zero is allowed as immediate value");
7435 po_scalar_or_goto (8, try_rr, REG_TYPE_VFD);
7438 po_reg_or_fail (REG_TYPE_RN);
7442 case OP_RNSDQ_RNSC_MQ_RR:
7443 po_reg_or_goto (REG_TYPE_RN, try_rnsdq_rnsc_mq);
7446 case OP_RNSDQ_RNSC_MQ:
7447 po_reg_or_goto (REG_TYPE_MQ, try_rnsdq_rnsc);
7452 po_scalar_or_goto (8, try_nsdq, REG_TYPE_VFD);
7456 po_reg_or_fail (REG_TYPE_NSDQ);
7463 po_scalar_or_goto (8, try_s_scalar, REG_TYPE_VFD);
7466 po_scalar_or_goto (4, try_nsd, REG_TYPE_VFS);
7469 po_reg_or_fail (REG_TYPE_NSD);
7473 case OP_RNDQMQ_RNSC_RR:
7474 po_reg_or_goto (REG_TYPE_MQ, try_rndq_rnsc_rr);
7477 case OP_RNDQ_RNSC_RR:
7478 po_reg_or_goto (REG_TYPE_RN, try_rndq_rnsc);
7480 case OP_RNDQMQ_RNSC:
7481 po_reg_or_goto (REG_TYPE_MQ, try_rndq_rnsc);
7486 po_scalar_or_goto (8, try_ndq, REG_TYPE_VFD);
7489 po_reg_or_fail (REG_TYPE_NDQ);
7495 po_scalar_or_goto (8, try_vfd, REG_TYPE_VFD);
7498 po_reg_or_fail (REG_TYPE_VFD);
7503 /* WARNING: parse_neon_mov can move the operand counter, i. If we're
7504 not careful then bad things might happen. */
7505 po_misc_or_fail (parse_neon_mov (&str, &i) == FAIL);
7508 case OP_RNDQMQ_Ibig:
7509 po_reg_or_goto (REG_TYPE_MQ, try_rndq_ibig);
7514 po_reg_or_goto (REG_TYPE_NDQ, try_immbig);
7517 /* There's a possibility of getting a 64-bit immediate here, so
7518 we need special handling. */
7519 if (parse_big_immediate (&str, i, NULL, /*allow_symbol_p=*/FALSE)
7522 inst.error = _("immediate value is out of range");
7528 case OP_RNDQMQ_I63b_RR:
7529 po_reg_or_goto (REG_TYPE_MQ, try_rndq_i63b_rr);
7532 po_reg_or_goto (REG_TYPE_RN, try_rndq_i63b);
7537 po_reg_or_goto (REG_TYPE_NDQ, try_shimm);
7540 po_imm_or_fail (0, 63, TRUE);
7545 po_char_or_fail ('[');
7546 po_reg_or_fail (REG_TYPE_RN);
7547 po_char_or_fail (']');
7553 po_reg_or_fail (REG_TYPE_RN);
7554 if (skip_past_char (&str, '!') == SUCCESS)
7555 inst.operands[i].writeback = 1;
7559 case OP_I7: po_imm_or_fail ( 0, 7, FALSE); break;
7560 case OP_I15: po_imm_or_fail ( 0, 15, FALSE); break;
7561 case OP_I16: po_imm_or_fail ( 1, 16, FALSE); break;
7562 case OP_I16z: po_imm_or_fail ( 0, 16, FALSE); break;
7563 case OP_I31: po_imm_or_fail ( 0, 31, FALSE); break;
7564 case OP_I32: po_imm_or_fail ( 1, 32, FALSE); break;
7565 case OP_I32z: po_imm_or_fail ( 0, 32, FALSE); break;
7566 case OP_I48_I64: po_imm1_or_imm2_or_fail (48, 64, FALSE); break;
7567 case OP_I63s: po_imm_or_fail (-64, 63, FALSE); break;
7568 case OP_I63: po_imm_or_fail ( 0, 63, FALSE); break;
7569 case OP_I64: po_imm_or_fail ( 1, 64, FALSE); break;
7570 case OP_I64z: po_imm_or_fail ( 0, 64, FALSE); break;
7571 case OP_I255: po_imm_or_fail ( 0, 255, FALSE); break;
7573 case OP_I4b: po_imm_or_fail ( 1, 4, TRUE); break;
7575 case OP_I7b: po_imm_or_fail ( 0, 7, TRUE); break;
7576 case OP_I15b: po_imm_or_fail ( 0, 15, TRUE); break;
7578 case OP_I31b: po_imm_or_fail ( 0, 31, TRUE); break;
7579 case OP_oI32b: po_imm_or_fail ( 1, 32, TRUE); break;
7580 case OP_oI32z: po_imm_or_fail ( 0, 32, TRUE); break;
7581 case OP_oIffffb: po_imm_or_fail ( 0, 0xffff, TRUE); break;
7583 /* Immediate variants */
7585 po_char_or_fail ('{');
7586 po_imm_or_fail (0, 255, TRUE);
7587 po_char_or_fail ('}');
7591 /* The expression parser chokes on a trailing !, so we have
7592 to find it first and zap it. */
7595 while (*s && *s != ',')
7600 inst.operands[i].writeback = 1;
7602 po_imm_or_fail (0, 31, TRUE);
7610 po_misc_or_fail (my_get_expression (&inst.relocs[0].exp, &str,
7615 po_misc_or_fail (my_get_expression (&inst.relocs[0].exp, &str,
7620 po_misc_or_fail (my_get_expression (&inst.relocs[0].exp, &str,
7622 if (inst.relocs[0].exp.X_op == O_symbol)
7624 val = parse_reloc (&str);
7627 inst.error = _("unrecognized relocation suffix");
7630 else if (val != BFD_RELOC_UNUSED)
7632 inst.operands[i].imm = val;
7633 inst.operands[i].hasreloc = 1;
7639 po_misc_or_fail (my_get_expression (&inst.relocs[i].exp, &str,
7641 if (inst.relocs[i].exp.X_op == O_symbol)
7643 inst.operands[i].hasreloc = 1;
7645 else if (inst.relocs[i].exp.X_op == O_constant)
7647 inst.operands[i].imm = inst.relocs[i].exp.X_add_number;
7648 inst.operands[i].hasreloc = 0;
7652 /* Operand for MOVW or MOVT. */
7654 po_misc_or_fail (parse_half (&str));
7657 /* Register or expression. */
7658 case OP_RR_EXr: po_reg_or_goto (REG_TYPE_RN, EXPr); break;
7659 case OP_RR_EXi: po_reg_or_goto (REG_TYPE_RN, EXPi); break;
7661 /* Register or immediate. */
7662 case OP_RRnpc_I0: po_reg_or_goto (REG_TYPE_RN, I0); break;
7663 I0: po_imm_or_fail (0, 0, FALSE); break;
7665 case OP_RRnpcsp_I32: po_reg_or_goto (REG_TYPE_RN, I32); break;
7666 I32: po_imm_or_fail (1, 32, FALSE); break;
7668 case OP_RF_IF: po_reg_or_goto (REG_TYPE_FN, IF); break;
7670 if (!is_immediate_prefix (*str))
7673 val = parse_fpa_immediate (&str);
7676 /* FPA immediates are encoded as registers 8-15.
7677 parse_fpa_immediate has already applied the offset. */
7678 inst.operands[i].reg = val;
7679 inst.operands[i].isreg = 1;
7682 case OP_RIWR_I32z: po_reg_or_goto (REG_TYPE_MMXWR, I32z); break;
7683 I32z: po_imm_or_fail (0, 32, FALSE); break;
7685 /* Two kinds of register. */
7688 struct reg_entry *rege = arm_reg_parse_multi (&str);
7690 || (rege->type != REG_TYPE_MMXWR
7691 && rege->type != REG_TYPE_MMXWC
7692 && rege->type != REG_TYPE_MMXWCG))
7694 inst.error = _("iWMMXt data or control register expected");
7697 inst.operands[i].reg = rege->number;
7698 inst.operands[i].isreg = (rege->type == REG_TYPE_MMXWR);
7704 struct reg_entry *rege = arm_reg_parse_multi (&str);
7706 || (rege->type != REG_TYPE_MMXWC
7707 && rege->type != REG_TYPE_MMXWCG))
7709 inst.error = _("iWMMXt control register expected");
7712 inst.operands[i].reg = rege->number;
7713 inst.operands[i].isreg = 1;
7718 case OP_CPSF: val = parse_cps_flags (&str); break;
7719 case OP_ENDI: val = parse_endian_specifier (&str); break;
7720 case OP_oROR: val = parse_ror (&str); break;
7722 case OP_COND: val = parse_cond (&str); break;
7723 case OP_oBARRIER_I15:
7724 po_barrier_or_imm (str); break;
7726 if (parse_immediate (&str, &val, 0, 15, TRUE) == FAIL)
7732 po_reg_or_goto (REG_TYPE_RNB, try_psr);
7733 if (!ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_virt))
7735 inst.error = _("Banked registers are not available with this "
7741 val = parse_psr (&str, op_parse_code == OP_wPSR);
7745 po_reg_or_goto (REG_TYPE_VFSD, try_sysreg);
7748 val = parse_sys_vldr_vstr (&str);
7752 po_reg_or_goto (REG_TYPE_RN, try_apsr);
7755 /* Parse "APSR_nvzc" operand (for FMSTAT-equivalent MRS
7757 if (strncasecmp (str, "APSR_", 5) == 0)
7764 case 'c': found = (found & 1) ? 16 : found | 1; break;
7765 case 'n': found = (found & 2) ? 16 : found | 2; break;
7766 case 'z': found = (found & 4) ? 16 : found | 4; break;
7767 case 'v': found = (found & 8) ? 16 : found | 8; break;
7768 default: found = 16;
7772 inst.operands[i].isvec = 1;
7773 /* APSR_nzcv is encoded in instructions as if it were the REG_PC. */
7774 inst.operands[i].reg = REG_PC;
7781 po_misc_or_fail (parse_tb (&str));
7784 /* Register lists. */
7786 val = parse_reg_list (&str, REGLIST_RN);
7789 inst.operands[i].writeback = 1;
7795 val = parse_reg_list (&str, REGLIST_CLRM);
7799 val = parse_vfp_reg_list (&str, &inst.operands[i].reg, REGLIST_VFP_S,
7804 val = parse_vfp_reg_list (&str, &inst.operands[i].reg, REGLIST_VFP_D,
7809 /* Allow Q registers too. */
7810 val = parse_vfp_reg_list (&str, &inst.operands[i].reg,
7811 REGLIST_NEON_D, &partial_match);
7815 val = parse_vfp_reg_list (&str, &inst.operands[i].reg,
7816 REGLIST_VFP_S, &partial_match);
7817 inst.operands[i].issingle = 1;
7822 val = parse_vfp_reg_list (&str, &inst.operands[i].reg,
7823 REGLIST_VFP_D_VPR, &partial_match);
7824 if (val == FAIL && !partial_match)
7827 val = parse_vfp_reg_list (&str, &inst.operands[i].reg,
7828 REGLIST_VFP_S_VPR, &partial_match);
7829 inst.operands[i].issingle = 1;
7834 val = parse_vfp_reg_list (&str, &inst.operands[i].reg,
7835 REGLIST_NEON_D, &partial_match);
7840 val = parse_neon_el_struct_list (&str, &inst.operands[i].reg,
7841 1, &inst.operands[i].vectype);
7842 if (val != (((op_parse_code == OP_MSTRLST2) ? 3 : 7) << 5 | 0xe))
7846 val = parse_neon_el_struct_list (&str, &inst.operands[i].reg,
7847 0, &inst.operands[i].vectype);
7850 /* Addressing modes */
7852 po_misc_or_fail (parse_address_group_reloc (&str, i, GROUP_MVE));
7856 po_misc_or_fail (parse_address (&str, i));
7860 po_misc_or_fail_no_backtrack (
7861 parse_address_group_reloc (&str, i, GROUP_LDR));
7865 po_misc_or_fail_no_backtrack (
7866 parse_address_group_reloc (&str, i, GROUP_LDRS));
7870 po_misc_or_fail_no_backtrack (
7871 parse_address_group_reloc (&str, i, GROUP_LDC));
7875 po_misc_or_fail (parse_shifter_operand (&str, i));
7879 po_misc_or_fail_no_backtrack (
7880 parse_shifter_operand_group_reloc (&str, i));
7884 po_misc_or_fail (parse_shift (&str, i, SHIFT_LSL_IMMEDIATE));
7888 po_misc_or_fail (parse_shift (&str, i, SHIFT_ASR_IMMEDIATE));
7892 po_misc_or_fail (parse_shift (&str, i, SHIFT_LSL_OR_ASR_IMMEDIATE));
7897 po_reg_or_goto (REG_TYPE_MQ, try_rr_zr);
7902 po_reg_or_goto (REG_TYPE_RN, ZR);
7905 po_reg_or_fail (REG_TYPE_ZR);
7909 as_fatal (_("unhandled operand code %d"), op_parse_code);
7912 /* Various value-based sanity checks and shared operations. We
7913 do not signal immediate failures for the register constraints;
7914 this allows a syntax error to take precedence. */
7915 switch (op_parse_code)
7923 if (inst.operands[i].isreg && inst.operands[i].reg == REG_PC)
7924 inst.error = BAD_PC;
7929 case OP_RRnpcsp_I32:
7930 if (inst.operands[i].isreg)
7932 if (inst.operands[i].reg == REG_PC)
7933 inst.error = BAD_PC;
7934 else if (inst.operands[i].reg == REG_SP
7935 /* The restriction on Rd/Rt/Rt2 on Thumb mode has been
7936 relaxed since ARMv8-A. */
7937 && !ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_v8))
7940 inst.error = BAD_SP;
7946 if (inst.operands[i].isreg
7947 && inst.operands[i].reg == REG_PC
7948 && (inst.operands[i].writeback || thumb))
7949 inst.error = BAD_PC;
7954 if (inst.operands[i].isreg)
7964 case OP_oBARRIER_I15:
7977 inst.operands[i].imm = val;
7982 if (inst.operands[i].reg != REG_LR)
7983 inst.error = _("operand must be LR register");
7989 if (!inst.operands[i].iszr && inst.operands[i].reg == REG_PC)
7990 inst.error = BAD_PC;
7994 if (inst.operands[i].isreg
7995 && (inst.operands[i].reg & 0x00000001) != 0)
7996 inst.error = BAD_ODD;
8000 if (inst.operands[i].isreg)
8002 if ((inst.operands[i].reg & 0x00000001) != 1)
8003 inst.error = BAD_EVEN;
8004 else if (inst.operands[i].reg == REG_SP)
8005 as_tsktsk (MVE_BAD_SP);
8006 else if (inst.operands[i].reg == REG_PC)
8007 inst.error = BAD_PC;
8015 /* If we get here, this operand was successfully parsed. */
8016 inst.operands[i].present = 1;
8020 inst.error = BAD_ARGS;
8025 /* The parse routine should already have set inst.error, but set a
8026 default here just in case. */
8028 inst.error = BAD_SYNTAX;
8032 /* Do not backtrack over a trailing optional argument that
8033 absorbed some text. We will only fail again, with the
8034 'garbage following instruction' error message, which is
8035 probably less helpful than the current one. */
8036 if (backtrack_index == i && backtrack_pos != str
8037 && upat[i+1] == OP_stop)
8040 inst.error = BAD_SYNTAX;
8044 /* Try again, skipping the optional argument at backtrack_pos. */
8045 str = backtrack_pos;
8046 inst.error = backtrack_error;
8047 inst.operands[backtrack_index].present = 0;
8048 i = backtrack_index;
8052 /* Check that we have parsed all the arguments. */
8053 if (*str != '\0' && !inst.error)
8054 inst.error = _("garbage following instruction");
8056 return inst.error ? FAIL : SUCCESS;
8059 #undef po_char_or_fail
8060 #undef po_reg_or_fail
8061 #undef po_reg_or_goto
8062 #undef po_imm_or_fail
8063 #undef po_scalar_or_fail
8064 #undef po_barrier_or_imm
8066 /* Shorthand macro for instruction encoding functions issuing errors. */
8067 #define constraint(expr, err) \
8078 /* Reject "bad registers" for Thumb-2 instructions. Many Thumb-2
8079 instructions are unpredictable if these registers are used. This
8080 is the BadReg predicate in ARM's Thumb-2 documentation.
8082 Before ARMv8-A, REG_PC and REG_SP were not allowed in quite a few
8083 places, while the restriction on REG_SP was relaxed since ARMv8-A. */
8084 #define reject_bad_reg(reg) \
8086 if (reg == REG_PC) \
8088 inst.error = BAD_PC; \
8091 else if (reg == REG_SP \
8092 && !ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_v8)) \
8094 inst.error = BAD_SP; \
8099 /* If REG is R13 (the stack pointer), warn that its use is
8101 #define warn_deprecated_sp(reg) \
8103 if (warn_on_deprecated && reg == REG_SP) \
8104 as_tsktsk (_("use of r13 is deprecated")); \
8107 /* Functions for operand encoding. ARM, then Thumb. */
8109 #define rotate_left(v, n) (v << (n & 31) | v >> ((32 - n) & 31))
8111 /* If the current inst is scalar ARMv8.2 fp16 instruction, do special encoding.
8113 The only binary encoding difference is the Coprocessor number. Coprocessor
8114 9 is used for half-precision calculations or conversions. The format of the
8115 instruction is the same as the equivalent Coprocessor 10 instruction that
8116 exists for Single-Precision operation. */
8119 do_scalar_fp16_v82_encode (void)
8121 if (inst.cond < COND_ALWAYS)
8122 as_warn (_("ARMv8.2 scalar fp16 instruction cannot be conditional,"
8123 " the behaviour is UNPREDICTABLE"));
8124 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_fp16),
8127 inst.instruction = (inst.instruction & 0xfffff0ff) | 0x900;
8128 mark_feature_used (&arm_ext_fp16);
8131 /* If VAL can be encoded in the immediate field of an ARM instruction,
8132 return the encoded form. Otherwise, return FAIL. */
8135 encode_arm_immediate (unsigned int val)
8142 for (i = 2; i < 32; i += 2)
8143 if ((a = rotate_left (val, i)) <= 0xff)
8144 return a | (i << 7); /* 12-bit pack: [shift-cnt,const]. */
8149 /* If VAL can be encoded in the immediate field of a Thumb32 instruction,
8150 return the encoded form. Otherwise, return FAIL. */
8152 encode_thumb32_immediate (unsigned int val)
8159 for (i = 1; i <= 24; i++)
8162 if ((val & ~(0xff << i)) == 0)
8163 return ((val >> i) & 0x7f) | ((32 - i) << 7);
8167 if (val == ((a << 16) | a))
8169 if (val == ((a << 24) | (a << 16) | (a << 8) | a))
8173 if (val == ((a << 16) | a))
8174 return 0x200 | (a >> 8);
8178 /* Encode a VFP SP or DP register number into inst.instruction. */
8181 encode_arm_vfp_reg (int reg, enum vfp_reg_pos pos)
8183 if ((pos == VFP_REG_Dd || pos == VFP_REG_Dn || pos == VFP_REG_Dm)
8186 if (ARM_CPU_HAS_FEATURE (cpu_variant, fpu_vfp_ext_d32))
8189 ARM_MERGE_FEATURE_SETS (thumb_arch_used, thumb_arch_used,
8192 ARM_MERGE_FEATURE_SETS (arm_arch_used, arm_arch_used,
8197 first_error (_("D register out of range for selected VFP version"));
8205 inst.instruction |= ((reg >> 1) << 12) | ((reg & 1) << 22);
8209 inst.instruction |= ((reg >> 1) << 16) | ((reg & 1) << 7);
8213 inst.instruction |= ((reg >> 1) << 0) | ((reg & 1) << 5);
8217 inst.instruction |= ((reg & 15) << 12) | ((reg >> 4) << 22);
8221 inst.instruction |= ((reg & 15) << 16) | ((reg >> 4) << 7);
8225 inst.instruction |= (reg & 15) | ((reg >> 4) << 5);
8233 /* Encode a <shift> in an ARM-format instruction. The immediate,
8234 if any, is handled by md_apply_fix. */
8236 encode_arm_shift (int i)
8238 /* register-shifted register. */
8239 if (inst.operands[i].immisreg)
8242 for (op_index = 0; op_index <= i; ++op_index)
8244 /* Check the operand only when it's presented. In pre-UAL syntax,
8245 if the destination register is the same as the first operand, two
8246 register form of the instruction can be used. */
8247 if (inst.operands[op_index].present && inst.operands[op_index].isreg
8248 && inst.operands[op_index].reg == REG_PC)
8249 as_warn (UNPRED_REG ("r15"));
8252 if (inst.operands[i].imm == REG_PC)
8253 as_warn (UNPRED_REG ("r15"));
8256 if (inst.operands[i].shift_kind == SHIFT_RRX)
8257 inst.instruction |= SHIFT_ROR << 5;
8260 inst.instruction |= inst.operands[i].shift_kind << 5;
8261 if (inst.operands[i].immisreg)
8263 inst.instruction |= SHIFT_BY_REG;
8264 inst.instruction |= inst.operands[i].imm << 8;
8267 inst.relocs[0].type = BFD_RELOC_ARM_SHIFT_IMM;
8272 encode_arm_shifter_operand (int i)
8274 if (inst.operands[i].isreg)
8276 inst.instruction |= inst.operands[i].reg;
8277 encode_arm_shift (i);
8281 inst.instruction |= INST_IMMEDIATE;
8282 if (inst.relocs[0].type != BFD_RELOC_ARM_IMMEDIATE)
8283 inst.instruction |= inst.operands[i].imm;
8287 /* Subroutine of encode_arm_addr_mode_2 and encode_arm_addr_mode_3. */
8289 encode_arm_addr_mode_common (int i, bfd_boolean is_t)
8292 Generate an error if the operand is not a register. */
8293 constraint (!inst.operands[i].isreg,
8294 _("Instruction does not support =N addresses"));
8296 inst.instruction |= inst.operands[i].reg << 16;
8298 if (inst.operands[i].preind)
8302 inst.error = _("instruction does not accept preindexed addressing");
8305 inst.instruction |= PRE_INDEX;
8306 if (inst.operands[i].writeback)
8307 inst.instruction |= WRITE_BACK;
8310 else if (inst.operands[i].postind)
8312 gas_assert (inst.operands[i].writeback);
8314 inst.instruction |= WRITE_BACK;
8316 else /* unindexed - only for coprocessor */
8318 inst.error = _("instruction does not accept unindexed addressing");
8322 if (((inst.instruction & WRITE_BACK) || !(inst.instruction & PRE_INDEX))
8323 && (((inst.instruction & 0x000f0000) >> 16)
8324 == ((inst.instruction & 0x0000f000) >> 12)))
8325 as_warn ((inst.instruction & LOAD_BIT)
8326 ? _("destination register same as write-back base")
8327 : _("source register same as write-back base"));
8330 /* inst.operands[i] was set up by parse_address. Encode it into an
8331 ARM-format mode 2 load or store instruction. If is_t is true,
8332 reject forms that cannot be used with a T instruction (i.e. not
8335 encode_arm_addr_mode_2 (int i, bfd_boolean is_t)
8337 const bfd_boolean is_pc = (inst.operands[i].reg == REG_PC);
8339 encode_arm_addr_mode_common (i, is_t);
8341 if (inst.operands[i].immisreg)
8343 constraint ((inst.operands[i].imm == REG_PC
8344 || (is_pc && inst.operands[i].writeback)),
8346 inst.instruction |= INST_IMMEDIATE; /* yes, this is backwards */
8347 inst.instruction |= inst.operands[i].imm;
8348 if (!inst.operands[i].negative)
8349 inst.instruction |= INDEX_UP;
8350 if (inst.operands[i].shifted)
8352 if (inst.operands[i].shift_kind == SHIFT_RRX)
8353 inst.instruction |= SHIFT_ROR << 5;
8356 inst.instruction |= inst.operands[i].shift_kind << 5;
8357 inst.relocs[0].type = BFD_RELOC_ARM_SHIFT_IMM;
8361 else /* immediate offset in inst.relocs[0] */
8363 if (is_pc && !inst.relocs[0].pc_rel)
8365 const bfd_boolean is_load = ((inst.instruction & LOAD_BIT) != 0);
8367 /* If is_t is TRUE, it's called from do_ldstt. ldrt/strt
8368 cannot use PC in addressing.
8369 PC cannot be used in writeback addressing, either. */
8370 constraint ((is_t || inst.operands[i].writeback),
8373 /* Use of PC in str is deprecated for ARMv7. */
8374 if (warn_on_deprecated
8376 && ARM_CPU_HAS_FEATURE (selected_cpu, arm_ext_v7))
8377 as_tsktsk (_("use of PC in this instruction is deprecated"));
8380 if (inst.relocs[0].type == BFD_RELOC_UNUSED)
8382 /* Prefer + for zero encoded value. */
8383 if (!inst.operands[i].negative)
8384 inst.instruction |= INDEX_UP;
8385 inst.relocs[0].type = BFD_RELOC_ARM_OFFSET_IMM;
8390 /* inst.operands[i] was set up by parse_address. Encode it into an
8391 ARM-format mode 3 load or store instruction. Reject forms that
8392 cannot be used with such instructions. If is_t is true, reject
8393 forms that cannot be used with a T instruction (i.e. not
8396 encode_arm_addr_mode_3 (int i, bfd_boolean is_t)
8398 if (inst.operands[i].immisreg && inst.operands[i].shifted)
8400 inst.error = _("instruction does not accept scaled register index");
8404 encode_arm_addr_mode_common (i, is_t);
8406 if (inst.operands[i].immisreg)
8408 constraint ((inst.operands[i].imm == REG_PC
8409 || (is_t && inst.operands[i].reg == REG_PC)),
8411 constraint (inst.operands[i].reg == REG_PC && inst.operands[i].writeback,
8413 inst.instruction |= inst.operands[i].imm;
8414 if (!inst.operands[i].negative)
8415 inst.instruction |= INDEX_UP;
8417 else /* immediate offset in inst.relocs[0] */
8419 constraint ((inst.operands[i].reg == REG_PC && !inst.relocs[0].pc_rel
8420 && inst.operands[i].writeback),
8422 inst.instruction |= HWOFFSET_IMM;
8423 if (inst.relocs[0].type == BFD_RELOC_UNUSED)
8425 /* Prefer + for zero encoded value. */
8426 if (!inst.operands[i].negative)
8427 inst.instruction |= INDEX_UP;
8429 inst.relocs[0].type = BFD_RELOC_ARM_OFFSET_IMM8;
8434 /* Write immediate bits [7:0] to the following locations:
8436 |28/24|23 19|18 16|15 4|3 0|
8437 | 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|
8439 This function is used by VMOV/VMVN/VORR/VBIC. */
8442 neon_write_immbits (unsigned immbits)
8444 inst.instruction |= immbits & 0xf;
8445 inst.instruction |= ((immbits >> 4) & 0x7) << 16;
8446 inst.instruction |= ((immbits >> 7) & 0x1) << (thumb_mode ? 28 : 24);
8449 /* Invert low-order SIZE bits of XHI:XLO. */
8452 neon_invert_size (unsigned *xlo, unsigned *xhi, int size)
8454 unsigned immlo = xlo ? *xlo : 0;
8455 unsigned immhi = xhi ? *xhi : 0;
8460 immlo = (~immlo) & 0xff;
8464 immlo = (~immlo) & 0xffff;
8468 immhi = (~immhi) & 0xffffffff;
8472 immlo = (~immlo) & 0xffffffff;
8486 /* True if IMM has form 0bAAAAAAAABBBBBBBBCCCCCCCCDDDDDDDD for bits
8490 neon_bits_same_in_bytes (unsigned imm)
8492 return ((imm & 0x000000ff) == 0 || (imm & 0x000000ff) == 0x000000ff)
8493 && ((imm & 0x0000ff00) == 0 || (imm & 0x0000ff00) == 0x0000ff00)
8494 && ((imm & 0x00ff0000) == 0 || (imm & 0x00ff0000) == 0x00ff0000)
8495 && ((imm & 0xff000000) == 0 || (imm & 0xff000000) == 0xff000000);
8498 /* For immediate of above form, return 0bABCD. */
8501 neon_squash_bits (unsigned imm)
8503 return (imm & 0x01) | ((imm & 0x0100) >> 7) | ((imm & 0x010000) >> 14)
8504 | ((imm & 0x01000000) >> 21);
8507 /* Compress quarter-float representation to 0b...000 abcdefgh. */
8510 neon_qfloat_bits (unsigned imm)
8512 return ((imm >> 19) & 0x7f) | ((imm >> 24) & 0x80);
8515 /* Returns CMODE. IMMBITS [7:0] is set to bits suitable for inserting into
8516 the instruction. *OP is passed as the initial value of the op field, and
8517 may be set to a different value depending on the constant (i.e.
8518 "MOV I64, 0bAAAAAAAABBBB..." which uses OP = 1 despite being MOV not
8519 MVN). If the immediate looks like a repeated pattern then also
8520 try smaller element sizes. */
8523 neon_cmode_for_move_imm (unsigned immlo, unsigned immhi, int float_p,
8524 unsigned *immbits, int *op, int size,
8525 enum neon_el_type type)
8527 /* Only permit float immediates (including 0.0/-0.0) if the operand type is
8529 if (type == NT_float && !float_p)
8532 if (type == NT_float && is_quarter_float (immlo) && immhi == 0)
8534 if (size != 32 || *op == 1)
8536 *immbits = neon_qfloat_bits (immlo);
8542 if (neon_bits_same_in_bytes (immhi)
8543 && neon_bits_same_in_bytes (immlo))
8547 *immbits = (neon_squash_bits (immhi) << 4)
8548 | neon_squash_bits (immlo);
8559 if (immlo == (immlo & 0x000000ff))
8564 else if (immlo == (immlo & 0x0000ff00))
8566 *immbits = immlo >> 8;
8569 else if (immlo == (immlo & 0x00ff0000))
8571 *immbits = immlo >> 16;
8574 else if (immlo == (immlo & 0xff000000))
8576 *immbits = immlo >> 24;
8579 else if (immlo == ((immlo & 0x0000ff00) | 0x000000ff))
8581 *immbits = (immlo >> 8) & 0xff;
8584 else if (immlo == ((immlo & 0x00ff0000) | 0x0000ffff))
8586 *immbits = (immlo >> 16) & 0xff;
8590 if ((immlo & 0xffff) != (immlo >> 16))
8597 if (immlo == (immlo & 0x000000ff))
8602 else if (immlo == (immlo & 0x0000ff00))
8604 *immbits = immlo >> 8;
8608 if ((immlo & 0xff) != (immlo >> 8))
8613 if (immlo == (immlo & 0x000000ff))
8615 /* Don't allow MVN with 8-bit immediate. */
8625 #if defined BFD_HOST_64_BIT
8626 /* Returns TRUE if double precision value V may be cast
8627 to single precision without loss of accuracy. */
8630 is_double_a_single (bfd_int64_t v)
8632 int exp = (int)((v >> 52) & 0x7FF);
8633 bfd_int64_t mantissa = (v & (bfd_int64_t)0xFFFFFFFFFFFFFULL);
8635 return (exp == 0 || exp == 0x7FF
8636 || (exp >= 1023 - 126 && exp <= 1023 + 127))
8637 && (mantissa & 0x1FFFFFFFl) == 0;
8640 /* Returns a double precision value casted to single precision
8641 (ignoring the least significant bits in exponent and mantissa). */
8644 double_to_single (bfd_int64_t v)
8646 int sign = (int) ((v >> 63) & 1l);
8647 int exp = (int) ((v >> 52) & 0x7FF);
8648 bfd_int64_t mantissa = (v & (bfd_int64_t)0xFFFFFFFFFFFFFULL);
8654 exp = exp - 1023 + 127;
8663 /* No denormalized numbers. */
8669 return (sign << 31) | (exp << 23) | mantissa;
8671 #endif /* BFD_HOST_64_BIT */
8680 static void do_vfp_nsyn_opcode (const char *);
8682 /* inst.relocs[0].exp describes an "=expr" load pseudo-operation.
8683 Determine whether it can be performed with a move instruction; if
8684 it can, convert inst.instruction to that move instruction and
8685 return TRUE; if it can't, convert inst.instruction to a literal-pool
8686 load and return FALSE. If this is not a valid thing to do in the
8687 current context, set inst.error and return TRUE.
8689 inst.operands[i] describes the destination register. */
8692 move_or_literal_pool (int i, enum lit_type t, bfd_boolean mode_3)
8695 bfd_boolean thumb_p = (t == CONST_THUMB);
8696 bfd_boolean arm_p = (t == CONST_ARM);
8699 tbit = (inst.instruction > 0xffff) ? THUMB2_LOAD_BIT : THUMB_LOAD_BIT;
8703 if ((inst.instruction & tbit) == 0)
8705 inst.error = _("invalid pseudo operation");
8709 if (inst.relocs[0].exp.X_op != O_constant
8710 && inst.relocs[0].exp.X_op != O_symbol
8711 && inst.relocs[0].exp.X_op != O_big)
8713 inst.error = _("constant expression expected");
8717 if (inst.relocs[0].exp.X_op == O_constant
8718 || inst.relocs[0].exp.X_op == O_big)
8720 #if defined BFD_HOST_64_BIT
8725 if (inst.relocs[0].exp.X_op == O_big)
8727 LITTLENUM_TYPE w[X_PRECISION];
8730 if (inst.relocs[0].exp.X_add_number == -1)
8732 gen_to_words (w, X_PRECISION, E_PRECISION);
8734 /* FIXME: Should we check words w[2..5] ? */
8739 #if defined BFD_HOST_64_BIT
8741 ((((((((bfd_int64_t) l[3] & LITTLENUM_MASK)
8742 << LITTLENUM_NUMBER_OF_BITS)
8743 | ((bfd_int64_t) l[2] & LITTLENUM_MASK))
8744 << LITTLENUM_NUMBER_OF_BITS)
8745 | ((bfd_int64_t) l[1] & LITTLENUM_MASK))
8746 << LITTLENUM_NUMBER_OF_BITS)
8747 | ((bfd_int64_t) l[0] & LITTLENUM_MASK));
8749 v = ((l[1] & LITTLENUM_MASK) << LITTLENUM_NUMBER_OF_BITS)
8750 | (l[0] & LITTLENUM_MASK);
8754 v = inst.relocs[0].exp.X_add_number;
8756 if (!inst.operands[i].issingle)
8760 /* LDR should not use lead in a flag-setting instruction being
8761 chosen so we do not check whether movs can be used. */
8763 if ((ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_v6t2)
8764 || ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_v6t2_v8m))
8765 && inst.operands[i].reg != 13
8766 && inst.operands[i].reg != 15)
8768 /* Check if on thumb2 it can be done with a mov.w, mvn or
8769 movw instruction. */
8770 unsigned int newimm;
8771 bfd_boolean isNegated;
8773 newimm = encode_thumb32_immediate (v);
8774 if (newimm != (unsigned int) FAIL)
8778 newimm = encode_thumb32_immediate (~v);
8779 if (newimm != (unsigned int) FAIL)
8783 /* The number can be loaded with a mov.w or mvn
8785 if (newimm != (unsigned int) FAIL
8786 && ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_v6t2))
8788 inst.instruction = (0xf04f0000 /* MOV.W. */
8789 | (inst.operands[i].reg << 8));
8790 /* Change to MOVN. */
8791 inst.instruction |= (isNegated ? 0x200000 : 0);
8792 inst.instruction |= (newimm & 0x800) << 15;
8793 inst.instruction |= (newimm & 0x700) << 4;
8794 inst.instruction |= (newimm & 0x0ff);
8797 /* The number can be loaded with a movw instruction. */
8798 else if ((v & ~0xFFFF) == 0
8799 && ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_v6t2_v8m))
8801 int imm = v & 0xFFFF;
8803 inst.instruction = 0xf2400000; /* MOVW. */
8804 inst.instruction |= (inst.operands[i].reg << 8);
8805 inst.instruction |= (imm & 0xf000) << 4;
8806 inst.instruction |= (imm & 0x0800) << 15;
8807 inst.instruction |= (imm & 0x0700) << 4;
8808 inst.instruction |= (imm & 0x00ff);
8809 /* In case this replacement is being done on Armv8-M
8810 Baseline we need to make sure to disable the
8811 instruction size check, as otherwise GAS will reject
8812 the use of this T32 instruction. */
8820 int value = encode_arm_immediate (v);
8824 /* This can be done with a mov instruction. */
8825 inst.instruction &= LITERAL_MASK;
8826 inst.instruction |= INST_IMMEDIATE | (OPCODE_MOV << DATA_OP_SHIFT);
8827 inst.instruction |= value & 0xfff;
8831 value = encode_arm_immediate (~ v);
8834 /* This can be done with a mvn instruction. */
8835 inst.instruction &= LITERAL_MASK;
8836 inst.instruction |= INST_IMMEDIATE | (OPCODE_MVN << DATA_OP_SHIFT);
8837 inst.instruction |= value & 0xfff;
8841 else if (t == CONST_VEC && ARM_CPU_HAS_FEATURE (cpu_variant, fpu_neon_ext_v1))
8844 unsigned immbits = 0;
8845 unsigned immlo = inst.operands[1].imm;
8846 unsigned immhi = inst.operands[1].regisimm
8847 ? inst.operands[1].reg
8848 : inst.relocs[0].exp.X_unsigned
8850 : ((bfd_int64_t)((int) immlo)) >> 32;
8851 int cmode = neon_cmode_for_move_imm (immlo, immhi, FALSE, &immbits,
8852 &op, 64, NT_invtype);
8856 neon_invert_size (&immlo, &immhi, 64);
8858 cmode = neon_cmode_for_move_imm (immlo, immhi, FALSE, &immbits,
8859 &op, 64, NT_invtype);
8864 inst.instruction = (inst.instruction & VLDR_VMOV_SAME)
8870 /* Fill other bits in vmov encoding for both thumb and arm. */
8872 inst.instruction |= (0x7U << 29) | (0xF << 24);
8874 inst.instruction |= (0xFU << 28) | (0x1 << 25);
8875 neon_write_immbits (immbits);
8883 /* Check if vldr Rx, =constant could be optimized to vmov Rx, #constant. */
8884 if (inst.operands[i].issingle
8885 && is_quarter_float (inst.operands[1].imm)
8886 && ARM_CPU_HAS_FEATURE (cpu_variant, fpu_vfp_ext_v3xd))
8888 inst.operands[1].imm =
8889 neon_qfloat_bits (v);
8890 do_vfp_nsyn_opcode ("fconsts");
8894 /* If our host does not support a 64-bit type then we cannot perform
8895 the following optimization. This mean that there will be a
8896 discrepancy between the output produced by an assembler built for
8897 a 32-bit-only host and the output produced from a 64-bit host, but
8898 this cannot be helped. */
8899 #if defined BFD_HOST_64_BIT
8900 else if (!inst.operands[1].issingle
8901 && ARM_CPU_HAS_FEATURE (cpu_variant, fpu_vfp_ext_v3))
8903 if (is_double_a_single (v)
8904 && is_quarter_float (double_to_single (v)))
8906 inst.operands[1].imm =
8907 neon_qfloat_bits (double_to_single (v));
8908 do_vfp_nsyn_opcode ("fconstd");
8916 if (add_to_lit_pool ((!inst.operands[i].isvec
8917 || inst.operands[i].issingle) ? 4 : 8) == FAIL)
8920 inst.operands[1].reg = REG_PC;
8921 inst.operands[1].isreg = 1;
8922 inst.operands[1].preind = 1;
8923 inst.relocs[0].pc_rel = 1;
8924 inst.relocs[0].type = (thumb_p
8925 ? BFD_RELOC_ARM_THUMB_OFFSET
8927 ? BFD_RELOC_ARM_HWLITERAL
8928 : BFD_RELOC_ARM_LITERAL));
8932 /* inst.operands[i] was set up by parse_address. Encode it into an
8933 ARM-format instruction. Reject all forms which cannot be encoded
8934 into a coprocessor load/store instruction. If wb_ok is false,
8935 reject use of writeback; if unind_ok is false, reject use of
8936 unindexed addressing. If reloc_override is not 0, use it instead
8937 of BFD_ARM_CP_OFF_IMM, unless the initial relocation is a group one
8938 (in which case it is preserved). */
8941 encode_arm_cp_address (int i, int wb_ok, int unind_ok, int reloc_override)
8943 if (!inst.operands[i].isreg)
8946 if (! inst.operands[0].isvec)
8948 inst.error = _("invalid co-processor operand");
8951 if (move_or_literal_pool (0, CONST_VEC, /*mode_3=*/FALSE))
8955 inst.instruction |= inst.operands[i].reg << 16;
8957 gas_assert (!(inst.operands[i].preind && inst.operands[i].postind));
8959 if (!inst.operands[i].preind && !inst.operands[i].postind) /* unindexed */
8961 gas_assert (!inst.operands[i].writeback);
8964 inst.error = _("instruction does not support unindexed addressing");
8967 inst.instruction |= inst.operands[i].imm;
8968 inst.instruction |= INDEX_UP;
8972 if (inst.operands[i].preind)
8973 inst.instruction |= PRE_INDEX;
8975 if (inst.operands[i].writeback)
8977 if (inst.operands[i].reg == REG_PC)
8979 inst.error = _("pc may not be used with write-back");
8984 inst.error = _("instruction does not support writeback");
8987 inst.instruction |= WRITE_BACK;
8991 inst.relocs[0].type = (bfd_reloc_code_real_type) reloc_override;
8992 else if ((inst.relocs[0].type < BFD_RELOC_ARM_ALU_PC_G0_NC
8993 || inst.relocs[0].type > BFD_RELOC_ARM_LDC_SB_G2)
8994 && inst.relocs[0].type != BFD_RELOC_ARM_LDR_PC_G0)
8997 inst.relocs[0].type = BFD_RELOC_ARM_T32_CP_OFF_IMM;
8999 inst.relocs[0].type = BFD_RELOC_ARM_CP_OFF_IMM;
9002 /* Prefer + for zero encoded value. */
9003 if (!inst.operands[i].negative)
9004 inst.instruction |= INDEX_UP;
9009 /* Functions for instruction encoding, sorted by sub-architecture.
9010 First some generics; their names are taken from the conventional
9011 bit positions for register arguments in ARM format instructions. */
9021 inst.instruction |= inst.operands[0].reg << 12;
9027 inst.instruction |= inst.operands[0].reg << 16;
9033 inst.instruction |= inst.operands[0].reg << 12;
9034 inst.instruction |= inst.operands[1].reg;
9040 inst.instruction |= inst.operands[0].reg;
9041 inst.instruction |= inst.operands[1].reg << 16;
9047 inst.instruction |= inst.operands[0].reg << 12;
9048 inst.instruction |= inst.operands[1].reg << 16;
9054 inst.instruction |= inst.operands[0].reg << 16;
9055 inst.instruction |= inst.operands[1].reg << 12;
9061 inst.instruction |= inst.operands[0].reg << 8;
9062 inst.instruction |= inst.operands[1].reg << 16;
9066 check_obsolete (const arm_feature_set *feature, const char *msg)
9068 if (ARM_CPU_IS_ANY (cpu_variant))
9070 as_tsktsk ("%s", msg);
9073 else if (ARM_CPU_HAS_FEATURE (cpu_variant, *feature))
9085 unsigned Rn = inst.operands[2].reg;
9086 /* Enforce restrictions on SWP instruction. */
9087 if ((inst.instruction & 0x0fbfffff) == 0x01000090)
9089 constraint (Rn == inst.operands[0].reg || Rn == inst.operands[1].reg,
9090 _("Rn must not overlap other operands"));
9092 /* SWP{b} is obsolete for ARMv8-A, and deprecated for ARMv6* and ARMv7.
9094 if (!check_obsolete (&arm_ext_v8,
9095 _("swp{b} use is obsoleted for ARMv8 and later"))
9096 && warn_on_deprecated
9097 && ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_v6))
9098 as_tsktsk (_("swp{b} use is deprecated for ARMv6 and ARMv7"));
9101 inst.instruction |= inst.operands[0].reg << 12;
9102 inst.instruction |= inst.operands[1].reg;
9103 inst.instruction |= Rn << 16;
9109 inst.instruction |= inst.operands[0].reg << 12;
9110 inst.instruction |= inst.operands[1].reg << 16;
9111 inst.instruction |= inst.operands[2].reg;
9117 constraint ((inst.operands[2].reg == REG_PC), BAD_PC);
9118 constraint (((inst.relocs[0].exp.X_op != O_constant
9119 && inst.relocs[0].exp.X_op != O_illegal)
9120 || inst.relocs[0].exp.X_add_number != 0),
9122 inst.instruction |= inst.operands[0].reg;
9123 inst.instruction |= inst.operands[1].reg << 12;
9124 inst.instruction |= inst.operands[2].reg << 16;
9130 inst.instruction |= inst.operands[0].imm;
9136 inst.instruction |= inst.operands[0].reg << 12;
9137 encode_arm_cp_address (1, TRUE, TRUE, 0);
9140 /* ARM instructions, in alphabetical order by function name (except
9141 that wrapper functions appear immediately after the function they
9144 /* This is a pseudo-op of the form "adr rd, label" to be converted
9145 into a relative address of the form "add rd, pc, #label-.-8". */
9150 inst.instruction |= (inst.operands[0].reg << 12); /* Rd */
9152 /* Frag hacking will turn this into a sub instruction if the offset turns
9153 out to be negative. */
9154 inst.relocs[0].type = BFD_RELOC_ARM_IMMEDIATE;
9155 inst.relocs[0].pc_rel = 1;
9156 inst.relocs[0].exp.X_add_number -= 8;
9158 if (support_interwork
9159 && inst.relocs[0].exp.X_op == O_symbol
9160 && inst.relocs[0].exp.X_add_symbol != NULL
9161 && S_IS_DEFINED (inst.relocs[0].exp.X_add_symbol)
9162 && THUMB_IS_FUNC (inst.relocs[0].exp.X_add_symbol))
9163 inst.relocs[0].exp.X_add_number |= 1;
9166 /* This is a pseudo-op of the form "adrl rd, label" to be converted
9167 into a relative address of the form:
9168 add rd, pc, #low(label-.-8)"
9169 add rd, rd, #high(label-.-8)" */
9174 inst.instruction |= (inst.operands[0].reg << 12); /* Rd */
9176 /* Frag hacking will turn this into a sub instruction if the offset turns
9177 out to be negative. */
9178 inst.relocs[0].type = BFD_RELOC_ARM_ADRL_IMMEDIATE;
9179 inst.relocs[0].pc_rel = 1;
9180 inst.size = INSN_SIZE * 2;
9181 inst.relocs[0].exp.X_add_number -= 8;
9183 if (support_interwork
9184 && inst.relocs[0].exp.X_op == O_symbol
9185 && inst.relocs[0].exp.X_add_symbol != NULL
9186 && S_IS_DEFINED (inst.relocs[0].exp.X_add_symbol)
9187 && THUMB_IS_FUNC (inst.relocs[0].exp.X_add_symbol))
9188 inst.relocs[0].exp.X_add_number |= 1;
9194 constraint (inst.relocs[0].type >= BFD_RELOC_ARM_THUMB_ALU_ABS_G0_NC
9195 && inst.relocs[0].type <= BFD_RELOC_ARM_THUMB_ALU_ABS_G3_NC ,
9197 if (!inst.operands[1].present)
9198 inst.operands[1].reg = inst.operands[0].reg;
9199 inst.instruction |= inst.operands[0].reg << 12;
9200 inst.instruction |= inst.operands[1].reg << 16;
9201 encode_arm_shifter_operand (2);
9207 if (inst.operands[0].present)
9208 inst.instruction |= inst.operands[0].imm;
9210 inst.instruction |= 0xf;
9216 unsigned int msb = inst.operands[1].imm + inst.operands[2].imm;
9217 constraint (msb > 32, _("bit-field extends past end of register"));
9218 /* The instruction encoding stores the LSB and MSB,
9219 not the LSB and width. */
9220 inst.instruction |= inst.operands[0].reg << 12;
9221 inst.instruction |= inst.operands[1].imm << 7;
9222 inst.instruction |= (msb - 1) << 16;
9230 /* #0 in second position is alternative syntax for bfc, which is
9231 the same instruction but with REG_PC in the Rm field. */
9232 if (!inst.operands[1].isreg)
9233 inst.operands[1].reg = REG_PC;
9235 msb = inst.operands[2].imm + inst.operands[3].imm;
9236 constraint (msb > 32, _("bit-field extends past end of register"));
9237 /* The instruction encoding stores the LSB and MSB,
9238 not the LSB and width. */
9239 inst.instruction |= inst.operands[0].reg << 12;
9240 inst.instruction |= inst.operands[1].reg;
9241 inst.instruction |= inst.operands[2].imm << 7;
9242 inst.instruction |= (msb - 1) << 16;
9248 constraint (inst.operands[2].imm + inst.operands[3].imm > 32,
9249 _("bit-field extends past end of register"));
9250 inst.instruction |= inst.operands[0].reg << 12;
9251 inst.instruction |= inst.operands[1].reg;
9252 inst.instruction |= inst.operands[2].imm << 7;
9253 inst.instruction |= (inst.operands[3].imm - 1) << 16;
9256 /* ARM V5 breakpoint instruction (argument parse)
9257 BKPT <16 bit unsigned immediate>
9258 Instruction is not conditional.
9259 The bit pattern given in insns[] has the COND_ALWAYS condition,
9260 and it is an error if the caller tried to override that. */
9265 /* Top 12 of 16 bits to bits 19:8. */
9266 inst.instruction |= (inst.operands[0].imm & 0xfff0) << 4;
9268 /* Bottom 4 of 16 bits to bits 3:0. */
9269 inst.instruction |= inst.operands[0].imm & 0xf;
9273 encode_branch (int default_reloc)
9275 if (inst.operands[0].hasreloc)
9277 constraint (inst.operands[0].imm != BFD_RELOC_ARM_PLT32
9278 && inst.operands[0].imm != BFD_RELOC_ARM_TLS_CALL,
9279 _("the only valid suffixes here are '(plt)' and '(tlscall)'"));
9280 inst.relocs[0].type = inst.operands[0].imm == BFD_RELOC_ARM_PLT32
9281 ? BFD_RELOC_ARM_PLT32
9282 : thumb_mode ? BFD_RELOC_ARM_THM_TLS_CALL : BFD_RELOC_ARM_TLS_CALL;
9285 inst.relocs[0].type = (bfd_reloc_code_real_type) default_reloc;
9286 inst.relocs[0].pc_rel = 1;
9293 if (EF_ARM_EABI_VERSION (meabi_flags) >= EF_ARM_EABI_VER4)
9294 encode_branch (BFD_RELOC_ARM_PCREL_JUMP);
9297 encode_branch (BFD_RELOC_ARM_PCREL_BRANCH);
9304 if (EF_ARM_EABI_VERSION (meabi_flags) >= EF_ARM_EABI_VER4)
9306 if (inst.cond == COND_ALWAYS)
9307 encode_branch (BFD_RELOC_ARM_PCREL_CALL);
9309 encode_branch (BFD_RELOC_ARM_PCREL_JUMP);
9313 encode_branch (BFD_RELOC_ARM_PCREL_BRANCH);
9316 /* ARM V5 branch-link-exchange instruction (argument parse)
9317 BLX <target_addr> ie BLX(1)
9318 BLX{<condition>} <Rm> ie BLX(2)
9319 Unfortunately, there are two different opcodes for this mnemonic.
9320 So, the insns[].value is not used, and the code here zaps values
9321 into inst.instruction.
9322 Also, the <target_addr> can be 25 bits, hence has its own reloc. */
9327 if (inst.operands[0].isreg)
9329 /* Arg is a register; the opcode provided by insns[] is correct.
9330 It is not illegal to do "blx pc", just useless. */
9331 if (inst.operands[0].reg == REG_PC)
9332 as_tsktsk (_("use of r15 in blx in ARM mode is not really useful"));
9334 inst.instruction |= inst.operands[0].reg;
9338 /* Arg is an address; this instruction cannot be executed
9339 conditionally, and the opcode must be adjusted.
9340 We retain the BFD_RELOC_ARM_PCREL_BLX till the very end
9341 where we generate out a BFD_RELOC_ARM_PCREL_CALL instead. */
9342 constraint (inst.cond != COND_ALWAYS, BAD_COND);
9343 inst.instruction = 0xfa000000;
9344 encode_branch (BFD_RELOC_ARM_PCREL_BLX);
9351 bfd_boolean want_reloc;
9353 if (inst.operands[0].reg == REG_PC)
9354 as_tsktsk (_("use of r15 in bx in ARM mode is not really useful"));
9356 inst.instruction |= inst.operands[0].reg;
9357 /* Output R_ARM_V4BX relocations if is an EABI object that looks like
9358 it is for ARMv4t or earlier. */
9359 want_reloc = !ARM_CPU_HAS_FEATURE (selected_cpu, arm_ext_v5);
9360 if (!ARM_FEATURE_ZERO (selected_object_arch)
9361 && !ARM_CPU_HAS_FEATURE (selected_object_arch, arm_ext_v5))
9365 if (EF_ARM_EABI_VERSION (meabi_flags) < EF_ARM_EABI_VER4)
9370 inst.relocs[0].type = BFD_RELOC_ARM_V4BX;
9374 /* ARM v5TEJ. Jump to Jazelle code. */
9379 if (inst.operands[0].reg == REG_PC)
9380 as_tsktsk (_("use of r15 in bxj is not really useful"));
9382 inst.instruction |= inst.operands[0].reg;
9385 /* Co-processor data operation:
9386 CDP{cond} <coproc>, <opcode_1>, <CRd>, <CRn>, <CRm>{, <opcode_2>}
9387 CDP2 <coproc>, <opcode_1>, <CRd>, <CRn>, <CRm>{, <opcode_2>} */
9391 inst.instruction |= inst.operands[0].reg << 8;
9392 inst.instruction |= inst.operands[1].imm << 20;
9393 inst.instruction |= inst.operands[2].reg << 12;
9394 inst.instruction |= inst.operands[3].reg << 16;
9395 inst.instruction |= inst.operands[4].reg;
9396 inst.instruction |= inst.operands[5].imm << 5;
9402 inst.instruction |= inst.operands[0].reg << 16;
9403 encode_arm_shifter_operand (1);
9406 /* Transfer between coprocessor and ARM registers.
9407 MRC{cond} <coproc>, <opcode_1>, <Rd>, <CRn>, <CRm>{, <opcode_2>}
9412 No special properties. */
9414 struct deprecated_coproc_regs_s
9421 arm_feature_set deprecated;
9422 arm_feature_set obsoleted;
9423 const char *dep_msg;
9424 const char *obs_msg;
9427 #define DEPR_ACCESS_V8 \
9428 N_("This coprocessor register access is deprecated in ARMv8")
9430 /* Table of all deprecated coprocessor registers. */
9431 static struct deprecated_coproc_regs_s deprecated_coproc_regs[] =
9433 {15, 0, 7, 10, 5, /* CP15DMB. */
9434 ARM_FEATURE_CORE_LOW (ARM_EXT_V8), ARM_ARCH_NONE,
9435 DEPR_ACCESS_V8, NULL},
9436 {15, 0, 7, 10, 4, /* CP15DSB. */
9437 ARM_FEATURE_CORE_LOW (ARM_EXT_V8), ARM_ARCH_NONE,
9438 DEPR_ACCESS_V8, NULL},
9439 {15, 0, 7, 5, 4, /* CP15ISB. */
9440 ARM_FEATURE_CORE_LOW (ARM_EXT_V8), ARM_ARCH_NONE,
9441 DEPR_ACCESS_V8, NULL},
9442 {14, 6, 1, 0, 0, /* TEEHBR. */
9443 ARM_FEATURE_CORE_LOW (ARM_EXT_V8), ARM_ARCH_NONE,
9444 DEPR_ACCESS_V8, NULL},
9445 {14, 6, 0, 0, 0, /* TEECR. */
9446 ARM_FEATURE_CORE_LOW (ARM_EXT_V8), ARM_ARCH_NONE,
9447 DEPR_ACCESS_V8, NULL},
9450 #undef DEPR_ACCESS_V8
9452 static const size_t deprecated_coproc_reg_count =
9453 sizeof (deprecated_coproc_regs) / sizeof (deprecated_coproc_regs[0]);
9461 Rd = inst.operands[2].reg;
9464 if (inst.instruction == 0xee000010
9465 || inst.instruction == 0xfe000010)
9467 reject_bad_reg (Rd);
9468 else if (!ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_v8))
9470 constraint (Rd == REG_SP, BAD_SP);
9475 if (inst.instruction == 0xe000010)
9476 constraint (Rd == REG_PC, BAD_PC);
9479 for (i = 0; i < deprecated_coproc_reg_count; ++i)
9481 const struct deprecated_coproc_regs_s *r =
9482 deprecated_coproc_regs + i;
9484 if (inst.operands[0].reg == r->cp
9485 && inst.operands[1].imm == r->opc1
9486 && inst.operands[3].reg == r->crn
9487 && inst.operands[4].reg == r->crm
9488 && inst.operands[5].imm == r->opc2)
9490 if (! ARM_CPU_IS_ANY (cpu_variant)
9491 && warn_on_deprecated
9492 && ARM_CPU_HAS_FEATURE (cpu_variant, r->deprecated))
9493 as_tsktsk ("%s", r->dep_msg);
9497 inst.instruction |= inst.operands[0].reg << 8;
9498 inst.instruction |= inst.operands[1].imm << 21;
9499 inst.instruction |= Rd << 12;
9500 inst.instruction |= inst.operands[3].reg << 16;
9501 inst.instruction |= inst.operands[4].reg;
9502 inst.instruction |= inst.operands[5].imm << 5;
9505 /* Transfer between coprocessor register and pair of ARM registers.
9506 MCRR{cond} <coproc>, <opcode>, <Rd>, <Rn>, <CRm>.
9511 Two XScale instructions are special cases of these:
9513 MAR{cond} acc0, <RdLo>, <RdHi> == MCRR{cond} p0, #0, <RdLo>, <RdHi>, c0
9514 MRA{cond} acc0, <RdLo>, <RdHi> == MRRC{cond} p0, #0, <RdLo>, <RdHi>, c0
9516 Result unpredictable if Rd or Rn is R15. */
9523 Rd = inst.operands[2].reg;
9524 Rn = inst.operands[3].reg;
9528 reject_bad_reg (Rd);
9529 reject_bad_reg (Rn);
9533 constraint (Rd == REG_PC, BAD_PC);
9534 constraint (Rn == REG_PC, BAD_PC);
9537 /* Only check the MRRC{2} variants. */
9538 if ((inst.instruction & 0x0FF00000) == 0x0C500000)
9540 /* If Rd == Rn, error that the operation is
9541 unpredictable (example MRRC p3,#1,r1,r1,c4). */
9542 constraint (Rd == Rn, BAD_OVERLAP);
9545 inst.instruction |= inst.operands[0].reg << 8;
9546 inst.instruction |= inst.operands[1].imm << 4;
9547 inst.instruction |= Rd << 12;
9548 inst.instruction |= Rn << 16;
9549 inst.instruction |= inst.operands[4].reg;
9555 inst.instruction |= inst.operands[0].imm << 6;
9556 if (inst.operands[1].present)
9558 inst.instruction |= CPSI_MMOD;
9559 inst.instruction |= inst.operands[1].imm;
9566 inst.instruction |= inst.operands[0].imm;
9572 unsigned Rd, Rn, Rm;
9574 Rd = inst.operands[0].reg;
9575 Rn = (inst.operands[1].present
9576 ? inst.operands[1].reg : Rd);
9577 Rm = inst.operands[2].reg;
9579 constraint ((Rd == REG_PC), BAD_PC);
9580 constraint ((Rn == REG_PC), BAD_PC);
9581 constraint ((Rm == REG_PC), BAD_PC);
9583 inst.instruction |= Rd << 16;
9584 inst.instruction |= Rn << 0;
9585 inst.instruction |= Rm << 8;
9591 /* There is no IT instruction in ARM mode. We
9592 process it to do the validation as if in
9593 thumb mode, just in case the code gets
9594 assembled for thumb using the unified syntax. */
9599 set_pred_insn_type (IT_INSN);
9600 now_pred.mask = (inst.instruction & 0xf) | 0x10;
9601 now_pred.cc = inst.operands[0].imm;
9605 /* If there is only one register in the register list,
9606 then return its register number. Otherwise return -1. */
9608 only_one_reg_in_list (int range)
9610 int i = ffs (range) - 1;
9611 return (i > 15 || range != (1 << i)) ? -1 : i;
9615 encode_ldmstm(int from_push_pop_mnem)
9617 int base_reg = inst.operands[0].reg;
9618 int range = inst.operands[1].imm;
9621 inst.instruction |= base_reg << 16;
9622 inst.instruction |= range;
9624 if (inst.operands[1].writeback)
9625 inst.instruction |= LDM_TYPE_2_OR_3;
9627 if (inst.operands[0].writeback)
9629 inst.instruction |= WRITE_BACK;
9630 /* Check for unpredictable uses of writeback. */
9631 if (inst.instruction & LOAD_BIT)
9633 /* Not allowed in LDM type 2. */
9634 if ((inst.instruction & LDM_TYPE_2_OR_3)
9635 && ((range & (1 << REG_PC)) == 0))
9636 as_warn (_("writeback of base register is UNPREDICTABLE"));
9637 /* Only allowed if base reg not in list for other types. */
9638 else if (range & (1 << base_reg))
9639 as_warn (_("writeback of base register when in register list is UNPREDICTABLE"));
9643 /* Not allowed for type 2. */
9644 if (inst.instruction & LDM_TYPE_2_OR_3)
9645 as_warn (_("writeback of base register is UNPREDICTABLE"));
9646 /* Only allowed if base reg not in list, or first in list. */
9647 else if ((range & (1 << base_reg))
9648 && (range & ((1 << base_reg) - 1)))
9649 as_warn (_("if writeback register is in list, it must be the lowest reg in the list"));
9653 /* If PUSH/POP has only one register, then use the A2 encoding. */
9654 one_reg = only_one_reg_in_list (range);
9655 if (from_push_pop_mnem && one_reg >= 0)
9657 int is_push = (inst.instruction & A_PUSH_POP_OP_MASK) == A1_OPCODE_PUSH;
9659 if (is_push && one_reg == 13 /* SP */)
9660 /* PR 22483: The A2 encoding cannot be used when
9661 pushing the stack pointer as this is UNPREDICTABLE. */
9664 inst.instruction &= A_COND_MASK;
9665 inst.instruction |= is_push ? A2_OPCODE_PUSH : A2_OPCODE_POP;
9666 inst.instruction |= one_reg << 12;
9673 encode_ldmstm (/*from_push_pop_mnem=*/FALSE);
9676 /* ARMv5TE load-consecutive (argument parse)
9685 constraint (inst.operands[0].reg % 2 != 0,
9686 _("first transfer register must be even"));
9687 constraint (inst.operands[1].present
9688 && inst.operands[1].reg != inst.operands[0].reg + 1,
9689 _("can only transfer two consecutive registers"));
9690 constraint (inst.operands[0].reg == REG_LR, _("r14 not allowed here"));
9691 constraint (!inst.operands[2].isreg, _("'[' expected"));
9693 if (!inst.operands[1].present)
9694 inst.operands[1].reg = inst.operands[0].reg + 1;
9696 /* encode_arm_addr_mode_3 will diagnose overlap between the base
9697 register and the first register written; we have to diagnose
9698 overlap between the base and the second register written here. */
9700 if (inst.operands[2].reg == inst.operands[1].reg
9701 && (inst.operands[2].writeback || inst.operands[2].postind))
9702 as_warn (_("base register written back, and overlaps "
9703 "second transfer register"));
9705 if (!(inst.instruction & V4_STR_BIT))
9707 /* For an index-register load, the index register must not overlap the
9708 destination (even if not write-back). */
9709 if (inst.operands[2].immisreg
9710 && ((unsigned) inst.operands[2].imm == inst.operands[0].reg
9711 || (unsigned) inst.operands[2].imm == inst.operands[1].reg))
9712 as_warn (_("index register overlaps transfer register"));
9714 inst.instruction |= inst.operands[0].reg << 12;
9715 encode_arm_addr_mode_3 (2, /*is_t=*/FALSE);
9721 constraint (!inst.operands[1].isreg || !inst.operands[1].preind
9722 || inst.operands[1].postind || inst.operands[1].writeback
9723 || inst.operands[1].immisreg || inst.operands[1].shifted
9724 || inst.operands[1].negative
9725 /* This can arise if the programmer has written
9727 or if they have mistakenly used a register name as the last
9730 It is very difficult to distinguish between these two cases
9731 because "rX" might actually be a label. ie the register
9732 name has been occluded by a symbol of the same name. So we
9733 just generate a general 'bad addressing mode' type error
9734 message and leave it up to the programmer to discover the
9735 true cause and fix their mistake. */
9736 || (inst.operands[1].reg == REG_PC),
9739 constraint (inst.relocs[0].exp.X_op != O_constant
9740 || inst.relocs[0].exp.X_add_number != 0,
9741 _("offset must be zero in ARM encoding"));
9743 constraint ((inst.operands[1].reg == REG_PC), BAD_PC);
9745 inst.instruction |= inst.operands[0].reg << 12;
9746 inst.instruction |= inst.operands[1].reg << 16;
9747 inst.relocs[0].type = BFD_RELOC_UNUSED;
9753 constraint (inst.operands[0].reg % 2 != 0,
9754 _("even register required"));
9755 constraint (inst.operands[1].present
9756 && inst.operands[1].reg != inst.operands[0].reg + 1,
9757 _("can only load two consecutive registers"));
9758 /* If op 1 were present and equal to PC, this function wouldn't
9759 have been called in the first place. */
9760 constraint (inst.operands[0].reg == REG_LR, _("r14 not allowed here"));
9762 inst.instruction |= inst.operands[0].reg << 12;
9763 inst.instruction |= inst.operands[2].reg << 16;
9766 /* In both ARM and thumb state 'ldr pc, #imm' with an immediate
9767 which is not a multiple of four is UNPREDICTABLE. */
9769 check_ldr_r15_aligned (void)
9771 constraint (!(inst.operands[1].immisreg)
9772 && (inst.operands[0].reg == REG_PC
9773 && inst.operands[1].reg == REG_PC
9774 && (inst.relocs[0].exp.X_add_number & 0x3)),
9775 _("ldr to register 15 must be 4-byte aligned"));
9781 inst.instruction |= inst.operands[0].reg << 12;
9782 if (!inst.operands[1].isreg)
9783 if (move_or_literal_pool (0, CONST_ARM, /*mode_3=*/FALSE))
9785 encode_arm_addr_mode_2 (1, /*is_t=*/FALSE);
9786 check_ldr_r15_aligned ();
9792 /* ldrt/strt always use post-indexed addressing. Turn [Rn] into [Rn]! and
9794 if (inst.operands[1].preind)
9796 constraint (inst.relocs[0].exp.X_op != O_constant
9797 || inst.relocs[0].exp.X_add_number != 0,
9798 _("this instruction requires a post-indexed address"));
9800 inst.operands[1].preind = 0;
9801 inst.operands[1].postind = 1;
9802 inst.operands[1].writeback = 1;
9804 inst.instruction |= inst.operands[0].reg << 12;
9805 encode_arm_addr_mode_2 (1, /*is_t=*/TRUE);
9808 /* Halfword and signed-byte load/store operations. */
9813 constraint (inst.operands[0].reg == REG_PC, BAD_PC);
9814 inst.instruction |= inst.operands[0].reg << 12;
9815 if (!inst.operands[1].isreg)
9816 if (move_or_literal_pool (0, CONST_ARM, /*mode_3=*/TRUE))
9818 encode_arm_addr_mode_3 (1, /*is_t=*/FALSE);
9824 /* ldrt/strt always use post-indexed addressing. Turn [Rn] into [Rn]! and
9826 if (inst.operands[1].preind)
9828 constraint (inst.relocs[0].exp.X_op != O_constant
9829 || inst.relocs[0].exp.X_add_number != 0,
9830 _("this instruction requires a post-indexed address"));
9832 inst.operands[1].preind = 0;
9833 inst.operands[1].postind = 1;
9834 inst.operands[1].writeback = 1;
9836 inst.instruction |= inst.operands[0].reg << 12;
9837 encode_arm_addr_mode_3 (1, /*is_t=*/TRUE);
9840 /* Co-processor register load/store.
9841 Format: <LDC|STC>{cond}[L] CP#,CRd,<address> */
9845 inst.instruction |= inst.operands[0].reg << 8;
9846 inst.instruction |= inst.operands[1].reg << 12;
9847 encode_arm_cp_address (2, TRUE, TRUE, 0);
9853 /* This restriction does not apply to mls (nor to mla in v6 or later). */
9854 if (inst.operands[0].reg == inst.operands[1].reg
9855 && !ARM_CPU_HAS_FEATURE (selected_cpu, arm_ext_v6)
9856 && !(inst.instruction & 0x00400000))
9857 as_tsktsk (_("Rd and Rm should be different in mla"));
9859 inst.instruction |= inst.operands[0].reg << 16;
9860 inst.instruction |= inst.operands[1].reg;
9861 inst.instruction |= inst.operands[2].reg << 8;
9862 inst.instruction |= inst.operands[3].reg << 12;
9868 constraint (inst.relocs[0].type >= BFD_RELOC_ARM_THUMB_ALU_ABS_G0_NC
9869 && inst.relocs[0].type <= BFD_RELOC_ARM_THUMB_ALU_ABS_G3_NC ,
9871 inst.instruction |= inst.operands[0].reg << 12;
9872 encode_arm_shifter_operand (1);
9875 /* ARM V6T2 16-bit immediate register load: MOV[WT]{cond} Rd, #<imm16>. */
9882 top = (inst.instruction & 0x00400000) != 0;
9883 constraint (top && inst.relocs[0].type == BFD_RELOC_ARM_MOVW,
9884 _(":lower16: not allowed in this instruction"));
9885 constraint (!top && inst.relocs[0].type == BFD_RELOC_ARM_MOVT,
9886 _(":upper16: not allowed in this instruction"));
9887 inst.instruction |= inst.operands[0].reg << 12;
9888 if (inst.relocs[0].type == BFD_RELOC_UNUSED)
9890 imm = inst.relocs[0].exp.X_add_number;
9891 /* The value is in two pieces: 0:11, 16:19. */
9892 inst.instruction |= (imm & 0x00000fff);
9893 inst.instruction |= (imm & 0x0000f000) << 4;
9898 do_vfp_nsyn_mrs (void)
9900 if (inst.operands[0].isvec)
9902 if (inst.operands[1].reg != 1)
9903 first_error (_("operand 1 must be FPSCR"));
9904 memset (&inst.operands[0], '\0', sizeof (inst.operands[0]));
9905 memset (&inst.operands[1], '\0', sizeof (inst.operands[1]));
9906 do_vfp_nsyn_opcode ("fmstat");
9908 else if (inst.operands[1].isvec)
9909 do_vfp_nsyn_opcode ("fmrx");
9917 do_vfp_nsyn_msr (void)
9919 if (inst.operands[0].isvec)
9920 do_vfp_nsyn_opcode ("fmxr");
9930 unsigned Rt = inst.operands[0].reg;
9932 if (thumb_mode && Rt == REG_SP)
9934 inst.error = BAD_SP;
9938 switch (inst.operands[1].reg)
9940 /* MVFR2 is only valid for Armv8-A. */
9942 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant, fpu_vfp_ext_armv8),
9946 /* Check for new Armv8.1-M Mainline changes to <spec_reg>. */
9947 case 1: /* fpscr. */
9948 constraint (!(ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext)
9949 || ARM_CPU_HAS_FEATURE (cpu_variant, fpu_vfp_ext_v1xd)),
9953 case 14: /* fpcxt_ns. */
9954 case 15: /* fpcxt_s. */
9955 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_v8_1m_main),
9956 _("selected processor does not support instruction"));
9959 case 2: /* fpscr_nzcvqc. */
9962 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_v8_1m_main)
9963 || (!ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext)
9964 && !ARM_CPU_HAS_FEATURE (cpu_variant, fpu_vfp_ext_v1xd)),
9965 _("selected processor does not support instruction"));
9966 if (inst.operands[0].reg != 2
9967 && !ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext))
9968 as_warn (_("accessing MVE system register without MVE is UNPREDICTABLE"));
9975 /* APSR_ sets isvec. All other refs to PC are illegal. */
9976 if (!inst.operands[0].isvec && Rt == REG_PC)
9978 inst.error = BAD_PC;
9982 /* If we get through parsing the register name, we just insert the number
9983 generated into the instruction without further validation. */
9984 inst.instruction |= (inst.operands[1].reg << 16);
9985 inst.instruction |= (Rt << 12);
9991 unsigned Rt = inst.operands[1].reg;
9994 reject_bad_reg (Rt);
9995 else if (Rt == REG_PC)
9997 inst.error = BAD_PC;
10001 switch (inst.operands[0].reg)
10003 /* MVFR2 is only valid for Armv8-A. */
10005 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant, fpu_vfp_ext_armv8),
10009 /* Check for new Armv8.1-M Mainline changes to <spec_reg>. */
10010 case 1: /* fpcr. */
10011 constraint (!(ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext)
10012 || ARM_CPU_HAS_FEATURE (cpu_variant, fpu_vfp_ext_v1xd)),
10016 case 14: /* fpcxt_ns. */
10017 case 15: /* fpcxt_s. */
10018 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_v8_1m_main),
10019 _("selected processor does not support instruction"));
10022 case 2: /* fpscr_nzcvqc. */
10023 case 12: /* vpr. */
10025 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_v8_1m_main)
10026 || (!ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext)
10027 && !ARM_CPU_HAS_FEATURE (cpu_variant, fpu_vfp_ext_v1xd)),
10028 _("selected processor does not support instruction"));
10029 if (inst.operands[0].reg != 2
10030 && !ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext))
10031 as_warn (_("accessing MVE system register without MVE is UNPREDICTABLE"));
10038 /* If we get through parsing the register name, we just insert the number
10039 generated into the instruction without further validation. */
10040 inst.instruction |= (inst.operands[0].reg << 16);
10041 inst.instruction |= (Rt << 12);
10049 if (do_vfp_nsyn_mrs () == SUCCESS)
10052 constraint (inst.operands[0].reg == REG_PC, BAD_PC);
10053 inst.instruction |= inst.operands[0].reg << 12;
10055 if (inst.operands[1].isreg)
10057 br = inst.operands[1].reg;
10058 if (((br & 0x200) == 0) && ((br & 0xf0000) != 0xf0000))
10059 as_bad (_("bad register for mrs"));
10063 /* mrs only accepts CPSR/SPSR/CPSR_all/SPSR_all. */
10064 constraint ((inst.operands[1].imm & (PSR_c|PSR_x|PSR_s|PSR_f))
10066 _("'APSR', 'CPSR' or 'SPSR' expected"));
10067 br = (15<<16) | (inst.operands[1].imm & SPSR_BIT);
10070 inst.instruction |= br;
10073 /* Two possible forms:
10074 "{C|S}PSR_<field>, Rm",
10075 "{C|S}PSR_f, #expression". */
10080 if (do_vfp_nsyn_msr () == SUCCESS)
10083 inst.instruction |= inst.operands[0].imm;
10084 if (inst.operands[1].isreg)
10085 inst.instruction |= inst.operands[1].reg;
10088 inst.instruction |= INST_IMMEDIATE;
10089 inst.relocs[0].type = BFD_RELOC_ARM_IMMEDIATE;
10090 inst.relocs[0].pc_rel = 0;
10097 constraint (inst.operands[2].reg == REG_PC, BAD_PC);
10099 if (!inst.operands[2].present)
10100 inst.operands[2].reg = inst.operands[0].reg;
10101 inst.instruction |= inst.operands[0].reg << 16;
10102 inst.instruction |= inst.operands[1].reg;
10103 inst.instruction |= inst.operands[2].reg << 8;
10105 if (inst.operands[0].reg == inst.operands[1].reg
10106 && !ARM_CPU_HAS_FEATURE (selected_cpu, arm_ext_v6))
10107 as_tsktsk (_("Rd and Rm should be different in mul"));
10110 /* Long Multiply Parser
10111 UMULL RdLo, RdHi, Rm, Rs
10112 SMULL RdLo, RdHi, Rm, Rs
10113 UMLAL RdLo, RdHi, Rm, Rs
10114 SMLAL RdLo, RdHi, Rm, Rs. */
10119 inst.instruction |= inst.operands[0].reg << 12;
10120 inst.instruction |= inst.operands[1].reg << 16;
10121 inst.instruction |= inst.operands[2].reg;
10122 inst.instruction |= inst.operands[3].reg << 8;
10124 /* rdhi and rdlo must be different. */
10125 if (inst.operands[0].reg == inst.operands[1].reg)
10126 as_tsktsk (_("rdhi and rdlo must be different"));
10128 /* rdhi, rdlo and rm must all be different before armv6. */
10129 if ((inst.operands[0].reg == inst.operands[2].reg
10130 || inst.operands[1].reg == inst.operands[2].reg)
10131 && !ARM_CPU_HAS_FEATURE (selected_cpu, arm_ext_v6))
10132 as_tsktsk (_("rdhi, rdlo and rm must all be different"));
10138 if (inst.operands[0].present
10139 || ARM_CPU_HAS_FEATURE (selected_cpu, arm_ext_v6k))
10141 /* Architectural NOP hints are CPSR sets with no bits selected. */
10142 inst.instruction &= 0xf0000000;
10143 inst.instruction |= 0x0320f000;
10144 if (inst.operands[0].present)
10145 inst.instruction |= inst.operands[0].imm;
10149 /* ARM V6 Pack Halfword Bottom Top instruction (argument parse).
10150 PKHBT {<cond>} <Rd>, <Rn>, <Rm> {, LSL #<shift_imm>}
10151 Condition defaults to COND_ALWAYS.
10152 Error if Rd, Rn or Rm are R15. */
10157 inst.instruction |= inst.operands[0].reg << 12;
10158 inst.instruction |= inst.operands[1].reg << 16;
10159 inst.instruction |= inst.operands[2].reg;
10160 if (inst.operands[3].present)
10161 encode_arm_shift (3);
10164 /* ARM V6 PKHTB (Argument Parse). */
10169 if (!inst.operands[3].present)
10171 /* If the shift specifier is omitted, turn the instruction
10172 into pkhbt rd, rm, rn. */
10173 inst.instruction &= 0xfff00010;
10174 inst.instruction |= inst.operands[0].reg << 12;
10175 inst.instruction |= inst.operands[1].reg;
10176 inst.instruction |= inst.operands[2].reg << 16;
10180 inst.instruction |= inst.operands[0].reg << 12;
10181 inst.instruction |= inst.operands[1].reg << 16;
10182 inst.instruction |= inst.operands[2].reg;
10183 encode_arm_shift (3);
10187 /* ARMv5TE: Preload-Cache
10188 MP Extensions: Preload for write
10192 Syntactically, like LDR with B=1, W=0, L=1. */
10197 constraint (!inst.operands[0].isreg,
10198 _("'[' expected after PLD mnemonic"));
10199 constraint (inst.operands[0].postind,
10200 _("post-indexed expression used in preload instruction"));
10201 constraint (inst.operands[0].writeback,
10202 _("writeback used in preload instruction"));
10203 constraint (!inst.operands[0].preind,
10204 _("unindexed addressing used in preload instruction"));
10205 encode_arm_addr_mode_2 (0, /*is_t=*/FALSE);
10208 /* ARMv7: PLI <addr_mode> */
10212 constraint (!inst.operands[0].isreg,
10213 _("'[' expected after PLI mnemonic"));
10214 constraint (inst.operands[0].postind,
10215 _("post-indexed expression used in preload instruction"));
10216 constraint (inst.operands[0].writeback,
10217 _("writeback used in preload instruction"));
10218 constraint (!inst.operands[0].preind,
10219 _("unindexed addressing used in preload instruction"));
10220 encode_arm_addr_mode_2 (0, /*is_t=*/FALSE);
10221 inst.instruction &= ~PRE_INDEX;
10227 constraint (inst.operands[0].writeback,
10228 _("push/pop do not support {reglist}^"));
10229 inst.operands[1] = inst.operands[0];
10230 memset (&inst.operands[0], 0, sizeof inst.operands[0]);
10231 inst.operands[0].isreg = 1;
10232 inst.operands[0].writeback = 1;
10233 inst.operands[0].reg = REG_SP;
10234 encode_ldmstm (/*from_push_pop_mnem=*/TRUE);
10237 /* ARM V6 RFE (Return from Exception) loads the PC and CPSR from the
10238 word at the specified address and the following word
10240 Unconditionally executed.
10241 Error if Rn is R15. */
10246 inst.instruction |= inst.operands[0].reg << 16;
10247 if (inst.operands[0].writeback)
10248 inst.instruction |= WRITE_BACK;
10251 /* ARM V6 ssat (argument parse). */
10256 inst.instruction |= inst.operands[0].reg << 12;
10257 inst.instruction |= (inst.operands[1].imm - 1) << 16;
10258 inst.instruction |= inst.operands[2].reg;
10260 if (inst.operands[3].present)
10261 encode_arm_shift (3);
10264 /* ARM V6 usat (argument parse). */
10269 inst.instruction |= inst.operands[0].reg << 12;
10270 inst.instruction |= inst.operands[1].imm << 16;
10271 inst.instruction |= inst.operands[2].reg;
10273 if (inst.operands[3].present)
10274 encode_arm_shift (3);
10277 /* ARM V6 ssat16 (argument parse). */
10282 inst.instruction |= inst.operands[0].reg << 12;
10283 inst.instruction |= ((inst.operands[1].imm - 1) << 16);
10284 inst.instruction |= inst.operands[2].reg;
10290 inst.instruction |= inst.operands[0].reg << 12;
10291 inst.instruction |= inst.operands[1].imm << 16;
10292 inst.instruction |= inst.operands[2].reg;
10295 /* ARM V6 SETEND (argument parse). Sets the E bit in the CPSR while
10296 preserving the other bits.
10298 setend <endian_specifier>, where <endian_specifier> is either
10304 if (warn_on_deprecated
10305 && ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_v8))
10306 as_tsktsk (_("setend use is deprecated for ARMv8"));
10308 if (inst.operands[0].imm)
10309 inst.instruction |= 0x200;
10315 unsigned int Rm = (inst.operands[1].present
10316 ? inst.operands[1].reg
10317 : inst.operands[0].reg);
10319 inst.instruction |= inst.operands[0].reg << 12;
10320 inst.instruction |= Rm;
10321 if (inst.operands[2].isreg) /* Rd, {Rm,} Rs */
10323 inst.instruction |= inst.operands[2].reg << 8;
10324 inst.instruction |= SHIFT_BY_REG;
10325 /* PR 12854: Error on extraneous shifts. */
10326 constraint (inst.operands[2].shifted,
10327 _("extraneous shift as part of operand to shift insn"));
10330 inst.relocs[0].type = BFD_RELOC_ARM_SHIFT_IMM;
10336 unsigned int value = inst.relocs[0].exp.X_add_number;
10337 constraint (value > 0xf, _("immediate too large (bigger than 0xF)"));
10339 inst.relocs[0].type = BFD_RELOC_ARM_SMC;
10340 inst.relocs[0].pc_rel = 0;
10346 inst.relocs[0].type = BFD_RELOC_ARM_HVC;
10347 inst.relocs[0].pc_rel = 0;
10353 inst.relocs[0].type = BFD_RELOC_ARM_SWI;
10354 inst.relocs[0].pc_rel = 0;
10360 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_pan),
10361 _("selected processor does not support SETPAN instruction"));
10363 inst.instruction |= ((inst.operands[0].imm & 1) << 9);
10369 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_pan),
10370 _("selected processor does not support SETPAN instruction"));
10372 inst.instruction |= (inst.operands[0].imm << 3);
10375 /* ARM V5E (El Segundo) signed-multiply-accumulate (argument parse)
10376 SMLAxy{cond} Rd,Rm,Rs,Rn
10377 SMLAWy{cond} Rd,Rm,Rs,Rn
10378 Error if any register is R15. */
10383 inst.instruction |= inst.operands[0].reg << 16;
10384 inst.instruction |= inst.operands[1].reg;
10385 inst.instruction |= inst.operands[2].reg << 8;
10386 inst.instruction |= inst.operands[3].reg << 12;
10389 /* ARM V5E (El Segundo) signed-multiply-accumulate-long (argument parse)
10390 SMLALxy{cond} Rdlo,Rdhi,Rm,Rs
10391 Error if any register is R15.
10392 Warning if Rdlo == Rdhi. */
10397 inst.instruction |= inst.operands[0].reg << 12;
10398 inst.instruction |= inst.operands[1].reg << 16;
10399 inst.instruction |= inst.operands[2].reg;
10400 inst.instruction |= inst.operands[3].reg << 8;
10402 if (inst.operands[0].reg == inst.operands[1].reg)
10403 as_tsktsk (_("rdhi and rdlo must be different"));
10406 /* ARM V5E (El Segundo) signed-multiply (argument parse)
10407 SMULxy{cond} Rd,Rm,Rs
10408 Error if any register is R15. */
10413 inst.instruction |= inst.operands[0].reg << 16;
10414 inst.instruction |= inst.operands[1].reg;
10415 inst.instruction |= inst.operands[2].reg << 8;
10418 /* ARM V6 srs (argument parse). The variable fields in the encoding are
10419 the same for both ARM and Thumb-2. */
10426 if (inst.operands[0].present)
10428 reg = inst.operands[0].reg;
10429 constraint (reg != REG_SP, _("SRS base register must be r13"));
10434 inst.instruction |= reg << 16;
10435 inst.instruction |= inst.operands[1].imm;
10436 if (inst.operands[0].writeback || inst.operands[1].writeback)
10437 inst.instruction |= WRITE_BACK;
10440 /* ARM V6 strex (argument parse). */
10445 constraint (!inst.operands[2].isreg || !inst.operands[2].preind
10446 || inst.operands[2].postind || inst.operands[2].writeback
10447 || inst.operands[2].immisreg || inst.operands[2].shifted
10448 || inst.operands[2].negative
10449 /* See comment in do_ldrex(). */
10450 || (inst.operands[2].reg == REG_PC),
10453 constraint (inst.operands[0].reg == inst.operands[1].reg
10454 || inst.operands[0].reg == inst.operands[2].reg, BAD_OVERLAP);
10456 constraint (inst.relocs[0].exp.X_op != O_constant
10457 || inst.relocs[0].exp.X_add_number != 0,
10458 _("offset must be zero in ARM encoding"));
10460 inst.instruction |= inst.operands[0].reg << 12;
10461 inst.instruction |= inst.operands[1].reg;
10462 inst.instruction |= inst.operands[2].reg << 16;
10463 inst.relocs[0].type = BFD_RELOC_UNUSED;
10467 do_t_strexbh (void)
10469 constraint (!inst.operands[2].isreg || !inst.operands[2].preind
10470 || inst.operands[2].postind || inst.operands[2].writeback
10471 || inst.operands[2].immisreg || inst.operands[2].shifted
10472 || inst.operands[2].negative,
10475 constraint (inst.operands[0].reg == inst.operands[1].reg
10476 || inst.operands[0].reg == inst.operands[2].reg, BAD_OVERLAP);
10484 constraint (inst.operands[1].reg % 2 != 0,
10485 _("even register required"));
10486 constraint (inst.operands[2].present
10487 && inst.operands[2].reg != inst.operands[1].reg + 1,
10488 _("can only store two consecutive registers"));
10489 /* If op 2 were present and equal to PC, this function wouldn't
10490 have been called in the first place. */
10491 constraint (inst.operands[1].reg == REG_LR, _("r14 not allowed here"));
10493 constraint (inst.operands[0].reg == inst.operands[1].reg
10494 || inst.operands[0].reg == inst.operands[1].reg + 1
10495 || inst.operands[0].reg == inst.operands[3].reg,
10498 inst.instruction |= inst.operands[0].reg << 12;
10499 inst.instruction |= inst.operands[1].reg;
10500 inst.instruction |= inst.operands[3].reg << 16;
10507 constraint (inst.operands[0].reg == inst.operands[1].reg
10508 || inst.operands[0].reg == inst.operands[2].reg, BAD_OVERLAP);
10516 constraint (inst.operands[0].reg == inst.operands[1].reg
10517 || inst.operands[0].reg == inst.operands[2].reg, BAD_OVERLAP);
10522 /* ARM V6 SXTAH extracts a 16-bit value from a register, sign
10523 extends it to 32-bits, and adds the result to a value in another
10524 register. You can specify a rotation by 0, 8, 16, or 24 bits
10525 before extracting the 16-bit value.
10526 SXTAH{<cond>} <Rd>, <Rn>, <Rm>{, <rotation>}
10527 Condition defaults to COND_ALWAYS.
10528 Error if any register uses R15. */
10533 inst.instruction |= inst.operands[0].reg << 12;
10534 inst.instruction |= inst.operands[1].reg << 16;
10535 inst.instruction |= inst.operands[2].reg;
10536 inst.instruction |= inst.operands[3].imm << 10;
10541 SXTH {<cond>} <Rd>, <Rm>{, <rotation>}
10542 Condition defaults to COND_ALWAYS.
10543 Error if any register uses R15. */
10548 inst.instruction |= inst.operands[0].reg << 12;
10549 inst.instruction |= inst.operands[1].reg;
10550 inst.instruction |= inst.operands[2].imm << 10;
10553 /* VFP instructions. In a logical order: SP variant first, monad
10554 before dyad, arithmetic then move then load/store. */
10557 do_vfp_sp_monadic (void)
10559 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant, fpu_vfp_ext_v1xd)
10560 && !ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext),
10563 encode_arm_vfp_reg (inst.operands[0].reg, VFP_REG_Sd);
10564 encode_arm_vfp_reg (inst.operands[1].reg, VFP_REG_Sm);
10568 do_vfp_sp_dyadic (void)
10570 encode_arm_vfp_reg (inst.operands[0].reg, VFP_REG_Sd);
10571 encode_arm_vfp_reg (inst.operands[1].reg, VFP_REG_Sn);
10572 encode_arm_vfp_reg (inst.operands[2].reg, VFP_REG_Sm);
10576 do_vfp_sp_compare_z (void)
10578 encode_arm_vfp_reg (inst.operands[0].reg, VFP_REG_Sd);
10582 do_vfp_dp_sp_cvt (void)
10584 encode_arm_vfp_reg (inst.operands[0].reg, VFP_REG_Dd);
10585 encode_arm_vfp_reg (inst.operands[1].reg, VFP_REG_Sm);
10589 do_vfp_sp_dp_cvt (void)
10591 encode_arm_vfp_reg (inst.operands[0].reg, VFP_REG_Sd);
10592 encode_arm_vfp_reg (inst.operands[1].reg, VFP_REG_Dm);
10596 do_vfp_reg_from_sp (void)
10598 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant, fpu_vfp_ext_v1xd)
10599 && !ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext),
10602 inst.instruction |= inst.operands[0].reg << 12;
10603 encode_arm_vfp_reg (inst.operands[1].reg, VFP_REG_Sn);
10607 do_vfp_reg2_from_sp2 (void)
10609 constraint (inst.operands[2].imm != 2,
10610 _("only two consecutive VFP SP registers allowed here"));
10611 inst.instruction |= inst.operands[0].reg << 12;
10612 inst.instruction |= inst.operands[1].reg << 16;
10613 encode_arm_vfp_reg (inst.operands[2].reg, VFP_REG_Sm);
10617 do_vfp_sp_from_reg (void)
10619 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant, fpu_vfp_ext_v1xd)
10620 && !ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext),
10623 encode_arm_vfp_reg (inst.operands[0].reg, VFP_REG_Sn);
10624 inst.instruction |= inst.operands[1].reg << 12;
10628 do_vfp_sp2_from_reg2 (void)
10630 constraint (inst.operands[0].imm != 2,
10631 _("only two consecutive VFP SP registers allowed here"));
10632 encode_arm_vfp_reg (inst.operands[0].reg, VFP_REG_Sm);
10633 inst.instruction |= inst.operands[1].reg << 12;
10634 inst.instruction |= inst.operands[2].reg << 16;
10638 do_vfp_sp_ldst (void)
10640 encode_arm_vfp_reg (inst.operands[0].reg, VFP_REG_Sd);
10641 encode_arm_cp_address (1, FALSE, TRUE, 0);
10645 do_vfp_dp_ldst (void)
10647 encode_arm_vfp_reg (inst.operands[0].reg, VFP_REG_Dd);
10648 encode_arm_cp_address (1, FALSE, TRUE, 0);
10653 vfp_sp_ldstm (enum vfp_ldstm_type ldstm_type)
10655 if (inst.operands[0].writeback)
10656 inst.instruction |= WRITE_BACK;
10658 constraint (ldstm_type != VFP_LDSTMIA,
10659 _("this addressing mode requires base-register writeback"));
10660 inst.instruction |= inst.operands[0].reg << 16;
10661 encode_arm_vfp_reg (inst.operands[1].reg, VFP_REG_Sd);
10662 inst.instruction |= inst.operands[1].imm;
10666 vfp_dp_ldstm (enum vfp_ldstm_type ldstm_type)
10670 if (inst.operands[0].writeback)
10671 inst.instruction |= WRITE_BACK;
10673 constraint (ldstm_type != VFP_LDSTMIA && ldstm_type != VFP_LDSTMIAX,
10674 _("this addressing mode requires base-register writeback"));
10676 inst.instruction |= inst.operands[0].reg << 16;
10677 encode_arm_vfp_reg (inst.operands[1].reg, VFP_REG_Dd);
10679 count = inst.operands[1].imm << 1;
10680 if (ldstm_type == VFP_LDSTMIAX || ldstm_type == VFP_LDSTMDBX)
10683 inst.instruction |= count;
10687 do_vfp_sp_ldstmia (void)
10689 vfp_sp_ldstm (VFP_LDSTMIA);
10693 do_vfp_sp_ldstmdb (void)
10695 vfp_sp_ldstm (VFP_LDSTMDB);
10699 do_vfp_dp_ldstmia (void)
10701 vfp_dp_ldstm (VFP_LDSTMIA);
10705 do_vfp_dp_ldstmdb (void)
10707 vfp_dp_ldstm (VFP_LDSTMDB);
10711 do_vfp_xp_ldstmia (void)
10713 vfp_dp_ldstm (VFP_LDSTMIAX);
10717 do_vfp_xp_ldstmdb (void)
10719 vfp_dp_ldstm (VFP_LDSTMDBX);
10723 do_vfp_dp_rd_rm (void)
10725 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant, fpu_vfp_ext_v1)
10726 && !ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext),
10729 encode_arm_vfp_reg (inst.operands[0].reg, VFP_REG_Dd);
10730 encode_arm_vfp_reg (inst.operands[1].reg, VFP_REG_Dm);
10734 do_vfp_dp_rn_rd (void)
10736 encode_arm_vfp_reg (inst.operands[0].reg, VFP_REG_Dn);
10737 encode_arm_vfp_reg (inst.operands[1].reg, VFP_REG_Dd);
10741 do_vfp_dp_rd_rn (void)
10743 encode_arm_vfp_reg (inst.operands[0].reg, VFP_REG_Dd);
10744 encode_arm_vfp_reg (inst.operands[1].reg, VFP_REG_Dn);
10748 do_vfp_dp_rd_rn_rm (void)
10750 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant, fpu_vfp_ext_v2)
10751 && !ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext),
10754 encode_arm_vfp_reg (inst.operands[0].reg, VFP_REG_Dd);
10755 encode_arm_vfp_reg (inst.operands[1].reg, VFP_REG_Dn);
10756 encode_arm_vfp_reg (inst.operands[2].reg, VFP_REG_Dm);
10760 do_vfp_dp_rd (void)
10762 encode_arm_vfp_reg (inst.operands[0].reg, VFP_REG_Dd);
10766 do_vfp_dp_rm_rd_rn (void)
10768 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant, fpu_vfp_ext_v2)
10769 && !ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext),
10772 encode_arm_vfp_reg (inst.operands[0].reg, VFP_REG_Dm);
10773 encode_arm_vfp_reg (inst.operands[1].reg, VFP_REG_Dd);
10774 encode_arm_vfp_reg (inst.operands[2].reg, VFP_REG_Dn);
10777 /* VFPv3 instructions. */
10779 do_vfp_sp_const (void)
10781 encode_arm_vfp_reg (inst.operands[0].reg, VFP_REG_Sd);
10782 inst.instruction |= (inst.operands[1].imm & 0xf0) << 12;
10783 inst.instruction |= (inst.operands[1].imm & 0x0f);
10787 do_vfp_dp_const (void)
10789 encode_arm_vfp_reg (inst.operands[0].reg, VFP_REG_Dd);
10790 inst.instruction |= (inst.operands[1].imm & 0xf0) << 12;
10791 inst.instruction |= (inst.operands[1].imm & 0x0f);
10795 vfp_conv (int srcsize)
10797 int immbits = srcsize - inst.operands[1].imm;
10799 if (srcsize == 16 && !(immbits >= 0 && immbits <= srcsize))
10801 /* If srcsize is 16, inst.operands[1].imm must be in the range 0-16.
10802 i.e. immbits must be in range 0 - 16. */
10803 inst.error = _("immediate value out of range, expected range [0, 16]");
10806 else if (srcsize == 32 && !(immbits >= 0 && immbits < srcsize))
10808 /* If srcsize is 32, inst.operands[1].imm must be in the range 1-32.
10809 i.e. immbits must be in range 0 - 31. */
10810 inst.error = _("immediate value out of range, expected range [1, 32]");
10814 inst.instruction |= (immbits & 1) << 5;
10815 inst.instruction |= (immbits >> 1);
10819 do_vfp_sp_conv_16 (void)
10821 encode_arm_vfp_reg (inst.operands[0].reg, VFP_REG_Sd);
10826 do_vfp_dp_conv_16 (void)
10828 encode_arm_vfp_reg (inst.operands[0].reg, VFP_REG_Dd);
10833 do_vfp_sp_conv_32 (void)
10835 encode_arm_vfp_reg (inst.operands[0].reg, VFP_REG_Sd);
10840 do_vfp_dp_conv_32 (void)
10842 encode_arm_vfp_reg (inst.operands[0].reg, VFP_REG_Dd);
10846 /* FPA instructions. Also in a logical order. */
10851 inst.instruction |= inst.operands[0].reg << 16;
10852 inst.instruction |= inst.operands[1].reg;
10856 do_fpa_ldmstm (void)
10858 inst.instruction |= inst.operands[0].reg << 12;
10859 switch (inst.operands[1].imm)
10861 case 1: inst.instruction |= CP_T_X; break;
10862 case 2: inst.instruction |= CP_T_Y; break;
10863 case 3: inst.instruction |= CP_T_Y | CP_T_X; break;
10868 if (inst.instruction & (PRE_INDEX | INDEX_UP))
10870 /* The instruction specified "ea" or "fd", so we can only accept
10871 [Rn]{!}. The instruction does not really support stacking or
10872 unstacking, so we have to emulate these by setting appropriate
10873 bits and offsets. */
10874 constraint (inst.relocs[0].exp.X_op != O_constant
10875 || inst.relocs[0].exp.X_add_number != 0,
10876 _("this instruction does not support indexing"));
10878 if ((inst.instruction & PRE_INDEX) || inst.operands[2].writeback)
10879 inst.relocs[0].exp.X_add_number = 12 * inst.operands[1].imm;
10881 if (!(inst.instruction & INDEX_UP))
10882 inst.relocs[0].exp.X_add_number = -inst.relocs[0].exp.X_add_number;
10884 if (!(inst.instruction & PRE_INDEX) && inst.operands[2].writeback)
10886 inst.operands[2].preind = 0;
10887 inst.operands[2].postind = 1;
10891 encode_arm_cp_address (2, TRUE, TRUE, 0);
10894 /* iWMMXt instructions: strictly in alphabetical order. */
10897 do_iwmmxt_tandorc (void)
10899 constraint (inst.operands[0].reg != REG_PC, _("only r15 allowed here"));
10903 do_iwmmxt_textrc (void)
10905 inst.instruction |= inst.operands[0].reg << 12;
10906 inst.instruction |= inst.operands[1].imm;
10910 do_iwmmxt_textrm (void)
10912 inst.instruction |= inst.operands[0].reg << 12;
10913 inst.instruction |= inst.operands[1].reg << 16;
10914 inst.instruction |= inst.operands[2].imm;
10918 do_iwmmxt_tinsr (void)
10920 inst.instruction |= inst.operands[0].reg << 16;
10921 inst.instruction |= inst.operands[1].reg << 12;
10922 inst.instruction |= inst.operands[2].imm;
10926 do_iwmmxt_tmia (void)
10928 inst.instruction |= inst.operands[0].reg << 5;
10929 inst.instruction |= inst.operands[1].reg;
10930 inst.instruction |= inst.operands[2].reg << 12;
10934 do_iwmmxt_waligni (void)
10936 inst.instruction |= inst.operands[0].reg << 12;
10937 inst.instruction |= inst.operands[1].reg << 16;
10938 inst.instruction |= inst.operands[2].reg;
10939 inst.instruction |= inst.operands[3].imm << 20;
10943 do_iwmmxt_wmerge (void)
10945 inst.instruction |= inst.operands[0].reg << 12;
10946 inst.instruction |= inst.operands[1].reg << 16;
10947 inst.instruction |= inst.operands[2].reg;
10948 inst.instruction |= inst.operands[3].imm << 21;
10952 do_iwmmxt_wmov (void)
10954 /* WMOV rD, rN is an alias for WOR rD, rN, rN. */
10955 inst.instruction |= inst.operands[0].reg << 12;
10956 inst.instruction |= inst.operands[1].reg << 16;
10957 inst.instruction |= inst.operands[1].reg;
10961 do_iwmmxt_wldstbh (void)
10964 inst.instruction |= inst.operands[0].reg << 12;
10966 reloc = BFD_RELOC_ARM_T32_CP_OFF_IMM_S2;
10968 reloc = BFD_RELOC_ARM_CP_OFF_IMM_S2;
10969 encode_arm_cp_address (1, TRUE, FALSE, reloc);
10973 do_iwmmxt_wldstw (void)
10975 /* RIWR_RIWC clears .isreg for a control register. */
10976 if (!inst.operands[0].isreg)
10978 constraint (inst.cond != COND_ALWAYS, BAD_COND);
10979 inst.instruction |= 0xf0000000;
10982 inst.instruction |= inst.operands[0].reg << 12;
10983 encode_arm_cp_address (1, TRUE, TRUE, 0);
10987 do_iwmmxt_wldstd (void)
10989 inst.instruction |= inst.operands[0].reg << 12;
10990 if (ARM_CPU_HAS_FEATURE (cpu_variant, arm_cext_iwmmxt2)
10991 && inst.operands[1].immisreg)
10993 inst.instruction &= ~0x1a000ff;
10994 inst.instruction |= (0xfU << 28);
10995 if (inst.operands[1].preind)
10996 inst.instruction |= PRE_INDEX;
10997 if (!inst.operands[1].negative)
10998 inst.instruction |= INDEX_UP;
10999 if (inst.operands[1].writeback)
11000 inst.instruction |= WRITE_BACK;
11001 inst.instruction |= inst.operands[1].reg << 16;
11002 inst.instruction |= inst.relocs[0].exp.X_add_number << 4;
11003 inst.instruction |= inst.operands[1].imm;
11006 encode_arm_cp_address (1, TRUE, FALSE, 0);
11010 do_iwmmxt_wshufh (void)
11012 inst.instruction |= inst.operands[0].reg << 12;
11013 inst.instruction |= inst.operands[1].reg << 16;
11014 inst.instruction |= ((inst.operands[2].imm & 0xf0) << 16);
11015 inst.instruction |= (inst.operands[2].imm & 0x0f);
11019 do_iwmmxt_wzero (void)
11021 /* WZERO reg is an alias for WANDN reg, reg, reg. */
11022 inst.instruction |= inst.operands[0].reg;
11023 inst.instruction |= inst.operands[0].reg << 12;
11024 inst.instruction |= inst.operands[0].reg << 16;
11028 do_iwmmxt_wrwrwr_or_imm5 (void)
11030 if (inst.operands[2].isreg)
11033 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant, arm_cext_iwmmxt2),
11034 _("immediate operand requires iWMMXt2"));
11036 if (inst.operands[2].imm == 0)
11038 switch ((inst.instruction >> 20) & 0xf)
11044 /* w...h wrd, wrn, #0 -> wrorh wrd, wrn, #16. */
11045 inst.operands[2].imm = 16;
11046 inst.instruction = (inst.instruction & 0xff0fffff) | (0x7 << 20);
11052 /* w...w wrd, wrn, #0 -> wrorw wrd, wrn, #32. */
11053 inst.operands[2].imm = 32;
11054 inst.instruction = (inst.instruction & 0xff0fffff) | (0xb << 20);
11061 /* w...d wrd, wrn, #0 -> wor wrd, wrn, wrn. */
11063 wrn = (inst.instruction >> 16) & 0xf;
11064 inst.instruction &= 0xff0fff0f;
11065 inst.instruction |= wrn;
11066 /* Bail out here; the instruction is now assembled. */
11071 /* Map 32 -> 0, etc. */
11072 inst.operands[2].imm &= 0x1f;
11073 inst.instruction |= (0xfU << 28) | ((inst.operands[2].imm & 0x10) << 4) | (inst.operands[2].imm & 0xf);
11077 /* Cirrus Maverick instructions. Simple 2-, 3-, and 4-register
11078 operations first, then control, shift, and load/store. */
11080 /* Insns like "foo X,Y,Z". */
11083 do_mav_triple (void)
11085 inst.instruction |= inst.operands[0].reg << 16;
11086 inst.instruction |= inst.operands[1].reg;
11087 inst.instruction |= inst.operands[2].reg << 12;
11090 /* Insns like "foo W,X,Y,Z".
11091 where W=MVAX[0:3] and X,Y,Z=MVFX[0:15]. */
11096 inst.instruction |= inst.operands[0].reg << 5;
11097 inst.instruction |= inst.operands[1].reg << 12;
11098 inst.instruction |= inst.operands[2].reg << 16;
11099 inst.instruction |= inst.operands[3].reg;
11102 /* cfmvsc32<cond> DSPSC,MVDX[15:0]. */
11104 do_mav_dspsc (void)
11106 inst.instruction |= inst.operands[1].reg << 12;
11109 /* Maverick shift immediate instructions.
11110 cfsh32<cond> MVFX[15:0],MVFX[15:0],Shift[6:0].
11111 cfsh64<cond> MVDX[15:0],MVDX[15:0],Shift[6:0]. */
11114 do_mav_shift (void)
11116 int imm = inst.operands[2].imm;
11118 inst.instruction |= inst.operands[0].reg << 12;
11119 inst.instruction |= inst.operands[1].reg << 16;
11121 /* Bits 0-3 of the insn should have bits 0-3 of the immediate.
11122 Bits 5-7 of the insn should have bits 4-6 of the immediate.
11123 Bit 4 should be 0. */
11124 imm = (imm & 0xf) | ((imm & 0x70) << 1);
11126 inst.instruction |= imm;
11129 /* XScale instructions. Also sorted arithmetic before move. */
11131 /* Xscale multiply-accumulate (argument parse)
11134 MIAxycc acc0,Rm,Rs. */
11139 inst.instruction |= inst.operands[1].reg;
11140 inst.instruction |= inst.operands[2].reg << 12;
11143 /* Xscale move-accumulator-register (argument parse)
11145 MARcc acc0,RdLo,RdHi. */
11150 inst.instruction |= inst.operands[1].reg << 12;
11151 inst.instruction |= inst.operands[2].reg << 16;
11154 /* Xscale move-register-accumulator (argument parse)
11156 MRAcc RdLo,RdHi,acc0. */
11161 constraint (inst.operands[0].reg == inst.operands[1].reg, BAD_OVERLAP);
11162 inst.instruction |= inst.operands[0].reg << 12;
11163 inst.instruction |= inst.operands[1].reg << 16;
11166 /* Encoding functions relevant only to Thumb. */
11168 /* inst.operands[i] is a shifted-register operand; encode
11169 it into inst.instruction in the format used by Thumb32. */
11172 encode_thumb32_shifted_operand (int i)
11174 unsigned int value = inst.relocs[0].exp.X_add_number;
11175 unsigned int shift = inst.operands[i].shift_kind;
11177 constraint (inst.operands[i].immisreg,
11178 _("shift by register not allowed in thumb mode"));
11179 inst.instruction |= inst.operands[i].reg;
11180 if (shift == SHIFT_RRX)
11181 inst.instruction |= SHIFT_ROR << 4;
11184 constraint (inst.relocs[0].exp.X_op != O_constant,
11185 _("expression too complex"));
11187 constraint (value > 32
11188 || (value == 32 && (shift == SHIFT_LSL
11189 || shift == SHIFT_ROR)),
11190 _("shift expression is too large"));
11194 else if (value == 32)
11197 inst.instruction |= shift << 4;
11198 inst.instruction |= (value & 0x1c) << 10;
11199 inst.instruction |= (value & 0x03) << 6;
11204 /* inst.operands[i] was set up by parse_address. Encode it into a
11205 Thumb32 format load or store instruction. Reject forms that cannot
11206 be used with such instructions. If is_t is true, reject forms that
11207 cannot be used with a T instruction; if is_d is true, reject forms
11208 that cannot be used with a D instruction. If it is a store insn,
11209 reject PC in Rn. */
11212 encode_thumb32_addr_mode (int i, bfd_boolean is_t, bfd_boolean is_d)
11214 const bfd_boolean is_pc = (inst.operands[i].reg == REG_PC);
11216 constraint (!inst.operands[i].isreg,
11217 _("Instruction does not support =N addresses"));
11219 inst.instruction |= inst.operands[i].reg << 16;
11220 if (inst.operands[i].immisreg)
11222 constraint (is_pc, BAD_PC_ADDRESSING);
11223 constraint (is_t || is_d, _("cannot use register index with this instruction"));
11224 constraint (inst.operands[i].negative,
11225 _("Thumb does not support negative register indexing"));
11226 constraint (inst.operands[i].postind,
11227 _("Thumb does not support register post-indexing"));
11228 constraint (inst.operands[i].writeback,
11229 _("Thumb does not support register indexing with writeback"));
11230 constraint (inst.operands[i].shifted && inst.operands[i].shift_kind != SHIFT_LSL,
11231 _("Thumb supports only LSL in shifted register indexing"));
11233 inst.instruction |= inst.operands[i].imm;
11234 if (inst.operands[i].shifted)
11236 constraint (inst.relocs[0].exp.X_op != O_constant,
11237 _("expression too complex"));
11238 constraint (inst.relocs[0].exp.X_add_number < 0
11239 || inst.relocs[0].exp.X_add_number > 3,
11240 _("shift out of range"));
11241 inst.instruction |= inst.relocs[0].exp.X_add_number << 4;
11243 inst.relocs[0].type = BFD_RELOC_UNUSED;
11245 else if (inst.operands[i].preind)
11247 constraint (is_pc && inst.operands[i].writeback, BAD_PC_WRITEBACK);
11248 constraint (is_t && inst.operands[i].writeback,
11249 _("cannot use writeback with this instruction"));
11250 constraint (is_pc && ((inst.instruction & THUMB2_LOAD_BIT) == 0),
11251 BAD_PC_ADDRESSING);
11255 inst.instruction |= 0x01000000;
11256 if (inst.operands[i].writeback)
11257 inst.instruction |= 0x00200000;
11261 inst.instruction |= 0x00000c00;
11262 if (inst.operands[i].writeback)
11263 inst.instruction |= 0x00000100;
11265 inst.relocs[0].type = BFD_RELOC_ARM_T32_OFFSET_IMM;
11267 else if (inst.operands[i].postind)
11269 gas_assert (inst.operands[i].writeback);
11270 constraint (is_pc, _("cannot use post-indexing with PC-relative addressing"));
11271 constraint (is_t, _("cannot use post-indexing with this instruction"));
11274 inst.instruction |= 0x00200000;
11276 inst.instruction |= 0x00000900;
11277 inst.relocs[0].type = BFD_RELOC_ARM_T32_OFFSET_IMM;
11279 else /* unindexed - only for coprocessor */
11280 inst.error = _("instruction does not accept unindexed addressing");
11283 /* Table of Thumb instructions which exist in 16- and/or 32-bit
11284 encodings (the latter only in post-V6T2 cores). The index is the
11285 value used in the insns table below. When there is more than one
11286 possible 16-bit encoding for the instruction, this table always
11288 Also contains several pseudo-instructions used during relaxation. */
11289 #define T16_32_TAB \
11290 X(_adc, 4140, eb400000), \
11291 X(_adcs, 4140, eb500000), \
11292 X(_add, 1c00, eb000000), \
11293 X(_adds, 1c00, eb100000), \
11294 X(_addi, 0000, f1000000), \
11295 X(_addis, 0000, f1100000), \
11296 X(_add_pc,000f, f20f0000), \
11297 X(_add_sp,000d, f10d0000), \
11298 X(_adr, 000f, f20f0000), \
11299 X(_and, 4000, ea000000), \
11300 X(_ands, 4000, ea100000), \
11301 X(_asr, 1000, fa40f000), \
11302 X(_asrs, 1000, fa50f000), \
11303 X(_b, e000, f000b000), \
11304 X(_bcond, d000, f0008000), \
11305 X(_bf, 0000, f040e001), \
11306 X(_bfcsel,0000, f000e001), \
11307 X(_bfx, 0000, f060e001), \
11308 X(_bfl, 0000, f000c001), \
11309 X(_bflx, 0000, f070e001), \
11310 X(_bic, 4380, ea200000), \
11311 X(_bics, 4380, ea300000), \
11312 X(_cinc, 0000, ea509000), \
11313 X(_cinv, 0000, ea50a000), \
11314 X(_cmn, 42c0, eb100f00), \
11315 X(_cmp, 2800, ebb00f00), \
11316 X(_cneg, 0000, ea50b000), \
11317 X(_cpsie, b660, f3af8400), \
11318 X(_cpsid, b670, f3af8600), \
11319 X(_cpy, 4600, ea4f0000), \
11320 X(_csel, 0000, ea508000), \
11321 X(_cset, 0000, ea5f900f), \
11322 X(_csetm, 0000, ea5fa00f), \
11323 X(_csinc, 0000, ea509000), \
11324 X(_csinv, 0000, ea50a000), \
11325 X(_csneg, 0000, ea50b000), \
11326 X(_dec_sp,80dd, f1ad0d00), \
11327 X(_dls, 0000, f040e001), \
11328 X(_dlstp, 0000, f000e001), \
11329 X(_eor, 4040, ea800000), \
11330 X(_eors, 4040, ea900000), \
11331 X(_inc_sp,00dd, f10d0d00), \
11332 X(_lctp, 0000, f00fe001), \
11333 X(_ldmia, c800, e8900000), \
11334 X(_ldr, 6800, f8500000), \
11335 X(_ldrb, 7800, f8100000), \
11336 X(_ldrh, 8800, f8300000), \
11337 X(_ldrsb, 5600, f9100000), \
11338 X(_ldrsh, 5e00, f9300000), \
11339 X(_ldr_pc,4800, f85f0000), \
11340 X(_ldr_pc2,4800, f85f0000), \
11341 X(_ldr_sp,9800, f85d0000), \
11342 X(_le, 0000, f00fc001), \
11343 X(_letp, 0000, f01fc001), \
11344 X(_lsl, 0000, fa00f000), \
11345 X(_lsls, 0000, fa10f000), \
11346 X(_lsr, 0800, fa20f000), \
11347 X(_lsrs, 0800, fa30f000), \
11348 X(_mov, 2000, ea4f0000), \
11349 X(_movs, 2000, ea5f0000), \
11350 X(_mul, 4340, fb00f000), \
11351 X(_muls, 4340, ffffffff), /* no 32b muls */ \
11352 X(_mvn, 43c0, ea6f0000), \
11353 X(_mvns, 43c0, ea7f0000), \
11354 X(_neg, 4240, f1c00000), /* rsb #0 */ \
11355 X(_negs, 4240, f1d00000), /* rsbs #0 */ \
11356 X(_orr, 4300, ea400000), \
11357 X(_orrs, 4300, ea500000), \
11358 X(_pop, bc00, e8bd0000), /* ldmia sp!,... */ \
11359 X(_push, b400, e92d0000), /* stmdb sp!,... */ \
11360 X(_rev, ba00, fa90f080), \
11361 X(_rev16, ba40, fa90f090), \
11362 X(_revsh, bac0, fa90f0b0), \
11363 X(_ror, 41c0, fa60f000), \
11364 X(_rors, 41c0, fa70f000), \
11365 X(_sbc, 4180, eb600000), \
11366 X(_sbcs, 4180, eb700000), \
11367 X(_stmia, c000, e8800000), \
11368 X(_str, 6000, f8400000), \
11369 X(_strb, 7000, f8000000), \
11370 X(_strh, 8000, f8200000), \
11371 X(_str_sp,9000, f84d0000), \
11372 X(_sub, 1e00, eba00000), \
11373 X(_subs, 1e00, ebb00000), \
11374 X(_subi, 8000, f1a00000), \
11375 X(_subis, 8000, f1b00000), \
11376 X(_sxtb, b240, fa4ff080), \
11377 X(_sxth, b200, fa0ff080), \
11378 X(_tst, 4200, ea100f00), \
11379 X(_uxtb, b2c0, fa5ff080), \
11380 X(_uxth, b280, fa1ff080), \
11381 X(_nop, bf00, f3af8000), \
11382 X(_yield, bf10, f3af8001), \
11383 X(_wfe, bf20, f3af8002), \
11384 X(_wfi, bf30, f3af8003), \
11385 X(_wls, 0000, f040c001), \
11386 X(_wlstp, 0000, f000c001), \
11387 X(_sev, bf40, f3af8004), \
11388 X(_sevl, bf50, f3af8005), \
11389 X(_udf, de00, f7f0a000)
11391 /* To catch errors in encoding functions, the codes are all offset by
11392 0xF800, putting them in one of the 32-bit prefix ranges, ergo undefined
11393 as 16-bit instructions. */
11394 #define X(a,b,c) T_MNEM##a
11395 enum t16_32_codes { T16_32_OFFSET = 0xF7FF, T16_32_TAB };
11398 #define X(a,b,c) 0x##b
11399 static const unsigned short thumb_op16[] = { T16_32_TAB };
11400 #define THUMB_OP16(n) (thumb_op16[(n) - (T16_32_OFFSET + 1)])
11403 #define X(a,b,c) 0x##c
11404 static const unsigned int thumb_op32[] = { T16_32_TAB };
11405 #define THUMB_OP32(n) (thumb_op32[(n) - (T16_32_OFFSET + 1)])
11406 #define THUMB_SETS_FLAGS(n) (THUMB_OP32 (n) & 0x00100000)
11410 /* Thumb instruction encoders, in alphabetical order. */
11412 /* ADDW or SUBW. */
11415 do_t_add_sub_w (void)
11419 Rd = inst.operands[0].reg;
11420 Rn = inst.operands[1].reg;
11422 /* If Rn is REG_PC, this is ADR; if Rn is REG_SP, then this
11423 is the SP-{plus,minus}-immediate form of the instruction. */
11425 constraint (Rd == REG_PC, BAD_PC);
11427 reject_bad_reg (Rd);
11429 inst.instruction |= (Rn << 16) | (Rd << 8);
11430 inst.relocs[0].type = BFD_RELOC_ARM_T32_IMM12;
11433 /* Parse an add or subtract instruction. We get here with inst.instruction
11434 equaling any of THUMB_OPCODE_add, adds, sub, or subs. */
11437 do_t_add_sub (void)
11441 Rd = inst.operands[0].reg;
11442 Rs = (inst.operands[1].present
11443 ? inst.operands[1].reg /* Rd, Rs, foo */
11444 : inst.operands[0].reg); /* Rd, foo -> Rd, Rd, foo */
11447 set_pred_insn_type_last ();
11449 if (unified_syntax)
11452 bfd_boolean narrow;
11455 flags = (inst.instruction == T_MNEM_adds
11456 || inst.instruction == T_MNEM_subs);
11458 narrow = !in_pred_block ();
11460 narrow = in_pred_block ();
11461 if (!inst.operands[2].isreg)
11465 if (!ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_v8))
11466 constraint (Rd == REG_SP && Rs != REG_SP, BAD_SP);
11468 add = (inst.instruction == T_MNEM_add
11469 || inst.instruction == T_MNEM_adds);
11471 if (inst.size_req != 4)
11473 /* Attempt to use a narrow opcode, with relaxation if
11475 if (Rd == REG_SP && Rs == REG_SP && !flags)
11476 opcode = add ? T_MNEM_inc_sp : T_MNEM_dec_sp;
11477 else if (Rd <= 7 && Rs == REG_SP && add && !flags)
11478 opcode = T_MNEM_add_sp;
11479 else if (Rd <= 7 && Rs == REG_PC && add && !flags)
11480 opcode = T_MNEM_add_pc;
11481 else if (Rd <= 7 && Rs <= 7 && narrow)
11484 opcode = add ? T_MNEM_addis : T_MNEM_subis;
11486 opcode = add ? T_MNEM_addi : T_MNEM_subi;
11490 inst.instruction = THUMB_OP16(opcode);
11491 inst.instruction |= (Rd << 4) | Rs;
11492 if (inst.relocs[0].type < BFD_RELOC_ARM_THUMB_ALU_ABS_G0_NC
11493 || (inst.relocs[0].type
11494 > BFD_RELOC_ARM_THUMB_ALU_ABS_G3_NC))
11496 if (inst.size_req == 2)
11497 inst.relocs[0].type = BFD_RELOC_ARM_THUMB_ADD;
11499 inst.relax = opcode;
11503 constraint (inst.size_req == 2, BAD_HIREG);
11505 if (inst.size_req == 4
11506 || (inst.size_req != 2 && !opcode))
11508 constraint ((inst.relocs[0].type
11509 >= BFD_RELOC_ARM_THUMB_ALU_ABS_G0_NC)
11510 && (inst.relocs[0].type
11511 <= BFD_RELOC_ARM_THUMB_ALU_ABS_G3_NC) ,
11512 THUMB1_RELOC_ONLY);
11515 constraint (add, BAD_PC);
11516 constraint (Rs != REG_LR || inst.instruction != T_MNEM_subs,
11517 _("only SUBS PC, LR, #const allowed"));
11518 constraint (inst.relocs[0].exp.X_op != O_constant,
11519 _("expression too complex"));
11520 constraint (inst.relocs[0].exp.X_add_number < 0
11521 || inst.relocs[0].exp.X_add_number > 0xff,
11522 _("immediate value out of range"));
11523 inst.instruction = T2_SUBS_PC_LR
11524 | inst.relocs[0].exp.X_add_number;
11525 inst.relocs[0].type = BFD_RELOC_UNUSED;
11528 else if (Rs == REG_PC)
11530 /* Always use addw/subw. */
11531 inst.instruction = add ? 0xf20f0000 : 0xf2af0000;
11532 inst.relocs[0].type = BFD_RELOC_ARM_T32_IMM12;
11536 inst.instruction = THUMB_OP32 (inst.instruction);
11537 inst.instruction = (inst.instruction & 0xe1ffffff)
11540 inst.relocs[0].type = BFD_RELOC_ARM_T32_IMMEDIATE;
11542 inst.relocs[0].type = BFD_RELOC_ARM_T32_ADD_IMM;
11544 inst.instruction |= Rd << 8;
11545 inst.instruction |= Rs << 16;
11550 unsigned int value = inst.relocs[0].exp.X_add_number;
11551 unsigned int shift = inst.operands[2].shift_kind;
11553 Rn = inst.operands[2].reg;
11554 /* See if we can do this with a 16-bit instruction. */
11555 if (!inst.operands[2].shifted && inst.size_req != 4)
11557 if (Rd > 7 || Rs > 7 || Rn > 7)
11562 inst.instruction = ((inst.instruction == T_MNEM_adds
11563 || inst.instruction == T_MNEM_add)
11565 : T_OPCODE_SUB_R3);
11566 inst.instruction |= Rd | (Rs << 3) | (Rn << 6);
11570 if (inst.instruction == T_MNEM_add && (Rd == Rs || Rd == Rn))
11572 /* Thumb-1 cores (except v6-M) require at least one high
11573 register in a narrow non flag setting add. */
11574 if (Rd > 7 || Rn > 7
11575 || ARM_CPU_HAS_FEATURE (selected_cpu, arm_ext_v6t2)
11576 || ARM_CPU_HAS_FEATURE (selected_cpu, arm_ext_msr))
11583 inst.instruction = T_OPCODE_ADD_HI;
11584 inst.instruction |= (Rd & 8) << 4;
11585 inst.instruction |= (Rd & 7);
11586 inst.instruction |= Rn << 3;
11592 constraint (Rd == REG_PC, BAD_PC);
11593 if (!ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_v8))
11594 constraint (Rd == REG_SP && Rs != REG_SP, BAD_SP);
11595 constraint (Rs == REG_PC, BAD_PC);
11596 reject_bad_reg (Rn);
11598 /* If we get here, it can't be done in 16 bits. */
11599 constraint (inst.operands[2].shifted && inst.operands[2].immisreg,
11600 _("shift must be constant"));
11601 inst.instruction = THUMB_OP32 (inst.instruction);
11602 inst.instruction |= Rd << 8;
11603 inst.instruction |= Rs << 16;
11604 constraint (Rd == REG_SP && Rs == REG_SP && value > 3,
11605 _("shift value over 3 not allowed in thumb mode"));
11606 constraint (Rd == REG_SP && Rs == REG_SP && shift != SHIFT_LSL,
11607 _("only LSL shift allowed in thumb mode"));
11608 encode_thumb32_shifted_operand (2);
11613 constraint (inst.instruction == T_MNEM_adds
11614 || inst.instruction == T_MNEM_subs,
11617 if (!inst.operands[2].isreg) /* Rd, Rs, #imm */
11619 constraint ((Rd > 7 && (Rd != REG_SP || Rs != REG_SP))
11620 || (Rs > 7 && Rs != REG_SP && Rs != REG_PC),
11623 inst.instruction = (inst.instruction == T_MNEM_add
11624 ? 0x0000 : 0x8000);
11625 inst.instruction |= (Rd << 4) | Rs;
11626 inst.relocs[0].type = BFD_RELOC_ARM_THUMB_ADD;
11630 Rn = inst.operands[2].reg;
11631 constraint (inst.operands[2].shifted, _("unshifted register required"));
11633 /* We now have Rd, Rs, and Rn set to registers. */
11634 if (Rd > 7 || Rs > 7 || Rn > 7)
11636 /* Can't do this for SUB. */
11637 constraint (inst.instruction == T_MNEM_sub, BAD_HIREG);
11638 inst.instruction = T_OPCODE_ADD_HI;
11639 inst.instruction |= (Rd & 8) << 4;
11640 inst.instruction |= (Rd & 7);
11642 inst.instruction |= Rn << 3;
11644 inst.instruction |= Rs << 3;
11646 constraint (1, _("dest must overlap one source register"));
11650 inst.instruction = (inst.instruction == T_MNEM_add
11651 ? T_OPCODE_ADD_R3 : T_OPCODE_SUB_R3);
11652 inst.instruction |= Rd | (Rs << 3) | (Rn << 6);
11662 Rd = inst.operands[0].reg;
11663 reject_bad_reg (Rd);
11665 if (unified_syntax && inst.size_req == 0 && Rd <= 7)
11667 /* Defer to section relaxation. */
11668 inst.relax = inst.instruction;
11669 inst.instruction = THUMB_OP16 (inst.instruction);
11670 inst.instruction |= Rd << 4;
11672 else if (unified_syntax && inst.size_req != 2)
11674 /* Generate a 32-bit opcode. */
11675 inst.instruction = THUMB_OP32 (inst.instruction);
11676 inst.instruction |= Rd << 8;
11677 inst.relocs[0].type = BFD_RELOC_ARM_T32_ADD_PC12;
11678 inst.relocs[0].pc_rel = 1;
11682 /* Generate a 16-bit opcode. */
11683 inst.instruction = THUMB_OP16 (inst.instruction);
11684 inst.relocs[0].type = BFD_RELOC_ARM_THUMB_ADD;
11685 inst.relocs[0].exp.X_add_number -= 4; /* PC relative adjust. */
11686 inst.relocs[0].pc_rel = 1;
11687 inst.instruction |= Rd << 4;
11690 if (inst.relocs[0].exp.X_op == O_symbol
11691 && inst.relocs[0].exp.X_add_symbol != NULL
11692 && S_IS_DEFINED (inst.relocs[0].exp.X_add_symbol)
11693 && THUMB_IS_FUNC (inst.relocs[0].exp.X_add_symbol))
11694 inst.relocs[0].exp.X_add_number += 1;
11697 /* Arithmetic instructions for which there is just one 16-bit
11698 instruction encoding, and it allows only two low registers.
11699 For maximal compatibility with ARM syntax, we allow three register
11700 operands even when Thumb-32 instructions are not available, as long
11701 as the first two are identical. For instance, both "sbc r0,r1" and
11702 "sbc r0,r0,r1" are allowed. */
11708 Rd = inst.operands[0].reg;
11709 Rs = (inst.operands[1].present
11710 ? inst.operands[1].reg /* Rd, Rs, foo */
11711 : inst.operands[0].reg); /* Rd, foo -> Rd, Rd, foo */
11712 Rn = inst.operands[2].reg;
11714 reject_bad_reg (Rd);
11715 reject_bad_reg (Rs);
11716 if (inst.operands[2].isreg)
11717 reject_bad_reg (Rn);
11719 if (unified_syntax)
11721 if (!inst.operands[2].isreg)
11723 /* For an immediate, we always generate a 32-bit opcode;
11724 section relaxation will shrink it later if possible. */
11725 inst.instruction = THUMB_OP32 (inst.instruction);
11726 inst.instruction = (inst.instruction & 0xe1ffffff) | 0x10000000;
11727 inst.instruction |= Rd << 8;
11728 inst.instruction |= Rs << 16;
11729 inst.relocs[0].type = BFD_RELOC_ARM_T32_IMMEDIATE;
11733 bfd_boolean narrow;
11735 /* See if we can do this with a 16-bit instruction. */
11736 if (THUMB_SETS_FLAGS (inst.instruction))
11737 narrow = !in_pred_block ();
11739 narrow = in_pred_block ();
11741 if (Rd > 7 || Rn > 7 || Rs > 7)
11743 if (inst.operands[2].shifted)
11745 if (inst.size_req == 4)
11751 inst.instruction = THUMB_OP16 (inst.instruction);
11752 inst.instruction |= Rd;
11753 inst.instruction |= Rn << 3;
11757 /* If we get here, it can't be done in 16 bits. */
11758 constraint (inst.operands[2].shifted
11759 && inst.operands[2].immisreg,
11760 _("shift must be constant"));
11761 inst.instruction = THUMB_OP32 (inst.instruction);
11762 inst.instruction |= Rd << 8;
11763 inst.instruction |= Rs << 16;
11764 encode_thumb32_shifted_operand (2);
11769 /* On its face this is a lie - the instruction does set the
11770 flags. However, the only supported mnemonic in this mode
11771 says it doesn't. */
11772 constraint (THUMB_SETS_FLAGS (inst.instruction), BAD_THUMB32);
11774 constraint (!inst.operands[2].isreg || inst.operands[2].shifted,
11775 _("unshifted register required"));
11776 constraint (Rd > 7 || Rs > 7 || Rn > 7, BAD_HIREG);
11777 constraint (Rd != Rs,
11778 _("dest and source1 must be the same register"));
11780 inst.instruction = THUMB_OP16 (inst.instruction);
11781 inst.instruction |= Rd;
11782 inst.instruction |= Rn << 3;
11786 /* Similarly, but for instructions where the arithmetic operation is
11787 commutative, so we can allow either of them to be different from
11788 the destination operand in a 16-bit instruction. For instance, all
11789 three of "adc r0,r1", "adc r0,r0,r1", and "adc r0,r1,r0" are
11796 Rd = inst.operands[0].reg;
11797 Rs = (inst.operands[1].present
11798 ? inst.operands[1].reg /* Rd, Rs, foo */
11799 : inst.operands[0].reg); /* Rd, foo -> Rd, Rd, foo */
11800 Rn = inst.operands[2].reg;
11802 reject_bad_reg (Rd);
11803 reject_bad_reg (Rs);
11804 if (inst.operands[2].isreg)
11805 reject_bad_reg (Rn);
11807 if (unified_syntax)
11809 if (!inst.operands[2].isreg)
11811 /* For an immediate, we always generate a 32-bit opcode;
11812 section relaxation will shrink it later if possible. */
11813 inst.instruction = THUMB_OP32 (inst.instruction);
11814 inst.instruction = (inst.instruction & 0xe1ffffff) | 0x10000000;
11815 inst.instruction |= Rd << 8;
11816 inst.instruction |= Rs << 16;
11817 inst.relocs[0].type = BFD_RELOC_ARM_T32_IMMEDIATE;
11821 bfd_boolean narrow;
11823 /* See if we can do this with a 16-bit instruction. */
11824 if (THUMB_SETS_FLAGS (inst.instruction))
11825 narrow = !in_pred_block ();
11827 narrow = in_pred_block ();
11829 if (Rd > 7 || Rn > 7 || Rs > 7)
11831 if (inst.operands[2].shifted)
11833 if (inst.size_req == 4)
11840 inst.instruction = THUMB_OP16 (inst.instruction);
11841 inst.instruction |= Rd;
11842 inst.instruction |= Rn << 3;
11847 inst.instruction = THUMB_OP16 (inst.instruction);
11848 inst.instruction |= Rd;
11849 inst.instruction |= Rs << 3;
11854 /* If we get here, it can't be done in 16 bits. */
11855 constraint (inst.operands[2].shifted
11856 && inst.operands[2].immisreg,
11857 _("shift must be constant"));
11858 inst.instruction = THUMB_OP32 (inst.instruction);
11859 inst.instruction |= Rd << 8;
11860 inst.instruction |= Rs << 16;
11861 encode_thumb32_shifted_operand (2);
11866 /* On its face this is a lie - the instruction does set the
11867 flags. However, the only supported mnemonic in this mode
11868 says it doesn't. */
11869 constraint (THUMB_SETS_FLAGS (inst.instruction), BAD_THUMB32);
11871 constraint (!inst.operands[2].isreg || inst.operands[2].shifted,
11872 _("unshifted register required"));
11873 constraint (Rd > 7 || Rs > 7 || Rn > 7, BAD_HIREG);
11875 inst.instruction = THUMB_OP16 (inst.instruction);
11876 inst.instruction |= Rd;
11879 inst.instruction |= Rn << 3;
11881 inst.instruction |= Rs << 3;
11883 constraint (1, _("dest must overlap one source register"));
11891 unsigned int msb = inst.operands[1].imm + inst.operands[2].imm;
11892 constraint (msb > 32, _("bit-field extends past end of register"));
11893 /* The instruction encoding stores the LSB and MSB,
11894 not the LSB and width. */
11895 Rd = inst.operands[0].reg;
11896 reject_bad_reg (Rd);
11897 inst.instruction |= Rd << 8;
11898 inst.instruction |= (inst.operands[1].imm & 0x1c) << 10;
11899 inst.instruction |= (inst.operands[1].imm & 0x03) << 6;
11900 inst.instruction |= msb - 1;
11909 Rd = inst.operands[0].reg;
11910 reject_bad_reg (Rd);
11912 /* #0 in second position is alternative syntax for bfc, which is
11913 the same instruction but with REG_PC in the Rm field. */
11914 if (!inst.operands[1].isreg)
11918 Rn = inst.operands[1].reg;
11919 reject_bad_reg (Rn);
11922 msb = inst.operands[2].imm + inst.operands[3].imm;
11923 constraint (msb > 32, _("bit-field extends past end of register"));
11924 /* The instruction encoding stores the LSB and MSB,
11925 not the LSB and width. */
11926 inst.instruction |= Rd << 8;
11927 inst.instruction |= Rn << 16;
11928 inst.instruction |= (inst.operands[2].imm & 0x1c) << 10;
11929 inst.instruction |= (inst.operands[2].imm & 0x03) << 6;
11930 inst.instruction |= msb - 1;
11938 Rd = inst.operands[0].reg;
11939 Rn = inst.operands[1].reg;
11941 reject_bad_reg (Rd);
11942 reject_bad_reg (Rn);
11944 constraint (inst.operands[2].imm + inst.operands[3].imm > 32,
11945 _("bit-field extends past end of register"));
11946 inst.instruction |= Rd << 8;
11947 inst.instruction |= Rn << 16;
11948 inst.instruction |= (inst.operands[2].imm & 0x1c) << 10;
11949 inst.instruction |= (inst.operands[2].imm & 0x03) << 6;
11950 inst.instruction |= inst.operands[3].imm - 1;
11953 /* ARM V5 Thumb BLX (argument parse)
11954 BLX <target_addr> which is BLX(1)
11955 BLX <Rm> which is BLX(2)
11956 Unfortunately, there are two different opcodes for this mnemonic.
11957 So, the insns[].value is not used, and the code here zaps values
11958 into inst.instruction.
11960 ??? How to take advantage of the additional two bits of displacement
11961 available in Thumb32 mode? Need new relocation? */
11966 set_pred_insn_type_last ();
11968 if (inst.operands[0].isreg)
11970 constraint (inst.operands[0].reg == REG_PC, BAD_PC);
11971 /* We have a register, so this is BLX(2). */
11972 inst.instruction |= inst.operands[0].reg << 3;
11976 /* No register. This must be BLX(1). */
11977 inst.instruction = 0xf000e800;
11978 encode_branch (BFD_RELOC_THUMB_PCREL_BLX);
11987 bfd_reloc_code_real_type reloc;
11990 set_pred_insn_type (IF_INSIDE_IT_LAST_INSN);
11992 if (in_pred_block ())
11994 /* Conditional branches inside IT blocks are encoded as unconditional
11996 cond = COND_ALWAYS;
12001 if (cond != COND_ALWAYS)
12002 opcode = T_MNEM_bcond;
12004 opcode = inst.instruction;
12007 && (inst.size_req == 4
12008 || (inst.size_req != 2
12009 && (inst.operands[0].hasreloc
12010 || inst.relocs[0].exp.X_op == O_constant))))
12012 inst.instruction = THUMB_OP32(opcode);
12013 if (cond == COND_ALWAYS)
12014 reloc = BFD_RELOC_THUMB_PCREL_BRANCH25;
12017 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_v6t2),
12018 _("selected architecture does not support "
12019 "wide conditional branch instruction"));
12021 gas_assert (cond != 0xF);
12022 inst.instruction |= cond << 22;
12023 reloc = BFD_RELOC_THUMB_PCREL_BRANCH20;
12028 inst.instruction = THUMB_OP16(opcode);
12029 if (cond == COND_ALWAYS)
12030 reloc = BFD_RELOC_THUMB_PCREL_BRANCH12;
12033 inst.instruction |= cond << 8;
12034 reloc = BFD_RELOC_THUMB_PCREL_BRANCH9;
12036 /* Allow section relaxation. */
12037 if (unified_syntax && inst.size_req != 2)
12038 inst.relax = opcode;
12040 inst.relocs[0].type = reloc;
12041 inst.relocs[0].pc_rel = 1;
12044 /* Actually do the work for Thumb state bkpt and hlt. The only difference
12045 between the two is the maximum immediate allowed - which is passed in
12048 do_t_bkpt_hlt1 (int range)
12050 constraint (inst.cond != COND_ALWAYS,
12051 _("instruction is always unconditional"));
12052 if (inst.operands[0].present)
12054 constraint (inst.operands[0].imm > range,
12055 _("immediate value out of range"));
12056 inst.instruction |= inst.operands[0].imm;
12059 set_pred_insn_type (NEUTRAL_IT_INSN);
12065 do_t_bkpt_hlt1 (63);
12071 do_t_bkpt_hlt1 (255);
12075 do_t_branch23 (void)
12077 set_pred_insn_type_last ();
12078 encode_branch (BFD_RELOC_THUMB_PCREL_BRANCH23);
12080 /* md_apply_fix blows up with 'bl foo(PLT)' where foo is defined in
12081 this file. We used to simply ignore the PLT reloc type here --
12082 the branch encoding is now needed to deal with TLSCALL relocs.
12083 So if we see a PLT reloc now, put it back to how it used to be to
12084 keep the preexisting behaviour. */
12085 if (inst.relocs[0].type == BFD_RELOC_ARM_PLT32)
12086 inst.relocs[0].type = BFD_RELOC_THUMB_PCREL_BRANCH23;
12088 #if defined(OBJ_COFF)
12089 /* If the destination of the branch is a defined symbol which does not have
12090 the THUMB_FUNC attribute, then we must be calling a function which has
12091 the (interfacearm) attribute. We look for the Thumb entry point to that
12092 function and change the branch to refer to that function instead. */
12093 if ( inst.relocs[0].exp.X_op == O_symbol
12094 && inst.relocs[0].exp.X_add_symbol != NULL
12095 && S_IS_DEFINED (inst.relocs[0].exp.X_add_symbol)
12096 && ! THUMB_IS_FUNC (inst.relocs[0].exp.X_add_symbol))
12097 inst.relocs[0].exp.X_add_symbol
12098 = find_real_start (inst.relocs[0].exp.X_add_symbol);
12105 set_pred_insn_type_last ();
12106 inst.instruction |= inst.operands[0].reg << 3;
12107 /* ??? FIXME: Should add a hacky reloc here if reg is REG_PC. The reloc
12108 should cause the alignment to be checked once it is known. This is
12109 because BX PC only works if the instruction is word aligned. */
12117 set_pred_insn_type_last ();
12118 Rm = inst.operands[0].reg;
12119 reject_bad_reg (Rm);
12120 inst.instruction |= Rm << 16;
12129 Rd = inst.operands[0].reg;
12130 Rm = inst.operands[1].reg;
12132 reject_bad_reg (Rd);
12133 reject_bad_reg (Rm);
12135 inst.instruction |= Rd << 8;
12136 inst.instruction |= Rm << 16;
12137 inst.instruction |= Rm;
12140 /* For the Armv8.1-M conditional instructions. */
12144 unsigned Rd, Rn, Rm;
12147 constraint (inst.cond != COND_ALWAYS, BAD_COND);
12149 Rd = inst.operands[0].reg;
12150 switch (inst.instruction)
12156 Rn = inst.operands[1].reg;
12157 Rm = inst.operands[2].reg;
12158 cond = inst.operands[3].imm;
12159 constraint (Rn == REG_SP, BAD_SP);
12160 constraint (Rm == REG_SP, BAD_SP);
12166 Rn = inst.operands[1].reg;
12167 cond = inst.operands[2].imm;
12168 /* Invert the last bit to invert the cond. */
12169 cond = TOGGLE_BIT (cond, 0);
12170 constraint (Rn == REG_SP, BAD_SP);
12176 cond = inst.operands[1].imm;
12177 /* Invert the last bit to invert the cond. */
12178 cond = TOGGLE_BIT (cond, 0);
12186 set_pred_insn_type (OUTSIDE_PRED_INSN);
12187 inst.instruction = THUMB_OP32 (inst.instruction);
12188 inst.instruction |= Rd << 8;
12189 inst.instruction |= Rn << 16;
12190 inst.instruction |= Rm;
12191 inst.instruction |= cond << 4;
12197 set_pred_insn_type (OUTSIDE_PRED_INSN);
12203 set_pred_insn_type (OUTSIDE_PRED_INSN);
12204 inst.instruction |= inst.operands[0].imm;
12210 set_pred_insn_type (OUTSIDE_PRED_INSN);
12212 && (inst.operands[1].present || inst.size_req == 4)
12213 && ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_v6_notm))
12215 unsigned int imod = (inst.instruction & 0x0030) >> 4;
12216 inst.instruction = 0xf3af8000;
12217 inst.instruction |= imod << 9;
12218 inst.instruction |= inst.operands[0].imm << 5;
12219 if (inst.operands[1].present)
12220 inst.instruction |= 0x100 | inst.operands[1].imm;
12224 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_v1)
12225 && (inst.operands[0].imm & 4),
12226 _("selected processor does not support 'A' form "
12227 "of this instruction"));
12228 constraint (inst.operands[1].present || inst.size_req == 4,
12229 _("Thumb does not support the 2-argument "
12230 "form of this instruction"));
12231 inst.instruction |= inst.operands[0].imm;
12235 /* THUMB CPY instruction (argument parse). */
12240 if (inst.size_req == 4)
12242 inst.instruction = THUMB_OP32 (T_MNEM_mov);
12243 inst.instruction |= inst.operands[0].reg << 8;
12244 inst.instruction |= inst.operands[1].reg;
12248 inst.instruction |= (inst.operands[0].reg & 0x8) << 4;
12249 inst.instruction |= (inst.operands[0].reg & 0x7);
12250 inst.instruction |= inst.operands[1].reg << 3;
12257 set_pred_insn_type (OUTSIDE_PRED_INSN);
12258 constraint (inst.operands[0].reg > 7, BAD_HIREG);
12259 inst.instruction |= inst.operands[0].reg;
12260 inst.relocs[0].pc_rel = 1;
12261 inst.relocs[0].type = BFD_RELOC_THUMB_PCREL_BRANCH7;
12267 inst.instruction |= inst.operands[0].imm;
12273 unsigned Rd, Rn, Rm;
12275 Rd = inst.operands[0].reg;
12276 Rn = (inst.operands[1].present
12277 ? inst.operands[1].reg : Rd);
12278 Rm = inst.operands[2].reg;
12280 reject_bad_reg (Rd);
12281 reject_bad_reg (Rn);
12282 reject_bad_reg (Rm);
12284 inst.instruction |= Rd << 8;
12285 inst.instruction |= Rn << 16;
12286 inst.instruction |= Rm;
12292 if (unified_syntax && inst.size_req == 4)
12293 inst.instruction = THUMB_OP32 (inst.instruction);
12295 inst.instruction = THUMB_OP16 (inst.instruction);
12301 unsigned int cond = inst.operands[0].imm;
12303 set_pred_insn_type (IT_INSN);
12304 now_pred.mask = (inst.instruction & 0xf) | 0x10;
12305 now_pred.cc = cond;
12306 now_pred.warn_deprecated = FALSE;
12307 now_pred.type = SCALAR_PRED;
12309 /* If the condition is a negative condition, invert the mask. */
12310 if ((cond & 0x1) == 0x0)
12312 unsigned int mask = inst.instruction & 0x000f;
12314 if ((mask & 0x7) == 0)
12316 /* No conversion needed. */
12317 now_pred.block_length = 1;
12319 else if ((mask & 0x3) == 0)
12322 now_pred.block_length = 2;
12324 else if ((mask & 0x1) == 0)
12327 now_pred.block_length = 3;
12332 now_pred.block_length = 4;
12335 inst.instruction &= 0xfff0;
12336 inst.instruction |= mask;
12339 inst.instruction |= cond << 4;
12342 /* Helper function used for both push/pop and ldm/stm. */
12344 encode_thumb2_multi (bfd_boolean do_io, int base, unsigned mask,
12345 bfd_boolean writeback)
12347 bfd_boolean load, store;
12349 gas_assert (base != -1 || !do_io);
12350 load = do_io && ((inst.instruction & (1 << 20)) != 0);
12351 store = do_io && !load;
12353 if (mask & (1 << 13))
12354 inst.error = _("SP not allowed in register list");
12356 if (do_io && (mask & (1 << base)) != 0
12358 inst.error = _("having the base register in the register list when "
12359 "using write back is UNPREDICTABLE");
12363 if (mask & (1 << 15))
12365 if (mask & (1 << 14))
12366 inst.error = _("LR and PC should not both be in register list");
12368 set_pred_insn_type_last ();
12373 if (mask & (1 << 15))
12374 inst.error = _("PC not allowed in register list");
12377 if (do_io && ((mask & (mask - 1)) == 0))
12379 /* Single register transfers implemented as str/ldr. */
12382 if (inst.instruction & (1 << 23))
12383 inst.instruction = 0x00000b04; /* ia! -> [base], #4 */
12385 inst.instruction = 0x00000d04; /* db! -> [base, #-4]! */
12389 if (inst.instruction & (1 << 23))
12390 inst.instruction = 0x00800000; /* ia -> [base] */
12392 inst.instruction = 0x00000c04; /* db -> [base, #-4] */
12395 inst.instruction |= 0xf8400000;
12397 inst.instruction |= 0x00100000;
12399 mask = ffs (mask) - 1;
12402 else if (writeback)
12403 inst.instruction |= WRITE_BACK;
12405 inst.instruction |= mask;
12407 inst.instruction |= base << 16;
12413 /* This really doesn't seem worth it. */
12414 constraint (inst.relocs[0].type != BFD_RELOC_UNUSED,
12415 _("expression too complex"));
12416 constraint (inst.operands[1].writeback,
12417 _("Thumb load/store multiple does not support {reglist}^"));
12419 if (unified_syntax)
12421 bfd_boolean narrow;
12425 /* See if we can use a 16-bit instruction. */
12426 if (inst.instruction < 0xffff /* not ldmdb/stmdb */
12427 && inst.size_req != 4
12428 && !(inst.operands[1].imm & ~0xff))
12430 mask = 1 << inst.operands[0].reg;
12432 if (inst.operands[0].reg <= 7)
12434 if (inst.instruction == T_MNEM_stmia
12435 ? inst.operands[0].writeback
12436 : (inst.operands[0].writeback
12437 == !(inst.operands[1].imm & mask)))
12439 if (inst.instruction == T_MNEM_stmia
12440 && (inst.operands[1].imm & mask)
12441 && (inst.operands[1].imm & (mask - 1)))
12442 as_warn (_("value stored for r%d is UNKNOWN"),
12443 inst.operands[0].reg);
12445 inst.instruction = THUMB_OP16 (inst.instruction);
12446 inst.instruction |= inst.operands[0].reg << 8;
12447 inst.instruction |= inst.operands[1].imm;
12450 else if ((inst.operands[1].imm & (inst.operands[1].imm-1)) == 0)
12452 /* This means 1 register in reg list one of 3 situations:
12453 1. Instruction is stmia, but without writeback.
12454 2. lmdia without writeback, but with Rn not in
12456 3. ldmia with writeback, but with Rn in reglist.
12457 Case 3 is UNPREDICTABLE behaviour, so we handle
12458 case 1 and 2 which can be converted into a 16-bit
12459 str or ldr. The SP cases are handled below. */
12460 unsigned long opcode;
12461 /* First, record an error for Case 3. */
12462 if (inst.operands[1].imm & mask
12463 && inst.operands[0].writeback)
12465 _("having the base register in the register list when "
12466 "using write back is UNPREDICTABLE");
12468 opcode = (inst.instruction == T_MNEM_stmia ? T_MNEM_str
12470 inst.instruction = THUMB_OP16 (opcode);
12471 inst.instruction |= inst.operands[0].reg << 3;
12472 inst.instruction |= (ffs (inst.operands[1].imm)-1);
12476 else if (inst.operands[0] .reg == REG_SP)
12478 if (inst.operands[0].writeback)
12481 THUMB_OP16 (inst.instruction == T_MNEM_stmia
12482 ? T_MNEM_push : T_MNEM_pop);
12483 inst.instruction |= inst.operands[1].imm;
12486 else if ((inst.operands[1].imm & (inst.operands[1].imm-1)) == 0)
12489 THUMB_OP16 (inst.instruction == T_MNEM_stmia
12490 ? T_MNEM_str_sp : T_MNEM_ldr_sp);
12491 inst.instruction |= ((ffs (inst.operands[1].imm)-1) << 8);
12499 if (inst.instruction < 0xffff)
12500 inst.instruction = THUMB_OP32 (inst.instruction);
12502 encode_thumb2_multi (TRUE /* do_io */, inst.operands[0].reg,
12503 inst.operands[1].imm,
12504 inst.operands[0].writeback);
12509 constraint (inst.operands[0].reg > 7
12510 || (inst.operands[1].imm & ~0xff), BAD_HIREG);
12511 constraint (inst.instruction != T_MNEM_ldmia
12512 && inst.instruction != T_MNEM_stmia,
12513 _("Thumb-2 instruction only valid in unified syntax"));
12514 if (inst.instruction == T_MNEM_stmia)
12516 if (!inst.operands[0].writeback)
12517 as_warn (_("this instruction will write back the base register"));
12518 if ((inst.operands[1].imm & (1 << inst.operands[0].reg))
12519 && (inst.operands[1].imm & ((1 << inst.operands[0].reg) - 1)))
12520 as_warn (_("value stored for r%d is UNKNOWN"),
12521 inst.operands[0].reg);
12525 if (!inst.operands[0].writeback
12526 && !(inst.operands[1].imm & (1 << inst.operands[0].reg)))
12527 as_warn (_("this instruction will write back the base register"));
12528 else if (inst.operands[0].writeback
12529 && (inst.operands[1].imm & (1 << inst.operands[0].reg)))
12530 as_warn (_("this instruction will not write back the base register"));
12533 inst.instruction = THUMB_OP16 (inst.instruction);
12534 inst.instruction |= inst.operands[0].reg << 8;
12535 inst.instruction |= inst.operands[1].imm;
12542 constraint (!inst.operands[1].isreg || !inst.operands[1].preind
12543 || inst.operands[1].postind || inst.operands[1].writeback
12544 || inst.operands[1].immisreg || inst.operands[1].shifted
12545 || inst.operands[1].negative,
12548 constraint ((inst.operands[1].reg == REG_PC), BAD_PC);
12550 inst.instruction |= inst.operands[0].reg << 12;
12551 inst.instruction |= inst.operands[1].reg << 16;
12552 inst.relocs[0].type = BFD_RELOC_ARM_T32_OFFSET_U8;
12558 if (!inst.operands[1].present)
12560 constraint (inst.operands[0].reg == REG_LR,
12561 _("r14 not allowed as first register "
12562 "when second register is omitted"));
12563 inst.operands[1].reg = inst.operands[0].reg + 1;
12565 constraint (inst.operands[0].reg == inst.operands[1].reg,
12568 inst.instruction |= inst.operands[0].reg << 12;
12569 inst.instruction |= inst.operands[1].reg << 8;
12570 inst.instruction |= inst.operands[2].reg << 16;
12576 unsigned long opcode;
12579 if (inst.operands[0].isreg
12580 && !inst.operands[0].preind
12581 && inst.operands[0].reg == REG_PC)
12582 set_pred_insn_type_last ();
12584 opcode = inst.instruction;
12585 if (unified_syntax)
12587 if (!inst.operands[1].isreg)
12589 if (opcode <= 0xffff)
12590 inst.instruction = THUMB_OP32 (opcode);
12591 if (move_or_literal_pool (0, CONST_THUMB, /*mode_3=*/FALSE))
12594 if (inst.operands[1].isreg
12595 && !inst.operands[1].writeback
12596 && !inst.operands[1].shifted && !inst.operands[1].postind
12597 && !inst.operands[1].negative && inst.operands[0].reg <= 7
12598 && opcode <= 0xffff
12599 && inst.size_req != 4)
12601 /* Insn may have a 16-bit form. */
12602 Rn = inst.operands[1].reg;
12603 if (inst.operands[1].immisreg)
12605 inst.instruction = THUMB_OP16 (opcode);
12607 if (Rn <= 7 && inst.operands[1].imm <= 7)
12609 else if (opcode != T_MNEM_ldr && opcode != T_MNEM_str)
12610 reject_bad_reg (inst.operands[1].imm);
12612 else if ((Rn <= 7 && opcode != T_MNEM_ldrsh
12613 && opcode != T_MNEM_ldrsb)
12614 || ((Rn == REG_PC || Rn == REG_SP) && opcode == T_MNEM_ldr)
12615 || (Rn == REG_SP && opcode == T_MNEM_str))
12622 if (inst.relocs[0].pc_rel)
12623 opcode = T_MNEM_ldr_pc2;
12625 opcode = T_MNEM_ldr_pc;
12629 if (opcode == T_MNEM_ldr)
12630 opcode = T_MNEM_ldr_sp;
12632 opcode = T_MNEM_str_sp;
12634 inst.instruction = inst.operands[0].reg << 8;
12638 inst.instruction = inst.operands[0].reg;
12639 inst.instruction |= inst.operands[1].reg << 3;
12641 inst.instruction |= THUMB_OP16 (opcode);
12642 if (inst.size_req == 2)
12643 inst.relocs[0].type = BFD_RELOC_ARM_THUMB_OFFSET;
12645 inst.relax = opcode;
12649 /* Definitely a 32-bit variant. */
12651 /* Warning for Erratum 752419. */
12652 if (opcode == T_MNEM_ldr
12653 && inst.operands[0].reg == REG_SP
12654 && inst.operands[1].writeback == 1
12655 && !inst.operands[1].immisreg)
12657 if (no_cpu_selected ()
12658 || (ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_v7)
12659 && !ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_v7a)
12660 && !ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_v7r)))
12661 as_warn (_("This instruction may be unpredictable "
12662 "if executed on M-profile cores "
12663 "with interrupts enabled."));
12666 /* Do some validations regarding addressing modes. */
12667 if (inst.operands[1].immisreg)
12668 reject_bad_reg (inst.operands[1].imm);
12670 constraint (inst.operands[1].writeback == 1
12671 && inst.operands[0].reg == inst.operands[1].reg,
12674 inst.instruction = THUMB_OP32 (opcode);
12675 inst.instruction |= inst.operands[0].reg << 12;
12676 encode_thumb32_addr_mode (1, /*is_t=*/FALSE, /*is_d=*/FALSE);
12677 check_ldr_r15_aligned ();
12681 constraint (inst.operands[0].reg > 7, BAD_HIREG);
12683 if (inst.instruction == T_MNEM_ldrsh || inst.instruction == T_MNEM_ldrsb)
12685 /* Only [Rn,Rm] is acceptable. */
12686 constraint (inst.operands[1].reg > 7 || inst.operands[1].imm > 7, BAD_HIREG);
12687 constraint (!inst.operands[1].isreg || !inst.operands[1].immisreg
12688 || inst.operands[1].postind || inst.operands[1].shifted
12689 || inst.operands[1].negative,
12690 _("Thumb does not support this addressing mode"));
12691 inst.instruction = THUMB_OP16 (inst.instruction);
12695 inst.instruction = THUMB_OP16 (inst.instruction);
12696 if (!inst.operands[1].isreg)
12697 if (move_or_literal_pool (0, CONST_THUMB, /*mode_3=*/FALSE))
12700 constraint (!inst.operands[1].preind
12701 || inst.operands[1].shifted
12702 || inst.operands[1].writeback,
12703 _("Thumb does not support this addressing mode"));
12704 if (inst.operands[1].reg == REG_PC || inst.operands[1].reg == REG_SP)
12706 constraint (inst.instruction & 0x0600,
12707 _("byte or halfword not valid for base register"));
12708 constraint (inst.operands[1].reg == REG_PC
12709 && !(inst.instruction & THUMB_LOAD_BIT),
12710 _("r15 based store not allowed"));
12711 constraint (inst.operands[1].immisreg,
12712 _("invalid base register for register offset"));
12714 if (inst.operands[1].reg == REG_PC)
12715 inst.instruction = T_OPCODE_LDR_PC;
12716 else if (inst.instruction & THUMB_LOAD_BIT)
12717 inst.instruction = T_OPCODE_LDR_SP;
12719 inst.instruction = T_OPCODE_STR_SP;
12721 inst.instruction |= inst.operands[0].reg << 8;
12722 inst.relocs[0].type = BFD_RELOC_ARM_THUMB_OFFSET;
12726 constraint (inst.operands[1].reg > 7, BAD_HIREG);
12727 if (!inst.operands[1].immisreg)
12729 /* Immediate offset. */
12730 inst.instruction |= inst.operands[0].reg;
12731 inst.instruction |= inst.operands[1].reg << 3;
12732 inst.relocs[0].type = BFD_RELOC_ARM_THUMB_OFFSET;
12736 /* Register offset. */
12737 constraint (inst.operands[1].imm > 7, BAD_HIREG);
12738 constraint (inst.operands[1].negative,
12739 _("Thumb does not support this addressing mode"));
12742 switch (inst.instruction)
12744 case T_OPCODE_STR_IW: inst.instruction = T_OPCODE_STR_RW; break;
12745 case T_OPCODE_STR_IH: inst.instruction = T_OPCODE_STR_RH; break;
12746 case T_OPCODE_STR_IB: inst.instruction = T_OPCODE_STR_RB; break;
12747 case T_OPCODE_LDR_IW: inst.instruction = T_OPCODE_LDR_RW; break;
12748 case T_OPCODE_LDR_IH: inst.instruction = T_OPCODE_LDR_RH; break;
12749 case T_OPCODE_LDR_IB: inst.instruction = T_OPCODE_LDR_RB; break;
12750 case 0x5600 /* ldrsb */:
12751 case 0x5e00 /* ldrsh */: break;
12755 inst.instruction |= inst.operands[0].reg;
12756 inst.instruction |= inst.operands[1].reg << 3;
12757 inst.instruction |= inst.operands[1].imm << 6;
12763 if (!inst.operands[1].present)
12765 inst.operands[1].reg = inst.operands[0].reg + 1;
12766 constraint (inst.operands[0].reg == REG_LR,
12767 _("r14 not allowed here"));
12768 constraint (inst.operands[0].reg == REG_R12,
12769 _("r12 not allowed here"));
12772 if (inst.operands[2].writeback
12773 && (inst.operands[0].reg == inst.operands[2].reg
12774 || inst.operands[1].reg == inst.operands[2].reg))
12775 as_warn (_("base register written back, and overlaps "
12776 "one of transfer registers"));
12778 inst.instruction |= inst.operands[0].reg << 12;
12779 inst.instruction |= inst.operands[1].reg << 8;
12780 encode_thumb32_addr_mode (2, /*is_t=*/FALSE, /*is_d=*/TRUE);
12786 inst.instruction |= inst.operands[0].reg << 12;
12787 encode_thumb32_addr_mode (1, /*is_t=*/TRUE, /*is_d=*/FALSE);
12793 unsigned Rd, Rn, Rm, Ra;
12795 Rd = inst.operands[0].reg;
12796 Rn = inst.operands[1].reg;
12797 Rm = inst.operands[2].reg;
12798 Ra = inst.operands[3].reg;
12800 reject_bad_reg (Rd);
12801 reject_bad_reg (Rn);
12802 reject_bad_reg (Rm);
12803 reject_bad_reg (Ra);
12805 inst.instruction |= Rd << 8;
12806 inst.instruction |= Rn << 16;
12807 inst.instruction |= Rm;
12808 inst.instruction |= Ra << 12;
12814 unsigned RdLo, RdHi, Rn, Rm;
12816 RdLo = inst.operands[0].reg;
12817 RdHi = inst.operands[1].reg;
12818 Rn = inst.operands[2].reg;
12819 Rm = inst.operands[3].reg;
12821 reject_bad_reg (RdLo);
12822 reject_bad_reg (RdHi);
12823 reject_bad_reg (Rn);
12824 reject_bad_reg (Rm);
12826 inst.instruction |= RdLo << 12;
12827 inst.instruction |= RdHi << 8;
12828 inst.instruction |= Rn << 16;
12829 inst.instruction |= Rm;
12833 do_t_mov_cmp (void)
12837 Rn = inst.operands[0].reg;
12838 Rm = inst.operands[1].reg;
12841 set_pred_insn_type_last ();
12843 if (unified_syntax)
12845 int r0off = (inst.instruction == T_MNEM_mov
12846 || inst.instruction == T_MNEM_movs) ? 8 : 16;
12847 unsigned long opcode;
12848 bfd_boolean narrow;
12849 bfd_boolean low_regs;
12851 low_regs = (Rn <= 7 && Rm <= 7);
12852 opcode = inst.instruction;
12853 if (in_pred_block ())
12854 narrow = opcode != T_MNEM_movs;
12856 narrow = opcode != T_MNEM_movs || low_regs;
12857 if (inst.size_req == 4
12858 || inst.operands[1].shifted)
12861 /* MOVS PC, LR is encoded as SUBS PC, LR, #0. */
12862 if (opcode == T_MNEM_movs && inst.operands[1].isreg
12863 && !inst.operands[1].shifted
12867 inst.instruction = T2_SUBS_PC_LR;
12871 if (opcode == T_MNEM_cmp)
12873 constraint (Rn == REG_PC, BAD_PC);
12876 /* In the Thumb-2 ISA, use of R13 as Rm is deprecated,
12878 warn_deprecated_sp (Rm);
12879 /* R15 was documented as a valid choice for Rm in ARMv6,
12880 but as UNPREDICTABLE in ARMv7. ARM's proprietary
12881 tools reject R15, so we do too. */
12882 constraint (Rm == REG_PC, BAD_PC);
12885 reject_bad_reg (Rm);
12887 else if (opcode == T_MNEM_mov
12888 || opcode == T_MNEM_movs)
12890 if (inst.operands[1].isreg)
12892 if (opcode == T_MNEM_movs)
12894 reject_bad_reg (Rn);
12895 reject_bad_reg (Rm);
12899 /* This is mov.n. */
12900 if ((Rn == REG_SP || Rn == REG_PC)
12901 && (Rm == REG_SP || Rm == REG_PC))
12903 as_tsktsk (_("Use of r%u as a source register is "
12904 "deprecated when r%u is the destination "
12905 "register."), Rm, Rn);
12910 /* This is mov.w. */
12911 constraint (Rn == REG_PC, BAD_PC);
12912 constraint (Rm == REG_PC, BAD_PC);
12913 if (!ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_v8))
12914 constraint (Rn == REG_SP && Rm == REG_SP, BAD_SP);
12918 reject_bad_reg (Rn);
12921 if (!inst.operands[1].isreg)
12923 /* Immediate operand. */
12924 if (!in_pred_block () && opcode == T_MNEM_mov)
12926 if (low_regs && narrow)
12928 inst.instruction = THUMB_OP16 (opcode);
12929 inst.instruction |= Rn << 8;
12930 if (inst.relocs[0].type < BFD_RELOC_ARM_THUMB_ALU_ABS_G0_NC
12931 || inst.relocs[0].type > BFD_RELOC_ARM_THUMB_ALU_ABS_G3_NC)
12933 if (inst.size_req == 2)
12934 inst.relocs[0].type = BFD_RELOC_ARM_THUMB_IMM;
12936 inst.relax = opcode;
12941 constraint ((inst.relocs[0].type
12942 >= BFD_RELOC_ARM_THUMB_ALU_ABS_G0_NC)
12943 && (inst.relocs[0].type
12944 <= BFD_RELOC_ARM_THUMB_ALU_ABS_G3_NC) ,
12945 THUMB1_RELOC_ONLY);
12947 inst.instruction = THUMB_OP32 (inst.instruction);
12948 inst.instruction = (inst.instruction & 0xe1ffffff) | 0x10000000;
12949 inst.instruction |= Rn << r0off;
12950 inst.relocs[0].type = BFD_RELOC_ARM_T32_IMMEDIATE;
12953 else if (inst.operands[1].shifted && inst.operands[1].immisreg
12954 && (inst.instruction == T_MNEM_mov
12955 || inst.instruction == T_MNEM_movs))
12957 /* Register shifts are encoded as separate shift instructions. */
12958 bfd_boolean flags = (inst.instruction == T_MNEM_movs);
12960 if (in_pred_block ())
12965 if (inst.size_req == 4)
12968 if (!low_regs || inst.operands[1].imm > 7)
12974 switch (inst.operands[1].shift_kind)
12977 opcode = narrow ? T_OPCODE_LSL_R : THUMB_OP32 (T_MNEM_lsl);
12980 opcode = narrow ? T_OPCODE_ASR_R : THUMB_OP32 (T_MNEM_asr);
12983 opcode = narrow ? T_OPCODE_LSR_R : THUMB_OP32 (T_MNEM_lsr);
12986 opcode = narrow ? T_OPCODE_ROR_R : THUMB_OP32 (T_MNEM_ror);
12992 inst.instruction = opcode;
12995 inst.instruction |= Rn;
12996 inst.instruction |= inst.operands[1].imm << 3;
13001 inst.instruction |= CONDS_BIT;
13003 inst.instruction |= Rn << 8;
13004 inst.instruction |= Rm << 16;
13005 inst.instruction |= inst.operands[1].imm;
13010 /* Some mov with immediate shift have narrow variants.
13011 Register shifts are handled above. */
13012 if (low_regs && inst.operands[1].shifted
13013 && (inst.instruction == T_MNEM_mov
13014 || inst.instruction == T_MNEM_movs))
13016 if (in_pred_block ())
13017 narrow = (inst.instruction == T_MNEM_mov);
13019 narrow = (inst.instruction == T_MNEM_movs);
13024 switch (inst.operands[1].shift_kind)
13026 case SHIFT_LSL: inst.instruction = T_OPCODE_LSL_I; break;
13027 case SHIFT_LSR: inst.instruction = T_OPCODE_LSR_I; break;
13028 case SHIFT_ASR: inst.instruction = T_OPCODE_ASR_I; break;
13029 default: narrow = FALSE; break;
13035 inst.instruction |= Rn;
13036 inst.instruction |= Rm << 3;
13037 inst.relocs[0].type = BFD_RELOC_ARM_THUMB_SHIFT;
13041 inst.instruction = THUMB_OP32 (inst.instruction);
13042 inst.instruction |= Rn << r0off;
13043 encode_thumb32_shifted_operand (1);
13047 switch (inst.instruction)
13050 /* In v4t or v5t a move of two lowregs produces unpredictable
13051 results. Don't allow this. */
13054 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_v6),
13055 "MOV Rd, Rs with two low registers is not "
13056 "permitted on this architecture");
13057 ARM_MERGE_FEATURE_SETS (thumb_arch_used, thumb_arch_used,
13061 inst.instruction = T_OPCODE_MOV_HR;
13062 inst.instruction |= (Rn & 0x8) << 4;
13063 inst.instruction |= (Rn & 0x7);
13064 inst.instruction |= Rm << 3;
13068 /* We know we have low registers at this point.
13069 Generate LSLS Rd, Rs, #0. */
13070 inst.instruction = T_OPCODE_LSL_I;
13071 inst.instruction |= Rn;
13072 inst.instruction |= Rm << 3;
13078 inst.instruction = T_OPCODE_CMP_LR;
13079 inst.instruction |= Rn;
13080 inst.instruction |= Rm << 3;
13084 inst.instruction = T_OPCODE_CMP_HR;
13085 inst.instruction |= (Rn & 0x8) << 4;
13086 inst.instruction |= (Rn & 0x7);
13087 inst.instruction |= Rm << 3;
13094 inst.instruction = THUMB_OP16 (inst.instruction);
13096 /* PR 10443: Do not silently ignore shifted operands. */
13097 constraint (inst.operands[1].shifted,
13098 _("shifts in CMP/MOV instructions are only supported in unified syntax"));
13100 if (inst.operands[1].isreg)
13102 if (Rn < 8 && Rm < 8)
13104 /* A move of two lowregs is encoded as ADD Rd, Rs, #0
13105 since a MOV instruction produces unpredictable results. */
13106 if (inst.instruction == T_OPCODE_MOV_I8)
13107 inst.instruction = T_OPCODE_ADD_I3;
13109 inst.instruction = T_OPCODE_CMP_LR;
13111 inst.instruction |= Rn;
13112 inst.instruction |= Rm << 3;
13116 if (inst.instruction == T_OPCODE_MOV_I8)
13117 inst.instruction = T_OPCODE_MOV_HR;
13119 inst.instruction = T_OPCODE_CMP_HR;
13125 constraint (Rn > 7,
13126 _("only lo regs allowed with immediate"));
13127 inst.instruction |= Rn << 8;
13128 inst.relocs[0].type = BFD_RELOC_ARM_THUMB_IMM;
13139 top = (inst.instruction & 0x00800000) != 0;
13140 if (inst.relocs[0].type == BFD_RELOC_ARM_MOVW)
13142 constraint (top, _(":lower16: not allowed in this instruction"));
13143 inst.relocs[0].type = BFD_RELOC_ARM_THUMB_MOVW;
13145 else if (inst.relocs[0].type == BFD_RELOC_ARM_MOVT)
13147 constraint (!top, _(":upper16: not allowed in this instruction"));
13148 inst.relocs[0].type = BFD_RELOC_ARM_THUMB_MOVT;
13151 Rd = inst.operands[0].reg;
13152 reject_bad_reg (Rd);
13154 inst.instruction |= Rd << 8;
13155 if (inst.relocs[0].type == BFD_RELOC_UNUSED)
13157 imm = inst.relocs[0].exp.X_add_number;
13158 inst.instruction |= (imm & 0xf000) << 4;
13159 inst.instruction |= (imm & 0x0800) << 15;
13160 inst.instruction |= (imm & 0x0700) << 4;
13161 inst.instruction |= (imm & 0x00ff);
13166 do_t_mvn_tst (void)
13170 Rn = inst.operands[0].reg;
13171 Rm = inst.operands[1].reg;
13173 if (inst.instruction == T_MNEM_cmp
13174 || inst.instruction == T_MNEM_cmn)
13175 constraint (Rn == REG_PC, BAD_PC);
13177 reject_bad_reg (Rn);
13178 reject_bad_reg (Rm);
13180 if (unified_syntax)
13182 int r0off = (inst.instruction == T_MNEM_mvn
13183 || inst.instruction == T_MNEM_mvns) ? 8 : 16;
13184 bfd_boolean narrow;
13186 if (inst.size_req == 4
13187 || inst.instruction > 0xffff
13188 || inst.operands[1].shifted
13189 || Rn > 7 || Rm > 7)
13191 else if (inst.instruction == T_MNEM_cmn
13192 || inst.instruction == T_MNEM_tst)
13194 else if (THUMB_SETS_FLAGS (inst.instruction))
13195 narrow = !in_pred_block ();
13197 narrow = in_pred_block ();
13199 if (!inst.operands[1].isreg)
13201 /* For an immediate, we always generate a 32-bit opcode;
13202 section relaxation will shrink it later if possible. */
13203 if (inst.instruction < 0xffff)
13204 inst.instruction = THUMB_OP32 (inst.instruction);
13205 inst.instruction = (inst.instruction & 0xe1ffffff) | 0x10000000;
13206 inst.instruction |= Rn << r0off;
13207 inst.relocs[0].type = BFD_RELOC_ARM_T32_IMMEDIATE;
13211 /* See if we can do this with a 16-bit instruction. */
13214 inst.instruction = THUMB_OP16 (inst.instruction);
13215 inst.instruction |= Rn;
13216 inst.instruction |= Rm << 3;
13220 constraint (inst.operands[1].shifted
13221 && inst.operands[1].immisreg,
13222 _("shift must be constant"));
13223 if (inst.instruction < 0xffff)
13224 inst.instruction = THUMB_OP32 (inst.instruction);
13225 inst.instruction |= Rn << r0off;
13226 encode_thumb32_shifted_operand (1);
13232 constraint (inst.instruction > 0xffff
13233 || inst.instruction == T_MNEM_mvns, BAD_THUMB32);
13234 constraint (!inst.operands[1].isreg || inst.operands[1].shifted,
13235 _("unshifted register required"));
13236 constraint (Rn > 7 || Rm > 7,
13239 inst.instruction = THUMB_OP16 (inst.instruction);
13240 inst.instruction |= Rn;
13241 inst.instruction |= Rm << 3;
13250 if (do_vfp_nsyn_mrs () == SUCCESS)
13253 Rd = inst.operands[0].reg;
13254 reject_bad_reg (Rd);
13255 inst.instruction |= Rd << 8;
13257 if (inst.operands[1].isreg)
13259 unsigned br = inst.operands[1].reg;
13260 if (((br & 0x200) == 0) && ((br & 0xf000) != 0xf000))
13261 as_bad (_("bad register for mrs"));
13263 inst.instruction |= br & (0xf << 16);
13264 inst.instruction |= (br & 0x300) >> 4;
13265 inst.instruction |= (br & SPSR_BIT) >> 2;
13269 int flags = inst.operands[1].imm & (PSR_c|PSR_x|PSR_s|PSR_f|SPSR_BIT);
13271 if (ARM_CPU_HAS_FEATURE (selected_cpu, arm_ext_m))
13273 /* PR gas/12698: The constraint is only applied for m_profile.
13274 If the user has specified -march=all, we want to ignore it as
13275 we are building for any CPU type, including non-m variants. */
13276 bfd_boolean m_profile =
13277 !ARM_FEATURE_CORE_EQUAL (selected_cpu, arm_arch_any);
13278 constraint ((flags != 0) && m_profile, _("selected processor does "
13279 "not support requested special purpose register"));
13282 /* mrs only accepts APSR/CPSR/SPSR/CPSR_all/SPSR_all (for non-M profile
13284 constraint ((flags & ~SPSR_BIT) != (PSR_c|PSR_f),
13285 _("'APSR', 'CPSR' or 'SPSR' expected"));
13287 inst.instruction |= (flags & SPSR_BIT) >> 2;
13288 inst.instruction |= inst.operands[1].imm & 0xff;
13289 inst.instruction |= 0xf0000;
13299 if (do_vfp_nsyn_msr () == SUCCESS)
13302 constraint (!inst.operands[1].isreg,
13303 _("Thumb encoding does not support an immediate here"));
13305 if (inst.operands[0].isreg)
13306 flags = (int)(inst.operands[0].reg);
13308 flags = inst.operands[0].imm;
13310 if (ARM_CPU_HAS_FEATURE (selected_cpu, arm_ext_m))
13312 int bits = inst.operands[0].imm & (PSR_c|PSR_x|PSR_s|PSR_f|SPSR_BIT);
13314 /* PR gas/12698: The constraint is only applied for m_profile.
13315 If the user has specified -march=all, we want to ignore it as
13316 we are building for any CPU type, including non-m variants. */
13317 bfd_boolean m_profile =
13318 !ARM_FEATURE_CORE_EQUAL (selected_cpu, arm_arch_any);
13319 constraint (((ARM_CPU_HAS_FEATURE (selected_cpu, arm_ext_v6_dsp)
13320 && (bits & ~(PSR_s | PSR_f)) != 0)
13321 || (!ARM_CPU_HAS_FEATURE (selected_cpu, arm_ext_v6_dsp)
13322 && bits != PSR_f)) && m_profile,
13323 _("selected processor does not support requested special "
13324 "purpose register"));
13327 constraint ((flags & 0xff) != 0, _("selected processor does not support "
13328 "requested special purpose register"));
13330 Rn = inst.operands[1].reg;
13331 reject_bad_reg (Rn);
13333 inst.instruction |= (flags & SPSR_BIT) >> 2;
13334 inst.instruction |= (flags & 0xf0000) >> 8;
13335 inst.instruction |= (flags & 0x300) >> 4;
13336 inst.instruction |= (flags & 0xff);
13337 inst.instruction |= Rn << 16;
13343 bfd_boolean narrow;
13344 unsigned Rd, Rn, Rm;
13346 if (!inst.operands[2].present)
13347 inst.operands[2].reg = inst.operands[0].reg;
13349 Rd = inst.operands[0].reg;
13350 Rn = inst.operands[1].reg;
13351 Rm = inst.operands[2].reg;
13353 if (unified_syntax)
13355 if (inst.size_req == 4
13361 else if (inst.instruction == T_MNEM_muls)
13362 narrow = !in_pred_block ();
13364 narrow = in_pred_block ();
13368 constraint (inst.instruction == T_MNEM_muls, BAD_THUMB32);
13369 constraint (Rn > 7 || Rm > 7,
13376 /* 16-bit MULS/Conditional MUL. */
13377 inst.instruction = THUMB_OP16 (inst.instruction);
13378 inst.instruction |= Rd;
13381 inst.instruction |= Rm << 3;
13383 inst.instruction |= Rn << 3;
13385 constraint (1, _("dest must overlap one source register"));
13389 constraint (inst.instruction != T_MNEM_mul,
13390 _("Thumb-2 MUL must not set flags"));
13392 inst.instruction = THUMB_OP32 (inst.instruction);
13393 inst.instruction |= Rd << 8;
13394 inst.instruction |= Rn << 16;
13395 inst.instruction |= Rm << 0;
13397 reject_bad_reg (Rd);
13398 reject_bad_reg (Rn);
13399 reject_bad_reg (Rm);
13406 unsigned RdLo, RdHi, Rn, Rm;
13408 RdLo = inst.operands[0].reg;
13409 RdHi = inst.operands[1].reg;
13410 Rn = inst.operands[2].reg;
13411 Rm = inst.operands[3].reg;
13413 reject_bad_reg (RdLo);
13414 reject_bad_reg (RdHi);
13415 reject_bad_reg (Rn);
13416 reject_bad_reg (Rm);
13418 inst.instruction |= RdLo << 12;
13419 inst.instruction |= RdHi << 8;
13420 inst.instruction |= Rn << 16;
13421 inst.instruction |= Rm;
13424 as_tsktsk (_("rdhi and rdlo must be different"));
13430 set_pred_insn_type (NEUTRAL_IT_INSN);
13432 if (unified_syntax)
13434 if (inst.size_req == 4 || inst.operands[0].imm > 15)
13436 inst.instruction = THUMB_OP32 (inst.instruction);
13437 inst.instruction |= inst.operands[0].imm;
13441 /* PR9722: Check for Thumb2 availability before
13442 generating a thumb2 nop instruction. */
13443 if (ARM_CPU_HAS_FEATURE (selected_cpu, arm_ext_v6t2))
13445 inst.instruction = THUMB_OP16 (inst.instruction);
13446 inst.instruction |= inst.operands[0].imm << 4;
13449 inst.instruction = 0x46c0;
13454 constraint (inst.operands[0].present,
13455 _("Thumb does not support NOP with hints"));
13456 inst.instruction = 0x46c0;
13463 if (unified_syntax)
13465 bfd_boolean narrow;
13467 if (THUMB_SETS_FLAGS (inst.instruction))
13468 narrow = !in_pred_block ();
13470 narrow = in_pred_block ();
13471 if (inst.operands[0].reg > 7 || inst.operands[1].reg > 7)
13473 if (inst.size_req == 4)
13478 inst.instruction = THUMB_OP32 (inst.instruction);
13479 inst.instruction |= inst.operands[0].reg << 8;
13480 inst.instruction |= inst.operands[1].reg << 16;
13484 inst.instruction = THUMB_OP16 (inst.instruction);
13485 inst.instruction |= inst.operands[0].reg;
13486 inst.instruction |= inst.operands[1].reg << 3;
13491 constraint (inst.operands[0].reg > 7 || inst.operands[1].reg > 7,
13493 constraint (THUMB_SETS_FLAGS (inst.instruction), BAD_THUMB32);
13495 inst.instruction = THUMB_OP16 (inst.instruction);
13496 inst.instruction |= inst.operands[0].reg;
13497 inst.instruction |= inst.operands[1].reg << 3;
13506 Rd = inst.operands[0].reg;
13507 Rn = inst.operands[1].present ? inst.operands[1].reg : Rd;
13509 reject_bad_reg (Rd);
13510 /* Rn == REG_SP is unpredictable; Rn == REG_PC is MVN. */
13511 reject_bad_reg (Rn);
13513 inst.instruction |= Rd << 8;
13514 inst.instruction |= Rn << 16;
13516 if (!inst.operands[2].isreg)
13518 inst.instruction = (inst.instruction & 0xe1ffffff) | 0x10000000;
13519 inst.relocs[0].type = BFD_RELOC_ARM_T32_IMMEDIATE;
13525 Rm = inst.operands[2].reg;
13526 reject_bad_reg (Rm);
13528 constraint (inst.operands[2].shifted
13529 && inst.operands[2].immisreg,
13530 _("shift must be constant"));
13531 encode_thumb32_shifted_operand (2);
13538 unsigned Rd, Rn, Rm;
13540 Rd = inst.operands[0].reg;
13541 Rn = inst.operands[1].reg;
13542 Rm = inst.operands[2].reg;
13544 reject_bad_reg (Rd);
13545 reject_bad_reg (Rn);
13546 reject_bad_reg (Rm);
13548 inst.instruction |= Rd << 8;
13549 inst.instruction |= Rn << 16;
13550 inst.instruction |= Rm;
13551 if (inst.operands[3].present)
13553 unsigned int val = inst.relocs[0].exp.X_add_number;
13554 constraint (inst.relocs[0].exp.X_op != O_constant,
13555 _("expression too complex"));
13556 inst.instruction |= (val & 0x1c) << 10;
13557 inst.instruction |= (val & 0x03) << 6;
13564 if (!inst.operands[3].present)
13568 inst.instruction &= ~0x00000020;
13570 /* PR 10168. Swap the Rm and Rn registers. */
13571 Rtmp = inst.operands[1].reg;
13572 inst.operands[1].reg = inst.operands[2].reg;
13573 inst.operands[2].reg = Rtmp;
13581 if (inst.operands[0].immisreg)
13582 reject_bad_reg (inst.operands[0].imm);
13584 encode_thumb32_addr_mode (0, /*is_t=*/FALSE, /*is_d=*/FALSE);
13588 do_t_push_pop (void)
13592 constraint (inst.operands[0].writeback,
13593 _("push/pop do not support {reglist}^"));
13594 constraint (inst.relocs[0].type != BFD_RELOC_UNUSED,
13595 _("expression too complex"));
13597 mask = inst.operands[0].imm;
13598 if (inst.size_req != 4 && (mask & ~0xff) == 0)
13599 inst.instruction = THUMB_OP16 (inst.instruction) | mask;
13600 else if (inst.size_req != 4
13601 && (mask & ~0xff) == (1U << (inst.instruction == T_MNEM_push
13602 ? REG_LR : REG_PC)))
13604 inst.instruction = THUMB_OP16 (inst.instruction);
13605 inst.instruction |= THUMB_PP_PC_LR;
13606 inst.instruction |= mask & 0xff;
13608 else if (unified_syntax)
13610 inst.instruction = THUMB_OP32 (inst.instruction);
13611 encode_thumb2_multi (TRUE /* do_io */, 13, mask, TRUE);
13615 inst.error = _("invalid register list to push/pop instruction");
13623 if (unified_syntax)
13624 encode_thumb2_multi (FALSE /* do_io */, -1, inst.operands[0].imm, FALSE);
13627 inst.error = _("invalid register list to push/pop instruction");
13633 do_t_vscclrm (void)
13635 if (inst.operands[0].issingle)
13637 inst.instruction |= (inst.operands[0].reg & 0x1) << 22;
13638 inst.instruction |= (inst.operands[0].reg & 0x1e) << 11;
13639 inst.instruction |= inst.operands[0].imm;
13643 inst.instruction |= (inst.operands[0].reg & 0x10) << 18;
13644 inst.instruction |= (inst.operands[0].reg & 0xf) << 12;
13645 inst.instruction |= 1 << 8;
13646 inst.instruction |= inst.operands[0].imm << 1;
13655 Rd = inst.operands[0].reg;
13656 Rm = inst.operands[1].reg;
13658 reject_bad_reg (Rd);
13659 reject_bad_reg (Rm);
13661 inst.instruction |= Rd << 8;
13662 inst.instruction |= Rm << 16;
13663 inst.instruction |= Rm;
13671 Rd = inst.operands[0].reg;
13672 Rm = inst.operands[1].reg;
13674 reject_bad_reg (Rd);
13675 reject_bad_reg (Rm);
13677 if (Rd <= 7 && Rm <= 7
13678 && inst.size_req != 4)
13680 inst.instruction = THUMB_OP16 (inst.instruction);
13681 inst.instruction |= Rd;
13682 inst.instruction |= Rm << 3;
13684 else if (unified_syntax)
13686 inst.instruction = THUMB_OP32 (inst.instruction);
13687 inst.instruction |= Rd << 8;
13688 inst.instruction |= Rm << 16;
13689 inst.instruction |= Rm;
13692 inst.error = BAD_HIREG;
13700 Rd = inst.operands[0].reg;
13701 Rm = inst.operands[1].reg;
13703 reject_bad_reg (Rd);
13704 reject_bad_reg (Rm);
13706 inst.instruction |= Rd << 8;
13707 inst.instruction |= Rm;
13715 Rd = inst.operands[0].reg;
13716 Rs = (inst.operands[1].present
13717 ? inst.operands[1].reg /* Rd, Rs, foo */
13718 : inst.operands[0].reg); /* Rd, foo -> Rd, Rd, foo */
13720 reject_bad_reg (Rd);
13721 reject_bad_reg (Rs);
13722 if (inst.operands[2].isreg)
13723 reject_bad_reg (inst.operands[2].reg);
13725 inst.instruction |= Rd << 8;
13726 inst.instruction |= Rs << 16;
13727 if (!inst.operands[2].isreg)
13729 bfd_boolean narrow;
13731 if ((inst.instruction & 0x00100000) != 0)
13732 narrow = !in_pred_block ();
13734 narrow = in_pred_block ();
13736 if (Rd > 7 || Rs > 7)
13739 if (inst.size_req == 4 || !unified_syntax)
13742 if (inst.relocs[0].exp.X_op != O_constant
13743 || inst.relocs[0].exp.X_add_number != 0)
13746 /* Turn rsb #0 into 16-bit neg. We should probably do this via
13747 relaxation, but it doesn't seem worth the hassle. */
13750 inst.relocs[0].type = BFD_RELOC_UNUSED;
13751 inst.instruction = THUMB_OP16 (T_MNEM_negs);
13752 inst.instruction |= Rs << 3;
13753 inst.instruction |= Rd;
13757 inst.instruction = (inst.instruction & 0xe1ffffff) | 0x10000000;
13758 inst.relocs[0].type = BFD_RELOC_ARM_T32_IMMEDIATE;
13762 encode_thumb32_shifted_operand (2);
13768 if (warn_on_deprecated
13769 && ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_v8))
13770 as_tsktsk (_("setend use is deprecated for ARMv8"));
13772 set_pred_insn_type (OUTSIDE_PRED_INSN);
13773 if (inst.operands[0].imm)
13774 inst.instruction |= 0x8;
13780 if (!inst.operands[1].present)
13781 inst.operands[1].reg = inst.operands[0].reg;
13783 if (unified_syntax)
13785 bfd_boolean narrow;
13788 switch (inst.instruction)
13791 case T_MNEM_asrs: shift_kind = SHIFT_ASR; break;
13793 case T_MNEM_lsls: shift_kind = SHIFT_LSL; break;
13795 case T_MNEM_lsrs: shift_kind = SHIFT_LSR; break;
13797 case T_MNEM_rors: shift_kind = SHIFT_ROR; break;
13801 if (THUMB_SETS_FLAGS (inst.instruction))
13802 narrow = !in_pred_block ();
13804 narrow = in_pred_block ();
13805 if (inst.operands[0].reg > 7 || inst.operands[1].reg > 7)
13807 if (!inst.operands[2].isreg && shift_kind == SHIFT_ROR)
13809 if (inst.operands[2].isreg
13810 && (inst.operands[1].reg != inst.operands[0].reg
13811 || inst.operands[2].reg > 7))
13813 if (inst.size_req == 4)
13816 reject_bad_reg (inst.operands[0].reg);
13817 reject_bad_reg (inst.operands[1].reg);
13821 if (inst.operands[2].isreg)
13823 reject_bad_reg (inst.operands[2].reg);
13824 inst.instruction = THUMB_OP32 (inst.instruction);
13825 inst.instruction |= inst.operands[0].reg << 8;
13826 inst.instruction |= inst.operands[1].reg << 16;
13827 inst.instruction |= inst.operands[2].reg;
13829 /* PR 12854: Error on extraneous shifts. */
13830 constraint (inst.operands[2].shifted,
13831 _("extraneous shift as part of operand to shift insn"));
13835 inst.operands[1].shifted = 1;
13836 inst.operands[1].shift_kind = shift_kind;
13837 inst.instruction = THUMB_OP32 (THUMB_SETS_FLAGS (inst.instruction)
13838 ? T_MNEM_movs : T_MNEM_mov);
13839 inst.instruction |= inst.operands[0].reg << 8;
13840 encode_thumb32_shifted_operand (1);
13841 /* Prevent the incorrect generation of an ARM_IMMEDIATE fixup. */
13842 inst.relocs[0].type = BFD_RELOC_UNUSED;
13847 if (inst.operands[2].isreg)
13849 switch (shift_kind)
13851 case SHIFT_ASR: inst.instruction = T_OPCODE_ASR_R; break;
13852 case SHIFT_LSL: inst.instruction = T_OPCODE_LSL_R; break;
13853 case SHIFT_LSR: inst.instruction = T_OPCODE_LSR_R; break;
13854 case SHIFT_ROR: inst.instruction = T_OPCODE_ROR_R; break;
13858 inst.instruction |= inst.operands[0].reg;
13859 inst.instruction |= inst.operands[2].reg << 3;
13861 /* PR 12854: Error on extraneous shifts. */
13862 constraint (inst.operands[2].shifted,
13863 _("extraneous shift as part of operand to shift insn"));
13867 switch (shift_kind)
13869 case SHIFT_ASR: inst.instruction = T_OPCODE_ASR_I; break;
13870 case SHIFT_LSL: inst.instruction = T_OPCODE_LSL_I; break;
13871 case SHIFT_LSR: inst.instruction = T_OPCODE_LSR_I; break;
13874 inst.relocs[0].type = BFD_RELOC_ARM_THUMB_SHIFT;
13875 inst.instruction |= inst.operands[0].reg;
13876 inst.instruction |= inst.operands[1].reg << 3;
13882 constraint (inst.operands[0].reg > 7
13883 || inst.operands[1].reg > 7, BAD_HIREG);
13884 constraint (THUMB_SETS_FLAGS (inst.instruction), BAD_THUMB32);
13886 if (inst.operands[2].isreg) /* Rd, {Rs,} Rn */
13888 constraint (inst.operands[2].reg > 7, BAD_HIREG);
13889 constraint (inst.operands[0].reg != inst.operands[1].reg,
13890 _("source1 and dest must be same register"));
13892 switch (inst.instruction)
13894 case T_MNEM_asr: inst.instruction = T_OPCODE_ASR_R; break;
13895 case T_MNEM_lsl: inst.instruction = T_OPCODE_LSL_R; break;
13896 case T_MNEM_lsr: inst.instruction = T_OPCODE_LSR_R; break;
13897 case T_MNEM_ror: inst.instruction = T_OPCODE_ROR_R; break;
13901 inst.instruction |= inst.operands[0].reg;
13902 inst.instruction |= inst.operands[2].reg << 3;
13904 /* PR 12854: Error on extraneous shifts. */
13905 constraint (inst.operands[2].shifted,
13906 _("extraneous shift as part of operand to shift insn"));
13910 switch (inst.instruction)
13912 case T_MNEM_asr: inst.instruction = T_OPCODE_ASR_I; break;
13913 case T_MNEM_lsl: inst.instruction = T_OPCODE_LSL_I; break;
13914 case T_MNEM_lsr: inst.instruction = T_OPCODE_LSR_I; break;
13915 case T_MNEM_ror: inst.error = _("ror #imm not supported"); return;
13918 inst.relocs[0].type = BFD_RELOC_ARM_THUMB_SHIFT;
13919 inst.instruction |= inst.operands[0].reg;
13920 inst.instruction |= inst.operands[1].reg << 3;
13928 unsigned Rd, Rn, Rm;
13930 Rd = inst.operands[0].reg;
13931 Rn = inst.operands[1].reg;
13932 Rm = inst.operands[2].reg;
13934 reject_bad_reg (Rd);
13935 reject_bad_reg (Rn);
13936 reject_bad_reg (Rm);
13938 inst.instruction |= Rd << 8;
13939 inst.instruction |= Rn << 16;
13940 inst.instruction |= Rm;
13946 unsigned Rd, Rn, Rm;
13948 Rd = inst.operands[0].reg;
13949 Rm = inst.operands[1].reg;
13950 Rn = inst.operands[2].reg;
13952 reject_bad_reg (Rd);
13953 reject_bad_reg (Rn);
13954 reject_bad_reg (Rm);
13956 inst.instruction |= Rd << 8;
13957 inst.instruction |= Rn << 16;
13958 inst.instruction |= Rm;
13964 unsigned int value = inst.relocs[0].exp.X_add_number;
13965 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_v7a),
13966 _("SMC is not permitted on this architecture"));
13967 constraint (inst.relocs[0].exp.X_op != O_constant,
13968 _("expression too complex"));
13969 constraint (value > 0xf, _("immediate too large (bigger than 0xF)"));
13971 inst.relocs[0].type = BFD_RELOC_UNUSED;
13972 inst.instruction |= (value & 0x000f) << 16;
13974 /* PR gas/15623: SMC instructions must be last in an IT block. */
13975 set_pred_insn_type_last ();
13981 unsigned int value = inst.relocs[0].exp.X_add_number;
13983 inst.relocs[0].type = BFD_RELOC_UNUSED;
13984 inst.instruction |= (value & 0x0fff);
13985 inst.instruction |= (value & 0xf000) << 4;
13989 do_t_ssat_usat (int bias)
13993 Rd = inst.operands[0].reg;
13994 Rn = inst.operands[2].reg;
13996 reject_bad_reg (Rd);
13997 reject_bad_reg (Rn);
13999 inst.instruction |= Rd << 8;
14000 inst.instruction |= inst.operands[1].imm - bias;
14001 inst.instruction |= Rn << 16;
14003 if (inst.operands[3].present)
14005 offsetT shift_amount = inst.relocs[0].exp.X_add_number;
14007 inst.relocs[0].type = BFD_RELOC_UNUSED;
14009 constraint (inst.relocs[0].exp.X_op != O_constant,
14010 _("expression too complex"));
14012 if (shift_amount != 0)
14014 constraint (shift_amount > 31,
14015 _("shift expression is too large"));
14017 if (inst.operands[3].shift_kind == SHIFT_ASR)
14018 inst.instruction |= 0x00200000; /* sh bit. */
14020 inst.instruction |= (shift_amount & 0x1c) << 10;
14021 inst.instruction |= (shift_amount & 0x03) << 6;
14029 do_t_ssat_usat (1);
14037 Rd = inst.operands[0].reg;
14038 Rn = inst.operands[2].reg;
14040 reject_bad_reg (Rd);
14041 reject_bad_reg (Rn);
14043 inst.instruction |= Rd << 8;
14044 inst.instruction |= inst.operands[1].imm - 1;
14045 inst.instruction |= Rn << 16;
14051 constraint (!inst.operands[2].isreg || !inst.operands[2].preind
14052 || inst.operands[2].postind || inst.operands[2].writeback
14053 || inst.operands[2].immisreg || inst.operands[2].shifted
14054 || inst.operands[2].negative,
14057 constraint (inst.operands[2].reg == REG_PC, BAD_PC);
14059 inst.instruction |= inst.operands[0].reg << 8;
14060 inst.instruction |= inst.operands[1].reg << 12;
14061 inst.instruction |= inst.operands[2].reg << 16;
14062 inst.relocs[0].type = BFD_RELOC_ARM_T32_OFFSET_U8;
14068 if (!inst.operands[2].present)
14069 inst.operands[2].reg = inst.operands[1].reg + 1;
14071 constraint (inst.operands[0].reg == inst.operands[1].reg
14072 || inst.operands[0].reg == inst.operands[2].reg
14073 || inst.operands[0].reg == inst.operands[3].reg,
14076 inst.instruction |= inst.operands[0].reg;
14077 inst.instruction |= inst.operands[1].reg << 12;
14078 inst.instruction |= inst.operands[2].reg << 8;
14079 inst.instruction |= inst.operands[3].reg << 16;
14085 unsigned Rd, Rn, Rm;
14087 Rd = inst.operands[0].reg;
14088 Rn = inst.operands[1].reg;
14089 Rm = inst.operands[2].reg;
14091 reject_bad_reg (Rd);
14092 reject_bad_reg (Rn);
14093 reject_bad_reg (Rm);
14095 inst.instruction |= Rd << 8;
14096 inst.instruction |= Rn << 16;
14097 inst.instruction |= Rm;
14098 inst.instruction |= inst.operands[3].imm << 4;
14106 Rd = inst.operands[0].reg;
14107 Rm = inst.operands[1].reg;
14109 reject_bad_reg (Rd);
14110 reject_bad_reg (Rm);
14112 if (inst.instruction <= 0xffff
14113 && inst.size_req != 4
14114 && Rd <= 7 && Rm <= 7
14115 && (!inst.operands[2].present || inst.operands[2].imm == 0))
14117 inst.instruction = THUMB_OP16 (inst.instruction);
14118 inst.instruction |= Rd;
14119 inst.instruction |= Rm << 3;
14121 else if (unified_syntax)
14123 if (inst.instruction <= 0xffff)
14124 inst.instruction = THUMB_OP32 (inst.instruction);
14125 inst.instruction |= Rd << 8;
14126 inst.instruction |= Rm;
14127 inst.instruction |= inst.operands[2].imm << 4;
14131 constraint (inst.operands[2].present && inst.operands[2].imm != 0,
14132 _("Thumb encoding does not support rotation"));
14133 constraint (1, BAD_HIREG);
14140 inst.relocs[0].type = BFD_RELOC_ARM_SWI;
14149 half = (inst.instruction & 0x10) != 0;
14150 set_pred_insn_type_last ();
14151 constraint (inst.operands[0].immisreg,
14152 _("instruction requires register index"));
14154 Rn = inst.operands[0].reg;
14155 Rm = inst.operands[0].imm;
14157 if (!ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_v8))
14158 constraint (Rn == REG_SP, BAD_SP);
14159 reject_bad_reg (Rm);
14161 constraint (!half && inst.operands[0].shifted,
14162 _("instruction does not allow shifted index"));
14163 inst.instruction |= (Rn << 16) | Rm;
14169 if (!inst.operands[0].present)
14170 inst.operands[0].imm = 0;
14172 if ((unsigned int) inst.operands[0].imm > 255 || inst.size_req == 4)
14174 constraint (inst.size_req == 2,
14175 _("immediate value out of range"));
14176 inst.instruction = THUMB_OP32 (inst.instruction);
14177 inst.instruction |= (inst.operands[0].imm & 0xf000u) << 4;
14178 inst.instruction |= (inst.operands[0].imm & 0x0fffu) << 0;
14182 inst.instruction = THUMB_OP16 (inst.instruction);
14183 inst.instruction |= inst.operands[0].imm;
14186 set_pred_insn_type (NEUTRAL_IT_INSN);
14193 do_t_ssat_usat (0);
14201 Rd = inst.operands[0].reg;
14202 Rn = inst.operands[2].reg;
14204 reject_bad_reg (Rd);
14205 reject_bad_reg (Rn);
14207 inst.instruction |= Rd << 8;
14208 inst.instruction |= inst.operands[1].imm;
14209 inst.instruction |= Rn << 16;
14212 /* Checking the range of the branch offset (VAL) with NBITS bits
14213 and IS_SIGNED signedness. Also checks the LSB to be 0. */
14215 v8_1_branch_value_check (int val, int nbits, int is_signed)
14217 gas_assert (nbits > 0 && nbits <= 32);
14220 int cmp = (1 << (nbits - 1));
14221 if ((val < -cmp) || (val >= cmp) || (val & 0x01))
14226 if ((val <= 0) || (val >= (1 << nbits)) || (val & 0x1))
14232 /* For branches in Armv8.1-M Mainline. */
14234 do_t_branch_future (void)
14236 unsigned long insn = inst.instruction;
14238 inst.instruction = THUMB_OP32 (inst.instruction);
14239 if (inst.operands[0].hasreloc == 0)
14241 if (v8_1_branch_value_check (inst.operands[0].imm, 5, FALSE) == FAIL)
14242 as_bad (BAD_BRANCH_OFF);
14244 inst.instruction |= ((inst.operands[0].imm & 0x1f) >> 1) << 23;
14248 inst.relocs[0].type = BFD_RELOC_THUMB_PCREL_BRANCH5;
14249 inst.relocs[0].pc_rel = 1;
14255 if (inst.operands[1].hasreloc == 0)
14257 int val = inst.operands[1].imm;
14258 if (v8_1_branch_value_check (inst.operands[1].imm, 17, TRUE) == FAIL)
14259 as_bad (BAD_BRANCH_OFF);
14261 int immA = (val & 0x0001f000) >> 12;
14262 int immB = (val & 0x00000ffc) >> 2;
14263 int immC = (val & 0x00000002) >> 1;
14264 inst.instruction |= (immA << 16) | (immB << 1) | (immC << 11);
14268 inst.relocs[1].type = BFD_RELOC_ARM_THUMB_BF17;
14269 inst.relocs[1].pc_rel = 1;
14274 if (inst.operands[1].hasreloc == 0)
14276 int val = inst.operands[1].imm;
14277 if (v8_1_branch_value_check (inst.operands[1].imm, 19, TRUE) == FAIL)
14278 as_bad (BAD_BRANCH_OFF);
14280 int immA = (val & 0x0007f000) >> 12;
14281 int immB = (val & 0x00000ffc) >> 2;
14282 int immC = (val & 0x00000002) >> 1;
14283 inst.instruction |= (immA << 16) | (immB << 1) | (immC << 11);
14287 inst.relocs[1].type = BFD_RELOC_ARM_THUMB_BF19;
14288 inst.relocs[1].pc_rel = 1;
14292 case T_MNEM_bfcsel:
14294 if (inst.operands[1].hasreloc == 0)
14296 int val = inst.operands[1].imm;
14297 int immA = (val & 0x00001000) >> 12;
14298 int immB = (val & 0x00000ffc) >> 2;
14299 int immC = (val & 0x00000002) >> 1;
14300 inst.instruction |= (immA << 16) | (immB << 1) | (immC << 11);
14304 inst.relocs[1].type = BFD_RELOC_ARM_THUMB_BF13;
14305 inst.relocs[1].pc_rel = 1;
14309 if (inst.operands[2].hasreloc == 0)
14311 constraint ((inst.operands[0].hasreloc != 0), BAD_ARGS);
14312 int val2 = inst.operands[2].imm;
14313 int val0 = inst.operands[0].imm & 0x1f;
14314 int diff = val2 - val0;
14316 inst.instruction |= 1 << 17; /* T bit. */
14317 else if (diff != 2)
14318 as_bad (_("out of range label-relative fixup value"));
14322 constraint ((inst.operands[0].hasreloc == 0), BAD_ARGS);
14323 inst.relocs[2].type = BFD_RELOC_THUMB_PCREL_BFCSEL;
14324 inst.relocs[2].pc_rel = 1;
14328 constraint (inst.cond != COND_ALWAYS, BAD_COND);
14329 inst.instruction |= (inst.operands[3].imm & 0xf) << 18;
14334 inst.instruction |= inst.operands[1].reg << 16;
14341 /* Helper function for do_t_loloop to handle relocations. */
14343 v8_1_loop_reloc (int is_le)
14345 if (inst.relocs[0].exp.X_op == O_constant)
14347 int value = inst.relocs[0].exp.X_add_number;
14348 value = (is_le) ? -value : value;
14350 if (v8_1_branch_value_check (value, 12, FALSE) == FAIL)
14351 as_bad (BAD_BRANCH_OFF);
14355 immh = (value & 0x00000ffc) >> 2;
14356 imml = (value & 0x00000002) >> 1;
14358 inst.instruction |= (imml << 11) | (immh << 1);
14362 inst.relocs[0].type = BFD_RELOC_ARM_THUMB_LOOP12;
14363 inst.relocs[0].pc_rel = 1;
14367 /* For shifts with four operands in MVE. */
14369 do_mve_scalar_shift1 (void)
14371 unsigned int value = inst.operands[2].imm;
14373 inst.instruction |= inst.operands[0].reg << 16;
14374 inst.instruction |= inst.operands[1].reg << 8;
14376 /* Setting the bit for saturation. */
14377 inst.instruction |= ((value == 64) ? 0: 1) << 7;
14379 /* Assuming Rm is already checked not to be 11x1. */
14380 constraint (inst.operands[3].reg == inst.operands[0].reg, BAD_OVERLAP);
14381 constraint (inst.operands[3].reg == inst.operands[1].reg, BAD_OVERLAP);
14382 inst.instruction |= inst.operands[3].reg << 12;
14385 /* For shifts in MVE. */
14387 do_mve_scalar_shift (void)
14389 if (!inst.operands[2].present)
14391 inst.operands[2] = inst.operands[1];
14392 inst.operands[1].reg = 0xf;
14395 inst.instruction |= inst.operands[0].reg << 16;
14396 inst.instruction |= inst.operands[1].reg << 8;
14398 if (inst.operands[2].isreg)
14400 /* Assuming Rm is already checked not to be 11x1. */
14401 constraint (inst.operands[2].reg == inst.operands[0].reg, BAD_OVERLAP);
14402 constraint (inst.operands[2].reg == inst.operands[1].reg, BAD_OVERLAP);
14403 inst.instruction |= inst.operands[2].reg << 12;
14407 /* Assuming imm is already checked as [1,32]. */
14408 unsigned int value = inst.operands[2].imm;
14409 inst.instruction |= (value & 0x1c) << 10;
14410 inst.instruction |= (value & 0x03) << 6;
14411 /* Change last 4 bits from 0xd to 0xf. */
14412 inst.instruction |= 0x2;
14416 /* MVE instruction encoder helpers. */
14417 #define M_MNEM_vabav 0xee800f01
14418 #define M_MNEM_vmladav 0xeef00e00
14419 #define M_MNEM_vmladava 0xeef00e20
14420 #define M_MNEM_vmladavx 0xeef01e00
14421 #define M_MNEM_vmladavax 0xeef01e20
14422 #define M_MNEM_vmlsdav 0xeef00e01
14423 #define M_MNEM_vmlsdava 0xeef00e21
14424 #define M_MNEM_vmlsdavx 0xeef01e01
14425 #define M_MNEM_vmlsdavax 0xeef01e21
14426 #define M_MNEM_vmullt 0xee011e00
14427 #define M_MNEM_vmullb 0xee010e00
14428 #define M_MNEM_vctp 0xf000e801
14429 #define M_MNEM_vst20 0xfc801e00
14430 #define M_MNEM_vst21 0xfc801e20
14431 #define M_MNEM_vst40 0xfc801e01
14432 #define M_MNEM_vst41 0xfc801e21
14433 #define M_MNEM_vst42 0xfc801e41
14434 #define M_MNEM_vst43 0xfc801e61
14435 #define M_MNEM_vld20 0xfc901e00
14436 #define M_MNEM_vld21 0xfc901e20
14437 #define M_MNEM_vld40 0xfc901e01
14438 #define M_MNEM_vld41 0xfc901e21
14439 #define M_MNEM_vld42 0xfc901e41
14440 #define M_MNEM_vld43 0xfc901e61
14441 #define M_MNEM_vstrb 0xec000e00
14442 #define M_MNEM_vstrh 0xec000e10
14443 #define M_MNEM_vstrw 0xec000e40
14444 #define M_MNEM_vstrd 0xec000e50
14445 #define M_MNEM_vldrb 0xec100e00
14446 #define M_MNEM_vldrh 0xec100e10
14447 #define M_MNEM_vldrw 0xec100e40
14448 #define M_MNEM_vldrd 0xec100e50
14449 #define M_MNEM_vmovlt 0xeea01f40
14450 #define M_MNEM_vmovlb 0xeea00f40
14451 #define M_MNEM_vmovnt 0xfe311e81
14452 #define M_MNEM_vmovnb 0xfe310e81
14453 #define M_MNEM_vadc 0xee300f00
14454 #define M_MNEM_vadci 0xee301f00
14455 #define M_MNEM_vbrsr 0xfe011e60
14456 #define M_MNEM_vaddlv 0xee890f00
14457 #define M_MNEM_vaddlva 0xee890f20
14458 #define M_MNEM_vaddv 0xeef10f00
14459 #define M_MNEM_vaddva 0xeef10f20
14460 #define M_MNEM_vddup 0xee011f6e
14461 #define M_MNEM_vdwdup 0xee011f60
14462 #define M_MNEM_vidup 0xee010f6e
14463 #define M_MNEM_viwdup 0xee010f60
14464 #define M_MNEM_vmaxv 0xeee20f00
14465 #define M_MNEM_vmaxav 0xeee00f00
14466 #define M_MNEM_vminv 0xeee20f80
14467 #define M_MNEM_vminav 0xeee00f80
14468 #define M_MNEM_vmlaldav 0xee800e00
14469 #define M_MNEM_vmlaldava 0xee800e20
14470 #define M_MNEM_vmlaldavx 0xee801e00
14471 #define M_MNEM_vmlaldavax 0xee801e20
14472 #define M_MNEM_vmlsldav 0xee800e01
14473 #define M_MNEM_vmlsldava 0xee800e21
14474 #define M_MNEM_vmlsldavx 0xee801e01
14475 #define M_MNEM_vmlsldavax 0xee801e21
14476 #define M_MNEM_vrmlaldavhx 0xee801f00
14477 #define M_MNEM_vrmlaldavhax 0xee801f20
14478 #define M_MNEM_vrmlsldavh 0xfe800e01
14479 #define M_MNEM_vrmlsldavha 0xfe800e21
14480 #define M_MNEM_vrmlsldavhx 0xfe801e01
14481 #define M_MNEM_vrmlsldavhax 0xfe801e21
14482 #define M_MNEM_vqmovnt 0xee331e01
14483 #define M_MNEM_vqmovnb 0xee330e01
14484 #define M_MNEM_vqmovunt 0xee311e81
14485 #define M_MNEM_vqmovunb 0xee310e81
14486 #define M_MNEM_vshrnt 0xee801fc1
14487 #define M_MNEM_vshrnb 0xee800fc1
14488 #define M_MNEM_vrshrnt 0xfe801fc1
14489 #define M_MNEM_vqshrnt 0xee801f40
14490 #define M_MNEM_vqshrnb 0xee800f40
14491 #define M_MNEM_vqshrunt 0xee801fc0
14492 #define M_MNEM_vqshrunb 0xee800fc0
14493 #define M_MNEM_vrshrnb 0xfe800fc1
14494 #define M_MNEM_vqrshrnt 0xee801f41
14495 #define M_MNEM_vqrshrnb 0xee800f41
14496 #define M_MNEM_vqrshrunt 0xfe801fc0
14497 #define M_MNEM_vqrshrunb 0xfe800fc0
14499 /* Neon instruction encoder helpers. */
14501 /* Encodings for the different types for various Neon opcodes. */
14503 /* An "invalid" code for the following tables. */
14506 struct neon_tab_entry
14509 unsigned float_or_poly;
14510 unsigned scalar_or_imm;
14513 /* Map overloaded Neon opcodes to their respective encodings. */
14514 #define NEON_ENC_TAB \
14515 X(vabd, 0x0000700, 0x1200d00, N_INV), \
14516 X(vabdl, 0x0800700, N_INV, N_INV), \
14517 X(vmax, 0x0000600, 0x0000f00, N_INV), \
14518 X(vmin, 0x0000610, 0x0200f00, N_INV), \
14519 X(vpadd, 0x0000b10, 0x1000d00, N_INV), \
14520 X(vpmax, 0x0000a00, 0x1000f00, N_INV), \
14521 X(vpmin, 0x0000a10, 0x1200f00, N_INV), \
14522 X(vadd, 0x0000800, 0x0000d00, N_INV), \
14523 X(vaddl, 0x0800000, N_INV, N_INV), \
14524 X(vsub, 0x1000800, 0x0200d00, N_INV), \
14525 X(vsubl, 0x0800200, N_INV, N_INV), \
14526 X(vceq, 0x1000810, 0x0000e00, 0x1b10100), \
14527 X(vcge, 0x0000310, 0x1000e00, 0x1b10080), \
14528 X(vcgt, 0x0000300, 0x1200e00, 0x1b10000), \
14529 /* Register variants of the following two instructions are encoded as
14530 vcge / vcgt with the operands reversed. */ \
14531 X(vclt, 0x0000300, 0x1200e00, 0x1b10200), \
14532 X(vcle, 0x0000310, 0x1000e00, 0x1b10180), \
14533 X(vfma, N_INV, 0x0000c10, N_INV), \
14534 X(vfms, N_INV, 0x0200c10, N_INV), \
14535 X(vmla, 0x0000900, 0x0000d10, 0x0800040), \
14536 X(vmls, 0x1000900, 0x0200d10, 0x0800440), \
14537 X(vmul, 0x0000910, 0x1000d10, 0x0800840), \
14538 X(vmull, 0x0800c00, 0x0800e00, 0x0800a40), /* polynomial not float. */ \
14539 X(vmlal, 0x0800800, N_INV, 0x0800240), \
14540 X(vmlsl, 0x0800a00, N_INV, 0x0800640), \
14541 X(vqdmlal, 0x0800900, N_INV, 0x0800340), \
14542 X(vqdmlsl, 0x0800b00, N_INV, 0x0800740), \
14543 X(vqdmull, 0x0800d00, N_INV, 0x0800b40), \
14544 X(vqdmulh, 0x0000b00, N_INV, 0x0800c40), \
14545 X(vqrdmulh, 0x1000b00, N_INV, 0x0800d40), \
14546 X(vqrdmlah, 0x3000b10, N_INV, 0x0800e40), \
14547 X(vqrdmlsh, 0x3000c10, N_INV, 0x0800f40), \
14548 X(vshl, 0x0000400, N_INV, 0x0800510), \
14549 X(vqshl, 0x0000410, N_INV, 0x0800710), \
14550 X(vand, 0x0000110, N_INV, 0x0800030), \
14551 X(vbic, 0x0100110, N_INV, 0x0800030), \
14552 X(veor, 0x1000110, N_INV, N_INV), \
14553 X(vorn, 0x0300110, N_INV, 0x0800010), \
14554 X(vorr, 0x0200110, N_INV, 0x0800010), \
14555 X(vmvn, 0x1b00580, N_INV, 0x0800030), \
14556 X(vshll, 0x1b20300, N_INV, 0x0800a10), /* max shift, immediate. */ \
14557 X(vcvt, 0x1b30600, N_INV, 0x0800e10), /* integer, fixed-point. */ \
14558 X(vdup, 0xe800b10, N_INV, 0x1b00c00), /* arm, scalar. */ \
14559 X(vld1, 0x0200000, 0x0a00000, 0x0a00c00), /* interlv, lane, dup. */ \
14560 X(vst1, 0x0000000, 0x0800000, N_INV), \
14561 X(vld2, 0x0200100, 0x0a00100, 0x0a00d00), \
14562 X(vst2, 0x0000100, 0x0800100, N_INV), \
14563 X(vld3, 0x0200200, 0x0a00200, 0x0a00e00), \
14564 X(vst3, 0x0000200, 0x0800200, N_INV), \
14565 X(vld4, 0x0200300, 0x0a00300, 0x0a00f00), \
14566 X(vst4, 0x0000300, 0x0800300, N_INV), \
14567 X(vmovn, 0x1b20200, N_INV, N_INV), \
14568 X(vtrn, 0x1b20080, N_INV, N_INV), \
14569 X(vqmovn, 0x1b20200, N_INV, N_INV), \
14570 X(vqmovun, 0x1b20240, N_INV, N_INV), \
14571 X(vnmul, 0xe200a40, 0xe200b40, N_INV), \
14572 X(vnmla, 0xe100a40, 0xe100b40, N_INV), \
14573 X(vnmls, 0xe100a00, 0xe100b00, N_INV), \
14574 X(vfnma, 0xe900a40, 0xe900b40, N_INV), \
14575 X(vfnms, 0xe900a00, 0xe900b00, N_INV), \
14576 X(vcmp, 0xeb40a40, 0xeb40b40, N_INV), \
14577 X(vcmpz, 0xeb50a40, 0xeb50b40, N_INV), \
14578 X(vcmpe, 0xeb40ac0, 0xeb40bc0, N_INV), \
14579 X(vcmpez, 0xeb50ac0, 0xeb50bc0, N_INV), \
14580 X(vseleq, 0xe000a00, N_INV, N_INV), \
14581 X(vselvs, 0xe100a00, N_INV, N_INV), \
14582 X(vselge, 0xe200a00, N_INV, N_INV), \
14583 X(vselgt, 0xe300a00, N_INV, N_INV), \
14584 X(vmaxnm, 0xe800a00, 0x3000f10, N_INV), \
14585 X(vminnm, 0xe800a40, 0x3200f10, N_INV), \
14586 X(vcvta, 0xebc0a40, 0x3bb0000, N_INV), \
14587 X(vrintr, 0xeb60a40, 0x3ba0400, N_INV), \
14588 X(vrinta, 0xeb80a40, 0x3ba0400, N_INV), \
14589 X(aes, 0x3b00300, N_INV, N_INV), \
14590 X(sha3op, 0x2000c00, N_INV, N_INV), \
14591 X(sha1h, 0x3b902c0, N_INV, N_INV), \
14592 X(sha2op, 0x3ba0380, N_INV, N_INV)
14596 #define X(OPC,I,F,S) N_MNEM_##OPC
14601 static const struct neon_tab_entry neon_enc_tab[] =
14603 #define X(OPC,I,F,S) { (I), (F), (S) }
14608 /* Do not use these macros; instead, use NEON_ENCODE defined below. */
14609 #define NEON_ENC_INTEGER_(X) (neon_enc_tab[(X) & 0x0fffffff].integer)
14610 #define NEON_ENC_ARMREG_(X) (neon_enc_tab[(X) & 0x0fffffff].integer)
14611 #define NEON_ENC_POLY_(X) (neon_enc_tab[(X) & 0x0fffffff].float_or_poly)
14612 #define NEON_ENC_FLOAT_(X) (neon_enc_tab[(X) & 0x0fffffff].float_or_poly)
14613 #define NEON_ENC_SCALAR_(X) (neon_enc_tab[(X) & 0x0fffffff].scalar_or_imm)
14614 #define NEON_ENC_IMMED_(X) (neon_enc_tab[(X) & 0x0fffffff].scalar_or_imm)
14615 #define NEON_ENC_INTERLV_(X) (neon_enc_tab[(X) & 0x0fffffff].integer)
14616 #define NEON_ENC_LANE_(X) (neon_enc_tab[(X) & 0x0fffffff].float_or_poly)
14617 #define NEON_ENC_DUP_(X) (neon_enc_tab[(X) & 0x0fffffff].scalar_or_imm)
14618 #define NEON_ENC_SINGLE_(X) \
14619 ((neon_enc_tab[(X) & 0x0fffffff].integer) | ((X) & 0xf0000000))
14620 #define NEON_ENC_DOUBLE_(X) \
14621 ((neon_enc_tab[(X) & 0x0fffffff].float_or_poly) | ((X) & 0xf0000000))
14622 #define NEON_ENC_FPV8_(X) \
14623 ((neon_enc_tab[(X) & 0x0fffffff].integer) | ((X) & 0xf000000))
14625 #define NEON_ENCODE(type, inst) \
14628 inst.instruction = NEON_ENC_##type##_ (inst.instruction); \
14629 inst.is_neon = 1; \
14633 #define check_neon_suffixes \
14636 if (!inst.error && inst.vectype.elems > 0 && !inst.is_neon) \
14638 as_bad (_("invalid neon suffix for non neon instruction")); \
14644 /* Define shapes for instruction operands. The following mnemonic characters
14645 are used in this table:
14647 F - VFP S<n> register
14648 D - Neon D<n> register
14649 Q - Neon Q<n> register
14653 L - D<n> register list
14655 This table is used to generate various data:
14656 - enumerations of the form NS_DDR to be used as arguments to
14658 - a table classifying shapes into single, double, quad, mixed.
14659 - a table used to drive neon_select_shape. */
14661 #define NEON_SHAPE_DEF \
14662 X(4, (R, R, Q, Q), QUAD), \
14663 X(4, (Q, R, R, I), QUAD), \
14664 X(4, (R, R, S, S), QUAD), \
14665 X(4, (S, S, R, R), QUAD), \
14666 X(3, (Q, R, I), QUAD), \
14667 X(3, (I, Q, Q), QUAD), \
14668 X(3, (I, Q, R), QUAD), \
14669 X(3, (R, Q, Q), QUAD), \
14670 X(3, (D, D, D), DOUBLE), \
14671 X(3, (Q, Q, Q), QUAD), \
14672 X(3, (D, D, I), DOUBLE), \
14673 X(3, (Q, Q, I), QUAD), \
14674 X(3, (D, D, S), DOUBLE), \
14675 X(3, (Q, Q, S), QUAD), \
14676 X(3, (Q, Q, R), QUAD), \
14677 X(3, (R, R, Q), QUAD), \
14678 X(2, (R, Q), QUAD), \
14679 X(2, (D, D), DOUBLE), \
14680 X(2, (Q, Q), QUAD), \
14681 X(2, (D, S), DOUBLE), \
14682 X(2, (Q, S), QUAD), \
14683 X(2, (D, R), DOUBLE), \
14684 X(2, (Q, R), QUAD), \
14685 X(2, (D, I), DOUBLE), \
14686 X(2, (Q, I), QUAD), \
14687 X(3, (D, L, D), DOUBLE), \
14688 X(2, (D, Q), MIXED), \
14689 X(2, (Q, D), MIXED), \
14690 X(3, (D, Q, I), MIXED), \
14691 X(3, (Q, D, I), MIXED), \
14692 X(3, (Q, D, D), MIXED), \
14693 X(3, (D, Q, Q), MIXED), \
14694 X(3, (Q, Q, D), MIXED), \
14695 X(3, (Q, D, S), MIXED), \
14696 X(3, (D, Q, S), MIXED), \
14697 X(4, (D, D, D, I), DOUBLE), \
14698 X(4, (Q, Q, Q, I), QUAD), \
14699 X(4, (D, D, S, I), DOUBLE), \
14700 X(4, (Q, Q, S, I), QUAD), \
14701 X(2, (F, F), SINGLE), \
14702 X(3, (F, F, F), SINGLE), \
14703 X(2, (F, I), SINGLE), \
14704 X(2, (F, D), MIXED), \
14705 X(2, (D, F), MIXED), \
14706 X(3, (F, F, I), MIXED), \
14707 X(4, (R, R, F, F), SINGLE), \
14708 X(4, (F, F, R, R), SINGLE), \
14709 X(3, (D, R, R), DOUBLE), \
14710 X(3, (R, R, D), DOUBLE), \
14711 X(2, (S, R), SINGLE), \
14712 X(2, (R, S), SINGLE), \
14713 X(2, (F, R), SINGLE), \
14714 X(2, (R, F), SINGLE), \
14715 /* Used for MVE tail predicated loop instructions. */\
14716 X(2, (R, R), QUAD), \
14717 /* Half float shape supported so far. */\
14718 X (2, (H, D), MIXED), \
14719 X (2, (D, H), MIXED), \
14720 X (2, (H, F), MIXED), \
14721 X (2, (F, H), MIXED), \
14722 X (2, (H, H), HALF), \
14723 X (2, (H, R), HALF), \
14724 X (2, (R, H), HALF), \
14725 X (2, (H, I), HALF), \
14726 X (3, (H, H, H), HALF), \
14727 X (3, (H, F, I), MIXED), \
14728 X (3, (F, H, I), MIXED), \
14729 X (3, (D, H, H), MIXED), \
14730 X (3, (D, H, S), MIXED)
14732 #define S2(A,B) NS_##A##B
14733 #define S3(A,B,C) NS_##A##B##C
14734 #define S4(A,B,C,D) NS_##A##B##C##D
14736 #define X(N, L, C) S##N L
14749 enum neon_shape_class
14758 #define X(N, L, C) SC_##C
14760 static enum neon_shape_class neon_shape_class[] =
14779 /* Register widths of above. */
14780 static unsigned neon_shape_el_size[] =
14792 struct neon_shape_info
14795 enum neon_shape_el el[NEON_MAX_TYPE_ELS];
14798 #define S2(A,B) { SE_##A, SE_##B }
14799 #define S3(A,B,C) { SE_##A, SE_##B, SE_##C }
14800 #define S4(A,B,C,D) { SE_##A, SE_##B, SE_##C, SE_##D }
14802 #define X(N, L, C) { N, S##N L }
14804 static struct neon_shape_info neon_shape_tab[] =
14814 /* Bit masks used in type checking given instructions.
14815 'N_EQK' means the type must be the same as (or based on in some way) the key
14816 type, which itself is marked with the 'N_KEY' bit. If the 'N_EQK' bit is
14817 set, various other bits can be set as well in order to modify the meaning of
14818 the type constraint. */
14820 enum neon_type_mask
14844 N_KEY = 0x1000000, /* Key element (main type specifier). */
14845 N_EQK = 0x2000000, /* Given operand has the same type & size as the key. */
14846 N_VFP = 0x4000000, /* VFP mode: operand size must match register width. */
14847 N_UNT = 0x8000000, /* Must be explicitly untyped. */
14848 N_DBL = 0x0000001, /* If N_EQK, this operand is twice the size. */
14849 N_HLF = 0x0000002, /* If N_EQK, this operand is half the size. */
14850 N_SGN = 0x0000004, /* If N_EQK, this operand is forced to be signed. */
14851 N_UNS = 0x0000008, /* If N_EQK, this operand is forced to be unsigned. */
14852 N_INT = 0x0000010, /* If N_EQK, this operand is forced to be integer. */
14853 N_FLT = 0x0000020, /* If N_EQK, this operand is forced to be float. */
14854 N_SIZ = 0x0000040, /* If N_EQK, this operand is forced to be size-only. */
14856 N_MAX_NONSPECIAL = N_P64
14859 #define N_ALLMODS (N_DBL | N_HLF | N_SGN | N_UNS | N_INT | N_FLT | N_SIZ)
14861 #define N_SU_ALL (N_S8 | N_S16 | N_S32 | N_S64 | N_U8 | N_U16 | N_U32 | N_U64)
14862 #define N_SU_32 (N_S8 | N_S16 | N_S32 | N_U8 | N_U16 | N_U32)
14863 #define N_SU_16_64 (N_S16 | N_S32 | N_S64 | N_U16 | N_U32 | N_U64)
14864 #define N_S_32 (N_S8 | N_S16 | N_S32)
14865 #define N_F_16_32 (N_F16 | N_F32)
14866 #define N_SUF_32 (N_SU_32 | N_F_16_32)
14867 #define N_I_ALL (N_I8 | N_I16 | N_I32 | N_I64)
14868 #define N_IF_32 (N_I8 | N_I16 | N_I32 | N_F16 | N_F32)
14869 #define N_F_ALL (N_F16 | N_F32 | N_F64)
14870 #define N_I_MVE (N_I8 | N_I16 | N_I32)
14871 #define N_F_MVE (N_F16 | N_F32)
14872 #define N_SU_MVE (N_S8 | N_S16 | N_S32 | N_U8 | N_U16 | N_U32)
14874 /* Pass this as the first type argument to neon_check_type to ignore types
14876 #define N_IGNORE_TYPE (N_KEY | N_EQK)
14878 /* Select a "shape" for the current instruction (describing register types or
14879 sizes) from a list of alternatives. Return NS_NULL if the current instruction
14880 doesn't fit. For non-polymorphic shapes, checking is usually done as a
14881 function of operand parsing, so this function doesn't need to be called.
14882 Shapes should be listed in order of decreasing length. */
14884 static enum neon_shape
14885 neon_select_shape (enum neon_shape shape, ...)
14888 enum neon_shape first_shape = shape;
14890 /* Fix missing optional operands. FIXME: we don't know at this point how
14891 many arguments we should have, so this makes the assumption that we have
14892 > 1. This is true of all current Neon opcodes, I think, but may not be
14893 true in the future. */
14894 if (!inst.operands[1].present)
14895 inst.operands[1] = inst.operands[0];
14897 va_start (ap, shape);
14899 for (; shape != NS_NULL; shape = (enum neon_shape) va_arg (ap, int))
14904 for (j = 0; j < neon_shape_tab[shape].els; j++)
14906 if (!inst.operands[j].present)
14912 switch (neon_shape_tab[shape].el[j])
14914 /* If a .f16, .16, .u16, .s16 type specifier is given over
14915 a VFP single precision register operand, it's essentially
14916 means only half of the register is used.
14918 If the type specifier is given after the mnemonics, the
14919 information is stored in inst.vectype. If the type specifier
14920 is given after register operand, the information is stored
14921 in inst.operands[].vectype.
14923 When there is only one type specifier, and all the register
14924 operands are the same type of hardware register, the type
14925 specifier applies to all register operands.
14927 If no type specifier is given, the shape is inferred from
14928 operand information.
14931 vadd.f16 s0, s1, s2: NS_HHH
14932 vabs.f16 s0, s1: NS_HH
14933 vmov.f16 s0, r1: NS_HR
14934 vmov.f16 r0, s1: NS_RH
14935 vcvt.f16 r0, s1: NS_RH
14936 vcvt.f16.s32 s2, s2, #29: NS_HFI
14937 vcvt.f16.s32 s2, s2: NS_HF
14940 if (!(inst.operands[j].isreg
14941 && inst.operands[j].isvec
14942 && inst.operands[j].issingle
14943 && !inst.operands[j].isquad
14944 && ((inst.vectype.elems == 1
14945 && inst.vectype.el[0].size == 16)
14946 || (inst.vectype.elems > 1
14947 && inst.vectype.el[j].size == 16)
14948 || (inst.vectype.elems == 0
14949 && inst.operands[j].vectype.type != NT_invtype
14950 && inst.operands[j].vectype.size == 16))))
14955 if (!(inst.operands[j].isreg
14956 && inst.operands[j].isvec
14957 && inst.operands[j].issingle
14958 && !inst.operands[j].isquad
14959 && ((inst.vectype.elems == 1 && inst.vectype.el[0].size == 32)
14960 || (inst.vectype.elems > 1 && inst.vectype.el[j].size == 32)
14961 || (inst.vectype.elems == 0
14962 && (inst.operands[j].vectype.size == 32
14963 || inst.operands[j].vectype.type == NT_invtype)))))
14968 if (!(inst.operands[j].isreg
14969 && inst.operands[j].isvec
14970 && !inst.operands[j].isquad
14971 && !inst.operands[j].issingle))
14976 if (!(inst.operands[j].isreg
14977 && !inst.operands[j].isvec))
14982 if (!(inst.operands[j].isreg
14983 && inst.operands[j].isvec
14984 && inst.operands[j].isquad
14985 && !inst.operands[j].issingle))
14990 if (!(!inst.operands[j].isreg
14991 && !inst.operands[j].isscalar))
14996 if (!(!inst.operands[j].isreg
14997 && inst.operands[j].isscalar))
15007 if (matches && (j >= ARM_IT_MAX_OPERANDS || !inst.operands[j].present))
15008 /* We've matched all the entries in the shape table, and we don't
15009 have any left over operands which have not been matched. */
15015 if (shape == NS_NULL && first_shape != NS_NULL)
15016 first_error (_("invalid instruction shape"));
15021 /* True if SHAPE is predominantly a quadword operation (most of the time, this
15022 means the Q bit should be set). */
15025 neon_quad (enum neon_shape shape)
15027 return neon_shape_class[shape] == SC_QUAD;
15031 neon_modify_type_size (unsigned typebits, enum neon_el_type *g_type,
15034 /* Allow modification to be made to types which are constrained to be
15035 based on the key element, based on bits set alongside N_EQK. */
15036 if ((typebits & N_EQK) != 0)
15038 if ((typebits & N_HLF) != 0)
15040 else if ((typebits & N_DBL) != 0)
15042 if ((typebits & N_SGN) != 0)
15043 *g_type = NT_signed;
15044 else if ((typebits & N_UNS) != 0)
15045 *g_type = NT_unsigned;
15046 else if ((typebits & N_INT) != 0)
15047 *g_type = NT_integer;
15048 else if ((typebits & N_FLT) != 0)
15049 *g_type = NT_float;
15050 else if ((typebits & N_SIZ) != 0)
15051 *g_type = NT_untyped;
15055 /* Return operand OPNO promoted by bits set in THISARG. KEY should be the "key"
15056 operand type, i.e. the single type specified in a Neon instruction when it
15057 is the only one given. */
15059 static struct neon_type_el
15060 neon_type_promote (struct neon_type_el *key, unsigned thisarg)
15062 struct neon_type_el dest = *key;
15064 gas_assert ((thisarg & N_EQK) != 0);
15066 neon_modify_type_size (thisarg, &dest.type, &dest.size);
15071 /* Convert Neon type and size into compact bitmask representation. */
15073 static enum neon_type_mask
15074 type_chk_of_el_type (enum neon_el_type type, unsigned size)
15081 case 8: return N_8;
15082 case 16: return N_16;
15083 case 32: return N_32;
15084 case 64: return N_64;
15092 case 8: return N_I8;
15093 case 16: return N_I16;
15094 case 32: return N_I32;
15095 case 64: return N_I64;
15103 case 16: return N_F16;
15104 case 32: return N_F32;
15105 case 64: return N_F64;
15113 case 8: return N_P8;
15114 case 16: return N_P16;
15115 case 64: return N_P64;
15123 case 8: return N_S8;
15124 case 16: return N_S16;
15125 case 32: return N_S32;
15126 case 64: return N_S64;
15134 case 8: return N_U8;
15135 case 16: return N_U16;
15136 case 32: return N_U32;
15137 case 64: return N_U64;
15148 /* Convert compact Neon bitmask type representation to a type and size. Only
15149 handles the case where a single bit is set in the mask. */
15152 el_type_of_type_chk (enum neon_el_type *type, unsigned *size,
15153 enum neon_type_mask mask)
15155 if ((mask & N_EQK) != 0)
15158 if ((mask & (N_S8 | N_U8 | N_I8 | N_8 | N_P8)) != 0)
15160 else if ((mask & (N_S16 | N_U16 | N_I16 | N_16 | N_F16 | N_P16)) != 0)
15162 else if ((mask & (N_S32 | N_U32 | N_I32 | N_32 | N_F32)) != 0)
15164 else if ((mask & (N_S64 | N_U64 | N_I64 | N_64 | N_F64 | N_P64)) != 0)
15169 if ((mask & (N_S8 | N_S16 | N_S32 | N_S64)) != 0)
15171 else if ((mask & (N_U8 | N_U16 | N_U32 | N_U64)) != 0)
15172 *type = NT_unsigned;
15173 else if ((mask & (N_I8 | N_I16 | N_I32 | N_I64)) != 0)
15174 *type = NT_integer;
15175 else if ((mask & (N_8 | N_16 | N_32 | N_64)) != 0)
15176 *type = NT_untyped;
15177 else if ((mask & (N_P8 | N_P16 | N_P64)) != 0)
15179 else if ((mask & (N_F_ALL)) != 0)
15187 /* Modify a bitmask of allowed types. This is only needed for type
15191 modify_types_allowed (unsigned allowed, unsigned mods)
15194 enum neon_el_type type;
15200 for (i = 1; i <= N_MAX_NONSPECIAL; i <<= 1)
15202 if (el_type_of_type_chk (&type, &size,
15203 (enum neon_type_mask) (allowed & i)) == SUCCESS)
15205 neon_modify_type_size (mods, &type, &size);
15206 destmask |= type_chk_of_el_type (type, size);
15213 /* Check type and return type classification.
15214 The manual states (paraphrase): If one datatype is given, it indicates the
15216 - the second operand, if there is one
15217 - the operand, if there is no second operand
15218 - the result, if there are no operands.
15219 This isn't quite good enough though, so we use a concept of a "key" datatype
15220 which is set on a per-instruction basis, which is the one which matters when
15221 only one data type is written.
15222 Note: this function has side-effects (e.g. filling in missing operands). All
15223 Neon instructions should call it before performing bit encoding. */
15225 static struct neon_type_el
15226 neon_check_type (unsigned els, enum neon_shape ns, ...)
15229 unsigned i, pass, key_el = 0;
15230 unsigned types[NEON_MAX_TYPE_ELS];
15231 enum neon_el_type k_type = NT_invtype;
15232 unsigned k_size = -1u;
15233 struct neon_type_el badtype = {NT_invtype, -1};
15234 unsigned key_allowed = 0;
15236 /* Optional registers in Neon instructions are always (not) in operand 1.
15237 Fill in the missing operand here, if it was omitted. */
15238 if (els > 1 && !inst.operands[1].present)
15239 inst.operands[1] = inst.operands[0];
15241 /* Suck up all the varargs. */
15243 for (i = 0; i < els; i++)
15245 unsigned thisarg = va_arg (ap, unsigned);
15246 if (thisarg == N_IGNORE_TYPE)
15251 types[i] = thisarg;
15252 if ((thisarg & N_KEY) != 0)
15257 if (inst.vectype.elems > 0)
15258 for (i = 0; i < els; i++)
15259 if (inst.operands[i].vectype.type != NT_invtype)
15261 first_error (_("types specified in both the mnemonic and operands"));
15265 /* Duplicate inst.vectype elements here as necessary.
15266 FIXME: No idea if this is exactly the same as the ARM assembler,
15267 particularly when an insn takes one register and one non-register
15269 if (inst.vectype.elems == 1 && els > 1)
15272 inst.vectype.elems = els;
15273 inst.vectype.el[key_el] = inst.vectype.el[0];
15274 for (j = 0; j < els; j++)
15276 inst.vectype.el[j] = neon_type_promote (&inst.vectype.el[key_el],
15279 else if (inst.vectype.elems == 0 && els > 0)
15282 /* No types were given after the mnemonic, so look for types specified
15283 after each operand. We allow some flexibility here; as long as the
15284 "key" operand has a type, we can infer the others. */
15285 for (j = 0; j < els; j++)
15286 if (inst.operands[j].vectype.type != NT_invtype)
15287 inst.vectype.el[j] = inst.operands[j].vectype;
15289 if (inst.operands[key_el].vectype.type != NT_invtype)
15291 for (j = 0; j < els; j++)
15292 if (inst.operands[j].vectype.type == NT_invtype)
15293 inst.vectype.el[j] = neon_type_promote (&inst.vectype.el[key_el],
15298 first_error (_("operand types can't be inferred"));
15302 else if (inst.vectype.elems != els)
15304 first_error (_("type specifier has the wrong number of parts"));
15308 for (pass = 0; pass < 2; pass++)
15310 for (i = 0; i < els; i++)
15312 unsigned thisarg = types[i];
15313 unsigned types_allowed = ((thisarg & N_EQK) != 0 && pass != 0)
15314 ? modify_types_allowed (key_allowed, thisarg) : thisarg;
15315 enum neon_el_type g_type = inst.vectype.el[i].type;
15316 unsigned g_size = inst.vectype.el[i].size;
15318 /* Decay more-specific signed & unsigned types to sign-insensitive
15319 integer types if sign-specific variants are unavailable. */
15320 if ((g_type == NT_signed || g_type == NT_unsigned)
15321 && (types_allowed & N_SU_ALL) == 0)
15322 g_type = NT_integer;
15324 /* If only untyped args are allowed, decay any more specific types to
15325 them. Some instructions only care about signs for some element
15326 sizes, so handle that properly. */
15327 if (((types_allowed & N_UNT) == 0)
15328 && ((g_size == 8 && (types_allowed & N_8) != 0)
15329 || (g_size == 16 && (types_allowed & N_16) != 0)
15330 || (g_size == 32 && (types_allowed & N_32) != 0)
15331 || (g_size == 64 && (types_allowed & N_64) != 0)))
15332 g_type = NT_untyped;
15336 if ((thisarg & N_KEY) != 0)
15340 key_allowed = thisarg & ~N_KEY;
15342 /* Check architecture constraint on FP16 extension. */
15344 && k_type == NT_float
15345 && ! ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_fp16))
15347 inst.error = _(BAD_FP16);
15354 if ((thisarg & N_VFP) != 0)
15356 enum neon_shape_el regshape;
15357 unsigned regwidth, match;
15359 /* PR 11136: Catch the case where we are passed a shape of NS_NULL. */
15362 first_error (_("invalid instruction shape"));
15365 regshape = neon_shape_tab[ns].el[i];
15366 regwidth = neon_shape_el_size[regshape];
15368 /* In VFP mode, operands must match register widths. If we
15369 have a key operand, use its width, else use the width of
15370 the current operand. */
15376 /* FP16 will use a single precision register. */
15377 if (regwidth == 32 && match == 16)
15379 if (ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_fp16))
15383 inst.error = _(BAD_FP16);
15388 if (regwidth != match)
15390 first_error (_("operand size must match register width"));
15395 if ((thisarg & N_EQK) == 0)
15397 unsigned given_type = type_chk_of_el_type (g_type, g_size);
15399 if ((given_type & types_allowed) == 0)
15401 first_error (BAD_SIMD_TYPE);
15407 enum neon_el_type mod_k_type = k_type;
15408 unsigned mod_k_size = k_size;
15409 neon_modify_type_size (thisarg, &mod_k_type, &mod_k_size);
15410 if (g_type != mod_k_type || g_size != mod_k_size)
15412 first_error (_("inconsistent types in Neon instruction"));
15420 return inst.vectype.el[key_el];
15423 /* Neon-style VFP instruction forwarding. */
15425 /* Thumb VFP instructions have 0xE in the condition field. */
15428 do_vfp_cond_or_thumb (void)
15433 inst.instruction |= 0xe0000000;
15435 inst.instruction |= inst.cond << 28;
15438 /* Look up and encode a simple mnemonic, for use as a helper function for the
15439 Neon-style VFP syntax. This avoids duplication of bits of the insns table,
15440 etc. It is assumed that operand parsing has already been done, and that the
15441 operands are in the form expected by the given opcode (this isn't necessarily
15442 the same as the form in which they were parsed, hence some massaging must
15443 take place before this function is called).
15444 Checks current arch version against that in the looked-up opcode. */
15447 do_vfp_nsyn_opcode (const char *opname)
15449 const struct asm_opcode *opcode;
15451 opcode = (const struct asm_opcode *) hash_find (arm_ops_hsh, opname);
15456 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant,
15457 thumb_mode ? *opcode->tvariant : *opcode->avariant),
15464 inst.instruction = opcode->tvalue;
15465 opcode->tencode ();
15469 inst.instruction = (inst.cond << 28) | opcode->avalue;
15470 opcode->aencode ();
15475 do_vfp_nsyn_add_sub (enum neon_shape rs)
15477 int is_add = (inst.instruction & 0x0fffffff) == N_MNEM_vadd;
15479 if (rs == NS_FFF || rs == NS_HHH)
15482 do_vfp_nsyn_opcode ("fadds");
15484 do_vfp_nsyn_opcode ("fsubs");
15486 /* ARMv8.2 fp16 instruction. */
15488 do_scalar_fp16_v82_encode ();
15493 do_vfp_nsyn_opcode ("faddd");
15495 do_vfp_nsyn_opcode ("fsubd");
15499 /* Check operand types to see if this is a VFP instruction, and if so call
15503 try_vfp_nsyn (int args, void (*pfn) (enum neon_shape))
15505 enum neon_shape rs;
15506 struct neon_type_el et;
15511 rs = neon_select_shape (NS_HH, NS_FF, NS_DD, NS_NULL);
15512 et = neon_check_type (2, rs, N_EQK | N_VFP, N_F_ALL | N_KEY | N_VFP);
15516 rs = neon_select_shape (NS_HHH, NS_FFF, NS_DDD, NS_NULL);
15517 et = neon_check_type (3, rs, N_EQK | N_VFP, N_EQK | N_VFP,
15518 N_F_ALL | N_KEY | N_VFP);
15525 if (et.type != NT_invtype)
15536 do_vfp_nsyn_mla_mls (enum neon_shape rs)
15538 int is_mla = (inst.instruction & 0x0fffffff) == N_MNEM_vmla;
15540 if (rs == NS_FFF || rs == NS_HHH)
15543 do_vfp_nsyn_opcode ("fmacs");
15545 do_vfp_nsyn_opcode ("fnmacs");
15547 /* ARMv8.2 fp16 instruction. */
15549 do_scalar_fp16_v82_encode ();
15554 do_vfp_nsyn_opcode ("fmacd");
15556 do_vfp_nsyn_opcode ("fnmacd");
15561 do_vfp_nsyn_fma_fms (enum neon_shape rs)
15563 int is_fma = (inst.instruction & 0x0fffffff) == N_MNEM_vfma;
15565 if (rs == NS_FFF || rs == NS_HHH)
15568 do_vfp_nsyn_opcode ("ffmas");
15570 do_vfp_nsyn_opcode ("ffnmas");
15572 /* ARMv8.2 fp16 instruction. */
15574 do_scalar_fp16_v82_encode ();
15579 do_vfp_nsyn_opcode ("ffmad");
15581 do_vfp_nsyn_opcode ("ffnmad");
15586 do_vfp_nsyn_mul (enum neon_shape rs)
15588 if (rs == NS_FFF || rs == NS_HHH)
15590 do_vfp_nsyn_opcode ("fmuls");
15592 /* ARMv8.2 fp16 instruction. */
15594 do_scalar_fp16_v82_encode ();
15597 do_vfp_nsyn_opcode ("fmuld");
15601 do_vfp_nsyn_abs_neg (enum neon_shape rs)
15603 int is_neg = (inst.instruction & 0x80) != 0;
15604 neon_check_type (2, rs, N_EQK | N_VFP, N_F_ALL | N_VFP | N_KEY);
15606 if (rs == NS_FF || rs == NS_HH)
15609 do_vfp_nsyn_opcode ("fnegs");
15611 do_vfp_nsyn_opcode ("fabss");
15613 /* ARMv8.2 fp16 instruction. */
15615 do_scalar_fp16_v82_encode ();
15620 do_vfp_nsyn_opcode ("fnegd");
15622 do_vfp_nsyn_opcode ("fabsd");
15626 /* Encode single-precision (only!) VFP fldm/fstm instructions. Double precision
15627 insns belong to Neon, and are handled elsewhere. */
15630 do_vfp_nsyn_ldm_stm (int is_dbmode)
15632 int is_ldm = (inst.instruction & (1 << 20)) != 0;
15636 do_vfp_nsyn_opcode ("fldmdbs");
15638 do_vfp_nsyn_opcode ("fldmias");
15643 do_vfp_nsyn_opcode ("fstmdbs");
15645 do_vfp_nsyn_opcode ("fstmias");
15650 do_vfp_nsyn_sqrt (void)
15652 enum neon_shape rs = neon_select_shape (NS_HH, NS_FF, NS_DD, NS_NULL);
15653 neon_check_type (2, rs, N_EQK | N_VFP, N_F_ALL | N_KEY | N_VFP);
15655 if (rs == NS_FF || rs == NS_HH)
15657 do_vfp_nsyn_opcode ("fsqrts");
15659 /* ARMv8.2 fp16 instruction. */
15661 do_scalar_fp16_v82_encode ();
15664 do_vfp_nsyn_opcode ("fsqrtd");
15668 do_vfp_nsyn_div (void)
15670 enum neon_shape rs = neon_select_shape (NS_HHH, NS_FFF, NS_DDD, NS_NULL);
15671 neon_check_type (3, rs, N_EQK | N_VFP, N_EQK | N_VFP,
15672 N_F_ALL | N_KEY | N_VFP);
15674 if (rs == NS_FFF || rs == NS_HHH)
15676 do_vfp_nsyn_opcode ("fdivs");
15678 /* ARMv8.2 fp16 instruction. */
15680 do_scalar_fp16_v82_encode ();
15683 do_vfp_nsyn_opcode ("fdivd");
15687 do_vfp_nsyn_nmul (void)
15689 enum neon_shape rs = neon_select_shape (NS_HHH, NS_FFF, NS_DDD, NS_NULL);
15690 neon_check_type (3, rs, N_EQK | N_VFP, N_EQK | N_VFP,
15691 N_F_ALL | N_KEY | N_VFP);
15693 if (rs == NS_FFF || rs == NS_HHH)
15695 NEON_ENCODE (SINGLE, inst);
15696 do_vfp_sp_dyadic ();
15698 /* ARMv8.2 fp16 instruction. */
15700 do_scalar_fp16_v82_encode ();
15704 NEON_ENCODE (DOUBLE, inst);
15705 do_vfp_dp_rd_rn_rm ();
15707 do_vfp_cond_or_thumb ();
15711 /* Turn a size (8, 16, 32, 64) into the respective bit number minus 3
15715 neon_logbits (unsigned x)
15717 return ffs (x) - 4;
15720 #define LOW4(R) ((R) & 0xf)
15721 #define HI1(R) (((R) >> 4) & 1)
15724 mve_get_vcmp_vpt_cond (struct neon_type_el et)
15729 first_error (BAD_EL_TYPE);
15732 switch (inst.operands[0].imm)
15735 first_error (_("invalid condition"));
15757 /* only accept eq and ne. */
15758 if (inst.operands[0].imm > 1)
15760 first_error (_("invalid condition"));
15763 return inst.operands[0].imm;
15765 if (inst.operands[0].imm == 0x2)
15767 else if (inst.operands[0].imm == 0x8)
15771 first_error (_("invalid condition"));
15775 switch (inst.operands[0].imm)
15778 first_error (_("invalid condition"));
15794 /* Should be unreachable. */
15798 /* For VCTP (create vector tail predicate) in MVE. */
15803 unsigned size = 0x0;
15805 if (inst.cond > COND_ALWAYS)
15806 inst.pred_insn_type = INSIDE_VPT_INSN;
15808 inst.pred_insn_type = MVE_OUTSIDE_PRED_INSN;
15810 /* This is a typical MVE instruction which has no type but have size 8, 16,
15811 32 and 64. For instructions with no type, inst.vectype.el[j].type is set
15812 to NT_untyped and size is updated in inst.vectype.el[j].size. */
15813 if ((inst.operands[0].present) && (inst.vectype.el[0].type == NT_untyped))
15814 dt = inst.vectype.el[0].size;
15816 /* Setting this does not indicate an actual NEON instruction, but only
15817 indicates that the mnemonic accepts neon-style type suffixes. */
15831 first_error (_("Type is not allowed for this instruction"));
15833 inst.instruction |= size << 20;
15834 inst.instruction |= inst.operands[0].reg << 16;
15840 /* We are dealing with a vector predicated block. */
15841 if (inst.operands[0].present)
15843 enum neon_shape rs = neon_select_shape (NS_IQQ, NS_IQR, NS_NULL);
15844 struct neon_type_el et
15845 = neon_check_type (3, rs, N_EQK, N_KEY | N_F_MVE | N_I_MVE | N_SU_32,
15848 unsigned fcond = mve_get_vcmp_vpt_cond (et);
15850 constraint (inst.operands[1].reg > 14, MVE_BAD_QREG);
15852 if (et.type == NT_invtype)
15855 if (et.type == NT_float)
15857 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant, mve_fp_ext),
15859 constraint (et.size != 16 && et.size != 32, BAD_EL_TYPE);
15860 inst.instruction |= (et.size == 16) << 28;
15861 inst.instruction |= 0x3 << 20;
15865 constraint (et.size != 8 && et.size != 16 && et.size != 32,
15867 inst.instruction |= 1 << 28;
15868 inst.instruction |= neon_logbits (et.size) << 20;
15871 if (inst.operands[2].isquad)
15873 inst.instruction |= HI1 (inst.operands[2].reg) << 5;
15874 inst.instruction |= LOW4 (inst.operands[2].reg);
15875 inst.instruction |= (fcond & 0x2) >> 1;
15879 if (inst.operands[2].reg == REG_SP)
15880 as_tsktsk (MVE_BAD_SP);
15881 inst.instruction |= 1 << 6;
15882 inst.instruction |= (fcond & 0x2) << 4;
15883 inst.instruction |= inst.operands[2].reg;
15885 inst.instruction |= LOW4 (inst.operands[1].reg) << 16;
15886 inst.instruction |= (fcond & 0x4) << 10;
15887 inst.instruction |= (fcond & 0x1) << 7;
15890 set_pred_insn_type (VPT_INSN);
15892 now_pred.mask = ((inst.instruction & 0x00400000) >> 19)
15893 | ((inst.instruction & 0xe000) >> 13);
15894 now_pred.warn_deprecated = FALSE;
15895 now_pred.type = VECTOR_PRED;
15902 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext), BAD_FPU);
15903 if (!inst.operands[1].isreg || !inst.operands[1].isquad)
15904 first_error (_(reg_expected_msgs[REG_TYPE_MQ]));
15905 if (!inst.operands[2].present)
15906 first_error (_("MVE vector or ARM register expected"));
15907 constraint (inst.operands[1].reg > 14, MVE_BAD_QREG);
15909 /* Deal with 'else' conditional MVE's vcmp, it will be parsed as vcmpe. */
15910 if ((inst.instruction & 0xffffffff) == N_MNEM_vcmpe
15911 && inst.operands[1].isquad)
15913 inst.instruction = N_MNEM_vcmp;
15917 if (inst.cond > COND_ALWAYS)
15918 inst.pred_insn_type = INSIDE_VPT_INSN;
15920 inst.pred_insn_type = MVE_OUTSIDE_PRED_INSN;
15922 enum neon_shape rs = neon_select_shape (NS_IQQ, NS_IQR, NS_NULL);
15923 struct neon_type_el et
15924 = neon_check_type (3, rs, N_EQK, N_KEY | N_F_MVE | N_I_MVE | N_SU_32,
15927 constraint (rs == NS_IQR && inst.operands[2].reg == REG_PC
15928 && !inst.operands[2].iszr, BAD_PC);
15930 unsigned fcond = mve_get_vcmp_vpt_cond (et);
15932 inst.instruction = 0xee010f00;
15933 inst.instruction |= LOW4 (inst.operands[1].reg) << 16;
15934 inst.instruction |= (fcond & 0x4) << 10;
15935 inst.instruction |= (fcond & 0x1) << 7;
15936 if (et.type == NT_float)
15938 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant, mve_fp_ext),
15940 inst.instruction |= (et.size == 16) << 28;
15941 inst.instruction |= 0x3 << 20;
15945 inst.instruction |= 1 << 28;
15946 inst.instruction |= neon_logbits (et.size) << 20;
15948 if (inst.operands[2].isquad)
15950 inst.instruction |= HI1 (inst.operands[2].reg) << 5;
15951 inst.instruction |= (fcond & 0x2) >> 1;
15952 inst.instruction |= LOW4 (inst.operands[2].reg);
15956 if (inst.operands[2].reg == REG_SP)
15957 as_tsktsk (MVE_BAD_SP);
15958 inst.instruction |= 1 << 6;
15959 inst.instruction |= (fcond & 0x2) << 4;
15960 inst.instruction |= inst.operands[2].reg;
15968 do_mve_vmaxa_vmina (void)
15970 if (inst.cond > COND_ALWAYS)
15971 inst.pred_insn_type = INSIDE_VPT_INSN;
15973 inst.pred_insn_type = MVE_OUTSIDE_PRED_INSN;
15975 enum neon_shape rs = neon_select_shape (NS_QQ, NS_NULL);
15976 struct neon_type_el et
15977 = neon_check_type (2, rs, N_EQK, N_KEY | N_S8 | N_S16 | N_S32);
15979 inst.instruction |= HI1 (inst.operands[0].reg) << 22;
15980 inst.instruction |= neon_logbits (et.size) << 18;
15981 inst.instruction |= LOW4 (inst.operands[0].reg) << 12;
15982 inst.instruction |= HI1 (inst.operands[1].reg) << 5;
15983 inst.instruction |= LOW4 (inst.operands[1].reg);
15988 do_mve_vfmas (void)
15990 enum neon_shape rs = neon_select_shape (NS_QQR, NS_NULL);
15991 struct neon_type_el et
15992 = neon_check_type (3, rs, N_F_MVE | N_KEY, N_EQK, N_EQK);
15994 if (inst.cond > COND_ALWAYS)
15995 inst.pred_insn_type = INSIDE_VPT_INSN;
15997 inst.pred_insn_type = MVE_OUTSIDE_PRED_INSN;
15999 if (inst.operands[2].reg == REG_SP)
16000 as_tsktsk (MVE_BAD_SP);
16001 else if (inst.operands[2].reg == REG_PC)
16002 as_tsktsk (MVE_BAD_PC);
16004 inst.instruction |= (et.size == 16) << 28;
16005 inst.instruction |= HI1 (inst.operands[0].reg) << 22;
16006 inst.instruction |= LOW4 (inst.operands[1].reg) << 16;
16007 inst.instruction |= LOW4 (inst.operands[0].reg) << 12;
16008 inst.instruction |= HI1 (inst.operands[1].reg) << 7;
16009 inst.instruction |= inst.operands[2].reg;
16014 do_mve_viddup (void)
16016 if (inst.cond > COND_ALWAYS)
16017 inst.pred_insn_type = INSIDE_VPT_INSN;
16019 inst.pred_insn_type = MVE_OUTSIDE_PRED_INSN;
16021 unsigned imm = inst.relocs[0].exp.X_add_number;
16022 constraint (imm != 1 && imm != 2 && imm != 4 && imm != 8,
16023 _("immediate must be either 1, 2, 4 or 8"));
16025 enum neon_shape rs;
16026 struct neon_type_el et;
16028 if (inst.instruction == M_MNEM_vddup || inst.instruction == M_MNEM_vidup)
16030 rs = neon_select_shape (NS_QRI, NS_NULL);
16031 et = neon_check_type (2, rs, N_KEY | N_U8 | N_U16 | N_U32, N_EQK);
16036 constraint ((inst.operands[2].reg % 2) != 1, BAD_EVEN);
16037 if (inst.operands[2].reg == REG_SP)
16038 as_tsktsk (MVE_BAD_SP);
16039 else if (inst.operands[2].reg == REG_PC)
16040 first_error (BAD_PC);
16042 rs = neon_select_shape (NS_QRRI, NS_NULL);
16043 et = neon_check_type (3, rs, N_KEY | N_U8 | N_U16 | N_U32, N_EQK, N_EQK);
16044 Rm = inst.operands[2].reg >> 1;
16046 inst.instruction |= HI1 (inst.operands[0].reg) << 22;
16047 inst.instruction |= neon_logbits (et.size) << 20;
16048 inst.instruction |= inst.operands[1].reg << 16;
16049 inst.instruction |= LOW4 (inst.operands[0].reg) << 12;
16050 inst.instruction |= (imm > 2) << 7;
16051 inst.instruction |= Rm << 1;
16052 inst.instruction |= (imm == 2 || imm == 8);
16057 do_mve_vmlas (void)
16059 enum neon_shape rs = neon_select_shape (NS_QQR, NS_NULL);
16060 struct neon_type_el et
16061 = neon_check_type (3, rs, N_EQK, N_EQK, N_SU_MVE | N_KEY);
16063 if (inst.operands[2].reg == REG_PC)
16064 as_tsktsk (MVE_BAD_PC);
16065 else if (inst.operands[2].reg == REG_SP)
16066 as_tsktsk (MVE_BAD_SP);
16068 if (inst.cond > COND_ALWAYS)
16069 inst.pred_insn_type = INSIDE_VPT_INSN;
16071 inst.pred_insn_type = MVE_OUTSIDE_PRED_INSN;
16073 inst.instruction |= (et.type == NT_unsigned) << 28;
16074 inst.instruction |= HI1 (inst.operands[0].reg) << 22;
16075 inst.instruction |= neon_logbits (et.size) << 20;
16076 inst.instruction |= LOW4 (inst.operands[1].reg) << 16;
16077 inst.instruction |= LOW4 (inst.operands[0].reg) << 12;
16078 inst.instruction |= HI1 (inst.operands[1].reg) << 7;
16079 inst.instruction |= inst.operands[2].reg;
16084 do_mve_vshll (void)
16086 struct neon_type_el et
16087 = neon_check_type (2, NS_QQI, N_EQK, N_S8 | N_U8 | N_S16 | N_U16 | N_KEY);
16089 if (inst.cond > COND_ALWAYS)
16090 inst.pred_insn_type = INSIDE_VPT_INSN;
16092 inst.pred_insn_type = MVE_OUTSIDE_PRED_INSN;
16094 int imm = inst.operands[2].imm;
16095 constraint (imm < 1 || (unsigned)imm > et.size,
16096 _("immediate value out of range"));
16098 if ((unsigned)imm == et.size)
16100 inst.instruction |= neon_logbits (et.size) << 18;
16101 inst.instruction |= 0x110001;
16105 inst.instruction |= (et.size + imm) << 16;
16106 inst.instruction |= 0x800140;
16109 inst.instruction |= (et.type == NT_unsigned) << 28;
16110 inst.instruction |= HI1 (inst.operands[0].reg) << 22;
16111 inst.instruction |= LOW4 (inst.operands[0].reg) << 12;
16112 inst.instruction |= HI1 (inst.operands[1].reg) << 5;
16113 inst.instruction |= LOW4 (inst.operands[1].reg);
16118 do_mve_vshlc (void)
16120 if (inst.cond > COND_ALWAYS)
16121 inst.pred_insn_type = INSIDE_VPT_INSN;
16123 inst.pred_insn_type = MVE_OUTSIDE_PRED_INSN;
16125 if (inst.operands[1].reg == REG_PC)
16126 as_tsktsk (MVE_BAD_PC);
16127 else if (inst.operands[1].reg == REG_SP)
16128 as_tsktsk (MVE_BAD_SP);
16130 int imm = inst.operands[2].imm;
16131 constraint (imm < 1 || imm > 32, _("immediate value out of range"));
16133 inst.instruction |= HI1 (inst.operands[0].reg) << 22;
16134 inst.instruction |= (imm & 0x1f) << 16;
16135 inst.instruction |= LOW4 (inst.operands[0].reg) << 12;
16136 inst.instruction |= inst.operands[1].reg;
16141 do_mve_vshrn (void)
16144 switch (inst.instruction)
16146 case M_MNEM_vshrnt:
16147 case M_MNEM_vshrnb:
16148 case M_MNEM_vrshrnt:
16149 case M_MNEM_vrshrnb:
16150 types = N_I16 | N_I32;
16152 case M_MNEM_vqshrnt:
16153 case M_MNEM_vqshrnb:
16154 case M_MNEM_vqrshrnt:
16155 case M_MNEM_vqrshrnb:
16156 types = N_U16 | N_U32 | N_S16 | N_S32;
16158 case M_MNEM_vqshrunt:
16159 case M_MNEM_vqshrunb:
16160 case M_MNEM_vqrshrunt:
16161 case M_MNEM_vqrshrunb:
16162 types = N_S16 | N_S32;
16168 struct neon_type_el et = neon_check_type (2, NS_QQI, N_EQK, types | N_KEY);
16170 if (inst.cond > COND_ALWAYS)
16171 inst.pred_insn_type = INSIDE_VPT_INSN;
16173 inst.pred_insn_type = MVE_OUTSIDE_PRED_INSN;
16175 unsigned Qd = inst.operands[0].reg;
16176 unsigned Qm = inst.operands[1].reg;
16177 unsigned imm = inst.operands[2].imm;
16178 constraint (imm < 1 || ((unsigned) imm) > (et.size / 2),
16180 ? _("immediate operand expected in the range [1,8]")
16181 : _("immediate operand expected in the range [1,16]"));
16183 inst.instruction |= (et.type == NT_unsigned) << 28;
16184 inst.instruction |= HI1 (Qd) << 22;
16185 inst.instruction |= (et.size - imm) << 16;
16186 inst.instruction |= LOW4 (Qd) << 12;
16187 inst.instruction |= HI1 (Qm) << 5;
16188 inst.instruction |= LOW4 (Qm);
16193 do_mve_vqmovn (void)
16195 struct neon_type_el et;
16196 if (inst.instruction == M_MNEM_vqmovnt
16197 || inst.instruction == M_MNEM_vqmovnb)
16198 et = neon_check_type (2, NS_QQ, N_EQK,
16199 N_U16 | N_U32 | N_S16 | N_S32 | N_KEY);
16201 et = neon_check_type (2, NS_QQ, N_EQK, N_S16 | N_S32 | N_KEY);
16203 if (inst.cond > COND_ALWAYS)
16204 inst.pred_insn_type = INSIDE_VPT_INSN;
16206 inst.pred_insn_type = MVE_OUTSIDE_PRED_INSN;
16208 inst.instruction |= (et.type == NT_unsigned) << 28;
16209 inst.instruction |= HI1 (inst.operands[0].reg) << 22;
16210 inst.instruction |= (et.size == 32) << 18;
16211 inst.instruction |= LOW4 (inst.operands[0].reg) << 12;
16212 inst.instruction |= HI1 (inst.operands[1].reg) << 5;
16213 inst.instruction |= LOW4 (inst.operands[1].reg);
16218 do_mve_vpsel (void)
16220 neon_select_shape (NS_QQQ, NS_NULL);
16222 if (inst.cond > COND_ALWAYS)
16223 inst.pred_insn_type = INSIDE_VPT_INSN;
16225 inst.pred_insn_type = MVE_OUTSIDE_PRED_INSN;
16227 inst.instruction |= HI1 (inst.operands[0].reg) << 22;
16228 inst.instruction |= LOW4 (inst.operands[1].reg) << 16;
16229 inst.instruction |= LOW4 (inst.operands[0].reg) << 12;
16230 inst.instruction |= HI1 (inst.operands[1].reg) << 7;
16231 inst.instruction |= HI1 (inst.operands[2].reg) << 5;
16232 inst.instruction |= LOW4 (inst.operands[2].reg);
16237 do_mve_vpnot (void)
16239 if (inst.cond > COND_ALWAYS)
16240 inst.pred_insn_type = INSIDE_VPT_INSN;
16242 inst.pred_insn_type = MVE_OUTSIDE_PRED_INSN;
16246 do_mve_vmaxnma_vminnma (void)
16248 enum neon_shape rs = neon_select_shape (NS_QQ, NS_NULL);
16249 struct neon_type_el et
16250 = neon_check_type (2, rs, N_EQK, N_F_MVE | N_KEY);
16252 if (inst.cond > COND_ALWAYS)
16253 inst.pred_insn_type = INSIDE_VPT_INSN;
16255 inst.pred_insn_type = MVE_OUTSIDE_PRED_INSN;
16257 inst.instruction |= (et.size == 16) << 28;
16258 inst.instruction |= HI1 (inst.operands[0].reg) << 22;
16259 inst.instruction |= LOW4 (inst.operands[0].reg) << 12;
16260 inst.instruction |= HI1 (inst.operands[1].reg) << 5;
16261 inst.instruction |= LOW4 (inst.operands[1].reg);
16266 do_mve_vcmul (void)
16268 enum neon_shape rs = neon_select_shape (NS_QQQI, NS_NULL);
16269 struct neon_type_el et
16270 = neon_check_type (3, rs, N_EQK, N_EQK, N_F_MVE | N_KEY);
16272 if (inst.cond > COND_ALWAYS)
16273 inst.pred_insn_type = INSIDE_VPT_INSN;
16275 inst.pred_insn_type = MVE_OUTSIDE_PRED_INSN;
16277 unsigned rot = inst.relocs[0].exp.X_add_number;
16278 constraint (rot != 0 && rot != 90 && rot != 180 && rot != 270,
16279 _("immediate out of range"));
16281 if (et.size == 32 && (inst.operands[0].reg == inst.operands[1].reg
16282 || inst.operands[0].reg == inst.operands[2].reg))
16283 as_tsktsk (BAD_MVE_SRCDEST);
16285 inst.instruction |= (et.size == 32) << 28;
16286 inst.instruction |= HI1 (inst.operands[0].reg) << 22;
16287 inst.instruction |= LOW4 (inst.operands[1].reg) << 16;
16288 inst.instruction |= LOW4 (inst.operands[0].reg) << 12;
16289 inst.instruction |= (rot > 90) << 12;
16290 inst.instruction |= HI1 (inst.operands[1].reg) << 7;
16291 inst.instruction |= HI1 (inst.operands[2].reg) << 5;
16292 inst.instruction |= LOW4 (inst.operands[2].reg);
16293 inst.instruction |= (rot == 90 || rot == 270);
16297 /* To handle the Low Overhead Loop instructions
16298 in Armv8.1-M Mainline and MVE. */
16302 unsigned long insn = inst.instruction;
16304 inst.instruction = THUMB_OP32 (inst.instruction);
16306 if (insn == T_MNEM_lctp)
16309 set_pred_insn_type (MVE_OUTSIDE_PRED_INSN);
16311 if (insn == T_MNEM_wlstp || insn == T_MNEM_dlstp)
16313 struct neon_type_el et
16314 = neon_check_type (2, NS_RR, N_EQK, N_8 | N_16 | N_32 | N_64 | N_KEY);
16315 inst.instruction |= neon_logbits (et.size) << 20;
16322 constraint (!inst.operands[0].present,
16324 /* fall through. */
16327 if (!inst.operands[0].present)
16328 inst.instruction |= 1 << 21;
16330 v8_1_loop_reloc (TRUE);
16335 v8_1_loop_reloc (FALSE);
16336 /* fall through. */
16339 constraint (inst.operands[1].isreg != 1, BAD_ARGS);
16341 if (insn == T_MNEM_wlstp || insn == T_MNEM_dlstp)
16342 constraint (inst.operands[1].reg == REG_PC, BAD_PC);
16343 else if (inst.operands[1].reg == REG_PC)
16344 as_tsktsk (MVE_BAD_PC);
16345 if (inst.operands[1].reg == REG_SP)
16346 as_tsktsk (MVE_BAD_SP);
16348 inst.instruction |= (inst.operands[1].reg << 16);
16358 do_vfp_nsyn_cmp (void)
16360 enum neon_shape rs;
16361 if (!inst.operands[0].isreg)
16368 constraint (inst.operands[2].present, BAD_SYNTAX);
16369 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant, fpu_vfp_ext_v1xd),
16373 if (inst.operands[1].isreg)
16375 rs = neon_select_shape (NS_HH, NS_FF, NS_DD, NS_NULL);
16376 neon_check_type (2, rs, N_EQK | N_VFP, N_F_ALL | N_KEY | N_VFP);
16378 if (rs == NS_FF || rs == NS_HH)
16380 NEON_ENCODE (SINGLE, inst);
16381 do_vfp_sp_monadic ();
16385 NEON_ENCODE (DOUBLE, inst);
16386 do_vfp_dp_rd_rm ();
16391 rs = neon_select_shape (NS_HI, NS_FI, NS_DI, NS_NULL);
16392 neon_check_type (2, rs, N_F_ALL | N_KEY | N_VFP, N_EQK);
16394 switch (inst.instruction & 0x0fffffff)
16397 inst.instruction += N_MNEM_vcmpz - N_MNEM_vcmp;
16400 inst.instruction += N_MNEM_vcmpez - N_MNEM_vcmpe;
16406 if (rs == NS_FI || rs == NS_HI)
16408 NEON_ENCODE (SINGLE, inst);
16409 do_vfp_sp_compare_z ();
16413 NEON_ENCODE (DOUBLE, inst);
16417 do_vfp_cond_or_thumb ();
16419 /* ARMv8.2 fp16 instruction. */
16420 if (rs == NS_HI || rs == NS_HH)
16421 do_scalar_fp16_v82_encode ();
16425 nsyn_insert_sp (void)
16427 inst.operands[1] = inst.operands[0];
16428 memset (&inst.operands[0], '\0', sizeof (inst.operands[0]));
16429 inst.operands[0].reg = REG_SP;
16430 inst.operands[0].isreg = 1;
16431 inst.operands[0].writeback = 1;
16432 inst.operands[0].present = 1;
16436 do_vfp_nsyn_push (void)
16440 constraint (inst.operands[1].imm < 1 || inst.operands[1].imm > 16,
16441 _("register list must contain at least 1 and at most 16 "
16444 if (inst.operands[1].issingle)
16445 do_vfp_nsyn_opcode ("fstmdbs");
16447 do_vfp_nsyn_opcode ("fstmdbd");
16451 do_vfp_nsyn_pop (void)
16455 constraint (inst.operands[1].imm < 1 || inst.operands[1].imm > 16,
16456 _("register list must contain at least 1 and at most 16 "
16459 if (inst.operands[1].issingle)
16460 do_vfp_nsyn_opcode ("fldmias");
16462 do_vfp_nsyn_opcode ("fldmiad");
16465 /* Fix up Neon data-processing instructions, ORing in the correct bits for
16466 ARM mode or Thumb mode and moving the encoded bit 24 to bit 28. */
16469 neon_dp_fixup (struct arm_it* insn)
16471 unsigned int i = insn->instruction;
16476 /* The U bit is at bit 24 by default. Move to bit 28 in Thumb mode. */
16487 insn->instruction = i;
16491 mve_encode_qqr (int size, int U, int fp)
16493 if (inst.operands[2].reg == REG_SP)
16494 as_tsktsk (MVE_BAD_SP);
16495 else if (inst.operands[2].reg == REG_PC)
16496 as_tsktsk (MVE_BAD_PC);
16501 if (((unsigned)inst.instruction) == 0xd00)
16502 inst.instruction = 0xee300f40;
16504 else if (((unsigned)inst.instruction) == 0x200d00)
16505 inst.instruction = 0xee301f40;
16507 else if (((unsigned)inst.instruction) == 0x1000d10)
16508 inst.instruction = 0xee310e60;
16510 /* Setting size which is 1 for F16 and 0 for F32. */
16511 inst.instruction |= (size == 16) << 28;
16516 if (((unsigned)inst.instruction) == 0x800)
16517 inst.instruction = 0xee010f40;
16519 else if (((unsigned)inst.instruction) == 0x1000800)
16520 inst.instruction = 0xee011f40;
16522 else if (((unsigned)inst.instruction) == 0)
16523 inst.instruction = 0xee000f40;
16525 else if (((unsigned)inst.instruction) == 0x200)
16526 inst.instruction = 0xee001f40;
16528 else if (((unsigned)inst.instruction) == 0x900)
16529 inst.instruction = 0xee010e40;
16531 else if (((unsigned)inst.instruction) == 0x910)
16532 inst.instruction = 0xee011e60;
16534 else if (((unsigned)inst.instruction) == 0x10)
16535 inst.instruction = 0xee000f60;
16537 else if (((unsigned)inst.instruction) == 0x210)
16538 inst.instruction = 0xee001f60;
16540 else if (((unsigned)inst.instruction) == 0x3000b10)
16541 inst.instruction = 0xee000e40;
16543 else if (((unsigned)inst.instruction) == 0x0000b00)
16544 inst.instruction = 0xee010e60;
16546 else if (((unsigned)inst.instruction) == 0x1000b00)
16547 inst.instruction = 0xfe010e60;
16550 inst.instruction |= U << 28;
16552 /* Setting bits for size. */
16553 inst.instruction |= neon_logbits (size) << 20;
16555 inst.instruction |= LOW4 (inst.operands[0].reg) << 12;
16556 inst.instruction |= HI1 (inst.operands[0].reg) << 22;
16557 inst.instruction |= LOW4 (inst.operands[1].reg) << 16;
16558 inst.instruction |= HI1 (inst.operands[1].reg) << 7;
16559 inst.instruction |= inst.operands[2].reg;
16564 mve_encode_rqq (unsigned bit28, unsigned size)
16566 inst.instruction |= bit28 << 28;
16567 inst.instruction |= neon_logbits (size) << 20;
16568 inst.instruction |= LOW4 (inst.operands[1].reg) << 16;
16569 inst.instruction |= inst.operands[0].reg << 12;
16570 inst.instruction |= HI1 (inst.operands[1].reg) << 7;
16571 inst.instruction |= HI1 (inst.operands[2].reg) << 5;
16572 inst.instruction |= LOW4 (inst.operands[2].reg);
16577 mve_encode_qqq (int ubit, int size)
16580 inst.instruction |= (ubit != 0) << 28;
16581 inst.instruction |= HI1 (inst.operands[0].reg) << 22;
16582 inst.instruction |= neon_logbits (size) << 20;
16583 inst.instruction |= LOW4 (inst.operands[1].reg) << 16;
16584 inst.instruction |= LOW4 (inst.operands[0].reg) << 12;
16585 inst.instruction |= HI1 (inst.operands[1].reg) << 7;
16586 inst.instruction |= HI1 (inst.operands[2].reg) << 5;
16587 inst.instruction |= LOW4 (inst.operands[2].reg);
16593 mve_encode_rq (unsigned bit28, unsigned size)
16595 inst.instruction |= bit28 << 28;
16596 inst.instruction |= neon_logbits (size) << 18;
16597 inst.instruction |= inst.operands[0].reg << 12;
16598 inst.instruction |= LOW4 (inst.operands[1].reg);
16603 mve_encode_rrqq (unsigned U, unsigned size)
16605 constraint (inst.operands[3].reg > 14, MVE_BAD_QREG);
16607 inst.instruction |= U << 28;
16608 inst.instruction |= (inst.operands[1].reg >> 1) << 20;
16609 inst.instruction |= LOW4 (inst.operands[2].reg) << 16;
16610 inst.instruction |= (size == 32) << 16;
16611 inst.instruction |= inst.operands[0].reg << 12;
16612 inst.instruction |= HI1 (inst.operands[2].reg) << 7;
16613 inst.instruction |= inst.operands[3].reg;
16617 /* Encode insns with bit pattern:
16619 |28/24|23|22 |21 20|19 16|15 12|11 8|7|6|5|4|3 0|
16620 | U |x |D |size | Rn | Rd |x x x x|N|Q|M|x| Rm |
16622 SIZE is passed in bits. -1 means size field isn't changed, in case it has a
16623 different meaning for some instruction. */
16626 neon_three_same (int isquad, int ubit, int size)
16628 inst.instruction |= LOW4 (inst.operands[0].reg) << 12;
16629 inst.instruction |= HI1 (inst.operands[0].reg) << 22;
16630 inst.instruction |= LOW4 (inst.operands[1].reg) << 16;
16631 inst.instruction |= HI1 (inst.operands[1].reg) << 7;
16632 inst.instruction |= LOW4 (inst.operands[2].reg);
16633 inst.instruction |= HI1 (inst.operands[2].reg) << 5;
16634 inst.instruction |= (isquad != 0) << 6;
16635 inst.instruction |= (ubit != 0) << 24;
16637 inst.instruction |= neon_logbits (size) << 20;
16639 neon_dp_fixup (&inst);
16642 /* Encode instructions of the form:
16644 |28/24|23|22|21 20|19 18|17 16|15 12|11 7|6|5|4|3 0|
16645 | U |x |D |x x |size |x x | Rd |x x x x x|Q|M|x| Rm |
16647 Don't write size if SIZE == -1. */
16650 neon_two_same (int qbit, int ubit, int size)
16652 inst.instruction |= LOW4 (inst.operands[0].reg) << 12;
16653 inst.instruction |= HI1 (inst.operands[0].reg) << 22;
16654 inst.instruction |= LOW4 (inst.operands[1].reg);
16655 inst.instruction |= HI1 (inst.operands[1].reg) << 5;
16656 inst.instruction |= (qbit != 0) << 6;
16657 inst.instruction |= (ubit != 0) << 24;
16660 inst.instruction |= neon_logbits (size) << 18;
16662 neon_dp_fixup (&inst);
16665 enum vfp_or_neon_is_neon_bits
16668 NEON_CHECK_ARCH = 2,
16669 NEON_CHECK_ARCH8 = 4
16672 /* Call this function if an instruction which may have belonged to the VFP or
16673 Neon instruction sets, but turned out to be a Neon instruction (due to the
16674 operand types involved, etc.). We have to check and/or fix-up a couple of
16677 - Make sure the user hasn't attempted to make a Neon instruction
16679 - Alter the value in the condition code field if necessary.
16680 - Make sure that the arch supports Neon instructions.
16682 Which of these operations take place depends on bits from enum
16683 vfp_or_neon_is_neon_bits.
16685 WARNING: This function has side effects! If NEON_CHECK_CC is used and the
16686 current instruction's condition is COND_ALWAYS, the condition field is
16687 changed to inst.uncond_value. This is necessary because instructions shared
16688 between VFP and Neon may be conditional for the VFP variants only, and the
16689 unconditional Neon version must have, e.g., 0xF in the condition field. */
16692 vfp_or_neon_is_neon (unsigned check)
16694 /* Conditions are always legal in Thumb mode (IT blocks). */
16695 if (!thumb_mode && (check & NEON_CHECK_CC))
16697 if (inst.cond != COND_ALWAYS)
16699 first_error (_(BAD_COND));
16702 if (inst.uncond_value != -1)
16703 inst.instruction |= inst.uncond_value << 28;
16707 if (((check & NEON_CHECK_ARCH) && !mark_feature_used (&fpu_neon_ext_v1))
16708 || ((check & NEON_CHECK_ARCH8)
16709 && !mark_feature_used (&fpu_neon_ext_armv8)))
16711 first_error (_(BAD_FPU));
16719 /* Return TRUE if the SIMD instruction is available for the current
16720 cpu_variant. FP is set to TRUE if this is a SIMD floating-point
16721 instruction. CHECK contains th. CHECK contains the set of bits to pass to
16722 vfp_or_neon_is_neon for the NEON specific checks. */
16725 check_simd_pred_availability (int fp, unsigned check)
16727 if (inst.cond > COND_ALWAYS)
16729 if (!ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext))
16731 inst.error = BAD_FPU;
16734 inst.pred_insn_type = INSIDE_VPT_INSN;
16736 else if (inst.cond < COND_ALWAYS)
16738 if (ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext))
16739 inst.pred_insn_type = MVE_OUTSIDE_PRED_INSN;
16740 else if (vfp_or_neon_is_neon (check) == FAIL)
16745 if (!ARM_CPU_HAS_FEATURE (cpu_variant, fp ? mve_fp_ext : mve_ext)
16746 && vfp_or_neon_is_neon (check) == FAIL)
16749 if (ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext))
16750 inst.pred_insn_type = MVE_OUTSIDE_PRED_INSN;
16755 /* Neon instruction encoders, in approximate order of appearance. */
16758 do_neon_dyadic_i_su (void)
16760 if (!check_simd_pred_availability (FALSE, NEON_CHECK_ARCH | NEON_CHECK_CC))
16763 enum neon_shape rs;
16764 struct neon_type_el et;
16765 if (ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext))
16766 rs = neon_select_shape (NS_QQQ, NS_QQR, NS_NULL);
16768 rs = neon_select_shape (NS_DDD, NS_QQQ, NS_NULL);
16770 et = neon_check_type (3, rs, N_EQK, N_EQK, N_SU_32 | N_KEY);
16774 neon_three_same (neon_quad (rs), et.type == NT_unsigned, et.size);
16776 mve_encode_qqr (et.size, et.type == NT_unsigned, 0);
16780 do_neon_dyadic_i64_su (void)
16782 if (!check_simd_pred_availability (FALSE, NEON_CHECK_CC | NEON_CHECK_ARCH))
16784 enum neon_shape rs;
16785 struct neon_type_el et;
16786 if (ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext))
16788 rs = neon_select_shape (NS_QQR, NS_QQQ, NS_NULL);
16789 et = neon_check_type (3, rs, N_EQK, N_EQK, N_SU_MVE | N_KEY);
16793 rs = neon_select_shape (NS_DDD, NS_QQQ, NS_NULL);
16794 et = neon_check_type (3, rs, N_EQK, N_EQK, N_SU_ALL | N_KEY);
16797 mve_encode_qqr (et.size, et.type == NT_unsigned, 0);
16799 neon_three_same (neon_quad (rs), et.type == NT_unsigned, et.size);
16803 neon_imm_shift (int write_ubit, int uval, int isquad, struct neon_type_el et,
16806 unsigned size = et.size >> 3;
16807 inst.instruction |= LOW4 (inst.operands[0].reg) << 12;
16808 inst.instruction |= HI1 (inst.operands[0].reg) << 22;
16809 inst.instruction |= LOW4 (inst.operands[1].reg);
16810 inst.instruction |= HI1 (inst.operands[1].reg) << 5;
16811 inst.instruction |= (isquad != 0) << 6;
16812 inst.instruction |= immbits << 16;
16813 inst.instruction |= (size >> 3) << 7;
16814 inst.instruction |= (size & 0x7) << 19;
16816 inst.instruction |= (uval != 0) << 24;
16818 neon_dp_fixup (&inst);
16824 if (!check_simd_pred_availability (FALSE, NEON_CHECK_ARCH | NEON_CHECK_CC))
16827 if (!inst.operands[2].isreg)
16829 enum neon_shape rs;
16830 struct neon_type_el et;
16831 if (ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext))
16833 rs = neon_select_shape (NS_QQI, NS_NULL);
16834 et = neon_check_type (2, rs, N_EQK, N_KEY | N_I_MVE);
16838 rs = neon_select_shape (NS_DDI, NS_QQI, NS_NULL);
16839 et = neon_check_type (2, rs, N_EQK, N_KEY | N_I_ALL);
16841 int imm = inst.operands[2].imm;
16843 constraint (imm < 0 || (unsigned)imm >= et.size,
16844 _("immediate out of range for shift"));
16845 NEON_ENCODE (IMMED, inst);
16846 neon_imm_shift (FALSE, 0, neon_quad (rs), et, imm);
16850 enum neon_shape rs;
16851 struct neon_type_el et;
16852 if (ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext))
16854 rs = neon_select_shape (NS_QQQ, NS_QQR, NS_NULL);
16855 et = neon_check_type (3, rs, N_EQK, N_SU_MVE | N_KEY, N_EQK | N_EQK);
16859 rs = neon_select_shape (NS_DDD, NS_QQQ, NS_NULL);
16860 et = neon_check_type (3, rs, N_EQK, N_SU_ALL | N_KEY, N_EQK | N_SGN);
16866 constraint (inst.operands[0].reg != inst.operands[1].reg,
16867 _("invalid instruction shape"));
16868 if (inst.operands[2].reg == REG_SP)
16869 as_tsktsk (MVE_BAD_SP);
16870 else if (inst.operands[2].reg == REG_PC)
16871 as_tsktsk (MVE_BAD_PC);
16873 inst.instruction = 0xee311e60;
16874 inst.instruction |= (et.type == NT_unsigned) << 28;
16875 inst.instruction |= HI1 (inst.operands[0].reg) << 22;
16876 inst.instruction |= neon_logbits (et.size) << 18;
16877 inst.instruction |= LOW4 (inst.operands[0].reg) << 12;
16878 inst.instruction |= inst.operands[2].reg;
16885 /* VSHL/VQSHL 3-register variants have syntax such as:
16887 whereas other 3-register operations encoded by neon_three_same have
16890 (i.e. with Dn & Dm reversed). Swap operands[1].reg and
16891 operands[2].reg here. */
16892 tmp = inst.operands[2].reg;
16893 inst.operands[2].reg = inst.operands[1].reg;
16894 inst.operands[1].reg = tmp;
16895 NEON_ENCODE (INTEGER, inst);
16896 neon_three_same (neon_quad (rs), et.type == NT_unsigned, et.size);
16902 do_neon_qshl (void)
16904 if (!check_simd_pred_availability (FALSE, NEON_CHECK_ARCH | NEON_CHECK_CC))
16907 if (!inst.operands[2].isreg)
16909 enum neon_shape rs;
16910 struct neon_type_el et;
16911 if (ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext))
16913 rs = neon_select_shape (NS_QQI, NS_NULL);
16914 et = neon_check_type (2, rs, N_EQK, N_KEY | N_SU_MVE);
16918 rs = neon_select_shape (NS_DDI, NS_QQI, NS_NULL);
16919 et = neon_check_type (2, rs, N_EQK, N_SU_ALL | N_KEY);
16921 int imm = inst.operands[2].imm;
16923 constraint (imm < 0 || (unsigned)imm >= et.size,
16924 _("immediate out of range for shift"));
16925 NEON_ENCODE (IMMED, inst);
16926 neon_imm_shift (TRUE, et.type == NT_unsigned, neon_quad (rs), et, imm);
16930 enum neon_shape rs;
16931 struct neon_type_el et;
16933 if (ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext))
16935 rs = neon_select_shape (NS_QQQ, NS_QQR, NS_NULL);
16936 et = neon_check_type (3, rs, N_EQK, N_SU_MVE | N_KEY, N_EQK | N_EQK);
16940 rs = neon_select_shape (NS_DDD, NS_QQQ, NS_NULL);
16941 et = neon_check_type (3, rs, N_EQK, N_SU_ALL | N_KEY, N_EQK | N_SGN);
16946 constraint (inst.operands[0].reg != inst.operands[1].reg,
16947 _("invalid instruction shape"));
16948 if (inst.operands[2].reg == REG_SP)
16949 as_tsktsk (MVE_BAD_SP);
16950 else if (inst.operands[2].reg == REG_PC)
16951 as_tsktsk (MVE_BAD_PC);
16953 inst.instruction = 0xee311ee0;
16954 inst.instruction |= (et.type == NT_unsigned) << 28;
16955 inst.instruction |= HI1 (inst.operands[0].reg) << 22;
16956 inst.instruction |= neon_logbits (et.size) << 18;
16957 inst.instruction |= LOW4 (inst.operands[0].reg) << 12;
16958 inst.instruction |= inst.operands[2].reg;
16965 /* See note in do_neon_shl. */
16966 tmp = inst.operands[2].reg;
16967 inst.operands[2].reg = inst.operands[1].reg;
16968 inst.operands[1].reg = tmp;
16969 NEON_ENCODE (INTEGER, inst);
16970 neon_three_same (neon_quad (rs), et.type == NT_unsigned, et.size);
16976 do_neon_rshl (void)
16978 if (!check_simd_pred_availability (FALSE, NEON_CHECK_ARCH | NEON_CHECK_CC))
16981 enum neon_shape rs;
16982 struct neon_type_el et;
16983 if (ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext))
16985 rs = neon_select_shape (NS_QQR, NS_QQQ, NS_NULL);
16986 et = neon_check_type (3, rs, N_EQK, N_EQK, N_SU_MVE | N_KEY);
16990 rs = neon_select_shape (NS_DDD, NS_QQQ, NS_NULL);
16991 et = neon_check_type (3, rs, N_EQK, N_EQK, N_SU_ALL | N_KEY);
16998 if (inst.operands[2].reg == REG_PC)
16999 as_tsktsk (MVE_BAD_PC);
17000 else if (inst.operands[2].reg == REG_SP)
17001 as_tsktsk (MVE_BAD_SP);
17003 constraint (inst.operands[0].reg != inst.operands[1].reg,
17004 _("invalid instruction shape"));
17006 if (inst.instruction == 0x0000510)
17007 /* We are dealing with vqrshl. */
17008 inst.instruction = 0xee331ee0;
17010 /* We are dealing with vrshl. */
17011 inst.instruction = 0xee331e60;
17013 inst.instruction |= (et.type == NT_unsigned) << 28;
17014 inst.instruction |= HI1 (inst.operands[0].reg) << 22;
17015 inst.instruction |= neon_logbits (et.size) << 18;
17016 inst.instruction |= LOW4 (inst.operands[0].reg) << 12;
17017 inst.instruction |= inst.operands[2].reg;
17022 tmp = inst.operands[2].reg;
17023 inst.operands[2].reg = inst.operands[1].reg;
17024 inst.operands[1].reg = tmp;
17025 neon_three_same (neon_quad (rs), et.type == NT_unsigned, et.size);
17030 neon_cmode_for_logic_imm (unsigned immediate, unsigned *immbits, int size)
17032 /* Handle .I8 pseudo-instructions. */
17035 /* Unfortunately, this will make everything apart from zero out-of-range.
17036 FIXME is this the intended semantics? There doesn't seem much point in
17037 accepting .I8 if so. */
17038 immediate |= immediate << 8;
17044 if (immediate == (immediate & 0x000000ff))
17046 *immbits = immediate;
17049 else if (immediate == (immediate & 0x0000ff00))
17051 *immbits = immediate >> 8;
17054 else if (immediate == (immediate & 0x00ff0000))
17056 *immbits = immediate >> 16;
17059 else if (immediate == (immediate & 0xff000000))
17061 *immbits = immediate >> 24;
17064 if ((immediate & 0xffff) != (immediate >> 16))
17065 goto bad_immediate;
17066 immediate &= 0xffff;
17069 if (immediate == (immediate & 0x000000ff))
17071 *immbits = immediate;
17074 else if (immediate == (immediate & 0x0000ff00))
17076 *immbits = immediate >> 8;
17081 first_error (_("immediate value out of range"));
17086 do_neon_logic (void)
17088 if (inst.operands[2].present && inst.operands[2].isreg)
17090 enum neon_shape rs = neon_select_shape (NS_DDD, NS_QQQ, NS_NULL);
17092 && !check_simd_pred_availability (FALSE,
17093 NEON_CHECK_ARCH | NEON_CHECK_CC))
17095 else if (rs != NS_QQQ
17096 && !ARM_CPU_HAS_FEATURE (cpu_variant, fpu_neon_ext_v1))
17097 first_error (BAD_FPU);
17099 neon_check_type (3, rs, N_IGNORE_TYPE);
17100 /* U bit and size field were set as part of the bitmask. */
17101 NEON_ENCODE (INTEGER, inst);
17102 neon_three_same (neon_quad (rs), 0, -1);
17106 const int three_ops_form = (inst.operands[2].present
17107 && !inst.operands[2].isreg);
17108 const int immoperand = (three_ops_form ? 2 : 1);
17109 enum neon_shape rs = (three_ops_form
17110 ? neon_select_shape (NS_DDI, NS_QQI, NS_NULL)
17111 : neon_select_shape (NS_DI, NS_QI, NS_NULL));
17112 /* Because neon_select_shape makes the second operand a copy of the first
17113 if the second operand is not present. */
17115 && !check_simd_pred_availability (FALSE,
17116 NEON_CHECK_ARCH | NEON_CHECK_CC))
17118 else if (rs != NS_QQI
17119 && !ARM_CPU_HAS_FEATURE (cpu_variant, fpu_neon_ext_v1))
17120 first_error (BAD_FPU);
17122 struct neon_type_el et;
17123 if (ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext))
17124 et = neon_check_type (2, rs, N_I32 | N_I16 | N_KEY, N_EQK);
17126 et = neon_check_type (2, rs, N_I8 | N_I16 | N_I32 | N_I64 | N_F32
17129 if (et.type == NT_invtype)
17131 enum neon_opc opcode = (enum neon_opc) inst.instruction & 0x0fffffff;
17136 if (three_ops_form)
17137 constraint (inst.operands[0].reg != inst.operands[1].reg,
17138 _("first and second operands shall be the same register"));
17140 NEON_ENCODE (IMMED, inst);
17142 immbits = inst.operands[immoperand].imm;
17145 /* .i64 is a pseudo-op, so the immediate must be a repeating
17147 if (immbits != (inst.operands[immoperand].regisimm ?
17148 inst.operands[immoperand].reg : 0))
17150 /* Set immbits to an invalid constant. */
17151 immbits = 0xdeadbeef;
17158 cmode = neon_cmode_for_logic_imm (immbits, &immbits, et.size);
17162 cmode = neon_cmode_for_logic_imm (immbits, &immbits, et.size);
17166 /* Pseudo-instruction for VBIC. */
17167 neon_invert_size (&immbits, 0, et.size);
17168 cmode = neon_cmode_for_logic_imm (immbits, &immbits, et.size);
17172 /* Pseudo-instruction for VORR. */
17173 neon_invert_size (&immbits, 0, et.size);
17174 cmode = neon_cmode_for_logic_imm (immbits, &immbits, et.size);
17184 inst.instruction |= neon_quad (rs) << 6;
17185 inst.instruction |= LOW4 (inst.operands[0].reg) << 12;
17186 inst.instruction |= HI1 (inst.operands[0].reg) << 22;
17187 inst.instruction |= cmode << 8;
17188 neon_write_immbits (immbits);
17190 neon_dp_fixup (&inst);
17195 do_neon_bitfield (void)
17197 enum neon_shape rs = neon_select_shape (NS_DDD, NS_QQQ, NS_NULL);
17198 neon_check_type (3, rs, N_IGNORE_TYPE);
17199 neon_three_same (neon_quad (rs), 0, -1);
17203 neon_dyadic_misc (enum neon_el_type ubit_meaning, unsigned types,
17206 enum neon_shape rs = neon_select_shape (NS_DDD, NS_QQQ, NS_QQR, NS_NULL);
17207 struct neon_type_el et = neon_check_type (3, rs, N_EQK | destbits, N_EQK,
17209 if (et.type == NT_float)
17211 NEON_ENCODE (FLOAT, inst);
17213 mve_encode_qqr (et.size, 0, 1);
17215 neon_three_same (neon_quad (rs), 0, et.size == 16 ? (int) et.size : -1);
17219 NEON_ENCODE (INTEGER, inst);
17221 mve_encode_qqr (et.size, et.type == ubit_meaning, 0);
17223 neon_three_same (neon_quad (rs), et.type == ubit_meaning, et.size);
17229 do_neon_dyadic_if_su_d (void)
17231 /* This version only allow D registers, but that constraint is enforced during
17232 operand parsing so we don't need to do anything extra here. */
17233 neon_dyadic_misc (NT_unsigned, N_SUF_32, 0);
17237 do_neon_dyadic_if_i_d (void)
17239 /* The "untyped" case can't happen. Do this to stop the "U" bit being
17240 affected if we specify unsigned args. */
17241 neon_dyadic_misc (NT_untyped, N_IF_32, 0);
17245 do_mve_vstr_vldr_QI (int size, int elsize, int load)
17247 constraint (size < 32, BAD_ADDR_MODE);
17248 constraint (size != elsize, BAD_EL_TYPE);
17249 constraint (inst.operands[1].immisreg, BAD_ADDR_MODE);
17250 constraint (!inst.operands[1].preind, BAD_ADDR_MODE);
17251 constraint (load && inst.operands[0].reg == inst.operands[1].reg,
17252 _("destination register and offset register may not be the"
17255 int imm = inst.relocs[0].exp.X_add_number;
17262 constraint ((imm % (size / 8) != 0)
17263 || imm > (0x7f << neon_logbits (size)),
17264 (size == 32) ? _("immediate must be a multiple of 4 in the"
17265 " range of +/-[0,508]")
17266 : _("immediate must be a multiple of 8 in the"
17267 " range of +/-[0,1016]"));
17268 inst.instruction |= 0x11 << 24;
17269 inst.instruction |= add << 23;
17270 inst.instruction |= HI1 (inst.operands[0].reg) << 22;
17271 inst.instruction |= inst.operands[1].writeback << 21;
17272 inst.instruction |= LOW4 (inst.operands[1].reg) << 16;
17273 inst.instruction |= LOW4 (inst.operands[0].reg) << 12;
17274 inst.instruction |= 1 << 12;
17275 inst.instruction |= (size == 64) << 8;
17276 inst.instruction &= 0xffffff00;
17277 inst.instruction |= HI1 (inst.operands[1].reg) << 7;
17278 inst.instruction |= imm >> neon_logbits (size);
17282 do_mve_vstr_vldr_RQ (int size, int elsize, int load)
17284 unsigned os = inst.operands[1].imm >> 5;
17285 constraint (os != 0 && size == 8,
17286 _("can not shift offsets when accessing less than half-word"));
17287 constraint (os && os != neon_logbits (size),
17288 _("shift immediate must be 1, 2 or 3 for half-word, word"
17289 " or double-word accesses respectively"));
17290 if (inst.operands[1].reg == REG_PC)
17291 as_tsktsk (MVE_BAD_PC);
17296 constraint (elsize >= 64, BAD_EL_TYPE);
17299 constraint (elsize < 16 || elsize >= 64, BAD_EL_TYPE);
17303 constraint (elsize != size, BAD_EL_TYPE);
17308 constraint (inst.operands[1].writeback || !inst.operands[1].preind,
17312 constraint (inst.operands[0].reg == (inst.operands[1].imm & 0x1f),
17313 _("destination register and offset register may not be"
17315 constraint (size == elsize && inst.vectype.el[0].type != NT_unsigned,
17317 constraint (inst.vectype.el[0].type != NT_unsigned
17318 && inst.vectype.el[0].type != NT_signed, BAD_EL_TYPE);
17319 inst.instruction |= (inst.vectype.el[0].type == NT_unsigned) << 28;
17323 constraint (inst.vectype.el[0].type != NT_untyped, BAD_EL_TYPE);
17326 inst.instruction |= 1 << 23;
17327 inst.instruction |= HI1 (inst.operands[0].reg) << 22;
17328 inst.instruction |= inst.operands[1].reg << 16;
17329 inst.instruction |= LOW4 (inst.operands[0].reg) << 12;
17330 inst.instruction |= neon_logbits (elsize) << 7;
17331 inst.instruction |= HI1 (inst.operands[1].imm) << 5;
17332 inst.instruction |= LOW4 (inst.operands[1].imm);
17333 inst.instruction |= !!os;
17337 do_mve_vstr_vldr_RI (int size, int elsize, int load)
17339 enum neon_el_type type = inst.vectype.el[0].type;
17341 constraint (size >= 64, BAD_ADDR_MODE);
17345 constraint (elsize < 16 || elsize >= 64, BAD_EL_TYPE);
17348 constraint (elsize != size, BAD_EL_TYPE);
17355 constraint (elsize != size && type != NT_unsigned
17356 && type != NT_signed, BAD_EL_TYPE);
17360 constraint (elsize != size && type != NT_untyped, BAD_EL_TYPE);
17363 int imm = inst.relocs[0].exp.X_add_number;
17371 if ((imm % (size / 8) != 0) || imm > (0x7f << neon_logbits (size)))
17376 constraint (1, _("immediate must be in the range of +/-[0,127]"));
17379 constraint (1, _("immediate must be a multiple of 2 in the"
17380 " range of +/-[0,254]"));
17383 constraint (1, _("immediate must be a multiple of 4 in the"
17384 " range of +/-[0,508]"));
17389 if (size != elsize)
17391 constraint (inst.operands[1].reg > 7, BAD_HIREG);
17392 constraint (inst.operands[0].reg > 14,
17393 _("MVE vector register in the range [Q0..Q7] expected"));
17394 inst.instruction |= (load && type == NT_unsigned) << 28;
17395 inst.instruction |= (size == 16) << 19;
17396 inst.instruction |= neon_logbits (elsize) << 7;
17400 if (inst.operands[1].reg == REG_PC)
17401 as_tsktsk (MVE_BAD_PC);
17402 else if (inst.operands[1].reg == REG_SP && inst.operands[1].writeback)
17403 as_tsktsk (MVE_BAD_SP);
17404 inst.instruction |= 1 << 12;
17405 inst.instruction |= neon_logbits (size) << 7;
17407 inst.instruction |= inst.operands[1].preind << 24;
17408 inst.instruction |= add << 23;
17409 inst.instruction |= HI1 (inst.operands[0].reg) << 22;
17410 inst.instruction |= inst.operands[1].writeback << 21;
17411 inst.instruction |= inst.operands[1].reg << 16;
17412 inst.instruction |= LOW4 (inst.operands[0].reg) << 12;
17413 inst.instruction &= 0xffffff80;
17414 inst.instruction |= imm >> neon_logbits (size);
17419 do_mve_vstr_vldr (void)
17424 if (inst.cond > COND_ALWAYS)
17425 inst.pred_insn_type = INSIDE_VPT_INSN;
17427 inst.pred_insn_type = MVE_OUTSIDE_PRED_INSN;
17429 switch (inst.instruction)
17436 /* fall through. */
17442 /* fall through. */
17448 /* fall through. */
17454 /* fall through. */
17459 unsigned elsize = inst.vectype.el[0].size;
17461 if (inst.operands[1].isquad)
17463 /* We are dealing with [Q, imm]{!} cases. */
17464 do_mve_vstr_vldr_QI (size, elsize, load);
17468 if (inst.operands[1].immisreg == 2)
17470 /* We are dealing with [R, Q, {UXTW #os}] cases. */
17471 do_mve_vstr_vldr_RQ (size, elsize, load);
17473 else if (!inst.operands[1].immisreg)
17475 /* We are dealing with [R, Imm]{!}/[R], Imm cases. */
17476 do_mve_vstr_vldr_RI (size, elsize, load);
17479 constraint (1, BAD_ADDR_MODE);
17486 do_mve_vst_vld (void)
17488 if (!ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext))
17491 constraint (!inst.operands[1].preind || inst.relocs[0].exp.X_add_symbol != 0
17492 || inst.relocs[0].exp.X_add_number != 0
17493 || inst.operands[1].immisreg != 0,
17495 constraint (inst.vectype.el[0].size > 32, BAD_EL_TYPE);
17496 if (inst.operands[1].reg == REG_PC)
17497 as_tsktsk (MVE_BAD_PC);
17498 else if (inst.operands[1].reg == REG_SP && inst.operands[1].writeback)
17499 as_tsktsk (MVE_BAD_SP);
17502 /* These instructions are one of the "exceptions" mentioned in
17503 handle_pred_state. They are MVE instructions that are not VPT compatible
17504 and do not accept a VPT code, thus appending such a code is a syntax
17506 if (inst.cond > COND_ALWAYS)
17507 first_error (BAD_SYNTAX);
17508 /* If we append a scalar condition code we can set this to
17509 MVE_OUTSIDE_PRED_INSN as it will also lead to a syntax error. */
17510 else if (inst.cond < COND_ALWAYS)
17511 inst.pred_insn_type = MVE_OUTSIDE_PRED_INSN;
17513 inst.pred_insn_type = MVE_UNPREDICABLE_INSN;
17515 inst.instruction |= HI1 (inst.operands[0].reg) << 22;
17516 inst.instruction |= inst.operands[1].writeback << 21;
17517 inst.instruction |= inst.operands[1].reg << 16;
17518 inst.instruction |= LOW4 (inst.operands[0].reg) << 12;
17519 inst.instruction |= neon_logbits (inst.vectype.el[0].size) << 7;
17524 do_mve_vaddlv (void)
17526 enum neon_shape rs = neon_select_shape (NS_RRQ, NS_NULL);
17527 struct neon_type_el et
17528 = neon_check_type (3, rs, N_EQK, N_EQK, N_S32 | N_U32 | N_KEY);
17530 if (et.type == NT_invtype)
17531 first_error (BAD_EL_TYPE);
17533 if (inst.cond > COND_ALWAYS)
17534 inst.pred_insn_type = INSIDE_VPT_INSN;
17536 inst.pred_insn_type = MVE_OUTSIDE_PRED_INSN;
17538 constraint (inst.operands[1].reg > 14, MVE_BAD_QREG);
17540 inst.instruction |= (et.type == NT_unsigned) << 28;
17541 inst.instruction |= inst.operands[1].reg << 19;
17542 inst.instruction |= inst.operands[0].reg << 12;
17543 inst.instruction |= inst.operands[2].reg;
17548 do_neon_dyadic_if_su (void)
17550 enum neon_shape rs = neon_select_shape (NS_DDD, NS_QQQ, NS_QQR, NS_NULL);
17551 struct neon_type_el et = neon_check_type (3, rs, N_EQK , N_EQK,
17554 constraint ((inst.instruction == ((unsigned) N_MNEM_vmax)
17555 || inst.instruction == ((unsigned) N_MNEM_vmin))
17556 && et.type == NT_float
17557 && !ARM_CPU_HAS_FEATURE (cpu_variant,fpu_neon_ext_v1), BAD_FPU);
17559 if (!check_simd_pred_availability (et.type == NT_float,
17560 NEON_CHECK_ARCH | NEON_CHECK_CC))
17563 neon_dyadic_misc (NT_unsigned, N_SUF_32, 0);
17567 do_neon_addsub_if_i (void)
17569 if (ARM_CPU_HAS_FEATURE (cpu_variant, fpu_vfp_ext_v1xd)
17570 && try_vfp_nsyn (3, do_vfp_nsyn_add_sub) == SUCCESS)
17573 enum neon_shape rs = neon_select_shape (NS_DDD, NS_QQQ, NS_QQR, NS_NULL);
17574 struct neon_type_el et = neon_check_type (3, rs, N_EQK,
17575 N_EQK, N_IF_32 | N_I64 | N_KEY);
17577 constraint (rs == NS_QQR && et.size == 64, BAD_FPU);
17578 /* If we are parsing Q registers and the element types match MVE, which NEON
17579 also supports, then we must check whether this is an instruction that can
17580 be used by both MVE/NEON. This distinction can be made based on whether
17581 they are predicated or not. */
17582 if ((rs == NS_QQQ || rs == NS_QQR) && et.size != 64)
17584 if (!check_simd_pred_availability (et.type == NT_float,
17585 NEON_CHECK_ARCH | NEON_CHECK_CC))
17590 /* If they are either in a D register or are using an unsupported. */
17592 && vfp_or_neon_is_neon (NEON_CHECK_CC | NEON_CHECK_ARCH) == FAIL)
17596 /* The "untyped" case can't happen. Do this to stop the "U" bit being
17597 affected if we specify unsigned args. */
17598 neon_dyadic_misc (NT_untyped, N_IF_32 | N_I64, 0);
17601 /* Swaps operands 1 and 2. If operand 1 (optional arg) was omitted, we want the
17603 V<op> A,B (A is operand 0, B is operand 2)
17608 so handle that case specially. */
17611 neon_exchange_operands (void)
17613 if (inst.operands[1].present)
17615 void *scratch = xmalloc (sizeof (inst.operands[0]));
17617 /* Swap operands[1] and operands[2]. */
17618 memcpy (scratch, &inst.operands[1], sizeof (inst.operands[0]));
17619 inst.operands[1] = inst.operands[2];
17620 memcpy (&inst.operands[2], scratch, sizeof (inst.operands[0]));
17625 inst.operands[1] = inst.operands[2];
17626 inst.operands[2] = inst.operands[0];
17631 neon_compare (unsigned regtypes, unsigned immtypes, int invert)
17633 if (inst.operands[2].isreg)
17636 neon_exchange_operands ();
17637 neon_dyadic_misc (NT_unsigned, regtypes, N_SIZ);
17641 enum neon_shape rs = neon_select_shape (NS_DDI, NS_QQI, NS_NULL);
17642 struct neon_type_el et = neon_check_type (2, rs,
17643 N_EQK | N_SIZ, immtypes | N_KEY);
17645 NEON_ENCODE (IMMED, inst);
17646 inst.instruction |= LOW4 (inst.operands[0].reg) << 12;
17647 inst.instruction |= HI1 (inst.operands[0].reg) << 22;
17648 inst.instruction |= LOW4 (inst.operands[1].reg);
17649 inst.instruction |= HI1 (inst.operands[1].reg) << 5;
17650 inst.instruction |= neon_quad (rs) << 6;
17651 inst.instruction |= (et.type == NT_float) << 10;
17652 inst.instruction |= neon_logbits (et.size) << 18;
17654 neon_dp_fixup (&inst);
17661 neon_compare (N_SUF_32, N_S_32 | N_F_16_32, FALSE);
17665 do_neon_cmp_inv (void)
17667 neon_compare (N_SUF_32, N_S_32 | N_F_16_32, TRUE);
17673 neon_compare (N_IF_32, N_IF_32, FALSE);
17676 /* For multiply instructions, we have the possibility of 16-bit or 32-bit
17677 scalars, which are encoded in 5 bits, M : Rm.
17678 For 16-bit scalars, the register is encoded in Rm[2:0] and the index in
17679 M:Rm[3], and for 32-bit scalars, the register is encoded in Rm[3:0] and the
17682 Dot Product instructions are similar to multiply instructions except elsize
17683 should always be 32.
17685 This function translates SCALAR, which is GAS's internal encoding of indexed
17686 scalar register, to raw encoding. There is also register and index range
17687 check based on ELSIZE. */
17690 neon_scalar_for_mul (unsigned scalar, unsigned elsize)
17692 unsigned regno = NEON_SCALAR_REG (scalar);
17693 unsigned elno = NEON_SCALAR_INDEX (scalar);
17698 if (regno > 7 || elno > 3)
17700 return regno | (elno << 3);
17703 if (regno > 15 || elno > 1)
17705 return regno | (elno << 4);
17709 first_error (_("scalar out of range for multiply instruction"));
17715 /* Encode multiply / multiply-accumulate scalar instructions. */
17718 neon_mul_mac (struct neon_type_el et, int ubit)
17722 /* Give a more helpful error message if we have an invalid type. */
17723 if (et.type == NT_invtype)
17726 scalar = neon_scalar_for_mul (inst.operands[2].reg, et.size);
17727 inst.instruction |= LOW4 (inst.operands[0].reg) << 12;
17728 inst.instruction |= HI1 (inst.operands[0].reg) << 22;
17729 inst.instruction |= LOW4 (inst.operands[1].reg) << 16;
17730 inst.instruction |= HI1 (inst.operands[1].reg) << 7;
17731 inst.instruction |= LOW4 (scalar);
17732 inst.instruction |= HI1 (scalar) << 5;
17733 inst.instruction |= (et.type == NT_float) << 8;
17734 inst.instruction |= neon_logbits (et.size) << 20;
17735 inst.instruction |= (ubit != 0) << 24;
17737 neon_dp_fixup (&inst);
17741 do_neon_mac_maybe_scalar (void)
17743 if (try_vfp_nsyn (3, do_vfp_nsyn_mla_mls) == SUCCESS)
17746 if (!check_simd_pred_availability (FALSE, NEON_CHECK_CC | NEON_CHECK_ARCH))
17749 if (inst.operands[2].isscalar)
17751 constraint (ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext), BAD_FPU);
17752 enum neon_shape rs = neon_select_shape (NS_DDS, NS_QQS, NS_NULL);
17753 struct neon_type_el et = neon_check_type (3, rs,
17754 N_EQK, N_EQK, N_I16 | N_I32 | N_F_16_32 | N_KEY);
17755 NEON_ENCODE (SCALAR, inst);
17756 neon_mul_mac (et, neon_quad (rs));
17758 else if (!inst.operands[2].isvec)
17760 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext), BAD_FPU);
17762 enum neon_shape rs = neon_select_shape (NS_QQR, NS_NULL);
17763 neon_check_type (3, rs, N_EQK, N_EQK, N_SU_MVE | N_KEY);
17765 neon_dyadic_misc (NT_unsigned, N_SU_MVE, 0);
17769 constraint (ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext), BAD_FPU);
17770 /* The "untyped" case can't happen. Do this to stop the "U" bit being
17771 affected if we specify unsigned args. */
17772 neon_dyadic_misc (NT_untyped, N_IF_32, 0);
17777 do_neon_fmac (void)
17779 if (ARM_CPU_HAS_FEATURE (cpu_variant, fpu_vfp_ext_fma)
17780 && try_vfp_nsyn (3, do_vfp_nsyn_fma_fms) == SUCCESS)
17783 if (!check_simd_pred_availability (TRUE, NEON_CHECK_CC | NEON_CHECK_ARCH))
17786 if (ARM_CPU_HAS_FEATURE (cpu_variant, mve_fp_ext))
17788 enum neon_shape rs = neon_select_shape (NS_QQQ, NS_QQR, NS_NULL);
17789 struct neon_type_el et = neon_check_type (3, rs, N_F_MVE | N_KEY, N_EQK,
17794 if (inst.operands[2].reg == REG_SP)
17795 as_tsktsk (MVE_BAD_SP);
17796 else if (inst.operands[2].reg == REG_PC)
17797 as_tsktsk (MVE_BAD_PC);
17799 inst.instruction = 0xee310e40;
17800 inst.instruction |= (et.size == 16) << 28;
17801 inst.instruction |= HI1 (inst.operands[0].reg) << 22;
17802 inst.instruction |= LOW4 (inst.operands[1].reg) << 16;
17803 inst.instruction |= LOW4 (inst.operands[0].reg) << 12;
17804 inst.instruction |= HI1 (inst.operands[1].reg) << 6;
17805 inst.instruction |= inst.operands[2].reg;
17812 constraint (!inst.operands[2].isvec, BAD_FPU);
17815 neon_dyadic_misc (NT_untyped, N_IF_32, 0);
17821 enum neon_shape rs = neon_select_shape (NS_DDD, NS_QQQ, NS_NULL);
17822 struct neon_type_el et = neon_check_type (3, rs,
17823 N_EQK, N_EQK, N_8 | N_16 | N_32 | N_KEY);
17824 neon_three_same (neon_quad (rs), 0, et.size);
17827 /* VMUL with 3 registers allows the P8 type. The scalar version supports the
17828 same types as the MAC equivalents. The polynomial type for this instruction
17829 is encoded the same as the integer type. */
17834 if (try_vfp_nsyn (3, do_vfp_nsyn_mul) == SUCCESS)
17837 if (!check_simd_pred_availability (FALSE, NEON_CHECK_CC | NEON_CHECK_ARCH))
17840 if (inst.operands[2].isscalar)
17842 constraint (ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext), BAD_FPU);
17843 do_neon_mac_maybe_scalar ();
17847 if (ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext))
17849 enum neon_shape rs = neon_select_shape (NS_QQR, NS_QQQ, NS_NULL);
17850 struct neon_type_el et
17851 = neon_check_type (3, rs, N_EQK, N_EQK, N_I_MVE | N_F_MVE | N_KEY);
17852 if (et.type == NT_float)
17853 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant, mve_fp_ext),
17856 neon_dyadic_misc (NT_float, N_I_MVE | N_F_MVE, 0);
17860 constraint (!inst.operands[2].isvec, BAD_FPU);
17861 neon_dyadic_misc (NT_poly,
17862 N_I8 | N_I16 | N_I32 | N_F16 | N_F32 | N_P8, 0);
17868 do_neon_qdmulh (void)
17870 if (!check_simd_pred_availability (FALSE, NEON_CHECK_ARCH | NEON_CHECK_CC))
17873 if (inst.operands[2].isscalar)
17875 constraint (ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext), BAD_FPU);
17876 enum neon_shape rs = neon_select_shape (NS_DDS, NS_QQS, NS_NULL);
17877 struct neon_type_el et = neon_check_type (3, rs,
17878 N_EQK, N_EQK, N_S16 | N_S32 | N_KEY);
17879 NEON_ENCODE (SCALAR, inst);
17880 neon_mul_mac (et, neon_quad (rs));
17884 enum neon_shape rs;
17885 struct neon_type_el et;
17886 if (ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext))
17888 rs = neon_select_shape (NS_QQR, NS_QQQ, NS_NULL);
17889 et = neon_check_type (3, rs,
17890 N_EQK, N_EQK, N_S8 | N_S16 | N_S32 | N_KEY);
17894 rs = neon_select_shape (NS_DDD, NS_QQQ, NS_NULL);
17895 et = neon_check_type (3, rs,
17896 N_EQK, N_EQK, N_S16 | N_S32 | N_KEY);
17899 NEON_ENCODE (INTEGER, inst);
17901 mve_encode_qqr (et.size, 0, 0);
17903 /* The U bit (rounding) comes from bit mask. */
17904 neon_three_same (neon_quad (rs), 0, et.size);
17909 do_mve_vaddv (void)
17911 enum neon_shape rs = neon_select_shape (NS_RQ, NS_NULL);
17912 struct neon_type_el et
17913 = neon_check_type (2, rs, N_EQK, N_SU_32 | N_KEY);
17915 if (et.type == NT_invtype)
17916 first_error (BAD_EL_TYPE);
17918 if (inst.cond > COND_ALWAYS)
17919 inst.pred_insn_type = INSIDE_VPT_INSN;
17921 inst.pred_insn_type = MVE_OUTSIDE_PRED_INSN;
17923 constraint (inst.operands[1].reg > 14, MVE_BAD_QREG);
17925 mve_encode_rq (et.type == NT_unsigned, et.size);
17929 do_mve_vhcadd (void)
17931 enum neon_shape rs = neon_select_shape (NS_QQQI, NS_NULL);
17932 struct neon_type_el et
17933 = neon_check_type (3, rs, N_EQK, N_EQK, N_S8 | N_S16 | N_S32 | N_KEY);
17935 if (inst.cond > COND_ALWAYS)
17936 inst.pred_insn_type = INSIDE_VPT_INSN;
17938 inst.pred_insn_type = MVE_OUTSIDE_PRED_INSN;
17940 unsigned rot = inst.relocs[0].exp.X_add_number;
17941 constraint (rot != 90 && rot != 270, _("immediate out of range"));
17943 if (et.size == 32 && inst.operands[0].reg == inst.operands[2].reg)
17944 as_tsktsk (_("Warning: 32-bit element size and same first and third "
17945 "operand makes instruction UNPREDICTABLE"));
17947 mve_encode_qqq (0, et.size);
17948 inst.instruction |= (rot == 270) << 12;
17953 do_mve_vqdmull (void)
17955 enum neon_shape rs = neon_select_shape (NS_QQQ, NS_QQR, NS_NULL);
17956 struct neon_type_el et
17957 = neon_check_type (3, rs, N_EQK, N_EQK, N_S16 | N_S32 | N_KEY);
17960 && (inst.operands[0].reg == inst.operands[1].reg
17961 || (rs == NS_QQQ && inst.operands[0].reg == inst.operands[2].reg)))
17962 as_tsktsk (BAD_MVE_SRCDEST);
17964 if (inst.cond > COND_ALWAYS)
17965 inst.pred_insn_type = INSIDE_VPT_INSN;
17967 inst.pred_insn_type = MVE_OUTSIDE_PRED_INSN;
17971 mve_encode_qqq (et.size == 32, 64);
17972 inst.instruction |= 1;
17976 mve_encode_qqr (64, et.size == 32, 0);
17977 inst.instruction |= 0x3 << 5;
17984 enum neon_shape rs = neon_select_shape (NS_QQQ, NS_NULL);
17985 struct neon_type_el et
17986 = neon_check_type (3, rs, N_KEY | N_I32, N_EQK, N_EQK);
17988 if (et.type == NT_invtype)
17989 first_error (BAD_EL_TYPE);
17991 if (inst.cond > COND_ALWAYS)
17992 inst.pred_insn_type = INSIDE_VPT_INSN;
17994 inst.pred_insn_type = MVE_OUTSIDE_PRED_INSN;
17996 mve_encode_qqq (0, 64);
18000 do_mve_vbrsr (void)
18002 enum neon_shape rs = neon_select_shape (NS_QQR, NS_NULL);
18003 struct neon_type_el et
18004 = neon_check_type (3, rs, N_EQK, N_EQK, N_8 | N_16 | N_32 | N_KEY);
18006 if (inst.cond > COND_ALWAYS)
18007 inst.pred_insn_type = INSIDE_VPT_INSN;
18009 inst.pred_insn_type = MVE_OUTSIDE_PRED_INSN;
18011 mve_encode_qqr (et.size, 0, 0);
18017 neon_check_type (3, NS_QQQ, N_EQK, N_EQK, N_I32 | N_KEY);
18019 if (inst.cond > COND_ALWAYS)
18020 inst.pred_insn_type = INSIDE_VPT_INSN;
18022 inst.pred_insn_type = MVE_OUTSIDE_PRED_INSN;
18024 mve_encode_qqq (1, 64);
18028 do_mve_vmulh (void)
18030 enum neon_shape rs = neon_select_shape (NS_QQQ, NS_NULL);
18031 struct neon_type_el et
18032 = neon_check_type (3, rs, N_EQK, N_EQK, N_SU_MVE | N_KEY);
18034 if (inst.cond > COND_ALWAYS)
18035 inst.pred_insn_type = INSIDE_VPT_INSN;
18037 inst.pred_insn_type = MVE_OUTSIDE_PRED_INSN;
18039 mve_encode_qqq (et.type == NT_unsigned, et.size);
18043 do_mve_vqdmlah (void)
18045 enum neon_shape rs = neon_select_shape (NS_QQR, NS_NULL);
18046 struct neon_type_el et
18047 = neon_check_type (3, rs, N_EQK, N_EQK, N_S_32 | N_KEY);
18049 if (inst.cond > COND_ALWAYS)
18050 inst.pred_insn_type = INSIDE_VPT_INSN;
18052 inst.pred_insn_type = MVE_OUTSIDE_PRED_INSN;
18054 mve_encode_qqr (et.size, et.type == NT_unsigned, 0);
18058 do_mve_vqdmladh (void)
18060 enum neon_shape rs = neon_select_shape (NS_QQQ, NS_NULL);
18061 struct neon_type_el et
18062 = neon_check_type (3, rs, N_EQK, N_EQK, N_S8 | N_S16 | N_S32 | N_KEY);
18064 if (inst.cond > COND_ALWAYS)
18065 inst.pred_insn_type = INSIDE_VPT_INSN;
18067 inst.pred_insn_type = MVE_OUTSIDE_PRED_INSN;
18069 mve_encode_qqq (0, et.size);
18074 do_mve_vmull (void)
18077 enum neon_shape rs = neon_select_shape (NS_HHH, NS_FFF, NS_DDD, NS_DDS,
18078 NS_QQS, NS_QQQ, NS_QQR, NS_NULL);
18079 if (!ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext)
18080 && inst.cond == COND_ALWAYS
18081 && ((unsigned)inst.instruction) == M_MNEM_vmullt)
18086 struct neon_type_el et = neon_check_type (3, rs, N_EQK , N_EQK,
18087 N_SUF_32 | N_F64 | N_P8
18088 | N_P16 | N_I_MVE | N_KEY);
18089 if (((et.type == NT_poly) && et.size == 8
18090 && ARM_CPU_IS_ANY (cpu_variant))
18091 || (et.type == NT_integer) || (et.type == NT_float))
18098 constraint (rs != NS_QQQ, BAD_FPU);
18099 struct neon_type_el et = neon_check_type (3, rs, N_EQK , N_EQK,
18100 N_SU_32 | N_P8 | N_P16 | N_KEY);
18102 /* We are dealing with MVE's vmullt. */
18104 && (inst.operands[0].reg == inst.operands[1].reg
18105 || inst.operands[0].reg == inst.operands[2].reg))
18106 as_tsktsk (BAD_MVE_SRCDEST);
18108 if (inst.cond > COND_ALWAYS)
18109 inst.pred_insn_type = INSIDE_VPT_INSN;
18111 inst.pred_insn_type = MVE_OUTSIDE_PRED_INSN;
18113 if (et.type == NT_poly)
18114 mve_encode_qqq (neon_logbits (et.size), 64);
18116 mve_encode_qqq (et.type == NT_unsigned, et.size);
18121 inst.instruction = N_MNEM_vmul;
18124 inst.pred_insn_type = INSIDE_IT_INSN;
18129 do_mve_vabav (void)
18131 enum neon_shape rs = neon_select_shape (NS_RQQ, NS_NULL);
18136 if (!ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext))
18139 struct neon_type_el et = neon_check_type (2, NS_NULL, N_EQK, N_KEY | N_S8
18140 | N_S16 | N_S32 | N_U8 | N_U16
18143 if (inst.cond > COND_ALWAYS)
18144 inst.pred_insn_type = INSIDE_VPT_INSN;
18146 inst.pred_insn_type = MVE_OUTSIDE_PRED_INSN;
18148 mve_encode_rqq (et.type == NT_unsigned, et.size);
18152 do_mve_vmladav (void)
18154 enum neon_shape rs = neon_select_shape (NS_RQQ, NS_NULL);
18155 struct neon_type_el et = neon_check_type (3, rs,
18156 N_EQK, N_EQK, N_SU_MVE | N_KEY);
18158 if (et.type == NT_unsigned
18159 && (inst.instruction == M_MNEM_vmladavx
18160 || inst.instruction == M_MNEM_vmladavax
18161 || inst.instruction == M_MNEM_vmlsdav
18162 || inst.instruction == M_MNEM_vmlsdava
18163 || inst.instruction == M_MNEM_vmlsdavx
18164 || inst.instruction == M_MNEM_vmlsdavax))
18165 first_error (BAD_SIMD_TYPE);
18167 constraint (inst.operands[2].reg > 14,
18168 _("MVE vector register in the range [Q0..Q7] expected"));
18170 if (inst.cond > COND_ALWAYS)
18171 inst.pred_insn_type = INSIDE_VPT_INSN;
18173 inst.pred_insn_type = MVE_OUTSIDE_PRED_INSN;
18175 if (inst.instruction == M_MNEM_vmlsdav
18176 || inst.instruction == M_MNEM_vmlsdava
18177 || inst.instruction == M_MNEM_vmlsdavx
18178 || inst.instruction == M_MNEM_vmlsdavax)
18179 inst.instruction |= (et.size == 8) << 28;
18181 inst.instruction |= (et.size == 8) << 8;
18183 mve_encode_rqq (et.type == NT_unsigned, 64);
18184 inst.instruction |= (et.size == 32) << 16;
18188 do_mve_vmlaldav (void)
18190 enum neon_shape rs = neon_select_shape (NS_RRQQ, NS_NULL);
18191 struct neon_type_el et
18192 = neon_check_type (4, rs, N_EQK, N_EQK, N_EQK,
18193 N_S16 | N_S32 | N_U16 | N_U32 | N_KEY);
18195 if (et.type == NT_unsigned
18196 && (inst.instruction == M_MNEM_vmlsldav
18197 || inst.instruction == M_MNEM_vmlsldava
18198 || inst.instruction == M_MNEM_vmlsldavx
18199 || inst.instruction == M_MNEM_vmlsldavax))
18200 first_error (BAD_SIMD_TYPE);
18202 if (inst.cond > COND_ALWAYS)
18203 inst.pred_insn_type = INSIDE_VPT_INSN;
18205 inst.pred_insn_type = MVE_OUTSIDE_PRED_INSN;
18207 mve_encode_rrqq (et.type == NT_unsigned, et.size);
18211 do_mve_vrmlaldavh (void)
18213 struct neon_type_el et;
18214 if (inst.instruction == M_MNEM_vrmlsldavh
18215 || inst.instruction == M_MNEM_vrmlsldavha
18216 || inst.instruction == M_MNEM_vrmlsldavhx
18217 || inst.instruction == M_MNEM_vrmlsldavhax)
18219 et = neon_check_type (4, NS_RRQQ, N_EQK, N_EQK, N_EQK, N_S32 | N_KEY);
18220 if (inst.operands[1].reg == REG_SP)
18221 as_tsktsk (MVE_BAD_SP);
18225 if (inst.instruction == M_MNEM_vrmlaldavhx
18226 || inst.instruction == M_MNEM_vrmlaldavhax)
18227 et = neon_check_type (4, NS_RRQQ, N_EQK, N_EQK, N_EQK, N_S32 | N_KEY);
18229 et = neon_check_type (4, NS_RRQQ, N_EQK, N_EQK, N_EQK,
18230 N_U32 | N_S32 | N_KEY);
18231 /* vrmlaldavh's encoding with SP as the second, odd, GPR operand may alias
18232 with vmax/min instructions, making the use of SP in assembly really
18233 nonsensical, so instead of issuing a warning like we do for other uses
18234 of SP for the odd register operand we error out. */
18235 constraint (inst.operands[1].reg == REG_SP, BAD_SP);
18238 /* Make sure we still check the second operand is an odd one and that PC is
18239 disallowed. This because we are parsing for any GPR operand, to be able
18240 to distinguish between giving a warning or an error for SP as described
18242 constraint ((inst.operands[1].reg % 2) != 1, BAD_EVEN);
18243 constraint (inst.operands[1].reg == REG_PC, BAD_PC);
18245 if (inst.cond > COND_ALWAYS)
18246 inst.pred_insn_type = INSIDE_VPT_INSN;
18248 inst.pred_insn_type = MVE_OUTSIDE_PRED_INSN;
18250 mve_encode_rrqq (et.type == NT_unsigned, 0);
18255 do_mve_vmaxnmv (void)
18257 enum neon_shape rs = neon_select_shape (NS_RQ, NS_NULL);
18258 struct neon_type_el et
18259 = neon_check_type (2, rs, N_EQK, N_F_MVE | N_KEY);
18261 if (inst.cond > COND_ALWAYS)
18262 inst.pred_insn_type = INSIDE_VPT_INSN;
18264 inst.pred_insn_type = MVE_OUTSIDE_PRED_INSN;
18266 if (inst.operands[0].reg == REG_SP)
18267 as_tsktsk (MVE_BAD_SP);
18268 else if (inst.operands[0].reg == REG_PC)
18269 as_tsktsk (MVE_BAD_PC);
18271 mve_encode_rq (et.size == 16, 64);
18275 do_mve_vmaxv (void)
18277 enum neon_shape rs = neon_select_shape (NS_RQ, NS_NULL);
18278 struct neon_type_el et;
18280 if (inst.instruction == M_MNEM_vmaxv || inst.instruction == M_MNEM_vminv)
18281 et = neon_check_type (2, rs, N_EQK, N_SU_MVE | N_KEY);
18283 et = neon_check_type (2, rs, N_EQK, N_S8 | N_S16 | N_S32 | N_KEY);
18285 if (inst.cond > COND_ALWAYS)
18286 inst.pred_insn_type = INSIDE_VPT_INSN;
18288 inst.pred_insn_type = MVE_OUTSIDE_PRED_INSN;
18290 if (inst.operands[0].reg == REG_SP)
18291 as_tsktsk (MVE_BAD_SP);
18292 else if (inst.operands[0].reg == REG_PC)
18293 as_tsktsk (MVE_BAD_PC);
18295 mve_encode_rq (et.type == NT_unsigned, et.size);
18300 do_neon_qrdmlah (void)
18302 if (!check_simd_pred_availability (FALSE, NEON_CHECK_ARCH | NEON_CHECK_CC))
18304 if (!ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext))
18306 /* Check we're on the correct architecture. */
18307 if (!mark_feature_used (&fpu_neon_ext_armv8))
18309 = _("instruction form not available on this architecture.");
18310 else if (!mark_feature_used (&fpu_neon_ext_v8_1))
18312 as_warn (_("this instruction implies use of ARMv8.1 AdvSIMD."));
18313 record_feature_use (&fpu_neon_ext_v8_1);
18315 if (inst.operands[2].isscalar)
18317 enum neon_shape rs = neon_select_shape (NS_DDS, NS_QQS, NS_NULL);
18318 struct neon_type_el et = neon_check_type (3, rs,
18319 N_EQK, N_EQK, N_S16 | N_S32 | N_KEY);
18320 NEON_ENCODE (SCALAR, inst);
18321 neon_mul_mac (et, neon_quad (rs));
18325 enum neon_shape rs = neon_select_shape (NS_DDD, NS_QQQ, NS_NULL);
18326 struct neon_type_el et = neon_check_type (3, rs,
18327 N_EQK, N_EQK, N_S16 | N_S32 | N_KEY);
18328 NEON_ENCODE (INTEGER, inst);
18329 /* The U bit (rounding) comes from bit mask. */
18330 neon_three_same (neon_quad (rs), 0, et.size);
18335 enum neon_shape rs = neon_select_shape (NS_QQR, NS_NULL);
18336 struct neon_type_el et
18337 = neon_check_type (3, rs, N_EQK, N_EQK, N_S_32 | N_KEY);
18339 NEON_ENCODE (INTEGER, inst);
18340 mve_encode_qqr (et.size, et.type == NT_unsigned, 0);
18345 do_neon_fcmp_absolute (void)
18347 enum neon_shape rs = neon_select_shape (NS_DDD, NS_QQQ, NS_NULL);
18348 struct neon_type_el et = neon_check_type (3, rs, N_EQK, N_EQK,
18349 N_F_16_32 | N_KEY);
18350 /* Size field comes from bit mask. */
18351 neon_three_same (neon_quad (rs), 1, et.size == 16 ? (int) et.size : -1);
18355 do_neon_fcmp_absolute_inv (void)
18357 neon_exchange_operands ();
18358 do_neon_fcmp_absolute ();
18362 do_neon_step (void)
18364 enum neon_shape rs = neon_select_shape (NS_DDD, NS_QQQ, NS_NULL);
18365 struct neon_type_el et = neon_check_type (3, rs, N_EQK, N_EQK,
18366 N_F_16_32 | N_KEY);
18367 neon_three_same (neon_quad (rs), 0, et.size == 16 ? (int) et.size : -1);
18371 do_neon_abs_neg (void)
18373 enum neon_shape rs;
18374 struct neon_type_el et;
18376 if (try_vfp_nsyn (2, do_vfp_nsyn_abs_neg) == SUCCESS)
18379 rs = neon_select_shape (NS_DD, NS_QQ, NS_NULL);
18380 et = neon_check_type (2, rs, N_EQK, N_S_32 | N_F_16_32 | N_KEY);
18382 if (!check_simd_pred_availability (et.type == NT_float,
18383 NEON_CHECK_ARCH | NEON_CHECK_CC))
18386 inst.instruction |= LOW4 (inst.operands[0].reg) << 12;
18387 inst.instruction |= HI1 (inst.operands[0].reg) << 22;
18388 inst.instruction |= LOW4 (inst.operands[1].reg);
18389 inst.instruction |= HI1 (inst.operands[1].reg) << 5;
18390 inst.instruction |= neon_quad (rs) << 6;
18391 inst.instruction |= (et.type == NT_float) << 10;
18392 inst.instruction |= neon_logbits (et.size) << 18;
18394 neon_dp_fixup (&inst);
18400 if (!check_simd_pred_availability (FALSE, NEON_CHECK_ARCH | NEON_CHECK_CC))
18403 enum neon_shape rs;
18404 struct neon_type_el et;
18405 if (ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext))
18407 rs = neon_select_shape (NS_QQI, NS_NULL);
18408 et = neon_check_type (2, rs, N_EQK, N_8 | N_16 | N_32 | N_KEY);
18412 rs = neon_select_shape (NS_DDI, NS_QQI, NS_NULL);
18413 et = neon_check_type (2, rs, N_EQK, N_8 | N_16 | N_32 | N_64 | N_KEY);
18417 int imm = inst.operands[2].imm;
18418 constraint (imm < 0 || (unsigned)imm >= et.size,
18419 _("immediate out of range for insert"));
18420 neon_imm_shift (FALSE, 0, neon_quad (rs), et, imm);
18426 if (!check_simd_pred_availability (FALSE, NEON_CHECK_ARCH | NEON_CHECK_CC))
18429 enum neon_shape rs;
18430 struct neon_type_el et;
18431 if (ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext))
18433 rs = neon_select_shape (NS_QQI, NS_NULL);
18434 et = neon_check_type (2, rs, N_EQK, N_8 | N_16 | N_32 | N_KEY);
18438 rs = neon_select_shape (NS_DDI, NS_QQI, NS_NULL);
18439 et = neon_check_type (2, rs, N_EQK, N_8 | N_16 | N_32 | N_64 | N_KEY);
18442 int imm = inst.operands[2].imm;
18443 constraint (imm < 1 || (unsigned)imm > et.size,
18444 _("immediate out of range for insert"));
18445 neon_imm_shift (FALSE, 0, neon_quad (rs), et, et.size - imm);
18449 do_neon_qshlu_imm (void)
18451 if (!check_simd_pred_availability (FALSE, NEON_CHECK_ARCH | NEON_CHECK_CC))
18454 enum neon_shape rs;
18455 struct neon_type_el et;
18456 if (ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext))
18458 rs = neon_select_shape (NS_QQI, NS_NULL);
18459 et = neon_check_type (2, rs, N_EQK, N_S8 | N_S16 | N_S32 | N_KEY);
18463 rs = neon_select_shape (NS_DDI, NS_QQI, NS_NULL);
18464 et = neon_check_type (2, rs, N_EQK | N_UNS,
18465 N_S8 | N_S16 | N_S32 | N_S64 | N_KEY);
18468 int imm = inst.operands[2].imm;
18469 constraint (imm < 0 || (unsigned)imm >= et.size,
18470 _("immediate out of range for shift"));
18471 /* Only encodes the 'U present' variant of the instruction.
18472 In this case, signed types have OP (bit 8) set to 0.
18473 Unsigned types have OP set to 1. */
18474 inst.instruction |= (et.type == NT_unsigned) << 8;
18475 /* The rest of the bits are the same as other immediate shifts. */
18476 neon_imm_shift (FALSE, 0, neon_quad (rs), et, imm);
18480 do_neon_qmovn (void)
18482 struct neon_type_el et = neon_check_type (2, NS_DQ,
18483 N_EQK | N_HLF, N_SU_16_64 | N_KEY);
18484 /* Saturating move where operands can be signed or unsigned, and the
18485 destination has the same signedness. */
18486 NEON_ENCODE (INTEGER, inst);
18487 if (et.type == NT_unsigned)
18488 inst.instruction |= 0xc0;
18490 inst.instruction |= 0x80;
18491 neon_two_same (0, 1, et.size / 2);
18495 do_neon_qmovun (void)
18497 struct neon_type_el et = neon_check_type (2, NS_DQ,
18498 N_EQK | N_HLF | N_UNS, N_S16 | N_S32 | N_S64 | N_KEY);
18499 /* Saturating move with unsigned results. Operands must be signed. */
18500 NEON_ENCODE (INTEGER, inst);
18501 neon_two_same (0, 1, et.size / 2);
18505 do_neon_rshift_sat_narrow (void)
18507 /* FIXME: Types for narrowing. If operands are signed, results can be signed
18508 or unsigned. If operands are unsigned, results must also be unsigned. */
18509 struct neon_type_el et = neon_check_type (2, NS_DQI,
18510 N_EQK | N_HLF, N_SU_16_64 | N_KEY);
18511 int imm = inst.operands[2].imm;
18512 /* This gets the bounds check, size encoding and immediate bits calculation
18516 /* VQ{R}SHRN.I<size> <Dd>, <Qm>, #0 is a synonym for
18517 VQMOVN.I<size> <Dd>, <Qm>. */
18520 inst.operands[2].present = 0;
18521 inst.instruction = N_MNEM_vqmovn;
18526 constraint (imm < 1 || (unsigned)imm > et.size,
18527 _("immediate out of range"));
18528 neon_imm_shift (TRUE, et.type == NT_unsigned, 0, et, et.size - imm);
18532 do_neon_rshift_sat_narrow_u (void)
18534 /* FIXME: Types for narrowing. If operands are signed, results can be signed
18535 or unsigned. If operands are unsigned, results must also be unsigned. */
18536 struct neon_type_el et = neon_check_type (2, NS_DQI,
18537 N_EQK | N_HLF | N_UNS, N_S16 | N_S32 | N_S64 | N_KEY);
18538 int imm = inst.operands[2].imm;
18539 /* This gets the bounds check, size encoding and immediate bits calculation
18543 /* VQSHRUN.I<size> <Dd>, <Qm>, #0 is a synonym for
18544 VQMOVUN.I<size> <Dd>, <Qm>. */
18547 inst.operands[2].present = 0;
18548 inst.instruction = N_MNEM_vqmovun;
18553 constraint (imm < 1 || (unsigned)imm > et.size,
18554 _("immediate out of range"));
18555 /* FIXME: The manual is kind of unclear about what value U should have in
18556 VQ{R}SHRUN instructions, but U=0, op=0 definitely encodes VRSHR, so it
18558 neon_imm_shift (TRUE, 1, 0, et, et.size - imm);
18562 do_neon_movn (void)
18564 struct neon_type_el et = neon_check_type (2, NS_DQ,
18565 N_EQK | N_HLF, N_I16 | N_I32 | N_I64 | N_KEY);
18566 NEON_ENCODE (INTEGER, inst);
18567 neon_two_same (0, 1, et.size / 2);
18571 do_neon_rshift_narrow (void)
18573 struct neon_type_el et = neon_check_type (2, NS_DQI,
18574 N_EQK | N_HLF, N_I16 | N_I32 | N_I64 | N_KEY);
18575 int imm = inst.operands[2].imm;
18576 /* This gets the bounds check, size encoding and immediate bits calculation
18580 /* If immediate is zero then we are a pseudo-instruction for
18581 VMOVN.I<size> <Dd>, <Qm> */
18584 inst.operands[2].present = 0;
18585 inst.instruction = N_MNEM_vmovn;
18590 constraint (imm < 1 || (unsigned)imm > et.size,
18591 _("immediate out of range for narrowing operation"));
18592 neon_imm_shift (FALSE, 0, 0, et, et.size - imm);
18596 do_neon_shll (void)
18598 /* FIXME: Type checking when lengthening. */
18599 struct neon_type_el et = neon_check_type (2, NS_QDI,
18600 N_EQK | N_DBL, N_I8 | N_I16 | N_I32 | N_KEY);
18601 unsigned imm = inst.operands[2].imm;
18603 if (imm == et.size)
18605 /* Maximum shift variant. */
18606 NEON_ENCODE (INTEGER, inst);
18607 inst.instruction |= LOW4 (inst.operands[0].reg) << 12;
18608 inst.instruction |= HI1 (inst.operands[0].reg) << 22;
18609 inst.instruction |= LOW4 (inst.operands[1].reg);
18610 inst.instruction |= HI1 (inst.operands[1].reg) << 5;
18611 inst.instruction |= neon_logbits (et.size) << 18;
18613 neon_dp_fixup (&inst);
18617 /* A more-specific type check for non-max versions. */
18618 et = neon_check_type (2, NS_QDI,
18619 N_EQK | N_DBL, N_SU_32 | N_KEY);
18620 NEON_ENCODE (IMMED, inst);
18621 neon_imm_shift (TRUE, et.type == NT_unsigned, 0, et, imm);
18625 /* Check the various types for the VCVT instruction, and return which version
18626 the current instruction is. */
18628 #define CVT_FLAVOUR_VAR \
18629 CVT_VAR (s32_f32, N_S32, N_F32, whole_reg, "ftosls", "ftosis", "ftosizs") \
18630 CVT_VAR (u32_f32, N_U32, N_F32, whole_reg, "ftouls", "ftouis", "ftouizs") \
18631 CVT_VAR (f32_s32, N_F32, N_S32, whole_reg, "fsltos", "fsitos", NULL) \
18632 CVT_VAR (f32_u32, N_F32, N_U32, whole_reg, "fultos", "fuitos", NULL) \
18633 /* Half-precision conversions. */ \
18634 CVT_VAR (s16_f16, N_S16, N_F16 | N_KEY, whole_reg, NULL, NULL, NULL) \
18635 CVT_VAR (u16_f16, N_U16, N_F16 | N_KEY, whole_reg, NULL, NULL, NULL) \
18636 CVT_VAR (f16_s16, N_F16 | N_KEY, N_S16, whole_reg, NULL, NULL, NULL) \
18637 CVT_VAR (f16_u16, N_F16 | N_KEY, N_U16, whole_reg, NULL, NULL, NULL) \
18638 CVT_VAR (f32_f16, N_F32, N_F16, whole_reg, NULL, NULL, NULL) \
18639 CVT_VAR (f16_f32, N_F16, N_F32, whole_reg, NULL, NULL, NULL) \
18640 /* New VCVT instructions introduced by ARMv8.2 fp16 extension. \
18641 Compared with single/double precision variants, only the co-processor \
18642 field is different, so the encoding flow is reused here. */ \
18643 CVT_VAR (f16_s32, N_F16 | N_KEY, N_S32, N_VFP, "fsltos", "fsitos", NULL) \
18644 CVT_VAR (f16_u32, N_F16 | N_KEY, N_U32, N_VFP, "fultos", "fuitos", NULL) \
18645 CVT_VAR (u32_f16, N_U32, N_F16 | N_KEY, N_VFP, "ftouls", "ftouis", "ftouizs")\
18646 CVT_VAR (s32_f16, N_S32, N_F16 | N_KEY, N_VFP, "ftosls", "ftosis", "ftosizs")\
18647 /* VFP instructions. */ \
18648 CVT_VAR (f32_f64, N_F32, N_F64, N_VFP, NULL, "fcvtsd", NULL) \
18649 CVT_VAR (f64_f32, N_F64, N_F32, N_VFP, NULL, "fcvtds", NULL) \
18650 CVT_VAR (s32_f64, N_S32, N_F64 | key, N_VFP, "ftosld", "ftosid", "ftosizd") \
18651 CVT_VAR (u32_f64, N_U32, N_F64 | key, N_VFP, "ftould", "ftouid", "ftouizd") \
18652 CVT_VAR (f64_s32, N_F64 | key, N_S32, N_VFP, "fsltod", "fsitod", NULL) \
18653 CVT_VAR (f64_u32, N_F64 | key, N_U32, N_VFP, "fultod", "fuitod", NULL) \
18654 /* VFP instructions with bitshift. */ \
18655 CVT_VAR (f32_s16, N_F32 | key, N_S16, N_VFP, "fshtos", NULL, NULL) \
18656 CVT_VAR (f32_u16, N_F32 | key, N_U16, N_VFP, "fuhtos", NULL, NULL) \
18657 CVT_VAR (f64_s16, N_F64 | key, N_S16, N_VFP, "fshtod", NULL, NULL) \
18658 CVT_VAR (f64_u16, N_F64 | key, N_U16, N_VFP, "fuhtod", NULL, NULL) \
18659 CVT_VAR (s16_f32, N_S16, N_F32 | key, N_VFP, "ftoshs", NULL, NULL) \
18660 CVT_VAR (u16_f32, N_U16, N_F32 | key, N_VFP, "ftouhs", NULL, NULL) \
18661 CVT_VAR (s16_f64, N_S16, N_F64 | key, N_VFP, "ftoshd", NULL, NULL) \
18662 CVT_VAR (u16_f64, N_U16, N_F64 | key, N_VFP, "ftouhd", NULL, NULL)
18664 #define CVT_VAR(C, X, Y, R, BSN, CN, ZN) \
18665 neon_cvt_flavour_##C,
18667 /* The different types of conversions we can do. */
18668 enum neon_cvt_flavour
18671 neon_cvt_flavour_invalid,
18672 neon_cvt_flavour_first_fp = neon_cvt_flavour_f32_f64
18677 static enum neon_cvt_flavour
18678 get_neon_cvt_flavour (enum neon_shape rs)
18680 #define CVT_VAR(C,X,Y,R,BSN,CN,ZN) \
18681 et = neon_check_type (2, rs, (R) | (X), (R) | (Y)); \
18682 if (et.type != NT_invtype) \
18684 inst.error = NULL; \
18685 return (neon_cvt_flavour_##C); \
18688 struct neon_type_el et;
18689 unsigned whole_reg = (rs == NS_FFI || rs == NS_FD || rs == NS_DF
18690 || rs == NS_FF) ? N_VFP : 0;
18691 /* The instruction versions which take an immediate take one register
18692 argument, which is extended to the width of the full register. Thus the
18693 "source" and "destination" registers must have the same width. Hack that
18694 here by making the size equal to the key (wider, in this case) operand. */
18695 unsigned key = (rs == NS_QQI || rs == NS_DDI || rs == NS_FFI) ? N_KEY : 0;
18699 return neon_cvt_flavour_invalid;
18714 /* Neon-syntax VFP conversions. */
18717 do_vfp_nsyn_cvt (enum neon_shape rs, enum neon_cvt_flavour flavour)
18719 const char *opname = 0;
18721 if (rs == NS_DDI || rs == NS_QQI || rs == NS_FFI
18722 || rs == NS_FHI || rs == NS_HFI)
18724 /* Conversions with immediate bitshift. */
18725 const char *enc[] =
18727 #define CVT_VAR(C,A,B,R,BSN,CN,ZN) BSN,
18733 if (flavour < (int) ARRAY_SIZE (enc))
18735 opname = enc[flavour];
18736 constraint (inst.operands[0].reg != inst.operands[1].reg,
18737 _("operands 0 and 1 must be the same register"));
18738 inst.operands[1] = inst.operands[2];
18739 memset (&inst.operands[2], '\0', sizeof (inst.operands[2]));
18744 /* Conversions without bitshift. */
18745 const char *enc[] =
18747 #define CVT_VAR(C,A,B,R,BSN,CN,ZN) CN,
18753 if (flavour < (int) ARRAY_SIZE (enc))
18754 opname = enc[flavour];
18758 do_vfp_nsyn_opcode (opname);
18760 /* ARMv8.2 fp16 VCVT instruction. */
18761 if (flavour == neon_cvt_flavour_s32_f16
18762 || flavour == neon_cvt_flavour_u32_f16
18763 || flavour == neon_cvt_flavour_f16_u32
18764 || flavour == neon_cvt_flavour_f16_s32)
18765 do_scalar_fp16_v82_encode ();
18769 do_vfp_nsyn_cvtz (void)
18771 enum neon_shape rs = neon_select_shape (NS_FH, NS_FF, NS_FD, NS_NULL);
18772 enum neon_cvt_flavour flavour = get_neon_cvt_flavour (rs);
18773 const char *enc[] =
18775 #define CVT_VAR(C,A,B,R,BSN,CN,ZN) ZN,
18781 if (flavour < (int) ARRAY_SIZE (enc) && enc[flavour])
18782 do_vfp_nsyn_opcode (enc[flavour]);
18786 do_vfp_nsyn_cvt_fpv8 (enum neon_cvt_flavour flavour,
18787 enum neon_cvt_mode mode)
18792 /* Targets like FPv5-SP-D16 don't support FP v8 instructions with
18793 D register operands. */
18794 if (flavour == neon_cvt_flavour_s32_f64
18795 || flavour == neon_cvt_flavour_u32_f64)
18796 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant, fpu_vfp_ext_armv8),
18799 if (flavour == neon_cvt_flavour_s32_f16
18800 || flavour == neon_cvt_flavour_u32_f16)
18801 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_fp16),
18804 set_pred_insn_type (OUTSIDE_PRED_INSN);
18808 case neon_cvt_flavour_s32_f64:
18812 case neon_cvt_flavour_s32_f32:
18816 case neon_cvt_flavour_s32_f16:
18820 case neon_cvt_flavour_u32_f64:
18824 case neon_cvt_flavour_u32_f32:
18828 case neon_cvt_flavour_u32_f16:
18833 first_error (_("invalid instruction shape"));
18839 case neon_cvt_mode_a: rm = 0; break;
18840 case neon_cvt_mode_n: rm = 1; break;
18841 case neon_cvt_mode_p: rm = 2; break;
18842 case neon_cvt_mode_m: rm = 3; break;
18843 default: first_error (_("invalid rounding mode")); return;
18846 NEON_ENCODE (FPV8, inst);
18847 encode_arm_vfp_reg (inst.operands[0].reg, VFP_REG_Sd);
18848 encode_arm_vfp_reg (inst.operands[1].reg, sz == 1 ? VFP_REG_Dm : VFP_REG_Sm);
18849 inst.instruction |= sz << 8;
18851 /* ARMv8.2 fp16 VCVT instruction. */
18852 if (flavour == neon_cvt_flavour_s32_f16
18853 ||flavour == neon_cvt_flavour_u32_f16)
18854 do_scalar_fp16_v82_encode ();
18855 inst.instruction |= op << 7;
18856 inst.instruction |= rm << 16;
18857 inst.instruction |= 0xf0000000;
18858 inst.is_neon = TRUE;
18862 do_neon_cvt_1 (enum neon_cvt_mode mode)
18864 enum neon_shape rs = neon_select_shape (NS_DDI, NS_QQI, NS_FFI, NS_DD, NS_QQ,
18865 NS_FD, NS_DF, NS_FF, NS_QD, NS_DQ,
18866 NS_FH, NS_HF, NS_FHI, NS_HFI,
18868 enum neon_cvt_flavour flavour = get_neon_cvt_flavour (rs);
18870 if (flavour == neon_cvt_flavour_invalid)
18873 /* PR11109: Handle round-to-zero for VCVT conversions. */
18874 if (mode == neon_cvt_mode_z
18875 && ARM_CPU_HAS_FEATURE (cpu_variant, fpu_arch_vfp_v2)
18876 && (flavour == neon_cvt_flavour_s16_f16
18877 || flavour == neon_cvt_flavour_u16_f16
18878 || flavour == neon_cvt_flavour_s32_f32
18879 || flavour == neon_cvt_flavour_u32_f32
18880 || flavour == neon_cvt_flavour_s32_f64
18881 || flavour == neon_cvt_flavour_u32_f64)
18882 && (rs == NS_FD || rs == NS_FF))
18884 do_vfp_nsyn_cvtz ();
18888 /* ARMv8.2 fp16 VCVT conversions. */
18889 if (mode == neon_cvt_mode_z
18890 && ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_fp16)
18891 && (flavour == neon_cvt_flavour_s32_f16
18892 || flavour == neon_cvt_flavour_u32_f16)
18895 do_vfp_nsyn_cvtz ();
18896 do_scalar_fp16_v82_encode ();
18900 /* VFP rather than Neon conversions. */
18901 if (flavour >= neon_cvt_flavour_first_fp)
18903 if (mode == neon_cvt_mode_x || mode == neon_cvt_mode_z)
18904 do_vfp_nsyn_cvt (rs, flavour);
18906 do_vfp_nsyn_cvt_fpv8 (flavour, mode);
18914 if (mode == neon_cvt_mode_z
18915 && (flavour == neon_cvt_flavour_f16_s16
18916 || flavour == neon_cvt_flavour_f16_u16
18917 || flavour == neon_cvt_flavour_s16_f16
18918 || flavour == neon_cvt_flavour_u16_f16
18919 || flavour == neon_cvt_flavour_f32_u32
18920 || flavour == neon_cvt_flavour_f32_s32
18921 || flavour == neon_cvt_flavour_s32_f32
18922 || flavour == neon_cvt_flavour_u32_f32))
18924 if (!check_simd_pred_availability (TRUE,
18925 NEON_CHECK_CC | NEON_CHECK_ARCH))
18928 else if (mode == neon_cvt_mode_n)
18930 /* We are dealing with vcvt with the 'ne' condition. */
18932 inst.instruction = N_MNEM_vcvt;
18933 do_neon_cvt_1 (neon_cvt_mode_z);
18936 /* fall through. */
18940 unsigned enctab[] = {0x0000100, 0x1000100, 0x0, 0x1000000,
18941 0x0000100, 0x1000100, 0x0, 0x1000000};
18943 if ((rs != NS_QQI || !ARM_CPU_HAS_FEATURE (cpu_variant, mve_fp_ext))
18944 && vfp_or_neon_is_neon (NEON_CHECK_CC | NEON_CHECK_ARCH) == FAIL)
18947 if (ARM_CPU_HAS_FEATURE (cpu_variant, mve_fp_ext))
18949 constraint (inst.operands[2].present && inst.operands[2].imm == 0,
18950 _("immediate value out of range"));
18953 case neon_cvt_flavour_f16_s16:
18954 case neon_cvt_flavour_f16_u16:
18955 case neon_cvt_flavour_s16_f16:
18956 case neon_cvt_flavour_u16_f16:
18957 constraint (inst.operands[2].imm > 16,
18958 _("immediate value out of range"));
18960 case neon_cvt_flavour_f32_u32:
18961 case neon_cvt_flavour_f32_s32:
18962 case neon_cvt_flavour_s32_f32:
18963 case neon_cvt_flavour_u32_f32:
18964 constraint (inst.operands[2].imm > 32,
18965 _("immediate value out of range"));
18968 inst.error = BAD_FPU;
18973 /* Fixed-point conversion with #0 immediate is encoded as an
18974 integer conversion. */
18975 if (inst.operands[2].present && inst.operands[2].imm == 0)
18977 NEON_ENCODE (IMMED, inst);
18978 if (flavour != neon_cvt_flavour_invalid)
18979 inst.instruction |= enctab[flavour];
18980 inst.instruction |= LOW4 (inst.operands[0].reg) << 12;
18981 inst.instruction |= HI1 (inst.operands[0].reg) << 22;
18982 inst.instruction |= LOW4 (inst.operands[1].reg);
18983 inst.instruction |= HI1 (inst.operands[1].reg) << 5;
18984 inst.instruction |= neon_quad (rs) << 6;
18985 inst.instruction |= 1 << 21;
18986 if (flavour < neon_cvt_flavour_s16_f16)
18988 inst.instruction |= 1 << 21;
18989 immbits = 32 - inst.operands[2].imm;
18990 inst.instruction |= immbits << 16;
18994 inst.instruction |= 3 << 20;
18995 immbits = 16 - inst.operands[2].imm;
18996 inst.instruction |= immbits << 16;
18997 inst.instruction &= ~(1 << 9);
19000 neon_dp_fixup (&inst);
19005 if ((mode == neon_cvt_mode_a || mode == neon_cvt_mode_n
19006 || mode == neon_cvt_mode_m || mode == neon_cvt_mode_p)
19007 && (flavour == neon_cvt_flavour_s16_f16
19008 || flavour == neon_cvt_flavour_u16_f16
19009 || flavour == neon_cvt_flavour_s32_f32
19010 || flavour == neon_cvt_flavour_u32_f32))
19012 if (!check_simd_pred_availability (TRUE,
19013 NEON_CHECK_CC | NEON_CHECK_ARCH8))
19016 else if (mode == neon_cvt_mode_z
19017 && (flavour == neon_cvt_flavour_f16_s16
19018 || flavour == neon_cvt_flavour_f16_u16
19019 || flavour == neon_cvt_flavour_s16_f16
19020 || flavour == neon_cvt_flavour_u16_f16
19021 || flavour == neon_cvt_flavour_f32_u32
19022 || flavour == neon_cvt_flavour_f32_s32
19023 || flavour == neon_cvt_flavour_s32_f32
19024 || flavour == neon_cvt_flavour_u32_f32))
19026 if (!check_simd_pred_availability (TRUE,
19027 NEON_CHECK_CC | NEON_CHECK_ARCH))
19030 /* fall through. */
19032 if (mode != neon_cvt_mode_x && mode != neon_cvt_mode_z)
19035 NEON_ENCODE (FLOAT, inst);
19036 if (!check_simd_pred_availability (TRUE,
19037 NEON_CHECK_CC | NEON_CHECK_ARCH8))
19040 inst.instruction |= LOW4 (inst.operands[0].reg) << 12;
19041 inst.instruction |= HI1 (inst.operands[0].reg) << 22;
19042 inst.instruction |= LOW4 (inst.operands[1].reg);
19043 inst.instruction |= HI1 (inst.operands[1].reg) << 5;
19044 inst.instruction |= neon_quad (rs) << 6;
19045 inst.instruction |= (flavour == neon_cvt_flavour_u16_f16
19046 || flavour == neon_cvt_flavour_u32_f32) << 7;
19047 inst.instruction |= mode << 8;
19048 if (flavour == neon_cvt_flavour_u16_f16
19049 || flavour == neon_cvt_flavour_s16_f16)
19050 /* Mask off the original size bits and reencode them. */
19051 inst.instruction = ((inst.instruction & 0xfff3ffff) | (1 << 18));
19054 inst.instruction |= 0xfc000000;
19056 inst.instruction |= 0xf0000000;
19062 unsigned enctab[] = { 0x100, 0x180, 0x0, 0x080,
19063 0x100, 0x180, 0x0, 0x080};
19065 NEON_ENCODE (INTEGER, inst);
19067 if (!ARM_CPU_HAS_FEATURE (cpu_variant, mve_fp_ext))
19069 if (vfp_or_neon_is_neon (NEON_CHECK_CC | NEON_CHECK_ARCH) == FAIL)
19073 if (flavour != neon_cvt_flavour_invalid)
19074 inst.instruction |= enctab[flavour];
19076 inst.instruction |= LOW4 (inst.operands[0].reg) << 12;
19077 inst.instruction |= HI1 (inst.operands[0].reg) << 22;
19078 inst.instruction |= LOW4 (inst.operands[1].reg);
19079 inst.instruction |= HI1 (inst.operands[1].reg) << 5;
19080 inst.instruction |= neon_quad (rs) << 6;
19081 if (flavour >= neon_cvt_flavour_s16_f16
19082 && flavour <= neon_cvt_flavour_f16_u16)
19083 /* Half precision. */
19084 inst.instruction |= 1 << 18;
19086 inst.instruction |= 2 << 18;
19088 neon_dp_fixup (&inst);
19093 /* Half-precision conversions for Advanced SIMD -- neon. */
19096 if (vfp_or_neon_is_neon (NEON_CHECK_CC | NEON_CHECK_ARCH) == FAIL)
19100 && (inst.vectype.el[0].size != 16 || inst.vectype.el[1].size != 32))
19102 as_bad (_("operand size must match register width"));
19107 && ((inst.vectype.el[0].size != 32 || inst.vectype.el[1].size != 16)))
19109 as_bad (_("operand size must match register width"));
19114 inst.instruction = 0x3b60600;
19116 inst.instruction = 0x3b60700;
19118 inst.instruction |= LOW4 (inst.operands[0].reg) << 12;
19119 inst.instruction |= HI1 (inst.operands[0].reg) << 22;
19120 inst.instruction |= LOW4 (inst.operands[1].reg);
19121 inst.instruction |= HI1 (inst.operands[1].reg) << 5;
19122 neon_dp_fixup (&inst);
19126 /* Some VFP conversions go here (s32 <-> f32, u32 <-> f32). */
19127 if (mode == neon_cvt_mode_x || mode == neon_cvt_mode_z)
19128 do_vfp_nsyn_cvt (rs, flavour);
19130 do_vfp_nsyn_cvt_fpv8 (flavour, mode);
19135 do_neon_cvtr (void)
19137 do_neon_cvt_1 (neon_cvt_mode_x);
19143 do_neon_cvt_1 (neon_cvt_mode_z);
19147 do_neon_cvta (void)
19149 do_neon_cvt_1 (neon_cvt_mode_a);
19153 do_neon_cvtn (void)
19155 do_neon_cvt_1 (neon_cvt_mode_n);
19159 do_neon_cvtp (void)
19161 do_neon_cvt_1 (neon_cvt_mode_p);
19165 do_neon_cvtm (void)
19167 do_neon_cvt_1 (neon_cvt_mode_m);
19171 do_neon_cvttb_2 (bfd_boolean t, bfd_boolean to, bfd_boolean is_double)
19174 mark_feature_used (&fpu_vfp_ext_armv8);
19176 encode_arm_vfp_reg (inst.operands[0].reg,
19177 (is_double && !to) ? VFP_REG_Dd : VFP_REG_Sd);
19178 encode_arm_vfp_reg (inst.operands[1].reg,
19179 (is_double && to) ? VFP_REG_Dm : VFP_REG_Sm);
19180 inst.instruction |= to ? 0x10000 : 0;
19181 inst.instruction |= t ? 0x80 : 0;
19182 inst.instruction |= is_double ? 0x100 : 0;
19183 do_vfp_cond_or_thumb ();
19187 do_neon_cvttb_1 (bfd_boolean t)
19189 enum neon_shape rs = neon_select_shape (NS_HF, NS_HD, NS_FH, NS_FF, NS_FD,
19190 NS_DF, NS_DH, NS_QQ, NS_QQI, NS_NULL);
19194 else if (rs == NS_QQ || rs == NS_QQI)
19196 int single_to_half = 0;
19197 if (!check_simd_pred_availability (TRUE, NEON_CHECK_ARCH))
19200 enum neon_cvt_flavour flavour = get_neon_cvt_flavour (rs);
19202 if (ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext)
19203 && (flavour == neon_cvt_flavour_u16_f16
19204 || flavour == neon_cvt_flavour_s16_f16
19205 || flavour == neon_cvt_flavour_f16_s16
19206 || flavour == neon_cvt_flavour_f16_u16
19207 || flavour == neon_cvt_flavour_u32_f32
19208 || flavour == neon_cvt_flavour_s32_f32
19209 || flavour == neon_cvt_flavour_f32_s32
19210 || flavour == neon_cvt_flavour_f32_u32))
19213 inst.instruction = N_MNEM_vcvt;
19214 set_pred_insn_type (INSIDE_VPT_INSN);
19215 do_neon_cvt_1 (neon_cvt_mode_z);
19218 else if (rs == NS_QQ && flavour == neon_cvt_flavour_f32_f16)
19219 single_to_half = 1;
19220 else if (rs == NS_QQ && flavour != neon_cvt_flavour_f16_f32)
19222 first_error (BAD_FPU);
19226 inst.instruction = 0xee3f0e01;
19227 inst.instruction |= single_to_half << 28;
19228 inst.instruction |= HI1 (inst.operands[0].reg) << 22;
19229 inst.instruction |= LOW4 (inst.operands[0].reg) << 13;
19230 inst.instruction |= t << 12;
19231 inst.instruction |= HI1 (inst.operands[1].reg) << 5;
19232 inst.instruction |= LOW4 (inst.operands[1].reg) << 1;
19235 else if (neon_check_type (2, rs, N_F16, N_F32 | N_VFP).type != NT_invtype)
19238 do_neon_cvttb_2 (t, /*to=*/TRUE, /*is_double=*/FALSE);
19240 else if (neon_check_type (2, rs, N_F32 | N_VFP, N_F16).type != NT_invtype)
19243 do_neon_cvttb_2 (t, /*to=*/FALSE, /*is_double=*/FALSE);
19245 else if (neon_check_type (2, rs, N_F16, N_F64 | N_VFP).type != NT_invtype)
19247 /* The VCVTB and VCVTT instructions with D-register operands
19248 don't work for SP only targets. */
19249 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant, fpu_vfp_ext_armv8),
19253 do_neon_cvttb_2 (t, /*to=*/TRUE, /*is_double=*/TRUE);
19255 else if (neon_check_type (2, rs, N_F64 | N_VFP, N_F16).type != NT_invtype)
19257 /* The VCVTB and VCVTT instructions with D-register operands
19258 don't work for SP only targets. */
19259 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant, fpu_vfp_ext_armv8),
19263 do_neon_cvttb_2 (t, /*to=*/FALSE, /*is_double=*/TRUE);
19270 do_neon_cvtb (void)
19272 do_neon_cvttb_1 (FALSE);
19277 do_neon_cvtt (void)
19279 do_neon_cvttb_1 (TRUE);
19283 neon_move_immediate (void)
19285 enum neon_shape rs = neon_select_shape (NS_DI, NS_QI, NS_NULL);
19286 struct neon_type_el et = neon_check_type (2, rs,
19287 N_I8 | N_I16 | N_I32 | N_I64 | N_F32 | N_KEY, N_EQK);
19288 unsigned immlo, immhi = 0, immbits;
19289 int op, cmode, float_p;
19291 constraint (et.type == NT_invtype,
19292 _("operand size must be specified for immediate VMOV"));
19294 /* We start out as an MVN instruction if OP = 1, MOV otherwise. */
19295 op = (inst.instruction & (1 << 5)) != 0;
19297 immlo = inst.operands[1].imm;
19298 if (inst.operands[1].regisimm)
19299 immhi = inst.operands[1].reg;
19301 constraint (et.size < 32 && (immlo & ~((1 << et.size) - 1)) != 0,
19302 _("immediate has bits set outside the operand size"));
19304 float_p = inst.operands[1].immisfloat;
19306 if ((cmode = neon_cmode_for_move_imm (immlo, immhi, float_p, &immbits, &op,
19307 et.size, et.type)) == FAIL)
19309 /* Invert relevant bits only. */
19310 neon_invert_size (&immlo, &immhi, et.size);
19311 /* Flip from VMOV/VMVN to VMVN/VMOV. Some immediate types are unavailable
19312 with one or the other; those cases are caught by
19313 neon_cmode_for_move_imm. */
19315 if ((cmode = neon_cmode_for_move_imm (immlo, immhi, float_p, &immbits,
19316 &op, et.size, et.type)) == FAIL)
19318 first_error (_("immediate out of range"));
19323 inst.instruction &= ~(1 << 5);
19324 inst.instruction |= op << 5;
19326 inst.instruction |= LOW4 (inst.operands[0].reg) << 12;
19327 inst.instruction |= HI1 (inst.operands[0].reg) << 22;
19328 inst.instruction |= neon_quad (rs) << 6;
19329 inst.instruction |= cmode << 8;
19331 neon_write_immbits (immbits);
19337 if (!check_simd_pred_availability (FALSE, NEON_CHECK_CC | NEON_CHECK_ARCH))
19340 if (inst.operands[1].isreg)
19342 enum neon_shape rs;
19343 if (ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext))
19344 rs = neon_select_shape (NS_QQ, NS_NULL);
19346 rs = neon_select_shape (NS_DD, NS_QQ, NS_NULL);
19348 NEON_ENCODE (INTEGER, inst);
19349 inst.instruction |= LOW4 (inst.operands[0].reg) << 12;
19350 inst.instruction |= HI1 (inst.operands[0].reg) << 22;
19351 inst.instruction |= LOW4 (inst.operands[1].reg);
19352 inst.instruction |= HI1 (inst.operands[1].reg) << 5;
19353 inst.instruction |= neon_quad (rs) << 6;
19357 NEON_ENCODE (IMMED, inst);
19358 neon_move_immediate ();
19361 neon_dp_fixup (&inst);
19363 if (ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext))
19365 constraint (!inst.operands[1].isreg && !inst.operands[0].isquad, BAD_FPU);
19366 constraint ((inst.instruction & 0xd00) == 0xd00,
19367 _("immediate value out of range"));
19371 /* Encode instructions of form:
19373 |28/24|23|22|21 20|19 16|15 12|11 8|7|6|5|4|3 0|
19374 | U |x |D |size | Rn | Rd |x x x x|N|x|M|x| Rm | */
19377 neon_mixed_length (struct neon_type_el et, unsigned size)
19379 inst.instruction |= LOW4 (inst.operands[0].reg) << 12;
19380 inst.instruction |= HI1 (inst.operands[0].reg) << 22;
19381 inst.instruction |= LOW4 (inst.operands[1].reg) << 16;
19382 inst.instruction |= HI1 (inst.operands[1].reg) << 7;
19383 inst.instruction |= LOW4 (inst.operands[2].reg);
19384 inst.instruction |= HI1 (inst.operands[2].reg) << 5;
19385 inst.instruction |= (et.type == NT_unsigned) << 24;
19386 inst.instruction |= neon_logbits (size) << 20;
19388 neon_dp_fixup (&inst);
19392 do_neon_dyadic_long (void)
19394 enum neon_shape rs = neon_select_shape (NS_QDD, NS_QQQ, NS_QQR, NS_NULL);
19397 if (vfp_or_neon_is_neon (NEON_CHECK_ARCH | NEON_CHECK_CC) == FAIL)
19400 NEON_ENCODE (INTEGER, inst);
19401 /* FIXME: Type checking for lengthening op. */
19402 struct neon_type_el et = neon_check_type (3, NS_QDD,
19403 N_EQK | N_DBL, N_EQK, N_SU_32 | N_KEY);
19404 neon_mixed_length (et, et.size);
19406 else if (ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext)
19407 && (inst.cond == 0xf || inst.cond == 0x10))
19409 /* If parsing for MVE, vaddl/vsubl/vabdl{e,t} can only be vadd/vsub/vabd
19410 in an IT block with le/lt conditions. */
19412 if (inst.cond == 0xf)
19414 else if (inst.cond == 0x10)
19417 inst.pred_insn_type = INSIDE_IT_INSN;
19419 if (inst.instruction == N_MNEM_vaddl)
19421 inst.instruction = N_MNEM_vadd;
19422 do_neon_addsub_if_i ();
19424 else if (inst.instruction == N_MNEM_vsubl)
19426 inst.instruction = N_MNEM_vsub;
19427 do_neon_addsub_if_i ();
19429 else if (inst.instruction == N_MNEM_vabdl)
19431 inst.instruction = N_MNEM_vabd;
19432 do_neon_dyadic_if_su ();
19436 first_error (BAD_FPU);
19440 do_neon_abal (void)
19442 struct neon_type_el et = neon_check_type (3, NS_QDD,
19443 N_EQK | N_INT | N_DBL, N_EQK, N_SU_32 | N_KEY);
19444 neon_mixed_length (et, et.size);
19448 neon_mac_reg_scalar_long (unsigned regtypes, unsigned scalartypes)
19450 if (inst.operands[2].isscalar)
19452 struct neon_type_el et = neon_check_type (3, NS_QDS,
19453 N_EQK | N_DBL, N_EQK, regtypes | N_KEY);
19454 NEON_ENCODE (SCALAR, inst);
19455 neon_mul_mac (et, et.type == NT_unsigned);
19459 struct neon_type_el et = neon_check_type (3, NS_QDD,
19460 N_EQK | N_DBL, N_EQK, scalartypes | N_KEY);
19461 NEON_ENCODE (INTEGER, inst);
19462 neon_mixed_length (et, et.size);
19467 do_neon_mac_maybe_scalar_long (void)
19469 neon_mac_reg_scalar_long (N_S16 | N_S32 | N_U16 | N_U32, N_SU_32);
19472 /* Like neon_scalar_for_mul, this function generate Rm encoding from GAS's
19473 internal SCALAR. QUAD_P is 1 if it's for Q format, otherwise it's 0. */
19476 neon_scalar_for_fmac_fp16_long (unsigned scalar, unsigned quad_p)
19478 unsigned regno = NEON_SCALAR_REG (scalar);
19479 unsigned elno = NEON_SCALAR_INDEX (scalar);
19483 if (regno > 7 || elno > 3)
19486 return ((regno & 0x7)
19487 | ((elno & 0x1) << 3)
19488 | (((elno >> 1) & 0x1) << 5));
19492 if (regno > 15 || elno > 1)
19495 return (((regno & 0x1) << 5)
19496 | ((regno >> 1) & 0x7)
19497 | ((elno & 0x1) << 3));
19501 first_error (_("scalar out of range for multiply instruction"));
19506 do_neon_fmac_maybe_scalar_long (int subtype)
19508 enum neon_shape rs;
19510 /* NOTE: vfmal/vfmsl use slightly different NEON three-same encoding. 'size"
19511 field (bits[21:20]) has different meaning. For scalar index variant, it's
19512 used to differentiate add and subtract, otherwise it's with fixed value
19516 if (inst.cond != COND_ALWAYS)
19517 as_warn (_("vfmal/vfmsl with FP16 type cannot be conditional, the "
19518 "behaviour is UNPREDICTABLE"));
19520 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_fp16_fml),
19523 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant, fpu_neon_ext_armv8),
19526 /* vfmal/vfmsl are in three-same D/Q register format or the third operand can
19527 be a scalar index register. */
19528 if (inst.operands[2].isscalar)
19530 high8 = 0xfe000000;
19533 rs = neon_select_shape (NS_DHS, NS_QDS, NS_NULL);
19537 high8 = 0xfc000000;
19540 inst.instruction |= (0x1 << 23);
19541 rs = neon_select_shape (NS_DHH, NS_QDD, NS_NULL);
19544 neon_check_type (3, rs, N_EQK, N_EQK, N_KEY | N_F16);
19546 /* "opcode" from template has included "ubit", so simply pass 0 here. Also,
19547 the "S" bit in size field has been reused to differentiate vfmal and vfmsl,
19548 so we simply pass -1 as size. */
19549 unsigned quad_p = (rs == NS_QDD || rs == NS_QDS);
19550 neon_three_same (quad_p, 0, size);
19552 /* Undo neon_dp_fixup. Redo the high eight bits. */
19553 inst.instruction &= 0x00ffffff;
19554 inst.instruction |= high8;
19556 #define LOW1(R) ((R) & 0x1)
19557 #define HI4(R) (((R) >> 1) & 0xf)
19558 /* Unlike usually NEON three-same, encoding for Vn and Vm will depend on
19559 whether the instruction is in Q form and whether Vm is a scalar indexed
19561 if (inst.operands[2].isscalar)
19564 = neon_scalar_for_fmac_fp16_long (inst.operands[2].reg, quad_p);
19565 inst.instruction &= 0xffffffd0;
19566 inst.instruction |= rm;
19570 /* Redo Rn as well. */
19571 inst.instruction &= 0xfff0ff7f;
19572 inst.instruction |= HI4 (inst.operands[1].reg) << 16;
19573 inst.instruction |= LOW1 (inst.operands[1].reg) << 7;
19578 /* Redo Rn and Rm. */
19579 inst.instruction &= 0xfff0ff50;
19580 inst.instruction |= HI4 (inst.operands[1].reg) << 16;
19581 inst.instruction |= LOW1 (inst.operands[1].reg) << 7;
19582 inst.instruction |= HI4 (inst.operands[2].reg);
19583 inst.instruction |= LOW1 (inst.operands[2].reg) << 5;
19588 do_neon_vfmal (void)
19590 return do_neon_fmac_maybe_scalar_long (0);
19594 do_neon_vfmsl (void)
19596 return do_neon_fmac_maybe_scalar_long (1);
19600 do_neon_dyadic_wide (void)
19602 struct neon_type_el et = neon_check_type (3, NS_QQD,
19603 N_EQK | N_DBL, N_EQK | N_DBL, N_SU_32 | N_KEY);
19604 neon_mixed_length (et, et.size);
19608 do_neon_dyadic_narrow (void)
19610 struct neon_type_el et = neon_check_type (3, NS_QDD,
19611 N_EQK | N_DBL, N_EQK, N_I16 | N_I32 | N_I64 | N_KEY);
19612 /* Operand sign is unimportant, and the U bit is part of the opcode,
19613 so force the operand type to integer. */
19614 et.type = NT_integer;
19615 neon_mixed_length (et, et.size / 2);
19619 do_neon_mul_sat_scalar_long (void)
19621 neon_mac_reg_scalar_long (N_S16 | N_S32, N_S16 | N_S32);
19625 do_neon_vmull (void)
19627 if (inst.operands[2].isscalar)
19628 do_neon_mac_maybe_scalar_long ();
19631 struct neon_type_el et = neon_check_type (3, NS_QDD,
19632 N_EQK | N_DBL, N_EQK, N_SU_32 | N_P8 | N_P64 | N_KEY);
19634 if (et.type == NT_poly)
19635 NEON_ENCODE (POLY, inst);
19637 NEON_ENCODE (INTEGER, inst);
19639 /* For polynomial encoding the U bit must be zero, and the size must
19640 be 8 (encoded as 0b00) or, on ARMv8 or later 64 (encoded, non
19641 obviously, as 0b10). */
19644 /* Check we're on the correct architecture. */
19645 if (!mark_feature_used (&fpu_crypto_ext_armv8))
19647 _("Instruction form not available on this architecture.");
19652 neon_mixed_length (et, et.size);
19659 enum neon_shape rs = neon_select_shape (NS_DDDI, NS_QQQI, NS_NULL);
19660 struct neon_type_el et = neon_check_type (3, rs,
19661 N_EQK, N_EQK, N_8 | N_16 | N_32 | N_64 | N_KEY);
19662 unsigned imm = (inst.operands[3].imm * et.size) / 8;
19664 constraint (imm >= (unsigned) (neon_quad (rs) ? 16 : 8),
19665 _("shift out of range"));
19666 inst.instruction |= LOW4 (inst.operands[0].reg) << 12;
19667 inst.instruction |= HI1 (inst.operands[0].reg) << 22;
19668 inst.instruction |= LOW4 (inst.operands[1].reg) << 16;
19669 inst.instruction |= HI1 (inst.operands[1].reg) << 7;
19670 inst.instruction |= LOW4 (inst.operands[2].reg);
19671 inst.instruction |= HI1 (inst.operands[2].reg) << 5;
19672 inst.instruction |= neon_quad (rs) << 6;
19673 inst.instruction |= imm << 8;
19675 neon_dp_fixup (&inst);
19681 if (!check_simd_pred_availability (FALSE, NEON_CHECK_ARCH | NEON_CHECK_CC))
19684 enum neon_shape rs;
19685 if (ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext))
19686 rs = neon_select_shape (NS_QQ, NS_NULL);
19688 rs = neon_select_shape (NS_DD, NS_QQ, NS_NULL);
19690 struct neon_type_el et = neon_check_type (2, rs,
19691 N_EQK, N_8 | N_16 | N_32 | N_KEY);
19693 unsigned op = (inst.instruction >> 7) & 3;
19694 /* N (width of reversed regions) is encoded as part of the bitmask. We
19695 extract it here to check the elements to be reversed are smaller.
19696 Otherwise we'd get a reserved instruction. */
19697 unsigned elsize = (op == 2) ? 16 : (op == 1) ? 32 : (op == 0) ? 64 : 0;
19699 if (ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext) && elsize == 64
19700 && inst.operands[0].reg == inst.operands[1].reg)
19701 as_tsktsk (_("Warning: 64-bit element size and same destination and source"
19702 " operands makes instruction UNPREDICTABLE"));
19704 gas_assert (elsize != 0);
19705 constraint (et.size >= elsize,
19706 _("elements must be smaller than reversal region"));
19707 neon_two_same (neon_quad (rs), 1, et.size);
19713 if (inst.operands[1].isscalar)
19715 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant, fpu_neon_ext_v1),
19717 enum neon_shape rs = neon_select_shape (NS_DS, NS_QS, NS_NULL);
19718 struct neon_type_el et = neon_check_type (2, rs,
19719 N_EQK, N_8 | N_16 | N_32 | N_KEY);
19720 unsigned sizebits = et.size >> 3;
19721 unsigned dm = NEON_SCALAR_REG (inst.operands[1].reg);
19722 int logsize = neon_logbits (et.size);
19723 unsigned x = NEON_SCALAR_INDEX (inst.operands[1].reg) << logsize;
19725 if (vfp_or_neon_is_neon (NEON_CHECK_CC) == FAIL)
19728 NEON_ENCODE (SCALAR, inst);
19729 inst.instruction |= LOW4 (inst.operands[0].reg) << 12;
19730 inst.instruction |= HI1 (inst.operands[0].reg) << 22;
19731 inst.instruction |= LOW4 (dm);
19732 inst.instruction |= HI1 (dm) << 5;
19733 inst.instruction |= neon_quad (rs) << 6;
19734 inst.instruction |= x << 17;
19735 inst.instruction |= sizebits << 16;
19737 neon_dp_fixup (&inst);
19741 enum neon_shape rs = neon_select_shape (NS_DR, NS_QR, NS_NULL);
19742 struct neon_type_el et = neon_check_type (2, rs,
19743 N_8 | N_16 | N_32 | N_KEY, N_EQK);
19746 if (!check_simd_pred_availability (FALSE, NEON_CHECK_ARCH))
19750 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant, fpu_neon_ext_v1),
19753 if (ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext))
19755 if (inst.operands[1].reg == REG_SP)
19756 as_tsktsk (MVE_BAD_SP);
19757 else if (inst.operands[1].reg == REG_PC)
19758 as_tsktsk (MVE_BAD_PC);
19761 /* Duplicate ARM register to lanes of vector. */
19762 NEON_ENCODE (ARMREG, inst);
19765 case 8: inst.instruction |= 0x400000; break;
19766 case 16: inst.instruction |= 0x000020; break;
19767 case 32: inst.instruction |= 0x000000; break;
19770 inst.instruction |= LOW4 (inst.operands[1].reg) << 12;
19771 inst.instruction |= LOW4 (inst.operands[0].reg) << 16;
19772 inst.instruction |= HI1 (inst.operands[0].reg) << 7;
19773 inst.instruction |= neon_quad (rs) << 21;
19774 /* The encoding for this instruction is identical for the ARM and Thumb
19775 variants, except for the condition field. */
19776 do_vfp_cond_or_thumb ();
19781 do_mve_mov (int toQ)
19783 if (!ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext))
19785 if (inst.cond > COND_ALWAYS)
19786 inst.pred_insn_type = MVE_UNPREDICABLE_INSN;
19788 unsigned Rt = 0, Rt2 = 1, Q0 = 2, Q1 = 3;
19797 constraint (inst.operands[Q0].reg != inst.operands[Q1].reg + 2,
19798 _("Index one must be [2,3] and index two must be two less than"
19800 constraint (inst.operands[Rt].reg == inst.operands[Rt2].reg,
19801 _("General purpose registers may not be the same"));
19802 constraint (inst.operands[Rt].reg == REG_SP
19803 || inst.operands[Rt2].reg == REG_SP,
19805 constraint (inst.operands[Rt].reg == REG_PC
19806 || inst.operands[Rt2].reg == REG_PC,
19809 inst.instruction = 0xec000f00;
19810 inst.instruction |= HI1 (inst.operands[Q1].reg / 32) << 23;
19811 inst.instruction |= !!toQ << 20;
19812 inst.instruction |= inst.operands[Rt2].reg << 16;
19813 inst.instruction |= LOW4 (inst.operands[Q1].reg / 32) << 13;
19814 inst.instruction |= (inst.operands[Q1].reg % 4) << 4;
19815 inst.instruction |= inst.operands[Rt].reg;
19821 if (!ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext))
19824 if (inst.cond > COND_ALWAYS)
19825 inst.pred_insn_type = INSIDE_VPT_INSN;
19827 inst.pred_insn_type = MVE_OUTSIDE_PRED_INSN;
19829 struct neon_type_el et = neon_check_type (2, NS_QQ, N_EQK, N_I16 | N_I32
19832 inst.instruction |= HI1 (inst.operands[0].reg) << 22;
19833 inst.instruction |= (neon_logbits (et.size) - 1) << 18;
19834 inst.instruction |= LOW4 (inst.operands[0].reg) << 12;
19835 inst.instruction |= HI1 (inst.operands[1].reg) << 5;
19836 inst.instruction |= LOW4 (inst.operands[1].reg);
19841 /* VMOV has particularly many variations. It can be one of:
19842 0. VMOV<c><q> <Qd>, <Qm>
19843 1. VMOV<c><q> <Dd>, <Dm>
19844 (Register operations, which are VORR with Rm = Rn.)
19845 2. VMOV<c><q>.<dt> <Qd>, #<imm>
19846 3. VMOV<c><q>.<dt> <Dd>, #<imm>
19848 4. VMOV<c><q>.<size> <Dn[x]>, <Rd>
19849 (ARM register to scalar.)
19850 5. VMOV<c><q> <Dm>, <Rd>, <Rn>
19851 (Two ARM registers to vector.)
19852 6. VMOV<c><q>.<dt> <Rd>, <Dn[x]>
19853 (Scalar to ARM register.)
19854 7. VMOV<c><q> <Rd>, <Rn>, <Dm>
19855 (Vector to two ARM registers.)
19856 8. VMOV.F32 <Sd>, <Sm>
19857 9. VMOV.F64 <Dd>, <Dm>
19858 (VFP register moves.)
19859 10. VMOV.F32 <Sd>, #imm
19860 11. VMOV.F64 <Dd>, #imm
19861 (VFP float immediate load.)
19862 12. VMOV <Rd>, <Sm>
19863 (VFP single to ARM reg.)
19864 13. VMOV <Sd>, <Rm>
19865 (ARM reg to VFP single.)
19866 14. VMOV <Rd>, <Re>, <Sn>, <Sm>
19867 (Two ARM regs to two VFP singles.)
19868 15. VMOV <Sd>, <Se>, <Rn>, <Rm>
19869 (Two VFP singles to two ARM regs.)
19870 16. VMOV<c> <Rt>, <Rt2>, <Qd[idx]>, <Qd[idx2]>
19871 17. VMOV<c> <Qd[idx]>, <Qd[idx2]>, <Rt>, <Rt2>
19872 18. VMOV<c>.<dt> <Rt>, <Qn[idx]>
19873 19. VMOV<c>.<dt> <Qd[idx]>, <Rt>
19875 These cases can be disambiguated using neon_select_shape, except cases 1/9
19876 and 3/11 which depend on the operand type too.
19878 All the encoded bits are hardcoded by this function.
19880 Cases 4, 6 may be used with VFPv1 and above (only 32-bit transfers!).
19881 Cases 5, 7 may be used with VFPv2 and above.
19883 FIXME: Some of the checking may be a bit sloppy (in a couple of cases you
19884 can specify a type where it doesn't make sense to, and is ignored). */
19889 enum neon_shape rs = neon_select_shape (NS_RRSS, NS_SSRR, NS_RRFF, NS_FFRR,
19890 NS_DRR, NS_RRD, NS_QQ, NS_DD, NS_QI,
19891 NS_DI, NS_SR, NS_RS, NS_FF, NS_FI,
19892 NS_RF, NS_FR, NS_HR, NS_RH, NS_HI,
19894 struct neon_type_el et;
19895 const char *ldconst = 0;
19899 case NS_DD: /* case 1/9. */
19900 et = neon_check_type (2, rs, N_EQK, N_F64 | N_KEY);
19901 /* It is not an error here if no type is given. */
19904 /* In MVE we interpret the following instructions as same, so ignoring
19905 the following type (float) and size (64) checks.
19906 a: VMOV<c><q> <Dd>, <Dm>
19907 b: VMOV<c><q>.F64 <Dd>, <Dm>. */
19908 if ((et.type == NT_float && et.size == 64)
19909 || (ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext)))
19911 do_vfp_nsyn_opcode ("fcpyd");
19914 /* fall through. */
19916 case NS_QQ: /* case 0/1. */
19918 if (!check_simd_pred_availability (FALSE,
19919 NEON_CHECK_CC | NEON_CHECK_ARCH))
19921 /* The architecture manual I have doesn't explicitly state which
19922 value the U bit should have for register->register moves, but
19923 the equivalent VORR instruction has U = 0, so do that. */
19924 inst.instruction = 0x0200110;
19925 inst.instruction |= LOW4 (inst.operands[0].reg) << 12;
19926 inst.instruction |= HI1 (inst.operands[0].reg) << 22;
19927 inst.instruction |= LOW4 (inst.operands[1].reg);
19928 inst.instruction |= HI1 (inst.operands[1].reg) << 5;
19929 inst.instruction |= LOW4 (inst.operands[1].reg) << 16;
19930 inst.instruction |= HI1 (inst.operands[1].reg) << 7;
19931 inst.instruction |= neon_quad (rs) << 6;
19933 neon_dp_fixup (&inst);
19937 case NS_DI: /* case 3/11. */
19938 et = neon_check_type (2, rs, N_EQK, N_F64 | N_KEY);
19940 if (et.type == NT_float && et.size == 64)
19942 /* case 11 (fconstd). */
19943 ldconst = "fconstd";
19944 goto encode_fconstd;
19946 /* fall through. */
19948 case NS_QI: /* case 2/3. */
19949 if (!check_simd_pred_availability (FALSE,
19950 NEON_CHECK_CC | NEON_CHECK_ARCH))
19952 inst.instruction = 0x0800010;
19953 neon_move_immediate ();
19954 neon_dp_fixup (&inst);
19957 case NS_SR: /* case 4. */
19959 unsigned bcdebits = 0;
19961 unsigned dn = NEON_SCALAR_REG (inst.operands[0].reg);
19962 unsigned x = NEON_SCALAR_INDEX (inst.operands[0].reg);
19964 /* .<size> is optional here, defaulting to .32. */
19965 if (inst.vectype.elems == 0
19966 && inst.operands[0].vectype.type == NT_invtype
19967 && inst.operands[1].vectype.type == NT_invtype)
19969 inst.vectype.el[0].type = NT_untyped;
19970 inst.vectype.el[0].size = 32;
19971 inst.vectype.elems = 1;
19974 et = neon_check_type (2, NS_NULL, N_8 | N_16 | N_32 | N_KEY, N_EQK);
19975 logsize = neon_logbits (et.size);
19979 if (!ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext)
19980 && vfp_or_neon_is_neon (NEON_CHECK_ARCH) == FAIL)
19985 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant, fpu_vfp_ext_v1)
19986 && !ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext),
19990 if (ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext))
19992 if (inst.operands[1].reg == REG_SP)
19993 as_tsktsk (MVE_BAD_SP);
19994 else if (inst.operands[1].reg == REG_PC)
19995 as_tsktsk (MVE_BAD_PC);
19997 unsigned size = inst.operands[0].isscalar == 1 ? 64 : 128;
19999 constraint (et.type == NT_invtype, _("bad type for scalar"));
20000 constraint (x >= size / et.size, _("scalar index out of range"));
20005 case 8: bcdebits = 0x8; break;
20006 case 16: bcdebits = 0x1; break;
20007 case 32: bcdebits = 0x0; break;
20011 bcdebits |= (x & ((1 << (3-logsize)) - 1)) << logsize;
20013 inst.instruction = 0xe000b10;
20014 do_vfp_cond_or_thumb ();
20015 inst.instruction |= LOW4 (dn) << 16;
20016 inst.instruction |= HI1 (dn) << 7;
20017 inst.instruction |= inst.operands[1].reg << 12;
20018 inst.instruction |= (bcdebits & 3) << 5;
20019 inst.instruction |= ((bcdebits >> 2) & 3) << 21;
20020 inst.instruction |= (x >> (3-logsize)) << 16;
20024 case NS_DRR: /* case 5 (fmdrr). */
20025 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant, fpu_vfp_ext_v2)
20026 && !ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext),
20029 inst.instruction = 0xc400b10;
20030 do_vfp_cond_or_thumb ();
20031 inst.instruction |= LOW4 (inst.operands[0].reg);
20032 inst.instruction |= HI1 (inst.operands[0].reg) << 5;
20033 inst.instruction |= inst.operands[1].reg << 12;
20034 inst.instruction |= inst.operands[2].reg << 16;
20037 case NS_RS: /* case 6. */
20040 unsigned dn = NEON_SCALAR_REG (inst.operands[1].reg);
20041 unsigned x = NEON_SCALAR_INDEX (inst.operands[1].reg);
20042 unsigned abcdebits = 0;
20044 /* .<dt> is optional here, defaulting to .32. */
20045 if (inst.vectype.elems == 0
20046 && inst.operands[0].vectype.type == NT_invtype
20047 && inst.operands[1].vectype.type == NT_invtype)
20049 inst.vectype.el[0].type = NT_untyped;
20050 inst.vectype.el[0].size = 32;
20051 inst.vectype.elems = 1;
20054 et = neon_check_type (2, NS_NULL,
20055 N_EQK, N_S8 | N_S16 | N_U8 | N_U16 | N_32 | N_KEY);
20056 logsize = neon_logbits (et.size);
20060 if (!ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext)
20061 && vfp_or_neon_is_neon (NEON_CHECK_CC
20062 | NEON_CHECK_ARCH) == FAIL)
20067 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant, fpu_vfp_ext_v1)
20068 && !ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext),
20072 if (ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext))
20074 if (inst.operands[0].reg == REG_SP)
20075 as_tsktsk (MVE_BAD_SP);
20076 else if (inst.operands[0].reg == REG_PC)
20077 as_tsktsk (MVE_BAD_PC);
20080 unsigned size = inst.operands[1].isscalar == 1 ? 64 : 128;
20082 constraint (et.type == NT_invtype, _("bad type for scalar"));
20083 constraint (x >= size / et.size, _("scalar index out of range"));
20087 case 8: abcdebits = (et.type == NT_signed) ? 0x08 : 0x18; break;
20088 case 16: abcdebits = (et.type == NT_signed) ? 0x01 : 0x11; break;
20089 case 32: abcdebits = 0x00; break;
20093 abcdebits |= (x & ((1 << (3-logsize)) - 1)) << logsize;
20094 inst.instruction = 0xe100b10;
20095 do_vfp_cond_or_thumb ();
20096 inst.instruction |= LOW4 (dn) << 16;
20097 inst.instruction |= HI1 (dn) << 7;
20098 inst.instruction |= inst.operands[0].reg << 12;
20099 inst.instruction |= (abcdebits & 3) << 5;
20100 inst.instruction |= (abcdebits >> 2) << 21;
20101 inst.instruction |= (x >> (3-logsize)) << 16;
20105 case NS_RRD: /* case 7 (fmrrd). */
20106 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant, fpu_vfp_ext_v2)
20107 && !ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext),
20110 inst.instruction = 0xc500b10;
20111 do_vfp_cond_or_thumb ();
20112 inst.instruction |= inst.operands[0].reg << 12;
20113 inst.instruction |= inst.operands[1].reg << 16;
20114 inst.instruction |= LOW4 (inst.operands[2].reg);
20115 inst.instruction |= HI1 (inst.operands[2].reg) << 5;
20118 case NS_FF: /* case 8 (fcpys). */
20119 do_vfp_nsyn_opcode ("fcpys");
20123 case NS_FI: /* case 10 (fconsts). */
20124 ldconst = "fconsts";
20126 if (!inst.operands[1].immisfloat)
20129 /* Immediate has to fit in 8 bits so float is enough. */
20130 float imm = (float) inst.operands[1].imm;
20131 memcpy (&new_imm, &imm, sizeof (float));
20132 /* But the assembly may have been written to provide an integer
20133 bit pattern that equates to a float, so check that the
20134 conversion has worked. */
20135 if (is_quarter_float (new_imm))
20137 if (is_quarter_float (inst.operands[1].imm))
20138 as_warn (_("immediate constant is valid both as a bit-pattern and a floating point value (using the fp value)"));
20140 inst.operands[1].imm = new_imm;
20141 inst.operands[1].immisfloat = 1;
20145 if (is_quarter_float (inst.operands[1].imm))
20147 inst.operands[1].imm = neon_qfloat_bits (inst.operands[1].imm);
20148 do_vfp_nsyn_opcode (ldconst);
20150 /* ARMv8.2 fp16 vmov.f16 instruction. */
20152 do_scalar_fp16_v82_encode ();
20155 first_error (_("immediate out of range"));
20159 case NS_RF: /* case 12 (fmrs). */
20160 do_vfp_nsyn_opcode ("fmrs");
20161 /* ARMv8.2 fp16 vmov.f16 instruction. */
20163 do_scalar_fp16_v82_encode ();
20167 case NS_FR: /* case 13 (fmsr). */
20168 do_vfp_nsyn_opcode ("fmsr");
20169 /* ARMv8.2 fp16 vmov.f16 instruction. */
20171 do_scalar_fp16_v82_encode ();
20181 /* The encoders for the fmrrs and fmsrr instructions expect three operands
20182 (one of which is a list), but we have parsed four. Do some fiddling to
20183 make the operands what do_vfp_reg2_from_sp2 and do_vfp_sp2_from_reg2
20185 case NS_RRFF: /* case 14 (fmrrs). */
20186 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant, fpu_vfp_ext_v2)
20187 && !ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext),
20189 constraint (inst.operands[3].reg != inst.operands[2].reg + 1,
20190 _("VFP registers must be adjacent"));
20191 inst.operands[2].imm = 2;
20192 memset (&inst.operands[3], '\0', sizeof (inst.operands[3]));
20193 do_vfp_nsyn_opcode ("fmrrs");
20196 case NS_FFRR: /* case 15 (fmsrr). */
20197 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant, fpu_vfp_ext_v2)
20198 && !ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext),
20200 constraint (inst.operands[1].reg != inst.operands[0].reg + 1,
20201 _("VFP registers must be adjacent"));
20202 inst.operands[1] = inst.operands[2];
20203 inst.operands[2] = inst.operands[3];
20204 inst.operands[0].imm = 2;
20205 memset (&inst.operands[3], '\0', sizeof (inst.operands[3]));
20206 do_vfp_nsyn_opcode ("fmsrr");
20210 /* neon_select_shape has determined that the instruction
20211 shape is wrong and has already set the error message. */
20222 if (!(inst.operands[0].present && inst.operands[0].isquad
20223 && inst.operands[1].present && inst.operands[1].isquad
20224 && !inst.operands[2].present))
20226 inst.instruction = 0;
20229 set_pred_insn_type (INSIDE_IT_INSN);
20234 if (!ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext))
20237 if (inst.cond != COND_ALWAYS)
20238 inst.pred_insn_type = INSIDE_VPT_INSN;
20240 struct neon_type_el et = neon_check_type (2, NS_QQ, N_EQK, N_S8 | N_U8
20241 | N_S16 | N_U16 | N_KEY);
20243 inst.instruction |= (et.type == NT_unsigned) << 28;
20244 inst.instruction |= HI1 (inst.operands[0].reg) << 22;
20245 inst.instruction |= (neon_logbits (et.size) + 1) << 19;
20246 inst.instruction |= LOW4 (inst.operands[0].reg) << 12;
20247 inst.instruction |= HI1 (inst.operands[1].reg) << 5;
20248 inst.instruction |= LOW4 (inst.operands[1].reg);
20253 do_neon_rshift_round_imm (void)
20255 if (!check_simd_pred_availability (FALSE, NEON_CHECK_ARCH | NEON_CHECK_CC))
20258 enum neon_shape rs;
20259 struct neon_type_el et;
20261 if (ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext))
20263 rs = neon_select_shape (NS_QQI, NS_NULL);
20264 et = neon_check_type (2, rs, N_EQK, N_SU_MVE | N_KEY);
20268 rs = neon_select_shape (NS_DDI, NS_QQI, NS_NULL);
20269 et = neon_check_type (2, rs, N_EQK, N_SU_ALL | N_KEY);
20271 int imm = inst.operands[2].imm;
20273 /* imm == 0 case is encoded as VMOV for V{R}SHR. */
20276 inst.operands[2].present = 0;
20281 constraint (imm < 1 || (unsigned)imm > et.size,
20282 _("immediate out of range for shift"));
20283 neon_imm_shift (TRUE, et.type == NT_unsigned, neon_quad (rs), et,
20288 do_neon_movhf (void)
20290 enum neon_shape rs = neon_select_shape (NS_HH, NS_NULL);
20291 constraint (rs != NS_HH, _("invalid suffix"));
20293 if (inst.cond != COND_ALWAYS)
20297 as_warn (_("ARMv8.2 scalar fp16 instruction cannot be conditional,"
20298 " the behaviour is UNPREDICTABLE"));
20302 inst.error = BAD_COND;
20307 do_vfp_sp_monadic ();
20310 inst.instruction |= 0xf0000000;
20314 do_neon_movl (void)
20316 struct neon_type_el et = neon_check_type (2, NS_QD,
20317 N_EQK | N_DBL, N_SU_32 | N_KEY);
20318 unsigned sizebits = et.size >> 3;
20319 inst.instruction |= sizebits << 19;
20320 neon_two_same (0, et.type == NT_unsigned, -1);
20326 enum neon_shape rs = neon_select_shape (NS_DD, NS_QQ, NS_NULL);
20327 struct neon_type_el et = neon_check_type (2, rs,
20328 N_EQK, N_8 | N_16 | N_32 | N_KEY);
20329 NEON_ENCODE (INTEGER, inst);
20330 neon_two_same (neon_quad (rs), 1, et.size);
20334 do_neon_zip_uzp (void)
20336 enum neon_shape rs = neon_select_shape (NS_DD, NS_QQ, NS_NULL);
20337 struct neon_type_el et = neon_check_type (2, rs,
20338 N_EQK, N_8 | N_16 | N_32 | N_KEY);
20339 if (rs == NS_DD && et.size == 32)
20341 /* Special case: encode as VTRN.32 <Dd>, <Dm>. */
20342 inst.instruction = N_MNEM_vtrn;
20346 neon_two_same (neon_quad (rs), 1, et.size);
20350 do_neon_sat_abs_neg (void)
20352 if (!check_simd_pred_availability (FALSE, NEON_CHECK_CC | NEON_CHECK_ARCH))
20355 enum neon_shape rs;
20356 if (ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext))
20357 rs = neon_select_shape (NS_QQ, NS_NULL);
20359 rs = neon_select_shape (NS_DD, NS_QQ, NS_NULL);
20360 struct neon_type_el et = neon_check_type (2, rs,
20361 N_EQK, N_S8 | N_S16 | N_S32 | N_KEY);
20362 neon_two_same (neon_quad (rs), 1, et.size);
20366 do_neon_pair_long (void)
20368 enum neon_shape rs = neon_select_shape (NS_DD, NS_QQ, NS_NULL);
20369 struct neon_type_el et = neon_check_type (2, rs, N_EQK, N_SU_32 | N_KEY);
20370 /* Unsigned is encoded in OP field (bit 7) for these instruction. */
20371 inst.instruction |= (et.type == NT_unsigned) << 7;
20372 neon_two_same (neon_quad (rs), 1, et.size);
20376 do_neon_recip_est (void)
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_FLT, N_F_16_32 | N_U32 | N_KEY);
20381 inst.instruction |= (et.type == NT_float) << 8;
20382 neon_two_same (neon_quad (rs), 1, et.size);
20388 if (!check_simd_pred_availability (FALSE, NEON_CHECK_ARCH | NEON_CHECK_CC))
20391 enum neon_shape rs;
20392 if (ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext))
20393 rs = neon_select_shape (NS_QQ, NS_NULL);
20395 rs = neon_select_shape (NS_DD, NS_QQ, NS_NULL);
20397 struct neon_type_el et = neon_check_type (2, rs,
20398 N_EQK, N_S8 | N_S16 | N_S32 | N_KEY);
20399 neon_two_same (neon_quad (rs), 1, et.size);
20405 if (!check_simd_pred_availability (FALSE, NEON_CHECK_ARCH | NEON_CHECK_CC))
20408 enum neon_shape rs;
20409 if (ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext))
20410 rs = neon_select_shape (NS_QQ, NS_NULL);
20412 rs = neon_select_shape (NS_DD, NS_QQ, NS_NULL);
20414 struct neon_type_el et = neon_check_type (2, rs,
20415 N_EQK, N_I8 | N_I16 | N_I32 | N_KEY);
20416 neon_two_same (neon_quad (rs), 1, et.size);
20422 enum neon_shape rs = neon_select_shape (NS_DD, NS_QQ, NS_NULL);
20423 struct neon_type_el et = neon_check_type (2, rs,
20424 N_EQK | N_INT, N_8 | N_KEY);
20425 neon_two_same (neon_quad (rs), 1, et.size);
20431 enum neon_shape rs = neon_select_shape (NS_DD, NS_QQ, NS_NULL);
20432 neon_two_same (neon_quad (rs), 1, -1);
20436 do_neon_tbl_tbx (void)
20438 unsigned listlenbits;
20439 neon_check_type (3, NS_DLD, N_EQK, N_EQK, N_8 | N_KEY);
20441 if (inst.operands[1].imm < 1 || inst.operands[1].imm > 4)
20443 first_error (_("bad list length for table lookup"));
20447 listlenbits = inst.operands[1].imm - 1;
20448 inst.instruction |= LOW4 (inst.operands[0].reg) << 12;
20449 inst.instruction |= HI1 (inst.operands[0].reg) << 22;
20450 inst.instruction |= LOW4 (inst.operands[1].reg) << 16;
20451 inst.instruction |= HI1 (inst.operands[1].reg) << 7;
20452 inst.instruction |= LOW4 (inst.operands[2].reg);
20453 inst.instruction |= HI1 (inst.operands[2].reg) << 5;
20454 inst.instruction |= listlenbits << 8;
20456 neon_dp_fixup (&inst);
20460 do_neon_ldm_stm (void)
20462 /* P, U and L bits are part of bitmask. */
20463 int is_dbmode = (inst.instruction & (1 << 24)) != 0;
20464 unsigned offsetbits = inst.operands[1].imm * 2;
20466 if (inst.operands[1].issingle)
20468 do_vfp_nsyn_ldm_stm (is_dbmode);
20472 constraint (is_dbmode && !inst.operands[0].writeback,
20473 _("writeback (!) must be used for VLDMDB and VSTMDB"));
20475 constraint (inst.operands[1].imm < 1 || inst.operands[1].imm > 16,
20476 _("register list must contain at least 1 and at most 16 "
20479 inst.instruction |= inst.operands[0].reg << 16;
20480 inst.instruction |= inst.operands[0].writeback << 21;
20481 inst.instruction |= LOW4 (inst.operands[1].reg) << 12;
20482 inst.instruction |= HI1 (inst.operands[1].reg) << 22;
20484 inst.instruction |= offsetbits;
20486 do_vfp_cond_or_thumb ();
20490 do_neon_ldr_str (void)
20492 int is_ldr = (inst.instruction & (1 << 20)) != 0;
20494 /* Use of PC in vstr in ARM mode is deprecated in ARMv7.
20495 And is UNPREDICTABLE in thumb mode. */
20497 && inst.operands[1].reg == REG_PC
20498 && (ARM_CPU_HAS_FEATURE (selected_cpu, arm_ext_v7) || thumb_mode))
20501 inst.error = _("Use of PC here is UNPREDICTABLE");
20502 else if (warn_on_deprecated)
20503 as_tsktsk (_("Use of PC here is deprecated"));
20506 if (inst.operands[0].issingle)
20509 do_vfp_nsyn_opcode ("flds");
20511 do_vfp_nsyn_opcode ("fsts");
20513 /* ARMv8.2 vldr.16/vstr.16 instruction. */
20514 if (inst.vectype.el[0].size == 16)
20515 do_scalar_fp16_v82_encode ();
20520 do_vfp_nsyn_opcode ("fldd");
20522 do_vfp_nsyn_opcode ("fstd");
20527 do_t_vldr_vstr_sysreg (void)
20529 int fp_vldr_bitno = 20, sysreg_vldr_bitno = 20;
20530 bfd_boolean is_vldr = ((inst.instruction & (1 << fp_vldr_bitno)) != 0);
20532 /* Use of PC is UNPREDICTABLE. */
20533 if (inst.operands[1].reg == REG_PC)
20534 inst.error = _("Use of PC here is UNPREDICTABLE");
20536 if (inst.operands[1].immisreg)
20537 inst.error = _("instruction does not accept register index");
20539 if (!inst.operands[1].isreg)
20540 inst.error = _("instruction does not accept PC-relative addressing");
20542 if (abs (inst.operands[1].imm) >= (1 << 7))
20543 inst.error = _("immediate value out of range");
20545 inst.instruction = 0xec000f80;
20547 inst.instruction |= 1 << sysreg_vldr_bitno;
20548 encode_arm_cp_address (1, TRUE, FALSE, BFD_RELOC_ARM_T32_VLDR_VSTR_OFF_IMM);
20549 inst.instruction |= (inst.operands[0].imm & 0x7) << 13;
20550 inst.instruction |= (inst.operands[0].imm & 0x8) << 19;
20554 do_vldr_vstr (void)
20556 bfd_boolean sysreg_op = !inst.operands[0].isreg;
20558 /* VLDR/VSTR (System Register). */
20561 if (!mark_feature_used (&arm_ext_v8_1m_main))
20562 as_bad (_("Instruction not permitted on this architecture"));
20564 do_t_vldr_vstr_sysreg ();
20569 if (!mark_feature_used (&fpu_vfp_ext_v1xd))
20570 as_bad (_("Instruction not permitted on this architecture"));
20571 do_neon_ldr_str ();
20575 /* "interleave" version also handles non-interleaving register VLD1/VST1
20579 do_neon_ld_st_interleave (void)
20581 struct neon_type_el et = neon_check_type (1, NS_NULL,
20582 N_8 | N_16 | N_32 | N_64);
20583 unsigned alignbits = 0;
20585 /* The bits in this table go:
20586 0: register stride of one (0) or two (1)
20587 1,2: register list length, minus one (1, 2, 3, 4).
20588 3,4: <n> in instruction type, minus one (VLD<n> / VST<n>).
20589 We use -1 for invalid entries. */
20590 const int typetable[] =
20592 0x7, -1, 0xa, -1, 0x6, -1, 0x2, -1, /* VLD1 / VST1. */
20593 -1, -1, 0x8, 0x9, -1, -1, 0x3, -1, /* VLD2 / VST2. */
20594 -1, -1, -1, -1, 0x4, 0x5, -1, -1, /* VLD3 / VST3. */
20595 -1, -1, -1, -1, -1, -1, 0x0, 0x1 /* VLD4 / VST4. */
20599 if (et.type == NT_invtype)
20602 if (inst.operands[1].immisalign)
20603 switch (inst.operands[1].imm >> 8)
20605 case 64: alignbits = 1; break;
20607 if (NEON_REGLIST_LENGTH (inst.operands[0].imm) != 2
20608 && NEON_REGLIST_LENGTH (inst.operands[0].imm) != 4)
20609 goto bad_alignment;
20613 if (NEON_REGLIST_LENGTH (inst.operands[0].imm) != 4)
20614 goto bad_alignment;
20619 first_error (_("bad alignment"));
20623 inst.instruction |= alignbits << 4;
20624 inst.instruction |= neon_logbits (et.size) << 6;
20626 /* Bits [4:6] of the immediate in a list specifier encode register stride
20627 (minus 1) in bit 4, and list length in bits [5:6]. We put the <n> of
20628 VLD<n>/VST<n> in bits [9:8] of the initial bitmask. Suck it out here, look
20629 up the right value for "type" in a table based on this value and the given
20630 list style, then stick it back. */
20631 idx = ((inst.operands[0].imm >> 4) & 7)
20632 | (((inst.instruction >> 8) & 3) << 3);
20634 typebits = typetable[idx];
20636 constraint (typebits == -1, _("bad list type for instruction"));
20637 constraint (((inst.instruction >> 8) & 3) && et.size == 64,
20640 inst.instruction &= ~0xf00;
20641 inst.instruction |= typebits << 8;
20644 /* Check alignment is valid for do_neon_ld_st_lane and do_neon_ld_dup.
20645 *DO_ALIGN is set to 1 if the relevant alignment bit should be set, 0
20646 otherwise. The variable arguments are a list of pairs of legal (size, align)
20647 values, terminated with -1. */
20650 neon_alignment_bit (int size, int align, int *do_alignment, ...)
20653 int result = FAIL, thissize, thisalign;
20655 if (!inst.operands[1].immisalign)
20661 va_start (ap, do_alignment);
20665 thissize = va_arg (ap, int);
20666 if (thissize == -1)
20668 thisalign = va_arg (ap, int);
20670 if (size == thissize && align == thisalign)
20673 while (result != SUCCESS);
20677 if (result == SUCCESS)
20680 first_error (_("unsupported alignment for instruction"));
20686 do_neon_ld_st_lane (void)
20688 struct neon_type_el et = neon_check_type (1, NS_NULL, N_8 | N_16 | N_32);
20689 int align_good, do_alignment = 0;
20690 int logsize = neon_logbits (et.size);
20691 int align = inst.operands[1].imm >> 8;
20692 int n = (inst.instruction >> 8) & 3;
20693 int max_el = 64 / et.size;
20695 if (et.type == NT_invtype)
20698 constraint (NEON_REGLIST_LENGTH (inst.operands[0].imm) != n + 1,
20699 _("bad list length"));
20700 constraint (NEON_LANE (inst.operands[0].imm) >= max_el,
20701 _("scalar index out of range"));
20702 constraint (n != 0 && NEON_REG_STRIDE (inst.operands[0].imm) == 2
20704 _("stride of 2 unavailable when element size is 8"));
20708 case 0: /* VLD1 / VST1. */
20709 align_good = neon_alignment_bit (et.size, align, &do_alignment, 16, 16,
20711 if (align_good == FAIL)
20715 unsigned alignbits = 0;
20718 case 16: alignbits = 0x1; break;
20719 case 32: alignbits = 0x3; break;
20722 inst.instruction |= alignbits << 4;
20726 case 1: /* VLD2 / VST2. */
20727 align_good = neon_alignment_bit (et.size, align, &do_alignment, 8, 16,
20728 16, 32, 32, 64, -1);
20729 if (align_good == FAIL)
20732 inst.instruction |= 1 << 4;
20735 case 2: /* VLD3 / VST3. */
20736 constraint (inst.operands[1].immisalign,
20737 _("can't use alignment with this instruction"));
20740 case 3: /* VLD4 / VST4. */
20741 align_good = neon_alignment_bit (et.size, align, &do_alignment, 8, 32,
20742 16, 64, 32, 64, 32, 128, -1);
20743 if (align_good == FAIL)
20747 unsigned alignbits = 0;
20750 case 8: alignbits = 0x1; break;
20751 case 16: alignbits = 0x1; break;
20752 case 32: alignbits = (align == 64) ? 0x1 : 0x2; break;
20755 inst.instruction |= alignbits << 4;
20762 /* Reg stride of 2 is encoded in bit 5 when size==16, bit 6 when size==32. */
20763 if (n != 0 && NEON_REG_STRIDE (inst.operands[0].imm) == 2)
20764 inst.instruction |= 1 << (4 + logsize);
20766 inst.instruction |= NEON_LANE (inst.operands[0].imm) << (logsize + 5);
20767 inst.instruction |= logsize << 10;
20770 /* Encode single n-element structure to all lanes VLD<n> instructions. */
20773 do_neon_ld_dup (void)
20775 struct neon_type_el et = neon_check_type (1, NS_NULL, N_8 | N_16 | N_32);
20776 int align_good, do_alignment = 0;
20778 if (et.type == NT_invtype)
20781 switch ((inst.instruction >> 8) & 3)
20783 case 0: /* VLD1. */
20784 gas_assert (NEON_REG_STRIDE (inst.operands[0].imm) != 2);
20785 align_good = neon_alignment_bit (et.size, inst.operands[1].imm >> 8,
20786 &do_alignment, 16, 16, 32, 32, -1);
20787 if (align_good == FAIL)
20789 switch (NEON_REGLIST_LENGTH (inst.operands[0].imm))
20792 case 2: inst.instruction |= 1 << 5; break;
20793 default: first_error (_("bad list length")); return;
20795 inst.instruction |= neon_logbits (et.size) << 6;
20798 case 1: /* VLD2. */
20799 align_good = neon_alignment_bit (et.size, inst.operands[1].imm >> 8,
20800 &do_alignment, 8, 16, 16, 32, 32, 64,
20802 if (align_good == FAIL)
20804 constraint (NEON_REGLIST_LENGTH (inst.operands[0].imm) != 2,
20805 _("bad list length"));
20806 if (NEON_REG_STRIDE (inst.operands[0].imm) == 2)
20807 inst.instruction |= 1 << 5;
20808 inst.instruction |= neon_logbits (et.size) << 6;
20811 case 2: /* VLD3. */
20812 constraint (inst.operands[1].immisalign,
20813 _("can't use alignment with this instruction"));
20814 constraint (NEON_REGLIST_LENGTH (inst.operands[0].imm) != 3,
20815 _("bad list length"));
20816 if (NEON_REG_STRIDE (inst.operands[0].imm) == 2)
20817 inst.instruction |= 1 << 5;
20818 inst.instruction |= neon_logbits (et.size) << 6;
20821 case 3: /* VLD4. */
20823 int align = inst.operands[1].imm >> 8;
20824 align_good = neon_alignment_bit (et.size, align, &do_alignment, 8, 32,
20825 16, 64, 32, 64, 32, 128, -1);
20826 if (align_good == FAIL)
20828 constraint (NEON_REGLIST_LENGTH (inst.operands[0].imm) != 4,
20829 _("bad list length"));
20830 if (NEON_REG_STRIDE (inst.operands[0].imm) == 2)
20831 inst.instruction |= 1 << 5;
20832 if (et.size == 32 && align == 128)
20833 inst.instruction |= 0x3 << 6;
20835 inst.instruction |= neon_logbits (et.size) << 6;
20842 inst.instruction |= do_alignment << 4;
20845 /* Disambiguate VLD<n> and VST<n> instructions, and fill in common bits (those
20846 apart from bits [11:4]. */
20849 do_neon_ldx_stx (void)
20851 if (inst.operands[1].isreg)
20852 constraint (inst.operands[1].reg == REG_PC, BAD_PC);
20854 switch (NEON_LANE (inst.operands[0].imm))
20856 case NEON_INTERLEAVE_LANES:
20857 NEON_ENCODE (INTERLV, inst);
20858 do_neon_ld_st_interleave ();
20861 case NEON_ALL_LANES:
20862 NEON_ENCODE (DUP, inst);
20863 if (inst.instruction == N_INV)
20865 first_error ("only loads support such operands");
20872 NEON_ENCODE (LANE, inst);
20873 do_neon_ld_st_lane ();
20876 /* L bit comes from bit mask. */
20877 inst.instruction |= LOW4 (inst.operands[0].reg) << 12;
20878 inst.instruction |= HI1 (inst.operands[0].reg) << 22;
20879 inst.instruction |= inst.operands[1].reg << 16;
20881 if (inst.operands[1].postind)
20883 int postreg = inst.operands[1].imm & 0xf;
20884 constraint (!inst.operands[1].immisreg,
20885 _("post-index must be a register"));
20886 constraint (postreg == 0xd || postreg == 0xf,
20887 _("bad register for post-index"));
20888 inst.instruction |= postreg;
20892 constraint (inst.operands[1].immisreg, BAD_ADDR_MODE);
20893 constraint (inst.relocs[0].exp.X_op != O_constant
20894 || inst.relocs[0].exp.X_add_number != 0,
20897 if (inst.operands[1].writeback)
20899 inst.instruction |= 0xd;
20902 inst.instruction |= 0xf;
20906 inst.instruction |= 0xf9000000;
20908 inst.instruction |= 0xf4000000;
20913 do_vfp_nsyn_fpv8 (enum neon_shape rs)
20915 /* Targets like FPv5-SP-D16 don't support FP v8 instructions with
20916 D register operands. */
20917 if (neon_shape_class[rs] == SC_DOUBLE)
20918 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant, fpu_vfp_ext_armv8),
20921 NEON_ENCODE (FPV8, inst);
20923 if (rs == NS_FFF || rs == NS_HHH)
20925 do_vfp_sp_dyadic ();
20927 /* ARMv8.2 fp16 instruction. */
20929 do_scalar_fp16_v82_encode ();
20932 do_vfp_dp_rd_rn_rm ();
20935 inst.instruction |= 0x100;
20937 inst.instruction |= 0xf0000000;
20943 set_pred_insn_type (OUTSIDE_PRED_INSN);
20945 if (try_vfp_nsyn (3, do_vfp_nsyn_fpv8) != SUCCESS)
20946 first_error (_("invalid instruction shape"));
20952 if (!ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext))
20953 set_pred_insn_type (OUTSIDE_PRED_INSN);
20955 if (try_vfp_nsyn (3, do_vfp_nsyn_fpv8) == SUCCESS)
20958 if (!check_simd_pred_availability (TRUE, NEON_CHECK_CC | NEON_CHECK_ARCH8))
20961 neon_dyadic_misc (NT_untyped, N_F_16_32, 0);
20965 do_vrint_1 (enum neon_cvt_mode mode)
20967 enum neon_shape rs = neon_select_shape (NS_HH, NS_FF, NS_DD, NS_QQ, NS_NULL);
20968 struct neon_type_el et;
20973 /* Targets like FPv5-SP-D16 don't support FP v8 instructions with
20974 D register operands. */
20975 if (neon_shape_class[rs] == SC_DOUBLE)
20976 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant, fpu_vfp_ext_armv8),
20979 et = neon_check_type (2, rs, N_EQK | N_VFP, N_F_ALL | N_KEY
20981 if (et.type != NT_invtype)
20983 /* VFP encodings. */
20984 if (mode == neon_cvt_mode_a || mode == neon_cvt_mode_n
20985 || mode == neon_cvt_mode_p || mode == neon_cvt_mode_m)
20986 set_pred_insn_type (OUTSIDE_PRED_INSN);
20988 NEON_ENCODE (FPV8, inst);
20989 if (rs == NS_FF || rs == NS_HH)
20990 do_vfp_sp_monadic ();
20992 do_vfp_dp_rd_rm ();
20996 case neon_cvt_mode_r: inst.instruction |= 0x00000000; break;
20997 case neon_cvt_mode_z: inst.instruction |= 0x00000080; break;
20998 case neon_cvt_mode_x: inst.instruction |= 0x00010000; break;
20999 case neon_cvt_mode_a: inst.instruction |= 0xf0000000; break;
21000 case neon_cvt_mode_n: inst.instruction |= 0xf0010000; break;
21001 case neon_cvt_mode_p: inst.instruction |= 0xf0020000; break;
21002 case neon_cvt_mode_m: inst.instruction |= 0xf0030000; break;
21006 inst.instruction |= (rs == NS_DD) << 8;
21007 do_vfp_cond_or_thumb ();
21009 /* ARMv8.2 fp16 vrint instruction. */
21011 do_scalar_fp16_v82_encode ();
21015 /* Neon encodings (or something broken...). */
21017 et = neon_check_type (2, rs, N_EQK, N_F_16_32 | N_KEY);
21019 if (et.type == NT_invtype)
21022 if (!check_simd_pred_availability (TRUE,
21023 NEON_CHECK_CC | NEON_CHECK_ARCH8))
21026 NEON_ENCODE (FLOAT, inst);
21028 inst.instruction |= LOW4 (inst.operands[0].reg) << 12;
21029 inst.instruction |= HI1 (inst.operands[0].reg) << 22;
21030 inst.instruction |= LOW4 (inst.operands[1].reg);
21031 inst.instruction |= HI1 (inst.operands[1].reg) << 5;
21032 inst.instruction |= neon_quad (rs) << 6;
21033 /* Mask off the original size bits and reencode them. */
21034 inst.instruction = ((inst.instruction & 0xfff3ffff)
21035 | neon_logbits (et.size) << 18);
21039 case neon_cvt_mode_z: inst.instruction |= 3 << 7; break;
21040 case neon_cvt_mode_x: inst.instruction |= 1 << 7; break;
21041 case neon_cvt_mode_a: inst.instruction |= 2 << 7; break;
21042 case neon_cvt_mode_n: inst.instruction |= 0 << 7; break;
21043 case neon_cvt_mode_p: inst.instruction |= 7 << 7; break;
21044 case neon_cvt_mode_m: inst.instruction |= 5 << 7; break;
21045 case neon_cvt_mode_r: inst.error = _("invalid rounding mode"); break;
21050 inst.instruction |= 0xfc000000;
21052 inst.instruction |= 0xf0000000;
21059 do_vrint_1 (neon_cvt_mode_x);
21065 do_vrint_1 (neon_cvt_mode_z);
21071 do_vrint_1 (neon_cvt_mode_r);
21077 do_vrint_1 (neon_cvt_mode_a);
21083 do_vrint_1 (neon_cvt_mode_n);
21089 do_vrint_1 (neon_cvt_mode_p);
21095 do_vrint_1 (neon_cvt_mode_m);
21099 neon_scalar_for_vcmla (unsigned opnd, unsigned elsize)
21101 unsigned regno = NEON_SCALAR_REG (opnd);
21102 unsigned elno = NEON_SCALAR_INDEX (opnd);
21104 if (elsize == 16 && elno < 2 && regno < 16)
21105 return regno | (elno << 4);
21106 else if (elsize == 32 && elno == 0)
21109 first_error (_("scalar out of range"));
21116 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant, mve_fp_ext)
21117 && (!ARM_CPU_HAS_FEATURE (cpu_variant, fpu_neon_ext_armv8)
21118 || !mark_feature_used (&arm_ext_v8_3)), (BAD_FPU));
21119 constraint (inst.relocs[0].exp.X_op != O_constant,
21120 _("expression too complex"));
21121 unsigned rot = inst.relocs[0].exp.X_add_number;
21122 constraint (rot != 0 && rot != 90 && rot != 180 && rot != 270,
21123 _("immediate out of range"));
21126 if (!check_simd_pred_availability (TRUE,
21127 NEON_CHECK_ARCH8 | NEON_CHECK_CC))
21130 if (inst.operands[2].isscalar)
21132 if (ARM_CPU_HAS_FEATURE (cpu_variant, mve_fp_ext))
21133 first_error (_("invalid instruction shape"));
21134 enum neon_shape rs = neon_select_shape (NS_DDSI, NS_QQSI, NS_NULL);
21135 unsigned size = neon_check_type (3, rs, N_EQK, N_EQK,
21136 N_KEY | N_F16 | N_F32).size;
21137 unsigned m = neon_scalar_for_vcmla (inst.operands[2].reg, size);
21139 inst.instruction = 0xfe000800;
21140 inst.instruction |= LOW4 (inst.operands[0].reg) << 12;
21141 inst.instruction |= HI1 (inst.operands[0].reg) << 22;
21142 inst.instruction |= LOW4 (inst.operands[1].reg) << 16;
21143 inst.instruction |= HI1 (inst.operands[1].reg) << 7;
21144 inst.instruction |= LOW4 (m);
21145 inst.instruction |= HI1 (m) << 5;
21146 inst.instruction |= neon_quad (rs) << 6;
21147 inst.instruction |= rot << 20;
21148 inst.instruction |= (size == 32) << 23;
21152 enum neon_shape rs;
21153 if (ARM_CPU_HAS_FEATURE (cpu_variant, mve_fp_ext))
21154 rs = neon_select_shape (NS_QQQI, NS_NULL);
21156 rs = neon_select_shape (NS_DDDI, NS_QQQI, NS_NULL);
21158 unsigned size = neon_check_type (3, rs, N_EQK, N_EQK,
21159 N_KEY | N_F16 | N_F32).size;
21160 if (ARM_CPU_HAS_FEATURE (cpu_variant, mve_fp_ext) && size == 32
21161 && (inst.operands[0].reg == inst.operands[1].reg
21162 || inst.operands[0].reg == inst.operands[2].reg))
21163 as_tsktsk (BAD_MVE_SRCDEST);
21165 neon_three_same (neon_quad (rs), 0, -1);
21166 inst.instruction &= 0x00ffffff; /* Undo neon_dp_fixup. */
21167 inst.instruction |= 0xfc200800;
21168 inst.instruction |= rot << 23;
21169 inst.instruction |= (size == 32) << 20;
21176 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext)
21177 && (!ARM_CPU_HAS_FEATURE (cpu_variant, fpu_neon_ext_armv8)
21178 || !mark_feature_used (&arm_ext_v8_3)), (BAD_FPU));
21179 constraint (inst.relocs[0].exp.X_op != O_constant,
21180 _("expression too complex"));
21182 unsigned rot = inst.relocs[0].exp.X_add_number;
21183 constraint (rot != 90 && rot != 270, _("immediate out of range"));
21184 enum neon_shape rs;
21185 struct neon_type_el et;
21186 if (!ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext))
21188 rs = neon_select_shape (NS_DDDI, NS_QQQI, NS_NULL);
21189 et = neon_check_type (3, rs, N_EQK, N_EQK, N_KEY | N_F16 | N_F32);
21193 rs = neon_select_shape (NS_QQQI, NS_NULL);
21194 et = neon_check_type (3, rs, N_EQK, N_EQK, N_KEY | N_F16 | N_F32 | N_I8
21196 if (et.size == 32 && inst.operands[0].reg == inst.operands[2].reg)
21197 as_tsktsk (_("Warning: 32-bit element size and same first and third "
21198 "operand makes instruction UNPREDICTABLE"));
21201 if (et.type == NT_invtype)
21204 if (!check_simd_pred_availability (et.type == NT_float,
21205 NEON_CHECK_ARCH8 | NEON_CHECK_CC))
21208 if (et.type == NT_float)
21210 neon_three_same (neon_quad (rs), 0, -1);
21211 inst.instruction &= 0x00ffffff; /* Undo neon_dp_fixup. */
21212 inst.instruction |= 0xfc800800;
21213 inst.instruction |= (rot == 270) << 24;
21214 inst.instruction |= (et.size == 32) << 20;
21218 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext), BAD_FPU);
21219 inst.instruction = 0xfe000f00;
21220 inst.instruction |= HI1 (inst.operands[0].reg) << 22;
21221 inst.instruction |= neon_logbits (et.size) << 20;
21222 inst.instruction |= LOW4 (inst.operands[1].reg) << 16;
21223 inst.instruction |= LOW4 (inst.operands[0].reg) << 12;
21224 inst.instruction |= (rot == 270) << 12;
21225 inst.instruction |= HI1 (inst.operands[1].reg) << 7;
21226 inst.instruction |= HI1 (inst.operands[2].reg) << 5;
21227 inst.instruction |= LOW4 (inst.operands[2].reg);
21232 /* Dot Product instructions encoding support. */
21235 do_neon_dotproduct (int unsigned_p)
21237 enum neon_shape rs;
21238 unsigned scalar_oprd2 = 0;
21241 if (inst.cond != COND_ALWAYS)
21242 as_warn (_("Dot Product instructions cannot be conditional, the behaviour "
21243 "is UNPREDICTABLE"));
21245 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant, fpu_neon_ext_armv8),
21248 /* Dot Product instructions are in three-same D/Q register format or the third
21249 operand can be a scalar index register. */
21250 if (inst.operands[2].isscalar)
21252 scalar_oprd2 = neon_scalar_for_mul (inst.operands[2].reg, 32);
21253 high8 = 0xfe000000;
21254 rs = neon_select_shape (NS_DDS, NS_QQS, NS_NULL);
21258 high8 = 0xfc000000;
21259 rs = neon_select_shape (NS_DDD, NS_QQQ, NS_NULL);
21263 neon_check_type (3, rs, N_EQK, N_EQK, N_KEY | N_U8);
21265 neon_check_type (3, rs, N_EQK, N_EQK, N_KEY | N_S8);
21267 /* The "U" bit in traditional Three Same encoding is fixed to 0 for Dot
21268 Product instruction, so we pass 0 as the "ubit" parameter. And the
21269 "Size" field are fixed to 0x2, so we pass 32 as the "size" parameter. */
21270 neon_three_same (neon_quad (rs), 0, 32);
21272 /* Undo neon_dp_fixup. Dot Product instructions are using a slightly
21273 different NEON three-same encoding. */
21274 inst.instruction &= 0x00ffffff;
21275 inst.instruction |= high8;
21276 /* Encode 'U' bit which indicates signedness. */
21277 inst.instruction |= (unsigned_p ? 1 : 0) << 4;
21278 /* Re-encode operand2 if it's indexed scalar operand. What has been encoded
21279 from inst.operand[2].reg in neon_three_same is GAS's internal encoding, not
21280 the instruction encoding. */
21281 if (inst.operands[2].isscalar)
21283 inst.instruction &= 0xffffffd0;
21284 inst.instruction |= LOW4 (scalar_oprd2);
21285 inst.instruction |= HI1 (scalar_oprd2) << 5;
21289 /* Dot Product instructions for signed integer. */
21292 do_neon_dotproduct_s (void)
21294 return do_neon_dotproduct (0);
21297 /* Dot Product instructions for unsigned integer. */
21300 do_neon_dotproduct_u (void)
21302 return do_neon_dotproduct (1);
21305 /* Crypto v1 instructions. */
21307 do_crypto_2op_1 (unsigned elttype, int op)
21309 set_pred_insn_type (OUTSIDE_PRED_INSN);
21311 if (neon_check_type (2, NS_QQ, N_EQK | N_UNT, elttype | N_UNT | N_KEY).type
21317 NEON_ENCODE (INTEGER, inst);
21318 inst.instruction |= LOW4 (inst.operands[0].reg) << 12;
21319 inst.instruction |= HI1 (inst.operands[0].reg) << 22;
21320 inst.instruction |= LOW4 (inst.operands[1].reg);
21321 inst.instruction |= HI1 (inst.operands[1].reg) << 5;
21323 inst.instruction |= op << 6;
21326 inst.instruction |= 0xfc000000;
21328 inst.instruction |= 0xf0000000;
21332 do_crypto_3op_1 (int u, int op)
21334 set_pred_insn_type (OUTSIDE_PRED_INSN);
21336 if (neon_check_type (3, NS_QQQ, N_EQK | N_UNT, N_EQK | N_UNT,
21337 N_32 | N_UNT | N_KEY).type == NT_invtype)
21342 NEON_ENCODE (INTEGER, inst);
21343 neon_three_same (1, u, 8 << op);
21349 do_crypto_2op_1 (N_8, 0);
21355 do_crypto_2op_1 (N_8, 1);
21361 do_crypto_2op_1 (N_8, 2);
21367 do_crypto_2op_1 (N_8, 3);
21373 do_crypto_3op_1 (0, 0);
21379 do_crypto_3op_1 (0, 1);
21385 do_crypto_3op_1 (0, 2);
21391 do_crypto_3op_1 (0, 3);
21397 do_crypto_3op_1 (1, 0);
21403 do_crypto_3op_1 (1, 1);
21407 do_sha256su1 (void)
21409 do_crypto_3op_1 (1, 2);
21415 do_crypto_2op_1 (N_32, -1);
21421 do_crypto_2op_1 (N_32, 0);
21425 do_sha256su0 (void)
21427 do_crypto_2op_1 (N_32, 1);
21431 do_crc32_1 (unsigned int poly, unsigned int sz)
21433 unsigned int Rd = inst.operands[0].reg;
21434 unsigned int Rn = inst.operands[1].reg;
21435 unsigned int Rm = inst.operands[2].reg;
21437 set_pred_insn_type (OUTSIDE_PRED_INSN);
21438 inst.instruction |= LOW4 (Rd) << (thumb_mode ? 8 : 12);
21439 inst.instruction |= LOW4 (Rn) << 16;
21440 inst.instruction |= LOW4 (Rm);
21441 inst.instruction |= sz << (thumb_mode ? 4 : 21);
21442 inst.instruction |= poly << (thumb_mode ? 20 : 9);
21444 if (Rd == REG_PC || Rn == REG_PC || Rm == REG_PC)
21445 as_warn (UNPRED_REG ("r15"));
21487 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant, fpu_vfp_ext_armv8),
21489 neon_check_type (2, NS_FD, N_S32, N_F64);
21490 do_vfp_sp_dp_cvt ();
21491 do_vfp_cond_or_thumb ();
21495 /* Overall per-instruction processing. */
21497 /* We need to be able to fix up arbitrary expressions in some statements.
21498 This is so that we can handle symbols that are an arbitrary distance from
21499 the pc. The most common cases are of the form ((+/-sym -/+ . - 8) & mask),
21500 which returns part of an address in a form which will be valid for
21501 a data instruction. We do this by pushing the expression into a symbol
21502 in the expr_section, and creating a fix for that. */
21505 fix_new_arm (fragS * frag,
21519 /* Create an absolute valued symbol, so we have something to
21520 refer to in the object file. Unfortunately for us, gas's
21521 generic expression parsing will already have folded out
21522 any use of .set foo/.type foo %function that may have
21523 been used to set type information of the target location,
21524 that's being specified symbolically. We have to presume
21525 the user knows what they are doing. */
21529 sprintf (name, "*ABS*0x%lx", (unsigned long)exp->X_add_number);
21531 symbol = symbol_find_or_make (name);
21532 S_SET_SEGMENT (symbol, absolute_section);
21533 symbol_set_frag (symbol, &zero_address_frag);
21534 S_SET_VALUE (symbol, exp->X_add_number);
21535 exp->X_op = O_symbol;
21536 exp->X_add_symbol = symbol;
21537 exp->X_add_number = 0;
21543 new_fix = fix_new_exp (frag, where, size, exp, pc_rel,
21544 (enum bfd_reloc_code_real) reloc);
21548 new_fix = (fixS *) fix_new (frag, where, size, make_expr_symbol (exp), 0,
21549 pc_rel, (enum bfd_reloc_code_real) reloc);
21553 /* Mark whether the fix is to a THUMB instruction, or an ARM
21555 new_fix->tc_fix_data = thumb_mode;
21558 /* Create a frg for an instruction requiring relaxation. */
21560 output_relax_insn (void)
21566 /* The size of the instruction is unknown, so tie the debug info to the
21567 start of the instruction. */
21568 dwarf2_emit_insn (0);
21570 switch (inst.relocs[0].exp.X_op)
21573 sym = inst.relocs[0].exp.X_add_symbol;
21574 offset = inst.relocs[0].exp.X_add_number;
21578 offset = inst.relocs[0].exp.X_add_number;
21581 sym = make_expr_symbol (&inst.relocs[0].exp);
21585 to = frag_var (rs_machine_dependent, INSN_SIZE, THUMB_SIZE,
21586 inst.relax, sym, offset, NULL/*offset, opcode*/);
21587 md_number_to_chars (to, inst.instruction, THUMB_SIZE);
21590 /* Write a 32-bit thumb instruction to buf. */
21592 put_thumb32_insn (char * buf, unsigned long insn)
21594 md_number_to_chars (buf, insn >> 16, THUMB_SIZE);
21595 md_number_to_chars (buf + THUMB_SIZE, insn, THUMB_SIZE);
21599 output_inst (const char * str)
21605 as_bad ("%s -- `%s'", inst.error, str);
21610 output_relax_insn ();
21613 if (inst.size == 0)
21616 to = frag_more (inst.size);
21617 /* PR 9814: Record the thumb mode into the current frag so that we know
21618 what type of NOP padding to use, if necessary. We override any previous
21619 setting so that if the mode has changed then the NOPS that we use will
21620 match the encoding of the last instruction in the frag. */
21621 frag_now->tc_frag_data.thumb_mode = thumb_mode | MODE_RECORDED;
21623 if (thumb_mode && (inst.size > THUMB_SIZE))
21625 gas_assert (inst.size == (2 * THUMB_SIZE));
21626 put_thumb32_insn (to, inst.instruction);
21628 else if (inst.size > INSN_SIZE)
21630 gas_assert (inst.size == (2 * INSN_SIZE));
21631 md_number_to_chars (to, inst.instruction, INSN_SIZE);
21632 md_number_to_chars (to + INSN_SIZE, inst.instruction, INSN_SIZE);
21635 md_number_to_chars (to, inst.instruction, inst.size);
21638 for (r = 0; r < ARM_IT_MAX_RELOCS; r++)
21640 if (inst.relocs[r].type != BFD_RELOC_UNUSED)
21641 fix_new_arm (frag_now, to - frag_now->fr_literal,
21642 inst.size, & inst.relocs[r].exp, inst.relocs[r].pc_rel,
21643 inst.relocs[r].type);
21646 dwarf2_emit_insn (inst.size);
21650 output_it_inst (int cond, int mask, char * to)
21652 unsigned long instruction = 0xbf00;
21655 instruction |= mask;
21656 instruction |= cond << 4;
21660 to = frag_more (2);
21662 dwarf2_emit_insn (2);
21666 md_number_to_chars (to, instruction, 2);
21671 /* Tag values used in struct asm_opcode's tag field. */
21674 OT_unconditional, /* Instruction cannot be conditionalized.
21675 The ARM condition field is still 0xE. */
21676 OT_unconditionalF, /* Instruction cannot be conditionalized
21677 and carries 0xF in its ARM condition field. */
21678 OT_csuffix, /* Instruction takes a conditional suffix. */
21679 OT_csuffixF, /* Some forms of the instruction take a scalar
21680 conditional suffix, others place 0xF where the
21681 condition field would be, others take a vector
21682 conditional suffix. */
21683 OT_cinfix3, /* Instruction takes a conditional infix,
21684 beginning at character index 3. (In
21685 unified mode, it becomes a suffix.) */
21686 OT_cinfix3_deprecated, /* The same as OT_cinfix3. This is used for
21687 tsts, cmps, cmns, and teqs. */
21688 OT_cinfix3_legacy, /* Legacy instruction takes a conditional infix at
21689 character index 3, even in unified mode. Used for
21690 legacy instructions where suffix and infix forms
21691 may be ambiguous. */
21692 OT_csuf_or_in3, /* Instruction takes either a conditional
21693 suffix or an infix at character index 3. */
21694 OT_odd_infix_unc, /* This is the unconditional variant of an
21695 instruction that takes a conditional infix
21696 at an unusual position. In unified mode,
21697 this variant will accept a suffix. */
21698 OT_odd_infix_0 /* Values greater than or equal to OT_odd_infix_0
21699 are the conditional variants of instructions that
21700 take conditional infixes in unusual positions.
21701 The infix appears at character index
21702 (tag - OT_odd_infix_0). These are not accepted
21703 in unified mode. */
21706 /* Subroutine of md_assemble, responsible for looking up the primary
21707 opcode from the mnemonic the user wrote. STR points to the
21708 beginning of the mnemonic.
21710 This is not simply a hash table lookup, because of conditional
21711 variants. Most instructions have conditional variants, which are
21712 expressed with a _conditional affix_ to the mnemonic. If we were
21713 to encode each conditional variant as a literal string in the opcode
21714 table, it would have approximately 20,000 entries.
21716 Most mnemonics take this affix as a suffix, and in unified syntax,
21717 'most' is upgraded to 'all'. However, in the divided syntax, some
21718 instructions take the affix as an infix, notably the s-variants of
21719 the arithmetic instructions. Of those instructions, all but six
21720 have the infix appear after the third character of the mnemonic.
21722 Accordingly, the algorithm for looking up primary opcodes given
21725 1. Look up the identifier in the opcode table.
21726 If we find a match, go to step U.
21728 2. Look up the last two characters of the identifier in the
21729 conditions table. If we find a match, look up the first N-2
21730 characters of the identifier in the opcode table. If we
21731 find a match, go to step CE.
21733 3. Look up the fourth and fifth characters of the identifier in
21734 the conditions table. If we find a match, extract those
21735 characters from the identifier, and look up the remaining
21736 characters in the opcode table. If we find a match, go
21741 U. Examine the tag field of the opcode structure, in case this is
21742 one of the six instructions with its conditional infix in an
21743 unusual place. If it is, the tag tells us where to find the
21744 infix; look it up in the conditions table and set inst.cond
21745 accordingly. Otherwise, this is an unconditional instruction.
21746 Again set inst.cond accordingly. Return the opcode structure.
21748 CE. Examine the tag field to make sure this is an instruction that
21749 should receive a conditional suffix. If it is not, fail.
21750 Otherwise, set inst.cond from the suffix we already looked up,
21751 and return the opcode structure.
21753 CM. Examine the tag field to make sure this is an instruction that
21754 should receive a conditional infix after the third character.
21755 If it is not, fail. Otherwise, undo the edits to the current
21756 line of input and proceed as for case CE. */
21758 static const struct asm_opcode *
21759 opcode_lookup (char **str)
21763 const struct asm_opcode *opcode;
21764 const struct asm_cond *cond;
21767 /* Scan up to the end of the mnemonic, which must end in white space,
21768 '.' (in unified mode, or for Neon/VFP instructions), or end of string. */
21769 for (base = end = *str; *end != '\0'; end++)
21770 if (*end == ' ' || *end == '.')
21776 /* Handle a possible width suffix and/or Neon type suffix. */
21781 /* The .w and .n suffixes are only valid if the unified syntax is in
21783 if (unified_syntax && end[1] == 'w')
21785 else if (unified_syntax && end[1] == 'n')
21790 inst.vectype.elems = 0;
21792 *str = end + offset;
21794 if (end[offset] == '.')
21796 /* See if we have a Neon type suffix (possible in either unified or
21797 non-unified ARM syntax mode). */
21798 if (parse_neon_type (&inst.vectype, str) == FAIL)
21801 else if (end[offset] != '\0' && end[offset] != ' ')
21807 /* Look for unaffixed or special-case affixed mnemonic. */
21808 opcode = (const struct asm_opcode *) hash_find_n (arm_ops_hsh, base,
21813 if (opcode->tag < OT_odd_infix_0)
21815 inst.cond = COND_ALWAYS;
21819 if (warn_on_deprecated && unified_syntax)
21820 as_tsktsk (_("conditional infixes are deprecated in unified syntax"));
21821 affix = base + (opcode->tag - OT_odd_infix_0);
21822 cond = (const struct asm_cond *) hash_find_n (arm_cond_hsh, affix, 2);
21825 inst.cond = cond->value;
21828 if (ARM_CPU_HAS_FEATURE (cpu_variant, mve_ext))
21830 /* Cannot have a conditional suffix on a mnemonic of less than a character.
21832 if (end - base < 2)
21835 cond = (const struct asm_cond *) hash_find_n (arm_vcond_hsh, affix, 1);
21836 opcode = (const struct asm_opcode *) hash_find_n (arm_ops_hsh, base,
21838 /* If this opcode can not be vector predicated then don't accept it with a
21839 vector predication code. */
21840 if (opcode && !opcode->mayBeVecPred)
21843 if (!opcode || !cond)
21845 /* Cannot have a conditional suffix on a mnemonic of less than two
21847 if (end - base < 3)
21850 /* Look for suffixed mnemonic. */
21852 cond = (const struct asm_cond *) hash_find_n (arm_cond_hsh, affix, 2);
21853 opcode = (const struct asm_opcode *) hash_find_n (arm_ops_hsh, base,
21857 if (opcode && cond)
21860 switch (opcode->tag)
21862 case OT_cinfix3_legacy:
21863 /* Ignore conditional suffixes matched on infix only mnemonics. */
21867 case OT_cinfix3_deprecated:
21868 case OT_odd_infix_unc:
21869 if (!unified_syntax)
21871 /* Fall through. */
21875 case OT_csuf_or_in3:
21876 inst.cond = cond->value;
21879 case OT_unconditional:
21880 case OT_unconditionalF:
21882 inst.cond = cond->value;
21885 /* Delayed diagnostic. */
21886 inst.error = BAD_COND;
21887 inst.cond = COND_ALWAYS;
21896 /* Cannot have a usual-position infix on a mnemonic of less than
21897 six characters (five would be a suffix). */
21898 if (end - base < 6)
21901 /* Look for infixed mnemonic in the usual position. */
21903 cond = (const struct asm_cond *) hash_find_n (arm_cond_hsh, affix, 2);
21907 memcpy (save, affix, 2);
21908 memmove (affix, affix + 2, (end - affix) - 2);
21909 opcode = (const struct asm_opcode *) hash_find_n (arm_ops_hsh, base,
21911 memmove (affix + 2, affix, (end - affix) - 2);
21912 memcpy (affix, save, 2);
21915 && (opcode->tag == OT_cinfix3
21916 || opcode->tag == OT_cinfix3_deprecated
21917 || opcode->tag == OT_csuf_or_in3
21918 || opcode->tag == OT_cinfix3_legacy))
21921 if (warn_on_deprecated && unified_syntax
21922 && (opcode->tag == OT_cinfix3
21923 || opcode->tag == OT_cinfix3_deprecated))
21924 as_tsktsk (_("conditional infixes are deprecated in unified syntax"));
21926 inst.cond = cond->value;
21933 /* This function generates an initial IT instruction, leaving its block
21934 virtually open for the new instructions. Eventually,
21935 the mask will be updated by now_pred_add_mask () each time
21936 a new instruction needs to be included in the IT block.
21937 Finally, the block is closed with close_automatic_it_block ().
21938 The block closure can be requested either from md_assemble (),
21939 a tencode (), or due to a label hook. */
21942 new_automatic_it_block (int cond)
21944 now_pred.state = AUTOMATIC_PRED_BLOCK;
21945 now_pred.mask = 0x18;
21946 now_pred.cc = cond;
21947 now_pred.block_length = 1;
21948 mapping_state (MAP_THUMB);
21949 now_pred.insn = output_it_inst (cond, now_pred.mask, NULL);
21950 now_pred.warn_deprecated = FALSE;
21951 now_pred.insn_cond = TRUE;
21954 /* Close an automatic IT block.
21955 See comments in new_automatic_it_block (). */
21958 close_automatic_it_block (void)
21960 now_pred.mask = 0x10;
21961 now_pred.block_length = 0;
21964 /* Update the mask of the current automatically-generated IT
21965 instruction. See comments in new_automatic_it_block (). */
21968 now_pred_add_mask (int cond)
21970 #define CLEAR_BIT(value, nbit) ((value) & ~(1 << (nbit)))
21971 #define SET_BIT_VALUE(value, bitvalue, nbit) (CLEAR_BIT (value, nbit) \
21972 | ((bitvalue) << (nbit)))
21973 const int resulting_bit = (cond & 1);
21975 now_pred.mask &= 0xf;
21976 now_pred.mask = SET_BIT_VALUE (now_pred.mask,
21978 (5 - now_pred.block_length));
21979 now_pred.mask = SET_BIT_VALUE (now_pred.mask,
21981 ((5 - now_pred.block_length) - 1));
21982 output_it_inst (now_pred.cc, now_pred.mask, now_pred.insn);
21985 #undef SET_BIT_VALUE
21988 /* The IT blocks handling machinery is accessed through the these functions:
21989 it_fsm_pre_encode () from md_assemble ()
21990 set_pred_insn_type () optional, from the tencode functions
21991 set_pred_insn_type_last () ditto
21992 in_pred_block () ditto
21993 it_fsm_post_encode () from md_assemble ()
21994 force_automatic_it_block_close () from label handling functions
21997 1) md_assemble () calls it_fsm_pre_encode () before calling tencode (),
21998 initializing the IT insn type with a generic initial value depending
21999 on the inst.condition.
22000 2) During the tencode function, two things may happen:
22001 a) The tencode function overrides the IT insn type by
22002 calling either set_pred_insn_type (type) or
22003 set_pred_insn_type_last ().
22004 b) The tencode function queries the IT block state by
22005 calling in_pred_block () (i.e. to determine narrow/not narrow mode).
22007 Both set_pred_insn_type and in_pred_block run the internal FSM state
22008 handling function (handle_pred_state), because: a) setting the IT insn
22009 type may incur in an invalid state (exiting the function),
22010 and b) querying the state requires the FSM to be updated.
22011 Specifically we want to avoid creating an IT block for conditional
22012 branches, so it_fsm_pre_encode is actually a guess and we can't
22013 determine whether an IT block is required until the tencode () routine
22014 has decided what type of instruction this actually it.
22015 Because of this, if set_pred_insn_type and in_pred_block have to be
22016 used, set_pred_insn_type has to be called first.
22018 set_pred_insn_type_last () is a wrapper of set_pred_insn_type (type),
22019 that determines the insn IT type depending on the inst.cond code.
22020 When a tencode () routine encodes an instruction that can be
22021 either outside an IT block, or, in the case of being inside, has to be
22022 the last one, set_pred_insn_type_last () will determine the proper
22023 IT instruction type based on the inst.cond code. Otherwise,
22024 set_pred_insn_type can be called for overriding that logic or
22025 for covering other cases.
22027 Calling handle_pred_state () may not transition the IT block state to
22028 OUTSIDE_PRED_BLOCK immediately, since the (current) state could be
22029 still queried. Instead, if the FSM determines that the state should
22030 be transitioned to OUTSIDE_PRED_BLOCK, a flag is marked to be closed
22031 after the tencode () function: that's what it_fsm_post_encode () does.
22033 Since in_pred_block () calls the state handling function to get an
22034 updated state, an error may occur (due to invalid insns combination).
22035 In that case, inst.error is set.
22036 Therefore, inst.error has to be checked after the execution of
22037 the tencode () routine.
22039 3) Back in md_assemble(), it_fsm_post_encode () is called to commit
22040 any pending state change (if any) that didn't take place in
22041 handle_pred_state () as explained above. */
22044 it_fsm_pre_encode (void)
22046 if (inst.cond != COND_ALWAYS)
22047 inst.pred_insn_type = INSIDE_IT_INSN;
22049 inst.pred_insn_type = OUTSIDE_PRED_INSN;
22051 now_pred.state_handled = 0;
22054 /* IT state FSM handling function. */
22055 /* MVE instructions and non-MVE instructions are handled differently because of
22056 the introduction of VPT blocks.
22057 Specifications say that any non-MVE instruction inside a VPT block is
22058 UNPREDICTABLE, with the exception of the BKPT instruction. Whereas most MVE
22059 instructions are deemed to be UNPREDICTABLE if inside an IT block. For the
22060 few exceptions we have MVE_UNPREDICABLE_INSN.
22061 The error messages provided depending on the different combinations possible
22062 are described in the cases below:
22063 For 'most' MVE instructions:
22064 1) In an IT block, with an IT code: syntax error
22065 2) In an IT block, with a VPT code: error: must be in a VPT block
22066 3) In an IT block, with no code: warning: UNPREDICTABLE
22067 4) In a VPT block, with an IT code: syntax error
22068 5) In a VPT block, with a VPT code: OK!
22069 6) In a VPT block, with no code: error: missing code
22070 7) Outside a pred block, with an IT code: error: syntax error
22071 8) Outside a pred block, with a VPT code: error: should be in a VPT block
22072 9) Outside a pred block, with no code: OK!
22073 For non-MVE instructions:
22074 10) In an IT block, with an IT code: OK!
22075 11) In an IT block, with a VPT code: syntax error
22076 12) In an IT block, with no code: error: missing code
22077 13) In a VPT block, with an IT code: error: should be in an IT block
22078 14) In a VPT block, with a VPT code: syntax error
22079 15) In a VPT block, with no code: UNPREDICTABLE
22080 16) Outside a pred block, with an IT code: error: should be in an IT block
22081 17) Outside a pred block, with a VPT code: syntax error
22082 18) Outside a pred block, with no code: OK!
22087 handle_pred_state (void)
22089 now_pred.state_handled = 1;
22090 now_pred.insn_cond = FALSE;
22092 switch (now_pred.state)
22094 case OUTSIDE_PRED_BLOCK:
22095 switch (inst.pred_insn_type)
22097 case MVE_UNPREDICABLE_INSN:
22098 case MVE_OUTSIDE_PRED_INSN:
22099 if (inst.cond < COND_ALWAYS)
22101 /* Case 7: Outside a pred block, with an IT code: error: syntax
22103 inst.error = BAD_SYNTAX;
22106 /* Case 9: Outside a pred block, with no code: OK! */
22108 case OUTSIDE_PRED_INSN:
22109 if (inst.cond > COND_ALWAYS)
22111 /* Case 17: Outside a pred block, with a VPT code: syntax error.
22113 inst.error = BAD_SYNTAX;
22116 /* Case 18: Outside a pred block, with no code: OK! */
22119 case INSIDE_VPT_INSN:
22120 /* Case 8: Outside a pred block, with a VPT code: error: should be in
22122 inst.error = BAD_OUT_VPT;
22125 case INSIDE_IT_INSN:
22126 case INSIDE_IT_LAST_INSN:
22127 if (inst.cond < COND_ALWAYS)
22129 /* Case 16: Outside a pred block, with an IT code: error: should
22130 be in an IT block. */
22131 if (thumb_mode == 0)
22134 && !(implicit_it_mode & IMPLICIT_IT_MODE_ARM))
22135 as_tsktsk (_("Warning: conditional outside an IT block"\
22140 if ((implicit_it_mode & IMPLICIT_IT_MODE_THUMB)
22141 && ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_v6t2))
22143 /* Automatically generate the IT instruction. */
22144 new_automatic_it_block (inst.cond);
22145 if (inst.pred_insn_type == INSIDE_IT_LAST_INSN)
22146 close_automatic_it_block ();
22150 inst.error = BAD_OUT_IT;
22156 else if (inst.cond > COND_ALWAYS)
22158 /* Case 17: Outside a pred block, with a VPT code: syntax error.
22160 inst.error = BAD_SYNTAX;
22165 case IF_INSIDE_IT_LAST_INSN:
22166 case NEUTRAL_IT_INSN:
22170 if (inst.cond != COND_ALWAYS)
22171 first_error (BAD_SYNTAX);
22172 now_pred.state = MANUAL_PRED_BLOCK;
22173 now_pred.block_length = 0;
22174 now_pred.type = VECTOR_PRED;
22178 now_pred.state = MANUAL_PRED_BLOCK;
22179 now_pred.block_length = 0;
22180 now_pred.type = SCALAR_PRED;
22185 case AUTOMATIC_PRED_BLOCK:
22186 /* Three things may happen now:
22187 a) We should increment current it block size;
22188 b) We should close current it block (closing insn or 4 insns);
22189 c) We should close current it block and start a new one (due
22190 to incompatible conditions or
22191 4 insns-length block reached). */
22193 switch (inst.pred_insn_type)
22195 case INSIDE_VPT_INSN:
22197 case MVE_UNPREDICABLE_INSN:
22198 case MVE_OUTSIDE_PRED_INSN:
22200 case OUTSIDE_PRED_INSN:
22201 /* The closure of the block shall happen immediately,
22202 so any in_pred_block () call reports the block as closed. */
22203 force_automatic_it_block_close ();
22206 case INSIDE_IT_INSN:
22207 case INSIDE_IT_LAST_INSN:
22208 case IF_INSIDE_IT_LAST_INSN:
22209 now_pred.block_length++;
22211 if (now_pred.block_length > 4
22212 || !now_pred_compatible (inst.cond))
22214 force_automatic_it_block_close ();
22215 if (inst.pred_insn_type != IF_INSIDE_IT_LAST_INSN)
22216 new_automatic_it_block (inst.cond);
22220 now_pred.insn_cond = TRUE;
22221 now_pred_add_mask (inst.cond);
22224 if (now_pred.state == AUTOMATIC_PRED_BLOCK
22225 && (inst.pred_insn_type == INSIDE_IT_LAST_INSN
22226 || inst.pred_insn_type == IF_INSIDE_IT_LAST_INSN))
22227 close_automatic_it_block ();
22230 case NEUTRAL_IT_INSN:
22231 now_pred.block_length++;
22232 now_pred.insn_cond = TRUE;
22234 if (now_pred.block_length > 4)
22235 force_automatic_it_block_close ();
22237 now_pred_add_mask (now_pred.cc & 1);
22241 close_automatic_it_block ();
22242 now_pred.state = MANUAL_PRED_BLOCK;
22247 case MANUAL_PRED_BLOCK:
22250 if (now_pred.type == SCALAR_PRED)
22252 /* Check conditional suffixes. */
22253 cond = now_pred.cc ^ ((now_pred.mask >> 4) & 1) ^ 1;
22254 now_pred.mask <<= 1;
22255 now_pred.mask &= 0x1f;
22256 is_last = (now_pred.mask == 0x10);
22260 now_pred.cc ^= (now_pred.mask >> 4);
22261 cond = now_pred.cc + 0xf;
22262 now_pred.mask <<= 1;
22263 now_pred.mask &= 0x1f;
22264 is_last = now_pred.mask == 0x10;
22266 now_pred.insn_cond = TRUE;
22268 switch (inst.pred_insn_type)
22270 case OUTSIDE_PRED_INSN:
22271 if (now_pred.type == SCALAR_PRED)
22273 if (inst.cond == COND_ALWAYS)
22275 /* Case 12: In an IT block, with no code: error: missing
22277 inst.error = BAD_NOT_IT;
22280 else if (inst.cond > COND_ALWAYS)
22282 /* Case 11: In an IT block, with a VPT code: syntax error.
22284 inst.error = BAD_SYNTAX;
22287 else if (thumb_mode)
22289 /* This is for some special cases where a non-MVE
22290 instruction is not allowed in an IT block, such as cbz,
22291 but are put into one with a condition code.
22292 You could argue this should be a syntax error, but we
22293 gave the 'not allowed in IT block' diagnostic in the
22294 past so we will keep doing so. */
22295 inst.error = BAD_NOT_IT;
22302 /* Case 15: In a VPT block, with no code: UNPREDICTABLE. */
22303 as_tsktsk (MVE_NOT_VPT);
22306 case MVE_OUTSIDE_PRED_INSN:
22307 if (now_pred.type == SCALAR_PRED)
22309 if (inst.cond == COND_ALWAYS)
22311 /* Case 3: In an IT block, with no code: warning:
22313 as_tsktsk (MVE_NOT_IT);
22316 else if (inst.cond < COND_ALWAYS)
22318 /* Case 1: In an IT block, with an IT code: syntax error.
22320 inst.error = BAD_SYNTAX;
22328 if (inst.cond < COND_ALWAYS)
22330 /* Case 4: In a VPT block, with an IT code: syntax error.
22332 inst.error = BAD_SYNTAX;
22335 else if (inst.cond == COND_ALWAYS)
22337 /* Case 6: In a VPT block, with no code: error: missing
22339 inst.error = BAD_NOT_VPT;
22347 case MVE_UNPREDICABLE_INSN:
22348 as_tsktsk (now_pred.type == SCALAR_PRED ? MVE_NOT_IT : MVE_NOT_VPT);
22350 case INSIDE_IT_INSN:
22351 if (inst.cond > COND_ALWAYS)
22353 /* Case 11: In an IT block, with a VPT code: syntax error. */
22354 /* Case 14: In a VPT block, with a VPT code: syntax error. */
22355 inst.error = BAD_SYNTAX;
22358 else if (now_pred.type == SCALAR_PRED)
22360 /* Case 10: In an IT block, with an IT code: OK! */
22361 if (cond != inst.cond)
22363 inst.error = now_pred.type == SCALAR_PRED ? BAD_IT_COND :
22370 /* Case 13: In a VPT block, with an IT code: error: should be
22372 inst.error = BAD_OUT_IT;
22377 case INSIDE_VPT_INSN:
22378 if (now_pred.type == SCALAR_PRED)
22380 /* Case 2: In an IT block, with a VPT code: error: must be in a
22382 inst.error = BAD_OUT_VPT;
22385 /* Case 5: In a VPT block, with a VPT code: OK! */
22386 else if (cond != inst.cond)
22388 inst.error = BAD_VPT_COND;
22392 case INSIDE_IT_LAST_INSN:
22393 case IF_INSIDE_IT_LAST_INSN:
22394 if (now_pred.type == VECTOR_PRED || inst.cond > COND_ALWAYS)
22396 /* Case 4: In a VPT block, with an IT code: syntax error. */
22397 /* Case 11: In an IT block, with a VPT code: syntax error. */
22398 inst.error = BAD_SYNTAX;
22401 else if (cond != inst.cond)
22403 inst.error = BAD_IT_COND;
22408 inst.error = BAD_BRANCH;
22413 case NEUTRAL_IT_INSN:
22414 /* The BKPT instruction is unconditional even in a IT or VPT
22419 if (now_pred.type == SCALAR_PRED)
22421 inst.error = BAD_IT_IT;
22424 /* fall through. */
22426 if (inst.cond == COND_ALWAYS)
22428 /* Executing a VPT/VPST instruction inside an IT block or a
22429 VPT/VPST/IT instruction inside a VPT block is UNPREDICTABLE.
22431 if (now_pred.type == SCALAR_PRED)
22432 as_tsktsk (MVE_NOT_IT);
22434 as_tsktsk (MVE_NOT_VPT);
22439 /* VPT/VPST do not accept condition codes. */
22440 inst.error = BAD_SYNTAX;
22451 struct depr_insn_mask
22453 unsigned long pattern;
22454 unsigned long mask;
22455 const char* description;
22458 /* List of 16-bit instruction patterns deprecated in an IT block in
22460 static const struct depr_insn_mask depr_it_insns[] = {
22461 { 0xc000, 0xc000, N_("Short branches, Undefined, SVC, LDM/STM") },
22462 { 0xb000, 0xb000, N_("Miscellaneous 16-bit instructions") },
22463 { 0xa000, 0xb800, N_("ADR") },
22464 { 0x4800, 0xf800, N_("Literal loads") },
22465 { 0x4478, 0xf478, N_("Hi-register ADD, MOV, CMP, BX, BLX using pc") },
22466 { 0x4487, 0xfc87, N_("Hi-register ADD, MOV, CMP using pc") },
22467 /* NOTE: 0x00dd is not the real encoding, instead, it is the 'tvalue'
22468 field in asm_opcode. 'tvalue' is used at the stage this check happen. */
22469 { 0x00dd, 0x7fff, N_("ADD/SUB sp, sp #imm") },
22474 it_fsm_post_encode (void)
22478 if (!now_pred.state_handled)
22479 handle_pred_state ();
22481 if (now_pred.insn_cond
22482 && !now_pred.warn_deprecated
22483 && warn_on_deprecated
22484 && ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_v8)
22485 && !ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_m))
22487 if (inst.instruction >= 0x10000)
22489 as_tsktsk (_("IT blocks containing 32-bit Thumb instructions are "
22490 "performance deprecated in ARMv8-A and ARMv8-R"));
22491 now_pred.warn_deprecated = TRUE;
22495 const struct depr_insn_mask *p = depr_it_insns;
22497 while (p->mask != 0)
22499 if ((inst.instruction & p->mask) == p->pattern)
22501 as_tsktsk (_("IT blocks containing 16-bit Thumb "
22502 "instructions of the following class are "
22503 "performance deprecated in ARMv8-A and "
22504 "ARMv8-R: %s"), p->description);
22505 now_pred.warn_deprecated = TRUE;
22513 if (now_pred.block_length > 1)
22515 as_tsktsk (_("IT blocks containing more than one conditional "
22516 "instruction are performance deprecated in ARMv8-A and "
22518 now_pred.warn_deprecated = TRUE;
22522 is_last = (now_pred.mask == 0x10);
22525 now_pred.state = OUTSIDE_PRED_BLOCK;
22531 force_automatic_it_block_close (void)
22533 if (now_pred.state == AUTOMATIC_PRED_BLOCK)
22535 close_automatic_it_block ();
22536 now_pred.state = OUTSIDE_PRED_BLOCK;
22542 in_pred_block (void)
22544 if (!now_pred.state_handled)
22545 handle_pred_state ();
22547 return now_pred.state != OUTSIDE_PRED_BLOCK;
22550 /* Whether OPCODE only has T32 encoding. Since this function is only used by
22551 t32_insn_ok, OPCODE enabled by v6t2 extension bit do not need to be listed
22552 here, hence the "known" in the function name. */
22555 known_t32_only_insn (const struct asm_opcode *opcode)
22557 /* Original Thumb-1 wide instruction. */
22558 if (opcode->tencode == do_t_blx
22559 || opcode->tencode == do_t_branch23
22560 || ARM_CPU_HAS_FEATURE (*opcode->tvariant, arm_ext_msr)
22561 || ARM_CPU_HAS_FEATURE (*opcode->tvariant, arm_ext_barrier))
22564 /* Wide-only instruction added to ARMv8-M Baseline. */
22565 if (ARM_CPU_HAS_FEATURE (*opcode->tvariant, arm_ext_v8m_m_only)
22566 || ARM_CPU_HAS_FEATURE (*opcode->tvariant, arm_ext_atomics)
22567 || ARM_CPU_HAS_FEATURE (*opcode->tvariant, arm_ext_v6t2_v8m)
22568 || ARM_CPU_HAS_FEATURE (*opcode->tvariant, arm_ext_div))
22574 /* Whether wide instruction variant can be used if available for a valid OPCODE
22578 t32_insn_ok (arm_feature_set arch, const struct asm_opcode *opcode)
22580 if (known_t32_only_insn (opcode))
22583 /* Instruction with narrow and wide encoding added to ARMv8-M. Availability
22584 of variant T3 of B.W is checked in do_t_branch. */
22585 if (ARM_CPU_HAS_FEATURE (arch, arm_ext_v8m)
22586 && opcode->tencode == do_t_branch)
22589 /* MOV accepts T1/T3 encodings under Baseline, T3 encoding is 32bit. */
22590 if (ARM_CPU_HAS_FEATURE (arch, arm_ext_v8m)
22591 && opcode->tencode == do_t_mov_cmp
22592 /* Make sure CMP instruction is not affected. */
22593 && opcode->aencode == do_mov)
22596 /* Wide instruction variants of all instructions with narrow *and* wide
22597 variants become available with ARMv6t2. Other opcodes are either
22598 narrow-only or wide-only and are thus available if OPCODE is valid. */
22599 if (ARM_CPU_HAS_FEATURE (arch, arm_ext_v6t2))
22602 /* OPCODE with narrow only instruction variant or wide variant not
22608 md_assemble (char *str)
22611 const struct asm_opcode * opcode;
22613 /* Align the previous label if needed. */
22614 if (last_label_seen != NULL)
22616 symbol_set_frag (last_label_seen, frag_now);
22617 S_SET_VALUE (last_label_seen, (valueT) frag_now_fix ());
22618 S_SET_SEGMENT (last_label_seen, now_seg);
22621 memset (&inst, '\0', sizeof (inst));
22623 for (r = 0; r < ARM_IT_MAX_RELOCS; r++)
22624 inst.relocs[r].type = BFD_RELOC_UNUSED;
22626 opcode = opcode_lookup (&p);
22629 /* It wasn't an instruction, but it might be a register alias of
22630 the form alias .req reg, or a Neon .dn/.qn directive. */
22631 if (! create_register_alias (str, p)
22632 && ! create_neon_reg_alias (str, p))
22633 as_bad (_("bad instruction `%s'"), str);
22638 if (warn_on_deprecated && opcode->tag == OT_cinfix3_deprecated)
22639 as_tsktsk (_("s suffix on comparison instruction is deprecated"));
22641 /* The value which unconditional instructions should have in place of the
22642 condition field. */
22643 inst.uncond_value = (opcode->tag == OT_csuffixF) ? 0xf : -1;
22647 arm_feature_set variant;
22649 variant = cpu_variant;
22650 /* Only allow coprocessor instructions on Thumb-2 capable devices. */
22651 if (!ARM_CPU_HAS_FEATURE (variant, arm_arch_t2))
22652 ARM_CLEAR_FEATURE (variant, variant, fpu_any_hard);
22653 /* Check that this instruction is supported for this CPU. */
22654 if (!opcode->tvariant
22655 || (thumb_mode == 1
22656 && !ARM_CPU_HAS_FEATURE (variant, *opcode->tvariant)))
22658 if (opcode->tencode == do_t_swi)
22659 as_bad (_("SVC is not permitted on this architecture"));
22661 as_bad (_("selected processor does not support `%s' in Thumb mode"), str);
22664 if (inst.cond != COND_ALWAYS && !unified_syntax
22665 && opcode->tencode != do_t_branch)
22667 as_bad (_("Thumb does not support conditional execution"));
22671 /* Two things are addressed here:
22672 1) Implicit require narrow instructions on Thumb-1.
22673 This avoids relaxation accidentally introducing Thumb-2
22675 2) Reject wide instructions in non Thumb-2 cores.
22677 Only instructions with narrow and wide variants need to be handled
22678 but selecting all non wide-only instructions is easier. */
22679 if (!ARM_CPU_HAS_FEATURE (variant, arm_ext_v6t2)
22680 && !t32_insn_ok (variant, opcode))
22682 if (inst.size_req == 0)
22684 else if (inst.size_req == 4)
22686 if (ARM_CPU_HAS_FEATURE (variant, arm_ext_v8m))
22687 as_bad (_("selected processor does not support 32bit wide "
22688 "variant of instruction `%s'"), str);
22690 as_bad (_("selected processor does not support `%s' in "
22691 "Thumb-2 mode"), str);
22696 inst.instruction = opcode->tvalue;
22698 if (!parse_operands (p, opcode->operands, /*thumb=*/TRUE))
22700 /* Prepare the pred_insn_type for those encodings that don't set
22702 it_fsm_pre_encode ();
22704 opcode->tencode ();
22706 it_fsm_post_encode ();
22709 if (!(inst.error || inst.relax))
22711 gas_assert (inst.instruction < 0xe800 || inst.instruction > 0xffff);
22712 inst.size = (inst.instruction > 0xffff ? 4 : 2);
22713 if (inst.size_req && inst.size_req != inst.size)
22715 as_bad (_("cannot honor width suffix -- `%s'"), str);
22720 /* Something has gone badly wrong if we try to relax a fixed size
22722 gas_assert (inst.size_req == 0 || !inst.relax);
22724 ARM_MERGE_FEATURE_SETS (thumb_arch_used, thumb_arch_used,
22725 *opcode->tvariant);
22726 /* Many Thumb-2 instructions also have Thumb-1 variants, so explicitly
22727 set those bits when Thumb-2 32-bit instructions are seen. The impact
22728 of relaxable instructions will be considered later after we finish all
22730 if (ARM_FEATURE_CORE_EQUAL (cpu_variant, arm_arch_any))
22731 variant = arm_arch_none;
22733 variant = cpu_variant;
22734 if (inst.size == 4 && !t32_insn_ok (variant, opcode))
22735 ARM_MERGE_FEATURE_SETS (thumb_arch_used, thumb_arch_used,
22738 check_neon_suffixes;
22742 mapping_state (MAP_THUMB);
22745 else if (ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_v1))
22749 /* bx is allowed on v5 cores, and sometimes on v4 cores. */
22750 is_bx = (opcode->aencode == do_bx);
22752 /* Check that this instruction is supported for this CPU. */
22753 if (!(is_bx && fix_v4bx)
22754 && !(opcode->avariant &&
22755 ARM_CPU_HAS_FEATURE (cpu_variant, *opcode->avariant)))
22757 as_bad (_("selected processor does not support `%s' in ARM mode"), str);
22762 as_bad (_("width suffixes are invalid in ARM mode -- `%s'"), str);
22766 inst.instruction = opcode->avalue;
22767 if (opcode->tag == OT_unconditionalF)
22768 inst.instruction |= 0xFU << 28;
22770 inst.instruction |= inst.cond << 28;
22771 inst.size = INSN_SIZE;
22772 if (!parse_operands (p, opcode->operands, /*thumb=*/FALSE))
22774 it_fsm_pre_encode ();
22775 opcode->aencode ();
22776 it_fsm_post_encode ();
22778 /* Arm mode bx is marked as both v4T and v5 because it's still required
22779 on a hypothetical non-thumb v5 core. */
22781 ARM_MERGE_FEATURE_SETS (arm_arch_used, arm_arch_used, arm_ext_v4t);
22783 ARM_MERGE_FEATURE_SETS (arm_arch_used, arm_arch_used,
22784 *opcode->avariant);
22786 check_neon_suffixes;
22790 mapping_state (MAP_ARM);
22795 as_bad (_("attempt to use an ARM instruction on a Thumb-only processor "
22803 check_pred_blocks_finished (void)
22808 for (sect = stdoutput->sections; sect != NULL; sect = sect->next)
22809 if (seg_info (sect)->tc_segment_info_data.current_pred.state
22810 == MANUAL_PRED_BLOCK)
22812 if (now_pred.type == SCALAR_PRED)
22813 as_warn (_("section '%s' finished with an open IT block."),
22816 as_warn (_("section '%s' finished with an open VPT/VPST block."),
22820 if (now_pred.state == MANUAL_PRED_BLOCK)
22822 if (now_pred.type == SCALAR_PRED)
22823 as_warn (_("file finished with an open IT block."));
22825 as_warn (_("file finished with an open VPT/VPST block."));
22830 /* Various frobbings of labels and their addresses. */
22833 arm_start_line_hook (void)
22835 last_label_seen = NULL;
22839 arm_frob_label (symbolS * sym)
22841 last_label_seen = sym;
22843 ARM_SET_THUMB (sym, thumb_mode);
22845 #if defined OBJ_COFF || defined OBJ_ELF
22846 ARM_SET_INTERWORK (sym, support_interwork);
22849 force_automatic_it_block_close ();
22851 /* Note - do not allow local symbols (.Lxxx) to be labelled
22852 as Thumb functions. This is because these labels, whilst
22853 they exist inside Thumb code, are not the entry points for
22854 possible ARM->Thumb calls. Also, these labels can be used
22855 as part of a computed goto or switch statement. eg gcc
22856 can generate code that looks like this:
22858 ldr r2, [pc, .Laaa]
22868 The first instruction loads the address of the jump table.
22869 The second instruction converts a table index into a byte offset.
22870 The third instruction gets the jump address out of the table.
22871 The fourth instruction performs the jump.
22873 If the address stored at .Laaa is that of a symbol which has the
22874 Thumb_Func bit set, then the linker will arrange for this address
22875 to have the bottom bit set, which in turn would mean that the
22876 address computation performed by the third instruction would end
22877 up with the bottom bit set. Since the ARM is capable of unaligned
22878 word loads, the instruction would then load the incorrect address
22879 out of the jump table, and chaos would ensue. */
22880 if (label_is_thumb_function_name
22881 && (S_GET_NAME (sym)[0] != '.' || S_GET_NAME (sym)[1] != 'L')
22882 && (bfd_section_flags (now_seg) & SEC_CODE) != 0)
22884 /* When the address of a Thumb function is taken the bottom
22885 bit of that address should be set. This will allow
22886 interworking between Arm and Thumb functions to work
22889 THUMB_SET_FUNC (sym, 1);
22891 label_is_thumb_function_name = FALSE;
22894 dwarf2_emit_label (sym);
22898 arm_data_in_code (void)
22900 if (thumb_mode && ! strncmp (input_line_pointer + 1, "data:", 5))
22902 *input_line_pointer = '/';
22903 input_line_pointer += 5;
22904 *input_line_pointer = 0;
22912 arm_canonicalize_symbol_name (char * name)
22916 if (thumb_mode && (len = strlen (name)) > 5
22917 && streq (name + len - 5, "/data"))
22918 *(name + len - 5) = 0;
22923 /* Table of all register names defined by default. The user can
22924 define additional names with .req. Note that all register names
22925 should appear in both upper and lowercase variants. Some registers
22926 also have mixed-case names. */
22928 #define REGDEF(s,n,t) { #s, n, REG_TYPE_##t, TRUE, 0 }
22929 #define REGNUM(p,n,t) REGDEF(p##n, n, t)
22930 #define REGNUM2(p,n,t) REGDEF(p##n, 2 * n, t)
22931 #define REGSET(p,t) \
22932 REGNUM(p, 0,t), REGNUM(p, 1,t), REGNUM(p, 2,t), REGNUM(p, 3,t), \
22933 REGNUM(p, 4,t), REGNUM(p, 5,t), REGNUM(p, 6,t), REGNUM(p, 7,t), \
22934 REGNUM(p, 8,t), REGNUM(p, 9,t), REGNUM(p,10,t), REGNUM(p,11,t), \
22935 REGNUM(p,12,t), REGNUM(p,13,t), REGNUM(p,14,t), REGNUM(p,15,t)
22936 #define REGSETH(p,t) \
22937 REGNUM(p,16,t), REGNUM(p,17,t), REGNUM(p,18,t), REGNUM(p,19,t), \
22938 REGNUM(p,20,t), REGNUM(p,21,t), REGNUM(p,22,t), REGNUM(p,23,t), \
22939 REGNUM(p,24,t), REGNUM(p,25,t), REGNUM(p,26,t), REGNUM(p,27,t), \
22940 REGNUM(p,28,t), REGNUM(p,29,t), REGNUM(p,30,t), REGNUM(p,31,t)
22941 #define REGSET2(p,t) \
22942 REGNUM2(p, 0,t), REGNUM2(p, 1,t), REGNUM2(p, 2,t), REGNUM2(p, 3,t), \
22943 REGNUM2(p, 4,t), REGNUM2(p, 5,t), REGNUM2(p, 6,t), REGNUM2(p, 7,t), \
22944 REGNUM2(p, 8,t), REGNUM2(p, 9,t), REGNUM2(p,10,t), REGNUM2(p,11,t), \
22945 REGNUM2(p,12,t), REGNUM2(p,13,t), REGNUM2(p,14,t), REGNUM2(p,15,t)
22946 #define SPLRBANK(base,bank,t) \
22947 REGDEF(lr_##bank, 768|((base+0)<<16), t), \
22948 REGDEF(sp_##bank, 768|((base+1)<<16), t), \
22949 REGDEF(spsr_##bank, 768|(base<<16)|SPSR_BIT, t), \
22950 REGDEF(LR_##bank, 768|((base+0)<<16), t), \
22951 REGDEF(SP_##bank, 768|((base+1)<<16), t), \
22952 REGDEF(SPSR_##bank, 768|(base<<16)|SPSR_BIT, t)
22954 static const struct reg_entry reg_names[] =
22956 /* ARM integer registers. */
22957 REGSET(r, RN), REGSET(R, RN),
22959 /* ATPCS synonyms. */
22960 REGDEF(a1,0,RN), REGDEF(a2,1,RN), REGDEF(a3, 2,RN), REGDEF(a4, 3,RN),
22961 REGDEF(v1,4,RN), REGDEF(v2,5,RN), REGDEF(v3, 6,RN), REGDEF(v4, 7,RN),
22962 REGDEF(v5,8,RN), REGDEF(v6,9,RN), REGDEF(v7,10,RN), REGDEF(v8,11,RN),
22964 REGDEF(A1,0,RN), REGDEF(A2,1,RN), REGDEF(A3, 2,RN), REGDEF(A4, 3,RN),
22965 REGDEF(V1,4,RN), REGDEF(V2,5,RN), REGDEF(V3, 6,RN), REGDEF(V4, 7,RN),
22966 REGDEF(V5,8,RN), REGDEF(V6,9,RN), REGDEF(V7,10,RN), REGDEF(V8,11,RN),
22968 /* Well-known aliases. */
22969 REGDEF(wr, 7,RN), REGDEF(sb, 9,RN), REGDEF(sl,10,RN), REGDEF(fp,11,RN),
22970 REGDEF(ip,12,RN), REGDEF(sp,13,RN), REGDEF(lr,14,RN), REGDEF(pc,15,RN),
22972 REGDEF(WR, 7,RN), REGDEF(SB, 9,RN), REGDEF(SL,10,RN), REGDEF(FP,11,RN),
22973 REGDEF(IP,12,RN), REGDEF(SP,13,RN), REGDEF(LR,14,RN), REGDEF(PC,15,RN),
22975 /* Defining the new Zero register from ARMv8.1-M. */
22979 /* Coprocessor numbers. */
22980 REGSET(p, CP), REGSET(P, CP),
22982 /* Coprocessor register numbers. The "cr" variants are for backward
22984 REGSET(c, CN), REGSET(C, CN),
22985 REGSET(cr, CN), REGSET(CR, CN),
22987 /* ARM banked registers. */
22988 REGDEF(R8_usr,512|(0<<16),RNB), REGDEF(r8_usr,512|(0<<16),RNB),
22989 REGDEF(R9_usr,512|(1<<16),RNB), REGDEF(r9_usr,512|(1<<16),RNB),
22990 REGDEF(R10_usr,512|(2<<16),RNB), REGDEF(r10_usr,512|(2<<16),RNB),
22991 REGDEF(R11_usr,512|(3<<16),RNB), REGDEF(r11_usr,512|(3<<16),RNB),
22992 REGDEF(R12_usr,512|(4<<16),RNB), REGDEF(r12_usr,512|(4<<16),RNB),
22993 REGDEF(SP_usr,512|(5<<16),RNB), REGDEF(sp_usr,512|(5<<16),RNB),
22994 REGDEF(LR_usr,512|(6<<16),RNB), REGDEF(lr_usr,512|(6<<16),RNB),
22996 REGDEF(R8_fiq,512|(8<<16),RNB), REGDEF(r8_fiq,512|(8<<16),RNB),
22997 REGDEF(R9_fiq,512|(9<<16),RNB), REGDEF(r9_fiq,512|(9<<16),RNB),
22998 REGDEF(R10_fiq,512|(10<<16),RNB), REGDEF(r10_fiq,512|(10<<16),RNB),
22999 REGDEF(R11_fiq,512|(11<<16),RNB), REGDEF(r11_fiq,512|(11<<16),RNB),
23000 REGDEF(R12_fiq,512|(12<<16),RNB), REGDEF(r12_fiq,512|(12<<16),RNB),
23001 REGDEF(SP_fiq,512|(13<<16),RNB), REGDEF(sp_fiq,512|(13<<16),RNB),
23002 REGDEF(LR_fiq,512|(14<<16),RNB), REGDEF(lr_fiq,512|(14<<16),RNB),
23003 REGDEF(SPSR_fiq,512|(14<<16)|SPSR_BIT,RNB), REGDEF(spsr_fiq,512|(14<<16)|SPSR_BIT,RNB),
23005 SPLRBANK(0,IRQ,RNB), SPLRBANK(0,irq,RNB),
23006 SPLRBANK(2,SVC,RNB), SPLRBANK(2,svc,RNB),
23007 SPLRBANK(4,ABT,RNB), SPLRBANK(4,abt,RNB),
23008 SPLRBANK(6,UND,RNB), SPLRBANK(6,und,RNB),
23009 SPLRBANK(12,MON,RNB), SPLRBANK(12,mon,RNB),
23010 REGDEF(elr_hyp,768|(14<<16),RNB), REGDEF(ELR_hyp,768|(14<<16),RNB),
23011 REGDEF(sp_hyp,768|(15<<16),RNB), REGDEF(SP_hyp,768|(15<<16),RNB),
23012 REGDEF(spsr_hyp,768|(14<<16)|SPSR_BIT,RNB),
23013 REGDEF(SPSR_hyp,768|(14<<16)|SPSR_BIT,RNB),
23015 /* FPA registers. */
23016 REGNUM(f,0,FN), REGNUM(f,1,FN), REGNUM(f,2,FN), REGNUM(f,3,FN),
23017 REGNUM(f,4,FN), REGNUM(f,5,FN), REGNUM(f,6,FN), REGNUM(f,7, FN),
23019 REGNUM(F,0,FN), REGNUM(F,1,FN), REGNUM(F,2,FN), REGNUM(F,3,FN),
23020 REGNUM(F,4,FN), REGNUM(F,5,FN), REGNUM(F,6,FN), REGNUM(F,7, FN),
23022 /* VFP SP registers. */
23023 REGSET(s,VFS), REGSET(S,VFS),
23024 REGSETH(s,VFS), REGSETH(S,VFS),
23026 /* VFP DP Registers. */
23027 REGSET(d,VFD), REGSET(D,VFD),
23028 /* Extra Neon DP registers. */
23029 REGSETH(d,VFD), REGSETH(D,VFD),
23031 /* Neon QP registers. */
23032 REGSET2(q,NQ), REGSET2(Q,NQ),
23034 /* VFP control registers. */
23035 REGDEF(fpsid,0,VFC), REGDEF(fpscr,1,VFC), REGDEF(fpexc,8,VFC),
23036 REGDEF(FPSID,0,VFC), REGDEF(FPSCR,1,VFC), REGDEF(FPEXC,8,VFC),
23037 REGDEF(fpinst,9,VFC), REGDEF(fpinst2,10,VFC),
23038 REGDEF(FPINST,9,VFC), REGDEF(FPINST2,10,VFC),
23039 REGDEF(mvfr0,7,VFC), REGDEF(mvfr1,6,VFC),
23040 REGDEF(MVFR0,7,VFC), REGDEF(MVFR1,6,VFC),
23041 REGDEF(mvfr2,5,VFC), REGDEF(MVFR2,5,VFC),
23042 REGDEF(fpscr_nzcvqc,2,VFC), REGDEF(FPSCR_nzcvqc,2,VFC),
23043 REGDEF(vpr,12,VFC), REGDEF(VPR,12,VFC),
23044 REGDEF(fpcxt_ns,14,VFC), REGDEF(FPCXT_NS,14,VFC),
23045 REGDEF(fpcxt_s,15,VFC), REGDEF(FPCXT_S,15,VFC),
23047 /* Maverick DSP coprocessor registers. */
23048 REGSET(mvf,MVF), REGSET(mvd,MVD), REGSET(mvfx,MVFX), REGSET(mvdx,MVDX),
23049 REGSET(MVF,MVF), REGSET(MVD,MVD), REGSET(MVFX,MVFX), REGSET(MVDX,MVDX),
23051 REGNUM(mvax,0,MVAX), REGNUM(mvax,1,MVAX),
23052 REGNUM(mvax,2,MVAX), REGNUM(mvax,3,MVAX),
23053 REGDEF(dspsc,0,DSPSC),
23055 REGNUM(MVAX,0,MVAX), REGNUM(MVAX,1,MVAX),
23056 REGNUM(MVAX,2,MVAX), REGNUM(MVAX,3,MVAX),
23057 REGDEF(DSPSC,0,DSPSC),
23059 /* iWMMXt data registers - p0, c0-15. */
23060 REGSET(wr,MMXWR), REGSET(wR,MMXWR), REGSET(WR, MMXWR),
23062 /* iWMMXt control registers - p1, c0-3. */
23063 REGDEF(wcid, 0,MMXWC), REGDEF(wCID, 0,MMXWC), REGDEF(WCID, 0,MMXWC),
23064 REGDEF(wcon, 1,MMXWC), REGDEF(wCon, 1,MMXWC), REGDEF(WCON, 1,MMXWC),
23065 REGDEF(wcssf, 2,MMXWC), REGDEF(wCSSF, 2,MMXWC), REGDEF(WCSSF, 2,MMXWC),
23066 REGDEF(wcasf, 3,MMXWC), REGDEF(wCASF, 3,MMXWC), REGDEF(WCASF, 3,MMXWC),
23068 /* iWMMXt scalar (constant/offset) registers - p1, c8-11. */
23069 REGDEF(wcgr0, 8,MMXWCG), REGDEF(wCGR0, 8,MMXWCG), REGDEF(WCGR0, 8,MMXWCG),
23070 REGDEF(wcgr1, 9,MMXWCG), REGDEF(wCGR1, 9,MMXWCG), REGDEF(WCGR1, 9,MMXWCG),
23071 REGDEF(wcgr2,10,MMXWCG), REGDEF(wCGR2,10,MMXWCG), REGDEF(WCGR2,10,MMXWCG),
23072 REGDEF(wcgr3,11,MMXWCG), REGDEF(wCGR3,11,MMXWCG), REGDEF(WCGR3,11,MMXWCG),
23074 /* XScale accumulator registers. */
23075 REGNUM(acc,0,XSCALE), REGNUM(ACC,0,XSCALE),
23081 /* Table of all PSR suffixes. Bare "CPSR" and "SPSR" are handled
23082 within psr_required_here. */
23083 static const struct asm_psr psrs[] =
23085 /* Backward compatibility notation. Note that "all" is no longer
23086 truly all possible PSR bits. */
23087 {"all", PSR_c | PSR_f},
23091 /* Individual flags. */
23097 /* Combinations of flags. */
23098 {"fs", PSR_f | PSR_s},
23099 {"fx", PSR_f | PSR_x},
23100 {"fc", PSR_f | PSR_c},
23101 {"sf", PSR_s | PSR_f},
23102 {"sx", PSR_s | PSR_x},
23103 {"sc", PSR_s | PSR_c},
23104 {"xf", PSR_x | PSR_f},
23105 {"xs", PSR_x | PSR_s},
23106 {"xc", PSR_x | PSR_c},
23107 {"cf", PSR_c | PSR_f},
23108 {"cs", PSR_c | PSR_s},
23109 {"cx", PSR_c | PSR_x},
23110 {"fsx", PSR_f | PSR_s | PSR_x},
23111 {"fsc", PSR_f | PSR_s | PSR_c},
23112 {"fxs", PSR_f | PSR_x | PSR_s},
23113 {"fxc", PSR_f | PSR_x | PSR_c},
23114 {"fcs", PSR_f | PSR_c | PSR_s},
23115 {"fcx", PSR_f | PSR_c | PSR_x},
23116 {"sfx", PSR_s | PSR_f | PSR_x},
23117 {"sfc", PSR_s | PSR_f | PSR_c},
23118 {"sxf", PSR_s | PSR_x | PSR_f},
23119 {"sxc", PSR_s | PSR_x | PSR_c},
23120 {"scf", PSR_s | PSR_c | PSR_f},
23121 {"scx", PSR_s | PSR_c | PSR_x},
23122 {"xfs", PSR_x | PSR_f | PSR_s},
23123 {"xfc", PSR_x | PSR_f | PSR_c},
23124 {"xsf", PSR_x | PSR_s | PSR_f},
23125 {"xsc", PSR_x | PSR_s | PSR_c},
23126 {"xcf", PSR_x | PSR_c | PSR_f},
23127 {"xcs", PSR_x | PSR_c | PSR_s},
23128 {"cfs", PSR_c | PSR_f | PSR_s},
23129 {"cfx", PSR_c | PSR_f | PSR_x},
23130 {"csf", PSR_c | PSR_s | PSR_f},
23131 {"csx", PSR_c | PSR_s | PSR_x},
23132 {"cxf", PSR_c | PSR_x | PSR_f},
23133 {"cxs", PSR_c | PSR_x | PSR_s},
23134 {"fsxc", PSR_f | PSR_s | PSR_x | PSR_c},
23135 {"fscx", PSR_f | PSR_s | PSR_c | PSR_x},
23136 {"fxsc", PSR_f | PSR_x | PSR_s | PSR_c},
23137 {"fxcs", PSR_f | PSR_x | PSR_c | PSR_s},
23138 {"fcsx", PSR_f | PSR_c | PSR_s | PSR_x},
23139 {"fcxs", PSR_f | PSR_c | PSR_x | PSR_s},
23140 {"sfxc", PSR_s | PSR_f | PSR_x | PSR_c},
23141 {"sfcx", PSR_s | PSR_f | PSR_c | PSR_x},
23142 {"sxfc", PSR_s | PSR_x | PSR_f | PSR_c},
23143 {"sxcf", PSR_s | PSR_x | PSR_c | PSR_f},
23144 {"scfx", PSR_s | PSR_c | PSR_f | PSR_x},
23145 {"scxf", PSR_s | PSR_c | PSR_x | PSR_f},
23146 {"xfsc", PSR_x | PSR_f | PSR_s | PSR_c},
23147 {"xfcs", PSR_x | PSR_f | PSR_c | PSR_s},
23148 {"xsfc", PSR_x | PSR_s | PSR_f | PSR_c},
23149 {"xscf", PSR_x | PSR_s | PSR_c | PSR_f},
23150 {"xcfs", PSR_x | PSR_c | PSR_f | PSR_s},
23151 {"xcsf", PSR_x | PSR_c | PSR_s | PSR_f},
23152 {"cfsx", PSR_c | PSR_f | PSR_s | PSR_x},
23153 {"cfxs", PSR_c | PSR_f | PSR_x | PSR_s},
23154 {"csfx", PSR_c | PSR_s | PSR_f | PSR_x},
23155 {"csxf", PSR_c | PSR_s | PSR_x | PSR_f},
23156 {"cxfs", PSR_c | PSR_x | PSR_f | PSR_s},
23157 {"cxsf", PSR_c | PSR_x | PSR_s | PSR_f},
23160 /* Table of V7M psr names. */
23161 static const struct asm_psr v7m_psrs[] =
23163 {"apsr", 0x0 }, {"APSR", 0x0 },
23164 {"iapsr", 0x1 }, {"IAPSR", 0x1 },
23165 {"eapsr", 0x2 }, {"EAPSR", 0x2 },
23166 {"psr", 0x3 }, {"PSR", 0x3 },
23167 {"xpsr", 0x3 }, {"XPSR", 0x3 }, {"xPSR", 3 },
23168 {"ipsr", 0x5 }, {"IPSR", 0x5 },
23169 {"epsr", 0x6 }, {"EPSR", 0x6 },
23170 {"iepsr", 0x7 }, {"IEPSR", 0x7 },
23171 {"msp", 0x8 }, {"MSP", 0x8 },
23172 {"psp", 0x9 }, {"PSP", 0x9 },
23173 {"msplim", 0xa }, {"MSPLIM", 0xa },
23174 {"psplim", 0xb }, {"PSPLIM", 0xb },
23175 {"primask", 0x10}, {"PRIMASK", 0x10},
23176 {"basepri", 0x11}, {"BASEPRI", 0x11},
23177 {"basepri_max", 0x12}, {"BASEPRI_MAX", 0x12},
23178 {"faultmask", 0x13}, {"FAULTMASK", 0x13},
23179 {"control", 0x14}, {"CONTROL", 0x14},
23180 {"msp_ns", 0x88}, {"MSP_NS", 0x88},
23181 {"psp_ns", 0x89}, {"PSP_NS", 0x89},
23182 {"msplim_ns", 0x8a}, {"MSPLIM_NS", 0x8a},
23183 {"psplim_ns", 0x8b}, {"PSPLIM_NS", 0x8b},
23184 {"primask_ns", 0x90}, {"PRIMASK_NS", 0x90},
23185 {"basepri_ns", 0x91}, {"BASEPRI_NS", 0x91},
23186 {"faultmask_ns", 0x93}, {"FAULTMASK_NS", 0x93},
23187 {"control_ns", 0x94}, {"CONTROL_NS", 0x94},
23188 {"sp_ns", 0x98}, {"SP_NS", 0x98 }
23191 /* Table of all shift-in-operand names. */
23192 static const struct asm_shift_name shift_names [] =
23194 { "asl", SHIFT_LSL }, { "ASL", SHIFT_LSL },
23195 { "lsl", SHIFT_LSL }, { "LSL", SHIFT_LSL },
23196 { "lsr", SHIFT_LSR }, { "LSR", SHIFT_LSR },
23197 { "asr", SHIFT_ASR }, { "ASR", SHIFT_ASR },
23198 { "ror", SHIFT_ROR }, { "ROR", SHIFT_ROR },
23199 { "rrx", SHIFT_RRX }, { "RRX", SHIFT_RRX },
23200 { "uxtw", SHIFT_UXTW}, { "UXTW", SHIFT_UXTW}
23203 /* Table of all explicit relocation names. */
23205 static struct reloc_entry reloc_names[] =
23207 { "got", BFD_RELOC_ARM_GOT32 }, { "GOT", BFD_RELOC_ARM_GOT32 },
23208 { "gotoff", BFD_RELOC_ARM_GOTOFF }, { "GOTOFF", BFD_RELOC_ARM_GOTOFF },
23209 { "plt", BFD_RELOC_ARM_PLT32 }, { "PLT", BFD_RELOC_ARM_PLT32 },
23210 { "target1", BFD_RELOC_ARM_TARGET1 }, { "TARGET1", BFD_RELOC_ARM_TARGET1 },
23211 { "target2", BFD_RELOC_ARM_TARGET2 }, { "TARGET2", BFD_RELOC_ARM_TARGET2 },
23212 { "sbrel", BFD_RELOC_ARM_SBREL32 }, { "SBREL", BFD_RELOC_ARM_SBREL32 },
23213 { "tlsgd", BFD_RELOC_ARM_TLS_GD32}, { "TLSGD", BFD_RELOC_ARM_TLS_GD32},
23214 { "tlsldm", BFD_RELOC_ARM_TLS_LDM32}, { "TLSLDM", BFD_RELOC_ARM_TLS_LDM32},
23215 { "tlsldo", BFD_RELOC_ARM_TLS_LDO32}, { "TLSLDO", BFD_RELOC_ARM_TLS_LDO32},
23216 { "gottpoff",BFD_RELOC_ARM_TLS_IE32}, { "GOTTPOFF",BFD_RELOC_ARM_TLS_IE32},
23217 { "tpoff", BFD_RELOC_ARM_TLS_LE32}, { "TPOFF", BFD_RELOC_ARM_TLS_LE32},
23218 { "got_prel", BFD_RELOC_ARM_GOT_PREL}, { "GOT_PREL", BFD_RELOC_ARM_GOT_PREL},
23219 { "tlsdesc", BFD_RELOC_ARM_TLS_GOTDESC},
23220 { "TLSDESC", BFD_RELOC_ARM_TLS_GOTDESC},
23221 { "tlscall", BFD_RELOC_ARM_TLS_CALL},
23222 { "TLSCALL", BFD_RELOC_ARM_TLS_CALL},
23223 { "tlsdescseq", BFD_RELOC_ARM_TLS_DESCSEQ},
23224 { "TLSDESCSEQ", BFD_RELOC_ARM_TLS_DESCSEQ},
23225 { "gotfuncdesc", BFD_RELOC_ARM_GOTFUNCDESC },
23226 { "GOTFUNCDESC", BFD_RELOC_ARM_GOTFUNCDESC },
23227 { "gotofffuncdesc", BFD_RELOC_ARM_GOTOFFFUNCDESC },
23228 { "GOTOFFFUNCDESC", BFD_RELOC_ARM_GOTOFFFUNCDESC },
23229 { "funcdesc", BFD_RELOC_ARM_FUNCDESC },
23230 { "FUNCDESC", BFD_RELOC_ARM_FUNCDESC },
23231 { "tlsgd_fdpic", BFD_RELOC_ARM_TLS_GD32_FDPIC }, { "TLSGD_FDPIC", BFD_RELOC_ARM_TLS_GD32_FDPIC },
23232 { "tlsldm_fdpic", BFD_RELOC_ARM_TLS_LDM32_FDPIC }, { "TLSLDM_FDPIC", BFD_RELOC_ARM_TLS_LDM32_FDPIC },
23233 { "gottpoff_fdpic", BFD_RELOC_ARM_TLS_IE32_FDPIC }, { "GOTTPOFF_FDIC", BFD_RELOC_ARM_TLS_IE32_FDPIC },
23237 /* Table of all conditional affixes. */
23238 static const struct asm_cond conds[] =
23242 {"cs", 0x2}, {"hs", 0x2},
23243 {"cc", 0x3}, {"ul", 0x3}, {"lo", 0x3},
23256 static const struct asm_cond vconds[] =
23262 #define UL_BARRIER(L,U,CODE,FEAT) \
23263 { L, CODE, ARM_FEATURE_CORE_LOW (FEAT) }, \
23264 { U, CODE, ARM_FEATURE_CORE_LOW (FEAT) }
23266 static struct asm_barrier_opt barrier_opt_names[] =
23268 UL_BARRIER ("sy", "SY", 0xf, ARM_EXT_BARRIER),
23269 UL_BARRIER ("st", "ST", 0xe, ARM_EXT_BARRIER),
23270 UL_BARRIER ("ld", "LD", 0xd, ARM_EXT_V8),
23271 UL_BARRIER ("ish", "ISH", 0xb, ARM_EXT_BARRIER),
23272 UL_BARRIER ("sh", "SH", 0xb, ARM_EXT_BARRIER),
23273 UL_BARRIER ("ishst", "ISHST", 0xa, ARM_EXT_BARRIER),
23274 UL_BARRIER ("shst", "SHST", 0xa, ARM_EXT_BARRIER),
23275 UL_BARRIER ("ishld", "ISHLD", 0x9, ARM_EXT_V8),
23276 UL_BARRIER ("un", "UN", 0x7, ARM_EXT_BARRIER),
23277 UL_BARRIER ("nsh", "NSH", 0x7, ARM_EXT_BARRIER),
23278 UL_BARRIER ("unst", "UNST", 0x6, ARM_EXT_BARRIER),
23279 UL_BARRIER ("nshst", "NSHST", 0x6, ARM_EXT_BARRIER),
23280 UL_BARRIER ("nshld", "NSHLD", 0x5, ARM_EXT_V8),
23281 UL_BARRIER ("osh", "OSH", 0x3, ARM_EXT_BARRIER),
23282 UL_BARRIER ("oshst", "OSHST", 0x2, ARM_EXT_BARRIER),
23283 UL_BARRIER ("oshld", "OSHLD", 0x1, ARM_EXT_V8)
23288 /* Table of ARM-format instructions. */
23290 /* Macros for gluing together operand strings. N.B. In all cases
23291 other than OPS0, the trailing OP_stop comes from default
23292 zero-initialization of the unspecified elements of the array. */
23293 #define OPS0() { OP_stop, }
23294 #define OPS1(a) { OP_##a, }
23295 #define OPS2(a,b) { OP_##a,OP_##b, }
23296 #define OPS3(a,b,c) { OP_##a,OP_##b,OP_##c, }
23297 #define OPS4(a,b,c,d) { OP_##a,OP_##b,OP_##c,OP_##d, }
23298 #define OPS5(a,b,c,d,e) { OP_##a,OP_##b,OP_##c,OP_##d,OP_##e, }
23299 #define OPS6(a,b,c,d,e,f) { OP_##a,OP_##b,OP_##c,OP_##d,OP_##e,OP_##f, }
23301 /* These macros are similar to the OPSn, but do not prepend the OP_ prefix.
23302 This is useful when mixing operands for ARM and THUMB, i.e. using the
23303 MIX_ARM_THUMB_OPERANDS macro.
23304 In order to use these macros, prefix the number of operands with _
23306 #define OPS_1(a) { a, }
23307 #define OPS_2(a,b) { a,b, }
23308 #define OPS_3(a,b,c) { a,b,c, }
23309 #define OPS_4(a,b,c,d) { a,b,c,d, }
23310 #define OPS_5(a,b,c,d,e) { a,b,c,d,e, }
23311 #define OPS_6(a,b,c,d,e,f) { a,b,c,d,e,f, }
23313 /* These macros abstract out the exact format of the mnemonic table and
23314 save some repeated characters. */
23316 /* The normal sort of mnemonic; has a Thumb variant; takes a conditional suffix. */
23317 #define TxCE(mnem, op, top, nops, ops, ae, te) \
23318 { mnem, OPS##nops ops, OT_csuffix, 0x##op, top, ARM_VARIANT, \
23319 THUMB_VARIANT, do_##ae, do_##te, 0 }
23321 /* Two variants of the above - TCE for a numeric Thumb opcode, tCE for
23322 a T_MNEM_xyz enumerator. */
23323 #define TCE(mnem, aop, top, nops, ops, ae, te) \
23324 TxCE (mnem, aop, 0x##top, nops, ops, ae, te)
23325 #define tCE(mnem, aop, top, nops, ops, ae, te) \
23326 TxCE (mnem, aop, T_MNEM##top, nops, ops, ae, te)
23328 /* Second most common sort of mnemonic: has a Thumb variant, takes a conditional
23329 infix after the third character. */
23330 #define TxC3(mnem, op, top, nops, ops, ae, te) \
23331 { mnem, OPS##nops ops, OT_cinfix3, 0x##op, top, ARM_VARIANT, \
23332 THUMB_VARIANT, do_##ae, do_##te, 0 }
23333 #define TxC3w(mnem, op, top, nops, ops, ae, te) \
23334 { mnem, OPS##nops ops, OT_cinfix3_deprecated, 0x##op, top, ARM_VARIANT, \
23335 THUMB_VARIANT, do_##ae, do_##te, 0 }
23336 #define TC3(mnem, aop, top, nops, ops, ae, te) \
23337 TxC3 (mnem, aop, 0x##top, nops, ops, ae, te)
23338 #define TC3w(mnem, aop, top, nops, ops, ae, te) \
23339 TxC3w (mnem, aop, 0x##top, nops, ops, ae, te)
23340 #define tC3(mnem, aop, top, nops, ops, ae, te) \
23341 TxC3 (mnem, aop, T_MNEM##top, nops, ops, ae, te)
23342 #define tC3w(mnem, aop, top, nops, ops, ae, te) \
23343 TxC3w (mnem, aop, T_MNEM##top, nops, ops, ae, te)
23345 /* Mnemonic that cannot be conditionalized. The ARM condition-code
23346 field is still 0xE. Many of the Thumb variants can be executed
23347 conditionally, so this is checked separately. */
23348 #define TUE(mnem, op, top, nops, ops, ae, te) \
23349 { mnem, OPS##nops ops, OT_unconditional, 0x##op, 0x##top, ARM_VARIANT, \
23350 THUMB_VARIANT, do_##ae, do_##te, 0 }
23352 /* Same as TUE but the encoding function for ARM and Thumb modes is the same.
23353 Used by mnemonics that have very minimal differences in the encoding for
23354 ARM and Thumb variants and can be handled in a common function. */
23355 #define TUEc(mnem, op, top, nops, ops, en) \
23356 { mnem, OPS##nops ops, OT_unconditional, 0x##op, 0x##top, ARM_VARIANT, \
23357 THUMB_VARIANT, do_##en, do_##en, 0 }
23359 /* Mnemonic that cannot be conditionalized, and bears 0xF in its ARM
23360 condition code field. */
23361 #define TUF(mnem, op, top, nops, ops, ae, te) \
23362 { mnem, OPS##nops ops, OT_unconditionalF, 0x##op, 0x##top, ARM_VARIANT, \
23363 THUMB_VARIANT, do_##ae, do_##te, 0 }
23365 /* ARM-only variants of all the above. */
23366 #define CE(mnem, op, nops, ops, ae) \
23367 { mnem, OPS##nops ops, OT_csuffix, 0x##op, 0x0, ARM_VARIANT, 0, do_##ae, NULL, 0 }
23369 #define C3(mnem, op, nops, ops, ae) \
23370 { #mnem, OPS##nops ops, OT_cinfix3, 0x##op, 0x0, ARM_VARIANT, 0, do_##ae, NULL, 0 }
23372 /* Thumb-only variants of TCE and TUE. */
23373 #define ToC(mnem, top, nops, ops, te) \
23374 { mnem, OPS##nops ops, OT_csuffix, 0x0, 0x##top, 0, THUMB_VARIANT, NULL, \
23377 #define ToU(mnem, top, nops, ops, te) \
23378 { mnem, OPS##nops ops, OT_unconditional, 0x0, 0x##top, 0, THUMB_VARIANT, \
23381 /* T_MNEM_xyz enumerator variants of ToC. */
23382 #define toC(mnem, top, nops, ops, te) \
23383 { mnem, OPS##nops ops, OT_csuffix, 0x0, T_MNEM##top, 0, THUMB_VARIANT, NULL, \
23386 /* T_MNEM_xyz enumerator variants of ToU. */
23387 #define toU(mnem, top, nops, ops, te) \
23388 { mnem, OPS##nops ops, OT_unconditional, 0x0, T_MNEM##top, 0, THUMB_VARIANT, \
23391 /* Legacy mnemonics that always have conditional infix after the third
23393 #define CL(mnem, op, nops, ops, ae) \
23394 { mnem, OPS##nops ops, OT_cinfix3_legacy, \
23395 0x##op, 0x0, ARM_VARIANT, 0, do_##ae, NULL, 0 }
23397 /* Coprocessor instructions. Isomorphic between Arm and Thumb-2. */
23398 #define cCE(mnem, op, nops, ops, ae) \
23399 { mnem, OPS##nops ops, OT_csuffix, 0x##op, 0xe##op, ARM_VARIANT, ARM_VARIANT, do_##ae, do_##ae, 0 }
23401 /* mov instructions that are shared between coprocessor and MVE. */
23402 #define mcCE(mnem, op, nops, ops, ae) \
23403 { #mnem, OPS##nops ops, OT_csuffix, 0x##op, 0xe##op, ARM_VARIANT, THUMB_VARIANT, do_##ae, do_##ae, 0 }
23405 /* Legacy coprocessor instructions where conditional infix and conditional
23406 suffix are ambiguous. For consistency this includes all FPA instructions,
23407 not just the potentially ambiguous ones. */
23408 #define cCL(mnem, op, nops, ops, ae) \
23409 { mnem, OPS##nops ops, OT_cinfix3_legacy, \
23410 0x##op, 0xe##op, ARM_VARIANT, ARM_VARIANT, do_##ae, do_##ae, 0 }
23412 /* Coprocessor, takes either a suffix or a position-3 infix
23413 (for an FPA corner case). */
23414 #define C3E(mnem, op, nops, ops, ae) \
23415 { mnem, OPS##nops ops, OT_csuf_or_in3, \
23416 0x##op, 0xe##op, ARM_VARIANT, ARM_VARIANT, do_##ae, do_##ae, 0 }
23418 #define xCM_(m1, m2, m3, op, nops, ops, ae) \
23419 { m1 #m2 m3, OPS##nops ops, \
23420 sizeof (#m2) == 1 ? OT_odd_infix_unc : OT_odd_infix_0 + sizeof (m1) - 1, \
23421 0x##op, 0x0, ARM_VARIANT, 0, do_##ae, NULL, 0 }
23423 #define CM(m1, m2, op, nops, ops, ae) \
23424 xCM_ (m1, , m2, op, nops, ops, ae), \
23425 xCM_ (m1, eq, m2, op, nops, ops, ae), \
23426 xCM_ (m1, ne, m2, op, nops, ops, ae), \
23427 xCM_ (m1, cs, m2, op, nops, ops, ae), \
23428 xCM_ (m1, hs, m2, op, nops, ops, ae), \
23429 xCM_ (m1, cc, m2, op, nops, ops, ae), \
23430 xCM_ (m1, ul, m2, op, nops, ops, ae), \
23431 xCM_ (m1, lo, m2, op, nops, ops, ae), \
23432 xCM_ (m1, mi, m2, op, nops, ops, ae), \
23433 xCM_ (m1, pl, m2, op, nops, ops, ae), \
23434 xCM_ (m1, vs, m2, op, nops, ops, ae), \
23435 xCM_ (m1, vc, m2, op, nops, ops, ae), \
23436 xCM_ (m1, hi, m2, op, nops, ops, ae), \
23437 xCM_ (m1, ls, m2, op, nops, ops, ae), \
23438 xCM_ (m1, ge, m2, op, nops, ops, ae), \
23439 xCM_ (m1, lt, m2, op, nops, ops, ae), \
23440 xCM_ (m1, gt, m2, op, nops, ops, ae), \
23441 xCM_ (m1, le, m2, op, nops, ops, ae), \
23442 xCM_ (m1, al, m2, op, nops, ops, ae)
23444 #define UE(mnem, op, nops, ops, ae) \
23445 { #mnem, OPS##nops ops, OT_unconditional, 0x##op, 0, ARM_VARIANT, 0, do_##ae, NULL, 0 }
23447 #define UF(mnem, op, nops, ops, ae) \
23448 { #mnem, OPS##nops ops, OT_unconditionalF, 0x##op, 0, ARM_VARIANT, 0, do_##ae, NULL, 0 }
23450 /* Neon data-processing. ARM versions are unconditional with cond=0xf.
23451 The Thumb and ARM variants are mostly the same (bits 0-23 and 24/28), so we
23452 use the same encoding function for each. */
23453 #define NUF(mnem, op, nops, ops, enc) \
23454 { #mnem, OPS##nops ops, OT_unconditionalF, 0x##op, 0x##op, \
23455 ARM_VARIANT, THUMB_VARIANT, do_##enc, do_##enc, 0 }
23457 /* Neon data processing, version which indirects through neon_enc_tab for
23458 the various overloaded versions of opcodes. */
23459 #define nUF(mnem, op, nops, ops, enc) \
23460 { #mnem, OPS##nops ops, OT_unconditionalF, N_MNEM##op, N_MNEM##op, \
23461 ARM_VARIANT, THUMB_VARIANT, do_##enc, do_##enc, 0 }
23463 /* Neon insn with conditional suffix for the ARM version, non-overloaded
23465 #define NCE_tag(mnem, op, nops, ops, enc, tag, mve_p) \
23466 { #mnem, OPS##nops ops, tag, 0x##op, 0x##op, ARM_VARIANT, \
23467 THUMB_VARIANT, do_##enc, do_##enc, mve_p }
23469 #define NCE(mnem, op, nops, ops, enc) \
23470 NCE_tag (mnem, op, nops, ops, enc, OT_csuffix, 0)
23472 #define NCEF(mnem, op, nops, ops, enc) \
23473 NCE_tag (mnem, op, nops, ops, enc, OT_csuffixF, 0)
23475 /* Neon insn with conditional suffix for the ARM version, overloaded types. */
23476 #define nCE_tag(mnem, op, nops, ops, enc, tag, mve_p) \
23477 { #mnem, OPS##nops ops, tag, N_MNEM##op, N_MNEM##op, \
23478 ARM_VARIANT, THUMB_VARIANT, do_##enc, do_##enc, mve_p }
23480 #define nCE(mnem, op, nops, ops, enc) \
23481 nCE_tag (mnem, op, nops, ops, enc, OT_csuffix, 0)
23483 #define nCEF(mnem, op, nops, ops, enc) \
23484 nCE_tag (mnem, op, nops, ops, enc, OT_csuffixF, 0)
23487 #define mCEF(mnem, op, nops, ops, enc) \
23488 { #mnem, OPS##nops ops, OT_csuffixF, M_MNEM##op, M_MNEM##op, \
23489 ARM_VARIANT, THUMB_VARIANT, do_##enc, do_##enc, 1 }
23492 /* nCEF but for MVE predicated instructions. */
23493 #define mnCEF(mnem, op, nops, ops, enc) \
23494 nCE_tag (mnem, op, nops, ops, enc, OT_csuffixF, 1)
23496 /* nCE but for MVE predicated instructions. */
23497 #define mnCE(mnem, op, nops, ops, enc) \
23498 nCE_tag (mnem, op, nops, ops, enc, OT_csuffix, 1)
23500 /* NUF but for potentially MVE predicated instructions. */
23501 #define MNUF(mnem, op, nops, ops, enc) \
23502 { #mnem, OPS##nops ops, OT_unconditionalF, 0x##op, 0x##op, \
23503 ARM_VARIANT, THUMB_VARIANT, do_##enc, do_##enc, 1 }
23505 /* nUF but for potentially MVE predicated instructions. */
23506 #define mnUF(mnem, op, nops, ops, enc) \
23507 { #mnem, OPS##nops ops, OT_unconditionalF, N_MNEM##op, N_MNEM##op, \
23508 ARM_VARIANT, THUMB_VARIANT, do_##enc, do_##enc, 1 }
23510 /* ToC but for potentially MVE predicated instructions. */
23511 #define mToC(mnem, top, nops, ops, te) \
23512 { mnem, OPS##nops ops, OT_csuffix, 0x0, 0x##top, 0, THUMB_VARIANT, NULL, \
23515 /* NCE but for MVE predicated instructions. */
23516 #define MNCE(mnem, op, nops, ops, enc) \
23517 NCE_tag (mnem, op, nops, ops, enc, OT_csuffix, 1)
23519 /* NCEF but for MVE predicated instructions. */
23520 #define MNCEF(mnem, op, nops, ops, enc) \
23521 NCE_tag (mnem, op, nops, ops, enc, OT_csuffixF, 1)
23524 static const struct asm_opcode insns[] =
23526 #define ARM_VARIANT & arm_ext_v1 /* Core ARM Instructions. */
23527 #define THUMB_VARIANT & arm_ext_v4t
23528 tCE("and", 0000000, _and, 3, (RR, oRR, SH), arit, t_arit3c),
23529 tC3("ands", 0100000, _ands, 3, (RR, oRR, SH), arit, t_arit3c),
23530 tCE("eor", 0200000, _eor, 3, (RR, oRR, SH), arit, t_arit3c),
23531 tC3("eors", 0300000, _eors, 3, (RR, oRR, SH), arit, t_arit3c),
23532 tCE("sub", 0400000, _sub, 3, (RR, oRR, SH), arit, t_add_sub),
23533 tC3("subs", 0500000, _subs, 3, (RR, oRR, SH), arit, t_add_sub),
23534 tCE("add", 0800000, _add, 3, (RR, oRR, SHG), arit, t_add_sub),
23535 tC3("adds", 0900000, _adds, 3, (RR, oRR, SHG), arit, t_add_sub),
23536 tCE("adc", 0a00000, _adc, 3, (RR, oRR, SH), arit, t_arit3c),
23537 tC3("adcs", 0b00000, _adcs, 3, (RR, oRR, SH), arit, t_arit3c),
23538 tCE("sbc", 0c00000, _sbc, 3, (RR, oRR, SH), arit, t_arit3),
23539 tC3("sbcs", 0d00000, _sbcs, 3, (RR, oRR, SH), arit, t_arit3),
23540 tCE("orr", 1800000, _orr, 3, (RR, oRR, SH), arit, t_arit3c),
23541 tC3("orrs", 1900000, _orrs, 3, (RR, oRR, SH), arit, t_arit3c),
23542 tCE("bic", 1c00000, _bic, 3, (RR, oRR, SH), arit, t_arit3),
23543 tC3("bics", 1d00000, _bics, 3, (RR, oRR, SH), arit, t_arit3),
23545 /* The p-variants of tst/cmp/cmn/teq (below) are the pre-V6 mechanism
23546 for setting PSR flag bits. They are obsolete in V6 and do not
23547 have Thumb equivalents. */
23548 tCE("tst", 1100000, _tst, 2, (RR, SH), cmp, t_mvn_tst),
23549 tC3w("tsts", 1100000, _tst, 2, (RR, SH), cmp, t_mvn_tst),
23550 CL("tstp", 110f000, 2, (RR, SH), cmp),
23551 tCE("cmp", 1500000, _cmp, 2, (RR, SH), cmp, t_mov_cmp),
23552 tC3w("cmps", 1500000, _cmp, 2, (RR, SH), cmp, t_mov_cmp),
23553 CL("cmpp", 150f000, 2, (RR, SH), cmp),
23554 tCE("cmn", 1700000, _cmn, 2, (RR, SH), cmp, t_mvn_tst),
23555 tC3w("cmns", 1700000, _cmn, 2, (RR, SH), cmp, t_mvn_tst),
23556 CL("cmnp", 170f000, 2, (RR, SH), cmp),
23558 tCE("mov", 1a00000, _mov, 2, (RR, SH), mov, t_mov_cmp),
23559 tC3("movs", 1b00000, _movs, 2, (RR, SHG), mov, t_mov_cmp),
23560 tCE("mvn", 1e00000, _mvn, 2, (RR, SH), mov, t_mvn_tst),
23561 tC3("mvns", 1f00000, _mvns, 2, (RR, SH), mov, t_mvn_tst),
23563 tCE("ldr", 4100000, _ldr, 2, (RR, ADDRGLDR),ldst, t_ldst),
23564 tC3("ldrb", 4500000, _ldrb, 2, (RRnpc_npcsp, ADDRGLDR),ldst, t_ldst),
23565 tCE("str", 4000000, _str, _2, (MIX_ARM_THUMB_OPERANDS (OP_RR,
23567 OP_ADDRGLDR),ldst, t_ldst),
23568 tC3("strb", 4400000, _strb, 2, (RRnpc_npcsp, ADDRGLDR),ldst, t_ldst),
23570 tCE("stm", 8800000, _stmia, 2, (RRw, REGLST), ldmstm, t_ldmstm),
23571 tC3("stmia", 8800000, _stmia, 2, (RRw, REGLST), ldmstm, t_ldmstm),
23572 tC3("stmea", 8800000, _stmia, 2, (RRw, REGLST), ldmstm, t_ldmstm),
23573 tCE("ldm", 8900000, _ldmia, 2, (RRw, REGLST), ldmstm, t_ldmstm),
23574 tC3("ldmia", 8900000, _ldmia, 2, (RRw, REGLST), ldmstm, t_ldmstm),
23575 tC3("ldmfd", 8900000, _ldmia, 2, (RRw, REGLST), ldmstm, t_ldmstm),
23577 tCE("b", a000000, _b, 1, (EXPr), branch, t_branch),
23578 TCE("bl", b000000, f000f800, 1, (EXPr), bl, t_branch23),
23581 tCE("adr", 28f0000, _adr, 2, (RR, EXP), adr, t_adr),
23582 C3(adrl, 28f0000, 2, (RR, EXP), adrl),
23583 tCE("nop", 1a00000, _nop, 1, (oI255c), nop, t_nop),
23584 tCE("udf", 7f000f0, _udf, 1, (oIffffb), bkpt, t_udf),
23586 /* Thumb-compatibility pseudo ops. */
23587 tCE("lsl", 1a00000, _lsl, 3, (RR, oRR, SH), shift, t_shift),
23588 tC3("lsls", 1b00000, _lsls, 3, (RR, oRR, SH), shift, t_shift),
23589 tCE("lsr", 1a00020, _lsr, 3, (RR, oRR, SH), shift, t_shift),
23590 tC3("lsrs", 1b00020, _lsrs, 3, (RR, oRR, SH), shift, t_shift),
23591 tCE("asr", 1a00040, _asr, 3, (RR, oRR, SH), shift, t_shift),
23592 tC3("asrs", 1b00040, _asrs, 3, (RR, oRR, SH), shift, t_shift),
23593 tCE("ror", 1a00060, _ror, 3, (RR, oRR, SH), shift, t_shift),
23594 tC3("rors", 1b00060, _rors, 3, (RR, oRR, SH), shift, t_shift),
23595 tCE("neg", 2600000, _neg, 2, (RR, RR), rd_rn, t_neg),
23596 tC3("negs", 2700000, _negs, 2, (RR, RR), rd_rn, t_neg),
23597 tCE("push", 92d0000, _push, 1, (REGLST), push_pop, t_push_pop),
23598 tCE("pop", 8bd0000, _pop, 1, (REGLST), push_pop, t_push_pop),
23600 /* These may simplify to neg. */
23601 TCE("rsb", 0600000, ebc00000, 3, (RR, oRR, SH), arit, t_rsb),
23602 TC3("rsbs", 0700000, ebd00000, 3, (RR, oRR, SH), arit, t_rsb),
23604 #undef THUMB_VARIANT
23605 #define THUMB_VARIANT & arm_ext_os
23607 TCE("swi", f000000, df00, 1, (EXPi), swi, t_swi),
23608 TCE("svc", f000000, df00, 1, (EXPi), swi, t_swi),
23610 #undef THUMB_VARIANT
23611 #define THUMB_VARIANT & arm_ext_v6
23613 TCE("cpy", 1a00000, 4600, 2, (RR, RR), rd_rm, t_cpy),
23615 /* V1 instructions with no Thumb analogue prior to V6T2. */
23616 #undef THUMB_VARIANT
23617 #define THUMB_VARIANT & arm_ext_v6t2
23619 TCE("teq", 1300000, ea900f00, 2, (RR, SH), cmp, t_mvn_tst),
23620 TC3w("teqs", 1300000, ea900f00, 2, (RR, SH), cmp, t_mvn_tst),
23621 CL("teqp", 130f000, 2, (RR, SH), cmp),
23623 TC3("ldrt", 4300000, f8500e00, 2, (RRnpc_npcsp, ADDR),ldstt, t_ldstt),
23624 TC3("ldrbt", 4700000, f8100e00, 2, (RRnpc_npcsp, ADDR),ldstt, t_ldstt),
23625 TC3("strt", 4200000, f8400e00, 2, (RR_npcsp, ADDR), ldstt, t_ldstt),
23626 TC3("strbt", 4600000, f8000e00, 2, (RRnpc_npcsp, ADDR),ldstt, t_ldstt),
23628 TC3("stmdb", 9000000, e9000000, 2, (RRw, REGLST), ldmstm, t_ldmstm),
23629 TC3("stmfd", 9000000, e9000000, 2, (RRw, REGLST), ldmstm, t_ldmstm),
23631 TC3("ldmdb", 9100000, e9100000, 2, (RRw, REGLST), ldmstm, t_ldmstm),
23632 TC3("ldmea", 9100000, e9100000, 2, (RRw, REGLST), ldmstm, t_ldmstm),
23634 /* V1 instructions with no Thumb analogue at all. */
23635 CE("rsc", 0e00000, 3, (RR, oRR, SH), arit),
23636 C3(rscs, 0f00000, 3, (RR, oRR, SH), arit),
23638 C3(stmib, 9800000, 2, (RRw, REGLST), ldmstm),
23639 C3(stmfa, 9800000, 2, (RRw, REGLST), ldmstm),
23640 C3(stmda, 8000000, 2, (RRw, REGLST), ldmstm),
23641 C3(stmed, 8000000, 2, (RRw, REGLST), ldmstm),
23642 C3(ldmib, 9900000, 2, (RRw, REGLST), ldmstm),
23643 C3(ldmed, 9900000, 2, (RRw, REGLST), ldmstm),
23644 C3(ldmda, 8100000, 2, (RRw, REGLST), ldmstm),
23645 C3(ldmfa, 8100000, 2, (RRw, REGLST), ldmstm),
23648 #define ARM_VARIANT & arm_ext_v2 /* ARM 2 - multiplies. */
23649 #undef THUMB_VARIANT
23650 #define THUMB_VARIANT & arm_ext_v4t
23652 tCE("mul", 0000090, _mul, 3, (RRnpc, RRnpc, oRR), mul, t_mul),
23653 tC3("muls", 0100090, _muls, 3, (RRnpc, RRnpc, oRR), mul, t_mul),
23655 #undef THUMB_VARIANT
23656 #define THUMB_VARIANT & arm_ext_v6t2
23658 TCE("mla", 0200090, fb000000, 4, (RRnpc, RRnpc, RRnpc, RRnpc), mlas, t_mla),
23659 C3(mlas, 0300090, 4, (RRnpc, RRnpc, RRnpc, RRnpc), mlas),
23661 /* Generic coprocessor instructions. */
23662 TCE("cdp", e000000, ee000000, 6, (RCP, I15b, RCN, RCN, RCN, oI7b), cdp, cdp),
23663 TCE("ldc", c100000, ec100000, 3, (RCP, RCN, ADDRGLDC), lstc, lstc),
23664 TC3("ldcl", c500000, ec500000, 3, (RCP, RCN, ADDRGLDC), lstc, lstc),
23665 TCE("stc", c000000, ec000000, 3, (RCP, RCN, ADDRGLDC), lstc, lstc),
23666 TC3("stcl", c400000, ec400000, 3, (RCP, RCN, ADDRGLDC), lstc, lstc),
23667 TCE("mcr", e000010, ee000010, 6, (RCP, I7b, RR, RCN, RCN, oI7b), co_reg, co_reg),
23668 TCE("mrc", e100010, ee100010, 6, (RCP, I7b, APSR_RR, RCN, RCN, oI7b), co_reg, co_reg),
23671 #define ARM_VARIANT & arm_ext_v2s /* ARM 3 - swp instructions. */
23673 CE("swp", 1000090, 3, (RRnpc, RRnpc, RRnpcb), rd_rm_rn),
23674 C3(swpb, 1400090, 3, (RRnpc, RRnpc, RRnpcb), rd_rm_rn),
23677 #define ARM_VARIANT & arm_ext_v3 /* ARM 6 Status register instructions. */
23678 #undef THUMB_VARIANT
23679 #define THUMB_VARIANT & arm_ext_msr
23681 TCE("mrs", 1000000, f3e08000, 2, (RRnpc, rPSR), mrs, t_mrs),
23682 TCE("msr", 120f000, f3808000, 2, (wPSR, RR_EXi), msr, t_msr),
23685 #define ARM_VARIANT & arm_ext_v3m /* ARM 7M long multiplies. */
23686 #undef THUMB_VARIANT
23687 #define THUMB_VARIANT & arm_ext_v6t2
23689 TCE("smull", 0c00090, fb800000, 4, (RRnpc, RRnpc, RRnpc, RRnpc), mull, t_mull),
23690 CM("smull","s", 0d00090, 4, (RRnpc, RRnpc, RRnpc, RRnpc), mull),
23691 TCE("umull", 0800090, fba00000, 4, (RRnpc, RRnpc, RRnpc, RRnpc), mull, t_mull),
23692 CM("umull","s", 0900090, 4, (RRnpc, RRnpc, RRnpc, RRnpc), mull),
23693 TCE("smlal", 0e00090, fbc00000, 4, (RRnpc, RRnpc, RRnpc, RRnpc), mull, t_mull),
23694 CM("smlal","s", 0f00090, 4, (RRnpc, RRnpc, RRnpc, RRnpc), mull),
23695 TCE("umlal", 0a00090, fbe00000, 4, (RRnpc, RRnpc, RRnpc, RRnpc), mull, t_mull),
23696 CM("umlal","s", 0b00090, 4, (RRnpc, RRnpc, RRnpc, RRnpc), mull),
23699 #define ARM_VARIANT & arm_ext_v4 /* ARM Architecture 4. */
23700 #undef THUMB_VARIANT
23701 #define THUMB_VARIANT & arm_ext_v4t
23703 tC3("ldrh", 01000b0, _ldrh, 2, (RRnpc_npcsp, ADDRGLDRS), ldstv4, t_ldst),
23704 tC3("strh", 00000b0, _strh, 2, (RRnpc_npcsp, ADDRGLDRS), ldstv4, t_ldst),
23705 tC3("ldrsh", 01000f0, _ldrsh, 2, (RRnpc_npcsp, ADDRGLDRS), ldstv4, t_ldst),
23706 tC3("ldrsb", 01000d0, _ldrsb, 2, (RRnpc_npcsp, ADDRGLDRS), ldstv4, t_ldst),
23707 tC3("ldsh", 01000f0, _ldrsh, 2, (RRnpc_npcsp, ADDRGLDRS), ldstv4, t_ldst),
23708 tC3("ldsb", 01000d0, _ldrsb, 2, (RRnpc_npcsp, ADDRGLDRS), ldstv4, t_ldst),
23711 #define ARM_VARIANT & arm_ext_v4t_5
23713 /* ARM Architecture 4T. */
23714 /* Note: bx (and blx) are required on V5, even if the processor does
23715 not support Thumb. */
23716 TCE("bx", 12fff10, 4700, 1, (RR), bx, t_bx),
23719 #define ARM_VARIANT & arm_ext_v5 /* ARM Architecture 5T. */
23720 #undef THUMB_VARIANT
23721 #define THUMB_VARIANT & arm_ext_v5t
23723 /* Note: blx has 2 variants; the .value coded here is for
23724 BLX(2). Only this variant has conditional execution. */
23725 TCE("blx", 12fff30, 4780, 1, (RR_EXr), blx, t_blx),
23726 TUE("bkpt", 1200070, be00, 1, (oIffffb), bkpt, t_bkpt),
23728 #undef THUMB_VARIANT
23729 #define THUMB_VARIANT & arm_ext_v6t2
23731 TCE("clz", 16f0f10, fab0f080, 2, (RRnpc, RRnpc), rd_rm, t_clz),
23732 TUF("ldc2", c100000, fc100000, 3, (RCP, RCN, ADDRGLDC), lstc, lstc),
23733 TUF("ldc2l", c500000, fc500000, 3, (RCP, RCN, ADDRGLDC), lstc, lstc),
23734 TUF("stc2", c000000, fc000000, 3, (RCP, RCN, ADDRGLDC), lstc, lstc),
23735 TUF("stc2l", c400000, fc400000, 3, (RCP, RCN, ADDRGLDC), lstc, lstc),
23736 TUF("cdp2", e000000, fe000000, 6, (RCP, I15b, RCN, RCN, RCN, oI7b), cdp, cdp),
23737 TUF("mcr2", e000010, fe000010, 6, (RCP, I7b, RR, RCN, RCN, oI7b), co_reg, co_reg),
23738 TUF("mrc2", e100010, fe100010, 6, (RCP, I7b, RR, RCN, RCN, oI7b), co_reg, co_reg),
23741 #define ARM_VARIANT & arm_ext_v5exp /* ARM Architecture 5TExP. */
23742 #undef THUMB_VARIANT
23743 #define THUMB_VARIANT & arm_ext_v5exp
23745 TCE("smlabb", 1000080, fb100000, 4, (RRnpc, RRnpc, RRnpc, RRnpc), smla, t_mla),
23746 TCE("smlatb", 10000a0, fb100020, 4, (RRnpc, RRnpc, RRnpc, RRnpc), smla, t_mla),
23747 TCE("smlabt", 10000c0, fb100010, 4, (RRnpc, RRnpc, RRnpc, RRnpc), smla, t_mla),
23748 TCE("smlatt", 10000e0, fb100030, 4, (RRnpc, RRnpc, RRnpc, RRnpc), smla, t_mla),
23750 TCE("smlawb", 1200080, fb300000, 4, (RRnpc, RRnpc, RRnpc, RRnpc), smla, t_mla),
23751 TCE("smlawt", 12000c0, fb300010, 4, (RRnpc, RRnpc, RRnpc, RRnpc), smla, t_mla),
23753 TCE("smlalbb", 1400080, fbc00080, 4, (RRnpc, RRnpc, RRnpc, RRnpc), smlal, t_mlal),
23754 TCE("smlaltb", 14000a0, fbc000a0, 4, (RRnpc, RRnpc, RRnpc, RRnpc), smlal, t_mlal),
23755 TCE("smlalbt", 14000c0, fbc00090, 4, (RRnpc, RRnpc, RRnpc, RRnpc), smlal, t_mlal),
23756 TCE("smlaltt", 14000e0, fbc000b0, 4, (RRnpc, RRnpc, RRnpc, RRnpc), smlal, t_mlal),
23758 TCE("smulbb", 1600080, fb10f000, 3, (RRnpc, RRnpc, RRnpc), smul, t_simd),
23759 TCE("smultb", 16000a0, fb10f020, 3, (RRnpc, RRnpc, RRnpc), smul, t_simd),
23760 TCE("smulbt", 16000c0, fb10f010, 3, (RRnpc, RRnpc, RRnpc), smul, t_simd),
23761 TCE("smultt", 16000e0, fb10f030, 3, (RRnpc, RRnpc, RRnpc), smul, t_simd),
23763 TCE("smulwb", 12000a0, fb30f000, 3, (RRnpc, RRnpc, RRnpc), smul, t_simd),
23764 TCE("smulwt", 12000e0, fb30f010, 3, (RRnpc, RRnpc, RRnpc), smul, t_simd),
23766 TCE("qadd", 1000050, fa80f080, 3, (RRnpc, RRnpc, RRnpc), rd_rm_rn, t_simd2),
23767 TCE("qdadd", 1400050, fa80f090, 3, (RRnpc, RRnpc, RRnpc), rd_rm_rn, t_simd2),
23768 TCE("qsub", 1200050, fa80f0a0, 3, (RRnpc, RRnpc, RRnpc), rd_rm_rn, t_simd2),
23769 TCE("qdsub", 1600050, fa80f0b0, 3, (RRnpc, RRnpc, RRnpc), rd_rm_rn, t_simd2),
23772 #define ARM_VARIANT & arm_ext_v5e /* ARM Architecture 5TE. */
23773 #undef THUMB_VARIANT
23774 #define THUMB_VARIANT & arm_ext_v6t2
23776 TUF("pld", 450f000, f810f000, 1, (ADDR), pld, t_pld),
23777 TC3("ldrd", 00000d0, e8500000, 3, (RRnpc_npcsp, oRRnpc_npcsp, ADDRGLDRS),
23779 TC3("strd", 00000f0, e8400000, 3, (RRnpc_npcsp, oRRnpc_npcsp,
23780 ADDRGLDRS), ldrd, t_ldstd),
23782 TCE("mcrr", c400000, ec400000, 5, (RCP, I15b, RRnpc, RRnpc, RCN), co_reg2c, co_reg2c),
23783 TCE("mrrc", c500000, ec500000, 5, (RCP, I15b, RRnpc, RRnpc, RCN), co_reg2c, co_reg2c),
23786 #define ARM_VARIANT & arm_ext_v5j /* ARM Architecture 5TEJ. */
23788 TCE("bxj", 12fff20, f3c08f00, 1, (RR), bxj, t_bxj),
23791 #define ARM_VARIANT & arm_ext_v6 /* ARM V6. */
23792 #undef THUMB_VARIANT
23793 #define THUMB_VARIANT & arm_ext_v6
23795 TUF("cpsie", 1080000, b660, 2, (CPSF, oI31b), cpsi, t_cpsi),
23796 TUF("cpsid", 10c0000, b670, 2, (CPSF, oI31b), cpsi, t_cpsi),
23797 tCE("rev", 6bf0f30, _rev, 2, (RRnpc, RRnpc), rd_rm, t_rev),
23798 tCE("rev16", 6bf0fb0, _rev16, 2, (RRnpc, RRnpc), rd_rm, t_rev),
23799 tCE("revsh", 6ff0fb0, _revsh, 2, (RRnpc, RRnpc), rd_rm, t_rev),
23800 tCE("sxth", 6bf0070, _sxth, 3, (RRnpc, RRnpc, oROR), sxth, t_sxth),
23801 tCE("uxth", 6ff0070, _uxth, 3, (RRnpc, RRnpc, oROR), sxth, t_sxth),
23802 tCE("sxtb", 6af0070, _sxtb, 3, (RRnpc, RRnpc, oROR), sxth, t_sxth),
23803 tCE("uxtb", 6ef0070, _uxtb, 3, (RRnpc, RRnpc, oROR), sxth, t_sxth),
23804 TUF("setend", 1010000, b650, 1, (ENDI), setend, t_setend),
23806 #undef THUMB_VARIANT
23807 #define THUMB_VARIANT & arm_ext_v6t2_v8m
23809 TCE("ldrex", 1900f9f, e8500f00, 2, (RRnpc_npcsp, ADDR), ldrex, t_ldrex),
23810 TCE("strex", 1800f90, e8400000, 3, (RRnpc_npcsp, RRnpc_npcsp, ADDR),
23812 #undef THUMB_VARIANT
23813 #define THUMB_VARIANT & arm_ext_v6t2
23815 TUF("mcrr2", c400000, fc400000, 5, (RCP, I15b, RRnpc, RRnpc, RCN), co_reg2c, co_reg2c),
23816 TUF("mrrc2", c500000, fc500000, 5, (RCP, I15b, RRnpc, RRnpc, RCN), co_reg2c, co_reg2c),
23818 TCE("ssat", 6a00010, f3000000, 4, (RRnpc, I32, RRnpc, oSHllar),ssat, t_ssat),
23819 TCE("usat", 6e00010, f3800000, 4, (RRnpc, I31, RRnpc, oSHllar),usat, t_usat),
23821 /* ARM V6 not included in V7M. */
23822 #undef THUMB_VARIANT
23823 #define THUMB_VARIANT & arm_ext_v6_notm
23824 TUF("rfeia", 8900a00, e990c000, 1, (RRw), rfe, rfe),
23825 TUF("rfe", 8900a00, e990c000, 1, (RRw), rfe, rfe),
23826 UF(rfeib, 9900a00, 1, (RRw), rfe),
23827 UF(rfeda, 8100a00, 1, (RRw), rfe),
23828 TUF("rfedb", 9100a00, e810c000, 1, (RRw), rfe, rfe),
23829 TUF("rfefd", 8900a00, e990c000, 1, (RRw), rfe, rfe),
23830 UF(rfefa, 8100a00, 1, (RRw), rfe),
23831 TUF("rfeea", 9100a00, e810c000, 1, (RRw), rfe, rfe),
23832 UF(rfeed, 9900a00, 1, (RRw), rfe),
23833 TUF("srsia", 8c00500, e980c000, 2, (oRRw, I31w), srs, srs),
23834 TUF("srs", 8c00500, e980c000, 2, (oRRw, I31w), srs, srs),
23835 TUF("srsea", 8c00500, e980c000, 2, (oRRw, I31w), srs, srs),
23836 UF(srsib, 9c00500, 2, (oRRw, I31w), srs),
23837 UF(srsfa, 9c00500, 2, (oRRw, I31w), srs),
23838 UF(srsda, 8400500, 2, (oRRw, I31w), srs),
23839 UF(srsed, 8400500, 2, (oRRw, I31w), srs),
23840 TUF("srsdb", 9400500, e800c000, 2, (oRRw, I31w), srs, srs),
23841 TUF("srsfd", 9400500, e800c000, 2, (oRRw, I31w), srs, srs),
23842 TUF("cps", 1020000, f3af8100, 1, (I31b), imm0, t_cps),
23844 /* ARM V6 not included in V7M (eg. integer SIMD). */
23845 #undef THUMB_VARIANT
23846 #define THUMB_VARIANT & arm_ext_v6_dsp
23847 TCE("pkhbt", 6800010, eac00000, 4, (RRnpc, RRnpc, RRnpc, oSHll), pkhbt, t_pkhbt),
23848 TCE("pkhtb", 6800050, eac00020, 4, (RRnpc, RRnpc, RRnpc, oSHar), pkhtb, t_pkhtb),
23849 TCE("qadd16", 6200f10, fa90f010, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
23850 TCE("qadd8", 6200f90, fa80f010, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
23851 TCE("qasx", 6200f30, faa0f010, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
23852 /* Old name for QASX. */
23853 TCE("qaddsubx",6200f30, faa0f010, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
23854 TCE("qsax", 6200f50, fae0f010, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
23855 /* Old name for QSAX. */
23856 TCE("qsubaddx",6200f50, fae0f010, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
23857 TCE("qsub16", 6200f70, fad0f010, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
23858 TCE("qsub8", 6200ff0, fac0f010, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
23859 TCE("sadd16", 6100f10, fa90f000, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
23860 TCE("sadd8", 6100f90, fa80f000, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
23861 TCE("sasx", 6100f30, faa0f000, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
23862 /* Old name for SASX. */
23863 TCE("saddsubx",6100f30, faa0f000, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
23864 TCE("shadd16", 6300f10, fa90f020, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
23865 TCE("shadd8", 6300f90, fa80f020, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
23866 TCE("shasx", 6300f30, faa0f020, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
23867 /* Old name for SHASX. */
23868 TCE("shaddsubx", 6300f30, faa0f020, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
23869 TCE("shsax", 6300f50, fae0f020, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
23870 /* Old name for SHSAX. */
23871 TCE("shsubaddx", 6300f50, fae0f020, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
23872 TCE("shsub16", 6300f70, fad0f020, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
23873 TCE("shsub8", 6300ff0, fac0f020, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
23874 TCE("ssax", 6100f50, fae0f000, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
23875 /* Old name for SSAX. */
23876 TCE("ssubaddx",6100f50, fae0f000, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
23877 TCE("ssub16", 6100f70, fad0f000, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
23878 TCE("ssub8", 6100ff0, fac0f000, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
23879 TCE("uadd16", 6500f10, fa90f040, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
23880 TCE("uadd8", 6500f90, fa80f040, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
23881 TCE("uasx", 6500f30, faa0f040, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
23882 /* Old name for UASX. */
23883 TCE("uaddsubx",6500f30, faa0f040, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
23884 TCE("uhadd16", 6700f10, fa90f060, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
23885 TCE("uhadd8", 6700f90, fa80f060, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
23886 TCE("uhasx", 6700f30, faa0f060, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
23887 /* Old name for UHASX. */
23888 TCE("uhaddsubx", 6700f30, faa0f060, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
23889 TCE("uhsax", 6700f50, fae0f060, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
23890 /* Old name for UHSAX. */
23891 TCE("uhsubaddx", 6700f50, fae0f060, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
23892 TCE("uhsub16", 6700f70, fad0f060, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
23893 TCE("uhsub8", 6700ff0, fac0f060, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
23894 TCE("uqadd16", 6600f10, fa90f050, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
23895 TCE("uqadd8", 6600f90, fa80f050, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
23896 TCE("uqasx", 6600f30, faa0f050, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
23897 /* Old name for UQASX. */
23898 TCE("uqaddsubx", 6600f30, faa0f050, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
23899 TCE("uqsax", 6600f50, fae0f050, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
23900 /* Old name for UQSAX. */
23901 TCE("uqsubaddx", 6600f50, fae0f050, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
23902 TCE("uqsub16", 6600f70, fad0f050, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
23903 TCE("uqsub8", 6600ff0, fac0f050, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
23904 TCE("usub16", 6500f70, fad0f040, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
23905 TCE("usax", 6500f50, fae0f040, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
23906 /* Old name for USAX. */
23907 TCE("usubaddx",6500f50, fae0f040, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
23908 TCE("usub8", 6500ff0, fac0f040, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
23909 TCE("sxtah", 6b00070, fa00f080, 4, (RRnpc, RRnpc, RRnpc, oROR), sxtah, t_sxtah),
23910 TCE("sxtab16", 6800070, fa20f080, 4, (RRnpc, RRnpc, RRnpc, oROR), sxtah, t_sxtah),
23911 TCE("sxtab", 6a00070, fa40f080, 4, (RRnpc, RRnpc, RRnpc, oROR), sxtah, t_sxtah),
23912 TCE("sxtb16", 68f0070, fa2ff080, 3, (RRnpc, RRnpc, oROR), sxth, t_sxth),
23913 TCE("uxtah", 6f00070, fa10f080, 4, (RRnpc, RRnpc, RRnpc, oROR), sxtah, t_sxtah),
23914 TCE("uxtab16", 6c00070, fa30f080, 4, (RRnpc, RRnpc, RRnpc, oROR), sxtah, t_sxtah),
23915 TCE("uxtab", 6e00070, fa50f080, 4, (RRnpc, RRnpc, RRnpc, oROR), sxtah, t_sxtah),
23916 TCE("uxtb16", 6cf0070, fa3ff080, 3, (RRnpc, RRnpc, oROR), sxth, t_sxth),
23917 TCE("sel", 6800fb0, faa0f080, 3, (RRnpc, RRnpc, RRnpc), rd_rn_rm, t_simd),
23918 TCE("smlad", 7000010, fb200000, 4, (RRnpc, RRnpc, RRnpc, RRnpc),smla, t_mla),
23919 TCE("smladx", 7000030, fb200010, 4, (RRnpc, RRnpc, RRnpc, RRnpc),smla, t_mla),
23920 TCE("smlald", 7400010, fbc000c0, 4, (RRnpc, RRnpc, RRnpc, RRnpc),smlal,t_mlal),
23921 TCE("smlaldx", 7400030, fbc000d0, 4, (RRnpc, RRnpc, RRnpc, RRnpc),smlal,t_mlal),
23922 TCE("smlsd", 7000050, fb400000, 4, (RRnpc, RRnpc, RRnpc, RRnpc),smla, t_mla),
23923 TCE("smlsdx", 7000070, fb400010, 4, (RRnpc, RRnpc, RRnpc, RRnpc),smla, t_mla),
23924 TCE("smlsld", 7400050, fbd000c0, 4, (RRnpc, RRnpc, RRnpc, RRnpc),smlal,t_mlal),
23925 TCE("smlsldx", 7400070, fbd000d0, 4, (RRnpc, RRnpc, RRnpc, RRnpc),smlal,t_mlal),
23926 TCE("smmla", 7500010, fb500000, 4, (RRnpc, RRnpc, RRnpc, RRnpc),smla, t_mla),
23927 TCE("smmlar", 7500030, fb500010, 4, (RRnpc, RRnpc, RRnpc, RRnpc),smla, t_mla),
23928 TCE("smmls", 75000d0, fb600000, 4, (RRnpc, RRnpc, RRnpc, RRnpc),smla, t_mla),
23929 TCE("smmlsr", 75000f0, fb600010, 4, (RRnpc, RRnpc, RRnpc, RRnpc),smla, t_mla),
23930 TCE("smmul", 750f010, fb50f000, 3, (RRnpc, RRnpc, RRnpc), smul, t_simd),
23931 TCE("smmulr", 750f030, fb50f010, 3, (RRnpc, RRnpc, RRnpc), smul, t_simd),
23932 TCE("smuad", 700f010, fb20f000, 3, (RRnpc, RRnpc, RRnpc), smul, t_simd),
23933 TCE("smuadx", 700f030, fb20f010, 3, (RRnpc, RRnpc, RRnpc), smul, t_simd),
23934 TCE("smusd", 700f050, fb40f000, 3, (RRnpc, RRnpc, RRnpc), smul, t_simd),
23935 TCE("smusdx", 700f070, fb40f010, 3, (RRnpc, RRnpc, RRnpc), smul, t_simd),
23936 TCE("ssat16", 6a00f30, f3200000, 3, (RRnpc, I16, RRnpc), ssat16, t_ssat16),
23937 TCE("umaal", 0400090, fbe00060, 4, (RRnpc, RRnpc, RRnpc, RRnpc),smlal, t_mlal),
23938 TCE("usad8", 780f010, fb70f000, 3, (RRnpc, RRnpc, RRnpc), smul, t_simd),
23939 TCE("usada8", 7800010, fb700000, 4, (RRnpc, RRnpc, RRnpc, RRnpc),smla, t_mla),
23940 TCE("usat16", 6e00f30, f3a00000, 3, (RRnpc, I15, RRnpc), usat16, t_usat16),
23943 #define ARM_VARIANT & arm_ext_v6k_v6t2
23944 #undef THUMB_VARIANT
23945 #define THUMB_VARIANT & arm_ext_v6k_v6t2
23947 tCE("yield", 320f001, _yield, 0, (), noargs, t_hint),
23948 tCE("wfe", 320f002, _wfe, 0, (), noargs, t_hint),
23949 tCE("wfi", 320f003, _wfi, 0, (), noargs, t_hint),
23950 tCE("sev", 320f004, _sev, 0, (), noargs, t_hint),
23952 #undef THUMB_VARIANT
23953 #define THUMB_VARIANT & arm_ext_v6_notm
23954 TCE("ldrexd", 1b00f9f, e8d0007f, 3, (RRnpc_npcsp, oRRnpc_npcsp, RRnpcb),
23956 TCE("strexd", 1a00f90, e8c00070, 4, (RRnpc_npcsp, RRnpc_npcsp, oRRnpc_npcsp,
23957 RRnpcb), strexd, t_strexd),
23959 #undef THUMB_VARIANT
23960 #define THUMB_VARIANT & arm_ext_v6t2_v8m
23961 TCE("ldrexb", 1d00f9f, e8d00f4f, 2, (RRnpc_npcsp,RRnpcb),
23963 TCE("ldrexh", 1f00f9f, e8d00f5f, 2, (RRnpc_npcsp, RRnpcb),
23965 TCE("strexb", 1c00f90, e8c00f40, 3, (RRnpc_npcsp, RRnpc_npcsp, ADDR),
23967 TCE("strexh", 1e00f90, e8c00f50, 3, (RRnpc_npcsp, RRnpc_npcsp, ADDR),
23969 TUF("clrex", 57ff01f, f3bf8f2f, 0, (), noargs, noargs),
23972 #define ARM_VARIANT & arm_ext_sec
23973 #undef THUMB_VARIANT
23974 #define THUMB_VARIANT & arm_ext_sec
23976 TCE("smc", 1600070, f7f08000, 1, (EXPi), smc, t_smc),
23979 #define ARM_VARIANT & arm_ext_virt
23980 #undef THUMB_VARIANT
23981 #define THUMB_VARIANT & arm_ext_virt
23983 TCE("hvc", 1400070, f7e08000, 1, (EXPi), hvc, t_hvc),
23984 TCE("eret", 160006e, f3de8f00, 0, (), noargs, noargs),
23987 #define ARM_VARIANT & arm_ext_pan
23988 #undef THUMB_VARIANT
23989 #define THUMB_VARIANT & arm_ext_pan
23991 TUF("setpan", 1100000, b610, 1, (I7), setpan, t_setpan),
23994 #define ARM_VARIANT & arm_ext_v6t2
23995 #undef THUMB_VARIANT
23996 #define THUMB_VARIANT & arm_ext_v6t2
23998 TCE("bfc", 7c0001f, f36f0000, 3, (RRnpc, I31, I32), bfc, t_bfc),
23999 TCE("bfi", 7c00010, f3600000, 4, (RRnpc, RRnpc_I0, I31, I32), bfi, t_bfi),
24000 TCE("sbfx", 7a00050, f3400000, 4, (RR, RR, I31, I32), bfx, t_bfx),
24001 TCE("ubfx", 7e00050, f3c00000, 4, (RR, RR, I31, I32), bfx, t_bfx),
24003 TCE("mls", 0600090, fb000010, 4, (RRnpc, RRnpc, RRnpc, RRnpc), mlas, t_mla),
24004 TCE("rbit", 6ff0f30, fa90f0a0, 2, (RR, RR), rd_rm, t_rbit),
24006 TC3("ldrht", 03000b0, f8300e00, 2, (RRnpc_npcsp, ADDR), ldsttv4, t_ldstt),
24007 TC3("ldrsht", 03000f0, f9300e00, 2, (RRnpc_npcsp, ADDR), ldsttv4, t_ldstt),
24008 TC3("ldrsbt", 03000d0, f9100e00, 2, (RRnpc_npcsp, ADDR), ldsttv4, t_ldstt),
24009 TC3("strht", 02000b0, f8200e00, 2, (RRnpc_npcsp, ADDR), ldsttv4, t_ldstt),
24012 #define ARM_VARIANT & arm_ext_v3
24013 #undef THUMB_VARIANT
24014 #define THUMB_VARIANT & arm_ext_v6t2
24016 TUE("csdb", 320f014, f3af8014, 0, (), noargs, t_csdb),
24017 TUF("ssbb", 57ff040, f3bf8f40, 0, (), noargs, t_csdb),
24018 TUF("pssbb", 57ff044, f3bf8f44, 0, (), noargs, t_csdb),
24021 #define ARM_VARIANT & arm_ext_v6t2
24022 #undef THUMB_VARIANT
24023 #define THUMB_VARIANT & arm_ext_v6t2_v8m
24024 TCE("movw", 3000000, f2400000, 2, (RRnpc, HALF), mov16, t_mov16),
24025 TCE("movt", 3400000, f2c00000, 2, (RRnpc, HALF), mov16, t_mov16),
24027 /* Thumb-only instructions. */
24029 #define ARM_VARIANT NULL
24030 TUE("cbnz", 0, b900, 2, (RR, EXP), 0, t_cbz),
24031 TUE("cbz", 0, b100, 2, (RR, EXP), 0, t_cbz),
24033 /* ARM does not really have an IT instruction, so always allow it.
24034 The opcode is copied from Thumb in order to allow warnings in
24035 -mimplicit-it=[never | arm] modes. */
24037 #define ARM_VARIANT & arm_ext_v1
24038 #undef THUMB_VARIANT
24039 #define THUMB_VARIANT & arm_ext_v6t2
24041 TUE("it", bf08, bf08, 1, (COND), it, t_it),
24042 TUE("itt", bf0c, bf0c, 1, (COND), it, t_it),
24043 TUE("ite", bf04, bf04, 1, (COND), it, t_it),
24044 TUE("ittt", bf0e, bf0e, 1, (COND), it, t_it),
24045 TUE("itet", bf06, bf06, 1, (COND), it, t_it),
24046 TUE("itte", bf0a, bf0a, 1, (COND), it, t_it),
24047 TUE("itee", bf02, bf02, 1, (COND), it, t_it),
24048 TUE("itttt", bf0f, bf0f, 1, (COND), it, t_it),
24049 TUE("itett", bf07, bf07, 1, (COND), it, t_it),
24050 TUE("ittet", bf0b, bf0b, 1, (COND), it, t_it),
24051 TUE("iteet", bf03, bf03, 1, (COND), it, t_it),
24052 TUE("ittte", bf0d, bf0d, 1, (COND), it, t_it),
24053 TUE("itete", bf05, bf05, 1, (COND), it, t_it),
24054 TUE("ittee", bf09, bf09, 1, (COND), it, t_it),
24055 TUE("iteee", bf01, bf01, 1, (COND), it, t_it),
24056 /* ARM/Thumb-2 instructions with no Thumb-1 equivalent. */
24057 TC3("rrx", 01a00060, ea4f0030, 2, (RR, RR), rd_rm, t_rrx),
24058 TC3("rrxs", 01b00060, ea5f0030, 2, (RR, RR), rd_rm, t_rrx),
24060 /* Thumb2 only instructions. */
24062 #define ARM_VARIANT NULL
24064 TCE("addw", 0, f2000000, 3, (RR, RR, EXPi), 0, t_add_sub_w),
24065 TCE("subw", 0, f2a00000, 3, (RR, RR, EXPi), 0, t_add_sub_w),
24066 TCE("orn", 0, ea600000, 3, (RR, oRR, SH), 0, t_orn),
24067 TCE("orns", 0, ea700000, 3, (RR, oRR, SH), 0, t_orn),
24068 TCE("tbb", 0, e8d0f000, 1, (TB), 0, t_tb),
24069 TCE("tbh", 0, e8d0f010, 1, (TB), 0, t_tb),
24071 /* Hardware division instructions. */
24073 #define ARM_VARIANT & arm_ext_adiv
24074 #undef THUMB_VARIANT
24075 #define THUMB_VARIANT & arm_ext_div
24077 TCE("sdiv", 710f010, fb90f0f0, 3, (RR, oRR, RR), div, t_div),
24078 TCE("udiv", 730f010, fbb0f0f0, 3, (RR, oRR, RR), div, t_div),
24080 /* ARM V6M/V7 instructions. */
24082 #define ARM_VARIANT & arm_ext_barrier
24083 #undef THUMB_VARIANT
24084 #define THUMB_VARIANT & arm_ext_barrier
24086 TUF("dmb", 57ff050, f3bf8f50, 1, (oBARRIER_I15), barrier, barrier),
24087 TUF("dsb", 57ff040, f3bf8f40, 1, (oBARRIER_I15), barrier, barrier),
24088 TUF("isb", 57ff060, f3bf8f60, 1, (oBARRIER_I15), barrier, barrier),
24090 /* ARM V7 instructions. */
24092 #define ARM_VARIANT & arm_ext_v7
24093 #undef THUMB_VARIANT
24094 #define THUMB_VARIANT & arm_ext_v7
24096 TUF("pli", 450f000, f910f000, 1, (ADDR), pli, t_pld),
24097 TCE("dbg", 320f0f0, f3af80f0, 1, (I15), dbg, t_dbg),
24100 #define ARM_VARIANT & arm_ext_mp
24101 #undef THUMB_VARIANT
24102 #define THUMB_VARIANT & arm_ext_mp
24104 TUF("pldw", 410f000, f830f000, 1, (ADDR), pld, t_pld),
24106 /* AArchv8 instructions. */
24108 #define ARM_VARIANT & arm_ext_v8
24110 /* Instructions shared between armv8-a and armv8-m. */
24111 #undef THUMB_VARIANT
24112 #define THUMB_VARIANT & arm_ext_atomics
24114 TCE("lda", 1900c9f, e8d00faf, 2, (RRnpc, RRnpcb), rd_rn, rd_rn),
24115 TCE("ldab", 1d00c9f, e8d00f8f, 2, (RRnpc, RRnpcb), rd_rn, rd_rn),
24116 TCE("ldah", 1f00c9f, e8d00f9f, 2, (RRnpc, RRnpcb), rd_rn, rd_rn),
24117 TCE("stl", 180fc90, e8c00faf, 2, (RRnpc, RRnpcb), rm_rn, rd_rn),
24118 TCE("stlb", 1c0fc90, e8c00f8f, 2, (RRnpc, RRnpcb), rm_rn, rd_rn),
24119 TCE("stlh", 1e0fc90, e8c00f9f, 2, (RRnpc, RRnpcb), rm_rn, rd_rn),
24120 TCE("ldaex", 1900e9f, e8d00fef, 2, (RRnpc, RRnpcb), rd_rn, rd_rn),
24121 TCE("ldaexb", 1d00e9f, e8d00fcf, 2, (RRnpc,RRnpcb), rd_rn, rd_rn),
24122 TCE("ldaexh", 1f00e9f, e8d00fdf, 2, (RRnpc, RRnpcb), rd_rn, rd_rn),
24123 TCE("stlex", 1800e90, e8c00fe0, 3, (RRnpc, RRnpc, RRnpcb),
24125 TCE("stlexb", 1c00e90, e8c00fc0, 3, (RRnpc, RRnpc, RRnpcb),
24127 TCE("stlexh", 1e00e90, e8c00fd0, 3, (RRnpc, RRnpc, RRnpcb),
24129 #undef THUMB_VARIANT
24130 #define THUMB_VARIANT & arm_ext_v8
24132 tCE("sevl", 320f005, _sevl, 0, (), noargs, t_hint),
24133 TCE("ldaexd", 1b00e9f, e8d000ff, 3, (RRnpc, oRRnpc, RRnpcb),
24135 TCE("stlexd", 1a00e90, e8c000f0, 4, (RRnpc, RRnpc, oRRnpc, RRnpcb),
24138 /* Defined in V8 but is in undefined encoding space for earlier
24139 architectures. However earlier architectures are required to treat
24140 this instuction as a semihosting trap as well. Hence while not explicitly
24141 defined as such, it is in fact correct to define the instruction for all
24143 #undef THUMB_VARIANT
24144 #define THUMB_VARIANT & arm_ext_v1
24146 #define ARM_VARIANT & arm_ext_v1
24147 TUE("hlt", 1000070, ba80, 1, (oIffffb), bkpt, t_hlt),
24149 /* ARMv8 T32 only. */
24151 #define ARM_VARIANT NULL
24152 TUF("dcps1", 0, f78f8001, 0, (), noargs, noargs),
24153 TUF("dcps2", 0, f78f8002, 0, (), noargs, noargs),
24154 TUF("dcps3", 0, f78f8003, 0, (), noargs, noargs),
24156 /* FP for ARMv8. */
24158 #define ARM_VARIANT & fpu_vfp_ext_armv8xd
24159 #undef THUMB_VARIANT
24160 #define THUMB_VARIANT & fpu_vfp_ext_armv8xd
24162 nUF(vseleq, _vseleq, 3, (RVSD, RVSD, RVSD), vsel),
24163 nUF(vselvs, _vselvs, 3, (RVSD, RVSD, RVSD), vsel),
24164 nUF(vselge, _vselge, 3, (RVSD, RVSD, RVSD), vsel),
24165 nUF(vselgt, _vselgt, 3, (RVSD, RVSD, RVSD), vsel),
24166 nCE(vrintr, _vrintr, 2, (RNSDQ, oRNSDQ), vrintr),
24167 mnCE(vrintz, _vrintr, 2, (RNSDQMQ, oRNSDQMQ), vrintz),
24168 mnCE(vrintx, _vrintr, 2, (RNSDQMQ, oRNSDQMQ), vrintx),
24169 mnUF(vrinta, _vrinta, 2, (RNSDQMQ, oRNSDQMQ), vrinta),
24170 mnUF(vrintn, _vrinta, 2, (RNSDQMQ, oRNSDQMQ), vrintn),
24171 mnUF(vrintp, _vrinta, 2, (RNSDQMQ, oRNSDQMQ), vrintp),
24172 mnUF(vrintm, _vrinta, 2, (RNSDQMQ, oRNSDQMQ), vrintm),
24174 /* Crypto v1 extensions. */
24176 #define ARM_VARIANT & fpu_crypto_ext_armv8
24177 #undef THUMB_VARIANT
24178 #define THUMB_VARIANT & fpu_crypto_ext_armv8
24180 nUF(aese, _aes, 2, (RNQ, RNQ), aese),
24181 nUF(aesd, _aes, 2, (RNQ, RNQ), aesd),
24182 nUF(aesmc, _aes, 2, (RNQ, RNQ), aesmc),
24183 nUF(aesimc, _aes, 2, (RNQ, RNQ), aesimc),
24184 nUF(sha1c, _sha3op, 3, (RNQ, RNQ, RNQ), sha1c),
24185 nUF(sha1p, _sha3op, 3, (RNQ, RNQ, RNQ), sha1p),
24186 nUF(sha1m, _sha3op, 3, (RNQ, RNQ, RNQ), sha1m),
24187 nUF(sha1su0, _sha3op, 3, (RNQ, RNQ, RNQ), sha1su0),
24188 nUF(sha256h, _sha3op, 3, (RNQ, RNQ, RNQ), sha256h),
24189 nUF(sha256h2, _sha3op, 3, (RNQ, RNQ, RNQ), sha256h2),
24190 nUF(sha256su1, _sha3op, 3, (RNQ, RNQ, RNQ), sha256su1),
24191 nUF(sha1h, _sha1h, 2, (RNQ, RNQ), sha1h),
24192 nUF(sha1su1, _sha2op, 2, (RNQ, RNQ), sha1su1),
24193 nUF(sha256su0, _sha2op, 2, (RNQ, RNQ), sha256su0),
24196 #define ARM_VARIANT & crc_ext_armv8
24197 #undef THUMB_VARIANT
24198 #define THUMB_VARIANT & crc_ext_armv8
24199 TUEc("crc32b", 1000040, fac0f080, 3, (RR, oRR, RR), crc32b),
24200 TUEc("crc32h", 1200040, fac0f090, 3, (RR, oRR, RR), crc32h),
24201 TUEc("crc32w", 1400040, fac0f0a0, 3, (RR, oRR, RR), crc32w),
24202 TUEc("crc32cb",1000240, fad0f080, 3, (RR, oRR, RR), crc32cb),
24203 TUEc("crc32ch",1200240, fad0f090, 3, (RR, oRR, RR), crc32ch),
24204 TUEc("crc32cw",1400240, fad0f0a0, 3, (RR, oRR, RR), crc32cw),
24206 /* ARMv8.2 RAS extension. */
24208 #define ARM_VARIANT & arm_ext_ras
24209 #undef THUMB_VARIANT
24210 #define THUMB_VARIANT & arm_ext_ras
24211 TUE ("esb", 320f010, f3af8010, 0, (), noargs, noargs),
24214 #define ARM_VARIANT & arm_ext_v8_3
24215 #undef THUMB_VARIANT
24216 #define THUMB_VARIANT & arm_ext_v8_3
24217 NCE (vjcvt, eb90bc0, 2, (RVS, RVD), vjcvt),
24220 #define ARM_VARIANT & fpu_neon_ext_dotprod
24221 #undef THUMB_VARIANT
24222 #define THUMB_VARIANT & fpu_neon_ext_dotprod
24223 NUF (vsdot, d00, 3, (RNDQ, RNDQ, RNDQ_RNSC), neon_dotproduct_s),
24224 NUF (vudot, d00, 3, (RNDQ, RNDQ, RNDQ_RNSC), neon_dotproduct_u),
24227 #define ARM_VARIANT & fpu_fpa_ext_v1 /* Core FPA instruction set (V1). */
24228 #undef THUMB_VARIANT
24229 #define THUMB_VARIANT NULL
24231 cCE("wfs", e200110, 1, (RR), rd),
24232 cCE("rfs", e300110, 1, (RR), rd),
24233 cCE("wfc", e400110, 1, (RR), rd),
24234 cCE("rfc", e500110, 1, (RR), rd),
24236 cCL("ldfs", c100100, 2, (RF, ADDRGLDC), rd_cpaddr),
24237 cCL("ldfd", c108100, 2, (RF, ADDRGLDC), rd_cpaddr),
24238 cCL("ldfe", c500100, 2, (RF, ADDRGLDC), rd_cpaddr),
24239 cCL("ldfp", c508100, 2, (RF, ADDRGLDC), rd_cpaddr),
24241 cCL("stfs", c000100, 2, (RF, ADDRGLDC), rd_cpaddr),
24242 cCL("stfd", c008100, 2, (RF, ADDRGLDC), rd_cpaddr),
24243 cCL("stfe", c400100, 2, (RF, ADDRGLDC), rd_cpaddr),
24244 cCL("stfp", c408100, 2, (RF, ADDRGLDC), rd_cpaddr),
24246 cCL("mvfs", e008100, 2, (RF, RF_IF), rd_rm),
24247 cCL("mvfsp", e008120, 2, (RF, RF_IF), rd_rm),
24248 cCL("mvfsm", e008140, 2, (RF, RF_IF), rd_rm),
24249 cCL("mvfsz", e008160, 2, (RF, RF_IF), rd_rm),
24250 cCL("mvfd", e008180, 2, (RF, RF_IF), rd_rm),
24251 cCL("mvfdp", e0081a0, 2, (RF, RF_IF), rd_rm),
24252 cCL("mvfdm", e0081c0, 2, (RF, RF_IF), rd_rm),
24253 cCL("mvfdz", e0081e0, 2, (RF, RF_IF), rd_rm),
24254 cCL("mvfe", e088100, 2, (RF, RF_IF), rd_rm),
24255 cCL("mvfep", e088120, 2, (RF, RF_IF), rd_rm),
24256 cCL("mvfem", e088140, 2, (RF, RF_IF), rd_rm),
24257 cCL("mvfez", e088160, 2, (RF, RF_IF), rd_rm),
24259 cCL("mnfs", e108100, 2, (RF, RF_IF), rd_rm),
24260 cCL("mnfsp", e108120, 2, (RF, RF_IF), rd_rm),
24261 cCL("mnfsm", e108140, 2, (RF, RF_IF), rd_rm),
24262 cCL("mnfsz", e108160, 2, (RF, RF_IF), rd_rm),
24263 cCL("mnfd", e108180, 2, (RF, RF_IF), rd_rm),
24264 cCL("mnfdp", e1081a0, 2, (RF, RF_IF), rd_rm),
24265 cCL("mnfdm", e1081c0, 2, (RF, RF_IF), rd_rm),
24266 cCL("mnfdz", e1081e0, 2, (RF, RF_IF), rd_rm),
24267 cCL("mnfe", e188100, 2, (RF, RF_IF), rd_rm),
24268 cCL("mnfep", e188120, 2, (RF, RF_IF), rd_rm),
24269 cCL("mnfem", e188140, 2, (RF, RF_IF), rd_rm),
24270 cCL("mnfez", e188160, 2, (RF, RF_IF), rd_rm),
24272 cCL("abss", e208100, 2, (RF, RF_IF), rd_rm),
24273 cCL("abssp", e208120, 2, (RF, RF_IF), rd_rm),
24274 cCL("abssm", e208140, 2, (RF, RF_IF), rd_rm),
24275 cCL("abssz", e208160, 2, (RF, RF_IF), rd_rm),
24276 cCL("absd", e208180, 2, (RF, RF_IF), rd_rm),
24277 cCL("absdp", e2081a0, 2, (RF, RF_IF), rd_rm),
24278 cCL("absdm", e2081c0, 2, (RF, RF_IF), rd_rm),
24279 cCL("absdz", e2081e0, 2, (RF, RF_IF), rd_rm),
24280 cCL("abse", e288100, 2, (RF, RF_IF), rd_rm),
24281 cCL("absep", e288120, 2, (RF, RF_IF), rd_rm),
24282 cCL("absem", e288140, 2, (RF, RF_IF), rd_rm),
24283 cCL("absez", e288160, 2, (RF, RF_IF), rd_rm),
24285 cCL("rnds", e308100, 2, (RF, RF_IF), rd_rm),
24286 cCL("rndsp", e308120, 2, (RF, RF_IF), rd_rm),
24287 cCL("rndsm", e308140, 2, (RF, RF_IF), rd_rm),
24288 cCL("rndsz", e308160, 2, (RF, RF_IF), rd_rm),
24289 cCL("rndd", e308180, 2, (RF, RF_IF), rd_rm),
24290 cCL("rnddp", e3081a0, 2, (RF, RF_IF), rd_rm),
24291 cCL("rnddm", e3081c0, 2, (RF, RF_IF), rd_rm),
24292 cCL("rnddz", e3081e0, 2, (RF, RF_IF), rd_rm),
24293 cCL("rnde", e388100, 2, (RF, RF_IF), rd_rm),
24294 cCL("rndep", e388120, 2, (RF, RF_IF), rd_rm),
24295 cCL("rndem", e388140, 2, (RF, RF_IF), rd_rm),
24296 cCL("rndez", e388160, 2, (RF, RF_IF), rd_rm),
24298 cCL("sqts", e408100, 2, (RF, RF_IF), rd_rm),
24299 cCL("sqtsp", e408120, 2, (RF, RF_IF), rd_rm),
24300 cCL("sqtsm", e408140, 2, (RF, RF_IF), rd_rm),
24301 cCL("sqtsz", e408160, 2, (RF, RF_IF), rd_rm),
24302 cCL("sqtd", e408180, 2, (RF, RF_IF), rd_rm),
24303 cCL("sqtdp", e4081a0, 2, (RF, RF_IF), rd_rm),
24304 cCL("sqtdm", e4081c0, 2, (RF, RF_IF), rd_rm),
24305 cCL("sqtdz", e4081e0, 2, (RF, RF_IF), rd_rm),
24306 cCL("sqte", e488100, 2, (RF, RF_IF), rd_rm),
24307 cCL("sqtep", e488120, 2, (RF, RF_IF), rd_rm),
24308 cCL("sqtem", e488140, 2, (RF, RF_IF), rd_rm),
24309 cCL("sqtez", e488160, 2, (RF, RF_IF), rd_rm),
24311 cCL("logs", e508100, 2, (RF, RF_IF), rd_rm),
24312 cCL("logsp", e508120, 2, (RF, RF_IF), rd_rm),
24313 cCL("logsm", e508140, 2, (RF, RF_IF), rd_rm),
24314 cCL("logsz", e508160, 2, (RF, RF_IF), rd_rm),
24315 cCL("logd", e508180, 2, (RF, RF_IF), rd_rm),
24316 cCL("logdp", e5081a0, 2, (RF, RF_IF), rd_rm),
24317 cCL("logdm", e5081c0, 2, (RF, RF_IF), rd_rm),
24318 cCL("logdz", e5081e0, 2, (RF, RF_IF), rd_rm),
24319 cCL("loge", e588100, 2, (RF, RF_IF), rd_rm),
24320 cCL("logep", e588120, 2, (RF, RF_IF), rd_rm),
24321 cCL("logem", e588140, 2, (RF, RF_IF), rd_rm),
24322 cCL("logez", e588160, 2, (RF, RF_IF), rd_rm),
24324 cCL("lgns", e608100, 2, (RF, RF_IF), rd_rm),
24325 cCL("lgnsp", e608120, 2, (RF, RF_IF), rd_rm),
24326 cCL("lgnsm", e608140, 2, (RF, RF_IF), rd_rm),
24327 cCL("lgnsz", e608160, 2, (RF, RF_IF), rd_rm),
24328 cCL("lgnd", e608180, 2, (RF, RF_IF), rd_rm),
24329 cCL("lgndp", e6081a0, 2, (RF, RF_IF), rd_rm),
24330 cCL("lgndm", e6081c0, 2, (RF, RF_IF), rd_rm),
24331 cCL("lgndz", e6081e0, 2, (RF, RF_IF), rd_rm),
24332 cCL("lgne", e688100, 2, (RF, RF_IF), rd_rm),
24333 cCL("lgnep", e688120, 2, (RF, RF_IF), rd_rm),
24334 cCL("lgnem", e688140, 2, (RF, RF_IF), rd_rm),
24335 cCL("lgnez", e688160, 2, (RF, RF_IF), rd_rm),
24337 cCL("exps", e708100, 2, (RF, RF_IF), rd_rm),
24338 cCL("expsp", e708120, 2, (RF, RF_IF), rd_rm),
24339 cCL("expsm", e708140, 2, (RF, RF_IF), rd_rm),
24340 cCL("expsz", e708160, 2, (RF, RF_IF), rd_rm),
24341 cCL("expd", e708180, 2, (RF, RF_IF), rd_rm),
24342 cCL("expdp", e7081a0, 2, (RF, RF_IF), rd_rm),
24343 cCL("expdm", e7081c0, 2, (RF, RF_IF), rd_rm),
24344 cCL("expdz", e7081e0, 2, (RF, RF_IF), rd_rm),
24345 cCL("expe", e788100, 2, (RF, RF_IF), rd_rm),
24346 cCL("expep", e788120, 2, (RF, RF_IF), rd_rm),
24347 cCL("expem", e788140, 2, (RF, RF_IF), rd_rm),
24348 cCL("expdz", e788160, 2, (RF, RF_IF), rd_rm),
24350 cCL("sins", e808100, 2, (RF, RF_IF), rd_rm),
24351 cCL("sinsp", e808120, 2, (RF, RF_IF), rd_rm),
24352 cCL("sinsm", e808140, 2, (RF, RF_IF), rd_rm),
24353 cCL("sinsz", e808160, 2, (RF, RF_IF), rd_rm),
24354 cCL("sind", e808180, 2, (RF, RF_IF), rd_rm),
24355 cCL("sindp", e8081a0, 2, (RF, RF_IF), rd_rm),
24356 cCL("sindm", e8081c0, 2, (RF, RF_IF), rd_rm),
24357 cCL("sindz", e8081e0, 2, (RF, RF_IF), rd_rm),
24358 cCL("sine", e888100, 2, (RF, RF_IF), rd_rm),
24359 cCL("sinep", e888120, 2, (RF, RF_IF), rd_rm),
24360 cCL("sinem", e888140, 2, (RF, RF_IF), rd_rm),
24361 cCL("sinez", e888160, 2, (RF, RF_IF), rd_rm),
24363 cCL("coss", e908100, 2, (RF, RF_IF), rd_rm),
24364 cCL("cossp", e908120, 2, (RF, RF_IF), rd_rm),
24365 cCL("cossm", e908140, 2, (RF, RF_IF), rd_rm),
24366 cCL("cossz", e908160, 2, (RF, RF_IF), rd_rm),
24367 cCL("cosd", e908180, 2, (RF, RF_IF), rd_rm),
24368 cCL("cosdp", e9081a0, 2, (RF, RF_IF), rd_rm),
24369 cCL("cosdm", e9081c0, 2, (RF, RF_IF), rd_rm),
24370 cCL("cosdz", e9081e0, 2, (RF, RF_IF), rd_rm),
24371 cCL("cose", e988100, 2, (RF, RF_IF), rd_rm),
24372 cCL("cosep", e988120, 2, (RF, RF_IF), rd_rm),
24373 cCL("cosem", e988140, 2, (RF, RF_IF), rd_rm),
24374 cCL("cosez", e988160, 2, (RF, RF_IF), rd_rm),
24376 cCL("tans", ea08100, 2, (RF, RF_IF), rd_rm),
24377 cCL("tansp", ea08120, 2, (RF, RF_IF), rd_rm),
24378 cCL("tansm", ea08140, 2, (RF, RF_IF), rd_rm),
24379 cCL("tansz", ea08160, 2, (RF, RF_IF), rd_rm),
24380 cCL("tand", ea08180, 2, (RF, RF_IF), rd_rm),
24381 cCL("tandp", ea081a0, 2, (RF, RF_IF), rd_rm),
24382 cCL("tandm", ea081c0, 2, (RF, RF_IF), rd_rm),
24383 cCL("tandz", ea081e0, 2, (RF, RF_IF), rd_rm),
24384 cCL("tane", ea88100, 2, (RF, RF_IF), rd_rm),
24385 cCL("tanep", ea88120, 2, (RF, RF_IF), rd_rm),
24386 cCL("tanem", ea88140, 2, (RF, RF_IF), rd_rm),
24387 cCL("tanez", ea88160, 2, (RF, RF_IF), rd_rm),
24389 cCL("asns", eb08100, 2, (RF, RF_IF), rd_rm),
24390 cCL("asnsp", eb08120, 2, (RF, RF_IF), rd_rm),
24391 cCL("asnsm", eb08140, 2, (RF, RF_IF), rd_rm),
24392 cCL("asnsz", eb08160, 2, (RF, RF_IF), rd_rm),
24393 cCL("asnd", eb08180, 2, (RF, RF_IF), rd_rm),
24394 cCL("asndp", eb081a0, 2, (RF, RF_IF), rd_rm),
24395 cCL("asndm", eb081c0, 2, (RF, RF_IF), rd_rm),
24396 cCL("asndz", eb081e0, 2, (RF, RF_IF), rd_rm),
24397 cCL("asne", eb88100, 2, (RF, RF_IF), rd_rm),
24398 cCL("asnep", eb88120, 2, (RF, RF_IF), rd_rm),
24399 cCL("asnem", eb88140, 2, (RF, RF_IF), rd_rm),
24400 cCL("asnez", eb88160, 2, (RF, RF_IF), rd_rm),
24402 cCL("acss", ec08100, 2, (RF, RF_IF), rd_rm),
24403 cCL("acssp", ec08120, 2, (RF, RF_IF), rd_rm),
24404 cCL("acssm", ec08140, 2, (RF, RF_IF), rd_rm),
24405 cCL("acssz", ec08160, 2, (RF, RF_IF), rd_rm),
24406 cCL("acsd", ec08180, 2, (RF, RF_IF), rd_rm),
24407 cCL("acsdp", ec081a0, 2, (RF, RF_IF), rd_rm),
24408 cCL("acsdm", ec081c0, 2, (RF, RF_IF), rd_rm),
24409 cCL("acsdz", ec081e0, 2, (RF, RF_IF), rd_rm),
24410 cCL("acse", ec88100, 2, (RF, RF_IF), rd_rm),
24411 cCL("acsep", ec88120, 2, (RF, RF_IF), rd_rm),
24412 cCL("acsem", ec88140, 2, (RF, RF_IF), rd_rm),
24413 cCL("acsez", ec88160, 2, (RF, RF_IF), rd_rm),
24415 cCL("atns", ed08100, 2, (RF, RF_IF), rd_rm),
24416 cCL("atnsp", ed08120, 2, (RF, RF_IF), rd_rm),
24417 cCL("atnsm", ed08140, 2, (RF, RF_IF), rd_rm),
24418 cCL("atnsz", ed08160, 2, (RF, RF_IF), rd_rm),
24419 cCL("atnd", ed08180, 2, (RF, RF_IF), rd_rm),
24420 cCL("atndp", ed081a0, 2, (RF, RF_IF), rd_rm),
24421 cCL("atndm", ed081c0, 2, (RF, RF_IF), rd_rm),
24422 cCL("atndz", ed081e0, 2, (RF, RF_IF), rd_rm),
24423 cCL("atne", ed88100, 2, (RF, RF_IF), rd_rm),
24424 cCL("atnep", ed88120, 2, (RF, RF_IF), rd_rm),
24425 cCL("atnem", ed88140, 2, (RF, RF_IF), rd_rm),
24426 cCL("atnez", ed88160, 2, (RF, RF_IF), rd_rm),
24428 cCL("urds", ee08100, 2, (RF, RF_IF), rd_rm),
24429 cCL("urdsp", ee08120, 2, (RF, RF_IF), rd_rm),
24430 cCL("urdsm", ee08140, 2, (RF, RF_IF), rd_rm),
24431 cCL("urdsz", ee08160, 2, (RF, RF_IF), rd_rm),
24432 cCL("urdd", ee08180, 2, (RF, RF_IF), rd_rm),
24433 cCL("urddp", ee081a0, 2, (RF, RF_IF), rd_rm),
24434 cCL("urddm", ee081c0, 2, (RF, RF_IF), rd_rm),
24435 cCL("urddz", ee081e0, 2, (RF, RF_IF), rd_rm),
24436 cCL("urde", ee88100, 2, (RF, RF_IF), rd_rm),
24437 cCL("urdep", ee88120, 2, (RF, RF_IF), rd_rm),
24438 cCL("urdem", ee88140, 2, (RF, RF_IF), rd_rm),
24439 cCL("urdez", ee88160, 2, (RF, RF_IF), rd_rm),
24441 cCL("nrms", ef08100, 2, (RF, RF_IF), rd_rm),
24442 cCL("nrmsp", ef08120, 2, (RF, RF_IF), rd_rm),
24443 cCL("nrmsm", ef08140, 2, (RF, RF_IF), rd_rm),
24444 cCL("nrmsz", ef08160, 2, (RF, RF_IF), rd_rm),
24445 cCL("nrmd", ef08180, 2, (RF, RF_IF), rd_rm),
24446 cCL("nrmdp", ef081a0, 2, (RF, RF_IF), rd_rm),
24447 cCL("nrmdm", ef081c0, 2, (RF, RF_IF), rd_rm),
24448 cCL("nrmdz", ef081e0, 2, (RF, RF_IF), rd_rm),
24449 cCL("nrme", ef88100, 2, (RF, RF_IF), rd_rm),
24450 cCL("nrmep", ef88120, 2, (RF, RF_IF), rd_rm),
24451 cCL("nrmem", ef88140, 2, (RF, RF_IF), rd_rm),
24452 cCL("nrmez", ef88160, 2, (RF, RF_IF), rd_rm),
24454 cCL("adfs", e000100, 3, (RF, RF, RF_IF), rd_rn_rm),
24455 cCL("adfsp", e000120, 3, (RF, RF, RF_IF), rd_rn_rm),
24456 cCL("adfsm", e000140, 3, (RF, RF, RF_IF), rd_rn_rm),
24457 cCL("adfsz", e000160, 3, (RF, RF, RF_IF), rd_rn_rm),
24458 cCL("adfd", e000180, 3, (RF, RF, RF_IF), rd_rn_rm),
24459 cCL("adfdp", e0001a0, 3, (RF, RF, RF_IF), rd_rn_rm),
24460 cCL("adfdm", e0001c0, 3, (RF, RF, RF_IF), rd_rn_rm),
24461 cCL("adfdz", e0001e0, 3, (RF, RF, RF_IF), rd_rn_rm),
24462 cCL("adfe", e080100, 3, (RF, RF, RF_IF), rd_rn_rm),
24463 cCL("adfep", e080120, 3, (RF, RF, RF_IF), rd_rn_rm),
24464 cCL("adfem", e080140, 3, (RF, RF, RF_IF), rd_rn_rm),
24465 cCL("adfez", e080160, 3, (RF, RF, RF_IF), rd_rn_rm),
24467 cCL("sufs", e200100, 3, (RF, RF, RF_IF), rd_rn_rm),
24468 cCL("sufsp", e200120, 3, (RF, RF, RF_IF), rd_rn_rm),
24469 cCL("sufsm", e200140, 3, (RF, RF, RF_IF), rd_rn_rm),
24470 cCL("sufsz", e200160, 3, (RF, RF, RF_IF), rd_rn_rm),
24471 cCL("sufd", e200180, 3, (RF, RF, RF_IF), rd_rn_rm),
24472 cCL("sufdp", e2001a0, 3, (RF, RF, RF_IF), rd_rn_rm),
24473 cCL("sufdm", e2001c0, 3, (RF, RF, RF_IF), rd_rn_rm),
24474 cCL("sufdz", e2001e0, 3, (RF, RF, RF_IF), rd_rn_rm),
24475 cCL("sufe", e280100, 3, (RF, RF, RF_IF), rd_rn_rm),
24476 cCL("sufep", e280120, 3, (RF, RF, RF_IF), rd_rn_rm),
24477 cCL("sufem", e280140, 3, (RF, RF, RF_IF), rd_rn_rm),
24478 cCL("sufez", e280160, 3, (RF, RF, RF_IF), rd_rn_rm),
24480 cCL("rsfs", e300100, 3, (RF, RF, RF_IF), rd_rn_rm),
24481 cCL("rsfsp", e300120, 3, (RF, RF, RF_IF), rd_rn_rm),
24482 cCL("rsfsm", e300140, 3, (RF, RF, RF_IF), rd_rn_rm),
24483 cCL("rsfsz", e300160, 3, (RF, RF, RF_IF), rd_rn_rm),
24484 cCL("rsfd", e300180, 3, (RF, RF, RF_IF), rd_rn_rm),
24485 cCL("rsfdp", e3001a0, 3, (RF, RF, RF_IF), rd_rn_rm),
24486 cCL("rsfdm", e3001c0, 3, (RF, RF, RF_IF), rd_rn_rm),
24487 cCL("rsfdz", e3001e0, 3, (RF, RF, RF_IF), rd_rn_rm),
24488 cCL("rsfe", e380100, 3, (RF, RF, RF_IF), rd_rn_rm),
24489 cCL("rsfep", e380120, 3, (RF, RF, RF_IF), rd_rn_rm),
24490 cCL("rsfem", e380140, 3, (RF, RF, RF_IF), rd_rn_rm),
24491 cCL("rsfez", e380160, 3, (RF, RF, RF_IF), rd_rn_rm),
24493 cCL("mufs", e100100, 3, (RF, RF, RF_IF), rd_rn_rm),
24494 cCL("mufsp", e100120, 3, (RF, RF, RF_IF), rd_rn_rm),
24495 cCL("mufsm", e100140, 3, (RF, RF, RF_IF), rd_rn_rm),
24496 cCL("mufsz", e100160, 3, (RF, RF, RF_IF), rd_rn_rm),
24497 cCL("mufd", e100180, 3, (RF, RF, RF_IF), rd_rn_rm),
24498 cCL("mufdp", e1001a0, 3, (RF, RF, RF_IF), rd_rn_rm),
24499 cCL("mufdm", e1001c0, 3, (RF, RF, RF_IF), rd_rn_rm),
24500 cCL("mufdz", e1001e0, 3, (RF, RF, RF_IF), rd_rn_rm),
24501 cCL("mufe", e180100, 3, (RF, RF, RF_IF), rd_rn_rm),
24502 cCL("mufep", e180120, 3, (RF, RF, RF_IF), rd_rn_rm),
24503 cCL("mufem", e180140, 3, (RF, RF, RF_IF), rd_rn_rm),
24504 cCL("mufez", e180160, 3, (RF, RF, RF_IF), rd_rn_rm),
24506 cCL("dvfs", e400100, 3, (RF, RF, RF_IF), rd_rn_rm),
24507 cCL("dvfsp", e400120, 3, (RF, RF, RF_IF), rd_rn_rm),
24508 cCL("dvfsm", e400140, 3, (RF, RF, RF_IF), rd_rn_rm),
24509 cCL("dvfsz", e400160, 3, (RF, RF, RF_IF), rd_rn_rm),
24510 cCL("dvfd", e400180, 3, (RF, RF, RF_IF), rd_rn_rm),
24511 cCL("dvfdp", e4001a0, 3, (RF, RF, RF_IF), rd_rn_rm),
24512 cCL("dvfdm", e4001c0, 3, (RF, RF, RF_IF), rd_rn_rm),
24513 cCL("dvfdz", e4001e0, 3, (RF, RF, RF_IF), rd_rn_rm),
24514 cCL("dvfe", e480100, 3, (RF, RF, RF_IF), rd_rn_rm),
24515 cCL("dvfep", e480120, 3, (RF, RF, RF_IF), rd_rn_rm),
24516 cCL("dvfem", e480140, 3, (RF, RF, RF_IF), rd_rn_rm),
24517 cCL("dvfez", e480160, 3, (RF, RF, RF_IF), rd_rn_rm),
24519 cCL("rdfs", e500100, 3, (RF, RF, RF_IF), rd_rn_rm),
24520 cCL("rdfsp", e500120, 3, (RF, RF, RF_IF), rd_rn_rm),
24521 cCL("rdfsm", e500140, 3, (RF, RF, RF_IF), rd_rn_rm),
24522 cCL("rdfsz", e500160, 3, (RF, RF, RF_IF), rd_rn_rm),
24523 cCL("rdfd", e500180, 3, (RF, RF, RF_IF), rd_rn_rm),
24524 cCL("rdfdp", e5001a0, 3, (RF, RF, RF_IF), rd_rn_rm),
24525 cCL("rdfdm", e5001c0, 3, (RF, RF, RF_IF), rd_rn_rm),
24526 cCL("rdfdz", e5001e0, 3, (RF, RF, RF_IF), rd_rn_rm),
24527 cCL("rdfe", e580100, 3, (RF, RF, RF_IF), rd_rn_rm),
24528 cCL("rdfep", e580120, 3, (RF, RF, RF_IF), rd_rn_rm),
24529 cCL("rdfem", e580140, 3, (RF, RF, RF_IF), rd_rn_rm),
24530 cCL("rdfez", e580160, 3, (RF, RF, RF_IF), rd_rn_rm),
24532 cCL("pows", e600100, 3, (RF, RF, RF_IF), rd_rn_rm),
24533 cCL("powsp", e600120, 3, (RF, RF, RF_IF), rd_rn_rm),
24534 cCL("powsm", e600140, 3, (RF, RF, RF_IF), rd_rn_rm),
24535 cCL("powsz", e600160, 3, (RF, RF, RF_IF), rd_rn_rm),
24536 cCL("powd", e600180, 3, (RF, RF, RF_IF), rd_rn_rm),
24537 cCL("powdp", e6001a0, 3, (RF, RF, RF_IF), rd_rn_rm),
24538 cCL("powdm", e6001c0, 3, (RF, RF, RF_IF), rd_rn_rm),
24539 cCL("powdz", e6001e0, 3, (RF, RF, RF_IF), rd_rn_rm),
24540 cCL("powe", e680100, 3, (RF, RF, RF_IF), rd_rn_rm),
24541 cCL("powep", e680120, 3, (RF, RF, RF_IF), rd_rn_rm),
24542 cCL("powem", e680140, 3, (RF, RF, RF_IF), rd_rn_rm),
24543 cCL("powez", e680160, 3, (RF, RF, RF_IF), rd_rn_rm),
24545 cCL("rpws", e700100, 3, (RF, RF, RF_IF), rd_rn_rm),
24546 cCL("rpwsp", e700120, 3, (RF, RF, RF_IF), rd_rn_rm),
24547 cCL("rpwsm", e700140, 3, (RF, RF, RF_IF), rd_rn_rm),
24548 cCL("rpwsz", e700160, 3, (RF, RF, RF_IF), rd_rn_rm),
24549 cCL("rpwd", e700180, 3, (RF, RF, RF_IF), rd_rn_rm),
24550 cCL("rpwdp", e7001a0, 3, (RF, RF, RF_IF), rd_rn_rm),
24551 cCL("rpwdm", e7001c0, 3, (RF, RF, RF_IF), rd_rn_rm),
24552 cCL("rpwdz", e7001e0, 3, (RF, RF, RF_IF), rd_rn_rm),
24553 cCL("rpwe", e780100, 3, (RF, RF, RF_IF), rd_rn_rm),
24554 cCL("rpwep", e780120, 3, (RF, RF, RF_IF), rd_rn_rm),
24555 cCL("rpwem", e780140, 3, (RF, RF, RF_IF), rd_rn_rm),
24556 cCL("rpwez", e780160, 3, (RF, RF, RF_IF), rd_rn_rm),
24558 cCL("rmfs", e800100, 3, (RF, RF, RF_IF), rd_rn_rm),
24559 cCL("rmfsp", e800120, 3, (RF, RF, RF_IF), rd_rn_rm),
24560 cCL("rmfsm", e800140, 3, (RF, RF, RF_IF), rd_rn_rm),
24561 cCL("rmfsz", e800160, 3, (RF, RF, RF_IF), rd_rn_rm),
24562 cCL("rmfd", e800180, 3, (RF, RF, RF_IF), rd_rn_rm),
24563 cCL("rmfdp", e8001a0, 3, (RF, RF, RF_IF), rd_rn_rm),
24564 cCL("rmfdm", e8001c0, 3, (RF, RF, RF_IF), rd_rn_rm),
24565 cCL("rmfdz", e8001e0, 3, (RF, RF, RF_IF), rd_rn_rm),
24566 cCL("rmfe", e880100, 3, (RF, RF, RF_IF), rd_rn_rm),
24567 cCL("rmfep", e880120, 3, (RF, RF, RF_IF), rd_rn_rm),
24568 cCL("rmfem", e880140, 3, (RF, RF, RF_IF), rd_rn_rm),
24569 cCL("rmfez", e880160, 3, (RF, RF, RF_IF), rd_rn_rm),
24571 cCL("fmls", e900100, 3, (RF, RF, RF_IF), rd_rn_rm),
24572 cCL("fmlsp", e900120, 3, (RF, RF, RF_IF), rd_rn_rm),
24573 cCL("fmlsm", e900140, 3, (RF, RF, RF_IF), rd_rn_rm),
24574 cCL("fmlsz", e900160, 3, (RF, RF, RF_IF), rd_rn_rm),
24575 cCL("fmld", e900180, 3, (RF, RF, RF_IF), rd_rn_rm),
24576 cCL("fmldp", e9001a0, 3, (RF, RF, RF_IF), rd_rn_rm),
24577 cCL("fmldm", e9001c0, 3, (RF, RF, RF_IF), rd_rn_rm),
24578 cCL("fmldz", e9001e0, 3, (RF, RF, RF_IF), rd_rn_rm),
24579 cCL("fmle", e980100, 3, (RF, RF, RF_IF), rd_rn_rm),
24580 cCL("fmlep", e980120, 3, (RF, RF, RF_IF), rd_rn_rm),
24581 cCL("fmlem", e980140, 3, (RF, RF, RF_IF), rd_rn_rm),
24582 cCL("fmlez", e980160, 3, (RF, RF, RF_IF), rd_rn_rm),
24584 cCL("fdvs", ea00100, 3, (RF, RF, RF_IF), rd_rn_rm),
24585 cCL("fdvsp", ea00120, 3, (RF, RF, RF_IF), rd_rn_rm),
24586 cCL("fdvsm", ea00140, 3, (RF, RF, RF_IF), rd_rn_rm),
24587 cCL("fdvsz", ea00160, 3, (RF, RF, RF_IF), rd_rn_rm),
24588 cCL("fdvd", ea00180, 3, (RF, RF, RF_IF), rd_rn_rm),
24589 cCL("fdvdp", ea001a0, 3, (RF, RF, RF_IF), rd_rn_rm),
24590 cCL("fdvdm", ea001c0, 3, (RF, RF, RF_IF), rd_rn_rm),
24591 cCL("fdvdz", ea001e0, 3, (RF, RF, RF_IF), rd_rn_rm),
24592 cCL("fdve", ea80100, 3, (RF, RF, RF_IF), rd_rn_rm),
24593 cCL("fdvep", ea80120, 3, (RF, RF, RF_IF), rd_rn_rm),
24594 cCL("fdvem", ea80140, 3, (RF, RF, RF_IF), rd_rn_rm),
24595 cCL("fdvez", ea80160, 3, (RF, RF, RF_IF), rd_rn_rm),
24597 cCL("frds", eb00100, 3, (RF, RF, RF_IF), rd_rn_rm),
24598 cCL("frdsp", eb00120, 3, (RF, RF, RF_IF), rd_rn_rm),
24599 cCL("frdsm", eb00140, 3, (RF, RF, RF_IF), rd_rn_rm),
24600 cCL("frdsz", eb00160, 3, (RF, RF, RF_IF), rd_rn_rm),
24601 cCL("frdd", eb00180, 3, (RF, RF, RF_IF), rd_rn_rm),
24602 cCL("frddp", eb001a0, 3, (RF, RF, RF_IF), rd_rn_rm),
24603 cCL("frddm", eb001c0, 3, (RF, RF, RF_IF), rd_rn_rm),
24604 cCL("frddz", eb001e0, 3, (RF, RF, RF_IF), rd_rn_rm),
24605 cCL("frde", eb80100, 3, (RF, RF, RF_IF), rd_rn_rm),
24606 cCL("frdep", eb80120, 3, (RF, RF, RF_IF), rd_rn_rm),
24607 cCL("frdem", eb80140, 3, (RF, RF, RF_IF), rd_rn_rm),
24608 cCL("frdez", eb80160, 3, (RF, RF, RF_IF), rd_rn_rm),
24610 cCL("pols", ec00100, 3, (RF, RF, RF_IF), rd_rn_rm),
24611 cCL("polsp", ec00120, 3, (RF, RF, RF_IF), rd_rn_rm),
24612 cCL("polsm", ec00140, 3, (RF, RF, RF_IF), rd_rn_rm),
24613 cCL("polsz", ec00160, 3, (RF, RF, RF_IF), rd_rn_rm),
24614 cCL("pold", ec00180, 3, (RF, RF, RF_IF), rd_rn_rm),
24615 cCL("poldp", ec001a0, 3, (RF, RF, RF_IF), rd_rn_rm),
24616 cCL("poldm", ec001c0, 3, (RF, RF, RF_IF), rd_rn_rm),
24617 cCL("poldz", ec001e0, 3, (RF, RF, RF_IF), rd_rn_rm),
24618 cCL("pole", ec80100, 3, (RF, RF, RF_IF), rd_rn_rm),
24619 cCL("polep", ec80120, 3, (RF, RF, RF_IF), rd_rn_rm),
24620 cCL("polem", ec80140, 3, (RF, RF, RF_IF), rd_rn_rm),
24621 cCL("polez", ec80160, 3, (RF, RF, RF_IF), rd_rn_rm),
24623 cCE("cmf", e90f110, 2, (RF, RF_IF), fpa_cmp),
24624 C3E("cmfe", ed0f110, 2, (RF, RF_IF), fpa_cmp),
24625 cCE("cnf", eb0f110, 2, (RF, RF_IF), fpa_cmp),
24626 C3E("cnfe", ef0f110, 2, (RF, RF_IF), fpa_cmp),
24628 cCL("flts", e000110, 2, (RF, RR), rn_rd),
24629 cCL("fltsp", e000130, 2, (RF, RR), rn_rd),
24630 cCL("fltsm", e000150, 2, (RF, RR), rn_rd),
24631 cCL("fltsz", e000170, 2, (RF, RR), rn_rd),
24632 cCL("fltd", e000190, 2, (RF, RR), rn_rd),
24633 cCL("fltdp", e0001b0, 2, (RF, RR), rn_rd),
24634 cCL("fltdm", e0001d0, 2, (RF, RR), rn_rd),
24635 cCL("fltdz", e0001f0, 2, (RF, RR), rn_rd),
24636 cCL("flte", e080110, 2, (RF, RR), rn_rd),
24637 cCL("fltep", e080130, 2, (RF, RR), rn_rd),
24638 cCL("fltem", e080150, 2, (RF, RR), rn_rd),
24639 cCL("fltez", e080170, 2, (RF, RR), rn_rd),
24641 /* The implementation of the FIX instruction is broken on some
24642 assemblers, in that it accepts a precision specifier as well as a
24643 rounding specifier, despite the fact that this is meaningless.
24644 To be more compatible, we accept it as well, though of course it
24645 does not set any bits. */
24646 cCE("fix", e100110, 2, (RR, RF), rd_rm),
24647 cCL("fixp", e100130, 2, (RR, RF), rd_rm),
24648 cCL("fixm", e100150, 2, (RR, RF), rd_rm),
24649 cCL("fixz", e100170, 2, (RR, RF), rd_rm),
24650 cCL("fixsp", e100130, 2, (RR, RF), rd_rm),
24651 cCL("fixsm", e100150, 2, (RR, RF), rd_rm),
24652 cCL("fixsz", e100170, 2, (RR, RF), rd_rm),
24653 cCL("fixdp", e100130, 2, (RR, RF), rd_rm),
24654 cCL("fixdm", e100150, 2, (RR, RF), rd_rm),
24655 cCL("fixdz", e100170, 2, (RR, RF), rd_rm),
24656 cCL("fixep", e100130, 2, (RR, RF), rd_rm),
24657 cCL("fixem", e100150, 2, (RR, RF), rd_rm),
24658 cCL("fixez", e100170, 2, (RR, RF), rd_rm),
24660 /* Instructions that were new with the real FPA, call them V2. */
24662 #define ARM_VARIANT & fpu_fpa_ext_v2
24664 cCE("lfm", c100200, 3, (RF, I4b, ADDR), fpa_ldmstm),
24665 cCL("lfmfd", c900200, 3, (RF, I4b, ADDR), fpa_ldmstm),
24666 cCL("lfmea", d100200, 3, (RF, I4b, ADDR), fpa_ldmstm),
24667 cCE("sfm", c000200, 3, (RF, I4b, ADDR), fpa_ldmstm),
24668 cCL("sfmfd", d000200, 3, (RF, I4b, ADDR), fpa_ldmstm),
24669 cCL("sfmea", c800200, 3, (RF, I4b, ADDR), fpa_ldmstm),
24672 #define ARM_VARIANT & fpu_vfp_ext_v1xd /* VFP V1xD (single precision). */
24673 #undef THUMB_VARIANT
24674 #define THUMB_VARIANT & arm_ext_v6t2
24675 mcCE(vmrs, ef00a10, 2, (APSR_RR, RVC), vmrs),
24676 mcCE(vmsr, ee00a10, 2, (RVC, RR), vmsr),
24677 #undef THUMB_VARIANT
24679 /* Moves and type conversions. */
24680 cCE("fmstat", ef1fa10, 0, (), noargs),
24681 cCE("fsitos", eb80ac0, 2, (RVS, RVS), vfp_sp_monadic),
24682 cCE("fuitos", eb80a40, 2, (RVS, RVS), vfp_sp_monadic),
24683 cCE("ftosis", ebd0a40, 2, (RVS, RVS), vfp_sp_monadic),
24684 cCE("ftosizs", ebd0ac0, 2, (RVS, RVS), vfp_sp_monadic),
24685 cCE("ftouis", ebc0a40, 2, (RVS, RVS), vfp_sp_monadic),
24686 cCE("ftouizs", ebc0ac0, 2, (RVS, RVS), vfp_sp_monadic),
24687 cCE("fmrx", ef00a10, 2, (RR, RVC), rd_rn),
24688 cCE("fmxr", ee00a10, 2, (RVC, RR), rn_rd),
24690 /* Memory operations. */
24691 cCE("flds", d100a00, 2, (RVS, ADDRGLDC), vfp_sp_ldst),
24692 cCE("fsts", d000a00, 2, (RVS, ADDRGLDC), vfp_sp_ldst),
24693 cCE("fldmias", c900a00, 2, (RRnpctw, VRSLST), vfp_sp_ldstmia),
24694 cCE("fldmfds", c900a00, 2, (RRnpctw, VRSLST), vfp_sp_ldstmia),
24695 cCE("fldmdbs", d300a00, 2, (RRnpctw, VRSLST), vfp_sp_ldstmdb),
24696 cCE("fldmeas", d300a00, 2, (RRnpctw, VRSLST), vfp_sp_ldstmdb),
24697 cCE("fldmiax", c900b00, 2, (RRnpctw, VRDLST), vfp_xp_ldstmia),
24698 cCE("fldmfdx", c900b00, 2, (RRnpctw, VRDLST), vfp_xp_ldstmia),
24699 cCE("fldmdbx", d300b00, 2, (RRnpctw, VRDLST), vfp_xp_ldstmdb),
24700 cCE("fldmeax", d300b00, 2, (RRnpctw, VRDLST), vfp_xp_ldstmdb),
24701 cCE("fstmias", c800a00, 2, (RRnpctw, VRSLST), vfp_sp_ldstmia),
24702 cCE("fstmeas", c800a00, 2, (RRnpctw, VRSLST), vfp_sp_ldstmia),
24703 cCE("fstmdbs", d200a00, 2, (RRnpctw, VRSLST), vfp_sp_ldstmdb),
24704 cCE("fstmfds", d200a00, 2, (RRnpctw, VRSLST), vfp_sp_ldstmdb),
24705 cCE("fstmiax", c800b00, 2, (RRnpctw, VRDLST), vfp_xp_ldstmia),
24706 cCE("fstmeax", c800b00, 2, (RRnpctw, VRDLST), vfp_xp_ldstmia),
24707 cCE("fstmdbx", d200b00, 2, (RRnpctw, VRDLST), vfp_xp_ldstmdb),
24708 cCE("fstmfdx", d200b00, 2, (RRnpctw, VRDLST), vfp_xp_ldstmdb),
24710 /* Monadic operations. */
24711 cCE("fabss", eb00ac0, 2, (RVS, RVS), vfp_sp_monadic),
24712 cCE("fnegs", eb10a40, 2, (RVS, RVS), vfp_sp_monadic),
24713 cCE("fsqrts", eb10ac0, 2, (RVS, RVS), vfp_sp_monadic),
24715 /* Dyadic operations. */
24716 cCE("fadds", e300a00, 3, (RVS, RVS, RVS), vfp_sp_dyadic),
24717 cCE("fsubs", e300a40, 3, (RVS, RVS, RVS), vfp_sp_dyadic),
24718 cCE("fmuls", e200a00, 3, (RVS, RVS, RVS), vfp_sp_dyadic),
24719 cCE("fdivs", e800a00, 3, (RVS, RVS, RVS), vfp_sp_dyadic),
24720 cCE("fmacs", e000a00, 3, (RVS, RVS, RVS), vfp_sp_dyadic),
24721 cCE("fmscs", e100a00, 3, (RVS, RVS, RVS), vfp_sp_dyadic),
24722 cCE("fnmuls", e200a40, 3, (RVS, RVS, RVS), vfp_sp_dyadic),
24723 cCE("fnmacs", e000a40, 3, (RVS, RVS, RVS), vfp_sp_dyadic),
24724 cCE("fnmscs", e100a40, 3, (RVS, RVS, RVS), vfp_sp_dyadic),
24727 cCE("fcmps", eb40a40, 2, (RVS, RVS), vfp_sp_monadic),
24728 cCE("fcmpzs", eb50a40, 1, (RVS), vfp_sp_compare_z),
24729 cCE("fcmpes", eb40ac0, 2, (RVS, RVS), vfp_sp_monadic),
24730 cCE("fcmpezs", eb50ac0, 1, (RVS), vfp_sp_compare_z),
24732 /* Double precision load/store are still present on single precision
24733 implementations. */
24734 cCE("fldd", d100b00, 2, (RVD, ADDRGLDC), vfp_dp_ldst),
24735 cCE("fstd", d000b00, 2, (RVD, ADDRGLDC), vfp_dp_ldst),
24736 cCE("fldmiad", c900b00, 2, (RRnpctw, VRDLST), vfp_dp_ldstmia),
24737 cCE("fldmfdd", c900b00, 2, (RRnpctw, VRDLST), vfp_dp_ldstmia),
24738 cCE("fldmdbd", d300b00, 2, (RRnpctw, VRDLST), vfp_dp_ldstmdb),
24739 cCE("fldmead", d300b00, 2, (RRnpctw, VRDLST), vfp_dp_ldstmdb),
24740 cCE("fstmiad", c800b00, 2, (RRnpctw, VRDLST), vfp_dp_ldstmia),
24741 cCE("fstmead", c800b00, 2, (RRnpctw, VRDLST), vfp_dp_ldstmia),
24742 cCE("fstmdbd", d200b00, 2, (RRnpctw, VRDLST), vfp_dp_ldstmdb),
24743 cCE("fstmfdd", d200b00, 2, (RRnpctw, VRDLST), vfp_dp_ldstmdb),
24746 #define ARM_VARIANT & fpu_vfp_ext_v1 /* VFP V1 (Double precision). */
24748 /* Moves and type conversions. */
24749 cCE("fcvtds", eb70ac0, 2, (RVD, RVS), vfp_dp_sp_cvt),
24750 cCE("fcvtsd", eb70bc0, 2, (RVS, RVD), vfp_sp_dp_cvt),
24751 cCE("fmdhr", e200b10, 2, (RVD, RR), vfp_dp_rn_rd),
24752 cCE("fmdlr", e000b10, 2, (RVD, RR), vfp_dp_rn_rd),
24753 cCE("fmrdh", e300b10, 2, (RR, RVD), vfp_dp_rd_rn),
24754 cCE("fmrdl", e100b10, 2, (RR, RVD), vfp_dp_rd_rn),
24755 cCE("fsitod", eb80bc0, 2, (RVD, RVS), vfp_dp_sp_cvt),
24756 cCE("fuitod", eb80b40, 2, (RVD, RVS), vfp_dp_sp_cvt),
24757 cCE("ftosid", ebd0b40, 2, (RVS, RVD), vfp_sp_dp_cvt),
24758 cCE("ftosizd", ebd0bc0, 2, (RVS, RVD), vfp_sp_dp_cvt),
24759 cCE("ftouid", ebc0b40, 2, (RVS, RVD), vfp_sp_dp_cvt),
24760 cCE("ftouizd", ebc0bc0, 2, (RVS, RVD), vfp_sp_dp_cvt),
24762 /* Monadic operations. */
24763 cCE("fabsd", eb00bc0, 2, (RVD, RVD), vfp_dp_rd_rm),
24764 cCE("fnegd", eb10b40, 2, (RVD, RVD), vfp_dp_rd_rm),
24765 cCE("fsqrtd", eb10bc0, 2, (RVD, RVD), vfp_dp_rd_rm),
24767 /* Dyadic operations. */
24768 cCE("faddd", e300b00, 3, (RVD, RVD, RVD), vfp_dp_rd_rn_rm),
24769 cCE("fsubd", e300b40, 3, (RVD, RVD, RVD), vfp_dp_rd_rn_rm),
24770 cCE("fmuld", e200b00, 3, (RVD, RVD, RVD), vfp_dp_rd_rn_rm),
24771 cCE("fdivd", e800b00, 3, (RVD, RVD, RVD), vfp_dp_rd_rn_rm),
24772 cCE("fmacd", e000b00, 3, (RVD, RVD, RVD), vfp_dp_rd_rn_rm),
24773 cCE("fmscd", e100b00, 3, (RVD, RVD, RVD), vfp_dp_rd_rn_rm),
24774 cCE("fnmuld", e200b40, 3, (RVD, RVD, RVD), vfp_dp_rd_rn_rm),
24775 cCE("fnmacd", e000b40, 3, (RVD, RVD, RVD), vfp_dp_rd_rn_rm),
24776 cCE("fnmscd", e100b40, 3, (RVD, RVD, RVD), vfp_dp_rd_rn_rm),
24779 cCE("fcmpd", eb40b40, 2, (RVD, RVD), vfp_dp_rd_rm),
24780 cCE("fcmpzd", eb50b40, 1, (RVD), vfp_dp_rd),
24781 cCE("fcmped", eb40bc0, 2, (RVD, RVD), vfp_dp_rd_rm),
24782 cCE("fcmpezd", eb50bc0, 1, (RVD), vfp_dp_rd),
24784 /* Instructions which may belong to either the Neon or VFP instruction sets.
24785 Individual encoder functions perform additional architecture checks. */
24787 #define ARM_VARIANT & fpu_vfp_ext_v1xd
24788 #undef THUMB_VARIANT
24789 #define THUMB_VARIANT & fpu_vfp_ext_v1xd
24791 /* These mnemonics are unique to VFP. */
24792 NCE(vsqrt, 0, 2, (RVSD, RVSD), vfp_nsyn_sqrt),
24793 NCE(vdiv, 0, 3, (RVSD, RVSD, RVSD), vfp_nsyn_div),
24794 nCE(vnmul, _vnmul, 3, (RVSD, RVSD, RVSD), vfp_nsyn_nmul),
24795 nCE(vnmla, _vnmla, 3, (RVSD, RVSD, RVSD), vfp_nsyn_nmul),
24796 nCE(vnmls, _vnmls, 3, (RVSD, RVSD, RVSD), vfp_nsyn_nmul),
24797 NCE(vpush, 0, 1, (VRSDLST), vfp_nsyn_push),
24798 NCE(vpop, 0, 1, (VRSDLST), vfp_nsyn_pop),
24799 NCE(vcvtz, 0, 2, (RVSD, RVSD), vfp_nsyn_cvtz),
24801 /* Mnemonics shared by Neon and VFP. */
24802 nCEF(vmls, _vmls, 3, (RNSDQ, oRNSDQ, RNSDQ_RNSC), neon_mac_maybe_scalar),
24804 NCE(vldm, c900b00, 2, (RRnpctw, VRSDLST), neon_ldm_stm),
24805 NCE(vldmia, c900b00, 2, (RRnpctw, VRSDLST), neon_ldm_stm),
24806 NCE(vldmdb, d100b00, 2, (RRnpctw, VRSDLST), neon_ldm_stm),
24807 NCE(vstm, c800b00, 2, (RRnpctw, VRSDLST), neon_ldm_stm),
24808 NCE(vstmia, c800b00, 2, (RRnpctw, VRSDLST), neon_ldm_stm),
24809 NCE(vstmdb, d000b00, 2, (RRnpctw, VRSDLST), neon_ldm_stm),
24811 mnCEF(vcvt, _vcvt, 3, (RNSDQMQ, RNSDQMQ, oI32z), neon_cvt),
24812 nCEF(vcvtr, _vcvt, 2, (RNSDQ, RNSDQ), neon_cvtr),
24813 MNCEF(vcvtb, eb20a40, 3, (RVSDMQ, RVSDMQ, oI32b), neon_cvtb),
24814 MNCEF(vcvtt, eb20a40, 3, (RVSDMQ, RVSDMQ, oI32b), neon_cvtt),
24817 /* NOTE: All VMOV encoding is special-cased! */
24818 NCE(vmovq, 0, 1, (VMOV), neon_mov),
24820 #undef THUMB_VARIANT
24821 /* Could be either VLDR/VSTR or VLDR/VSTR (system register) which are guarded
24822 by different feature bits. Since we are setting the Thumb guard, we can
24823 require Thumb-1 which makes it a nop guard and set the right feature bit in
24824 do_vldr_vstr (). */
24825 #define THUMB_VARIANT & arm_ext_v4t
24826 NCE(vldr, d100b00, 2, (VLDR, ADDRGLDC), vldr_vstr),
24827 NCE(vstr, d000b00, 2, (VLDR, ADDRGLDC), vldr_vstr),
24830 #define ARM_VARIANT & arm_ext_fp16
24831 #undef THUMB_VARIANT
24832 #define THUMB_VARIANT & arm_ext_fp16
24833 /* New instructions added from v8.2, allowing the extraction and insertion of
24834 the upper 16 bits of a 32-bit vector register. */
24835 NCE (vmovx, eb00a40, 2, (RVS, RVS), neon_movhf),
24836 NCE (vins, eb00ac0, 2, (RVS, RVS), neon_movhf),
24838 /* New backported fma/fms instructions optional in v8.2. */
24839 NCE (vfmal, 810, 3, (RNDQ, RNSD, RNSD_RNSC), neon_vfmal),
24840 NCE (vfmsl, 810, 3, (RNDQ, RNSD, RNSD_RNSC), neon_vfmsl),
24842 #undef THUMB_VARIANT
24843 #define THUMB_VARIANT & fpu_neon_ext_v1
24845 #define ARM_VARIANT & fpu_neon_ext_v1
24847 /* Data processing with three registers of the same length. */
24848 /* integer ops, valid types S8 S16 S32 U8 U16 U32. */
24849 NUF(vaba, 0000710, 3, (RNDQ, RNDQ, RNDQ), neon_dyadic_i_su),
24850 NUF(vabaq, 0000710, 3, (RNQ, RNQ, RNQ), neon_dyadic_i_su),
24851 NUF(vhaddq, 0000000, 3, (RNQ, oRNQ, RNQ), neon_dyadic_i_su),
24852 NUF(vrhaddq, 0000100, 3, (RNQ, oRNQ, RNQ), neon_dyadic_i_su),
24853 NUF(vhsubq, 0000200, 3, (RNQ, oRNQ, RNQ), neon_dyadic_i_su),
24854 /* integer ops, valid types S8 S16 S32 S64 U8 U16 U32 U64. */
24855 NUF(vqaddq, 0000010, 3, (RNQ, oRNQ, RNQ), neon_dyadic_i64_su),
24856 NUF(vqsubq, 0000210, 3, (RNQ, oRNQ, RNQ), neon_dyadic_i64_su),
24857 NUF(vrshlq, 0000500, 3, (RNQ, oRNQ, RNQ), neon_rshl),
24858 NUF(vqrshlq, 0000510, 3, (RNQ, oRNQ, RNQ), neon_rshl),
24859 /* If not immediate, fall back to neon_dyadic_i64_su.
24860 shl should accept I8 I16 I32 I64,
24861 qshl should accept S8 S16 S32 S64 U8 U16 U32 U64. */
24862 nUF(vshlq, _vshl, 3, (RNQ, oRNQ, RNDQ_I63b), neon_shl),
24863 nUF(vqshlq, _vqshl, 3, (RNQ, oRNQ, RNDQ_I63b), neon_qshl),
24864 /* Logic ops, types optional & ignored. */
24865 nUF(vandq, _vand, 3, (RNQ, oRNQ, RNDQ_Ibig), neon_logic),
24866 nUF(vbicq, _vbic, 3, (RNQ, oRNQ, RNDQ_Ibig), neon_logic),
24867 nUF(vorrq, _vorr, 3, (RNQ, oRNQ, RNDQ_Ibig), neon_logic),
24868 nUF(vornq, _vorn, 3, (RNQ, oRNQ, RNDQ_Ibig), neon_logic),
24869 nUF(veorq, _veor, 3, (RNQ, oRNQ, RNQ), neon_logic),
24870 /* Bitfield ops, untyped. */
24871 NUF(vbsl, 1100110, 3, (RNDQ, RNDQ, RNDQ), neon_bitfield),
24872 NUF(vbslq, 1100110, 3, (RNQ, RNQ, RNQ), neon_bitfield),
24873 NUF(vbit, 1200110, 3, (RNDQ, RNDQ, RNDQ), neon_bitfield),
24874 NUF(vbitq, 1200110, 3, (RNQ, RNQ, RNQ), neon_bitfield),
24875 NUF(vbif, 1300110, 3, (RNDQ, RNDQ, RNDQ), neon_bitfield),
24876 NUF(vbifq, 1300110, 3, (RNQ, RNQ, RNQ), neon_bitfield),
24877 /* Int and float variants, types S8 S16 S32 U8 U16 U32 F16 F32. */
24878 nUF(vabdq, _vabd, 3, (RNQ, oRNQ, RNQ), neon_dyadic_if_su),
24879 nUF(vmaxq, _vmax, 3, (RNQ, oRNQ, RNQ), neon_dyadic_if_su),
24880 nUF(vminq, _vmin, 3, (RNQ, oRNQ, RNQ), neon_dyadic_if_su),
24881 /* Comparisons. Types S8 S16 S32 U8 U16 U32 F32. Non-immediate versions fall
24882 back to neon_dyadic_if_su. */
24883 nUF(vcge, _vcge, 3, (RNDQ, oRNDQ, RNDQ_I0), neon_cmp),
24884 nUF(vcgeq, _vcge, 3, (RNQ, oRNQ, RNDQ_I0), neon_cmp),
24885 nUF(vcgt, _vcgt, 3, (RNDQ, oRNDQ, RNDQ_I0), neon_cmp),
24886 nUF(vcgtq, _vcgt, 3, (RNQ, oRNQ, RNDQ_I0), neon_cmp),
24887 nUF(vclt, _vclt, 3, (RNDQ, oRNDQ, RNDQ_I0), neon_cmp_inv),
24888 nUF(vcltq, _vclt, 3, (RNQ, oRNQ, RNDQ_I0), neon_cmp_inv),
24889 nUF(vcle, _vcle, 3, (RNDQ, oRNDQ, RNDQ_I0), neon_cmp_inv),
24890 nUF(vcleq, _vcle, 3, (RNQ, oRNQ, RNDQ_I0), neon_cmp_inv),
24891 /* Comparison. Type I8 I16 I32 F32. */
24892 nUF(vceq, _vceq, 3, (RNDQ, oRNDQ, RNDQ_I0), neon_ceq),
24893 nUF(vceqq, _vceq, 3, (RNQ, oRNQ, RNDQ_I0), neon_ceq),
24894 /* As above, D registers only. */
24895 nUF(vpmax, _vpmax, 3, (RND, oRND, RND), neon_dyadic_if_su_d),
24896 nUF(vpmin, _vpmin, 3, (RND, oRND, RND), neon_dyadic_if_su_d),
24897 /* Int and float variants, signedness unimportant. */
24898 nUF(vmlaq, _vmla, 3, (RNQ, oRNQ, RNDQ_RNSC), neon_mac_maybe_scalar),
24899 nUF(vmlsq, _vmls, 3, (RNQ, oRNQ, RNDQ_RNSC), neon_mac_maybe_scalar),
24900 nUF(vpadd, _vpadd, 3, (RND, oRND, RND), neon_dyadic_if_i_d),
24901 /* Add/sub take types I8 I16 I32 I64 F32. */
24902 nUF(vaddq, _vadd, 3, (RNQ, oRNQ, RNQ), neon_addsub_if_i),
24903 nUF(vsubq, _vsub, 3, (RNQ, oRNQ, RNQ), neon_addsub_if_i),
24904 /* vtst takes sizes 8, 16, 32. */
24905 NUF(vtst, 0000810, 3, (RNDQ, oRNDQ, RNDQ), neon_tst),
24906 NUF(vtstq, 0000810, 3, (RNQ, oRNQ, RNQ), neon_tst),
24907 /* VMUL takes I8 I16 I32 F32 P8. */
24908 nUF(vmulq, _vmul, 3, (RNQ, oRNQ, RNDQ_RNSC), neon_mul),
24909 /* VQD{R}MULH takes S16 S32. */
24910 nUF(vqdmulhq, _vqdmulh, 3, (RNQ, oRNQ, RNDQ_RNSC), neon_qdmulh),
24911 nUF(vqrdmulhq, _vqrdmulh, 3, (RNQ, oRNQ, RNDQ_RNSC), neon_qdmulh),
24912 NUF(vacge, 0000e10, 3, (RNDQ, oRNDQ, RNDQ), neon_fcmp_absolute),
24913 NUF(vacgeq, 0000e10, 3, (RNQ, oRNQ, RNQ), neon_fcmp_absolute),
24914 NUF(vacgt, 0200e10, 3, (RNDQ, oRNDQ, RNDQ), neon_fcmp_absolute),
24915 NUF(vacgtq, 0200e10, 3, (RNQ, oRNQ, RNQ), neon_fcmp_absolute),
24916 NUF(vaclt, 0200e10, 3, (RNDQ, oRNDQ, RNDQ), neon_fcmp_absolute_inv),
24917 NUF(vacltq, 0200e10, 3, (RNQ, oRNQ, RNQ), neon_fcmp_absolute_inv),
24918 NUF(vacle, 0000e10, 3, (RNDQ, oRNDQ, RNDQ), neon_fcmp_absolute_inv),
24919 NUF(vacleq, 0000e10, 3, (RNQ, oRNQ, RNQ), neon_fcmp_absolute_inv),
24920 NUF(vrecps, 0000f10, 3, (RNDQ, oRNDQ, RNDQ), neon_step),
24921 NUF(vrecpsq, 0000f10, 3, (RNQ, oRNQ, RNQ), neon_step),
24922 NUF(vrsqrts, 0200f10, 3, (RNDQ, oRNDQ, RNDQ), neon_step),
24923 NUF(vrsqrtsq, 0200f10, 3, (RNQ, oRNQ, RNQ), neon_step),
24924 /* ARM v8.1 extension. */
24925 nUF (vqrdmlahq, _vqrdmlah, 3, (RNQ, oRNQ, RNDQ_RNSC), neon_qrdmlah),
24926 nUF (vqrdmlsh, _vqrdmlsh, 3, (RNDQ, oRNDQ, RNDQ_RNSC), neon_qrdmlah),
24927 nUF (vqrdmlshq, _vqrdmlsh, 3, (RNQ, oRNQ, RNDQ_RNSC), neon_qrdmlah),
24929 /* Two address, int/float. Types S8 S16 S32 F32. */
24930 NUF(vabsq, 1b10300, 2, (RNQ, RNQ), neon_abs_neg),
24931 NUF(vnegq, 1b10380, 2, (RNQ, RNQ), neon_abs_neg),
24933 /* Data processing with two registers and a shift amount. */
24934 /* Right shifts, and variants with rounding.
24935 Types accepted S8 S16 S32 S64 U8 U16 U32 U64. */
24936 NUF(vshrq, 0800010, 3, (RNQ, oRNQ, I64z), neon_rshift_round_imm),
24937 NUF(vrshrq, 0800210, 3, (RNQ, oRNQ, I64z), neon_rshift_round_imm),
24938 NUF(vsra, 0800110, 3, (RNDQ, oRNDQ, I64), neon_rshift_round_imm),
24939 NUF(vsraq, 0800110, 3, (RNQ, oRNQ, I64), neon_rshift_round_imm),
24940 NUF(vrsra, 0800310, 3, (RNDQ, oRNDQ, I64), neon_rshift_round_imm),
24941 NUF(vrsraq, 0800310, 3, (RNQ, oRNQ, I64), neon_rshift_round_imm),
24942 /* Shift and insert. Sizes accepted 8 16 32 64. */
24943 NUF(vsliq, 1800510, 3, (RNQ, oRNQ, I63), neon_sli),
24944 NUF(vsriq, 1800410, 3, (RNQ, oRNQ, I64), neon_sri),
24945 /* QSHL{U} immediate accepts S8 S16 S32 S64 U8 U16 U32 U64. */
24946 NUF(vqshluq, 1800610, 3, (RNQ, oRNQ, I63), neon_qshlu_imm),
24947 /* Right shift immediate, saturating & narrowing, with rounding variants.
24948 Types accepted S16 S32 S64 U16 U32 U64. */
24949 NUF(vqshrn, 0800910, 3, (RND, RNQ, I32z), neon_rshift_sat_narrow),
24950 NUF(vqrshrn, 0800950, 3, (RND, RNQ, I32z), neon_rshift_sat_narrow),
24951 /* As above, unsigned. Types accepted S16 S32 S64. */
24952 NUF(vqshrun, 0800810, 3, (RND, RNQ, I32z), neon_rshift_sat_narrow_u),
24953 NUF(vqrshrun, 0800850, 3, (RND, RNQ, I32z), neon_rshift_sat_narrow_u),
24954 /* Right shift narrowing. Types accepted I16 I32 I64. */
24955 NUF(vshrn, 0800810, 3, (RND, RNQ, I32z), neon_rshift_narrow),
24956 NUF(vrshrn, 0800850, 3, (RND, RNQ, I32z), neon_rshift_narrow),
24957 /* Special case. Types S8 S16 S32 U8 U16 U32. Handles max shift variant. */
24958 nUF(vshll, _vshll, 3, (RNQ, RND, I32), neon_shll),
24959 /* CVT with optional immediate for fixed-point variant. */
24960 nUF(vcvtq, _vcvt, 3, (RNQ, RNQ, oI32b), neon_cvt),
24962 nUF(vmvnq, _vmvn, 2, (RNQ, RNDQ_Ibig), neon_mvn),
24964 /* Data processing, three registers of different lengths. */
24965 /* Dyadic, long insns. Types S8 S16 S32 U8 U16 U32. */
24966 NUF(vabal, 0800500, 3, (RNQ, RND, RND), neon_abal),
24967 /* If not scalar, fall back to neon_dyadic_long.
24968 Vector types as above, scalar types S16 S32 U16 U32. */
24969 nUF(vmlal, _vmlal, 3, (RNQ, RND, RND_RNSC), neon_mac_maybe_scalar_long),
24970 nUF(vmlsl, _vmlsl, 3, (RNQ, RND, RND_RNSC), neon_mac_maybe_scalar_long),
24971 /* Dyadic, widening insns. Types S8 S16 S32 U8 U16 U32. */
24972 NUF(vaddw, 0800100, 3, (RNQ, oRNQ, RND), neon_dyadic_wide),
24973 NUF(vsubw, 0800300, 3, (RNQ, oRNQ, RND), neon_dyadic_wide),
24974 /* Dyadic, narrowing insns. Types I16 I32 I64. */
24975 NUF(vaddhn, 0800400, 3, (RND, RNQ, RNQ), neon_dyadic_narrow),
24976 NUF(vraddhn, 1800400, 3, (RND, RNQ, RNQ), neon_dyadic_narrow),
24977 NUF(vsubhn, 0800600, 3, (RND, RNQ, RNQ), neon_dyadic_narrow),
24978 NUF(vrsubhn, 1800600, 3, (RND, RNQ, RNQ), neon_dyadic_narrow),
24979 /* Saturating doubling multiplies. Types S16 S32. */
24980 nUF(vqdmlal, _vqdmlal, 3, (RNQ, RND, RND_RNSC), neon_mul_sat_scalar_long),
24981 nUF(vqdmlsl, _vqdmlsl, 3, (RNQ, RND, RND_RNSC), neon_mul_sat_scalar_long),
24982 nUF(vqdmull, _vqdmull, 3, (RNQ, RND, RND_RNSC), neon_mul_sat_scalar_long),
24983 /* VMULL. Vector types S8 S16 S32 U8 U16 U32 P8, scalar types
24984 S16 S32 U16 U32. */
24985 nUF(vmull, _vmull, 3, (RNQ, RND, RND_RNSC), neon_vmull),
24987 /* Extract. Size 8. */
24988 NUF(vext, 0b00000, 4, (RNDQ, oRNDQ, RNDQ, I15), neon_ext),
24989 NUF(vextq, 0b00000, 4, (RNQ, oRNQ, RNQ, I15), neon_ext),
24991 /* Two registers, miscellaneous. */
24992 /* Reverse. Sizes 8 16 32 (must be < size in opcode). */
24993 NUF(vrev64q, 1b00000, 2, (RNQ, RNQ), neon_rev),
24994 NUF(vrev32q, 1b00080, 2, (RNQ, RNQ), neon_rev),
24995 NUF(vrev16q, 1b00100, 2, (RNQ, RNQ), neon_rev),
24996 /* Vector replicate. Sizes 8 16 32. */
24997 nCE(vdupq, _vdup, 2, (RNQ, RR_RNSC), neon_dup),
24998 /* VMOVL. Types S8 S16 S32 U8 U16 U32. */
24999 NUF(vmovl, 0800a10, 2, (RNQ, RND), neon_movl),
25000 /* VMOVN. Types I16 I32 I64. */
25001 nUF(vmovn, _vmovn, 2, (RND, RNQ), neon_movn),
25002 /* VQMOVN. Types S16 S32 S64 U16 U32 U64. */
25003 nUF(vqmovn, _vqmovn, 2, (RND, RNQ), neon_qmovn),
25004 /* VQMOVUN. Types S16 S32 S64. */
25005 nUF(vqmovun, _vqmovun, 2, (RND, RNQ), neon_qmovun),
25006 /* VZIP / VUZP. Sizes 8 16 32. */
25007 NUF(vzip, 1b20180, 2, (RNDQ, RNDQ), neon_zip_uzp),
25008 NUF(vzipq, 1b20180, 2, (RNQ, RNQ), neon_zip_uzp),
25009 NUF(vuzp, 1b20100, 2, (RNDQ, RNDQ), neon_zip_uzp),
25010 NUF(vuzpq, 1b20100, 2, (RNQ, RNQ), neon_zip_uzp),
25011 /* VQABS / VQNEG. Types S8 S16 S32. */
25012 NUF(vqabsq, 1b00700, 2, (RNQ, RNQ), neon_sat_abs_neg),
25013 NUF(vqnegq, 1b00780, 2, (RNQ, RNQ), neon_sat_abs_neg),
25014 /* Pairwise, lengthening. Types S8 S16 S32 U8 U16 U32. */
25015 NUF(vpadal, 1b00600, 2, (RNDQ, RNDQ), neon_pair_long),
25016 NUF(vpadalq, 1b00600, 2, (RNQ, RNQ), neon_pair_long),
25017 NUF(vpaddl, 1b00200, 2, (RNDQ, RNDQ), neon_pair_long),
25018 NUF(vpaddlq, 1b00200, 2, (RNQ, RNQ), neon_pair_long),
25019 /* Reciprocal estimates. Types U32 F16 F32. */
25020 NUF(vrecpe, 1b30400, 2, (RNDQ, RNDQ), neon_recip_est),
25021 NUF(vrecpeq, 1b30400, 2, (RNQ, RNQ), neon_recip_est),
25022 NUF(vrsqrte, 1b30480, 2, (RNDQ, RNDQ), neon_recip_est),
25023 NUF(vrsqrteq, 1b30480, 2, (RNQ, RNQ), neon_recip_est),
25024 /* VCLS. Types S8 S16 S32. */
25025 NUF(vclsq, 1b00400, 2, (RNQ, RNQ), neon_cls),
25026 /* VCLZ. Types I8 I16 I32. */
25027 NUF(vclzq, 1b00480, 2, (RNQ, RNQ), neon_clz),
25028 /* VCNT. Size 8. */
25029 NUF(vcnt, 1b00500, 2, (RNDQ, RNDQ), neon_cnt),
25030 NUF(vcntq, 1b00500, 2, (RNQ, RNQ), neon_cnt),
25031 /* Two address, untyped. */
25032 NUF(vswp, 1b20000, 2, (RNDQ, RNDQ), neon_swp),
25033 NUF(vswpq, 1b20000, 2, (RNQ, RNQ), neon_swp),
25034 /* VTRN. Sizes 8 16 32. */
25035 nUF(vtrn, _vtrn, 2, (RNDQ, RNDQ), neon_trn),
25036 nUF(vtrnq, _vtrn, 2, (RNQ, RNQ), neon_trn),
25038 /* Table lookup. Size 8. */
25039 NUF(vtbl, 1b00800, 3, (RND, NRDLST, RND), neon_tbl_tbx),
25040 NUF(vtbx, 1b00840, 3, (RND, NRDLST, RND), neon_tbl_tbx),
25042 #undef THUMB_VARIANT
25043 #define THUMB_VARIANT & fpu_vfp_v3_or_neon_ext
25045 #define ARM_VARIANT & fpu_vfp_v3_or_neon_ext
25047 /* Neon element/structure load/store. */
25048 nUF(vld1, _vld1, 2, (NSTRLST, ADDR), neon_ldx_stx),
25049 nUF(vst1, _vst1, 2, (NSTRLST, ADDR), neon_ldx_stx),
25050 nUF(vld2, _vld2, 2, (NSTRLST, ADDR), neon_ldx_stx),
25051 nUF(vst2, _vst2, 2, (NSTRLST, ADDR), neon_ldx_stx),
25052 nUF(vld3, _vld3, 2, (NSTRLST, ADDR), neon_ldx_stx),
25053 nUF(vst3, _vst3, 2, (NSTRLST, ADDR), neon_ldx_stx),
25054 nUF(vld4, _vld4, 2, (NSTRLST, ADDR), neon_ldx_stx),
25055 nUF(vst4, _vst4, 2, (NSTRLST, ADDR), neon_ldx_stx),
25057 #undef THUMB_VARIANT
25058 #define THUMB_VARIANT & fpu_vfp_ext_v3xd
25060 #define ARM_VARIANT & fpu_vfp_ext_v3xd
25061 cCE("fconsts", eb00a00, 2, (RVS, I255), vfp_sp_const),
25062 cCE("fshtos", eba0a40, 2, (RVS, I16z), vfp_sp_conv_16),
25063 cCE("fsltos", eba0ac0, 2, (RVS, I32), vfp_sp_conv_32),
25064 cCE("fuhtos", ebb0a40, 2, (RVS, I16z), vfp_sp_conv_16),
25065 cCE("fultos", ebb0ac0, 2, (RVS, I32), vfp_sp_conv_32),
25066 cCE("ftoshs", ebe0a40, 2, (RVS, I16z), vfp_sp_conv_16),
25067 cCE("ftosls", ebe0ac0, 2, (RVS, I32), vfp_sp_conv_32),
25068 cCE("ftouhs", ebf0a40, 2, (RVS, I16z), vfp_sp_conv_16),
25069 cCE("ftouls", ebf0ac0, 2, (RVS, I32), vfp_sp_conv_32),
25071 #undef THUMB_VARIANT
25072 #define THUMB_VARIANT & fpu_vfp_ext_v3
25074 #define ARM_VARIANT & fpu_vfp_ext_v3
25076 cCE("fconstd", eb00b00, 2, (RVD, I255), vfp_dp_const),
25077 cCE("fshtod", eba0b40, 2, (RVD, I16z), vfp_dp_conv_16),
25078 cCE("fsltod", eba0bc0, 2, (RVD, I32), vfp_dp_conv_32),
25079 cCE("fuhtod", ebb0b40, 2, (RVD, I16z), vfp_dp_conv_16),
25080 cCE("fultod", ebb0bc0, 2, (RVD, I32), vfp_dp_conv_32),
25081 cCE("ftoshd", ebe0b40, 2, (RVD, I16z), vfp_dp_conv_16),
25082 cCE("ftosld", ebe0bc0, 2, (RVD, I32), vfp_dp_conv_32),
25083 cCE("ftouhd", ebf0b40, 2, (RVD, I16z), vfp_dp_conv_16),
25084 cCE("ftould", ebf0bc0, 2, (RVD, I32), vfp_dp_conv_32),
25087 #define ARM_VARIANT & fpu_vfp_ext_fma
25088 #undef THUMB_VARIANT
25089 #define THUMB_VARIANT & fpu_vfp_ext_fma
25090 /* Mnemonics shared by Neon, VFP and MVE. These are included in the
25091 VFP FMA variant; NEON and VFP FMA always includes the NEON
25092 FMA instructions. */
25093 mnCEF(vfma, _vfma, 3, (RNSDQMQ, oRNSDQMQ, RNSDQMQR), neon_fmac),
25094 mnCEF(vfms, _vfms, 3, (RNSDQMQ, oRNSDQMQ, RNSDQMQ), neon_fmac),
25096 /* ffmas/ffmad/ffmss/ffmsd are dummy mnemonics to satisfy gas;
25097 the v form should always be used. */
25098 cCE("ffmas", ea00a00, 3, (RVS, RVS, RVS), vfp_sp_dyadic),
25099 cCE("ffnmas", ea00a40, 3, (RVS, RVS, RVS), vfp_sp_dyadic),
25100 cCE("ffmad", ea00b00, 3, (RVD, RVD, RVD), vfp_dp_rd_rn_rm),
25101 cCE("ffnmad", ea00b40, 3, (RVD, RVD, RVD), vfp_dp_rd_rn_rm),
25102 nCE(vfnma, _vfnma, 3, (RVSD, RVSD, RVSD), vfp_nsyn_nmul),
25103 nCE(vfnms, _vfnms, 3, (RVSD, RVSD, RVSD), vfp_nsyn_nmul),
25105 #undef THUMB_VARIANT
25107 #define ARM_VARIANT & arm_cext_xscale /* Intel XScale extensions. */
25109 cCE("mia", e200010, 3, (RXA, RRnpc, RRnpc), xsc_mia),
25110 cCE("miaph", e280010, 3, (RXA, RRnpc, RRnpc), xsc_mia),
25111 cCE("miabb", e2c0010, 3, (RXA, RRnpc, RRnpc), xsc_mia),
25112 cCE("miabt", e2d0010, 3, (RXA, RRnpc, RRnpc), xsc_mia),
25113 cCE("miatb", e2e0010, 3, (RXA, RRnpc, RRnpc), xsc_mia),
25114 cCE("miatt", e2f0010, 3, (RXA, RRnpc, RRnpc), xsc_mia),
25115 cCE("mar", c400000, 3, (RXA, RRnpc, RRnpc), xsc_mar),
25116 cCE("mra", c500000, 3, (RRnpc, RRnpc, RXA), xsc_mra),
25119 #define ARM_VARIANT & arm_cext_iwmmxt /* Intel Wireless MMX technology. */
25121 cCE("tandcb", e13f130, 1, (RR), iwmmxt_tandorc),
25122 cCE("tandch", e53f130, 1, (RR), iwmmxt_tandorc),
25123 cCE("tandcw", e93f130, 1, (RR), iwmmxt_tandorc),
25124 cCE("tbcstb", e400010, 2, (RIWR, RR), rn_rd),
25125 cCE("tbcsth", e400050, 2, (RIWR, RR), rn_rd),
25126 cCE("tbcstw", e400090, 2, (RIWR, RR), rn_rd),
25127 cCE("textrcb", e130170, 2, (RR, I7), iwmmxt_textrc),
25128 cCE("textrch", e530170, 2, (RR, I7), iwmmxt_textrc),
25129 cCE("textrcw", e930170, 2, (RR, I7), iwmmxt_textrc),
25130 cCE("textrmub",e100070, 3, (RR, RIWR, I7), iwmmxt_textrm),
25131 cCE("textrmuh",e500070, 3, (RR, RIWR, I7), iwmmxt_textrm),
25132 cCE("textrmuw",e900070, 3, (RR, RIWR, I7), iwmmxt_textrm),
25133 cCE("textrmsb",e100078, 3, (RR, RIWR, I7), iwmmxt_textrm),
25134 cCE("textrmsh",e500078, 3, (RR, RIWR, I7), iwmmxt_textrm),
25135 cCE("textrmsw",e900078, 3, (RR, RIWR, I7), iwmmxt_textrm),
25136 cCE("tinsrb", e600010, 3, (RIWR, RR, I7), iwmmxt_tinsr),
25137 cCE("tinsrh", e600050, 3, (RIWR, RR, I7), iwmmxt_tinsr),
25138 cCE("tinsrw", e600090, 3, (RIWR, RR, I7), iwmmxt_tinsr),
25139 cCE("tmcr", e000110, 2, (RIWC_RIWG, RR), rn_rd),
25140 cCE("tmcrr", c400000, 3, (RIWR, RR, RR), rm_rd_rn),
25141 cCE("tmia", e200010, 3, (RIWR, RR, RR), iwmmxt_tmia),
25142 cCE("tmiaph", e280010, 3, (RIWR, RR, RR), iwmmxt_tmia),
25143 cCE("tmiabb", e2c0010, 3, (RIWR, RR, RR), iwmmxt_tmia),
25144 cCE("tmiabt", e2d0010, 3, (RIWR, RR, RR), iwmmxt_tmia),
25145 cCE("tmiatb", e2e0010, 3, (RIWR, RR, RR), iwmmxt_tmia),
25146 cCE("tmiatt", e2f0010, 3, (RIWR, RR, RR), iwmmxt_tmia),
25147 cCE("tmovmskb",e100030, 2, (RR, RIWR), rd_rn),
25148 cCE("tmovmskh",e500030, 2, (RR, RIWR), rd_rn),
25149 cCE("tmovmskw",e900030, 2, (RR, RIWR), rd_rn),
25150 cCE("tmrc", e100110, 2, (RR, RIWC_RIWG), rd_rn),
25151 cCE("tmrrc", c500000, 3, (RR, RR, RIWR), rd_rn_rm),
25152 cCE("torcb", e13f150, 1, (RR), iwmmxt_tandorc),
25153 cCE("torch", e53f150, 1, (RR), iwmmxt_tandorc),
25154 cCE("torcw", e93f150, 1, (RR), iwmmxt_tandorc),
25155 cCE("waccb", e0001c0, 2, (RIWR, RIWR), rd_rn),
25156 cCE("wacch", e4001c0, 2, (RIWR, RIWR), rd_rn),
25157 cCE("waccw", e8001c0, 2, (RIWR, RIWR), rd_rn),
25158 cCE("waddbss", e300180, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25159 cCE("waddb", e000180, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25160 cCE("waddbus", e100180, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25161 cCE("waddhss", e700180, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25162 cCE("waddh", e400180, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25163 cCE("waddhus", e500180, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25164 cCE("waddwss", eb00180, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25165 cCE("waddw", e800180, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25166 cCE("waddwus", e900180, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25167 cCE("waligni", e000020, 4, (RIWR, RIWR, RIWR, I7), iwmmxt_waligni),
25168 cCE("walignr0",e800020, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25169 cCE("walignr1",e900020, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25170 cCE("walignr2",ea00020, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25171 cCE("walignr3",eb00020, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25172 cCE("wand", e200000, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25173 cCE("wandn", e300000, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25174 cCE("wavg2b", e800000, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25175 cCE("wavg2br", e900000, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25176 cCE("wavg2h", ec00000, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25177 cCE("wavg2hr", ed00000, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25178 cCE("wcmpeqb", e000060, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25179 cCE("wcmpeqh", e400060, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25180 cCE("wcmpeqw", e800060, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25181 cCE("wcmpgtub",e100060, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25182 cCE("wcmpgtuh",e500060, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25183 cCE("wcmpgtuw",e900060, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25184 cCE("wcmpgtsb",e300060, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25185 cCE("wcmpgtsh",e700060, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25186 cCE("wcmpgtsw",eb00060, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25187 cCE("wldrb", c100000, 2, (RIWR, ADDR), iwmmxt_wldstbh),
25188 cCE("wldrh", c500000, 2, (RIWR, ADDR), iwmmxt_wldstbh),
25189 cCE("wldrw", c100100, 2, (RIWR_RIWC, ADDR), iwmmxt_wldstw),
25190 cCE("wldrd", c500100, 2, (RIWR, ADDR), iwmmxt_wldstd),
25191 cCE("wmacs", e600100, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25192 cCE("wmacsz", e700100, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25193 cCE("wmacu", e400100, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25194 cCE("wmacuz", e500100, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25195 cCE("wmadds", ea00100, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25196 cCE("wmaddu", e800100, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25197 cCE("wmaxsb", e200160, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25198 cCE("wmaxsh", e600160, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25199 cCE("wmaxsw", ea00160, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25200 cCE("wmaxub", e000160, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25201 cCE("wmaxuh", e400160, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25202 cCE("wmaxuw", e800160, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25203 cCE("wminsb", e300160, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25204 cCE("wminsh", e700160, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25205 cCE("wminsw", eb00160, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25206 cCE("wminub", e100160, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25207 cCE("wminuh", e500160, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25208 cCE("wminuw", e900160, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25209 cCE("wmov", e000000, 2, (RIWR, RIWR), iwmmxt_wmov),
25210 cCE("wmulsm", e300100, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25211 cCE("wmulsl", e200100, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25212 cCE("wmulum", e100100, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25213 cCE("wmulul", e000100, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25214 cCE("wor", e000000, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25215 cCE("wpackhss",e700080, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25216 cCE("wpackhus",e500080, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25217 cCE("wpackwss",eb00080, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25218 cCE("wpackwus",e900080, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25219 cCE("wpackdss",ef00080, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25220 cCE("wpackdus",ed00080, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25221 cCE("wrorh", e700040, 3, (RIWR, RIWR, RIWR_I32z),iwmmxt_wrwrwr_or_imm5),
25222 cCE("wrorhg", e700148, 3, (RIWR, RIWR, RIWG), rd_rn_rm),
25223 cCE("wrorw", eb00040, 3, (RIWR, RIWR, RIWR_I32z),iwmmxt_wrwrwr_or_imm5),
25224 cCE("wrorwg", eb00148, 3, (RIWR, RIWR, RIWG), rd_rn_rm),
25225 cCE("wrord", ef00040, 3, (RIWR, RIWR, RIWR_I32z),iwmmxt_wrwrwr_or_imm5),
25226 cCE("wrordg", ef00148, 3, (RIWR, RIWR, RIWG), rd_rn_rm),
25227 cCE("wsadb", e000120, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25228 cCE("wsadbz", e100120, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25229 cCE("wsadh", e400120, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25230 cCE("wsadhz", e500120, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25231 cCE("wshufh", e0001e0, 3, (RIWR, RIWR, I255), iwmmxt_wshufh),
25232 cCE("wsllh", e500040, 3, (RIWR, RIWR, RIWR_I32z),iwmmxt_wrwrwr_or_imm5),
25233 cCE("wsllhg", e500148, 3, (RIWR, RIWR, RIWG), rd_rn_rm),
25234 cCE("wsllw", e900040, 3, (RIWR, RIWR, RIWR_I32z),iwmmxt_wrwrwr_or_imm5),
25235 cCE("wsllwg", e900148, 3, (RIWR, RIWR, RIWG), rd_rn_rm),
25236 cCE("wslld", ed00040, 3, (RIWR, RIWR, RIWR_I32z),iwmmxt_wrwrwr_or_imm5),
25237 cCE("wslldg", ed00148, 3, (RIWR, RIWR, RIWG), rd_rn_rm),
25238 cCE("wsrah", e400040, 3, (RIWR, RIWR, RIWR_I32z),iwmmxt_wrwrwr_or_imm5),
25239 cCE("wsrahg", e400148, 3, (RIWR, RIWR, RIWG), rd_rn_rm),
25240 cCE("wsraw", e800040, 3, (RIWR, RIWR, RIWR_I32z),iwmmxt_wrwrwr_or_imm5),
25241 cCE("wsrawg", e800148, 3, (RIWR, RIWR, RIWG), rd_rn_rm),
25242 cCE("wsrad", ec00040, 3, (RIWR, RIWR, RIWR_I32z),iwmmxt_wrwrwr_or_imm5),
25243 cCE("wsradg", ec00148, 3, (RIWR, RIWR, RIWG), rd_rn_rm),
25244 cCE("wsrlh", e600040, 3, (RIWR, RIWR, RIWR_I32z),iwmmxt_wrwrwr_or_imm5),
25245 cCE("wsrlhg", e600148, 3, (RIWR, RIWR, RIWG), rd_rn_rm),
25246 cCE("wsrlw", ea00040, 3, (RIWR, RIWR, RIWR_I32z),iwmmxt_wrwrwr_or_imm5),
25247 cCE("wsrlwg", ea00148, 3, (RIWR, RIWR, RIWG), rd_rn_rm),
25248 cCE("wsrld", ee00040, 3, (RIWR, RIWR, RIWR_I32z),iwmmxt_wrwrwr_or_imm5),
25249 cCE("wsrldg", ee00148, 3, (RIWR, RIWR, RIWG), rd_rn_rm),
25250 cCE("wstrb", c000000, 2, (RIWR, ADDR), iwmmxt_wldstbh),
25251 cCE("wstrh", c400000, 2, (RIWR, ADDR), iwmmxt_wldstbh),
25252 cCE("wstrw", c000100, 2, (RIWR_RIWC, ADDR), iwmmxt_wldstw),
25253 cCE("wstrd", c400100, 2, (RIWR, ADDR), iwmmxt_wldstd),
25254 cCE("wsubbss", e3001a0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25255 cCE("wsubb", e0001a0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25256 cCE("wsubbus", e1001a0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25257 cCE("wsubhss", e7001a0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25258 cCE("wsubh", e4001a0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25259 cCE("wsubhus", e5001a0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25260 cCE("wsubwss", eb001a0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25261 cCE("wsubw", e8001a0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25262 cCE("wsubwus", e9001a0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25263 cCE("wunpckehub",e0000c0, 2, (RIWR, RIWR), rd_rn),
25264 cCE("wunpckehuh",e4000c0, 2, (RIWR, RIWR), rd_rn),
25265 cCE("wunpckehuw",e8000c0, 2, (RIWR, RIWR), rd_rn),
25266 cCE("wunpckehsb",e2000c0, 2, (RIWR, RIWR), rd_rn),
25267 cCE("wunpckehsh",e6000c0, 2, (RIWR, RIWR), rd_rn),
25268 cCE("wunpckehsw",ea000c0, 2, (RIWR, RIWR), rd_rn),
25269 cCE("wunpckihb", e1000c0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25270 cCE("wunpckihh", e5000c0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25271 cCE("wunpckihw", e9000c0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25272 cCE("wunpckelub",e0000e0, 2, (RIWR, RIWR), rd_rn),
25273 cCE("wunpckeluh",e4000e0, 2, (RIWR, RIWR), rd_rn),
25274 cCE("wunpckeluw",e8000e0, 2, (RIWR, RIWR), rd_rn),
25275 cCE("wunpckelsb",e2000e0, 2, (RIWR, RIWR), rd_rn),
25276 cCE("wunpckelsh",e6000e0, 2, (RIWR, RIWR), rd_rn),
25277 cCE("wunpckelsw",ea000e0, 2, (RIWR, RIWR), rd_rn),
25278 cCE("wunpckilb", e1000e0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25279 cCE("wunpckilh", e5000e0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25280 cCE("wunpckilw", e9000e0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25281 cCE("wxor", e100000, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25282 cCE("wzero", e300000, 1, (RIWR), iwmmxt_wzero),
25285 #define ARM_VARIANT & arm_cext_iwmmxt2 /* Intel Wireless MMX technology, version 2. */
25287 cCE("torvscb", e12f190, 1, (RR), iwmmxt_tandorc),
25288 cCE("torvsch", e52f190, 1, (RR), iwmmxt_tandorc),
25289 cCE("torvscw", e92f190, 1, (RR), iwmmxt_tandorc),
25290 cCE("wabsb", e2001c0, 2, (RIWR, RIWR), rd_rn),
25291 cCE("wabsh", e6001c0, 2, (RIWR, RIWR), rd_rn),
25292 cCE("wabsw", ea001c0, 2, (RIWR, RIWR), rd_rn),
25293 cCE("wabsdiffb", e1001c0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25294 cCE("wabsdiffh", e5001c0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25295 cCE("wabsdiffw", e9001c0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25296 cCE("waddbhusl", e2001a0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25297 cCE("waddbhusm", e6001a0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25298 cCE("waddhc", e600180, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25299 cCE("waddwc", ea00180, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25300 cCE("waddsubhx", ea001a0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25301 cCE("wavg4", e400000, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25302 cCE("wavg4r", e500000, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25303 cCE("wmaddsn", ee00100, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25304 cCE("wmaddsx", eb00100, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25305 cCE("wmaddun", ec00100, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25306 cCE("wmaddux", e900100, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25307 cCE("wmerge", e000080, 4, (RIWR, RIWR, RIWR, I7), iwmmxt_wmerge),
25308 cCE("wmiabb", e0000a0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25309 cCE("wmiabt", e1000a0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25310 cCE("wmiatb", e2000a0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25311 cCE("wmiatt", e3000a0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25312 cCE("wmiabbn", e4000a0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25313 cCE("wmiabtn", e5000a0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25314 cCE("wmiatbn", e6000a0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25315 cCE("wmiattn", e7000a0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25316 cCE("wmiawbb", e800120, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25317 cCE("wmiawbt", e900120, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25318 cCE("wmiawtb", ea00120, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25319 cCE("wmiawtt", eb00120, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25320 cCE("wmiawbbn", ec00120, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25321 cCE("wmiawbtn", ed00120, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25322 cCE("wmiawtbn", ee00120, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25323 cCE("wmiawttn", ef00120, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25324 cCE("wmulsmr", ef00100, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25325 cCE("wmulumr", ed00100, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25326 cCE("wmulwumr", ec000c0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25327 cCE("wmulwsmr", ee000c0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25328 cCE("wmulwum", ed000c0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25329 cCE("wmulwsm", ef000c0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25330 cCE("wmulwl", eb000c0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25331 cCE("wqmiabb", e8000a0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25332 cCE("wqmiabt", e9000a0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25333 cCE("wqmiatb", ea000a0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25334 cCE("wqmiatt", eb000a0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25335 cCE("wqmiabbn", ec000a0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25336 cCE("wqmiabtn", ed000a0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25337 cCE("wqmiatbn", ee000a0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25338 cCE("wqmiattn", ef000a0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25339 cCE("wqmulm", e100080, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25340 cCE("wqmulmr", e300080, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25341 cCE("wqmulwm", ec000e0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25342 cCE("wqmulwmr", ee000e0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25343 cCE("wsubaddhx", ed001c0, 3, (RIWR, RIWR, RIWR), rd_rn_rm),
25346 #define ARM_VARIANT & arm_cext_maverick /* Cirrus Maverick instructions. */
25348 cCE("cfldrs", c100400, 2, (RMF, ADDRGLDC), rd_cpaddr),
25349 cCE("cfldrd", c500400, 2, (RMD, ADDRGLDC), rd_cpaddr),
25350 cCE("cfldr32", c100500, 2, (RMFX, ADDRGLDC), rd_cpaddr),
25351 cCE("cfldr64", c500500, 2, (RMDX, ADDRGLDC), rd_cpaddr),
25352 cCE("cfstrs", c000400, 2, (RMF, ADDRGLDC), rd_cpaddr),
25353 cCE("cfstrd", c400400, 2, (RMD, ADDRGLDC), rd_cpaddr),
25354 cCE("cfstr32", c000500, 2, (RMFX, ADDRGLDC), rd_cpaddr),
25355 cCE("cfstr64", c400500, 2, (RMDX, ADDRGLDC), rd_cpaddr),
25356 cCE("cfmvsr", e000450, 2, (RMF, RR), rn_rd),
25357 cCE("cfmvrs", e100450, 2, (RR, RMF), rd_rn),
25358 cCE("cfmvdlr", e000410, 2, (RMD, RR), rn_rd),
25359 cCE("cfmvrdl", e100410, 2, (RR, RMD), rd_rn),
25360 cCE("cfmvdhr", e000430, 2, (RMD, RR), rn_rd),
25361 cCE("cfmvrdh", e100430, 2, (RR, RMD), rd_rn),
25362 cCE("cfmv64lr",e000510, 2, (RMDX, RR), rn_rd),
25363 cCE("cfmvr64l",e100510, 2, (RR, RMDX), rd_rn),
25364 cCE("cfmv64hr",e000530, 2, (RMDX, RR), rn_rd),
25365 cCE("cfmvr64h",e100530, 2, (RR, RMDX), rd_rn),
25366 cCE("cfmval32",e200440, 2, (RMAX, RMFX), rd_rn),
25367 cCE("cfmv32al",e100440, 2, (RMFX, RMAX), rd_rn),
25368 cCE("cfmvam32",e200460, 2, (RMAX, RMFX), rd_rn),
25369 cCE("cfmv32am",e100460, 2, (RMFX, RMAX), rd_rn),
25370 cCE("cfmvah32",e200480, 2, (RMAX, RMFX), rd_rn),
25371 cCE("cfmv32ah",e100480, 2, (RMFX, RMAX), rd_rn),
25372 cCE("cfmva32", e2004a0, 2, (RMAX, RMFX), rd_rn),
25373 cCE("cfmv32a", e1004a0, 2, (RMFX, RMAX), rd_rn),
25374 cCE("cfmva64", e2004c0, 2, (RMAX, RMDX), rd_rn),
25375 cCE("cfmv64a", e1004c0, 2, (RMDX, RMAX), rd_rn),
25376 cCE("cfmvsc32",e2004e0, 2, (RMDS, RMDX), mav_dspsc),
25377 cCE("cfmv32sc",e1004e0, 2, (RMDX, RMDS), rd),
25378 cCE("cfcpys", e000400, 2, (RMF, RMF), rd_rn),
25379 cCE("cfcpyd", e000420, 2, (RMD, RMD), rd_rn),
25380 cCE("cfcvtsd", e000460, 2, (RMD, RMF), rd_rn),
25381 cCE("cfcvtds", e000440, 2, (RMF, RMD), rd_rn),
25382 cCE("cfcvt32s",e000480, 2, (RMF, RMFX), rd_rn),
25383 cCE("cfcvt32d",e0004a0, 2, (RMD, RMFX), rd_rn),
25384 cCE("cfcvt64s",e0004c0, 2, (RMF, RMDX), rd_rn),
25385 cCE("cfcvt64d",e0004e0, 2, (RMD, RMDX), rd_rn),
25386 cCE("cfcvts32",e100580, 2, (RMFX, RMF), rd_rn),
25387 cCE("cfcvtd32",e1005a0, 2, (RMFX, RMD), rd_rn),
25388 cCE("cftruncs32",e1005c0, 2, (RMFX, RMF), rd_rn),
25389 cCE("cftruncd32",e1005e0, 2, (RMFX, RMD), rd_rn),
25390 cCE("cfrshl32",e000550, 3, (RMFX, RMFX, RR), mav_triple),
25391 cCE("cfrshl64",e000570, 3, (RMDX, RMDX, RR), mav_triple),
25392 cCE("cfsh32", e000500, 3, (RMFX, RMFX, I63s), mav_shift),
25393 cCE("cfsh64", e200500, 3, (RMDX, RMDX, I63s), mav_shift),
25394 cCE("cfcmps", e100490, 3, (RR, RMF, RMF), rd_rn_rm),
25395 cCE("cfcmpd", e1004b0, 3, (RR, RMD, RMD), rd_rn_rm),
25396 cCE("cfcmp32", e100590, 3, (RR, RMFX, RMFX), rd_rn_rm),
25397 cCE("cfcmp64", e1005b0, 3, (RR, RMDX, RMDX), rd_rn_rm),
25398 cCE("cfabss", e300400, 2, (RMF, RMF), rd_rn),
25399 cCE("cfabsd", e300420, 2, (RMD, RMD), rd_rn),
25400 cCE("cfnegs", e300440, 2, (RMF, RMF), rd_rn),
25401 cCE("cfnegd", e300460, 2, (RMD, RMD), rd_rn),
25402 cCE("cfadds", e300480, 3, (RMF, RMF, RMF), rd_rn_rm),
25403 cCE("cfaddd", e3004a0, 3, (RMD, RMD, RMD), rd_rn_rm),
25404 cCE("cfsubs", e3004c0, 3, (RMF, RMF, RMF), rd_rn_rm),
25405 cCE("cfsubd", e3004e0, 3, (RMD, RMD, RMD), rd_rn_rm),
25406 cCE("cfmuls", e100400, 3, (RMF, RMF, RMF), rd_rn_rm),
25407 cCE("cfmuld", e100420, 3, (RMD, RMD, RMD), rd_rn_rm),
25408 cCE("cfabs32", e300500, 2, (RMFX, RMFX), rd_rn),
25409 cCE("cfabs64", e300520, 2, (RMDX, RMDX), rd_rn),
25410 cCE("cfneg32", e300540, 2, (RMFX, RMFX), rd_rn),
25411 cCE("cfneg64", e300560, 2, (RMDX, RMDX), rd_rn),
25412 cCE("cfadd32", e300580, 3, (RMFX, RMFX, RMFX), rd_rn_rm),
25413 cCE("cfadd64", e3005a0, 3, (RMDX, RMDX, RMDX), rd_rn_rm),
25414 cCE("cfsub32", e3005c0, 3, (RMFX, RMFX, RMFX), rd_rn_rm),
25415 cCE("cfsub64", e3005e0, 3, (RMDX, RMDX, RMDX), rd_rn_rm),
25416 cCE("cfmul32", e100500, 3, (RMFX, RMFX, RMFX), rd_rn_rm),
25417 cCE("cfmul64", e100520, 3, (RMDX, RMDX, RMDX), rd_rn_rm),
25418 cCE("cfmac32", e100540, 3, (RMFX, RMFX, RMFX), rd_rn_rm),
25419 cCE("cfmsc32", e100560, 3, (RMFX, RMFX, RMFX), rd_rn_rm),
25420 cCE("cfmadd32",e000600, 4, (RMAX, RMFX, RMFX, RMFX), mav_quad),
25421 cCE("cfmsub32",e100600, 4, (RMAX, RMFX, RMFX, RMFX), mav_quad),
25422 cCE("cfmadda32", e200600, 4, (RMAX, RMAX, RMFX, RMFX), mav_quad),
25423 cCE("cfmsuba32", e300600, 4, (RMAX, RMAX, RMFX, RMFX), mav_quad),
25425 /* ARMv8.5-A instructions. */
25427 #define ARM_VARIANT & arm_ext_sb
25428 #undef THUMB_VARIANT
25429 #define THUMB_VARIANT & arm_ext_sb
25430 TUF("sb", 57ff070, f3bf8f70, 0, (), noargs, noargs),
25433 #define ARM_VARIANT & arm_ext_predres
25434 #undef THUMB_VARIANT
25435 #define THUMB_VARIANT & arm_ext_predres
25436 CE("cfprctx", e070f93, 1, (RRnpc), rd),
25437 CE("dvprctx", e070fb3, 1, (RRnpc), rd),
25438 CE("cpprctx", e070ff3, 1, (RRnpc), rd),
25440 /* ARMv8-M instructions. */
25442 #define ARM_VARIANT NULL
25443 #undef THUMB_VARIANT
25444 #define THUMB_VARIANT & arm_ext_v8m
25445 ToU("sg", e97fe97f, 0, (), noargs),
25446 ToC("blxns", 4784, 1, (RRnpc), t_blx),
25447 ToC("bxns", 4704, 1, (RRnpc), t_bx),
25448 ToC("tt", e840f000, 2, (RRnpc, RRnpc), tt),
25449 ToC("ttt", e840f040, 2, (RRnpc, RRnpc), tt),
25450 ToC("tta", e840f080, 2, (RRnpc, RRnpc), tt),
25451 ToC("ttat", e840f0c0, 2, (RRnpc, RRnpc), tt),
25453 /* FP for ARMv8-M Mainline. Enabled for ARMv8-M Mainline because the
25454 instructions behave as nop if no VFP is present. */
25455 #undef THUMB_VARIANT
25456 #define THUMB_VARIANT & arm_ext_v8m_main
25457 ToC("vlldm", ec300a00, 1, (RRnpc), rn),
25458 ToC("vlstm", ec200a00, 1, (RRnpc), rn),
25460 /* Armv8.1-M Mainline instructions. */
25461 #undef THUMB_VARIANT
25462 #define THUMB_VARIANT & arm_ext_v8_1m_main
25463 toU("cinc", _cinc, 3, (RRnpcsp, RR_ZR, COND), t_cond),
25464 toU("cinv", _cinv, 3, (RRnpcsp, RR_ZR, COND), t_cond),
25465 toU("cneg", _cneg, 3, (RRnpcsp, RR_ZR, COND), t_cond),
25466 toU("csel", _csel, 4, (RRnpcsp, RR_ZR, RR_ZR, COND), t_cond),
25467 toU("csetm", _csetm, 2, (RRnpcsp, COND), t_cond),
25468 toU("cset", _cset, 2, (RRnpcsp, COND), t_cond),
25469 toU("csinc", _csinc, 4, (RRnpcsp, RR_ZR, RR_ZR, COND), t_cond),
25470 toU("csinv", _csinv, 4, (RRnpcsp, RR_ZR, RR_ZR, COND), t_cond),
25471 toU("csneg", _csneg, 4, (RRnpcsp, RR_ZR, RR_ZR, COND), t_cond),
25473 toC("bf", _bf, 2, (EXPs, EXPs), t_branch_future),
25474 toU("bfcsel", _bfcsel, 4, (EXPs, EXPs, EXPs, COND), t_branch_future),
25475 toC("bfx", _bfx, 2, (EXPs, RRnpcsp), t_branch_future),
25476 toC("bfl", _bfl, 2, (EXPs, EXPs), t_branch_future),
25477 toC("bflx", _bflx, 2, (EXPs, RRnpcsp), t_branch_future),
25479 toU("dls", _dls, 2, (LR, RRnpcsp), t_loloop),
25480 toU("wls", _wls, 3, (LR, RRnpcsp, EXP), t_loloop),
25481 toU("le", _le, 2, (oLR, EXP), t_loloop),
25483 ToC("clrm", e89f0000, 1, (CLRMLST), t_clrm),
25484 ToC("vscclrm", ec9f0a00, 1, (VRSDVLST), t_vscclrm),
25486 #undef THUMB_VARIANT
25487 #define THUMB_VARIANT & mve_ext
25488 ToC("lsll", ea50010d, 3, (RRe, RRo, RRnpcsp_I32), mve_scalar_shift),
25489 ToC("lsrl", ea50011f, 3, (RRe, RRo, I32), mve_scalar_shift),
25490 ToC("asrl", ea50012d, 3, (RRe, RRo, RRnpcsp_I32), mve_scalar_shift),
25491 ToC("uqrshll", ea51010d, 4, (RRe, RRo, I48_I64, RRnpcsp), mve_scalar_shift1),
25492 ToC("sqrshrl", ea51012d, 4, (RRe, RRo, I48_I64, RRnpcsp), mve_scalar_shift1),
25493 ToC("uqshll", ea51010f, 3, (RRe, RRo, I32), mve_scalar_shift),
25494 ToC("urshrl", ea51011f, 3, (RRe, RRo, I32), mve_scalar_shift),
25495 ToC("srshrl", ea51012f, 3, (RRe, RRo, I32), mve_scalar_shift),
25496 ToC("sqshll", ea51013f, 3, (RRe, RRo, I32), mve_scalar_shift),
25497 ToC("uqrshl", ea500f0d, 2, (RRnpcsp, RRnpcsp), mve_scalar_shift),
25498 ToC("sqrshr", ea500f2d, 2, (RRnpcsp, RRnpcsp), mve_scalar_shift),
25499 ToC("uqshl", ea500f0f, 2, (RRnpcsp, I32), mve_scalar_shift),
25500 ToC("urshr", ea500f1f, 2, (RRnpcsp, I32), mve_scalar_shift),
25501 ToC("srshr", ea500f2f, 2, (RRnpcsp, I32), mve_scalar_shift),
25502 ToC("sqshl", ea500f3f, 2, (RRnpcsp, I32), mve_scalar_shift),
25504 ToC("vpt", ee410f00, 3, (COND, RMQ, RMQRZ), mve_vpt),
25505 ToC("vptt", ee018f00, 3, (COND, RMQ, RMQRZ), mve_vpt),
25506 ToC("vpte", ee418f00, 3, (COND, RMQ, RMQRZ), mve_vpt),
25507 ToC("vpttt", ee014f00, 3, (COND, RMQ, RMQRZ), mve_vpt),
25508 ToC("vptte", ee01cf00, 3, (COND, RMQ, RMQRZ), mve_vpt),
25509 ToC("vptet", ee41cf00, 3, (COND, RMQ, RMQRZ), mve_vpt),
25510 ToC("vptee", ee414f00, 3, (COND, RMQ, RMQRZ), mve_vpt),
25511 ToC("vptttt", ee012f00, 3, (COND, RMQ, RMQRZ), mve_vpt),
25512 ToC("vpttte", ee016f00, 3, (COND, RMQ, RMQRZ), mve_vpt),
25513 ToC("vpttet", ee01ef00, 3, (COND, RMQ, RMQRZ), mve_vpt),
25514 ToC("vpttee", ee01af00, 3, (COND, RMQ, RMQRZ), mve_vpt),
25515 ToC("vptett", ee41af00, 3, (COND, RMQ, RMQRZ), mve_vpt),
25516 ToC("vptete", ee41ef00, 3, (COND, RMQ, RMQRZ), mve_vpt),
25517 ToC("vpteet", ee416f00, 3, (COND, RMQ, RMQRZ), mve_vpt),
25518 ToC("vpteee", ee412f00, 3, (COND, RMQ, RMQRZ), mve_vpt),
25520 ToC("vpst", fe710f4d, 0, (), mve_vpt),
25521 ToC("vpstt", fe318f4d, 0, (), mve_vpt),
25522 ToC("vpste", fe718f4d, 0, (), mve_vpt),
25523 ToC("vpsttt", fe314f4d, 0, (), mve_vpt),
25524 ToC("vpstte", fe31cf4d, 0, (), mve_vpt),
25525 ToC("vpstet", fe71cf4d, 0, (), mve_vpt),
25526 ToC("vpstee", fe714f4d, 0, (), mve_vpt),
25527 ToC("vpstttt", fe312f4d, 0, (), mve_vpt),
25528 ToC("vpsttte", fe316f4d, 0, (), mve_vpt),
25529 ToC("vpsttet", fe31ef4d, 0, (), mve_vpt),
25530 ToC("vpsttee", fe31af4d, 0, (), mve_vpt),
25531 ToC("vpstett", fe71af4d, 0, (), mve_vpt),
25532 ToC("vpstete", fe71ef4d, 0, (), mve_vpt),
25533 ToC("vpsteet", fe716f4d, 0, (), mve_vpt),
25534 ToC("vpsteee", fe712f4d, 0, (), mve_vpt),
25536 /* MVE and MVE FP only. */
25537 mToC("vhcadd", ee000f00, 4, (RMQ, RMQ, RMQ, EXPi), mve_vhcadd),
25538 mCEF(vctp, _vctp, 1, (RRnpc), mve_vctp),
25539 mCEF(vadc, _vadc, 3, (RMQ, RMQ, RMQ), mve_vadc),
25540 mCEF(vadci, _vadci, 3, (RMQ, RMQ, RMQ), mve_vadc),
25541 mToC("vsbc", fe300f00, 3, (RMQ, RMQ, RMQ), mve_vsbc),
25542 mToC("vsbci", fe301f00, 3, (RMQ, RMQ, RMQ), mve_vsbc),
25543 mCEF(vmullb, _vmullb, 3, (RMQ, RMQ, RMQ), mve_vmull),
25544 mCEF(vabav, _vabav, 3, (RRnpcsp, RMQ, RMQ), mve_vabav),
25545 mCEF(vmladav, _vmladav, 3, (RRe, RMQ, RMQ), mve_vmladav),
25546 mCEF(vmladava, _vmladava, 3, (RRe, RMQ, RMQ), mve_vmladav),
25547 mCEF(vmladavx, _vmladavx, 3, (RRe, RMQ, RMQ), mve_vmladav),
25548 mCEF(vmladavax, _vmladavax, 3, (RRe, RMQ, RMQ), mve_vmladav),
25549 mCEF(vmlav, _vmladav, 3, (RRe, RMQ, RMQ), mve_vmladav),
25550 mCEF(vmlava, _vmladava, 3, (RRe, RMQ, RMQ), mve_vmladav),
25551 mCEF(vmlsdav, _vmlsdav, 3, (RRe, RMQ, RMQ), mve_vmladav),
25552 mCEF(vmlsdava, _vmlsdava, 3, (RRe, RMQ, RMQ), mve_vmladav),
25553 mCEF(vmlsdavx, _vmlsdavx, 3, (RRe, RMQ, RMQ), mve_vmladav),
25554 mCEF(vmlsdavax, _vmlsdavax, 3, (RRe, RMQ, RMQ), mve_vmladav),
25556 mCEF(vst20, _vst20, 2, (MSTRLST2, ADDRMVE), mve_vst_vld),
25557 mCEF(vst21, _vst21, 2, (MSTRLST2, ADDRMVE), mve_vst_vld),
25558 mCEF(vst40, _vst40, 2, (MSTRLST4, ADDRMVE), mve_vst_vld),
25559 mCEF(vst41, _vst41, 2, (MSTRLST4, ADDRMVE), mve_vst_vld),
25560 mCEF(vst42, _vst42, 2, (MSTRLST4, ADDRMVE), mve_vst_vld),
25561 mCEF(vst43, _vst43, 2, (MSTRLST4, ADDRMVE), mve_vst_vld),
25562 mCEF(vld20, _vld20, 2, (MSTRLST2, ADDRMVE), mve_vst_vld),
25563 mCEF(vld21, _vld21, 2, (MSTRLST2, ADDRMVE), mve_vst_vld),
25564 mCEF(vld40, _vld40, 2, (MSTRLST4, ADDRMVE), mve_vst_vld),
25565 mCEF(vld41, _vld41, 2, (MSTRLST4, ADDRMVE), mve_vst_vld),
25566 mCEF(vld42, _vld42, 2, (MSTRLST4, ADDRMVE), mve_vst_vld),
25567 mCEF(vld43, _vld43, 2, (MSTRLST4, ADDRMVE), mve_vst_vld),
25568 mCEF(vstrb, _vstrb, 2, (RMQ, ADDRMVE), mve_vstr_vldr),
25569 mCEF(vstrh, _vstrh, 2, (RMQ, ADDRMVE), mve_vstr_vldr),
25570 mCEF(vstrw, _vstrw, 2, (RMQ, ADDRMVE), mve_vstr_vldr),
25571 mCEF(vstrd, _vstrd, 2, (RMQ, ADDRMVE), mve_vstr_vldr),
25572 mCEF(vldrb, _vldrb, 2, (RMQ, ADDRMVE), mve_vstr_vldr),
25573 mCEF(vldrh, _vldrh, 2, (RMQ, ADDRMVE), mve_vstr_vldr),
25574 mCEF(vldrw, _vldrw, 2, (RMQ, ADDRMVE), mve_vstr_vldr),
25575 mCEF(vldrd, _vldrd, 2, (RMQ, ADDRMVE), mve_vstr_vldr),
25577 mCEF(vmovnt, _vmovnt, 2, (RMQ, RMQ), mve_movn),
25578 mCEF(vmovnb, _vmovnb, 2, (RMQ, RMQ), mve_movn),
25579 mCEF(vbrsr, _vbrsr, 3, (RMQ, RMQ, RR), mve_vbrsr),
25580 mCEF(vaddlv, _vaddlv, 3, (RRe, RRo, RMQ), mve_vaddlv),
25581 mCEF(vaddlva, _vaddlva, 3, (RRe, RRo, RMQ), mve_vaddlv),
25582 mCEF(vaddv, _vaddv, 2, (RRe, RMQ), mve_vaddv),
25583 mCEF(vaddva, _vaddva, 2, (RRe, RMQ), mve_vaddv),
25584 mCEF(vddup, _vddup, 3, (RMQ, RRe, EXPi), mve_viddup),
25585 mCEF(vdwdup, _vdwdup, 4, (RMQ, RRe, RR, EXPi), mve_viddup),
25586 mCEF(vidup, _vidup, 3, (RMQ, RRe, EXPi), mve_viddup),
25587 mCEF(viwdup, _viwdup, 4, (RMQ, RRe, RR, EXPi), mve_viddup),
25588 mToC("vmaxa", ee330e81, 2, (RMQ, RMQ), mve_vmaxa_vmina),
25589 mToC("vmina", ee331e81, 2, (RMQ, RMQ), mve_vmaxa_vmina),
25590 mCEF(vmaxv, _vmaxv, 2, (RR, RMQ), mve_vmaxv),
25591 mCEF(vmaxav, _vmaxav, 2, (RR, RMQ), mve_vmaxv),
25592 mCEF(vminv, _vminv, 2, (RR, RMQ), mve_vmaxv),
25593 mCEF(vminav, _vminav, 2, (RR, RMQ), mve_vmaxv),
25595 mCEF(vmlaldav, _vmlaldav, 4, (RRe, RRo, RMQ, RMQ), mve_vmlaldav),
25596 mCEF(vmlaldava, _vmlaldava, 4, (RRe, RRo, RMQ, RMQ), mve_vmlaldav),
25597 mCEF(vmlaldavx, _vmlaldavx, 4, (RRe, RRo, RMQ, RMQ), mve_vmlaldav),
25598 mCEF(vmlaldavax, _vmlaldavax, 4, (RRe, RRo, RMQ, RMQ), mve_vmlaldav),
25599 mCEF(vmlalv, _vmlaldav, 4, (RRe, RRo, RMQ, RMQ), mve_vmlaldav),
25600 mCEF(vmlalva, _vmlaldava, 4, (RRe, RRo, RMQ, RMQ), mve_vmlaldav),
25601 mCEF(vmlsldav, _vmlsldav, 4, (RRe, RRo, RMQ, RMQ), mve_vmlaldav),
25602 mCEF(vmlsldava, _vmlsldava, 4, (RRe, RRo, RMQ, RMQ), mve_vmlaldav),
25603 mCEF(vmlsldavx, _vmlsldavx, 4, (RRe, RRo, RMQ, RMQ), mve_vmlaldav),
25604 mCEF(vmlsldavax, _vmlsldavax, 4, (RRe, RRo, RMQ, RMQ), mve_vmlaldav),
25605 mToC("vrmlaldavh", ee800f00, 4, (RRe, RR, RMQ, RMQ), mve_vrmlaldavh),
25606 mToC("vrmlaldavha",ee800f20, 4, (RRe, RR, RMQ, RMQ), mve_vrmlaldavh),
25607 mCEF(vrmlaldavhx, _vrmlaldavhx, 4, (RRe, RR, RMQ, RMQ), mve_vrmlaldavh),
25608 mCEF(vrmlaldavhax, _vrmlaldavhax, 4, (RRe, RR, RMQ, RMQ), mve_vrmlaldavh),
25609 mToC("vrmlalvh", ee800f00, 4, (RRe, RR, RMQ, RMQ), mve_vrmlaldavh),
25610 mToC("vrmlalvha", ee800f20, 4, (RRe, RR, RMQ, RMQ), mve_vrmlaldavh),
25611 mCEF(vrmlsldavh, _vrmlsldavh, 4, (RRe, RR, RMQ, RMQ), mve_vrmlaldavh),
25612 mCEF(vrmlsldavha, _vrmlsldavha, 4, (RRe, RR, RMQ, RMQ), mve_vrmlaldavh),
25613 mCEF(vrmlsldavhx, _vrmlsldavhx, 4, (RRe, RR, RMQ, RMQ), mve_vrmlaldavh),
25614 mCEF(vrmlsldavhax, _vrmlsldavhax, 4, (RRe, RR, RMQ, RMQ), mve_vrmlaldavh),
25616 mToC("vmlas", ee011e40, 3, (RMQ, RMQ, RR), mve_vmlas),
25617 mToC("vmulh", ee010e01, 3, (RMQ, RMQ, RMQ), mve_vmulh),
25618 mToC("vrmulh", ee011e01, 3, (RMQ, RMQ, RMQ), mve_vmulh),
25619 mToC("vpnot", fe310f4d, 0, (), mve_vpnot),
25620 mToC("vpsel", fe310f01, 3, (RMQ, RMQ, RMQ), mve_vpsel),
25622 mToC("vqdmladh", ee000e00, 3, (RMQ, RMQ, RMQ), mve_vqdmladh),
25623 mToC("vqdmladhx", ee001e00, 3, (RMQ, RMQ, RMQ), mve_vqdmladh),
25624 mToC("vqrdmladh", ee000e01, 3, (RMQ, RMQ, RMQ), mve_vqdmladh),
25625 mToC("vqrdmladhx",ee001e01, 3, (RMQ, RMQ, RMQ), mve_vqdmladh),
25626 mToC("vqdmlsdh", fe000e00, 3, (RMQ, RMQ, RMQ), mve_vqdmladh),
25627 mToC("vqdmlsdhx", fe001e00, 3, (RMQ, RMQ, RMQ), mve_vqdmladh),
25628 mToC("vqrdmlsdh", fe000e01, 3, (RMQ, RMQ, RMQ), mve_vqdmladh),
25629 mToC("vqrdmlsdhx",fe001e01, 3, (RMQ, RMQ, RMQ), mve_vqdmladh),
25630 mToC("vqdmlah", ee000e60, 3, (RMQ, RMQ, RR), mve_vqdmlah),
25631 mToC("vqdmlash", ee001e60, 3, (RMQ, RMQ, RR), mve_vqdmlah),
25632 mToC("vqrdmlash", ee001e40, 3, (RMQ, RMQ, RR), mve_vqdmlah),
25633 mToC("vqdmullt", ee301f00, 3, (RMQ, RMQ, RMQRR), mve_vqdmull),
25634 mToC("vqdmullb", ee300f00, 3, (RMQ, RMQ, RMQRR), mve_vqdmull),
25635 mCEF(vqmovnt, _vqmovnt, 2, (RMQ, RMQ), mve_vqmovn),
25636 mCEF(vqmovnb, _vqmovnb, 2, (RMQ, RMQ), mve_vqmovn),
25637 mCEF(vqmovunt, _vqmovunt, 2, (RMQ, RMQ), mve_vqmovn),
25638 mCEF(vqmovunb, _vqmovunb, 2, (RMQ, RMQ), mve_vqmovn),
25640 mCEF(vshrnt, _vshrnt, 3, (RMQ, RMQ, I32z), mve_vshrn),
25641 mCEF(vshrnb, _vshrnb, 3, (RMQ, RMQ, I32z), mve_vshrn),
25642 mCEF(vrshrnt, _vrshrnt, 3, (RMQ, RMQ, I32z), mve_vshrn),
25643 mCEF(vrshrnb, _vrshrnb, 3, (RMQ, RMQ, I32z), mve_vshrn),
25644 mCEF(vqshrnt, _vqrshrnt, 3, (RMQ, RMQ, I32z), mve_vshrn),
25645 mCEF(vqshrnb, _vqrshrnb, 3, (RMQ, RMQ, I32z), mve_vshrn),
25646 mCEF(vqshrunt, _vqrshrunt, 3, (RMQ, RMQ, I32z), mve_vshrn),
25647 mCEF(vqshrunb, _vqrshrunb, 3, (RMQ, RMQ, I32z), mve_vshrn),
25648 mCEF(vqrshrnt, _vqrshrnt, 3, (RMQ, RMQ, I32z), mve_vshrn),
25649 mCEF(vqrshrnb, _vqrshrnb, 3, (RMQ, RMQ, I32z), mve_vshrn),
25650 mCEF(vqrshrunt, _vqrshrunt, 3, (RMQ, RMQ, I32z), mve_vshrn),
25651 mCEF(vqrshrunb, _vqrshrunb, 3, (RMQ, RMQ, I32z), mve_vshrn),
25653 mToC("vshlc", eea00fc0, 3, (RMQ, RR, I32z), mve_vshlc),
25654 mToC("vshllt", ee201e00, 3, (RMQ, RMQ, I32), mve_vshll),
25655 mToC("vshllb", ee200e00, 3, (RMQ, RMQ, I32), mve_vshll),
25657 toU("dlstp", _dlstp, 2, (LR, RR), t_loloop),
25658 toU("wlstp", _wlstp, 3, (LR, RR, EXP), t_loloop),
25659 toU("letp", _letp, 2, (LR, EXP), t_loloop),
25660 toU("lctp", _lctp, 0, (), t_loloop),
25662 #undef THUMB_VARIANT
25663 #define THUMB_VARIANT & mve_fp_ext
25664 mToC("vcmul", ee300e00, 4, (RMQ, RMQ, RMQ, EXPi), mve_vcmul),
25665 mToC("vfmas", ee311e40, 3, (RMQ, RMQ, RR), mve_vfmas),
25666 mToC("vmaxnma", ee3f0e81, 2, (RMQ, RMQ), mve_vmaxnma_vminnma),
25667 mToC("vminnma", ee3f1e81, 2, (RMQ, RMQ), mve_vmaxnma_vminnma),
25668 mToC("vmaxnmv", eeee0f00, 2, (RR, RMQ), mve_vmaxnmv),
25669 mToC("vmaxnmav",eeec0f00, 2, (RR, RMQ), mve_vmaxnmv),
25670 mToC("vminnmv", eeee0f80, 2, (RR, RMQ), mve_vmaxnmv),
25671 mToC("vminnmav",eeec0f80, 2, (RR, RMQ), mve_vmaxnmv),
25674 #define ARM_VARIANT & fpu_vfp_ext_v1
25675 #undef THUMB_VARIANT
25676 #define THUMB_VARIANT & arm_ext_v6t2
25677 mnCEF(vmla, _vmla, 3, (RNSDQMQ, oRNSDQMQ, RNSDQ_RNSC_MQ_RR), neon_mac_maybe_scalar),
25678 mnCEF(vmul, _vmul, 3, (RNSDQMQ, oRNSDQMQ, RNSDQ_RNSC_MQ_RR), neon_mul),
25680 mcCE(fcpyd, eb00b40, 2, (RVD, RVD), vfp_dp_rd_rm),
25683 #define ARM_VARIANT & fpu_vfp_ext_v1xd
25685 MNCE(vmov, 0, 1, (VMOV), neon_mov),
25686 mcCE(fmrs, e100a10, 2, (RR, RVS), vfp_reg_from_sp),
25687 mcCE(fmsr, e000a10, 2, (RVS, RR), vfp_sp_from_reg),
25688 mcCE(fcpys, eb00a40, 2, (RVS, RVS), vfp_sp_monadic),
25690 mCEF(vmullt, _vmullt, 3, (RNSDQMQ, oRNSDQMQ, RNSDQ_RNSC_MQ), mve_vmull),
25691 mnCEF(vadd, _vadd, 3, (RNSDQMQ, oRNSDQMQ, RNSDQMQR), neon_addsub_if_i),
25692 mnCEF(vsub, _vsub, 3, (RNSDQMQ, oRNSDQMQ, RNSDQMQR), neon_addsub_if_i),
25694 MNCEF(vabs, 1b10300, 2, (RNSDQMQ, RNSDQMQ), neon_abs_neg),
25695 MNCEF(vneg, 1b10380, 2, (RNSDQMQ, RNSDQMQ), neon_abs_neg),
25697 mCEF(vmovlt, _vmovlt, 1, (VMOV), mve_movl),
25698 mCEF(vmovlb, _vmovlb, 1, (VMOV), mve_movl),
25700 mnCE(vcmp, _vcmp, 3, (RVSD_COND, RSVDMQ_FI0, oRMQRZ), vfp_nsyn_cmp),
25701 mnCE(vcmpe, _vcmpe, 3, (RVSD_COND, RSVDMQ_FI0, oRMQRZ), vfp_nsyn_cmp),
25704 #define ARM_VARIANT & fpu_vfp_ext_v2
25706 mcCE(fmsrr, c400a10, 3, (VRSLST, RR, RR), vfp_sp2_from_reg2),
25707 mcCE(fmrrs, c500a10, 3, (RR, RR, VRSLST), vfp_reg2_from_sp2),
25708 mcCE(fmdrr, c400b10, 3, (RVD, RR, RR), vfp_dp_rm_rd_rn),
25709 mcCE(fmrrd, c500b10, 3, (RR, RR, RVD), vfp_dp_rd_rn_rm),
25712 #define ARM_VARIANT & fpu_vfp_ext_armv8xd
25713 mnUF(vcvta, _vcvta, 2, (RNSDQMQ, oRNSDQMQ), neon_cvta),
25714 mnUF(vcvtp, _vcvta, 2, (RNSDQMQ, oRNSDQMQ), neon_cvtp),
25715 mnUF(vcvtn, _vcvta, 3, (RNSDQMQ, oRNSDQMQ, oI32z), neon_cvtn),
25716 mnUF(vcvtm, _vcvta, 2, (RNSDQMQ, oRNSDQMQ), neon_cvtm),
25717 mnUF(vmaxnm, _vmaxnm, 3, (RNSDQMQ, oRNSDQMQ, RNSDQMQ), vmaxnm),
25718 mnUF(vminnm, _vminnm, 3, (RNSDQMQ, oRNSDQMQ, RNSDQMQ), vmaxnm),
25721 #define ARM_VARIANT & fpu_neon_ext_v1
25722 mnUF(vabd, _vabd, 3, (RNDQMQ, oRNDQMQ, RNDQMQ), neon_dyadic_if_su),
25723 mnUF(vabdl, _vabdl, 3, (RNQMQ, RNDMQ, RNDMQ), neon_dyadic_long),
25724 mnUF(vaddl, _vaddl, 3, (RNQMQ, RNDMQ, RNDMQR), neon_dyadic_long),
25725 mnUF(vsubl, _vsubl, 3, (RNQMQ, RNDMQ, RNDMQR), neon_dyadic_long),
25726 mnUF(vand, _vand, 3, (RNDQMQ, oRNDQMQ, RNDQMQ_Ibig), neon_logic),
25727 mnUF(vbic, _vbic, 3, (RNDQMQ, oRNDQMQ, RNDQMQ_Ibig), neon_logic),
25728 mnUF(vorr, _vorr, 3, (RNDQMQ, oRNDQMQ, RNDQMQ_Ibig), neon_logic),
25729 mnUF(vorn, _vorn, 3, (RNDQMQ, oRNDQMQ, RNDQMQ_Ibig), neon_logic),
25730 mnUF(veor, _veor, 3, (RNDQMQ, oRNDQMQ, RNDQMQ), neon_logic),
25731 MNUF(vcls, 1b00400, 2, (RNDQMQ, RNDQMQ), neon_cls),
25732 MNUF(vclz, 1b00480, 2, (RNDQMQ, RNDQMQ), neon_clz),
25733 mnCE(vdup, _vdup, 2, (RNDQMQ, RR_RNSC), neon_dup),
25734 MNUF(vhadd, 00000000, 3, (RNDQMQ, oRNDQMQ, RNDQMQR), neon_dyadic_i_su),
25735 MNUF(vrhadd, 00000100, 3, (RNDQMQ, oRNDQMQ, RNDQMQ), neon_dyadic_i_su),
25736 MNUF(vhsub, 00000200, 3, (RNDQMQ, oRNDQMQ, RNDQMQR), neon_dyadic_i_su),
25737 mnUF(vmin, _vmin, 3, (RNDQMQ, oRNDQMQ, RNDQMQ), neon_dyadic_if_su),
25738 mnUF(vmax, _vmax, 3, (RNDQMQ, oRNDQMQ, RNDQMQ), neon_dyadic_if_su),
25739 MNUF(vqadd, 0000010, 3, (RNDQMQ, oRNDQMQ, RNDQMQR), neon_dyadic_i64_su),
25740 MNUF(vqsub, 0000210, 3, (RNDQMQ, oRNDQMQ, RNDQMQR), neon_dyadic_i64_su),
25741 mnUF(vmvn, _vmvn, 2, (RNDQMQ, RNDQMQ_Ibig), neon_mvn),
25742 MNUF(vqabs, 1b00700, 2, (RNDQMQ, RNDQMQ), neon_sat_abs_neg),
25743 MNUF(vqneg, 1b00780, 2, (RNDQMQ, RNDQMQ), neon_sat_abs_neg),
25744 mnUF(vqrdmlah, _vqrdmlah,3, (RNDQMQ, oRNDQMQ, RNDQ_RNSC_RR), neon_qrdmlah),
25745 mnUF(vqdmulh, _vqdmulh, 3, (RNDQMQ, oRNDQMQ, RNDQMQ_RNSC_RR), neon_qdmulh),
25746 mnUF(vqrdmulh, _vqrdmulh,3, (RNDQMQ, oRNDQMQ, RNDQMQ_RNSC_RR), neon_qdmulh),
25747 MNUF(vqrshl, 0000510, 3, (RNDQMQ, oRNDQMQ, RNDQMQR), neon_rshl),
25748 MNUF(vrshl, 0000500, 3, (RNDQMQ, oRNDQMQ, RNDQMQR), neon_rshl),
25749 MNUF(vshr, 0800010, 3, (RNDQMQ, oRNDQMQ, I64z), neon_rshift_round_imm),
25750 MNUF(vrshr, 0800210, 3, (RNDQMQ, oRNDQMQ, I64z), neon_rshift_round_imm),
25751 MNUF(vsli, 1800510, 3, (RNDQMQ, oRNDQMQ, I63), neon_sli),
25752 MNUF(vsri, 1800410, 3, (RNDQMQ, oRNDQMQ, I64z), neon_sri),
25753 MNUF(vrev64, 1b00000, 2, (RNDQMQ, RNDQMQ), neon_rev),
25754 MNUF(vrev32, 1b00080, 2, (RNDQMQ, RNDQMQ), neon_rev),
25755 MNUF(vrev16, 1b00100, 2, (RNDQMQ, RNDQMQ), neon_rev),
25756 mnUF(vshl, _vshl, 3, (RNDQMQ, oRNDQMQ, RNDQMQ_I63b_RR), neon_shl),
25757 mnUF(vqshl, _vqshl, 3, (RNDQMQ, oRNDQMQ, RNDQMQ_I63b_RR), neon_qshl),
25758 MNUF(vqshlu, 1800610, 3, (RNDQMQ, oRNDQMQ, I63), neon_qshlu_imm),
25761 #define ARM_VARIANT & arm_ext_v8_3
25762 #undef THUMB_VARIANT
25763 #define THUMB_VARIANT & arm_ext_v6t2_v8m
25764 MNUF (vcadd, 0, 4, (RNDQMQ, RNDQMQ, RNDQMQ, EXPi), vcadd),
25765 MNUF (vcmla, 0, 4, (RNDQMQ, RNDQMQ, RNDQMQ_RNSC, EXPi), vcmla),
25768 #undef THUMB_VARIANT
25800 /* MD interface: bits in the object file. */
25802 /* Turn an integer of n bytes (in val) into a stream of bytes appropriate
25803 for use in the a.out file, and stores them in the array pointed to by buf.
25804 This knows about the endian-ness of the target machine and does
25805 THE RIGHT THING, whatever it is. Possible values for n are 1 (byte)
25806 2 (short) and 4 (long) Floating numbers are put out as a series of
25807 LITTLENUMS (shorts, here at least). */
25810 md_number_to_chars (char * buf, valueT val, int n)
25812 if (target_big_endian)
25813 number_to_chars_bigendian (buf, val, n);
25815 number_to_chars_littleendian (buf, val, n);
25819 md_chars_to_number (char * buf, int n)
25822 unsigned char * where = (unsigned char *) buf;
25824 if (target_big_endian)
25829 result |= (*where++ & 255);
25837 result |= (where[n] & 255);
25844 /* MD interface: Sections. */
25846 /* Calculate the maximum variable size (i.e., excluding fr_fix)
25847 that an rs_machine_dependent frag may reach. */
25850 arm_frag_max_var (fragS *fragp)
25852 /* We only use rs_machine_dependent for variable-size Thumb instructions,
25853 which are either THUMB_SIZE (2) or INSN_SIZE (4).
25855 Note that we generate relaxable instructions even for cases that don't
25856 really need it, like an immediate that's a trivial constant. So we're
25857 overestimating the instruction size for some of those cases. Rather
25858 than putting more intelligence here, it would probably be better to
25859 avoid generating a relaxation frag in the first place when it can be
25860 determined up front that a short instruction will suffice. */
25862 gas_assert (fragp->fr_type == rs_machine_dependent);
25866 /* Estimate the size of a frag before relaxing. Assume everything fits in
25870 md_estimate_size_before_relax (fragS * fragp,
25871 segT segtype ATTRIBUTE_UNUSED)
25877 /* Convert a machine dependent frag. */
25880 md_convert_frag (bfd *abfd, segT asec ATTRIBUTE_UNUSED, fragS *fragp)
25882 unsigned long insn;
25883 unsigned long old_op;
25891 buf = fragp->fr_literal + fragp->fr_fix;
25893 old_op = bfd_get_16(abfd, buf);
25894 if (fragp->fr_symbol)
25896 exp.X_op = O_symbol;
25897 exp.X_add_symbol = fragp->fr_symbol;
25901 exp.X_op = O_constant;
25903 exp.X_add_number = fragp->fr_offset;
25904 opcode = fragp->fr_subtype;
25907 case T_MNEM_ldr_pc:
25908 case T_MNEM_ldr_pc2:
25909 case T_MNEM_ldr_sp:
25910 case T_MNEM_str_sp:
25917 if (fragp->fr_var == 4)
25919 insn = THUMB_OP32 (opcode);
25920 if ((old_op >> 12) == 4 || (old_op >> 12) == 9)
25922 insn |= (old_op & 0x700) << 4;
25926 insn |= (old_op & 7) << 12;
25927 insn |= (old_op & 0x38) << 13;
25929 insn |= 0x00000c00;
25930 put_thumb32_insn (buf, insn);
25931 reloc_type = BFD_RELOC_ARM_T32_OFFSET_IMM;
25935 reloc_type = BFD_RELOC_ARM_THUMB_OFFSET;
25937 pc_rel = (opcode == T_MNEM_ldr_pc2);
25940 if (fragp->fr_var == 4)
25942 insn = THUMB_OP32 (opcode);
25943 insn |= (old_op & 0xf0) << 4;
25944 put_thumb32_insn (buf, insn);
25945 reloc_type = BFD_RELOC_ARM_T32_ADD_PC12;
25949 reloc_type = BFD_RELOC_ARM_THUMB_ADD;
25950 exp.X_add_number -= 4;
25958 if (fragp->fr_var == 4)
25960 int r0off = (opcode == T_MNEM_mov
25961 || opcode == T_MNEM_movs) ? 0 : 8;
25962 insn = THUMB_OP32 (opcode);
25963 insn = (insn & 0xe1ffffff) | 0x10000000;
25964 insn |= (old_op & 0x700) << r0off;
25965 put_thumb32_insn (buf, insn);
25966 reloc_type = BFD_RELOC_ARM_T32_IMMEDIATE;
25970 reloc_type = BFD_RELOC_ARM_THUMB_IMM;
25975 if (fragp->fr_var == 4)
25977 insn = THUMB_OP32(opcode);
25978 put_thumb32_insn (buf, insn);
25979 reloc_type = BFD_RELOC_THUMB_PCREL_BRANCH25;
25982 reloc_type = BFD_RELOC_THUMB_PCREL_BRANCH12;
25986 if (fragp->fr_var == 4)
25988 insn = THUMB_OP32(opcode);
25989 insn |= (old_op & 0xf00) << 14;
25990 put_thumb32_insn (buf, insn);
25991 reloc_type = BFD_RELOC_THUMB_PCREL_BRANCH20;
25994 reloc_type = BFD_RELOC_THUMB_PCREL_BRANCH9;
25997 case T_MNEM_add_sp:
25998 case T_MNEM_add_pc:
25999 case T_MNEM_inc_sp:
26000 case T_MNEM_dec_sp:
26001 if (fragp->fr_var == 4)
26003 /* ??? Choose between add and addw. */
26004 insn = THUMB_OP32 (opcode);
26005 insn |= (old_op & 0xf0) << 4;
26006 put_thumb32_insn (buf, insn);
26007 if (opcode == T_MNEM_add_pc)
26008 reloc_type = BFD_RELOC_ARM_T32_IMM12;
26010 reloc_type = BFD_RELOC_ARM_T32_ADD_IMM;
26013 reloc_type = BFD_RELOC_ARM_THUMB_ADD;
26021 if (fragp->fr_var == 4)
26023 insn = THUMB_OP32 (opcode);
26024 insn |= (old_op & 0xf0) << 4;
26025 insn |= (old_op & 0xf) << 16;
26026 put_thumb32_insn (buf, insn);
26027 if (insn & (1 << 20))
26028 reloc_type = BFD_RELOC_ARM_T32_ADD_IMM;
26030 reloc_type = BFD_RELOC_ARM_T32_IMMEDIATE;
26033 reloc_type = BFD_RELOC_ARM_THUMB_ADD;
26039 fixp = fix_new_exp (fragp, fragp->fr_fix, fragp->fr_var, &exp, pc_rel,
26040 (enum bfd_reloc_code_real) reloc_type);
26041 fixp->fx_file = fragp->fr_file;
26042 fixp->fx_line = fragp->fr_line;
26043 fragp->fr_fix += fragp->fr_var;
26045 /* Set whether we use thumb-2 ISA based on final relaxation results. */
26046 if (thumb_mode && fragp->fr_var == 4 && no_cpu_selected ()
26047 && !ARM_CPU_HAS_FEATURE (thumb_arch_used, arm_arch_t2))
26048 ARM_MERGE_FEATURE_SETS (arm_arch_used, thumb_arch_used, arm_ext_v6t2);
26051 /* Return the size of a relaxable immediate operand instruction.
26052 SHIFT and SIZE specify the form of the allowable immediate. */
26054 relax_immediate (fragS *fragp, int size, int shift)
26060 /* ??? Should be able to do better than this. */
26061 if (fragp->fr_symbol)
26064 low = (1 << shift) - 1;
26065 mask = (1 << (shift + size)) - (1 << shift);
26066 offset = fragp->fr_offset;
26067 /* Force misaligned offsets to 32-bit variant. */
26070 if (offset & ~mask)
26075 /* Get the address of a symbol during relaxation. */
26077 relaxed_symbol_addr (fragS *fragp, long stretch)
26083 sym = fragp->fr_symbol;
26084 sym_frag = symbol_get_frag (sym);
26085 know (S_GET_SEGMENT (sym) != absolute_section
26086 || sym_frag == &zero_address_frag);
26087 addr = S_GET_VALUE (sym) + fragp->fr_offset;
26089 /* If frag has yet to be reached on this pass, assume it will
26090 move by STRETCH just as we did. If this is not so, it will
26091 be because some frag between grows, and that will force
26095 && sym_frag->relax_marker != fragp->relax_marker)
26099 /* Adjust stretch for any alignment frag. Note that if have
26100 been expanding the earlier code, the symbol may be
26101 defined in what appears to be an earlier frag. FIXME:
26102 This doesn't handle the fr_subtype field, which specifies
26103 a maximum number of bytes to skip when doing an
26105 for (f = fragp; f != NULL && f != sym_frag; f = f->fr_next)
26107 if (f->fr_type == rs_align || f->fr_type == rs_align_code)
26110 stretch = - ((- stretch)
26111 & ~ ((1 << (int) f->fr_offset) - 1));
26113 stretch &= ~ ((1 << (int) f->fr_offset) - 1);
26125 /* Return the size of a relaxable adr pseudo-instruction or PC-relative
26128 relax_adr (fragS *fragp, asection *sec, long stretch)
26133 /* Assume worst case for symbols not known to be in the same section. */
26134 if (fragp->fr_symbol == NULL
26135 || !S_IS_DEFINED (fragp->fr_symbol)
26136 || sec != S_GET_SEGMENT (fragp->fr_symbol)
26137 || S_IS_WEAK (fragp->fr_symbol))
26140 val = relaxed_symbol_addr (fragp, stretch);
26141 addr = fragp->fr_address + fragp->fr_fix;
26142 addr = (addr + 4) & ~3;
26143 /* Force misaligned targets to 32-bit variant. */
26147 if (val < 0 || val > 1020)
26152 /* Return the size of a relaxable add/sub immediate instruction. */
26154 relax_addsub (fragS *fragp, asection *sec)
26159 buf = fragp->fr_literal + fragp->fr_fix;
26160 op = bfd_get_16(sec->owner, buf);
26161 if ((op & 0xf) == ((op >> 4) & 0xf))
26162 return relax_immediate (fragp, 8, 0);
26164 return relax_immediate (fragp, 3, 0);
26167 /* Return TRUE iff the definition of symbol S could be pre-empted
26168 (overridden) at link or load time. */
26170 symbol_preemptible (symbolS *s)
26172 /* Weak symbols can always be pre-empted. */
26176 /* Non-global symbols cannot be pre-empted. */
26177 if (! S_IS_EXTERNAL (s))
26181 /* In ELF, a global symbol can be marked protected, or private. In that
26182 case it can't be pre-empted (other definitions in the same link unit
26183 would violate the ODR). */
26184 if (ELF_ST_VISIBILITY (S_GET_OTHER (s)) > STV_DEFAULT)
26188 /* Other global symbols might be pre-empted. */
26192 /* Return the size of a relaxable branch instruction. BITS is the
26193 size of the offset field in the narrow instruction. */
26196 relax_branch (fragS *fragp, asection *sec, int bits, long stretch)
26202 /* Assume worst case for symbols not known to be in the same section. */
26203 if (!S_IS_DEFINED (fragp->fr_symbol)
26204 || sec != S_GET_SEGMENT (fragp->fr_symbol)
26205 || S_IS_WEAK (fragp->fr_symbol))
26209 /* A branch to a function in ARM state will require interworking. */
26210 if (S_IS_DEFINED (fragp->fr_symbol)
26211 && ARM_IS_FUNC (fragp->fr_symbol))
26215 if (symbol_preemptible (fragp->fr_symbol))
26218 val = relaxed_symbol_addr (fragp, stretch);
26219 addr = fragp->fr_address + fragp->fr_fix + 4;
26222 /* Offset is a signed value *2 */
26224 if (val >= limit || val < -limit)
26230 /* Relax a machine dependent frag. This returns the amount by which
26231 the current size of the frag should change. */
26234 arm_relax_frag (asection *sec, fragS *fragp, long stretch)
26239 oldsize = fragp->fr_var;
26240 switch (fragp->fr_subtype)
26242 case T_MNEM_ldr_pc2:
26243 newsize = relax_adr (fragp, sec, stretch);
26245 case T_MNEM_ldr_pc:
26246 case T_MNEM_ldr_sp:
26247 case T_MNEM_str_sp:
26248 newsize = relax_immediate (fragp, 8, 2);
26252 newsize = relax_immediate (fragp, 5, 2);
26256 newsize = relax_immediate (fragp, 5, 1);
26260 newsize = relax_immediate (fragp, 5, 0);
26263 newsize = relax_adr (fragp, sec, stretch);
26269 newsize = relax_immediate (fragp, 8, 0);
26272 newsize = relax_branch (fragp, sec, 11, stretch);
26275 newsize = relax_branch (fragp, sec, 8, stretch);
26277 case T_MNEM_add_sp:
26278 case T_MNEM_add_pc:
26279 newsize = relax_immediate (fragp, 8, 2);
26281 case T_MNEM_inc_sp:
26282 case T_MNEM_dec_sp:
26283 newsize = relax_immediate (fragp, 7, 2);
26289 newsize = relax_addsub (fragp, sec);
26295 fragp->fr_var = newsize;
26296 /* Freeze wide instructions that are at or before the same location as
26297 in the previous pass. This avoids infinite loops.
26298 Don't freeze them unconditionally because targets may be artificially
26299 misaligned by the expansion of preceding frags. */
26300 if (stretch <= 0 && newsize > 2)
26302 md_convert_frag (sec->owner, sec, fragp);
26306 return newsize - oldsize;
26309 /* Round up a section size to the appropriate boundary. */
26312 md_section_align (segT segment ATTRIBUTE_UNUSED,
26318 /* This is called from HANDLE_ALIGN in write.c. Fill in the contents
26319 of an rs_align_code fragment. */
26322 arm_handle_align (fragS * fragP)
26324 static unsigned char const arm_noop[2][2][4] =
26327 {0x00, 0x00, 0xa0, 0xe1}, /* LE */
26328 {0xe1, 0xa0, 0x00, 0x00}, /* BE */
26331 {0x00, 0xf0, 0x20, 0xe3}, /* LE */
26332 {0xe3, 0x20, 0xf0, 0x00}, /* BE */
26335 static unsigned char const thumb_noop[2][2][2] =
26338 {0xc0, 0x46}, /* LE */
26339 {0x46, 0xc0}, /* BE */
26342 {0x00, 0xbf}, /* LE */
26343 {0xbf, 0x00} /* BE */
26346 static unsigned char const wide_thumb_noop[2][4] =
26347 { /* Wide Thumb-2 */
26348 {0xaf, 0xf3, 0x00, 0x80}, /* LE */
26349 {0xf3, 0xaf, 0x80, 0x00}, /* BE */
26352 unsigned bytes, fix, noop_size;
26354 const unsigned char * noop;
26355 const unsigned char *narrow_noop = NULL;
26360 if (fragP->fr_type != rs_align_code)
26363 bytes = fragP->fr_next->fr_address - fragP->fr_address - fragP->fr_fix;
26364 p = fragP->fr_literal + fragP->fr_fix;
26367 if (bytes > MAX_MEM_FOR_RS_ALIGN_CODE)
26368 bytes &= MAX_MEM_FOR_RS_ALIGN_CODE;
26370 gas_assert ((fragP->tc_frag_data.thumb_mode & MODE_RECORDED) != 0);
26372 if (fragP->tc_frag_data.thumb_mode & (~ MODE_RECORDED))
26374 if (ARM_CPU_HAS_FEATURE (selected_cpu_name[0]
26375 ? selected_cpu : arm_arch_none, arm_ext_v6t2))
26377 narrow_noop = thumb_noop[1][target_big_endian];
26378 noop = wide_thumb_noop[target_big_endian];
26381 noop = thumb_noop[0][target_big_endian];
26389 noop = arm_noop[ARM_CPU_HAS_FEATURE (selected_cpu_name[0]
26390 ? selected_cpu : arm_arch_none,
26392 [target_big_endian];
26399 fragP->fr_var = noop_size;
26401 if (bytes & (noop_size - 1))
26403 fix = bytes & (noop_size - 1);
26405 insert_data_mapping_symbol (state, fragP->fr_fix, fragP, fix);
26407 memset (p, 0, fix);
26414 if (bytes & noop_size)
26416 /* Insert a narrow noop. */
26417 memcpy (p, narrow_noop, noop_size);
26419 bytes -= noop_size;
26423 /* Use wide noops for the remainder */
26427 while (bytes >= noop_size)
26429 memcpy (p, noop, noop_size);
26431 bytes -= noop_size;
26435 fragP->fr_fix += fix;
26438 /* Called from md_do_align. Used to create an alignment
26439 frag in a code section. */
26442 arm_frag_align_code (int n, int max)
26446 /* We assume that there will never be a requirement
26447 to support alignments greater than MAX_MEM_FOR_RS_ALIGN_CODE bytes. */
26448 if (max > MAX_MEM_FOR_RS_ALIGN_CODE)
26453 _("alignments greater than %d bytes not supported in .text sections."),
26454 MAX_MEM_FOR_RS_ALIGN_CODE + 1);
26455 as_fatal ("%s", err_msg);
26458 p = frag_var (rs_align_code,
26459 MAX_MEM_FOR_RS_ALIGN_CODE,
26461 (relax_substateT) max,
26468 /* Perform target specific initialisation of a frag.
26469 Note - despite the name this initialisation is not done when the frag
26470 is created, but only when its type is assigned. A frag can be created
26471 and used a long time before its type is set, so beware of assuming that
26472 this initialisation is performed first. */
26476 arm_init_frag (fragS * fragP, int max_chars ATTRIBUTE_UNUSED)
26478 /* Record whether this frag is in an ARM or a THUMB area. */
26479 fragP->tc_frag_data.thumb_mode = thumb_mode | MODE_RECORDED;
26482 #else /* OBJ_ELF is defined. */
26484 arm_init_frag (fragS * fragP, int max_chars)
26486 bfd_boolean frag_thumb_mode;
26488 /* If the current ARM vs THUMB mode has not already
26489 been recorded into this frag then do so now. */
26490 if ((fragP->tc_frag_data.thumb_mode & MODE_RECORDED) == 0)
26491 fragP->tc_frag_data.thumb_mode = thumb_mode | MODE_RECORDED;
26493 /* PR 21809: Do not set a mapping state for debug sections
26494 - it just confuses other tools. */
26495 if (bfd_section_flags (now_seg) & SEC_DEBUGGING)
26498 frag_thumb_mode = fragP->tc_frag_data.thumb_mode ^ MODE_RECORDED;
26500 /* Record a mapping symbol for alignment frags. We will delete this
26501 later if the alignment ends up empty. */
26502 switch (fragP->fr_type)
26505 case rs_align_test:
26507 mapping_state_2 (MAP_DATA, max_chars);
26509 case rs_align_code:
26510 mapping_state_2 (frag_thumb_mode ? MAP_THUMB : MAP_ARM, max_chars);
26517 /* When we change sections we need to issue a new mapping symbol. */
26520 arm_elf_change_section (void)
26522 /* Link an unlinked unwind index table section to the .text section. */
26523 if (elf_section_type (now_seg) == SHT_ARM_EXIDX
26524 && elf_linked_to_section (now_seg) == NULL)
26525 elf_linked_to_section (now_seg) = text_section;
26529 arm_elf_section_type (const char * str, size_t len)
26531 if (len == 5 && strncmp (str, "exidx", 5) == 0)
26532 return SHT_ARM_EXIDX;
26537 /* Code to deal with unwinding tables. */
26539 static void add_unwind_adjustsp (offsetT);
26541 /* Generate any deferred unwind frame offset. */
26544 flush_pending_unwind (void)
26548 offset = unwind.pending_offset;
26549 unwind.pending_offset = 0;
26551 add_unwind_adjustsp (offset);
26554 /* Add an opcode to this list for this function. Two-byte opcodes should
26555 be passed as op[0] << 8 | op[1]. The list of opcodes is built in reverse
26559 add_unwind_opcode (valueT op, int length)
26561 /* Add any deferred stack adjustment. */
26562 if (unwind.pending_offset)
26563 flush_pending_unwind ();
26565 unwind.sp_restored = 0;
26567 if (unwind.opcode_count + length > unwind.opcode_alloc)
26569 unwind.opcode_alloc += ARM_OPCODE_CHUNK_SIZE;
26570 if (unwind.opcodes)
26571 unwind.opcodes = XRESIZEVEC (unsigned char, unwind.opcodes,
26572 unwind.opcode_alloc);
26574 unwind.opcodes = XNEWVEC (unsigned char, unwind.opcode_alloc);
26579 unwind.opcodes[unwind.opcode_count] = op & 0xff;
26581 unwind.opcode_count++;
26585 /* Add unwind opcodes to adjust the stack pointer. */
26588 add_unwind_adjustsp (offsetT offset)
26592 if (offset > 0x200)
26594 /* We need at most 5 bytes to hold a 32-bit value in a uleb128. */
26599 /* Long form: 0xb2, uleb128. */
26600 /* This might not fit in a word so add the individual bytes,
26601 remembering the list is built in reverse order. */
26602 o = (valueT) ((offset - 0x204) >> 2);
26604 add_unwind_opcode (0, 1);
26606 /* Calculate the uleb128 encoding of the offset. */
26610 bytes[n] = o & 0x7f;
26616 /* Add the insn. */
26618 add_unwind_opcode (bytes[n - 1], 1);
26619 add_unwind_opcode (0xb2, 1);
26621 else if (offset > 0x100)
26623 /* Two short opcodes. */
26624 add_unwind_opcode (0x3f, 1);
26625 op = (offset - 0x104) >> 2;
26626 add_unwind_opcode (op, 1);
26628 else if (offset > 0)
26630 /* Short opcode. */
26631 op = (offset - 4) >> 2;
26632 add_unwind_opcode (op, 1);
26634 else if (offset < 0)
26637 while (offset > 0x100)
26639 add_unwind_opcode (0x7f, 1);
26642 op = ((offset - 4) >> 2) | 0x40;
26643 add_unwind_opcode (op, 1);
26647 /* Finish the list of unwind opcodes for this function. */
26650 finish_unwind_opcodes (void)
26654 if (unwind.fp_used)
26656 /* Adjust sp as necessary. */
26657 unwind.pending_offset += unwind.fp_offset - unwind.frame_size;
26658 flush_pending_unwind ();
26660 /* After restoring sp from the frame pointer. */
26661 op = 0x90 | unwind.fp_reg;
26662 add_unwind_opcode (op, 1);
26665 flush_pending_unwind ();
26669 /* Start an exception table entry. If idx is nonzero this is an index table
26673 start_unwind_section (const segT text_seg, int idx)
26675 const char * text_name;
26676 const char * prefix;
26677 const char * prefix_once;
26678 const char * group_name;
26686 prefix = ELF_STRING_ARM_unwind;
26687 prefix_once = ELF_STRING_ARM_unwind_once;
26688 type = SHT_ARM_EXIDX;
26692 prefix = ELF_STRING_ARM_unwind_info;
26693 prefix_once = ELF_STRING_ARM_unwind_info_once;
26694 type = SHT_PROGBITS;
26697 text_name = segment_name (text_seg);
26698 if (streq (text_name, ".text"))
26701 if (strncmp (text_name, ".gnu.linkonce.t.",
26702 strlen (".gnu.linkonce.t.")) == 0)
26704 prefix = prefix_once;
26705 text_name += strlen (".gnu.linkonce.t.");
26708 sec_name = concat (prefix, text_name, (char *) NULL);
26714 /* Handle COMDAT group. */
26715 if (prefix != prefix_once && (text_seg->flags & SEC_LINK_ONCE) != 0)
26717 group_name = elf_group_name (text_seg);
26718 if (group_name == NULL)
26720 as_bad (_("Group section `%s' has no group signature"),
26721 segment_name (text_seg));
26722 ignore_rest_of_line ();
26725 flags |= SHF_GROUP;
26729 obj_elf_change_section (sec_name, type, 0, flags, 0, group_name,
26732 /* Set the section link for index tables. */
26734 elf_linked_to_section (now_seg) = text_seg;
26738 /* Start an unwind table entry. HAVE_DATA is nonzero if we have additional
26739 personality routine data. Returns zero, or the index table value for
26740 an inline entry. */
26743 create_unwind_entry (int have_data)
26748 /* The current word of data. */
26750 /* The number of bytes left in this word. */
26753 finish_unwind_opcodes ();
26755 /* Remember the current text section. */
26756 unwind.saved_seg = now_seg;
26757 unwind.saved_subseg = now_subseg;
26759 start_unwind_section (now_seg, 0);
26761 if (unwind.personality_routine == NULL)
26763 if (unwind.personality_index == -2)
26766 as_bad (_("handlerdata in cantunwind frame"));
26767 return 1; /* EXIDX_CANTUNWIND. */
26770 /* Use a default personality routine if none is specified. */
26771 if (unwind.personality_index == -1)
26773 if (unwind.opcode_count > 3)
26774 unwind.personality_index = 1;
26776 unwind.personality_index = 0;
26779 /* Space for the personality routine entry. */
26780 if (unwind.personality_index == 0)
26782 if (unwind.opcode_count > 3)
26783 as_bad (_("too many unwind opcodes for personality routine 0"));
26787 /* All the data is inline in the index table. */
26790 while (unwind.opcode_count > 0)
26792 unwind.opcode_count--;
26793 data = (data << 8) | unwind.opcodes[unwind.opcode_count];
26797 /* Pad with "finish" opcodes. */
26799 data = (data << 8) | 0xb0;
26806 /* We get two opcodes "free" in the first word. */
26807 size = unwind.opcode_count - 2;
26811 /* PR 16765: Missing or misplaced unwind directives can trigger this. */
26812 if (unwind.personality_index != -1)
26814 as_bad (_("attempt to recreate an unwind entry"));
26818 /* An extra byte is required for the opcode count. */
26819 size = unwind.opcode_count + 1;
26822 size = (size + 3) >> 2;
26824 as_bad (_("too many unwind opcodes"));
26826 frag_align (2, 0, 0);
26827 record_alignment (now_seg, 2);
26828 unwind.table_entry = expr_build_dot ();
26830 /* Allocate the table entry. */
26831 ptr = frag_more ((size << 2) + 4);
26832 /* PR 13449: Zero the table entries in case some of them are not used. */
26833 memset (ptr, 0, (size << 2) + 4);
26834 where = frag_now_fix () - ((size << 2) + 4);
26836 switch (unwind.personality_index)
26839 /* ??? Should this be a PLT generating relocation? */
26840 /* Custom personality routine. */
26841 fix_new (frag_now, where, 4, unwind.personality_routine, 0, 1,
26842 BFD_RELOC_ARM_PREL31);
26847 /* Set the first byte to the number of additional words. */
26848 data = size > 0 ? size - 1 : 0;
26852 /* ABI defined personality routines. */
26854 /* Three opcodes bytes are packed into the first word. */
26861 /* The size and first two opcode bytes go in the first word. */
26862 data = ((0x80 + unwind.personality_index) << 8) | size;
26867 /* Should never happen. */
26871 /* Pack the opcodes into words (MSB first), reversing the list at the same
26873 while (unwind.opcode_count > 0)
26877 md_number_to_chars (ptr, data, 4);
26882 unwind.opcode_count--;
26884 data = (data << 8) | unwind.opcodes[unwind.opcode_count];
26887 /* Finish off the last word. */
26890 /* Pad with "finish" opcodes. */
26892 data = (data << 8) | 0xb0;
26894 md_number_to_chars (ptr, data, 4);
26899 /* Add an empty descriptor if there is no user-specified data. */
26900 ptr = frag_more (4);
26901 md_number_to_chars (ptr, 0, 4);
26908 /* Initialize the DWARF-2 unwind information for this procedure. */
26911 tc_arm_frame_initial_instructions (void)
26913 cfi_add_CFA_def_cfa (REG_SP, 0);
26915 #endif /* OBJ_ELF */
26917 /* Convert REGNAME to a DWARF-2 register number. */
26920 tc_arm_regname_to_dw2regnum (char *regname)
26922 int reg = arm_reg_parse (®name, REG_TYPE_RN);
26926 /* PR 16694: Allow VFP registers as well. */
26927 reg = arm_reg_parse (®name, REG_TYPE_VFS);
26931 reg = arm_reg_parse (®name, REG_TYPE_VFD);
26940 tc_pe_dwarf2_emit_offset (symbolS *symbol, unsigned int size)
26944 exp.X_op = O_secrel;
26945 exp.X_add_symbol = symbol;
26946 exp.X_add_number = 0;
26947 emit_expr (&exp, size);
26951 /* MD interface: Symbol and relocation handling. */
26953 /* Return the address within the segment that a PC-relative fixup is
26954 relative to. For ARM, PC-relative fixups applied to instructions
26955 are generally relative to the location of the fixup plus 8 bytes.
26956 Thumb branches are offset by 4, and Thumb loads relative to PC
26957 require special handling. */
26960 md_pcrel_from_section (fixS * fixP, segT seg)
26962 offsetT base = fixP->fx_where + fixP->fx_frag->fr_address;
26964 /* If this is pc-relative and we are going to emit a relocation
26965 then we just want to put out any pipeline compensation that the linker
26966 will need. Otherwise we want to use the calculated base.
26967 For WinCE we skip the bias for externals as well, since this
26968 is how the MS ARM-CE assembler behaves and we want to be compatible. */
26970 && ((fixP->fx_addsy && S_GET_SEGMENT (fixP->fx_addsy) != seg)
26971 || (arm_force_relocation (fixP)
26973 && !S_IS_EXTERNAL (fixP->fx_addsy)
26979 switch (fixP->fx_r_type)
26981 /* PC relative addressing on the Thumb is slightly odd as the
26982 bottom two bits of the PC are forced to zero for the
26983 calculation. This happens *after* application of the
26984 pipeline offset. However, Thumb adrl already adjusts for
26985 this, so we need not do it again. */
26986 case BFD_RELOC_ARM_THUMB_ADD:
26989 case BFD_RELOC_ARM_THUMB_OFFSET:
26990 case BFD_RELOC_ARM_T32_OFFSET_IMM:
26991 case BFD_RELOC_ARM_T32_ADD_PC12:
26992 case BFD_RELOC_ARM_T32_CP_OFF_IMM:
26993 return (base + 4) & ~3;
26995 /* Thumb branches are simply offset by +4. */
26996 case BFD_RELOC_THUMB_PCREL_BRANCH5:
26997 case BFD_RELOC_THUMB_PCREL_BRANCH7:
26998 case BFD_RELOC_THUMB_PCREL_BRANCH9:
26999 case BFD_RELOC_THUMB_PCREL_BRANCH12:
27000 case BFD_RELOC_THUMB_PCREL_BRANCH20:
27001 case BFD_RELOC_THUMB_PCREL_BRANCH25:
27002 case BFD_RELOC_THUMB_PCREL_BFCSEL:
27003 case BFD_RELOC_ARM_THUMB_BF17:
27004 case BFD_RELOC_ARM_THUMB_BF19:
27005 case BFD_RELOC_ARM_THUMB_BF13:
27006 case BFD_RELOC_ARM_THUMB_LOOP12:
27009 case BFD_RELOC_THUMB_PCREL_BRANCH23:
27011 && (S_GET_SEGMENT (fixP->fx_addsy) == seg)
27012 && !S_FORCE_RELOC (fixP->fx_addsy, TRUE)
27013 && ARM_IS_FUNC (fixP->fx_addsy)
27014 && ARM_CPU_HAS_FEATURE (selected_cpu, arm_ext_v5t))
27015 base = fixP->fx_where + fixP->fx_frag->fr_address;
27018 /* BLX is like branches above, but forces the low two bits of PC to
27020 case BFD_RELOC_THUMB_PCREL_BLX:
27022 && (S_GET_SEGMENT (fixP->fx_addsy) == seg)
27023 && !S_FORCE_RELOC (fixP->fx_addsy, TRUE)
27024 && THUMB_IS_FUNC (fixP->fx_addsy)
27025 && ARM_CPU_HAS_FEATURE (selected_cpu, arm_ext_v5t))
27026 base = fixP->fx_where + fixP->fx_frag->fr_address;
27027 return (base + 4) & ~3;
27029 /* ARM mode branches are offset by +8. However, the Windows CE
27030 loader expects the relocation not to take this into account. */
27031 case BFD_RELOC_ARM_PCREL_BLX:
27033 && (S_GET_SEGMENT (fixP->fx_addsy) == seg)
27034 && !S_FORCE_RELOC (fixP->fx_addsy, TRUE)
27035 && ARM_IS_FUNC (fixP->fx_addsy)
27036 && ARM_CPU_HAS_FEATURE (selected_cpu, arm_ext_v5t))
27037 base = fixP->fx_where + fixP->fx_frag->fr_address;
27040 case BFD_RELOC_ARM_PCREL_CALL:
27042 && (S_GET_SEGMENT (fixP->fx_addsy) == seg)
27043 && !S_FORCE_RELOC (fixP->fx_addsy, TRUE)
27044 && THUMB_IS_FUNC (fixP->fx_addsy)
27045 && ARM_CPU_HAS_FEATURE (selected_cpu, arm_ext_v5t))
27046 base = fixP->fx_where + fixP->fx_frag->fr_address;
27049 case BFD_RELOC_ARM_PCREL_BRANCH:
27050 case BFD_RELOC_ARM_PCREL_JUMP:
27051 case BFD_RELOC_ARM_PLT32:
27053 /* When handling fixups immediately, because we have already
27054 discovered the value of a symbol, or the address of the frag involved
27055 we must account for the offset by +8, as the OS loader will never see the reloc.
27056 see fixup_segment() in write.c
27057 The S_IS_EXTERNAL test handles the case of global symbols.
27058 Those need the calculated base, not just the pipe compensation the linker will need. */
27060 && fixP->fx_addsy != NULL
27061 && (S_GET_SEGMENT (fixP->fx_addsy) == seg)
27062 && (S_IS_EXTERNAL (fixP->fx_addsy) || !arm_force_relocation (fixP)))
27070 /* ARM mode loads relative to PC are also offset by +8. Unlike
27071 branches, the Windows CE loader *does* expect the relocation
27072 to take this into account. */
27073 case BFD_RELOC_ARM_OFFSET_IMM:
27074 case BFD_RELOC_ARM_OFFSET_IMM8:
27075 case BFD_RELOC_ARM_HWLITERAL:
27076 case BFD_RELOC_ARM_LITERAL:
27077 case BFD_RELOC_ARM_CP_OFF_IMM:
27081 /* Other PC-relative relocations are un-offset. */
27087 static bfd_boolean flag_warn_syms = TRUE;
27090 arm_tc_equal_in_insn (int c ATTRIBUTE_UNUSED, char * name)
27092 /* PR 18347 - Warn if the user attempts to create a symbol with the same
27093 name as an ARM instruction. Whilst strictly speaking it is allowed, it
27094 does mean that the resulting code might be very confusing to the reader.
27095 Also this warning can be triggered if the user omits an operand before
27096 an immediate address, eg:
27100 GAS treats this as an assignment of the value of the symbol foo to a
27101 symbol LDR, and so (without this code) it will not issue any kind of
27102 warning or error message.
27104 Note - ARM instructions are case-insensitive but the strings in the hash
27105 table are all stored in lower case, so we must first ensure that name is
27107 if (flag_warn_syms && arm_ops_hsh)
27109 char * nbuf = strdup (name);
27112 for (p = nbuf; *p; p++)
27114 if (hash_find (arm_ops_hsh, nbuf) != NULL)
27116 static struct hash_control * already_warned = NULL;
27118 if (already_warned == NULL)
27119 already_warned = hash_new ();
27120 /* Only warn about the symbol once. To keep the code
27121 simple we let hash_insert do the lookup for us. */
27122 if (hash_insert (already_warned, nbuf, NULL) == NULL)
27123 as_warn (_("[-mwarn-syms]: Assignment makes a symbol match an ARM instruction: %s"), name);
27132 /* Under ELF we need to default _GLOBAL_OFFSET_TABLE.
27133 Otherwise we have no need to default values of symbols. */
27136 md_undefined_symbol (char * name ATTRIBUTE_UNUSED)
27139 if (name[0] == '_' && name[1] == 'G'
27140 && streq (name, GLOBAL_OFFSET_TABLE_NAME))
27144 if (symbol_find (name))
27145 as_bad (_("GOT already in the symbol table"));
27147 GOT_symbol = symbol_new (name, undefined_section,
27148 (valueT) 0, & zero_address_frag);
27158 /* Subroutine of md_apply_fix. Check to see if an immediate can be
27159 computed as two separate immediate values, added together. We
27160 already know that this value cannot be computed by just one ARM
27163 static unsigned int
27164 validate_immediate_twopart (unsigned int val,
27165 unsigned int * highpart)
27170 for (i = 0; i < 32; i += 2)
27171 if (((a = rotate_left (val, i)) & 0xff) != 0)
27177 * highpart = (a >> 8) | ((i + 24) << 7);
27179 else if (a & 0xff0000)
27181 if (a & 0xff000000)
27183 * highpart = (a >> 16) | ((i + 16) << 7);
27187 gas_assert (a & 0xff000000);
27188 * highpart = (a >> 24) | ((i + 8) << 7);
27191 return (a & 0xff) | (i << 7);
27198 validate_offset_imm (unsigned int val, int hwse)
27200 if ((hwse && val > 255) || val > 4095)
27205 /* Subroutine of md_apply_fix. Do those data_ops which can take a
27206 negative immediate constant by altering the instruction. A bit of
27211 by inverting the second operand, and
27214 by negating the second operand. */
27217 negate_data_op (unsigned long * instruction,
27218 unsigned long value)
27221 unsigned long negated, inverted;
27223 negated = encode_arm_immediate (-value);
27224 inverted = encode_arm_immediate (~value);
27226 op = (*instruction >> DATA_OP_SHIFT) & 0xf;
27229 /* First negates. */
27230 case OPCODE_SUB: /* ADD <-> SUB */
27231 new_inst = OPCODE_ADD;
27236 new_inst = OPCODE_SUB;
27240 case OPCODE_CMP: /* CMP <-> CMN */
27241 new_inst = OPCODE_CMN;
27246 new_inst = OPCODE_CMP;
27250 /* Now Inverted ops. */
27251 case OPCODE_MOV: /* MOV <-> MVN */
27252 new_inst = OPCODE_MVN;
27257 new_inst = OPCODE_MOV;
27261 case OPCODE_AND: /* AND <-> BIC */
27262 new_inst = OPCODE_BIC;
27267 new_inst = OPCODE_AND;
27271 case OPCODE_ADC: /* ADC <-> SBC */
27272 new_inst = OPCODE_SBC;
27277 new_inst = OPCODE_ADC;
27281 /* We cannot do anything. */
27286 if (value == (unsigned) FAIL)
27289 *instruction &= OPCODE_MASK;
27290 *instruction |= new_inst << DATA_OP_SHIFT;
27294 /* Like negate_data_op, but for Thumb-2. */
27296 static unsigned int
27297 thumb32_negate_data_op (offsetT *instruction, unsigned int value)
27301 unsigned int negated, inverted;
27303 negated = encode_thumb32_immediate (-value);
27304 inverted = encode_thumb32_immediate (~value);
27306 rd = (*instruction >> 8) & 0xf;
27307 op = (*instruction >> T2_DATA_OP_SHIFT) & 0xf;
27310 /* ADD <-> SUB. Includes CMP <-> CMN. */
27311 case T2_OPCODE_SUB:
27312 new_inst = T2_OPCODE_ADD;
27316 case T2_OPCODE_ADD:
27317 new_inst = T2_OPCODE_SUB;
27321 /* ORR <-> ORN. Includes MOV <-> MVN. */
27322 case T2_OPCODE_ORR:
27323 new_inst = T2_OPCODE_ORN;
27327 case T2_OPCODE_ORN:
27328 new_inst = T2_OPCODE_ORR;
27332 /* AND <-> BIC. TST has no inverted equivalent. */
27333 case T2_OPCODE_AND:
27334 new_inst = T2_OPCODE_BIC;
27341 case T2_OPCODE_BIC:
27342 new_inst = T2_OPCODE_AND;
27347 case T2_OPCODE_ADC:
27348 new_inst = T2_OPCODE_SBC;
27352 case T2_OPCODE_SBC:
27353 new_inst = T2_OPCODE_ADC;
27357 /* We cannot do anything. */
27362 if (value == (unsigned int)FAIL)
27365 *instruction &= T2_OPCODE_MASK;
27366 *instruction |= new_inst << T2_DATA_OP_SHIFT;
27370 /* Read a 32-bit thumb instruction from buf. */
27372 static unsigned long
27373 get_thumb32_insn (char * buf)
27375 unsigned long insn;
27376 insn = md_chars_to_number (buf, THUMB_SIZE) << 16;
27377 insn |= md_chars_to_number (buf + THUMB_SIZE, THUMB_SIZE);
27382 /* We usually want to set the low bit on the address of thumb function
27383 symbols. In particular .word foo - . should have the low bit set.
27384 Generic code tries to fold the difference of two symbols to
27385 a constant. Prevent this and force a relocation when the first symbols
27386 is a thumb function. */
27389 arm_optimize_expr (expressionS *l, operatorT op, expressionS *r)
27391 if (op == O_subtract
27392 && l->X_op == O_symbol
27393 && r->X_op == O_symbol
27394 && THUMB_IS_FUNC (l->X_add_symbol))
27396 l->X_op = O_subtract;
27397 l->X_op_symbol = r->X_add_symbol;
27398 l->X_add_number -= r->X_add_number;
27402 /* Process as normal. */
27406 /* Encode Thumb2 unconditional branches and calls. The encoding
27407 for the 2 are identical for the immediate values. */
27410 encode_thumb2_b_bl_offset (char * buf, offsetT value)
27412 #define T2I1I2MASK ((1 << 13) | (1 << 11))
27415 addressT S, I1, I2, lo, hi;
27417 S = (value >> 24) & 0x01;
27418 I1 = (value >> 23) & 0x01;
27419 I2 = (value >> 22) & 0x01;
27420 hi = (value >> 12) & 0x3ff;
27421 lo = (value >> 1) & 0x7ff;
27422 newval = md_chars_to_number (buf, THUMB_SIZE);
27423 newval2 = md_chars_to_number (buf + THUMB_SIZE, THUMB_SIZE);
27424 newval |= (S << 10) | hi;
27425 newval2 &= ~T2I1I2MASK;
27426 newval2 |= (((I1 ^ S) << 13) | ((I2 ^ S) << 11) | lo) ^ T2I1I2MASK;
27427 md_number_to_chars (buf, newval, THUMB_SIZE);
27428 md_number_to_chars (buf + THUMB_SIZE, newval2, THUMB_SIZE);
27432 md_apply_fix (fixS * fixP,
27436 offsetT value = * valP;
27438 unsigned int newimm;
27439 unsigned long temp;
27441 char * buf = fixP->fx_where + fixP->fx_frag->fr_literal;
27443 gas_assert (fixP->fx_r_type <= BFD_RELOC_UNUSED);
27445 /* Note whether this will delete the relocation. */
27447 if (fixP->fx_addsy == 0 && !fixP->fx_pcrel)
27450 /* On a 64-bit host, silently truncate 'value' to 32 bits for
27451 consistency with the behaviour on 32-bit hosts. Remember value
27453 value &= 0xffffffff;
27454 value ^= 0x80000000;
27455 value -= 0x80000000;
27458 fixP->fx_addnumber = value;
27460 /* Same treatment for fixP->fx_offset. */
27461 fixP->fx_offset &= 0xffffffff;
27462 fixP->fx_offset ^= 0x80000000;
27463 fixP->fx_offset -= 0x80000000;
27465 switch (fixP->fx_r_type)
27467 case BFD_RELOC_NONE:
27468 /* This will need to go in the object file. */
27472 case BFD_RELOC_ARM_IMMEDIATE:
27473 /* We claim that this fixup has been processed here,
27474 even if in fact we generate an error because we do
27475 not have a reloc for it, so tc_gen_reloc will reject it. */
27478 if (fixP->fx_addsy)
27480 const char *msg = 0;
27482 if (! S_IS_DEFINED (fixP->fx_addsy))
27483 msg = _("undefined symbol %s used as an immediate value");
27484 else if (S_GET_SEGMENT (fixP->fx_addsy) != seg)
27485 msg = _("symbol %s is in a different section");
27486 else if (S_IS_WEAK (fixP->fx_addsy))
27487 msg = _("symbol %s is weak and may be overridden later");
27491 as_bad_where (fixP->fx_file, fixP->fx_line,
27492 msg, S_GET_NAME (fixP->fx_addsy));
27497 temp = md_chars_to_number (buf, INSN_SIZE);
27499 /* If the offset is negative, we should use encoding A2 for ADR. */
27500 if ((temp & 0xfff0000) == 0x28f0000 && value < 0)
27501 newimm = negate_data_op (&temp, value);
27504 newimm = encode_arm_immediate (value);
27506 /* If the instruction will fail, see if we can fix things up by
27507 changing the opcode. */
27508 if (newimm == (unsigned int) FAIL)
27509 newimm = negate_data_op (&temp, value);
27510 /* MOV accepts both ARM modified immediate (A1 encoding) and
27511 UINT16 (A2 encoding) when possible, MOVW only accepts UINT16.
27512 When disassembling, MOV is preferred when there is no encoding
27514 if (newimm == (unsigned int) FAIL
27515 && ((temp >> DATA_OP_SHIFT) & 0xf) == OPCODE_MOV
27516 && ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_v6t2)
27517 && !((temp >> SBIT_SHIFT) & 0x1)
27518 && value >= 0 && value <= 0xffff)
27520 /* Clear bits[23:20] to change encoding from A1 to A2. */
27521 temp &= 0xff0fffff;
27522 /* Encoding high 4bits imm. Code below will encode the remaining
27524 temp |= (value & 0x0000f000) << 4;
27525 newimm = value & 0x00000fff;
27529 if (newimm == (unsigned int) FAIL)
27531 as_bad_where (fixP->fx_file, fixP->fx_line,
27532 _("invalid constant (%lx) after fixup"),
27533 (unsigned long) value);
27537 newimm |= (temp & 0xfffff000);
27538 md_number_to_chars (buf, (valueT) newimm, INSN_SIZE);
27541 case BFD_RELOC_ARM_ADRL_IMMEDIATE:
27543 unsigned int highpart = 0;
27544 unsigned int newinsn = 0xe1a00000; /* nop. */
27546 if (fixP->fx_addsy)
27548 const char *msg = 0;
27550 if (! S_IS_DEFINED (fixP->fx_addsy))
27551 msg = _("undefined symbol %s used as an immediate value");
27552 else if (S_GET_SEGMENT (fixP->fx_addsy) != seg)
27553 msg = _("symbol %s is in a different section");
27554 else if (S_IS_WEAK (fixP->fx_addsy))
27555 msg = _("symbol %s is weak and may be overridden later");
27559 as_bad_where (fixP->fx_file, fixP->fx_line,
27560 msg, S_GET_NAME (fixP->fx_addsy));
27565 newimm = encode_arm_immediate (value);
27566 temp = md_chars_to_number (buf, INSN_SIZE);
27568 /* If the instruction will fail, see if we can fix things up by
27569 changing the opcode. */
27570 if (newimm == (unsigned int) FAIL
27571 && (newimm = negate_data_op (& temp, value)) == (unsigned int) FAIL)
27573 /* No ? OK - try using two ADD instructions to generate
27575 newimm = validate_immediate_twopart (value, & highpart);
27577 /* Yes - then make sure that the second instruction is
27579 if (newimm != (unsigned int) FAIL)
27581 /* Still No ? Try using a negated value. */
27582 else if ((newimm = validate_immediate_twopart (- value, & highpart)) != (unsigned int) FAIL)
27583 temp = newinsn = (temp & OPCODE_MASK) | OPCODE_SUB << DATA_OP_SHIFT;
27584 /* Otherwise - give up. */
27587 as_bad_where (fixP->fx_file, fixP->fx_line,
27588 _("unable to compute ADRL instructions for PC offset of 0x%lx"),
27593 /* Replace the first operand in the 2nd instruction (which
27594 is the PC) with the destination register. We have
27595 already added in the PC in the first instruction and we
27596 do not want to do it again. */
27597 newinsn &= ~ 0xf0000;
27598 newinsn |= ((newinsn & 0x0f000) << 4);
27601 newimm |= (temp & 0xfffff000);
27602 md_number_to_chars (buf, (valueT) newimm, INSN_SIZE);
27604 highpart |= (newinsn & 0xfffff000);
27605 md_number_to_chars (buf + INSN_SIZE, (valueT) highpart, INSN_SIZE);
27609 case BFD_RELOC_ARM_OFFSET_IMM:
27610 if (!fixP->fx_done && seg->use_rela_p)
27612 /* Fall through. */
27614 case BFD_RELOC_ARM_LITERAL:
27620 if (validate_offset_imm (value, 0) == FAIL)
27622 if (fixP->fx_r_type == BFD_RELOC_ARM_LITERAL)
27623 as_bad_where (fixP->fx_file, fixP->fx_line,
27624 _("invalid literal constant: pool needs to be closer"));
27626 as_bad_where (fixP->fx_file, fixP->fx_line,
27627 _("bad immediate value for offset (%ld)"),
27632 newval = md_chars_to_number (buf, INSN_SIZE);
27634 newval &= 0xfffff000;
27637 newval &= 0xff7ff000;
27638 newval |= value | (sign ? INDEX_UP : 0);
27640 md_number_to_chars (buf, newval, INSN_SIZE);
27643 case BFD_RELOC_ARM_OFFSET_IMM8:
27644 case BFD_RELOC_ARM_HWLITERAL:
27650 if (validate_offset_imm (value, 1) == FAIL)
27652 if (fixP->fx_r_type == BFD_RELOC_ARM_HWLITERAL)
27653 as_bad_where (fixP->fx_file, fixP->fx_line,
27654 _("invalid literal constant: pool needs to be closer"));
27656 as_bad_where (fixP->fx_file, fixP->fx_line,
27657 _("bad immediate value for 8-bit offset (%ld)"),
27662 newval = md_chars_to_number (buf, INSN_SIZE);
27664 newval &= 0xfffff0f0;
27667 newval &= 0xff7ff0f0;
27668 newval |= ((value >> 4) << 8) | (value & 0xf) | (sign ? INDEX_UP : 0);
27670 md_number_to_chars (buf, newval, INSN_SIZE);
27673 case BFD_RELOC_ARM_T32_OFFSET_U8:
27674 if (value < 0 || value > 1020 || value % 4 != 0)
27675 as_bad_where (fixP->fx_file, fixP->fx_line,
27676 _("bad immediate value for offset (%ld)"), (long) value);
27679 newval = md_chars_to_number (buf+2, THUMB_SIZE);
27681 md_number_to_chars (buf+2, newval, THUMB_SIZE);
27684 case BFD_RELOC_ARM_T32_OFFSET_IMM:
27685 /* This is a complicated relocation used for all varieties of Thumb32
27686 load/store instruction with immediate offset:
27688 1110 100P u1WL NNNN XXXX YYYY iiii iiii - +/-(U) pre/post(P) 8-bit,
27689 *4, optional writeback(W)
27690 (doubleword load/store)
27692 1111 100S uTTL 1111 XXXX iiii iiii iiii - +/-(U) 12-bit PC-rel
27693 1111 100S 0TTL NNNN XXXX 1Pu1 iiii iiii - +/-(U) pre/post(P) 8-bit
27694 1111 100S 0TTL NNNN XXXX 1110 iiii iiii - positive 8-bit (T instruction)
27695 1111 100S 1TTL NNNN XXXX iiii iiii iiii - positive 12-bit
27696 1111 100S 0TTL NNNN XXXX 1100 iiii iiii - negative 8-bit
27698 Uppercase letters indicate bits that are already encoded at
27699 this point. Lowercase letters are our problem. For the
27700 second block of instructions, the secondary opcode nybble
27701 (bits 8..11) is present, and bit 23 is zero, even if this is
27702 a PC-relative operation. */
27703 newval = md_chars_to_number (buf, THUMB_SIZE);
27705 newval |= md_chars_to_number (buf+THUMB_SIZE, THUMB_SIZE);
27707 if ((newval & 0xf0000000) == 0xe0000000)
27709 /* Doubleword load/store: 8-bit offset, scaled by 4. */
27711 newval |= (1 << 23);
27714 if (value % 4 != 0)
27716 as_bad_where (fixP->fx_file, fixP->fx_line,
27717 _("offset not a multiple of 4"));
27723 as_bad_where (fixP->fx_file, fixP->fx_line,
27724 _("offset out of range"));
27729 else if ((newval & 0x000f0000) == 0x000f0000)
27731 /* PC-relative, 12-bit offset. */
27733 newval |= (1 << 23);
27738 as_bad_where (fixP->fx_file, fixP->fx_line,
27739 _("offset out of range"));
27744 else if ((newval & 0x00000100) == 0x00000100)
27746 /* Writeback: 8-bit, +/- offset. */
27748 newval |= (1 << 9);
27753 as_bad_where (fixP->fx_file, fixP->fx_line,
27754 _("offset out of range"));
27759 else if ((newval & 0x00000f00) == 0x00000e00)
27761 /* T-instruction: positive 8-bit offset. */
27762 if (value < 0 || value > 0xff)
27764 as_bad_where (fixP->fx_file, fixP->fx_line,
27765 _("offset out of range"));
27773 /* Positive 12-bit or negative 8-bit offset. */
27777 newval |= (1 << 23);
27787 as_bad_where (fixP->fx_file, fixP->fx_line,
27788 _("offset out of range"));
27795 md_number_to_chars (buf, (newval >> 16) & 0xffff, THUMB_SIZE);
27796 md_number_to_chars (buf + THUMB_SIZE, newval & 0xffff, THUMB_SIZE);
27799 case BFD_RELOC_ARM_SHIFT_IMM:
27800 newval = md_chars_to_number (buf, INSN_SIZE);
27801 if (((unsigned long) value) > 32
27803 && (((newval & 0x60) == 0) || (newval & 0x60) == 0x60)))
27805 as_bad_where (fixP->fx_file, fixP->fx_line,
27806 _("shift expression is too large"));
27811 /* Shifts of zero must be done as lsl. */
27813 else if (value == 32)
27815 newval &= 0xfffff07f;
27816 newval |= (value & 0x1f) << 7;
27817 md_number_to_chars (buf, newval, INSN_SIZE);
27820 case BFD_RELOC_ARM_T32_IMMEDIATE:
27821 case BFD_RELOC_ARM_T32_ADD_IMM:
27822 case BFD_RELOC_ARM_T32_IMM12:
27823 case BFD_RELOC_ARM_T32_ADD_PC12:
27824 /* We claim that this fixup has been processed here,
27825 even if in fact we generate an error because we do
27826 not have a reloc for it, so tc_gen_reloc will reject it. */
27830 && ! S_IS_DEFINED (fixP->fx_addsy))
27832 as_bad_where (fixP->fx_file, fixP->fx_line,
27833 _("undefined symbol %s used as an immediate value"),
27834 S_GET_NAME (fixP->fx_addsy));
27838 newval = md_chars_to_number (buf, THUMB_SIZE);
27840 newval |= md_chars_to_number (buf+2, THUMB_SIZE);
27843 if ((fixP->fx_r_type == BFD_RELOC_ARM_T32_IMMEDIATE
27844 /* ARMv8-M Baseline MOV will reach here, but it doesn't support
27845 Thumb2 modified immediate encoding (T2). */
27846 && ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_v6t2))
27847 || fixP->fx_r_type == BFD_RELOC_ARM_T32_ADD_IMM)
27849 newimm = encode_thumb32_immediate (value);
27850 if (newimm == (unsigned int) FAIL)
27851 newimm = thumb32_negate_data_op (&newval, value);
27853 if (newimm == (unsigned int) FAIL)
27855 if (fixP->fx_r_type != BFD_RELOC_ARM_T32_IMMEDIATE)
27857 /* Turn add/sum into addw/subw. */
27858 if (fixP->fx_r_type == BFD_RELOC_ARM_T32_ADD_IMM)
27859 newval = (newval & 0xfeffffff) | 0x02000000;
27860 /* No flat 12-bit imm encoding for addsw/subsw. */
27861 if ((newval & 0x00100000) == 0)
27863 /* 12 bit immediate for addw/subw. */
27867 newval ^= 0x00a00000;
27870 newimm = (unsigned int) FAIL;
27877 /* MOV accepts both Thumb2 modified immediate (T2 encoding) and
27878 UINT16 (T3 encoding), MOVW only accepts UINT16. When
27879 disassembling, MOV is preferred when there is no encoding
27881 if (((newval >> T2_DATA_OP_SHIFT) & 0xf) == T2_OPCODE_ORR
27882 /* NOTE: MOV uses the ORR opcode in Thumb 2 mode
27883 but with the Rn field [19:16] set to 1111. */
27884 && (((newval >> 16) & 0xf) == 0xf)
27885 && ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_v6t2_v8m)
27886 && !((newval >> T2_SBIT_SHIFT) & 0x1)
27887 && value >= 0 && value <= 0xffff)
27889 /* Toggle bit[25] to change encoding from T2 to T3. */
27891 /* Clear bits[19:16]. */
27892 newval &= 0xfff0ffff;
27893 /* Encoding high 4bits imm. Code below will encode the
27894 remaining low 12bits. */
27895 newval |= (value & 0x0000f000) << 4;
27896 newimm = value & 0x00000fff;
27901 if (newimm == (unsigned int)FAIL)
27903 as_bad_where (fixP->fx_file, fixP->fx_line,
27904 _("invalid constant (%lx) after fixup"),
27905 (unsigned long) value);
27909 newval |= (newimm & 0x800) << 15;
27910 newval |= (newimm & 0x700) << 4;
27911 newval |= (newimm & 0x0ff);
27913 md_number_to_chars (buf, (valueT) ((newval >> 16) & 0xffff), THUMB_SIZE);
27914 md_number_to_chars (buf+2, (valueT) (newval & 0xffff), THUMB_SIZE);
27917 case BFD_RELOC_ARM_SMC:
27918 if (((unsigned long) value) > 0xf)
27919 as_bad_where (fixP->fx_file, fixP->fx_line,
27920 _("invalid smc expression"));
27922 newval = md_chars_to_number (buf, INSN_SIZE);
27923 newval |= (value & 0xf);
27924 md_number_to_chars (buf, newval, INSN_SIZE);
27927 case BFD_RELOC_ARM_HVC:
27928 if (((unsigned long) value) > 0xffff)
27929 as_bad_where (fixP->fx_file, fixP->fx_line,
27930 _("invalid hvc expression"));
27931 newval = md_chars_to_number (buf, INSN_SIZE);
27932 newval |= (value & 0xf) | ((value & 0xfff0) << 4);
27933 md_number_to_chars (buf, newval, INSN_SIZE);
27936 case BFD_RELOC_ARM_SWI:
27937 if (fixP->tc_fix_data != 0)
27939 if (((unsigned long) value) > 0xff)
27940 as_bad_where (fixP->fx_file, fixP->fx_line,
27941 _("invalid swi expression"));
27942 newval = md_chars_to_number (buf, THUMB_SIZE);
27944 md_number_to_chars (buf, newval, THUMB_SIZE);
27948 if (((unsigned long) value) > 0x00ffffff)
27949 as_bad_where (fixP->fx_file, fixP->fx_line,
27950 _("invalid swi expression"));
27951 newval = md_chars_to_number (buf, INSN_SIZE);
27953 md_number_to_chars (buf, newval, INSN_SIZE);
27957 case BFD_RELOC_ARM_MULTI:
27958 if (((unsigned long) value) > 0xffff)
27959 as_bad_where (fixP->fx_file, fixP->fx_line,
27960 _("invalid expression in load/store multiple"));
27961 newval = value | md_chars_to_number (buf, INSN_SIZE);
27962 md_number_to_chars (buf, newval, INSN_SIZE);
27966 case BFD_RELOC_ARM_PCREL_CALL:
27968 if (ARM_CPU_HAS_FEATURE (selected_cpu, arm_ext_v5t)
27970 && !S_FORCE_RELOC (fixP->fx_addsy, TRUE)
27971 && (S_GET_SEGMENT (fixP->fx_addsy) == seg)
27972 && THUMB_IS_FUNC (fixP->fx_addsy))
27973 /* Flip the bl to blx. This is a simple flip
27974 bit here because we generate PCREL_CALL for
27975 unconditional bls. */
27977 newval = md_chars_to_number (buf, INSN_SIZE);
27978 newval = newval | 0x10000000;
27979 md_number_to_chars (buf, newval, INSN_SIZE);
27985 goto arm_branch_common;
27987 case BFD_RELOC_ARM_PCREL_JUMP:
27988 if (ARM_CPU_HAS_FEATURE (selected_cpu, arm_ext_v5t)
27990 && !S_FORCE_RELOC (fixP->fx_addsy, TRUE)
27991 && (S_GET_SEGMENT (fixP->fx_addsy) == seg)
27992 && THUMB_IS_FUNC (fixP->fx_addsy))
27994 /* This would map to a bl<cond>, b<cond>,
27995 b<always> to a Thumb function. We
27996 need to force a relocation for this particular
27998 newval = md_chars_to_number (buf, INSN_SIZE);
28001 /* Fall through. */
28003 case BFD_RELOC_ARM_PLT32:
28005 case BFD_RELOC_ARM_PCREL_BRANCH:
28007 goto arm_branch_common;
28009 case BFD_RELOC_ARM_PCREL_BLX:
28012 if (ARM_CPU_HAS_FEATURE (selected_cpu, arm_ext_v5t)
28014 && !S_FORCE_RELOC (fixP->fx_addsy, TRUE)
28015 && (S_GET_SEGMENT (fixP->fx_addsy) == seg)
28016 && ARM_IS_FUNC (fixP->fx_addsy))
28018 /* Flip the blx to a bl and warn. */
28019 const char *name = S_GET_NAME (fixP->fx_addsy);
28020 newval = 0xeb000000;
28021 as_warn_where (fixP->fx_file, fixP->fx_line,
28022 _("blx to '%s' an ARM ISA state function changed to bl"),
28024 md_number_to_chars (buf, newval, INSN_SIZE);
28030 if (EF_ARM_EABI_VERSION (meabi_flags) >= EF_ARM_EABI_VER4)
28031 fixP->fx_r_type = BFD_RELOC_ARM_PCREL_CALL;
28035 /* We are going to store value (shifted right by two) in the
28036 instruction, in a 24 bit, signed field. Bits 26 through 32 either
28037 all clear or all set and bit 0 must be clear. For B/BL bit 1 must
28040 as_bad_where (fixP->fx_file, fixP->fx_line,
28041 _("misaligned branch destination"));
28042 if ((value & (offsetT)0xfe000000) != (offsetT)0
28043 && (value & (offsetT)0xfe000000) != (offsetT)0xfe000000)
28044 as_bad_where (fixP->fx_file, fixP->fx_line, BAD_RANGE);
28046 if (fixP->fx_done || !seg->use_rela_p)
28048 newval = md_chars_to_number (buf, INSN_SIZE);
28049 newval |= (value >> 2) & 0x00ffffff;
28050 /* Set the H bit on BLX instructions. */
28054 newval |= 0x01000000;
28056 newval &= ~0x01000000;
28058 md_number_to_chars (buf, newval, INSN_SIZE);
28062 case BFD_RELOC_THUMB_PCREL_BRANCH7: /* CBZ */
28063 /* CBZ can only branch forward. */
28065 /* Attempts to use CBZ to branch to the next instruction
28066 (which, strictly speaking, are prohibited) will be turned into
28069 FIXME: It may be better to remove the instruction completely and
28070 perform relaxation. */
28073 newval = md_chars_to_number (buf, THUMB_SIZE);
28074 newval = 0xbf00; /* NOP encoding T1 */
28075 md_number_to_chars (buf, newval, THUMB_SIZE);
28080 as_bad_where (fixP->fx_file, fixP->fx_line, BAD_RANGE);
28082 if (fixP->fx_done || !seg->use_rela_p)
28084 newval = md_chars_to_number (buf, THUMB_SIZE);
28085 newval |= ((value & 0x3e) << 2) | ((value & 0x40) << 3);
28086 md_number_to_chars (buf, newval, THUMB_SIZE);
28091 case BFD_RELOC_THUMB_PCREL_BRANCH9: /* Conditional branch. */
28092 if ((value & ~0xff) && ((value & ~0xff) != ~0xff))
28093 as_bad_where (fixP->fx_file, fixP->fx_line, BAD_RANGE);
28095 if (fixP->fx_done || !seg->use_rela_p)
28097 newval = md_chars_to_number (buf, THUMB_SIZE);
28098 newval |= (value & 0x1ff) >> 1;
28099 md_number_to_chars (buf, newval, THUMB_SIZE);
28103 case BFD_RELOC_THUMB_PCREL_BRANCH12: /* Unconditional branch. */
28104 if ((value & ~0x7ff) && ((value & ~0x7ff) != ~0x7ff))
28105 as_bad_where (fixP->fx_file, fixP->fx_line, BAD_RANGE);
28107 if (fixP->fx_done || !seg->use_rela_p)
28109 newval = md_chars_to_number (buf, THUMB_SIZE);
28110 newval |= (value & 0xfff) >> 1;
28111 md_number_to_chars (buf, newval, THUMB_SIZE);
28115 case BFD_RELOC_THUMB_PCREL_BRANCH20:
28117 && (S_GET_SEGMENT (fixP->fx_addsy) == seg)
28118 && !S_FORCE_RELOC (fixP->fx_addsy, TRUE)
28119 && ARM_IS_FUNC (fixP->fx_addsy)
28120 && ARM_CPU_HAS_FEATURE (selected_cpu, arm_ext_v5t))
28122 /* Force a relocation for a branch 20 bits wide. */
28125 if ((value & ~0x1fffff) && ((value & ~0x0fffff) != ~0x0fffff))
28126 as_bad_where (fixP->fx_file, fixP->fx_line,
28127 _("conditional branch out of range"));
28129 if (fixP->fx_done || !seg->use_rela_p)
28132 addressT S, J1, J2, lo, hi;
28134 S = (value & 0x00100000) >> 20;
28135 J2 = (value & 0x00080000) >> 19;
28136 J1 = (value & 0x00040000) >> 18;
28137 hi = (value & 0x0003f000) >> 12;
28138 lo = (value & 0x00000ffe) >> 1;
28140 newval = md_chars_to_number (buf, THUMB_SIZE);
28141 newval2 = md_chars_to_number (buf + THUMB_SIZE, THUMB_SIZE);
28142 newval |= (S << 10) | hi;
28143 newval2 |= (J1 << 13) | (J2 << 11) | lo;
28144 md_number_to_chars (buf, newval, THUMB_SIZE);
28145 md_number_to_chars (buf + THUMB_SIZE, newval2, THUMB_SIZE);
28149 case BFD_RELOC_THUMB_PCREL_BLX:
28150 /* If there is a blx from a thumb state function to
28151 another thumb function flip this to a bl and warn
28155 && !S_FORCE_RELOC (fixP->fx_addsy, TRUE)
28156 && (S_GET_SEGMENT (fixP->fx_addsy) == seg)
28157 && THUMB_IS_FUNC (fixP->fx_addsy))
28159 const char *name = S_GET_NAME (fixP->fx_addsy);
28160 as_warn_where (fixP->fx_file, fixP->fx_line,
28161 _("blx to Thumb func '%s' from Thumb ISA state changed to bl"),
28163 newval = md_chars_to_number (buf + THUMB_SIZE, THUMB_SIZE);
28164 newval = newval | 0x1000;
28165 md_number_to_chars (buf+THUMB_SIZE, newval, THUMB_SIZE);
28166 fixP->fx_r_type = BFD_RELOC_THUMB_PCREL_BRANCH23;
28171 goto thumb_bl_common;
28173 case BFD_RELOC_THUMB_PCREL_BRANCH23:
28174 /* A bl from Thumb state ISA to an internal ARM state function
28175 is converted to a blx. */
28177 && (S_GET_SEGMENT (fixP->fx_addsy) == seg)
28178 && !S_FORCE_RELOC (fixP->fx_addsy, TRUE)
28179 && ARM_IS_FUNC (fixP->fx_addsy)
28180 && ARM_CPU_HAS_FEATURE (selected_cpu, arm_ext_v5t))
28182 newval = md_chars_to_number (buf + THUMB_SIZE, THUMB_SIZE);
28183 newval = newval & ~0x1000;
28184 md_number_to_chars (buf+THUMB_SIZE, newval, THUMB_SIZE);
28185 fixP->fx_r_type = BFD_RELOC_THUMB_PCREL_BLX;
28191 if (fixP->fx_r_type == BFD_RELOC_THUMB_PCREL_BLX)
28192 /* For a BLX instruction, make sure that the relocation is rounded up
28193 to a word boundary. This follows the semantics of the instruction
28194 which specifies that bit 1 of the target address will come from bit
28195 1 of the base address. */
28196 value = (value + 3) & ~ 3;
28199 if (EF_ARM_EABI_VERSION (meabi_flags) >= EF_ARM_EABI_VER4
28200 && fixP->fx_r_type == BFD_RELOC_THUMB_PCREL_BLX)
28201 fixP->fx_r_type = BFD_RELOC_THUMB_PCREL_BRANCH23;
28204 if ((value & ~0x3fffff) && ((value & ~0x3fffff) != ~0x3fffff))
28206 if (!(ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_v6t2)))
28207 as_bad_where (fixP->fx_file, fixP->fx_line, BAD_RANGE);
28208 else if ((value & ~0x1ffffff)
28209 && ((value & ~0x1ffffff) != ~0x1ffffff))
28210 as_bad_where (fixP->fx_file, fixP->fx_line,
28211 _("Thumb2 branch out of range"));
28214 if (fixP->fx_done || !seg->use_rela_p)
28215 encode_thumb2_b_bl_offset (buf, value);
28219 case BFD_RELOC_THUMB_PCREL_BRANCH25:
28220 if ((value & ~0x0ffffff) && ((value & ~0x0ffffff) != ~0x0ffffff))
28221 as_bad_where (fixP->fx_file, fixP->fx_line, BAD_RANGE);
28223 if (fixP->fx_done || !seg->use_rela_p)
28224 encode_thumb2_b_bl_offset (buf, value);
28229 if (fixP->fx_done || !seg->use_rela_p)
28234 if (fixP->fx_done || !seg->use_rela_p)
28235 md_number_to_chars (buf, value, 2);
28239 case BFD_RELOC_ARM_TLS_CALL:
28240 case BFD_RELOC_ARM_THM_TLS_CALL:
28241 case BFD_RELOC_ARM_TLS_DESCSEQ:
28242 case BFD_RELOC_ARM_THM_TLS_DESCSEQ:
28243 case BFD_RELOC_ARM_TLS_GOTDESC:
28244 case BFD_RELOC_ARM_TLS_GD32:
28245 case BFD_RELOC_ARM_TLS_LE32:
28246 case BFD_RELOC_ARM_TLS_IE32:
28247 case BFD_RELOC_ARM_TLS_LDM32:
28248 case BFD_RELOC_ARM_TLS_LDO32:
28249 S_SET_THREAD_LOCAL (fixP->fx_addsy);
28252 /* Same handling as above, but with the arm_fdpic guard. */
28253 case BFD_RELOC_ARM_TLS_GD32_FDPIC:
28254 case BFD_RELOC_ARM_TLS_IE32_FDPIC:
28255 case BFD_RELOC_ARM_TLS_LDM32_FDPIC:
28258 S_SET_THREAD_LOCAL (fixP->fx_addsy);
28262 as_bad_where (fixP->fx_file, fixP->fx_line,
28263 _("Relocation supported only in FDPIC mode"));
28267 case BFD_RELOC_ARM_GOT32:
28268 case BFD_RELOC_ARM_GOTOFF:
28271 case BFD_RELOC_ARM_GOT_PREL:
28272 if (fixP->fx_done || !seg->use_rela_p)
28273 md_number_to_chars (buf, value, 4);
28276 case BFD_RELOC_ARM_TARGET2:
28277 /* TARGET2 is not partial-inplace, so we need to write the
28278 addend here for REL targets, because it won't be written out
28279 during reloc processing later. */
28280 if (fixP->fx_done || !seg->use_rela_p)
28281 md_number_to_chars (buf, fixP->fx_offset, 4);
28284 /* Relocations for FDPIC. */
28285 case BFD_RELOC_ARM_GOTFUNCDESC:
28286 case BFD_RELOC_ARM_GOTOFFFUNCDESC:
28287 case BFD_RELOC_ARM_FUNCDESC:
28290 if (fixP->fx_done || !seg->use_rela_p)
28291 md_number_to_chars (buf, 0, 4);
28295 as_bad_where (fixP->fx_file, fixP->fx_line,
28296 _("Relocation supported only in FDPIC mode"));
28301 case BFD_RELOC_RVA:
28303 case BFD_RELOC_ARM_TARGET1:
28304 case BFD_RELOC_ARM_ROSEGREL32:
28305 case BFD_RELOC_ARM_SBREL32:
28306 case BFD_RELOC_32_PCREL:
28308 case BFD_RELOC_32_SECREL:
28310 if (fixP->fx_done || !seg->use_rela_p)
28312 /* For WinCE we only do this for pcrel fixups. */
28313 if (fixP->fx_done || fixP->fx_pcrel)
28315 md_number_to_chars (buf, value, 4);
28319 case BFD_RELOC_ARM_PREL31:
28320 if (fixP->fx_done || !seg->use_rela_p)
28322 newval = md_chars_to_number (buf, 4) & 0x80000000;
28323 if ((value ^ (value >> 1)) & 0x40000000)
28325 as_bad_where (fixP->fx_file, fixP->fx_line,
28326 _("rel31 relocation overflow"));
28328 newval |= value & 0x7fffffff;
28329 md_number_to_chars (buf, newval, 4);
28334 case BFD_RELOC_ARM_CP_OFF_IMM:
28335 case BFD_RELOC_ARM_T32_CP_OFF_IMM:
28336 case BFD_RELOC_ARM_T32_VLDR_VSTR_OFF_IMM:
28337 if (fixP->fx_r_type == BFD_RELOC_ARM_CP_OFF_IMM)
28338 newval = md_chars_to_number (buf, INSN_SIZE);
28340 newval = get_thumb32_insn (buf);
28341 if ((newval & 0x0f200f00) == 0x0d000900)
28343 /* This is a fp16 vstr/vldr. The immediate offset in the mnemonic
28344 has permitted values that are multiples of 2, in the range 0
28346 if (value < -510 || value > 510 || (value & 1))
28347 as_bad_where (fixP->fx_file, fixP->fx_line,
28348 _("co-processor offset out of range"));
28350 else if ((newval & 0xfe001f80) == 0xec000f80)
28352 if (value < -511 || value > 512 || (value & 3))
28353 as_bad_where (fixP->fx_file, fixP->fx_line,
28354 _("co-processor offset out of range"));
28356 else if (value < -1023 || value > 1023 || (value & 3))
28357 as_bad_where (fixP->fx_file, fixP->fx_line,
28358 _("co-processor offset out of range"));
28363 if (fixP->fx_r_type == BFD_RELOC_ARM_CP_OFF_IMM
28364 || fixP->fx_r_type == BFD_RELOC_ARM_CP_OFF_IMM_S2)
28365 newval = md_chars_to_number (buf, INSN_SIZE);
28367 newval = get_thumb32_insn (buf);
28370 if (fixP->fx_r_type == BFD_RELOC_ARM_T32_VLDR_VSTR_OFF_IMM)
28371 newval &= 0xffffff80;
28373 newval &= 0xffffff00;
28377 if (fixP->fx_r_type == BFD_RELOC_ARM_T32_VLDR_VSTR_OFF_IMM)
28378 newval &= 0xff7fff80;
28380 newval &= 0xff7fff00;
28381 if ((newval & 0x0f200f00) == 0x0d000900)
28383 /* This is a fp16 vstr/vldr.
28385 It requires the immediate offset in the instruction is shifted
28386 left by 1 to be a half-word offset.
28388 Here, left shift by 1 first, and later right shift by 2
28389 should get the right offset. */
28392 newval |= (value >> 2) | (sign ? INDEX_UP : 0);
28394 if (fixP->fx_r_type == BFD_RELOC_ARM_CP_OFF_IMM
28395 || fixP->fx_r_type == BFD_RELOC_ARM_CP_OFF_IMM_S2)
28396 md_number_to_chars (buf, newval, INSN_SIZE);
28398 put_thumb32_insn (buf, newval);
28401 case BFD_RELOC_ARM_CP_OFF_IMM_S2:
28402 case BFD_RELOC_ARM_T32_CP_OFF_IMM_S2:
28403 if (value < -255 || value > 255)
28404 as_bad_where (fixP->fx_file, fixP->fx_line,
28405 _("co-processor offset out of range"));
28407 goto cp_off_common;
28409 case BFD_RELOC_ARM_THUMB_OFFSET:
28410 newval = md_chars_to_number (buf, THUMB_SIZE);
28411 /* Exactly what ranges, and where the offset is inserted depends
28412 on the type of instruction, we can establish this from the
28414 switch (newval >> 12)
28416 case 4: /* PC load. */
28417 /* Thumb PC loads are somewhat odd, bit 1 of the PC is
28418 forced to zero for these loads; md_pcrel_from has already
28419 compensated for this. */
28421 as_bad_where (fixP->fx_file, fixP->fx_line,
28422 _("invalid offset, target not word aligned (0x%08lX)"),
28423 (((unsigned long) fixP->fx_frag->fr_address
28424 + (unsigned long) fixP->fx_where) & ~3)
28425 + (unsigned long) value);
28427 if (value & ~0x3fc)
28428 as_bad_where (fixP->fx_file, fixP->fx_line,
28429 _("invalid offset, value too big (0x%08lX)"),
28432 newval |= value >> 2;
28435 case 9: /* SP load/store. */
28436 if (value & ~0x3fc)
28437 as_bad_where (fixP->fx_file, fixP->fx_line,
28438 _("invalid offset, value too big (0x%08lX)"),
28440 newval |= value >> 2;
28443 case 6: /* Word load/store. */
28445 as_bad_where (fixP->fx_file, fixP->fx_line,
28446 _("invalid offset, value too big (0x%08lX)"),
28448 newval |= value << 4; /* 6 - 2. */
28451 case 7: /* Byte load/store. */
28453 as_bad_where (fixP->fx_file, fixP->fx_line,
28454 _("invalid offset, value too big (0x%08lX)"),
28456 newval |= value << 6;
28459 case 8: /* Halfword load/store. */
28461 as_bad_where (fixP->fx_file, fixP->fx_line,
28462 _("invalid offset, value too big (0x%08lX)"),
28464 newval |= value << 5; /* 6 - 1. */
28468 as_bad_where (fixP->fx_file, fixP->fx_line,
28469 "Unable to process relocation for thumb opcode: %lx",
28470 (unsigned long) newval);
28473 md_number_to_chars (buf, newval, THUMB_SIZE);
28476 case BFD_RELOC_ARM_THUMB_ADD:
28477 /* This is a complicated relocation, since we use it for all of
28478 the following immediate relocations:
28482 9bit ADD/SUB SP word-aligned
28483 10bit ADD PC/SP word-aligned
28485 The type of instruction being processed is encoded in the
28492 newval = md_chars_to_number (buf, THUMB_SIZE);
28494 int rd = (newval >> 4) & 0xf;
28495 int rs = newval & 0xf;
28496 int subtract = !!(newval & 0x8000);
28498 /* Check for HI regs, only very restricted cases allowed:
28499 Adjusting SP, and using PC or SP to get an address. */
28500 if ((rd > 7 && (rd != REG_SP || rs != REG_SP))
28501 || (rs > 7 && rs != REG_SP && rs != REG_PC))
28502 as_bad_where (fixP->fx_file, fixP->fx_line,
28503 _("invalid Hi register with immediate"));
28505 /* If value is negative, choose the opposite instruction. */
28509 subtract = !subtract;
28511 as_bad_where (fixP->fx_file, fixP->fx_line,
28512 _("immediate value out of range"));
28517 if (value & ~0x1fc)
28518 as_bad_where (fixP->fx_file, fixP->fx_line,
28519 _("invalid immediate for stack address calculation"));
28520 newval = subtract ? T_OPCODE_SUB_ST : T_OPCODE_ADD_ST;
28521 newval |= value >> 2;
28523 else if (rs == REG_PC || rs == REG_SP)
28525 /* PR gas/18541. If the addition is for a defined symbol
28526 within range of an ADR instruction then accept it. */
28529 && fixP->fx_addsy != NULL)
28533 if (! S_IS_DEFINED (fixP->fx_addsy)
28534 || S_GET_SEGMENT (fixP->fx_addsy) != seg
28535 || S_IS_WEAK (fixP->fx_addsy))
28537 as_bad_where (fixP->fx_file, fixP->fx_line,
28538 _("address calculation needs a strongly defined nearby symbol"));
28542 offsetT v = fixP->fx_where + fixP->fx_frag->fr_address;
28544 /* Round up to the next 4-byte boundary. */
28549 v = S_GET_VALUE (fixP->fx_addsy) - v;
28553 as_bad_where (fixP->fx_file, fixP->fx_line,
28554 _("symbol too far away"));
28564 if (subtract || value & ~0x3fc)
28565 as_bad_where (fixP->fx_file, fixP->fx_line,
28566 _("invalid immediate for address calculation (value = 0x%08lX)"),
28567 (unsigned long) (subtract ? - value : value));
28568 newval = (rs == REG_PC ? T_OPCODE_ADD_PC : T_OPCODE_ADD_SP);
28570 newval |= value >> 2;
28575 as_bad_where (fixP->fx_file, fixP->fx_line,
28576 _("immediate value out of range"));
28577 newval = subtract ? T_OPCODE_SUB_I8 : T_OPCODE_ADD_I8;
28578 newval |= (rd << 8) | value;
28583 as_bad_where (fixP->fx_file, fixP->fx_line,
28584 _("immediate value out of range"));
28585 newval = subtract ? T_OPCODE_SUB_I3 : T_OPCODE_ADD_I3;
28586 newval |= rd | (rs << 3) | (value << 6);
28589 md_number_to_chars (buf, newval, THUMB_SIZE);
28592 case BFD_RELOC_ARM_THUMB_IMM:
28593 newval = md_chars_to_number (buf, THUMB_SIZE);
28594 if (value < 0 || value > 255)
28595 as_bad_where (fixP->fx_file, fixP->fx_line,
28596 _("invalid immediate: %ld is out of range"),
28599 md_number_to_chars (buf, newval, THUMB_SIZE);
28602 case BFD_RELOC_ARM_THUMB_SHIFT:
28603 /* 5bit shift value (0..32). LSL cannot take 32. */
28604 newval = md_chars_to_number (buf, THUMB_SIZE) & 0xf83f;
28605 temp = newval & 0xf800;
28606 if (value < 0 || value > 32 || (value == 32 && temp == T_OPCODE_LSL_I))
28607 as_bad_where (fixP->fx_file, fixP->fx_line,
28608 _("invalid shift value: %ld"), (long) value);
28609 /* Shifts of zero must be encoded as LSL. */
28611 newval = (newval & 0x003f) | T_OPCODE_LSL_I;
28612 /* Shifts of 32 are encoded as zero. */
28613 else if (value == 32)
28615 newval |= value << 6;
28616 md_number_to_chars (buf, newval, THUMB_SIZE);
28619 case BFD_RELOC_VTABLE_INHERIT:
28620 case BFD_RELOC_VTABLE_ENTRY:
28624 case BFD_RELOC_ARM_MOVW:
28625 case BFD_RELOC_ARM_MOVT:
28626 case BFD_RELOC_ARM_THUMB_MOVW:
28627 case BFD_RELOC_ARM_THUMB_MOVT:
28628 if (fixP->fx_done || !seg->use_rela_p)
28630 /* REL format relocations are limited to a 16-bit addend. */
28631 if (!fixP->fx_done)
28633 if (value < -0x8000 || value > 0x7fff)
28634 as_bad_where (fixP->fx_file, fixP->fx_line,
28635 _("offset out of range"));
28637 else if (fixP->fx_r_type == BFD_RELOC_ARM_MOVT
28638 || fixP->fx_r_type == BFD_RELOC_ARM_THUMB_MOVT)
28643 if (fixP->fx_r_type == BFD_RELOC_ARM_THUMB_MOVW
28644 || fixP->fx_r_type == BFD_RELOC_ARM_THUMB_MOVT)
28646 newval = get_thumb32_insn (buf);
28647 newval &= 0xfbf08f00;
28648 newval |= (value & 0xf000) << 4;
28649 newval |= (value & 0x0800) << 15;
28650 newval |= (value & 0x0700) << 4;
28651 newval |= (value & 0x00ff);
28652 put_thumb32_insn (buf, newval);
28656 newval = md_chars_to_number (buf, 4);
28657 newval &= 0xfff0f000;
28658 newval |= value & 0x0fff;
28659 newval |= (value & 0xf000) << 4;
28660 md_number_to_chars (buf, newval, 4);
28665 case BFD_RELOC_ARM_THUMB_ALU_ABS_G0_NC:
28666 case BFD_RELOC_ARM_THUMB_ALU_ABS_G1_NC:
28667 case BFD_RELOC_ARM_THUMB_ALU_ABS_G2_NC:
28668 case BFD_RELOC_ARM_THUMB_ALU_ABS_G3_NC:
28669 gas_assert (!fixP->fx_done);
28672 bfd_boolean is_mov;
28673 bfd_vma encoded_addend = value;
28675 /* Check that addend can be encoded in instruction. */
28676 if (!seg->use_rela_p && (value < 0 || value > 255))
28677 as_bad_where (fixP->fx_file, fixP->fx_line,
28678 _("the offset 0x%08lX is not representable"),
28679 (unsigned long) encoded_addend);
28681 /* Extract the instruction. */
28682 insn = md_chars_to_number (buf, THUMB_SIZE);
28683 is_mov = (insn & 0xf800) == 0x2000;
28688 if (!seg->use_rela_p)
28689 insn |= encoded_addend;
28695 /* Extract the instruction. */
28696 /* Encoding is the following
28701 /* The following conditions must be true :
28706 rd = (insn >> 4) & 0xf;
28708 if ((insn & 0x8000) || (rd != rs) || rd > 7)
28709 as_bad_where (fixP->fx_file, fixP->fx_line,
28710 _("Unable to process relocation for thumb opcode: %lx"),
28711 (unsigned long) insn);
28713 /* Encode as ADD immediate8 thumb 1 code. */
28714 insn = 0x3000 | (rd << 8);
28716 /* Place the encoded addend into the first 8 bits of the
28718 if (!seg->use_rela_p)
28719 insn |= encoded_addend;
28722 /* Update the instruction. */
28723 md_number_to_chars (buf, insn, THUMB_SIZE);
28727 case BFD_RELOC_ARM_ALU_PC_G0_NC:
28728 case BFD_RELOC_ARM_ALU_PC_G0:
28729 case BFD_RELOC_ARM_ALU_PC_G1_NC:
28730 case BFD_RELOC_ARM_ALU_PC_G1:
28731 case BFD_RELOC_ARM_ALU_PC_G2:
28732 case BFD_RELOC_ARM_ALU_SB_G0_NC:
28733 case BFD_RELOC_ARM_ALU_SB_G0:
28734 case BFD_RELOC_ARM_ALU_SB_G1_NC:
28735 case BFD_RELOC_ARM_ALU_SB_G1:
28736 case BFD_RELOC_ARM_ALU_SB_G2:
28737 gas_assert (!fixP->fx_done);
28738 if (!seg->use_rela_p)
28741 bfd_vma encoded_addend;
28742 bfd_vma addend_abs = llabs (value);
28744 /* Check that the absolute value of the addend can be
28745 expressed as an 8-bit constant plus a rotation. */
28746 encoded_addend = encode_arm_immediate (addend_abs);
28747 if (encoded_addend == (unsigned int) FAIL)
28748 as_bad_where (fixP->fx_file, fixP->fx_line,
28749 _("the offset 0x%08lX is not representable"),
28750 (unsigned long) addend_abs);
28752 /* Extract the instruction. */
28753 insn = md_chars_to_number (buf, INSN_SIZE);
28755 /* If the addend is positive, use an ADD instruction.
28756 Otherwise use a SUB. Take care not to destroy the S bit. */
28757 insn &= 0xff1fffff;
28763 /* Place the encoded addend into the first 12 bits of the
28765 insn &= 0xfffff000;
28766 insn |= encoded_addend;
28768 /* Update the instruction. */
28769 md_number_to_chars (buf, insn, INSN_SIZE);
28773 case BFD_RELOC_ARM_LDR_PC_G0:
28774 case BFD_RELOC_ARM_LDR_PC_G1:
28775 case BFD_RELOC_ARM_LDR_PC_G2:
28776 case BFD_RELOC_ARM_LDR_SB_G0:
28777 case BFD_RELOC_ARM_LDR_SB_G1:
28778 case BFD_RELOC_ARM_LDR_SB_G2:
28779 gas_assert (!fixP->fx_done);
28780 if (!seg->use_rela_p)
28783 bfd_vma addend_abs = llabs (value);
28785 /* Check that the absolute value of the addend can be
28786 encoded in 12 bits. */
28787 if (addend_abs >= 0x1000)
28788 as_bad_where (fixP->fx_file, fixP->fx_line,
28789 _("bad offset 0x%08lX (only 12 bits available for the magnitude)"),
28790 (unsigned long) addend_abs);
28792 /* Extract the instruction. */
28793 insn = md_chars_to_number (buf, INSN_SIZE);
28795 /* If the addend is negative, clear bit 23 of the instruction.
28796 Otherwise set it. */
28798 insn &= ~(1 << 23);
28802 /* Place the absolute value of the addend into the first 12 bits
28803 of the instruction. */
28804 insn &= 0xfffff000;
28805 insn |= addend_abs;
28807 /* Update the instruction. */
28808 md_number_to_chars (buf, insn, INSN_SIZE);
28812 case BFD_RELOC_ARM_LDRS_PC_G0:
28813 case BFD_RELOC_ARM_LDRS_PC_G1:
28814 case BFD_RELOC_ARM_LDRS_PC_G2:
28815 case BFD_RELOC_ARM_LDRS_SB_G0:
28816 case BFD_RELOC_ARM_LDRS_SB_G1:
28817 case BFD_RELOC_ARM_LDRS_SB_G2:
28818 gas_assert (!fixP->fx_done);
28819 if (!seg->use_rela_p)
28822 bfd_vma addend_abs = llabs (value);
28824 /* Check that the absolute value of the addend can be
28825 encoded in 8 bits. */
28826 if (addend_abs >= 0x100)
28827 as_bad_where (fixP->fx_file, fixP->fx_line,
28828 _("bad offset 0x%08lX (only 8 bits available for the magnitude)"),
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 first four bits of the absolute value of the addend
28842 into the first 4 bits of the instruction, and the remaining
28843 four into bits 8 .. 11. */
28844 insn &= 0xfffff0f0;
28845 insn |= (addend_abs & 0xf) | ((addend_abs & 0xf0) << 4);
28847 /* Update the instruction. */
28848 md_number_to_chars (buf, insn, INSN_SIZE);
28852 case BFD_RELOC_ARM_LDC_PC_G0:
28853 case BFD_RELOC_ARM_LDC_PC_G1:
28854 case BFD_RELOC_ARM_LDC_PC_G2:
28855 case BFD_RELOC_ARM_LDC_SB_G0:
28856 case BFD_RELOC_ARM_LDC_SB_G1:
28857 case BFD_RELOC_ARM_LDC_SB_G2:
28858 gas_assert (!fixP->fx_done);
28859 if (!seg->use_rela_p)
28862 bfd_vma addend_abs = llabs (value);
28864 /* Check that the absolute value of the addend is a multiple of
28865 four and, when divided by four, fits in 8 bits. */
28866 if (addend_abs & 0x3)
28867 as_bad_where (fixP->fx_file, fixP->fx_line,
28868 _("bad offset 0x%08lX (must be word-aligned)"),
28869 (unsigned long) addend_abs);
28871 if ((addend_abs >> 2) > 0xff)
28872 as_bad_where (fixP->fx_file, fixP->fx_line,
28873 _("bad offset 0x%08lX (must be an 8-bit number of words)"),
28874 (unsigned long) addend_abs);
28876 /* Extract the instruction. */
28877 insn = md_chars_to_number (buf, INSN_SIZE);
28879 /* If the addend is negative, clear bit 23 of the instruction.
28880 Otherwise set it. */
28882 insn &= ~(1 << 23);
28886 /* Place the addend (divided by four) into the first eight
28887 bits of the instruction. */
28888 insn &= 0xfffffff0;
28889 insn |= addend_abs >> 2;
28891 /* Update the instruction. */
28892 md_number_to_chars (buf, insn, INSN_SIZE);
28896 case BFD_RELOC_THUMB_PCREL_BRANCH5:
28898 && (S_GET_SEGMENT (fixP->fx_addsy) == seg)
28899 && !S_FORCE_RELOC (fixP->fx_addsy, TRUE)
28900 && ARM_IS_FUNC (fixP->fx_addsy)
28901 && ARM_CPU_HAS_FEATURE (selected_cpu, arm_ext_v8_1m_main))
28903 /* Force a relocation for a branch 5 bits wide. */
28906 if (v8_1_branch_value_check (value, 5, FALSE) == FAIL)
28907 as_bad_where (fixP->fx_file, fixP->fx_line,
28910 if (fixP->fx_done || !seg->use_rela_p)
28912 addressT boff = value >> 1;
28914 newval = md_chars_to_number (buf, THUMB_SIZE);
28915 newval |= (boff << 7);
28916 md_number_to_chars (buf, newval, THUMB_SIZE);
28920 case BFD_RELOC_THUMB_PCREL_BFCSEL:
28922 && (S_GET_SEGMENT (fixP->fx_addsy) == seg)
28923 && !S_FORCE_RELOC (fixP->fx_addsy, TRUE)
28924 && ARM_IS_FUNC (fixP->fx_addsy)
28925 && ARM_CPU_HAS_FEATURE (selected_cpu, arm_ext_v8_1m_main))
28929 if ((value & ~0x7f) && ((value & ~0x3f) != ~0x3f))
28930 as_bad_where (fixP->fx_file, fixP->fx_line,
28931 _("branch out of range"));
28933 if (fixP->fx_done || !seg->use_rela_p)
28935 newval = md_chars_to_number (buf, THUMB_SIZE);
28937 addressT boff = ((newval & 0x0780) >> 7) << 1;
28938 addressT diff = value - boff;
28942 newval |= 1 << 1; /* T bit. */
28944 else if (diff != 2)
28946 as_bad_where (fixP->fx_file, fixP->fx_line,
28947 _("out of range label-relative fixup value"));
28949 md_number_to_chars (buf, newval, THUMB_SIZE);
28953 case BFD_RELOC_ARM_THUMB_BF17:
28955 && (S_GET_SEGMENT (fixP->fx_addsy) == seg)
28956 && !S_FORCE_RELOC (fixP->fx_addsy, TRUE)
28957 && ARM_IS_FUNC (fixP->fx_addsy)
28958 && ARM_CPU_HAS_FEATURE (selected_cpu, arm_ext_v8_1m_main))
28960 /* Force a relocation for a branch 17 bits wide. */
28964 if (v8_1_branch_value_check (value, 17, TRUE) == FAIL)
28965 as_bad_where (fixP->fx_file, fixP->fx_line,
28968 if (fixP->fx_done || !seg->use_rela_p)
28971 addressT immA, immB, immC;
28973 immA = (value & 0x0001f000) >> 12;
28974 immB = (value & 0x00000ffc) >> 2;
28975 immC = (value & 0x00000002) >> 1;
28977 newval = md_chars_to_number (buf, THUMB_SIZE);
28978 newval2 = md_chars_to_number (buf + THUMB_SIZE, THUMB_SIZE);
28980 newval2 |= (immC << 11) | (immB << 1);
28981 md_number_to_chars (buf, newval, THUMB_SIZE);
28982 md_number_to_chars (buf + THUMB_SIZE, newval2, THUMB_SIZE);
28986 case BFD_RELOC_ARM_THUMB_BF19:
28988 && (S_GET_SEGMENT (fixP->fx_addsy) == seg)
28989 && !S_FORCE_RELOC (fixP->fx_addsy, TRUE)
28990 && ARM_IS_FUNC (fixP->fx_addsy)
28991 && ARM_CPU_HAS_FEATURE (selected_cpu, arm_ext_v8_1m_main))
28993 /* Force a relocation for a branch 19 bits wide. */
28997 if (v8_1_branch_value_check (value, 19, TRUE) == FAIL)
28998 as_bad_where (fixP->fx_file, fixP->fx_line,
29001 if (fixP->fx_done || !seg->use_rela_p)
29004 addressT immA, immB, immC;
29006 immA = (value & 0x0007f000) >> 12;
29007 immB = (value & 0x00000ffc) >> 2;
29008 immC = (value & 0x00000002) >> 1;
29010 newval = md_chars_to_number (buf, THUMB_SIZE);
29011 newval2 = md_chars_to_number (buf + THUMB_SIZE, THUMB_SIZE);
29013 newval2 |= (immC << 11) | (immB << 1);
29014 md_number_to_chars (buf, newval, THUMB_SIZE);
29015 md_number_to_chars (buf + THUMB_SIZE, newval2, THUMB_SIZE);
29019 case BFD_RELOC_ARM_THUMB_BF13:
29021 && (S_GET_SEGMENT (fixP->fx_addsy) == seg)
29022 && !S_FORCE_RELOC (fixP->fx_addsy, TRUE)
29023 && ARM_IS_FUNC (fixP->fx_addsy)
29024 && ARM_CPU_HAS_FEATURE (selected_cpu, arm_ext_v8_1m_main))
29026 /* Force a relocation for a branch 13 bits wide. */
29030 if (v8_1_branch_value_check (value, 13, TRUE) == FAIL)
29031 as_bad_where (fixP->fx_file, fixP->fx_line,
29034 if (fixP->fx_done || !seg->use_rela_p)
29037 addressT immA, immB, immC;
29039 immA = (value & 0x00001000) >> 12;
29040 immB = (value & 0x00000ffc) >> 2;
29041 immC = (value & 0x00000002) >> 1;
29043 newval = md_chars_to_number (buf, THUMB_SIZE);
29044 newval2 = md_chars_to_number (buf + THUMB_SIZE, THUMB_SIZE);
29046 newval2 |= (immC << 11) | (immB << 1);
29047 md_number_to_chars (buf, newval, THUMB_SIZE);
29048 md_number_to_chars (buf + THUMB_SIZE, newval2, THUMB_SIZE);
29052 case BFD_RELOC_ARM_THUMB_LOOP12:
29054 && (S_GET_SEGMENT (fixP->fx_addsy) == seg)
29055 && !S_FORCE_RELOC (fixP->fx_addsy, TRUE)
29056 && ARM_IS_FUNC (fixP->fx_addsy)
29057 && ARM_CPU_HAS_FEATURE (selected_cpu, arm_ext_v8_1m_main))
29059 /* Force a relocation for a branch 12 bits wide. */
29063 bfd_vma insn = get_thumb32_insn (buf);
29064 /* le lr, <label>, le <label> or letp lr, <label> */
29065 if (((insn & 0xffffffff) == 0xf00fc001)
29066 || ((insn & 0xffffffff) == 0xf02fc001)
29067 || ((insn & 0xffffffff) == 0xf01fc001))
29070 if (v8_1_branch_value_check (value, 12, FALSE) == FAIL)
29071 as_bad_where (fixP->fx_file, fixP->fx_line,
29073 if (fixP->fx_done || !seg->use_rela_p)
29075 addressT imml, immh;
29077 immh = (value & 0x00000ffc) >> 2;
29078 imml = (value & 0x00000002) >> 1;
29080 newval = md_chars_to_number (buf + THUMB_SIZE, THUMB_SIZE);
29081 newval |= (imml << 11) | (immh << 1);
29082 md_number_to_chars (buf + THUMB_SIZE, newval, THUMB_SIZE);
29086 case BFD_RELOC_ARM_V4BX:
29087 /* This will need to go in the object file. */
29091 case BFD_RELOC_UNUSED:
29093 as_bad_where (fixP->fx_file, fixP->fx_line,
29094 _("bad relocation fixup type (%d)"), fixP->fx_r_type);
29098 /* Translate internal representation of relocation info to BFD target
29102 tc_gen_reloc (asection *section, fixS *fixp)
29105 bfd_reloc_code_real_type code;
29107 reloc = XNEW (arelent);
29109 reloc->sym_ptr_ptr = XNEW (asymbol *);
29110 *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
29111 reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
29113 if (fixp->fx_pcrel)
29115 if (section->use_rela_p)
29116 fixp->fx_offset -= md_pcrel_from_section (fixp, section);
29118 fixp->fx_offset = reloc->address;
29120 reloc->addend = fixp->fx_offset;
29122 switch (fixp->fx_r_type)
29125 if (fixp->fx_pcrel)
29127 code = BFD_RELOC_8_PCREL;
29130 /* Fall through. */
29133 if (fixp->fx_pcrel)
29135 code = BFD_RELOC_16_PCREL;
29138 /* Fall through. */
29141 if (fixp->fx_pcrel)
29143 code = BFD_RELOC_32_PCREL;
29146 /* Fall through. */
29148 case BFD_RELOC_ARM_MOVW:
29149 if (fixp->fx_pcrel)
29151 code = BFD_RELOC_ARM_MOVW_PCREL;
29154 /* Fall through. */
29156 case BFD_RELOC_ARM_MOVT:
29157 if (fixp->fx_pcrel)
29159 code = BFD_RELOC_ARM_MOVT_PCREL;
29162 /* Fall through. */
29164 case BFD_RELOC_ARM_THUMB_MOVW:
29165 if (fixp->fx_pcrel)
29167 code = BFD_RELOC_ARM_THUMB_MOVW_PCREL;
29170 /* Fall through. */
29172 case BFD_RELOC_ARM_THUMB_MOVT:
29173 if (fixp->fx_pcrel)
29175 code = BFD_RELOC_ARM_THUMB_MOVT_PCREL;
29178 /* Fall through. */
29180 case BFD_RELOC_NONE:
29181 case BFD_RELOC_ARM_PCREL_BRANCH:
29182 case BFD_RELOC_ARM_PCREL_BLX:
29183 case BFD_RELOC_RVA:
29184 case BFD_RELOC_THUMB_PCREL_BRANCH7:
29185 case BFD_RELOC_THUMB_PCREL_BRANCH9:
29186 case BFD_RELOC_THUMB_PCREL_BRANCH12:
29187 case BFD_RELOC_THUMB_PCREL_BRANCH20:
29188 case BFD_RELOC_THUMB_PCREL_BRANCH23:
29189 case BFD_RELOC_THUMB_PCREL_BRANCH25:
29190 case BFD_RELOC_VTABLE_ENTRY:
29191 case BFD_RELOC_VTABLE_INHERIT:
29193 case BFD_RELOC_32_SECREL:
29195 code = fixp->fx_r_type;
29198 case BFD_RELOC_THUMB_PCREL_BLX:
29200 if (EF_ARM_EABI_VERSION (meabi_flags) >= EF_ARM_EABI_VER4)
29201 code = BFD_RELOC_THUMB_PCREL_BRANCH23;
29204 code = BFD_RELOC_THUMB_PCREL_BLX;
29207 case BFD_RELOC_ARM_LITERAL:
29208 case BFD_RELOC_ARM_HWLITERAL:
29209 /* If this is called then the a literal has
29210 been referenced across a section boundary. */
29211 as_bad_where (fixp->fx_file, fixp->fx_line,
29212 _("literal referenced across section boundary"));
29216 case BFD_RELOC_ARM_TLS_CALL:
29217 case BFD_RELOC_ARM_THM_TLS_CALL:
29218 case BFD_RELOC_ARM_TLS_DESCSEQ:
29219 case BFD_RELOC_ARM_THM_TLS_DESCSEQ:
29220 case BFD_RELOC_ARM_GOT32:
29221 case BFD_RELOC_ARM_GOTOFF:
29222 case BFD_RELOC_ARM_GOT_PREL:
29223 case BFD_RELOC_ARM_PLT32:
29224 case BFD_RELOC_ARM_TARGET1:
29225 case BFD_RELOC_ARM_ROSEGREL32:
29226 case BFD_RELOC_ARM_SBREL32:
29227 case BFD_RELOC_ARM_PREL31:
29228 case BFD_RELOC_ARM_TARGET2:
29229 case BFD_RELOC_ARM_TLS_LDO32:
29230 case BFD_RELOC_ARM_PCREL_CALL:
29231 case BFD_RELOC_ARM_PCREL_JUMP:
29232 case BFD_RELOC_ARM_ALU_PC_G0_NC:
29233 case BFD_RELOC_ARM_ALU_PC_G0:
29234 case BFD_RELOC_ARM_ALU_PC_G1_NC:
29235 case BFD_RELOC_ARM_ALU_PC_G1:
29236 case BFD_RELOC_ARM_ALU_PC_G2:
29237 case BFD_RELOC_ARM_LDR_PC_G0:
29238 case BFD_RELOC_ARM_LDR_PC_G1:
29239 case BFD_RELOC_ARM_LDR_PC_G2:
29240 case BFD_RELOC_ARM_LDRS_PC_G0:
29241 case BFD_RELOC_ARM_LDRS_PC_G1:
29242 case BFD_RELOC_ARM_LDRS_PC_G2:
29243 case BFD_RELOC_ARM_LDC_PC_G0:
29244 case BFD_RELOC_ARM_LDC_PC_G1:
29245 case BFD_RELOC_ARM_LDC_PC_G2:
29246 case BFD_RELOC_ARM_ALU_SB_G0_NC:
29247 case BFD_RELOC_ARM_ALU_SB_G0:
29248 case BFD_RELOC_ARM_ALU_SB_G1_NC:
29249 case BFD_RELOC_ARM_ALU_SB_G1:
29250 case BFD_RELOC_ARM_ALU_SB_G2:
29251 case BFD_RELOC_ARM_LDR_SB_G0:
29252 case BFD_RELOC_ARM_LDR_SB_G1:
29253 case BFD_RELOC_ARM_LDR_SB_G2:
29254 case BFD_RELOC_ARM_LDRS_SB_G0:
29255 case BFD_RELOC_ARM_LDRS_SB_G1:
29256 case BFD_RELOC_ARM_LDRS_SB_G2:
29257 case BFD_RELOC_ARM_LDC_SB_G0:
29258 case BFD_RELOC_ARM_LDC_SB_G1:
29259 case BFD_RELOC_ARM_LDC_SB_G2:
29260 case BFD_RELOC_ARM_V4BX:
29261 case BFD_RELOC_ARM_THUMB_ALU_ABS_G0_NC:
29262 case BFD_RELOC_ARM_THUMB_ALU_ABS_G1_NC:
29263 case BFD_RELOC_ARM_THUMB_ALU_ABS_G2_NC:
29264 case BFD_RELOC_ARM_THUMB_ALU_ABS_G3_NC:
29265 case BFD_RELOC_ARM_GOTFUNCDESC:
29266 case BFD_RELOC_ARM_GOTOFFFUNCDESC:
29267 case BFD_RELOC_ARM_FUNCDESC:
29268 case BFD_RELOC_ARM_THUMB_BF17:
29269 case BFD_RELOC_ARM_THUMB_BF19:
29270 case BFD_RELOC_ARM_THUMB_BF13:
29271 code = fixp->fx_r_type;
29274 case BFD_RELOC_ARM_TLS_GOTDESC:
29275 case BFD_RELOC_ARM_TLS_GD32:
29276 case BFD_RELOC_ARM_TLS_GD32_FDPIC:
29277 case BFD_RELOC_ARM_TLS_LE32:
29278 case BFD_RELOC_ARM_TLS_IE32:
29279 case BFD_RELOC_ARM_TLS_IE32_FDPIC:
29280 case BFD_RELOC_ARM_TLS_LDM32:
29281 case BFD_RELOC_ARM_TLS_LDM32_FDPIC:
29282 /* BFD will include the symbol's address in the addend.
29283 But we don't want that, so subtract it out again here. */
29284 if (!S_IS_COMMON (fixp->fx_addsy))
29285 reloc->addend -= (*reloc->sym_ptr_ptr)->value;
29286 code = fixp->fx_r_type;
29290 case BFD_RELOC_ARM_IMMEDIATE:
29291 as_bad_where (fixp->fx_file, fixp->fx_line,
29292 _("internal relocation (type: IMMEDIATE) not fixed up"));
29295 case BFD_RELOC_ARM_ADRL_IMMEDIATE:
29296 as_bad_where (fixp->fx_file, fixp->fx_line,
29297 _("ADRL used for a symbol not defined in the same file"));
29300 case BFD_RELOC_THUMB_PCREL_BRANCH5:
29301 case BFD_RELOC_THUMB_PCREL_BFCSEL:
29302 case BFD_RELOC_ARM_THUMB_LOOP12:
29303 as_bad_where (fixp->fx_file, fixp->fx_line,
29304 _("%s used for a symbol not defined in the same file"),
29305 bfd_get_reloc_code_name (fixp->fx_r_type));
29308 case BFD_RELOC_ARM_OFFSET_IMM:
29309 if (section->use_rela_p)
29311 code = fixp->fx_r_type;
29315 if (fixp->fx_addsy != NULL
29316 && !S_IS_DEFINED (fixp->fx_addsy)
29317 && S_IS_LOCAL (fixp->fx_addsy))
29319 as_bad_where (fixp->fx_file, fixp->fx_line,
29320 _("undefined local label `%s'"),
29321 S_GET_NAME (fixp->fx_addsy));
29325 as_bad_where (fixp->fx_file, fixp->fx_line,
29326 _("internal_relocation (type: OFFSET_IMM) not fixed up"));
29333 switch (fixp->fx_r_type)
29335 case BFD_RELOC_NONE: type = "NONE"; break;
29336 case BFD_RELOC_ARM_OFFSET_IMM8: type = "OFFSET_IMM8"; break;
29337 case BFD_RELOC_ARM_SHIFT_IMM: type = "SHIFT_IMM"; break;
29338 case BFD_RELOC_ARM_SMC: type = "SMC"; break;
29339 case BFD_RELOC_ARM_SWI: type = "SWI"; break;
29340 case BFD_RELOC_ARM_MULTI: type = "MULTI"; break;
29341 case BFD_RELOC_ARM_CP_OFF_IMM: type = "CP_OFF_IMM"; break;
29342 case BFD_RELOC_ARM_T32_OFFSET_IMM: type = "T32_OFFSET_IMM"; break;
29343 case BFD_RELOC_ARM_T32_CP_OFF_IMM: type = "T32_CP_OFF_IMM"; break;
29344 case BFD_RELOC_ARM_THUMB_ADD: type = "THUMB_ADD"; break;
29345 case BFD_RELOC_ARM_THUMB_SHIFT: type = "THUMB_SHIFT"; break;
29346 case BFD_RELOC_ARM_THUMB_IMM: type = "THUMB_IMM"; break;
29347 case BFD_RELOC_ARM_THUMB_OFFSET: type = "THUMB_OFFSET"; break;
29348 default: type = _("<unknown>"); break;
29350 as_bad_where (fixp->fx_file, fixp->fx_line,
29351 _("cannot represent %s relocation in this object file format"),
29358 if ((code == BFD_RELOC_32_PCREL || code == BFD_RELOC_32)
29360 && fixp->fx_addsy == GOT_symbol)
29362 code = BFD_RELOC_ARM_GOTPC;
29363 reloc->addend = fixp->fx_offset = reloc->address;
29367 reloc->howto = bfd_reloc_type_lookup (stdoutput, code);
29369 if (reloc->howto == NULL)
29371 as_bad_where (fixp->fx_file, fixp->fx_line,
29372 _("cannot represent %s relocation in this object file format"),
29373 bfd_get_reloc_code_name (code));
29377 /* HACK: Since arm ELF uses Rel instead of Rela, encode the
29378 vtable entry to be used in the relocation's section offset. */
29379 if (fixp->fx_r_type == BFD_RELOC_VTABLE_ENTRY)
29380 reloc->address = fixp->fx_offset;
29385 /* This fix_new is called by cons via TC_CONS_FIX_NEW. */
29388 cons_fix_new_arm (fragS * frag,
29392 bfd_reloc_code_real_type reloc)
29397 FIXME: @@ Should look at CPU word size. */
29401 reloc = BFD_RELOC_8;
29404 reloc = BFD_RELOC_16;
29408 reloc = BFD_RELOC_32;
29411 reloc = BFD_RELOC_64;
29416 if (exp->X_op == O_secrel)
29418 exp->X_op = O_symbol;
29419 reloc = BFD_RELOC_32_SECREL;
29423 fix_new_exp (frag, where, size, exp, pcrel, reloc);
29426 #if defined (OBJ_COFF)
29428 arm_validate_fix (fixS * fixP)
29430 /* If the destination of the branch is a defined symbol which does not have
29431 the THUMB_FUNC attribute, then we must be calling a function which has
29432 the (interfacearm) attribute. We look for the Thumb entry point to that
29433 function and change the branch to refer to that function instead. */
29434 if (fixP->fx_r_type == BFD_RELOC_THUMB_PCREL_BRANCH23
29435 && fixP->fx_addsy != NULL
29436 && S_IS_DEFINED (fixP->fx_addsy)
29437 && ! THUMB_IS_FUNC (fixP->fx_addsy))
29439 fixP->fx_addsy = find_real_start (fixP->fx_addsy);
29446 arm_force_relocation (struct fix * fixp)
29448 #if defined (OBJ_COFF) && defined (TE_PE)
29449 if (fixp->fx_r_type == BFD_RELOC_RVA)
29453 /* In case we have a call or a branch to a function in ARM ISA mode from
29454 a thumb function or vice-versa force the relocation. These relocations
29455 are cleared off for some cores that might have blx and simple transformations
29459 switch (fixp->fx_r_type)
29461 case BFD_RELOC_ARM_PCREL_JUMP:
29462 case BFD_RELOC_ARM_PCREL_CALL:
29463 case BFD_RELOC_THUMB_PCREL_BLX:
29464 if (THUMB_IS_FUNC (fixp->fx_addsy))
29468 case BFD_RELOC_ARM_PCREL_BLX:
29469 case BFD_RELOC_THUMB_PCREL_BRANCH25:
29470 case BFD_RELOC_THUMB_PCREL_BRANCH20:
29471 case BFD_RELOC_THUMB_PCREL_BRANCH23:
29472 if (ARM_IS_FUNC (fixp->fx_addsy))
29481 /* Resolve these relocations even if the symbol is extern or weak.
29482 Technically this is probably wrong due to symbol preemption.
29483 In practice these relocations do not have enough range to be useful
29484 at dynamic link time, and some code (e.g. in the Linux kernel)
29485 expects these references to be resolved. */
29486 if (fixp->fx_r_type == BFD_RELOC_ARM_IMMEDIATE
29487 || fixp->fx_r_type == BFD_RELOC_ARM_OFFSET_IMM
29488 || fixp->fx_r_type == BFD_RELOC_ARM_OFFSET_IMM8
29489 || fixp->fx_r_type == BFD_RELOC_ARM_ADRL_IMMEDIATE
29490 || fixp->fx_r_type == BFD_RELOC_ARM_CP_OFF_IMM
29491 || fixp->fx_r_type == BFD_RELOC_ARM_CP_OFF_IMM_S2
29492 || fixp->fx_r_type == BFD_RELOC_ARM_THUMB_OFFSET
29493 || fixp->fx_r_type == BFD_RELOC_ARM_T32_ADD_IMM
29494 || fixp->fx_r_type == BFD_RELOC_ARM_T32_IMMEDIATE
29495 || fixp->fx_r_type == BFD_RELOC_ARM_T32_IMM12
29496 || fixp->fx_r_type == BFD_RELOC_ARM_T32_OFFSET_IMM
29497 || fixp->fx_r_type == BFD_RELOC_ARM_T32_ADD_PC12
29498 || fixp->fx_r_type == BFD_RELOC_ARM_T32_CP_OFF_IMM
29499 || fixp->fx_r_type == BFD_RELOC_ARM_T32_CP_OFF_IMM_S2)
29502 /* Always leave these relocations for the linker. */
29503 if ((fixp->fx_r_type >= BFD_RELOC_ARM_ALU_PC_G0_NC
29504 && fixp->fx_r_type <= BFD_RELOC_ARM_LDC_SB_G2)
29505 || fixp->fx_r_type == BFD_RELOC_ARM_LDR_PC_G0)
29508 /* Always generate relocations against function symbols. */
29509 if (fixp->fx_r_type == BFD_RELOC_32
29511 && (symbol_get_bfdsym (fixp->fx_addsy)->flags & BSF_FUNCTION))
29514 return generic_force_reloc (fixp);
29517 #if defined (OBJ_ELF) || defined (OBJ_COFF)
29518 /* Relocations against function names must be left unadjusted,
29519 so that the linker can use this information to generate interworking
29520 stubs. The MIPS version of this function
29521 also prevents relocations that are mips-16 specific, but I do not
29522 know why it does this.
29525 There is one other problem that ought to be addressed here, but
29526 which currently is not: Taking the address of a label (rather
29527 than a function) and then later jumping to that address. Such
29528 addresses also ought to have their bottom bit set (assuming that
29529 they reside in Thumb code), but at the moment they will not. */
29532 arm_fix_adjustable (fixS * fixP)
29534 if (fixP->fx_addsy == NULL)
29537 /* Preserve relocations against symbols with function type. */
29538 if (symbol_get_bfdsym (fixP->fx_addsy)->flags & BSF_FUNCTION)
29541 if (THUMB_IS_FUNC (fixP->fx_addsy)
29542 && fixP->fx_subsy == NULL)
29545 /* We need the symbol name for the VTABLE entries. */
29546 if ( fixP->fx_r_type == BFD_RELOC_VTABLE_INHERIT
29547 || fixP->fx_r_type == BFD_RELOC_VTABLE_ENTRY)
29550 /* Don't allow symbols to be discarded on GOT related relocs. */
29551 if (fixP->fx_r_type == BFD_RELOC_ARM_PLT32
29552 || fixP->fx_r_type == BFD_RELOC_ARM_GOT32
29553 || fixP->fx_r_type == BFD_RELOC_ARM_GOTOFF
29554 || fixP->fx_r_type == BFD_RELOC_ARM_TLS_GD32
29555 || fixP->fx_r_type == BFD_RELOC_ARM_TLS_GD32_FDPIC
29556 || fixP->fx_r_type == BFD_RELOC_ARM_TLS_LE32
29557 || fixP->fx_r_type == BFD_RELOC_ARM_TLS_IE32
29558 || fixP->fx_r_type == BFD_RELOC_ARM_TLS_IE32_FDPIC
29559 || fixP->fx_r_type == BFD_RELOC_ARM_TLS_LDM32
29560 || fixP->fx_r_type == BFD_RELOC_ARM_TLS_LDM32_FDPIC
29561 || fixP->fx_r_type == BFD_RELOC_ARM_TLS_LDO32
29562 || fixP->fx_r_type == BFD_RELOC_ARM_TLS_GOTDESC
29563 || fixP->fx_r_type == BFD_RELOC_ARM_TLS_CALL
29564 || fixP->fx_r_type == BFD_RELOC_ARM_THM_TLS_CALL
29565 || fixP->fx_r_type == BFD_RELOC_ARM_TLS_DESCSEQ
29566 || fixP->fx_r_type == BFD_RELOC_ARM_THM_TLS_DESCSEQ
29567 || fixP->fx_r_type == BFD_RELOC_ARM_TARGET2)
29570 /* Similarly for group relocations. */
29571 if ((fixP->fx_r_type >= BFD_RELOC_ARM_ALU_PC_G0_NC
29572 && fixP->fx_r_type <= BFD_RELOC_ARM_LDC_SB_G2)
29573 || fixP->fx_r_type == BFD_RELOC_ARM_LDR_PC_G0)
29576 /* MOVW/MOVT REL relocations have limited offsets, so keep the symbols. */
29577 if (fixP->fx_r_type == BFD_RELOC_ARM_MOVW
29578 || fixP->fx_r_type == BFD_RELOC_ARM_MOVT
29579 || fixP->fx_r_type == BFD_RELOC_ARM_MOVW_PCREL
29580 || fixP->fx_r_type == BFD_RELOC_ARM_MOVT_PCREL
29581 || fixP->fx_r_type == BFD_RELOC_ARM_THUMB_MOVW
29582 || fixP->fx_r_type == BFD_RELOC_ARM_THUMB_MOVT
29583 || fixP->fx_r_type == BFD_RELOC_ARM_THUMB_MOVW_PCREL
29584 || fixP->fx_r_type == BFD_RELOC_ARM_THUMB_MOVT_PCREL)
29587 /* BFD_RELOC_ARM_THUMB_ALU_ABS_Gx_NC relocations have VERY limited
29588 offsets, so keep these symbols. */
29589 if (fixP->fx_r_type >= BFD_RELOC_ARM_THUMB_ALU_ABS_G0_NC
29590 && fixP->fx_r_type <= BFD_RELOC_ARM_THUMB_ALU_ABS_G3_NC)
29595 #endif /* defined (OBJ_ELF) || defined (OBJ_COFF) */
29599 elf32_arm_target_format (void)
29602 return (target_big_endian
29603 ? "elf32-bigarm-symbian"
29604 : "elf32-littlearm-symbian");
29605 #elif defined (TE_VXWORKS)
29606 return (target_big_endian
29607 ? "elf32-bigarm-vxworks"
29608 : "elf32-littlearm-vxworks");
29609 #elif defined (TE_NACL)
29610 return (target_big_endian
29611 ? "elf32-bigarm-nacl"
29612 : "elf32-littlearm-nacl");
29616 if (target_big_endian)
29617 return "elf32-bigarm-fdpic";
29619 return "elf32-littlearm-fdpic";
29623 if (target_big_endian)
29624 return "elf32-bigarm";
29626 return "elf32-littlearm";
29632 armelf_frob_symbol (symbolS * symp,
29635 elf_frob_symbol (symp, puntp);
29639 /* MD interface: Finalization. */
29644 literal_pool * pool;
29646 /* Ensure that all the predication blocks are properly closed. */
29647 check_pred_blocks_finished ();
29649 for (pool = list_of_pools; pool; pool = pool->next)
29651 /* Put it at the end of the relevant section. */
29652 subseg_set (pool->section, pool->sub_section);
29654 arm_elf_change_section ();
29661 /* Remove any excess mapping symbols generated for alignment frags in
29662 SEC. We may have created a mapping symbol before a zero byte
29663 alignment; remove it if there's a mapping symbol after the
29666 check_mapping_symbols (bfd *abfd ATTRIBUTE_UNUSED, asection *sec,
29667 void *dummy ATTRIBUTE_UNUSED)
29669 segment_info_type *seginfo = seg_info (sec);
29672 if (seginfo == NULL || seginfo->frchainP == NULL)
29675 for (fragp = seginfo->frchainP->frch_root;
29677 fragp = fragp->fr_next)
29679 symbolS *sym = fragp->tc_frag_data.last_map;
29680 fragS *next = fragp->fr_next;
29682 /* Variable-sized frags have been converted to fixed size by
29683 this point. But if this was variable-sized to start with,
29684 there will be a fixed-size frag after it. So don't handle
29686 if (sym == NULL || next == NULL)
29689 if (S_GET_VALUE (sym) < next->fr_address)
29690 /* Not at the end of this frag. */
29692 know (S_GET_VALUE (sym) == next->fr_address);
29696 if (next->tc_frag_data.first_map != NULL)
29698 /* Next frag starts with a mapping symbol. Discard this
29700 symbol_remove (sym, &symbol_rootP, &symbol_lastP);
29704 if (next->fr_next == NULL)
29706 /* This mapping symbol is at the end of the section. Discard
29708 know (next->fr_fix == 0 && next->fr_var == 0);
29709 symbol_remove (sym, &symbol_rootP, &symbol_lastP);
29713 /* As long as we have empty frags without any mapping symbols,
29715 /* If the next frag is non-empty and does not start with a
29716 mapping symbol, then this mapping symbol is required. */
29717 if (next->fr_address != next->fr_next->fr_address)
29720 next = next->fr_next;
29722 while (next != NULL);
29727 /* Adjust the symbol table. This marks Thumb symbols as distinct from
29731 arm_adjust_symtab (void)
29736 for (sym = symbol_rootP; sym != NULL; sym = symbol_next (sym))
29738 if (ARM_IS_THUMB (sym))
29740 if (THUMB_IS_FUNC (sym))
29742 /* Mark the symbol as a Thumb function. */
29743 if ( S_GET_STORAGE_CLASS (sym) == C_STAT
29744 || S_GET_STORAGE_CLASS (sym) == C_LABEL) /* This can happen! */
29745 S_SET_STORAGE_CLASS (sym, C_THUMBSTATFUNC);
29747 else if (S_GET_STORAGE_CLASS (sym) == C_EXT)
29748 S_SET_STORAGE_CLASS (sym, C_THUMBEXTFUNC);
29750 as_bad (_("%s: unexpected function type: %d"),
29751 S_GET_NAME (sym), S_GET_STORAGE_CLASS (sym));
29753 else switch (S_GET_STORAGE_CLASS (sym))
29756 S_SET_STORAGE_CLASS (sym, C_THUMBEXT);
29759 S_SET_STORAGE_CLASS (sym, C_THUMBSTAT);
29762 S_SET_STORAGE_CLASS (sym, C_THUMBLABEL);
29770 if (ARM_IS_INTERWORK (sym))
29771 coffsymbol (symbol_get_bfdsym (sym))->native->u.syment.n_flags = 0xFF;
29778 for (sym = symbol_rootP; sym != NULL; sym = symbol_next (sym))
29780 if (ARM_IS_THUMB (sym))
29782 elf_symbol_type * elf_sym;
29784 elf_sym = elf_symbol (symbol_get_bfdsym (sym));
29785 bind = ELF_ST_BIND (elf_sym->internal_elf_sym.st_info);
29787 if (! bfd_is_arm_special_symbol_name (elf_sym->symbol.name,
29788 BFD_ARM_SPECIAL_SYM_TYPE_ANY))
29790 /* If it's a .thumb_func, declare it as so,
29791 otherwise tag label as .code 16. */
29792 if (THUMB_IS_FUNC (sym))
29793 ARM_SET_SYM_BRANCH_TYPE (elf_sym->internal_elf_sym.st_target_internal,
29794 ST_BRANCH_TO_THUMB);
29795 else if (EF_ARM_EABI_VERSION (meabi_flags) < EF_ARM_EABI_VER4)
29796 elf_sym->internal_elf_sym.st_info =
29797 ELF_ST_INFO (bind, STT_ARM_16BIT);
29802 /* Remove any overlapping mapping symbols generated by alignment frags. */
29803 bfd_map_over_sections (stdoutput, check_mapping_symbols, (char *) 0);
29804 /* Now do generic ELF adjustments. */
29805 elf_adjust_symtab ();
29809 /* MD interface: Initialization. */
29812 set_constant_flonums (void)
29816 for (i = 0; i < NUM_FLOAT_VALS; i++)
29817 if (atof_ieee ((char *) fp_const[i], 'x', fp_values[i]) == NULL)
29821 /* Auto-select Thumb mode if it's the only available instruction set for the
29822 given architecture. */
29825 autoselect_thumb_from_cpu_variant (void)
29827 if (!ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_v1))
29828 opcode_select (16);
29837 if ( (arm_ops_hsh = hash_new ()) == NULL
29838 || (arm_cond_hsh = hash_new ()) == NULL
29839 || (arm_vcond_hsh = hash_new ()) == NULL
29840 || (arm_shift_hsh = hash_new ()) == NULL
29841 || (arm_psr_hsh = hash_new ()) == NULL
29842 || (arm_v7m_psr_hsh = hash_new ()) == NULL
29843 || (arm_reg_hsh = hash_new ()) == NULL
29844 || (arm_reloc_hsh = hash_new ()) == NULL
29845 || (arm_barrier_opt_hsh = hash_new ()) == NULL)
29846 as_fatal (_("virtual memory exhausted"));
29848 for (i = 0; i < sizeof (insns) / sizeof (struct asm_opcode); i++)
29849 hash_insert (arm_ops_hsh, insns[i].template_name, (void *) (insns + i));
29850 for (i = 0; i < sizeof (conds) / sizeof (struct asm_cond); i++)
29851 hash_insert (arm_cond_hsh, conds[i].template_name, (void *) (conds + i));
29852 for (i = 0; i < sizeof (vconds) / sizeof (struct asm_cond); i++)
29853 hash_insert (arm_vcond_hsh, vconds[i].template_name, (void *) (vconds + i));
29854 for (i = 0; i < sizeof (shift_names) / sizeof (struct asm_shift_name); i++)
29855 hash_insert (arm_shift_hsh, shift_names[i].name, (void *) (shift_names + i));
29856 for (i = 0; i < sizeof (psrs) / sizeof (struct asm_psr); i++)
29857 hash_insert (arm_psr_hsh, psrs[i].template_name, (void *) (psrs + i));
29858 for (i = 0; i < sizeof (v7m_psrs) / sizeof (struct asm_psr); i++)
29859 hash_insert (arm_v7m_psr_hsh, v7m_psrs[i].template_name,
29860 (void *) (v7m_psrs + i));
29861 for (i = 0; i < sizeof (reg_names) / sizeof (struct reg_entry); i++)
29862 hash_insert (arm_reg_hsh, reg_names[i].name, (void *) (reg_names + i));
29864 i < sizeof (barrier_opt_names) / sizeof (struct asm_barrier_opt);
29866 hash_insert (arm_barrier_opt_hsh, barrier_opt_names[i].template_name,
29867 (void *) (barrier_opt_names + i));
29869 for (i = 0; i < ARRAY_SIZE (reloc_names); i++)
29871 struct reloc_entry * entry = reloc_names + i;
29873 if (arm_is_eabi() && entry->reloc == BFD_RELOC_ARM_PLT32)
29874 /* This makes encode_branch() use the EABI versions of this relocation. */
29875 entry->reloc = BFD_RELOC_UNUSED;
29877 hash_insert (arm_reloc_hsh, entry->name, (void *) entry);
29881 set_constant_flonums ();
29883 /* Set the cpu variant based on the command-line options. We prefer
29884 -mcpu= over -march= if both are set (as for GCC); and we prefer
29885 -mfpu= over any other way of setting the floating point unit.
29886 Use of legacy options with new options are faulted. */
29889 if (mcpu_cpu_opt || march_cpu_opt)
29890 as_bad (_("use of old and new-style options to set CPU type"));
29892 selected_arch = *legacy_cpu;
29894 else if (mcpu_cpu_opt)
29896 selected_arch = *mcpu_cpu_opt;
29897 selected_ext = *mcpu_ext_opt;
29899 else if (march_cpu_opt)
29901 selected_arch = *march_cpu_opt;
29902 selected_ext = *march_ext_opt;
29904 ARM_MERGE_FEATURE_SETS (selected_cpu, selected_arch, selected_ext);
29909 as_bad (_("use of old and new-style options to set FPU type"));
29911 selected_fpu = *legacy_fpu;
29914 selected_fpu = *mfpu_opt;
29917 #if !(defined (EABI_DEFAULT) || defined (TE_LINUX) \
29918 || defined (TE_NetBSD) || defined (TE_VXWORKS))
29919 /* Some environments specify a default FPU. If they don't, infer it
29920 from the processor. */
29922 selected_fpu = *mcpu_fpu_opt;
29923 else if (march_fpu_opt)
29924 selected_fpu = *march_fpu_opt;
29926 selected_fpu = fpu_default;
29930 if (ARM_FEATURE_ZERO (selected_fpu))
29932 if (!no_cpu_selected ())
29933 selected_fpu = fpu_default;
29935 selected_fpu = fpu_arch_fpa;
29939 if (ARM_FEATURE_ZERO (selected_arch))
29941 selected_arch = cpu_default;
29942 selected_cpu = selected_arch;
29944 ARM_MERGE_FEATURE_SETS (cpu_variant, selected_cpu, selected_fpu);
29946 /* Autodection of feature mode: allow all features in cpu_variant but leave
29947 selected_cpu unset. It will be set in aeabi_set_public_attributes ()
29948 after all instruction have been processed and we can decide what CPU
29949 should be selected. */
29950 if (ARM_FEATURE_ZERO (selected_arch))
29951 ARM_MERGE_FEATURE_SETS (cpu_variant, arm_arch_any, selected_fpu);
29953 ARM_MERGE_FEATURE_SETS (cpu_variant, selected_cpu, selected_fpu);
29956 autoselect_thumb_from_cpu_variant ();
29958 arm_arch_used = thumb_arch_used = arm_arch_none;
29960 #if defined OBJ_COFF || defined OBJ_ELF
29962 unsigned int flags = 0;
29964 #if defined OBJ_ELF
29965 flags = meabi_flags;
29967 switch (meabi_flags)
29969 case EF_ARM_EABI_UNKNOWN:
29971 /* Set the flags in the private structure. */
29972 if (uses_apcs_26) flags |= F_APCS26;
29973 if (support_interwork) flags |= F_INTERWORK;
29974 if (uses_apcs_float) flags |= F_APCS_FLOAT;
29975 if (pic_code) flags |= F_PIC;
29976 if (!ARM_CPU_HAS_FEATURE (cpu_variant, fpu_any_hard))
29977 flags |= F_SOFT_FLOAT;
29979 switch (mfloat_abi_opt)
29981 case ARM_FLOAT_ABI_SOFT:
29982 case ARM_FLOAT_ABI_SOFTFP:
29983 flags |= F_SOFT_FLOAT;
29986 case ARM_FLOAT_ABI_HARD:
29987 if (flags & F_SOFT_FLOAT)
29988 as_bad (_("hard-float conflicts with specified fpu"));
29992 /* Using pure-endian doubles (even if soft-float). */
29993 if (ARM_CPU_HAS_FEATURE (cpu_variant, fpu_endian_pure))
29994 flags |= F_VFP_FLOAT;
29996 #if defined OBJ_ELF
29997 if (ARM_CPU_HAS_FEATURE (cpu_variant, fpu_arch_maverick))
29998 flags |= EF_ARM_MAVERICK_FLOAT;
30001 case EF_ARM_EABI_VER4:
30002 case EF_ARM_EABI_VER5:
30003 /* No additional flags to set. */
30010 bfd_set_private_flags (stdoutput, flags);
30012 /* We have run out flags in the COFF header to encode the
30013 status of ATPCS support, so instead we create a dummy,
30014 empty, debug section called .arm.atpcs. */
30019 sec = bfd_make_section (stdoutput, ".arm.atpcs");
30023 bfd_set_section_flags (sec, SEC_READONLY | SEC_DEBUGGING);
30024 bfd_set_section_size (sec, 0);
30025 bfd_set_section_contents (stdoutput, sec, NULL, 0, 0);
30031 /* Record the CPU type as well. */
30032 if (ARM_CPU_HAS_FEATURE (cpu_variant, arm_cext_iwmmxt2))
30033 mach = bfd_mach_arm_iWMMXt2;
30034 else if (ARM_CPU_HAS_FEATURE (cpu_variant, arm_cext_iwmmxt))
30035 mach = bfd_mach_arm_iWMMXt;
30036 else if (ARM_CPU_HAS_FEATURE (cpu_variant, arm_cext_xscale))
30037 mach = bfd_mach_arm_XScale;
30038 else if (ARM_CPU_HAS_FEATURE (cpu_variant, arm_cext_maverick))
30039 mach = bfd_mach_arm_ep9312;
30040 else if (ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_v5e))
30041 mach = bfd_mach_arm_5TE;
30042 else if (ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_v5))
30044 if (ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_v4t))
30045 mach = bfd_mach_arm_5T;
30047 mach = bfd_mach_arm_5;
30049 else if (ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_v4))
30051 if (ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_v4t))
30052 mach = bfd_mach_arm_4T;
30054 mach = bfd_mach_arm_4;
30056 else if (ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_v3m))
30057 mach = bfd_mach_arm_3M;
30058 else if (ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_v3))
30059 mach = bfd_mach_arm_3;
30060 else if (ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_v2s))
30061 mach = bfd_mach_arm_2a;
30062 else if (ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_v2))
30063 mach = bfd_mach_arm_2;
30065 mach = bfd_mach_arm_unknown;
30067 bfd_set_arch_mach (stdoutput, TARGET_ARCH, mach);
30070 /* Command line processing. */
30073 Invocation line includes a switch not recognized by the base assembler.
30074 See if it's a processor-specific option.
30076 This routine is somewhat complicated by the need for backwards
30077 compatibility (since older releases of gcc can't be changed).
30078 The new options try to make the interface as compatible as
30081 New options (supported) are:
30083 -mcpu=<cpu name> Assemble for selected processor
30084 -march=<architecture name> Assemble for selected architecture
30085 -mfpu=<fpu architecture> Assemble for selected FPU.
30086 -EB/-mbig-endian Big-endian
30087 -EL/-mlittle-endian Little-endian
30088 -k Generate PIC code
30089 -mthumb Start in Thumb mode
30090 -mthumb-interwork Code supports ARM/Thumb interworking
30092 -m[no-]warn-deprecated Warn about deprecated features
30093 -m[no-]warn-syms Warn when symbols match instructions
30095 For now we will also provide support for:
30097 -mapcs-32 32-bit Program counter
30098 -mapcs-26 26-bit Program counter
30099 -macps-float Floats passed in FP registers
30100 -mapcs-reentrant Reentrant code
30102 (sometime these will probably be replaced with -mapcs=<list of options>
30103 and -matpcs=<list of options>)
30105 The remaining options are only supported for back-wards compatibility.
30106 Cpu variants, the arm part is optional:
30107 -m[arm]1 Currently not supported.
30108 -m[arm]2, -m[arm]250 Arm 2 and Arm 250 processor
30109 -m[arm]3 Arm 3 processor
30110 -m[arm]6[xx], Arm 6 processors
30111 -m[arm]7[xx][t][[d]m] Arm 7 processors
30112 -m[arm]8[10] Arm 8 processors
30113 -m[arm]9[20][tdmi] Arm 9 processors
30114 -mstrongarm[110[0]] StrongARM processors
30115 -mxscale XScale processors
30116 -m[arm]v[2345[t[e]]] Arm architectures
30117 -mall All (except the ARM1)
30119 -mfpa10, -mfpa11 FPA10 and 11 co-processor instructions
30120 -mfpe-old (No float load/store multiples)
30121 -mvfpxd VFP Single precision
30123 -mno-fpu Disable all floating point instructions
30125 The following CPU names are recognized:
30126 arm1, arm2, arm250, arm3, arm6, arm600, arm610, arm620,
30127 arm7, arm7m, arm7d, arm7dm, arm7di, arm7dmi, arm70, arm700,
30128 arm700i, arm710 arm710t, arm720, arm720t, arm740t, arm710c,
30129 arm7100, arm7500, arm7500fe, arm7tdmi, arm8, arm810, arm9,
30130 arm920, arm920t, arm940t, arm946, arm966, arm9tdmi, arm9e,
30131 arm10t arm10e, arm1020t, arm1020e, arm10200e,
30132 strongarm, strongarm110, strongarm1100, strongarm1110, xscale.
30136 const char * md_shortopts = "m:k";
30138 #ifdef ARM_BI_ENDIAN
30139 #define OPTION_EB (OPTION_MD_BASE + 0)
30140 #define OPTION_EL (OPTION_MD_BASE + 1)
30142 #if TARGET_BYTES_BIG_ENDIAN
30143 #define OPTION_EB (OPTION_MD_BASE + 0)
30145 #define OPTION_EL (OPTION_MD_BASE + 1)
30148 #define OPTION_FIX_V4BX (OPTION_MD_BASE + 2)
30149 #define OPTION_FDPIC (OPTION_MD_BASE + 3)
30151 struct option md_longopts[] =
30154 {"EB", no_argument, NULL, OPTION_EB},
30157 {"EL", no_argument, NULL, OPTION_EL},
30159 {"fix-v4bx", no_argument, NULL, OPTION_FIX_V4BX},
30161 {"fdpic", no_argument, NULL, OPTION_FDPIC},
30163 {NULL, no_argument, NULL, 0}
30166 size_t md_longopts_size = sizeof (md_longopts);
30168 struct arm_option_table
30170 const char * option; /* Option name to match. */
30171 const char * help; /* Help information. */
30172 int * var; /* Variable to change. */
30173 int value; /* What to change it to. */
30174 const char * deprecated; /* If non-null, print this message. */
30177 struct arm_option_table arm_opts[] =
30179 {"k", N_("generate PIC code"), &pic_code, 1, NULL},
30180 {"mthumb", N_("assemble Thumb code"), &thumb_mode, 1, NULL},
30181 {"mthumb-interwork", N_("support ARM/Thumb interworking"),
30182 &support_interwork, 1, NULL},
30183 {"mapcs-32", N_("code uses 32-bit program counter"), &uses_apcs_26, 0, NULL},
30184 {"mapcs-26", N_("code uses 26-bit program counter"), &uses_apcs_26, 1, NULL},
30185 {"mapcs-float", N_("floating point args are in fp regs"), &uses_apcs_float,
30187 {"mapcs-reentrant", N_("re-entrant code"), &pic_code, 1, NULL},
30188 {"matpcs", N_("code is ATPCS conformant"), &atpcs, 1, NULL},
30189 {"mbig-endian", N_("assemble for big-endian"), &target_big_endian, 1, NULL},
30190 {"mlittle-endian", N_("assemble for little-endian"), &target_big_endian, 0,
30193 /* These are recognized by the assembler, but have no affect on code. */
30194 {"mapcs-frame", N_("use frame pointer"), NULL, 0, NULL},
30195 {"mapcs-stack-check", N_("use stack size checking"), NULL, 0, NULL},
30197 {"mwarn-deprecated", NULL, &warn_on_deprecated, 1, NULL},
30198 {"mno-warn-deprecated", N_("do not warn on use of deprecated feature"),
30199 &warn_on_deprecated, 0, NULL},
30200 {"mwarn-syms", N_("warn about symbols that match instruction names [default]"), (int *) (& flag_warn_syms), TRUE, NULL},
30201 {"mno-warn-syms", N_("disable warnings about symobls that match instructions"), (int *) (& flag_warn_syms), FALSE, NULL},
30202 {NULL, NULL, NULL, 0, NULL}
30205 struct arm_legacy_option_table
30207 const char * option; /* Option name to match. */
30208 const arm_feature_set ** var; /* Variable to change. */
30209 const arm_feature_set value; /* What to change it to. */
30210 const char * deprecated; /* If non-null, print this message. */
30213 const struct arm_legacy_option_table arm_legacy_opts[] =
30215 /* DON'T add any new processors to this list -- we want the whole list
30216 to go away... Add them to the processors table instead. */
30217 {"marm1", &legacy_cpu, ARM_ARCH_V1, N_("use -mcpu=arm1")},
30218 {"m1", &legacy_cpu, ARM_ARCH_V1, N_("use -mcpu=arm1")},
30219 {"marm2", &legacy_cpu, ARM_ARCH_V2, N_("use -mcpu=arm2")},
30220 {"m2", &legacy_cpu, ARM_ARCH_V2, N_("use -mcpu=arm2")},
30221 {"marm250", &legacy_cpu, ARM_ARCH_V2S, N_("use -mcpu=arm250")},
30222 {"m250", &legacy_cpu, ARM_ARCH_V2S, N_("use -mcpu=arm250")},
30223 {"marm3", &legacy_cpu, ARM_ARCH_V2S, N_("use -mcpu=arm3")},
30224 {"m3", &legacy_cpu, ARM_ARCH_V2S, N_("use -mcpu=arm3")},
30225 {"marm6", &legacy_cpu, ARM_ARCH_V3, N_("use -mcpu=arm6")},
30226 {"m6", &legacy_cpu, ARM_ARCH_V3, N_("use -mcpu=arm6")},
30227 {"marm600", &legacy_cpu, ARM_ARCH_V3, N_("use -mcpu=arm600")},
30228 {"m600", &legacy_cpu, ARM_ARCH_V3, N_("use -mcpu=arm600")},
30229 {"marm610", &legacy_cpu, ARM_ARCH_V3, N_("use -mcpu=arm610")},
30230 {"m610", &legacy_cpu, ARM_ARCH_V3, N_("use -mcpu=arm610")},
30231 {"marm620", &legacy_cpu, ARM_ARCH_V3, N_("use -mcpu=arm620")},
30232 {"m620", &legacy_cpu, ARM_ARCH_V3, N_("use -mcpu=arm620")},
30233 {"marm7", &legacy_cpu, ARM_ARCH_V3, N_("use -mcpu=arm7")},
30234 {"m7", &legacy_cpu, ARM_ARCH_V3, N_("use -mcpu=arm7")},
30235 {"marm70", &legacy_cpu, ARM_ARCH_V3, N_("use -mcpu=arm70")},
30236 {"m70", &legacy_cpu, ARM_ARCH_V3, N_("use -mcpu=arm70")},
30237 {"marm700", &legacy_cpu, ARM_ARCH_V3, N_("use -mcpu=arm700")},
30238 {"m700", &legacy_cpu, ARM_ARCH_V3, N_("use -mcpu=arm700")},
30239 {"marm700i", &legacy_cpu, ARM_ARCH_V3, N_("use -mcpu=arm700i")},
30240 {"m700i", &legacy_cpu, ARM_ARCH_V3, N_("use -mcpu=arm700i")},
30241 {"marm710", &legacy_cpu, ARM_ARCH_V3, N_("use -mcpu=arm710")},
30242 {"m710", &legacy_cpu, ARM_ARCH_V3, N_("use -mcpu=arm710")},
30243 {"marm710c", &legacy_cpu, ARM_ARCH_V3, N_("use -mcpu=arm710c")},
30244 {"m710c", &legacy_cpu, ARM_ARCH_V3, N_("use -mcpu=arm710c")},
30245 {"marm720", &legacy_cpu, ARM_ARCH_V3, N_("use -mcpu=arm720")},
30246 {"m720", &legacy_cpu, ARM_ARCH_V3, N_("use -mcpu=arm720")},
30247 {"marm7d", &legacy_cpu, ARM_ARCH_V3, N_("use -mcpu=arm7d")},
30248 {"m7d", &legacy_cpu, ARM_ARCH_V3, N_("use -mcpu=arm7d")},
30249 {"marm7di", &legacy_cpu, ARM_ARCH_V3, N_("use -mcpu=arm7di")},
30250 {"m7di", &legacy_cpu, ARM_ARCH_V3, N_("use -mcpu=arm7di")},
30251 {"marm7m", &legacy_cpu, ARM_ARCH_V3M, N_("use -mcpu=arm7m")},
30252 {"m7m", &legacy_cpu, ARM_ARCH_V3M, N_("use -mcpu=arm7m")},
30253 {"marm7dm", &legacy_cpu, ARM_ARCH_V3M, N_("use -mcpu=arm7dm")},
30254 {"m7dm", &legacy_cpu, ARM_ARCH_V3M, N_("use -mcpu=arm7dm")},
30255 {"marm7dmi", &legacy_cpu, ARM_ARCH_V3M, N_("use -mcpu=arm7dmi")},
30256 {"m7dmi", &legacy_cpu, ARM_ARCH_V3M, N_("use -mcpu=arm7dmi")},
30257 {"marm7100", &legacy_cpu, ARM_ARCH_V3, N_("use -mcpu=arm7100")},
30258 {"m7100", &legacy_cpu, ARM_ARCH_V3, N_("use -mcpu=arm7100")},
30259 {"marm7500", &legacy_cpu, ARM_ARCH_V3, N_("use -mcpu=arm7500")},
30260 {"m7500", &legacy_cpu, ARM_ARCH_V3, N_("use -mcpu=arm7500")},
30261 {"marm7500fe", &legacy_cpu, ARM_ARCH_V3, N_("use -mcpu=arm7500fe")},
30262 {"m7500fe", &legacy_cpu, ARM_ARCH_V3, N_("use -mcpu=arm7500fe")},
30263 {"marm7t", &legacy_cpu, ARM_ARCH_V4T, N_("use -mcpu=arm7tdmi")},
30264 {"m7t", &legacy_cpu, ARM_ARCH_V4T, N_("use -mcpu=arm7tdmi")},
30265 {"marm7tdmi", &legacy_cpu, ARM_ARCH_V4T, N_("use -mcpu=arm7tdmi")},
30266 {"m7tdmi", &legacy_cpu, ARM_ARCH_V4T, N_("use -mcpu=arm7tdmi")},
30267 {"marm710t", &legacy_cpu, ARM_ARCH_V4T, N_("use -mcpu=arm710t")},
30268 {"m710t", &legacy_cpu, ARM_ARCH_V4T, N_("use -mcpu=arm710t")},
30269 {"marm720t", &legacy_cpu, ARM_ARCH_V4T, N_("use -mcpu=arm720t")},
30270 {"m720t", &legacy_cpu, ARM_ARCH_V4T, N_("use -mcpu=arm720t")},
30271 {"marm740t", &legacy_cpu, ARM_ARCH_V4T, N_("use -mcpu=arm740t")},
30272 {"m740t", &legacy_cpu, ARM_ARCH_V4T, N_("use -mcpu=arm740t")},
30273 {"marm8", &legacy_cpu, ARM_ARCH_V4, N_("use -mcpu=arm8")},
30274 {"m8", &legacy_cpu, ARM_ARCH_V4, N_("use -mcpu=arm8")},
30275 {"marm810", &legacy_cpu, ARM_ARCH_V4, N_("use -mcpu=arm810")},
30276 {"m810", &legacy_cpu, ARM_ARCH_V4, N_("use -mcpu=arm810")},
30277 {"marm9", &legacy_cpu, ARM_ARCH_V4T, N_("use -mcpu=arm9")},
30278 {"m9", &legacy_cpu, ARM_ARCH_V4T, N_("use -mcpu=arm9")},
30279 {"marm9tdmi", &legacy_cpu, ARM_ARCH_V4T, N_("use -mcpu=arm9tdmi")},
30280 {"m9tdmi", &legacy_cpu, ARM_ARCH_V4T, N_("use -mcpu=arm9tdmi")},
30281 {"marm920", &legacy_cpu, ARM_ARCH_V4T, N_("use -mcpu=arm920")},
30282 {"m920", &legacy_cpu, ARM_ARCH_V4T, N_("use -mcpu=arm920")},
30283 {"marm940", &legacy_cpu, ARM_ARCH_V4T, N_("use -mcpu=arm940")},
30284 {"m940", &legacy_cpu, ARM_ARCH_V4T, N_("use -mcpu=arm940")},
30285 {"mstrongarm", &legacy_cpu, ARM_ARCH_V4, N_("use -mcpu=strongarm")},
30286 {"mstrongarm110", &legacy_cpu, ARM_ARCH_V4,
30287 N_("use -mcpu=strongarm110")},
30288 {"mstrongarm1100", &legacy_cpu, ARM_ARCH_V4,
30289 N_("use -mcpu=strongarm1100")},
30290 {"mstrongarm1110", &legacy_cpu, ARM_ARCH_V4,
30291 N_("use -mcpu=strongarm1110")},
30292 {"mxscale", &legacy_cpu, ARM_ARCH_XSCALE, N_("use -mcpu=xscale")},
30293 {"miwmmxt", &legacy_cpu, ARM_ARCH_IWMMXT, N_("use -mcpu=iwmmxt")},
30294 {"mall", &legacy_cpu, ARM_ANY, N_("use -mcpu=all")},
30296 /* Architecture variants -- don't add any more to this list either. */
30297 {"mv2", &legacy_cpu, ARM_ARCH_V2, N_("use -march=armv2")},
30298 {"marmv2", &legacy_cpu, ARM_ARCH_V2, N_("use -march=armv2")},
30299 {"mv2a", &legacy_cpu, ARM_ARCH_V2S, N_("use -march=armv2a")},
30300 {"marmv2a", &legacy_cpu, ARM_ARCH_V2S, N_("use -march=armv2a")},
30301 {"mv3", &legacy_cpu, ARM_ARCH_V3, N_("use -march=armv3")},
30302 {"marmv3", &legacy_cpu, ARM_ARCH_V3, N_("use -march=armv3")},
30303 {"mv3m", &legacy_cpu, ARM_ARCH_V3M, N_("use -march=armv3m")},
30304 {"marmv3m", &legacy_cpu, ARM_ARCH_V3M, N_("use -march=armv3m")},
30305 {"mv4", &legacy_cpu, ARM_ARCH_V4, N_("use -march=armv4")},
30306 {"marmv4", &legacy_cpu, ARM_ARCH_V4, N_("use -march=armv4")},
30307 {"mv4t", &legacy_cpu, ARM_ARCH_V4T, N_("use -march=armv4t")},
30308 {"marmv4t", &legacy_cpu, ARM_ARCH_V4T, N_("use -march=armv4t")},
30309 {"mv5", &legacy_cpu, ARM_ARCH_V5, N_("use -march=armv5")},
30310 {"marmv5", &legacy_cpu, ARM_ARCH_V5, N_("use -march=armv5")},
30311 {"mv5t", &legacy_cpu, ARM_ARCH_V5T, N_("use -march=armv5t")},
30312 {"marmv5t", &legacy_cpu, ARM_ARCH_V5T, N_("use -march=armv5t")},
30313 {"mv5e", &legacy_cpu, ARM_ARCH_V5TE, N_("use -march=armv5te")},
30314 {"marmv5e", &legacy_cpu, ARM_ARCH_V5TE, N_("use -march=armv5te")},
30316 /* Floating point variants -- don't add any more to this list either. */
30317 {"mfpe-old", &legacy_fpu, FPU_ARCH_FPE, N_("use -mfpu=fpe")},
30318 {"mfpa10", &legacy_fpu, FPU_ARCH_FPA, N_("use -mfpu=fpa10")},
30319 {"mfpa11", &legacy_fpu, FPU_ARCH_FPA, N_("use -mfpu=fpa11")},
30320 {"mno-fpu", &legacy_fpu, ARM_ARCH_NONE,
30321 N_("use either -mfpu=softfpa or -mfpu=softvfp")},
30323 {NULL, NULL, ARM_ARCH_NONE, NULL}
30326 struct arm_cpu_option_table
30330 const arm_feature_set value;
30331 const arm_feature_set ext;
30332 /* For some CPUs we assume an FPU unless the user explicitly sets
30334 const arm_feature_set default_fpu;
30335 /* The canonical name of the CPU, or NULL to use NAME converted to upper
30337 const char * canonical_name;
30340 /* This list should, at a minimum, contain all the cpu names
30341 recognized by GCC. */
30342 #define ARM_CPU_OPT(N, CN, V, E, DF) { N, sizeof (N) - 1, V, E, DF, CN }
30344 static const struct arm_cpu_option_table arm_cpus[] =
30346 ARM_CPU_OPT ("all", NULL, ARM_ANY,
30349 ARM_CPU_OPT ("arm1", NULL, ARM_ARCH_V1,
30352 ARM_CPU_OPT ("arm2", NULL, ARM_ARCH_V2,
30355 ARM_CPU_OPT ("arm250", NULL, ARM_ARCH_V2S,
30358 ARM_CPU_OPT ("arm3", NULL, ARM_ARCH_V2S,
30361 ARM_CPU_OPT ("arm6", NULL, ARM_ARCH_V3,
30364 ARM_CPU_OPT ("arm60", NULL, ARM_ARCH_V3,
30367 ARM_CPU_OPT ("arm600", NULL, ARM_ARCH_V3,
30370 ARM_CPU_OPT ("arm610", NULL, ARM_ARCH_V3,
30373 ARM_CPU_OPT ("arm620", NULL, ARM_ARCH_V3,
30376 ARM_CPU_OPT ("arm7", NULL, ARM_ARCH_V3,
30379 ARM_CPU_OPT ("arm7m", NULL, ARM_ARCH_V3M,
30382 ARM_CPU_OPT ("arm7d", NULL, ARM_ARCH_V3,
30385 ARM_CPU_OPT ("arm7dm", NULL, ARM_ARCH_V3M,
30388 ARM_CPU_OPT ("arm7di", NULL, ARM_ARCH_V3,
30391 ARM_CPU_OPT ("arm7dmi", NULL, ARM_ARCH_V3M,
30394 ARM_CPU_OPT ("arm70", NULL, ARM_ARCH_V3,
30397 ARM_CPU_OPT ("arm700", NULL, ARM_ARCH_V3,
30400 ARM_CPU_OPT ("arm700i", NULL, ARM_ARCH_V3,
30403 ARM_CPU_OPT ("arm710", NULL, ARM_ARCH_V3,
30406 ARM_CPU_OPT ("arm710t", NULL, ARM_ARCH_V4T,
30409 ARM_CPU_OPT ("arm720", NULL, ARM_ARCH_V3,
30412 ARM_CPU_OPT ("arm720t", NULL, ARM_ARCH_V4T,
30415 ARM_CPU_OPT ("arm740t", NULL, ARM_ARCH_V4T,
30418 ARM_CPU_OPT ("arm710c", NULL, ARM_ARCH_V3,
30421 ARM_CPU_OPT ("arm7100", NULL, ARM_ARCH_V3,
30424 ARM_CPU_OPT ("arm7500", NULL, ARM_ARCH_V3,
30427 ARM_CPU_OPT ("arm7500fe", NULL, ARM_ARCH_V3,
30430 ARM_CPU_OPT ("arm7t", NULL, ARM_ARCH_V4T,
30433 ARM_CPU_OPT ("arm7tdmi", NULL, ARM_ARCH_V4T,
30436 ARM_CPU_OPT ("arm7tdmi-s", NULL, ARM_ARCH_V4T,
30439 ARM_CPU_OPT ("arm8", NULL, ARM_ARCH_V4,
30442 ARM_CPU_OPT ("arm810", NULL, ARM_ARCH_V4,
30445 ARM_CPU_OPT ("strongarm", NULL, ARM_ARCH_V4,
30448 ARM_CPU_OPT ("strongarm1", NULL, ARM_ARCH_V4,
30451 ARM_CPU_OPT ("strongarm110", NULL, ARM_ARCH_V4,
30454 ARM_CPU_OPT ("strongarm1100", NULL, ARM_ARCH_V4,
30457 ARM_CPU_OPT ("strongarm1110", NULL, ARM_ARCH_V4,
30460 ARM_CPU_OPT ("arm9", NULL, ARM_ARCH_V4T,
30463 ARM_CPU_OPT ("arm920", "ARM920T", ARM_ARCH_V4T,
30466 ARM_CPU_OPT ("arm920t", NULL, ARM_ARCH_V4T,
30469 ARM_CPU_OPT ("arm922t", NULL, ARM_ARCH_V4T,
30472 ARM_CPU_OPT ("arm940t", NULL, ARM_ARCH_V4T,
30475 ARM_CPU_OPT ("arm9tdmi", NULL, ARM_ARCH_V4T,
30478 ARM_CPU_OPT ("fa526", NULL, ARM_ARCH_V4,
30481 ARM_CPU_OPT ("fa626", NULL, ARM_ARCH_V4,
30485 /* For V5 or later processors we default to using VFP; but the user
30486 should really set the FPU type explicitly. */
30487 ARM_CPU_OPT ("arm9e-r0", NULL, ARM_ARCH_V5TExP,
30490 ARM_CPU_OPT ("arm9e", NULL, ARM_ARCH_V5TE,
30493 ARM_CPU_OPT ("arm926ej", "ARM926EJ-S", ARM_ARCH_V5TEJ,
30496 ARM_CPU_OPT ("arm926ejs", "ARM926EJ-S", ARM_ARCH_V5TEJ,
30499 ARM_CPU_OPT ("arm926ej-s", NULL, ARM_ARCH_V5TEJ,
30502 ARM_CPU_OPT ("arm946e-r0", NULL, ARM_ARCH_V5TExP,
30505 ARM_CPU_OPT ("arm946e", "ARM946E-S", ARM_ARCH_V5TE,
30508 ARM_CPU_OPT ("arm946e-s", NULL, ARM_ARCH_V5TE,
30511 ARM_CPU_OPT ("arm966e-r0", NULL, ARM_ARCH_V5TExP,
30514 ARM_CPU_OPT ("arm966e", "ARM966E-S", ARM_ARCH_V5TE,
30517 ARM_CPU_OPT ("arm966e-s", NULL, ARM_ARCH_V5TE,
30520 ARM_CPU_OPT ("arm968e-s", NULL, ARM_ARCH_V5TE,
30523 ARM_CPU_OPT ("arm10t", NULL, ARM_ARCH_V5T,
30526 ARM_CPU_OPT ("arm10tdmi", NULL, ARM_ARCH_V5T,
30529 ARM_CPU_OPT ("arm10e", NULL, ARM_ARCH_V5TE,
30532 ARM_CPU_OPT ("arm1020", "ARM1020E", ARM_ARCH_V5TE,
30535 ARM_CPU_OPT ("arm1020t", NULL, ARM_ARCH_V5T,
30538 ARM_CPU_OPT ("arm1020e", NULL, ARM_ARCH_V5TE,
30541 ARM_CPU_OPT ("arm1022e", NULL, ARM_ARCH_V5TE,
30544 ARM_CPU_OPT ("arm1026ejs", "ARM1026EJ-S", ARM_ARCH_V5TEJ,
30547 ARM_CPU_OPT ("arm1026ej-s", NULL, ARM_ARCH_V5TEJ,
30550 ARM_CPU_OPT ("fa606te", NULL, ARM_ARCH_V5TE,
30553 ARM_CPU_OPT ("fa616te", NULL, ARM_ARCH_V5TE,
30556 ARM_CPU_OPT ("fa626te", NULL, ARM_ARCH_V5TE,
30559 ARM_CPU_OPT ("fmp626", NULL, ARM_ARCH_V5TE,
30562 ARM_CPU_OPT ("fa726te", NULL, ARM_ARCH_V5TE,
30565 ARM_CPU_OPT ("arm1136js", "ARM1136J-S", ARM_ARCH_V6,
30568 ARM_CPU_OPT ("arm1136j-s", NULL, ARM_ARCH_V6,
30571 ARM_CPU_OPT ("arm1136jfs", "ARM1136JF-S", ARM_ARCH_V6,
30574 ARM_CPU_OPT ("arm1136jf-s", NULL, ARM_ARCH_V6,
30577 ARM_CPU_OPT ("mpcore", "MPCore", ARM_ARCH_V6K,
30580 ARM_CPU_OPT ("mpcorenovfp", "MPCore", ARM_ARCH_V6K,
30583 ARM_CPU_OPT ("arm1156t2-s", NULL, ARM_ARCH_V6T2,
30586 ARM_CPU_OPT ("arm1156t2f-s", NULL, ARM_ARCH_V6T2,
30589 ARM_CPU_OPT ("arm1176jz-s", NULL, ARM_ARCH_V6KZ,
30592 ARM_CPU_OPT ("arm1176jzf-s", NULL, ARM_ARCH_V6KZ,
30595 ARM_CPU_OPT ("cortex-a5", "Cortex-A5", ARM_ARCH_V7A,
30596 ARM_FEATURE_CORE_LOW (ARM_EXT_MP | ARM_EXT_SEC),
30598 ARM_CPU_OPT ("cortex-a7", "Cortex-A7", ARM_ARCH_V7VE,
30600 FPU_ARCH_NEON_VFP_V4),
30601 ARM_CPU_OPT ("cortex-a8", "Cortex-A8", ARM_ARCH_V7A,
30602 ARM_FEATURE_CORE_LOW (ARM_EXT_SEC),
30603 ARM_FEATURE_COPROC (FPU_VFP_V3 | FPU_NEON_EXT_V1)),
30604 ARM_CPU_OPT ("cortex-a9", "Cortex-A9", ARM_ARCH_V7A,
30605 ARM_FEATURE_CORE_LOW (ARM_EXT_MP | ARM_EXT_SEC),
30606 ARM_FEATURE_COPROC (FPU_VFP_V3 | FPU_NEON_EXT_V1)),
30607 ARM_CPU_OPT ("cortex-a12", "Cortex-A12", ARM_ARCH_V7VE,
30609 FPU_ARCH_NEON_VFP_V4),
30610 ARM_CPU_OPT ("cortex-a15", "Cortex-A15", ARM_ARCH_V7VE,
30612 FPU_ARCH_NEON_VFP_V4),
30613 ARM_CPU_OPT ("cortex-a17", "Cortex-A17", ARM_ARCH_V7VE,
30615 FPU_ARCH_NEON_VFP_V4),
30616 ARM_CPU_OPT ("cortex-a32", "Cortex-A32", ARM_ARCH_V8A,
30617 ARM_FEATURE_COPROC (CRC_EXT_ARMV8),
30618 FPU_ARCH_CRYPTO_NEON_VFP_ARMV8),
30619 ARM_CPU_OPT ("cortex-a35", "Cortex-A35", ARM_ARCH_V8A,
30620 ARM_FEATURE_COPROC (CRC_EXT_ARMV8),
30621 FPU_ARCH_CRYPTO_NEON_VFP_ARMV8),
30622 ARM_CPU_OPT ("cortex-a53", "Cortex-A53", ARM_ARCH_V8A,
30623 ARM_FEATURE_COPROC (CRC_EXT_ARMV8),
30624 FPU_ARCH_CRYPTO_NEON_VFP_ARMV8),
30625 ARM_CPU_OPT ("cortex-a55", "Cortex-A55", ARM_ARCH_V8_2A,
30626 ARM_FEATURE_CORE_HIGH (ARM_EXT2_FP16_INST),
30627 FPU_ARCH_CRYPTO_NEON_VFP_ARMV8_DOTPROD),
30628 ARM_CPU_OPT ("cortex-a57", "Cortex-A57", ARM_ARCH_V8A,
30629 ARM_FEATURE_COPROC (CRC_EXT_ARMV8),
30630 FPU_ARCH_CRYPTO_NEON_VFP_ARMV8),
30631 ARM_CPU_OPT ("cortex-a72", "Cortex-A72", ARM_ARCH_V8A,
30632 ARM_FEATURE_COPROC (CRC_EXT_ARMV8),
30633 FPU_ARCH_CRYPTO_NEON_VFP_ARMV8),
30634 ARM_CPU_OPT ("cortex-a73", "Cortex-A73", ARM_ARCH_V8A,
30635 ARM_FEATURE_COPROC (CRC_EXT_ARMV8),
30636 FPU_ARCH_CRYPTO_NEON_VFP_ARMV8),
30637 ARM_CPU_OPT ("cortex-a75", "Cortex-A75", ARM_ARCH_V8_2A,
30638 ARM_FEATURE_CORE_HIGH (ARM_EXT2_FP16_INST),
30639 FPU_ARCH_CRYPTO_NEON_VFP_ARMV8_DOTPROD),
30640 ARM_CPU_OPT ("cortex-a76", "Cortex-A76", ARM_ARCH_V8_2A,
30641 ARM_FEATURE_CORE_HIGH (ARM_EXT2_FP16_INST),
30642 FPU_ARCH_CRYPTO_NEON_VFP_ARMV8_DOTPROD),
30643 ARM_CPU_OPT ("cortex-a76ae", "Cortex-A76AE", ARM_ARCH_V8_2A,
30644 ARM_FEATURE_CORE_HIGH (ARM_EXT2_FP16_INST),
30645 FPU_ARCH_CRYPTO_NEON_VFP_ARMV8_DOTPROD),
30646 ARM_CPU_OPT ("cortex-a77", "Cortex-A77", ARM_ARCH_V8_2A,
30647 ARM_FEATURE_CORE_HIGH (ARM_EXT2_FP16_INST),
30648 FPU_ARCH_CRYPTO_NEON_VFP_ARMV8_DOTPROD),
30649 ARM_CPU_OPT ("ares", "Ares", ARM_ARCH_V8_2A,
30650 ARM_FEATURE_CORE_HIGH (ARM_EXT2_FP16_INST),
30651 FPU_ARCH_CRYPTO_NEON_VFP_ARMV8_DOTPROD),
30652 ARM_CPU_OPT ("cortex-r4", "Cortex-R4", ARM_ARCH_V7R,
30655 ARM_CPU_OPT ("cortex-r4f", "Cortex-R4F", ARM_ARCH_V7R,
30657 FPU_ARCH_VFP_V3D16),
30658 ARM_CPU_OPT ("cortex-r5", "Cortex-R5", ARM_ARCH_V7R,
30659 ARM_FEATURE_CORE_LOW (ARM_EXT_ADIV),
30661 ARM_CPU_OPT ("cortex-r7", "Cortex-R7", ARM_ARCH_V7R,
30662 ARM_FEATURE_CORE_LOW (ARM_EXT_ADIV),
30663 FPU_ARCH_VFP_V3D16),
30664 ARM_CPU_OPT ("cortex-r8", "Cortex-R8", ARM_ARCH_V7R,
30665 ARM_FEATURE_CORE_LOW (ARM_EXT_ADIV),
30666 FPU_ARCH_VFP_V3D16),
30667 ARM_CPU_OPT ("cortex-r52", "Cortex-R52", ARM_ARCH_V8R,
30668 ARM_FEATURE_COPROC (CRC_EXT_ARMV8),
30669 FPU_ARCH_NEON_VFP_ARMV8),
30670 ARM_CPU_OPT ("cortex-m35p", "Cortex-M35P", ARM_ARCH_V8M_MAIN,
30671 ARM_FEATURE_CORE_LOW (ARM_EXT_V5ExP | ARM_EXT_V6_DSP),
30673 ARM_CPU_OPT ("cortex-m33", "Cortex-M33", ARM_ARCH_V8M_MAIN,
30674 ARM_FEATURE_CORE_LOW (ARM_EXT_V5ExP | ARM_EXT_V6_DSP),
30676 ARM_CPU_OPT ("cortex-m23", "Cortex-M23", ARM_ARCH_V8M_BASE,
30679 ARM_CPU_OPT ("cortex-m7", "Cortex-M7", ARM_ARCH_V7EM,
30682 ARM_CPU_OPT ("cortex-m4", "Cortex-M4", ARM_ARCH_V7EM,
30685 ARM_CPU_OPT ("cortex-m3", "Cortex-M3", ARM_ARCH_V7M,
30688 ARM_CPU_OPT ("cortex-m1", "Cortex-M1", ARM_ARCH_V6SM,
30691 ARM_CPU_OPT ("cortex-m0", "Cortex-M0", ARM_ARCH_V6SM,
30694 ARM_CPU_OPT ("cortex-m0plus", "Cortex-M0+", ARM_ARCH_V6SM,
30697 ARM_CPU_OPT ("exynos-m1", "Samsung Exynos M1", ARM_ARCH_V8A,
30698 ARM_FEATURE_COPROC (CRC_EXT_ARMV8),
30699 FPU_ARCH_CRYPTO_NEON_VFP_ARMV8),
30700 ARM_CPU_OPT ("neoverse-n1", "Neoverse N1", ARM_ARCH_V8_2A,
30701 ARM_FEATURE_CORE_HIGH (ARM_EXT2_FP16_INST),
30702 FPU_ARCH_CRYPTO_NEON_VFP_ARMV8_DOTPROD),
30703 /* ??? XSCALE is really an architecture. */
30704 ARM_CPU_OPT ("xscale", NULL, ARM_ARCH_XSCALE,
30708 /* ??? iwmmxt is not a processor. */
30709 ARM_CPU_OPT ("iwmmxt", NULL, ARM_ARCH_IWMMXT,
30712 ARM_CPU_OPT ("iwmmxt2", NULL, ARM_ARCH_IWMMXT2,
30715 ARM_CPU_OPT ("i80200", NULL, ARM_ARCH_XSCALE,
30720 ARM_CPU_OPT ("ep9312", "ARM920T",
30721 ARM_FEATURE_LOW (ARM_AEXT_V4T, ARM_CEXT_MAVERICK),
30722 ARM_ARCH_NONE, FPU_ARCH_MAVERICK),
30724 /* Marvell processors. */
30725 ARM_CPU_OPT ("marvell-pj4", NULL, ARM_ARCH_V7A,
30726 ARM_FEATURE_CORE_LOW (ARM_EXT_MP | ARM_EXT_SEC),
30727 FPU_ARCH_VFP_V3D16),
30728 ARM_CPU_OPT ("marvell-whitney", NULL, ARM_ARCH_V7A,
30729 ARM_FEATURE_CORE_LOW (ARM_EXT_MP | ARM_EXT_SEC),
30730 FPU_ARCH_NEON_VFP_V4),
30732 /* APM X-Gene family. */
30733 ARM_CPU_OPT ("xgene1", "APM X-Gene 1", ARM_ARCH_V8A,
30735 FPU_ARCH_CRYPTO_NEON_VFP_ARMV8),
30736 ARM_CPU_OPT ("xgene2", "APM X-Gene 2", ARM_ARCH_V8A,
30737 ARM_FEATURE_COPROC (CRC_EXT_ARMV8),
30738 FPU_ARCH_CRYPTO_NEON_VFP_ARMV8),
30740 { NULL, 0, ARM_ARCH_NONE, ARM_ARCH_NONE, ARM_ARCH_NONE, NULL }
30744 struct arm_ext_table
30748 const arm_feature_set merge;
30749 const arm_feature_set clear;
30752 struct arm_arch_option_table
30756 const arm_feature_set value;
30757 const arm_feature_set default_fpu;
30758 const struct arm_ext_table * ext_table;
30761 /* Used to add support for +E and +noE extension. */
30762 #define ARM_EXT(E, M, C) { E, sizeof (E) - 1, M, C }
30763 /* Used to add support for a +E extension. */
30764 #define ARM_ADD(E, M) { E, sizeof(E) - 1, M, ARM_ARCH_NONE }
30765 /* Used to add support for a +noE extension. */
30766 #define ARM_REMOVE(E, C) { E, sizeof(E) -1, ARM_ARCH_NONE, C }
30768 #define ALL_FP ARM_FEATURE (0, ARM_EXT2_FP16_INST | ARM_EXT2_FP16_FML, \
30769 ~0 & ~FPU_ENDIAN_PURE)
30771 static const struct arm_ext_table armv5te_ext_table[] =
30773 ARM_EXT ("fp", FPU_ARCH_VFP_V2, ALL_FP),
30774 { NULL, 0, ARM_ARCH_NONE, ARM_ARCH_NONE }
30777 static const struct arm_ext_table armv7_ext_table[] =
30779 ARM_EXT ("fp", FPU_ARCH_VFP_V3D16, ALL_FP),
30780 { NULL, 0, ARM_ARCH_NONE, ARM_ARCH_NONE }
30783 static const struct arm_ext_table armv7ve_ext_table[] =
30785 ARM_EXT ("fp", FPU_ARCH_VFP_V4D16, ALL_FP),
30786 ARM_ADD ("vfpv3-d16", FPU_ARCH_VFP_V3D16),
30787 ARM_ADD ("vfpv3", FPU_ARCH_VFP_V3),
30788 ARM_ADD ("vfpv3-d16-fp16", FPU_ARCH_VFP_V3D16_FP16),
30789 ARM_ADD ("vfpv3-fp16", FPU_ARCH_VFP_V3_FP16),
30790 ARM_ADD ("vfpv4-d16", FPU_ARCH_VFP_V4D16), /* Alias for +fp. */
30791 ARM_ADD ("vfpv4", FPU_ARCH_VFP_V4),
30793 ARM_EXT ("simd", FPU_ARCH_NEON_VFP_V4,
30794 ARM_FEATURE_COPROC (FPU_NEON_EXT_V1 | FPU_NEON_EXT_FMA)),
30796 /* Aliases for +simd. */
30797 ARM_ADD ("neon-vfpv4", FPU_ARCH_NEON_VFP_V4),
30799 ARM_ADD ("neon", FPU_ARCH_VFP_V3_PLUS_NEON_V1),
30800 ARM_ADD ("neon-vfpv3", FPU_ARCH_VFP_V3_PLUS_NEON_V1),
30801 ARM_ADD ("neon-fp16", FPU_ARCH_NEON_FP16),
30803 { NULL, 0, ARM_ARCH_NONE, ARM_ARCH_NONE }
30806 static const struct arm_ext_table armv7a_ext_table[] =
30808 ARM_EXT ("fp", FPU_ARCH_VFP_V3D16, ALL_FP),
30809 ARM_ADD ("vfpv3-d16", FPU_ARCH_VFP_V3D16), /* Alias for +fp. */
30810 ARM_ADD ("vfpv3", FPU_ARCH_VFP_V3),
30811 ARM_ADD ("vfpv3-d16-fp16", FPU_ARCH_VFP_V3D16_FP16),
30812 ARM_ADD ("vfpv3-fp16", FPU_ARCH_VFP_V3_FP16),
30813 ARM_ADD ("vfpv4-d16", FPU_ARCH_VFP_V4D16),
30814 ARM_ADD ("vfpv4", FPU_ARCH_VFP_V4),
30816 ARM_EXT ("simd", FPU_ARCH_VFP_V3_PLUS_NEON_V1,
30817 ARM_FEATURE_COPROC (FPU_NEON_EXT_V1 | FPU_NEON_EXT_FMA)),
30819 /* Aliases for +simd. */
30820 ARM_ADD ("neon", FPU_ARCH_VFP_V3_PLUS_NEON_V1),
30821 ARM_ADD ("neon-vfpv3", FPU_ARCH_VFP_V3_PLUS_NEON_V1),
30823 ARM_ADD ("neon-fp16", FPU_ARCH_NEON_FP16),
30824 ARM_ADD ("neon-vfpv4", FPU_ARCH_NEON_VFP_V4),
30826 ARM_ADD ("mp", ARM_FEATURE_CORE_LOW (ARM_EXT_MP)),
30827 ARM_ADD ("sec", ARM_FEATURE_CORE_LOW (ARM_EXT_SEC)),
30828 { NULL, 0, ARM_ARCH_NONE, ARM_ARCH_NONE }
30831 static const struct arm_ext_table armv7r_ext_table[] =
30833 ARM_ADD ("fp.sp", FPU_ARCH_VFP_V3xD),
30834 ARM_ADD ("vfpv3xd", FPU_ARCH_VFP_V3xD), /* Alias for +fp.sp. */
30835 ARM_EXT ("fp", FPU_ARCH_VFP_V3D16, ALL_FP),
30836 ARM_ADD ("vfpv3-d16", FPU_ARCH_VFP_V3D16), /* Alias for +fp. */
30837 ARM_ADD ("vfpv3xd-fp16", FPU_ARCH_VFP_V3xD_FP16),
30838 ARM_ADD ("vfpv3-d16-fp16", FPU_ARCH_VFP_V3D16_FP16),
30839 ARM_EXT ("idiv", ARM_FEATURE_CORE_LOW (ARM_EXT_ADIV | ARM_EXT_DIV),
30840 ARM_FEATURE_CORE_LOW (ARM_EXT_ADIV | ARM_EXT_DIV)),
30841 { NULL, 0, ARM_ARCH_NONE, ARM_ARCH_NONE }
30844 static const struct arm_ext_table armv7em_ext_table[] =
30846 ARM_EXT ("fp", FPU_ARCH_VFP_V4_SP_D16, ALL_FP),
30847 /* Alias for +fp, used to be known as fpv4-sp-d16. */
30848 ARM_ADD ("vfpv4-sp-d16", FPU_ARCH_VFP_V4_SP_D16),
30849 ARM_ADD ("fpv5", FPU_ARCH_VFP_V5_SP_D16),
30850 ARM_ADD ("fp.dp", FPU_ARCH_VFP_V5D16),
30851 ARM_ADD ("fpv5-d16", FPU_ARCH_VFP_V5D16),
30852 { NULL, 0, ARM_ARCH_NONE, ARM_ARCH_NONE }
30855 static const struct arm_ext_table armv8a_ext_table[] =
30857 ARM_ADD ("crc", ARCH_CRC_ARMV8),
30858 ARM_ADD ("simd", FPU_ARCH_NEON_VFP_ARMV8),
30859 ARM_EXT ("crypto", FPU_ARCH_CRYPTO_NEON_VFP_ARMV8,
30860 ARM_FEATURE_COPROC (FPU_CRYPTO_ARMV8)),
30862 /* Armv8-a does not allow an FP implementation without SIMD, so the user
30863 should use the +simd option to turn on FP. */
30864 ARM_REMOVE ("fp", ALL_FP),
30865 ARM_ADD ("sb", ARM_FEATURE_CORE_HIGH (ARM_EXT2_SB)),
30866 ARM_ADD ("predres", ARM_FEATURE_CORE_HIGH (ARM_EXT2_PREDRES)),
30867 { NULL, 0, ARM_ARCH_NONE, ARM_ARCH_NONE }
30871 static const struct arm_ext_table armv81a_ext_table[] =
30873 ARM_ADD ("simd", FPU_ARCH_NEON_VFP_ARMV8_1),
30874 ARM_EXT ("crypto", FPU_ARCH_CRYPTO_NEON_VFP_ARMV8_1,
30875 ARM_FEATURE_COPROC (FPU_CRYPTO_ARMV8)),
30877 /* Armv8-a does not allow an FP implementation without SIMD, so the user
30878 should use the +simd option to turn on FP. */
30879 ARM_REMOVE ("fp", ALL_FP),
30880 ARM_ADD ("sb", ARM_FEATURE_CORE_HIGH (ARM_EXT2_SB)),
30881 ARM_ADD ("predres", ARM_FEATURE_CORE_HIGH (ARM_EXT2_PREDRES)),
30882 { NULL, 0, ARM_ARCH_NONE, ARM_ARCH_NONE }
30885 static const struct arm_ext_table armv82a_ext_table[] =
30887 ARM_ADD ("simd", FPU_ARCH_NEON_VFP_ARMV8_1),
30888 ARM_ADD ("fp16", FPU_ARCH_NEON_VFP_ARMV8_2_FP16),
30889 ARM_ADD ("fp16fml", FPU_ARCH_NEON_VFP_ARMV8_2_FP16FML),
30890 ARM_EXT ("crypto", FPU_ARCH_CRYPTO_NEON_VFP_ARMV8_1,
30891 ARM_FEATURE_COPROC (FPU_CRYPTO_ARMV8)),
30892 ARM_ADD ("dotprod", FPU_ARCH_DOTPROD_NEON_VFP_ARMV8),
30894 /* Armv8-a does not allow an FP implementation without SIMD, so the user
30895 should use the +simd option to turn on FP. */
30896 ARM_REMOVE ("fp", ALL_FP),
30897 ARM_ADD ("sb", ARM_FEATURE_CORE_HIGH (ARM_EXT2_SB)),
30898 ARM_ADD ("predres", ARM_FEATURE_CORE_HIGH (ARM_EXT2_PREDRES)),
30899 { NULL, 0, ARM_ARCH_NONE, ARM_ARCH_NONE }
30902 static const struct arm_ext_table armv84a_ext_table[] =
30904 ARM_ADD ("simd", FPU_ARCH_DOTPROD_NEON_VFP_ARMV8),
30905 ARM_ADD ("fp16", FPU_ARCH_NEON_VFP_ARMV8_4_FP16FML),
30906 ARM_EXT ("crypto", FPU_ARCH_CRYPTO_NEON_VFP_ARMV8_4,
30907 ARM_FEATURE_COPROC (FPU_CRYPTO_ARMV8)),
30909 /* Armv8-a does not allow an FP implementation without SIMD, so the user
30910 should use the +simd option to turn on FP. */
30911 ARM_REMOVE ("fp", ALL_FP),
30912 ARM_ADD ("sb", ARM_FEATURE_CORE_HIGH (ARM_EXT2_SB)),
30913 ARM_ADD ("predres", ARM_FEATURE_CORE_HIGH (ARM_EXT2_PREDRES)),
30914 { NULL, 0, ARM_ARCH_NONE, ARM_ARCH_NONE }
30917 static const struct arm_ext_table armv85a_ext_table[] =
30919 ARM_ADD ("simd", FPU_ARCH_DOTPROD_NEON_VFP_ARMV8),
30920 ARM_ADD ("fp16", FPU_ARCH_NEON_VFP_ARMV8_4_FP16FML),
30921 ARM_EXT ("crypto", FPU_ARCH_CRYPTO_NEON_VFP_ARMV8_4,
30922 ARM_FEATURE_COPROC (FPU_CRYPTO_ARMV8)),
30924 /* Armv8-a does not allow an FP implementation without SIMD, so the user
30925 should use the +simd option to turn on FP. */
30926 ARM_REMOVE ("fp", ALL_FP),
30927 { NULL, 0, ARM_ARCH_NONE, ARM_ARCH_NONE }
30930 static const struct arm_ext_table armv8m_main_ext_table[] =
30932 ARM_EXT ("dsp", ARM_FEATURE_CORE_LOW (ARM_EXT_V5ExP | ARM_EXT_V6_DSP),
30933 ARM_FEATURE_CORE_LOW (ARM_EXT_V5ExP | ARM_EXT_V6_DSP)),
30934 ARM_EXT ("fp", FPU_ARCH_VFP_V5_SP_D16, ALL_FP),
30935 ARM_ADD ("fp.dp", FPU_ARCH_VFP_V5D16),
30936 { NULL, 0, ARM_ARCH_NONE, ARM_ARCH_NONE }
30939 static const struct arm_ext_table armv8_1m_main_ext_table[] =
30941 ARM_EXT ("dsp", ARM_FEATURE_CORE_LOW (ARM_EXT_V5ExP | ARM_EXT_V6_DSP),
30942 ARM_FEATURE_CORE_LOW (ARM_EXT_V5ExP | ARM_EXT_V6_DSP)),
30944 ARM_FEATURE (0, ARM_EXT2_FP16_INST,
30945 FPU_VFP_V5_SP_D16 | FPU_VFP_EXT_FP16 | FPU_VFP_EXT_FMA),
30948 ARM_FEATURE (0, ARM_EXT2_FP16_INST,
30949 FPU_VFP_V5D16 | FPU_VFP_EXT_FP16 | FPU_VFP_EXT_FMA)),
30950 ARM_EXT ("mve", ARM_FEATURE_COPROC (FPU_MVE),
30951 ARM_FEATURE_COPROC (FPU_MVE | FPU_MVE_FP)),
30953 ARM_FEATURE (0, ARM_EXT2_FP16_INST,
30954 FPU_MVE | FPU_MVE_FP | FPU_VFP_V5_SP_D16 |
30955 FPU_VFP_EXT_FP16 | FPU_VFP_EXT_FMA)),
30956 { NULL, 0, ARM_ARCH_NONE, ARM_ARCH_NONE }
30959 static const struct arm_ext_table armv8r_ext_table[] =
30961 ARM_ADD ("crc", ARCH_CRC_ARMV8),
30962 ARM_ADD ("simd", FPU_ARCH_NEON_VFP_ARMV8),
30963 ARM_EXT ("crypto", FPU_ARCH_CRYPTO_NEON_VFP_ARMV8,
30964 ARM_FEATURE_COPROC (FPU_CRYPTO_ARMV8)),
30965 ARM_REMOVE ("fp", ALL_FP),
30966 ARM_ADD ("fp.sp", FPU_ARCH_VFP_V5_SP_D16),
30967 { NULL, 0, ARM_ARCH_NONE, ARM_ARCH_NONE }
30970 /* This list should, at a minimum, contain all the architecture names
30971 recognized by GCC. */
30972 #define ARM_ARCH_OPT(N, V, DF) { N, sizeof (N) - 1, V, DF, NULL }
30973 #define ARM_ARCH_OPT2(N, V, DF, ext) \
30974 { N, sizeof (N) - 1, V, DF, ext##_ext_table }
30976 static const struct arm_arch_option_table arm_archs[] =
30978 ARM_ARCH_OPT ("all", ARM_ANY, FPU_ARCH_FPA),
30979 ARM_ARCH_OPT ("armv1", ARM_ARCH_V1, FPU_ARCH_FPA),
30980 ARM_ARCH_OPT ("armv2", ARM_ARCH_V2, FPU_ARCH_FPA),
30981 ARM_ARCH_OPT ("armv2a", ARM_ARCH_V2S, FPU_ARCH_FPA),
30982 ARM_ARCH_OPT ("armv2s", ARM_ARCH_V2S, FPU_ARCH_FPA),
30983 ARM_ARCH_OPT ("armv3", ARM_ARCH_V3, FPU_ARCH_FPA),
30984 ARM_ARCH_OPT ("armv3m", ARM_ARCH_V3M, FPU_ARCH_FPA),
30985 ARM_ARCH_OPT ("armv4", ARM_ARCH_V4, FPU_ARCH_FPA),
30986 ARM_ARCH_OPT ("armv4xm", ARM_ARCH_V4xM, FPU_ARCH_FPA),
30987 ARM_ARCH_OPT ("armv4t", ARM_ARCH_V4T, FPU_ARCH_FPA),
30988 ARM_ARCH_OPT ("armv4txm", ARM_ARCH_V4TxM, FPU_ARCH_FPA),
30989 ARM_ARCH_OPT ("armv5", ARM_ARCH_V5, FPU_ARCH_VFP),
30990 ARM_ARCH_OPT ("armv5t", ARM_ARCH_V5T, FPU_ARCH_VFP),
30991 ARM_ARCH_OPT ("armv5txm", ARM_ARCH_V5TxM, FPU_ARCH_VFP),
30992 ARM_ARCH_OPT2 ("armv5te", ARM_ARCH_V5TE, FPU_ARCH_VFP, armv5te),
30993 ARM_ARCH_OPT2 ("armv5texp", ARM_ARCH_V5TExP, FPU_ARCH_VFP, armv5te),
30994 ARM_ARCH_OPT2 ("armv5tej", ARM_ARCH_V5TEJ, FPU_ARCH_VFP, armv5te),
30995 ARM_ARCH_OPT2 ("armv6", ARM_ARCH_V6, FPU_ARCH_VFP, armv5te),
30996 ARM_ARCH_OPT2 ("armv6j", ARM_ARCH_V6, FPU_ARCH_VFP, armv5te),
30997 ARM_ARCH_OPT2 ("armv6k", ARM_ARCH_V6K, FPU_ARCH_VFP, armv5te),
30998 ARM_ARCH_OPT2 ("armv6z", ARM_ARCH_V6Z, FPU_ARCH_VFP, armv5te),
30999 /* The official spelling of this variant is ARMv6KZ, the name "armv6zk" is
31000 kept to preserve existing behaviour. */
31001 ARM_ARCH_OPT2 ("armv6kz", ARM_ARCH_V6KZ, FPU_ARCH_VFP, armv5te),
31002 ARM_ARCH_OPT2 ("armv6zk", ARM_ARCH_V6KZ, FPU_ARCH_VFP, armv5te),
31003 ARM_ARCH_OPT2 ("armv6t2", ARM_ARCH_V6T2, FPU_ARCH_VFP, armv5te),
31004 ARM_ARCH_OPT2 ("armv6kt2", ARM_ARCH_V6KT2, FPU_ARCH_VFP, armv5te),
31005 ARM_ARCH_OPT2 ("armv6zt2", ARM_ARCH_V6ZT2, FPU_ARCH_VFP, armv5te),
31006 /* The official spelling of this variant is ARMv6KZ, the name "armv6zkt2" is
31007 kept to preserve existing behaviour. */
31008 ARM_ARCH_OPT2 ("armv6kzt2", ARM_ARCH_V6KZT2, FPU_ARCH_VFP, armv5te),
31009 ARM_ARCH_OPT2 ("armv6zkt2", ARM_ARCH_V6KZT2, FPU_ARCH_VFP, armv5te),
31010 ARM_ARCH_OPT ("armv6-m", ARM_ARCH_V6M, FPU_ARCH_VFP),
31011 ARM_ARCH_OPT ("armv6s-m", ARM_ARCH_V6SM, FPU_ARCH_VFP),
31012 ARM_ARCH_OPT2 ("armv7", ARM_ARCH_V7, FPU_ARCH_VFP, armv7),
31013 /* The official spelling of the ARMv7 profile variants is the dashed form.
31014 Accept the non-dashed form for compatibility with old toolchains. */
31015 ARM_ARCH_OPT2 ("armv7a", ARM_ARCH_V7A, FPU_ARCH_VFP, armv7a),
31016 ARM_ARCH_OPT2 ("armv7ve", ARM_ARCH_V7VE, FPU_ARCH_VFP, armv7ve),
31017 ARM_ARCH_OPT2 ("armv7r", ARM_ARCH_V7R, FPU_ARCH_VFP, armv7r),
31018 ARM_ARCH_OPT ("armv7m", ARM_ARCH_V7M, FPU_ARCH_VFP),
31019 ARM_ARCH_OPT2 ("armv7-a", ARM_ARCH_V7A, FPU_ARCH_VFP, armv7a),
31020 ARM_ARCH_OPT2 ("armv7-r", ARM_ARCH_V7R, FPU_ARCH_VFP, armv7r),
31021 ARM_ARCH_OPT ("armv7-m", ARM_ARCH_V7M, FPU_ARCH_VFP),
31022 ARM_ARCH_OPT2 ("armv7e-m", ARM_ARCH_V7EM, FPU_ARCH_VFP, armv7em),
31023 ARM_ARCH_OPT ("armv8-m.base", ARM_ARCH_V8M_BASE, FPU_ARCH_VFP),
31024 ARM_ARCH_OPT2 ("armv8-m.main", ARM_ARCH_V8M_MAIN, FPU_ARCH_VFP,
31026 ARM_ARCH_OPT2 ("armv8.1-m.main", ARM_ARCH_V8_1M_MAIN, FPU_ARCH_VFP,
31028 ARM_ARCH_OPT2 ("armv8-a", ARM_ARCH_V8A, FPU_ARCH_VFP, armv8a),
31029 ARM_ARCH_OPT2 ("armv8.1-a", ARM_ARCH_V8_1A, FPU_ARCH_VFP, armv81a),
31030 ARM_ARCH_OPT2 ("armv8.2-a", ARM_ARCH_V8_2A, FPU_ARCH_VFP, armv82a),
31031 ARM_ARCH_OPT2 ("armv8.3-a", ARM_ARCH_V8_3A, FPU_ARCH_VFP, armv82a),
31032 ARM_ARCH_OPT2 ("armv8-r", ARM_ARCH_V8R, FPU_ARCH_VFP, armv8r),
31033 ARM_ARCH_OPT2 ("armv8.4-a", ARM_ARCH_V8_4A, FPU_ARCH_VFP, armv84a),
31034 ARM_ARCH_OPT2 ("armv8.5-a", ARM_ARCH_V8_5A, FPU_ARCH_VFP, armv85a),
31035 ARM_ARCH_OPT ("xscale", ARM_ARCH_XSCALE, FPU_ARCH_VFP),
31036 ARM_ARCH_OPT ("iwmmxt", ARM_ARCH_IWMMXT, FPU_ARCH_VFP),
31037 ARM_ARCH_OPT ("iwmmxt2", ARM_ARCH_IWMMXT2, FPU_ARCH_VFP),
31038 { NULL, 0, ARM_ARCH_NONE, ARM_ARCH_NONE, NULL }
31040 #undef ARM_ARCH_OPT
31042 /* ISA extensions in the co-processor and main instruction set space. */
31044 struct arm_option_extension_value_table
31048 const arm_feature_set merge_value;
31049 const arm_feature_set clear_value;
31050 /* List of architectures for which an extension is available. ARM_ARCH_NONE
31051 indicates that an extension is available for all architectures while
31052 ARM_ANY marks an empty entry. */
31053 const arm_feature_set allowed_archs[2];
31056 /* The following table must be in alphabetical order with a NULL last entry. */
31058 #define ARM_EXT_OPT(N, M, C, AA) { N, sizeof (N) - 1, M, C, { AA, ARM_ANY } }
31059 #define ARM_EXT_OPT2(N, M, C, AA1, AA2) { N, sizeof (N) - 1, M, C, {AA1, AA2} }
31061 /* DEPRECATED: Refrain from using this table to add any new extensions, instead
31062 use the context sensitive approach using arm_ext_table's. */
31063 static const struct arm_option_extension_value_table arm_extensions[] =
31065 ARM_EXT_OPT ("crc", ARCH_CRC_ARMV8, ARM_FEATURE_COPROC (CRC_EXT_ARMV8),
31066 ARM_FEATURE_CORE_LOW (ARM_EXT_V8)),
31067 ARM_EXT_OPT ("crypto", FPU_ARCH_CRYPTO_NEON_VFP_ARMV8,
31068 ARM_FEATURE_COPROC (FPU_CRYPTO_ARMV8),
31069 ARM_FEATURE_CORE_LOW (ARM_EXT_V8)),
31070 ARM_EXT_OPT ("dotprod", FPU_ARCH_DOTPROD_NEON_VFP_ARMV8,
31071 ARM_FEATURE_COPROC (FPU_NEON_EXT_DOTPROD),
31073 ARM_EXT_OPT ("dsp", ARM_FEATURE_CORE_LOW (ARM_EXT_V5ExP | ARM_EXT_V6_DSP),
31074 ARM_FEATURE_CORE_LOW (ARM_EXT_V5ExP | ARM_EXT_V6_DSP),
31075 ARM_FEATURE_CORE (ARM_EXT_V7M, ARM_EXT2_V8M)),
31076 ARM_EXT_OPT ("fp", FPU_ARCH_VFP_ARMV8, ARM_FEATURE_COPROC (FPU_VFP_ARMV8),
31077 ARM_FEATURE_CORE_LOW (ARM_EXT_V8)),
31078 ARM_EXT_OPT ("fp16", ARM_FEATURE_CORE_HIGH (ARM_EXT2_FP16_INST),
31079 ARM_FEATURE_CORE_HIGH (ARM_EXT2_FP16_INST),
31081 ARM_EXT_OPT ("fp16fml", ARM_FEATURE_CORE_HIGH (ARM_EXT2_FP16_INST
31082 | ARM_EXT2_FP16_FML),
31083 ARM_FEATURE_CORE_HIGH (ARM_EXT2_FP16_INST
31084 | ARM_EXT2_FP16_FML),
31086 ARM_EXT_OPT2 ("idiv", ARM_FEATURE_CORE_LOW (ARM_EXT_ADIV | ARM_EXT_DIV),
31087 ARM_FEATURE_CORE_LOW (ARM_EXT_ADIV | ARM_EXT_DIV),
31088 ARM_FEATURE_CORE_LOW (ARM_EXT_V7A),
31089 ARM_FEATURE_CORE_LOW (ARM_EXT_V7R)),
31090 /* Duplicate entry for the purpose of allowing ARMv7 to match in presence of
31091 Thumb divide instruction. Due to this having the same name as the
31092 previous entry, this will be ignored when doing command-line parsing and
31093 only considered by build attribute selection code. */
31094 ARM_EXT_OPT ("idiv", ARM_FEATURE_CORE_LOW (ARM_EXT_DIV),
31095 ARM_FEATURE_CORE_LOW (ARM_EXT_DIV),
31096 ARM_FEATURE_CORE_LOW (ARM_EXT_V7)),
31097 ARM_EXT_OPT ("iwmmxt",ARM_FEATURE_COPROC (ARM_CEXT_IWMMXT),
31098 ARM_FEATURE_COPROC (ARM_CEXT_IWMMXT), ARM_ARCH_NONE),
31099 ARM_EXT_OPT ("iwmmxt2", ARM_FEATURE_COPROC (ARM_CEXT_IWMMXT2),
31100 ARM_FEATURE_COPROC (ARM_CEXT_IWMMXT2), ARM_ARCH_NONE),
31101 ARM_EXT_OPT ("maverick", ARM_FEATURE_COPROC (ARM_CEXT_MAVERICK),
31102 ARM_FEATURE_COPROC (ARM_CEXT_MAVERICK), ARM_ARCH_NONE),
31103 ARM_EXT_OPT2 ("mp", ARM_FEATURE_CORE_LOW (ARM_EXT_MP),
31104 ARM_FEATURE_CORE_LOW (ARM_EXT_MP),
31105 ARM_FEATURE_CORE_LOW (ARM_EXT_V7A),
31106 ARM_FEATURE_CORE_LOW (ARM_EXT_V7R)),
31107 ARM_EXT_OPT ("os", ARM_FEATURE_CORE_LOW (ARM_EXT_OS),
31108 ARM_FEATURE_CORE_LOW (ARM_EXT_OS),
31109 ARM_FEATURE_CORE_LOW (ARM_EXT_V6M)),
31110 ARM_EXT_OPT ("pan", ARM_FEATURE_CORE_HIGH (ARM_EXT2_PAN),
31111 ARM_FEATURE (ARM_EXT_V8, ARM_EXT2_PAN, 0),
31112 ARM_FEATURE_CORE_HIGH (ARM_EXT2_V8A)),
31113 ARM_EXT_OPT ("predres", ARM_FEATURE_CORE_HIGH (ARM_EXT2_PREDRES),
31114 ARM_FEATURE_CORE_HIGH (ARM_EXT2_PREDRES),
31116 ARM_EXT_OPT ("ras", ARM_FEATURE_CORE_HIGH (ARM_EXT2_RAS),
31117 ARM_FEATURE (ARM_EXT_V8, ARM_EXT2_RAS, 0),
31118 ARM_FEATURE_CORE_HIGH (ARM_EXT2_V8A)),
31119 ARM_EXT_OPT ("rdma", FPU_ARCH_NEON_VFP_ARMV8_1,
31120 ARM_FEATURE_COPROC (FPU_NEON_ARMV8 | FPU_NEON_EXT_RDMA),
31121 ARM_FEATURE_CORE_HIGH (ARM_EXT2_V8A)),
31122 ARM_EXT_OPT ("sb", ARM_FEATURE_CORE_HIGH (ARM_EXT2_SB),
31123 ARM_FEATURE_CORE_HIGH (ARM_EXT2_SB),
31125 ARM_EXT_OPT2 ("sec", ARM_FEATURE_CORE_LOW (ARM_EXT_SEC),
31126 ARM_FEATURE_CORE_LOW (ARM_EXT_SEC),
31127 ARM_FEATURE_CORE_LOW (ARM_EXT_V6K),
31128 ARM_FEATURE_CORE_LOW (ARM_EXT_V7A)),
31129 ARM_EXT_OPT ("simd", FPU_ARCH_NEON_VFP_ARMV8,
31130 ARM_FEATURE_COPROC (FPU_NEON_ARMV8),
31131 ARM_FEATURE_CORE_LOW (ARM_EXT_V8)),
31132 ARM_EXT_OPT ("virt", ARM_FEATURE_CORE_LOW (ARM_EXT_VIRT | ARM_EXT_ADIV
31134 ARM_FEATURE_CORE_LOW (ARM_EXT_VIRT),
31135 ARM_FEATURE_CORE_LOW (ARM_EXT_V7A)),
31136 ARM_EXT_OPT ("xscale",ARM_FEATURE_COPROC (ARM_CEXT_XSCALE),
31137 ARM_FEATURE_COPROC (ARM_CEXT_XSCALE), ARM_ARCH_NONE),
31138 { NULL, 0, ARM_ARCH_NONE, ARM_ARCH_NONE, { ARM_ARCH_NONE, ARM_ARCH_NONE } }
31142 /* ISA floating-point and Advanced SIMD extensions. */
31143 struct arm_option_fpu_value_table
31146 const arm_feature_set value;
31149 /* This list should, at a minimum, contain all the fpu names
31150 recognized by GCC. */
31151 static const struct arm_option_fpu_value_table arm_fpus[] =
31153 {"softfpa", FPU_NONE},
31154 {"fpe", FPU_ARCH_FPE},
31155 {"fpe2", FPU_ARCH_FPE},
31156 {"fpe3", FPU_ARCH_FPA}, /* Third release supports LFM/SFM. */
31157 {"fpa", FPU_ARCH_FPA},
31158 {"fpa10", FPU_ARCH_FPA},
31159 {"fpa11", FPU_ARCH_FPA},
31160 {"arm7500fe", FPU_ARCH_FPA},
31161 {"softvfp", FPU_ARCH_VFP},
31162 {"softvfp+vfp", FPU_ARCH_VFP_V2},
31163 {"vfp", FPU_ARCH_VFP_V2},
31164 {"vfp9", FPU_ARCH_VFP_V2},
31165 {"vfp3", FPU_ARCH_VFP_V3}, /* Undocumented, use vfpv3. */
31166 {"vfp10", FPU_ARCH_VFP_V2},
31167 {"vfp10-r0", FPU_ARCH_VFP_V1},
31168 {"vfpxd", FPU_ARCH_VFP_V1xD},
31169 {"vfpv2", FPU_ARCH_VFP_V2},
31170 {"vfpv3", FPU_ARCH_VFP_V3},
31171 {"vfpv3-fp16", FPU_ARCH_VFP_V3_FP16},
31172 {"vfpv3-d16", FPU_ARCH_VFP_V3D16},
31173 {"vfpv3-d16-fp16", FPU_ARCH_VFP_V3D16_FP16},
31174 {"vfpv3xd", FPU_ARCH_VFP_V3xD},
31175 {"vfpv3xd-fp16", FPU_ARCH_VFP_V3xD_FP16},
31176 {"arm1020t", FPU_ARCH_VFP_V1},
31177 {"arm1020e", FPU_ARCH_VFP_V2},
31178 {"arm1136jfs", FPU_ARCH_VFP_V2}, /* Undocumented, use arm1136jf-s. */
31179 {"arm1136jf-s", FPU_ARCH_VFP_V2},
31180 {"maverick", FPU_ARCH_MAVERICK},
31181 {"neon", FPU_ARCH_VFP_V3_PLUS_NEON_V1},
31182 {"neon-vfpv3", FPU_ARCH_VFP_V3_PLUS_NEON_V1},
31183 {"neon-fp16", FPU_ARCH_NEON_FP16},
31184 {"vfpv4", FPU_ARCH_VFP_V4},
31185 {"vfpv4-d16", FPU_ARCH_VFP_V4D16},
31186 {"fpv4-sp-d16", FPU_ARCH_VFP_V4_SP_D16},
31187 {"fpv5-d16", FPU_ARCH_VFP_V5D16},
31188 {"fpv5-sp-d16", FPU_ARCH_VFP_V5_SP_D16},
31189 {"neon-vfpv4", FPU_ARCH_NEON_VFP_V4},
31190 {"fp-armv8", FPU_ARCH_VFP_ARMV8},
31191 {"neon-fp-armv8", FPU_ARCH_NEON_VFP_ARMV8},
31192 {"crypto-neon-fp-armv8",
31193 FPU_ARCH_CRYPTO_NEON_VFP_ARMV8},
31194 {"neon-fp-armv8.1", FPU_ARCH_NEON_VFP_ARMV8_1},
31195 {"crypto-neon-fp-armv8.1",
31196 FPU_ARCH_CRYPTO_NEON_VFP_ARMV8_1},
31197 {NULL, ARM_ARCH_NONE}
31200 struct arm_option_value_table
31206 static const struct arm_option_value_table arm_float_abis[] =
31208 {"hard", ARM_FLOAT_ABI_HARD},
31209 {"softfp", ARM_FLOAT_ABI_SOFTFP},
31210 {"soft", ARM_FLOAT_ABI_SOFT},
31215 /* We only know how to output GNU and ver 4/5 (AAELF) formats. */
31216 static const struct arm_option_value_table arm_eabis[] =
31218 {"gnu", EF_ARM_EABI_UNKNOWN},
31219 {"4", EF_ARM_EABI_VER4},
31220 {"5", EF_ARM_EABI_VER5},
31225 struct arm_long_option_table
31227 const char * option; /* Substring to match. */
31228 const char * help; /* Help information. */
31229 int (* func) (const char * subopt); /* Function to decode sub-option. */
31230 const char * deprecated; /* If non-null, print this message. */
31234 arm_parse_extension (const char *str, const arm_feature_set *opt_set,
31235 arm_feature_set *ext_set,
31236 const struct arm_ext_table *ext_table)
31238 /* We insist on extensions being specified in alphabetical order, and with
31239 extensions being added before being removed. We achieve this by having
31240 the global ARM_EXTENSIONS table in alphabetical order, and using the
31241 ADDING_VALUE variable to indicate whether we are adding an extension (1)
31242 or removing it (0) and only allowing it to change in the order
31244 const struct arm_option_extension_value_table * opt = NULL;
31245 const arm_feature_set arm_any = ARM_ANY;
31246 int adding_value = -1;
31248 while (str != NULL && *str != 0)
31255 as_bad (_("invalid architectural extension"));
31260 ext = strchr (str, '+');
31265 len = strlen (str);
31267 if (len >= 2 && strncmp (str, "no", 2) == 0)
31269 if (adding_value != 0)
31272 opt = arm_extensions;
31280 if (adding_value == -1)
31283 opt = arm_extensions;
31285 else if (adding_value != 1)
31287 as_bad (_("must specify extensions to add before specifying "
31288 "those to remove"));
31295 as_bad (_("missing architectural extension"));
31299 gas_assert (adding_value != -1);
31300 gas_assert (opt != NULL);
31302 if (ext_table != NULL)
31304 const struct arm_ext_table * ext_opt = ext_table;
31305 bfd_boolean found = FALSE;
31306 for (; ext_opt->name != NULL; ext_opt++)
31307 if (ext_opt->name_len == len
31308 && strncmp (ext_opt->name, str, len) == 0)
31312 if (ARM_FEATURE_ZERO (ext_opt->merge))
31313 /* TODO: Option not supported. When we remove the
31314 legacy table this case should error out. */
31317 ARM_MERGE_FEATURE_SETS (*ext_set, *ext_set, ext_opt->merge);
31321 if (ARM_FEATURE_ZERO (ext_opt->clear))
31322 /* TODO: Option not supported. When we remove the
31323 legacy table this case should error out. */
31325 ARM_CLEAR_FEATURE (*ext_set, *ext_set, ext_opt->clear);
31337 /* Scan over the options table trying to find an exact match. */
31338 for (; opt->name != NULL; opt++)
31339 if (opt->name_len == len && strncmp (opt->name, str, len) == 0)
31341 int i, nb_allowed_archs =
31342 sizeof (opt->allowed_archs) / sizeof (opt->allowed_archs[0]);
31343 /* Check we can apply the extension to this architecture. */
31344 for (i = 0; i < nb_allowed_archs; i++)
31347 if (ARM_FEATURE_EQUAL (opt->allowed_archs[i], arm_any))
31349 if (ARM_FSET_CPU_SUBSET (opt->allowed_archs[i], *opt_set))
31352 if (i == nb_allowed_archs)
31354 as_bad (_("extension does not apply to the base architecture"));
31358 /* Add or remove the extension. */
31360 ARM_MERGE_FEATURE_SETS (*ext_set, *ext_set, opt->merge_value);
31362 ARM_CLEAR_FEATURE (*ext_set, *ext_set, opt->clear_value);
31364 /* Allowing Thumb division instructions for ARMv7 in autodetection
31365 rely on this break so that duplicate extensions (extensions
31366 with the same name as a previous extension in the list) are not
31367 considered for command-line parsing. */
31371 if (opt->name == NULL)
31373 /* Did we fail to find an extension because it wasn't specified in
31374 alphabetical order, or because it does not exist? */
31376 for (opt = arm_extensions; opt->name != NULL; opt++)
31377 if (opt->name_len == len && strncmp (opt->name, str, len) == 0)
31380 if (opt->name == NULL)
31381 as_bad (_("unknown architectural extension `%s'"), str);
31383 as_bad (_("architectural extensions must be specified in "
31384 "alphabetical order"));
31390 /* We should skip the extension we've just matched the next time
31402 arm_parse_fp16_opt (const char *str)
31404 if (strcasecmp (str, "ieee") == 0)
31405 fp16_format = ARM_FP16_FORMAT_IEEE;
31406 else if (strcasecmp (str, "alternative") == 0)
31407 fp16_format = ARM_FP16_FORMAT_ALTERNATIVE;
31410 as_bad (_("unrecognised float16 format \"%s\""), str);
31418 arm_parse_cpu (const char *str)
31420 const struct arm_cpu_option_table *opt;
31421 const char *ext = strchr (str, '+');
31427 len = strlen (str);
31431 as_bad (_("missing cpu name `%s'"), str);
31435 for (opt = arm_cpus; opt->name != NULL; opt++)
31436 if (opt->name_len == len && strncmp (opt->name, str, len) == 0)
31438 mcpu_cpu_opt = &opt->value;
31439 if (mcpu_ext_opt == NULL)
31440 mcpu_ext_opt = XNEW (arm_feature_set);
31441 *mcpu_ext_opt = opt->ext;
31442 mcpu_fpu_opt = &opt->default_fpu;
31443 if (opt->canonical_name)
31445 gas_assert (sizeof selected_cpu_name > strlen (opt->canonical_name));
31446 strcpy (selected_cpu_name, opt->canonical_name);
31452 if (len >= sizeof selected_cpu_name)
31453 len = (sizeof selected_cpu_name) - 1;
31455 for (i = 0; i < len; i++)
31456 selected_cpu_name[i] = TOUPPER (opt->name[i]);
31457 selected_cpu_name[i] = 0;
31461 return arm_parse_extension (ext, mcpu_cpu_opt, mcpu_ext_opt, NULL);
31466 as_bad (_("unknown cpu `%s'"), str);
31471 arm_parse_arch (const char *str)
31473 const struct arm_arch_option_table *opt;
31474 const char *ext = strchr (str, '+');
31480 len = strlen (str);
31484 as_bad (_("missing architecture name `%s'"), str);
31488 for (opt = arm_archs; opt->name != NULL; opt++)
31489 if (opt->name_len == len && strncmp (opt->name, str, len) == 0)
31491 march_cpu_opt = &opt->value;
31492 if (march_ext_opt == NULL)
31493 march_ext_opt = XNEW (arm_feature_set);
31494 *march_ext_opt = arm_arch_none;
31495 march_fpu_opt = &opt->default_fpu;
31496 strcpy (selected_cpu_name, opt->name);
31499 return arm_parse_extension (ext, march_cpu_opt, march_ext_opt,
31505 as_bad (_("unknown architecture `%s'\n"), str);
31510 arm_parse_fpu (const char * str)
31512 const struct arm_option_fpu_value_table * opt;
31514 for (opt = arm_fpus; opt->name != NULL; opt++)
31515 if (streq (opt->name, str))
31517 mfpu_opt = &opt->value;
31521 as_bad (_("unknown floating point format `%s'\n"), str);
31526 arm_parse_float_abi (const char * str)
31528 const struct arm_option_value_table * opt;
31530 for (opt = arm_float_abis; opt->name != NULL; opt++)
31531 if (streq (opt->name, str))
31533 mfloat_abi_opt = opt->value;
31537 as_bad (_("unknown floating point abi `%s'\n"), str);
31543 arm_parse_eabi (const char * str)
31545 const struct arm_option_value_table *opt;
31547 for (opt = arm_eabis; opt->name != NULL; opt++)
31548 if (streq (opt->name, str))
31550 meabi_flags = opt->value;
31553 as_bad (_("unknown EABI `%s'\n"), str);
31559 arm_parse_it_mode (const char * str)
31561 bfd_boolean ret = TRUE;
31563 if (streq ("arm", str))
31564 implicit_it_mode = IMPLICIT_IT_MODE_ARM;
31565 else if (streq ("thumb", str))
31566 implicit_it_mode = IMPLICIT_IT_MODE_THUMB;
31567 else if (streq ("always", str))
31568 implicit_it_mode = IMPLICIT_IT_MODE_ALWAYS;
31569 else if (streq ("never", str))
31570 implicit_it_mode = IMPLICIT_IT_MODE_NEVER;
31573 as_bad (_("unknown implicit IT mode `%s', should be "\
31574 "arm, thumb, always, or never."), str);
31582 arm_ccs_mode (const char * unused ATTRIBUTE_UNUSED)
31584 codecomposer_syntax = TRUE;
31585 arm_comment_chars[0] = ';';
31586 arm_line_separator_chars[0] = 0;
31590 struct arm_long_option_table arm_long_opts[] =
31592 {"mcpu=", N_("<cpu name>\t assemble for CPU <cpu name>"),
31593 arm_parse_cpu, NULL},
31594 {"march=", N_("<arch name>\t assemble for architecture <arch name>"),
31595 arm_parse_arch, NULL},
31596 {"mfpu=", N_("<fpu name>\t assemble for FPU architecture <fpu name>"),
31597 arm_parse_fpu, NULL},
31598 {"mfloat-abi=", N_("<abi>\t assemble for floating point ABI <abi>"),
31599 arm_parse_float_abi, NULL},
31601 {"meabi=", N_("<ver>\t\t assemble for eabi version <ver>"),
31602 arm_parse_eabi, NULL},
31604 {"mimplicit-it=", N_("<mode>\t controls implicit insertion of IT instructions"),
31605 arm_parse_it_mode, NULL},
31606 {"mccs", N_("\t\t\t TI CodeComposer Studio syntax compatibility mode"),
31607 arm_ccs_mode, NULL},
31609 N_("[ieee|alternative]\n\
31610 set the encoding for half precision floating point "
31611 "numbers to IEEE\n\
31612 or Arm alternative format."),
31613 arm_parse_fp16_opt, NULL },
31614 {NULL, NULL, 0, NULL}
31618 md_parse_option (int c, const char * arg)
31620 struct arm_option_table *opt;
31621 const struct arm_legacy_option_table *fopt;
31622 struct arm_long_option_table *lopt;
31628 target_big_endian = 1;
31634 target_big_endian = 0;
31638 case OPTION_FIX_V4BX:
31646 #endif /* OBJ_ELF */
31649 /* Listing option. Just ignore these, we don't support additional
31654 for (opt = arm_opts; opt->option != NULL; opt++)
31656 if (c == opt->option[0]
31657 && ((arg == NULL && opt->option[1] == 0)
31658 || streq (arg, opt->option + 1)))
31660 /* If the option is deprecated, tell the user. */
31661 if (warn_on_deprecated && opt->deprecated != NULL)
31662 as_tsktsk (_("option `-%c%s' is deprecated: %s"), c,
31663 arg ? arg : "", _(opt->deprecated));
31665 if (opt->var != NULL)
31666 *opt->var = opt->value;
31672 for (fopt = arm_legacy_opts; fopt->option != NULL; fopt++)
31674 if (c == fopt->option[0]
31675 && ((arg == NULL && fopt->option[1] == 0)
31676 || streq (arg, fopt->option + 1)))
31678 /* If the option is deprecated, tell the user. */
31679 if (warn_on_deprecated && fopt->deprecated != NULL)
31680 as_tsktsk (_("option `-%c%s' is deprecated: %s"), c,
31681 arg ? arg : "", _(fopt->deprecated));
31683 if (fopt->var != NULL)
31684 *fopt->var = &fopt->value;
31690 for (lopt = arm_long_opts; lopt->option != NULL; lopt++)
31692 /* These options are expected to have an argument. */
31693 if (c == lopt->option[0]
31695 && strncmp (arg, lopt->option + 1,
31696 strlen (lopt->option + 1)) == 0)
31698 /* If the option is deprecated, tell the user. */
31699 if (warn_on_deprecated && lopt->deprecated != NULL)
31700 as_tsktsk (_("option `-%c%s' is deprecated: %s"), c, arg,
31701 _(lopt->deprecated));
31703 /* Call the sup-option parser. */
31704 return lopt->func (arg + strlen (lopt->option) - 1);
31715 md_show_usage (FILE * fp)
31717 struct arm_option_table *opt;
31718 struct arm_long_option_table *lopt;
31720 fprintf (fp, _(" ARM-specific assembler options:\n"));
31722 for (opt = arm_opts; opt->option != NULL; opt++)
31723 if (opt->help != NULL)
31724 fprintf (fp, " -%-23s%s\n", opt->option, _(opt->help));
31726 for (lopt = arm_long_opts; lopt->option != NULL; lopt++)
31727 if (lopt->help != NULL)
31728 fprintf (fp, " -%s%s\n", lopt->option, _(lopt->help));
31732 -EB assemble code for a big-endian cpu\n"));
31737 -EL assemble code for a little-endian cpu\n"));
31741 --fix-v4bx Allow BX in ARMv4 code\n"));
31745 --fdpic generate an FDPIC object file\n"));
31746 #endif /* OBJ_ELF */
31754 arm_feature_set flags;
31755 } cpu_arch_ver_table;
31757 /* Mapping from CPU features to EABI CPU arch values. Table must be sorted
31758 chronologically for architectures, with an exception for ARMv6-M and
31759 ARMv6S-M due to legacy reasons. No new architecture should have a
31760 special case. This allows for build attribute selection results to be
31761 stable when new architectures are added. */
31762 static const cpu_arch_ver_table cpu_arch_ver[] =
31764 {TAG_CPU_ARCH_PRE_V4, ARM_ARCH_V1},
31765 {TAG_CPU_ARCH_PRE_V4, ARM_ARCH_V2},
31766 {TAG_CPU_ARCH_PRE_V4, ARM_ARCH_V2S},
31767 {TAG_CPU_ARCH_PRE_V4, ARM_ARCH_V3},
31768 {TAG_CPU_ARCH_PRE_V4, ARM_ARCH_V3M},
31769 {TAG_CPU_ARCH_V4, ARM_ARCH_V4xM},
31770 {TAG_CPU_ARCH_V4, ARM_ARCH_V4},
31771 {TAG_CPU_ARCH_V4T, ARM_ARCH_V4TxM},
31772 {TAG_CPU_ARCH_V4T, ARM_ARCH_V4T},
31773 {TAG_CPU_ARCH_V5T, ARM_ARCH_V5xM},
31774 {TAG_CPU_ARCH_V5T, ARM_ARCH_V5},
31775 {TAG_CPU_ARCH_V5T, ARM_ARCH_V5TxM},
31776 {TAG_CPU_ARCH_V5T, ARM_ARCH_V5T},
31777 {TAG_CPU_ARCH_V5TE, ARM_ARCH_V5TExP},
31778 {TAG_CPU_ARCH_V5TE, ARM_ARCH_V5TE},
31779 {TAG_CPU_ARCH_V5TEJ, ARM_ARCH_V5TEJ},
31780 {TAG_CPU_ARCH_V6, ARM_ARCH_V6},
31781 {TAG_CPU_ARCH_V6KZ, ARM_ARCH_V6Z},
31782 {TAG_CPU_ARCH_V6KZ, ARM_ARCH_V6KZ},
31783 {TAG_CPU_ARCH_V6K, ARM_ARCH_V6K},
31784 {TAG_CPU_ARCH_V6T2, ARM_ARCH_V6T2},
31785 {TAG_CPU_ARCH_V6T2, ARM_ARCH_V6KT2},
31786 {TAG_CPU_ARCH_V6T2, ARM_ARCH_V6ZT2},
31787 {TAG_CPU_ARCH_V6T2, ARM_ARCH_V6KZT2},
31789 /* When assembling a file with only ARMv6-M or ARMv6S-M instruction, GNU as
31790 always selected build attributes to match those of ARMv6-M
31791 (resp. ARMv6S-M). However, due to these architectures being a strict
31792 subset of ARMv7-M in terms of instructions available, ARMv7-M attributes
31793 would be selected when fully respecting chronology of architectures.
31794 It is thus necessary to make a special case of ARMv6-M and ARMv6S-M and
31795 move them before ARMv7 architectures. */
31796 {TAG_CPU_ARCH_V6_M, ARM_ARCH_V6M},
31797 {TAG_CPU_ARCH_V6S_M, ARM_ARCH_V6SM},
31799 {TAG_CPU_ARCH_V7, ARM_ARCH_V7},
31800 {TAG_CPU_ARCH_V7, ARM_ARCH_V7A},
31801 {TAG_CPU_ARCH_V7, ARM_ARCH_V7R},
31802 {TAG_CPU_ARCH_V7, ARM_ARCH_V7M},
31803 {TAG_CPU_ARCH_V7, ARM_ARCH_V7VE},
31804 {TAG_CPU_ARCH_V7E_M, ARM_ARCH_V7EM},
31805 {TAG_CPU_ARCH_V8, ARM_ARCH_V8A},
31806 {TAG_CPU_ARCH_V8, ARM_ARCH_V8_1A},
31807 {TAG_CPU_ARCH_V8, ARM_ARCH_V8_2A},
31808 {TAG_CPU_ARCH_V8, ARM_ARCH_V8_3A},
31809 {TAG_CPU_ARCH_V8M_BASE, ARM_ARCH_V8M_BASE},
31810 {TAG_CPU_ARCH_V8M_MAIN, ARM_ARCH_V8M_MAIN},
31811 {TAG_CPU_ARCH_V8R, ARM_ARCH_V8R},
31812 {TAG_CPU_ARCH_V8, ARM_ARCH_V8_4A},
31813 {TAG_CPU_ARCH_V8, ARM_ARCH_V8_5A},
31814 {TAG_CPU_ARCH_V8_1M_MAIN, ARM_ARCH_V8_1M_MAIN},
31815 {-1, ARM_ARCH_NONE}
31818 /* Set an attribute if it has not already been set by the user. */
31821 aeabi_set_attribute_int (int tag, int value)
31824 || tag >= NUM_KNOWN_OBJ_ATTRIBUTES
31825 || !attributes_set_explicitly[tag])
31826 bfd_elf_add_proc_attr_int (stdoutput, tag, value);
31830 aeabi_set_attribute_string (int tag, const char *value)
31833 || tag >= NUM_KNOWN_OBJ_ATTRIBUTES
31834 || !attributes_set_explicitly[tag])
31835 bfd_elf_add_proc_attr_string (stdoutput, tag, value);
31838 /* Return whether features in the *NEEDED feature set are available via
31839 extensions for the architecture whose feature set is *ARCH_FSET. */
31842 have_ext_for_needed_feat_p (const arm_feature_set *arch_fset,
31843 const arm_feature_set *needed)
31845 int i, nb_allowed_archs;
31846 arm_feature_set ext_fset;
31847 const struct arm_option_extension_value_table *opt;
31849 ext_fset = arm_arch_none;
31850 for (opt = arm_extensions; opt->name != NULL; opt++)
31852 /* Extension does not provide any feature we need. */
31853 if (!ARM_CPU_HAS_FEATURE (*needed, opt->merge_value))
31857 sizeof (opt->allowed_archs) / sizeof (opt->allowed_archs[0]);
31858 for (i = 0; i < nb_allowed_archs; i++)
31861 if (ARM_FEATURE_EQUAL (opt->allowed_archs[i], arm_arch_any))
31864 /* Extension is available, add it. */
31865 if (ARM_FSET_CPU_SUBSET (opt->allowed_archs[i], *arch_fset))
31866 ARM_MERGE_FEATURE_SETS (ext_fset, ext_fset, opt->merge_value);
31870 /* Can we enable all features in *needed? */
31871 return ARM_FSET_CPU_SUBSET (*needed, ext_fset);
31874 /* Select value for Tag_CPU_arch and Tag_CPU_arch_profile build attributes for
31875 a given architecture feature set *ARCH_EXT_FSET including extension feature
31876 set *EXT_FSET. Selection logic used depend on EXACT_MATCH:
31877 - if true, check for an exact match of the architecture modulo extensions;
31878 - otherwise, select build attribute value of the first superset
31879 architecture released so that results remains stable when new architectures
31881 For -march/-mcpu=all the build attribute value of the most featureful
31882 architecture is returned. Tag_CPU_arch_profile result is returned in
31886 get_aeabi_cpu_arch_from_fset (const arm_feature_set *arch_ext_fset,
31887 const arm_feature_set *ext_fset,
31888 char *profile, int exact_match)
31890 arm_feature_set arch_fset;
31891 const cpu_arch_ver_table *p_ver, *p_ver_ret = NULL;
31893 /* Select most featureful architecture with all its extensions if building
31894 for -march=all as the feature sets used to set build attributes. */
31895 if (ARM_FEATURE_EQUAL (*arch_ext_fset, arm_arch_any))
31897 /* Force revisiting of decision for each new architecture. */
31898 gas_assert (MAX_TAG_CPU_ARCH <= TAG_CPU_ARCH_V8_1M_MAIN);
31900 return TAG_CPU_ARCH_V8;
31903 ARM_CLEAR_FEATURE (arch_fset, *arch_ext_fset, *ext_fset);
31905 for (p_ver = cpu_arch_ver; p_ver->val != -1; p_ver++)
31907 arm_feature_set known_arch_fset;
31909 ARM_CLEAR_FEATURE (known_arch_fset, p_ver->flags, fpu_any);
31912 /* Base architecture match user-specified architecture and
31913 extensions, eg. ARMv6S-M matching -march=armv6-m+os. */
31914 if (ARM_FEATURE_EQUAL (*arch_ext_fset, known_arch_fset))
31919 /* Base architecture match user-specified architecture only
31920 (eg. ARMv6-M in the same case as above). Record it in case we
31921 find a match with above condition. */
31922 else if (p_ver_ret == NULL
31923 && ARM_FEATURE_EQUAL (arch_fset, known_arch_fset))
31929 /* Architecture has all features wanted. */
31930 if (ARM_FSET_CPU_SUBSET (arch_fset, known_arch_fset))
31932 arm_feature_set added_fset;
31934 /* Compute features added by this architecture over the one
31935 recorded in p_ver_ret. */
31936 if (p_ver_ret != NULL)
31937 ARM_CLEAR_FEATURE (added_fset, known_arch_fset,
31939 /* First architecture that match incl. with extensions, or the
31940 only difference in features over the recorded match is
31941 features that were optional and are now mandatory. */
31942 if (p_ver_ret == NULL
31943 || ARM_FSET_CPU_SUBSET (added_fset, arch_fset))
31949 else if (p_ver_ret == NULL)
31951 arm_feature_set needed_ext_fset;
31953 ARM_CLEAR_FEATURE (needed_ext_fset, arch_fset, known_arch_fset);
31955 /* Architecture has all features needed when using some
31956 extensions. Record it and continue searching in case there
31957 exist an architecture providing all needed features without
31958 the need for extensions (eg. ARMv6S-M Vs ARMv6-M with
31960 if (have_ext_for_needed_feat_p (&known_arch_fset,
31967 if (p_ver_ret == NULL)
31971 /* Tag_CPU_arch_profile. */
31972 if (ARM_CPU_HAS_FEATURE (p_ver_ret->flags, arm_ext_v7a)
31973 || ARM_CPU_HAS_FEATURE (p_ver_ret->flags, arm_ext_v8)
31974 || (ARM_CPU_HAS_FEATURE (p_ver_ret->flags, arm_ext_atomics)
31975 && !ARM_CPU_HAS_FEATURE (p_ver_ret->flags, arm_ext_v8m_m_only)))
31977 else if (ARM_CPU_HAS_FEATURE (p_ver_ret->flags, arm_ext_v7r))
31979 else if (ARM_CPU_HAS_FEATURE (p_ver_ret->flags, arm_ext_m))
31983 return p_ver_ret->val;
31986 /* Set the public EABI object attributes. */
31989 aeabi_set_public_attributes (void)
31991 char profile = '\0';
31994 int fp16_optional = 0;
31995 int skip_exact_match = 0;
31996 arm_feature_set flags, flags_arch, flags_ext;
31998 /* Autodetection mode, choose the architecture based the instructions
32000 if (no_cpu_selected ())
32002 ARM_MERGE_FEATURE_SETS (flags, arm_arch_used, thumb_arch_used);
32004 if (ARM_CPU_HAS_FEATURE (arm_arch_used, arm_arch_any))
32005 ARM_MERGE_FEATURE_SETS (flags, flags, arm_ext_v1);
32007 if (ARM_CPU_HAS_FEATURE (thumb_arch_used, arm_arch_any))
32008 ARM_MERGE_FEATURE_SETS (flags, flags, arm_ext_v4t);
32010 /* Code run during relaxation relies on selected_cpu being set. */
32011 ARM_CLEAR_FEATURE (flags_arch, flags, fpu_any);
32012 flags_ext = arm_arch_none;
32013 ARM_CLEAR_FEATURE (selected_arch, flags_arch, flags_ext);
32014 selected_ext = flags_ext;
32015 selected_cpu = flags;
32017 /* Otherwise, choose the architecture based on the capabilities of the
32021 ARM_MERGE_FEATURE_SETS (flags_arch, selected_arch, selected_ext);
32022 ARM_CLEAR_FEATURE (flags_arch, flags_arch, fpu_any);
32023 flags_ext = selected_ext;
32024 flags = selected_cpu;
32026 ARM_MERGE_FEATURE_SETS (flags, flags, selected_fpu);
32028 /* Allow the user to override the reported architecture. */
32029 if (!ARM_FEATURE_ZERO (selected_object_arch))
32031 ARM_CLEAR_FEATURE (flags_arch, selected_object_arch, fpu_any);
32032 flags_ext = arm_arch_none;
32035 skip_exact_match = ARM_FEATURE_EQUAL (selected_cpu, arm_arch_any);
32037 /* When this function is run again after relaxation has happened there is no
32038 way to determine whether an architecture or CPU was specified by the user:
32039 - selected_cpu is set above for relaxation to work;
32040 - march_cpu_opt is not set if only -mcpu or .cpu is used;
32041 - mcpu_cpu_opt is set to arm_arch_any for autodetection.
32042 Therefore, if not in -march=all case we first try an exact match and fall
32043 back to autodetection. */
32044 if (!skip_exact_match)
32045 arch = get_aeabi_cpu_arch_from_fset (&flags_arch, &flags_ext, &profile, 1);
32047 arch = get_aeabi_cpu_arch_from_fset (&flags_arch, &flags_ext, &profile, 0);
32049 as_bad (_("no architecture contains all the instructions used\n"));
32051 /* Tag_CPU_name. */
32052 if (selected_cpu_name[0])
32056 q = selected_cpu_name;
32057 if (strncmp (q, "armv", 4) == 0)
32062 for (i = 0; q[i]; i++)
32063 q[i] = TOUPPER (q[i]);
32065 aeabi_set_attribute_string (Tag_CPU_name, q);
32068 /* Tag_CPU_arch. */
32069 aeabi_set_attribute_int (Tag_CPU_arch, arch);
32071 /* Tag_CPU_arch_profile. */
32072 if (profile != '\0')
32073 aeabi_set_attribute_int (Tag_CPU_arch_profile, profile);
32075 /* Tag_DSP_extension. */
32076 if (ARM_CPU_HAS_FEATURE (selected_ext, arm_ext_dsp))
32077 aeabi_set_attribute_int (Tag_DSP_extension, 1);
32079 ARM_CLEAR_FEATURE (flags_arch, flags, fpu_any);
32080 /* Tag_ARM_ISA_use. */
32081 if (ARM_CPU_HAS_FEATURE (flags, arm_ext_v1)
32082 || ARM_FEATURE_ZERO (flags_arch))
32083 aeabi_set_attribute_int (Tag_ARM_ISA_use, 1);
32085 /* Tag_THUMB_ISA_use. */
32086 if (ARM_CPU_HAS_FEATURE (flags, arm_ext_v4t)
32087 || ARM_FEATURE_ZERO (flags_arch))
32091 if (!ARM_CPU_HAS_FEATURE (flags, arm_ext_v8)
32092 && ARM_CPU_HAS_FEATURE (flags, arm_ext_v8m_m_only))
32094 else if (ARM_CPU_HAS_FEATURE (flags, arm_arch_t2))
32098 aeabi_set_attribute_int (Tag_THUMB_ISA_use, thumb_isa_use);
32101 /* Tag_VFP_arch. */
32102 if (ARM_CPU_HAS_FEATURE (flags, fpu_vfp_ext_armv8xd))
32103 aeabi_set_attribute_int (Tag_VFP_arch,
32104 ARM_CPU_HAS_FEATURE (flags, fpu_vfp_ext_d32)
32106 else if (ARM_CPU_HAS_FEATURE (flags, fpu_vfp_ext_fma))
32107 aeabi_set_attribute_int (Tag_VFP_arch,
32108 ARM_CPU_HAS_FEATURE (flags, fpu_vfp_ext_d32)
32110 else if (ARM_CPU_HAS_FEATURE (flags, fpu_vfp_ext_d32))
32113 aeabi_set_attribute_int (Tag_VFP_arch, 3);
32115 else if (ARM_CPU_HAS_FEATURE (flags, fpu_vfp_ext_v3xd))
32117 aeabi_set_attribute_int (Tag_VFP_arch, 4);
32120 else if (ARM_CPU_HAS_FEATURE (flags, fpu_vfp_ext_v2))
32121 aeabi_set_attribute_int (Tag_VFP_arch, 2);
32122 else if (ARM_CPU_HAS_FEATURE (flags, fpu_vfp_ext_v1)
32123 || ARM_CPU_HAS_FEATURE (flags, fpu_vfp_ext_v1xd))
32124 aeabi_set_attribute_int (Tag_VFP_arch, 1);
32126 /* Tag_ABI_HardFP_use. */
32127 if (ARM_CPU_HAS_FEATURE (flags, fpu_vfp_ext_v1xd)
32128 && !ARM_CPU_HAS_FEATURE (flags, fpu_vfp_ext_v1))
32129 aeabi_set_attribute_int (Tag_ABI_HardFP_use, 1);
32131 /* Tag_WMMX_arch. */
32132 if (ARM_CPU_HAS_FEATURE (flags, arm_cext_iwmmxt2))
32133 aeabi_set_attribute_int (Tag_WMMX_arch, 2);
32134 else if (ARM_CPU_HAS_FEATURE (flags, arm_cext_iwmmxt))
32135 aeabi_set_attribute_int (Tag_WMMX_arch, 1);
32137 /* Tag_Advanced_SIMD_arch (formerly Tag_NEON_arch). */
32138 if (ARM_CPU_HAS_FEATURE (flags, fpu_neon_ext_v8_1))
32139 aeabi_set_attribute_int (Tag_Advanced_SIMD_arch, 4);
32140 else if (ARM_CPU_HAS_FEATURE (flags, fpu_neon_ext_armv8))
32141 aeabi_set_attribute_int (Tag_Advanced_SIMD_arch, 3);
32142 else if (ARM_CPU_HAS_FEATURE (flags, fpu_neon_ext_v1))
32144 if (ARM_CPU_HAS_FEATURE (flags, fpu_neon_ext_fma))
32146 aeabi_set_attribute_int (Tag_Advanced_SIMD_arch, 2);
32150 aeabi_set_attribute_int (Tag_Advanced_SIMD_arch, 1);
32155 if (ARM_CPU_HAS_FEATURE (flags, mve_fp_ext))
32156 aeabi_set_attribute_int (Tag_MVE_arch, 2);
32157 else if (ARM_CPU_HAS_FEATURE (flags, mve_ext))
32158 aeabi_set_attribute_int (Tag_MVE_arch, 1);
32160 /* Tag_VFP_HP_extension (formerly Tag_NEON_FP16_arch). */
32161 if (ARM_CPU_HAS_FEATURE (flags, fpu_vfp_fp16) && fp16_optional)
32162 aeabi_set_attribute_int (Tag_VFP_HP_extension, 1);
32166 We set Tag_DIV_use to two when integer divide instructions have been used
32167 in ARM state, or when Thumb integer divide instructions have been used,
32168 but we have no architecture profile set, nor have we any ARM instructions.
32170 For ARMv8-A and ARMv8-M we set the tag to 0 as integer divide is implied
32171 by the base architecture.
32173 For new architectures we will have to check these tests. */
32174 gas_assert (arch <= TAG_CPU_ARCH_V8_1M_MAIN);
32175 if (ARM_CPU_HAS_FEATURE (flags, arm_ext_v8)
32176 || ARM_CPU_HAS_FEATURE (flags, arm_ext_v8m))
32177 aeabi_set_attribute_int (Tag_DIV_use, 0);
32178 else if (ARM_CPU_HAS_FEATURE (flags, arm_ext_adiv)
32179 || (profile == '\0'
32180 && ARM_CPU_HAS_FEATURE (flags, arm_ext_div)
32181 && !ARM_CPU_HAS_FEATURE (arm_arch_used, arm_arch_any)))
32182 aeabi_set_attribute_int (Tag_DIV_use, 2);
32184 /* Tag_MP_extension_use. */
32185 if (ARM_CPU_HAS_FEATURE (flags, arm_ext_mp))
32186 aeabi_set_attribute_int (Tag_MPextension_use, 1);
32188 /* Tag Virtualization_use. */
32189 if (ARM_CPU_HAS_FEATURE (flags, arm_ext_sec))
32191 if (ARM_CPU_HAS_FEATURE (flags, arm_ext_virt))
32194 aeabi_set_attribute_int (Tag_Virtualization_use, virt_sec);
32196 if (fp16_format != ARM_FP16_FORMAT_DEFAULT)
32197 aeabi_set_attribute_int (Tag_ABI_FP_16bit_format, fp16_format);
32200 /* Post relaxation hook. Recompute ARM attributes now that relaxation is
32201 finished and free extension feature bits which will not be used anymore. */
32204 arm_md_post_relax (void)
32206 aeabi_set_public_attributes ();
32207 XDELETE (mcpu_ext_opt);
32208 mcpu_ext_opt = NULL;
32209 XDELETE (march_ext_opt);
32210 march_ext_opt = NULL;
32213 /* Add the default contents for the .ARM.attributes section. */
32218 if (EF_ARM_EABI_VERSION (meabi_flags) < EF_ARM_EABI_VER4)
32221 aeabi_set_public_attributes ();
32223 #endif /* OBJ_ELF */
32225 /* Parse a .cpu directive. */
32228 s_arm_cpu (int ignored ATTRIBUTE_UNUSED)
32230 const struct arm_cpu_option_table *opt;
32234 name = input_line_pointer;
32235 while (*input_line_pointer && !ISSPACE (*input_line_pointer))
32236 input_line_pointer++;
32237 saved_char = *input_line_pointer;
32238 *input_line_pointer = 0;
32240 /* Skip the first "all" entry. */
32241 for (opt = arm_cpus + 1; opt->name != NULL; opt++)
32242 if (streq (opt->name, name))
32244 selected_arch = opt->value;
32245 selected_ext = opt->ext;
32246 ARM_MERGE_FEATURE_SETS (selected_cpu, selected_arch, selected_ext);
32247 if (opt->canonical_name)
32248 strcpy (selected_cpu_name, opt->canonical_name);
32252 for (i = 0; opt->name[i]; i++)
32253 selected_cpu_name[i] = TOUPPER (opt->name[i]);
32255 selected_cpu_name[i] = 0;
32257 ARM_MERGE_FEATURE_SETS (cpu_variant, selected_cpu, selected_fpu);
32259 *input_line_pointer = saved_char;
32260 demand_empty_rest_of_line ();
32263 as_bad (_("unknown cpu `%s'"), name);
32264 *input_line_pointer = saved_char;
32265 ignore_rest_of_line ();
32268 /* Parse a .arch directive. */
32271 s_arm_arch (int ignored ATTRIBUTE_UNUSED)
32273 const struct arm_arch_option_table *opt;
32277 name = input_line_pointer;
32278 while (*input_line_pointer && !ISSPACE (*input_line_pointer))
32279 input_line_pointer++;
32280 saved_char = *input_line_pointer;
32281 *input_line_pointer = 0;
32283 /* Skip the first "all" entry. */
32284 for (opt = arm_archs + 1; opt->name != NULL; opt++)
32285 if (streq (opt->name, name))
32287 selected_arch = opt->value;
32288 selected_ext = arm_arch_none;
32289 selected_cpu = selected_arch;
32290 strcpy (selected_cpu_name, opt->name);
32291 ARM_MERGE_FEATURE_SETS (cpu_variant, selected_cpu, selected_fpu);
32292 *input_line_pointer = saved_char;
32293 demand_empty_rest_of_line ();
32297 as_bad (_("unknown architecture `%s'\n"), name);
32298 *input_line_pointer = saved_char;
32299 ignore_rest_of_line ();
32302 /* Parse a .object_arch directive. */
32305 s_arm_object_arch (int ignored ATTRIBUTE_UNUSED)
32307 const struct arm_arch_option_table *opt;
32311 name = input_line_pointer;
32312 while (*input_line_pointer && !ISSPACE (*input_line_pointer))
32313 input_line_pointer++;
32314 saved_char = *input_line_pointer;
32315 *input_line_pointer = 0;
32317 /* Skip the first "all" entry. */
32318 for (opt = arm_archs + 1; opt->name != NULL; opt++)
32319 if (streq (opt->name, name))
32321 selected_object_arch = opt->value;
32322 *input_line_pointer = saved_char;
32323 demand_empty_rest_of_line ();
32327 as_bad (_("unknown architecture `%s'\n"), name);
32328 *input_line_pointer = saved_char;
32329 ignore_rest_of_line ();
32332 /* Parse a .arch_extension directive. */
32335 s_arm_arch_extension (int ignored ATTRIBUTE_UNUSED)
32337 const struct arm_option_extension_value_table *opt;
32340 int adding_value = 1;
32342 name = input_line_pointer;
32343 while (*input_line_pointer && !ISSPACE (*input_line_pointer))
32344 input_line_pointer++;
32345 saved_char = *input_line_pointer;
32346 *input_line_pointer = 0;
32348 if (strlen (name) >= 2
32349 && strncmp (name, "no", 2) == 0)
32355 for (opt = arm_extensions; opt->name != NULL; opt++)
32356 if (streq (opt->name, name))
32358 int i, nb_allowed_archs =
32359 sizeof (opt->allowed_archs) / sizeof (opt->allowed_archs[i]);
32360 for (i = 0; i < nb_allowed_archs; i++)
32363 if (ARM_CPU_IS_ANY (opt->allowed_archs[i]))
32365 if (ARM_FSET_CPU_SUBSET (opt->allowed_archs[i], selected_arch))
32369 if (i == nb_allowed_archs)
32371 as_bad (_("architectural extension `%s' is not allowed for the "
32372 "current base architecture"), name);
32377 ARM_MERGE_FEATURE_SETS (selected_ext, selected_ext,
32380 ARM_CLEAR_FEATURE (selected_ext, selected_ext, opt->clear_value);
32382 ARM_MERGE_FEATURE_SETS (selected_cpu, selected_arch, selected_ext);
32383 ARM_MERGE_FEATURE_SETS (cpu_variant, selected_cpu, selected_fpu);
32384 *input_line_pointer = saved_char;
32385 demand_empty_rest_of_line ();
32386 /* Allowing Thumb division instructions for ARMv7 in autodetection rely
32387 on this return so that duplicate extensions (extensions with the
32388 same name as a previous extension in the list) are not considered
32389 for command-line parsing. */
32393 if (opt->name == NULL)
32394 as_bad (_("unknown architecture extension `%s'\n"), name);
32396 *input_line_pointer = saved_char;
32397 ignore_rest_of_line ();
32400 /* Parse a .fpu directive. */
32403 s_arm_fpu (int ignored ATTRIBUTE_UNUSED)
32405 const struct arm_option_fpu_value_table *opt;
32409 name = input_line_pointer;
32410 while (*input_line_pointer && !ISSPACE (*input_line_pointer))
32411 input_line_pointer++;
32412 saved_char = *input_line_pointer;
32413 *input_line_pointer = 0;
32415 for (opt = arm_fpus; opt->name != NULL; opt++)
32416 if (streq (opt->name, name))
32418 selected_fpu = opt->value;
32419 #ifndef CPU_DEFAULT
32420 if (no_cpu_selected ())
32421 ARM_MERGE_FEATURE_SETS (cpu_variant, arm_arch_any, selected_fpu);
32424 ARM_MERGE_FEATURE_SETS (cpu_variant, selected_cpu, selected_fpu);
32425 *input_line_pointer = saved_char;
32426 demand_empty_rest_of_line ();
32430 as_bad (_("unknown floating point format `%s'\n"), name);
32431 *input_line_pointer = saved_char;
32432 ignore_rest_of_line ();
32435 /* Copy symbol information. */
32438 arm_copy_symbol_attributes (symbolS *dest, symbolS *src)
32440 ARM_GET_FLAG (dest) = ARM_GET_FLAG (src);
32444 /* Given a symbolic attribute NAME, return the proper integer value.
32445 Returns -1 if the attribute is not known. */
32448 arm_convert_symbolic_attribute (const char *name)
32450 static const struct
32455 attribute_table[] =
32457 /* When you modify this table you should
32458 also modify the list in doc/c-arm.texi. */
32459 #define T(tag) {#tag, tag}
32460 T (Tag_CPU_raw_name),
32463 T (Tag_CPU_arch_profile),
32464 T (Tag_ARM_ISA_use),
32465 T (Tag_THUMB_ISA_use),
32469 T (Tag_Advanced_SIMD_arch),
32470 T (Tag_PCS_config),
32471 T (Tag_ABI_PCS_R9_use),
32472 T (Tag_ABI_PCS_RW_data),
32473 T (Tag_ABI_PCS_RO_data),
32474 T (Tag_ABI_PCS_GOT_use),
32475 T (Tag_ABI_PCS_wchar_t),
32476 T (Tag_ABI_FP_rounding),
32477 T (Tag_ABI_FP_denormal),
32478 T (Tag_ABI_FP_exceptions),
32479 T (Tag_ABI_FP_user_exceptions),
32480 T (Tag_ABI_FP_number_model),
32481 T (Tag_ABI_align_needed),
32482 T (Tag_ABI_align8_needed),
32483 T (Tag_ABI_align_preserved),
32484 T (Tag_ABI_align8_preserved),
32485 T (Tag_ABI_enum_size),
32486 T (Tag_ABI_HardFP_use),
32487 T (Tag_ABI_VFP_args),
32488 T (Tag_ABI_WMMX_args),
32489 T (Tag_ABI_optimization_goals),
32490 T (Tag_ABI_FP_optimization_goals),
32491 T (Tag_compatibility),
32492 T (Tag_CPU_unaligned_access),
32493 T (Tag_FP_HP_extension),
32494 T (Tag_VFP_HP_extension),
32495 T (Tag_ABI_FP_16bit_format),
32496 T (Tag_MPextension_use),
32498 T (Tag_nodefaults),
32499 T (Tag_also_compatible_with),
32500 T (Tag_conformance),
32502 T (Tag_Virtualization_use),
32503 T (Tag_DSP_extension),
32505 /* We deliberately do not include Tag_MPextension_use_legacy. */
32513 for (i = 0; i < ARRAY_SIZE (attribute_table); i++)
32514 if (streq (name, attribute_table[i].name))
32515 return attribute_table[i].tag;
32520 /* Apply sym value for relocations only in the case that they are for
32521 local symbols in the same segment as the fixup and you have the
32522 respective architectural feature for blx and simple switches. */
32525 arm_apply_sym_value (struct fix * fixP, segT this_seg)
32528 && ARM_CPU_HAS_FEATURE (selected_cpu, arm_ext_v5t)
32529 /* PR 17444: If the local symbol is in a different section then a reloc
32530 will always be generated for it, so applying the symbol value now
32531 will result in a double offset being stored in the relocation. */
32532 && (S_GET_SEGMENT (fixP->fx_addsy) == this_seg)
32533 && !S_FORCE_RELOC (fixP->fx_addsy, TRUE))
32535 switch (fixP->fx_r_type)
32537 case BFD_RELOC_ARM_PCREL_BLX:
32538 case BFD_RELOC_THUMB_PCREL_BRANCH23:
32539 if (ARM_IS_FUNC (fixP->fx_addsy))
32543 case BFD_RELOC_ARM_PCREL_CALL:
32544 case BFD_RELOC_THUMB_PCREL_BLX:
32545 if (THUMB_IS_FUNC (fixP->fx_addsy))
32556 #endif /* OBJ_ELF */