1 /* tc-arm.c -- Assemble for the ARM
2 Copyright (C) 1994-2019 Free Software Foundation, Inc.
3 Contributed by Richard Earnshaw (rwe@pegasus.esprit.ec.org)
4 Modified by David Taylor (dtaylor@armltd.co.uk)
5 Cirrus coprocessor mods by Aldy Hernandez (aldyh@redhat.com)
6 Cirrus coprocessor fixes by Petko Manolov (petkan@nucleusys.com)
7 Cirrus coprocessor fixes by Vladimir Ivanov (vladitx@nucleusys.com)
9 This file is part of GAS, the GNU Assembler.
11 GAS is free software; you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation; either version 3, or (at your option)
16 GAS is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with GAS; see the file COPYING. If not, write to the Free
23 Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
30 #include "safe-ctype.h"
33 #include "libiberty.h"
34 #include "opcode/arm.h"
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. */
110 /* Perform range checks on positive and negative overflows by checking if the
111 VALUE given fits within the range of an BITS sized immediate. */
112 static bfd_boolean
out_of_range_p (offsetT value
, offsetT bits
)
114 gas_assert (bits
< (offsetT
)(sizeof (value
) * 8));
115 return (value
& ~((1 << bits
)-1))
116 && ((value
& ~((1 << bits
)-1)) != ~((1 << bits
)-1));
121 # define FPU_DEFAULT FPU_ARCH_FPA
122 # elif defined (TE_NetBSD)
124 # define FPU_DEFAULT FPU_ARCH_VFP /* Soft-float, but VFP order. */
126 /* Legacy a.out format. */
127 # define FPU_DEFAULT FPU_ARCH_FPA /* Soft-float, but FPA order. */
129 # elif defined (TE_VXWORKS)
130 # define FPU_DEFAULT FPU_ARCH_VFP /* Soft-float, VFP order. */
132 /* For backwards compatibility, default to FPA. */
133 # define FPU_DEFAULT FPU_ARCH_FPA
135 #endif /* ifndef FPU_DEFAULT */
137 #define streq(a, b) (strcmp (a, b) == 0)
139 /* Current set of feature bits available (CPU+FPU). Different from
140 selected_cpu + selected_fpu in case of autodetection since the CPU
141 feature bits are then all set. */
142 static arm_feature_set cpu_variant
;
143 /* Feature bits used in each execution state. Used to set build attribute
144 (in particular Tag_*_ISA_use) in CPU autodetection mode. */
145 static arm_feature_set arm_arch_used
;
146 static arm_feature_set thumb_arch_used
;
148 /* Flags stored in private area of BFD structure. */
149 static int uses_apcs_26
= FALSE
;
150 static int atpcs
= FALSE
;
151 static int support_interwork
= FALSE
;
152 static int uses_apcs_float
= FALSE
;
153 static int pic_code
= FALSE
;
154 static int fix_v4bx
= FALSE
;
155 /* Warn on using deprecated features. */
156 static int warn_on_deprecated
= TRUE
;
157 static int warn_on_restrict_it
= FALSE
;
159 /* Understand CodeComposer Studio assembly syntax. */
160 bfd_boolean codecomposer_syntax
= FALSE
;
162 /* Variables that we set while parsing command-line options. Once all
163 options have been read we re-process these values to set the real
166 /* CPU and FPU feature bits set for legacy CPU and FPU options (eg. -marm1
167 instead of -mcpu=arm1). */
168 static const arm_feature_set
*legacy_cpu
= NULL
;
169 static const arm_feature_set
*legacy_fpu
= NULL
;
171 /* CPU, extension and FPU feature bits selected by -mcpu. */
172 static const arm_feature_set
*mcpu_cpu_opt
= NULL
;
173 static arm_feature_set
*mcpu_ext_opt
= NULL
;
174 static const arm_feature_set
*mcpu_fpu_opt
= NULL
;
176 /* CPU, extension and FPU feature bits selected by -march. */
177 static const arm_feature_set
*march_cpu_opt
= NULL
;
178 static arm_feature_set
*march_ext_opt
= NULL
;
179 static const arm_feature_set
*march_fpu_opt
= NULL
;
181 /* Feature bits selected by -mfpu. */
182 static const arm_feature_set
*mfpu_opt
= NULL
;
184 /* Constants for known architecture features. */
185 static const arm_feature_set fpu_default
= FPU_DEFAULT
;
186 static const arm_feature_set fpu_arch_vfp_v1 ATTRIBUTE_UNUSED
= FPU_ARCH_VFP_V1
;
187 static const arm_feature_set fpu_arch_vfp_v2
= FPU_ARCH_VFP_V2
;
188 static const arm_feature_set fpu_arch_vfp_v3 ATTRIBUTE_UNUSED
= FPU_ARCH_VFP_V3
;
189 static const arm_feature_set fpu_arch_neon_v1 ATTRIBUTE_UNUSED
= FPU_ARCH_NEON_V1
;
190 static const arm_feature_set fpu_arch_fpa
= FPU_ARCH_FPA
;
191 static const arm_feature_set fpu_any_hard
= FPU_ANY_HARD
;
193 static const arm_feature_set fpu_arch_maverick
= FPU_ARCH_MAVERICK
;
195 static const arm_feature_set fpu_endian_pure
= FPU_ARCH_ENDIAN_PURE
;
198 static const arm_feature_set cpu_default
= CPU_DEFAULT
;
201 static const arm_feature_set arm_ext_v1
= ARM_FEATURE_CORE_LOW (ARM_EXT_V1
);
202 static const arm_feature_set arm_ext_v2
= ARM_FEATURE_CORE_LOW (ARM_EXT_V2
);
203 static const arm_feature_set arm_ext_v2s
= ARM_FEATURE_CORE_LOW (ARM_EXT_V2S
);
204 static const arm_feature_set arm_ext_v3
= ARM_FEATURE_CORE_LOW (ARM_EXT_V3
);
205 static const arm_feature_set arm_ext_v3m
= ARM_FEATURE_CORE_LOW (ARM_EXT_V3M
);
206 static const arm_feature_set arm_ext_v4
= ARM_FEATURE_CORE_LOW (ARM_EXT_V4
);
207 static const arm_feature_set arm_ext_v4t
= ARM_FEATURE_CORE_LOW (ARM_EXT_V4T
);
208 static const arm_feature_set arm_ext_v5
= ARM_FEATURE_CORE_LOW (ARM_EXT_V5
);
209 static const arm_feature_set arm_ext_v4t_5
=
210 ARM_FEATURE_CORE_LOW (ARM_EXT_V4T
| ARM_EXT_V5
);
211 static const arm_feature_set arm_ext_v5t
= ARM_FEATURE_CORE_LOW (ARM_EXT_V5T
);
212 static const arm_feature_set arm_ext_v5e
= ARM_FEATURE_CORE_LOW (ARM_EXT_V5E
);
213 static const arm_feature_set arm_ext_v5exp
= ARM_FEATURE_CORE_LOW (ARM_EXT_V5ExP
);
214 static const arm_feature_set arm_ext_v5j
= ARM_FEATURE_CORE_LOW (ARM_EXT_V5J
);
215 static const arm_feature_set arm_ext_v6
= ARM_FEATURE_CORE_LOW (ARM_EXT_V6
);
216 static const arm_feature_set arm_ext_v6k
= ARM_FEATURE_CORE_LOW (ARM_EXT_V6K
);
217 static const arm_feature_set arm_ext_v6t2
= ARM_FEATURE_CORE_LOW (ARM_EXT_V6T2
);
218 /* Only for compatability of hint instructions. */
219 static const arm_feature_set arm_ext_v6k_v6t2
=
220 ARM_FEATURE_CORE_LOW (ARM_EXT_V6K
| ARM_EXT_V6T2
);
221 static const arm_feature_set arm_ext_v6_notm
=
222 ARM_FEATURE_CORE_LOW (ARM_EXT_V6_NOTM
);
223 static const arm_feature_set arm_ext_v6_dsp
=
224 ARM_FEATURE_CORE_LOW (ARM_EXT_V6_DSP
);
225 static const arm_feature_set arm_ext_barrier
=
226 ARM_FEATURE_CORE_LOW (ARM_EXT_BARRIER
);
227 static const arm_feature_set arm_ext_msr
=
228 ARM_FEATURE_CORE_LOW (ARM_EXT_THUMB_MSR
);
229 static const arm_feature_set arm_ext_div
= ARM_FEATURE_CORE_LOW (ARM_EXT_DIV
);
230 static const arm_feature_set arm_ext_v7
= ARM_FEATURE_CORE_LOW (ARM_EXT_V7
);
231 static const arm_feature_set arm_ext_v7a
= ARM_FEATURE_CORE_LOW (ARM_EXT_V7A
);
232 static const arm_feature_set arm_ext_v7r
= ARM_FEATURE_CORE_LOW (ARM_EXT_V7R
);
234 static const arm_feature_set ATTRIBUTE_UNUSED arm_ext_v7m
= ARM_FEATURE_CORE_LOW (ARM_EXT_V7M
);
236 static const arm_feature_set arm_ext_v8
= ARM_FEATURE_CORE_LOW (ARM_EXT_V8
);
237 static const arm_feature_set arm_ext_m
=
238 ARM_FEATURE_CORE (ARM_EXT_V6M
| ARM_EXT_V7M
,
239 ARM_EXT2_V8M
| ARM_EXT2_V8M_MAIN
);
240 static const arm_feature_set arm_ext_mp
= ARM_FEATURE_CORE_LOW (ARM_EXT_MP
);
241 static const arm_feature_set arm_ext_sec
= ARM_FEATURE_CORE_LOW (ARM_EXT_SEC
);
242 static const arm_feature_set arm_ext_os
= ARM_FEATURE_CORE_LOW (ARM_EXT_OS
);
243 static const arm_feature_set arm_ext_adiv
= ARM_FEATURE_CORE_LOW (ARM_EXT_ADIV
);
244 static const arm_feature_set arm_ext_virt
= ARM_FEATURE_CORE_LOW (ARM_EXT_VIRT
);
245 static const arm_feature_set arm_ext_pan
= ARM_FEATURE_CORE_HIGH (ARM_EXT2_PAN
);
246 static const arm_feature_set arm_ext_v8m
= ARM_FEATURE_CORE_HIGH (ARM_EXT2_V8M
);
247 static const arm_feature_set arm_ext_v8m_main
=
248 ARM_FEATURE_CORE_HIGH (ARM_EXT2_V8M_MAIN
);
249 static const arm_feature_set arm_ext_v8_1m_main
=
250 ARM_FEATURE_CORE_HIGH (ARM_EXT2_V8_1M_MAIN
);
251 /* Instructions in ARMv8-M only found in M profile architectures. */
252 static const arm_feature_set arm_ext_v8m_m_only
=
253 ARM_FEATURE_CORE_HIGH (ARM_EXT2_V8M
| ARM_EXT2_V8M_MAIN
);
254 static const arm_feature_set arm_ext_v6t2_v8m
=
255 ARM_FEATURE_CORE_HIGH (ARM_EXT2_V6T2_V8M
);
256 /* Instructions shared between ARMv8-A and ARMv8-M. */
257 static const arm_feature_set arm_ext_atomics
=
258 ARM_FEATURE_CORE_HIGH (ARM_EXT2_ATOMICS
);
260 /* DSP instructions Tag_DSP_extension refers to. */
261 static const arm_feature_set arm_ext_dsp
=
262 ARM_FEATURE_CORE_LOW (ARM_EXT_V5E
| ARM_EXT_V5ExP
| ARM_EXT_V6_DSP
);
264 static const arm_feature_set arm_ext_ras
=
265 ARM_FEATURE_CORE_HIGH (ARM_EXT2_RAS
);
266 /* FP16 instructions. */
267 static const arm_feature_set arm_ext_fp16
=
268 ARM_FEATURE_CORE_HIGH (ARM_EXT2_FP16_INST
);
269 static const arm_feature_set arm_ext_fp16_fml
=
270 ARM_FEATURE_CORE_HIGH (ARM_EXT2_FP16_FML
);
271 static const arm_feature_set arm_ext_v8_2
=
272 ARM_FEATURE_CORE_HIGH (ARM_EXT2_V8_2A
);
273 static const arm_feature_set arm_ext_v8_3
=
274 ARM_FEATURE_CORE_HIGH (ARM_EXT2_V8_3A
);
275 static const arm_feature_set arm_ext_sb
=
276 ARM_FEATURE_CORE_HIGH (ARM_EXT2_SB
);
277 static const arm_feature_set arm_ext_predres
=
278 ARM_FEATURE_CORE_HIGH (ARM_EXT2_PREDRES
);
279 static const arm_feature_set arm_ext_bf16
=
280 ARM_FEATURE_CORE_HIGH (ARM_EXT2_BF16
);
281 static const arm_feature_set arm_ext_i8mm
=
282 ARM_FEATURE_CORE_HIGH (ARM_EXT2_I8MM
);
283 static const arm_feature_set arm_ext_crc
=
284 ARM_FEATURE_CORE_HIGH (ARM_EXT2_CRC
);
286 static const arm_feature_set arm_arch_any
= ARM_ANY
;
287 static const arm_feature_set fpu_any
= FPU_ANY
;
288 static const arm_feature_set arm_arch_full ATTRIBUTE_UNUSED
= ARM_FEATURE (-1, -1, -1);
289 static const arm_feature_set arm_arch_t2
= ARM_ARCH_THUMB2
;
290 static const arm_feature_set arm_arch_none
= ARM_ARCH_NONE
;
292 static const arm_feature_set arm_cext_iwmmxt2
=
293 ARM_FEATURE_COPROC (ARM_CEXT_IWMMXT2
);
294 static const arm_feature_set arm_cext_iwmmxt
=
295 ARM_FEATURE_COPROC (ARM_CEXT_IWMMXT
);
296 static const arm_feature_set arm_cext_xscale
=
297 ARM_FEATURE_COPROC (ARM_CEXT_XSCALE
);
298 static const arm_feature_set arm_cext_maverick
=
299 ARM_FEATURE_COPROC (ARM_CEXT_MAVERICK
);
300 static const arm_feature_set fpu_fpa_ext_v1
=
301 ARM_FEATURE_COPROC (FPU_FPA_EXT_V1
);
302 static const arm_feature_set fpu_fpa_ext_v2
=
303 ARM_FEATURE_COPROC (FPU_FPA_EXT_V2
);
304 static const arm_feature_set fpu_vfp_ext_v1xd
=
305 ARM_FEATURE_COPROC (FPU_VFP_EXT_V1xD
);
306 static const arm_feature_set fpu_vfp_ext_v1
=
307 ARM_FEATURE_COPROC (FPU_VFP_EXT_V1
);
308 static const arm_feature_set fpu_vfp_ext_v2
=
309 ARM_FEATURE_COPROC (FPU_VFP_EXT_V2
);
310 static const arm_feature_set fpu_vfp_ext_v3xd
=
311 ARM_FEATURE_COPROC (FPU_VFP_EXT_V3xD
);
312 static const arm_feature_set fpu_vfp_ext_v3
=
313 ARM_FEATURE_COPROC (FPU_VFP_EXT_V3
);
314 static const arm_feature_set fpu_vfp_ext_d32
=
315 ARM_FEATURE_COPROC (FPU_VFP_EXT_D32
);
316 static const arm_feature_set fpu_neon_ext_v1
=
317 ARM_FEATURE_COPROC (FPU_NEON_EXT_V1
);
318 static const arm_feature_set fpu_vfp_v3_or_neon_ext
=
319 ARM_FEATURE_COPROC (FPU_NEON_EXT_V1
| FPU_VFP_EXT_V3
);
320 static const arm_feature_set mve_ext
=
321 ARM_FEATURE_COPROC (FPU_MVE
);
322 static const arm_feature_set mve_fp_ext
=
323 ARM_FEATURE_COPROC (FPU_MVE_FP
);
325 static const arm_feature_set fpu_vfp_fp16
=
326 ARM_FEATURE_COPROC (FPU_VFP_EXT_FP16
);
327 static const arm_feature_set fpu_neon_ext_fma
=
328 ARM_FEATURE_COPROC (FPU_NEON_EXT_FMA
);
330 static const arm_feature_set fpu_vfp_ext_fma
=
331 ARM_FEATURE_COPROC (FPU_VFP_EXT_FMA
);
332 static const arm_feature_set fpu_vfp_ext_armv8
=
333 ARM_FEATURE_COPROC (FPU_VFP_EXT_ARMV8
);
334 static const arm_feature_set fpu_vfp_ext_armv8xd
=
335 ARM_FEATURE_COPROC (FPU_VFP_EXT_ARMV8xD
);
336 static const arm_feature_set fpu_neon_ext_armv8
=
337 ARM_FEATURE_COPROC (FPU_NEON_EXT_ARMV8
);
338 static const arm_feature_set fpu_crypto_ext_armv8
=
339 ARM_FEATURE_COPROC (FPU_CRYPTO_EXT_ARMV8
);
340 static const arm_feature_set fpu_neon_ext_v8_1
=
341 ARM_FEATURE_COPROC (FPU_NEON_EXT_RDMA
);
342 static const arm_feature_set fpu_neon_ext_dotprod
=
343 ARM_FEATURE_COPROC (FPU_NEON_EXT_DOTPROD
);
345 static int mfloat_abi_opt
= -1;
346 /* Architecture feature bits selected by the last -mcpu/-march or .cpu/.arch
348 static arm_feature_set selected_arch
= ARM_ARCH_NONE
;
349 /* Extension feature bits selected by the last -mcpu/-march or .arch_extension
351 static arm_feature_set selected_ext
= ARM_ARCH_NONE
;
352 /* Feature bits selected by the last -mcpu/-march or by the combination of the
353 last .cpu/.arch directive .arch_extension directives since that
355 static arm_feature_set selected_cpu
= ARM_ARCH_NONE
;
356 /* FPU feature bits selected by the last -mfpu or .fpu directive. */
357 static arm_feature_set selected_fpu
= FPU_NONE
;
358 /* Feature bits selected by the last .object_arch directive. */
359 static arm_feature_set selected_object_arch
= ARM_ARCH_NONE
;
360 /* Must be long enough to hold any of the names in arm_cpus. */
361 static const struct arm_ext_table
* selected_ctx_ext_table
= NULL
;
362 static char selected_cpu_name
[20];
364 extern FLONUM_TYPE generic_floating_point_number
;
366 /* Return if no cpu was selected on command-line. */
368 no_cpu_selected (void)
370 return ARM_FEATURE_EQUAL (selected_cpu
, arm_arch_none
);
375 static int meabi_flags
= EABI_DEFAULT
;
377 static int meabi_flags
= EF_ARM_EABI_UNKNOWN
;
380 static int attributes_set_explicitly
[NUM_KNOWN_OBJ_ATTRIBUTES
];
385 return (EF_ARM_EABI_VERSION (meabi_flags
) >= EF_ARM_EABI_VER4
);
390 /* Pre-defined "_GLOBAL_OFFSET_TABLE_" */
391 symbolS
* GOT_symbol
;
394 /* 0: assemble for ARM,
395 1: assemble for Thumb,
396 2: assemble for Thumb even though target CPU does not support thumb
398 static int thumb_mode
= 0;
399 /* A value distinct from the possible values for thumb_mode that we
400 can use to record whether thumb_mode has been copied into the
401 tc_frag_data field of a frag. */
402 #define MODE_RECORDED (1 << 4)
404 /* Specifies the intrinsic IT insn behavior mode. */
405 enum implicit_it_mode
407 IMPLICIT_IT_MODE_NEVER
= 0x00,
408 IMPLICIT_IT_MODE_ARM
= 0x01,
409 IMPLICIT_IT_MODE_THUMB
= 0x02,
410 IMPLICIT_IT_MODE_ALWAYS
= (IMPLICIT_IT_MODE_ARM
| IMPLICIT_IT_MODE_THUMB
)
412 static int implicit_it_mode
= IMPLICIT_IT_MODE_ARM
;
414 /* If unified_syntax is true, we are processing the new unified
415 ARM/Thumb syntax. Important differences from the old ARM mode:
417 - Immediate operands do not require a # prefix.
418 - Conditional affixes always appear at the end of the
419 instruction. (For backward compatibility, those instructions
420 that formerly had them in the middle, continue to accept them
422 - The IT instruction may appear, and if it does is validated
423 against subsequent conditional affixes. It does not generate
426 Important differences from the old Thumb mode:
428 - Immediate operands do not require a # prefix.
429 - Most of the V6T2 instructions are only available in unified mode.
430 - The .N and .W suffixes are recognized and honored (it is an error
431 if they cannot be honored).
432 - All instructions set the flags if and only if they have an 's' affix.
433 - Conditional affixes may be used. They are validated against
434 preceding IT instructions. Unlike ARM mode, you cannot use a
435 conditional affix except in the scope of an IT instruction. */
437 static bfd_boolean unified_syntax
= FALSE
;
439 /* An immediate operand can start with #, and ld*, st*, pld operands
440 can contain [ and ]. We need to tell APP not to elide whitespace
441 before a [, which can appear as the first operand for pld.
442 Likewise, a { can appear as the first operand for push, pop, vld*, etc. */
443 const char arm_symbol_chars
[] = "#[]{}";
459 enum neon_el_type type
;
463 #define NEON_MAX_TYPE_ELS 4
467 struct neon_type_el el
[NEON_MAX_TYPE_ELS
];
471 enum pred_instruction_type
477 IF_INSIDE_IT_LAST_INSN
, /* Either outside or inside;
478 if inside, should be the last one. */
479 NEUTRAL_IT_INSN
, /* This could be either inside or outside,
480 i.e. BKPT and NOP. */
481 IT_INSN
, /* The IT insn has been parsed. */
482 VPT_INSN
, /* The VPT/VPST insn has been parsed. */
483 MVE_OUTSIDE_PRED_INSN
, /* Instruction to indicate a MVE instruction without
484 a predication code. */
485 MVE_UNPREDICABLE_INSN
/* MVE instruction that is non-predicable. */
488 /* The maximum number of operands we need. */
489 #define ARM_IT_MAX_OPERANDS 6
490 #define ARM_IT_MAX_RELOCS 3
495 unsigned long instruction
;
499 /* "uncond_value" is set to the value in place of the conditional field in
500 unconditional versions of the instruction, or -1 if nothing is
503 struct neon_type vectype
;
504 /* This does not indicate an actual NEON instruction, only that
505 the mnemonic accepts neon-style type suffixes. */
507 /* Set to the opcode if the instruction needs relaxation.
508 Zero if the instruction is not relaxed. */
512 bfd_reloc_code_real_type type
;
515 } relocs
[ARM_IT_MAX_RELOCS
];
517 enum pred_instruction_type pred_insn_type
;
523 struct neon_type_el vectype
;
524 unsigned present
: 1; /* Operand present. */
525 unsigned isreg
: 1; /* Operand was a register. */
526 unsigned immisreg
: 2; /* .imm field is a second register.
527 0: imm, 1: gpr, 2: MVE Q-register. */
528 unsigned isscalar
: 2; /* Operand is a (SIMD) scalar:
532 unsigned immisalign
: 1; /* Immediate is an alignment specifier. */
533 unsigned immisfloat
: 1; /* Immediate was parsed as a float. */
534 /* Note: we abuse "regisimm" to mean "is Neon register" in VMOV
535 instructions. This allows us to disambiguate ARM <-> vector insns. */
536 unsigned regisimm
: 1; /* 64-bit immediate, reg forms high 32 bits. */
537 unsigned isvec
: 1; /* Is a single, double or quad VFP/Neon reg. */
538 unsigned isquad
: 1; /* Operand is SIMD quad register. */
539 unsigned issingle
: 1; /* Operand is VFP single-precision register. */
540 unsigned iszr
: 1; /* Operand is ZR register. */
541 unsigned hasreloc
: 1; /* Operand has relocation suffix. */
542 unsigned writeback
: 1; /* Operand has trailing ! */
543 unsigned preind
: 1; /* Preindexed address. */
544 unsigned postind
: 1; /* Postindexed address. */
545 unsigned negative
: 1; /* Index register was negated. */
546 unsigned shifted
: 1; /* Shift applied to operation. */
547 unsigned shift_kind
: 3; /* Shift operation (enum shift_kind). */
548 } operands
[ARM_IT_MAX_OPERANDS
];
551 static struct arm_it inst
;
553 #define NUM_FLOAT_VALS 8
555 const char * fp_const
[] =
557 "0.0", "1.0", "2.0", "3.0", "4.0", "5.0", "0.5", "10.0", 0
560 LITTLENUM_TYPE fp_values
[NUM_FLOAT_VALS
][MAX_LITTLENUMS
];
570 #define CP_T_X 0x00008000
571 #define CP_T_Y 0x00400000
573 #define CONDS_BIT 0x00100000
574 #define LOAD_BIT 0x00100000
576 #define DOUBLE_LOAD_FLAG 0x00000001
580 const char * template_name
;
584 #define COND_ALWAYS 0xE
588 const char * template_name
;
592 struct asm_barrier_opt
594 const char * template_name
;
596 const arm_feature_set arch
;
599 /* The bit that distinguishes CPSR and SPSR. */
600 #define SPSR_BIT (1 << 22)
602 /* The individual PSR flag bits. */
603 #define PSR_c (1 << 16)
604 #define PSR_x (1 << 17)
605 #define PSR_s (1 << 18)
606 #define PSR_f (1 << 19)
611 bfd_reloc_code_real_type reloc
;
616 VFP_REG_Sd
, VFP_REG_Sm
, VFP_REG_Sn
,
617 VFP_REG_Dd
, VFP_REG_Dm
, VFP_REG_Dn
622 VFP_LDSTMIA
, VFP_LDSTMDB
, VFP_LDSTMIAX
, VFP_LDSTMDBX
625 /* Bits for DEFINED field in neon_typed_alias. */
626 #define NTA_HASTYPE 1
627 #define NTA_HASINDEX 2
629 struct neon_typed_alias
631 unsigned char defined
;
633 struct neon_type_el eltype
;
636 /* ARM register categories. This includes coprocessor numbers and various
637 architecture extensions' registers. Each entry should have an error message
638 in reg_expected_msgs below. */
668 /* Structure for a hash table entry for a register.
669 If TYPE is REG_TYPE_VFD or REG_TYPE_NQ, the NEON field can point to extra
670 information which states whether a vector type or index is specified (for a
671 register alias created with .dn or .qn). Otherwise NEON should be NULL. */
677 unsigned char builtin
;
678 struct neon_typed_alias
* neon
;
681 /* Diagnostics used when we don't get a register of the expected type. */
682 const char * const reg_expected_msgs
[] =
684 [REG_TYPE_RN
] = N_("ARM register expected"),
685 [REG_TYPE_CP
] = N_("bad or missing co-processor number"),
686 [REG_TYPE_CN
] = N_("co-processor register expected"),
687 [REG_TYPE_FN
] = N_("FPA register expected"),
688 [REG_TYPE_VFS
] = N_("VFP single precision register expected"),
689 [REG_TYPE_VFD
] = N_("VFP/Neon double precision register expected"),
690 [REG_TYPE_NQ
] = N_("Neon quad precision register expected"),
691 [REG_TYPE_VFSD
] = N_("VFP single or double precision register expected"),
692 [REG_TYPE_NDQ
] = N_("Neon double or quad precision register expected"),
693 [REG_TYPE_NSD
] = N_("Neon single or double precision register expected"),
694 [REG_TYPE_NSDQ
] = N_("VFP single, double or Neon quad precision register"
696 [REG_TYPE_VFC
] = N_("VFP system register expected"),
697 [REG_TYPE_MVF
] = N_("Maverick MVF register expected"),
698 [REG_TYPE_MVD
] = N_("Maverick MVD register expected"),
699 [REG_TYPE_MVFX
] = N_("Maverick MVFX register expected"),
700 [REG_TYPE_MVDX
] = N_("Maverick MVDX register expected"),
701 [REG_TYPE_MVAX
] = N_("Maverick MVAX register expected"),
702 [REG_TYPE_DSPSC
] = N_("Maverick DSPSC register expected"),
703 [REG_TYPE_MMXWR
] = N_("iWMMXt data register expected"),
704 [REG_TYPE_MMXWC
] = N_("iWMMXt control register expected"),
705 [REG_TYPE_MMXWCG
] = N_("iWMMXt scalar register expected"),
706 [REG_TYPE_XSCALE
] = N_("XScale accumulator register expected"),
707 [REG_TYPE_MQ
] = N_("MVE vector register expected"),
708 [REG_TYPE_RNB
] = N_("")
711 /* Some well known registers that we refer to directly elsewhere. */
717 /* ARM instructions take 4bytes in the object file, Thumb instructions
723 /* Basic string to match. */
724 const char * template_name
;
726 /* Parameters to instruction. */
727 unsigned int operands
[8];
729 /* Conditional tag - see opcode_lookup. */
730 unsigned int tag
: 4;
732 /* Basic instruction code. */
735 /* Thumb-format instruction code. */
738 /* Which architecture variant provides this instruction. */
739 const arm_feature_set
* avariant
;
740 const arm_feature_set
* tvariant
;
742 /* Function to call to encode instruction in ARM format. */
743 void (* aencode
) (void);
745 /* Function to call to encode instruction in Thumb format. */
746 void (* tencode
) (void);
748 /* Indicates whether this instruction may be vector predicated. */
749 unsigned int mayBeVecPred
: 1;
752 /* Defines for various bits that we will want to toggle. */
753 #define INST_IMMEDIATE 0x02000000
754 #define OFFSET_REG 0x02000000
755 #define HWOFFSET_IMM 0x00400000
756 #define SHIFT_BY_REG 0x00000010
757 #define PRE_INDEX 0x01000000
758 #define INDEX_UP 0x00800000
759 #define WRITE_BACK 0x00200000
760 #define LDM_TYPE_2_OR_3 0x00400000
761 #define CPSI_MMOD 0x00020000
763 #define LITERAL_MASK 0xf000f000
764 #define OPCODE_MASK 0xfe1fffff
765 #define V4_STR_BIT 0x00000020
766 #define VLDR_VMOV_SAME 0x0040f000
768 #define T2_SUBS_PC_LR 0xf3de8f00
770 #define DATA_OP_SHIFT 21
771 #define SBIT_SHIFT 20
773 #define T2_OPCODE_MASK 0xfe1fffff
774 #define T2_DATA_OP_SHIFT 21
775 #define T2_SBIT_SHIFT 20
777 #define A_COND_MASK 0xf0000000
778 #define A_PUSH_POP_OP_MASK 0x0fff0000
780 /* Opcodes for pushing/poping registers to/from the stack. */
781 #define A1_OPCODE_PUSH 0x092d0000
782 #define A2_OPCODE_PUSH 0x052d0004
783 #define A2_OPCODE_POP 0x049d0004
785 /* Codes to distinguish the arithmetic instructions. */
796 #define OPCODE_CMP 10
797 #define OPCODE_CMN 11
798 #define OPCODE_ORR 12
799 #define OPCODE_MOV 13
800 #define OPCODE_BIC 14
801 #define OPCODE_MVN 15
803 #define T2_OPCODE_AND 0
804 #define T2_OPCODE_BIC 1
805 #define T2_OPCODE_ORR 2
806 #define T2_OPCODE_ORN 3
807 #define T2_OPCODE_EOR 4
808 #define T2_OPCODE_ADD 8
809 #define T2_OPCODE_ADC 10
810 #define T2_OPCODE_SBC 11
811 #define T2_OPCODE_SUB 13
812 #define T2_OPCODE_RSB 14
814 #define T_OPCODE_MUL 0x4340
815 #define T_OPCODE_TST 0x4200
816 #define T_OPCODE_CMN 0x42c0
817 #define T_OPCODE_NEG 0x4240
818 #define T_OPCODE_MVN 0x43c0
820 #define T_OPCODE_ADD_R3 0x1800
821 #define T_OPCODE_SUB_R3 0x1a00
822 #define T_OPCODE_ADD_HI 0x4400
823 #define T_OPCODE_ADD_ST 0xb000
824 #define T_OPCODE_SUB_ST 0xb080
825 #define T_OPCODE_ADD_SP 0xa800
826 #define T_OPCODE_ADD_PC 0xa000
827 #define T_OPCODE_ADD_I8 0x3000
828 #define T_OPCODE_SUB_I8 0x3800
829 #define T_OPCODE_ADD_I3 0x1c00
830 #define T_OPCODE_SUB_I3 0x1e00
832 #define T_OPCODE_ASR_R 0x4100
833 #define T_OPCODE_LSL_R 0x4080
834 #define T_OPCODE_LSR_R 0x40c0
835 #define T_OPCODE_ROR_R 0x41c0
836 #define T_OPCODE_ASR_I 0x1000
837 #define T_OPCODE_LSL_I 0x0000
838 #define T_OPCODE_LSR_I 0x0800
840 #define T_OPCODE_MOV_I8 0x2000
841 #define T_OPCODE_CMP_I8 0x2800
842 #define T_OPCODE_CMP_LR 0x4280
843 #define T_OPCODE_MOV_HR 0x4600
844 #define T_OPCODE_CMP_HR 0x4500
846 #define T_OPCODE_LDR_PC 0x4800
847 #define T_OPCODE_LDR_SP 0x9800
848 #define T_OPCODE_STR_SP 0x9000
849 #define T_OPCODE_LDR_IW 0x6800
850 #define T_OPCODE_STR_IW 0x6000
851 #define T_OPCODE_LDR_IH 0x8800
852 #define T_OPCODE_STR_IH 0x8000
853 #define T_OPCODE_LDR_IB 0x7800
854 #define T_OPCODE_STR_IB 0x7000
855 #define T_OPCODE_LDR_RW 0x5800
856 #define T_OPCODE_STR_RW 0x5000
857 #define T_OPCODE_LDR_RH 0x5a00
858 #define T_OPCODE_STR_RH 0x5200
859 #define T_OPCODE_LDR_RB 0x5c00
860 #define T_OPCODE_STR_RB 0x5400
862 #define T_OPCODE_PUSH 0xb400
863 #define T_OPCODE_POP 0xbc00
865 #define T_OPCODE_BRANCH 0xe000
867 #define THUMB_SIZE 2 /* Size of thumb instruction. */
868 #define THUMB_PP_PC_LR 0x0100
869 #define THUMB_LOAD_BIT 0x0800
870 #define THUMB2_LOAD_BIT 0x00100000
872 #define BAD_SYNTAX _("syntax error")
873 #define BAD_ARGS _("bad arguments to instruction")
874 #define BAD_SP _("r13 not allowed here")
875 #define BAD_PC _("r15 not allowed here")
876 #define BAD_ODD _("Odd register not allowed here")
877 #define BAD_EVEN _("Even register not allowed here")
878 #define BAD_COND _("instruction cannot be conditional")
879 #define BAD_OVERLAP _("registers may not be the same")
880 #define BAD_HIREG _("lo register required")
881 #define BAD_THUMB32 _("instruction not supported in Thumb16 mode")
882 #define BAD_ADDR_MODE _("instruction does not accept this addressing mode")
883 #define BAD_BRANCH _("branch must be last instruction in IT block")
884 #define BAD_BRANCH_OFF _("branch out of range or not a multiple of 2")
885 #define BAD_NOT_IT _("instruction not allowed in IT block")
886 #define BAD_NOT_VPT _("instruction missing MVE vector predication code")
887 #define BAD_FPU _("selected FPU does not support instruction")
888 #define BAD_OUT_IT _("thumb conditional instruction should be in IT block")
889 #define BAD_OUT_VPT \
890 _("vector predicated instruction should be in VPT/VPST block")
891 #define BAD_IT_COND _("incorrect condition in IT block")
892 #define BAD_VPT_COND _("incorrect condition in VPT/VPST block")
893 #define BAD_IT_IT _("IT falling in the range of a previous IT block")
894 #define MISSING_FNSTART _("missing .fnstart before unwinding directive")
895 #define BAD_PC_ADDRESSING \
896 _("cannot use register index with PC-relative addressing")
897 #define BAD_PC_WRITEBACK \
898 _("cannot use writeback with PC-relative addressing")
899 #define BAD_RANGE _("branch out of range")
900 #define BAD_FP16 _("selected processor does not support fp16 instruction")
901 #define BAD_BF16 _("selected processor does not support bf16 instruction")
902 #define UNPRED_REG(R) _("using " R " results in unpredictable behaviour")
903 #define THUMB1_RELOC_ONLY _("relocation valid in thumb1 code only")
904 #define MVE_NOT_IT _("Warning: instruction is UNPREDICTABLE in an IT " \
906 #define MVE_NOT_VPT _("Warning: instruction is UNPREDICTABLE in a VPT " \
908 #define MVE_BAD_PC _("Warning: instruction is UNPREDICTABLE with PC" \
910 #define MVE_BAD_SP _("Warning: instruction is UNPREDICTABLE with SP" \
912 #define BAD_SIMD_TYPE _("bad type in SIMD instruction")
913 #define BAD_MVE_AUTO \
914 _("GAS auto-detection mode and -march=all is deprecated for MVE, please" \
915 " use a valid -march or -mcpu option.")
916 #define BAD_MVE_SRCDEST _("Warning: 32-bit element size and same destination "\
917 "and source operands makes instruction UNPREDICTABLE")
918 #define BAD_EL_TYPE _("bad element type for instruction")
919 #define MVE_BAD_QREG _("MVE vector register Q[0..7] expected")
921 static struct hash_control
* arm_ops_hsh
;
922 static struct hash_control
* arm_cond_hsh
;
923 static struct hash_control
* arm_vcond_hsh
;
924 static struct hash_control
* arm_shift_hsh
;
925 static struct hash_control
* arm_psr_hsh
;
926 static struct hash_control
* arm_v7m_psr_hsh
;
927 static struct hash_control
* arm_reg_hsh
;
928 static struct hash_control
* arm_reloc_hsh
;
929 static struct hash_control
* arm_barrier_opt_hsh
;
931 /* Stuff needed to resolve the label ambiguity
940 symbolS
* last_label_seen
;
941 static int label_is_thumb_function_name
= FALSE
;
943 /* Literal pool structure. Held on a per-section
944 and per-sub-section basis. */
946 #define MAX_LITERAL_POOL_SIZE 1024
947 typedef struct literal_pool
949 expressionS literals
[MAX_LITERAL_POOL_SIZE
];
950 unsigned int next_free_entry
;
956 struct dwarf2_line_info locs
[MAX_LITERAL_POOL_SIZE
];
958 struct literal_pool
* next
;
959 unsigned int alignment
;
962 /* Pointer to a linked list of literal pools. */
963 literal_pool
* list_of_pools
= NULL
;
965 typedef enum asmfunc_states
968 WAITING_ASMFUNC_NAME
,
972 static asmfunc_states asmfunc_state
= OUTSIDE_ASMFUNC
;
975 # define now_pred seg_info (now_seg)->tc_segment_info_data.current_pred
977 static struct current_pred now_pred
;
981 now_pred_compatible (int cond
)
983 return (cond
& ~1) == (now_pred
.cc
& ~1);
987 conditional_insn (void)
989 return inst
.cond
!= COND_ALWAYS
;
992 static int in_pred_block (void);
994 static int handle_pred_state (void);
996 static void force_automatic_it_block_close (void);
998 static void it_fsm_post_encode (void);
1000 #define set_pred_insn_type(type) \
1003 inst.pred_insn_type = type; \
1004 if (handle_pred_state () == FAIL) \
1009 #define set_pred_insn_type_nonvoid(type, failret) \
1012 inst.pred_insn_type = type; \
1013 if (handle_pred_state () == FAIL) \
1018 #define set_pred_insn_type_last() \
1021 if (inst.cond == COND_ALWAYS) \
1022 set_pred_insn_type (IF_INSIDE_IT_LAST_INSN); \
1024 set_pred_insn_type (INSIDE_IT_LAST_INSN); \
1028 /* Toggle value[pos]. */
1029 #define TOGGLE_BIT(value, pos) (value ^ (1 << pos))
1033 /* This array holds the chars that always start a comment. If the
1034 pre-processor is disabled, these aren't very useful. */
1035 char arm_comment_chars
[] = "@";
1037 /* This array holds the chars that only start a comment at the beginning of
1038 a line. If the line seems to have the form '# 123 filename'
1039 .line and .file directives will appear in the pre-processed output. */
1040 /* Note that input_file.c hand checks for '#' at the beginning of the
1041 first line of the input file. This is because the compiler outputs
1042 #NO_APP at the beginning of its output. */
1043 /* Also note that comments like this one will always work. */
1044 const char line_comment_chars
[] = "#";
1046 char arm_line_separator_chars
[] = ";";
1048 /* Chars that can be used to separate mant
1049 from exp in floating point numbers. */
1050 const char EXP_CHARS
[] = "eE";
1052 /* Chars that mean this number is a floating point constant. */
1053 /* As in 0f12.456 */
1054 /* or 0d1.2345e12 */
1056 const char FLT_CHARS
[] = "rRsSfFdDxXeEpPHh";
1058 /* Prefix characters that indicate the start of an immediate
1060 #define is_immediate_prefix(C) ((C) == '#' || (C) == '$')
1062 /* Separator character handling. */
1064 #define skip_whitespace(str) do { if (*(str) == ' ') ++(str); } while (0)
1066 enum fp_16bit_format
1068 ARM_FP16_FORMAT_IEEE
= 0x1,
1069 ARM_FP16_FORMAT_ALTERNATIVE
= 0x2,
1070 ARM_FP16_FORMAT_DEFAULT
= 0x3
1073 static enum fp_16bit_format fp16_format
= ARM_FP16_FORMAT_DEFAULT
;
1077 skip_past_char (char ** str
, char c
)
1079 /* PR gas/14987: Allow for whitespace before the expected character. */
1080 skip_whitespace (*str
);
1091 #define skip_past_comma(str) skip_past_char (str, ',')
1093 /* Arithmetic expressions (possibly involving symbols). */
1095 /* Return TRUE if anything in the expression is a bignum. */
1098 walk_no_bignums (symbolS
* sp
)
1100 if (symbol_get_value_expression (sp
)->X_op
== O_big
)
1103 if (symbol_get_value_expression (sp
)->X_add_symbol
)
1105 return (walk_no_bignums (symbol_get_value_expression (sp
)->X_add_symbol
)
1106 || (symbol_get_value_expression (sp
)->X_op_symbol
1107 && walk_no_bignums (symbol_get_value_expression (sp
)->X_op_symbol
)));
1113 static bfd_boolean in_my_get_expression
= FALSE
;
1115 /* Third argument to my_get_expression. */
1116 #define GE_NO_PREFIX 0
1117 #define GE_IMM_PREFIX 1
1118 #define GE_OPT_PREFIX 2
1119 /* This is a bit of a hack. Use an optional prefix, and also allow big (64-bit)
1120 immediates, as can be used in Neon VMVN and VMOV immediate instructions. */
1121 #define GE_OPT_PREFIX_BIG 3
1124 my_get_expression (expressionS
* ep
, char ** str
, int prefix_mode
)
1128 /* In unified syntax, all prefixes are optional. */
1130 prefix_mode
= (prefix_mode
== GE_OPT_PREFIX_BIG
) ? prefix_mode
1133 switch (prefix_mode
)
1135 case GE_NO_PREFIX
: break;
1137 if (!is_immediate_prefix (**str
))
1139 inst
.error
= _("immediate expression requires a # prefix");
1145 case GE_OPT_PREFIX_BIG
:
1146 if (is_immediate_prefix (**str
))
1153 memset (ep
, 0, sizeof (expressionS
));
1155 save_in
= input_line_pointer
;
1156 input_line_pointer
= *str
;
1157 in_my_get_expression
= TRUE
;
1159 in_my_get_expression
= FALSE
;
1161 if (ep
->X_op
== O_illegal
|| ep
->X_op
== O_absent
)
1163 /* We found a bad or missing expression in md_operand(). */
1164 *str
= input_line_pointer
;
1165 input_line_pointer
= save_in
;
1166 if (inst
.error
== NULL
)
1167 inst
.error
= (ep
->X_op
== O_absent
1168 ? _("missing expression") :_("bad expression"));
1172 /* Get rid of any bignums now, so that we don't generate an error for which
1173 we can't establish a line number later on. Big numbers are never valid
1174 in instructions, which is where this routine is always called. */
1175 if (prefix_mode
!= GE_OPT_PREFIX_BIG
1176 && (ep
->X_op
== O_big
1177 || (ep
->X_add_symbol
1178 && (walk_no_bignums (ep
->X_add_symbol
)
1180 && walk_no_bignums (ep
->X_op_symbol
))))))
1182 inst
.error
= _("invalid constant");
1183 *str
= input_line_pointer
;
1184 input_line_pointer
= save_in
;
1188 *str
= input_line_pointer
;
1189 input_line_pointer
= save_in
;
1193 /* Turn a string in input_line_pointer into a floating point constant
1194 of type TYPE, and store the appropriate bytes in *LITP. The number
1195 of LITTLENUMS emitted is stored in *SIZEP. An error message is
1196 returned, or NULL on OK.
1198 Note that fp constants aren't represent in the normal way on the ARM.
1199 In big endian mode, things are as expected. However, in little endian
1200 mode fp constants are big-endian word-wise, and little-endian byte-wise
1201 within the words. For example, (double) 1.1 in big endian mode is
1202 the byte sequence 3f f1 99 99 99 99 99 9a, and in little endian mode is
1203 the byte sequence 99 99 f1 3f 9a 99 99 99.
1205 ??? The format of 12 byte floats is uncertain according to gcc's arm.h. */
1208 md_atof (int type
, char * litP
, int * sizeP
)
1211 LITTLENUM_TYPE words
[MAX_LITTLENUMS
];
1222 /* If this is a bfloat16, then parse it slightly differently, as it
1223 does not follow the IEEE specification for floating point numbers
1227 FLONUM_TYPE generic_float
;
1229 t
= atof_ieee_detail (input_line_pointer
, 1, 8, words
, &generic_float
);
1232 input_line_pointer
= t
;
1234 return _("invalid floating point number");
1236 switch (generic_float
.sign
)
1249 /* bfloat16 has two types of NaN - quiet and signalling.
1250 Quiet NaN has bit[6] == 1 && faction != 0, whereas
1251 signalling NaN's have bit[0] == 0 && fraction != 0.
1252 Chosen this specific encoding as it is the same form
1253 as used by other IEEE 754 encodings in GAS. */
1264 md_number_to_chars (litP
, (valueT
) words
[0], sizeof (LITTLENUM_TYPE
));
1294 return _("Unrecognized or unsupported floating point constant");
1297 t
= atof_ieee (input_line_pointer
, type
, words
);
1299 input_line_pointer
= t
;
1300 *sizeP
= prec
* sizeof (LITTLENUM_TYPE
);
1302 if (target_big_endian
|| prec
== 1)
1303 for (i
= 0; i
< prec
; i
++)
1305 md_number_to_chars (litP
, (valueT
) words
[i
], sizeof (LITTLENUM_TYPE
));
1306 litP
+= sizeof (LITTLENUM_TYPE
);
1308 else if (ARM_CPU_HAS_FEATURE (cpu_variant
, fpu_endian_pure
))
1309 for (i
= prec
- 1; i
>= 0; i
--)
1311 md_number_to_chars (litP
, (valueT
) words
[i
], sizeof (LITTLENUM_TYPE
));
1312 litP
+= sizeof (LITTLENUM_TYPE
);
1315 /* For a 4 byte float the order of elements in `words' is 1 0.
1316 For an 8 byte float the order is 1 0 3 2. */
1317 for (i
= 0; i
< prec
; i
+= 2)
1319 md_number_to_chars (litP
, (valueT
) words
[i
+ 1],
1320 sizeof (LITTLENUM_TYPE
));
1321 md_number_to_chars (litP
+ sizeof (LITTLENUM_TYPE
),
1322 (valueT
) words
[i
], sizeof (LITTLENUM_TYPE
));
1323 litP
+= 2 * sizeof (LITTLENUM_TYPE
);
1329 /* We handle all bad expressions here, so that we can report the faulty
1330 instruction in the error message. */
1333 md_operand (expressionS
* exp
)
1335 if (in_my_get_expression
)
1336 exp
->X_op
= O_illegal
;
1339 /* Immediate values. */
1342 /* Generic immediate-value read function for use in directives.
1343 Accepts anything that 'expression' can fold to a constant.
1344 *val receives the number. */
1347 immediate_for_directive (int *val
)
1350 exp
.X_op
= O_illegal
;
1352 if (is_immediate_prefix (*input_line_pointer
))
1354 input_line_pointer
++;
1358 if (exp
.X_op
!= O_constant
)
1360 as_bad (_("expected #constant"));
1361 ignore_rest_of_line ();
1364 *val
= exp
.X_add_number
;
1369 /* Register parsing. */
1371 /* Generic register parser. CCP points to what should be the
1372 beginning of a register name. If it is indeed a valid register
1373 name, advance CCP over it and return the reg_entry structure;
1374 otherwise return NULL. Does not issue diagnostics. */
1376 static struct reg_entry
*
1377 arm_reg_parse_multi (char **ccp
)
1381 struct reg_entry
*reg
;
1383 skip_whitespace (start
);
1385 #ifdef REGISTER_PREFIX
1386 if (*start
!= REGISTER_PREFIX
)
1390 #ifdef OPTIONAL_REGISTER_PREFIX
1391 if (*start
== OPTIONAL_REGISTER_PREFIX
)
1396 if (!ISALPHA (*p
) || !is_name_beginner (*p
))
1401 while (ISALPHA (*p
) || ISDIGIT (*p
) || *p
== '_');
1403 reg
= (struct reg_entry
*) hash_find_n (arm_reg_hsh
, start
, p
- start
);
1413 arm_reg_alt_syntax (char **ccp
, char *start
, struct reg_entry
*reg
,
1414 enum arm_reg_type type
)
1416 /* Alternative syntaxes are accepted for a few register classes. */
1423 /* Generic coprocessor register names are allowed for these. */
1424 if (reg
&& reg
->type
== REG_TYPE_CN
)
1429 /* For backward compatibility, a bare number is valid here. */
1431 unsigned long processor
= strtoul (start
, ccp
, 10);
1432 if (*ccp
!= start
&& processor
<= 15)
1437 case REG_TYPE_MMXWC
:
1438 /* WC includes WCG. ??? I'm not sure this is true for all
1439 instructions that take WC registers. */
1440 if (reg
&& reg
->type
== REG_TYPE_MMXWCG
)
1451 /* As arm_reg_parse_multi, but the register must be of type TYPE, and the
1452 return value is the register number or FAIL. */
1455 arm_reg_parse (char **ccp
, enum arm_reg_type type
)
1458 struct reg_entry
*reg
= arm_reg_parse_multi (ccp
);
1461 /* Do not allow a scalar (reg+index) to parse as a register. */
1462 if (reg
&& reg
->neon
&& (reg
->neon
->defined
& NTA_HASINDEX
))
1465 if (reg
&& reg
->type
== type
)
1468 if ((ret
= arm_reg_alt_syntax (ccp
, start
, reg
, type
)) != FAIL
)
1475 /* Parse a Neon type specifier. *STR should point at the leading '.'
1476 character. Does no verification at this stage that the type fits the opcode
1483 Can all be legally parsed by this function.
1485 Fills in neon_type struct pointer with parsed information, and updates STR
1486 to point after the parsed type specifier. Returns SUCCESS if this was a legal
1487 type, FAIL if not. */
1490 parse_neon_type (struct neon_type
*type
, char **str
)
1497 while (type
->elems
< NEON_MAX_TYPE_ELS
)
1499 enum neon_el_type thistype
= NT_untyped
;
1500 unsigned thissize
= -1u;
1507 /* Just a size without an explicit type. */
1511 switch (TOLOWER (*ptr
))
1513 case 'i': thistype
= NT_integer
; break;
1514 case 'f': thistype
= NT_float
; break;
1515 case 'p': thistype
= NT_poly
; break;
1516 case 's': thistype
= NT_signed
; break;
1517 case 'u': thistype
= NT_unsigned
; break;
1519 thistype
= NT_float
;
1524 thistype
= NT_bfloat
;
1525 switch (TOLOWER (*(++ptr
)))
1529 thissize
= strtoul (ptr
, &ptr
, 10);
1532 as_bad (_("bad size %d in type specifier"), thissize
);
1536 case '0': case '1': case '2': case '3': case '4':
1537 case '5': case '6': case '7': case '8': case '9':
1539 as_bad (_("unexpected type character `b' -- did you mean `bf'?"));
1546 as_bad (_("unexpected character `%c' in type specifier"), *ptr
);
1552 /* .f is an abbreviation for .f32. */
1553 if (thistype
== NT_float
&& !ISDIGIT (*ptr
))
1558 thissize
= strtoul (ptr
, &ptr
, 10);
1560 if (thissize
!= 8 && thissize
!= 16 && thissize
!= 32
1563 as_bad (_("bad size %d in type specifier"), thissize
);
1571 type
->el
[type
->elems
].type
= thistype
;
1572 type
->el
[type
->elems
].size
= thissize
;
1577 /* Empty/missing type is not a successful parse. */
1578 if (type
->elems
== 0)
1586 /* Errors may be set multiple times during parsing or bit encoding
1587 (particularly in the Neon bits), but usually the earliest error which is set
1588 will be the most meaningful. Avoid overwriting it with later (cascading)
1589 errors by calling this function. */
1592 first_error (const char *err
)
1598 /* Parse a single type, e.g. ".s32", leading period included. */
1600 parse_neon_operand_type (struct neon_type_el
*vectype
, char **ccp
)
1603 struct neon_type optype
;
1607 if (parse_neon_type (&optype
, &str
) == SUCCESS
)
1609 if (optype
.elems
== 1)
1610 *vectype
= optype
.el
[0];
1613 first_error (_("only one type should be specified for operand"));
1619 first_error (_("vector type expected"));
1631 /* Special meanings for indices (which have a range of 0-7), which will fit into
1634 #define NEON_ALL_LANES 15
1635 #define NEON_INTERLEAVE_LANES 14
1637 /* Record a use of the given feature. */
1639 record_feature_use (const arm_feature_set
*feature
)
1642 ARM_MERGE_FEATURE_SETS (thumb_arch_used
, thumb_arch_used
, *feature
);
1644 ARM_MERGE_FEATURE_SETS (arm_arch_used
, arm_arch_used
, *feature
);
1647 /* If the given feature available in the selected CPU, mark it as used.
1648 Returns TRUE iff feature is available. */
1650 mark_feature_used (const arm_feature_set
*feature
)
1653 /* Do not support the use of MVE only instructions when in auto-detection or
1655 if (((feature
== &mve_ext
) || (feature
== &mve_fp_ext
))
1656 && ARM_CPU_IS_ANY (cpu_variant
))
1658 first_error (BAD_MVE_AUTO
);
1661 /* Ensure the option is valid on the current architecture. */
1662 if (!ARM_CPU_HAS_FEATURE (cpu_variant
, *feature
))
1665 /* Add the appropriate architecture feature for the barrier option used.
1667 record_feature_use (feature
);
1672 /* Parse either a register or a scalar, with an optional type. Return the
1673 register number, and optionally fill in the actual type of the register
1674 when multiple alternatives were given (NEON_TYPE_NDQ) in *RTYPE, and
1675 type/index information in *TYPEINFO. */
1678 parse_typed_reg_or_scalar (char **ccp
, enum arm_reg_type type
,
1679 enum arm_reg_type
*rtype
,
1680 struct neon_typed_alias
*typeinfo
)
1683 struct reg_entry
*reg
= arm_reg_parse_multi (&str
);
1684 struct neon_typed_alias atype
;
1685 struct neon_type_el parsetype
;
1689 atype
.eltype
.type
= NT_invtype
;
1690 atype
.eltype
.size
= -1;
1692 /* Try alternate syntax for some types of register. Note these are mutually
1693 exclusive with the Neon syntax extensions. */
1696 int altreg
= arm_reg_alt_syntax (&str
, *ccp
, reg
, type
);
1704 /* Undo polymorphism when a set of register types may be accepted. */
1705 if ((type
== REG_TYPE_NDQ
1706 && (reg
->type
== REG_TYPE_NQ
|| reg
->type
== REG_TYPE_VFD
))
1707 || (type
== REG_TYPE_VFSD
1708 && (reg
->type
== REG_TYPE_VFS
|| reg
->type
== REG_TYPE_VFD
))
1709 || (type
== REG_TYPE_NSDQ
1710 && (reg
->type
== REG_TYPE_VFS
|| reg
->type
== REG_TYPE_VFD
1711 || reg
->type
== REG_TYPE_NQ
))
1712 || (type
== REG_TYPE_NSD
1713 && (reg
->type
== REG_TYPE_VFS
|| reg
->type
== REG_TYPE_VFD
))
1714 || (type
== REG_TYPE_MMXWC
1715 && (reg
->type
== REG_TYPE_MMXWCG
)))
1716 type
= (enum arm_reg_type
) reg
->type
;
1718 if (type
== REG_TYPE_MQ
)
1720 if (!ARM_CPU_HAS_FEATURE (cpu_variant
, mve_ext
))
1723 if (!reg
|| reg
->type
!= REG_TYPE_NQ
)
1726 if (reg
->number
> 14 && !mark_feature_used (&fpu_vfp_ext_d32
))
1728 first_error (_("expected MVE register [q0..q7]"));
1733 else if (ARM_CPU_HAS_FEATURE (cpu_variant
, mve_ext
)
1734 && (type
== REG_TYPE_NQ
))
1738 if (type
!= reg
->type
)
1744 if (parse_neon_operand_type (&parsetype
, &str
) == SUCCESS
)
1746 if ((atype
.defined
& NTA_HASTYPE
) != 0)
1748 first_error (_("can't redefine type for operand"));
1751 atype
.defined
|= NTA_HASTYPE
;
1752 atype
.eltype
= parsetype
;
1755 if (skip_past_char (&str
, '[') == SUCCESS
)
1757 if (type
!= REG_TYPE_VFD
1758 && !(type
== REG_TYPE_VFS
1759 && ARM_CPU_HAS_FEATURE (cpu_variant
, arm_ext_v8_2
))
1760 && !(type
== REG_TYPE_NQ
1761 && ARM_CPU_HAS_FEATURE (cpu_variant
, mve_ext
)))
1763 if (ARM_CPU_HAS_FEATURE (cpu_variant
, mve_ext
))
1764 first_error (_("only D and Q registers may be indexed"));
1766 first_error (_("only D registers may be indexed"));
1770 if ((atype
.defined
& NTA_HASINDEX
) != 0)
1772 first_error (_("can't change index for operand"));
1776 atype
.defined
|= NTA_HASINDEX
;
1778 if (skip_past_char (&str
, ']') == SUCCESS
)
1779 atype
.index
= NEON_ALL_LANES
;
1784 my_get_expression (&exp
, &str
, GE_NO_PREFIX
);
1786 if (exp
.X_op
!= O_constant
)
1788 first_error (_("constant expression required"));
1792 if (skip_past_char (&str
, ']') == FAIL
)
1795 atype
.index
= exp
.X_add_number
;
1810 /* Like arm_reg_parse, but also allow the following extra features:
1811 - If RTYPE is non-zero, return the (possibly restricted) type of the
1812 register (e.g. Neon double or quad reg when either has been requested).
1813 - If this is a Neon vector type with additional type information, fill
1814 in the struct pointed to by VECTYPE (if non-NULL).
1815 This function will fault on encountering a scalar. */
1818 arm_typed_reg_parse (char **ccp
, enum arm_reg_type type
,
1819 enum arm_reg_type
*rtype
, struct neon_type_el
*vectype
)
1821 struct neon_typed_alias atype
;
1823 int reg
= parse_typed_reg_or_scalar (&str
, type
, rtype
, &atype
);
1828 /* Do not allow regname(... to parse as a register. */
1832 /* Do not allow a scalar (reg+index) to parse as a register. */
1833 if ((atype
.defined
& NTA_HASINDEX
) != 0)
1835 first_error (_("register operand expected, but got scalar"));
1840 *vectype
= atype
.eltype
;
1847 #define NEON_SCALAR_REG(X) ((X) >> 4)
1848 #define NEON_SCALAR_INDEX(X) ((X) & 15)
1850 /* Parse a Neon scalar. Most of the time when we're parsing a scalar, we don't
1851 have enough information to be able to do a good job bounds-checking. So, we
1852 just do easy checks here, and do further checks later. */
1855 parse_scalar (char **ccp
, int elsize
, struct neon_type_el
*type
, enum
1856 arm_reg_type reg_type
)
1860 struct neon_typed_alias atype
;
1863 reg
= parse_typed_reg_or_scalar (&str
, reg_type
, NULL
, &atype
);
1881 if (reg
== FAIL
|| (atype
.defined
& NTA_HASINDEX
) == 0)
1884 if (reg_type
!= REG_TYPE_MQ
&& atype
.index
== NEON_ALL_LANES
)
1886 first_error (_("scalar must have an index"));
1889 else if (atype
.index
>= reg_size
/ elsize
)
1891 first_error (_("scalar index out of range"));
1896 *type
= atype
.eltype
;
1900 return reg
* 16 + atype
.index
;
1903 /* Types of registers in a list. */
1916 /* Parse an ARM register list. Returns the bitmask, or FAIL. */
1919 parse_reg_list (char ** strp
, enum reg_list_els etype
)
1925 gas_assert (etype
== REGLIST_RN
|| etype
== REGLIST_CLRM
);
1927 /* We come back here if we get ranges concatenated by '+' or '|'. */
1930 skip_whitespace (str
);
1943 const char apsr_str
[] = "apsr";
1944 int apsr_str_len
= strlen (apsr_str
);
1946 reg
= arm_reg_parse (&str
, REGLIST_RN
);
1947 if (etype
== REGLIST_CLRM
)
1949 if (reg
== REG_SP
|| reg
== REG_PC
)
1951 else if (reg
== FAIL
1952 && !strncasecmp (str
, apsr_str
, apsr_str_len
)
1953 && !ISALPHA (*(str
+ apsr_str_len
)))
1956 str
+= apsr_str_len
;
1961 first_error (_("r0-r12, lr or APSR expected"));
1965 else /* etype == REGLIST_RN. */
1969 first_error (_(reg_expected_msgs
[REGLIST_RN
]));
1980 first_error (_("bad range in register list"));
1984 for (i
= cur_reg
+ 1; i
< reg
; i
++)
1986 if (range
& (1 << i
))
1988 (_("Warning: duplicated register (r%d) in register list"),
1996 if (range
& (1 << reg
))
1997 as_tsktsk (_("Warning: duplicated register (r%d) in register list"),
1999 else if (reg
<= cur_reg
)
2000 as_tsktsk (_("Warning: register range not in ascending order"));
2005 while (skip_past_comma (&str
) != FAIL
2006 || (in_range
= 1, *str
++ == '-'));
2009 if (skip_past_char (&str
, '}') == FAIL
)
2011 first_error (_("missing `}'"));
2015 else if (etype
== REGLIST_RN
)
2019 if (my_get_expression (&exp
, &str
, GE_NO_PREFIX
))
2022 if (exp
.X_op
== O_constant
)
2024 if (exp
.X_add_number
2025 != (exp
.X_add_number
& 0x0000ffff))
2027 inst
.error
= _("invalid register mask");
2031 if ((range
& exp
.X_add_number
) != 0)
2033 int regno
= range
& exp
.X_add_number
;
2036 regno
= (1 << regno
) - 1;
2038 (_("Warning: duplicated register (r%d) in register list"),
2042 range
|= exp
.X_add_number
;
2046 if (inst
.relocs
[0].type
!= 0)
2048 inst
.error
= _("expression too complex");
2052 memcpy (&inst
.relocs
[0].exp
, &exp
, sizeof (expressionS
));
2053 inst
.relocs
[0].type
= BFD_RELOC_ARM_MULTI
;
2054 inst
.relocs
[0].pc_rel
= 0;
2058 if (*str
== '|' || *str
== '+')
2064 while (another_range
);
2070 /* Parse a VFP register list. If the string is invalid return FAIL.
2071 Otherwise return the number of registers, and set PBASE to the first
2072 register. Parses registers of type ETYPE.
2073 If REGLIST_NEON_D is used, several syntax enhancements are enabled:
2074 - Q registers can be used to specify pairs of D registers
2075 - { } can be omitted from around a singleton register list
2076 FIXME: This is not implemented, as it would require backtracking in
2079 This could be done (the meaning isn't really ambiguous), but doesn't
2080 fit in well with the current parsing framework.
2081 - 32 D registers may be used (also true for VFPv3).
2082 FIXME: Types are ignored in these register lists, which is probably a
2086 parse_vfp_reg_list (char **ccp
, unsigned int *pbase
, enum reg_list_els etype
,
2087 bfd_boolean
*partial_match
)
2092 enum arm_reg_type regtype
= (enum arm_reg_type
) 0;
2096 unsigned long mask
= 0;
2098 bfd_boolean vpr_seen
= FALSE
;
2099 bfd_boolean expect_vpr
=
2100 (etype
== REGLIST_VFP_S_VPR
) || (etype
== REGLIST_VFP_D_VPR
);
2102 if (skip_past_char (&str
, '{') == FAIL
)
2104 inst
.error
= _("expecting {");
2111 case REGLIST_VFP_S_VPR
:
2112 regtype
= REG_TYPE_VFS
;
2117 case REGLIST_VFP_D_VPR
:
2118 regtype
= REG_TYPE_VFD
;
2121 case REGLIST_NEON_D
:
2122 regtype
= REG_TYPE_NDQ
;
2129 if (etype
!= REGLIST_VFP_S
&& etype
!= REGLIST_VFP_S_VPR
)
2131 /* VFPv3 allows 32 D registers, except for the VFPv3-D16 variant. */
2132 if (ARM_CPU_HAS_FEATURE (cpu_variant
, fpu_vfp_ext_d32
))
2136 ARM_MERGE_FEATURE_SETS (thumb_arch_used
, thumb_arch_used
,
2139 ARM_MERGE_FEATURE_SETS (arm_arch_used
, arm_arch_used
,
2146 base_reg
= max_regs
;
2147 *partial_match
= FALSE
;
2151 int setmask
= 1, addregs
= 1;
2152 const char vpr_str
[] = "vpr";
2153 int vpr_str_len
= strlen (vpr_str
);
2155 new_base
= arm_typed_reg_parse (&str
, regtype
, ®type
, NULL
);
2159 if (new_base
== FAIL
2160 && !strncasecmp (str
, vpr_str
, vpr_str_len
)
2161 && !ISALPHA (*(str
+ vpr_str_len
))
2167 base_reg
= 0; /* Canonicalize VPR only on d0 with 0 regs. */
2171 first_error (_("VPR expected last"));
2174 else if (new_base
== FAIL
)
2176 if (regtype
== REG_TYPE_VFS
)
2177 first_error (_("VFP single precision register or VPR "
2179 else /* regtype == REG_TYPE_VFD. */
2180 first_error (_("VFP/Neon double precision register or VPR "
2185 else if (new_base
== FAIL
)
2187 first_error (_(reg_expected_msgs
[regtype
]));
2191 *partial_match
= TRUE
;
2195 if (new_base
>= max_regs
)
2197 first_error (_("register out of range in list"));
2201 /* Note: a value of 2 * n is returned for the register Q<n>. */
2202 if (regtype
== REG_TYPE_NQ
)
2208 if (new_base
< base_reg
)
2209 base_reg
= new_base
;
2211 if (mask
& (setmask
<< new_base
))
2213 first_error (_("invalid register list"));
2217 if ((mask
>> new_base
) != 0 && ! warned
&& !vpr_seen
)
2219 as_tsktsk (_("register list not in ascending order"));
2223 mask
|= setmask
<< new_base
;
2226 if (*str
== '-') /* We have the start of a range expression */
2232 if ((high_range
= arm_typed_reg_parse (&str
, regtype
, NULL
, NULL
))
2235 inst
.error
= gettext (reg_expected_msgs
[regtype
]);
2239 if (high_range
>= max_regs
)
2241 first_error (_("register out of range in list"));
2245 if (regtype
== REG_TYPE_NQ
)
2246 high_range
= high_range
+ 1;
2248 if (high_range
<= new_base
)
2250 inst
.error
= _("register range not in ascending order");
2254 for (new_base
+= addregs
; new_base
<= high_range
; new_base
+= addregs
)
2256 if (mask
& (setmask
<< new_base
))
2258 inst
.error
= _("invalid register list");
2262 mask
|= setmask
<< new_base
;
2267 while (skip_past_comma (&str
) != FAIL
);
2271 /* Sanity check -- should have raised a parse error above. */
2272 if ((!vpr_seen
&& count
== 0) || count
> max_regs
)
2277 if (expect_vpr
&& !vpr_seen
)
2279 first_error (_("VPR expected last"));
2283 /* Final test -- the registers must be consecutive. */
2285 for (i
= 0; i
< count
; i
++)
2287 if ((mask
& (1u << i
)) == 0)
2289 inst
.error
= _("non-contiguous register range");
2299 /* True if two alias types are the same. */
2302 neon_alias_types_same (struct neon_typed_alias
*a
, struct neon_typed_alias
*b
)
2310 if (a
->defined
!= b
->defined
)
2313 if ((a
->defined
& NTA_HASTYPE
) != 0
2314 && (a
->eltype
.type
!= b
->eltype
.type
2315 || a
->eltype
.size
!= b
->eltype
.size
))
2318 if ((a
->defined
& NTA_HASINDEX
) != 0
2319 && (a
->index
!= b
->index
))
2325 /* Parse element/structure lists for Neon VLD<n> and VST<n> instructions.
2326 The base register is put in *PBASE.
2327 The lane (or one of the NEON_*_LANES constants) is placed in bits [3:0] of
2329 The register stride (minus one) is put in bit 4 of the return value.
2330 Bits [6:5] encode the list length (minus one).
2331 The type of the list elements is put in *ELTYPE, if non-NULL. */
2333 #define NEON_LANE(X) ((X) & 0xf)
2334 #define NEON_REG_STRIDE(X) ((((X) >> 4) & 1) + 1)
2335 #define NEON_REGLIST_LENGTH(X) ((((X) >> 5) & 3) + 1)
2338 parse_neon_el_struct_list (char **str
, unsigned *pbase
,
2340 struct neon_type_el
*eltype
)
2347 int leading_brace
= 0;
2348 enum arm_reg_type rtype
= REG_TYPE_NDQ
;
2349 const char *const incr_error
= mve
? _("register stride must be 1") :
2350 _("register stride must be 1 or 2");
2351 const char *const type_error
= _("mismatched element/structure types in list");
2352 struct neon_typed_alias firsttype
;
2353 firsttype
.defined
= 0;
2354 firsttype
.eltype
.type
= NT_invtype
;
2355 firsttype
.eltype
.size
= -1;
2356 firsttype
.index
= -1;
2358 if (skip_past_char (&ptr
, '{') == SUCCESS
)
2363 struct neon_typed_alias atype
;
2365 rtype
= REG_TYPE_MQ
;
2366 int getreg
= parse_typed_reg_or_scalar (&ptr
, rtype
, &rtype
, &atype
);
2370 first_error (_(reg_expected_msgs
[rtype
]));
2377 if (rtype
== REG_TYPE_NQ
)
2383 else if (reg_incr
== -1)
2385 reg_incr
= getreg
- base_reg
;
2386 if (reg_incr
< 1 || reg_incr
> 2)
2388 first_error (_(incr_error
));
2392 else if (getreg
!= base_reg
+ reg_incr
* count
)
2394 first_error (_(incr_error
));
2398 if (! neon_alias_types_same (&atype
, &firsttype
))
2400 first_error (_(type_error
));
2404 /* Handle Dn-Dm or Qn-Qm syntax. Can only be used with non-indexed list
2408 struct neon_typed_alias htype
;
2409 int hireg
, dregs
= (rtype
== REG_TYPE_NQ
) ? 2 : 1;
2411 lane
= NEON_INTERLEAVE_LANES
;
2412 else if (lane
!= NEON_INTERLEAVE_LANES
)
2414 first_error (_(type_error
));
2419 else if (reg_incr
!= 1)
2421 first_error (_("don't use Rn-Rm syntax with non-unit stride"));
2425 hireg
= parse_typed_reg_or_scalar (&ptr
, rtype
, NULL
, &htype
);
2428 first_error (_(reg_expected_msgs
[rtype
]));
2431 if (! neon_alias_types_same (&htype
, &firsttype
))
2433 first_error (_(type_error
));
2436 count
+= hireg
+ dregs
- getreg
;
2440 /* If we're using Q registers, we can't use [] or [n] syntax. */
2441 if (rtype
== REG_TYPE_NQ
)
2447 if ((atype
.defined
& NTA_HASINDEX
) != 0)
2451 else if (lane
!= atype
.index
)
2453 first_error (_(type_error
));
2457 else if (lane
== -1)
2458 lane
= NEON_INTERLEAVE_LANES
;
2459 else if (lane
!= NEON_INTERLEAVE_LANES
)
2461 first_error (_(type_error
));
2466 while ((count
!= 1 || leading_brace
) && skip_past_comma (&ptr
) != FAIL
);
2468 /* No lane set by [x]. We must be interleaving structures. */
2470 lane
= NEON_INTERLEAVE_LANES
;
2473 if (lane
== -1 || base_reg
== -1 || count
< 1 || (!mve
&& count
> 4)
2474 || (count
> 1 && reg_incr
== -1))
2476 first_error (_("error parsing element/structure list"));
2480 if ((count
> 1 || leading_brace
) && skip_past_char (&ptr
, '}') == FAIL
)
2482 first_error (_("expected }"));
2490 *eltype
= firsttype
.eltype
;
2495 return lane
| ((reg_incr
- 1) << 4) | ((count
- 1) << 5);
2498 /* Parse an explicit relocation suffix on an expression. This is
2499 either nothing, or a word in parentheses. Note that if !OBJ_ELF,
2500 arm_reloc_hsh contains no entries, so this function can only
2501 succeed if there is no () after the word. Returns -1 on error,
2502 BFD_RELOC_UNUSED if there wasn't any suffix. */
2505 parse_reloc (char **str
)
2507 struct reloc_entry
*r
;
2511 return BFD_RELOC_UNUSED
;
2516 while (*q
&& *q
!= ')' && *q
!= ',')
2521 if ((r
= (struct reloc_entry
*)
2522 hash_find_n (arm_reloc_hsh
, p
, q
- p
)) == NULL
)
2529 /* Directives: register aliases. */
2531 static struct reg_entry
*
2532 insert_reg_alias (char *str
, unsigned number
, int type
)
2534 struct reg_entry
*new_reg
;
2537 if ((new_reg
= (struct reg_entry
*) hash_find (arm_reg_hsh
, str
)) != 0)
2539 if (new_reg
->builtin
)
2540 as_warn (_("ignoring attempt to redefine built-in register '%s'"), str
);
2542 /* Only warn about a redefinition if it's not defined as the
2544 else if (new_reg
->number
!= number
|| new_reg
->type
!= type
)
2545 as_warn (_("ignoring redefinition of register alias '%s'"), str
);
2550 name
= xstrdup (str
);
2551 new_reg
= XNEW (struct reg_entry
);
2553 new_reg
->name
= name
;
2554 new_reg
->number
= number
;
2555 new_reg
->type
= type
;
2556 new_reg
->builtin
= FALSE
;
2557 new_reg
->neon
= NULL
;
2559 if (hash_insert (arm_reg_hsh
, name
, (void *) new_reg
))
2566 insert_neon_reg_alias (char *str
, int number
, int type
,
2567 struct neon_typed_alias
*atype
)
2569 struct reg_entry
*reg
= insert_reg_alias (str
, number
, type
);
2573 first_error (_("attempt to redefine typed alias"));
2579 reg
->neon
= XNEW (struct neon_typed_alias
);
2580 *reg
->neon
= *atype
;
2584 /* Look for the .req directive. This is of the form:
2586 new_register_name .req existing_register_name
2588 If we find one, or if it looks sufficiently like one that we want to
2589 handle any error here, return TRUE. Otherwise return FALSE. */
2592 create_register_alias (char * newname
, char *p
)
2594 struct reg_entry
*old
;
2595 char *oldname
, *nbuf
;
2598 /* The input scrubber ensures that whitespace after the mnemonic is
2599 collapsed to single spaces. */
2601 if (strncmp (oldname
, " .req ", 6) != 0)
2605 if (*oldname
== '\0')
2608 old
= (struct reg_entry
*) hash_find (arm_reg_hsh
, oldname
);
2611 as_warn (_("unknown register '%s' -- .req ignored"), oldname
);
2615 /* If TC_CASE_SENSITIVE is defined, then newname already points to
2616 the desired alias name, and p points to its end. If not, then
2617 the desired alias name is in the global original_case_string. */
2618 #ifdef TC_CASE_SENSITIVE
2621 newname
= original_case_string
;
2622 nlen
= strlen (newname
);
2625 nbuf
= xmemdup0 (newname
, nlen
);
2627 /* Create aliases under the new name as stated; an all-lowercase
2628 version of the new name; and an all-uppercase version of the new
2630 if (insert_reg_alias (nbuf
, old
->number
, old
->type
) != NULL
)
2632 for (p
= nbuf
; *p
; p
++)
2635 if (strncmp (nbuf
, newname
, nlen
))
2637 /* If this attempt to create an additional alias fails, do not bother
2638 trying to create the all-lower case alias. We will fail and issue
2639 a second, duplicate error message. This situation arises when the
2640 programmer does something like:
2643 The second .req creates the "Foo" alias but then fails to create
2644 the artificial FOO alias because it has already been created by the
2646 if (insert_reg_alias (nbuf
, old
->number
, old
->type
) == NULL
)
2653 for (p
= nbuf
; *p
; p
++)
2656 if (strncmp (nbuf
, newname
, nlen
))
2657 insert_reg_alias (nbuf
, old
->number
, old
->type
);
2664 /* Create a Neon typed/indexed register alias using directives, e.g.:
2669 These typed registers can be used instead of the types specified after the
2670 Neon mnemonic, so long as all operands given have types. Types can also be
2671 specified directly, e.g.:
2672 vadd d0.s32, d1.s32, d2.s32 */
2675 create_neon_reg_alias (char *newname
, char *p
)
2677 enum arm_reg_type basetype
;
2678 struct reg_entry
*basereg
;
2679 struct reg_entry mybasereg
;
2680 struct neon_type ntype
;
2681 struct neon_typed_alias typeinfo
;
2682 char *namebuf
, *nameend ATTRIBUTE_UNUSED
;
2685 typeinfo
.defined
= 0;
2686 typeinfo
.eltype
.type
= NT_invtype
;
2687 typeinfo
.eltype
.size
= -1;
2688 typeinfo
.index
= -1;
2692 if (strncmp (p
, " .dn ", 5) == 0)
2693 basetype
= REG_TYPE_VFD
;
2694 else if (strncmp (p
, " .qn ", 5) == 0)
2695 basetype
= REG_TYPE_NQ
;
2704 basereg
= arm_reg_parse_multi (&p
);
2706 if (basereg
&& basereg
->type
!= basetype
)
2708 as_bad (_("bad type for register"));
2712 if (basereg
== NULL
)
2715 /* Try parsing as an integer. */
2716 my_get_expression (&exp
, &p
, GE_NO_PREFIX
);
2717 if (exp
.X_op
!= O_constant
)
2719 as_bad (_("expression must be constant"));
2722 basereg
= &mybasereg
;
2723 basereg
->number
= (basetype
== REG_TYPE_NQ
) ? exp
.X_add_number
* 2
2729 typeinfo
= *basereg
->neon
;
2731 if (parse_neon_type (&ntype
, &p
) == SUCCESS
)
2733 /* We got a type. */
2734 if (typeinfo
.defined
& NTA_HASTYPE
)
2736 as_bad (_("can't redefine the type of a register alias"));
2740 typeinfo
.defined
|= NTA_HASTYPE
;
2741 if (ntype
.elems
!= 1)
2743 as_bad (_("you must specify a single type only"));
2746 typeinfo
.eltype
= ntype
.el
[0];
2749 if (skip_past_char (&p
, '[') == SUCCESS
)
2752 /* We got a scalar index. */
2754 if (typeinfo
.defined
& NTA_HASINDEX
)
2756 as_bad (_("can't redefine the index of a scalar alias"));
2760 my_get_expression (&exp
, &p
, GE_NO_PREFIX
);
2762 if (exp
.X_op
!= O_constant
)
2764 as_bad (_("scalar index must be constant"));
2768 typeinfo
.defined
|= NTA_HASINDEX
;
2769 typeinfo
.index
= exp
.X_add_number
;
2771 if (skip_past_char (&p
, ']') == FAIL
)
2773 as_bad (_("expecting ]"));
2778 /* If TC_CASE_SENSITIVE is defined, then newname already points to
2779 the desired alias name, and p points to its end. If not, then
2780 the desired alias name is in the global original_case_string. */
2781 #ifdef TC_CASE_SENSITIVE
2782 namelen
= nameend
- newname
;
2784 newname
= original_case_string
;
2785 namelen
= strlen (newname
);
2788 namebuf
= xmemdup0 (newname
, namelen
);
2790 insert_neon_reg_alias (namebuf
, basereg
->number
, basetype
,
2791 typeinfo
.defined
!= 0 ? &typeinfo
: NULL
);
2793 /* Insert name in all uppercase. */
2794 for (p
= namebuf
; *p
; p
++)
2797 if (strncmp (namebuf
, newname
, namelen
))
2798 insert_neon_reg_alias (namebuf
, basereg
->number
, basetype
,
2799 typeinfo
.defined
!= 0 ? &typeinfo
: NULL
);
2801 /* Insert name in all lowercase. */
2802 for (p
= namebuf
; *p
; p
++)
2805 if (strncmp (namebuf
, newname
, namelen
))
2806 insert_neon_reg_alias (namebuf
, basereg
->number
, basetype
,
2807 typeinfo
.defined
!= 0 ? &typeinfo
: NULL
);
2813 /* Should never be called, as .req goes between the alias and the
2814 register name, not at the beginning of the line. */
2817 s_req (int a ATTRIBUTE_UNUSED
)
2819 as_bad (_("invalid syntax for .req directive"));
2823 s_dn (int a ATTRIBUTE_UNUSED
)
2825 as_bad (_("invalid syntax for .dn directive"));
2829 s_qn (int a ATTRIBUTE_UNUSED
)
2831 as_bad (_("invalid syntax for .qn directive"));
2834 /* The .unreq directive deletes an alias which was previously defined
2835 by .req. For example:
2841 s_unreq (int a ATTRIBUTE_UNUSED
)
2846 name
= input_line_pointer
;
2848 while (*input_line_pointer
!= 0
2849 && *input_line_pointer
!= ' '
2850 && *input_line_pointer
!= '\n')
2851 ++input_line_pointer
;
2853 saved_char
= *input_line_pointer
;
2854 *input_line_pointer
= 0;
2857 as_bad (_("invalid syntax for .unreq directive"));
2860 struct reg_entry
*reg
= (struct reg_entry
*) hash_find (arm_reg_hsh
,
2864 as_bad (_("unknown register alias '%s'"), name
);
2865 else if (reg
->builtin
)
2866 as_warn (_("ignoring attempt to use .unreq on fixed register name: '%s'"),
2873 hash_delete (arm_reg_hsh
, name
, FALSE
);
2874 free ((char *) reg
->name
);
2879 /* Also locate the all upper case and all lower case versions.
2880 Do not complain if we cannot find one or the other as it
2881 was probably deleted above. */
2883 nbuf
= strdup (name
);
2884 for (p
= nbuf
; *p
; p
++)
2886 reg
= (struct reg_entry
*) hash_find (arm_reg_hsh
, nbuf
);
2889 hash_delete (arm_reg_hsh
, nbuf
, FALSE
);
2890 free ((char *) reg
->name
);
2896 for (p
= nbuf
; *p
; p
++)
2898 reg
= (struct reg_entry
*) hash_find (arm_reg_hsh
, nbuf
);
2901 hash_delete (arm_reg_hsh
, nbuf
, FALSE
);
2902 free ((char *) reg
->name
);
2912 *input_line_pointer
= saved_char
;
2913 demand_empty_rest_of_line ();
2916 /* Directives: Instruction set selection. */
2919 /* This code is to handle mapping symbols as defined in the ARM ELF spec.
2920 (See "Mapping symbols", section 4.5.5, ARM AAELF version 1.0).
2921 Note that previously, $a and $t has type STT_FUNC (BSF_OBJECT flag),
2922 and $d has type STT_OBJECT (BSF_OBJECT flag). Now all three are untyped. */
2924 /* Create a new mapping symbol for the transition to STATE. */
2927 make_mapping_symbol (enum mstate state
, valueT value
, fragS
*frag
)
2930 const char * symname
;
2937 type
= BSF_NO_FLAGS
;
2941 type
= BSF_NO_FLAGS
;
2945 type
= BSF_NO_FLAGS
;
2951 symbolP
= symbol_new (symname
, now_seg
, value
, frag
);
2952 symbol_get_bfdsym (symbolP
)->flags
|= type
| BSF_LOCAL
;
2957 THUMB_SET_FUNC (symbolP
, 0);
2958 ARM_SET_THUMB (symbolP
, 0);
2959 ARM_SET_INTERWORK (symbolP
, support_interwork
);
2963 THUMB_SET_FUNC (symbolP
, 1);
2964 ARM_SET_THUMB (symbolP
, 1);
2965 ARM_SET_INTERWORK (symbolP
, support_interwork
);
2973 /* Save the mapping symbols for future reference. Also check that
2974 we do not place two mapping symbols at the same offset within a
2975 frag. We'll handle overlap between frags in
2976 check_mapping_symbols.
2978 If .fill or other data filling directive generates zero sized data,
2979 the mapping symbol for the following code will have the same value
2980 as the one generated for the data filling directive. In this case,
2981 we replace the old symbol with the new one at the same address. */
2984 if (frag
->tc_frag_data
.first_map
!= NULL
)
2986 know (S_GET_VALUE (frag
->tc_frag_data
.first_map
) == 0);
2987 symbol_remove (frag
->tc_frag_data
.first_map
, &symbol_rootP
, &symbol_lastP
);
2989 frag
->tc_frag_data
.first_map
= symbolP
;
2991 if (frag
->tc_frag_data
.last_map
!= NULL
)
2993 know (S_GET_VALUE (frag
->tc_frag_data
.last_map
) <= S_GET_VALUE (symbolP
));
2994 if (S_GET_VALUE (frag
->tc_frag_data
.last_map
) == S_GET_VALUE (symbolP
))
2995 symbol_remove (frag
->tc_frag_data
.last_map
, &symbol_rootP
, &symbol_lastP
);
2997 frag
->tc_frag_data
.last_map
= symbolP
;
3000 /* We must sometimes convert a region marked as code to data during
3001 code alignment, if an odd number of bytes have to be padded. The
3002 code mapping symbol is pushed to an aligned address. */
3005 insert_data_mapping_symbol (enum mstate state
,
3006 valueT value
, fragS
*frag
, offsetT bytes
)
3008 /* If there was already a mapping symbol, remove it. */
3009 if (frag
->tc_frag_data
.last_map
!= NULL
3010 && S_GET_VALUE (frag
->tc_frag_data
.last_map
) == frag
->fr_address
+ value
)
3012 symbolS
*symp
= frag
->tc_frag_data
.last_map
;
3016 know (frag
->tc_frag_data
.first_map
== symp
);
3017 frag
->tc_frag_data
.first_map
= NULL
;
3019 frag
->tc_frag_data
.last_map
= NULL
;
3020 symbol_remove (symp
, &symbol_rootP
, &symbol_lastP
);
3023 make_mapping_symbol (MAP_DATA
, value
, frag
);
3024 make_mapping_symbol (state
, value
+ bytes
, frag
);
3027 static void mapping_state_2 (enum mstate state
, int max_chars
);
3029 /* Set the mapping state to STATE. Only call this when about to
3030 emit some STATE bytes to the file. */
3032 #define TRANSITION(from, to) (mapstate == (from) && state == (to))
3034 mapping_state (enum mstate state
)
3036 enum mstate mapstate
= seg_info (now_seg
)->tc_segment_info_data
.mapstate
;
3038 if (mapstate
== state
)
3039 /* The mapping symbol has already been emitted.
3040 There is nothing else to do. */
3043 if (state
== MAP_ARM
|| state
== MAP_THUMB
)
3045 All ARM instructions require 4-byte alignment.
3046 (Almost) all Thumb instructions require 2-byte alignment.
3048 When emitting instructions into any section, mark the section
3051 Some Thumb instructions are alignment-sensitive modulo 4 bytes,
3052 but themselves require 2-byte alignment; this applies to some
3053 PC- relative forms. However, these cases will involve implicit
3054 literal pool generation or an explicit .align >=2, both of
3055 which will cause the section to me marked with sufficient
3056 alignment. Thus, we don't handle those cases here. */
3057 record_alignment (now_seg
, state
== MAP_ARM
? 2 : 1);
3059 if (TRANSITION (MAP_UNDEFINED
, MAP_DATA
))
3060 /* This case will be evaluated later. */
3063 mapping_state_2 (state
, 0);
3066 /* Same as mapping_state, but MAX_CHARS bytes have already been
3067 allocated. Put the mapping symbol that far back. */
3070 mapping_state_2 (enum mstate state
, int max_chars
)
3072 enum mstate mapstate
= seg_info (now_seg
)->tc_segment_info_data
.mapstate
;
3074 if (!SEG_NORMAL (now_seg
))
3077 if (mapstate
== state
)
3078 /* The mapping symbol has already been emitted.
3079 There is nothing else to do. */
3082 if (TRANSITION (MAP_UNDEFINED
, MAP_ARM
)
3083 || TRANSITION (MAP_UNDEFINED
, MAP_THUMB
))
3085 struct frag
* const frag_first
= seg_info (now_seg
)->frchainP
->frch_root
;
3086 const int add_symbol
= (frag_now
!= frag_first
) || (frag_now_fix () > 0);
3089 make_mapping_symbol (MAP_DATA
, (valueT
) 0, frag_first
);
3092 seg_info (now_seg
)->tc_segment_info_data
.mapstate
= state
;
3093 make_mapping_symbol (state
, (valueT
) frag_now_fix () - max_chars
, frag_now
);
3097 #define mapping_state(x) ((void)0)
3098 #define mapping_state_2(x, y) ((void)0)
3101 /* Find the real, Thumb encoded start of a Thumb function. */
3105 find_real_start (symbolS
* symbolP
)
3108 const char * name
= S_GET_NAME (symbolP
);
3109 symbolS
* new_target
;
3111 /* This definition must agree with the one in gcc/config/arm/thumb.c. */
3112 #define STUB_NAME ".real_start_of"
3117 /* The compiler may generate BL instructions to local labels because
3118 it needs to perform a branch to a far away location. These labels
3119 do not have a corresponding ".real_start_of" label. We check
3120 both for S_IS_LOCAL and for a leading dot, to give a way to bypass
3121 the ".real_start_of" convention for nonlocal branches. */
3122 if (S_IS_LOCAL (symbolP
) || name
[0] == '.')
3125 real_start
= concat (STUB_NAME
, name
, NULL
);
3126 new_target
= symbol_find (real_start
);
3129 if (new_target
== NULL
)
3131 as_warn (_("Failed to find real start of function: %s\n"), name
);
3132 new_target
= symbolP
;
3140 opcode_select (int width
)
3147 if (!ARM_CPU_HAS_FEATURE (cpu_variant
, arm_ext_v4t
))
3148 as_bad (_("selected processor does not support THUMB opcodes"));
3151 /* No need to force the alignment, since we will have been
3152 coming from ARM mode, which is word-aligned. */
3153 record_alignment (now_seg
, 1);
3160 if (!ARM_CPU_HAS_FEATURE (cpu_variant
, arm_ext_v1
))
3161 as_bad (_("selected processor does not support ARM opcodes"));
3166 frag_align (2, 0, 0);
3168 record_alignment (now_seg
, 1);
3173 as_bad (_("invalid instruction size selected (%d)"), width
);
3178 s_arm (int ignore ATTRIBUTE_UNUSED
)
3181 demand_empty_rest_of_line ();
3185 s_thumb (int ignore ATTRIBUTE_UNUSED
)
3188 demand_empty_rest_of_line ();
3192 s_code (int unused ATTRIBUTE_UNUSED
)
3196 temp
= get_absolute_expression ();
3201 opcode_select (temp
);
3205 as_bad (_("invalid operand to .code directive (%d) (expecting 16 or 32)"), temp
);
3210 s_force_thumb (int ignore ATTRIBUTE_UNUSED
)
3212 /* If we are not already in thumb mode go into it, EVEN if
3213 the target processor does not support thumb instructions.
3214 This is used by gcc/config/arm/lib1funcs.asm for example
3215 to compile interworking support functions even if the
3216 target processor should not support interworking. */
3220 record_alignment (now_seg
, 1);
3223 demand_empty_rest_of_line ();
3227 s_thumb_func (int ignore ATTRIBUTE_UNUSED
)
3231 /* The following label is the name/address of the start of a Thumb function.
3232 We need to know this for the interworking support. */
3233 label_is_thumb_function_name
= TRUE
;
3236 /* Perform a .set directive, but also mark the alias as
3237 being a thumb function. */
3240 s_thumb_set (int equiv
)
3242 /* XXX the following is a duplicate of the code for s_set() in read.c
3243 We cannot just call that code as we need to get at the symbol that
3250 /* Especial apologies for the random logic:
3251 This just grew, and could be parsed much more simply!
3253 delim
= get_symbol_name (& name
);
3254 end_name
= input_line_pointer
;
3255 (void) restore_line_pointer (delim
);
3257 if (*input_line_pointer
!= ',')
3260 as_bad (_("expected comma after name \"%s\""), name
);
3262 ignore_rest_of_line ();
3266 input_line_pointer
++;
3269 if (name
[0] == '.' && name
[1] == '\0')
3271 /* XXX - this should not happen to .thumb_set. */
3275 if ((symbolP
= symbol_find (name
)) == NULL
3276 && (symbolP
= md_undefined_symbol (name
)) == NULL
)
3279 /* When doing symbol listings, play games with dummy fragments living
3280 outside the normal fragment chain to record the file and line info
3282 if (listing
& LISTING_SYMBOLS
)
3284 extern struct list_info_struct
* listing_tail
;
3285 fragS
* dummy_frag
= (fragS
* ) xmalloc (sizeof (fragS
));
3287 memset (dummy_frag
, 0, sizeof (fragS
));
3288 dummy_frag
->fr_type
= rs_fill
;
3289 dummy_frag
->line
= listing_tail
;
3290 symbolP
= symbol_new (name
, undefined_section
, 0, dummy_frag
);
3291 dummy_frag
->fr_symbol
= symbolP
;
3295 symbolP
= symbol_new (name
, undefined_section
, 0, &zero_address_frag
);
3298 /* "set" symbols are local unless otherwise specified. */
3299 SF_SET_LOCAL (symbolP
);
3300 #endif /* OBJ_COFF */
3301 } /* Make a new symbol. */
3303 symbol_table_insert (symbolP
);
3308 && S_IS_DEFINED (symbolP
)
3309 && S_GET_SEGMENT (symbolP
) != reg_section
)
3310 as_bad (_("symbol `%s' already defined"), S_GET_NAME (symbolP
));
3312 pseudo_set (symbolP
);
3314 demand_empty_rest_of_line ();
3316 /* XXX Now we come to the Thumb specific bit of code. */
3318 THUMB_SET_FUNC (symbolP
, 1);
3319 ARM_SET_THUMB (symbolP
, 1);
3320 #if defined OBJ_ELF || defined OBJ_COFF
3321 ARM_SET_INTERWORK (symbolP
, support_interwork
);
3325 /* Directives: Mode selection. */
3327 /* .syntax [unified|divided] - choose the new unified syntax
3328 (same for Arm and Thumb encoding, modulo slight differences in what
3329 can be represented) or the old divergent syntax for each mode. */
3331 s_syntax (int unused ATTRIBUTE_UNUSED
)
3335 delim
= get_symbol_name (& name
);
3337 if (!strcasecmp (name
, "unified"))
3338 unified_syntax
= TRUE
;
3339 else if (!strcasecmp (name
, "divided"))
3340 unified_syntax
= FALSE
;
3343 as_bad (_("unrecognized syntax mode \"%s\""), name
);
3346 (void) restore_line_pointer (delim
);
3347 demand_empty_rest_of_line ();
3350 /* Directives: sectioning and alignment. */
3353 s_bss (int ignore ATTRIBUTE_UNUSED
)
3355 /* We don't support putting frags in the BSS segment, we fake it by
3356 marking in_bss, then looking at s_skip for clues. */
3357 subseg_set (bss_section
, 0);
3358 demand_empty_rest_of_line ();
3360 #ifdef md_elf_section_change_hook
3361 md_elf_section_change_hook ();
3366 s_even (int ignore ATTRIBUTE_UNUSED
)
3368 /* Never make frag if expect extra pass. */
3370 frag_align (1, 0, 0);
3372 record_alignment (now_seg
, 1);
3374 demand_empty_rest_of_line ();
3377 /* Directives: CodeComposer Studio. */
3379 /* .ref (for CodeComposer Studio syntax only). */
3381 s_ccs_ref (int unused ATTRIBUTE_UNUSED
)
3383 if (codecomposer_syntax
)
3384 ignore_rest_of_line ();
3386 as_bad (_(".ref pseudo-op only available with -mccs flag."));
3389 /* If name is not NULL, then it is used for marking the beginning of a
3390 function, whereas if it is NULL then it means the function end. */
3392 asmfunc_debug (const char * name
)
3394 static const char * last_name
= NULL
;
3398 gas_assert (last_name
== NULL
);
3401 if (debug_type
== DEBUG_STABS
)
3402 stabs_generate_asm_func (name
, name
);
3406 gas_assert (last_name
!= NULL
);
3408 if (debug_type
== DEBUG_STABS
)
3409 stabs_generate_asm_endfunc (last_name
, last_name
);
3416 s_ccs_asmfunc (int unused ATTRIBUTE_UNUSED
)
3418 if (codecomposer_syntax
)
3420 switch (asmfunc_state
)
3422 case OUTSIDE_ASMFUNC
:
3423 asmfunc_state
= WAITING_ASMFUNC_NAME
;
3426 case WAITING_ASMFUNC_NAME
:
3427 as_bad (_(".asmfunc repeated."));
3430 case WAITING_ENDASMFUNC
:
3431 as_bad (_(".asmfunc without function."));
3434 demand_empty_rest_of_line ();
3437 as_bad (_(".asmfunc pseudo-op only available with -mccs flag."));
3441 s_ccs_endasmfunc (int unused ATTRIBUTE_UNUSED
)
3443 if (codecomposer_syntax
)
3445 switch (asmfunc_state
)
3447 case OUTSIDE_ASMFUNC
:
3448 as_bad (_(".endasmfunc without a .asmfunc."));
3451 case WAITING_ASMFUNC_NAME
:
3452 as_bad (_(".endasmfunc without function."));
3455 case WAITING_ENDASMFUNC
:
3456 asmfunc_state
= OUTSIDE_ASMFUNC
;
3457 asmfunc_debug (NULL
);
3460 demand_empty_rest_of_line ();
3463 as_bad (_(".endasmfunc pseudo-op only available with -mccs flag."));
3467 s_ccs_def (int name
)
3469 if (codecomposer_syntax
)
3472 as_bad (_(".def pseudo-op only available with -mccs flag."));
3475 /* Directives: Literal pools. */
3477 static literal_pool
*
3478 find_literal_pool (void)
3480 literal_pool
* pool
;
3482 for (pool
= list_of_pools
; pool
!= NULL
; pool
= pool
->next
)
3484 if (pool
->section
== now_seg
3485 && pool
->sub_section
== now_subseg
)
3492 static literal_pool
*
3493 find_or_make_literal_pool (void)
3495 /* Next literal pool ID number. */
3496 static unsigned int latest_pool_num
= 1;
3497 literal_pool
* pool
;
3499 pool
= find_literal_pool ();
3503 /* Create a new pool. */
3504 pool
= XNEW (literal_pool
);
3508 pool
->next_free_entry
= 0;
3509 pool
->section
= now_seg
;
3510 pool
->sub_section
= now_subseg
;
3511 pool
->next
= list_of_pools
;
3512 pool
->symbol
= NULL
;
3513 pool
->alignment
= 2;
3515 /* Add it to the list. */
3516 list_of_pools
= pool
;
3519 /* New pools, and emptied pools, will have a NULL symbol. */
3520 if (pool
->symbol
== NULL
)
3522 pool
->symbol
= symbol_create (FAKE_LABEL_NAME
, undefined_section
,
3523 (valueT
) 0, &zero_address_frag
);
3524 pool
->id
= latest_pool_num
++;
3531 /* Add the literal in the global 'inst'
3532 structure to the relevant literal pool. */
3535 add_to_lit_pool (unsigned int nbytes
)
3537 #define PADDING_SLOT 0x1
3538 #define LIT_ENTRY_SIZE_MASK 0xFF
3539 literal_pool
* pool
;
3540 unsigned int entry
, pool_size
= 0;
3541 bfd_boolean padding_slot_p
= FALSE
;
3547 imm1
= inst
.operands
[1].imm
;
3548 imm2
= (inst
.operands
[1].regisimm
? inst
.operands
[1].reg
3549 : inst
.relocs
[0].exp
.X_unsigned
? 0
3550 : ((bfd_int64_t
) inst
.operands
[1].imm
) >> 32);
3551 if (target_big_endian
)
3554 imm2
= inst
.operands
[1].imm
;
3558 pool
= find_or_make_literal_pool ();
3560 /* Check if this literal value is already in the pool. */
3561 for (entry
= 0; entry
< pool
->next_free_entry
; entry
++)
3565 if ((pool
->literals
[entry
].X_op
== inst
.relocs
[0].exp
.X_op
)
3566 && (inst
.relocs
[0].exp
.X_op
== O_constant
)
3567 && (pool
->literals
[entry
].X_add_number
3568 == inst
.relocs
[0].exp
.X_add_number
)
3569 && (pool
->literals
[entry
].X_md
== nbytes
)
3570 && (pool
->literals
[entry
].X_unsigned
3571 == inst
.relocs
[0].exp
.X_unsigned
))
3574 if ((pool
->literals
[entry
].X_op
== inst
.relocs
[0].exp
.X_op
)
3575 && (inst
.relocs
[0].exp
.X_op
== O_symbol
)
3576 && (pool
->literals
[entry
].X_add_number
3577 == inst
.relocs
[0].exp
.X_add_number
)
3578 && (pool
->literals
[entry
].X_add_symbol
3579 == inst
.relocs
[0].exp
.X_add_symbol
)
3580 && (pool
->literals
[entry
].X_op_symbol
3581 == inst
.relocs
[0].exp
.X_op_symbol
)
3582 && (pool
->literals
[entry
].X_md
== nbytes
))
3585 else if ((nbytes
== 8)
3586 && !(pool_size
& 0x7)
3587 && ((entry
+ 1) != pool
->next_free_entry
)
3588 && (pool
->literals
[entry
].X_op
== O_constant
)
3589 && (pool
->literals
[entry
].X_add_number
== (offsetT
) imm1
)
3590 && (pool
->literals
[entry
].X_unsigned
3591 == inst
.relocs
[0].exp
.X_unsigned
)
3592 && (pool
->literals
[entry
+ 1].X_op
== O_constant
)
3593 && (pool
->literals
[entry
+ 1].X_add_number
== (offsetT
) imm2
)
3594 && (pool
->literals
[entry
+ 1].X_unsigned
3595 == inst
.relocs
[0].exp
.X_unsigned
))
3598 padding_slot_p
= ((pool
->literals
[entry
].X_md
>> 8) == PADDING_SLOT
);
3599 if (padding_slot_p
&& (nbytes
== 4))
3605 /* Do we need to create a new entry? */
3606 if (entry
== pool
->next_free_entry
)
3608 if (entry
>= MAX_LITERAL_POOL_SIZE
)
3610 inst
.error
= _("literal pool overflow");
3616 /* For 8-byte entries, we align to an 8-byte boundary,
3617 and split it into two 4-byte entries, because on 32-bit
3618 host, 8-byte constants are treated as big num, thus
3619 saved in "generic_bignum" which will be overwritten
3620 by later assignments.
3622 We also need to make sure there is enough space for
3625 We also check to make sure the literal operand is a
3627 if (!(inst
.relocs
[0].exp
.X_op
== O_constant
3628 || inst
.relocs
[0].exp
.X_op
== O_big
))
3630 inst
.error
= _("invalid type for literal pool");
3633 else if (pool_size
& 0x7)
3635 if ((entry
+ 2) >= MAX_LITERAL_POOL_SIZE
)
3637 inst
.error
= _("literal pool overflow");
3641 pool
->literals
[entry
] = inst
.relocs
[0].exp
;
3642 pool
->literals
[entry
].X_op
= O_constant
;
3643 pool
->literals
[entry
].X_add_number
= 0;
3644 pool
->literals
[entry
++].X_md
= (PADDING_SLOT
<< 8) | 4;
3645 pool
->next_free_entry
+= 1;
3648 else if ((entry
+ 1) >= MAX_LITERAL_POOL_SIZE
)
3650 inst
.error
= _("literal pool overflow");
3654 pool
->literals
[entry
] = inst
.relocs
[0].exp
;
3655 pool
->literals
[entry
].X_op
= O_constant
;
3656 pool
->literals
[entry
].X_add_number
= imm1
;
3657 pool
->literals
[entry
].X_unsigned
= inst
.relocs
[0].exp
.X_unsigned
;
3658 pool
->literals
[entry
++].X_md
= 4;
3659 pool
->literals
[entry
] = inst
.relocs
[0].exp
;
3660 pool
->literals
[entry
].X_op
= O_constant
;
3661 pool
->literals
[entry
].X_add_number
= imm2
;
3662 pool
->literals
[entry
].X_unsigned
= inst
.relocs
[0].exp
.X_unsigned
;
3663 pool
->literals
[entry
].X_md
= 4;
3664 pool
->alignment
= 3;
3665 pool
->next_free_entry
+= 1;
3669 pool
->literals
[entry
] = inst
.relocs
[0].exp
;
3670 pool
->literals
[entry
].X_md
= 4;
3674 /* PR ld/12974: Record the location of the first source line to reference
3675 this entry in the literal pool. If it turns out during linking that the
3676 symbol does not exist we will be able to give an accurate line number for
3677 the (first use of the) missing reference. */
3678 if (debug_type
== DEBUG_DWARF2
)
3679 dwarf2_where (pool
->locs
+ entry
);
3681 pool
->next_free_entry
+= 1;
3683 else if (padding_slot_p
)
3685 pool
->literals
[entry
] = inst
.relocs
[0].exp
;
3686 pool
->literals
[entry
].X_md
= nbytes
;
3689 inst
.relocs
[0].exp
.X_op
= O_symbol
;
3690 inst
.relocs
[0].exp
.X_add_number
= pool_size
;
3691 inst
.relocs
[0].exp
.X_add_symbol
= pool
->symbol
;
3697 tc_start_label_without_colon (void)
3699 bfd_boolean ret
= TRUE
;
3701 if (codecomposer_syntax
&& asmfunc_state
== WAITING_ASMFUNC_NAME
)
3703 const char *label
= input_line_pointer
;
3705 while (!is_end_of_line
[(int) label
[-1]])
3710 as_bad (_("Invalid label '%s'"), label
);
3714 asmfunc_debug (label
);
3716 asmfunc_state
= WAITING_ENDASMFUNC
;
3722 /* Can't use symbol_new here, so have to create a symbol and then at
3723 a later date assign it a value. That's what these functions do. */
3726 symbol_locate (symbolS
* symbolP
,
3727 const char * name
, /* It is copied, the caller can modify. */
3728 segT segment
, /* Segment identifier (SEG_<something>). */
3729 valueT valu
, /* Symbol value. */
3730 fragS
* frag
) /* Associated fragment. */
3733 char * preserved_copy_of_name
;
3735 name_length
= strlen (name
) + 1; /* +1 for \0. */
3736 obstack_grow (¬es
, name
, name_length
);
3737 preserved_copy_of_name
= (char *) obstack_finish (¬es
);
3739 #ifdef tc_canonicalize_symbol_name
3740 preserved_copy_of_name
=
3741 tc_canonicalize_symbol_name (preserved_copy_of_name
);
3744 S_SET_NAME (symbolP
, preserved_copy_of_name
);
3746 S_SET_SEGMENT (symbolP
, segment
);
3747 S_SET_VALUE (symbolP
, valu
);
3748 symbol_clear_list_pointers (symbolP
);
3750 symbol_set_frag (symbolP
, frag
);
3752 /* Link to end of symbol chain. */
3754 extern int symbol_table_frozen
;
3756 if (symbol_table_frozen
)
3760 symbol_append (symbolP
, symbol_lastP
, & symbol_rootP
, & symbol_lastP
);
3762 obj_symbol_new_hook (symbolP
);
3764 #ifdef tc_symbol_new_hook
3765 tc_symbol_new_hook (symbolP
);
3769 verify_symbol_chain (symbol_rootP
, symbol_lastP
);
3770 #endif /* DEBUG_SYMS */
3774 s_ltorg (int ignored ATTRIBUTE_UNUSED
)
3777 literal_pool
* pool
;
3780 pool
= find_literal_pool ();
3782 || pool
->symbol
== NULL
3783 || pool
->next_free_entry
== 0)
3786 /* Align pool as you have word accesses.
3787 Only make a frag if we have to. */
3789 frag_align (pool
->alignment
, 0, 0);
3791 record_alignment (now_seg
, 2);
3794 seg_info (now_seg
)->tc_segment_info_data
.mapstate
= MAP_DATA
;
3795 make_mapping_symbol (MAP_DATA
, (valueT
) frag_now_fix (), frag_now
);
3797 sprintf (sym_name
, "$$lit_\002%x", pool
->id
);
3799 symbol_locate (pool
->symbol
, sym_name
, now_seg
,
3800 (valueT
) frag_now_fix (), frag_now
);
3801 symbol_table_insert (pool
->symbol
);
3803 ARM_SET_THUMB (pool
->symbol
, thumb_mode
);
3805 #if defined OBJ_COFF || defined OBJ_ELF
3806 ARM_SET_INTERWORK (pool
->symbol
, support_interwork
);
3809 for (entry
= 0; entry
< pool
->next_free_entry
; entry
++)
3812 if (debug_type
== DEBUG_DWARF2
)
3813 dwarf2_gen_line_info (frag_now_fix (), pool
->locs
+ entry
);
3815 /* First output the expression in the instruction to the pool. */
3816 emit_expr (&(pool
->literals
[entry
]),
3817 pool
->literals
[entry
].X_md
& LIT_ENTRY_SIZE_MASK
);
3820 /* Mark the pool as empty. */
3821 pool
->next_free_entry
= 0;
3822 pool
->symbol
= NULL
;
3826 /* Forward declarations for functions below, in the MD interface
3828 static void fix_new_arm (fragS
*, int, short, expressionS
*, int, int);
3829 static valueT
create_unwind_entry (int);
3830 static void start_unwind_section (const segT
, int);
3831 static void add_unwind_opcode (valueT
, int);
3832 static void flush_pending_unwind (void);
3834 /* Directives: Data. */
3837 s_arm_elf_cons (int nbytes
)
3841 #ifdef md_flush_pending_output
3842 md_flush_pending_output ();
3845 if (is_it_end_of_statement ())
3847 demand_empty_rest_of_line ();
3851 #ifdef md_cons_align
3852 md_cons_align (nbytes
);
3855 mapping_state (MAP_DATA
);
3859 char *base
= input_line_pointer
;
3863 if (exp
.X_op
!= O_symbol
)
3864 emit_expr (&exp
, (unsigned int) nbytes
);
3867 char *before_reloc
= input_line_pointer
;
3868 reloc
= parse_reloc (&input_line_pointer
);
3871 as_bad (_("unrecognized relocation suffix"));
3872 ignore_rest_of_line ();
3875 else if (reloc
== BFD_RELOC_UNUSED
)
3876 emit_expr (&exp
, (unsigned int) nbytes
);
3879 reloc_howto_type
*howto
= (reloc_howto_type
*)
3880 bfd_reloc_type_lookup (stdoutput
,
3881 (bfd_reloc_code_real_type
) reloc
);
3882 int size
= bfd_get_reloc_size (howto
);
3884 if (reloc
== BFD_RELOC_ARM_PLT32
)
3886 as_bad (_("(plt) is only valid on branch targets"));
3887 reloc
= BFD_RELOC_UNUSED
;
3892 as_bad (ngettext ("%s relocations do not fit in %d byte",
3893 "%s relocations do not fit in %d bytes",
3895 howto
->name
, nbytes
);
3898 /* We've parsed an expression stopping at O_symbol.
3899 But there may be more expression left now that we
3900 have parsed the relocation marker. Parse it again.
3901 XXX Surely there is a cleaner way to do this. */
3902 char *p
= input_line_pointer
;
3904 char *save_buf
= XNEWVEC (char, input_line_pointer
- base
);
3906 memcpy (save_buf
, base
, input_line_pointer
- base
);
3907 memmove (base
+ (input_line_pointer
- before_reloc
),
3908 base
, before_reloc
- base
);
3910 input_line_pointer
= base
+ (input_line_pointer
-before_reloc
);
3912 memcpy (base
, save_buf
, p
- base
);
3914 offset
= nbytes
- size
;
3915 p
= frag_more (nbytes
);
3916 memset (p
, 0, nbytes
);
3917 fix_new_exp (frag_now
, p
- frag_now
->fr_literal
+ offset
,
3918 size
, &exp
, 0, (enum bfd_reloc_code_real
) reloc
);
3924 while (*input_line_pointer
++ == ',');
3926 /* Put terminator back into stream. */
3927 input_line_pointer
--;
3928 demand_empty_rest_of_line ();
3931 /* Emit an expression containing a 32-bit thumb instruction.
3932 Implementation based on put_thumb32_insn. */
3935 emit_thumb32_expr (expressionS
* exp
)
3937 expressionS exp_high
= *exp
;
3939 exp_high
.X_add_number
= (unsigned long)exp_high
.X_add_number
>> 16;
3940 emit_expr (& exp_high
, (unsigned int) THUMB_SIZE
);
3941 exp
->X_add_number
&= 0xffff;
3942 emit_expr (exp
, (unsigned int) THUMB_SIZE
);
3945 /* Guess the instruction size based on the opcode. */
3948 thumb_insn_size (int opcode
)
3950 if ((unsigned int) opcode
< 0xe800u
)
3952 else if ((unsigned int) opcode
>= 0xe8000000u
)
3959 emit_insn (expressionS
*exp
, int nbytes
)
3963 if (exp
->X_op
== O_constant
)
3968 size
= thumb_insn_size (exp
->X_add_number
);
3972 if (size
== 2 && (unsigned int)exp
->X_add_number
> 0xffffu
)
3974 as_bad (_(".inst.n operand too big. "\
3975 "Use .inst.w instead"));
3980 if (now_pred
.state
== AUTOMATIC_PRED_BLOCK
)
3981 set_pred_insn_type_nonvoid (OUTSIDE_PRED_INSN
, 0);
3983 set_pred_insn_type_nonvoid (NEUTRAL_IT_INSN
, 0);
3985 if (thumb_mode
&& (size
> THUMB_SIZE
) && !target_big_endian
)
3986 emit_thumb32_expr (exp
);
3988 emit_expr (exp
, (unsigned int) size
);
3990 it_fsm_post_encode ();
3994 as_bad (_("cannot determine Thumb instruction size. " \
3995 "Use .inst.n/.inst.w instead"));
3998 as_bad (_("constant expression required"));
4003 /* Like s_arm_elf_cons but do not use md_cons_align and
4004 set the mapping state to MAP_ARM/MAP_THUMB. */
4007 s_arm_elf_inst (int nbytes
)
4009 if (is_it_end_of_statement ())
4011 demand_empty_rest_of_line ();
4015 /* Calling mapping_state () here will not change ARM/THUMB,
4016 but will ensure not to be in DATA state. */
4019 mapping_state (MAP_THUMB
);
4024 as_bad (_("width suffixes are invalid in ARM mode"));
4025 ignore_rest_of_line ();
4031 mapping_state (MAP_ARM
);
4040 if (! emit_insn (& exp
, nbytes
))
4042 ignore_rest_of_line ();
4046 while (*input_line_pointer
++ == ',');
4048 /* Put terminator back into stream. */
4049 input_line_pointer
--;
4050 demand_empty_rest_of_line ();
4053 /* Parse a .rel31 directive. */
4056 s_arm_rel31 (int ignored ATTRIBUTE_UNUSED
)
4063 if (*input_line_pointer
== '1')
4064 highbit
= 0x80000000;
4065 else if (*input_line_pointer
!= '0')
4066 as_bad (_("expected 0 or 1"));
4068 input_line_pointer
++;
4069 if (*input_line_pointer
!= ',')
4070 as_bad (_("missing comma"));
4071 input_line_pointer
++;
4073 #ifdef md_flush_pending_output
4074 md_flush_pending_output ();
4077 #ifdef md_cons_align
4081 mapping_state (MAP_DATA
);
4086 md_number_to_chars (p
, highbit
, 4);
4087 fix_new_arm (frag_now
, p
- frag_now
->fr_literal
, 4, &exp
, 1,
4088 BFD_RELOC_ARM_PREL31
);
4090 demand_empty_rest_of_line ();
4093 /* Directives: AEABI stack-unwind tables. */
4095 /* Parse an unwind_fnstart directive. Simply records the current location. */
4098 s_arm_unwind_fnstart (int ignored ATTRIBUTE_UNUSED
)
4100 demand_empty_rest_of_line ();
4101 if (unwind
.proc_start
)
4103 as_bad (_("duplicate .fnstart directive"));
4107 /* Mark the start of the function. */
4108 unwind
.proc_start
= expr_build_dot ();
4110 /* Reset the rest of the unwind info. */
4111 unwind
.opcode_count
= 0;
4112 unwind
.table_entry
= NULL
;
4113 unwind
.personality_routine
= NULL
;
4114 unwind
.personality_index
= -1;
4115 unwind
.frame_size
= 0;
4116 unwind
.fp_offset
= 0;
4117 unwind
.fp_reg
= REG_SP
;
4119 unwind
.sp_restored
= 0;
4123 /* Parse a handlerdata directive. Creates the exception handling table entry
4124 for the function. */
4127 s_arm_unwind_handlerdata (int ignored ATTRIBUTE_UNUSED
)
4129 demand_empty_rest_of_line ();
4130 if (!unwind
.proc_start
)
4131 as_bad (MISSING_FNSTART
);
4133 if (unwind
.table_entry
)
4134 as_bad (_("duplicate .handlerdata directive"));
4136 create_unwind_entry (1);
4139 /* Parse an unwind_fnend directive. Generates the index table entry. */
4142 s_arm_unwind_fnend (int ignored ATTRIBUTE_UNUSED
)
4147 unsigned int marked_pr_dependency
;
4149 demand_empty_rest_of_line ();
4151 if (!unwind
.proc_start
)
4153 as_bad (_(".fnend directive without .fnstart"));
4157 /* Add eh table entry. */
4158 if (unwind
.table_entry
== NULL
)
4159 val
= create_unwind_entry (0);
4163 /* Add index table entry. This is two words. */
4164 start_unwind_section (unwind
.saved_seg
, 1);
4165 frag_align (2, 0, 0);
4166 record_alignment (now_seg
, 2);
4168 ptr
= frag_more (8);
4170 where
= frag_now_fix () - 8;
4172 /* Self relative offset of the function start. */
4173 fix_new (frag_now
, where
, 4, unwind
.proc_start
, 0, 1,
4174 BFD_RELOC_ARM_PREL31
);
4176 /* Indicate dependency on EHABI-defined personality routines to the
4177 linker, if it hasn't been done already. */
4178 marked_pr_dependency
4179 = seg_info (now_seg
)->tc_segment_info_data
.marked_pr_dependency
;
4180 if (unwind
.personality_index
>= 0 && unwind
.personality_index
< 3
4181 && !(marked_pr_dependency
& (1 << unwind
.personality_index
)))
4183 static const char *const name
[] =
4185 "__aeabi_unwind_cpp_pr0",
4186 "__aeabi_unwind_cpp_pr1",
4187 "__aeabi_unwind_cpp_pr2"
4189 symbolS
*pr
= symbol_find_or_make (name
[unwind
.personality_index
]);
4190 fix_new (frag_now
, where
, 0, pr
, 0, 1, BFD_RELOC_NONE
);
4191 seg_info (now_seg
)->tc_segment_info_data
.marked_pr_dependency
4192 |= 1 << unwind
.personality_index
;
4196 /* Inline exception table entry. */
4197 md_number_to_chars (ptr
+ 4, val
, 4);
4199 /* Self relative offset of the table entry. */
4200 fix_new (frag_now
, where
+ 4, 4, unwind
.table_entry
, 0, 1,
4201 BFD_RELOC_ARM_PREL31
);
4203 /* Restore the original section. */
4204 subseg_set (unwind
.saved_seg
, unwind
.saved_subseg
);
4206 unwind
.proc_start
= NULL
;
4210 /* Parse an unwind_cantunwind directive. */
4213 s_arm_unwind_cantunwind (int ignored ATTRIBUTE_UNUSED
)
4215 demand_empty_rest_of_line ();
4216 if (!unwind
.proc_start
)
4217 as_bad (MISSING_FNSTART
);
4219 if (unwind
.personality_routine
|| unwind
.personality_index
!= -1)
4220 as_bad (_("personality routine specified for cantunwind frame"));
4222 unwind
.personality_index
= -2;
4226 /* Parse a personalityindex directive. */
4229 s_arm_unwind_personalityindex (int ignored ATTRIBUTE_UNUSED
)
4233 if (!unwind
.proc_start
)
4234 as_bad (MISSING_FNSTART
);
4236 if (unwind
.personality_routine
|| unwind
.personality_index
!= -1)
4237 as_bad (_("duplicate .personalityindex directive"));
4241 if (exp
.X_op
!= O_constant
4242 || exp
.X_add_number
< 0 || exp
.X_add_number
> 15)
4244 as_bad (_("bad personality routine number"));
4245 ignore_rest_of_line ();
4249 unwind
.personality_index
= exp
.X_add_number
;
4251 demand_empty_rest_of_line ();
4255 /* Parse a personality directive. */
4258 s_arm_unwind_personality (int ignored ATTRIBUTE_UNUSED
)
4262 if (!unwind
.proc_start
)
4263 as_bad (MISSING_FNSTART
);
4265 if (unwind
.personality_routine
|| unwind
.personality_index
!= -1)
4266 as_bad (_("duplicate .personality directive"));
4268 c
= get_symbol_name (& name
);
4269 p
= input_line_pointer
;
4271 ++ input_line_pointer
;
4272 unwind
.personality_routine
= symbol_find_or_make (name
);
4274 demand_empty_rest_of_line ();
4278 /* Parse a directive saving core registers. */
4281 s_arm_unwind_save_core (void)
4287 range
= parse_reg_list (&input_line_pointer
, REGLIST_RN
);
4290 as_bad (_("expected register list"));
4291 ignore_rest_of_line ();
4295 demand_empty_rest_of_line ();
4297 /* Turn .unwind_movsp ip followed by .unwind_save {..., ip, ...}
4298 into .unwind_save {..., sp...}. We aren't bothered about the value of
4299 ip because it is clobbered by calls. */
4300 if (unwind
.sp_restored
&& unwind
.fp_reg
== 12
4301 && (range
& 0x3000) == 0x1000)
4303 unwind
.opcode_count
--;
4304 unwind
.sp_restored
= 0;
4305 range
= (range
| 0x2000) & ~0x1000;
4306 unwind
.pending_offset
= 0;
4312 /* See if we can use the short opcodes. These pop a block of up to 8
4313 registers starting with r4, plus maybe r14. */
4314 for (n
= 0; n
< 8; n
++)
4316 /* Break at the first non-saved register. */
4317 if ((range
& (1 << (n
+ 4))) == 0)
4320 /* See if there are any other bits set. */
4321 if (n
== 0 || (range
& (0xfff0 << n
) & 0xbff0) != 0)
4323 /* Use the long form. */
4324 op
= 0x8000 | ((range
>> 4) & 0xfff);
4325 add_unwind_opcode (op
, 2);
4329 /* Use the short form. */
4331 op
= 0xa8; /* Pop r14. */
4333 op
= 0xa0; /* Do not pop r14. */
4335 add_unwind_opcode (op
, 1);
4342 op
= 0xb100 | (range
& 0xf);
4343 add_unwind_opcode (op
, 2);
4346 /* Record the number of bytes pushed. */
4347 for (n
= 0; n
< 16; n
++)
4349 if (range
& (1 << n
))
4350 unwind
.frame_size
+= 4;
4355 /* Parse a directive saving FPA registers. */
4358 s_arm_unwind_save_fpa (int reg
)
4364 /* Get Number of registers to transfer. */
4365 if (skip_past_comma (&input_line_pointer
) != FAIL
)
4368 exp
.X_op
= O_illegal
;
4370 if (exp
.X_op
!= O_constant
)
4372 as_bad (_("expected , <constant>"));
4373 ignore_rest_of_line ();
4377 num_regs
= exp
.X_add_number
;
4379 if (num_regs
< 1 || num_regs
> 4)
4381 as_bad (_("number of registers must be in the range [1:4]"));
4382 ignore_rest_of_line ();
4386 demand_empty_rest_of_line ();
4391 op
= 0xb4 | (num_regs
- 1);
4392 add_unwind_opcode (op
, 1);
4397 op
= 0xc800 | (reg
<< 4) | (num_regs
- 1);
4398 add_unwind_opcode (op
, 2);
4400 unwind
.frame_size
+= num_regs
* 12;
4404 /* Parse a directive saving VFP registers for ARMv6 and above. */
4407 s_arm_unwind_save_vfp_armv6 (void)
4412 int num_vfpv3_regs
= 0;
4413 int num_regs_below_16
;
4414 bfd_boolean partial_match
;
4416 count
= parse_vfp_reg_list (&input_line_pointer
, &start
, REGLIST_VFP_D
,
4420 as_bad (_("expected register list"));
4421 ignore_rest_of_line ();
4425 demand_empty_rest_of_line ();
4427 /* We always generate FSTMD/FLDMD-style unwinding opcodes (rather
4428 than FSTMX/FLDMX-style ones). */
4430 /* Generate opcode for (VFPv3) registers numbered in the range 16 .. 31. */
4432 num_vfpv3_regs
= count
;
4433 else if (start
+ count
> 16)
4434 num_vfpv3_regs
= start
+ count
- 16;
4436 if (num_vfpv3_regs
> 0)
4438 int start_offset
= start
> 16 ? start
- 16 : 0;
4439 op
= 0xc800 | (start_offset
<< 4) | (num_vfpv3_regs
- 1);
4440 add_unwind_opcode (op
, 2);
4443 /* Generate opcode for registers numbered in the range 0 .. 15. */
4444 num_regs_below_16
= num_vfpv3_regs
> 0 ? 16 - (int) start
: count
;
4445 gas_assert (num_regs_below_16
+ num_vfpv3_regs
== count
);
4446 if (num_regs_below_16
> 0)
4448 op
= 0xc900 | (start
<< 4) | (num_regs_below_16
- 1);
4449 add_unwind_opcode (op
, 2);
4452 unwind
.frame_size
+= count
* 8;
4456 /* Parse a directive saving VFP registers for pre-ARMv6. */
4459 s_arm_unwind_save_vfp (void)
4464 bfd_boolean partial_match
;
4466 count
= parse_vfp_reg_list (&input_line_pointer
, ®
, REGLIST_VFP_D
,
4470 as_bad (_("expected register list"));
4471 ignore_rest_of_line ();
4475 demand_empty_rest_of_line ();
4480 op
= 0xb8 | (count
- 1);
4481 add_unwind_opcode (op
, 1);
4486 op
= 0xb300 | (reg
<< 4) | (count
- 1);
4487 add_unwind_opcode (op
, 2);
4489 unwind
.frame_size
+= count
* 8 + 4;
4493 /* Parse a directive saving iWMMXt data registers. */
4496 s_arm_unwind_save_mmxwr (void)
4504 if (*input_line_pointer
== '{')
4505 input_line_pointer
++;
4509 reg
= arm_reg_parse (&input_line_pointer
, REG_TYPE_MMXWR
);
4513 as_bad ("%s", _(reg_expected_msgs
[REG_TYPE_MMXWR
]));
4518 as_tsktsk (_("register list not in ascending order"));
4521 if (*input_line_pointer
== '-')
4523 input_line_pointer
++;
4524 hi_reg
= arm_reg_parse (&input_line_pointer
, REG_TYPE_MMXWR
);
4527 as_bad ("%s", _(reg_expected_msgs
[REG_TYPE_MMXWR
]));
4530 else if (reg
>= hi_reg
)
4532 as_bad (_("bad register range"));
4535 for (; reg
< hi_reg
; reg
++)
4539 while (skip_past_comma (&input_line_pointer
) != FAIL
);
4541 skip_past_char (&input_line_pointer
, '}');
4543 demand_empty_rest_of_line ();
4545 /* Generate any deferred opcodes because we're going to be looking at
4547 flush_pending_unwind ();
4549 for (i
= 0; i
< 16; i
++)
4551 if (mask
& (1 << i
))
4552 unwind
.frame_size
+= 8;
4555 /* Attempt to combine with a previous opcode. We do this because gcc
4556 likes to output separate unwind directives for a single block of
4558 if (unwind
.opcode_count
> 0)
4560 i
= unwind
.opcodes
[unwind
.opcode_count
- 1];
4561 if ((i
& 0xf8) == 0xc0)
4564 /* Only merge if the blocks are contiguous. */
4567 if ((mask
& 0xfe00) == (1 << 9))
4569 mask
|= ((1 << (i
+ 11)) - 1) & 0xfc00;
4570 unwind
.opcode_count
--;
4573 else if (i
== 6 && unwind
.opcode_count
>= 2)
4575 i
= unwind
.opcodes
[unwind
.opcode_count
- 2];
4579 op
= 0xffff << (reg
- 1);
4581 && ((mask
& op
) == (1u << (reg
- 1))))
4583 op
= (1 << (reg
+ i
+ 1)) - 1;
4584 op
&= ~((1 << reg
) - 1);
4586 unwind
.opcode_count
-= 2;
4593 /* We want to generate opcodes in the order the registers have been
4594 saved, ie. descending order. */
4595 for (reg
= 15; reg
>= -1; reg
--)
4597 /* Save registers in blocks. */
4599 || !(mask
& (1 << reg
)))
4601 /* We found an unsaved reg. Generate opcodes to save the
4608 op
= 0xc0 | (hi_reg
- 10);
4609 add_unwind_opcode (op
, 1);
4614 op
= 0xc600 | ((reg
+ 1) << 4) | ((hi_reg
- reg
) - 1);
4615 add_unwind_opcode (op
, 2);
4624 ignore_rest_of_line ();
4628 s_arm_unwind_save_mmxwcg (void)
4635 if (*input_line_pointer
== '{')
4636 input_line_pointer
++;
4638 skip_whitespace (input_line_pointer
);
4642 reg
= arm_reg_parse (&input_line_pointer
, REG_TYPE_MMXWCG
);
4646 as_bad ("%s", _(reg_expected_msgs
[REG_TYPE_MMXWCG
]));
4652 as_tsktsk (_("register list not in ascending order"));
4655 if (*input_line_pointer
== '-')
4657 input_line_pointer
++;
4658 hi_reg
= arm_reg_parse (&input_line_pointer
, REG_TYPE_MMXWCG
);
4661 as_bad ("%s", _(reg_expected_msgs
[REG_TYPE_MMXWCG
]));
4664 else if (reg
>= hi_reg
)
4666 as_bad (_("bad register range"));
4669 for (; reg
< hi_reg
; reg
++)
4673 while (skip_past_comma (&input_line_pointer
) != FAIL
);
4675 skip_past_char (&input_line_pointer
, '}');
4677 demand_empty_rest_of_line ();
4679 /* Generate any deferred opcodes because we're going to be looking at
4681 flush_pending_unwind ();
4683 for (reg
= 0; reg
< 16; reg
++)
4685 if (mask
& (1 << reg
))
4686 unwind
.frame_size
+= 4;
4689 add_unwind_opcode (op
, 2);
4692 ignore_rest_of_line ();
4696 /* Parse an unwind_save directive.
4697 If the argument is non-zero, this is a .vsave directive. */
4700 s_arm_unwind_save (int arch_v6
)
4703 struct reg_entry
*reg
;
4704 bfd_boolean had_brace
= FALSE
;
4706 if (!unwind
.proc_start
)
4707 as_bad (MISSING_FNSTART
);
4709 /* Figure out what sort of save we have. */
4710 peek
= input_line_pointer
;
4718 reg
= arm_reg_parse_multi (&peek
);
4722 as_bad (_("register expected"));
4723 ignore_rest_of_line ();
4732 as_bad (_("FPA .unwind_save does not take a register list"));
4733 ignore_rest_of_line ();
4736 input_line_pointer
= peek
;
4737 s_arm_unwind_save_fpa (reg
->number
);
4741 s_arm_unwind_save_core ();
4746 s_arm_unwind_save_vfp_armv6 ();
4748 s_arm_unwind_save_vfp ();
4751 case REG_TYPE_MMXWR
:
4752 s_arm_unwind_save_mmxwr ();
4755 case REG_TYPE_MMXWCG
:
4756 s_arm_unwind_save_mmxwcg ();
4760 as_bad (_(".unwind_save does not support this kind of register"));
4761 ignore_rest_of_line ();
4766 /* Parse an unwind_movsp directive. */
4769 s_arm_unwind_movsp (int ignored ATTRIBUTE_UNUSED
)
4775 if (!unwind
.proc_start
)
4776 as_bad (MISSING_FNSTART
);
4778 reg
= arm_reg_parse (&input_line_pointer
, REG_TYPE_RN
);
4781 as_bad ("%s", _(reg_expected_msgs
[REG_TYPE_RN
]));
4782 ignore_rest_of_line ();
4786 /* Optional constant. */
4787 if (skip_past_comma (&input_line_pointer
) != FAIL
)
4789 if (immediate_for_directive (&offset
) == FAIL
)
4795 demand_empty_rest_of_line ();
4797 if (reg
== REG_SP
|| reg
== REG_PC
)
4799 as_bad (_("SP and PC not permitted in .unwind_movsp directive"));
4803 if (unwind
.fp_reg
!= REG_SP
)
4804 as_bad (_("unexpected .unwind_movsp directive"));
4806 /* Generate opcode to restore the value. */
4808 add_unwind_opcode (op
, 1);
4810 /* Record the information for later. */
4811 unwind
.fp_reg
= reg
;
4812 unwind
.fp_offset
= unwind
.frame_size
- offset
;
4813 unwind
.sp_restored
= 1;
4816 /* Parse an unwind_pad directive. */
4819 s_arm_unwind_pad (int ignored ATTRIBUTE_UNUSED
)
4823 if (!unwind
.proc_start
)
4824 as_bad (MISSING_FNSTART
);
4826 if (immediate_for_directive (&offset
) == FAIL
)
4831 as_bad (_("stack increment must be multiple of 4"));
4832 ignore_rest_of_line ();
4836 /* Don't generate any opcodes, just record the details for later. */
4837 unwind
.frame_size
+= offset
;
4838 unwind
.pending_offset
+= offset
;
4840 demand_empty_rest_of_line ();
4843 /* Parse an unwind_setfp directive. */
4846 s_arm_unwind_setfp (int ignored ATTRIBUTE_UNUSED
)
4852 if (!unwind
.proc_start
)
4853 as_bad (MISSING_FNSTART
);
4855 fp_reg
= arm_reg_parse (&input_line_pointer
, REG_TYPE_RN
);
4856 if (skip_past_comma (&input_line_pointer
) == FAIL
)
4859 sp_reg
= arm_reg_parse (&input_line_pointer
, REG_TYPE_RN
);
4861 if (fp_reg
== FAIL
|| sp_reg
== FAIL
)
4863 as_bad (_("expected <reg>, <reg>"));
4864 ignore_rest_of_line ();
4868 /* Optional constant. */
4869 if (skip_past_comma (&input_line_pointer
) != FAIL
)
4871 if (immediate_for_directive (&offset
) == FAIL
)
4877 demand_empty_rest_of_line ();
4879 if (sp_reg
!= REG_SP
&& sp_reg
!= unwind
.fp_reg
)
4881 as_bad (_("register must be either sp or set by a previous"
4882 "unwind_movsp directive"));
4886 /* Don't generate any opcodes, just record the information for later. */
4887 unwind
.fp_reg
= fp_reg
;
4889 if (sp_reg
== REG_SP
)
4890 unwind
.fp_offset
= unwind
.frame_size
- offset
;
4892 unwind
.fp_offset
-= offset
;
4895 /* Parse an unwind_raw directive. */
4898 s_arm_unwind_raw (int ignored ATTRIBUTE_UNUSED
)
4901 /* This is an arbitrary limit. */
4902 unsigned char op
[16];
4905 if (!unwind
.proc_start
)
4906 as_bad (MISSING_FNSTART
);
4909 if (exp
.X_op
== O_constant
4910 && skip_past_comma (&input_line_pointer
) != FAIL
)
4912 unwind
.frame_size
+= exp
.X_add_number
;
4916 exp
.X_op
= O_illegal
;
4918 if (exp
.X_op
!= O_constant
)
4920 as_bad (_("expected <offset>, <opcode>"));
4921 ignore_rest_of_line ();
4927 /* Parse the opcode. */
4932 as_bad (_("unwind opcode too long"));
4933 ignore_rest_of_line ();
4935 if (exp
.X_op
!= O_constant
|| exp
.X_add_number
& ~0xff)
4937 as_bad (_("invalid unwind opcode"));
4938 ignore_rest_of_line ();
4941 op
[count
++] = exp
.X_add_number
;
4943 /* Parse the next byte. */
4944 if (skip_past_comma (&input_line_pointer
) == FAIL
)
4950 /* Add the opcode bytes in reverse order. */
4952 add_unwind_opcode (op
[count
], 1);
4954 demand_empty_rest_of_line ();
4958 /* Parse a .eabi_attribute directive. */
4961 s_arm_eabi_attribute (int ignored ATTRIBUTE_UNUSED
)
4963 int tag
= obj_elf_vendor_attribute (OBJ_ATTR_PROC
);
4965 if (tag
>= 0 && tag
< NUM_KNOWN_OBJ_ATTRIBUTES
)
4966 attributes_set_explicitly
[tag
] = 1;
4969 /* Emit a tls fix for the symbol. */
4972 s_arm_tls_descseq (int ignored ATTRIBUTE_UNUSED
)
4976 #ifdef md_flush_pending_output
4977 md_flush_pending_output ();
4980 #ifdef md_cons_align
4984 /* Since we're just labelling the code, there's no need to define a
4987 p
= obstack_next_free (&frchain_now
->frch_obstack
);
4988 fix_new_arm (frag_now
, p
- frag_now
->fr_literal
, 4, &exp
, 0,
4989 thumb_mode
? BFD_RELOC_ARM_THM_TLS_DESCSEQ
4990 : BFD_RELOC_ARM_TLS_DESCSEQ
);
4992 #endif /* OBJ_ELF */
4994 static void s_arm_arch (int);
4995 static void s_arm_object_arch (int);
4996 static void s_arm_cpu (int);
4997 static void s_arm_fpu (int);
4998 static void s_arm_arch_extension (int);
5003 pe_directive_secrel (int dummy ATTRIBUTE_UNUSED
)
5010 if (exp
.X_op
== O_symbol
)
5011 exp
.X_op
= O_secrel
;
5013 emit_expr (&exp
, 4);
5015 while (*input_line_pointer
++ == ',');
5017 input_line_pointer
--;
5018 demand_empty_rest_of_line ();
5023 arm_is_largest_exponent_ok (int precision
)
5025 /* precision == 1 ensures that this will only return
5026 true for 16 bit floats. */
5027 return (precision
== 1) && (fp16_format
== ARM_FP16_FORMAT_ALTERNATIVE
);
5031 set_fp16_format (int dummy ATTRIBUTE_UNUSED
)
5035 enum fp_16bit_format new_format
;
5037 new_format
= ARM_FP16_FORMAT_DEFAULT
;
5039 name
= input_line_pointer
;
5040 while (*input_line_pointer
&& !ISSPACE (*input_line_pointer
))
5041 input_line_pointer
++;
5043 saved_char
= *input_line_pointer
;
5044 *input_line_pointer
= 0;
5046 if (strcasecmp (name
, "ieee") == 0)
5047 new_format
= ARM_FP16_FORMAT_IEEE
;
5048 else if (strcasecmp (name
, "alternative") == 0)
5049 new_format
= ARM_FP16_FORMAT_ALTERNATIVE
;
5052 as_bad (_("unrecognised float16 format \"%s\""), name
);
5056 /* Only set fp16_format if it is still the default (aka not already
5058 if (fp16_format
== ARM_FP16_FORMAT_DEFAULT
)
5059 fp16_format
= new_format
;
5062 if (new_format
!= fp16_format
)
5063 as_warn (_("float16 format cannot be set more than once, ignoring."));
5067 *input_line_pointer
= saved_char
;
5068 ignore_rest_of_line ();
5071 /* This table describes all the machine specific pseudo-ops the assembler
5072 has to support. The fields are:
5073 pseudo-op name without dot
5074 function to call to execute this pseudo-op
5075 Integer arg to pass to the function. */
5077 const pseudo_typeS md_pseudo_table
[] =
5079 /* Never called because '.req' does not start a line. */
5080 { "req", s_req
, 0 },
5081 /* Following two are likewise never called. */
5084 { "unreq", s_unreq
, 0 },
5085 { "bss", s_bss
, 0 },
5086 { "align", s_align_ptwo
, 2 },
5087 { "arm", s_arm
, 0 },
5088 { "thumb", s_thumb
, 0 },
5089 { "code", s_code
, 0 },
5090 { "force_thumb", s_force_thumb
, 0 },
5091 { "thumb_func", s_thumb_func
, 0 },
5092 { "thumb_set", s_thumb_set
, 0 },
5093 { "even", s_even
, 0 },
5094 { "ltorg", s_ltorg
, 0 },
5095 { "pool", s_ltorg
, 0 },
5096 { "syntax", s_syntax
, 0 },
5097 { "cpu", s_arm_cpu
, 0 },
5098 { "arch", s_arm_arch
, 0 },
5099 { "object_arch", s_arm_object_arch
, 0 },
5100 { "fpu", s_arm_fpu
, 0 },
5101 { "arch_extension", s_arm_arch_extension
, 0 },
5103 { "word", s_arm_elf_cons
, 4 },
5104 { "long", s_arm_elf_cons
, 4 },
5105 { "inst.n", s_arm_elf_inst
, 2 },
5106 { "inst.w", s_arm_elf_inst
, 4 },
5107 { "inst", s_arm_elf_inst
, 0 },
5108 { "rel31", s_arm_rel31
, 0 },
5109 { "fnstart", s_arm_unwind_fnstart
, 0 },
5110 { "fnend", s_arm_unwind_fnend
, 0 },
5111 { "cantunwind", s_arm_unwind_cantunwind
, 0 },
5112 { "personality", s_arm_unwind_personality
, 0 },
5113 { "personalityindex", s_arm_unwind_personalityindex
, 0 },
5114 { "handlerdata", s_arm_unwind_handlerdata
, 0 },
5115 { "save", s_arm_unwind_save
, 0 },
5116 { "vsave", s_arm_unwind_save
, 1 },
5117 { "movsp", s_arm_unwind_movsp
, 0 },
5118 { "pad", s_arm_unwind_pad
, 0 },
5119 { "setfp", s_arm_unwind_setfp
, 0 },
5120 { "unwind_raw", s_arm_unwind_raw
, 0 },
5121 { "eabi_attribute", s_arm_eabi_attribute
, 0 },
5122 { "tlsdescseq", s_arm_tls_descseq
, 0 },
5126 /* These are used for dwarf. */
5130 /* These are used for dwarf2. */
5131 { "file", dwarf2_directive_file
, 0 },
5132 { "loc", dwarf2_directive_loc
, 0 },
5133 { "loc_mark_labels", dwarf2_directive_loc_mark_labels
, 0 },
5135 { "extend", float_cons
, 'x' },
5136 { "ldouble", float_cons
, 'x' },
5137 { "packed", float_cons
, 'p' },
5138 { "bfloat16", float_cons
, 'b' },
5140 {"secrel32", pe_directive_secrel
, 0},
5143 /* These are for compatibility with CodeComposer Studio. */
5144 {"ref", s_ccs_ref
, 0},
5145 {"def", s_ccs_def
, 0},
5146 {"asmfunc", s_ccs_asmfunc
, 0},
5147 {"endasmfunc", s_ccs_endasmfunc
, 0},
5149 {"float16", float_cons
, 'h' },
5150 {"float16_format", set_fp16_format
, 0 },
5155 /* Parser functions used exclusively in instruction operands. */
5157 /* Generic immediate-value read function for use in insn parsing.
5158 STR points to the beginning of the immediate (the leading #);
5159 VAL receives the value; if the value is outside [MIN, MAX]
5160 issue an error. PREFIX_OPT is true if the immediate prefix is
5164 parse_immediate (char **str
, int *val
, int min
, int max
,
5165 bfd_boolean prefix_opt
)
5169 my_get_expression (&exp
, str
, prefix_opt
? GE_OPT_PREFIX
: GE_IMM_PREFIX
);
5170 if (exp
.X_op
!= O_constant
)
5172 inst
.error
= _("constant expression required");
5176 if (exp
.X_add_number
< min
|| exp
.X_add_number
> max
)
5178 inst
.error
= _("immediate value out of range");
5182 *val
= exp
.X_add_number
;
5186 /* Less-generic immediate-value read function with the possibility of loading a
5187 big (64-bit) immediate, as required by Neon VMOV, VMVN and logic immediate
5188 instructions. Puts the result directly in inst.operands[i]. */
5191 parse_big_immediate (char **str
, int i
, expressionS
*in_exp
,
5192 bfd_boolean allow_symbol_p
)
5195 expressionS
*exp_p
= in_exp
? in_exp
: &exp
;
5198 my_get_expression (exp_p
, &ptr
, GE_OPT_PREFIX_BIG
);
5200 if (exp_p
->X_op
== O_constant
)
5202 inst
.operands
[i
].imm
= exp_p
->X_add_number
& 0xffffffff;
5203 /* If we're on a 64-bit host, then a 64-bit number can be returned using
5204 O_constant. We have to be careful not to break compilation for
5205 32-bit X_add_number, though. */
5206 if ((exp_p
->X_add_number
& ~(offsetT
)(0xffffffffU
)) != 0)
5208 /* X >> 32 is illegal if sizeof (exp_p->X_add_number) == 4. */
5209 inst
.operands
[i
].reg
= (((exp_p
->X_add_number
>> 16) >> 16)
5211 inst
.operands
[i
].regisimm
= 1;
5214 else if (exp_p
->X_op
== O_big
5215 && LITTLENUM_NUMBER_OF_BITS
* exp_p
->X_add_number
> 32)
5217 unsigned parts
= 32 / LITTLENUM_NUMBER_OF_BITS
, j
, idx
= 0;
5219 /* Bignums have their least significant bits in
5220 generic_bignum[0]. Make sure we put 32 bits in imm and
5221 32 bits in reg, in a (hopefully) portable way. */
5222 gas_assert (parts
!= 0);
5224 /* Make sure that the number is not too big.
5225 PR 11972: Bignums can now be sign-extended to the
5226 size of a .octa so check that the out of range bits
5227 are all zero or all one. */
5228 if (LITTLENUM_NUMBER_OF_BITS
* exp_p
->X_add_number
> 64)
5230 LITTLENUM_TYPE m
= -1;
5232 if (generic_bignum
[parts
* 2] != 0
5233 && generic_bignum
[parts
* 2] != m
)
5236 for (j
= parts
* 2 + 1; j
< (unsigned) exp_p
->X_add_number
; j
++)
5237 if (generic_bignum
[j
] != generic_bignum
[j
-1])
5241 inst
.operands
[i
].imm
= 0;
5242 for (j
= 0; j
< parts
; j
++, idx
++)
5243 inst
.operands
[i
].imm
|= generic_bignum
[idx
]
5244 << (LITTLENUM_NUMBER_OF_BITS
* j
);
5245 inst
.operands
[i
].reg
= 0;
5246 for (j
= 0; j
< parts
; j
++, idx
++)
5247 inst
.operands
[i
].reg
|= generic_bignum
[idx
]
5248 << (LITTLENUM_NUMBER_OF_BITS
* j
);
5249 inst
.operands
[i
].regisimm
= 1;
5251 else if (!(exp_p
->X_op
== O_symbol
&& allow_symbol_p
))
5259 /* Returns the pseudo-register number of an FPA immediate constant,
5260 or FAIL if there isn't a valid constant here. */
5263 parse_fpa_immediate (char ** str
)
5265 LITTLENUM_TYPE words
[MAX_LITTLENUMS
];
5271 /* First try and match exact strings, this is to guarantee
5272 that some formats will work even for cross assembly. */
5274 for (i
= 0; fp_const
[i
]; i
++)
5276 if (strncmp (*str
, fp_const
[i
], strlen (fp_const
[i
])) == 0)
5280 *str
+= strlen (fp_const
[i
]);
5281 if (is_end_of_line
[(unsigned char) **str
])
5287 /* Just because we didn't get a match doesn't mean that the constant
5288 isn't valid, just that it is in a format that we don't
5289 automatically recognize. Try parsing it with the standard
5290 expression routines. */
5292 memset (words
, 0, MAX_LITTLENUMS
* sizeof (LITTLENUM_TYPE
));
5294 /* Look for a raw floating point number. */
5295 if ((save_in
= atof_ieee (*str
, 'x', words
)) != NULL
5296 && is_end_of_line
[(unsigned char) *save_in
])
5298 for (i
= 0; i
< NUM_FLOAT_VALS
; i
++)
5300 for (j
= 0; j
< MAX_LITTLENUMS
; j
++)
5302 if (words
[j
] != fp_values
[i
][j
])
5306 if (j
== MAX_LITTLENUMS
)
5314 /* Try and parse a more complex expression, this will probably fail
5315 unless the code uses a floating point prefix (eg "0f"). */
5316 save_in
= input_line_pointer
;
5317 input_line_pointer
= *str
;
5318 if (expression (&exp
) == absolute_section
5319 && exp
.X_op
== O_big
5320 && exp
.X_add_number
< 0)
5322 /* FIXME: 5 = X_PRECISION, should be #define'd where we can use it.
5324 #define X_PRECISION 5
5325 #define E_PRECISION 15L
5326 if (gen_to_words (words
, X_PRECISION
, E_PRECISION
) == 0)
5328 for (i
= 0; i
< NUM_FLOAT_VALS
; i
++)
5330 for (j
= 0; j
< MAX_LITTLENUMS
; j
++)
5332 if (words
[j
] != fp_values
[i
][j
])
5336 if (j
== MAX_LITTLENUMS
)
5338 *str
= input_line_pointer
;
5339 input_line_pointer
= save_in
;
5346 *str
= input_line_pointer
;
5347 input_line_pointer
= save_in
;
5348 inst
.error
= _("invalid FPA immediate expression");
5352 /* Returns 1 if a number has "quarter-precision" float format
5353 0baBbbbbbc defgh000 00000000 00000000. */
5356 is_quarter_float (unsigned imm
)
5358 int bs
= (imm
& 0x20000000) ? 0x3e000000 : 0x40000000;
5359 return (imm
& 0x7ffff) == 0 && ((imm
& 0x7e000000) ^ bs
) == 0;
5363 /* Detect the presence of a floating point or integer zero constant,
5367 parse_ifimm_zero (char **in
)
5371 if (!is_immediate_prefix (**in
))
5373 /* In unified syntax, all prefixes are optional. */
5374 if (!unified_syntax
)
5380 /* Accept #0x0 as a synonym for #0. */
5381 if (strncmp (*in
, "0x", 2) == 0)
5384 if (parse_immediate (in
, &val
, 0, 0, TRUE
) == FAIL
)
5389 error_code
= atof_generic (in
, ".", EXP_CHARS
,
5390 &generic_floating_point_number
);
5393 && generic_floating_point_number
.sign
== '+'
5394 && (generic_floating_point_number
.low
5395 > generic_floating_point_number
.leader
))
5401 /* Parse an 8-bit "quarter-precision" floating point number of the form:
5402 0baBbbbbbc defgh000 00000000 00000000.
5403 The zero and minus-zero cases need special handling, since they can't be
5404 encoded in the "quarter-precision" float format, but can nonetheless be
5405 loaded as integer constants. */
5408 parse_qfloat_immediate (char **ccp
, int *immed
)
5412 LITTLENUM_TYPE words
[MAX_LITTLENUMS
];
5413 int found_fpchar
= 0;
5415 skip_past_char (&str
, '#');
5417 /* We must not accidentally parse an integer as a floating-point number. Make
5418 sure that the value we parse is not an integer by checking for special
5419 characters '.' or 'e'.
5420 FIXME: This is a horrible hack, but doing better is tricky because type
5421 information isn't in a very usable state at parse time. */
5423 skip_whitespace (fpnum
);
5425 if (strncmp (fpnum
, "0x", 2) == 0)
5429 for (; *fpnum
!= '\0' && *fpnum
!= ' ' && *fpnum
!= '\n'; fpnum
++)
5430 if (*fpnum
== '.' || *fpnum
== 'e' || *fpnum
== 'E')
5440 if ((str
= atof_ieee (str
, 's', words
)) != NULL
)
5442 unsigned fpword
= 0;
5445 /* Our FP word must be 32 bits (single-precision FP). */
5446 for (i
= 0; i
< 32 / LITTLENUM_NUMBER_OF_BITS
; i
++)
5448 fpword
<<= LITTLENUM_NUMBER_OF_BITS
;
5452 if (is_quarter_float (fpword
) || (fpword
& 0x7fffffff) == 0)
5465 /* Shift operands. */
5468 SHIFT_LSL
, SHIFT_LSR
, SHIFT_ASR
, SHIFT_ROR
, SHIFT_RRX
, SHIFT_UXTW
5471 struct asm_shift_name
5474 enum shift_kind kind
;
5477 /* Third argument to parse_shift. */
5478 enum parse_shift_mode
5480 NO_SHIFT_RESTRICT
, /* Any kind of shift is accepted. */
5481 SHIFT_IMMEDIATE
, /* Shift operand must be an immediate. */
5482 SHIFT_LSL_OR_ASR_IMMEDIATE
, /* Shift must be LSL or ASR immediate. */
5483 SHIFT_ASR_IMMEDIATE
, /* Shift must be ASR immediate. */
5484 SHIFT_LSL_IMMEDIATE
, /* Shift must be LSL immediate. */
5485 SHIFT_UXTW_IMMEDIATE
/* Shift must be UXTW immediate. */
5488 /* Parse a <shift> specifier on an ARM data processing instruction.
5489 This has three forms:
5491 (LSL|LSR|ASL|ASR|ROR) Rs
5492 (LSL|LSR|ASL|ASR|ROR) #imm
5495 Note that ASL is assimilated to LSL in the instruction encoding, and
5496 RRX to ROR #0 (which cannot be written as such). */
5499 parse_shift (char **str
, int i
, enum parse_shift_mode mode
)
5501 const struct asm_shift_name
*shift_name
;
5502 enum shift_kind shift
;
5507 for (p
= *str
; ISALPHA (*p
); p
++)
5512 inst
.error
= _("shift expression expected");
5516 shift_name
= (const struct asm_shift_name
*) hash_find_n (arm_shift_hsh
, *str
,
5519 if (shift_name
== NULL
)
5521 inst
.error
= _("shift expression expected");
5525 shift
= shift_name
->kind
;
5529 case NO_SHIFT_RESTRICT
:
5530 case SHIFT_IMMEDIATE
:
5531 if (shift
== SHIFT_UXTW
)
5533 inst
.error
= _("'UXTW' not allowed here");
5538 case SHIFT_LSL_OR_ASR_IMMEDIATE
:
5539 if (shift
!= SHIFT_LSL
&& shift
!= SHIFT_ASR
)
5541 inst
.error
= _("'LSL' or 'ASR' required");
5546 case SHIFT_LSL_IMMEDIATE
:
5547 if (shift
!= SHIFT_LSL
)
5549 inst
.error
= _("'LSL' required");
5554 case SHIFT_ASR_IMMEDIATE
:
5555 if (shift
!= SHIFT_ASR
)
5557 inst
.error
= _("'ASR' required");
5561 case SHIFT_UXTW_IMMEDIATE
:
5562 if (shift
!= SHIFT_UXTW
)
5564 inst
.error
= _("'UXTW' required");
5572 if (shift
!= SHIFT_RRX
)
5574 /* Whitespace can appear here if the next thing is a bare digit. */
5575 skip_whitespace (p
);
5577 if (mode
== NO_SHIFT_RESTRICT
5578 && (reg
= arm_reg_parse (&p
, REG_TYPE_RN
)) != FAIL
)
5580 inst
.operands
[i
].imm
= reg
;
5581 inst
.operands
[i
].immisreg
= 1;
5583 else if (my_get_expression (&inst
.relocs
[0].exp
, &p
, GE_IMM_PREFIX
))
5586 inst
.operands
[i
].shift_kind
= shift
;
5587 inst
.operands
[i
].shifted
= 1;
5592 /* Parse a <shifter_operand> for an ARM data processing instruction:
5595 #<immediate>, <rotate>
5599 where <shift> is defined by parse_shift above, and <rotate> is a
5600 multiple of 2 between 0 and 30. Validation of immediate operands
5601 is deferred to md_apply_fix. */
5604 parse_shifter_operand (char **str
, int i
)
5609 if ((value
= arm_reg_parse (str
, REG_TYPE_RN
)) != FAIL
)
5611 inst
.operands
[i
].reg
= value
;
5612 inst
.operands
[i
].isreg
= 1;
5614 /* parse_shift will override this if appropriate */
5615 inst
.relocs
[0].exp
.X_op
= O_constant
;
5616 inst
.relocs
[0].exp
.X_add_number
= 0;
5618 if (skip_past_comma (str
) == FAIL
)
5621 /* Shift operation on register. */
5622 return parse_shift (str
, i
, NO_SHIFT_RESTRICT
);
5625 if (my_get_expression (&inst
.relocs
[0].exp
, str
, GE_IMM_PREFIX
))
5628 if (skip_past_comma (str
) == SUCCESS
)
5630 /* #x, y -- ie explicit rotation by Y. */
5631 if (my_get_expression (&exp
, str
, GE_NO_PREFIX
))
5634 if (exp
.X_op
!= O_constant
|| inst
.relocs
[0].exp
.X_op
!= O_constant
)
5636 inst
.error
= _("constant expression expected");
5640 value
= exp
.X_add_number
;
5641 if (value
< 0 || value
> 30 || value
% 2 != 0)
5643 inst
.error
= _("invalid rotation");
5646 if (inst
.relocs
[0].exp
.X_add_number
< 0
5647 || inst
.relocs
[0].exp
.X_add_number
> 255)
5649 inst
.error
= _("invalid constant");
5653 /* Encode as specified. */
5654 inst
.operands
[i
].imm
= inst
.relocs
[0].exp
.X_add_number
| value
<< 7;
5658 inst
.relocs
[0].type
= BFD_RELOC_ARM_IMMEDIATE
;
5659 inst
.relocs
[0].pc_rel
= 0;
5663 /* Group relocation information. Each entry in the table contains the
5664 textual name of the relocation as may appear in assembler source
5665 and must end with a colon.
5666 Along with this textual name are the relocation codes to be used if
5667 the corresponding instruction is an ALU instruction (ADD or SUB only),
5668 an LDR, an LDRS, or an LDC. */
5670 struct group_reloc_table_entry
5681 /* Varieties of non-ALU group relocation. */
5689 static struct group_reloc_table_entry group_reloc_table
[] =
5690 { /* Program counter relative: */
5692 BFD_RELOC_ARM_ALU_PC_G0_NC
, /* ALU */
5697 BFD_RELOC_ARM_ALU_PC_G0
, /* ALU */
5698 BFD_RELOC_ARM_LDR_PC_G0
, /* LDR */
5699 BFD_RELOC_ARM_LDRS_PC_G0
, /* LDRS */
5700 BFD_RELOC_ARM_LDC_PC_G0
}, /* LDC */
5702 BFD_RELOC_ARM_ALU_PC_G1_NC
, /* ALU */
5707 BFD_RELOC_ARM_ALU_PC_G1
, /* ALU */
5708 BFD_RELOC_ARM_LDR_PC_G1
, /* LDR */
5709 BFD_RELOC_ARM_LDRS_PC_G1
, /* LDRS */
5710 BFD_RELOC_ARM_LDC_PC_G1
}, /* LDC */
5712 BFD_RELOC_ARM_ALU_PC_G2
, /* ALU */
5713 BFD_RELOC_ARM_LDR_PC_G2
, /* LDR */
5714 BFD_RELOC_ARM_LDRS_PC_G2
, /* LDRS */
5715 BFD_RELOC_ARM_LDC_PC_G2
}, /* LDC */
5716 /* Section base relative */
5718 BFD_RELOC_ARM_ALU_SB_G0_NC
, /* ALU */
5723 BFD_RELOC_ARM_ALU_SB_G0
, /* ALU */
5724 BFD_RELOC_ARM_LDR_SB_G0
, /* LDR */
5725 BFD_RELOC_ARM_LDRS_SB_G0
, /* LDRS */
5726 BFD_RELOC_ARM_LDC_SB_G0
}, /* LDC */
5728 BFD_RELOC_ARM_ALU_SB_G1_NC
, /* ALU */
5733 BFD_RELOC_ARM_ALU_SB_G1
, /* ALU */
5734 BFD_RELOC_ARM_LDR_SB_G1
, /* LDR */
5735 BFD_RELOC_ARM_LDRS_SB_G1
, /* LDRS */
5736 BFD_RELOC_ARM_LDC_SB_G1
}, /* LDC */
5738 BFD_RELOC_ARM_ALU_SB_G2
, /* ALU */
5739 BFD_RELOC_ARM_LDR_SB_G2
, /* LDR */
5740 BFD_RELOC_ARM_LDRS_SB_G2
, /* LDRS */
5741 BFD_RELOC_ARM_LDC_SB_G2
}, /* LDC */
5742 /* Absolute thumb alu relocations. */
5744 BFD_RELOC_ARM_THUMB_ALU_ABS_G0_NC
,/* ALU. */
5749 BFD_RELOC_ARM_THUMB_ALU_ABS_G1_NC
,/* ALU. */
5754 BFD_RELOC_ARM_THUMB_ALU_ABS_G2_NC
,/* ALU. */
5759 BFD_RELOC_ARM_THUMB_ALU_ABS_G3_NC
,/* ALU. */
5764 /* Given the address of a pointer pointing to the textual name of a group
5765 relocation as may appear in assembler source, attempt to find its details
5766 in group_reloc_table. The pointer will be updated to the character after
5767 the trailing colon. On failure, FAIL will be returned; SUCCESS
5768 otherwise. On success, *entry will be updated to point at the relevant
5769 group_reloc_table entry. */
5772 find_group_reloc_table_entry (char **str
, struct group_reloc_table_entry
**out
)
5775 for (i
= 0; i
< ARRAY_SIZE (group_reloc_table
); i
++)
5777 int length
= strlen (group_reloc_table
[i
].name
);
5779 if (strncasecmp (group_reloc_table
[i
].name
, *str
, length
) == 0
5780 && (*str
)[length
] == ':')
5782 *out
= &group_reloc_table
[i
];
5783 *str
+= (length
+ 1);
5791 /* Parse a <shifter_operand> for an ARM data processing instruction
5792 (as for parse_shifter_operand) where group relocations are allowed:
5795 #<immediate>, <rotate>
5796 #:<group_reloc>:<expression>
5800 where <group_reloc> is one of the strings defined in group_reloc_table.
5801 The hashes are optional.
5803 Everything else is as for parse_shifter_operand. */
5805 static parse_operand_result
5806 parse_shifter_operand_group_reloc (char **str
, int i
)
5808 /* Determine if we have the sequence of characters #: or just :
5809 coming next. If we do, then we check for a group relocation.
5810 If we don't, punt the whole lot to parse_shifter_operand. */
5812 if (((*str
)[0] == '#' && (*str
)[1] == ':')
5813 || (*str
)[0] == ':')
5815 struct group_reloc_table_entry
*entry
;
5817 if ((*str
)[0] == '#')
5822 /* Try to parse a group relocation. Anything else is an error. */
5823 if (find_group_reloc_table_entry (str
, &entry
) == FAIL
)
5825 inst
.error
= _("unknown group relocation");
5826 return PARSE_OPERAND_FAIL_NO_BACKTRACK
;
5829 /* We now have the group relocation table entry corresponding to
5830 the name in the assembler source. Next, we parse the expression. */
5831 if (my_get_expression (&inst
.relocs
[0].exp
, str
, GE_NO_PREFIX
))
5832 return PARSE_OPERAND_FAIL_NO_BACKTRACK
;
5834 /* Record the relocation type (always the ALU variant here). */
5835 inst
.relocs
[0].type
= (bfd_reloc_code_real_type
) entry
->alu_code
;
5836 gas_assert (inst
.relocs
[0].type
!= 0);
5838 return PARSE_OPERAND_SUCCESS
;
5841 return parse_shifter_operand (str
, i
) == SUCCESS
5842 ? PARSE_OPERAND_SUCCESS
: PARSE_OPERAND_FAIL
;
5844 /* Never reached. */
5847 /* Parse a Neon alignment expression. Information is written to
5848 inst.operands[i]. We assume the initial ':' has been skipped.
5850 align .imm = align << 8, .immisalign=1, .preind=0 */
5851 static parse_operand_result
5852 parse_neon_alignment (char **str
, int i
)
5857 my_get_expression (&exp
, &p
, GE_NO_PREFIX
);
5859 if (exp
.X_op
!= O_constant
)
5861 inst
.error
= _("alignment must be constant");
5862 return PARSE_OPERAND_FAIL
;
5865 inst
.operands
[i
].imm
= exp
.X_add_number
<< 8;
5866 inst
.operands
[i
].immisalign
= 1;
5867 /* Alignments are not pre-indexes. */
5868 inst
.operands
[i
].preind
= 0;
5871 return PARSE_OPERAND_SUCCESS
;
5874 /* Parse all forms of an ARM address expression. Information is written
5875 to inst.operands[i] and/or inst.relocs[0].
5877 Preindexed addressing (.preind=1):
5879 [Rn, #offset] .reg=Rn .relocs[0].exp=offset
5880 [Rn, +/-Rm] .reg=Rn .imm=Rm .immisreg=1 .negative=0/1
5881 [Rn, +/-Rm, shift] .reg=Rn .imm=Rm .immisreg=1 .negative=0/1
5882 .shift_kind=shift .relocs[0].exp=shift_imm
5884 These three may have a trailing ! which causes .writeback to be set also.
5886 Postindexed addressing (.postind=1, .writeback=1):
5888 [Rn], #offset .reg=Rn .relocs[0].exp=offset
5889 [Rn], +/-Rm .reg=Rn .imm=Rm .immisreg=1 .negative=0/1
5890 [Rn], +/-Rm, shift .reg=Rn .imm=Rm .immisreg=1 .negative=0/1
5891 .shift_kind=shift .relocs[0].exp=shift_imm
5893 Unindexed addressing (.preind=0, .postind=0):
5895 [Rn], {option} .reg=Rn .imm=option .immisreg=0
5899 [Rn]{!} shorthand for [Rn,#0]{!}
5900 =immediate .isreg=0 .relocs[0].exp=immediate
5901 label .reg=PC .relocs[0].pc_rel=1 .relocs[0].exp=label
5903 It is the caller's responsibility to check for addressing modes not
5904 supported by the instruction, and to set inst.relocs[0].type. */
5906 static parse_operand_result
5907 parse_address_main (char **str
, int i
, int group_relocations
,
5908 group_reloc_type group_type
)
5913 if (skip_past_char (&p
, '[') == FAIL
)
5915 if (skip_past_char (&p
, '=') == FAIL
)
5917 /* Bare address - translate to PC-relative offset. */
5918 inst
.relocs
[0].pc_rel
= 1;
5919 inst
.operands
[i
].reg
= REG_PC
;
5920 inst
.operands
[i
].isreg
= 1;
5921 inst
.operands
[i
].preind
= 1;
5923 if (my_get_expression (&inst
.relocs
[0].exp
, &p
, GE_OPT_PREFIX_BIG
))
5924 return PARSE_OPERAND_FAIL
;
5926 else if (parse_big_immediate (&p
, i
, &inst
.relocs
[0].exp
,
5927 /*allow_symbol_p=*/TRUE
))
5928 return PARSE_OPERAND_FAIL
;
5931 return PARSE_OPERAND_SUCCESS
;
5934 /* PR gas/14887: Allow for whitespace after the opening bracket. */
5935 skip_whitespace (p
);
5937 if (group_type
== GROUP_MVE
)
5939 enum arm_reg_type rtype
= REG_TYPE_MQ
;
5940 struct neon_type_el et
;
5941 if ((reg
= arm_typed_reg_parse (&p
, rtype
, &rtype
, &et
)) != FAIL
)
5943 inst
.operands
[i
].isquad
= 1;
5945 else if ((reg
= arm_reg_parse (&p
, REG_TYPE_RN
)) == FAIL
)
5947 inst
.error
= BAD_ADDR_MODE
;
5948 return PARSE_OPERAND_FAIL
;
5951 else if ((reg
= arm_reg_parse (&p
, REG_TYPE_RN
)) == FAIL
)
5953 if (group_type
== GROUP_MVE
)
5954 inst
.error
= BAD_ADDR_MODE
;
5956 inst
.error
= _(reg_expected_msgs
[REG_TYPE_RN
]);
5957 return PARSE_OPERAND_FAIL
;
5959 inst
.operands
[i
].reg
= reg
;
5960 inst
.operands
[i
].isreg
= 1;
5962 if (skip_past_comma (&p
) == SUCCESS
)
5964 inst
.operands
[i
].preind
= 1;
5967 else if (*p
== '-') p
++, inst
.operands
[i
].negative
= 1;
5969 enum arm_reg_type rtype
= REG_TYPE_MQ
;
5970 struct neon_type_el et
;
5971 if (group_type
== GROUP_MVE
5972 && (reg
= arm_typed_reg_parse (&p
, rtype
, &rtype
, &et
)) != FAIL
)
5974 inst
.operands
[i
].immisreg
= 2;
5975 inst
.operands
[i
].imm
= reg
;
5977 if (skip_past_comma (&p
) == SUCCESS
)
5979 if (parse_shift (&p
, i
, SHIFT_UXTW_IMMEDIATE
) == SUCCESS
)
5981 inst
.operands
[i
].imm
|= inst
.relocs
[0].exp
.X_add_number
<< 5;
5982 inst
.relocs
[0].exp
.X_add_number
= 0;
5985 return PARSE_OPERAND_FAIL
;
5988 else if ((reg
= arm_reg_parse (&p
, REG_TYPE_RN
)) != FAIL
)
5990 inst
.operands
[i
].imm
= reg
;
5991 inst
.operands
[i
].immisreg
= 1;
5993 if (skip_past_comma (&p
) == SUCCESS
)
5994 if (parse_shift (&p
, i
, SHIFT_IMMEDIATE
) == FAIL
)
5995 return PARSE_OPERAND_FAIL
;
5997 else if (skip_past_char (&p
, ':') == SUCCESS
)
5999 /* FIXME: '@' should be used here, but it's filtered out by generic
6000 code before we get to see it here. This may be subject to
6002 parse_operand_result result
= parse_neon_alignment (&p
, i
);
6004 if (result
!= PARSE_OPERAND_SUCCESS
)
6009 if (inst
.operands
[i
].negative
)
6011 inst
.operands
[i
].negative
= 0;
6015 if (group_relocations
6016 && ((*p
== '#' && *(p
+ 1) == ':') || *p
== ':'))
6018 struct group_reloc_table_entry
*entry
;
6020 /* Skip over the #: or : sequence. */
6026 /* Try to parse a group relocation. Anything else is an
6028 if (find_group_reloc_table_entry (&p
, &entry
) == FAIL
)
6030 inst
.error
= _("unknown group relocation");
6031 return PARSE_OPERAND_FAIL_NO_BACKTRACK
;
6034 /* We now have the group relocation table entry corresponding to
6035 the name in the assembler source. Next, we parse the
6037 if (my_get_expression (&inst
.relocs
[0].exp
, &p
, GE_NO_PREFIX
))
6038 return PARSE_OPERAND_FAIL_NO_BACKTRACK
;
6040 /* Record the relocation type. */
6045 = (bfd_reloc_code_real_type
) entry
->ldr_code
;
6050 = (bfd_reloc_code_real_type
) entry
->ldrs_code
;
6055 = (bfd_reloc_code_real_type
) entry
->ldc_code
;
6062 if (inst
.relocs
[0].type
== 0)
6064 inst
.error
= _("this group relocation is not allowed on this instruction");
6065 return PARSE_OPERAND_FAIL_NO_BACKTRACK
;
6072 if (my_get_expression (&inst
.relocs
[0].exp
, &p
, GE_IMM_PREFIX
))
6073 return PARSE_OPERAND_FAIL
;
6074 /* If the offset is 0, find out if it's a +0 or -0. */
6075 if (inst
.relocs
[0].exp
.X_op
== O_constant
6076 && inst
.relocs
[0].exp
.X_add_number
== 0)
6078 skip_whitespace (q
);
6082 skip_whitespace (q
);
6085 inst
.operands
[i
].negative
= 1;
6090 else if (skip_past_char (&p
, ':') == SUCCESS
)
6092 /* FIXME: '@' should be used here, but it's filtered out by generic code
6093 before we get to see it here. This may be subject to change. */
6094 parse_operand_result result
= parse_neon_alignment (&p
, i
);
6096 if (result
!= PARSE_OPERAND_SUCCESS
)
6100 if (skip_past_char (&p
, ']') == FAIL
)
6102 inst
.error
= _("']' expected");
6103 return PARSE_OPERAND_FAIL
;
6106 if (skip_past_char (&p
, '!') == SUCCESS
)
6107 inst
.operands
[i
].writeback
= 1;
6109 else if (skip_past_comma (&p
) == SUCCESS
)
6111 if (skip_past_char (&p
, '{') == SUCCESS
)
6113 /* [Rn], {expr} - unindexed, with option */
6114 if (parse_immediate (&p
, &inst
.operands
[i
].imm
,
6115 0, 255, TRUE
) == FAIL
)
6116 return PARSE_OPERAND_FAIL
;
6118 if (skip_past_char (&p
, '}') == FAIL
)
6120 inst
.error
= _("'}' expected at end of 'option' field");
6121 return PARSE_OPERAND_FAIL
;
6123 if (inst
.operands
[i
].preind
)
6125 inst
.error
= _("cannot combine index with option");
6126 return PARSE_OPERAND_FAIL
;
6129 return PARSE_OPERAND_SUCCESS
;
6133 inst
.operands
[i
].postind
= 1;
6134 inst
.operands
[i
].writeback
= 1;
6136 if (inst
.operands
[i
].preind
)
6138 inst
.error
= _("cannot combine pre- and post-indexing");
6139 return PARSE_OPERAND_FAIL
;
6143 else if (*p
== '-') p
++, inst
.operands
[i
].negative
= 1;
6145 enum arm_reg_type rtype
= REG_TYPE_MQ
;
6146 struct neon_type_el et
;
6147 if (group_type
== GROUP_MVE
6148 && (reg
= arm_typed_reg_parse (&p
, rtype
, &rtype
, &et
)) != FAIL
)
6150 inst
.operands
[i
].immisreg
= 2;
6151 inst
.operands
[i
].imm
= reg
;
6153 else if ((reg
= arm_reg_parse (&p
, REG_TYPE_RN
)) != FAIL
)
6155 /* We might be using the immediate for alignment already. If we
6156 are, OR the register number into the low-order bits. */
6157 if (inst
.operands
[i
].immisalign
)
6158 inst
.operands
[i
].imm
|= reg
;
6160 inst
.operands
[i
].imm
= reg
;
6161 inst
.operands
[i
].immisreg
= 1;
6163 if (skip_past_comma (&p
) == SUCCESS
)
6164 if (parse_shift (&p
, i
, SHIFT_IMMEDIATE
) == FAIL
)
6165 return PARSE_OPERAND_FAIL
;
6171 if (inst
.operands
[i
].negative
)
6173 inst
.operands
[i
].negative
= 0;
6176 if (my_get_expression (&inst
.relocs
[0].exp
, &p
, GE_IMM_PREFIX
))
6177 return PARSE_OPERAND_FAIL
;
6178 /* If the offset is 0, find out if it's a +0 or -0. */
6179 if (inst
.relocs
[0].exp
.X_op
== O_constant
6180 && inst
.relocs
[0].exp
.X_add_number
== 0)
6182 skip_whitespace (q
);
6186 skip_whitespace (q
);
6189 inst
.operands
[i
].negative
= 1;
6195 /* If at this point neither .preind nor .postind is set, we have a
6196 bare [Rn]{!}, which is shorthand for [Rn,#0]{!}. */
6197 if (inst
.operands
[i
].preind
== 0 && inst
.operands
[i
].postind
== 0)
6199 inst
.operands
[i
].preind
= 1;
6200 inst
.relocs
[0].exp
.X_op
= O_constant
;
6201 inst
.relocs
[0].exp
.X_add_number
= 0;
6204 return PARSE_OPERAND_SUCCESS
;
6208 parse_address (char **str
, int i
)
6210 return parse_address_main (str
, i
, 0, GROUP_LDR
) == PARSE_OPERAND_SUCCESS
6214 static parse_operand_result
6215 parse_address_group_reloc (char **str
, int i
, group_reloc_type type
)
6217 return parse_address_main (str
, i
, 1, type
);
6220 /* Parse an operand for a MOVW or MOVT instruction. */
6222 parse_half (char **str
)
6227 skip_past_char (&p
, '#');
6228 if (strncasecmp (p
, ":lower16:", 9) == 0)
6229 inst
.relocs
[0].type
= BFD_RELOC_ARM_MOVW
;
6230 else if (strncasecmp (p
, ":upper16:", 9) == 0)
6231 inst
.relocs
[0].type
= BFD_RELOC_ARM_MOVT
;
6233 if (inst
.relocs
[0].type
!= BFD_RELOC_UNUSED
)
6236 skip_whitespace (p
);
6239 if (my_get_expression (&inst
.relocs
[0].exp
, &p
, GE_NO_PREFIX
))
6242 if (inst
.relocs
[0].type
== BFD_RELOC_UNUSED
)
6244 if (inst
.relocs
[0].exp
.X_op
!= O_constant
)
6246 inst
.error
= _("constant expression expected");
6249 if (inst
.relocs
[0].exp
.X_add_number
< 0
6250 || inst
.relocs
[0].exp
.X_add_number
> 0xffff)
6252 inst
.error
= _("immediate value out of range");
6260 /* Miscellaneous. */
6262 /* Parse a PSR flag operand. The value returned is FAIL on syntax error,
6263 or a bitmask suitable to be or-ed into the ARM msr instruction. */
6265 parse_psr (char **str
, bfd_boolean lhs
)
6268 unsigned long psr_field
;
6269 const struct asm_psr
*psr
;
6271 bfd_boolean is_apsr
= FALSE
;
6272 bfd_boolean m_profile
= ARM_CPU_HAS_FEATURE (selected_cpu
, arm_ext_m
);
6274 /* PR gas/12698: If the user has specified -march=all then m_profile will
6275 be TRUE, but we want to ignore it in this case as we are building for any
6276 CPU type, including non-m variants. */
6277 if (ARM_FEATURE_CORE_EQUAL (selected_cpu
, arm_arch_any
))
6280 /* CPSR's and SPSR's can now be lowercase. This is just a convenience
6281 feature for ease of use and backwards compatibility. */
6283 if (strncasecmp (p
, "SPSR", 4) == 0)
6286 goto unsupported_psr
;
6288 psr_field
= SPSR_BIT
;
6290 else if (strncasecmp (p
, "CPSR", 4) == 0)
6293 goto unsupported_psr
;
6297 else if (strncasecmp (p
, "APSR", 4) == 0)
6299 /* APSR[_<bits>] can be used as a synonym for CPSR[_<flags>] on ARMv7-A
6300 and ARMv7-R architecture CPUs. */
6309 while (ISALNUM (*p
) || *p
== '_');
6311 if (strncasecmp (start
, "iapsr", 5) == 0
6312 || strncasecmp (start
, "eapsr", 5) == 0
6313 || strncasecmp (start
, "xpsr", 4) == 0
6314 || strncasecmp (start
, "psr", 3) == 0)
6315 p
= start
+ strcspn (start
, "rR") + 1;
6317 psr
= (const struct asm_psr
*) hash_find_n (arm_v7m_psr_hsh
, start
,
6323 /* If APSR is being written, a bitfield may be specified. Note that
6324 APSR itself is handled above. */
6325 if (psr
->field
<= 3)
6327 psr_field
= psr
->field
;
6333 /* M-profile MSR instructions have the mask field set to "10", except
6334 *PSR variants which modify APSR, which may use a different mask (and
6335 have been handled already). Do that by setting the PSR_f field
6337 return psr
->field
| (lhs
? PSR_f
: 0);
6340 goto unsupported_psr
;
6346 /* A suffix follows. */
6352 while (ISALNUM (*p
) || *p
== '_');
6356 /* APSR uses a notation for bits, rather than fields. */
6357 unsigned int nzcvq_bits
= 0;
6358 unsigned int g_bit
= 0;
6361 for (bit
= start
; bit
!= p
; bit
++)
6363 switch (TOLOWER (*bit
))
6366 nzcvq_bits
|= (nzcvq_bits
& 0x01) ? 0x20 : 0x01;
6370 nzcvq_bits
|= (nzcvq_bits
& 0x02) ? 0x20 : 0x02;
6374 nzcvq_bits
|= (nzcvq_bits
& 0x04) ? 0x20 : 0x04;
6378 nzcvq_bits
|= (nzcvq_bits
& 0x08) ? 0x20 : 0x08;
6382 nzcvq_bits
|= (nzcvq_bits
& 0x10) ? 0x20 : 0x10;
6386 g_bit
|= (g_bit
& 0x1) ? 0x2 : 0x1;
6390 inst
.error
= _("unexpected bit specified after APSR");
6395 if (nzcvq_bits
== 0x1f)
6400 if (!ARM_CPU_HAS_FEATURE (selected_cpu
, arm_ext_v6_dsp
))
6402 inst
.error
= _("selected processor does not "
6403 "support DSP extension");
6410 if ((nzcvq_bits
& 0x20) != 0
6411 || (nzcvq_bits
!= 0x1f && nzcvq_bits
!= 0)
6412 || (g_bit
& 0x2) != 0)
6414 inst
.error
= _("bad bitmask specified after APSR");
6420 psr
= (const struct asm_psr
*) hash_find_n (arm_psr_hsh
, start
,
6425 psr_field
|= psr
->field
;
6431 goto error
; /* Garbage after "[CS]PSR". */
6433 /* Unadorned APSR is equivalent to APSR_nzcvq/CPSR_f (for writes). This
6434 is deprecated, but allow it anyway. */
6438 as_tsktsk (_("writing to APSR without specifying a bitmask is "
6441 else if (!m_profile
)
6442 /* These bits are never right for M-profile devices: don't set them
6443 (only code paths which read/write APSR reach here). */
6444 psr_field
|= (PSR_c
| PSR_f
);
6450 inst
.error
= _("selected processor does not support requested special "
6451 "purpose register");
6455 inst
.error
= _("flag for {c}psr instruction expected");
6460 parse_sys_vldr_vstr (char **str
)
6469 {"FPSCR", 0x1, 0x0},
6470 {"FPSCR_nzcvqc", 0x2, 0x0},
6473 {"FPCXTNS", 0x6, 0x1},
6474 {"FPCXTS", 0x7, 0x1}
6476 char *op_end
= strchr (*str
, ',');
6477 size_t op_strlen
= op_end
- *str
;
6479 for (i
= 0; i
< sizeof (sysregs
) / sizeof (sysregs
[0]); i
++)
6481 if (!strncmp (*str
, sysregs
[i
].name
, op_strlen
))
6483 val
= sysregs
[i
].regl
| (sysregs
[i
].regh
<< 3);
6492 /* Parse the flags argument to CPSI[ED]. Returns FAIL on error, or a
6493 value suitable for splatting into the AIF field of the instruction. */
6496 parse_cps_flags (char **str
)
6505 case '\0': case ',':
6508 case 'a': case 'A': saw_a_flag
= 1; val
|= 0x4; break;
6509 case 'i': case 'I': saw_a_flag
= 1; val
|= 0x2; break;
6510 case 'f': case 'F': saw_a_flag
= 1; val
|= 0x1; break;
6513 inst
.error
= _("unrecognized CPS flag");
6518 if (saw_a_flag
== 0)
6520 inst
.error
= _("missing CPS flags");
6528 /* Parse an endian specifier ("BE" or "LE", case insensitive);
6529 returns 0 for big-endian, 1 for little-endian, FAIL for an error. */
6532 parse_endian_specifier (char **str
)
6537 if (strncasecmp (s
, "BE", 2))
6539 else if (strncasecmp (s
, "LE", 2))
6543 inst
.error
= _("valid endian specifiers are be or le");
6547 if (ISALNUM (s
[2]) || s
[2] == '_')
6549 inst
.error
= _("valid endian specifiers are be or le");
6554 return little_endian
;
6557 /* Parse a rotation specifier: ROR #0, #8, #16, #24. *val receives a
6558 value suitable for poking into the rotate field of an sxt or sxta
6559 instruction, or FAIL on error. */
6562 parse_ror (char **str
)
6567 if (strncasecmp (s
, "ROR", 3) == 0)
6571 inst
.error
= _("missing rotation field after comma");
6575 if (parse_immediate (&s
, &rot
, 0, 24, FALSE
) == FAIL
)
6580 case 0: *str
= s
; return 0x0;
6581 case 8: *str
= s
; return 0x1;
6582 case 16: *str
= s
; return 0x2;
6583 case 24: *str
= s
; return 0x3;
6586 inst
.error
= _("rotation can only be 0, 8, 16, or 24");
6591 /* Parse a conditional code (from conds[] below). The value returned is in the
6592 range 0 .. 14, or FAIL. */
6594 parse_cond (char **str
)
6597 const struct asm_cond
*c
;
6599 /* Condition codes are always 2 characters, so matching up to
6600 3 characters is sufficient. */
6605 while (ISALPHA (*q
) && n
< 3)
6607 cond
[n
] = TOLOWER (*q
);
6612 c
= (const struct asm_cond
*) hash_find_n (arm_cond_hsh
, cond
, n
);
6615 inst
.error
= _("condition required");
6623 /* Parse an option for a barrier instruction. Returns the encoding for the
6626 parse_barrier (char **str
)
6629 const struct asm_barrier_opt
*o
;
6632 while (ISALPHA (*q
))
6635 o
= (const struct asm_barrier_opt
*) hash_find_n (arm_barrier_opt_hsh
, p
,
6640 if (!mark_feature_used (&o
->arch
))
6647 /* Parse the operands of a table branch instruction. Similar to a memory
6650 parse_tb (char **str
)
6655 if (skip_past_char (&p
, '[') == FAIL
)
6657 inst
.error
= _("'[' expected");
6661 if ((reg
= arm_reg_parse (&p
, REG_TYPE_RN
)) == FAIL
)
6663 inst
.error
= _(reg_expected_msgs
[REG_TYPE_RN
]);
6666 inst
.operands
[0].reg
= reg
;
6668 if (skip_past_comma (&p
) == FAIL
)
6670 inst
.error
= _("',' expected");
6674 if ((reg
= arm_reg_parse (&p
, REG_TYPE_RN
)) == FAIL
)
6676 inst
.error
= _(reg_expected_msgs
[REG_TYPE_RN
]);
6679 inst
.operands
[0].imm
= reg
;
6681 if (skip_past_comma (&p
) == SUCCESS
)
6683 if (parse_shift (&p
, 0, SHIFT_LSL_IMMEDIATE
) == FAIL
)
6685 if (inst
.relocs
[0].exp
.X_add_number
!= 1)
6687 inst
.error
= _("invalid shift");
6690 inst
.operands
[0].shifted
= 1;
6693 if (skip_past_char (&p
, ']') == FAIL
)
6695 inst
.error
= _("']' expected");
6702 /* Parse the operands of a Neon VMOV instruction. See do_neon_mov for more
6703 information on the types the operands can take and how they are encoded.
6704 Up to four operands may be read; this function handles setting the
6705 ".present" field for each read operand itself.
6706 Updates STR and WHICH_OPERAND if parsing is successful and returns SUCCESS,
6707 else returns FAIL. */
6710 parse_neon_mov (char **str
, int *which_operand
)
6712 int i
= *which_operand
, val
;
6713 enum arm_reg_type rtype
;
6715 struct neon_type_el optype
;
6717 if ((val
= parse_scalar (&ptr
, 8, &optype
, REG_TYPE_MQ
)) != FAIL
)
6719 /* Cases 17 or 19. */
6720 inst
.operands
[i
].reg
= val
;
6721 inst
.operands
[i
].isvec
= 1;
6722 inst
.operands
[i
].isscalar
= 2;
6723 inst
.operands
[i
].vectype
= optype
;
6724 inst
.operands
[i
++].present
= 1;
6726 if (skip_past_comma (&ptr
) == FAIL
)
6729 if ((val
= arm_reg_parse (&ptr
, REG_TYPE_RN
)) != FAIL
)
6731 /* Case 17: VMOV<c>.<dt> <Qd[idx]>, <Rt> */
6732 inst
.operands
[i
].reg
= val
;
6733 inst
.operands
[i
].isreg
= 1;
6734 inst
.operands
[i
].present
= 1;
6736 else if ((val
= parse_scalar (&ptr
, 8, &optype
, REG_TYPE_MQ
)) != FAIL
)
6738 /* Case 19: VMOV<c> <Qd[idx]>, <Qd[idx2]>, <Rt>, <Rt2> */
6739 inst
.operands
[i
].reg
= val
;
6740 inst
.operands
[i
].isvec
= 1;
6741 inst
.operands
[i
].isscalar
= 2;
6742 inst
.operands
[i
].vectype
= optype
;
6743 inst
.operands
[i
++].present
= 1;
6745 if (skip_past_comma (&ptr
) == FAIL
)
6748 if ((val
= arm_reg_parse (&ptr
, REG_TYPE_RN
)) == FAIL
)
6751 inst
.operands
[i
].reg
= val
;
6752 inst
.operands
[i
].isreg
= 1;
6753 inst
.operands
[i
++].present
= 1;
6755 if (skip_past_comma (&ptr
) == FAIL
)
6758 if ((val
= arm_reg_parse (&ptr
, REG_TYPE_RN
)) == FAIL
)
6761 inst
.operands
[i
].reg
= val
;
6762 inst
.operands
[i
].isreg
= 1;
6763 inst
.operands
[i
].present
= 1;
6767 first_error (_("expected ARM or MVE vector register"));
6771 else if ((val
= parse_scalar (&ptr
, 8, &optype
, REG_TYPE_VFD
)) != FAIL
)
6773 /* Case 4: VMOV<c><q>.<size> <Dn[x]>, <Rd>. */
6774 inst
.operands
[i
].reg
= val
;
6775 inst
.operands
[i
].isscalar
= 1;
6776 inst
.operands
[i
].vectype
= optype
;
6777 inst
.operands
[i
++].present
= 1;
6779 if (skip_past_comma (&ptr
) == FAIL
)
6782 if ((val
= arm_reg_parse (&ptr
, REG_TYPE_RN
)) == FAIL
)
6785 inst
.operands
[i
].reg
= val
;
6786 inst
.operands
[i
].isreg
= 1;
6787 inst
.operands
[i
].present
= 1;
6789 else if (((val
= arm_typed_reg_parse (&ptr
, REG_TYPE_NSDQ
, &rtype
, &optype
))
6791 || ((val
= arm_typed_reg_parse (&ptr
, REG_TYPE_MQ
, &rtype
, &optype
))
6794 /* Cases 0, 1, 2, 3, 5 (D only). */
6795 if (skip_past_comma (&ptr
) == FAIL
)
6798 inst
.operands
[i
].reg
= val
;
6799 inst
.operands
[i
].isreg
= 1;
6800 inst
.operands
[i
].isquad
= (rtype
== REG_TYPE_NQ
);
6801 inst
.operands
[i
].issingle
= (rtype
== REG_TYPE_VFS
);
6802 inst
.operands
[i
].isvec
= 1;
6803 inst
.operands
[i
].vectype
= optype
;
6804 inst
.operands
[i
++].present
= 1;
6806 if ((val
= arm_reg_parse (&ptr
, REG_TYPE_RN
)) != FAIL
)
6808 /* Case 5: VMOV<c><q> <Dm>, <Rd>, <Rn>.
6809 Case 13: VMOV <Sd>, <Rm> */
6810 inst
.operands
[i
].reg
= val
;
6811 inst
.operands
[i
].isreg
= 1;
6812 inst
.operands
[i
].present
= 1;
6814 if (rtype
== REG_TYPE_NQ
)
6816 first_error (_("can't use Neon quad register here"));
6819 else if (rtype
!= REG_TYPE_VFS
)
6822 if (skip_past_comma (&ptr
) == FAIL
)
6824 if ((val
= arm_reg_parse (&ptr
, REG_TYPE_RN
)) == FAIL
)
6826 inst
.operands
[i
].reg
= val
;
6827 inst
.operands
[i
].isreg
= 1;
6828 inst
.operands
[i
].present
= 1;
6831 else if (((val
= arm_typed_reg_parse (&ptr
, REG_TYPE_NSDQ
, &rtype
,
6833 || ((val
= arm_typed_reg_parse (&ptr
, REG_TYPE_MQ
, &rtype
,
6836 /* Case 0: VMOV<c><q> <Qd>, <Qm>
6837 Case 1: VMOV<c><q> <Dd>, <Dm>
6838 Case 8: VMOV.F32 <Sd>, <Sm>
6839 Case 15: VMOV <Sd>, <Se>, <Rn>, <Rm> */
6841 inst
.operands
[i
].reg
= val
;
6842 inst
.operands
[i
].isreg
= 1;
6843 inst
.operands
[i
].isquad
= (rtype
== REG_TYPE_NQ
);
6844 inst
.operands
[i
].issingle
= (rtype
== REG_TYPE_VFS
);
6845 inst
.operands
[i
].isvec
= 1;
6846 inst
.operands
[i
].vectype
= optype
;
6847 inst
.operands
[i
].present
= 1;
6849 if (skip_past_comma (&ptr
) == SUCCESS
)
6854 if ((val
= arm_reg_parse (&ptr
, REG_TYPE_RN
)) == FAIL
)
6857 inst
.operands
[i
].reg
= val
;
6858 inst
.operands
[i
].isreg
= 1;
6859 inst
.operands
[i
++].present
= 1;
6861 if (skip_past_comma (&ptr
) == FAIL
)
6864 if ((val
= arm_reg_parse (&ptr
, REG_TYPE_RN
)) == FAIL
)
6867 inst
.operands
[i
].reg
= val
;
6868 inst
.operands
[i
].isreg
= 1;
6869 inst
.operands
[i
].present
= 1;
6872 else if (parse_qfloat_immediate (&ptr
, &inst
.operands
[i
].imm
) == SUCCESS
)
6873 /* Case 2: VMOV<c><q>.<dt> <Qd>, #<float-imm>
6874 Case 3: VMOV<c><q>.<dt> <Dd>, #<float-imm>
6875 Case 10: VMOV.F32 <Sd>, #<imm>
6876 Case 11: VMOV.F64 <Dd>, #<imm> */
6877 inst
.operands
[i
].immisfloat
= 1;
6878 else if (parse_big_immediate (&ptr
, i
, NULL
, /*allow_symbol_p=*/FALSE
)
6880 /* Case 2: VMOV<c><q>.<dt> <Qd>, #<imm>
6881 Case 3: VMOV<c><q>.<dt> <Dd>, #<imm> */
6885 first_error (_("expected <Rm> or <Dm> or <Qm> operand"));
6889 else if ((val
= arm_reg_parse (&ptr
, REG_TYPE_RN
)) != FAIL
)
6891 /* Cases 6, 7, 16, 18. */
6892 inst
.operands
[i
].reg
= val
;
6893 inst
.operands
[i
].isreg
= 1;
6894 inst
.operands
[i
++].present
= 1;
6896 if (skip_past_comma (&ptr
) == FAIL
)
6899 if ((val
= parse_scalar (&ptr
, 8, &optype
, REG_TYPE_MQ
)) != FAIL
)
6901 /* Case 18: VMOV<c>.<dt> <Rt>, <Qn[idx]> */
6902 inst
.operands
[i
].reg
= val
;
6903 inst
.operands
[i
].isscalar
= 2;
6904 inst
.operands
[i
].present
= 1;
6905 inst
.operands
[i
].vectype
= optype
;
6907 else if ((val
= parse_scalar (&ptr
, 8, &optype
, REG_TYPE_VFD
)) != FAIL
)
6909 /* Case 6: VMOV<c><q>.<dt> <Rd>, <Dn[x]> */
6910 inst
.operands
[i
].reg
= val
;
6911 inst
.operands
[i
].isscalar
= 1;
6912 inst
.operands
[i
].present
= 1;
6913 inst
.operands
[i
].vectype
= optype
;
6915 else if ((val
= arm_reg_parse (&ptr
, REG_TYPE_RN
)) != FAIL
)
6917 inst
.operands
[i
].reg
= val
;
6918 inst
.operands
[i
].isreg
= 1;
6919 inst
.operands
[i
++].present
= 1;
6921 if (skip_past_comma (&ptr
) == FAIL
)
6924 if ((val
= arm_typed_reg_parse (&ptr
, REG_TYPE_VFSD
, &rtype
, &optype
))
6927 /* Case 7: VMOV<c><q> <Rd>, <Rn>, <Dm> */
6929 inst
.operands
[i
].reg
= val
;
6930 inst
.operands
[i
].isreg
= 1;
6931 inst
.operands
[i
].isvec
= 1;
6932 inst
.operands
[i
].issingle
= (rtype
== REG_TYPE_VFS
);
6933 inst
.operands
[i
].vectype
= optype
;
6934 inst
.operands
[i
].present
= 1;
6936 if (rtype
== REG_TYPE_VFS
)
6940 if (skip_past_comma (&ptr
) == FAIL
)
6942 if ((val
= arm_typed_reg_parse (&ptr
, REG_TYPE_VFS
, NULL
,
6945 first_error (_(reg_expected_msgs
[REG_TYPE_VFS
]));
6948 inst
.operands
[i
].reg
= val
;
6949 inst
.operands
[i
].isreg
= 1;
6950 inst
.operands
[i
].isvec
= 1;
6951 inst
.operands
[i
].issingle
= 1;
6952 inst
.operands
[i
].vectype
= optype
;
6953 inst
.operands
[i
].present
= 1;
6958 if ((val
= parse_scalar (&ptr
, 8, &optype
, REG_TYPE_MQ
))
6961 /* Case 16: VMOV<c> <Rt>, <Rt2>, <Qd[idx]>, <Qd[idx2]> */
6962 inst
.operands
[i
].reg
= val
;
6963 inst
.operands
[i
].isvec
= 1;
6964 inst
.operands
[i
].isscalar
= 2;
6965 inst
.operands
[i
].vectype
= optype
;
6966 inst
.operands
[i
++].present
= 1;
6968 if (skip_past_comma (&ptr
) == FAIL
)
6971 if ((val
= parse_scalar (&ptr
, 8, &optype
, REG_TYPE_MQ
))
6974 first_error (_(reg_expected_msgs
[REG_TYPE_MQ
]));
6977 inst
.operands
[i
].reg
= val
;
6978 inst
.operands
[i
].isvec
= 1;
6979 inst
.operands
[i
].isscalar
= 2;
6980 inst
.operands
[i
].vectype
= optype
;
6981 inst
.operands
[i
].present
= 1;
6985 first_error (_("VFP single, double or MVE vector register"
6991 else if ((val
= arm_typed_reg_parse (&ptr
, REG_TYPE_VFS
, NULL
, &optype
))
6995 inst
.operands
[i
].reg
= val
;
6996 inst
.operands
[i
].isreg
= 1;
6997 inst
.operands
[i
].isvec
= 1;
6998 inst
.operands
[i
].issingle
= 1;
6999 inst
.operands
[i
].vectype
= optype
;
7000 inst
.operands
[i
].present
= 1;
7005 first_error (_("parse error"));
7009 /* Successfully parsed the operands. Update args. */
7015 first_error (_("expected comma"));
7019 first_error (_(reg_expected_msgs
[REG_TYPE_RN
]));
7023 /* Use this macro when the operand constraints are different
7024 for ARM and THUMB (e.g. ldrd). */
7025 #define MIX_ARM_THUMB_OPERANDS(arm_operand, thumb_operand) \
7026 ((arm_operand) | ((thumb_operand) << 16))
7028 /* Matcher codes for parse_operands. */
7029 enum operand_parse_code
7031 OP_stop
, /* end of line */
7033 OP_RR
, /* ARM register */
7034 OP_RRnpc
, /* ARM register, not r15 */
7035 OP_RRnpcsp
, /* ARM register, neither r15 nor r13 (a.k.a. 'BadReg') */
7036 OP_RRnpcb
, /* ARM register, not r15, in square brackets */
7037 OP_RRnpctw
, /* ARM register, not r15 in Thumb-state or with writeback,
7038 optional trailing ! */
7039 OP_RRw
, /* ARM register, not r15, optional trailing ! */
7040 OP_RCP
, /* Coprocessor number */
7041 OP_RCN
, /* Coprocessor register */
7042 OP_RF
, /* FPA register */
7043 OP_RVS
, /* VFP single precision register */
7044 OP_RVD
, /* VFP double precision register (0..15) */
7045 OP_RND
, /* Neon double precision register (0..31) */
7046 OP_RNDMQ
, /* Neon double precision (0..31) or MVE vector register. */
7047 OP_RNDMQR
, /* Neon double precision (0..31), MVE vector or ARM register.
7049 OP_RNQ
, /* Neon quad precision register */
7050 OP_RNQMQ
, /* Neon quad or MVE vector register. */
7051 OP_RVSD
, /* VFP single or double precision register */
7052 OP_RVSD_COND
, /* VFP single, double precision register or condition code. */
7053 OP_RVSDMQ
, /* VFP single, double precision or MVE vector register. */
7054 OP_RNSD
, /* Neon single or double precision register */
7055 OP_RNDQ
, /* Neon double or quad precision register */
7056 OP_RNDQMQ
, /* Neon double, quad or MVE vector register. */
7057 OP_RNDQMQR
, /* Neon double, quad, MVE vector or ARM register. */
7058 OP_RNSDQ
, /* Neon single, double or quad precision register */
7059 OP_RNSC
, /* Neon scalar D[X] */
7060 OP_RVC
, /* VFP control register */
7061 OP_RMF
, /* Maverick F register */
7062 OP_RMD
, /* Maverick D register */
7063 OP_RMFX
, /* Maverick FX register */
7064 OP_RMDX
, /* Maverick DX register */
7065 OP_RMAX
, /* Maverick AX register */
7066 OP_RMDS
, /* Maverick DSPSC register */
7067 OP_RIWR
, /* iWMMXt wR register */
7068 OP_RIWC
, /* iWMMXt wC register */
7069 OP_RIWG
, /* iWMMXt wCG register */
7070 OP_RXA
, /* XScale accumulator register */
7072 OP_RNSDQMQ
, /* Neon single, double or quad register or MVE vector register
7074 OP_RNSDQMQR
, /* Neon single, double or quad register, MVE vector register or
7076 OP_RMQ
, /* MVE vector register. */
7077 OP_RMQRZ
, /* MVE vector or ARM register including ZR. */
7078 OP_RMQRR
, /* MVE vector or ARM register. */
7080 /* New operands for Armv8.1-M Mainline. */
7081 OP_LR
, /* ARM LR register */
7082 OP_RRe
, /* ARM register, only even numbered. */
7083 OP_RRo
, /* ARM register, only odd numbered, not r13 or r15. */
7084 OP_RRnpcsp_I32
, /* ARM register (no BadReg) or literal 1 .. 32 */
7085 OP_RR_ZR
, /* ARM register or ZR but no PC */
7087 OP_REGLST
, /* ARM register list */
7088 OP_CLRMLST
, /* CLRM register list */
7089 OP_VRSLST
, /* VFP single-precision register list */
7090 OP_VRDLST
, /* VFP double-precision register list */
7091 OP_VRSDLST
, /* VFP single or double-precision register list (& quad) */
7092 OP_NRDLST
, /* Neon double-precision register list (d0-d31, qN aliases) */
7093 OP_NSTRLST
, /* Neon element/structure list */
7094 OP_VRSDVLST
, /* VFP single or double-precision register list and VPR */
7095 OP_MSTRLST2
, /* MVE vector list with two elements. */
7096 OP_MSTRLST4
, /* MVE vector list with four elements. */
7098 OP_RNDQ_I0
, /* Neon D or Q reg, or immediate zero. */
7099 OP_RVSD_I0
, /* VFP S or D reg, or immediate zero. */
7100 OP_RSVD_FI0
, /* VFP S or D reg, or floating point immediate zero. */
7101 OP_RSVDMQ_FI0
, /* VFP S, D, MVE vector register or floating point immediate
7103 OP_RR_RNSC
, /* ARM reg or Neon scalar. */
7104 OP_RNSD_RNSC
, /* Neon S or D reg, or Neon scalar. */
7105 OP_RNSDQ_RNSC
, /* Vector S, D or Q reg, or Neon scalar. */
7106 OP_RNSDQ_RNSC_MQ
, /* Vector S, D or Q reg, Neon scalar or MVE vector register.
7108 OP_RNSDQ_RNSC_MQ_RR
, /* Vector S, D or Q reg, or MVE vector reg , or Neon
7109 scalar, or ARM register. */
7110 OP_RNDQ_RNSC
, /* Neon D or Q reg, or Neon scalar. */
7111 OP_RNDQ_RNSC_RR
, /* Neon D or Q reg, Neon scalar, or ARM register. */
7112 OP_RNDQMQ_RNSC_RR
, /* Neon D or Q reg, Neon scalar, MVE vector or ARM
7114 OP_RNDQMQ_RNSC
, /* Neon D, Q or MVE vector reg, or Neon scalar. */
7115 OP_RND_RNSC
, /* Neon D reg, or Neon scalar. */
7116 OP_VMOV
, /* Neon VMOV operands. */
7117 OP_RNDQ_Ibig
, /* Neon D or Q reg, or big immediate for logic and VMVN. */
7118 /* Neon D, Q or MVE vector register, or big immediate for logic and VMVN. */
7120 OP_RNDQ_I63b
, /* Neon D or Q reg, or immediate for shift. */
7121 OP_RNDQMQ_I63b_RR
, /* Neon D or Q reg, immediate for shift, MVE vector or
7123 OP_RIWR_I32z
, /* iWMMXt wR register, or immediate 0 .. 32 for iWMMXt2. */
7124 OP_VLDR
, /* VLDR operand. */
7126 OP_I0
, /* immediate zero */
7127 OP_I7
, /* immediate value 0 .. 7 */
7128 OP_I15
, /* 0 .. 15 */
7129 OP_I16
, /* 1 .. 16 */
7130 OP_I16z
, /* 0 .. 16 */
7131 OP_I31
, /* 0 .. 31 */
7132 OP_I31w
, /* 0 .. 31, optional trailing ! */
7133 OP_I32
, /* 1 .. 32 */
7134 OP_I32z
, /* 0 .. 32 */
7135 OP_I48_I64
, /* 48 or 64 */
7136 OP_I63
, /* 0 .. 63 */
7137 OP_I63s
, /* -64 .. 63 */
7138 OP_I64
, /* 1 .. 64 */
7139 OP_I64z
, /* 0 .. 64 */
7140 OP_I255
, /* 0 .. 255 */
7142 OP_I4b
, /* immediate, prefix optional, 1 .. 4 */
7143 OP_I7b
, /* 0 .. 7 */
7144 OP_I15b
, /* 0 .. 15 */
7145 OP_I31b
, /* 0 .. 31 */
7147 OP_SH
, /* shifter operand */
7148 OP_SHG
, /* shifter operand with possible group relocation */
7149 OP_ADDR
, /* Memory address expression (any mode) */
7150 OP_ADDRMVE
, /* Memory address expression for MVE's VSTR/VLDR. */
7151 OP_ADDRGLDR
, /* Mem addr expr (any mode) with possible LDR group reloc */
7152 OP_ADDRGLDRS
, /* Mem addr expr (any mode) with possible LDRS group reloc */
7153 OP_ADDRGLDC
, /* Mem addr expr (any mode) with possible LDC group reloc */
7154 OP_EXP
, /* arbitrary expression */
7155 OP_EXPi
, /* same, with optional immediate prefix */
7156 OP_EXPr
, /* same, with optional relocation suffix */
7157 OP_EXPs
, /* same, with optional non-first operand relocation suffix */
7158 OP_HALF
, /* 0 .. 65535 or low/high reloc. */
7159 OP_IROT1
, /* VCADD rotate immediate: 90, 270. */
7160 OP_IROT2
, /* VCMLA rotate immediate: 0, 90, 180, 270. */
7162 OP_CPSF
, /* CPS flags */
7163 OP_ENDI
, /* Endianness specifier */
7164 OP_wPSR
, /* CPSR/SPSR/APSR mask for msr (writing). */
7165 OP_rPSR
, /* CPSR/SPSR/APSR mask for msr (reading). */
7166 OP_COND
, /* conditional code */
7167 OP_TB
, /* Table branch. */
7169 OP_APSR_RR
, /* ARM register or "APSR_nzcv". */
7171 OP_RRnpc_I0
, /* ARM register or literal 0 */
7172 OP_RR_EXr
, /* ARM register or expression with opt. reloc stuff. */
7173 OP_RR_EXi
, /* ARM register or expression with imm prefix */
7174 OP_RF_IF
, /* FPA register or immediate */
7175 OP_RIWR_RIWC
, /* iWMMXt R or C reg */
7176 OP_RIWC_RIWG
, /* iWMMXt wC or wCG reg */
7178 /* Optional operands. */
7179 OP_oI7b
, /* immediate, prefix optional, 0 .. 7 */
7180 OP_oI31b
, /* 0 .. 31 */
7181 OP_oI32b
, /* 1 .. 32 */
7182 OP_oI32z
, /* 0 .. 32 */
7183 OP_oIffffb
, /* 0 .. 65535 */
7184 OP_oI255c
, /* curly-brace enclosed, 0 .. 255 */
7186 OP_oRR
, /* ARM register */
7187 OP_oLR
, /* ARM LR register */
7188 OP_oRRnpc
, /* ARM register, not the PC */
7189 OP_oRRnpcsp
, /* ARM register, neither the PC nor the SP (a.k.a. BadReg) */
7190 OP_oRRw
, /* ARM register, not r15, optional trailing ! */
7191 OP_oRND
, /* Optional Neon double precision register */
7192 OP_oRNQ
, /* Optional Neon quad precision register */
7193 OP_oRNDQMQ
, /* Optional Neon double, quad or MVE vector register. */
7194 OP_oRNDQ
, /* Optional Neon double or quad precision register */
7195 OP_oRNSDQ
, /* Optional single, double or quad precision vector register */
7196 OP_oRNSDQMQ
, /* Optional single, double or quad register or MVE vector
7198 OP_oSHll
, /* LSL immediate */
7199 OP_oSHar
, /* ASR immediate */
7200 OP_oSHllar
, /* LSL or ASR immediate */
7201 OP_oROR
, /* ROR 0/8/16/24 */
7202 OP_oBARRIER_I15
, /* Option argument for a barrier instruction. */
7204 OP_oRMQRZ
, /* optional MVE vector or ARM register including ZR. */
7206 /* Some pre-defined mixed (ARM/THUMB) operands. */
7207 OP_RR_npcsp
= MIX_ARM_THUMB_OPERANDS (OP_RR
, OP_RRnpcsp
),
7208 OP_RRnpc_npcsp
= MIX_ARM_THUMB_OPERANDS (OP_RRnpc
, OP_RRnpcsp
),
7209 OP_oRRnpc_npcsp
= MIX_ARM_THUMB_OPERANDS (OP_oRRnpc
, OP_oRRnpcsp
),
7211 OP_FIRST_OPTIONAL
= OP_oI7b
7214 /* Generic instruction operand parser. This does no encoding and no
7215 semantic validation; it merely squirrels values away in the inst
7216 structure. Returns SUCCESS or FAIL depending on whether the
7217 specified grammar matched. */
7219 parse_operands (char *str
, const unsigned int *pattern
, bfd_boolean thumb
)
7221 unsigned const int *upat
= pattern
;
7222 char *backtrack_pos
= 0;
7223 const char *backtrack_error
= 0;
7224 int i
, val
= 0, backtrack_index
= 0;
7225 enum arm_reg_type rtype
;
7226 parse_operand_result result
;
7227 unsigned int op_parse_code
;
7228 bfd_boolean partial_match
;
7230 #define po_char_or_fail(chr) \
7233 if (skip_past_char (&str, chr) == FAIL) \
7238 #define po_reg_or_fail(regtype) \
7241 val = arm_typed_reg_parse (& str, regtype, & rtype, \
7242 & inst.operands[i].vectype); \
7245 first_error (_(reg_expected_msgs[regtype])); \
7248 inst.operands[i].reg = val; \
7249 inst.operands[i].isreg = 1; \
7250 inst.operands[i].isquad = (rtype == REG_TYPE_NQ); \
7251 inst.operands[i].issingle = (rtype == REG_TYPE_VFS); \
7252 inst.operands[i].isvec = (rtype == REG_TYPE_VFS \
7253 || rtype == REG_TYPE_VFD \
7254 || rtype == REG_TYPE_NQ); \
7255 inst.operands[i].iszr = (rtype == REG_TYPE_ZR); \
7259 #define po_reg_or_goto(regtype, label) \
7262 val = arm_typed_reg_parse (& str, regtype, & rtype, \
7263 & inst.operands[i].vectype); \
7267 inst.operands[i].reg = val; \
7268 inst.operands[i].isreg = 1; \
7269 inst.operands[i].isquad = (rtype == REG_TYPE_NQ); \
7270 inst.operands[i].issingle = (rtype == REG_TYPE_VFS); \
7271 inst.operands[i].isvec = (rtype == REG_TYPE_VFS \
7272 || rtype == REG_TYPE_VFD \
7273 || rtype == REG_TYPE_NQ); \
7274 inst.operands[i].iszr = (rtype == REG_TYPE_ZR); \
7278 #define po_imm_or_fail(min, max, popt) \
7281 if (parse_immediate (&str, &val, min, max, popt) == FAIL) \
7283 inst.operands[i].imm = val; \
7287 #define po_imm1_or_imm2_or_fail(imm1, imm2, popt) \
7291 my_get_expression (&exp, &str, popt); \
7292 if (exp.X_op != O_constant) \
7294 inst.error = _("constant expression required"); \
7297 if (exp.X_add_number != imm1 && exp.X_add_number != imm2) \
7299 inst.error = _("immediate value 48 or 64 expected"); \
7302 inst.operands[i].imm = exp.X_add_number; \
7306 #define po_scalar_or_goto(elsz, label, reg_type) \
7309 val = parse_scalar (& str, elsz, & inst.operands[i].vectype, \
7313 inst.operands[i].reg = val; \
7314 inst.operands[i].isscalar = 1; \
7318 #define po_misc_or_fail(expr) \
7326 #define po_misc_or_fail_no_backtrack(expr) \
7330 if (result == PARSE_OPERAND_FAIL_NO_BACKTRACK) \
7331 backtrack_pos = 0; \
7332 if (result != PARSE_OPERAND_SUCCESS) \
7337 #define po_barrier_or_imm(str) \
7340 val = parse_barrier (&str); \
7341 if (val == FAIL && ! ISALPHA (*str)) \
7344 /* ISB can only take SY as an option. */ \
7345 || ((inst.instruction & 0xf0) == 0x60 \
7348 inst.error = _("invalid barrier type"); \
7349 backtrack_pos = 0; \
7355 skip_whitespace (str
);
7357 for (i
= 0; upat
[i
] != OP_stop
; i
++)
7359 op_parse_code
= upat
[i
];
7360 if (op_parse_code
>= 1<<16)
7361 op_parse_code
= thumb
? (op_parse_code
>> 16)
7362 : (op_parse_code
& ((1<<16)-1));
7364 if (op_parse_code
>= OP_FIRST_OPTIONAL
)
7366 /* Remember where we are in case we need to backtrack. */
7367 backtrack_pos
= str
;
7368 backtrack_error
= inst
.error
;
7369 backtrack_index
= i
;
7372 if (i
> 0 && (i
> 1 || inst
.operands
[0].present
))
7373 po_char_or_fail (',');
7375 switch (op_parse_code
)
7387 case OP_RR
: po_reg_or_fail (REG_TYPE_RN
); break;
7388 case OP_RCP
: po_reg_or_fail (REG_TYPE_CP
); break;
7389 case OP_RCN
: po_reg_or_fail (REG_TYPE_CN
); break;
7390 case OP_RF
: po_reg_or_fail (REG_TYPE_FN
); break;
7391 case OP_RVS
: po_reg_or_fail (REG_TYPE_VFS
); break;
7392 case OP_RVD
: po_reg_or_fail (REG_TYPE_VFD
); break;
7395 po_reg_or_goto (REG_TYPE_RN
, try_rndmq
);
7399 po_reg_or_goto (REG_TYPE_MQ
, try_rnd
);
7402 case OP_RND
: po_reg_or_fail (REG_TYPE_VFD
); break;
7404 po_reg_or_goto (REG_TYPE_VFC
, coproc_reg
);
7406 /* Also accept generic coprocessor regs for unknown registers. */
7408 po_reg_or_goto (REG_TYPE_CN
, vpr_po
);
7410 /* Also accept P0 or p0 for VPR.P0. Since P0 is already an
7411 existing register with a value of 0, this seems like the
7412 best way to parse P0. */
7414 if (strncasecmp (str
, "P0", 2) == 0)
7417 inst
.operands
[i
].isreg
= 1;
7418 inst
.operands
[i
].reg
= 13;
7423 case OP_RMF
: po_reg_or_fail (REG_TYPE_MVF
); break;
7424 case OP_RMD
: po_reg_or_fail (REG_TYPE_MVD
); break;
7425 case OP_RMFX
: po_reg_or_fail (REG_TYPE_MVFX
); break;
7426 case OP_RMDX
: po_reg_or_fail (REG_TYPE_MVDX
); break;
7427 case OP_RMAX
: po_reg_or_fail (REG_TYPE_MVAX
); break;
7428 case OP_RMDS
: po_reg_or_fail (REG_TYPE_DSPSC
); break;
7429 case OP_RIWR
: po_reg_or_fail (REG_TYPE_MMXWR
); break;
7430 case OP_RIWC
: po_reg_or_fail (REG_TYPE_MMXWC
); break;
7431 case OP_RIWG
: po_reg_or_fail (REG_TYPE_MMXWCG
); break;
7432 case OP_RXA
: po_reg_or_fail (REG_TYPE_XSCALE
); break;
7435 po_reg_or_goto (REG_TYPE_MQ
, try_nq
);
7438 case OP_RNQ
: po_reg_or_fail (REG_TYPE_NQ
); break;
7439 case OP_RNSD
: po_reg_or_fail (REG_TYPE_NSD
); break;
7441 po_reg_or_goto (REG_TYPE_RN
, try_rndqmq
);
7446 po_reg_or_goto (REG_TYPE_MQ
, try_rndq
);
7450 case OP_RNDQ
: po_reg_or_fail (REG_TYPE_NDQ
); break;
7452 po_reg_or_goto (REG_TYPE_MQ
, try_rvsd
);
7455 case OP_RVSD
: po_reg_or_fail (REG_TYPE_VFSD
); break;
7457 po_reg_or_goto (REG_TYPE_VFSD
, try_cond
);
7460 case OP_RNSDQ
: po_reg_or_fail (REG_TYPE_NSDQ
); break;
7462 po_reg_or_goto (REG_TYPE_RN
, try_mq
);
7467 po_reg_or_goto (REG_TYPE_MQ
, try_nsdq2
);
7470 po_reg_or_fail (REG_TYPE_NSDQ
);
7474 po_reg_or_goto (REG_TYPE_RN
, try_rmq
);
7478 po_reg_or_fail (REG_TYPE_MQ
);
7480 /* Neon scalar. Using an element size of 8 means that some invalid
7481 scalars are accepted here, so deal with those in later code. */
7482 case OP_RNSC
: po_scalar_or_goto (8, failure
, REG_TYPE_VFD
); break;
7486 po_reg_or_goto (REG_TYPE_NDQ
, try_imm0
);
7489 po_imm_or_fail (0, 0, TRUE
);
7494 po_reg_or_goto (REG_TYPE_VFSD
, try_imm0
);
7498 po_reg_or_goto (REG_TYPE_MQ
, try_rsvd_fi0
);
7503 po_reg_or_goto (REG_TYPE_VFSD
, try_ifimm0
);
7506 if (parse_ifimm_zero (&str
))
7507 inst
.operands
[i
].imm
= 0;
7511 = _("only floating point zero is allowed as immediate value");
7519 po_scalar_or_goto (8, try_rr
, REG_TYPE_VFD
);
7522 po_reg_or_fail (REG_TYPE_RN
);
7526 case OP_RNSDQ_RNSC_MQ_RR
:
7527 po_reg_or_goto (REG_TYPE_RN
, try_rnsdq_rnsc_mq
);
7530 case OP_RNSDQ_RNSC_MQ
:
7531 po_reg_or_goto (REG_TYPE_MQ
, try_rnsdq_rnsc
);
7536 po_scalar_or_goto (8, try_nsdq
, REG_TYPE_VFD
);
7540 po_reg_or_fail (REG_TYPE_NSDQ
);
7547 po_scalar_or_goto (8, try_s_scalar
, REG_TYPE_VFD
);
7550 po_scalar_or_goto (4, try_nsd
, REG_TYPE_VFS
);
7553 po_reg_or_fail (REG_TYPE_NSD
);
7557 case OP_RNDQMQ_RNSC_RR
:
7558 po_reg_or_goto (REG_TYPE_MQ
, try_rndq_rnsc_rr
);
7561 case OP_RNDQ_RNSC_RR
:
7562 po_reg_or_goto (REG_TYPE_RN
, try_rndq_rnsc
);
7564 case OP_RNDQMQ_RNSC
:
7565 po_reg_or_goto (REG_TYPE_MQ
, try_rndq_rnsc
);
7570 po_scalar_or_goto (8, try_ndq
, REG_TYPE_VFD
);
7573 po_reg_or_fail (REG_TYPE_NDQ
);
7579 po_scalar_or_goto (8, try_vfd
, REG_TYPE_VFD
);
7582 po_reg_or_fail (REG_TYPE_VFD
);
7587 /* WARNING: parse_neon_mov can move the operand counter, i. If we're
7588 not careful then bad things might happen. */
7589 po_misc_or_fail (parse_neon_mov (&str
, &i
) == FAIL
);
7592 case OP_RNDQMQ_Ibig
:
7593 po_reg_or_goto (REG_TYPE_MQ
, try_rndq_ibig
);
7598 po_reg_or_goto (REG_TYPE_NDQ
, try_immbig
);
7601 /* There's a possibility of getting a 64-bit immediate here, so
7602 we need special handling. */
7603 if (parse_big_immediate (&str
, i
, NULL
, /*allow_symbol_p=*/FALSE
)
7606 inst
.error
= _("immediate value is out of range");
7612 case OP_RNDQMQ_I63b_RR
:
7613 po_reg_or_goto (REG_TYPE_MQ
, try_rndq_i63b_rr
);
7616 po_reg_or_goto (REG_TYPE_RN
, try_rndq_i63b
);
7621 po_reg_or_goto (REG_TYPE_NDQ
, try_shimm
);
7624 po_imm_or_fail (0, 63, TRUE
);
7629 po_char_or_fail ('[');
7630 po_reg_or_fail (REG_TYPE_RN
);
7631 po_char_or_fail (']');
7637 po_reg_or_fail (REG_TYPE_RN
);
7638 if (skip_past_char (&str
, '!') == SUCCESS
)
7639 inst
.operands
[i
].writeback
= 1;
7643 case OP_I7
: po_imm_or_fail ( 0, 7, FALSE
); break;
7644 case OP_I15
: po_imm_or_fail ( 0, 15, FALSE
); break;
7645 case OP_I16
: po_imm_or_fail ( 1, 16, FALSE
); break;
7646 case OP_I16z
: po_imm_or_fail ( 0, 16, FALSE
); break;
7647 case OP_I31
: po_imm_or_fail ( 0, 31, FALSE
); break;
7648 case OP_I32
: po_imm_or_fail ( 1, 32, FALSE
); break;
7649 case OP_I32z
: po_imm_or_fail ( 0, 32, FALSE
); break;
7650 case OP_I48_I64
: po_imm1_or_imm2_or_fail (48, 64, FALSE
); break;
7651 case OP_I63s
: po_imm_or_fail (-64, 63, FALSE
); break;
7652 case OP_I63
: po_imm_or_fail ( 0, 63, FALSE
); break;
7653 case OP_I64
: po_imm_or_fail ( 1, 64, FALSE
); break;
7654 case OP_I64z
: po_imm_or_fail ( 0, 64, FALSE
); break;
7655 case OP_I255
: po_imm_or_fail ( 0, 255, FALSE
); break;
7657 case OP_I4b
: po_imm_or_fail ( 1, 4, TRUE
); break;
7659 case OP_I7b
: po_imm_or_fail ( 0, 7, TRUE
); break;
7660 case OP_I15b
: po_imm_or_fail ( 0, 15, TRUE
); break;
7662 case OP_I31b
: po_imm_or_fail ( 0, 31, TRUE
); break;
7663 case OP_oI32b
: po_imm_or_fail ( 1, 32, TRUE
); break;
7664 case OP_oI32z
: po_imm_or_fail ( 0, 32, TRUE
); break;
7665 case OP_oIffffb
: po_imm_or_fail ( 0, 0xffff, TRUE
); break;
7667 /* Immediate variants */
7669 po_char_or_fail ('{');
7670 po_imm_or_fail (0, 255, TRUE
);
7671 po_char_or_fail ('}');
7675 /* The expression parser chokes on a trailing !, so we have
7676 to find it first and zap it. */
7679 while (*s
&& *s
!= ',')
7684 inst
.operands
[i
].writeback
= 1;
7686 po_imm_or_fail (0, 31, TRUE
);
7694 po_misc_or_fail (my_get_expression (&inst
.relocs
[0].exp
, &str
,
7699 po_misc_or_fail (my_get_expression (&inst
.relocs
[0].exp
, &str
,
7704 po_misc_or_fail (my_get_expression (&inst
.relocs
[0].exp
, &str
,
7706 if (inst
.relocs
[0].exp
.X_op
== O_symbol
)
7708 val
= parse_reloc (&str
);
7711 inst
.error
= _("unrecognized relocation suffix");
7714 else if (val
!= BFD_RELOC_UNUSED
)
7716 inst
.operands
[i
].imm
= val
;
7717 inst
.operands
[i
].hasreloc
= 1;
7723 po_misc_or_fail (my_get_expression (&inst
.relocs
[i
].exp
, &str
,
7725 if (inst
.relocs
[i
].exp
.X_op
== O_symbol
)
7727 inst
.operands
[i
].hasreloc
= 1;
7729 else if (inst
.relocs
[i
].exp
.X_op
== O_constant
)
7731 inst
.operands
[i
].imm
= inst
.relocs
[i
].exp
.X_add_number
;
7732 inst
.operands
[i
].hasreloc
= 0;
7736 /* Operand for MOVW or MOVT. */
7738 po_misc_or_fail (parse_half (&str
));
7741 /* Register or expression. */
7742 case OP_RR_EXr
: po_reg_or_goto (REG_TYPE_RN
, EXPr
); break;
7743 case OP_RR_EXi
: po_reg_or_goto (REG_TYPE_RN
, EXPi
); break;
7745 /* Register or immediate. */
7746 case OP_RRnpc_I0
: po_reg_or_goto (REG_TYPE_RN
, I0
); break;
7747 I0
: po_imm_or_fail (0, 0, FALSE
); break;
7749 case OP_RRnpcsp_I32
: po_reg_or_goto (REG_TYPE_RN
, I32
); break;
7750 I32
: po_imm_or_fail (1, 32, FALSE
); break;
7752 case OP_RF_IF
: po_reg_or_goto (REG_TYPE_FN
, IF
); break;
7754 if (!is_immediate_prefix (*str
))
7757 val
= parse_fpa_immediate (&str
);
7760 /* FPA immediates are encoded as registers 8-15.
7761 parse_fpa_immediate has already applied the offset. */
7762 inst
.operands
[i
].reg
= val
;
7763 inst
.operands
[i
].isreg
= 1;
7766 case OP_RIWR_I32z
: po_reg_or_goto (REG_TYPE_MMXWR
, I32z
); break;
7767 I32z
: po_imm_or_fail (0, 32, FALSE
); break;
7769 /* Two kinds of register. */
7772 struct reg_entry
*rege
= arm_reg_parse_multi (&str
);
7774 || (rege
->type
!= REG_TYPE_MMXWR
7775 && rege
->type
!= REG_TYPE_MMXWC
7776 && rege
->type
!= REG_TYPE_MMXWCG
))
7778 inst
.error
= _("iWMMXt data or control register expected");
7781 inst
.operands
[i
].reg
= rege
->number
;
7782 inst
.operands
[i
].isreg
= (rege
->type
== REG_TYPE_MMXWR
);
7788 struct reg_entry
*rege
= arm_reg_parse_multi (&str
);
7790 || (rege
->type
!= REG_TYPE_MMXWC
7791 && rege
->type
!= REG_TYPE_MMXWCG
))
7793 inst
.error
= _("iWMMXt control register expected");
7796 inst
.operands
[i
].reg
= rege
->number
;
7797 inst
.operands
[i
].isreg
= 1;
7802 case OP_CPSF
: val
= parse_cps_flags (&str
); break;
7803 case OP_ENDI
: val
= parse_endian_specifier (&str
); break;
7804 case OP_oROR
: val
= parse_ror (&str
); break;
7806 case OP_COND
: val
= parse_cond (&str
); break;
7807 case OP_oBARRIER_I15
:
7808 po_barrier_or_imm (str
); break;
7810 if (parse_immediate (&str
, &val
, 0, 15, TRUE
) == FAIL
)
7816 po_reg_or_goto (REG_TYPE_RNB
, try_psr
);
7817 if (!ARM_CPU_HAS_FEATURE (cpu_variant
, arm_ext_virt
))
7819 inst
.error
= _("Banked registers are not available with this "
7825 val
= parse_psr (&str
, op_parse_code
== OP_wPSR
);
7829 po_reg_or_goto (REG_TYPE_VFSD
, try_sysreg
);
7832 val
= parse_sys_vldr_vstr (&str
);
7836 po_reg_or_goto (REG_TYPE_RN
, try_apsr
);
7839 /* Parse "APSR_nvzc" operand (for FMSTAT-equivalent MRS
7841 if (strncasecmp (str
, "APSR_", 5) == 0)
7848 case 'c': found
= (found
& 1) ? 16 : found
| 1; break;
7849 case 'n': found
= (found
& 2) ? 16 : found
| 2; break;
7850 case 'z': found
= (found
& 4) ? 16 : found
| 4; break;
7851 case 'v': found
= (found
& 8) ? 16 : found
| 8; break;
7852 default: found
= 16;
7856 inst
.operands
[i
].isvec
= 1;
7857 /* APSR_nzcv is encoded in instructions as if it were the REG_PC. */
7858 inst
.operands
[i
].reg
= REG_PC
;
7865 po_misc_or_fail (parse_tb (&str
));
7868 /* Register lists. */
7870 val
= parse_reg_list (&str
, REGLIST_RN
);
7873 inst
.operands
[i
].writeback
= 1;
7879 val
= parse_reg_list (&str
, REGLIST_CLRM
);
7883 val
= parse_vfp_reg_list (&str
, &inst
.operands
[i
].reg
, REGLIST_VFP_S
,
7888 val
= parse_vfp_reg_list (&str
, &inst
.operands
[i
].reg
, REGLIST_VFP_D
,
7893 /* Allow Q registers too. */
7894 val
= parse_vfp_reg_list (&str
, &inst
.operands
[i
].reg
,
7895 REGLIST_NEON_D
, &partial_match
);
7899 val
= parse_vfp_reg_list (&str
, &inst
.operands
[i
].reg
,
7900 REGLIST_VFP_S
, &partial_match
);
7901 inst
.operands
[i
].issingle
= 1;
7906 val
= parse_vfp_reg_list (&str
, &inst
.operands
[i
].reg
,
7907 REGLIST_VFP_D_VPR
, &partial_match
);
7908 if (val
== FAIL
&& !partial_match
)
7911 val
= parse_vfp_reg_list (&str
, &inst
.operands
[i
].reg
,
7912 REGLIST_VFP_S_VPR
, &partial_match
);
7913 inst
.operands
[i
].issingle
= 1;
7918 val
= parse_vfp_reg_list (&str
, &inst
.operands
[i
].reg
,
7919 REGLIST_NEON_D
, &partial_match
);
7924 val
= parse_neon_el_struct_list (&str
, &inst
.operands
[i
].reg
,
7925 1, &inst
.operands
[i
].vectype
);
7926 if (val
!= (((op_parse_code
== OP_MSTRLST2
) ? 3 : 7) << 5 | 0xe))
7930 val
= parse_neon_el_struct_list (&str
, &inst
.operands
[i
].reg
,
7931 0, &inst
.operands
[i
].vectype
);
7934 /* Addressing modes */
7936 po_misc_or_fail (parse_address_group_reloc (&str
, i
, GROUP_MVE
));
7940 po_misc_or_fail (parse_address (&str
, i
));
7944 po_misc_or_fail_no_backtrack (
7945 parse_address_group_reloc (&str
, i
, GROUP_LDR
));
7949 po_misc_or_fail_no_backtrack (
7950 parse_address_group_reloc (&str
, i
, GROUP_LDRS
));
7954 po_misc_or_fail_no_backtrack (
7955 parse_address_group_reloc (&str
, i
, GROUP_LDC
));
7959 po_misc_or_fail (parse_shifter_operand (&str
, i
));
7963 po_misc_or_fail_no_backtrack (
7964 parse_shifter_operand_group_reloc (&str
, i
));
7968 po_misc_or_fail (parse_shift (&str
, i
, SHIFT_LSL_IMMEDIATE
));
7972 po_misc_or_fail (parse_shift (&str
, i
, SHIFT_ASR_IMMEDIATE
));
7976 po_misc_or_fail (parse_shift (&str
, i
, SHIFT_LSL_OR_ASR_IMMEDIATE
));
7981 po_reg_or_goto (REG_TYPE_MQ
, try_rr_zr
);
7986 po_reg_or_goto (REG_TYPE_RN
, ZR
);
7989 po_reg_or_fail (REG_TYPE_ZR
);
7993 as_fatal (_("unhandled operand code %d"), op_parse_code
);
7996 /* Various value-based sanity checks and shared operations. We
7997 do not signal immediate failures for the register constraints;
7998 this allows a syntax error to take precedence. */
7999 switch (op_parse_code
)
8007 if (inst
.operands
[i
].isreg
&& inst
.operands
[i
].reg
== REG_PC
)
8008 inst
.error
= BAD_PC
;
8013 case OP_RRnpcsp_I32
:
8014 if (inst
.operands
[i
].isreg
)
8016 if (inst
.operands
[i
].reg
== REG_PC
)
8017 inst
.error
= BAD_PC
;
8018 else if (inst
.operands
[i
].reg
== REG_SP
8019 /* The restriction on Rd/Rt/Rt2 on Thumb mode has been
8020 relaxed since ARMv8-A. */
8021 && !ARM_CPU_HAS_FEATURE (cpu_variant
, arm_ext_v8
))
8024 inst
.error
= BAD_SP
;
8030 if (inst
.operands
[i
].isreg
8031 && inst
.operands
[i
].reg
== REG_PC
8032 && (inst
.operands
[i
].writeback
|| thumb
))
8033 inst
.error
= BAD_PC
;
8038 if (inst
.operands
[i
].isreg
)
8048 case OP_oBARRIER_I15
:
8061 inst
.operands
[i
].imm
= val
;
8066 if (inst
.operands
[i
].reg
!= REG_LR
)
8067 inst
.error
= _("operand must be LR register");
8073 if (!inst
.operands
[i
].iszr
&& inst
.operands
[i
].reg
== REG_PC
)
8074 inst
.error
= BAD_PC
;
8078 if (inst
.operands
[i
].isreg
8079 && (inst
.operands
[i
].reg
& 0x00000001) != 0)
8080 inst
.error
= BAD_ODD
;
8084 if (inst
.operands
[i
].isreg
)
8086 if ((inst
.operands
[i
].reg
& 0x00000001) != 1)
8087 inst
.error
= BAD_EVEN
;
8088 else if (inst
.operands
[i
].reg
== REG_SP
)
8089 as_tsktsk (MVE_BAD_SP
);
8090 else if (inst
.operands
[i
].reg
== REG_PC
)
8091 inst
.error
= BAD_PC
;
8099 /* If we get here, this operand was successfully parsed. */
8100 inst
.operands
[i
].present
= 1;
8104 inst
.error
= BAD_ARGS
;
8109 /* The parse routine should already have set inst.error, but set a
8110 default here just in case. */
8112 inst
.error
= BAD_SYNTAX
;
8116 /* Do not backtrack over a trailing optional argument that
8117 absorbed some text. We will only fail again, with the
8118 'garbage following instruction' error message, which is
8119 probably less helpful than the current one. */
8120 if (backtrack_index
== i
&& backtrack_pos
!= str
8121 && upat
[i
+1] == OP_stop
)
8124 inst
.error
= BAD_SYNTAX
;
8128 /* Try again, skipping the optional argument at backtrack_pos. */
8129 str
= backtrack_pos
;
8130 inst
.error
= backtrack_error
;
8131 inst
.operands
[backtrack_index
].present
= 0;
8132 i
= backtrack_index
;
8136 /* Check that we have parsed all the arguments. */
8137 if (*str
!= '\0' && !inst
.error
)
8138 inst
.error
= _("garbage following instruction");
8140 return inst
.error
? FAIL
: SUCCESS
;
8143 #undef po_char_or_fail
8144 #undef po_reg_or_fail
8145 #undef po_reg_or_goto
8146 #undef po_imm_or_fail
8147 #undef po_scalar_or_fail
8148 #undef po_barrier_or_imm
8150 /* Shorthand macro for instruction encoding functions issuing errors. */
8151 #define constraint(expr, err) \
8162 /* Reject "bad registers" for Thumb-2 instructions. Many Thumb-2
8163 instructions are unpredictable if these registers are used. This
8164 is the BadReg predicate in ARM's Thumb-2 documentation.
8166 Before ARMv8-A, REG_PC and REG_SP were not allowed in quite a few
8167 places, while the restriction on REG_SP was relaxed since ARMv8-A. */
8168 #define reject_bad_reg(reg) \
8170 if (reg == REG_PC) \
8172 inst.error = BAD_PC; \
8175 else if (reg == REG_SP \
8176 && !ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_v8)) \
8178 inst.error = BAD_SP; \
8183 /* If REG is R13 (the stack pointer), warn that its use is
8185 #define warn_deprecated_sp(reg) \
8187 if (warn_on_deprecated && reg == REG_SP) \
8188 as_tsktsk (_("use of r13 is deprecated")); \
8191 /* Functions for operand encoding. ARM, then Thumb. */
8193 #define rotate_left(v, n) (v << (n & 31) | v >> ((32 - n) & 31))
8195 /* If the current inst is scalar ARMv8.2 fp16 instruction, do special encoding.
8197 The only binary encoding difference is the Coprocessor number. Coprocessor
8198 9 is used for half-precision calculations or conversions. The format of the
8199 instruction is the same as the equivalent Coprocessor 10 instruction that
8200 exists for Single-Precision operation. */
8203 do_scalar_fp16_v82_encode (void)
8205 if (inst
.cond
< COND_ALWAYS
)
8206 as_warn (_("ARMv8.2 scalar fp16 instruction cannot be conditional,"
8207 " the behaviour is UNPREDICTABLE"));
8208 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant
, arm_ext_fp16
),
8211 inst
.instruction
= (inst
.instruction
& 0xfffff0ff) | 0x900;
8212 mark_feature_used (&arm_ext_fp16
);
8215 /* If VAL can be encoded in the immediate field of an ARM instruction,
8216 return the encoded form. Otherwise, return FAIL. */
8219 encode_arm_immediate (unsigned int val
)
8226 for (i
= 2; i
< 32; i
+= 2)
8227 if ((a
= rotate_left (val
, i
)) <= 0xff)
8228 return a
| (i
<< 7); /* 12-bit pack: [shift-cnt,const]. */
8233 /* If VAL can be encoded in the immediate field of a Thumb32 instruction,
8234 return the encoded form. Otherwise, return FAIL. */
8236 encode_thumb32_immediate (unsigned int val
)
8243 for (i
= 1; i
<= 24; i
++)
8246 if ((val
& ~(0xff << i
)) == 0)
8247 return ((val
>> i
) & 0x7f) | ((32 - i
) << 7);
8251 if (val
== ((a
<< 16) | a
))
8253 if (val
== ((a
<< 24) | (a
<< 16) | (a
<< 8) | a
))
8257 if (val
== ((a
<< 16) | a
))
8258 return 0x200 | (a
>> 8);
8262 /* Encode a VFP SP or DP register number into inst.instruction. */
8265 encode_arm_vfp_reg (int reg
, enum vfp_reg_pos pos
)
8267 if ((pos
== VFP_REG_Dd
|| pos
== VFP_REG_Dn
|| pos
== VFP_REG_Dm
)
8270 if (ARM_CPU_HAS_FEATURE (cpu_variant
, fpu_vfp_ext_d32
))
8273 ARM_MERGE_FEATURE_SETS (thumb_arch_used
, thumb_arch_used
,
8276 ARM_MERGE_FEATURE_SETS (arm_arch_used
, arm_arch_used
,
8281 first_error (_("D register out of range for selected VFP version"));
8289 inst
.instruction
|= ((reg
>> 1) << 12) | ((reg
& 1) << 22);
8293 inst
.instruction
|= ((reg
>> 1) << 16) | ((reg
& 1) << 7);
8297 inst
.instruction
|= ((reg
>> 1) << 0) | ((reg
& 1) << 5);
8301 inst
.instruction
|= ((reg
& 15) << 12) | ((reg
>> 4) << 22);
8305 inst
.instruction
|= ((reg
& 15) << 16) | ((reg
>> 4) << 7);
8309 inst
.instruction
|= (reg
& 15) | ((reg
>> 4) << 5);
8317 /* Encode a <shift> in an ARM-format instruction. The immediate,
8318 if any, is handled by md_apply_fix. */
8320 encode_arm_shift (int i
)
8322 /* register-shifted register. */
8323 if (inst
.operands
[i
].immisreg
)
8326 for (op_index
= 0; op_index
<= i
; ++op_index
)
8328 /* Check the operand only when it's presented. In pre-UAL syntax,
8329 if the destination register is the same as the first operand, two
8330 register form of the instruction can be used. */
8331 if (inst
.operands
[op_index
].present
&& inst
.operands
[op_index
].isreg
8332 && inst
.operands
[op_index
].reg
== REG_PC
)
8333 as_warn (UNPRED_REG ("r15"));
8336 if (inst
.operands
[i
].imm
== REG_PC
)
8337 as_warn (UNPRED_REG ("r15"));
8340 if (inst
.operands
[i
].shift_kind
== SHIFT_RRX
)
8341 inst
.instruction
|= SHIFT_ROR
<< 5;
8344 inst
.instruction
|= inst
.operands
[i
].shift_kind
<< 5;
8345 if (inst
.operands
[i
].immisreg
)
8347 inst
.instruction
|= SHIFT_BY_REG
;
8348 inst
.instruction
|= inst
.operands
[i
].imm
<< 8;
8351 inst
.relocs
[0].type
= BFD_RELOC_ARM_SHIFT_IMM
;
8356 encode_arm_shifter_operand (int i
)
8358 if (inst
.operands
[i
].isreg
)
8360 inst
.instruction
|= inst
.operands
[i
].reg
;
8361 encode_arm_shift (i
);
8365 inst
.instruction
|= INST_IMMEDIATE
;
8366 if (inst
.relocs
[0].type
!= BFD_RELOC_ARM_IMMEDIATE
)
8367 inst
.instruction
|= inst
.operands
[i
].imm
;
8371 /* Subroutine of encode_arm_addr_mode_2 and encode_arm_addr_mode_3. */
8373 encode_arm_addr_mode_common (int i
, bfd_boolean is_t
)
8376 Generate an error if the operand is not a register. */
8377 constraint (!inst
.operands
[i
].isreg
,
8378 _("Instruction does not support =N addresses"));
8380 inst
.instruction
|= inst
.operands
[i
].reg
<< 16;
8382 if (inst
.operands
[i
].preind
)
8386 inst
.error
= _("instruction does not accept preindexed addressing");
8389 inst
.instruction
|= PRE_INDEX
;
8390 if (inst
.operands
[i
].writeback
)
8391 inst
.instruction
|= WRITE_BACK
;
8394 else if (inst
.operands
[i
].postind
)
8396 gas_assert (inst
.operands
[i
].writeback
);
8398 inst
.instruction
|= WRITE_BACK
;
8400 else /* unindexed - only for coprocessor */
8402 inst
.error
= _("instruction does not accept unindexed addressing");
8406 if (((inst
.instruction
& WRITE_BACK
) || !(inst
.instruction
& PRE_INDEX
))
8407 && (((inst
.instruction
& 0x000f0000) >> 16)
8408 == ((inst
.instruction
& 0x0000f000) >> 12)))
8409 as_warn ((inst
.instruction
& LOAD_BIT
)
8410 ? _("destination register same as write-back base")
8411 : _("source register same as write-back base"));
8414 /* inst.operands[i] was set up by parse_address. Encode it into an
8415 ARM-format mode 2 load or store instruction. If is_t is true,
8416 reject forms that cannot be used with a T instruction (i.e. not
8419 encode_arm_addr_mode_2 (int i
, bfd_boolean is_t
)
8421 const bfd_boolean is_pc
= (inst
.operands
[i
].reg
== REG_PC
);
8423 encode_arm_addr_mode_common (i
, is_t
);
8425 if (inst
.operands
[i
].immisreg
)
8427 constraint ((inst
.operands
[i
].imm
== REG_PC
8428 || (is_pc
&& inst
.operands
[i
].writeback
)),
8430 inst
.instruction
|= INST_IMMEDIATE
; /* yes, this is backwards */
8431 inst
.instruction
|= inst
.operands
[i
].imm
;
8432 if (!inst
.operands
[i
].negative
)
8433 inst
.instruction
|= INDEX_UP
;
8434 if (inst
.operands
[i
].shifted
)
8436 if (inst
.operands
[i
].shift_kind
== SHIFT_RRX
)
8437 inst
.instruction
|= SHIFT_ROR
<< 5;
8440 inst
.instruction
|= inst
.operands
[i
].shift_kind
<< 5;
8441 inst
.relocs
[0].type
= BFD_RELOC_ARM_SHIFT_IMM
;
8445 else /* immediate offset in inst.relocs[0] */
8447 if (is_pc
&& !inst
.relocs
[0].pc_rel
)
8449 const bfd_boolean is_load
= ((inst
.instruction
& LOAD_BIT
) != 0);
8451 /* If is_t is TRUE, it's called from do_ldstt. ldrt/strt
8452 cannot use PC in addressing.
8453 PC cannot be used in writeback addressing, either. */
8454 constraint ((is_t
|| inst
.operands
[i
].writeback
),
8457 /* Use of PC in str is deprecated for ARMv7. */
8458 if (warn_on_deprecated
8460 && ARM_CPU_HAS_FEATURE (selected_cpu
, arm_ext_v7
))
8461 as_tsktsk (_("use of PC in this instruction is deprecated"));
8464 if (inst
.relocs
[0].type
== BFD_RELOC_UNUSED
)
8466 /* Prefer + for zero encoded value. */
8467 if (!inst
.operands
[i
].negative
)
8468 inst
.instruction
|= INDEX_UP
;
8469 inst
.relocs
[0].type
= BFD_RELOC_ARM_OFFSET_IMM
;
8474 /* inst.operands[i] was set up by parse_address. Encode it into an
8475 ARM-format mode 3 load or store instruction. Reject forms that
8476 cannot be used with such instructions. If is_t is true, reject
8477 forms that cannot be used with a T instruction (i.e. not
8480 encode_arm_addr_mode_3 (int i
, bfd_boolean is_t
)
8482 if (inst
.operands
[i
].immisreg
&& inst
.operands
[i
].shifted
)
8484 inst
.error
= _("instruction does not accept scaled register index");
8488 encode_arm_addr_mode_common (i
, is_t
);
8490 if (inst
.operands
[i
].immisreg
)
8492 constraint ((inst
.operands
[i
].imm
== REG_PC
8493 || (is_t
&& inst
.operands
[i
].reg
== REG_PC
)),
8495 constraint (inst
.operands
[i
].reg
== REG_PC
&& inst
.operands
[i
].writeback
,
8497 inst
.instruction
|= inst
.operands
[i
].imm
;
8498 if (!inst
.operands
[i
].negative
)
8499 inst
.instruction
|= INDEX_UP
;
8501 else /* immediate offset in inst.relocs[0] */
8503 constraint ((inst
.operands
[i
].reg
== REG_PC
&& !inst
.relocs
[0].pc_rel
8504 && inst
.operands
[i
].writeback
),
8506 inst
.instruction
|= HWOFFSET_IMM
;
8507 if (inst
.relocs
[0].type
== BFD_RELOC_UNUSED
)
8509 /* Prefer + for zero encoded value. */
8510 if (!inst
.operands
[i
].negative
)
8511 inst
.instruction
|= INDEX_UP
;
8513 inst
.relocs
[0].type
= BFD_RELOC_ARM_OFFSET_IMM8
;
8518 /* Write immediate bits [7:0] to the following locations:
8520 |28/24|23 19|18 16|15 4|3 0|
8521 | 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|
8523 This function is used by VMOV/VMVN/VORR/VBIC. */
8526 neon_write_immbits (unsigned immbits
)
8528 inst
.instruction
|= immbits
& 0xf;
8529 inst
.instruction
|= ((immbits
>> 4) & 0x7) << 16;
8530 inst
.instruction
|= ((immbits
>> 7) & 0x1) << (thumb_mode
? 28 : 24);
8533 /* Invert low-order SIZE bits of XHI:XLO. */
8536 neon_invert_size (unsigned *xlo
, unsigned *xhi
, int size
)
8538 unsigned immlo
= xlo
? *xlo
: 0;
8539 unsigned immhi
= xhi
? *xhi
: 0;
8544 immlo
= (~immlo
) & 0xff;
8548 immlo
= (~immlo
) & 0xffff;
8552 immhi
= (~immhi
) & 0xffffffff;
8556 immlo
= (~immlo
) & 0xffffffff;
8570 /* True if IMM has form 0bAAAAAAAABBBBBBBBCCCCCCCCDDDDDDDD for bits
8574 neon_bits_same_in_bytes (unsigned imm
)
8576 return ((imm
& 0x000000ff) == 0 || (imm
& 0x000000ff) == 0x000000ff)
8577 && ((imm
& 0x0000ff00) == 0 || (imm
& 0x0000ff00) == 0x0000ff00)
8578 && ((imm
& 0x00ff0000) == 0 || (imm
& 0x00ff0000) == 0x00ff0000)
8579 && ((imm
& 0xff000000) == 0 || (imm
& 0xff000000) == 0xff000000);
8582 /* For immediate of above form, return 0bABCD. */
8585 neon_squash_bits (unsigned imm
)
8587 return (imm
& 0x01) | ((imm
& 0x0100) >> 7) | ((imm
& 0x010000) >> 14)
8588 | ((imm
& 0x01000000) >> 21);
8591 /* Compress quarter-float representation to 0b...000 abcdefgh. */
8594 neon_qfloat_bits (unsigned imm
)
8596 return ((imm
>> 19) & 0x7f) | ((imm
>> 24) & 0x80);
8599 /* Returns CMODE. IMMBITS [7:0] is set to bits suitable for inserting into
8600 the instruction. *OP is passed as the initial value of the op field, and
8601 may be set to a different value depending on the constant (i.e.
8602 "MOV I64, 0bAAAAAAAABBBB..." which uses OP = 1 despite being MOV not
8603 MVN). If the immediate looks like a repeated pattern then also
8604 try smaller element sizes. */
8607 neon_cmode_for_move_imm (unsigned immlo
, unsigned immhi
, int float_p
,
8608 unsigned *immbits
, int *op
, int size
,
8609 enum neon_el_type type
)
8611 /* Only permit float immediates (including 0.0/-0.0) if the operand type is
8613 if (type
== NT_float
&& !float_p
)
8616 if (type
== NT_float
&& is_quarter_float (immlo
) && immhi
== 0)
8618 if (size
!= 32 || *op
== 1)
8620 *immbits
= neon_qfloat_bits (immlo
);
8626 if (neon_bits_same_in_bytes (immhi
)
8627 && neon_bits_same_in_bytes (immlo
))
8631 *immbits
= (neon_squash_bits (immhi
) << 4)
8632 | neon_squash_bits (immlo
);
8643 if (immlo
== (immlo
& 0x000000ff))
8648 else if (immlo
== (immlo
& 0x0000ff00))
8650 *immbits
= immlo
>> 8;
8653 else if (immlo
== (immlo
& 0x00ff0000))
8655 *immbits
= immlo
>> 16;
8658 else if (immlo
== (immlo
& 0xff000000))
8660 *immbits
= immlo
>> 24;
8663 else if (immlo
== ((immlo
& 0x0000ff00) | 0x000000ff))
8665 *immbits
= (immlo
>> 8) & 0xff;
8668 else if (immlo
== ((immlo
& 0x00ff0000) | 0x0000ffff))
8670 *immbits
= (immlo
>> 16) & 0xff;
8674 if ((immlo
& 0xffff) != (immlo
>> 16))
8681 if (immlo
== (immlo
& 0x000000ff))
8686 else if (immlo
== (immlo
& 0x0000ff00))
8688 *immbits
= immlo
>> 8;
8692 if ((immlo
& 0xff) != (immlo
>> 8))
8697 if (immlo
== (immlo
& 0x000000ff))
8699 /* Don't allow MVN with 8-bit immediate. */
8709 #if defined BFD_HOST_64_BIT
8710 /* Returns TRUE if double precision value V may be cast
8711 to single precision without loss of accuracy. */
8714 is_double_a_single (bfd_int64_t v
)
8716 int exp
= (int)((v
>> 52) & 0x7FF);
8717 bfd_int64_t mantissa
= (v
& (bfd_int64_t
)0xFFFFFFFFFFFFFULL
);
8719 return (exp
== 0 || exp
== 0x7FF
8720 || (exp
>= 1023 - 126 && exp
<= 1023 + 127))
8721 && (mantissa
& 0x1FFFFFFFl
) == 0;
8724 /* Returns a double precision value casted to single precision
8725 (ignoring the least significant bits in exponent and mantissa). */
8728 double_to_single (bfd_int64_t v
)
8730 int sign
= (int) ((v
>> 63) & 1l);
8731 int exp
= (int) ((v
>> 52) & 0x7FF);
8732 bfd_int64_t mantissa
= (v
& (bfd_int64_t
)0xFFFFFFFFFFFFFULL
);
8738 exp
= exp
- 1023 + 127;
8747 /* No denormalized numbers. */
8753 return (sign
<< 31) | (exp
<< 23) | mantissa
;
8755 #endif /* BFD_HOST_64_BIT */
8764 static void do_vfp_nsyn_opcode (const char *);
8766 /* inst.relocs[0].exp describes an "=expr" load pseudo-operation.
8767 Determine whether it can be performed with a move instruction; if
8768 it can, convert inst.instruction to that move instruction and
8769 return TRUE; if it can't, convert inst.instruction to a literal-pool
8770 load and return FALSE. If this is not a valid thing to do in the
8771 current context, set inst.error and return TRUE.
8773 inst.operands[i] describes the destination register. */
8776 move_or_literal_pool (int i
, enum lit_type t
, bfd_boolean mode_3
)
8779 bfd_boolean thumb_p
= (t
== CONST_THUMB
);
8780 bfd_boolean arm_p
= (t
== CONST_ARM
);
8783 tbit
= (inst
.instruction
> 0xffff) ? THUMB2_LOAD_BIT
: THUMB_LOAD_BIT
;
8787 if ((inst
.instruction
& tbit
) == 0)
8789 inst
.error
= _("invalid pseudo operation");
8793 if (inst
.relocs
[0].exp
.X_op
!= O_constant
8794 && inst
.relocs
[0].exp
.X_op
!= O_symbol
8795 && inst
.relocs
[0].exp
.X_op
!= O_big
)
8797 inst
.error
= _("constant expression expected");
8801 if (inst
.relocs
[0].exp
.X_op
== O_constant
8802 || inst
.relocs
[0].exp
.X_op
== O_big
)
8804 #if defined BFD_HOST_64_BIT
8809 if (inst
.relocs
[0].exp
.X_op
== O_big
)
8811 LITTLENUM_TYPE w
[X_PRECISION
];
8814 if (inst
.relocs
[0].exp
.X_add_number
== -1)
8816 gen_to_words (w
, X_PRECISION
, E_PRECISION
);
8818 /* FIXME: Should we check words w[2..5] ? */
8823 #if defined BFD_HOST_64_BIT
8825 ((((((((bfd_int64_t
) l
[3] & LITTLENUM_MASK
)
8826 << LITTLENUM_NUMBER_OF_BITS
)
8827 | ((bfd_int64_t
) l
[2] & LITTLENUM_MASK
))
8828 << LITTLENUM_NUMBER_OF_BITS
)
8829 | ((bfd_int64_t
) l
[1] & LITTLENUM_MASK
))
8830 << LITTLENUM_NUMBER_OF_BITS
)
8831 | ((bfd_int64_t
) l
[0] & LITTLENUM_MASK
));
8833 v
= ((l
[1] & LITTLENUM_MASK
) << LITTLENUM_NUMBER_OF_BITS
)
8834 | (l
[0] & LITTLENUM_MASK
);
8838 v
= inst
.relocs
[0].exp
.X_add_number
;
8840 if (!inst
.operands
[i
].issingle
)
8844 /* LDR should not use lead in a flag-setting instruction being
8845 chosen so we do not check whether movs can be used. */
8847 if ((ARM_CPU_HAS_FEATURE (cpu_variant
, arm_ext_v6t2
)
8848 || ARM_CPU_HAS_FEATURE (cpu_variant
, arm_ext_v6t2_v8m
))
8849 && inst
.operands
[i
].reg
!= 13
8850 && inst
.operands
[i
].reg
!= 15)
8852 /* Check if on thumb2 it can be done with a mov.w, mvn or
8853 movw instruction. */
8854 unsigned int newimm
;
8855 bfd_boolean isNegated
;
8857 newimm
= encode_thumb32_immediate (v
);
8858 if (newimm
!= (unsigned int) FAIL
)
8862 newimm
= encode_thumb32_immediate (~v
);
8863 if (newimm
!= (unsigned int) FAIL
)
8867 /* The number can be loaded with a mov.w or mvn
8869 if (newimm
!= (unsigned int) FAIL
8870 && ARM_CPU_HAS_FEATURE (cpu_variant
, arm_ext_v6t2
))
8872 inst
.instruction
= (0xf04f0000 /* MOV.W. */
8873 | (inst
.operands
[i
].reg
<< 8));
8874 /* Change to MOVN. */
8875 inst
.instruction
|= (isNegated
? 0x200000 : 0);
8876 inst
.instruction
|= (newimm
& 0x800) << 15;
8877 inst
.instruction
|= (newimm
& 0x700) << 4;
8878 inst
.instruction
|= (newimm
& 0x0ff);
8881 /* The number can be loaded with a movw instruction. */
8882 else if ((v
& ~0xFFFF) == 0
8883 && ARM_CPU_HAS_FEATURE (cpu_variant
, arm_ext_v6t2_v8m
))
8885 int imm
= v
& 0xFFFF;
8887 inst
.instruction
= 0xf2400000; /* MOVW. */
8888 inst
.instruction
|= (inst
.operands
[i
].reg
<< 8);
8889 inst
.instruction
|= (imm
& 0xf000) << 4;
8890 inst
.instruction
|= (imm
& 0x0800) << 15;
8891 inst
.instruction
|= (imm
& 0x0700) << 4;
8892 inst
.instruction
|= (imm
& 0x00ff);
8893 /* In case this replacement is being done on Armv8-M
8894 Baseline we need to make sure to disable the
8895 instruction size check, as otherwise GAS will reject
8896 the use of this T32 instruction. */
8904 int value
= encode_arm_immediate (v
);
8908 /* This can be done with a mov instruction. */
8909 inst
.instruction
&= LITERAL_MASK
;
8910 inst
.instruction
|= INST_IMMEDIATE
| (OPCODE_MOV
<< DATA_OP_SHIFT
);
8911 inst
.instruction
|= value
& 0xfff;
8915 value
= encode_arm_immediate (~ v
);
8918 /* This can be done with a mvn instruction. */
8919 inst
.instruction
&= LITERAL_MASK
;
8920 inst
.instruction
|= INST_IMMEDIATE
| (OPCODE_MVN
<< DATA_OP_SHIFT
);
8921 inst
.instruction
|= value
& 0xfff;
8925 else if (t
== CONST_VEC
&& ARM_CPU_HAS_FEATURE (cpu_variant
, fpu_neon_ext_v1
))
8928 unsigned immbits
= 0;
8929 unsigned immlo
= inst
.operands
[1].imm
;
8930 unsigned immhi
= inst
.operands
[1].regisimm
8931 ? inst
.operands
[1].reg
8932 : inst
.relocs
[0].exp
.X_unsigned
8934 : ((bfd_int64_t
)((int) immlo
)) >> 32;
8935 int cmode
= neon_cmode_for_move_imm (immlo
, immhi
, FALSE
, &immbits
,
8936 &op
, 64, NT_invtype
);
8940 neon_invert_size (&immlo
, &immhi
, 64);
8942 cmode
= neon_cmode_for_move_imm (immlo
, immhi
, FALSE
, &immbits
,
8943 &op
, 64, NT_invtype
);
8948 inst
.instruction
= (inst
.instruction
& VLDR_VMOV_SAME
)
8954 /* Fill other bits in vmov encoding for both thumb and arm. */
8956 inst
.instruction
|= (0x7U
<< 29) | (0xF << 24);
8958 inst
.instruction
|= (0xFU
<< 28) | (0x1 << 25);
8959 neon_write_immbits (immbits
);
8967 /* Check if vldr Rx, =constant could be optimized to vmov Rx, #constant. */
8968 if (inst
.operands
[i
].issingle
8969 && is_quarter_float (inst
.operands
[1].imm
)
8970 && ARM_CPU_HAS_FEATURE (cpu_variant
, fpu_vfp_ext_v3xd
))
8972 inst
.operands
[1].imm
=
8973 neon_qfloat_bits (v
);
8974 do_vfp_nsyn_opcode ("fconsts");
8978 /* If our host does not support a 64-bit type then we cannot perform
8979 the following optimization. This mean that there will be a
8980 discrepancy between the output produced by an assembler built for
8981 a 32-bit-only host and the output produced from a 64-bit host, but
8982 this cannot be helped. */
8983 #if defined BFD_HOST_64_BIT
8984 else if (!inst
.operands
[1].issingle
8985 && ARM_CPU_HAS_FEATURE (cpu_variant
, fpu_vfp_ext_v3
))
8987 if (is_double_a_single (v
)
8988 && is_quarter_float (double_to_single (v
)))
8990 inst
.operands
[1].imm
=
8991 neon_qfloat_bits (double_to_single (v
));
8992 do_vfp_nsyn_opcode ("fconstd");
9000 if (add_to_lit_pool ((!inst
.operands
[i
].isvec
9001 || inst
.operands
[i
].issingle
) ? 4 : 8) == FAIL
)
9004 inst
.operands
[1].reg
= REG_PC
;
9005 inst
.operands
[1].isreg
= 1;
9006 inst
.operands
[1].preind
= 1;
9007 inst
.relocs
[0].pc_rel
= 1;
9008 inst
.relocs
[0].type
= (thumb_p
9009 ? BFD_RELOC_ARM_THUMB_OFFSET
9011 ? BFD_RELOC_ARM_HWLITERAL
9012 : BFD_RELOC_ARM_LITERAL
));
9016 /* inst.operands[i] was set up by parse_address. Encode it into an
9017 ARM-format instruction. Reject all forms which cannot be encoded
9018 into a coprocessor load/store instruction. If wb_ok is false,
9019 reject use of writeback; if unind_ok is false, reject use of
9020 unindexed addressing. If reloc_override is not 0, use it instead
9021 of BFD_ARM_CP_OFF_IMM, unless the initial relocation is a group one
9022 (in which case it is preserved). */
9025 encode_arm_cp_address (int i
, int wb_ok
, int unind_ok
, int reloc_override
)
9027 if (!inst
.operands
[i
].isreg
)
9030 if (! inst
.operands
[0].isvec
)
9032 inst
.error
= _("invalid co-processor operand");
9035 if (move_or_literal_pool (0, CONST_VEC
, /*mode_3=*/FALSE
))
9039 inst
.instruction
|= inst
.operands
[i
].reg
<< 16;
9041 gas_assert (!(inst
.operands
[i
].preind
&& inst
.operands
[i
].postind
));
9043 if (!inst
.operands
[i
].preind
&& !inst
.operands
[i
].postind
) /* unindexed */
9045 gas_assert (!inst
.operands
[i
].writeback
);
9048 inst
.error
= _("instruction does not support unindexed addressing");
9051 inst
.instruction
|= inst
.operands
[i
].imm
;
9052 inst
.instruction
|= INDEX_UP
;
9056 if (inst
.operands
[i
].preind
)
9057 inst
.instruction
|= PRE_INDEX
;
9059 if (inst
.operands
[i
].writeback
)
9061 if (inst
.operands
[i
].reg
== REG_PC
)
9063 inst
.error
= _("pc may not be used with write-back");
9068 inst
.error
= _("instruction does not support writeback");
9071 inst
.instruction
|= WRITE_BACK
;
9075 inst
.relocs
[0].type
= (bfd_reloc_code_real_type
) reloc_override
;
9076 else if ((inst
.relocs
[0].type
< BFD_RELOC_ARM_ALU_PC_G0_NC
9077 || inst
.relocs
[0].type
> BFD_RELOC_ARM_LDC_SB_G2
)
9078 && inst
.relocs
[0].type
!= BFD_RELOC_ARM_LDR_PC_G0
)
9081 inst
.relocs
[0].type
= BFD_RELOC_ARM_T32_CP_OFF_IMM
;
9083 inst
.relocs
[0].type
= BFD_RELOC_ARM_CP_OFF_IMM
;
9086 /* Prefer + for zero encoded value. */
9087 if (!inst
.operands
[i
].negative
)
9088 inst
.instruction
|= INDEX_UP
;
9093 /* Functions for instruction encoding, sorted by sub-architecture.
9094 First some generics; their names are taken from the conventional
9095 bit positions for register arguments in ARM format instructions. */
9105 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
9111 inst
.instruction
|= inst
.operands
[0].reg
<< 16;
9117 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
9118 inst
.instruction
|= inst
.operands
[1].reg
;
9124 inst
.instruction
|= inst
.operands
[0].reg
;
9125 inst
.instruction
|= inst
.operands
[1].reg
<< 16;
9131 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
9132 inst
.instruction
|= inst
.operands
[1].reg
<< 16;
9138 inst
.instruction
|= inst
.operands
[0].reg
<< 16;
9139 inst
.instruction
|= inst
.operands
[1].reg
<< 12;
9145 inst
.instruction
|= inst
.operands
[0].reg
<< 8;
9146 inst
.instruction
|= inst
.operands
[1].reg
<< 16;
9150 check_obsolete (const arm_feature_set
*feature
, const char *msg
)
9152 if (ARM_CPU_IS_ANY (cpu_variant
))
9154 as_tsktsk ("%s", msg
);
9157 else if (ARM_CPU_HAS_FEATURE (cpu_variant
, *feature
))
9169 unsigned Rn
= inst
.operands
[2].reg
;
9170 /* Enforce restrictions on SWP instruction. */
9171 if ((inst
.instruction
& 0x0fbfffff) == 0x01000090)
9173 constraint (Rn
== inst
.operands
[0].reg
|| Rn
== inst
.operands
[1].reg
,
9174 _("Rn must not overlap other operands"));
9176 /* SWP{b} is obsolete for ARMv8-A, and deprecated for ARMv6* and ARMv7.
9178 if (!check_obsolete (&arm_ext_v8
,
9179 _("swp{b} use is obsoleted for ARMv8 and later"))
9180 && warn_on_deprecated
9181 && ARM_CPU_HAS_FEATURE (cpu_variant
, arm_ext_v6
))
9182 as_tsktsk (_("swp{b} use is deprecated for ARMv6 and ARMv7"));
9185 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
9186 inst
.instruction
|= inst
.operands
[1].reg
;
9187 inst
.instruction
|= Rn
<< 16;
9193 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
9194 inst
.instruction
|= inst
.operands
[1].reg
<< 16;
9195 inst
.instruction
|= inst
.operands
[2].reg
;
9201 constraint ((inst
.operands
[2].reg
== REG_PC
), BAD_PC
);
9202 constraint (((inst
.relocs
[0].exp
.X_op
!= O_constant
9203 && inst
.relocs
[0].exp
.X_op
!= O_illegal
)
9204 || inst
.relocs
[0].exp
.X_add_number
!= 0),
9206 inst
.instruction
|= inst
.operands
[0].reg
;
9207 inst
.instruction
|= inst
.operands
[1].reg
<< 12;
9208 inst
.instruction
|= inst
.operands
[2].reg
<< 16;
9214 inst
.instruction
|= inst
.operands
[0].imm
;
9220 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
9221 encode_arm_cp_address (1, TRUE
, TRUE
, 0);
9224 /* ARM instructions, in alphabetical order by function name (except
9225 that wrapper functions appear immediately after the function they
9228 /* This is a pseudo-op of the form "adr rd, label" to be converted
9229 into a relative address of the form "add rd, pc, #label-.-8". */
9234 inst
.instruction
|= (inst
.operands
[0].reg
<< 12); /* Rd */
9236 /* Frag hacking will turn this into a sub instruction if the offset turns
9237 out to be negative. */
9238 inst
.relocs
[0].type
= BFD_RELOC_ARM_IMMEDIATE
;
9239 inst
.relocs
[0].pc_rel
= 1;
9240 inst
.relocs
[0].exp
.X_add_number
-= 8;
9242 if (support_interwork
9243 && inst
.relocs
[0].exp
.X_op
== O_symbol
9244 && inst
.relocs
[0].exp
.X_add_symbol
!= NULL
9245 && S_IS_DEFINED (inst
.relocs
[0].exp
.X_add_symbol
)
9246 && THUMB_IS_FUNC (inst
.relocs
[0].exp
.X_add_symbol
))
9247 inst
.relocs
[0].exp
.X_add_number
|= 1;
9250 /* This is a pseudo-op of the form "adrl rd, label" to be converted
9251 into a relative address of the form:
9252 add rd, pc, #low(label-.-8)"
9253 add rd, rd, #high(label-.-8)" */
9258 inst
.instruction
|= (inst
.operands
[0].reg
<< 12); /* Rd */
9260 /* Frag hacking will turn this into a sub instruction if the offset turns
9261 out to be negative. */
9262 inst
.relocs
[0].type
= BFD_RELOC_ARM_ADRL_IMMEDIATE
;
9263 inst
.relocs
[0].pc_rel
= 1;
9264 inst
.size
= INSN_SIZE
* 2;
9265 inst
.relocs
[0].exp
.X_add_number
-= 8;
9267 if (support_interwork
9268 && inst
.relocs
[0].exp
.X_op
== O_symbol
9269 && inst
.relocs
[0].exp
.X_add_symbol
!= NULL
9270 && S_IS_DEFINED (inst
.relocs
[0].exp
.X_add_symbol
)
9271 && THUMB_IS_FUNC (inst
.relocs
[0].exp
.X_add_symbol
))
9272 inst
.relocs
[0].exp
.X_add_number
|= 1;
9278 constraint (inst
.relocs
[0].type
>= BFD_RELOC_ARM_THUMB_ALU_ABS_G0_NC
9279 && inst
.relocs
[0].type
<= BFD_RELOC_ARM_THUMB_ALU_ABS_G3_NC
,
9281 if (!inst
.operands
[1].present
)
9282 inst
.operands
[1].reg
= inst
.operands
[0].reg
;
9283 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
9284 inst
.instruction
|= inst
.operands
[1].reg
<< 16;
9285 encode_arm_shifter_operand (2);
9291 if (inst
.operands
[0].present
)
9292 inst
.instruction
|= inst
.operands
[0].imm
;
9294 inst
.instruction
|= 0xf;
9300 unsigned int msb
= inst
.operands
[1].imm
+ inst
.operands
[2].imm
;
9301 constraint (msb
> 32, _("bit-field extends past end of register"));
9302 /* The instruction encoding stores the LSB and MSB,
9303 not the LSB and width. */
9304 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
9305 inst
.instruction
|= inst
.operands
[1].imm
<< 7;
9306 inst
.instruction
|= (msb
- 1) << 16;
9314 /* #0 in second position is alternative syntax for bfc, which is
9315 the same instruction but with REG_PC in the Rm field. */
9316 if (!inst
.operands
[1].isreg
)
9317 inst
.operands
[1].reg
= REG_PC
;
9319 msb
= inst
.operands
[2].imm
+ inst
.operands
[3].imm
;
9320 constraint (msb
> 32, _("bit-field extends past end of register"));
9321 /* The instruction encoding stores the LSB and MSB,
9322 not the LSB and width. */
9323 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
9324 inst
.instruction
|= inst
.operands
[1].reg
;
9325 inst
.instruction
|= inst
.operands
[2].imm
<< 7;
9326 inst
.instruction
|= (msb
- 1) << 16;
9332 constraint (inst
.operands
[2].imm
+ inst
.operands
[3].imm
> 32,
9333 _("bit-field extends past end of register"));
9334 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
9335 inst
.instruction
|= inst
.operands
[1].reg
;
9336 inst
.instruction
|= inst
.operands
[2].imm
<< 7;
9337 inst
.instruction
|= (inst
.operands
[3].imm
- 1) << 16;
9340 /* ARM V5 breakpoint instruction (argument parse)
9341 BKPT <16 bit unsigned immediate>
9342 Instruction is not conditional.
9343 The bit pattern given in insns[] has the COND_ALWAYS condition,
9344 and it is an error if the caller tried to override that. */
9349 /* Top 12 of 16 bits to bits 19:8. */
9350 inst
.instruction
|= (inst
.operands
[0].imm
& 0xfff0) << 4;
9352 /* Bottom 4 of 16 bits to bits 3:0. */
9353 inst
.instruction
|= inst
.operands
[0].imm
& 0xf;
9357 encode_branch (int default_reloc
)
9359 if (inst
.operands
[0].hasreloc
)
9361 constraint (inst
.operands
[0].imm
!= BFD_RELOC_ARM_PLT32
9362 && inst
.operands
[0].imm
!= BFD_RELOC_ARM_TLS_CALL
,
9363 _("the only valid suffixes here are '(plt)' and '(tlscall)'"));
9364 inst
.relocs
[0].type
= inst
.operands
[0].imm
== BFD_RELOC_ARM_PLT32
9365 ? BFD_RELOC_ARM_PLT32
9366 : thumb_mode
? BFD_RELOC_ARM_THM_TLS_CALL
: BFD_RELOC_ARM_TLS_CALL
;
9369 inst
.relocs
[0].type
= (bfd_reloc_code_real_type
) default_reloc
;
9370 inst
.relocs
[0].pc_rel
= 1;
9377 if (EF_ARM_EABI_VERSION (meabi_flags
) >= EF_ARM_EABI_VER4
)
9378 encode_branch (BFD_RELOC_ARM_PCREL_JUMP
);
9381 encode_branch (BFD_RELOC_ARM_PCREL_BRANCH
);
9388 if (EF_ARM_EABI_VERSION (meabi_flags
) >= EF_ARM_EABI_VER4
)
9390 if (inst
.cond
== COND_ALWAYS
)
9391 encode_branch (BFD_RELOC_ARM_PCREL_CALL
);
9393 encode_branch (BFD_RELOC_ARM_PCREL_JUMP
);
9397 encode_branch (BFD_RELOC_ARM_PCREL_BRANCH
);
9400 /* ARM V5 branch-link-exchange instruction (argument parse)
9401 BLX <target_addr> ie BLX(1)
9402 BLX{<condition>} <Rm> ie BLX(2)
9403 Unfortunately, there are two different opcodes for this mnemonic.
9404 So, the insns[].value is not used, and the code here zaps values
9405 into inst.instruction.
9406 Also, the <target_addr> can be 25 bits, hence has its own reloc. */
9411 if (inst
.operands
[0].isreg
)
9413 /* Arg is a register; the opcode provided by insns[] is correct.
9414 It is not illegal to do "blx pc", just useless. */
9415 if (inst
.operands
[0].reg
== REG_PC
)
9416 as_tsktsk (_("use of r15 in blx in ARM mode is not really useful"));
9418 inst
.instruction
|= inst
.operands
[0].reg
;
9422 /* Arg is an address; this instruction cannot be executed
9423 conditionally, and the opcode must be adjusted.
9424 We retain the BFD_RELOC_ARM_PCREL_BLX till the very end
9425 where we generate out a BFD_RELOC_ARM_PCREL_CALL instead. */
9426 constraint (inst
.cond
!= COND_ALWAYS
, BAD_COND
);
9427 inst
.instruction
= 0xfa000000;
9428 encode_branch (BFD_RELOC_ARM_PCREL_BLX
);
9435 bfd_boolean want_reloc
;
9437 if (inst
.operands
[0].reg
== REG_PC
)
9438 as_tsktsk (_("use of r15 in bx in ARM mode is not really useful"));
9440 inst
.instruction
|= inst
.operands
[0].reg
;
9441 /* Output R_ARM_V4BX relocations if is an EABI object that looks like
9442 it is for ARMv4t or earlier. */
9443 want_reloc
= !ARM_CPU_HAS_FEATURE (selected_cpu
, arm_ext_v5
);
9444 if (!ARM_FEATURE_ZERO (selected_object_arch
)
9445 && !ARM_CPU_HAS_FEATURE (selected_object_arch
, arm_ext_v5
))
9449 if (EF_ARM_EABI_VERSION (meabi_flags
) < EF_ARM_EABI_VER4
)
9454 inst
.relocs
[0].type
= BFD_RELOC_ARM_V4BX
;
9458 /* ARM v5TEJ. Jump to Jazelle code. */
9463 if (inst
.operands
[0].reg
== REG_PC
)
9464 as_tsktsk (_("use of r15 in bxj is not really useful"));
9466 inst
.instruction
|= inst
.operands
[0].reg
;
9469 /* Co-processor data operation:
9470 CDP{cond} <coproc>, <opcode_1>, <CRd>, <CRn>, <CRm>{, <opcode_2>}
9471 CDP2 <coproc>, <opcode_1>, <CRd>, <CRn>, <CRm>{, <opcode_2>} */
9475 inst
.instruction
|= inst
.operands
[0].reg
<< 8;
9476 inst
.instruction
|= inst
.operands
[1].imm
<< 20;
9477 inst
.instruction
|= inst
.operands
[2].reg
<< 12;
9478 inst
.instruction
|= inst
.operands
[3].reg
<< 16;
9479 inst
.instruction
|= inst
.operands
[4].reg
;
9480 inst
.instruction
|= inst
.operands
[5].imm
<< 5;
9486 inst
.instruction
|= inst
.operands
[0].reg
<< 16;
9487 encode_arm_shifter_operand (1);
9490 /* Transfer between coprocessor and ARM registers.
9491 MRC{cond} <coproc>, <opcode_1>, <Rd>, <CRn>, <CRm>{, <opcode_2>}
9496 No special properties. */
9498 struct deprecated_coproc_regs_s
9505 arm_feature_set deprecated
;
9506 arm_feature_set obsoleted
;
9507 const char *dep_msg
;
9508 const char *obs_msg
;
9511 #define DEPR_ACCESS_V8 \
9512 N_("This coprocessor register access is deprecated in ARMv8")
9514 /* Table of all deprecated coprocessor registers. */
9515 static struct deprecated_coproc_regs_s deprecated_coproc_regs
[] =
9517 {15, 0, 7, 10, 5, /* CP15DMB. */
9518 ARM_FEATURE_CORE_LOW (ARM_EXT_V8
), ARM_ARCH_NONE
,
9519 DEPR_ACCESS_V8
, NULL
},
9520 {15, 0, 7, 10, 4, /* CP15DSB. */
9521 ARM_FEATURE_CORE_LOW (ARM_EXT_V8
), ARM_ARCH_NONE
,
9522 DEPR_ACCESS_V8
, NULL
},
9523 {15, 0, 7, 5, 4, /* CP15ISB. */
9524 ARM_FEATURE_CORE_LOW (ARM_EXT_V8
), ARM_ARCH_NONE
,
9525 DEPR_ACCESS_V8
, NULL
},
9526 {14, 6, 1, 0, 0, /* TEEHBR. */
9527 ARM_FEATURE_CORE_LOW (ARM_EXT_V8
), ARM_ARCH_NONE
,
9528 DEPR_ACCESS_V8
, NULL
},
9529 {14, 6, 0, 0, 0, /* TEECR. */
9530 ARM_FEATURE_CORE_LOW (ARM_EXT_V8
), ARM_ARCH_NONE
,
9531 DEPR_ACCESS_V8
, NULL
},
9534 #undef DEPR_ACCESS_V8
9536 static const size_t deprecated_coproc_reg_count
=
9537 sizeof (deprecated_coproc_regs
) / sizeof (deprecated_coproc_regs
[0]);
9545 Rd
= inst
.operands
[2].reg
;
9548 if (inst
.instruction
== 0xee000010
9549 || inst
.instruction
== 0xfe000010)
9551 reject_bad_reg (Rd
);
9552 else if (!ARM_CPU_HAS_FEATURE (cpu_variant
, arm_ext_v8
))
9554 constraint (Rd
== REG_SP
, BAD_SP
);
9559 if (inst
.instruction
== 0xe000010)
9560 constraint (Rd
== REG_PC
, BAD_PC
);
9563 for (i
= 0; i
< deprecated_coproc_reg_count
; ++i
)
9565 const struct deprecated_coproc_regs_s
*r
=
9566 deprecated_coproc_regs
+ i
;
9568 if (inst
.operands
[0].reg
== r
->cp
9569 && inst
.operands
[1].imm
== r
->opc1
9570 && inst
.operands
[3].reg
== r
->crn
9571 && inst
.operands
[4].reg
== r
->crm
9572 && inst
.operands
[5].imm
== r
->opc2
)
9574 if (! ARM_CPU_IS_ANY (cpu_variant
)
9575 && warn_on_deprecated
9576 && ARM_CPU_HAS_FEATURE (cpu_variant
, r
->deprecated
))
9577 as_tsktsk ("%s", r
->dep_msg
);
9581 inst
.instruction
|= inst
.operands
[0].reg
<< 8;
9582 inst
.instruction
|= inst
.operands
[1].imm
<< 21;
9583 inst
.instruction
|= Rd
<< 12;
9584 inst
.instruction
|= inst
.operands
[3].reg
<< 16;
9585 inst
.instruction
|= inst
.operands
[4].reg
;
9586 inst
.instruction
|= inst
.operands
[5].imm
<< 5;
9589 /* Transfer between coprocessor register and pair of ARM registers.
9590 MCRR{cond} <coproc>, <opcode>, <Rd>, <Rn>, <CRm>.
9595 Two XScale instructions are special cases of these:
9597 MAR{cond} acc0, <RdLo>, <RdHi> == MCRR{cond} p0, #0, <RdLo>, <RdHi>, c0
9598 MRA{cond} acc0, <RdLo>, <RdHi> == MRRC{cond} p0, #0, <RdLo>, <RdHi>, c0
9600 Result unpredictable if Rd or Rn is R15. */
9607 Rd
= inst
.operands
[2].reg
;
9608 Rn
= inst
.operands
[3].reg
;
9612 reject_bad_reg (Rd
);
9613 reject_bad_reg (Rn
);
9617 constraint (Rd
== REG_PC
, BAD_PC
);
9618 constraint (Rn
== REG_PC
, BAD_PC
);
9621 /* Only check the MRRC{2} variants. */
9622 if ((inst
.instruction
& 0x0FF00000) == 0x0C500000)
9624 /* If Rd == Rn, error that the operation is
9625 unpredictable (example MRRC p3,#1,r1,r1,c4). */
9626 constraint (Rd
== Rn
, BAD_OVERLAP
);
9629 inst
.instruction
|= inst
.operands
[0].reg
<< 8;
9630 inst
.instruction
|= inst
.operands
[1].imm
<< 4;
9631 inst
.instruction
|= Rd
<< 12;
9632 inst
.instruction
|= Rn
<< 16;
9633 inst
.instruction
|= inst
.operands
[4].reg
;
9639 inst
.instruction
|= inst
.operands
[0].imm
<< 6;
9640 if (inst
.operands
[1].present
)
9642 inst
.instruction
|= CPSI_MMOD
;
9643 inst
.instruction
|= inst
.operands
[1].imm
;
9650 inst
.instruction
|= inst
.operands
[0].imm
;
9656 unsigned Rd
, Rn
, Rm
;
9658 Rd
= inst
.operands
[0].reg
;
9659 Rn
= (inst
.operands
[1].present
9660 ? inst
.operands
[1].reg
: Rd
);
9661 Rm
= inst
.operands
[2].reg
;
9663 constraint ((Rd
== REG_PC
), BAD_PC
);
9664 constraint ((Rn
== REG_PC
), BAD_PC
);
9665 constraint ((Rm
== REG_PC
), BAD_PC
);
9667 inst
.instruction
|= Rd
<< 16;
9668 inst
.instruction
|= Rn
<< 0;
9669 inst
.instruction
|= Rm
<< 8;
9675 /* There is no IT instruction in ARM mode. We
9676 process it to do the validation as if in
9677 thumb mode, just in case the code gets
9678 assembled for thumb using the unified syntax. */
9683 set_pred_insn_type (IT_INSN
);
9684 now_pred
.mask
= (inst
.instruction
& 0xf) | 0x10;
9685 now_pred
.cc
= inst
.operands
[0].imm
;
9689 /* If there is only one register in the register list,
9690 then return its register number. Otherwise return -1. */
9692 only_one_reg_in_list (int range
)
9694 int i
= ffs (range
) - 1;
9695 return (i
> 15 || range
!= (1 << i
)) ? -1 : i
;
9699 encode_ldmstm(int from_push_pop_mnem
)
9701 int base_reg
= inst
.operands
[0].reg
;
9702 int range
= inst
.operands
[1].imm
;
9705 inst
.instruction
|= base_reg
<< 16;
9706 inst
.instruction
|= range
;
9708 if (inst
.operands
[1].writeback
)
9709 inst
.instruction
|= LDM_TYPE_2_OR_3
;
9711 if (inst
.operands
[0].writeback
)
9713 inst
.instruction
|= WRITE_BACK
;
9714 /* Check for unpredictable uses of writeback. */
9715 if (inst
.instruction
& LOAD_BIT
)
9717 /* Not allowed in LDM type 2. */
9718 if ((inst
.instruction
& LDM_TYPE_2_OR_3
)
9719 && ((range
& (1 << REG_PC
)) == 0))
9720 as_warn (_("writeback of base register is UNPREDICTABLE"));
9721 /* Only allowed if base reg not in list for other types. */
9722 else if (range
& (1 << base_reg
))
9723 as_warn (_("writeback of base register when in register list is UNPREDICTABLE"));
9727 /* Not allowed for type 2. */
9728 if (inst
.instruction
& LDM_TYPE_2_OR_3
)
9729 as_warn (_("writeback of base register is UNPREDICTABLE"));
9730 /* Only allowed if base reg not in list, or first in list. */
9731 else if ((range
& (1 << base_reg
))
9732 && (range
& ((1 << base_reg
) - 1)))
9733 as_warn (_("if writeback register is in list, it must be the lowest reg in the list"));
9737 /* If PUSH/POP has only one register, then use the A2 encoding. */
9738 one_reg
= only_one_reg_in_list (range
);
9739 if (from_push_pop_mnem
&& one_reg
>= 0)
9741 int is_push
= (inst
.instruction
& A_PUSH_POP_OP_MASK
) == A1_OPCODE_PUSH
;
9743 if (is_push
&& one_reg
== 13 /* SP */)
9744 /* PR 22483: The A2 encoding cannot be used when
9745 pushing the stack pointer as this is UNPREDICTABLE. */
9748 inst
.instruction
&= A_COND_MASK
;
9749 inst
.instruction
|= is_push
? A2_OPCODE_PUSH
: A2_OPCODE_POP
;
9750 inst
.instruction
|= one_reg
<< 12;
9757 encode_ldmstm (/*from_push_pop_mnem=*/FALSE
);
9760 /* ARMv5TE load-consecutive (argument parse)
9769 constraint (inst
.operands
[0].reg
% 2 != 0,
9770 _("first transfer register must be even"));
9771 constraint (inst
.operands
[1].present
9772 && inst
.operands
[1].reg
!= inst
.operands
[0].reg
+ 1,
9773 _("can only transfer two consecutive registers"));
9774 constraint (inst
.operands
[0].reg
== REG_LR
, _("r14 not allowed here"));
9775 constraint (!inst
.operands
[2].isreg
, _("'[' expected"));
9777 if (!inst
.operands
[1].present
)
9778 inst
.operands
[1].reg
= inst
.operands
[0].reg
+ 1;
9780 /* encode_arm_addr_mode_3 will diagnose overlap between the base
9781 register and the first register written; we have to diagnose
9782 overlap between the base and the second register written here. */
9784 if (inst
.operands
[2].reg
== inst
.operands
[1].reg
9785 && (inst
.operands
[2].writeback
|| inst
.operands
[2].postind
))
9786 as_warn (_("base register written back, and overlaps "
9787 "second transfer register"));
9789 if (!(inst
.instruction
& V4_STR_BIT
))
9791 /* For an index-register load, the index register must not overlap the
9792 destination (even if not write-back). */
9793 if (inst
.operands
[2].immisreg
9794 && ((unsigned) inst
.operands
[2].imm
== inst
.operands
[0].reg
9795 || (unsigned) inst
.operands
[2].imm
== inst
.operands
[1].reg
))
9796 as_warn (_("index register overlaps transfer register"));
9798 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
9799 encode_arm_addr_mode_3 (2, /*is_t=*/FALSE
);
9805 constraint (!inst
.operands
[1].isreg
|| !inst
.operands
[1].preind
9806 || inst
.operands
[1].postind
|| inst
.operands
[1].writeback
9807 || inst
.operands
[1].immisreg
|| inst
.operands
[1].shifted
9808 || inst
.operands
[1].negative
9809 /* This can arise if the programmer has written
9811 or if they have mistakenly used a register name as the last
9814 It is very difficult to distinguish between these two cases
9815 because "rX" might actually be a label. ie the register
9816 name has been occluded by a symbol of the same name. So we
9817 just generate a general 'bad addressing mode' type error
9818 message and leave it up to the programmer to discover the
9819 true cause and fix their mistake. */
9820 || (inst
.operands
[1].reg
== REG_PC
),
9823 constraint (inst
.relocs
[0].exp
.X_op
!= O_constant
9824 || inst
.relocs
[0].exp
.X_add_number
!= 0,
9825 _("offset must be zero in ARM encoding"));
9827 constraint ((inst
.operands
[1].reg
== REG_PC
), BAD_PC
);
9829 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
9830 inst
.instruction
|= inst
.operands
[1].reg
<< 16;
9831 inst
.relocs
[0].type
= BFD_RELOC_UNUSED
;
9837 constraint (inst
.operands
[0].reg
% 2 != 0,
9838 _("even register required"));
9839 constraint (inst
.operands
[1].present
9840 && inst
.operands
[1].reg
!= inst
.operands
[0].reg
+ 1,
9841 _("can only load two consecutive registers"));
9842 /* If op 1 were present and equal to PC, this function wouldn't
9843 have been called in the first place. */
9844 constraint (inst
.operands
[0].reg
== REG_LR
, _("r14 not allowed here"));
9846 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
9847 inst
.instruction
|= inst
.operands
[2].reg
<< 16;
9850 /* In both ARM and thumb state 'ldr pc, #imm' with an immediate
9851 which is not a multiple of four is UNPREDICTABLE. */
9853 check_ldr_r15_aligned (void)
9855 constraint (!(inst
.operands
[1].immisreg
)
9856 && (inst
.operands
[0].reg
== REG_PC
9857 && inst
.operands
[1].reg
== REG_PC
9858 && (inst
.relocs
[0].exp
.X_add_number
& 0x3)),
9859 _("ldr to register 15 must be 4-byte aligned"));
9865 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
9866 if (!inst
.operands
[1].isreg
)
9867 if (move_or_literal_pool (0, CONST_ARM
, /*mode_3=*/FALSE
))
9869 encode_arm_addr_mode_2 (1, /*is_t=*/FALSE
);
9870 check_ldr_r15_aligned ();
9876 /* ldrt/strt always use post-indexed addressing. Turn [Rn] into [Rn]! and
9878 if (inst
.operands
[1].preind
)
9880 constraint (inst
.relocs
[0].exp
.X_op
!= O_constant
9881 || inst
.relocs
[0].exp
.X_add_number
!= 0,
9882 _("this instruction requires a post-indexed address"));
9884 inst
.operands
[1].preind
= 0;
9885 inst
.operands
[1].postind
= 1;
9886 inst
.operands
[1].writeback
= 1;
9888 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
9889 encode_arm_addr_mode_2 (1, /*is_t=*/TRUE
);
9892 /* Halfword and signed-byte load/store operations. */
9897 constraint (inst
.operands
[0].reg
== REG_PC
, BAD_PC
);
9898 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
9899 if (!inst
.operands
[1].isreg
)
9900 if (move_or_literal_pool (0, CONST_ARM
, /*mode_3=*/TRUE
))
9902 encode_arm_addr_mode_3 (1, /*is_t=*/FALSE
);
9908 /* ldrt/strt always use post-indexed addressing. Turn [Rn] into [Rn]! and
9910 if (inst
.operands
[1].preind
)
9912 constraint (inst
.relocs
[0].exp
.X_op
!= O_constant
9913 || inst
.relocs
[0].exp
.X_add_number
!= 0,
9914 _("this instruction requires a post-indexed address"));
9916 inst
.operands
[1].preind
= 0;
9917 inst
.operands
[1].postind
= 1;
9918 inst
.operands
[1].writeback
= 1;
9920 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
9921 encode_arm_addr_mode_3 (1, /*is_t=*/TRUE
);
9924 /* Co-processor register load/store.
9925 Format: <LDC|STC>{cond}[L] CP#,CRd,<address> */
9929 inst
.instruction
|= inst
.operands
[0].reg
<< 8;
9930 inst
.instruction
|= inst
.operands
[1].reg
<< 12;
9931 encode_arm_cp_address (2, TRUE
, TRUE
, 0);
9937 /* This restriction does not apply to mls (nor to mla in v6 or later). */
9938 if (inst
.operands
[0].reg
== inst
.operands
[1].reg
9939 && !ARM_CPU_HAS_FEATURE (selected_cpu
, arm_ext_v6
)
9940 && !(inst
.instruction
& 0x00400000))
9941 as_tsktsk (_("Rd and Rm should be different in mla"));
9943 inst
.instruction
|= inst
.operands
[0].reg
<< 16;
9944 inst
.instruction
|= inst
.operands
[1].reg
;
9945 inst
.instruction
|= inst
.operands
[2].reg
<< 8;
9946 inst
.instruction
|= inst
.operands
[3].reg
<< 12;
9952 constraint (inst
.relocs
[0].type
>= BFD_RELOC_ARM_THUMB_ALU_ABS_G0_NC
9953 && inst
.relocs
[0].type
<= BFD_RELOC_ARM_THUMB_ALU_ABS_G3_NC
,
9955 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
9956 encode_arm_shifter_operand (1);
9959 /* ARM V6T2 16-bit immediate register load: MOV[WT]{cond} Rd, #<imm16>. */
9966 top
= (inst
.instruction
& 0x00400000) != 0;
9967 constraint (top
&& inst
.relocs
[0].type
== BFD_RELOC_ARM_MOVW
,
9968 _(":lower16: not allowed in this instruction"));
9969 constraint (!top
&& inst
.relocs
[0].type
== BFD_RELOC_ARM_MOVT
,
9970 _(":upper16: not allowed in this instruction"));
9971 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
9972 if (inst
.relocs
[0].type
== BFD_RELOC_UNUSED
)
9974 imm
= inst
.relocs
[0].exp
.X_add_number
;
9975 /* The value is in two pieces: 0:11, 16:19. */
9976 inst
.instruction
|= (imm
& 0x00000fff);
9977 inst
.instruction
|= (imm
& 0x0000f000) << 4;
9982 do_vfp_nsyn_mrs (void)
9984 if (inst
.operands
[0].isvec
)
9986 if (inst
.operands
[1].reg
!= 1)
9987 first_error (_("operand 1 must be FPSCR"));
9988 memset (&inst
.operands
[0], '\0', sizeof (inst
.operands
[0]));
9989 memset (&inst
.operands
[1], '\0', sizeof (inst
.operands
[1]));
9990 do_vfp_nsyn_opcode ("fmstat");
9992 else if (inst
.operands
[1].isvec
)
9993 do_vfp_nsyn_opcode ("fmrx");
10001 do_vfp_nsyn_msr (void)
10003 if (inst
.operands
[0].isvec
)
10004 do_vfp_nsyn_opcode ("fmxr");
10014 unsigned Rt
= inst
.operands
[0].reg
;
10016 if (thumb_mode
&& Rt
== REG_SP
)
10018 inst
.error
= BAD_SP
;
10022 switch (inst
.operands
[1].reg
)
10024 /* MVFR2 is only valid for Armv8-A. */
10026 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant
, fpu_vfp_ext_armv8
),
10030 /* Check for new Armv8.1-M Mainline changes to <spec_reg>. */
10031 case 1: /* fpscr. */
10032 constraint (!(ARM_CPU_HAS_FEATURE (cpu_variant
, mve_ext
)
10033 || ARM_CPU_HAS_FEATURE (cpu_variant
, fpu_vfp_ext_v1xd
)),
10037 case 14: /* fpcxt_ns. */
10038 case 15: /* fpcxt_s. */
10039 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant
, arm_ext_v8_1m_main
),
10040 _("selected processor does not support instruction"));
10043 case 2: /* fpscr_nzcvqc. */
10044 case 12: /* vpr. */
10046 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant
, arm_ext_v8_1m_main
)
10047 || (!ARM_CPU_HAS_FEATURE (cpu_variant
, mve_ext
)
10048 && !ARM_CPU_HAS_FEATURE (cpu_variant
, fpu_vfp_ext_v1xd
)),
10049 _("selected processor does not support instruction"));
10050 if (inst
.operands
[0].reg
!= 2
10051 && !ARM_CPU_HAS_FEATURE (cpu_variant
, mve_ext
))
10052 as_warn (_("accessing MVE system register without MVE is UNPREDICTABLE"));
10059 /* APSR_ sets isvec. All other refs to PC are illegal. */
10060 if (!inst
.operands
[0].isvec
&& Rt
== REG_PC
)
10062 inst
.error
= BAD_PC
;
10066 /* If we get through parsing the register name, we just insert the number
10067 generated into the instruction without further validation. */
10068 inst
.instruction
|= (inst
.operands
[1].reg
<< 16);
10069 inst
.instruction
|= (Rt
<< 12);
10075 unsigned Rt
= inst
.operands
[1].reg
;
10078 reject_bad_reg (Rt
);
10079 else if (Rt
== REG_PC
)
10081 inst
.error
= BAD_PC
;
10085 switch (inst
.operands
[0].reg
)
10087 /* MVFR2 is only valid for Armv8-A. */
10089 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant
, fpu_vfp_ext_armv8
),
10093 /* Check for new Armv8.1-M Mainline changes to <spec_reg>. */
10094 case 1: /* fpcr. */
10095 constraint (!(ARM_CPU_HAS_FEATURE (cpu_variant
, mve_ext
)
10096 || ARM_CPU_HAS_FEATURE (cpu_variant
, fpu_vfp_ext_v1xd
)),
10100 case 14: /* fpcxt_ns. */
10101 case 15: /* fpcxt_s. */
10102 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant
, arm_ext_v8_1m_main
),
10103 _("selected processor does not support instruction"));
10106 case 2: /* fpscr_nzcvqc. */
10107 case 12: /* vpr. */
10109 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant
, arm_ext_v8_1m_main
)
10110 || (!ARM_CPU_HAS_FEATURE (cpu_variant
, mve_ext
)
10111 && !ARM_CPU_HAS_FEATURE (cpu_variant
, fpu_vfp_ext_v1xd
)),
10112 _("selected processor does not support instruction"));
10113 if (inst
.operands
[0].reg
!= 2
10114 && !ARM_CPU_HAS_FEATURE (cpu_variant
, mve_ext
))
10115 as_warn (_("accessing MVE system register without MVE is UNPREDICTABLE"));
10122 /* If we get through parsing the register name, we just insert the number
10123 generated into the instruction without further validation. */
10124 inst
.instruction
|= (inst
.operands
[0].reg
<< 16);
10125 inst
.instruction
|= (Rt
<< 12);
10133 if (do_vfp_nsyn_mrs () == SUCCESS
)
10136 constraint (inst
.operands
[0].reg
== REG_PC
, BAD_PC
);
10137 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
10139 if (inst
.operands
[1].isreg
)
10141 br
= inst
.operands
[1].reg
;
10142 if (((br
& 0x200) == 0) && ((br
& 0xf0000) != 0xf0000))
10143 as_bad (_("bad register for mrs"));
10147 /* mrs only accepts CPSR/SPSR/CPSR_all/SPSR_all. */
10148 constraint ((inst
.operands
[1].imm
& (PSR_c
|PSR_x
|PSR_s
|PSR_f
))
10150 _("'APSR', 'CPSR' or 'SPSR' expected"));
10151 br
= (15<<16) | (inst
.operands
[1].imm
& SPSR_BIT
);
10154 inst
.instruction
|= br
;
10157 /* Two possible forms:
10158 "{C|S}PSR_<field>, Rm",
10159 "{C|S}PSR_f, #expression". */
10164 if (do_vfp_nsyn_msr () == SUCCESS
)
10167 inst
.instruction
|= inst
.operands
[0].imm
;
10168 if (inst
.operands
[1].isreg
)
10169 inst
.instruction
|= inst
.operands
[1].reg
;
10172 inst
.instruction
|= INST_IMMEDIATE
;
10173 inst
.relocs
[0].type
= BFD_RELOC_ARM_IMMEDIATE
;
10174 inst
.relocs
[0].pc_rel
= 0;
10181 constraint (inst
.operands
[2].reg
== REG_PC
, BAD_PC
);
10183 if (!inst
.operands
[2].present
)
10184 inst
.operands
[2].reg
= inst
.operands
[0].reg
;
10185 inst
.instruction
|= inst
.operands
[0].reg
<< 16;
10186 inst
.instruction
|= inst
.operands
[1].reg
;
10187 inst
.instruction
|= inst
.operands
[2].reg
<< 8;
10189 if (inst
.operands
[0].reg
== inst
.operands
[1].reg
10190 && !ARM_CPU_HAS_FEATURE (selected_cpu
, arm_ext_v6
))
10191 as_tsktsk (_("Rd and Rm should be different in mul"));
10194 /* Long Multiply Parser
10195 UMULL RdLo, RdHi, Rm, Rs
10196 SMULL RdLo, RdHi, Rm, Rs
10197 UMLAL RdLo, RdHi, Rm, Rs
10198 SMLAL RdLo, RdHi, Rm, Rs. */
10203 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
10204 inst
.instruction
|= inst
.operands
[1].reg
<< 16;
10205 inst
.instruction
|= inst
.operands
[2].reg
;
10206 inst
.instruction
|= inst
.operands
[3].reg
<< 8;
10208 /* rdhi and rdlo must be different. */
10209 if (inst
.operands
[0].reg
== inst
.operands
[1].reg
)
10210 as_tsktsk (_("rdhi and rdlo must be different"));
10212 /* rdhi, rdlo and rm must all be different before armv6. */
10213 if ((inst
.operands
[0].reg
== inst
.operands
[2].reg
10214 || inst
.operands
[1].reg
== inst
.operands
[2].reg
)
10215 && !ARM_CPU_HAS_FEATURE (selected_cpu
, arm_ext_v6
))
10216 as_tsktsk (_("rdhi, rdlo and rm must all be different"));
10222 if (inst
.operands
[0].present
10223 || ARM_CPU_HAS_FEATURE (selected_cpu
, arm_ext_v6k
))
10225 /* Architectural NOP hints are CPSR sets with no bits selected. */
10226 inst
.instruction
&= 0xf0000000;
10227 inst
.instruction
|= 0x0320f000;
10228 if (inst
.operands
[0].present
)
10229 inst
.instruction
|= inst
.operands
[0].imm
;
10233 /* ARM V6 Pack Halfword Bottom Top instruction (argument parse).
10234 PKHBT {<cond>} <Rd>, <Rn>, <Rm> {, LSL #<shift_imm>}
10235 Condition defaults to COND_ALWAYS.
10236 Error if Rd, Rn or Rm are R15. */
10241 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
10242 inst
.instruction
|= inst
.operands
[1].reg
<< 16;
10243 inst
.instruction
|= inst
.operands
[2].reg
;
10244 if (inst
.operands
[3].present
)
10245 encode_arm_shift (3);
10248 /* ARM V6 PKHTB (Argument Parse). */
10253 if (!inst
.operands
[3].present
)
10255 /* If the shift specifier is omitted, turn the instruction
10256 into pkhbt rd, rm, rn. */
10257 inst
.instruction
&= 0xfff00010;
10258 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
10259 inst
.instruction
|= inst
.operands
[1].reg
;
10260 inst
.instruction
|= inst
.operands
[2].reg
<< 16;
10264 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
10265 inst
.instruction
|= inst
.operands
[1].reg
<< 16;
10266 inst
.instruction
|= inst
.operands
[2].reg
;
10267 encode_arm_shift (3);
10271 /* ARMv5TE: Preload-Cache
10272 MP Extensions: Preload for write
10276 Syntactically, like LDR with B=1, W=0, L=1. */
10281 constraint (!inst
.operands
[0].isreg
,
10282 _("'[' expected after PLD mnemonic"));
10283 constraint (inst
.operands
[0].postind
,
10284 _("post-indexed expression used in preload instruction"));
10285 constraint (inst
.operands
[0].writeback
,
10286 _("writeback used in preload instruction"));
10287 constraint (!inst
.operands
[0].preind
,
10288 _("unindexed addressing used in preload instruction"));
10289 encode_arm_addr_mode_2 (0, /*is_t=*/FALSE
);
10292 /* ARMv7: PLI <addr_mode> */
10296 constraint (!inst
.operands
[0].isreg
,
10297 _("'[' expected after PLI mnemonic"));
10298 constraint (inst
.operands
[0].postind
,
10299 _("post-indexed expression used in preload instruction"));
10300 constraint (inst
.operands
[0].writeback
,
10301 _("writeback used in preload instruction"));
10302 constraint (!inst
.operands
[0].preind
,
10303 _("unindexed addressing used in preload instruction"));
10304 encode_arm_addr_mode_2 (0, /*is_t=*/FALSE
);
10305 inst
.instruction
&= ~PRE_INDEX
;
10311 constraint (inst
.operands
[0].writeback
,
10312 _("push/pop do not support {reglist}^"));
10313 inst
.operands
[1] = inst
.operands
[0];
10314 memset (&inst
.operands
[0], 0, sizeof inst
.operands
[0]);
10315 inst
.operands
[0].isreg
= 1;
10316 inst
.operands
[0].writeback
= 1;
10317 inst
.operands
[0].reg
= REG_SP
;
10318 encode_ldmstm (/*from_push_pop_mnem=*/TRUE
);
10321 /* ARM V6 RFE (Return from Exception) loads the PC and CPSR from the
10322 word at the specified address and the following word
10324 Unconditionally executed.
10325 Error if Rn is R15. */
10330 inst
.instruction
|= inst
.operands
[0].reg
<< 16;
10331 if (inst
.operands
[0].writeback
)
10332 inst
.instruction
|= WRITE_BACK
;
10335 /* ARM V6 ssat (argument parse). */
10340 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
10341 inst
.instruction
|= (inst
.operands
[1].imm
- 1) << 16;
10342 inst
.instruction
|= inst
.operands
[2].reg
;
10344 if (inst
.operands
[3].present
)
10345 encode_arm_shift (3);
10348 /* ARM V6 usat (argument parse). */
10353 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
10354 inst
.instruction
|= inst
.operands
[1].imm
<< 16;
10355 inst
.instruction
|= inst
.operands
[2].reg
;
10357 if (inst
.operands
[3].present
)
10358 encode_arm_shift (3);
10361 /* ARM V6 ssat16 (argument parse). */
10366 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
10367 inst
.instruction
|= ((inst
.operands
[1].imm
- 1) << 16);
10368 inst
.instruction
|= inst
.operands
[2].reg
;
10374 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
10375 inst
.instruction
|= inst
.operands
[1].imm
<< 16;
10376 inst
.instruction
|= inst
.operands
[2].reg
;
10379 /* ARM V6 SETEND (argument parse). Sets the E bit in the CPSR while
10380 preserving the other bits.
10382 setend <endian_specifier>, where <endian_specifier> is either
10388 if (warn_on_deprecated
10389 && ARM_CPU_HAS_FEATURE (cpu_variant
, arm_ext_v8
))
10390 as_tsktsk (_("setend use is deprecated for ARMv8"));
10392 if (inst
.operands
[0].imm
)
10393 inst
.instruction
|= 0x200;
10399 unsigned int Rm
= (inst
.operands
[1].present
10400 ? inst
.operands
[1].reg
10401 : inst
.operands
[0].reg
);
10403 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
10404 inst
.instruction
|= Rm
;
10405 if (inst
.operands
[2].isreg
) /* Rd, {Rm,} Rs */
10407 inst
.instruction
|= inst
.operands
[2].reg
<< 8;
10408 inst
.instruction
|= SHIFT_BY_REG
;
10409 /* PR 12854: Error on extraneous shifts. */
10410 constraint (inst
.operands
[2].shifted
,
10411 _("extraneous shift as part of operand to shift insn"));
10414 inst
.relocs
[0].type
= BFD_RELOC_ARM_SHIFT_IMM
;
10420 unsigned int value
= inst
.relocs
[0].exp
.X_add_number
;
10421 constraint (value
> 0xf, _("immediate too large (bigger than 0xF)"));
10423 inst
.relocs
[0].type
= BFD_RELOC_ARM_SMC
;
10424 inst
.relocs
[0].pc_rel
= 0;
10430 inst
.relocs
[0].type
= BFD_RELOC_ARM_HVC
;
10431 inst
.relocs
[0].pc_rel
= 0;
10437 inst
.relocs
[0].type
= BFD_RELOC_ARM_SWI
;
10438 inst
.relocs
[0].pc_rel
= 0;
10444 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant
, arm_ext_pan
),
10445 _("selected processor does not support SETPAN instruction"));
10447 inst
.instruction
|= ((inst
.operands
[0].imm
& 1) << 9);
10453 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant
, arm_ext_pan
),
10454 _("selected processor does not support SETPAN instruction"));
10456 inst
.instruction
|= (inst
.operands
[0].imm
<< 3);
10459 /* ARM V5E (El Segundo) signed-multiply-accumulate (argument parse)
10460 SMLAxy{cond} Rd,Rm,Rs,Rn
10461 SMLAWy{cond} Rd,Rm,Rs,Rn
10462 Error if any register is R15. */
10467 inst
.instruction
|= inst
.operands
[0].reg
<< 16;
10468 inst
.instruction
|= inst
.operands
[1].reg
;
10469 inst
.instruction
|= inst
.operands
[2].reg
<< 8;
10470 inst
.instruction
|= inst
.operands
[3].reg
<< 12;
10473 /* ARM V5E (El Segundo) signed-multiply-accumulate-long (argument parse)
10474 SMLALxy{cond} Rdlo,Rdhi,Rm,Rs
10475 Error if any register is R15.
10476 Warning if Rdlo == Rdhi. */
10481 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
10482 inst
.instruction
|= inst
.operands
[1].reg
<< 16;
10483 inst
.instruction
|= inst
.operands
[2].reg
;
10484 inst
.instruction
|= inst
.operands
[3].reg
<< 8;
10486 if (inst
.operands
[0].reg
== inst
.operands
[1].reg
)
10487 as_tsktsk (_("rdhi and rdlo must be different"));
10490 /* ARM V5E (El Segundo) signed-multiply (argument parse)
10491 SMULxy{cond} Rd,Rm,Rs
10492 Error if any register is R15. */
10497 inst
.instruction
|= inst
.operands
[0].reg
<< 16;
10498 inst
.instruction
|= inst
.operands
[1].reg
;
10499 inst
.instruction
|= inst
.operands
[2].reg
<< 8;
10502 /* ARM V6 srs (argument parse). The variable fields in the encoding are
10503 the same for both ARM and Thumb-2. */
10510 if (inst
.operands
[0].present
)
10512 reg
= inst
.operands
[0].reg
;
10513 constraint (reg
!= REG_SP
, _("SRS base register must be r13"));
10518 inst
.instruction
|= reg
<< 16;
10519 inst
.instruction
|= inst
.operands
[1].imm
;
10520 if (inst
.operands
[0].writeback
|| inst
.operands
[1].writeback
)
10521 inst
.instruction
|= WRITE_BACK
;
10524 /* ARM V6 strex (argument parse). */
10529 constraint (!inst
.operands
[2].isreg
|| !inst
.operands
[2].preind
10530 || inst
.operands
[2].postind
|| inst
.operands
[2].writeback
10531 || inst
.operands
[2].immisreg
|| inst
.operands
[2].shifted
10532 || inst
.operands
[2].negative
10533 /* See comment in do_ldrex(). */
10534 || (inst
.operands
[2].reg
== REG_PC
),
10537 constraint (inst
.operands
[0].reg
== inst
.operands
[1].reg
10538 || inst
.operands
[0].reg
== inst
.operands
[2].reg
, BAD_OVERLAP
);
10540 constraint (inst
.relocs
[0].exp
.X_op
!= O_constant
10541 || inst
.relocs
[0].exp
.X_add_number
!= 0,
10542 _("offset must be zero in ARM encoding"));
10544 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
10545 inst
.instruction
|= inst
.operands
[1].reg
;
10546 inst
.instruction
|= inst
.operands
[2].reg
<< 16;
10547 inst
.relocs
[0].type
= BFD_RELOC_UNUSED
;
10551 do_t_strexbh (void)
10553 constraint (!inst
.operands
[2].isreg
|| !inst
.operands
[2].preind
10554 || inst
.operands
[2].postind
|| inst
.operands
[2].writeback
10555 || inst
.operands
[2].immisreg
|| inst
.operands
[2].shifted
10556 || inst
.operands
[2].negative
,
10559 constraint (inst
.operands
[0].reg
== inst
.operands
[1].reg
10560 || inst
.operands
[0].reg
== inst
.operands
[2].reg
, BAD_OVERLAP
);
10568 constraint (inst
.operands
[1].reg
% 2 != 0,
10569 _("even register required"));
10570 constraint (inst
.operands
[2].present
10571 && inst
.operands
[2].reg
!= inst
.operands
[1].reg
+ 1,
10572 _("can only store two consecutive registers"));
10573 /* If op 2 were present and equal to PC, this function wouldn't
10574 have been called in the first place. */
10575 constraint (inst
.operands
[1].reg
== REG_LR
, _("r14 not allowed here"));
10577 constraint (inst
.operands
[0].reg
== inst
.operands
[1].reg
10578 || inst
.operands
[0].reg
== inst
.operands
[1].reg
+ 1
10579 || inst
.operands
[0].reg
== inst
.operands
[3].reg
,
10582 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
10583 inst
.instruction
|= inst
.operands
[1].reg
;
10584 inst
.instruction
|= inst
.operands
[3].reg
<< 16;
10591 constraint (inst
.operands
[0].reg
== inst
.operands
[1].reg
10592 || inst
.operands
[0].reg
== inst
.operands
[2].reg
, BAD_OVERLAP
);
10600 constraint (inst
.operands
[0].reg
== inst
.operands
[1].reg
10601 || inst
.operands
[0].reg
== inst
.operands
[2].reg
, BAD_OVERLAP
);
10606 /* ARM V6 SXTAH extracts a 16-bit value from a register, sign
10607 extends it to 32-bits, and adds the result to a value in another
10608 register. You can specify a rotation by 0, 8, 16, or 24 bits
10609 before extracting the 16-bit value.
10610 SXTAH{<cond>} <Rd>, <Rn>, <Rm>{, <rotation>}
10611 Condition defaults to COND_ALWAYS.
10612 Error if any register uses R15. */
10617 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
10618 inst
.instruction
|= inst
.operands
[1].reg
<< 16;
10619 inst
.instruction
|= inst
.operands
[2].reg
;
10620 inst
.instruction
|= inst
.operands
[3].imm
<< 10;
10625 SXTH {<cond>} <Rd>, <Rm>{, <rotation>}
10626 Condition defaults to COND_ALWAYS.
10627 Error if any register uses R15. */
10632 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
10633 inst
.instruction
|= inst
.operands
[1].reg
;
10634 inst
.instruction
|= inst
.operands
[2].imm
<< 10;
10637 /* VFP instructions. In a logical order: SP variant first, monad
10638 before dyad, arithmetic then move then load/store. */
10641 do_vfp_sp_monadic (void)
10643 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant
, fpu_vfp_ext_v1xd
)
10644 && !ARM_CPU_HAS_FEATURE (cpu_variant
, mve_ext
),
10647 encode_arm_vfp_reg (inst
.operands
[0].reg
, VFP_REG_Sd
);
10648 encode_arm_vfp_reg (inst
.operands
[1].reg
, VFP_REG_Sm
);
10652 do_vfp_sp_dyadic (void)
10654 encode_arm_vfp_reg (inst
.operands
[0].reg
, VFP_REG_Sd
);
10655 encode_arm_vfp_reg (inst
.operands
[1].reg
, VFP_REG_Sn
);
10656 encode_arm_vfp_reg (inst
.operands
[2].reg
, VFP_REG_Sm
);
10660 do_vfp_sp_compare_z (void)
10662 encode_arm_vfp_reg (inst
.operands
[0].reg
, VFP_REG_Sd
);
10666 do_vfp_dp_sp_cvt (void)
10668 encode_arm_vfp_reg (inst
.operands
[0].reg
, VFP_REG_Dd
);
10669 encode_arm_vfp_reg (inst
.operands
[1].reg
, VFP_REG_Sm
);
10673 do_vfp_sp_dp_cvt (void)
10675 encode_arm_vfp_reg (inst
.operands
[0].reg
, VFP_REG_Sd
);
10676 encode_arm_vfp_reg (inst
.operands
[1].reg
, VFP_REG_Dm
);
10680 do_vfp_reg_from_sp (void)
10682 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant
, fpu_vfp_ext_v1xd
)
10683 && !ARM_CPU_HAS_FEATURE (cpu_variant
, mve_ext
),
10686 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
10687 encode_arm_vfp_reg (inst
.operands
[1].reg
, VFP_REG_Sn
);
10691 do_vfp_reg2_from_sp2 (void)
10693 constraint (inst
.operands
[2].imm
!= 2,
10694 _("only two consecutive VFP SP registers allowed here"));
10695 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
10696 inst
.instruction
|= inst
.operands
[1].reg
<< 16;
10697 encode_arm_vfp_reg (inst
.operands
[2].reg
, VFP_REG_Sm
);
10701 do_vfp_sp_from_reg (void)
10703 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant
, fpu_vfp_ext_v1xd
)
10704 && !ARM_CPU_HAS_FEATURE (cpu_variant
, mve_ext
),
10707 encode_arm_vfp_reg (inst
.operands
[0].reg
, VFP_REG_Sn
);
10708 inst
.instruction
|= inst
.operands
[1].reg
<< 12;
10712 do_vfp_sp2_from_reg2 (void)
10714 constraint (inst
.operands
[0].imm
!= 2,
10715 _("only two consecutive VFP SP registers allowed here"));
10716 encode_arm_vfp_reg (inst
.operands
[0].reg
, VFP_REG_Sm
);
10717 inst
.instruction
|= inst
.operands
[1].reg
<< 12;
10718 inst
.instruction
|= inst
.operands
[2].reg
<< 16;
10722 do_vfp_sp_ldst (void)
10724 encode_arm_vfp_reg (inst
.operands
[0].reg
, VFP_REG_Sd
);
10725 encode_arm_cp_address (1, FALSE
, TRUE
, 0);
10729 do_vfp_dp_ldst (void)
10731 encode_arm_vfp_reg (inst
.operands
[0].reg
, VFP_REG_Dd
);
10732 encode_arm_cp_address (1, FALSE
, TRUE
, 0);
10737 vfp_sp_ldstm (enum vfp_ldstm_type ldstm_type
)
10739 if (inst
.operands
[0].writeback
)
10740 inst
.instruction
|= WRITE_BACK
;
10742 constraint (ldstm_type
!= VFP_LDSTMIA
,
10743 _("this addressing mode requires base-register writeback"));
10744 inst
.instruction
|= inst
.operands
[0].reg
<< 16;
10745 encode_arm_vfp_reg (inst
.operands
[1].reg
, VFP_REG_Sd
);
10746 inst
.instruction
|= inst
.operands
[1].imm
;
10750 vfp_dp_ldstm (enum vfp_ldstm_type ldstm_type
)
10754 if (inst
.operands
[0].writeback
)
10755 inst
.instruction
|= WRITE_BACK
;
10757 constraint (ldstm_type
!= VFP_LDSTMIA
&& ldstm_type
!= VFP_LDSTMIAX
,
10758 _("this addressing mode requires base-register writeback"));
10760 inst
.instruction
|= inst
.operands
[0].reg
<< 16;
10761 encode_arm_vfp_reg (inst
.operands
[1].reg
, VFP_REG_Dd
);
10763 count
= inst
.operands
[1].imm
<< 1;
10764 if (ldstm_type
== VFP_LDSTMIAX
|| ldstm_type
== VFP_LDSTMDBX
)
10767 inst
.instruction
|= count
;
10771 do_vfp_sp_ldstmia (void)
10773 vfp_sp_ldstm (VFP_LDSTMIA
);
10777 do_vfp_sp_ldstmdb (void)
10779 vfp_sp_ldstm (VFP_LDSTMDB
);
10783 do_vfp_dp_ldstmia (void)
10785 vfp_dp_ldstm (VFP_LDSTMIA
);
10789 do_vfp_dp_ldstmdb (void)
10791 vfp_dp_ldstm (VFP_LDSTMDB
);
10795 do_vfp_xp_ldstmia (void)
10797 vfp_dp_ldstm (VFP_LDSTMIAX
);
10801 do_vfp_xp_ldstmdb (void)
10803 vfp_dp_ldstm (VFP_LDSTMDBX
);
10807 do_vfp_dp_rd_rm (void)
10809 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant
, fpu_vfp_ext_v1
)
10810 && !ARM_CPU_HAS_FEATURE (cpu_variant
, mve_ext
),
10813 encode_arm_vfp_reg (inst
.operands
[0].reg
, VFP_REG_Dd
);
10814 encode_arm_vfp_reg (inst
.operands
[1].reg
, VFP_REG_Dm
);
10818 do_vfp_dp_rn_rd (void)
10820 encode_arm_vfp_reg (inst
.operands
[0].reg
, VFP_REG_Dn
);
10821 encode_arm_vfp_reg (inst
.operands
[1].reg
, VFP_REG_Dd
);
10825 do_vfp_dp_rd_rn (void)
10827 encode_arm_vfp_reg (inst
.operands
[0].reg
, VFP_REG_Dd
);
10828 encode_arm_vfp_reg (inst
.operands
[1].reg
, VFP_REG_Dn
);
10832 do_vfp_dp_rd_rn_rm (void)
10834 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant
, fpu_vfp_ext_v2
)
10835 && !ARM_CPU_HAS_FEATURE (cpu_variant
, mve_ext
),
10838 encode_arm_vfp_reg (inst
.operands
[0].reg
, VFP_REG_Dd
);
10839 encode_arm_vfp_reg (inst
.operands
[1].reg
, VFP_REG_Dn
);
10840 encode_arm_vfp_reg (inst
.operands
[2].reg
, VFP_REG_Dm
);
10844 do_vfp_dp_rd (void)
10846 encode_arm_vfp_reg (inst
.operands
[0].reg
, VFP_REG_Dd
);
10850 do_vfp_dp_rm_rd_rn (void)
10852 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant
, fpu_vfp_ext_v2
)
10853 && !ARM_CPU_HAS_FEATURE (cpu_variant
, mve_ext
),
10856 encode_arm_vfp_reg (inst
.operands
[0].reg
, VFP_REG_Dm
);
10857 encode_arm_vfp_reg (inst
.operands
[1].reg
, VFP_REG_Dd
);
10858 encode_arm_vfp_reg (inst
.operands
[2].reg
, VFP_REG_Dn
);
10861 /* VFPv3 instructions. */
10863 do_vfp_sp_const (void)
10865 encode_arm_vfp_reg (inst
.operands
[0].reg
, VFP_REG_Sd
);
10866 inst
.instruction
|= (inst
.operands
[1].imm
& 0xf0) << 12;
10867 inst
.instruction
|= (inst
.operands
[1].imm
& 0x0f);
10871 do_vfp_dp_const (void)
10873 encode_arm_vfp_reg (inst
.operands
[0].reg
, VFP_REG_Dd
);
10874 inst
.instruction
|= (inst
.operands
[1].imm
& 0xf0) << 12;
10875 inst
.instruction
|= (inst
.operands
[1].imm
& 0x0f);
10879 vfp_conv (int srcsize
)
10881 int immbits
= srcsize
- inst
.operands
[1].imm
;
10883 if (srcsize
== 16 && !(immbits
>= 0 && immbits
<= srcsize
))
10885 /* If srcsize is 16, inst.operands[1].imm must be in the range 0-16.
10886 i.e. immbits must be in range 0 - 16. */
10887 inst
.error
= _("immediate value out of range, expected range [0, 16]");
10890 else if (srcsize
== 32 && !(immbits
>= 0 && immbits
< srcsize
))
10892 /* If srcsize is 32, inst.operands[1].imm must be in the range 1-32.
10893 i.e. immbits must be in range 0 - 31. */
10894 inst
.error
= _("immediate value out of range, expected range [1, 32]");
10898 inst
.instruction
|= (immbits
& 1) << 5;
10899 inst
.instruction
|= (immbits
>> 1);
10903 do_vfp_sp_conv_16 (void)
10905 encode_arm_vfp_reg (inst
.operands
[0].reg
, VFP_REG_Sd
);
10910 do_vfp_dp_conv_16 (void)
10912 encode_arm_vfp_reg (inst
.operands
[0].reg
, VFP_REG_Dd
);
10917 do_vfp_sp_conv_32 (void)
10919 encode_arm_vfp_reg (inst
.operands
[0].reg
, VFP_REG_Sd
);
10924 do_vfp_dp_conv_32 (void)
10926 encode_arm_vfp_reg (inst
.operands
[0].reg
, VFP_REG_Dd
);
10930 /* FPA instructions. Also in a logical order. */
10935 inst
.instruction
|= inst
.operands
[0].reg
<< 16;
10936 inst
.instruction
|= inst
.operands
[1].reg
;
10940 do_fpa_ldmstm (void)
10942 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
10943 switch (inst
.operands
[1].imm
)
10945 case 1: inst
.instruction
|= CP_T_X
; break;
10946 case 2: inst
.instruction
|= CP_T_Y
; break;
10947 case 3: inst
.instruction
|= CP_T_Y
| CP_T_X
; break;
10952 if (inst
.instruction
& (PRE_INDEX
| INDEX_UP
))
10954 /* The instruction specified "ea" or "fd", so we can only accept
10955 [Rn]{!}. The instruction does not really support stacking or
10956 unstacking, so we have to emulate these by setting appropriate
10957 bits and offsets. */
10958 constraint (inst
.relocs
[0].exp
.X_op
!= O_constant
10959 || inst
.relocs
[0].exp
.X_add_number
!= 0,
10960 _("this instruction does not support indexing"));
10962 if ((inst
.instruction
& PRE_INDEX
) || inst
.operands
[2].writeback
)
10963 inst
.relocs
[0].exp
.X_add_number
= 12 * inst
.operands
[1].imm
;
10965 if (!(inst
.instruction
& INDEX_UP
))
10966 inst
.relocs
[0].exp
.X_add_number
= -inst
.relocs
[0].exp
.X_add_number
;
10968 if (!(inst
.instruction
& PRE_INDEX
) && inst
.operands
[2].writeback
)
10970 inst
.operands
[2].preind
= 0;
10971 inst
.operands
[2].postind
= 1;
10975 encode_arm_cp_address (2, TRUE
, TRUE
, 0);
10978 /* iWMMXt instructions: strictly in alphabetical order. */
10981 do_iwmmxt_tandorc (void)
10983 constraint (inst
.operands
[0].reg
!= REG_PC
, _("only r15 allowed here"));
10987 do_iwmmxt_textrc (void)
10989 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
10990 inst
.instruction
|= inst
.operands
[1].imm
;
10994 do_iwmmxt_textrm (void)
10996 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
10997 inst
.instruction
|= inst
.operands
[1].reg
<< 16;
10998 inst
.instruction
|= inst
.operands
[2].imm
;
11002 do_iwmmxt_tinsr (void)
11004 inst
.instruction
|= inst
.operands
[0].reg
<< 16;
11005 inst
.instruction
|= inst
.operands
[1].reg
<< 12;
11006 inst
.instruction
|= inst
.operands
[2].imm
;
11010 do_iwmmxt_tmia (void)
11012 inst
.instruction
|= inst
.operands
[0].reg
<< 5;
11013 inst
.instruction
|= inst
.operands
[1].reg
;
11014 inst
.instruction
|= inst
.operands
[2].reg
<< 12;
11018 do_iwmmxt_waligni (void)
11020 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
11021 inst
.instruction
|= inst
.operands
[1].reg
<< 16;
11022 inst
.instruction
|= inst
.operands
[2].reg
;
11023 inst
.instruction
|= inst
.operands
[3].imm
<< 20;
11027 do_iwmmxt_wmerge (void)
11029 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
11030 inst
.instruction
|= inst
.operands
[1].reg
<< 16;
11031 inst
.instruction
|= inst
.operands
[2].reg
;
11032 inst
.instruction
|= inst
.operands
[3].imm
<< 21;
11036 do_iwmmxt_wmov (void)
11038 /* WMOV rD, rN is an alias for WOR rD, rN, rN. */
11039 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
11040 inst
.instruction
|= inst
.operands
[1].reg
<< 16;
11041 inst
.instruction
|= inst
.operands
[1].reg
;
11045 do_iwmmxt_wldstbh (void)
11048 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
11050 reloc
= BFD_RELOC_ARM_T32_CP_OFF_IMM_S2
;
11052 reloc
= BFD_RELOC_ARM_CP_OFF_IMM_S2
;
11053 encode_arm_cp_address (1, TRUE
, FALSE
, reloc
);
11057 do_iwmmxt_wldstw (void)
11059 /* RIWR_RIWC clears .isreg for a control register. */
11060 if (!inst
.operands
[0].isreg
)
11062 constraint (inst
.cond
!= COND_ALWAYS
, BAD_COND
);
11063 inst
.instruction
|= 0xf0000000;
11066 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
11067 encode_arm_cp_address (1, TRUE
, TRUE
, 0);
11071 do_iwmmxt_wldstd (void)
11073 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
11074 if (ARM_CPU_HAS_FEATURE (cpu_variant
, arm_cext_iwmmxt2
)
11075 && inst
.operands
[1].immisreg
)
11077 inst
.instruction
&= ~0x1a000ff;
11078 inst
.instruction
|= (0xfU
<< 28);
11079 if (inst
.operands
[1].preind
)
11080 inst
.instruction
|= PRE_INDEX
;
11081 if (!inst
.operands
[1].negative
)
11082 inst
.instruction
|= INDEX_UP
;
11083 if (inst
.operands
[1].writeback
)
11084 inst
.instruction
|= WRITE_BACK
;
11085 inst
.instruction
|= inst
.operands
[1].reg
<< 16;
11086 inst
.instruction
|= inst
.relocs
[0].exp
.X_add_number
<< 4;
11087 inst
.instruction
|= inst
.operands
[1].imm
;
11090 encode_arm_cp_address (1, TRUE
, FALSE
, 0);
11094 do_iwmmxt_wshufh (void)
11096 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
11097 inst
.instruction
|= inst
.operands
[1].reg
<< 16;
11098 inst
.instruction
|= ((inst
.operands
[2].imm
& 0xf0) << 16);
11099 inst
.instruction
|= (inst
.operands
[2].imm
& 0x0f);
11103 do_iwmmxt_wzero (void)
11105 /* WZERO reg is an alias for WANDN reg, reg, reg. */
11106 inst
.instruction
|= inst
.operands
[0].reg
;
11107 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
11108 inst
.instruction
|= inst
.operands
[0].reg
<< 16;
11112 do_iwmmxt_wrwrwr_or_imm5 (void)
11114 if (inst
.operands
[2].isreg
)
11117 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant
, arm_cext_iwmmxt2
),
11118 _("immediate operand requires iWMMXt2"));
11120 if (inst
.operands
[2].imm
== 0)
11122 switch ((inst
.instruction
>> 20) & 0xf)
11128 /* w...h wrd, wrn, #0 -> wrorh wrd, wrn, #16. */
11129 inst
.operands
[2].imm
= 16;
11130 inst
.instruction
= (inst
.instruction
& 0xff0fffff) | (0x7 << 20);
11136 /* w...w wrd, wrn, #0 -> wrorw wrd, wrn, #32. */
11137 inst
.operands
[2].imm
= 32;
11138 inst
.instruction
= (inst
.instruction
& 0xff0fffff) | (0xb << 20);
11145 /* w...d wrd, wrn, #0 -> wor wrd, wrn, wrn. */
11147 wrn
= (inst
.instruction
>> 16) & 0xf;
11148 inst
.instruction
&= 0xff0fff0f;
11149 inst
.instruction
|= wrn
;
11150 /* Bail out here; the instruction is now assembled. */
11155 /* Map 32 -> 0, etc. */
11156 inst
.operands
[2].imm
&= 0x1f;
11157 inst
.instruction
|= (0xfU
<< 28) | ((inst
.operands
[2].imm
& 0x10) << 4) | (inst
.operands
[2].imm
& 0xf);
11161 /* Cirrus Maverick instructions. Simple 2-, 3-, and 4-register
11162 operations first, then control, shift, and load/store. */
11164 /* Insns like "foo X,Y,Z". */
11167 do_mav_triple (void)
11169 inst
.instruction
|= inst
.operands
[0].reg
<< 16;
11170 inst
.instruction
|= inst
.operands
[1].reg
;
11171 inst
.instruction
|= inst
.operands
[2].reg
<< 12;
11174 /* Insns like "foo W,X,Y,Z".
11175 where W=MVAX[0:3] and X,Y,Z=MVFX[0:15]. */
11180 inst
.instruction
|= inst
.operands
[0].reg
<< 5;
11181 inst
.instruction
|= inst
.operands
[1].reg
<< 12;
11182 inst
.instruction
|= inst
.operands
[2].reg
<< 16;
11183 inst
.instruction
|= inst
.operands
[3].reg
;
11186 /* cfmvsc32<cond> DSPSC,MVDX[15:0]. */
11188 do_mav_dspsc (void)
11190 inst
.instruction
|= inst
.operands
[1].reg
<< 12;
11193 /* Maverick shift immediate instructions.
11194 cfsh32<cond> MVFX[15:0],MVFX[15:0],Shift[6:0].
11195 cfsh64<cond> MVDX[15:0],MVDX[15:0],Shift[6:0]. */
11198 do_mav_shift (void)
11200 int imm
= inst
.operands
[2].imm
;
11202 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
11203 inst
.instruction
|= inst
.operands
[1].reg
<< 16;
11205 /* Bits 0-3 of the insn should have bits 0-3 of the immediate.
11206 Bits 5-7 of the insn should have bits 4-6 of the immediate.
11207 Bit 4 should be 0. */
11208 imm
= (imm
& 0xf) | ((imm
& 0x70) << 1);
11210 inst
.instruction
|= imm
;
11213 /* XScale instructions. Also sorted arithmetic before move. */
11215 /* Xscale multiply-accumulate (argument parse)
11218 MIAxycc acc0,Rm,Rs. */
11223 inst
.instruction
|= inst
.operands
[1].reg
;
11224 inst
.instruction
|= inst
.operands
[2].reg
<< 12;
11227 /* Xscale move-accumulator-register (argument parse)
11229 MARcc acc0,RdLo,RdHi. */
11234 inst
.instruction
|= inst
.operands
[1].reg
<< 12;
11235 inst
.instruction
|= inst
.operands
[2].reg
<< 16;
11238 /* Xscale move-register-accumulator (argument parse)
11240 MRAcc RdLo,RdHi,acc0. */
11245 constraint (inst
.operands
[0].reg
== inst
.operands
[1].reg
, BAD_OVERLAP
);
11246 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
11247 inst
.instruction
|= inst
.operands
[1].reg
<< 16;
11250 /* Encoding functions relevant only to Thumb. */
11252 /* inst.operands[i] is a shifted-register operand; encode
11253 it into inst.instruction in the format used by Thumb32. */
11256 encode_thumb32_shifted_operand (int i
)
11258 unsigned int value
= inst
.relocs
[0].exp
.X_add_number
;
11259 unsigned int shift
= inst
.operands
[i
].shift_kind
;
11261 constraint (inst
.operands
[i
].immisreg
,
11262 _("shift by register not allowed in thumb mode"));
11263 inst
.instruction
|= inst
.operands
[i
].reg
;
11264 if (shift
== SHIFT_RRX
)
11265 inst
.instruction
|= SHIFT_ROR
<< 4;
11268 constraint (inst
.relocs
[0].exp
.X_op
!= O_constant
,
11269 _("expression too complex"));
11271 constraint (value
> 32
11272 || (value
== 32 && (shift
== SHIFT_LSL
11273 || shift
== SHIFT_ROR
)),
11274 _("shift expression is too large"));
11278 else if (value
== 32)
11281 inst
.instruction
|= shift
<< 4;
11282 inst
.instruction
|= (value
& 0x1c) << 10;
11283 inst
.instruction
|= (value
& 0x03) << 6;
11288 /* inst.operands[i] was set up by parse_address. Encode it into a
11289 Thumb32 format load or store instruction. Reject forms that cannot
11290 be used with such instructions. If is_t is true, reject forms that
11291 cannot be used with a T instruction; if is_d is true, reject forms
11292 that cannot be used with a D instruction. If it is a store insn,
11293 reject PC in Rn. */
11296 encode_thumb32_addr_mode (int i
, bfd_boolean is_t
, bfd_boolean is_d
)
11298 const bfd_boolean is_pc
= (inst
.operands
[i
].reg
== REG_PC
);
11300 constraint (!inst
.operands
[i
].isreg
,
11301 _("Instruction does not support =N addresses"));
11303 inst
.instruction
|= inst
.operands
[i
].reg
<< 16;
11304 if (inst
.operands
[i
].immisreg
)
11306 constraint (is_pc
, BAD_PC_ADDRESSING
);
11307 constraint (is_t
|| is_d
, _("cannot use register index with this instruction"));
11308 constraint (inst
.operands
[i
].negative
,
11309 _("Thumb does not support negative register indexing"));
11310 constraint (inst
.operands
[i
].postind
,
11311 _("Thumb does not support register post-indexing"));
11312 constraint (inst
.operands
[i
].writeback
,
11313 _("Thumb does not support register indexing with writeback"));
11314 constraint (inst
.operands
[i
].shifted
&& inst
.operands
[i
].shift_kind
!= SHIFT_LSL
,
11315 _("Thumb supports only LSL in shifted register indexing"));
11317 inst
.instruction
|= inst
.operands
[i
].imm
;
11318 if (inst
.operands
[i
].shifted
)
11320 constraint (inst
.relocs
[0].exp
.X_op
!= O_constant
,
11321 _("expression too complex"));
11322 constraint (inst
.relocs
[0].exp
.X_add_number
< 0
11323 || inst
.relocs
[0].exp
.X_add_number
> 3,
11324 _("shift out of range"));
11325 inst
.instruction
|= inst
.relocs
[0].exp
.X_add_number
<< 4;
11327 inst
.relocs
[0].type
= BFD_RELOC_UNUSED
;
11329 else if (inst
.operands
[i
].preind
)
11331 constraint (is_pc
&& inst
.operands
[i
].writeback
, BAD_PC_WRITEBACK
);
11332 constraint (is_t
&& inst
.operands
[i
].writeback
,
11333 _("cannot use writeback with this instruction"));
11334 constraint (is_pc
&& ((inst
.instruction
& THUMB2_LOAD_BIT
) == 0),
11335 BAD_PC_ADDRESSING
);
11339 inst
.instruction
|= 0x01000000;
11340 if (inst
.operands
[i
].writeback
)
11341 inst
.instruction
|= 0x00200000;
11345 inst
.instruction
|= 0x00000c00;
11346 if (inst
.operands
[i
].writeback
)
11347 inst
.instruction
|= 0x00000100;
11349 inst
.relocs
[0].type
= BFD_RELOC_ARM_T32_OFFSET_IMM
;
11351 else if (inst
.operands
[i
].postind
)
11353 gas_assert (inst
.operands
[i
].writeback
);
11354 constraint (is_pc
, _("cannot use post-indexing with PC-relative addressing"));
11355 constraint (is_t
, _("cannot use post-indexing with this instruction"));
11358 inst
.instruction
|= 0x00200000;
11360 inst
.instruction
|= 0x00000900;
11361 inst
.relocs
[0].type
= BFD_RELOC_ARM_T32_OFFSET_IMM
;
11363 else /* unindexed - only for coprocessor */
11364 inst
.error
= _("instruction does not accept unindexed addressing");
11367 /* Table of Thumb instructions which exist in 16- and/or 32-bit
11368 encodings (the latter only in post-V6T2 cores). The index is the
11369 value used in the insns table below. When there is more than one
11370 possible 16-bit encoding for the instruction, this table always
11372 Also contains several pseudo-instructions used during relaxation. */
11373 #define T16_32_TAB \
11374 X(_adc, 4140, eb400000), \
11375 X(_adcs, 4140, eb500000), \
11376 X(_add, 1c00, eb000000), \
11377 X(_adds, 1c00, eb100000), \
11378 X(_addi, 0000, f1000000), \
11379 X(_addis, 0000, f1100000), \
11380 X(_add_pc,000f, f20f0000), \
11381 X(_add_sp,000d, f10d0000), \
11382 X(_adr, 000f, f20f0000), \
11383 X(_and, 4000, ea000000), \
11384 X(_ands, 4000, ea100000), \
11385 X(_asr, 1000, fa40f000), \
11386 X(_asrs, 1000, fa50f000), \
11387 X(_b, e000, f000b000), \
11388 X(_bcond, d000, f0008000), \
11389 X(_bf, 0000, f040e001), \
11390 X(_bfcsel,0000, f000e001), \
11391 X(_bfx, 0000, f060e001), \
11392 X(_bfl, 0000, f000c001), \
11393 X(_bflx, 0000, f070e001), \
11394 X(_bic, 4380, ea200000), \
11395 X(_bics, 4380, ea300000), \
11396 X(_cinc, 0000, ea509000), \
11397 X(_cinv, 0000, ea50a000), \
11398 X(_cmn, 42c0, eb100f00), \
11399 X(_cmp, 2800, ebb00f00), \
11400 X(_cneg, 0000, ea50b000), \
11401 X(_cpsie, b660, f3af8400), \
11402 X(_cpsid, b670, f3af8600), \
11403 X(_cpy, 4600, ea4f0000), \
11404 X(_csel, 0000, ea508000), \
11405 X(_cset, 0000, ea5f900f), \
11406 X(_csetm, 0000, ea5fa00f), \
11407 X(_csinc, 0000, ea509000), \
11408 X(_csinv, 0000, ea50a000), \
11409 X(_csneg, 0000, ea50b000), \
11410 X(_dec_sp,80dd, f1ad0d00), \
11411 X(_dls, 0000, f040e001), \
11412 X(_dlstp, 0000, f000e001), \
11413 X(_eor, 4040, ea800000), \
11414 X(_eors, 4040, ea900000), \
11415 X(_inc_sp,00dd, f10d0d00), \
11416 X(_lctp, 0000, f00fe001), \
11417 X(_ldmia, c800, e8900000), \
11418 X(_ldr, 6800, f8500000), \
11419 X(_ldrb, 7800, f8100000), \
11420 X(_ldrh, 8800, f8300000), \
11421 X(_ldrsb, 5600, f9100000), \
11422 X(_ldrsh, 5e00, f9300000), \
11423 X(_ldr_pc,4800, f85f0000), \
11424 X(_ldr_pc2,4800, f85f0000), \
11425 X(_ldr_sp,9800, f85d0000), \
11426 X(_le, 0000, f00fc001), \
11427 X(_letp, 0000, f01fc001), \
11428 X(_lsl, 0000, fa00f000), \
11429 X(_lsls, 0000, fa10f000), \
11430 X(_lsr, 0800, fa20f000), \
11431 X(_lsrs, 0800, fa30f000), \
11432 X(_mov, 2000, ea4f0000), \
11433 X(_movs, 2000, ea5f0000), \
11434 X(_mul, 4340, fb00f000), \
11435 X(_muls, 4340, ffffffff), /* no 32b muls */ \
11436 X(_mvn, 43c0, ea6f0000), \
11437 X(_mvns, 43c0, ea7f0000), \
11438 X(_neg, 4240, f1c00000), /* rsb #0 */ \
11439 X(_negs, 4240, f1d00000), /* rsbs #0 */ \
11440 X(_orr, 4300, ea400000), \
11441 X(_orrs, 4300, ea500000), \
11442 X(_pop, bc00, e8bd0000), /* ldmia sp!,... */ \
11443 X(_push, b400, e92d0000), /* stmdb sp!,... */ \
11444 X(_rev, ba00, fa90f080), \
11445 X(_rev16, ba40, fa90f090), \
11446 X(_revsh, bac0, fa90f0b0), \
11447 X(_ror, 41c0, fa60f000), \
11448 X(_rors, 41c0, fa70f000), \
11449 X(_sbc, 4180, eb600000), \
11450 X(_sbcs, 4180, eb700000), \
11451 X(_stmia, c000, e8800000), \
11452 X(_str, 6000, f8400000), \
11453 X(_strb, 7000, f8000000), \
11454 X(_strh, 8000, f8200000), \
11455 X(_str_sp,9000, f84d0000), \
11456 X(_sub, 1e00, eba00000), \
11457 X(_subs, 1e00, ebb00000), \
11458 X(_subi, 8000, f1a00000), \
11459 X(_subis, 8000, f1b00000), \
11460 X(_sxtb, b240, fa4ff080), \
11461 X(_sxth, b200, fa0ff080), \
11462 X(_tst, 4200, ea100f00), \
11463 X(_uxtb, b2c0, fa5ff080), \
11464 X(_uxth, b280, fa1ff080), \
11465 X(_nop, bf00, f3af8000), \
11466 X(_yield, bf10, f3af8001), \
11467 X(_wfe, bf20, f3af8002), \
11468 X(_wfi, bf30, f3af8003), \
11469 X(_wls, 0000, f040c001), \
11470 X(_wlstp, 0000, f000c001), \
11471 X(_sev, bf40, f3af8004), \
11472 X(_sevl, bf50, f3af8005), \
11473 X(_udf, de00, f7f0a000)
11475 /* To catch errors in encoding functions, the codes are all offset by
11476 0xF800, putting them in one of the 32-bit prefix ranges, ergo undefined
11477 as 16-bit instructions. */
11478 #define X(a,b,c) T_MNEM##a
11479 enum t16_32_codes
{ T16_32_OFFSET
= 0xF7FF, T16_32_TAB
};
11482 #define X(a,b,c) 0x##b
11483 static const unsigned short thumb_op16
[] = { T16_32_TAB
};
11484 #define THUMB_OP16(n) (thumb_op16[(n) - (T16_32_OFFSET + 1)])
11487 #define X(a,b,c) 0x##c
11488 static const unsigned int thumb_op32
[] = { T16_32_TAB
};
11489 #define THUMB_OP32(n) (thumb_op32[(n) - (T16_32_OFFSET + 1)])
11490 #define THUMB_SETS_FLAGS(n) (THUMB_OP32 (n) & 0x00100000)
11494 /* Thumb instruction encoders, in alphabetical order. */
11496 /* ADDW or SUBW. */
11499 do_t_add_sub_w (void)
11503 Rd
= inst
.operands
[0].reg
;
11504 Rn
= inst
.operands
[1].reg
;
11506 /* If Rn is REG_PC, this is ADR; if Rn is REG_SP, then this
11507 is the SP-{plus,minus}-immediate form of the instruction. */
11509 constraint (Rd
== REG_PC
, BAD_PC
);
11511 reject_bad_reg (Rd
);
11513 inst
.instruction
|= (Rn
<< 16) | (Rd
<< 8);
11514 inst
.relocs
[0].type
= BFD_RELOC_ARM_T32_IMM12
;
11517 /* Parse an add or subtract instruction. We get here with inst.instruction
11518 equaling any of THUMB_OPCODE_add, adds, sub, or subs. */
11521 do_t_add_sub (void)
11525 Rd
= inst
.operands
[0].reg
;
11526 Rs
= (inst
.operands
[1].present
11527 ? inst
.operands
[1].reg
/* Rd, Rs, foo */
11528 : inst
.operands
[0].reg
); /* Rd, foo -> Rd, Rd, foo */
11531 set_pred_insn_type_last ();
11533 if (unified_syntax
)
11536 bfd_boolean narrow
;
11539 flags
= (inst
.instruction
== T_MNEM_adds
11540 || inst
.instruction
== T_MNEM_subs
);
11542 narrow
= !in_pred_block ();
11544 narrow
= in_pred_block ();
11545 if (!inst
.operands
[2].isreg
)
11549 if (!ARM_CPU_HAS_FEATURE (cpu_variant
, arm_ext_v8
))
11550 constraint (Rd
== REG_SP
&& Rs
!= REG_SP
, BAD_SP
);
11552 add
= (inst
.instruction
== T_MNEM_add
11553 || inst
.instruction
== T_MNEM_adds
);
11555 if (inst
.size_req
!= 4)
11557 /* Attempt to use a narrow opcode, with relaxation if
11559 if (Rd
== REG_SP
&& Rs
== REG_SP
&& !flags
)
11560 opcode
= add
? T_MNEM_inc_sp
: T_MNEM_dec_sp
;
11561 else if (Rd
<= 7 && Rs
== REG_SP
&& add
&& !flags
)
11562 opcode
= T_MNEM_add_sp
;
11563 else if (Rd
<= 7 && Rs
== REG_PC
&& add
&& !flags
)
11564 opcode
= T_MNEM_add_pc
;
11565 else if (Rd
<= 7 && Rs
<= 7 && narrow
)
11568 opcode
= add
? T_MNEM_addis
: T_MNEM_subis
;
11570 opcode
= add
? T_MNEM_addi
: T_MNEM_subi
;
11574 inst
.instruction
= THUMB_OP16(opcode
);
11575 inst
.instruction
|= (Rd
<< 4) | Rs
;
11576 if (inst
.relocs
[0].type
< BFD_RELOC_ARM_THUMB_ALU_ABS_G0_NC
11577 || (inst
.relocs
[0].type
11578 > BFD_RELOC_ARM_THUMB_ALU_ABS_G3_NC
))
11580 if (inst
.size_req
== 2)
11581 inst
.relocs
[0].type
= BFD_RELOC_ARM_THUMB_ADD
;
11583 inst
.relax
= opcode
;
11587 constraint (inst
.size_req
== 2, BAD_HIREG
);
11589 if (inst
.size_req
== 4
11590 || (inst
.size_req
!= 2 && !opcode
))
11592 constraint ((inst
.relocs
[0].type
11593 >= BFD_RELOC_ARM_THUMB_ALU_ABS_G0_NC
)
11594 && (inst
.relocs
[0].type
11595 <= BFD_RELOC_ARM_THUMB_ALU_ABS_G3_NC
) ,
11596 THUMB1_RELOC_ONLY
);
11599 constraint (add
, BAD_PC
);
11600 constraint (Rs
!= REG_LR
|| inst
.instruction
!= T_MNEM_subs
,
11601 _("only SUBS PC, LR, #const allowed"));
11602 constraint (inst
.relocs
[0].exp
.X_op
!= O_constant
,
11603 _("expression too complex"));
11604 constraint (inst
.relocs
[0].exp
.X_add_number
< 0
11605 || inst
.relocs
[0].exp
.X_add_number
> 0xff,
11606 _("immediate value out of range"));
11607 inst
.instruction
= T2_SUBS_PC_LR
11608 | inst
.relocs
[0].exp
.X_add_number
;
11609 inst
.relocs
[0].type
= BFD_RELOC_UNUSED
;
11612 else if (Rs
== REG_PC
)
11614 /* Always use addw/subw. */
11615 inst
.instruction
= add
? 0xf20f0000 : 0xf2af0000;
11616 inst
.relocs
[0].type
= BFD_RELOC_ARM_T32_IMM12
;
11620 inst
.instruction
= THUMB_OP32 (inst
.instruction
);
11621 inst
.instruction
= (inst
.instruction
& 0xe1ffffff)
11624 inst
.relocs
[0].type
= BFD_RELOC_ARM_T32_IMMEDIATE
;
11626 inst
.relocs
[0].type
= BFD_RELOC_ARM_T32_ADD_IMM
;
11628 inst
.instruction
|= Rd
<< 8;
11629 inst
.instruction
|= Rs
<< 16;
11634 unsigned int value
= inst
.relocs
[0].exp
.X_add_number
;
11635 unsigned int shift
= inst
.operands
[2].shift_kind
;
11637 Rn
= inst
.operands
[2].reg
;
11638 /* See if we can do this with a 16-bit instruction. */
11639 if (!inst
.operands
[2].shifted
&& inst
.size_req
!= 4)
11641 if (Rd
> 7 || Rs
> 7 || Rn
> 7)
11646 inst
.instruction
= ((inst
.instruction
== T_MNEM_adds
11647 || inst
.instruction
== T_MNEM_add
)
11649 : T_OPCODE_SUB_R3
);
11650 inst
.instruction
|= Rd
| (Rs
<< 3) | (Rn
<< 6);
11654 if (inst
.instruction
== T_MNEM_add
&& (Rd
== Rs
|| Rd
== Rn
))
11656 /* Thumb-1 cores (except v6-M) require at least one high
11657 register in a narrow non flag setting add. */
11658 if (Rd
> 7 || Rn
> 7
11659 || ARM_CPU_HAS_FEATURE (selected_cpu
, arm_ext_v6t2
)
11660 || ARM_CPU_HAS_FEATURE (selected_cpu
, arm_ext_msr
))
11667 inst
.instruction
= T_OPCODE_ADD_HI
;
11668 inst
.instruction
|= (Rd
& 8) << 4;
11669 inst
.instruction
|= (Rd
& 7);
11670 inst
.instruction
|= Rn
<< 3;
11676 constraint (Rd
== REG_PC
, BAD_PC
);
11677 if (!ARM_CPU_HAS_FEATURE (cpu_variant
, arm_ext_v8
))
11678 constraint (Rd
== REG_SP
&& Rs
!= REG_SP
, BAD_SP
);
11679 constraint (Rs
== REG_PC
, BAD_PC
);
11680 reject_bad_reg (Rn
);
11682 /* If we get here, it can't be done in 16 bits. */
11683 constraint (inst
.operands
[2].shifted
&& inst
.operands
[2].immisreg
,
11684 _("shift must be constant"));
11685 inst
.instruction
= THUMB_OP32 (inst
.instruction
);
11686 inst
.instruction
|= Rd
<< 8;
11687 inst
.instruction
|= Rs
<< 16;
11688 constraint (Rd
== REG_SP
&& Rs
== REG_SP
&& value
> 3,
11689 _("shift value over 3 not allowed in thumb mode"));
11690 constraint (Rd
== REG_SP
&& Rs
== REG_SP
&& shift
!= SHIFT_LSL
,
11691 _("only LSL shift allowed in thumb mode"));
11692 encode_thumb32_shifted_operand (2);
11697 constraint (inst
.instruction
== T_MNEM_adds
11698 || inst
.instruction
== T_MNEM_subs
,
11701 if (!inst
.operands
[2].isreg
) /* Rd, Rs, #imm */
11703 constraint ((Rd
> 7 && (Rd
!= REG_SP
|| Rs
!= REG_SP
))
11704 || (Rs
> 7 && Rs
!= REG_SP
&& Rs
!= REG_PC
),
11707 inst
.instruction
= (inst
.instruction
== T_MNEM_add
11708 ? 0x0000 : 0x8000);
11709 inst
.instruction
|= (Rd
<< 4) | Rs
;
11710 inst
.relocs
[0].type
= BFD_RELOC_ARM_THUMB_ADD
;
11714 Rn
= inst
.operands
[2].reg
;
11715 constraint (inst
.operands
[2].shifted
, _("unshifted register required"));
11717 /* We now have Rd, Rs, and Rn set to registers. */
11718 if (Rd
> 7 || Rs
> 7 || Rn
> 7)
11720 /* Can't do this for SUB. */
11721 constraint (inst
.instruction
== T_MNEM_sub
, BAD_HIREG
);
11722 inst
.instruction
= T_OPCODE_ADD_HI
;
11723 inst
.instruction
|= (Rd
& 8) << 4;
11724 inst
.instruction
|= (Rd
& 7);
11726 inst
.instruction
|= Rn
<< 3;
11728 inst
.instruction
|= Rs
<< 3;
11730 constraint (1, _("dest must overlap one source register"));
11734 inst
.instruction
= (inst
.instruction
== T_MNEM_add
11735 ? T_OPCODE_ADD_R3
: T_OPCODE_SUB_R3
);
11736 inst
.instruction
|= Rd
| (Rs
<< 3) | (Rn
<< 6);
11746 Rd
= inst
.operands
[0].reg
;
11747 reject_bad_reg (Rd
);
11749 if (unified_syntax
&& inst
.size_req
== 0 && Rd
<= 7)
11751 /* Defer to section relaxation. */
11752 inst
.relax
= inst
.instruction
;
11753 inst
.instruction
= THUMB_OP16 (inst
.instruction
);
11754 inst
.instruction
|= Rd
<< 4;
11756 else if (unified_syntax
&& inst
.size_req
!= 2)
11758 /* Generate a 32-bit opcode. */
11759 inst
.instruction
= THUMB_OP32 (inst
.instruction
);
11760 inst
.instruction
|= Rd
<< 8;
11761 inst
.relocs
[0].type
= BFD_RELOC_ARM_T32_ADD_PC12
;
11762 inst
.relocs
[0].pc_rel
= 1;
11766 /* Generate a 16-bit opcode. */
11767 inst
.instruction
= THUMB_OP16 (inst
.instruction
);
11768 inst
.relocs
[0].type
= BFD_RELOC_ARM_THUMB_ADD
;
11769 inst
.relocs
[0].exp
.X_add_number
-= 4; /* PC relative adjust. */
11770 inst
.relocs
[0].pc_rel
= 1;
11771 inst
.instruction
|= Rd
<< 4;
11774 if (inst
.relocs
[0].exp
.X_op
== O_symbol
11775 && inst
.relocs
[0].exp
.X_add_symbol
!= NULL
11776 && S_IS_DEFINED (inst
.relocs
[0].exp
.X_add_symbol
)
11777 && THUMB_IS_FUNC (inst
.relocs
[0].exp
.X_add_symbol
))
11778 inst
.relocs
[0].exp
.X_add_number
+= 1;
11781 /* Arithmetic instructions for which there is just one 16-bit
11782 instruction encoding, and it allows only two low registers.
11783 For maximal compatibility with ARM syntax, we allow three register
11784 operands even when Thumb-32 instructions are not available, as long
11785 as the first two are identical. For instance, both "sbc r0,r1" and
11786 "sbc r0,r0,r1" are allowed. */
11792 Rd
= inst
.operands
[0].reg
;
11793 Rs
= (inst
.operands
[1].present
11794 ? inst
.operands
[1].reg
/* Rd, Rs, foo */
11795 : inst
.operands
[0].reg
); /* Rd, foo -> Rd, Rd, foo */
11796 Rn
= inst
.operands
[2].reg
;
11798 reject_bad_reg (Rd
);
11799 reject_bad_reg (Rs
);
11800 if (inst
.operands
[2].isreg
)
11801 reject_bad_reg (Rn
);
11803 if (unified_syntax
)
11805 if (!inst
.operands
[2].isreg
)
11807 /* For an immediate, we always generate a 32-bit opcode;
11808 section relaxation will shrink it later if possible. */
11809 inst
.instruction
= THUMB_OP32 (inst
.instruction
);
11810 inst
.instruction
= (inst
.instruction
& 0xe1ffffff) | 0x10000000;
11811 inst
.instruction
|= Rd
<< 8;
11812 inst
.instruction
|= Rs
<< 16;
11813 inst
.relocs
[0].type
= BFD_RELOC_ARM_T32_IMMEDIATE
;
11817 bfd_boolean narrow
;
11819 /* See if we can do this with a 16-bit instruction. */
11820 if (THUMB_SETS_FLAGS (inst
.instruction
))
11821 narrow
= !in_pred_block ();
11823 narrow
= in_pred_block ();
11825 if (Rd
> 7 || Rn
> 7 || Rs
> 7)
11827 if (inst
.operands
[2].shifted
)
11829 if (inst
.size_req
== 4)
11835 inst
.instruction
= THUMB_OP16 (inst
.instruction
);
11836 inst
.instruction
|= Rd
;
11837 inst
.instruction
|= Rn
<< 3;
11841 /* If we get here, it can't be done in 16 bits. */
11842 constraint (inst
.operands
[2].shifted
11843 && inst
.operands
[2].immisreg
,
11844 _("shift must be constant"));
11845 inst
.instruction
= THUMB_OP32 (inst
.instruction
);
11846 inst
.instruction
|= Rd
<< 8;
11847 inst
.instruction
|= Rs
<< 16;
11848 encode_thumb32_shifted_operand (2);
11853 /* On its face this is a lie - the instruction does set the
11854 flags. However, the only supported mnemonic in this mode
11855 says it doesn't. */
11856 constraint (THUMB_SETS_FLAGS (inst
.instruction
), BAD_THUMB32
);
11858 constraint (!inst
.operands
[2].isreg
|| inst
.operands
[2].shifted
,
11859 _("unshifted register required"));
11860 constraint (Rd
> 7 || Rs
> 7 || Rn
> 7, BAD_HIREG
);
11861 constraint (Rd
!= Rs
,
11862 _("dest and source1 must be the same register"));
11864 inst
.instruction
= THUMB_OP16 (inst
.instruction
);
11865 inst
.instruction
|= Rd
;
11866 inst
.instruction
|= Rn
<< 3;
11870 /* Similarly, but for instructions where the arithmetic operation is
11871 commutative, so we can allow either of them to be different from
11872 the destination operand in a 16-bit instruction. For instance, all
11873 three of "adc r0,r1", "adc r0,r0,r1", and "adc r0,r1,r0" are
11880 Rd
= inst
.operands
[0].reg
;
11881 Rs
= (inst
.operands
[1].present
11882 ? inst
.operands
[1].reg
/* Rd, Rs, foo */
11883 : inst
.operands
[0].reg
); /* Rd, foo -> Rd, Rd, foo */
11884 Rn
= inst
.operands
[2].reg
;
11886 reject_bad_reg (Rd
);
11887 reject_bad_reg (Rs
);
11888 if (inst
.operands
[2].isreg
)
11889 reject_bad_reg (Rn
);
11891 if (unified_syntax
)
11893 if (!inst
.operands
[2].isreg
)
11895 /* For an immediate, we always generate a 32-bit opcode;
11896 section relaxation will shrink it later if possible. */
11897 inst
.instruction
= THUMB_OP32 (inst
.instruction
);
11898 inst
.instruction
= (inst
.instruction
& 0xe1ffffff) | 0x10000000;
11899 inst
.instruction
|= Rd
<< 8;
11900 inst
.instruction
|= Rs
<< 16;
11901 inst
.relocs
[0].type
= BFD_RELOC_ARM_T32_IMMEDIATE
;
11905 bfd_boolean narrow
;
11907 /* See if we can do this with a 16-bit instruction. */
11908 if (THUMB_SETS_FLAGS (inst
.instruction
))
11909 narrow
= !in_pred_block ();
11911 narrow
= in_pred_block ();
11913 if (Rd
> 7 || Rn
> 7 || Rs
> 7)
11915 if (inst
.operands
[2].shifted
)
11917 if (inst
.size_req
== 4)
11924 inst
.instruction
= THUMB_OP16 (inst
.instruction
);
11925 inst
.instruction
|= Rd
;
11926 inst
.instruction
|= Rn
<< 3;
11931 inst
.instruction
= THUMB_OP16 (inst
.instruction
);
11932 inst
.instruction
|= Rd
;
11933 inst
.instruction
|= Rs
<< 3;
11938 /* If we get here, it can't be done in 16 bits. */
11939 constraint (inst
.operands
[2].shifted
11940 && inst
.operands
[2].immisreg
,
11941 _("shift must be constant"));
11942 inst
.instruction
= THUMB_OP32 (inst
.instruction
);
11943 inst
.instruction
|= Rd
<< 8;
11944 inst
.instruction
|= Rs
<< 16;
11945 encode_thumb32_shifted_operand (2);
11950 /* On its face this is a lie - the instruction does set the
11951 flags. However, the only supported mnemonic in this mode
11952 says it doesn't. */
11953 constraint (THUMB_SETS_FLAGS (inst
.instruction
), BAD_THUMB32
);
11955 constraint (!inst
.operands
[2].isreg
|| inst
.operands
[2].shifted
,
11956 _("unshifted register required"));
11957 constraint (Rd
> 7 || Rs
> 7 || Rn
> 7, BAD_HIREG
);
11959 inst
.instruction
= THUMB_OP16 (inst
.instruction
);
11960 inst
.instruction
|= Rd
;
11963 inst
.instruction
|= Rn
<< 3;
11965 inst
.instruction
|= Rs
<< 3;
11967 constraint (1, _("dest must overlap one source register"));
11975 unsigned int msb
= inst
.operands
[1].imm
+ inst
.operands
[2].imm
;
11976 constraint (msb
> 32, _("bit-field extends past end of register"));
11977 /* The instruction encoding stores the LSB and MSB,
11978 not the LSB and width. */
11979 Rd
= inst
.operands
[0].reg
;
11980 reject_bad_reg (Rd
);
11981 inst
.instruction
|= Rd
<< 8;
11982 inst
.instruction
|= (inst
.operands
[1].imm
& 0x1c) << 10;
11983 inst
.instruction
|= (inst
.operands
[1].imm
& 0x03) << 6;
11984 inst
.instruction
|= msb
- 1;
11993 Rd
= inst
.operands
[0].reg
;
11994 reject_bad_reg (Rd
);
11996 /* #0 in second position is alternative syntax for bfc, which is
11997 the same instruction but with REG_PC in the Rm field. */
11998 if (!inst
.operands
[1].isreg
)
12002 Rn
= inst
.operands
[1].reg
;
12003 reject_bad_reg (Rn
);
12006 msb
= inst
.operands
[2].imm
+ inst
.operands
[3].imm
;
12007 constraint (msb
> 32, _("bit-field extends past end of register"));
12008 /* The instruction encoding stores the LSB and MSB,
12009 not the LSB and width. */
12010 inst
.instruction
|= Rd
<< 8;
12011 inst
.instruction
|= Rn
<< 16;
12012 inst
.instruction
|= (inst
.operands
[2].imm
& 0x1c) << 10;
12013 inst
.instruction
|= (inst
.operands
[2].imm
& 0x03) << 6;
12014 inst
.instruction
|= msb
- 1;
12022 Rd
= inst
.operands
[0].reg
;
12023 Rn
= inst
.operands
[1].reg
;
12025 reject_bad_reg (Rd
);
12026 reject_bad_reg (Rn
);
12028 constraint (inst
.operands
[2].imm
+ inst
.operands
[3].imm
> 32,
12029 _("bit-field extends past end of register"));
12030 inst
.instruction
|= Rd
<< 8;
12031 inst
.instruction
|= Rn
<< 16;
12032 inst
.instruction
|= (inst
.operands
[2].imm
& 0x1c) << 10;
12033 inst
.instruction
|= (inst
.operands
[2].imm
& 0x03) << 6;
12034 inst
.instruction
|= inst
.operands
[3].imm
- 1;
12037 /* ARM V5 Thumb BLX (argument parse)
12038 BLX <target_addr> which is BLX(1)
12039 BLX <Rm> which is BLX(2)
12040 Unfortunately, there are two different opcodes for this mnemonic.
12041 So, the insns[].value is not used, and the code here zaps values
12042 into inst.instruction.
12044 ??? How to take advantage of the additional two bits of displacement
12045 available in Thumb32 mode? Need new relocation? */
12050 set_pred_insn_type_last ();
12052 if (inst
.operands
[0].isreg
)
12054 constraint (inst
.operands
[0].reg
== REG_PC
, BAD_PC
);
12055 /* We have a register, so this is BLX(2). */
12056 inst
.instruction
|= inst
.operands
[0].reg
<< 3;
12060 /* No register. This must be BLX(1). */
12061 inst
.instruction
= 0xf000e800;
12062 encode_branch (BFD_RELOC_THUMB_PCREL_BLX
);
12071 bfd_reloc_code_real_type reloc
;
12074 set_pred_insn_type (IF_INSIDE_IT_LAST_INSN
);
12076 if (in_pred_block ())
12078 /* Conditional branches inside IT blocks are encoded as unconditional
12080 cond
= COND_ALWAYS
;
12085 if (cond
!= COND_ALWAYS
)
12086 opcode
= T_MNEM_bcond
;
12088 opcode
= inst
.instruction
;
12091 && (inst
.size_req
== 4
12092 || (inst
.size_req
!= 2
12093 && (inst
.operands
[0].hasreloc
12094 || inst
.relocs
[0].exp
.X_op
== O_constant
))))
12096 inst
.instruction
= THUMB_OP32(opcode
);
12097 if (cond
== COND_ALWAYS
)
12098 reloc
= BFD_RELOC_THUMB_PCREL_BRANCH25
;
12101 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant
, arm_ext_v6t2
),
12102 _("selected architecture does not support "
12103 "wide conditional branch instruction"));
12105 gas_assert (cond
!= 0xF);
12106 inst
.instruction
|= cond
<< 22;
12107 reloc
= BFD_RELOC_THUMB_PCREL_BRANCH20
;
12112 inst
.instruction
= THUMB_OP16(opcode
);
12113 if (cond
== COND_ALWAYS
)
12114 reloc
= BFD_RELOC_THUMB_PCREL_BRANCH12
;
12117 inst
.instruction
|= cond
<< 8;
12118 reloc
= BFD_RELOC_THUMB_PCREL_BRANCH9
;
12120 /* Allow section relaxation. */
12121 if (unified_syntax
&& inst
.size_req
!= 2)
12122 inst
.relax
= opcode
;
12124 inst
.relocs
[0].type
= reloc
;
12125 inst
.relocs
[0].pc_rel
= 1;
12128 /* Actually do the work for Thumb state bkpt and hlt. The only difference
12129 between the two is the maximum immediate allowed - which is passed in
12132 do_t_bkpt_hlt1 (int range
)
12134 constraint (inst
.cond
!= COND_ALWAYS
,
12135 _("instruction is always unconditional"));
12136 if (inst
.operands
[0].present
)
12138 constraint (inst
.operands
[0].imm
> range
,
12139 _("immediate value out of range"));
12140 inst
.instruction
|= inst
.operands
[0].imm
;
12143 set_pred_insn_type (NEUTRAL_IT_INSN
);
12149 do_t_bkpt_hlt1 (63);
12155 do_t_bkpt_hlt1 (255);
12159 do_t_branch23 (void)
12161 set_pred_insn_type_last ();
12162 encode_branch (BFD_RELOC_THUMB_PCREL_BRANCH23
);
12164 /* md_apply_fix blows up with 'bl foo(PLT)' where foo is defined in
12165 this file. We used to simply ignore the PLT reloc type here --
12166 the branch encoding is now needed to deal with TLSCALL relocs.
12167 So if we see a PLT reloc now, put it back to how it used to be to
12168 keep the preexisting behaviour. */
12169 if (inst
.relocs
[0].type
== BFD_RELOC_ARM_PLT32
)
12170 inst
.relocs
[0].type
= BFD_RELOC_THUMB_PCREL_BRANCH23
;
12172 #if defined(OBJ_COFF)
12173 /* If the destination of the branch is a defined symbol which does not have
12174 the THUMB_FUNC attribute, then we must be calling a function which has
12175 the (interfacearm) attribute. We look for the Thumb entry point to that
12176 function and change the branch to refer to that function instead. */
12177 if ( inst
.relocs
[0].exp
.X_op
== O_symbol
12178 && inst
.relocs
[0].exp
.X_add_symbol
!= NULL
12179 && S_IS_DEFINED (inst
.relocs
[0].exp
.X_add_symbol
)
12180 && ! THUMB_IS_FUNC (inst
.relocs
[0].exp
.X_add_symbol
))
12181 inst
.relocs
[0].exp
.X_add_symbol
12182 = find_real_start (inst
.relocs
[0].exp
.X_add_symbol
);
12189 set_pred_insn_type_last ();
12190 inst
.instruction
|= inst
.operands
[0].reg
<< 3;
12191 /* ??? FIXME: Should add a hacky reloc here if reg is REG_PC. The reloc
12192 should cause the alignment to be checked once it is known. This is
12193 because BX PC only works if the instruction is word aligned. */
12201 set_pred_insn_type_last ();
12202 Rm
= inst
.operands
[0].reg
;
12203 reject_bad_reg (Rm
);
12204 inst
.instruction
|= Rm
<< 16;
12213 Rd
= inst
.operands
[0].reg
;
12214 Rm
= inst
.operands
[1].reg
;
12216 reject_bad_reg (Rd
);
12217 reject_bad_reg (Rm
);
12219 inst
.instruction
|= Rd
<< 8;
12220 inst
.instruction
|= Rm
<< 16;
12221 inst
.instruction
|= Rm
;
12224 /* For the Armv8.1-M conditional instructions. */
12228 unsigned Rd
, Rn
, Rm
;
12231 constraint (inst
.cond
!= COND_ALWAYS
, BAD_COND
);
12233 Rd
= inst
.operands
[0].reg
;
12234 switch (inst
.instruction
)
12240 Rn
= inst
.operands
[1].reg
;
12241 Rm
= inst
.operands
[2].reg
;
12242 cond
= inst
.operands
[3].imm
;
12243 constraint (Rn
== REG_SP
, BAD_SP
);
12244 constraint (Rm
== REG_SP
, BAD_SP
);
12250 Rn
= inst
.operands
[1].reg
;
12251 cond
= inst
.operands
[2].imm
;
12252 /* Invert the last bit to invert the cond. */
12253 cond
= TOGGLE_BIT (cond
, 0);
12254 constraint (Rn
== REG_SP
, BAD_SP
);
12260 cond
= inst
.operands
[1].imm
;
12261 /* Invert the last bit to invert the cond. */
12262 cond
= TOGGLE_BIT (cond
, 0);
12270 set_pred_insn_type (OUTSIDE_PRED_INSN
);
12271 inst
.instruction
= THUMB_OP32 (inst
.instruction
);
12272 inst
.instruction
|= Rd
<< 8;
12273 inst
.instruction
|= Rn
<< 16;
12274 inst
.instruction
|= Rm
;
12275 inst
.instruction
|= cond
<< 4;
12281 set_pred_insn_type (OUTSIDE_PRED_INSN
);
12287 set_pred_insn_type (OUTSIDE_PRED_INSN
);
12288 inst
.instruction
|= inst
.operands
[0].imm
;
12294 set_pred_insn_type (OUTSIDE_PRED_INSN
);
12296 && (inst
.operands
[1].present
|| inst
.size_req
== 4)
12297 && ARM_CPU_HAS_FEATURE (cpu_variant
, arm_ext_v6_notm
))
12299 unsigned int imod
= (inst
.instruction
& 0x0030) >> 4;
12300 inst
.instruction
= 0xf3af8000;
12301 inst
.instruction
|= imod
<< 9;
12302 inst
.instruction
|= inst
.operands
[0].imm
<< 5;
12303 if (inst
.operands
[1].present
)
12304 inst
.instruction
|= 0x100 | inst
.operands
[1].imm
;
12308 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant
, arm_ext_v1
)
12309 && (inst
.operands
[0].imm
& 4),
12310 _("selected processor does not support 'A' form "
12311 "of this instruction"));
12312 constraint (inst
.operands
[1].present
|| inst
.size_req
== 4,
12313 _("Thumb does not support the 2-argument "
12314 "form of this instruction"));
12315 inst
.instruction
|= inst
.operands
[0].imm
;
12319 /* THUMB CPY instruction (argument parse). */
12324 if (inst
.size_req
== 4)
12326 inst
.instruction
= THUMB_OP32 (T_MNEM_mov
);
12327 inst
.instruction
|= inst
.operands
[0].reg
<< 8;
12328 inst
.instruction
|= inst
.operands
[1].reg
;
12332 inst
.instruction
|= (inst
.operands
[0].reg
& 0x8) << 4;
12333 inst
.instruction
|= (inst
.operands
[0].reg
& 0x7);
12334 inst
.instruction
|= inst
.operands
[1].reg
<< 3;
12341 set_pred_insn_type (OUTSIDE_PRED_INSN
);
12342 constraint (inst
.operands
[0].reg
> 7, BAD_HIREG
);
12343 inst
.instruction
|= inst
.operands
[0].reg
;
12344 inst
.relocs
[0].pc_rel
= 1;
12345 inst
.relocs
[0].type
= BFD_RELOC_THUMB_PCREL_BRANCH7
;
12351 inst
.instruction
|= inst
.operands
[0].imm
;
12357 unsigned Rd
, Rn
, Rm
;
12359 Rd
= inst
.operands
[0].reg
;
12360 Rn
= (inst
.operands
[1].present
12361 ? inst
.operands
[1].reg
: Rd
);
12362 Rm
= inst
.operands
[2].reg
;
12364 reject_bad_reg (Rd
);
12365 reject_bad_reg (Rn
);
12366 reject_bad_reg (Rm
);
12368 inst
.instruction
|= Rd
<< 8;
12369 inst
.instruction
|= Rn
<< 16;
12370 inst
.instruction
|= Rm
;
12376 if (unified_syntax
&& inst
.size_req
== 4)
12377 inst
.instruction
= THUMB_OP32 (inst
.instruction
);
12379 inst
.instruction
= THUMB_OP16 (inst
.instruction
);
12385 unsigned int cond
= inst
.operands
[0].imm
;
12387 set_pred_insn_type (IT_INSN
);
12388 now_pred
.mask
= (inst
.instruction
& 0xf) | 0x10;
12389 now_pred
.cc
= cond
;
12390 now_pred
.warn_deprecated
= FALSE
;
12391 now_pred
.type
= SCALAR_PRED
;
12393 /* If the condition is a negative condition, invert the mask. */
12394 if ((cond
& 0x1) == 0x0)
12396 unsigned int mask
= inst
.instruction
& 0x000f;
12398 if ((mask
& 0x7) == 0)
12400 /* No conversion needed. */
12401 now_pred
.block_length
= 1;
12403 else if ((mask
& 0x3) == 0)
12406 now_pred
.block_length
= 2;
12408 else if ((mask
& 0x1) == 0)
12411 now_pred
.block_length
= 3;
12416 now_pred
.block_length
= 4;
12419 inst
.instruction
&= 0xfff0;
12420 inst
.instruction
|= mask
;
12423 inst
.instruction
|= cond
<< 4;
12426 /* Helper function used for both push/pop and ldm/stm. */
12428 encode_thumb2_multi (bfd_boolean do_io
, int base
, unsigned mask
,
12429 bfd_boolean writeback
)
12431 bfd_boolean load
, store
;
12433 gas_assert (base
!= -1 || !do_io
);
12434 load
= do_io
&& ((inst
.instruction
& (1 << 20)) != 0);
12435 store
= do_io
&& !load
;
12437 if (mask
& (1 << 13))
12438 inst
.error
= _("SP not allowed in register list");
12440 if (do_io
&& (mask
& (1 << base
)) != 0
12442 inst
.error
= _("having the base register in the register list when "
12443 "using write back is UNPREDICTABLE");
12447 if (mask
& (1 << 15))
12449 if (mask
& (1 << 14))
12450 inst
.error
= _("LR and PC should not both be in register list");
12452 set_pred_insn_type_last ();
12457 if (mask
& (1 << 15))
12458 inst
.error
= _("PC not allowed in register list");
12461 if (do_io
&& ((mask
& (mask
- 1)) == 0))
12463 /* Single register transfers implemented as str/ldr. */
12466 if (inst
.instruction
& (1 << 23))
12467 inst
.instruction
= 0x00000b04; /* ia! -> [base], #4 */
12469 inst
.instruction
= 0x00000d04; /* db! -> [base, #-4]! */
12473 if (inst
.instruction
& (1 << 23))
12474 inst
.instruction
= 0x00800000; /* ia -> [base] */
12476 inst
.instruction
= 0x00000c04; /* db -> [base, #-4] */
12479 inst
.instruction
|= 0xf8400000;
12481 inst
.instruction
|= 0x00100000;
12483 mask
= ffs (mask
) - 1;
12486 else if (writeback
)
12487 inst
.instruction
|= WRITE_BACK
;
12489 inst
.instruction
|= mask
;
12491 inst
.instruction
|= base
<< 16;
12497 /* This really doesn't seem worth it. */
12498 constraint (inst
.relocs
[0].type
!= BFD_RELOC_UNUSED
,
12499 _("expression too complex"));
12500 constraint (inst
.operands
[1].writeback
,
12501 _("Thumb load/store multiple does not support {reglist}^"));
12503 if (unified_syntax
)
12505 bfd_boolean narrow
;
12509 /* See if we can use a 16-bit instruction. */
12510 if (inst
.instruction
< 0xffff /* not ldmdb/stmdb */
12511 && inst
.size_req
!= 4
12512 && !(inst
.operands
[1].imm
& ~0xff))
12514 mask
= 1 << inst
.operands
[0].reg
;
12516 if (inst
.operands
[0].reg
<= 7)
12518 if (inst
.instruction
== T_MNEM_stmia
12519 ? inst
.operands
[0].writeback
12520 : (inst
.operands
[0].writeback
12521 == !(inst
.operands
[1].imm
& mask
)))
12523 if (inst
.instruction
== T_MNEM_stmia
12524 && (inst
.operands
[1].imm
& mask
)
12525 && (inst
.operands
[1].imm
& (mask
- 1)))
12526 as_warn (_("value stored for r%d is UNKNOWN"),
12527 inst
.operands
[0].reg
);
12529 inst
.instruction
= THUMB_OP16 (inst
.instruction
);
12530 inst
.instruction
|= inst
.operands
[0].reg
<< 8;
12531 inst
.instruction
|= inst
.operands
[1].imm
;
12534 else if ((inst
.operands
[1].imm
& (inst
.operands
[1].imm
-1)) == 0)
12536 /* This means 1 register in reg list one of 3 situations:
12537 1. Instruction is stmia, but without writeback.
12538 2. lmdia without writeback, but with Rn not in
12540 3. ldmia with writeback, but with Rn in reglist.
12541 Case 3 is UNPREDICTABLE behaviour, so we handle
12542 case 1 and 2 which can be converted into a 16-bit
12543 str or ldr. The SP cases are handled below. */
12544 unsigned long opcode
;
12545 /* First, record an error for Case 3. */
12546 if (inst
.operands
[1].imm
& mask
12547 && inst
.operands
[0].writeback
)
12549 _("having the base register in the register list when "
12550 "using write back is UNPREDICTABLE");
12552 opcode
= (inst
.instruction
== T_MNEM_stmia
? T_MNEM_str
12554 inst
.instruction
= THUMB_OP16 (opcode
);
12555 inst
.instruction
|= inst
.operands
[0].reg
<< 3;
12556 inst
.instruction
|= (ffs (inst
.operands
[1].imm
)-1);
12560 else if (inst
.operands
[0] .reg
== REG_SP
)
12562 if (inst
.operands
[0].writeback
)
12565 THUMB_OP16 (inst
.instruction
== T_MNEM_stmia
12566 ? T_MNEM_push
: T_MNEM_pop
);
12567 inst
.instruction
|= inst
.operands
[1].imm
;
12570 else if ((inst
.operands
[1].imm
& (inst
.operands
[1].imm
-1)) == 0)
12573 THUMB_OP16 (inst
.instruction
== T_MNEM_stmia
12574 ? T_MNEM_str_sp
: T_MNEM_ldr_sp
);
12575 inst
.instruction
|= ((ffs (inst
.operands
[1].imm
)-1) << 8);
12583 if (inst
.instruction
< 0xffff)
12584 inst
.instruction
= THUMB_OP32 (inst
.instruction
);
12586 encode_thumb2_multi (TRUE
/* do_io */, inst
.operands
[0].reg
,
12587 inst
.operands
[1].imm
,
12588 inst
.operands
[0].writeback
);
12593 constraint (inst
.operands
[0].reg
> 7
12594 || (inst
.operands
[1].imm
& ~0xff), BAD_HIREG
);
12595 constraint (inst
.instruction
!= T_MNEM_ldmia
12596 && inst
.instruction
!= T_MNEM_stmia
,
12597 _("Thumb-2 instruction only valid in unified syntax"));
12598 if (inst
.instruction
== T_MNEM_stmia
)
12600 if (!inst
.operands
[0].writeback
)
12601 as_warn (_("this instruction will write back the base register"));
12602 if ((inst
.operands
[1].imm
& (1 << inst
.operands
[0].reg
))
12603 && (inst
.operands
[1].imm
& ((1 << inst
.operands
[0].reg
) - 1)))
12604 as_warn (_("value stored for r%d is UNKNOWN"),
12605 inst
.operands
[0].reg
);
12609 if (!inst
.operands
[0].writeback
12610 && !(inst
.operands
[1].imm
& (1 << inst
.operands
[0].reg
)))
12611 as_warn (_("this instruction will write back the base register"));
12612 else if (inst
.operands
[0].writeback
12613 && (inst
.operands
[1].imm
& (1 << inst
.operands
[0].reg
)))
12614 as_warn (_("this instruction will not write back the base register"));
12617 inst
.instruction
= THUMB_OP16 (inst
.instruction
);
12618 inst
.instruction
|= inst
.operands
[0].reg
<< 8;
12619 inst
.instruction
|= inst
.operands
[1].imm
;
12626 constraint (!inst
.operands
[1].isreg
|| !inst
.operands
[1].preind
12627 || inst
.operands
[1].postind
|| inst
.operands
[1].writeback
12628 || inst
.operands
[1].immisreg
|| inst
.operands
[1].shifted
12629 || inst
.operands
[1].negative
,
12632 constraint ((inst
.operands
[1].reg
== REG_PC
), BAD_PC
);
12634 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
12635 inst
.instruction
|= inst
.operands
[1].reg
<< 16;
12636 inst
.relocs
[0].type
= BFD_RELOC_ARM_T32_OFFSET_U8
;
12642 if (!inst
.operands
[1].present
)
12644 constraint (inst
.operands
[0].reg
== REG_LR
,
12645 _("r14 not allowed as first register "
12646 "when second register is omitted"));
12647 inst
.operands
[1].reg
= inst
.operands
[0].reg
+ 1;
12649 constraint (inst
.operands
[0].reg
== inst
.operands
[1].reg
,
12652 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
12653 inst
.instruction
|= inst
.operands
[1].reg
<< 8;
12654 inst
.instruction
|= inst
.operands
[2].reg
<< 16;
12660 unsigned long opcode
;
12663 if (inst
.operands
[0].isreg
12664 && !inst
.operands
[0].preind
12665 && inst
.operands
[0].reg
== REG_PC
)
12666 set_pred_insn_type_last ();
12668 opcode
= inst
.instruction
;
12669 if (unified_syntax
)
12671 if (!inst
.operands
[1].isreg
)
12673 if (opcode
<= 0xffff)
12674 inst
.instruction
= THUMB_OP32 (opcode
);
12675 if (move_or_literal_pool (0, CONST_THUMB
, /*mode_3=*/FALSE
))
12678 if (inst
.operands
[1].isreg
12679 && !inst
.operands
[1].writeback
12680 && !inst
.operands
[1].shifted
&& !inst
.operands
[1].postind
12681 && !inst
.operands
[1].negative
&& inst
.operands
[0].reg
<= 7
12682 && opcode
<= 0xffff
12683 && inst
.size_req
!= 4)
12685 /* Insn may have a 16-bit form. */
12686 Rn
= inst
.operands
[1].reg
;
12687 if (inst
.operands
[1].immisreg
)
12689 inst
.instruction
= THUMB_OP16 (opcode
);
12691 if (Rn
<= 7 && inst
.operands
[1].imm
<= 7)
12693 else if (opcode
!= T_MNEM_ldr
&& opcode
!= T_MNEM_str
)
12694 reject_bad_reg (inst
.operands
[1].imm
);
12696 else if ((Rn
<= 7 && opcode
!= T_MNEM_ldrsh
12697 && opcode
!= T_MNEM_ldrsb
)
12698 || ((Rn
== REG_PC
|| Rn
== REG_SP
) && opcode
== T_MNEM_ldr
)
12699 || (Rn
== REG_SP
&& opcode
== T_MNEM_str
))
12706 if (inst
.relocs
[0].pc_rel
)
12707 opcode
= T_MNEM_ldr_pc2
;
12709 opcode
= T_MNEM_ldr_pc
;
12713 if (opcode
== T_MNEM_ldr
)
12714 opcode
= T_MNEM_ldr_sp
;
12716 opcode
= T_MNEM_str_sp
;
12718 inst
.instruction
= inst
.operands
[0].reg
<< 8;
12722 inst
.instruction
= inst
.operands
[0].reg
;
12723 inst
.instruction
|= inst
.operands
[1].reg
<< 3;
12725 inst
.instruction
|= THUMB_OP16 (opcode
);
12726 if (inst
.size_req
== 2)
12727 inst
.relocs
[0].type
= BFD_RELOC_ARM_THUMB_OFFSET
;
12729 inst
.relax
= opcode
;
12733 /* Definitely a 32-bit variant. */
12735 /* Warning for Erratum 752419. */
12736 if (opcode
== T_MNEM_ldr
12737 && inst
.operands
[0].reg
== REG_SP
12738 && inst
.operands
[1].writeback
== 1
12739 && !inst
.operands
[1].immisreg
)
12741 if (no_cpu_selected ()
12742 || (ARM_CPU_HAS_FEATURE (cpu_variant
, arm_ext_v7
)
12743 && !ARM_CPU_HAS_FEATURE (cpu_variant
, arm_ext_v7a
)
12744 && !ARM_CPU_HAS_FEATURE (cpu_variant
, arm_ext_v7r
)))
12745 as_warn (_("This instruction may be unpredictable "
12746 "if executed on M-profile cores "
12747 "with interrupts enabled."));
12750 /* Do some validations regarding addressing modes. */
12751 if (inst
.operands
[1].immisreg
)
12752 reject_bad_reg (inst
.operands
[1].imm
);
12754 constraint (inst
.operands
[1].writeback
== 1
12755 && inst
.operands
[0].reg
== inst
.operands
[1].reg
,
12758 inst
.instruction
= THUMB_OP32 (opcode
);
12759 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
12760 encode_thumb32_addr_mode (1, /*is_t=*/FALSE
, /*is_d=*/FALSE
);
12761 check_ldr_r15_aligned ();
12765 constraint (inst
.operands
[0].reg
> 7, BAD_HIREG
);
12767 if (inst
.instruction
== T_MNEM_ldrsh
|| inst
.instruction
== T_MNEM_ldrsb
)
12769 /* Only [Rn,Rm] is acceptable. */
12770 constraint (inst
.operands
[1].reg
> 7 || inst
.operands
[1].imm
> 7, BAD_HIREG
);
12771 constraint (!inst
.operands
[1].isreg
|| !inst
.operands
[1].immisreg
12772 || inst
.operands
[1].postind
|| inst
.operands
[1].shifted
12773 || inst
.operands
[1].negative
,
12774 _("Thumb does not support this addressing mode"));
12775 inst
.instruction
= THUMB_OP16 (inst
.instruction
);
12779 inst
.instruction
= THUMB_OP16 (inst
.instruction
);
12780 if (!inst
.operands
[1].isreg
)
12781 if (move_or_literal_pool (0, CONST_THUMB
, /*mode_3=*/FALSE
))
12784 constraint (!inst
.operands
[1].preind
12785 || inst
.operands
[1].shifted
12786 || inst
.operands
[1].writeback
,
12787 _("Thumb does not support this addressing mode"));
12788 if (inst
.operands
[1].reg
== REG_PC
|| inst
.operands
[1].reg
== REG_SP
)
12790 constraint (inst
.instruction
& 0x0600,
12791 _("byte or halfword not valid for base register"));
12792 constraint (inst
.operands
[1].reg
== REG_PC
12793 && !(inst
.instruction
& THUMB_LOAD_BIT
),
12794 _("r15 based store not allowed"));
12795 constraint (inst
.operands
[1].immisreg
,
12796 _("invalid base register for register offset"));
12798 if (inst
.operands
[1].reg
== REG_PC
)
12799 inst
.instruction
= T_OPCODE_LDR_PC
;
12800 else if (inst
.instruction
& THUMB_LOAD_BIT
)
12801 inst
.instruction
= T_OPCODE_LDR_SP
;
12803 inst
.instruction
= T_OPCODE_STR_SP
;
12805 inst
.instruction
|= inst
.operands
[0].reg
<< 8;
12806 inst
.relocs
[0].type
= BFD_RELOC_ARM_THUMB_OFFSET
;
12810 constraint (inst
.operands
[1].reg
> 7, BAD_HIREG
);
12811 if (!inst
.operands
[1].immisreg
)
12813 /* Immediate offset. */
12814 inst
.instruction
|= inst
.operands
[0].reg
;
12815 inst
.instruction
|= inst
.operands
[1].reg
<< 3;
12816 inst
.relocs
[0].type
= BFD_RELOC_ARM_THUMB_OFFSET
;
12820 /* Register offset. */
12821 constraint (inst
.operands
[1].imm
> 7, BAD_HIREG
);
12822 constraint (inst
.operands
[1].negative
,
12823 _("Thumb does not support this addressing mode"));
12826 switch (inst
.instruction
)
12828 case T_OPCODE_STR_IW
: inst
.instruction
= T_OPCODE_STR_RW
; break;
12829 case T_OPCODE_STR_IH
: inst
.instruction
= T_OPCODE_STR_RH
; break;
12830 case T_OPCODE_STR_IB
: inst
.instruction
= T_OPCODE_STR_RB
; break;
12831 case T_OPCODE_LDR_IW
: inst
.instruction
= T_OPCODE_LDR_RW
; break;
12832 case T_OPCODE_LDR_IH
: inst
.instruction
= T_OPCODE_LDR_RH
; break;
12833 case T_OPCODE_LDR_IB
: inst
.instruction
= T_OPCODE_LDR_RB
; break;
12834 case 0x5600 /* ldrsb */:
12835 case 0x5e00 /* ldrsh */: break;
12839 inst
.instruction
|= inst
.operands
[0].reg
;
12840 inst
.instruction
|= inst
.operands
[1].reg
<< 3;
12841 inst
.instruction
|= inst
.operands
[1].imm
<< 6;
12847 if (!inst
.operands
[1].present
)
12849 inst
.operands
[1].reg
= inst
.operands
[0].reg
+ 1;
12850 constraint (inst
.operands
[0].reg
== REG_LR
,
12851 _("r14 not allowed here"));
12852 constraint (inst
.operands
[0].reg
== REG_R12
,
12853 _("r12 not allowed here"));
12856 if (inst
.operands
[2].writeback
12857 && (inst
.operands
[0].reg
== inst
.operands
[2].reg
12858 || inst
.operands
[1].reg
== inst
.operands
[2].reg
))
12859 as_warn (_("base register written back, and overlaps "
12860 "one of transfer registers"));
12862 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
12863 inst
.instruction
|= inst
.operands
[1].reg
<< 8;
12864 encode_thumb32_addr_mode (2, /*is_t=*/FALSE
, /*is_d=*/TRUE
);
12870 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
12871 encode_thumb32_addr_mode (1, /*is_t=*/TRUE
, /*is_d=*/FALSE
);
12877 unsigned Rd
, Rn
, Rm
, Ra
;
12879 Rd
= inst
.operands
[0].reg
;
12880 Rn
= inst
.operands
[1].reg
;
12881 Rm
= inst
.operands
[2].reg
;
12882 Ra
= inst
.operands
[3].reg
;
12884 reject_bad_reg (Rd
);
12885 reject_bad_reg (Rn
);
12886 reject_bad_reg (Rm
);
12887 reject_bad_reg (Ra
);
12889 inst
.instruction
|= Rd
<< 8;
12890 inst
.instruction
|= Rn
<< 16;
12891 inst
.instruction
|= Rm
;
12892 inst
.instruction
|= Ra
<< 12;
12898 unsigned RdLo
, RdHi
, Rn
, Rm
;
12900 RdLo
= inst
.operands
[0].reg
;
12901 RdHi
= inst
.operands
[1].reg
;
12902 Rn
= inst
.operands
[2].reg
;
12903 Rm
= inst
.operands
[3].reg
;
12905 reject_bad_reg (RdLo
);
12906 reject_bad_reg (RdHi
);
12907 reject_bad_reg (Rn
);
12908 reject_bad_reg (Rm
);
12910 inst
.instruction
|= RdLo
<< 12;
12911 inst
.instruction
|= RdHi
<< 8;
12912 inst
.instruction
|= Rn
<< 16;
12913 inst
.instruction
|= Rm
;
12917 do_t_mov_cmp (void)
12921 Rn
= inst
.operands
[0].reg
;
12922 Rm
= inst
.operands
[1].reg
;
12925 set_pred_insn_type_last ();
12927 if (unified_syntax
)
12929 int r0off
= (inst
.instruction
== T_MNEM_mov
12930 || inst
.instruction
== T_MNEM_movs
) ? 8 : 16;
12931 unsigned long opcode
;
12932 bfd_boolean narrow
;
12933 bfd_boolean low_regs
;
12935 low_regs
= (Rn
<= 7 && Rm
<= 7);
12936 opcode
= inst
.instruction
;
12937 if (in_pred_block ())
12938 narrow
= opcode
!= T_MNEM_movs
;
12940 narrow
= opcode
!= T_MNEM_movs
|| low_regs
;
12941 if (inst
.size_req
== 4
12942 || inst
.operands
[1].shifted
)
12945 /* MOVS PC, LR is encoded as SUBS PC, LR, #0. */
12946 if (opcode
== T_MNEM_movs
&& inst
.operands
[1].isreg
12947 && !inst
.operands
[1].shifted
12951 inst
.instruction
= T2_SUBS_PC_LR
;
12955 if (opcode
== T_MNEM_cmp
)
12957 constraint (Rn
== REG_PC
, BAD_PC
);
12960 /* In the Thumb-2 ISA, use of R13 as Rm is deprecated,
12962 warn_deprecated_sp (Rm
);
12963 /* R15 was documented as a valid choice for Rm in ARMv6,
12964 but as UNPREDICTABLE in ARMv7. ARM's proprietary
12965 tools reject R15, so we do too. */
12966 constraint (Rm
== REG_PC
, BAD_PC
);
12969 reject_bad_reg (Rm
);
12971 else if (opcode
== T_MNEM_mov
12972 || opcode
== T_MNEM_movs
)
12974 if (inst
.operands
[1].isreg
)
12976 if (opcode
== T_MNEM_movs
)
12978 reject_bad_reg (Rn
);
12979 reject_bad_reg (Rm
);
12983 /* This is mov.n. */
12984 if ((Rn
== REG_SP
|| Rn
== REG_PC
)
12985 && (Rm
== REG_SP
|| Rm
== REG_PC
))
12987 as_tsktsk (_("Use of r%u as a source register is "
12988 "deprecated when r%u is the destination "
12989 "register."), Rm
, Rn
);
12994 /* This is mov.w. */
12995 constraint (Rn
== REG_PC
, BAD_PC
);
12996 constraint (Rm
== REG_PC
, BAD_PC
);
12997 if (!ARM_CPU_HAS_FEATURE (cpu_variant
, arm_ext_v8
))
12998 constraint (Rn
== REG_SP
&& Rm
== REG_SP
, BAD_SP
);
13002 reject_bad_reg (Rn
);
13005 if (!inst
.operands
[1].isreg
)
13007 /* Immediate operand. */
13008 if (!in_pred_block () && opcode
== T_MNEM_mov
)
13010 if (low_regs
&& narrow
)
13012 inst
.instruction
= THUMB_OP16 (opcode
);
13013 inst
.instruction
|= Rn
<< 8;
13014 if (inst
.relocs
[0].type
< BFD_RELOC_ARM_THUMB_ALU_ABS_G0_NC
13015 || inst
.relocs
[0].type
> BFD_RELOC_ARM_THUMB_ALU_ABS_G3_NC
)
13017 if (inst
.size_req
== 2)
13018 inst
.relocs
[0].type
= BFD_RELOC_ARM_THUMB_IMM
;
13020 inst
.relax
= opcode
;
13025 constraint ((inst
.relocs
[0].type
13026 >= BFD_RELOC_ARM_THUMB_ALU_ABS_G0_NC
)
13027 && (inst
.relocs
[0].type
13028 <= BFD_RELOC_ARM_THUMB_ALU_ABS_G3_NC
) ,
13029 THUMB1_RELOC_ONLY
);
13031 inst
.instruction
= THUMB_OP32 (inst
.instruction
);
13032 inst
.instruction
= (inst
.instruction
& 0xe1ffffff) | 0x10000000;
13033 inst
.instruction
|= Rn
<< r0off
;
13034 inst
.relocs
[0].type
= BFD_RELOC_ARM_T32_IMMEDIATE
;
13037 else if (inst
.operands
[1].shifted
&& inst
.operands
[1].immisreg
13038 && (inst
.instruction
== T_MNEM_mov
13039 || inst
.instruction
== T_MNEM_movs
))
13041 /* Register shifts are encoded as separate shift instructions. */
13042 bfd_boolean flags
= (inst
.instruction
== T_MNEM_movs
);
13044 if (in_pred_block ())
13049 if (inst
.size_req
== 4)
13052 if (!low_regs
|| inst
.operands
[1].imm
> 7)
13058 switch (inst
.operands
[1].shift_kind
)
13061 opcode
= narrow
? T_OPCODE_LSL_R
: THUMB_OP32 (T_MNEM_lsl
);
13064 opcode
= narrow
? T_OPCODE_ASR_R
: THUMB_OP32 (T_MNEM_asr
);
13067 opcode
= narrow
? T_OPCODE_LSR_R
: THUMB_OP32 (T_MNEM_lsr
);
13070 opcode
= narrow
? T_OPCODE_ROR_R
: THUMB_OP32 (T_MNEM_ror
);
13076 inst
.instruction
= opcode
;
13079 inst
.instruction
|= Rn
;
13080 inst
.instruction
|= inst
.operands
[1].imm
<< 3;
13085 inst
.instruction
|= CONDS_BIT
;
13087 inst
.instruction
|= Rn
<< 8;
13088 inst
.instruction
|= Rm
<< 16;
13089 inst
.instruction
|= inst
.operands
[1].imm
;
13094 /* Some mov with immediate shift have narrow variants.
13095 Register shifts are handled above. */
13096 if (low_regs
&& inst
.operands
[1].shifted
13097 && (inst
.instruction
== T_MNEM_mov
13098 || inst
.instruction
== T_MNEM_movs
))
13100 if (in_pred_block ())
13101 narrow
= (inst
.instruction
== T_MNEM_mov
);
13103 narrow
= (inst
.instruction
== T_MNEM_movs
);
13108 switch (inst
.operands
[1].shift_kind
)
13110 case SHIFT_LSL
: inst
.instruction
= T_OPCODE_LSL_I
; break;
13111 case SHIFT_LSR
: inst
.instruction
= T_OPCODE_LSR_I
; break;
13112 case SHIFT_ASR
: inst
.instruction
= T_OPCODE_ASR_I
; break;
13113 default: narrow
= FALSE
; break;
13119 inst
.instruction
|= Rn
;
13120 inst
.instruction
|= Rm
<< 3;
13121 inst
.relocs
[0].type
= BFD_RELOC_ARM_THUMB_SHIFT
;
13125 inst
.instruction
= THUMB_OP32 (inst
.instruction
);
13126 inst
.instruction
|= Rn
<< r0off
;
13127 encode_thumb32_shifted_operand (1);
13131 switch (inst
.instruction
)
13134 /* In v4t or v5t a move of two lowregs produces unpredictable
13135 results. Don't allow this. */
13138 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant
, arm_ext_v6
),
13139 "MOV Rd, Rs with two low registers is not "
13140 "permitted on this architecture");
13141 ARM_MERGE_FEATURE_SETS (thumb_arch_used
, thumb_arch_used
,
13145 inst
.instruction
= T_OPCODE_MOV_HR
;
13146 inst
.instruction
|= (Rn
& 0x8) << 4;
13147 inst
.instruction
|= (Rn
& 0x7);
13148 inst
.instruction
|= Rm
<< 3;
13152 /* We know we have low registers at this point.
13153 Generate LSLS Rd, Rs, #0. */
13154 inst
.instruction
= T_OPCODE_LSL_I
;
13155 inst
.instruction
|= Rn
;
13156 inst
.instruction
|= Rm
<< 3;
13162 inst
.instruction
= T_OPCODE_CMP_LR
;
13163 inst
.instruction
|= Rn
;
13164 inst
.instruction
|= Rm
<< 3;
13168 inst
.instruction
= T_OPCODE_CMP_HR
;
13169 inst
.instruction
|= (Rn
& 0x8) << 4;
13170 inst
.instruction
|= (Rn
& 0x7);
13171 inst
.instruction
|= Rm
<< 3;
13178 inst
.instruction
= THUMB_OP16 (inst
.instruction
);
13180 /* PR 10443: Do not silently ignore shifted operands. */
13181 constraint (inst
.operands
[1].shifted
,
13182 _("shifts in CMP/MOV instructions are only supported in unified syntax"));
13184 if (inst
.operands
[1].isreg
)
13186 if (Rn
< 8 && Rm
< 8)
13188 /* A move of two lowregs is encoded as ADD Rd, Rs, #0
13189 since a MOV instruction produces unpredictable results. */
13190 if (inst
.instruction
== T_OPCODE_MOV_I8
)
13191 inst
.instruction
= T_OPCODE_ADD_I3
;
13193 inst
.instruction
= T_OPCODE_CMP_LR
;
13195 inst
.instruction
|= Rn
;
13196 inst
.instruction
|= Rm
<< 3;
13200 if (inst
.instruction
== T_OPCODE_MOV_I8
)
13201 inst
.instruction
= T_OPCODE_MOV_HR
;
13203 inst
.instruction
= T_OPCODE_CMP_HR
;
13209 constraint (Rn
> 7,
13210 _("only lo regs allowed with immediate"));
13211 inst
.instruction
|= Rn
<< 8;
13212 inst
.relocs
[0].type
= BFD_RELOC_ARM_THUMB_IMM
;
13223 top
= (inst
.instruction
& 0x00800000) != 0;
13224 if (inst
.relocs
[0].type
== BFD_RELOC_ARM_MOVW
)
13226 constraint (top
, _(":lower16: not allowed in this instruction"));
13227 inst
.relocs
[0].type
= BFD_RELOC_ARM_THUMB_MOVW
;
13229 else if (inst
.relocs
[0].type
== BFD_RELOC_ARM_MOVT
)
13231 constraint (!top
, _(":upper16: not allowed in this instruction"));
13232 inst
.relocs
[0].type
= BFD_RELOC_ARM_THUMB_MOVT
;
13235 Rd
= inst
.operands
[0].reg
;
13236 reject_bad_reg (Rd
);
13238 inst
.instruction
|= Rd
<< 8;
13239 if (inst
.relocs
[0].type
== BFD_RELOC_UNUSED
)
13241 imm
= inst
.relocs
[0].exp
.X_add_number
;
13242 inst
.instruction
|= (imm
& 0xf000) << 4;
13243 inst
.instruction
|= (imm
& 0x0800) << 15;
13244 inst
.instruction
|= (imm
& 0x0700) << 4;
13245 inst
.instruction
|= (imm
& 0x00ff);
13250 do_t_mvn_tst (void)
13254 Rn
= inst
.operands
[0].reg
;
13255 Rm
= inst
.operands
[1].reg
;
13257 if (inst
.instruction
== T_MNEM_cmp
13258 || inst
.instruction
== T_MNEM_cmn
)
13259 constraint (Rn
== REG_PC
, BAD_PC
);
13261 reject_bad_reg (Rn
);
13262 reject_bad_reg (Rm
);
13264 if (unified_syntax
)
13266 int r0off
= (inst
.instruction
== T_MNEM_mvn
13267 || inst
.instruction
== T_MNEM_mvns
) ? 8 : 16;
13268 bfd_boolean narrow
;
13270 if (inst
.size_req
== 4
13271 || inst
.instruction
> 0xffff
13272 || inst
.operands
[1].shifted
13273 || Rn
> 7 || Rm
> 7)
13275 else if (inst
.instruction
== T_MNEM_cmn
13276 || inst
.instruction
== T_MNEM_tst
)
13278 else if (THUMB_SETS_FLAGS (inst
.instruction
))
13279 narrow
= !in_pred_block ();
13281 narrow
= in_pred_block ();
13283 if (!inst
.operands
[1].isreg
)
13285 /* For an immediate, we always generate a 32-bit opcode;
13286 section relaxation will shrink it later if possible. */
13287 if (inst
.instruction
< 0xffff)
13288 inst
.instruction
= THUMB_OP32 (inst
.instruction
);
13289 inst
.instruction
= (inst
.instruction
& 0xe1ffffff) | 0x10000000;
13290 inst
.instruction
|= Rn
<< r0off
;
13291 inst
.relocs
[0].type
= BFD_RELOC_ARM_T32_IMMEDIATE
;
13295 /* See if we can do this with a 16-bit instruction. */
13298 inst
.instruction
= THUMB_OP16 (inst
.instruction
);
13299 inst
.instruction
|= Rn
;
13300 inst
.instruction
|= Rm
<< 3;
13304 constraint (inst
.operands
[1].shifted
13305 && inst
.operands
[1].immisreg
,
13306 _("shift must be constant"));
13307 if (inst
.instruction
< 0xffff)
13308 inst
.instruction
= THUMB_OP32 (inst
.instruction
);
13309 inst
.instruction
|= Rn
<< r0off
;
13310 encode_thumb32_shifted_operand (1);
13316 constraint (inst
.instruction
> 0xffff
13317 || inst
.instruction
== T_MNEM_mvns
, BAD_THUMB32
);
13318 constraint (!inst
.operands
[1].isreg
|| inst
.operands
[1].shifted
,
13319 _("unshifted register required"));
13320 constraint (Rn
> 7 || Rm
> 7,
13323 inst
.instruction
= THUMB_OP16 (inst
.instruction
);
13324 inst
.instruction
|= Rn
;
13325 inst
.instruction
|= Rm
<< 3;
13334 if (do_vfp_nsyn_mrs () == SUCCESS
)
13337 Rd
= inst
.operands
[0].reg
;
13338 reject_bad_reg (Rd
);
13339 inst
.instruction
|= Rd
<< 8;
13341 if (inst
.operands
[1].isreg
)
13343 unsigned br
= inst
.operands
[1].reg
;
13344 if (((br
& 0x200) == 0) && ((br
& 0xf000) != 0xf000))
13345 as_bad (_("bad register for mrs"));
13347 inst
.instruction
|= br
& (0xf << 16);
13348 inst
.instruction
|= (br
& 0x300) >> 4;
13349 inst
.instruction
|= (br
& SPSR_BIT
) >> 2;
13353 int flags
= inst
.operands
[1].imm
& (PSR_c
|PSR_x
|PSR_s
|PSR_f
|SPSR_BIT
);
13355 if (ARM_CPU_HAS_FEATURE (selected_cpu
, arm_ext_m
))
13357 /* PR gas/12698: The constraint is only applied for m_profile.
13358 If the user has specified -march=all, we want to ignore it as
13359 we are building for any CPU type, including non-m variants. */
13360 bfd_boolean m_profile
=
13361 !ARM_FEATURE_CORE_EQUAL (selected_cpu
, arm_arch_any
);
13362 constraint ((flags
!= 0) && m_profile
, _("selected processor does "
13363 "not support requested special purpose register"));
13366 /* mrs only accepts APSR/CPSR/SPSR/CPSR_all/SPSR_all (for non-M profile
13368 constraint ((flags
& ~SPSR_BIT
) != (PSR_c
|PSR_f
),
13369 _("'APSR', 'CPSR' or 'SPSR' expected"));
13371 inst
.instruction
|= (flags
& SPSR_BIT
) >> 2;
13372 inst
.instruction
|= inst
.operands
[1].imm
& 0xff;
13373 inst
.instruction
|= 0xf0000;
13383 if (do_vfp_nsyn_msr () == SUCCESS
)
13386 constraint (!inst
.operands
[1].isreg
,
13387 _("Thumb encoding does not support an immediate here"));
13389 if (inst
.operands
[0].isreg
)
13390 flags
= (int)(inst
.operands
[0].reg
);
13392 flags
= inst
.operands
[0].imm
;
13394 if (ARM_CPU_HAS_FEATURE (selected_cpu
, arm_ext_m
))
13396 int bits
= inst
.operands
[0].imm
& (PSR_c
|PSR_x
|PSR_s
|PSR_f
|SPSR_BIT
);
13398 /* PR gas/12698: The constraint is only applied for m_profile.
13399 If the user has specified -march=all, we want to ignore it as
13400 we are building for any CPU type, including non-m variants. */
13401 bfd_boolean m_profile
=
13402 !ARM_FEATURE_CORE_EQUAL (selected_cpu
, arm_arch_any
);
13403 constraint (((ARM_CPU_HAS_FEATURE (selected_cpu
, arm_ext_v6_dsp
)
13404 && (bits
& ~(PSR_s
| PSR_f
)) != 0)
13405 || (!ARM_CPU_HAS_FEATURE (selected_cpu
, arm_ext_v6_dsp
)
13406 && bits
!= PSR_f
)) && m_profile
,
13407 _("selected processor does not support requested special "
13408 "purpose register"));
13411 constraint ((flags
& 0xff) != 0, _("selected processor does not support "
13412 "requested special purpose register"));
13414 Rn
= inst
.operands
[1].reg
;
13415 reject_bad_reg (Rn
);
13417 inst
.instruction
|= (flags
& SPSR_BIT
) >> 2;
13418 inst
.instruction
|= (flags
& 0xf0000) >> 8;
13419 inst
.instruction
|= (flags
& 0x300) >> 4;
13420 inst
.instruction
|= (flags
& 0xff);
13421 inst
.instruction
|= Rn
<< 16;
13427 bfd_boolean narrow
;
13428 unsigned Rd
, Rn
, Rm
;
13430 if (!inst
.operands
[2].present
)
13431 inst
.operands
[2].reg
= inst
.operands
[0].reg
;
13433 Rd
= inst
.operands
[0].reg
;
13434 Rn
= inst
.operands
[1].reg
;
13435 Rm
= inst
.operands
[2].reg
;
13437 if (unified_syntax
)
13439 if (inst
.size_req
== 4
13445 else if (inst
.instruction
== T_MNEM_muls
)
13446 narrow
= !in_pred_block ();
13448 narrow
= in_pred_block ();
13452 constraint (inst
.instruction
== T_MNEM_muls
, BAD_THUMB32
);
13453 constraint (Rn
> 7 || Rm
> 7,
13460 /* 16-bit MULS/Conditional MUL. */
13461 inst
.instruction
= THUMB_OP16 (inst
.instruction
);
13462 inst
.instruction
|= Rd
;
13465 inst
.instruction
|= Rm
<< 3;
13467 inst
.instruction
|= Rn
<< 3;
13469 constraint (1, _("dest must overlap one source register"));
13473 constraint (inst
.instruction
!= T_MNEM_mul
,
13474 _("Thumb-2 MUL must not set flags"));
13476 inst
.instruction
= THUMB_OP32 (inst
.instruction
);
13477 inst
.instruction
|= Rd
<< 8;
13478 inst
.instruction
|= Rn
<< 16;
13479 inst
.instruction
|= Rm
<< 0;
13481 reject_bad_reg (Rd
);
13482 reject_bad_reg (Rn
);
13483 reject_bad_reg (Rm
);
13490 unsigned RdLo
, RdHi
, Rn
, Rm
;
13492 RdLo
= inst
.operands
[0].reg
;
13493 RdHi
= inst
.operands
[1].reg
;
13494 Rn
= inst
.operands
[2].reg
;
13495 Rm
= inst
.operands
[3].reg
;
13497 reject_bad_reg (RdLo
);
13498 reject_bad_reg (RdHi
);
13499 reject_bad_reg (Rn
);
13500 reject_bad_reg (Rm
);
13502 inst
.instruction
|= RdLo
<< 12;
13503 inst
.instruction
|= RdHi
<< 8;
13504 inst
.instruction
|= Rn
<< 16;
13505 inst
.instruction
|= Rm
;
13508 as_tsktsk (_("rdhi and rdlo must be different"));
13514 set_pred_insn_type (NEUTRAL_IT_INSN
);
13516 if (unified_syntax
)
13518 if (inst
.size_req
== 4 || inst
.operands
[0].imm
> 15)
13520 inst
.instruction
= THUMB_OP32 (inst
.instruction
);
13521 inst
.instruction
|= inst
.operands
[0].imm
;
13525 /* PR9722: Check for Thumb2 availability before
13526 generating a thumb2 nop instruction. */
13527 if (ARM_CPU_HAS_FEATURE (selected_cpu
, arm_ext_v6t2
))
13529 inst
.instruction
= THUMB_OP16 (inst
.instruction
);
13530 inst
.instruction
|= inst
.operands
[0].imm
<< 4;
13533 inst
.instruction
= 0x46c0;
13538 constraint (inst
.operands
[0].present
,
13539 _("Thumb does not support NOP with hints"));
13540 inst
.instruction
= 0x46c0;
13547 if (unified_syntax
)
13549 bfd_boolean narrow
;
13551 if (THUMB_SETS_FLAGS (inst
.instruction
))
13552 narrow
= !in_pred_block ();
13554 narrow
= in_pred_block ();
13555 if (inst
.operands
[0].reg
> 7 || inst
.operands
[1].reg
> 7)
13557 if (inst
.size_req
== 4)
13562 inst
.instruction
= THUMB_OP32 (inst
.instruction
);
13563 inst
.instruction
|= inst
.operands
[0].reg
<< 8;
13564 inst
.instruction
|= inst
.operands
[1].reg
<< 16;
13568 inst
.instruction
= THUMB_OP16 (inst
.instruction
);
13569 inst
.instruction
|= inst
.operands
[0].reg
;
13570 inst
.instruction
|= inst
.operands
[1].reg
<< 3;
13575 constraint (inst
.operands
[0].reg
> 7 || inst
.operands
[1].reg
> 7,
13577 constraint (THUMB_SETS_FLAGS (inst
.instruction
), BAD_THUMB32
);
13579 inst
.instruction
= THUMB_OP16 (inst
.instruction
);
13580 inst
.instruction
|= inst
.operands
[0].reg
;
13581 inst
.instruction
|= inst
.operands
[1].reg
<< 3;
13590 Rd
= inst
.operands
[0].reg
;
13591 Rn
= inst
.operands
[1].present
? inst
.operands
[1].reg
: Rd
;
13593 reject_bad_reg (Rd
);
13594 /* Rn == REG_SP is unpredictable; Rn == REG_PC is MVN. */
13595 reject_bad_reg (Rn
);
13597 inst
.instruction
|= Rd
<< 8;
13598 inst
.instruction
|= Rn
<< 16;
13600 if (!inst
.operands
[2].isreg
)
13602 inst
.instruction
= (inst
.instruction
& 0xe1ffffff) | 0x10000000;
13603 inst
.relocs
[0].type
= BFD_RELOC_ARM_T32_IMMEDIATE
;
13609 Rm
= inst
.operands
[2].reg
;
13610 reject_bad_reg (Rm
);
13612 constraint (inst
.operands
[2].shifted
13613 && inst
.operands
[2].immisreg
,
13614 _("shift must be constant"));
13615 encode_thumb32_shifted_operand (2);
13622 unsigned Rd
, Rn
, Rm
;
13624 Rd
= inst
.operands
[0].reg
;
13625 Rn
= inst
.operands
[1].reg
;
13626 Rm
= inst
.operands
[2].reg
;
13628 reject_bad_reg (Rd
);
13629 reject_bad_reg (Rn
);
13630 reject_bad_reg (Rm
);
13632 inst
.instruction
|= Rd
<< 8;
13633 inst
.instruction
|= Rn
<< 16;
13634 inst
.instruction
|= Rm
;
13635 if (inst
.operands
[3].present
)
13637 unsigned int val
= inst
.relocs
[0].exp
.X_add_number
;
13638 constraint (inst
.relocs
[0].exp
.X_op
!= O_constant
,
13639 _("expression too complex"));
13640 inst
.instruction
|= (val
& 0x1c) << 10;
13641 inst
.instruction
|= (val
& 0x03) << 6;
13648 if (!inst
.operands
[3].present
)
13652 inst
.instruction
&= ~0x00000020;
13654 /* PR 10168. Swap the Rm and Rn registers. */
13655 Rtmp
= inst
.operands
[1].reg
;
13656 inst
.operands
[1].reg
= inst
.operands
[2].reg
;
13657 inst
.operands
[2].reg
= Rtmp
;
13665 if (inst
.operands
[0].immisreg
)
13666 reject_bad_reg (inst
.operands
[0].imm
);
13668 encode_thumb32_addr_mode (0, /*is_t=*/FALSE
, /*is_d=*/FALSE
);
13672 do_t_push_pop (void)
13676 constraint (inst
.operands
[0].writeback
,
13677 _("push/pop do not support {reglist}^"));
13678 constraint (inst
.relocs
[0].type
!= BFD_RELOC_UNUSED
,
13679 _("expression too complex"));
13681 mask
= inst
.operands
[0].imm
;
13682 if (inst
.size_req
!= 4 && (mask
& ~0xff) == 0)
13683 inst
.instruction
= THUMB_OP16 (inst
.instruction
) | mask
;
13684 else if (inst
.size_req
!= 4
13685 && (mask
& ~0xff) == (1U << (inst
.instruction
== T_MNEM_push
13686 ? REG_LR
: REG_PC
)))
13688 inst
.instruction
= THUMB_OP16 (inst
.instruction
);
13689 inst
.instruction
|= THUMB_PP_PC_LR
;
13690 inst
.instruction
|= mask
& 0xff;
13692 else if (unified_syntax
)
13694 inst
.instruction
= THUMB_OP32 (inst
.instruction
);
13695 encode_thumb2_multi (TRUE
/* do_io */, 13, mask
, TRUE
);
13699 inst
.error
= _("invalid register list to push/pop instruction");
13707 if (unified_syntax
)
13708 encode_thumb2_multi (FALSE
/* do_io */, -1, inst
.operands
[0].imm
, FALSE
);
13711 inst
.error
= _("invalid register list to push/pop instruction");
13717 do_t_vscclrm (void)
13719 if (inst
.operands
[0].issingle
)
13721 inst
.instruction
|= (inst
.operands
[0].reg
& 0x1) << 22;
13722 inst
.instruction
|= (inst
.operands
[0].reg
& 0x1e) << 11;
13723 inst
.instruction
|= inst
.operands
[0].imm
;
13727 inst
.instruction
|= (inst
.operands
[0].reg
& 0x10) << 18;
13728 inst
.instruction
|= (inst
.operands
[0].reg
& 0xf) << 12;
13729 inst
.instruction
|= 1 << 8;
13730 inst
.instruction
|= inst
.operands
[0].imm
<< 1;
13739 Rd
= inst
.operands
[0].reg
;
13740 Rm
= inst
.operands
[1].reg
;
13742 reject_bad_reg (Rd
);
13743 reject_bad_reg (Rm
);
13745 inst
.instruction
|= Rd
<< 8;
13746 inst
.instruction
|= Rm
<< 16;
13747 inst
.instruction
|= Rm
;
13755 Rd
= inst
.operands
[0].reg
;
13756 Rm
= inst
.operands
[1].reg
;
13758 reject_bad_reg (Rd
);
13759 reject_bad_reg (Rm
);
13761 if (Rd
<= 7 && Rm
<= 7
13762 && inst
.size_req
!= 4)
13764 inst
.instruction
= THUMB_OP16 (inst
.instruction
);
13765 inst
.instruction
|= Rd
;
13766 inst
.instruction
|= Rm
<< 3;
13768 else if (unified_syntax
)
13770 inst
.instruction
= THUMB_OP32 (inst
.instruction
);
13771 inst
.instruction
|= Rd
<< 8;
13772 inst
.instruction
|= Rm
<< 16;
13773 inst
.instruction
|= Rm
;
13776 inst
.error
= BAD_HIREG
;
13784 Rd
= inst
.operands
[0].reg
;
13785 Rm
= inst
.operands
[1].reg
;
13787 reject_bad_reg (Rd
);
13788 reject_bad_reg (Rm
);
13790 inst
.instruction
|= Rd
<< 8;
13791 inst
.instruction
|= Rm
;
13799 Rd
= inst
.operands
[0].reg
;
13800 Rs
= (inst
.operands
[1].present
13801 ? inst
.operands
[1].reg
/* Rd, Rs, foo */
13802 : inst
.operands
[0].reg
); /* Rd, foo -> Rd, Rd, foo */
13804 reject_bad_reg (Rd
);
13805 reject_bad_reg (Rs
);
13806 if (inst
.operands
[2].isreg
)
13807 reject_bad_reg (inst
.operands
[2].reg
);
13809 inst
.instruction
|= Rd
<< 8;
13810 inst
.instruction
|= Rs
<< 16;
13811 if (!inst
.operands
[2].isreg
)
13813 bfd_boolean narrow
;
13815 if ((inst
.instruction
& 0x00100000) != 0)
13816 narrow
= !in_pred_block ();
13818 narrow
= in_pred_block ();
13820 if (Rd
> 7 || Rs
> 7)
13823 if (inst
.size_req
== 4 || !unified_syntax
)
13826 if (inst
.relocs
[0].exp
.X_op
!= O_constant
13827 || inst
.relocs
[0].exp
.X_add_number
!= 0)
13830 /* Turn rsb #0 into 16-bit neg. We should probably do this via
13831 relaxation, but it doesn't seem worth the hassle. */
13834 inst
.relocs
[0].type
= BFD_RELOC_UNUSED
;
13835 inst
.instruction
= THUMB_OP16 (T_MNEM_negs
);
13836 inst
.instruction
|= Rs
<< 3;
13837 inst
.instruction
|= Rd
;
13841 inst
.instruction
= (inst
.instruction
& 0xe1ffffff) | 0x10000000;
13842 inst
.relocs
[0].type
= BFD_RELOC_ARM_T32_IMMEDIATE
;
13846 encode_thumb32_shifted_operand (2);
13852 if (warn_on_deprecated
13853 && ARM_CPU_HAS_FEATURE (cpu_variant
, arm_ext_v8
))
13854 as_tsktsk (_("setend use is deprecated for ARMv8"));
13856 set_pred_insn_type (OUTSIDE_PRED_INSN
);
13857 if (inst
.operands
[0].imm
)
13858 inst
.instruction
|= 0x8;
13864 if (!inst
.operands
[1].present
)
13865 inst
.operands
[1].reg
= inst
.operands
[0].reg
;
13867 if (unified_syntax
)
13869 bfd_boolean narrow
;
13872 switch (inst
.instruction
)
13875 case T_MNEM_asrs
: shift_kind
= SHIFT_ASR
; break;
13877 case T_MNEM_lsls
: shift_kind
= SHIFT_LSL
; break;
13879 case T_MNEM_lsrs
: shift_kind
= SHIFT_LSR
; break;
13881 case T_MNEM_rors
: shift_kind
= SHIFT_ROR
; break;
13885 if (THUMB_SETS_FLAGS (inst
.instruction
))
13886 narrow
= !in_pred_block ();
13888 narrow
= in_pred_block ();
13889 if (inst
.operands
[0].reg
> 7 || inst
.operands
[1].reg
> 7)
13891 if (!inst
.operands
[2].isreg
&& shift_kind
== SHIFT_ROR
)
13893 if (inst
.operands
[2].isreg
13894 && (inst
.operands
[1].reg
!= inst
.operands
[0].reg
13895 || inst
.operands
[2].reg
> 7))
13897 if (inst
.size_req
== 4)
13900 reject_bad_reg (inst
.operands
[0].reg
);
13901 reject_bad_reg (inst
.operands
[1].reg
);
13905 if (inst
.operands
[2].isreg
)
13907 reject_bad_reg (inst
.operands
[2].reg
);
13908 inst
.instruction
= THUMB_OP32 (inst
.instruction
);
13909 inst
.instruction
|= inst
.operands
[0].reg
<< 8;
13910 inst
.instruction
|= inst
.operands
[1].reg
<< 16;
13911 inst
.instruction
|= inst
.operands
[2].reg
;
13913 /* PR 12854: Error on extraneous shifts. */
13914 constraint (inst
.operands
[2].shifted
,
13915 _("extraneous shift as part of operand to shift insn"));
13919 inst
.operands
[1].shifted
= 1;
13920 inst
.operands
[1].shift_kind
= shift_kind
;
13921 inst
.instruction
= THUMB_OP32 (THUMB_SETS_FLAGS (inst
.instruction
)
13922 ? T_MNEM_movs
: T_MNEM_mov
);
13923 inst
.instruction
|= inst
.operands
[0].reg
<< 8;
13924 encode_thumb32_shifted_operand (1);
13925 /* Prevent the incorrect generation of an ARM_IMMEDIATE fixup. */
13926 inst
.relocs
[0].type
= BFD_RELOC_UNUSED
;
13931 if (inst
.operands
[2].isreg
)
13933 switch (shift_kind
)
13935 case SHIFT_ASR
: inst
.instruction
= T_OPCODE_ASR_R
; break;
13936 case SHIFT_LSL
: inst
.instruction
= T_OPCODE_LSL_R
; break;
13937 case SHIFT_LSR
: inst
.instruction
= T_OPCODE_LSR_R
; break;
13938 case SHIFT_ROR
: inst
.instruction
= T_OPCODE_ROR_R
; break;
13942 inst
.instruction
|= inst
.operands
[0].reg
;
13943 inst
.instruction
|= inst
.operands
[2].reg
<< 3;
13945 /* PR 12854: Error on extraneous shifts. */
13946 constraint (inst
.operands
[2].shifted
,
13947 _("extraneous shift as part of operand to shift insn"));
13951 switch (shift_kind
)
13953 case SHIFT_ASR
: inst
.instruction
= T_OPCODE_ASR_I
; break;
13954 case SHIFT_LSL
: inst
.instruction
= T_OPCODE_LSL_I
; break;
13955 case SHIFT_LSR
: inst
.instruction
= T_OPCODE_LSR_I
; break;
13958 inst
.relocs
[0].type
= BFD_RELOC_ARM_THUMB_SHIFT
;
13959 inst
.instruction
|= inst
.operands
[0].reg
;
13960 inst
.instruction
|= inst
.operands
[1].reg
<< 3;
13966 constraint (inst
.operands
[0].reg
> 7
13967 || inst
.operands
[1].reg
> 7, BAD_HIREG
);
13968 constraint (THUMB_SETS_FLAGS (inst
.instruction
), BAD_THUMB32
);
13970 if (inst
.operands
[2].isreg
) /* Rd, {Rs,} Rn */
13972 constraint (inst
.operands
[2].reg
> 7, BAD_HIREG
);
13973 constraint (inst
.operands
[0].reg
!= inst
.operands
[1].reg
,
13974 _("source1 and dest must be same register"));
13976 switch (inst
.instruction
)
13978 case T_MNEM_asr
: inst
.instruction
= T_OPCODE_ASR_R
; break;
13979 case T_MNEM_lsl
: inst
.instruction
= T_OPCODE_LSL_R
; break;
13980 case T_MNEM_lsr
: inst
.instruction
= T_OPCODE_LSR_R
; break;
13981 case T_MNEM_ror
: inst
.instruction
= T_OPCODE_ROR_R
; break;
13985 inst
.instruction
|= inst
.operands
[0].reg
;
13986 inst
.instruction
|= inst
.operands
[2].reg
<< 3;
13988 /* PR 12854: Error on extraneous shifts. */
13989 constraint (inst
.operands
[2].shifted
,
13990 _("extraneous shift as part of operand to shift insn"));
13994 switch (inst
.instruction
)
13996 case T_MNEM_asr
: inst
.instruction
= T_OPCODE_ASR_I
; break;
13997 case T_MNEM_lsl
: inst
.instruction
= T_OPCODE_LSL_I
; break;
13998 case T_MNEM_lsr
: inst
.instruction
= T_OPCODE_LSR_I
; break;
13999 case T_MNEM_ror
: inst
.error
= _("ror #imm not supported"); return;
14002 inst
.relocs
[0].type
= BFD_RELOC_ARM_THUMB_SHIFT
;
14003 inst
.instruction
|= inst
.operands
[0].reg
;
14004 inst
.instruction
|= inst
.operands
[1].reg
<< 3;
14012 unsigned Rd
, Rn
, Rm
;
14014 Rd
= inst
.operands
[0].reg
;
14015 Rn
= inst
.operands
[1].reg
;
14016 Rm
= inst
.operands
[2].reg
;
14018 reject_bad_reg (Rd
);
14019 reject_bad_reg (Rn
);
14020 reject_bad_reg (Rm
);
14022 inst
.instruction
|= Rd
<< 8;
14023 inst
.instruction
|= Rn
<< 16;
14024 inst
.instruction
|= Rm
;
14030 unsigned Rd
, Rn
, Rm
;
14032 Rd
= inst
.operands
[0].reg
;
14033 Rm
= inst
.operands
[1].reg
;
14034 Rn
= inst
.operands
[2].reg
;
14036 reject_bad_reg (Rd
);
14037 reject_bad_reg (Rn
);
14038 reject_bad_reg (Rm
);
14040 inst
.instruction
|= Rd
<< 8;
14041 inst
.instruction
|= Rn
<< 16;
14042 inst
.instruction
|= Rm
;
14048 unsigned int value
= inst
.relocs
[0].exp
.X_add_number
;
14049 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant
, arm_ext_v7a
),
14050 _("SMC is not permitted on this architecture"));
14051 constraint (inst
.relocs
[0].exp
.X_op
!= O_constant
,
14052 _("expression too complex"));
14053 constraint (value
> 0xf, _("immediate too large (bigger than 0xF)"));
14055 inst
.relocs
[0].type
= BFD_RELOC_UNUSED
;
14056 inst
.instruction
|= (value
& 0x000f) << 16;
14058 /* PR gas/15623: SMC instructions must be last in an IT block. */
14059 set_pred_insn_type_last ();
14065 unsigned int value
= inst
.relocs
[0].exp
.X_add_number
;
14067 inst
.relocs
[0].type
= BFD_RELOC_UNUSED
;
14068 inst
.instruction
|= (value
& 0x0fff);
14069 inst
.instruction
|= (value
& 0xf000) << 4;
14073 do_t_ssat_usat (int bias
)
14077 Rd
= inst
.operands
[0].reg
;
14078 Rn
= inst
.operands
[2].reg
;
14080 reject_bad_reg (Rd
);
14081 reject_bad_reg (Rn
);
14083 inst
.instruction
|= Rd
<< 8;
14084 inst
.instruction
|= inst
.operands
[1].imm
- bias
;
14085 inst
.instruction
|= Rn
<< 16;
14087 if (inst
.operands
[3].present
)
14089 offsetT shift_amount
= inst
.relocs
[0].exp
.X_add_number
;
14091 inst
.relocs
[0].type
= BFD_RELOC_UNUSED
;
14093 constraint (inst
.relocs
[0].exp
.X_op
!= O_constant
,
14094 _("expression too complex"));
14096 if (shift_amount
!= 0)
14098 constraint (shift_amount
> 31,
14099 _("shift expression is too large"));
14101 if (inst
.operands
[3].shift_kind
== SHIFT_ASR
)
14102 inst
.instruction
|= 0x00200000; /* sh bit. */
14104 inst
.instruction
|= (shift_amount
& 0x1c) << 10;
14105 inst
.instruction
|= (shift_amount
& 0x03) << 6;
14113 do_t_ssat_usat (1);
14121 Rd
= inst
.operands
[0].reg
;
14122 Rn
= inst
.operands
[2].reg
;
14124 reject_bad_reg (Rd
);
14125 reject_bad_reg (Rn
);
14127 inst
.instruction
|= Rd
<< 8;
14128 inst
.instruction
|= inst
.operands
[1].imm
- 1;
14129 inst
.instruction
|= Rn
<< 16;
14135 constraint (!inst
.operands
[2].isreg
|| !inst
.operands
[2].preind
14136 || inst
.operands
[2].postind
|| inst
.operands
[2].writeback
14137 || inst
.operands
[2].immisreg
|| inst
.operands
[2].shifted
14138 || inst
.operands
[2].negative
,
14141 constraint (inst
.operands
[2].reg
== REG_PC
, BAD_PC
);
14143 inst
.instruction
|= inst
.operands
[0].reg
<< 8;
14144 inst
.instruction
|= inst
.operands
[1].reg
<< 12;
14145 inst
.instruction
|= inst
.operands
[2].reg
<< 16;
14146 inst
.relocs
[0].type
= BFD_RELOC_ARM_T32_OFFSET_U8
;
14152 if (!inst
.operands
[2].present
)
14153 inst
.operands
[2].reg
= inst
.operands
[1].reg
+ 1;
14155 constraint (inst
.operands
[0].reg
== inst
.operands
[1].reg
14156 || inst
.operands
[0].reg
== inst
.operands
[2].reg
14157 || inst
.operands
[0].reg
== inst
.operands
[3].reg
,
14160 inst
.instruction
|= inst
.operands
[0].reg
;
14161 inst
.instruction
|= inst
.operands
[1].reg
<< 12;
14162 inst
.instruction
|= inst
.operands
[2].reg
<< 8;
14163 inst
.instruction
|= inst
.operands
[3].reg
<< 16;
14169 unsigned Rd
, Rn
, Rm
;
14171 Rd
= inst
.operands
[0].reg
;
14172 Rn
= inst
.operands
[1].reg
;
14173 Rm
= inst
.operands
[2].reg
;
14175 reject_bad_reg (Rd
);
14176 reject_bad_reg (Rn
);
14177 reject_bad_reg (Rm
);
14179 inst
.instruction
|= Rd
<< 8;
14180 inst
.instruction
|= Rn
<< 16;
14181 inst
.instruction
|= Rm
;
14182 inst
.instruction
|= inst
.operands
[3].imm
<< 4;
14190 Rd
= inst
.operands
[0].reg
;
14191 Rm
= inst
.operands
[1].reg
;
14193 reject_bad_reg (Rd
);
14194 reject_bad_reg (Rm
);
14196 if (inst
.instruction
<= 0xffff
14197 && inst
.size_req
!= 4
14198 && Rd
<= 7 && Rm
<= 7
14199 && (!inst
.operands
[2].present
|| inst
.operands
[2].imm
== 0))
14201 inst
.instruction
= THUMB_OP16 (inst
.instruction
);
14202 inst
.instruction
|= Rd
;
14203 inst
.instruction
|= Rm
<< 3;
14205 else if (unified_syntax
)
14207 if (inst
.instruction
<= 0xffff)
14208 inst
.instruction
= THUMB_OP32 (inst
.instruction
);
14209 inst
.instruction
|= Rd
<< 8;
14210 inst
.instruction
|= Rm
;
14211 inst
.instruction
|= inst
.operands
[2].imm
<< 4;
14215 constraint (inst
.operands
[2].present
&& inst
.operands
[2].imm
!= 0,
14216 _("Thumb encoding does not support rotation"));
14217 constraint (1, BAD_HIREG
);
14224 inst
.relocs
[0].type
= BFD_RELOC_ARM_SWI
;
14233 half
= (inst
.instruction
& 0x10) != 0;
14234 set_pred_insn_type_last ();
14235 constraint (inst
.operands
[0].immisreg
,
14236 _("instruction requires register index"));
14238 Rn
= inst
.operands
[0].reg
;
14239 Rm
= inst
.operands
[0].imm
;
14241 if (!ARM_CPU_HAS_FEATURE (cpu_variant
, arm_ext_v8
))
14242 constraint (Rn
== REG_SP
, BAD_SP
);
14243 reject_bad_reg (Rm
);
14245 constraint (!half
&& inst
.operands
[0].shifted
,
14246 _("instruction does not allow shifted index"));
14247 inst
.instruction
|= (Rn
<< 16) | Rm
;
14253 if (!inst
.operands
[0].present
)
14254 inst
.operands
[0].imm
= 0;
14256 if ((unsigned int) inst
.operands
[0].imm
> 255 || inst
.size_req
== 4)
14258 constraint (inst
.size_req
== 2,
14259 _("immediate value out of range"));
14260 inst
.instruction
= THUMB_OP32 (inst
.instruction
);
14261 inst
.instruction
|= (inst
.operands
[0].imm
& 0xf000u
) << 4;
14262 inst
.instruction
|= (inst
.operands
[0].imm
& 0x0fffu
) << 0;
14266 inst
.instruction
= THUMB_OP16 (inst
.instruction
);
14267 inst
.instruction
|= inst
.operands
[0].imm
;
14270 set_pred_insn_type (NEUTRAL_IT_INSN
);
14277 do_t_ssat_usat (0);
14285 Rd
= inst
.operands
[0].reg
;
14286 Rn
= inst
.operands
[2].reg
;
14288 reject_bad_reg (Rd
);
14289 reject_bad_reg (Rn
);
14291 inst
.instruction
|= Rd
<< 8;
14292 inst
.instruction
|= inst
.operands
[1].imm
;
14293 inst
.instruction
|= Rn
<< 16;
14296 /* Checking the range of the branch offset (VAL) with NBITS bits
14297 and IS_SIGNED signedness. Also checks the LSB to be 0. */
14299 v8_1_branch_value_check (int val
, int nbits
, int is_signed
)
14301 gas_assert (nbits
> 0 && nbits
<= 32);
14304 int cmp
= (1 << (nbits
- 1));
14305 if ((val
< -cmp
) || (val
>= cmp
) || (val
& 0x01))
14310 if ((val
<= 0) || (val
>= (1 << nbits
)) || (val
& 0x1))
14316 /* For branches in Armv8.1-M Mainline. */
14318 do_t_branch_future (void)
14320 unsigned long insn
= inst
.instruction
;
14322 inst
.instruction
= THUMB_OP32 (inst
.instruction
);
14323 if (inst
.operands
[0].hasreloc
== 0)
14325 if (v8_1_branch_value_check (inst
.operands
[0].imm
, 5, FALSE
) == FAIL
)
14326 as_bad (BAD_BRANCH_OFF
);
14328 inst
.instruction
|= ((inst
.operands
[0].imm
& 0x1f) >> 1) << 23;
14332 inst
.relocs
[0].type
= BFD_RELOC_THUMB_PCREL_BRANCH5
;
14333 inst
.relocs
[0].pc_rel
= 1;
14339 if (inst
.operands
[1].hasreloc
== 0)
14341 int val
= inst
.operands
[1].imm
;
14342 if (v8_1_branch_value_check (inst
.operands
[1].imm
, 17, TRUE
) == FAIL
)
14343 as_bad (BAD_BRANCH_OFF
);
14345 int immA
= (val
& 0x0001f000) >> 12;
14346 int immB
= (val
& 0x00000ffc) >> 2;
14347 int immC
= (val
& 0x00000002) >> 1;
14348 inst
.instruction
|= (immA
<< 16) | (immB
<< 1) | (immC
<< 11);
14352 inst
.relocs
[1].type
= BFD_RELOC_ARM_THUMB_BF17
;
14353 inst
.relocs
[1].pc_rel
= 1;
14358 if (inst
.operands
[1].hasreloc
== 0)
14360 int val
= inst
.operands
[1].imm
;
14361 if (v8_1_branch_value_check (inst
.operands
[1].imm
, 19, TRUE
) == FAIL
)
14362 as_bad (BAD_BRANCH_OFF
);
14364 int immA
= (val
& 0x0007f000) >> 12;
14365 int immB
= (val
& 0x00000ffc) >> 2;
14366 int immC
= (val
& 0x00000002) >> 1;
14367 inst
.instruction
|= (immA
<< 16) | (immB
<< 1) | (immC
<< 11);
14371 inst
.relocs
[1].type
= BFD_RELOC_ARM_THUMB_BF19
;
14372 inst
.relocs
[1].pc_rel
= 1;
14376 case T_MNEM_bfcsel
:
14378 if (inst
.operands
[1].hasreloc
== 0)
14380 int val
= inst
.operands
[1].imm
;
14381 int immA
= (val
& 0x00001000) >> 12;
14382 int immB
= (val
& 0x00000ffc) >> 2;
14383 int immC
= (val
& 0x00000002) >> 1;
14384 inst
.instruction
|= (immA
<< 16) | (immB
<< 1) | (immC
<< 11);
14388 inst
.relocs
[1].type
= BFD_RELOC_ARM_THUMB_BF13
;
14389 inst
.relocs
[1].pc_rel
= 1;
14393 if (inst
.operands
[2].hasreloc
== 0)
14395 constraint ((inst
.operands
[0].hasreloc
!= 0), BAD_ARGS
);
14396 int val2
= inst
.operands
[2].imm
;
14397 int val0
= inst
.operands
[0].imm
& 0x1f;
14398 int diff
= val2
- val0
;
14400 inst
.instruction
|= 1 << 17; /* T bit. */
14401 else if (diff
!= 2)
14402 as_bad (_("out of range label-relative fixup value"));
14406 constraint ((inst
.operands
[0].hasreloc
== 0), BAD_ARGS
);
14407 inst
.relocs
[2].type
= BFD_RELOC_THUMB_PCREL_BFCSEL
;
14408 inst
.relocs
[2].pc_rel
= 1;
14412 constraint (inst
.cond
!= COND_ALWAYS
, BAD_COND
);
14413 inst
.instruction
|= (inst
.operands
[3].imm
& 0xf) << 18;
14418 inst
.instruction
|= inst
.operands
[1].reg
<< 16;
14425 /* Helper function for do_t_loloop to handle relocations. */
14427 v8_1_loop_reloc (int is_le
)
14429 if (inst
.relocs
[0].exp
.X_op
== O_constant
)
14431 int value
= inst
.relocs
[0].exp
.X_add_number
;
14432 value
= (is_le
) ? -value
: value
;
14434 if (v8_1_branch_value_check (value
, 12, FALSE
) == FAIL
)
14435 as_bad (BAD_BRANCH_OFF
);
14439 immh
= (value
& 0x00000ffc) >> 2;
14440 imml
= (value
& 0x00000002) >> 1;
14442 inst
.instruction
|= (imml
<< 11) | (immh
<< 1);
14446 inst
.relocs
[0].type
= BFD_RELOC_ARM_THUMB_LOOP12
;
14447 inst
.relocs
[0].pc_rel
= 1;
14451 /* For shifts with four operands in MVE. */
14453 do_mve_scalar_shift1 (void)
14455 unsigned int value
= inst
.operands
[2].imm
;
14457 inst
.instruction
|= inst
.operands
[0].reg
<< 16;
14458 inst
.instruction
|= inst
.operands
[1].reg
<< 8;
14460 /* Setting the bit for saturation. */
14461 inst
.instruction
|= ((value
== 64) ? 0: 1) << 7;
14463 /* Assuming Rm is already checked not to be 11x1. */
14464 constraint (inst
.operands
[3].reg
== inst
.operands
[0].reg
, BAD_OVERLAP
);
14465 constraint (inst
.operands
[3].reg
== inst
.operands
[1].reg
, BAD_OVERLAP
);
14466 inst
.instruction
|= inst
.operands
[3].reg
<< 12;
14469 /* For shifts in MVE. */
14471 do_mve_scalar_shift (void)
14473 if (!inst
.operands
[2].present
)
14475 inst
.operands
[2] = inst
.operands
[1];
14476 inst
.operands
[1].reg
= 0xf;
14479 inst
.instruction
|= inst
.operands
[0].reg
<< 16;
14480 inst
.instruction
|= inst
.operands
[1].reg
<< 8;
14482 if (inst
.operands
[2].isreg
)
14484 /* Assuming Rm is already checked not to be 11x1. */
14485 constraint (inst
.operands
[2].reg
== inst
.operands
[0].reg
, BAD_OVERLAP
);
14486 constraint (inst
.operands
[2].reg
== inst
.operands
[1].reg
, BAD_OVERLAP
);
14487 inst
.instruction
|= inst
.operands
[2].reg
<< 12;
14491 /* Assuming imm is already checked as [1,32]. */
14492 unsigned int value
= inst
.operands
[2].imm
;
14493 inst
.instruction
|= (value
& 0x1c) << 10;
14494 inst
.instruction
|= (value
& 0x03) << 6;
14495 /* Change last 4 bits from 0xd to 0xf. */
14496 inst
.instruction
|= 0x2;
14500 /* MVE instruction encoder helpers. */
14501 #define M_MNEM_vabav 0xee800f01
14502 #define M_MNEM_vmladav 0xeef00e00
14503 #define M_MNEM_vmladava 0xeef00e20
14504 #define M_MNEM_vmladavx 0xeef01e00
14505 #define M_MNEM_vmladavax 0xeef01e20
14506 #define M_MNEM_vmlsdav 0xeef00e01
14507 #define M_MNEM_vmlsdava 0xeef00e21
14508 #define M_MNEM_vmlsdavx 0xeef01e01
14509 #define M_MNEM_vmlsdavax 0xeef01e21
14510 #define M_MNEM_vmullt 0xee011e00
14511 #define M_MNEM_vmullb 0xee010e00
14512 #define M_MNEM_vctp 0xf000e801
14513 #define M_MNEM_vst20 0xfc801e00
14514 #define M_MNEM_vst21 0xfc801e20
14515 #define M_MNEM_vst40 0xfc801e01
14516 #define M_MNEM_vst41 0xfc801e21
14517 #define M_MNEM_vst42 0xfc801e41
14518 #define M_MNEM_vst43 0xfc801e61
14519 #define M_MNEM_vld20 0xfc901e00
14520 #define M_MNEM_vld21 0xfc901e20
14521 #define M_MNEM_vld40 0xfc901e01
14522 #define M_MNEM_vld41 0xfc901e21
14523 #define M_MNEM_vld42 0xfc901e41
14524 #define M_MNEM_vld43 0xfc901e61
14525 #define M_MNEM_vstrb 0xec000e00
14526 #define M_MNEM_vstrh 0xec000e10
14527 #define M_MNEM_vstrw 0xec000e40
14528 #define M_MNEM_vstrd 0xec000e50
14529 #define M_MNEM_vldrb 0xec100e00
14530 #define M_MNEM_vldrh 0xec100e10
14531 #define M_MNEM_vldrw 0xec100e40
14532 #define M_MNEM_vldrd 0xec100e50
14533 #define M_MNEM_vmovlt 0xeea01f40
14534 #define M_MNEM_vmovlb 0xeea00f40
14535 #define M_MNEM_vmovnt 0xfe311e81
14536 #define M_MNEM_vmovnb 0xfe310e81
14537 #define M_MNEM_vadc 0xee300f00
14538 #define M_MNEM_vadci 0xee301f00
14539 #define M_MNEM_vbrsr 0xfe011e60
14540 #define M_MNEM_vaddlv 0xee890f00
14541 #define M_MNEM_vaddlva 0xee890f20
14542 #define M_MNEM_vaddv 0xeef10f00
14543 #define M_MNEM_vaddva 0xeef10f20
14544 #define M_MNEM_vddup 0xee011f6e
14545 #define M_MNEM_vdwdup 0xee011f60
14546 #define M_MNEM_vidup 0xee010f6e
14547 #define M_MNEM_viwdup 0xee010f60
14548 #define M_MNEM_vmaxv 0xeee20f00
14549 #define M_MNEM_vmaxav 0xeee00f00
14550 #define M_MNEM_vminv 0xeee20f80
14551 #define M_MNEM_vminav 0xeee00f80
14552 #define M_MNEM_vmlaldav 0xee800e00
14553 #define M_MNEM_vmlaldava 0xee800e20
14554 #define M_MNEM_vmlaldavx 0xee801e00
14555 #define M_MNEM_vmlaldavax 0xee801e20
14556 #define M_MNEM_vmlsldav 0xee800e01
14557 #define M_MNEM_vmlsldava 0xee800e21
14558 #define M_MNEM_vmlsldavx 0xee801e01
14559 #define M_MNEM_vmlsldavax 0xee801e21
14560 #define M_MNEM_vrmlaldavhx 0xee801f00
14561 #define M_MNEM_vrmlaldavhax 0xee801f20
14562 #define M_MNEM_vrmlsldavh 0xfe800e01
14563 #define M_MNEM_vrmlsldavha 0xfe800e21
14564 #define M_MNEM_vrmlsldavhx 0xfe801e01
14565 #define M_MNEM_vrmlsldavhax 0xfe801e21
14566 #define M_MNEM_vqmovnt 0xee331e01
14567 #define M_MNEM_vqmovnb 0xee330e01
14568 #define M_MNEM_vqmovunt 0xee311e81
14569 #define M_MNEM_vqmovunb 0xee310e81
14570 #define M_MNEM_vshrnt 0xee801fc1
14571 #define M_MNEM_vshrnb 0xee800fc1
14572 #define M_MNEM_vrshrnt 0xfe801fc1
14573 #define M_MNEM_vqshrnt 0xee801f40
14574 #define M_MNEM_vqshrnb 0xee800f40
14575 #define M_MNEM_vqshrunt 0xee801fc0
14576 #define M_MNEM_vqshrunb 0xee800fc0
14577 #define M_MNEM_vrshrnb 0xfe800fc1
14578 #define M_MNEM_vqrshrnt 0xee801f41
14579 #define M_MNEM_vqrshrnb 0xee800f41
14580 #define M_MNEM_vqrshrunt 0xfe801fc0
14581 #define M_MNEM_vqrshrunb 0xfe800fc0
14583 /* Bfloat16 instruction encoder helpers. */
14584 #define B_MNEM_vfmat 0xfc300850
14585 #define B_MNEM_vfmab 0xfc300810
14587 /* Neon instruction encoder helpers. */
14589 /* Encodings for the different types for various Neon opcodes. */
14591 /* An "invalid" code for the following tables. */
14594 struct neon_tab_entry
14597 unsigned float_or_poly
;
14598 unsigned scalar_or_imm
;
14601 /* Map overloaded Neon opcodes to their respective encodings. */
14602 #define NEON_ENC_TAB \
14603 X(vabd, 0x0000700, 0x1200d00, N_INV), \
14604 X(vabdl, 0x0800700, N_INV, N_INV), \
14605 X(vmax, 0x0000600, 0x0000f00, N_INV), \
14606 X(vmin, 0x0000610, 0x0200f00, N_INV), \
14607 X(vpadd, 0x0000b10, 0x1000d00, N_INV), \
14608 X(vpmax, 0x0000a00, 0x1000f00, N_INV), \
14609 X(vpmin, 0x0000a10, 0x1200f00, N_INV), \
14610 X(vadd, 0x0000800, 0x0000d00, N_INV), \
14611 X(vaddl, 0x0800000, N_INV, N_INV), \
14612 X(vsub, 0x1000800, 0x0200d00, N_INV), \
14613 X(vsubl, 0x0800200, N_INV, N_INV), \
14614 X(vceq, 0x1000810, 0x0000e00, 0x1b10100), \
14615 X(vcge, 0x0000310, 0x1000e00, 0x1b10080), \
14616 X(vcgt, 0x0000300, 0x1200e00, 0x1b10000), \
14617 /* Register variants of the following two instructions are encoded as
14618 vcge / vcgt with the operands reversed. */ \
14619 X(vclt, 0x0000300, 0x1200e00, 0x1b10200), \
14620 X(vcle, 0x0000310, 0x1000e00, 0x1b10180), \
14621 X(vfma, N_INV, 0x0000c10, N_INV), \
14622 X(vfms, N_INV, 0x0200c10, N_INV), \
14623 X(vmla, 0x0000900, 0x0000d10, 0x0800040), \
14624 X(vmls, 0x1000900, 0x0200d10, 0x0800440), \
14625 X(vmul, 0x0000910, 0x1000d10, 0x0800840), \
14626 X(vmull, 0x0800c00, 0x0800e00, 0x0800a40), /* polynomial not float. */ \
14627 X(vmlal, 0x0800800, N_INV, 0x0800240), \
14628 X(vmlsl, 0x0800a00, N_INV, 0x0800640), \
14629 X(vqdmlal, 0x0800900, N_INV, 0x0800340), \
14630 X(vqdmlsl, 0x0800b00, N_INV, 0x0800740), \
14631 X(vqdmull, 0x0800d00, N_INV, 0x0800b40), \
14632 X(vqdmulh, 0x0000b00, N_INV, 0x0800c40), \
14633 X(vqrdmulh, 0x1000b00, N_INV, 0x0800d40), \
14634 X(vqrdmlah, 0x3000b10, N_INV, 0x0800e40), \
14635 X(vqrdmlsh, 0x3000c10, N_INV, 0x0800f40), \
14636 X(vshl, 0x0000400, N_INV, 0x0800510), \
14637 X(vqshl, 0x0000410, N_INV, 0x0800710), \
14638 X(vand, 0x0000110, N_INV, 0x0800030), \
14639 X(vbic, 0x0100110, N_INV, 0x0800030), \
14640 X(veor, 0x1000110, N_INV, N_INV), \
14641 X(vorn, 0x0300110, N_INV, 0x0800010), \
14642 X(vorr, 0x0200110, N_INV, 0x0800010), \
14643 X(vmvn, 0x1b00580, N_INV, 0x0800030), \
14644 X(vshll, 0x1b20300, N_INV, 0x0800a10), /* max shift, immediate. */ \
14645 X(vcvt, 0x1b30600, N_INV, 0x0800e10), /* integer, fixed-point. */ \
14646 X(vdup, 0xe800b10, N_INV, 0x1b00c00), /* arm, scalar. */ \
14647 X(vld1, 0x0200000, 0x0a00000, 0x0a00c00), /* interlv, lane, dup. */ \
14648 X(vst1, 0x0000000, 0x0800000, N_INV), \
14649 X(vld2, 0x0200100, 0x0a00100, 0x0a00d00), \
14650 X(vst2, 0x0000100, 0x0800100, N_INV), \
14651 X(vld3, 0x0200200, 0x0a00200, 0x0a00e00), \
14652 X(vst3, 0x0000200, 0x0800200, N_INV), \
14653 X(vld4, 0x0200300, 0x0a00300, 0x0a00f00), \
14654 X(vst4, 0x0000300, 0x0800300, N_INV), \
14655 X(vmovn, 0x1b20200, N_INV, N_INV), \
14656 X(vtrn, 0x1b20080, N_INV, N_INV), \
14657 X(vqmovn, 0x1b20200, N_INV, N_INV), \
14658 X(vqmovun, 0x1b20240, N_INV, N_INV), \
14659 X(vnmul, 0xe200a40, 0xe200b40, N_INV), \
14660 X(vnmla, 0xe100a40, 0xe100b40, N_INV), \
14661 X(vnmls, 0xe100a00, 0xe100b00, N_INV), \
14662 X(vfnma, 0xe900a40, 0xe900b40, N_INV), \
14663 X(vfnms, 0xe900a00, 0xe900b00, N_INV), \
14664 X(vcmp, 0xeb40a40, 0xeb40b40, N_INV), \
14665 X(vcmpz, 0xeb50a40, 0xeb50b40, N_INV), \
14666 X(vcmpe, 0xeb40ac0, 0xeb40bc0, N_INV), \
14667 X(vcmpez, 0xeb50ac0, 0xeb50bc0, N_INV), \
14668 X(vseleq, 0xe000a00, N_INV, N_INV), \
14669 X(vselvs, 0xe100a00, N_INV, N_INV), \
14670 X(vselge, 0xe200a00, N_INV, N_INV), \
14671 X(vselgt, 0xe300a00, N_INV, N_INV), \
14672 X(vmaxnm, 0xe800a00, 0x3000f10, N_INV), \
14673 X(vminnm, 0xe800a40, 0x3200f10, N_INV), \
14674 X(vcvta, 0xebc0a40, 0x3bb0000, N_INV), \
14675 X(vrintr, 0xeb60a40, 0x3ba0400, N_INV), \
14676 X(vrinta, 0xeb80a40, 0x3ba0400, N_INV), \
14677 X(aes, 0x3b00300, N_INV, N_INV), \
14678 X(sha3op, 0x2000c00, N_INV, N_INV), \
14679 X(sha1h, 0x3b902c0, N_INV, N_INV), \
14680 X(sha2op, 0x3ba0380, N_INV, N_INV)
14684 #define X(OPC,I,F,S) N_MNEM_##OPC
14689 static const struct neon_tab_entry neon_enc_tab
[] =
14691 #define X(OPC,I,F,S) { (I), (F), (S) }
14696 /* Do not use these macros; instead, use NEON_ENCODE defined below. */
14697 #define NEON_ENC_INTEGER_(X) (neon_enc_tab[(X) & 0x0fffffff].integer)
14698 #define NEON_ENC_ARMREG_(X) (neon_enc_tab[(X) & 0x0fffffff].integer)
14699 #define NEON_ENC_POLY_(X) (neon_enc_tab[(X) & 0x0fffffff].float_or_poly)
14700 #define NEON_ENC_FLOAT_(X) (neon_enc_tab[(X) & 0x0fffffff].float_or_poly)
14701 #define NEON_ENC_SCALAR_(X) (neon_enc_tab[(X) & 0x0fffffff].scalar_or_imm)
14702 #define NEON_ENC_IMMED_(X) (neon_enc_tab[(X) & 0x0fffffff].scalar_or_imm)
14703 #define NEON_ENC_INTERLV_(X) (neon_enc_tab[(X) & 0x0fffffff].integer)
14704 #define NEON_ENC_LANE_(X) (neon_enc_tab[(X) & 0x0fffffff].float_or_poly)
14705 #define NEON_ENC_DUP_(X) (neon_enc_tab[(X) & 0x0fffffff].scalar_or_imm)
14706 #define NEON_ENC_SINGLE_(X) \
14707 ((neon_enc_tab[(X) & 0x0fffffff].integer) | ((X) & 0xf0000000))
14708 #define NEON_ENC_DOUBLE_(X) \
14709 ((neon_enc_tab[(X) & 0x0fffffff].float_or_poly) | ((X) & 0xf0000000))
14710 #define NEON_ENC_FPV8_(X) \
14711 ((neon_enc_tab[(X) & 0x0fffffff].integer) | ((X) & 0xf000000))
14713 #define NEON_ENCODE(type, inst) \
14716 inst.instruction = NEON_ENC_##type##_ (inst.instruction); \
14717 inst.is_neon = 1; \
14721 #define check_neon_suffixes \
14724 if (!inst.error && inst.vectype.elems > 0 && !inst.is_neon) \
14726 as_bad (_("invalid neon suffix for non neon instruction")); \
14732 /* Define shapes for instruction operands. The following mnemonic characters
14733 are used in this table:
14735 F - VFP S<n> register
14736 D - Neon D<n> register
14737 Q - Neon Q<n> register
14741 L - D<n> register list
14743 This table is used to generate various data:
14744 - enumerations of the form NS_DDR to be used as arguments to
14746 - a table classifying shapes into single, double, quad, mixed.
14747 - a table used to drive neon_select_shape. */
14749 #define NEON_SHAPE_DEF \
14750 X(4, (R, R, Q, Q), QUAD), \
14751 X(4, (Q, R, R, I), QUAD), \
14752 X(4, (R, R, S, S), QUAD), \
14753 X(4, (S, S, R, R), QUAD), \
14754 X(3, (Q, R, I), QUAD), \
14755 X(3, (I, Q, Q), QUAD), \
14756 X(3, (I, Q, R), QUAD), \
14757 X(3, (R, Q, Q), QUAD), \
14758 X(3, (D, D, D), DOUBLE), \
14759 X(3, (Q, Q, Q), QUAD), \
14760 X(3, (D, D, I), DOUBLE), \
14761 X(3, (Q, Q, I), QUAD), \
14762 X(3, (D, D, S), DOUBLE), \
14763 X(3, (Q, Q, S), QUAD), \
14764 X(3, (Q, Q, R), QUAD), \
14765 X(3, (R, R, Q), QUAD), \
14766 X(2, (R, Q), QUAD), \
14767 X(2, (D, D), DOUBLE), \
14768 X(2, (Q, Q), QUAD), \
14769 X(2, (D, S), DOUBLE), \
14770 X(2, (Q, S), QUAD), \
14771 X(2, (D, R), DOUBLE), \
14772 X(2, (Q, R), QUAD), \
14773 X(2, (D, I), DOUBLE), \
14774 X(2, (Q, I), QUAD), \
14775 X(3, (D, L, D), DOUBLE), \
14776 X(2, (D, Q), MIXED), \
14777 X(2, (Q, D), MIXED), \
14778 X(3, (D, Q, I), MIXED), \
14779 X(3, (Q, D, I), MIXED), \
14780 X(3, (Q, D, D), MIXED), \
14781 X(3, (D, Q, Q), MIXED), \
14782 X(3, (Q, Q, D), MIXED), \
14783 X(3, (Q, D, S), MIXED), \
14784 X(3, (D, Q, S), MIXED), \
14785 X(4, (D, D, D, I), DOUBLE), \
14786 X(4, (Q, Q, Q, I), QUAD), \
14787 X(4, (D, D, S, I), DOUBLE), \
14788 X(4, (Q, Q, S, I), QUAD), \
14789 X(2, (F, F), SINGLE), \
14790 X(3, (F, F, F), SINGLE), \
14791 X(2, (F, I), SINGLE), \
14792 X(2, (F, D), MIXED), \
14793 X(2, (D, F), MIXED), \
14794 X(3, (F, F, I), MIXED), \
14795 X(4, (R, R, F, F), SINGLE), \
14796 X(4, (F, F, R, R), SINGLE), \
14797 X(3, (D, R, R), DOUBLE), \
14798 X(3, (R, R, D), DOUBLE), \
14799 X(2, (S, R), SINGLE), \
14800 X(2, (R, S), SINGLE), \
14801 X(2, (F, R), SINGLE), \
14802 X(2, (R, F), SINGLE), \
14803 /* Used for MVE tail predicated loop instructions. */\
14804 X(2, (R, R), QUAD), \
14805 /* Half float shape supported so far. */\
14806 X (2, (H, D), MIXED), \
14807 X (2, (D, H), MIXED), \
14808 X (2, (H, F), MIXED), \
14809 X (2, (F, H), MIXED), \
14810 X (2, (H, H), HALF), \
14811 X (2, (H, R), HALF), \
14812 X (2, (R, H), HALF), \
14813 X (2, (H, I), HALF), \
14814 X (3, (H, H, H), HALF), \
14815 X (3, (H, F, I), MIXED), \
14816 X (3, (F, H, I), MIXED), \
14817 X (3, (D, H, H), MIXED), \
14818 X (3, (D, H, S), MIXED)
14820 #define S2(A,B) NS_##A##B
14821 #define S3(A,B,C) NS_##A##B##C
14822 #define S4(A,B,C,D) NS_##A##B##C##D
14824 #define X(N, L, C) S##N L
14837 enum neon_shape_class
14846 #define X(N, L, C) SC_##C
14848 static enum neon_shape_class neon_shape_class
[] =
14867 /* Register widths of above. */
14868 static unsigned neon_shape_el_size
[] =
14880 struct neon_shape_info
14883 enum neon_shape_el el
[NEON_MAX_TYPE_ELS
];
14886 #define S2(A,B) { SE_##A, SE_##B }
14887 #define S3(A,B,C) { SE_##A, SE_##B, SE_##C }
14888 #define S4(A,B,C,D) { SE_##A, SE_##B, SE_##C, SE_##D }
14890 #define X(N, L, C) { N, S##N L }
14892 static struct neon_shape_info neon_shape_tab
[] =
14902 /* Bit masks used in type checking given instructions.
14903 'N_EQK' means the type must be the same as (or based on in some way) the key
14904 type, which itself is marked with the 'N_KEY' bit. If the 'N_EQK' bit is
14905 set, various other bits can be set as well in order to modify the meaning of
14906 the type constraint. */
14908 enum neon_type_mask
14932 N_BF16
= 0x0400000,
14933 N_KEY
= 0x1000000, /* Key element (main type specifier). */
14934 N_EQK
= 0x2000000, /* Given operand has the same type & size as the key. */
14935 N_VFP
= 0x4000000, /* VFP mode: operand size must match register width. */
14936 N_UNT
= 0x8000000, /* Must be explicitly untyped. */
14937 N_DBL
= 0x0000001, /* If N_EQK, this operand is twice the size. */
14938 N_HLF
= 0x0000002, /* If N_EQK, this operand is half the size. */
14939 N_SGN
= 0x0000004, /* If N_EQK, this operand is forced to be signed. */
14940 N_UNS
= 0x0000008, /* If N_EQK, this operand is forced to be unsigned. */
14941 N_INT
= 0x0000010, /* If N_EQK, this operand is forced to be integer. */
14942 N_FLT
= 0x0000020, /* If N_EQK, this operand is forced to be float. */
14943 N_SIZ
= 0x0000040, /* If N_EQK, this operand is forced to be size-only. */
14945 N_MAX_NONSPECIAL
= N_P64
14948 #define N_ALLMODS (N_DBL | N_HLF | N_SGN | N_UNS | N_INT | N_FLT | N_SIZ)
14950 #define N_SU_ALL (N_S8 | N_S16 | N_S32 | N_S64 | N_U8 | N_U16 | N_U32 | N_U64)
14951 #define N_SU_32 (N_S8 | N_S16 | N_S32 | N_U8 | N_U16 | N_U32)
14952 #define N_SU_16_64 (N_S16 | N_S32 | N_S64 | N_U16 | N_U32 | N_U64)
14953 #define N_S_32 (N_S8 | N_S16 | N_S32)
14954 #define N_F_16_32 (N_F16 | N_F32)
14955 #define N_SUF_32 (N_SU_32 | N_F_16_32)
14956 #define N_I_ALL (N_I8 | N_I16 | N_I32 | N_I64)
14957 #define N_IF_32 (N_I8 | N_I16 | N_I32 | N_F16 | N_F32)
14958 #define N_F_ALL (N_F16 | N_F32 | N_F64)
14959 #define N_I_MVE (N_I8 | N_I16 | N_I32)
14960 #define N_F_MVE (N_F16 | N_F32)
14961 #define N_SU_MVE (N_S8 | N_S16 | N_S32 | N_U8 | N_U16 | N_U32)
14963 /* Pass this as the first type argument to neon_check_type to ignore types
14965 #define N_IGNORE_TYPE (N_KEY | N_EQK)
14967 /* Select a "shape" for the current instruction (describing register types or
14968 sizes) from a list of alternatives. Return NS_NULL if the current instruction
14969 doesn't fit. For non-polymorphic shapes, checking is usually done as a
14970 function of operand parsing, so this function doesn't need to be called.
14971 Shapes should be listed in order of decreasing length. */
14973 static enum neon_shape
14974 neon_select_shape (enum neon_shape shape
, ...)
14977 enum neon_shape first_shape
= shape
;
14979 /* Fix missing optional operands. FIXME: we don't know at this point how
14980 many arguments we should have, so this makes the assumption that we have
14981 > 1. This is true of all current Neon opcodes, I think, but may not be
14982 true in the future. */
14983 if (!inst
.operands
[1].present
)
14984 inst
.operands
[1] = inst
.operands
[0];
14986 va_start (ap
, shape
);
14988 for (; shape
!= NS_NULL
; shape
= (enum neon_shape
) va_arg (ap
, int))
14993 for (j
= 0; j
< neon_shape_tab
[shape
].els
; j
++)
14995 if (!inst
.operands
[j
].present
)
15001 switch (neon_shape_tab
[shape
].el
[j
])
15003 /* If a .f16, .16, .u16, .s16 type specifier is given over
15004 a VFP single precision register operand, it's essentially
15005 means only half of the register is used.
15007 If the type specifier is given after the mnemonics, the
15008 information is stored in inst.vectype. If the type specifier
15009 is given after register operand, the information is stored
15010 in inst.operands[].vectype.
15012 When there is only one type specifier, and all the register
15013 operands are the same type of hardware register, the type
15014 specifier applies to all register operands.
15016 If no type specifier is given, the shape is inferred from
15017 operand information.
15020 vadd.f16 s0, s1, s2: NS_HHH
15021 vabs.f16 s0, s1: NS_HH
15022 vmov.f16 s0, r1: NS_HR
15023 vmov.f16 r0, s1: NS_RH
15024 vcvt.f16 r0, s1: NS_RH
15025 vcvt.f16.s32 s2, s2, #29: NS_HFI
15026 vcvt.f16.s32 s2, s2: NS_HF
15029 if (!(inst
.operands
[j
].isreg
15030 && inst
.operands
[j
].isvec
15031 && inst
.operands
[j
].issingle
15032 && !inst
.operands
[j
].isquad
15033 && ((inst
.vectype
.elems
== 1
15034 && inst
.vectype
.el
[0].size
== 16)
15035 || (inst
.vectype
.elems
> 1
15036 && inst
.vectype
.el
[j
].size
== 16)
15037 || (inst
.vectype
.elems
== 0
15038 && inst
.operands
[j
].vectype
.type
!= NT_invtype
15039 && inst
.operands
[j
].vectype
.size
== 16))))
15044 if (!(inst
.operands
[j
].isreg
15045 && inst
.operands
[j
].isvec
15046 && inst
.operands
[j
].issingle
15047 && !inst
.operands
[j
].isquad
15048 && ((inst
.vectype
.elems
== 1 && inst
.vectype
.el
[0].size
== 32)
15049 || (inst
.vectype
.elems
> 1 && inst
.vectype
.el
[j
].size
== 32)
15050 || (inst
.vectype
.elems
== 0
15051 && (inst
.operands
[j
].vectype
.size
== 32
15052 || inst
.operands
[j
].vectype
.type
== NT_invtype
)))))
15057 if (!(inst
.operands
[j
].isreg
15058 && inst
.operands
[j
].isvec
15059 && !inst
.operands
[j
].isquad
15060 && !inst
.operands
[j
].issingle
))
15065 if (!(inst
.operands
[j
].isreg
15066 && !inst
.operands
[j
].isvec
))
15071 if (!(inst
.operands
[j
].isreg
15072 && inst
.operands
[j
].isvec
15073 && inst
.operands
[j
].isquad
15074 && !inst
.operands
[j
].issingle
))
15079 if (!(!inst
.operands
[j
].isreg
15080 && !inst
.operands
[j
].isscalar
))
15085 if (!(!inst
.operands
[j
].isreg
15086 && inst
.operands
[j
].isscalar
))
15096 if (matches
&& (j
>= ARM_IT_MAX_OPERANDS
|| !inst
.operands
[j
].present
))
15097 /* We've matched all the entries in the shape table, and we don't
15098 have any left over operands which have not been matched. */
15104 if (shape
== NS_NULL
&& first_shape
!= NS_NULL
)
15105 first_error (_("invalid instruction shape"));
15110 /* True if SHAPE is predominantly a quadword operation (most of the time, this
15111 means the Q bit should be set). */
15114 neon_quad (enum neon_shape shape
)
15116 return neon_shape_class
[shape
] == SC_QUAD
;
15120 neon_modify_type_size (unsigned typebits
, enum neon_el_type
*g_type
,
15123 /* Allow modification to be made to types which are constrained to be
15124 based on the key element, based on bits set alongside N_EQK. */
15125 if ((typebits
& N_EQK
) != 0)
15127 if ((typebits
& N_HLF
) != 0)
15129 else if ((typebits
& N_DBL
) != 0)
15131 if ((typebits
& N_SGN
) != 0)
15132 *g_type
= NT_signed
;
15133 else if ((typebits
& N_UNS
) != 0)
15134 *g_type
= NT_unsigned
;
15135 else if ((typebits
& N_INT
) != 0)
15136 *g_type
= NT_integer
;
15137 else if ((typebits
& N_FLT
) != 0)
15138 *g_type
= NT_float
;
15139 else if ((typebits
& N_SIZ
) != 0)
15140 *g_type
= NT_untyped
;
15144 /* Return operand OPNO promoted by bits set in THISARG. KEY should be the "key"
15145 operand type, i.e. the single type specified in a Neon instruction when it
15146 is the only one given. */
15148 static struct neon_type_el
15149 neon_type_promote (struct neon_type_el
*key
, unsigned thisarg
)
15151 struct neon_type_el dest
= *key
;
15153 gas_assert ((thisarg
& N_EQK
) != 0);
15155 neon_modify_type_size (thisarg
, &dest
.type
, &dest
.size
);
15160 /* Convert Neon type and size into compact bitmask representation. */
15162 static enum neon_type_mask
15163 type_chk_of_el_type (enum neon_el_type type
, unsigned size
)
15170 case 8: return N_8
;
15171 case 16: return N_16
;
15172 case 32: return N_32
;
15173 case 64: return N_64
;
15181 case 8: return N_I8
;
15182 case 16: return N_I16
;
15183 case 32: return N_I32
;
15184 case 64: return N_I64
;
15192 case 16: return N_F16
;
15193 case 32: return N_F32
;
15194 case 64: return N_F64
;
15202 case 8: return N_P8
;
15203 case 16: return N_P16
;
15204 case 64: return N_P64
;
15212 case 8: return N_S8
;
15213 case 16: return N_S16
;
15214 case 32: return N_S32
;
15215 case 64: return N_S64
;
15223 case 8: return N_U8
;
15224 case 16: return N_U16
;
15225 case 32: return N_U32
;
15226 case 64: return N_U64
;
15232 if (size
== 16) return N_BF16
;
15241 /* Convert compact Neon bitmask type representation to a type and size. Only
15242 handles the case where a single bit is set in the mask. */
15245 el_type_of_type_chk (enum neon_el_type
*type
, unsigned *size
,
15246 enum neon_type_mask mask
)
15248 if ((mask
& N_EQK
) != 0)
15251 if ((mask
& (N_S8
| N_U8
| N_I8
| N_8
| N_P8
)) != 0)
15253 else if ((mask
& (N_S16
| N_U16
| N_I16
| N_16
| N_F16
| N_P16
| N_BF16
))
15256 else if ((mask
& (N_S32
| N_U32
| N_I32
| N_32
| N_F32
)) != 0)
15258 else if ((mask
& (N_S64
| N_U64
| N_I64
| N_64
| N_F64
| N_P64
)) != 0)
15263 if ((mask
& (N_S8
| N_S16
| N_S32
| N_S64
)) != 0)
15265 else if ((mask
& (N_U8
| N_U16
| N_U32
| N_U64
)) != 0)
15266 *type
= NT_unsigned
;
15267 else if ((mask
& (N_I8
| N_I16
| N_I32
| N_I64
)) != 0)
15268 *type
= NT_integer
;
15269 else if ((mask
& (N_8
| N_16
| N_32
| N_64
)) != 0)
15270 *type
= NT_untyped
;
15271 else if ((mask
& (N_P8
| N_P16
| N_P64
)) != 0)
15273 else if ((mask
& (N_F_ALL
)) != 0)
15275 else if ((mask
& (N_BF16
)) != 0)
15283 /* Modify a bitmask of allowed types. This is only needed for type
15287 modify_types_allowed (unsigned allowed
, unsigned mods
)
15290 enum neon_el_type type
;
15296 for (i
= 1; i
<= N_MAX_NONSPECIAL
; i
<<= 1)
15298 if (el_type_of_type_chk (&type
, &size
,
15299 (enum neon_type_mask
) (allowed
& i
)) == SUCCESS
)
15301 neon_modify_type_size (mods
, &type
, &size
);
15302 destmask
|= type_chk_of_el_type (type
, size
);
15309 /* Check type and return type classification.
15310 The manual states (paraphrase): If one datatype is given, it indicates the
15312 - the second operand, if there is one
15313 - the operand, if there is no second operand
15314 - the result, if there are no operands.
15315 This isn't quite good enough though, so we use a concept of a "key" datatype
15316 which is set on a per-instruction basis, which is the one which matters when
15317 only one data type is written.
15318 Note: this function has side-effects (e.g. filling in missing operands). All
15319 Neon instructions should call it before performing bit encoding. */
15321 static struct neon_type_el
15322 neon_check_type (unsigned els
, enum neon_shape ns
, ...)
15325 unsigned i
, pass
, key_el
= 0;
15326 unsigned types
[NEON_MAX_TYPE_ELS
];
15327 enum neon_el_type k_type
= NT_invtype
;
15328 unsigned k_size
= -1u;
15329 struct neon_type_el badtype
= {NT_invtype
, -1};
15330 unsigned key_allowed
= 0;
15332 /* Optional registers in Neon instructions are always (not) in operand 1.
15333 Fill in the missing operand here, if it was omitted. */
15334 if (els
> 1 && !inst
.operands
[1].present
)
15335 inst
.operands
[1] = inst
.operands
[0];
15337 /* Suck up all the varargs. */
15339 for (i
= 0; i
< els
; i
++)
15341 unsigned thisarg
= va_arg (ap
, unsigned);
15342 if (thisarg
== N_IGNORE_TYPE
)
15347 types
[i
] = thisarg
;
15348 if ((thisarg
& N_KEY
) != 0)
15353 if (inst
.vectype
.elems
> 0)
15354 for (i
= 0; i
< els
; i
++)
15355 if (inst
.operands
[i
].vectype
.type
!= NT_invtype
)
15357 first_error (_("types specified in both the mnemonic and operands"));
15361 /* Duplicate inst.vectype elements here as necessary.
15362 FIXME: No idea if this is exactly the same as the ARM assembler,
15363 particularly when an insn takes one register and one non-register
15365 if (inst
.vectype
.elems
== 1 && els
> 1)
15368 inst
.vectype
.elems
= els
;
15369 inst
.vectype
.el
[key_el
] = inst
.vectype
.el
[0];
15370 for (j
= 0; j
< els
; j
++)
15372 inst
.vectype
.el
[j
] = neon_type_promote (&inst
.vectype
.el
[key_el
],
15375 else if (inst
.vectype
.elems
== 0 && els
> 0)
15378 /* No types were given after the mnemonic, so look for types specified
15379 after each operand. We allow some flexibility here; as long as the
15380 "key" operand has a type, we can infer the others. */
15381 for (j
= 0; j
< els
; j
++)
15382 if (inst
.operands
[j
].vectype
.type
!= NT_invtype
)
15383 inst
.vectype
.el
[j
] = inst
.operands
[j
].vectype
;
15385 if (inst
.operands
[key_el
].vectype
.type
!= NT_invtype
)
15387 for (j
= 0; j
< els
; j
++)
15388 if (inst
.operands
[j
].vectype
.type
== NT_invtype
)
15389 inst
.vectype
.el
[j
] = neon_type_promote (&inst
.vectype
.el
[key_el
],
15394 first_error (_("operand types can't be inferred"));
15398 else if (inst
.vectype
.elems
!= els
)
15400 first_error (_("type specifier has the wrong number of parts"));
15404 for (pass
= 0; pass
< 2; pass
++)
15406 for (i
= 0; i
< els
; i
++)
15408 unsigned thisarg
= types
[i
];
15409 unsigned types_allowed
= ((thisarg
& N_EQK
) != 0 && pass
!= 0)
15410 ? modify_types_allowed (key_allowed
, thisarg
) : thisarg
;
15411 enum neon_el_type g_type
= inst
.vectype
.el
[i
].type
;
15412 unsigned g_size
= inst
.vectype
.el
[i
].size
;
15414 /* Decay more-specific signed & unsigned types to sign-insensitive
15415 integer types if sign-specific variants are unavailable. */
15416 if ((g_type
== NT_signed
|| g_type
== NT_unsigned
)
15417 && (types_allowed
& N_SU_ALL
) == 0)
15418 g_type
= NT_integer
;
15420 /* If only untyped args are allowed, decay any more specific types to
15421 them. Some instructions only care about signs for some element
15422 sizes, so handle that properly. */
15423 if (((types_allowed
& N_UNT
) == 0)
15424 && ((g_size
== 8 && (types_allowed
& N_8
) != 0)
15425 || (g_size
== 16 && (types_allowed
& N_16
) != 0)
15426 || (g_size
== 32 && (types_allowed
& N_32
) != 0)
15427 || (g_size
== 64 && (types_allowed
& N_64
) != 0)))
15428 g_type
= NT_untyped
;
15432 if ((thisarg
& N_KEY
) != 0)
15436 key_allowed
= thisarg
& ~N_KEY
;
15438 /* Check architecture constraint on FP16 extension. */
15440 && k_type
== NT_float
15441 && ! ARM_CPU_HAS_FEATURE (cpu_variant
, arm_ext_fp16
))
15443 inst
.error
= _(BAD_FP16
);
15450 if ((thisarg
& N_VFP
) != 0)
15452 enum neon_shape_el regshape
;
15453 unsigned regwidth
, match
;
15455 /* PR 11136: Catch the case where we are passed a shape of NS_NULL. */
15458 first_error (_("invalid instruction shape"));
15461 regshape
= neon_shape_tab
[ns
].el
[i
];
15462 regwidth
= neon_shape_el_size
[regshape
];
15464 /* In VFP mode, operands must match register widths. If we
15465 have a key operand, use its width, else use the width of
15466 the current operand. */
15472 /* FP16 will use a single precision register. */
15473 if (regwidth
== 32 && match
== 16)
15475 if (ARM_CPU_HAS_FEATURE (cpu_variant
, arm_ext_fp16
))
15479 inst
.error
= _(BAD_FP16
);
15484 if (regwidth
!= match
)
15486 first_error (_("operand size must match register width"));
15491 if ((thisarg
& N_EQK
) == 0)
15493 unsigned given_type
= type_chk_of_el_type (g_type
, g_size
);
15495 if ((given_type
& types_allowed
) == 0)
15497 first_error (BAD_SIMD_TYPE
);
15503 enum neon_el_type mod_k_type
= k_type
;
15504 unsigned mod_k_size
= k_size
;
15505 neon_modify_type_size (thisarg
, &mod_k_type
, &mod_k_size
);
15506 if (g_type
!= mod_k_type
|| g_size
!= mod_k_size
)
15508 first_error (_("inconsistent types in Neon instruction"));
15516 return inst
.vectype
.el
[key_el
];
15519 /* Neon-style VFP instruction forwarding. */
15521 /* Thumb VFP instructions have 0xE in the condition field. */
15524 do_vfp_cond_or_thumb (void)
15529 inst
.instruction
|= 0xe0000000;
15531 inst
.instruction
|= inst
.cond
<< 28;
15534 /* Look up and encode a simple mnemonic, for use as a helper function for the
15535 Neon-style VFP syntax. This avoids duplication of bits of the insns table,
15536 etc. It is assumed that operand parsing has already been done, and that the
15537 operands are in the form expected by the given opcode (this isn't necessarily
15538 the same as the form in which they were parsed, hence some massaging must
15539 take place before this function is called).
15540 Checks current arch version against that in the looked-up opcode. */
15543 do_vfp_nsyn_opcode (const char *opname
)
15545 const struct asm_opcode
*opcode
;
15547 opcode
= (const struct asm_opcode
*) hash_find (arm_ops_hsh
, opname
);
15552 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant
,
15553 thumb_mode
? *opcode
->tvariant
: *opcode
->avariant
),
15560 inst
.instruction
= opcode
->tvalue
;
15561 opcode
->tencode ();
15565 inst
.instruction
= (inst
.cond
<< 28) | opcode
->avalue
;
15566 opcode
->aencode ();
15571 do_vfp_nsyn_add_sub (enum neon_shape rs
)
15573 int is_add
= (inst
.instruction
& 0x0fffffff) == N_MNEM_vadd
;
15575 if (rs
== NS_FFF
|| rs
== NS_HHH
)
15578 do_vfp_nsyn_opcode ("fadds");
15580 do_vfp_nsyn_opcode ("fsubs");
15582 /* ARMv8.2 fp16 instruction. */
15584 do_scalar_fp16_v82_encode ();
15589 do_vfp_nsyn_opcode ("faddd");
15591 do_vfp_nsyn_opcode ("fsubd");
15595 /* Check operand types to see if this is a VFP instruction, and if so call
15599 try_vfp_nsyn (int args
, void (*pfn
) (enum neon_shape
))
15601 enum neon_shape rs
;
15602 struct neon_type_el et
;
15607 rs
= neon_select_shape (NS_HH
, NS_FF
, NS_DD
, NS_NULL
);
15608 et
= neon_check_type (2, rs
, N_EQK
| N_VFP
, N_F_ALL
| N_KEY
| N_VFP
);
15612 rs
= neon_select_shape (NS_HHH
, NS_FFF
, NS_DDD
, NS_NULL
);
15613 et
= neon_check_type (3, rs
, N_EQK
| N_VFP
, N_EQK
| N_VFP
,
15614 N_F_ALL
| N_KEY
| N_VFP
);
15621 if (et
.type
!= NT_invtype
)
15632 do_vfp_nsyn_mla_mls (enum neon_shape rs
)
15634 int is_mla
= (inst
.instruction
& 0x0fffffff) == N_MNEM_vmla
;
15636 if (rs
== NS_FFF
|| rs
== NS_HHH
)
15639 do_vfp_nsyn_opcode ("fmacs");
15641 do_vfp_nsyn_opcode ("fnmacs");
15643 /* ARMv8.2 fp16 instruction. */
15645 do_scalar_fp16_v82_encode ();
15650 do_vfp_nsyn_opcode ("fmacd");
15652 do_vfp_nsyn_opcode ("fnmacd");
15657 do_vfp_nsyn_fma_fms (enum neon_shape rs
)
15659 int is_fma
= (inst
.instruction
& 0x0fffffff) == N_MNEM_vfma
;
15661 if (rs
== NS_FFF
|| rs
== NS_HHH
)
15664 do_vfp_nsyn_opcode ("ffmas");
15666 do_vfp_nsyn_opcode ("ffnmas");
15668 /* ARMv8.2 fp16 instruction. */
15670 do_scalar_fp16_v82_encode ();
15675 do_vfp_nsyn_opcode ("ffmad");
15677 do_vfp_nsyn_opcode ("ffnmad");
15682 do_vfp_nsyn_mul (enum neon_shape rs
)
15684 if (rs
== NS_FFF
|| rs
== NS_HHH
)
15686 do_vfp_nsyn_opcode ("fmuls");
15688 /* ARMv8.2 fp16 instruction. */
15690 do_scalar_fp16_v82_encode ();
15693 do_vfp_nsyn_opcode ("fmuld");
15697 do_vfp_nsyn_abs_neg (enum neon_shape rs
)
15699 int is_neg
= (inst
.instruction
& 0x80) != 0;
15700 neon_check_type (2, rs
, N_EQK
| N_VFP
, N_F_ALL
| N_VFP
| N_KEY
);
15702 if (rs
== NS_FF
|| rs
== NS_HH
)
15705 do_vfp_nsyn_opcode ("fnegs");
15707 do_vfp_nsyn_opcode ("fabss");
15709 /* ARMv8.2 fp16 instruction. */
15711 do_scalar_fp16_v82_encode ();
15716 do_vfp_nsyn_opcode ("fnegd");
15718 do_vfp_nsyn_opcode ("fabsd");
15722 /* Encode single-precision (only!) VFP fldm/fstm instructions. Double precision
15723 insns belong to Neon, and are handled elsewhere. */
15726 do_vfp_nsyn_ldm_stm (int is_dbmode
)
15728 int is_ldm
= (inst
.instruction
& (1 << 20)) != 0;
15732 do_vfp_nsyn_opcode ("fldmdbs");
15734 do_vfp_nsyn_opcode ("fldmias");
15739 do_vfp_nsyn_opcode ("fstmdbs");
15741 do_vfp_nsyn_opcode ("fstmias");
15746 do_vfp_nsyn_sqrt (void)
15748 enum neon_shape rs
= neon_select_shape (NS_HH
, NS_FF
, NS_DD
, NS_NULL
);
15749 neon_check_type (2, rs
, N_EQK
| N_VFP
, N_F_ALL
| N_KEY
| N_VFP
);
15751 if (rs
== NS_FF
|| rs
== NS_HH
)
15753 do_vfp_nsyn_opcode ("fsqrts");
15755 /* ARMv8.2 fp16 instruction. */
15757 do_scalar_fp16_v82_encode ();
15760 do_vfp_nsyn_opcode ("fsqrtd");
15764 do_vfp_nsyn_div (void)
15766 enum neon_shape rs
= neon_select_shape (NS_HHH
, NS_FFF
, NS_DDD
, NS_NULL
);
15767 neon_check_type (3, rs
, N_EQK
| N_VFP
, N_EQK
| N_VFP
,
15768 N_F_ALL
| N_KEY
| N_VFP
);
15770 if (rs
== NS_FFF
|| rs
== NS_HHH
)
15772 do_vfp_nsyn_opcode ("fdivs");
15774 /* ARMv8.2 fp16 instruction. */
15776 do_scalar_fp16_v82_encode ();
15779 do_vfp_nsyn_opcode ("fdivd");
15783 do_vfp_nsyn_nmul (void)
15785 enum neon_shape rs
= neon_select_shape (NS_HHH
, NS_FFF
, NS_DDD
, NS_NULL
);
15786 neon_check_type (3, rs
, N_EQK
| N_VFP
, N_EQK
| N_VFP
,
15787 N_F_ALL
| N_KEY
| N_VFP
);
15789 if (rs
== NS_FFF
|| rs
== NS_HHH
)
15791 NEON_ENCODE (SINGLE
, inst
);
15792 do_vfp_sp_dyadic ();
15794 /* ARMv8.2 fp16 instruction. */
15796 do_scalar_fp16_v82_encode ();
15800 NEON_ENCODE (DOUBLE
, inst
);
15801 do_vfp_dp_rd_rn_rm ();
15803 do_vfp_cond_or_thumb ();
15807 /* Turn a size (8, 16, 32, 64) into the respective bit number minus 3
15811 neon_logbits (unsigned x
)
15813 return ffs (x
) - 4;
15816 #define LOW4(R) ((R) & 0xf)
15817 #define HI1(R) (((R) >> 4) & 1)
15820 mve_get_vcmp_vpt_cond (struct neon_type_el et
)
15825 first_error (BAD_EL_TYPE
);
15828 switch (inst
.operands
[0].imm
)
15831 first_error (_("invalid condition"));
15853 /* only accept eq and ne. */
15854 if (inst
.operands
[0].imm
> 1)
15856 first_error (_("invalid condition"));
15859 return inst
.operands
[0].imm
;
15861 if (inst
.operands
[0].imm
== 0x2)
15863 else if (inst
.operands
[0].imm
== 0x8)
15867 first_error (_("invalid condition"));
15871 switch (inst
.operands
[0].imm
)
15874 first_error (_("invalid condition"));
15890 /* Should be unreachable. */
15894 /* For VCTP (create vector tail predicate) in MVE. */
15899 unsigned size
= 0x0;
15901 if (inst
.cond
> COND_ALWAYS
)
15902 inst
.pred_insn_type
= INSIDE_VPT_INSN
;
15904 inst
.pred_insn_type
= MVE_OUTSIDE_PRED_INSN
;
15906 /* This is a typical MVE instruction which has no type but have size 8, 16,
15907 32 and 64. For instructions with no type, inst.vectype.el[j].type is set
15908 to NT_untyped and size is updated in inst.vectype.el[j].size. */
15909 if ((inst
.operands
[0].present
) && (inst
.vectype
.el
[0].type
== NT_untyped
))
15910 dt
= inst
.vectype
.el
[0].size
;
15912 /* Setting this does not indicate an actual NEON instruction, but only
15913 indicates that the mnemonic accepts neon-style type suffixes. */
15927 first_error (_("Type is not allowed for this instruction"));
15929 inst
.instruction
|= size
<< 20;
15930 inst
.instruction
|= inst
.operands
[0].reg
<< 16;
15936 /* We are dealing with a vector predicated block. */
15937 if (inst
.operands
[0].present
)
15939 enum neon_shape rs
= neon_select_shape (NS_IQQ
, NS_IQR
, NS_NULL
);
15940 struct neon_type_el et
15941 = neon_check_type (3, rs
, N_EQK
, N_KEY
| N_F_MVE
| N_I_MVE
| N_SU_32
,
15944 unsigned fcond
= mve_get_vcmp_vpt_cond (et
);
15946 constraint (inst
.operands
[1].reg
> 14, MVE_BAD_QREG
);
15948 if (et
.type
== NT_invtype
)
15951 if (et
.type
== NT_float
)
15953 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant
, mve_fp_ext
),
15955 constraint (et
.size
!= 16 && et
.size
!= 32, BAD_EL_TYPE
);
15956 inst
.instruction
|= (et
.size
== 16) << 28;
15957 inst
.instruction
|= 0x3 << 20;
15961 constraint (et
.size
!= 8 && et
.size
!= 16 && et
.size
!= 32,
15963 inst
.instruction
|= 1 << 28;
15964 inst
.instruction
|= neon_logbits (et
.size
) << 20;
15967 if (inst
.operands
[2].isquad
)
15969 inst
.instruction
|= HI1 (inst
.operands
[2].reg
) << 5;
15970 inst
.instruction
|= LOW4 (inst
.operands
[2].reg
);
15971 inst
.instruction
|= (fcond
& 0x2) >> 1;
15975 if (inst
.operands
[2].reg
== REG_SP
)
15976 as_tsktsk (MVE_BAD_SP
);
15977 inst
.instruction
|= 1 << 6;
15978 inst
.instruction
|= (fcond
& 0x2) << 4;
15979 inst
.instruction
|= inst
.operands
[2].reg
;
15981 inst
.instruction
|= LOW4 (inst
.operands
[1].reg
) << 16;
15982 inst
.instruction
|= (fcond
& 0x4) << 10;
15983 inst
.instruction
|= (fcond
& 0x1) << 7;
15986 set_pred_insn_type (VPT_INSN
);
15988 now_pred
.mask
= ((inst
.instruction
& 0x00400000) >> 19)
15989 | ((inst
.instruction
& 0xe000) >> 13);
15990 now_pred
.warn_deprecated
= FALSE
;
15991 now_pred
.type
= VECTOR_PRED
;
15998 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant
, mve_ext
), BAD_FPU
);
15999 if (!inst
.operands
[1].isreg
|| !inst
.operands
[1].isquad
)
16000 first_error (_(reg_expected_msgs
[REG_TYPE_MQ
]));
16001 if (!inst
.operands
[2].present
)
16002 first_error (_("MVE vector or ARM register expected"));
16003 constraint (inst
.operands
[1].reg
> 14, MVE_BAD_QREG
);
16005 /* Deal with 'else' conditional MVE's vcmp, it will be parsed as vcmpe. */
16006 if ((inst
.instruction
& 0xffffffff) == N_MNEM_vcmpe
16007 && inst
.operands
[1].isquad
)
16009 inst
.instruction
= N_MNEM_vcmp
;
16013 if (inst
.cond
> COND_ALWAYS
)
16014 inst
.pred_insn_type
= INSIDE_VPT_INSN
;
16016 inst
.pred_insn_type
= MVE_OUTSIDE_PRED_INSN
;
16018 enum neon_shape rs
= neon_select_shape (NS_IQQ
, NS_IQR
, NS_NULL
);
16019 struct neon_type_el et
16020 = neon_check_type (3, rs
, N_EQK
, N_KEY
| N_F_MVE
| N_I_MVE
| N_SU_32
,
16023 constraint (rs
== NS_IQR
&& inst
.operands
[2].reg
== REG_PC
16024 && !inst
.operands
[2].iszr
, BAD_PC
);
16026 unsigned fcond
= mve_get_vcmp_vpt_cond (et
);
16028 inst
.instruction
= 0xee010f00;
16029 inst
.instruction
|= LOW4 (inst
.operands
[1].reg
) << 16;
16030 inst
.instruction
|= (fcond
& 0x4) << 10;
16031 inst
.instruction
|= (fcond
& 0x1) << 7;
16032 if (et
.type
== NT_float
)
16034 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant
, mve_fp_ext
),
16036 inst
.instruction
|= (et
.size
== 16) << 28;
16037 inst
.instruction
|= 0x3 << 20;
16041 inst
.instruction
|= 1 << 28;
16042 inst
.instruction
|= neon_logbits (et
.size
) << 20;
16044 if (inst
.operands
[2].isquad
)
16046 inst
.instruction
|= HI1 (inst
.operands
[2].reg
) << 5;
16047 inst
.instruction
|= (fcond
& 0x2) >> 1;
16048 inst
.instruction
|= LOW4 (inst
.operands
[2].reg
);
16052 if (inst
.operands
[2].reg
== REG_SP
)
16053 as_tsktsk (MVE_BAD_SP
);
16054 inst
.instruction
|= 1 << 6;
16055 inst
.instruction
|= (fcond
& 0x2) << 4;
16056 inst
.instruction
|= inst
.operands
[2].reg
;
16064 do_mve_vmaxa_vmina (void)
16066 if (inst
.cond
> COND_ALWAYS
)
16067 inst
.pred_insn_type
= INSIDE_VPT_INSN
;
16069 inst
.pred_insn_type
= MVE_OUTSIDE_PRED_INSN
;
16071 enum neon_shape rs
= neon_select_shape (NS_QQ
, NS_NULL
);
16072 struct neon_type_el et
16073 = neon_check_type (2, rs
, N_EQK
, N_KEY
| N_S8
| N_S16
| N_S32
);
16075 inst
.instruction
|= HI1 (inst
.operands
[0].reg
) << 22;
16076 inst
.instruction
|= neon_logbits (et
.size
) << 18;
16077 inst
.instruction
|= LOW4 (inst
.operands
[0].reg
) << 12;
16078 inst
.instruction
|= HI1 (inst
.operands
[1].reg
) << 5;
16079 inst
.instruction
|= LOW4 (inst
.operands
[1].reg
);
16084 do_mve_vfmas (void)
16086 enum neon_shape rs
= neon_select_shape (NS_QQR
, NS_NULL
);
16087 struct neon_type_el et
16088 = neon_check_type (3, rs
, N_F_MVE
| N_KEY
, N_EQK
, N_EQK
);
16090 if (inst
.cond
> COND_ALWAYS
)
16091 inst
.pred_insn_type
= INSIDE_VPT_INSN
;
16093 inst
.pred_insn_type
= MVE_OUTSIDE_PRED_INSN
;
16095 if (inst
.operands
[2].reg
== REG_SP
)
16096 as_tsktsk (MVE_BAD_SP
);
16097 else if (inst
.operands
[2].reg
== REG_PC
)
16098 as_tsktsk (MVE_BAD_PC
);
16100 inst
.instruction
|= (et
.size
== 16) << 28;
16101 inst
.instruction
|= HI1 (inst
.operands
[0].reg
) << 22;
16102 inst
.instruction
|= LOW4 (inst
.operands
[1].reg
) << 16;
16103 inst
.instruction
|= LOW4 (inst
.operands
[0].reg
) << 12;
16104 inst
.instruction
|= HI1 (inst
.operands
[1].reg
) << 7;
16105 inst
.instruction
|= inst
.operands
[2].reg
;
16110 do_mve_viddup (void)
16112 if (inst
.cond
> COND_ALWAYS
)
16113 inst
.pred_insn_type
= INSIDE_VPT_INSN
;
16115 inst
.pred_insn_type
= MVE_OUTSIDE_PRED_INSN
;
16117 unsigned imm
= inst
.relocs
[0].exp
.X_add_number
;
16118 constraint (imm
!= 1 && imm
!= 2 && imm
!= 4 && imm
!= 8,
16119 _("immediate must be either 1, 2, 4 or 8"));
16121 enum neon_shape rs
;
16122 struct neon_type_el et
;
16124 if (inst
.instruction
== M_MNEM_vddup
|| inst
.instruction
== M_MNEM_vidup
)
16126 rs
= neon_select_shape (NS_QRI
, NS_NULL
);
16127 et
= neon_check_type (2, rs
, N_KEY
| N_U8
| N_U16
| N_U32
, N_EQK
);
16132 constraint ((inst
.operands
[2].reg
% 2) != 1, BAD_EVEN
);
16133 if (inst
.operands
[2].reg
== REG_SP
)
16134 as_tsktsk (MVE_BAD_SP
);
16135 else if (inst
.operands
[2].reg
== REG_PC
)
16136 first_error (BAD_PC
);
16138 rs
= neon_select_shape (NS_QRRI
, NS_NULL
);
16139 et
= neon_check_type (3, rs
, N_KEY
| N_U8
| N_U16
| N_U32
, N_EQK
, N_EQK
);
16140 Rm
= inst
.operands
[2].reg
>> 1;
16142 inst
.instruction
|= HI1 (inst
.operands
[0].reg
) << 22;
16143 inst
.instruction
|= neon_logbits (et
.size
) << 20;
16144 inst
.instruction
|= inst
.operands
[1].reg
<< 16;
16145 inst
.instruction
|= LOW4 (inst
.operands
[0].reg
) << 12;
16146 inst
.instruction
|= (imm
> 2) << 7;
16147 inst
.instruction
|= Rm
<< 1;
16148 inst
.instruction
|= (imm
== 2 || imm
== 8);
16153 do_mve_vmlas (void)
16155 enum neon_shape rs
= neon_select_shape (NS_QQR
, NS_NULL
);
16156 struct neon_type_el et
16157 = neon_check_type (3, rs
, N_EQK
, N_EQK
, N_SU_MVE
| N_KEY
);
16159 if (inst
.operands
[2].reg
== REG_PC
)
16160 as_tsktsk (MVE_BAD_PC
);
16161 else if (inst
.operands
[2].reg
== REG_SP
)
16162 as_tsktsk (MVE_BAD_SP
);
16164 if (inst
.cond
> COND_ALWAYS
)
16165 inst
.pred_insn_type
= INSIDE_VPT_INSN
;
16167 inst
.pred_insn_type
= MVE_OUTSIDE_PRED_INSN
;
16169 inst
.instruction
|= (et
.type
== NT_unsigned
) << 28;
16170 inst
.instruction
|= HI1 (inst
.operands
[0].reg
) << 22;
16171 inst
.instruction
|= neon_logbits (et
.size
) << 20;
16172 inst
.instruction
|= LOW4 (inst
.operands
[1].reg
) << 16;
16173 inst
.instruction
|= LOW4 (inst
.operands
[0].reg
) << 12;
16174 inst
.instruction
|= HI1 (inst
.operands
[1].reg
) << 7;
16175 inst
.instruction
|= inst
.operands
[2].reg
;
16180 do_mve_vshll (void)
16182 struct neon_type_el et
16183 = neon_check_type (2, NS_QQI
, N_EQK
, N_S8
| N_U8
| N_S16
| N_U16
| N_KEY
);
16185 if (inst
.cond
> COND_ALWAYS
)
16186 inst
.pred_insn_type
= INSIDE_VPT_INSN
;
16188 inst
.pred_insn_type
= MVE_OUTSIDE_PRED_INSN
;
16190 int imm
= inst
.operands
[2].imm
;
16191 constraint (imm
< 1 || (unsigned)imm
> et
.size
,
16192 _("immediate value out of range"));
16194 if ((unsigned)imm
== et
.size
)
16196 inst
.instruction
|= neon_logbits (et
.size
) << 18;
16197 inst
.instruction
|= 0x110001;
16201 inst
.instruction
|= (et
.size
+ imm
) << 16;
16202 inst
.instruction
|= 0x800140;
16205 inst
.instruction
|= (et
.type
== NT_unsigned
) << 28;
16206 inst
.instruction
|= HI1 (inst
.operands
[0].reg
) << 22;
16207 inst
.instruction
|= LOW4 (inst
.operands
[0].reg
) << 12;
16208 inst
.instruction
|= HI1 (inst
.operands
[1].reg
) << 5;
16209 inst
.instruction
|= LOW4 (inst
.operands
[1].reg
);
16214 do_mve_vshlc (void)
16216 if (inst
.cond
> COND_ALWAYS
)
16217 inst
.pred_insn_type
= INSIDE_VPT_INSN
;
16219 inst
.pred_insn_type
= MVE_OUTSIDE_PRED_INSN
;
16221 if (inst
.operands
[1].reg
== REG_PC
)
16222 as_tsktsk (MVE_BAD_PC
);
16223 else if (inst
.operands
[1].reg
== REG_SP
)
16224 as_tsktsk (MVE_BAD_SP
);
16226 int imm
= inst
.operands
[2].imm
;
16227 constraint (imm
< 1 || imm
> 32, _("immediate value out of range"));
16229 inst
.instruction
|= HI1 (inst
.operands
[0].reg
) << 22;
16230 inst
.instruction
|= (imm
& 0x1f) << 16;
16231 inst
.instruction
|= LOW4 (inst
.operands
[0].reg
) << 12;
16232 inst
.instruction
|= inst
.operands
[1].reg
;
16237 do_mve_vshrn (void)
16240 switch (inst
.instruction
)
16242 case M_MNEM_vshrnt
:
16243 case M_MNEM_vshrnb
:
16244 case M_MNEM_vrshrnt
:
16245 case M_MNEM_vrshrnb
:
16246 types
= N_I16
| N_I32
;
16248 case M_MNEM_vqshrnt
:
16249 case M_MNEM_vqshrnb
:
16250 case M_MNEM_vqrshrnt
:
16251 case M_MNEM_vqrshrnb
:
16252 types
= N_U16
| N_U32
| N_S16
| N_S32
;
16254 case M_MNEM_vqshrunt
:
16255 case M_MNEM_vqshrunb
:
16256 case M_MNEM_vqrshrunt
:
16257 case M_MNEM_vqrshrunb
:
16258 types
= N_S16
| N_S32
;
16264 struct neon_type_el et
= neon_check_type (2, NS_QQI
, N_EQK
, types
| N_KEY
);
16266 if (inst
.cond
> COND_ALWAYS
)
16267 inst
.pred_insn_type
= INSIDE_VPT_INSN
;
16269 inst
.pred_insn_type
= MVE_OUTSIDE_PRED_INSN
;
16271 unsigned Qd
= inst
.operands
[0].reg
;
16272 unsigned Qm
= inst
.operands
[1].reg
;
16273 unsigned imm
= inst
.operands
[2].imm
;
16274 constraint (imm
< 1 || ((unsigned) imm
) > (et
.size
/ 2),
16276 ? _("immediate operand expected in the range [1,8]")
16277 : _("immediate operand expected in the range [1,16]"));
16279 inst
.instruction
|= (et
.type
== NT_unsigned
) << 28;
16280 inst
.instruction
|= HI1 (Qd
) << 22;
16281 inst
.instruction
|= (et
.size
- imm
) << 16;
16282 inst
.instruction
|= LOW4 (Qd
) << 12;
16283 inst
.instruction
|= HI1 (Qm
) << 5;
16284 inst
.instruction
|= LOW4 (Qm
);
16289 do_mve_vqmovn (void)
16291 struct neon_type_el et
;
16292 if (inst
.instruction
== M_MNEM_vqmovnt
16293 || inst
.instruction
== M_MNEM_vqmovnb
)
16294 et
= neon_check_type (2, NS_QQ
, N_EQK
,
16295 N_U16
| N_U32
| N_S16
| N_S32
| N_KEY
);
16297 et
= neon_check_type (2, NS_QQ
, N_EQK
, N_S16
| N_S32
| N_KEY
);
16299 if (inst
.cond
> COND_ALWAYS
)
16300 inst
.pred_insn_type
= INSIDE_VPT_INSN
;
16302 inst
.pred_insn_type
= MVE_OUTSIDE_PRED_INSN
;
16304 inst
.instruction
|= (et
.type
== NT_unsigned
) << 28;
16305 inst
.instruction
|= HI1 (inst
.operands
[0].reg
) << 22;
16306 inst
.instruction
|= (et
.size
== 32) << 18;
16307 inst
.instruction
|= LOW4 (inst
.operands
[0].reg
) << 12;
16308 inst
.instruction
|= HI1 (inst
.operands
[1].reg
) << 5;
16309 inst
.instruction
|= LOW4 (inst
.operands
[1].reg
);
16314 do_mve_vpsel (void)
16316 neon_select_shape (NS_QQQ
, NS_NULL
);
16318 if (inst
.cond
> COND_ALWAYS
)
16319 inst
.pred_insn_type
= INSIDE_VPT_INSN
;
16321 inst
.pred_insn_type
= MVE_OUTSIDE_PRED_INSN
;
16323 inst
.instruction
|= HI1 (inst
.operands
[0].reg
) << 22;
16324 inst
.instruction
|= LOW4 (inst
.operands
[1].reg
) << 16;
16325 inst
.instruction
|= LOW4 (inst
.operands
[0].reg
) << 12;
16326 inst
.instruction
|= HI1 (inst
.operands
[1].reg
) << 7;
16327 inst
.instruction
|= HI1 (inst
.operands
[2].reg
) << 5;
16328 inst
.instruction
|= LOW4 (inst
.operands
[2].reg
);
16333 do_mve_vpnot (void)
16335 if (inst
.cond
> COND_ALWAYS
)
16336 inst
.pred_insn_type
= INSIDE_VPT_INSN
;
16338 inst
.pred_insn_type
= MVE_OUTSIDE_PRED_INSN
;
16342 do_mve_vmaxnma_vminnma (void)
16344 enum neon_shape rs
= neon_select_shape (NS_QQ
, NS_NULL
);
16345 struct neon_type_el et
16346 = neon_check_type (2, rs
, N_EQK
, N_F_MVE
| N_KEY
);
16348 if (inst
.cond
> COND_ALWAYS
)
16349 inst
.pred_insn_type
= INSIDE_VPT_INSN
;
16351 inst
.pred_insn_type
= MVE_OUTSIDE_PRED_INSN
;
16353 inst
.instruction
|= (et
.size
== 16) << 28;
16354 inst
.instruction
|= HI1 (inst
.operands
[0].reg
) << 22;
16355 inst
.instruction
|= LOW4 (inst
.operands
[0].reg
) << 12;
16356 inst
.instruction
|= HI1 (inst
.operands
[1].reg
) << 5;
16357 inst
.instruction
|= LOW4 (inst
.operands
[1].reg
);
16362 do_mve_vcmul (void)
16364 enum neon_shape rs
= neon_select_shape (NS_QQQI
, NS_NULL
);
16365 struct neon_type_el et
16366 = neon_check_type (3, rs
, N_EQK
, N_EQK
, N_F_MVE
| N_KEY
);
16368 if (inst
.cond
> COND_ALWAYS
)
16369 inst
.pred_insn_type
= INSIDE_VPT_INSN
;
16371 inst
.pred_insn_type
= MVE_OUTSIDE_PRED_INSN
;
16373 unsigned rot
= inst
.relocs
[0].exp
.X_add_number
;
16374 constraint (rot
!= 0 && rot
!= 90 && rot
!= 180 && rot
!= 270,
16375 _("immediate out of range"));
16377 if (et
.size
== 32 && (inst
.operands
[0].reg
== inst
.operands
[1].reg
16378 || inst
.operands
[0].reg
== inst
.operands
[2].reg
))
16379 as_tsktsk (BAD_MVE_SRCDEST
);
16381 inst
.instruction
|= (et
.size
== 32) << 28;
16382 inst
.instruction
|= HI1 (inst
.operands
[0].reg
) << 22;
16383 inst
.instruction
|= LOW4 (inst
.operands
[1].reg
) << 16;
16384 inst
.instruction
|= LOW4 (inst
.operands
[0].reg
) << 12;
16385 inst
.instruction
|= (rot
> 90) << 12;
16386 inst
.instruction
|= HI1 (inst
.operands
[1].reg
) << 7;
16387 inst
.instruction
|= HI1 (inst
.operands
[2].reg
) << 5;
16388 inst
.instruction
|= LOW4 (inst
.operands
[2].reg
);
16389 inst
.instruction
|= (rot
== 90 || rot
== 270);
16393 /* To handle the Low Overhead Loop instructions
16394 in Armv8.1-M Mainline and MVE. */
16398 unsigned long insn
= inst
.instruction
;
16400 inst
.instruction
= THUMB_OP32 (inst
.instruction
);
16402 if (insn
== T_MNEM_lctp
)
16405 set_pred_insn_type (MVE_OUTSIDE_PRED_INSN
);
16407 if (insn
== T_MNEM_wlstp
|| insn
== T_MNEM_dlstp
)
16409 struct neon_type_el et
16410 = neon_check_type (2, NS_RR
, N_EQK
, N_8
| N_16
| N_32
| N_64
| N_KEY
);
16411 inst
.instruction
|= neon_logbits (et
.size
) << 20;
16418 constraint (!inst
.operands
[0].present
,
16420 /* fall through. */
16423 if (!inst
.operands
[0].present
)
16424 inst
.instruction
|= 1 << 21;
16426 v8_1_loop_reloc (TRUE
);
16431 v8_1_loop_reloc (FALSE
);
16432 /* fall through. */
16435 constraint (inst
.operands
[1].isreg
!= 1, BAD_ARGS
);
16437 if (insn
== T_MNEM_wlstp
|| insn
== T_MNEM_dlstp
)
16438 constraint (inst
.operands
[1].reg
== REG_PC
, BAD_PC
);
16439 else if (inst
.operands
[1].reg
== REG_PC
)
16440 as_tsktsk (MVE_BAD_PC
);
16441 if (inst
.operands
[1].reg
== REG_SP
)
16442 as_tsktsk (MVE_BAD_SP
);
16444 inst
.instruction
|= (inst
.operands
[1].reg
<< 16);
16454 do_vfp_nsyn_cmp (void)
16456 enum neon_shape rs
;
16457 if (!inst
.operands
[0].isreg
)
16464 constraint (inst
.operands
[2].present
, BAD_SYNTAX
);
16465 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant
, fpu_vfp_ext_v1xd
),
16469 if (inst
.operands
[1].isreg
)
16471 rs
= neon_select_shape (NS_HH
, NS_FF
, NS_DD
, NS_NULL
);
16472 neon_check_type (2, rs
, N_EQK
| N_VFP
, N_F_ALL
| N_KEY
| N_VFP
);
16474 if (rs
== NS_FF
|| rs
== NS_HH
)
16476 NEON_ENCODE (SINGLE
, inst
);
16477 do_vfp_sp_monadic ();
16481 NEON_ENCODE (DOUBLE
, inst
);
16482 do_vfp_dp_rd_rm ();
16487 rs
= neon_select_shape (NS_HI
, NS_FI
, NS_DI
, NS_NULL
);
16488 neon_check_type (2, rs
, N_F_ALL
| N_KEY
| N_VFP
, N_EQK
);
16490 switch (inst
.instruction
& 0x0fffffff)
16493 inst
.instruction
+= N_MNEM_vcmpz
- N_MNEM_vcmp
;
16496 inst
.instruction
+= N_MNEM_vcmpez
- N_MNEM_vcmpe
;
16502 if (rs
== NS_FI
|| rs
== NS_HI
)
16504 NEON_ENCODE (SINGLE
, inst
);
16505 do_vfp_sp_compare_z ();
16509 NEON_ENCODE (DOUBLE
, inst
);
16513 do_vfp_cond_or_thumb ();
16515 /* ARMv8.2 fp16 instruction. */
16516 if (rs
== NS_HI
|| rs
== NS_HH
)
16517 do_scalar_fp16_v82_encode ();
16521 nsyn_insert_sp (void)
16523 inst
.operands
[1] = inst
.operands
[0];
16524 memset (&inst
.operands
[0], '\0', sizeof (inst
.operands
[0]));
16525 inst
.operands
[0].reg
= REG_SP
;
16526 inst
.operands
[0].isreg
= 1;
16527 inst
.operands
[0].writeback
= 1;
16528 inst
.operands
[0].present
= 1;
16531 /* Fix up Neon data-processing instructions, ORing in the correct bits for
16532 ARM mode or Thumb mode and moving the encoded bit 24 to bit 28. */
16535 neon_dp_fixup (struct arm_it
* insn
)
16537 unsigned int i
= insn
->instruction
;
16542 /* The U bit is at bit 24 by default. Move to bit 28 in Thumb mode. */
16553 insn
->instruction
= i
;
16557 mve_encode_qqr (int size
, int U
, int fp
)
16559 if (inst
.operands
[2].reg
== REG_SP
)
16560 as_tsktsk (MVE_BAD_SP
);
16561 else if (inst
.operands
[2].reg
== REG_PC
)
16562 as_tsktsk (MVE_BAD_PC
);
16567 if (((unsigned)inst
.instruction
) == 0xd00)
16568 inst
.instruction
= 0xee300f40;
16570 else if (((unsigned)inst
.instruction
) == 0x200d00)
16571 inst
.instruction
= 0xee301f40;
16573 else if (((unsigned)inst
.instruction
) == 0x1000d10)
16574 inst
.instruction
= 0xee310e60;
16576 /* Setting size which is 1 for F16 and 0 for F32. */
16577 inst
.instruction
|= (size
== 16) << 28;
16582 if (((unsigned)inst
.instruction
) == 0x800)
16583 inst
.instruction
= 0xee010f40;
16585 else if (((unsigned)inst
.instruction
) == 0x1000800)
16586 inst
.instruction
= 0xee011f40;
16588 else if (((unsigned)inst
.instruction
) == 0)
16589 inst
.instruction
= 0xee000f40;
16591 else if (((unsigned)inst
.instruction
) == 0x200)
16592 inst
.instruction
= 0xee001f40;
16594 else if (((unsigned)inst
.instruction
) == 0x900)
16595 inst
.instruction
= 0xee010e40;
16597 else if (((unsigned)inst
.instruction
) == 0x910)
16598 inst
.instruction
= 0xee011e60;
16600 else if (((unsigned)inst
.instruction
) == 0x10)
16601 inst
.instruction
= 0xee000f60;
16603 else if (((unsigned)inst
.instruction
) == 0x210)
16604 inst
.instruction
= 0xee001f60;
16606 else if (((unsigned)inst
.instruction
) == 0x3000b10)
16607 inst
.instruction
= 0xee000e40;
16609 else if (((unsigned)inst
.instruction
) == 0x0000b00)
16610 inst
.instruction
= 0xee010e60;
16612 else if (((unsigned)inst
.instruction
) == 0x1000b00)
16613 inst
.instruction
= 0xfe010e60;
16616 inst
.instruction
|= U
<< 28;
16618 /* Setting bits for size. */
16619 inst
.instruction
|= neon_logbits (size
) << 20;
16621 inst
.instruction
|= LOW4 (inst
.operands
[0].reg
) << 12;
16622 inst
.instruction
|= HI1 (inst
.operands
[0].reg
) << 22;
16623 inst
.instruction
|= LOW4 (inst
.operands
[1].reg
) << 16;
16624 inst
.instruction
|= HI1 (inst
.operands
[1].reg
) << 7;
16625 inst
.instruction
|= inst
.operands
[2].reg
;
16630 mve_encode_rqq (unsigned bit28
, unsigned size
)
16632 inst
.instruction
|= bit28
<< 28;
16633 inst
.instruction
|= neon_logbits (size
) << 20;
16634 inst
.instruction
|= LOW4 (inst
.operands
[1].reg
) << 16;
16635 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
16636 inst
.instruction
|= HI1 (inst
.operands
[1].reg
) << 7;
16637 inst
.instruction
|= HI1 (inst
.operands
[2].reg
) << 5;
16638 inst
.instruction
|= LOW4 (inst
.operands
[2].reg
);
16643 mve_encode_qqq (int ubit
, int size
)
16646 inst
.instruction
|= (ubit
!= 0) << 28;
16647 inst
.instruction
|= HI1 (inst
.operands
[0].reg
) << 22;
16648 inst
.instruction
|= neon_logbits (size
) << 20;
16649 inst
.instruction
|= LOW4 (inst
.operands
[1].reg
) << 16;
16650 inst
.instruction
|= LOW4 (inst
.operands
[0].reg
) << 12;
16651 inst
.instruction
|= HI1 (inst
.operands
[1].reg
) << 7;
16652 inst
.instruction
|= HI1 (inst
.operands
[2].reg
) << 5;
16653 inst
.instruction
|= LOW4 (inst
.operands
[2].reg
);
16659 mve_encode_rq (unsigned bit28
, unsigned size
)
16661 inst
.instruction
|= bit28
<< 28;
16662 inst
.instruction
|= neon_logbits (size
) << 18;
16663 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
16664 inst
.instruction
|= LOW4 (inst
.operands
[1].reg
);
16669 mve_encode_rrqq (unsigned U
, unsigned size
)
16671 constraint (inst
.operands
[3].reg
> 14, MVE_BAD_QREG
);
16673 inst
.instruction
|= U
<< 28;
16674 inst
.instruction
|= (inst
.operands
[1].reg
>> 1) << 20;
16675 inst
.instruction
|= LOW4 (inst
.operands
[2].reg
) << 16;
16676 inst
.instruction
|= (size
== 32) << 16;
16677 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
16678 inst
.instruction
|= HI1 (inst
.operands
[2].reg
) << 7;
16679 inst
.instruction
|= inst
.operands
[3].reg
;
16683 /* Helper function for neon_three_same handling the operands. */
16685 neon_three_args (int isquad
)
16687 inst
.instruction
|= LOW4 (inst
.operands
[0].reg
) << 12;
16688 inst
.instruction
|= HI1 (inst
.operands
[0].reg
) << 22;
16689 inst
.instruction
|= LOW4 (inst
.operands
[1].reg
) << 16;
16690 inst
.instruction
|= HI1 (inst
.operands
[1].reg
) << 7;
16691 inst
.instruction
|= LOW4 (inst
.operands
[2].reg
);
16692 inst
.instruction
|= HI1 (inst
.operands
[2].reg
) << 5;
16693 inst
.instruction
|= (isquad
!= 0) << 6;
16697 /* Encode insns with bit pattern:
16699 |28/24|23|22 |21 20|19 16|15 12|11 8|7|6|5|4|3 0|
16700 | U |x |D |size | Rn | Rd |x x x x|N|Q|M|x| Rm |
16702 SIZE is passed in bits. -1 means size field isn't changed, in case it has a
16703 different meaning for some instruction. */
16706 neon_three_same (int isquad
, int ubit
, int size
)
16708 neon_three_args (isquad
);
16709 inst
.instruction
|= (ubit
!= 0) << 24;
16711 inst
.instruction
|= neon_logbits (size
) << 20;
16713 neon_dp_fixup (&inst
);
16716 /* Encode instructions of the form:
16718 |28/24|23|22|21 20|19 18|17 16|15 12|11 7|6|5|4|3 0|
16719 | U |x |D |x x |size |x x | Rd |x x x x x|Q|M|x| Rm |
16721 Don't write size if SIZE == -1. */
16724 neon_two_same (int qbit
, int ubit
, int size
)
16726 inst
.instruction
|= LOW4 (inst
.operands
[0].reg
) << 12;
16727 inst
.instruction
|= HI1 (inst
.operands
[0].reg
) << 22;
16728 inst
.instruction
|= LOW4 (inst
.operands
[1].reg
);
16729 inst
.instruction
|= HI1 (inst
.operands
[1].reg
) << 5;
16730 inst
.instruction
|= (qbit
!= 0) << 6;
16731 inst
.instruction
|= (ubit
!= 0) << 24;
16734 inst
.instruction
|= neon_logbits (size
) << 18;
16736 neon_dp_fixup (&inst
);
16739 enum vfp_or_neon_is_neon_bits
16742 NEON_CHECK_ARCH
= 2,
16743 NEON_CHECK_ARCH8
= 4
16746 /* Call this function if an instruction which may have belonged to the VFP or
16747 Neon instruction sets, but turned out to be a Neon instruction (due to the
16748 operand types involved, etc.). We have to check and/or fix-up a couple of
16751 - Make sure the user hasn't attempted to make a Neon instruction
16753 - Alter the value in the condition code field if necessary.
16754 - Make sure that the arch supports Neon instructions.
16756 Which of these operations take place depends on bits from enum
16757 vfp_or_neon_is_neon_bits.
16759 WARNING: This function has side effects! If NEON_CHECK_CC is used and the
16760 current instruction's condition is COND_ALWAYS, the condition field is
16761 changed to inst.uncond_value. This is necessary because instructions shared
16762 between VFP and Neon may be conditional for the VFP variants only, and the
16763 unconditional Neon version must have, e.g., 0xF in the condition field. */
16766 vfp_or_neon_is_neon (unsigned check
)
16768 /* Conditions are always legal in Thumb mode (IT blocks). */
16769 if (!thumb_mode
&& (check
& NEON_CHECK_CC
))
16771 if (inst
.cond
!= COND_ALWAYS
)
16773 first_error (_(BAD_COND
));
16776 if (inst
.uncond_value
!= -1)
16777 inst
.instruction
|= inst
.uncond_value
<< 28;
16781 if (((check
& NEON_CHECK_ARCH
) && !mark_feature_used (&fpu_neon_ext_v1
))
16782 || ((check
& NEON_CHECK_ARCH8
)
16783 && !mark_feature_used (&fpu_neon_ext_armv8
)))
16785 first_error (_(BAD_FPU
));
16793 /* Return TRUE if the SIMD instruction is available for the current
16794 cpu_variant. FP is set to TRUE if this is a SIMD floating-point
16795 instruction. CHECK contains th. CHECK contains the set of bits to pass to
16796 vfp_or_neon_is_neon for the NEON specific checks. */
16799 check_simd_pred_availability (int fp
, unsigned check
)
16801 if (inst
.cond
> COND_ALWAYS
)
16803 if (!ARM_CPU_HAS_FEATURE (cpu_variant
, mve_ext
))
16805 inst
.error
= BAD_FPU
;
16808 inst
.pred_insn_type
= INSIDE_VPT_INSN
;
16810 else if (inst
.cond
< COND_ALWAYS
)
16812 if (ARM_CPU_HAS_FEATURE (cpu_variant
, mve_ext
))
16813 inst
.pred_insn_type
= MVE_OUTSIDE_PRED_INSN
;
16814 else if (vfp_or_neon_is_neon (check
) == FAIL
)
16819 if (!ARM_CPU_HAS_FEATURE (cpu_variant
, fp
? mve_fp_ext
: mve_ext
)
16820 && vfp_or_neon_is_neon (check
) == FAIL
)
16823 if (ARM_CPU_HAS_FEATURE (cpu_variant
, mve_ext
))
16824 inst
.pred_insn_type
= MVE_OUTSIDE_PRED_INSN
;
16829 /* Neon instruction encoders, in approximate order of appearance. */
16832 do_neon_dyadic_i_su (void)
16834 if (!check_simd_pred_availability (FALSE
, NEON_CHECK_ARCH
| NEON_CHECK_CC
))
16837 enum neon_shape rs
;
16838 struct neon_type_el et
;
16839 if (ARM_CPU_HAS_FEATURE (cpu_variant
, mve_ext
))
16840 rs
= neon_select_shape (NS_QQQ
, NS_QQR
, NS_NULL
);
16842 rs
= neon_select_shape (NS_DDD
, NS_QQQ
, NS_NULL
);
16844 et
= neon_check_type (3, rs
, N_EQK
, N_EQK
, N_SU_32
| N_KEY
);
16848 neon_three_same (neon_quad (rs
), et
.type
== NT_unsigned
, et
.size
);
16850 mve_encode_qqr (et
.size
, et
.type
== NT_unsigned
, 0);
16854 do_neon_dyadic_i64_su (void)
16856 if (!check_simd_pred_availability (FALSE
, NEON_CHECK_CC
| NEON_CHECK_ARCH
))
16858 enum neon_shape rs
;
16859 struct neon_type_el et
;
16860 if (ARM_CPU_HAS_FEATURE (cpu_variant
, mve_ext
))
16862 rs
= neon_select_shape (NS_QQR
, NS_QQQ
, NS_NULL
);
16863 et
= neon_check_type (3, rs
, N_EQK
, N_EQK
, N_SU_MVE
| N_KEY
);
16867 rs
= neon_select_shape (NS_DDD
, NS_QQQ
, NS_NULL
);
16868 et
= neon_check_type (3, rs
, N_EQK
, N_EQK
, N_SU_ALL
| N_KEY
);
16871 mve_encode_qqr (et
.size
, et
.type
== NT_unsigned
, 0);
16873 neon_three_same (neon_quad (rs
), et
.type
== NT_unsigned
, et
.size
);
16877 neon_imm_shift (int write_ubit
, int uval
, int isquad
, struct neon_type_el et
,
16880 unsigned size
= et
.size
>> 3;
16881 inst
.instruction
|= LOW4 (inst
.operands
[0].reg
) << 12;
16882 inst
.instruction
|= HI1 (inst
.operands
[0].reg
) << 22;
16883 inst
.instruction
|= LOW4 (inst
.operands
[1].reg
);
16884 inst
.instruction
|= HI1 (inst
.operands
[1].reg
) << 5;
16885 inst
.instruction
|= (isquad
!= 0) << 6;
16886 inst
.instruction
|= immbits
<< 16;
16887 inst
.instruction
|= (size
>> 3) << 7;
16888 inst
.instruction
|= (size
& 0x7) << 19;
16890 inst
.instruction
|= (uval
!= 0) << 24;
16892 neon_dp_fixup (&inst
);
16898 if (!check_simd_pred_availability (FALSE
, NEON_CHECK_ARCH
| NEON_CHECK_CC
))
16901 if (!inst
.operands
[2].isreg
)
16903 enum neon_shape rs
;
16904 struct neon_type_el et
;
16905 if (ARM_CPU_HAS_FEATURE (cpu_variant
, mve_ext
))
16907 rs
= neon_select_shape (NS_QQI
, NS_NULL
);
16908 et
= neon_check_type (2, rs
, N_EQK
, N_KEY
| N_I_MVE
);
16912 rs
= neon_select_shape (NS_DDI
, NS_QQI
, NS_NULL
);
16913 et
= neon_check_type (2, rs
, N_EQK
, N_KEY
| N_I_ALL
);
16915 int imm
= inst
.operands
[2].imm
;
16917 constraint (imm
< 0 || (unsigned)imm
>= et
.size
,
16918 _("immediate out of range for shift"));
16919 NEON_ENCODE (IMMED
, inst
);
16920 neon_imm_shift (FALSE
, 0, neon_quad (rs
), et
, imm
);
16924 enum neon_shape rs
;
16925 struct neon_type_el et
;
16926 if (ARM_CPU_HAS_FEATURE (cpu_variant
, mve_ext
))
16928 rs
= neon_select_shape (NS_QQQ
, NS_QQR
, NS_NULL
);
16929 et
= neon_check_type (3, rs
, N_EQK
, N_SU_MVE
| N_KEY
, N_EQK
| N_EQK
);
16933 rs
= neon_select_shape (NS_DDD
, NS_QQQ
, NS_NULL
);
16934 et
= neon_check_type (3, rs
, N_EQK
, N_SU_ALL
| N_KEY
, N_EQK
| N_SGN
);
16940 constraint (inst
.operands
[0].reg
!= inst
.operands
[1].reg
,
16941 _("invalid instruction shape"));
16942 if (inst
.operands
[2].reg
== REG_SP
)
16943 as_tsktsk (MVE_BAD_SP
);
16944 else if (inst
.operands
[2].reg
== REG_PC
)
16945 as_tsktsk (MVE_BAD_PC
);
16947 inst
.instruction
= 0xee311e60;
16948 inst
.instruction
|= (et
.type
== NT_unsigned
) << 28;
16949 inst
.instruction
|= HI1 (inst
.operands
[0].reg
) << 22;
16950 inst
.instruction
|= neon_logbits (et
.size
) << 18;
16951 inst
.instruction
|= LOW4 (inst
.operands
[0].reg
) << 12;
16952 inst
.instruction
|= inst
.operands
[2].reg
;
16959 /* VSHL/VQSHL 3-register variants have syntax such as:
16961 whereas other 3-register operations encoded by neon_three_same have
16964 (i.e. with Dn & Dm reversed). Swap operands[1].reg and
16965 operands[2].reg here. */
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_qshl (void)
16978 if (!check_simd_pred_availability (FALSE
, NEON_CHECK_ARCH
| NEON_CHECK_CC
))
16981 if (!inst
.operands
[2].isreg
)
16983 enum neon_shape rs
;
16984 struct neon_type_el et
;
16985 if (ARM_CPU_HAS_FEATURE (cpu_variant
, mve_ext
))
16987 rs
= neon_select_shape (NS_QQI
, NS_NULL
);
16988 et
= neon_check_type (2, rs
, N_EQK
, N_KEY
| N_SU_MVE
);
16992 rs
= neon_select_shape (NS_DDI
, NS_QQI
, NS_NULL
);
16993 et
= neon_check_type (2, rs
, N_EQK
, N_SU_ALL
| N_KEY
);
16995 int imm
= inst
.operands
[2].imm
;
16997 constraint (imm
< 0 || (unsigned)imm
>= et
.size
,
16998 _("immediate out of range for shift"));
16999 NEON_ENCODE (IMMED
, inst
);
17000 neon_imm_shift (TRUE
, et
.type
== NT_unsigned
, neon_quad (rs
), et
, imm
);
17004 enum neon_shape rs
;
17005 struct neon_type_el et
;
17007 if (ARM_CPU_HAS_FEATURE (cpu_variant
, mve_ext
))
17009 rs
= neon_select_shape (NS_QQQ
, NS_QQR
, NS_NULL
);
17010 et
= neon_check_type (3, rs
, N_EQK
, N_SU_MVE
| N_KEY
, N_EQK
| N_EQK
);
17014 rs
= neon_select_shape (NS_DDD
, NS_QQQ
, NS_NULL
);
17015 et
= neon_check_type (3, rs
, N_EQK
, N_SU_ALL
| N_KEY
, N_EQK
| N_SGN
);
17020 constraint (inst
.operands
[0].reg
!= inst
.operands
[1].reg
,
17021 _("invalid instruction shape"));
17022 if (inst
.operands
[2].reg
== REG_SP
)
17023 as_tsktsk (MVE_BAD_SP
);
17024 else if (inst
.operands
[2].reg
== REG_PC
)
17025 as_tsktsk (MVE_BAD_PC
);
17027 inst
.instruction
= 0xee311ee0;
17028 inst
.instruction
|= (et
.type
== NT_unsigned
) << 28;
17029 inst
.instruction
|= HI1 (inst
.operands
[0].reg
) << 22;
17030 inst
.instruction
|= neon_logbits (et
.size
) << 18;
17031 inst
.instruction
|= LOW4 (inst
.operands
[0].reg
) << 12;
17032 inst
.instruction
|= inst
.operands
[2].reg
;
17039 /* See note in do_neon_shl. */
17040 tmp
= inst
.operands
[2].reg
;
17041 inst
.operands
[2].reg
= inst
.operands
[1].reg
;
17042 inst
.operands
[1].reg
= tmp
;
17043 NEON_ENCODE (INTEGER
, inst
);
17044 neon_three_same (neon_quad (rs
), et
.type
== NT_unsigned
, et
.size
);
17050 do_neon_rshl (void)
17052 if (!check_simd_pred_availability (FALSE
, NEON_CHECK_ARCH
| NEON_CHECK_CC
))
17055 enum neon_shape rs
;
17056 struct neon_type_el et
;
17057 if (ARM_CPU_HAS_FEATURE (cpu_variant
, mve_ext
))
17059 rs
= neon_select_shape (NS_QQR
, NS_QQQ
, NS_NULL
);
17060 et
= neon_check_type (3, rs
, N_EQK
, N_EQK
, N_SU_MVE
| N_KEY
);
17064 rs
= neon_select_shape (NS_DDD
, NS_QQQ
, NS_NULL
);
17065 et
= neon_check_type (3, rs
, N_EQK
, N_EQK
, N_SU_ALL
| N_KEY
);
17072 if (inst
.operands
[2].reg
== REG_PC
)
17073 as_tsktsk (MVE_BAD_PC
);
17074 else if (inst
.operands
[2].reg
== REG_SP
)
17075 as_tsktsk (MVE_BAD_SP
);
17077 constraint (inst
.operands
[0].reg
!= inst
.operands
[1].reg
,
17078 _("invalid instruction shape"));
17080 if (inst
.instruction
== 0x0000510)
17081 /* We are dealing with vqrshl. */
17082 inst
.instruction
= 0xee331ee0;
17084 /* We are dealing with vrshl. */
17085 inst
.instruction
= 0xee331e60;
17087 inst
.instruction
|= (et
.type
== NT_unsigned
) << 28;
17088 inst
.instruction
|= HI1 (inst
.operands
[0].reg
) << 22;
17089 inst
.instruction
|= neon_logbits (et
.size
) << 18;
17090 inst
.instruction
|= LOW4 (inst
.operands
[0].reg
) << 12;
17091 inst
.instruction
|= inst
.operands
[2].reg
;
17096 tmp
= inst
.operands
[2].reg
;
17097 inst
.operands
[2].reg
= inst
.operands
[1].reg
;
17098 inst
.operands
[1].reg
= tmp
;
17099 neon_three_same (neon_quad (rs
), et
.type
== NT_unsigned
, et
.size
);
17104 neon_cmode_for_logic_imm (unsigned immediate
, unsigned *immbits
, int size
)
17106 /* Handle .I8 pseudo-instructions. */
17109 /* Unfortunately, this will make everything apart from zero out-of-range.
17110 FIXME is this the intended semantics? There doesn't seem much point in
17111 accepting .I8 if so. */
17112 immediate
|= immediate
<< 8;
17118 if (immediate
== (immediate
& 0x000000ff))
17120 *immbits
= immediate
;
17123 else if (immediate
== (immediate
& 0x0000ff00))
17125 *immbits
= immediate
>> 8;
17128 else if (immediate
== (immediate
& 0x00ff0000))
17130 *immbits
= immediate
>> 16;
17133 else if (immediate
== (immediate
& 0xff000000))
17135 *immbits
= immediate
>> 24;
17138 if ((immediate
& 0xffff) != (immediate
>> 16))
17139 goto bad_immediate
;
17140 immediate
&= 0xffff;
17143 if (immediate
== (immediate
& 0x000000ff))
17145 *immbits
= immediate
;
17148 else if (immediate
== (immediate
& 0x0000ff00))
17150 *immbits
= immediate
>> 8;
17155 first_error (_("immediate value out of range"));
17160 do_neon_logic (void)
17162 if (inst
.operands
[2].present
&& inst
.operands
[2].isreg
)
17164 enum neon_shape rs
= neon_select_shape (NS_DDD
, NS_QQQ
, NS_NULL
);
17166 && !check_simd_pred_availability (FALSE
,
17167 NEON_CHECK_ARCH
| NEON_CHECK_CC
))
17169 else if (rs
!= NS_QQQ
17170 && !ARM_CPU_HAS_FEATURE (cpu_variant
, fpu_neon_ext_v1
))
17171 first_error (BAD_FPU
);
17173 neon_check_type (3, rs
, N_IGNORE_TYPE
);
17174 /* U bit and size field were set as part of the bitmask. */
17175 NEON_ENCODE (INTEGER
, inst
);
17176 neon_three_same (neon_quad (rs
), 0, -1);
17180 const int three_ops_form
= (inst
.operands
[2].present
17181 && !inst
.operands
[2].isreg
);
17182 const int immoperand
= (three_ops_form
? 2 : 1);
17183 enum neon_shape rs
= (three_ops_form
17184 ? neon_select_shape (NS_DDI
, NS_QQI
, NS_NULL
)
17185 : neon_select_shape (NS_DI
, NS_QI
, NS_NULL
));
17186 /* Because neon_select_shape makes the second operand a copy of the first
17187 if the second operand is not present. */
17189 && !check_simd_pred_availability (FALSE
,
17190 NEON_CHECK_ARCH
| NEON_CHECK_CC
))
17192 else if (rs
!= NS_QQI
17193 && !ARM_CPU_HAS_FEATURE (cpu_variant
, fpu_neon_ext_v1
))
17194 first_error (BAD_FPU
);
17196 struct neon_type_el et
;
17197 if (ARM_CPU_HAS_FEATURE (cpu_variant
, mve_ext
))
17198 et
= neon_check_type (2, rs
, N_I32
| N_I16
| N_KEY
, N_EQK
);
17200 et
= neon_check_type (2, rs
, N_I8
| N_I16
| N_I32
| N_I64
| N_F32
17203 if (et
.type
== NT_invtype
)
17205 enum neon_opc opcode
= (enum neon_opc
) inst
.instruction
& 0x0fffffff;
17210 if (three_ops_form
)
17211 constraint (inst
.operands
[0].reg
!= inst
.operands
[1].reg
,
17212 _("first and second operands shall be the same register"));
17214 NEON_ENCODE (IMMED
, inst
);
17216 immbits
= inst
.operands
[immoperand
].imm
;
17219 /* .i64 is a pseudo-op, so the immediate must be a repeating
17221 if (immbits
!= (inst
.operands
[immoperand
].regisimm
?
17222 inst
.operands
[immoperand
].reg
: 0))
17224 /* Set immbits to an invalid constant. */
17225 immbits
= 0xdeadbeef;
17232 cmode
= neon_cmode_for_logic_imm (immbits
, &immbits
, et
.size
);
17236 cmode
= neon_cmode_for_logic_imm (immbits
, &immbits
, et
.size
);
17240 /* Pseudo-instruction for VBIC. */
17241 neon_invert_size (&immbits
, 0, et
.size
);
17242 cmode
= neon_cmode_for_logic_imm (immbits
, &immbits
, et
.size
);
17246 /* Pseudo-instruction for VORR. */
17247 neon_invert_size (&immbits
, 0, et
.size
);
17248 cmode
= neon_cmode_for_logic_imm (immbits
, &immbits
, et
.size
);
17258 inst
.instruction
|= neon_quad (rs
) << 6;
17259 inst
.instruction
|= LOW4 (inst
.operands
[0].reg
) << 12;
17260 inst
.instruction
|= HI1 (inst
.operands
[0].reg
) << 22;
17261 inst
.instruction
|= cmode
<< 8;
17262 neon_write_immbits (immbits
);
17264 neon_dp_fixup (&inst
);
17269 do_neon_bitfield (void)
17271 enum neon_shape rs
= neon_select_shape (NS_DDD
, NS_QQQ
, NS_NULL
);
17272 neon_check_type (3, rs
, N_IGNORE_TYPE
);
17273 neon_three_same (neon_quad (rs
), 0, -1);
17277 neon_dyadic_misc (enum neon_el_type ubit_meaning
, unsigned types
,
17280 enum neon_shape rs
= neon_select_shape (NS_DDD
, NS_QQQ
, NS_QQR
, NS_NULL
);
17281 struct neon_type_el et
= neon_check_type (3, rs
, N_EQK
| destbits
, N_EQK
,
17283 if (et
.type
== NT_float
)
17285 NEON_ENCODE (FLOAT
, inst
);
17287 mve_encode_qqr (et
.size
, 0, 1);
17289 neon_three_same (neon_quad (rs
), 0, et
.size
== 16 ? (int) et
.size
: -1);
17293 NEON_ENCODE (INTEGER
, inst
);
17295 mve_encode_qqr (et
.size
, et
.type
== ubit_meaning
, 0);
17297 neon_three_same (neon_quad (rs
), et
.type
== ubit_meaning
, et
.size
);
17303 do_neon_dyadic_if_su_d (void)
17305 /* This version only allow D registers, but that constraint is enforced during
17306 operand parsing so we don't need to do anything extra here. */
17307 neon_dyadic_misc (NT_unsigned
, N_SUF_32
, 0);
17311 do_neon_dyadic_if_i_d (void)
17313 /* The "untyped" case can't happen. Do this to stop the "U" bit being
17314 affected if we specify unsigned args. */
17315 neon_dyadic_misc (NT_untyped
, N_IF_32
, 0);
17319 do_mve_vstr_vldr_QI (int size
, int elsize
, int load
)
17321 constraint (size
< 32, BAD_ADDR_MODE
);
17322 constraint (size
!= elsize
, BAD_EL_TYPE
);
17323 constraint (inst
.operands
[1].immisreg
, BAD_ADDR_MODE
);
17324 constraint (!inst
.operands
[1].preind
, BAD_ADDR_MODE
);
17325 constraint (load
&& inst
.operands
[0].reg
== inst
.operands
[1].reg
,
17326 _("destination register and offset register may not be the"
17329 int imm
= inst
.relocs
[0].exp
.X_add_number
;
17336 constraint ((imm
% (size
/ 8) != 0)
17337 || imm
> (0x7f << neon_logbits (size
)),
17338 (size
== 32) ? _("immediate must be a multiple of 4 in the"
17339 " range of +/-[0,508]")
17340 : _("immediate must be a multiple of 8 in the"
17341 " range of +/-[0,1016]"));
17342 inst
.instruction
|= 0x11 << 24;
17343 inst
.instruction
|= add
<< 23;
17344 inst
.instruction
|= HI1 (inst
.operands
[0].reg
) << 22;
17345 inst
.instruction
|= inst
.operands
[1].writeback
<< 21;
17346 inst
.instruction
|= LOW4 (inst
.operands
[1].reg
) << 16;
17347 inst
.instruction
|= LOW4 (inst
.operands
[0].reg
) << 12;
17348 inst
.instruction
|= 1 << 12;
17349 inst
.instruction
|= (size
== 64) << 8;
17350 inst
.instruction
&= 0xffffff00;
17351 inst
.instruction
|= HI1 (inst
.operands
[1].reg
) << 7;
17352 inst
.instruction
|= imm
>> neon_logbits (size
);
17356 do_mve_vstr_vldr_RQ (int size
, int elsize
, int load
)
17358 unsigned os
= inst
.operands
[1].imm
>> 5;
17359 unsigned type
= inst
.vectype
.el
[0].type
;
17360 constraint (os
!= 0 && size
== 8,
17361 _("can not shift offsets when accessing less than half-word"));
17362 constraint (os
&& os
!= neon_logbits (size
),
17363 _("shift immediate must be 1, 2 or 3 for half-word, word"
17364 " or double-word accesses respectively"));
17365 if (inst
.operands
[1].reg
== REG_PC
)
17366 as_tsktsk (MVE_BAD_PC
);
17371 constraint (elsize
>= 64, BAD_EL_TYPE
);
17374 constraint (elsize
< 16 || elsize
>= 64, BAD_EL_TYPE
);
17378 constraint (elsize
!= size
, BAD_EL_TYPE
);
17383 constraint (inst
.operands
[1].writeback
|| !inst
.operands
[1].preind
,
17387 constraint (inst
.operands
[0].reg
== (inst
.operands
[1].imm
& 0x1f),
17388 _("destination register and offset register may not be"
17390 constraint (size
== elsize
&& type
== NT_signed
, BAD_EL_TYPE
);
17391 constraint (size
!= elsize
&& type
!= NT_unsigned
&& type
!= NT_signed
,
17393 inst
.instruction
|= ((size
== elsize
) || (type
== NT_unsigned
)) << 28;
17397 constraint (type
!= NT_untyped
, BAD_EL_TYPE
);
17400 inst
.instruction
|= 1 << 23;
17401 inst
.instruction
|= HI1 (inst
.operands
[0].reg
) << 22;
17402 inst
.instruction
|= inst
.operands
[1].reg
<< 16;
17403 inst
.instruction
|= LOW4 (inst
.operands
[0].reg
) << 12;
17404 inst
.instruction
|= neon_logbits (elsize
) << 7;
17405 inst
.instruction
|= HI1 (inst
.operands
[1].imm
) << 5;
17406 inst
.instruction
|= LOW4 (inst
.operands
[1].imm
);
17407 inst
.instruction
|= !!os
;
17411 do_mve_vstr_vldr_RI (int size
, int elsize
, int load
)
17413 enum neon_el_type type
= inst
.vectype
.el
[0].type
;
17415 constraint (size
>= 64, BAD_ADDR_MODE
);
17419 constraint (elsize
< 16 || elsize
>= 64, BAD_EL_TYPE
);
17422 constraint (elsize
!= size
, BAD_EL_TYPE
);
17429 constraint (elsize
!= size
&& type
!= NT_unsigned
17430 && type
!= NT_signed
, BAD_EL_TYPE
);
17434 constraint (elsize
!= size
&& type
!= NT_untyped
, BAD_EL_TYPE
);
17437 int imm
= inst
.relocs
[0].exp
.X_add_number
;
17445 if ((imm
% (size
/ 8) != 0) || imm
> (0x7f << neon_logbits (size
)))
17450 constraint (1, _("immediate must be in the range of +/-[0,127]"));
17453 constraint (1, _("immediate must be a multiple of 2 in the"
17454 " range of +/-[0,254]"));
17457 constraint (1, _("immediate must be a multiple of 4 in the"
17458 " range of +/-[0,508]"));
17463 if (size
!= elsize
)
17465 constraint (inst
.operands
[1].reg
> 7, BAD_HIREG
);
17466 constraint (inst
.operands
[0].reg
> 14,
17467 _("MVE vector register in the range [Q0..Q7] expected"));
17468 inst
.instruction
|= (load
&& type
== NT_unsigned
) << 28;
17469 inst
.instruction
|= (size
== 16) << 19;
17470 inst
.instruction
|= neon_logbits (elsize
) << 7;
17474 if (inst
.operands
[1].reg
== REG_PC
)
17475 as_tsktsk (MVE_BAD_PC
);
17476 else if (inst
.operands
[1].reg
== REG_SP
&& inst
.operands
[1].writeback
)
17477 as_tsktsk (MVE_BAD_SP
);
17478 inst
.instruction
|= 1 << 12;
17479 inst
.instruction
|= neon_logbits (size
) << 7;
17481 inst
.instruction
|= inst
.operands
[1].preind
<< 24;
17482 inst
.instruction
|= add
<< 23;
17483 inst
.instruction
|= HI1 (inst
.operands
[0].reg
) << 22;
17484 inst
.instruction
|= inst
.operands
[1].writeback
<< 21;
17485 inst
.instruction
|= inst
.operands
[1].reg
<< 16;
17486 inst
.instruction
|= LOW4 (inst
.operands
[0].reg
) << 12;
17487 inst
.instruction
&= 0xffffff80;
17488 inst
.instruction
|= imm
>> neon_logbits (size
);
17493 do_mve_vstr_vldr (void)
17498 if (inst
.cond
> COND_ALWAYS
)
17499 inst
.pred_insn_type
= INSIDE_VPT_INSN
;
17501 inst
.pred_insn_type
= MVE_OUTSIDE_PRED_INSN
;
17503 switch (inst
.instruction
)
17510 /* fall through. */
17516 /* fall through. */
17522 /* fall through. */
17528 /* fall through. */
17533 unsigned elsize
= inst
.vectype
.el
[0].size
;
17535 if (inst
.operands
[1].isquad
)
17537 /* We are dealing with [Q, imm]{!} cases. */
17538 do_mve_vstr_vldr_QI (size
, elsize
, load
);
17542 if (inst
.operands
[1].immisreg
== 2)
17544 /* We are dealing with [R, Q, {UXTW #os}] cases. */
17545 do_mve_vstr_vldr_RQ (size
, elsize
, load
);
17547 else if (!inst
.operands
[1].immisreg
)
17549 /* We are dealing with [R, Imm]{!}/[R], Imm cases. */
17550 do_mve_vstr_vldr_RI (size
, elsize
, load
);
17553 constraint (1, BAD_ADDR_MODE
);
17560 do_mve_vst_vld (void)
17562 if (!ARM_CPU_HAS_FEATURE (cpu_variant
, mve_ext
))
17565 constraint (!inst
.operands
[1].preind
|| inst
.relocs
[0].exp
.X_add_symbol
!= 0
17566 || inst
.relocs
[0].exp
.X_add_number
!= 0
17567 || inst
.operands
[1].immisreg
!= 0,
17569 constraint (inst
.vectype
.el
[0].size
> 32, BAD_EL_TYPE
);
17570 if (inst
.operands
[1].reg
== REG_PC
)
17571 as_tsktsk (MVE_BAD_PC
);
17572 else if (inst
.operands
[1].reg
== REG_SP
&& inst
.operands
[1].writeback
)
17573 as_tsktsk (MVE_BAD_SP
);
17576 /* These instructions are one of the "exceptions" mentioned in
17577 handle_pred_state. They are MVE instructions that are not VPT compatible
17578 and do not accept a VPT code, thus appending such a code is a syntax
17580 if (inst
.cond
> COND_ALWAYS
)
17581 first_error (BAD_SYNTAX
);
17582 /* If we append a scalar condition code we can set this to
17583 MVE_OUTSIDE_PRED_INSN as it will also lead to a syntax error. */
17584 else if (inst
.cond
< COND_ALWAYS
)
17585 inst
.pred_insn_type
= MVE_OUTSIDE_PRED_INSN
;
17587 inst
.pred_insn_type
= MVE_UNPREDICABLE_INSN
;
17589 inst
.instruction
|= HI1 (inst
.operands
[0].reg
) << 22;
17590 inst
.instruction
|= inst
.operands
[1].writeback
<< 21;
17591 inst
.instruction
|= inst
.operands
[1].reg
<< 16;
17592 inst
.instruction
|= LOW4 (inst
.operands
[0].reg
) << 12;
17593 inst
.instruction
|= neon_logbits (inst
.vectype
.el
[0].size
) << 7;
17598 do_mve_vaddlv (void)
17600 enum neon_shape rs
= neon_select_shape (NS_RRQ
, NS_NULL
);
17601 struct neon_type_el et
17602 = neon_check_type (3, rs
, N_EQK
, N_EQK
, N_S32
| N_U32
| N_KEY
);
17604 if (et
.type
== NT_invtype
)
17605 first_error (BAD_EL_TYPE
);
17607 if (inst
.cond
> COND_ALWAYS
)
17608 inst
.pred_insn_type
= INSIDE_VPT_INSN
;
17610 inst
.pred_insn_type
= MVE_OUTSIDE_PRED_INSN
;
17612 constraint (inst
.operands
[1].reg
> 14, MVE_BAD_QREG
);
17614 inst
.instruction
|= (et
.type
== NT_unsigned
) << 28;
17615 inst
.instruction
|= inst
.operands
[1].reg
<< 19;
17616 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
17617 inst
.instruction
|= inst
.operands
[2].reg
;
17622 do_neon_dyadic_if_su (void)
17624 enum neon_shape rs
= neon_select_shape (NS_DDD
, NS_QQQ
, NS_QQR
, NS_NULL
);
17625 struct neon_type_el et
= neon_check_type (3, rs
, N_EQK
, N_EQK
,
17628 constraint ((inst
.instruction
== ((unsigned) N_MNEM_vmax
)
17629 || inst
.instruction
== ((unsigned) N_MNEM_vmin
))
17630 && et
.type
== NT_float
17631 && !ARM_CPU_HAS_FEATURE (cpu_variant
,fpu_neon_ext_v1
), BAD_FPU
);
17633 if (!check_simd_pred_availability (et
.type
== NT_float
,
17634 NEON_CHECK_ARCH
| NEON_CHECK_CC
))
17637 neon_dyadic_misc (NT_unsigned
, N_SUF_32
, 0);
17641 do_neon_addsub_if_i (void)
17643 if (ARM_CPU_HAS_FEATURE (cpu_variant
, fpu_vfp_ext_v1xd
)
17644 && try_vfp_nsyn (3, do_vfp_nsyn_add_sub
) == SUCCESS
)
17647 enum neon_shape rs
= neon_select_shape (NS_DDD
, NS_QQQ
, NS_QQR
, NS_NULL
);
17648 struct neon_type_el et
= neon_check_type (3, rs
, N_EQK
,
17649 N_EQK
, N_IF_32
| N_I64
| N_KEY
);
17651 constraint (rs
== NS_QQR
&& et
.size
== 64, BAD_FPU
);
17652 /* If we are parsing Q registers and the element types match MVE, which NEON
17653 also supports, then we must check whether this is an instruction that can
17654 be used by both MVE/NEON. This distinction can be made based on whether
17655 they are predicated or not. */
17656 if ((rs
== NS_QQQ
|| rs
== NS_QQR
) && et
.size
!= 64)
17658 if (!check_simd_pred_availability (et
.type
== NT_float
,
17659 NEON_CHECK_ARCH
| NEON_CHECK_CC
))
17664 /* If they are either in a D register or are using an unsupported. */
17666 && vfp_or_neon_is_neon (NEON_CHECK_CC
| NEON_CHECK_ARCH
) == FAIL
)
17670 /* The "untyped" case can't happen. Do this to stop the "U" bit being
17671 affected if we specify unsigned args. */
17672 neon_dyadic_misc (NT_untyped
, N_IF_32
| N_I64
, 0);
17675 /* Swaps operands 1 and 2. If operand 1 (optional arg) was omitted, we want the
17677 V<op> A,B (A is operand 0, B is operand 2)
17682 so handle that case specially. */
17685 neon_exchange_operands (void)
17687 if (inst
.operands
[1].present
)
17689 void *scratch
= xmalloc (sizeof (inst
.operands
[0]));
17691 /* Swap operands[1] and operands[2]. */
17692 memcpy (scratch
, &inst
.operands
[1], sizeof (inst
.operands
[0]));
17693 inst
.operands
[1] = inst
.operands
[2];
17694 memcpy (&inst
.operands
[2], scratch
, sizeof (inst
.operands
[0]));
17699 inst
.operands
[1] = inst
.operands
[2];
17700 inst
.operands
[2] = inst
.operands
[0];
17705 neon_compare (unsigned regtypes
, unsigned immtypes
, int invert
)
17707 if (inst
.operands
[2].isreg
)
17710 neon_exchange_operands ();
17711 neon_dyadic_misc (NT_unsigned
, regtypes
, N_SIZ
);
17715 enum neon_shape rs
= neon_select_shape (NS_DDI
, NS_QQI
, NS_NULL
);
17716 struct neon_type_el et
= neon_check_type (2, rs
,
17717 N_EQK
| N_SIZ
, immtypes
| N_KEY
);
17719 NEON_ENCODE (IMMED
, inst
);
17720 inst
.instruction
|= LOW4 (inst
.operands
[0].reg
) << 12;
17721 inst
.instruction
|= HI1 (inst
.operands
[0].reg
) << 22;
17722 inst
.instruction
|= LOW4 (inst
.operands
[1].reg
);
17723 inst
.instruction
|= HI1 (inst
.operands
[1].reg
) << 5;
17724 inst
.instruction
|= neon_quad (rs
) << 6;
17725 inst
.instruction
|= (et
.type
== NT_float
) << 10;
17726 inst
.instruction
|= neon_logbits (et
.size
) << 18;
17728 neon_dp_fixup (&inst
);
17735 neon_compare (N_SUF_32
, N_S_32
| N_F_16_32
, FALSE
);
17739 do_neon_cmp_inv (void)
17741 neon_compare (N_SUF_32
, N_S_32
| N_F_16_32
, TRUE
);
17747 neon_compare (N_IF_32
, N_IF_32
, FALSE
);
17750 /* For multiply instructions, we have the possibility of 16-bit or 32-bit
17751 scalars, which are encoded in 5 bits, M : Rm.
17752 For 16-bit scalars, the register is encoded in Rm[2:0] and the index in
17753 M:Rm[3], and for 32-bit scalars, the register is encoded in Rm[3:0] and the
17756 Dot Product instructions are similar to multiply instructions except elsize
17757 should always be 32.
17759 This function translates SCALAR, which is GAS's internal encoding of indexed
17760 scalar register, to raw encoding. There is also register and index range
17761 check based on ELSIZE. */
17764 neon_scalar_for_mul (unsigned scalar
, unsigned elsize
)
17766 unsigned regno
= NEON_SCALAR_REG (scalar
);
17767 unsigned elno
= NEON_SCALAR_INDEX (scalar
);
17772 if (regno
> 7 || elno
> 3)
17774 return regno
| (elno
<< 3);
17777 if (regno
> 15 || elno
> 1)
17779 return regno
| (elno
<< 4);
17783 first_error (_("scalar out of range for multiply instruction"));
17789 /* Encode multiply / multiply-accumulate scalar instructions. */
17792 neon_mul_mac (struct neon_type_el et
, int ubit
)
17796 /* Give a more helpful error message if we have an invalid type. */
17797 if (et
.type
== NT_invtype
)
17800 scalar
= neon_scalar_for_mul (inst
.operands
[2].reg
, et
.size
);
17801 inst
.instruction
|= LOW4 (inst
.operands
[0].reg
) << 12;
17802 inst
.instruction
|= HI1 (inst
.operands
[0].reg
) << 22;
17803 inst
.instruction
|= LOW4 (inst
.operands
[1].reg
) << 16;
17804 inst
.instruction
|= HI1 (inst
.operands
[1].reg
) << 7;
17805 inst
.instruction
|= LOW4 (scalar
);
17806 inst
.instruction
|= HI1 (scalar
) << 5;
17807 inst
.instruction
|= (et
.type
== NT_float
) << 8;
17808 inst
.instruction
|= neon_logbits (et
.size
) << 20;
17809 inst
.instruction
|= (ubit
!= 0) << 24;
17811 neon_dp_fixup (&inst
);
17815 do_neon_mac_maybe_scalar (void)
17817 if (try_vfp_nsyn (3, do_vfp_nsyn_mla_mls
) == SUCCESS
)
17820 if (!check_simd_pred_availability (FALSE
, NEON_CHECK_CC
| NEON_CHECK_ARCH
))
17823 if (inst
.operands
[2].isscalar
)
17825 constraint (ARM_CPU_HAS_FEATURE (cpu_variant
, mve_ext
), BAD_FPU
);
17826 enum neon_shape rs
= neon_select_shape (NS_DDS
, NS_QQS
, NS_NULL
);
17827 struct neon_type_el et
= neon_check_type (3, rs
,
17828 N_EQK
, N_EQK
, N_I16
| N_I32
| N_F_16_32
| N_KEY
);
17829 NEON_ENCODE (SCALAR
, inst
);
17830 neon_mul_mac (et
, neon_quad (rs
));
17832 else if (!inst
.operands
[2].isvec
)
17834 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant
, mve_ext
), BAD_FPU
);
17836 enum neon_shape rs
= neon_select_shape (NS_QQR
, NS_NULL
);
17837 neon_check_type (3, rs
, N_EQK
, N_EQK
, N_SU_MVE
| N_KEY
);
17839 neon_dyadic_misc (NT_unsigned
, N_SU_MVE
, 0);
17843 constraint (ARM_CPU_HAS_FEATURE (cpu_variant
, mve_ext
), BAD_FPU
);
17844 /* The "untyped" case can't happen. Do this to stop the "U" bit being
17845 affected if we specify unsigned args. */
17846 neon_dyadic_misc (NT_untyped
, N_IF_32
, 0);
17851 do_bfloat_vfma (void)
17853 constraint (!mark_feature_used (&fpu_neon_ext_armv8
), _(BAD_FPU
));
17854 constraint (!mark_feature_used (&arm_ext_bf16
), _(BAD_BF16
));
17855 enum neon_shape rs
;
17858 if (inst
.instruction
!= B_MNEM_vfmab
)
17861 inst
.instruction
= B_MNEM_vfmat
;
17864 if (inst
.operands
[2].isscalar
)
17866 rs
= neon_select_shape (NS_QQS
, NS_NULL
);
17867 neon_check_type (3, rs
, N_EQK
, N_EQK
, N_BF16
| N_KEY
);
17869 inst
.instruction
|= (1 << 25);
17870 int index
= inst
.operands
[2].reg
& 0xf;
17871 constraint (!(index
< 4), _("index must be in the range 0 to 3"));
17872 inst
.operands
[2].reg
>>= 4;
17873 constraint (!(inst
.operands
[2].reg
< 8),
17874 _("indexed register must be less than 8"));
17875 neon_three_args (t_bit
);
17876 inst
.instruction
|= ((index
& 1) << 3);
17877 inst
.instruction
|= ((index
& 2) << 4);
17881 rs
= neon_select_shape (NS_QQQ
, NS_NULL
);
17882 neon_check_type (3, rs
, N_EQK
, N_EQK
, N_BF16
| N_KEY
);
17883 neon_three_args (t_bit
);
17889 do_neon_fmac (void)
17891 if (ARM_CPU_HAS_FEATURE (cpu_variant
, fpu_vfp_ext_fma
)
17892 && try_vfp_nsyn (3, do_vfp_nsyn_fma_fms
) == SUCCESS
)
17895 if (!check_simd_pred_availability (TRUE
, NEON_CHECK_CC
| NEON_CHECK_ARCH
))
17898 if (ARM_CPU_HAS_FEATURE (cpu_variant
, mve_fp_ext
))
17900 enum neon_shape rs
= neon_select_shape (NS_QQQ
, NS_QQR
, NS_NULL
);
17901 struct neon_type_el et
= neon_check_type (3, rs
, N_F_MVE
| N_KEY
, N_EQK
,
17907 if (inst
.operands
[2].reg
== REG_SP
)
17908 as_tsktsk (MVE_BAD_SP
);
17909 else if (inst
.operands
[2].reg
== REG_PC
)
17910 as_tsktsk (MVE_BAD_PC
);
17912 inst
.instruction
= 0xee310e40;
17913 inst
.instruction
|= (et
.size
== 16) << 28;
17914 inst
.instruction
|= HI1 (inst
.operands
[0].reg
) << 22;
17915 inst
.instruction
|= LOW4 (inst
.operands
[1].reg
) << 16;
17916 inst
.instruction
|= LOW4 (inst
.operands
[0].reg
) << 12;
17917 inst
.instruction
|= HI1 (inst
.operands
[1].reg
) << 6;
17918 inst
.instruction
|= inst
.operands
[2].reg
;
17925 constraint (!inst
.operands
[2].isvec
, BAD_FPU
);
17928 neon_dyadic_misc (NT_untyped
, N_IF_32
, 0);
17934 if (!ARM_CPU_HAS_FEATURE (cpu_variant
, arm_ext_bf16
) &&
17935 inst
.cond
== COND_ALWAYS
)
17937 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant
, mve_ext
), BAD_FPU
);
17938 inst
.instruction
= N_MNEM_vfma
;
17939 inst
.pred_insn_type
= INSIDE_VPT_INSN
;
17941 return do_neon_fmac();
17952 enum neon_shape rs
= neon_select_shape (NS_DDD
, NS_QQQ
, NS_NULL
);
17953 struct neon_type_el et
= neon_check_type (3, rs
,
17954 N_EQK
, N_EQK
, N_8
| N_16
| N_32
| N_KEY
);
17955 neon_three_same (neon_quad (rs
), 0, et
.size
);
17958 /* VMUL with 3 registers allows the P8 type. The scalar version supports the
17959 same types as the MAC equivalents. The polynomial type for this instruction
17960 is encoded the same as the integer type. */
17965 if (try_vfp_nsyn (3, do_vfp_nsyn_mul
) == SUCCESS
)
17968 if (!check_simd_pred_availability (FALSE
, NEON_CHECK_CC
| NEON_CHECK_ARCH
))
17971 if (inst
.operands
[2].isscalar
)
17973 constraint (ARM_CPU_HAS_FEATURE (cpu_variant
, mve_ext
), BAD_FPU
);
17974 do_neon_mac_maybe_scalar ();
17978 if (ARM_CPU_HAS_FEATURE (cpu_variant
, mve_ext
))
17980 enum neon_shape rs
= neon_select_shape (NS_QQR
, NS_QQQ
, NS_NULL
);
17981 struct neon_type_el et
17982 = neon_check_type (3, rs
, N_EQK
, N_EQK
, N_I_MVE
| N_F_MVE
| N_KEY
);
17983 if (et
.type
== NT_float
)
17984 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant
, mve_fp_ext
),
17987 neon_dyadic_misc (NT_float
, N_I_MVE
| N_F_MVE
, 0);
17991 constraint (!inst
.operands
[2].isvec
, BAD_FPU
);
17992 neon_dyadic_misc (NT_poly
,
17993 N_I8
| N_I16
| N_I32
| N_F16
| N_F32
| N_P8
, 0);
17999 do_neon_qdmulh (void)
18001 if (!check_simd_pred_availability (FALSE
, NEON_CHECK_ARCH
| NEON_CHECK_CC
))
18004 if (inst
.operands
[2].isscalar
)
18006 constraint (ARM_CPU_HAS_FEATURE (cpu_variant
, mve_ext
), BAD_FPU
);
18007 enum neon_shape rs
= neon_select_shape (NS_DDS
, NS_QQS
, NS_NULL
);
18008 struct neon_type_el et
= neon_check_type (3, rs
,
18009 N_EQK
, N_EQK
, N_S16
| N_S32
| N_KEY
);
18010 NEON_ENCODE (SCALAR
, inst
);
18011 neon_mul_mac (et
, neon_quad (rs
));
18015 enum neon_shape rs
;
18016 struct neon_type_el et
;
18017 if (ARM_CPU_HAS_FEATURE (cpu_variant
, mve_ext
))
18019 rs
= neon_select_shape (NS_QQR
, NS_QQQ
, NS_NULL
);
18020 et
= neon_check_type (3, rs
,
18021 N_EQK
, N_EQK
, N_S8
| N_S16
| N_S32
| N_KEY
);
18025 rs
= neon_select_shape (NS_DDD
, NS_QQQ
, NS_NULL
);
18026 et
= neon_check_type (3, rs
,
18027 N_EQK
, N_EQK
, N_S16
| N_S32
| N_KEY
);
18030 NEON_ENCODE (INTEGER
, inst
);
18032 mve_encode_qqr (et
.size
, 0, 0);
18034 /* The U bit (rounding) comes from bit mask. */
18035 neon_three_same (neon_quad (rs
), 0, et
.size
);
18040 do_mve_vaddv (void)
18042 enum neon_shape rs
= neon_select_shape (NS_RQ
, NS_NULL
);
18043 struct neon_type_el et
18044 = neon_check_type (2, rs
, N_EQK
, N_SU_32
| N_KEY
);
18046 if (et
.type
== NT_invtype
)
18047 first_error (BAD_EL_TYPE
);
18049 if (inst
.cond
> COND_ALWAYS
)
18050 inst
.pred_insn_type
= INSIDE_VPT_INSN
;
18052 inst
.pred_insn_type
= MVE_OUTSIDE_PRED_INSN
;
18054 constraint (inst
.operands
[1].reg
> 14, MVE_BAD_QREG
);
18056 mve_encode_rq (et
.type
== NT_unsigned
, et
.size
);
18060 do_mve_vhcadd (void)
18062 enum neon_shape rs
= neon_select_shape (NS_QQQI
, NS_NULL
);
18063 struct neon_type_el et
18064 = neon_check_type (3, rs
, N_EQK
, N_EQK
, N_S8
| N_S16
| N_S32
| N_KEY
);
18066 if (inst
.cond
> COND_ALWAYS
)
18067 inst
.pred_insn_type
= INSIDE_VPT_INSN
;
18069 inst
.pred_insn_type
= MVE_OUTSIDE_PRED_INSN
;
18071 unsigned rot
= inst
.relocs
[0].exp
.X_add_number
;
18072 constraint (rot
!= 90 && rot
!= 270, _("immediate out of range"));
18074 if (et
.size
== 32 && inst
.operands
[0].reg
== inst
.operands
[2].reg
)
18075 as_tsktsk (_("Warning: 32-bit element size and same first and third "
18076 "operand makes instruction UNPREDICTABLE"));
18078 mve_encode_qqq (0, et
.size
);
18079 inst
.instruction
|= (rot
== 270) << 12;
18084 do_mve_vqdmull (void)
18086 enum neon_shape rs
= neon_select_shape (NS_QQQ
, NS_QQR
, NS_NULL
);
18087 struct neon_type_el et
18088 = neon_check_type (3, rs
, N_EQK
, N_EQK
, N_S16
| N_S32
| N_KEY
);
18091 && (inst
.operands
[0].reg
== inst
.operands
[1].reg
18092 || (rs
== NS_QQQ
&& inst
.operands
[0].reg
== inst
.operands
[2].reg
)))
18093 as_tsktsk (BAD_MVE_SRCDEST
);
18095 if (inst
.cond
> COND_ALWAYS
)
18096 inst
.pred_insn_type
= INSIDE_VPT_INSN
;
18098 inst
.pred_insn_type
= MVE_OUTSIDE_PRED_INSN
;
18102 mve_encode_qqq (et
.size
== 32, 64);
18103 inst
.instruction
|= 1;
18107 mve_encode_qqr (64, et
.size
== 32, 0);
18108 inst
.instruction
|= 0x3 << 5;
18115 enum neon_shape rs
= neon_select_shape (NS_QQQ
, NS_NULL
);
18116 struct neon_type_el et
18117 = neon_check_type (3, rs
, N_KEY
| N_I32
, N_EQK
, N_EQK
);
18119 if (et
.type
== NT_invtype
)
18120 first_error (BAD_EL_TYPE
);
18122 if (inst
.cond
> COND_ALWAYS
)
18123 inst
.pred_insn_type
= INSIDE_VPT_INSN
;
18125 inst
.pred_insn_type
= MVE_OUTSIDE_PRED_INSN
;
18127 mve_encode_qqq (0, 64);
18131 do_mve_vbrsr (void)
18133 enum neon_shape rs
= neon_select_shape (NS_QQR
, NS_NULL
);
18134 struct neon_type_el et
18135 = neon_check_type (3, rs
, N_EQK
, N_EQK
, N_8
| N_16
| N_32
| N_KEY
);
18137 if (inst
.cond
> COND_ALWAYS
)
18138 inst
.pred_insn_type
= INSIDE_VPT_INSN
;
18140 inst
.pred_insn_type
= MVE_OUTSIDE_PRED_INSN
;
18142 mve_encode_qqr (et
.size
, 0, 0);
18148 neon_check_type (3, NS_QQQ
, N_EQK
, N_EQK
, N_I32
| N_KEY
);
18150 if (inst
.cond
> COND_ALWAYS
)
18151 inst
.pred_insn_type
= INSIDE_VPT_INSN
;
18153 inst
.pred_insn_type
= MVE_OUTSIDE_PRED_INSN
;
18155 mve_encode_qqq (1, 64);
18159 do_mve_vmulh (void)
18161 enum neon_shape rs
= neon_select_shape (NS_QQQ
, NS_NULL
);
18162 struct neon_type_el et
18163 = neon_check_type (3, rs
, N_EQK
, N_EQK
, N_SU_MVE
| N_KEY
);
18165 if (inst
.cond
> COND_ALWAYS
)
18166 inst
.pred_insn_type
= INSIDE_VPT_INSN
;
18168 inst
.pred_insn_type
= MVE_OUTSIDE_PRED_INSN
;
18170 mve_encode_qqq (et
.type
== NT_unsigned
, et
.size
);
18174 do_mve_vqdmlah (void)
18176 enum neon_shape rs
= neon_select_shape (NS_QQR
, NS_NULL
);
18177 struct neon_type_el et
18178 = neon_check_type (3, rs
, N_EQK
, N_EQK
, N_S_32
| N_KEY
);
18180 if (inst
.cond
> COND_ALWAYS
)
18181 inst
.pred_insn_type
= INSIDE_VPT_INSN
;
18183 inst
.pred_insn_type
= MVE_OUTSIDE_PRED_INSN
;
18185 mve_encode_qqr (et
.size
, et
.type
== NT_unsigned
, 0);
18189 do_mve_vqdmladh (void)
18191 enum neon_shape rs
= neon_select_shape (NS_QQQ
, NS_NULL
);
18192 struct neon_type_el et
18193 = neon_check_type (3, rs
, N_EQK
, N_EQK
, N_S8
| N_S16
| N_S32
| N_KEY
);
18195 if (inst
.cond
> COND_ALWAYS
)
18196 inst
.pred_insn_type
= INSIDE_VPT_INSN
;
18198 inst
.pred_insn_type
= MVE_OUTSIDE_PRED_INSN
;
18200 mve_encode_qqq (0, et
.size
);
18205 do_mve_vmull (void)
18208 enum neon_shape rs
= neon_select_shape (NS_HHH
, NS_FFF
, NS_DDD
, NS_DDS
,
18209 NS_QQS
, NS_QQQ
, NS_QQR
, NS_NULL
);
18210 if (!ARM_CPU_HAS_FEATURE (cpu_variant
, mve_ext
)
18211 && inst
.cond
== COND_ALWAYS
18212 && ((unsigned)inst
.instruction
) == M_MNEM_vmullt
)
18217 struct neon_type_el et
= neon_check_type (3, rs
, N_EQK
, N_EQK
,
18218 N_SUF_32
| N_F64
| N_P8
18219 | N_P16
| N_I_MVE
| N_KEY
);
18220 if (((et
.type
== NT_poly
) && et
.size
== 8
18221 && ARM_CPU_IS_ANY (cpu_variant
))
18222 || (et
.type
== NT_integer
) || (et
.type
== NT_float
))
18229 constraint (rs
!= NS_QQQ
, BAD_FPU
);
18230 struct neon_type_el et
= neon_check_type (3, rs
, N_EQK
, N_EQK
,
18231 N_SU_32
| N_P8
| N_P16
| N_KEY
);
18233 /* We are dealing with MVE's vmullt. */
18235 && (inst
.operands
[0].reg
== inst
.operands
[1].reg
18236 || inst
.operands
[0].reg
== inst
.operands
[2].reg
))
18237 as_tsktsk (BAD_MVE_SRCDEST
);
18239 if (inst
.cond
> COND_ALWAYS
)
18240 inst
.pred_insn_type
= INSIDE_VPT_INSN
;
18242 inst
.pred_insn_type
= MVE_OUTSIDE_PRED_INSN
;
18244 if (et
.type
== NT_poly
)
18245 mve_encode_qqq (neon_logbits (et
.size
), 64);
18247 mve_encode_qqq (et
.type
== NT_unsigned
, et
.size
);
18252 inst
.instruction
= N_MNEM_vmul
;
18255 inst
.pred_insn_type
= INSIDE_IT_INSN
;
18260 do_mve_vabav (void)
18262 enum neon_shape rs
= neon_select_shape (NS_RQQ
, NS_NULL
);
18267 if (!ARM_CPU_HAS_FEATURE (cpu_variant
, mve_ext
))
18270 struct neon_type_el et
= neon_check_type (2, NS_NULL
, N_EQK
, N_KEY
| N_S8
18271 | N_S16
| N_S32
| N_U8
| N_U16
18274 if (inst
.cond
> COND_ALWAYS
)
18275 inst
.pred_insn_type
= INSIDE_VPT_INSN
;
18277 inst
.pred_insn_type
= MVE_OUTSIDE_PRED_INSN
;
18279 mve_encode_rqq (et
.type
== NT_unsigned
, et
.size
);
18283 do_mve_vmladav (void)
18285 enum neon_shape rs
= neon_select_shape (NS_RQQ
, NS_NULL
);
18286 struct neon_type_el et
= neon_check_type (3, rs
,
18287 N_EQK
, N_EQK
, N_SU_MVE
| N_KEY
);
18289 if (et
.type
== NT_unsigned
18290 && (inst
.instruction
== M_MNEM_vmladavx
18291 || inst
.instruction
== M_MNEM_vmladavax
18292 || inst
.instruction
== M_MNEM_vmlsdav
18293 || inst
.instruction
== M_MNEM_vmlsdava
18294 || inst
.instruction
== M_MNEM_vmlsdavx
18295 || inst
.instruction
== M_MNEM_vmlsdavax
))
18296 first_error (BAD_SIMD_TYPE
);
18298 constraint (inst
.operands
[2].reg
> 14,
18299 _("MVE vector register in the range [Q0..Q7] expected"));
18301 if (inst
.cond
> COND_ALWAYS
)
18302 inst
.pred_insn_type
= INSIDE_VPT_INSN
;
18304 inst
.pred_insn_type
= MVE_OUTSIDE_PRED_INSN
;
18306 if (inst
.instruction
== M_MNEM_vmlsdav
18307 || inst
.instruction
== M_MNEM_vmlsdava
18308 || inst
.instruction
== M_MNEM_vmlsdavx
18309 || inst
.instruction
== M_MNEM_vmlsdavax
)
18310 inst
.instruction
|= (et
.size
== 8) << 28;
18312 inst
.instruction
|= (et
.size
== 8) << 8;
18314 mve_encode_rqq (et
.type
== NT_unsigned
, 64);
18315 inst
.instruction
|= (et
.size
== 32) << 16;
18319 do_mve_vmlaldav (void)
18321 enum neon_shape rs
= neon_select_shape (NS_RRQQ
, NS_NULL
);
18322 struct neon_type_el et
18323 = neon_check_type (4, rs
, N_EQK
, N_EQK
, N_EQK
,
18324 N_S16
| N_S32
| N_U16
| N_U32
| N_KEY
);
18326 if (et
.type
== NT_unsigned
18327 && (inst
.instruction
== M_MNEM_vmlsldav
18328 || inst
.instruction
== M_MNEM_vmlsldava
18329 || inst
.instruction
== M_MNEM_vmlsldavx
18330 || inst
.instruction
== M_MNEM_vmlsldavax
))
18331 first_error (BAD_SIMD_TYPE
);
18333 if (inst
.cond
> COND_ALWAYS
)
18334 inst
.pred_insn_type
= INSIDE_VPT_INSN
;
18336 inst
.pred_insn_type
= MVE_OUTSIDE_PRED_INSN
;
18338 mve_encode_rrqq (et
.type
== NT_unsigned
, et
.size
);
18342 do_mve_vrmlaldavh (void)
18344 struct neon_type_el et
;
18345 if (inst
.instruction
== M_MNEM_vrmlsldavh
18346 || inst
.instruction
== M_MNEM_vrmlsldavha
18347 || inst
.instruction
== M_MNEM_vrmlsldavhx
18348 || inst
.instruction
== M_MNEM_vrmlsldavhax
)
18350 et
= neon_check_type (4, NS_RRQQ
, N_EQK
, N_EQK
, N_EQK
, N_S32
| N_KEY
);
18351 if (inst
.operands
[1].reg
== REG_SP
)
18352 as_tsktsk (MVE_BAD_SP
);
18356 if (inst
.instruction
== M_MNEM_vrmlaldavhx
18357 || inst
.instruction
== M_MNEM_vrmlaldavhax
)
18358 et
= neon_check_type (4, NS_RRQQ
, N_EQK
, N_EQK
, N_EQK
, N_S32
| N_KEY
);
18360 et
= neon_check_type (4, NS_RRQQ
, N_EQK
, N_EQK
, N_EQK
,
18361 N_U32
| N_S32
| N_KEY
);
18362 /* vrmlaldavh's encoding with SP as the second, odd, GPR operand may alias
18363 with vmax/min instructions, making the use of SP in assembly really
18364 nonsensical, so instead of issuing a warning like we do for other uses
18365 of SP for the odd register operand we error out. */
18366 constraint (inst
.operands
[1].reg
== REG_SP
, BAD_SP
);
18369 /* Make sure we still check the second operand is an odd one and that PC is
18370 disallowed. This because we are parsing for any GPR operand, to be able
18371 to distinguish between giving a warning or an error for SP as described
18373 constraint ((inst
.operands
[1].reg
% 2) != 1, BAD_EVEN
);
18374 constraint (inst
.operands
[1].reg
== REG_PC
, BAD_PC
);
18376 if (inst
.cond
> COND_ALWAYS
)
18377 inst
.pred_insn_type
= INSIDE_VPT_INSN
;
18379 inst
.pred_insn_type
= MVE_OUTSIDE_PRED_INSN
;
18381 mve_encode_rrqq (et
.type
== NT_unsigned
, 0);
18386 do_mve_vmaxnmv (void)
18388 enum neon_shape rs
= neon_select_shape (NS_RQ
, NS_NULL
);
18389 struct neon_type_el et
18390 = neon_check_type (2, rs
, N_EQK
, N_F_MVE
| N_KEY
);
18392 if (inst
.cond
> COND_ALWAYS
)
18393 inst
.pred_insn_type
= INSIDE_VPT_INSN
;
18395 inst
.pred_insn_type
= MVE_OUTSIDE_PRED_INSN
;
18397 if (inst
.operands
[0].reg
== REG_SP
)
18398 as_tsktsk (MVE_BAD_SP
);
18399 else if (inst
.operands
[0].reg
== REG_PC
)
18400 as_tsktsk (MVE_BAD_PC
);
18402 mve_encode_rq (et
.size
== 16, 64);
18406 do_mve_vmaxv (void)
18408 enum neon_shape rs
= neon_select_shape (NS_RQ
, NS_NULL
);
18409 struct neon_type_el et
;
18411 if (inst
.instruction
== M_MNEM_vmaxv
|| inst
.instruction
== M_MNEM_vminv
)
18412 et
= neon_check_type (2, rs
, N_EQK
, N_SU_MVE
| N_KEY
);
18414 et
= neon_check_type (2, rs
, N_EQK
, N_S8
| N_S16
| N_S32
| N_KEY
);
18416 if (inst
.cond
> COND_ALWAYS
)
18417 inst
.pred_insn_type
= INSIDE_VPT_INSN
;
18419 inst
.pred_insn_type
= MVE_OUTSIDE_PRED_INSN
;
18421 if (inst
.operands
[0].reg
== REG_SP
)
18422 as_tsktsk (MVE_BAD_SP
);
18423 else if (inst
.operands
[0].reg
== REG_PC
)
18424 as_tsktsk (MVE_BAD_PC
);
18426 mve_encode_rq (et
.type
== NT_unsigned
, et
.size
);
18431 do_neon_qrdmlah (void)
18433 if (!check_simd_pred_availability (FALSE
, NEON_CHECK_ARCH
| NEON_CHECK_CC
))
18435 if (!ARM_CPU_HAS_FEATURE (cpu_variant
, mve_ext
))
18437 /* Check we're on the correct architecture. */
18438 if (!mark_feature_used (&fpu_neon_ext_armv8
))
18440 = _("instruction form not available on this architecture.");
18441 else if (!mark_feature_used (&fpu_neon_ext_v8_1
))
18443 as_warn (_("this instruction implies use of ARMv8.1 AdvSIMD."));
18444 record_feature_use (&fpu_neon_ext_v8_1
);
18446 if (inst
.operands
[2].isscalar
)
18448 enum neon_shape rs
= neon_select_shape (NS_DDS
, NS_QQS
, NS_NULL
);
18449 struct neon_type_el et
= neon_check_type (3, rs
,
18450 N_EQK
, N_EQK
, N_S16
| N_S32
| N_KEY
);
18451 NEON_ENCODE (SCALAR
, inst
);
18452 neon_mul_mac (et
, neon_quad (rs
));
18456 enum neon_shape rs
= neon_select_shape (NS_DDD
, NS_QQQ
, NS_NULL
);
18457 struct neon_type_el et
= neon_check_type (3, rs
,
18458 N_EQK
, N_EQK
, N_S16
| N_S32
| N_KEY
);
18459 NEON_ENCODE (INTEGER
, inst
);
18460 /* The U bit (rounding) comes from bit mask. */
18461 neon_three_same (neon_quad (rs
), 0, et
.size
);
18466 enum neon_shape rs
= neon_select_shape (NS_QQR
, NS_NULL
);
18467 struct neon_type_el et
18468 = neon_check_type (3, rs
, N_EQK
, N_EQK
, N_S_32
| N_KEY
);
18470 NEON_ENCODE (INTEGER
, inst
);
18471 mve_encode_qqr (et
.size
, et
.type
== NT_unsigned
, 0);
18476 do_neon_fcmp_absolute (void)
18478 enum neon_shape rs
= neon_select_shape (NS_DDD
, NS_QQQ
, NS_NULL
);
18479 struct neon_type_el et
= neon_check_type (3, rs
, N_EQK
, N_EQK
,
18480 N_F_16_32
| N_KEY
);
18481 /* Size field comes from bit mask. */
18482 neon_three_same (neon_quad (rs
), 1, et
.size
== 16 ? (int) et
.size
: -1);
18486 do_neon_fcmp_absolute_inv (void)
18488 neon_exchange_operands ();
18489 do_neon_fcmp_absolute ();
18493 do_neon_step (void)
18495 enum neon_shape rs
= neon_select_shape (NS_DDD
, NS_QQQ
, NS_NULL
);
18496 struct neon_type_el et
= neon_check_type (3, rs
, N_EQK
, N_EQK
,
18497 N_F_16_32
| N_KEY
);
18498 neon_three_same (neon_quad (rs
), 0, et
.size
== 16 ? (int) et
.size
: -1);
18502 do_neon_abs_neg (void)
18504 enum neon_shape rs
;
18505 struct neon_type_el et
;
18507 if (try_vfp_nsyn (2, do_vfp_nsyn_abs_neg
) == SUCCESS
)
18510 rs
= neon_select_shape (NS_DD
, NS_QQ
, NS_NULL
);
18511 et
= neon_check_type (2, rs
, N_EQK
, N_S_32
| N_F_16_32
| N_KEY
);
18513 if (!check_simd_pred_availability (et
.type
== NT_float
,
18514 NEON_CHECK_ARCH
| NEON_CHECK_CC
))
18517 inst
.instruction
|= LOW4 (inst
.operands
[0].reg
) << 12;
18518 inst
.instruction
|= HI1 (inst
.operands
[0].reg
) << 22;
18519 inst
.instruction
|= LOW4 (inst
.operands
[1].reg
);
18520 inst
.instruction
|= HI1 (inst
.operands
[1].reg
) << 5;
18521 inst
.instruction
|= neon_quad (rs
) << 6;
18522 inst
.instruction
|= (et
.type
== NT_float
) << 10;
18523 inst
.instruction
|= neon_logbits (et
.size
) << 18;
18525 neon_dp_fixup (&inst
);
18531 if (!check_simd_pred_availability (FALSE
, NEON_CHECK_ARCH
| NEON_CHECK_CC
))
18534 enum neon_shape rs
;
18535 struct neon_type_el et
;
18536 if (ARM_CPU_HAS_FEATURE (cpu_variant
, mve_ext
))
18538 rs
= neon_select_shape (NS_QQI
, NS_NULL
);
18539 et
= neon_check_type (2, rs
, N_EQK
, N_8
| N_16
| N_32
| N_KEY
);
18543 rs
= neon_select_shape (NS_DDI
, NS_QQI
, NS_NULL
);
18544 et
= neon_check_type (2, rs
, N_EQK
, N_8
| N_16
| N_32
| N_64
| N_KEY
);
18548 int imm
= inst
.operands
[2].imm
;
18549 constraint (imm
< 0 || (unsigned)imm
>= et
.size
,
18550 _("immediate out of range for insert"));
18551 neon_imm_shift (FALSE
, 0, neon_quad (rs
), et
, imm
);
18557 if (!check_simd_pred_availability (FALSE
, NEON_CHECK_ARCH
| NEON_CHECK_CC
))
18560 enum neon_shape rs
;
18561 struct neon_type_el et
;
18562 if (ARM_CPU_HAS_FEATURE (cpu_variant
, mve_ext
))
18564 rs
= neon_select_shape (NS_QQI
, NS_NULL
);
18565 et
= neon_check_type (2, rs
, N_EQK
, N_8
| N_16
| N_32
| N_KEY
);
18569 rs
= neon_select_shape (NS_DDI
, NS_QQI
, NS_NULL
);
18570 et
= neon_check_type (2, rs
, N_EQK
, N_8
| N_16
| N_32
| N_64
| N_KEY
);
18573 int imm
= inst
.operands
[2].imm
;
18574 constraint (imm
< 1 || (unsigned)imm
> et
.size
,
18575 _("immediate out of range for insert"));
18576 neon_imm_shift (FALSE
, 0, neon_quad (rs
), et
, et
.size
- imm
);
18580 do_neon_qshlu_imm (void)
18582 if (!check_simd_pred_availability (FALSE
, NEON_CHECK_ARCH
| NEON_CHECK_CC
))
18585 enum neon_shape rs
;
18586 struct neon_type_el et
;
18587 if (ARM_CPU_HAS_FEATURE (cpu_variant
, mve_ext
))
18589 rs
= neon_select_shape (NS_QQI
, NS_NULL
);
18590 et
= neon_check_type (2, rs
, N_EQK
, N_S8
| N_S16
| N_S32
| N_KEY
);
18594 rs
= neon_select_shape (NS_DDI
, NS_QQI
, NS_NULL
);
18595 et
= neon_check_type (2, rs
, N_EQK
| N_UNS
,
18596 N_S8
| N_S16
| N_S32
| N_S64
| N_KEY
);
18599 int imm
= inst
.operands
[2].imm
;
18600 constraint (imm
< 0 || (unsigned)imm
>= et
.size
,
18601 _("immediate out of range for shift"));
18602 /* Only encodes the 'U present' variant of the instruction.
18603 In this case, signed types have OP (bit 8) set to 0.
18604 Unsigned types have OP set to 1. */
18605 inst
.instruction
|= (et
.type
== NT_unsigned
) << 8;
18606 /* The rest of the bits are the same as other immediate shifts. */
18607 neon_imm_shift (FALSE
, 0, neon_quad (rs
), et
, imm
);
18611 do_neon_qmovn (void)
18613 struct neon_type_el et
= neon_check_type (2, NS_DQ
,
18614 N_EQK
| N_HLF
, N_SU_16_64
| N_KEY
);
18615 /* Saturating move where operands can be signed or unsigned, and the
18616 destination has the same signedness. */
18617 NEON_ENCODE (INTEGER
, inst
);
18618 if (et
.type
== NT_unsigned
)
18619 inst
.instruction
|= 0xc0;
18621 inst
.instruction
|= 0x80;
18622 neon_two_same (0, 1, et
.size
/ 2);
18626 do_neon_qmovun (void)
18628 struct neon_type_el et
= neon_check_type (2, NS_DQ
,
18629 N_EQK
| N_HLF
| N_UNS
, N_S16
| N_S32
| N_S64
| N_KEY
);
18630 /* Saturating move with unsigned results. Operands must be signed. */
18631 NEON_ENCODE (INTEGER
, inst
);
18632 neon_two_same (0, 1, et
.size
/ 2);
18636 do_neon_rshift_sat_narrow (void)
18638 /* FIXME: Types for narrowing. If operands are signed, results can be signed
18639 or unsigned. If operands are unsigned, results must also be unsigned. */
18640 struct neon_type_el et
= neon_check_type (2, NS_DQI
,
18641 N_EQK
| N_HLF
, N_SU_16_64
| N_KEY
);
18642 int imm
= inst
.operands
[2].imm
;
18643 /* This gets the bounds check, size encoding and immediate bits calculation
18647 /* VQ{R}SHRN.I<size> <Dd>, <Qm>, #0 is a synonym for
18648 VQMOVN.I<size> <Dd>, <Qm>. */
18651 inst
.operands
[2].present
= 0;
18652 inst
.instruction
= N_MNEM_vqmovn
;
18657 constraint (imm
< 1 || (unsigned)imm
> et
.size
,
18658 _("immediate out of range"));
18659 neon_imm_shift (TRUE
, et
.type
== NT_unsigned
, 0, et
, et
.size
- imm
);
18663 do_neon_rshift_sat_narrow_u (void)
18665 /* FIXME: Types for narrowing. If operands are signed, results can be signed
18666 or unsigned. If operands are unsigned, results must also be unsigned. */
18667 struct neon_type_el et
= neon_check_type (2, NS_DQI
,
18668 N_EQK
| N_HLF
| N_UNS
, N_S16
| N_S32
| N_S64
| N_KEY
);
18669 int imm
= inst
.operands
[2].imm
;
18670 /* This gets the bounds check, size encoding and immediate bits calculation
18674 /* VQSHRUN.I<size> <Dd>, <Qm>, #0 is a synonym for
18675 VQMOVUN.I<size> <Dd>, <Qm>. */
18678 inst
.operands
[2].present
= 0;
18679 inst
.instruction
= N_MNEM_vqmovun
;
18684 constraint (imm
< 1 || (unsigned)imm
> et
.size
,
18685 _("immediate out of range"));
18686 /* FIXME: The manual is kind of unclear about what value U should have in
18687 VQ{R}SHRUN instructions, but U=0, op=0 definitely encodes VRSHR, so it
18689 neon_imm_shift (TRUE
, 1, 0, et
, et
.size
- imm
);
18693 do_neon_movn (void)
18695 struct neon_type_el et
= neon_check_type (2, NS_DQ
,
18696 N_EQK
| N_HLF
, N_I16
| N_I32
| N_I64
| N_KEY
);
18697 NEON_ENCODE (INTEGER
, inst
);
18698 neon_two_same (0, 1, et
.size
/ 2);
18702 do_neon_rshift_narrow (void)
18704 struct neon_type_el et
= neon_check_type (2, NS_DQI
,
18705 N_EQK
| N_HLF
, N_I16
| N_I32
| N_I64
| N_KEY
);
18706 int imm
= inst
.operands
[2].imm
;
18707 /* This gets the bounds check, size encoding and immediate bits calculation
18711 /* If immediate is zero then we are a pseudo-instruction for
18712 VMOVN.I<size> <Dd>, <Qm> */
18715 inst
.operands
[2].present
= 0;
18716 inst
.instruction
= N_MNEM_vmovn
;
18721 constraint (imm
< 1 || (unsigned)imm
> et
.size
,
18722 _("immediate out of range for narrowing operation"));
18723 neon_imm_shift (FALSE
, 0, 0, et
, et
.size
- imm
);
18727 do_neon_shll (void)
18729 /* FIXME: Type checking when lengthening. */
18730 struct neon_type_el et
= neon_check_type (2, NS_QDI
,
18731 N_EQK
| N_DBL
, N_I8
| N_I16
| N_I32
| N_KEY
);
18732 unsigned imm
= inst
.operands
[2].imm
;
18734 if (imm
== et
.size
)
18736 /* Maximum shift variant. */
18737 NEON_ENCODE (INTEGER
, inst
);
18738 inst
.instruction
|= LOW4 (inst
.operands
[0].reg
) << 12;
18739 inst
.instruction
|= HI1 (inst
.operands
[0].reg
) << 22;
18740 inst
.instruction
|= LOW4 (inst
.operands
[1].reg
);
18741 inst
.instruction
|= HI1 (inst
.operands
[1].reg
) << 5;
18742 inst
.instruction
|= neon_logbits (et
.size
) << 18;
18744 neon_dp_fixup (&inst
);
18748 /* A more-specific type check for non-max versions. */
18749 et
= neon_check_type (2, NS_QDI
,
18750 N_EQK
| N_DBL
, N_SU_32
| N_KEY
);
18751 NEON_ENCODE (IMMED
, inst
);
18752 neon_imm_shift (TRUE
, et
.type
== NT_unsigned
, 0, et
, imm
);
18756 /* Check the various types for the VCVT instruction, and return which version
18757 the current instruction is. */
18759 #define CVT_FLAVOUR_VAR \
18760 CVT_VAR (s32_f32, N_S32, N_F32, whole_reg, "ftosls", "ftosis", "ftosizs") \
18761 CVT_VAR (u32_f32, N_U32, N_F32, whole_reg, "ftouls", "ftouis", "ftouizs") \
18762 CVT_VAR (f32_s32, N_F32, N_S32, whole_reg, "fsltos", "fsitos", NULL) \
18763 CVT_VAR (f32_u32, N_F32, N_U32, whole_reg, "fultos", "fuitos", NULL) \
18764 /* Half-precision conversions. */ \
18765 CVT_VAR (s16_f16, N_S16, N_F16 | N_KEY, whole_reg, NULL, NULL, NULL) \
18766 CVT_VAR (u16_f16, N_U16, N_F16 | N_KEY, whole_reg, NULL, NULL, NULL) \
18767 CVT_VAR (f16_s16, N_F16 | N_KEY, N_S16, whole_reg, NULL, NULL, NULL) \
18768 CVT_VAR (f16_u16, N_F16 | N_KEY, N_U16, whole_reg, NULL, NULL, NULL) \
18769 CVT_VAR (f32_f16, N_F32, N_F16, whole_reg, NULL, NULL, NULL) \
18770 CVT_VAR (f16_f32, N_F16, N_F32, whole_reg, NULL, NULL, NULL) \
18771 /* New VCVT instructions introduced by ARMv8.2 fp16 extension. \
18772 Compared with single/double precision variants, only the co-processor \
18773 field is different, so the encoding flow is reused here. */ \
18774 CVT_VAR (f16_s32, N_F16 | N_KEY, N_S32, N_VFP, "fsltos", "fsitos", NULL) \
18775 CVT_VAR (f16_u32, N_F16 | N_KEY, N_U32, N_VFP, "fultos", "fuitos", NULL) \
18776 CVT_VAR (u32_f16, N_U32, N_F16 | N_KEY, N_VFP, "ftouls", "ftouis", "ftouizs")\
18777 CVT_VAR (s32_f16, N_S32, N_F16 | N_KEY, N_VFP, "ftosls", "ftosis", "ftosizs")\
18778 CVT_VAR (bf16_f32, N_BF16, N_F32, whole_reg, NULL, NULL, NULL) \
18779 /* VFP instructions. */ \
18780 CVT_VAR (f32_f64, N_F32, N_F64, N_VFP, NULL, "fcvtsd", NULL) \
18781 CVT_VAR (f64_f32, N_F64, N_F32, N_VFP, NULL, "fcvtds", NULL) \
18782 CVT_VAR (s32_f64, N_S32, N_F64 | key, N_VFP, "ftosld", "ftosid", "ftosizd") \
18783 CVT_VAR (u32_f64, N_U32, N_F64 | key, N_VFP, "ftould", "ftouid", "ftouizd") \
18784 CVT_VAR (f64_s32, N_F64 | key, N_S32, N_VFP, "fsltod", "fsitod", NULL) \
18785 CVT_VAR (f64_u32, N_F64 | key, N_U32, N_VFP, "fultod", "fuitod", NULL) \
18786 /* VFP instructions with bitshift. */ \
18787 CVT_VAR (f32_s16, N_F32 | key, N_S16, N_VFP, "fshtos", NULL, NULL) \
18788 CVT_VAR (f32_u16, N_F32 | key, N_U16, N_VFP, "fuhtos", NULL, NULL) \
18789 CVT_VAR (f64_s16, N_F64 | key, N_S16, N_VFP, "fshtod", NULL, NULL) \
18790 CVT_VAR (f64_u16, N_F64 | key, N_U16, N_VFP, "fuhtod", NULL, NULL) \
18791 CVT_VAR (s16_f32, N_S16, N_F32 | key, N_VFP, "ftoshs", NULL, NULL) \
18792 CVT_VAR (u16_f32, N_U16, N_F32 | key, N_VFP, "ftouhs", NULL, NULL) \
18793 CVT_VAR (s16_f64, N_S16, N_F64 | key, N_VFP, "ftoshd", NULL, NULL) \
18794 CVT_VAR (u16_f64, N_U16, N_F64 | key, N_VFP, "ftouhd", NULL, NULL)
18796 #define CVT_VAR(C, X, Y, R, BSN, CN, ZN) \
18797 neon_cvt_flavour_##C,
18799 /* The different types of conversions we can do. */
18800 enum neon_cvt_flavour
18803 neon_cvt_flavour_invalid
,
18804 neon_cvt_flavour_first_fp
= neon_cvt_flavour_f32_f64
18809 static enum neon_cvt_flavour
18810 get_neon_cvt_flavour (enum neon_shape rs
)
18812 #define CVT_VAR(C,X,Y,R,BSN,CN,ZN) \
18813 et = neon_check_type (2, rs, (R) | (X), (R) | (Y)); \
18814 if (et.type != NT_invtype) \
18816 inst.error = NULL; \
18817 return (neon_cvt_flavour_##C); \
18820 struct neon_type_el et
;
18821 unsigned whole_reg
= (rs
== NS_FFI
|| rs
== NS_FD
|| rs
== NS_DF
18822 || rs
== NS_FF
) ? N_VFP
: 0;
18823 /* The instruction versions which take an immediate take one register
18824 argument, which is extended to the width of the full register. Thus the
18825 "source" and "destination" registers must have the same width. Hack that
18826 here by making the size equal to the key (wider, in this case) operand. */
18827 unsigned key
= (rs
== NS_QQI
|| rs
== NS_DDI
|| rs
== NS_FFI
) ? N_KEY
: 0;
18831 return neon_cvt_flavour_invalid
;
18846 /* Neon-syntax VFP conversions. */
18849 do_vfp_nsyn_cvt (enum neon_shape rs
, enum neon_cvt_flavour flavour
)
18851 const char *opname
= 0;
18853 if (rs
== NS_DDI
|| rs
== NS_QQI
|| rs
== NS_FFI
18854 || rs
== NS_FHI
|| rs
== NS_HFI
)
18856 /* Conversions with immediate bitshift. */
18857 const char *enc
[] =
18859 #define CVT_VAR(C,A,B,R,BSN,CN,ZN) BSN,
18865 if (flavour
< (int) ARRAY_SIZE (enc
))
18867 opname
= enc
[flavour
];
18868 constraint (inst
.operands
[0].reg
!= inst
.operands
[1].reg
,
18869 _("operands 0 and 1 must be the same register"));
18870 inst
.operands
[1] = inst
.operands
[2];
18871 memset (&inst
.operands
[2], '\0', sizeof (inst
.operands
[2]));
18876 /* Conversions without bitshift. */
18877 const char *enc
[] =
18879 #define CVT_VAR(C,A,B,R,BSN,CN,ZN) CN,
18885 if (flavour
< (int) ARRAY_SIZE (enc
))
18886 opname
= enc
[flavour
];
18890 do_vfp_nsyn_opcode (opname
);
18892 /* ARMv8.2 fp16 VCVT instruction. */
18893 if (flavour
== neon_cvt_flavour_s32_f16
18894 || flavour
== neon_cvt_flavour_u32_f16
18895 || flavour
== neon_cvt_flavour_f16_u32
18896 || flavour
== neon_cvt_flavour_f16_s32
)
18897 do_scalar_fp16_v82_encode ();
18901 do_vfp_nsyn_cvtz (void)
18903 enum neon_shape rs
= neon_select_shape (NS_FH
, NS_FF
, NS_FD
, NS_NULL
);
18904 enum neon_cvt_flavour flavour
= get_neon_cvt_flavour (rs
);
18905 const char *enc
[] =
18907 #define CVT_VAR(C,A,B,R,BSN,CN,ZN) ZN,
18913 if (flavour
< (int) ARRAY_SIZE (enc
) && enc
[flavour
])
18914 do_vfp_nsyn_opcode (enc
[flavour
]);
18918 do_vfp_nsyn_cvt_fpv8 (enum neon_cvt_flavour flavour
,
18919 enum neon_cvt_mode mode
)
18924 /* Targets like FPv5-SP-D16 don't support FP v8 instructions with
18925 D register operands. */
18926 if (flavour
== neon_cvt_flavour_s32_f64
18927 || flavour
== neon_cvt_flavour_u32_f64
)
18928 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant
, fpu_vfp_ext_armv8
),
18931 if (flavour
== neon_cvt_flavour_s32_f16
18932 || flavour
== neon_cvt_flavour_u32_f16
)
18933 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant
, arm_ext_fp16
),
18936 set_pred_insn_type (OUTSIDE_PRED_INSN
);
18940 case neon_cvt_flavour_s32_f64
:
18944 case neon_cvt_flavour_s32_f32
:
18948 case neon_cvt_flavour_s32_f16
:
18952 case neon_cvt_flavour_u32_f64
:
18956 case neon_cvt_flavour_u32_f32
:
18960 case neon_cvt_flavour_u32_f16
:
18965 first_error (_("invalid instruction shape"));
18971 case neon_cvt_mode_a
: rm
= 0; break;
18972 case neon_cvt_mode_n
: rm
= 1; break;
18973 case neon_cvt_mode_p
: rm
= 2; break;
18974 case neon_cvt_mode_m
: rm
= 3; break;
18975 default: first_error (_("invalid rounding mode")); return;
18978 NEON_ENCODE (FPV8
, inst
);
18979 encode_arm_vfp_reg (inst
.operands
[0].reg
, VFP_REG_Sd
);
18980 encode_arm_vfp_reg (inst
.operands
[1].reg
, sz
== 1 ? VFP_REG_Dm
: VFP_REG_Sm
);
18981 inst
.instruction
|= sz
<< 8;
18983 /* ARMv8.2 fp16 VCVT instruction. */
18984 if (flavour
== neon_cvt_flavour_s32_f16
18985 ||flavour
== neon_cvt_flavour_u32_f16
)
18986 do_scalar_fp16_v82_encode ();
18987 inst
.instruction
|= op
<< 7;
18988 inst
.instruction
|= rm
<< 16;
18989 inst
.instruction
|= 0xf0000000;
18990 inst
.is_neon
= TRUE
;
18994 do_neon_cvt_1 (enum neon_cvt_mode mode
)
18996 enum neon_shape rs
= neon_select_shape (NS_DDI
, NS_QQI
, NS_FFI
, NS_DD
, NS_QQ
,
18997 NS_FD
, NS_DF
, NS_FF
, NS_QD
, NS_DQ
,
18998 NS_FH
, NS_HF
, NS_FHI
, NS_HFI
,
19000 enum neon_cvt_flavour flavour
= get_neon_cvt_flavour (rs
);
19002 if (flavour
== neon_cvt_flavour_invalid
)
19005 /* PR11109: Handle round-to-zero for VCVT conversions. */
19006 if (mode
== neon_cvt_mode_z
19007 && ARM_CPU_HAS_FEATURE (cpu_variant
, fpu_arch_vfp_v2
)
19008 && (flavour
== neon_cvt_flavour_s16_f16
19009 || flavour
== neon_cvt_flavour_u16_f16
19010 || flavour
== neon_cvt_flavour_s32_f32
19011 || flavour
== neon_cvt_flavour_u32_f32
19012 || flavour
== neon_cvt_flavour_s32_f64
19013 || flavour
== neon_cvt_flavour_u32_f64
)
19014 && (rs
== NS_FD
|| rs
== NS_FF
))
19016 do_vfp_nsyn_cvtz ();
19020 /* ARMv8.2 fp16 VCVT conversions. */
19021 if (mode
== neon_cvt_mode_z
19022 && ARM_CPU_HAS_FEATURE (cpu_variant
, arm_ext_fp16
)
19023 && (flavour
== neon_cvt_flavour_s32_f16
19024 || flavour
== neon_cvt_flavour_u32_f16
)
19027 do_vfp_nsyn_cvtz ();
19028 do_scalar_fp16_v82_encode ();
19032 /* VFP rather than Neon conversions. */
19033 if (flavour
>= neon_cvt_flavour_first_fp
)
19035 if (mode
== neon_cvt_mode_x
|| mode
== neon_cvt_mode_z
)
19036 do_vfp_nsyn_cvt (rs
, flavour
);
19038 do_vfp_nsyn_cvt_fpv8 (flavour
, mode
);
19046 if (mode
== neon_cvt_mode_z
19047 && (flavour
== neon_cvt_flavour_f16_s16
19048 || flavour
== neon_cvt_flavour_f16_u16
19049 || flavour
== neon_cvt_flavour_s16_f16
19050 || flavour
== neon_cvt_flavour_u16_f16
19051 || flavour
== neon_cvt_flavour_f32_u32
19052 || flavour
== neon_cvt_flavour_f32_s32
19053 || flavour
== neon_cvt_flavour_s32_f32
19054 || flavour
== neon_cvt_flavour_u32_f32
))
19056 if (!check_simd_pred_availability (TRUE
,
19057 NEON_CHECK_CC
| NEON_CHECK_ARCH
))
19060 else if (mode
== neon_cvt_mode_n
)
19062 /* We are dealing with vcvt with the 'ne' condition. */
19064 inst
.instruction
= N_MNEM_vcvt
;
19065 do_neon_cvt_1 (neon_cvt_mode_z
);
19068 /* fall through. */
19072 unsigned enctab
[] = {0x0000100, 0x1000100, 0x0, 0x1000000,
19073 0x0000100, 0x1000100, 0x0, 0x1000000};
19075 if ((rs
!= NS_QQI
|| !ARM_CPU_HAS_FEATURE (cpu_variant
, mve_fp_ext
))
19076 && vfp_or_neon_is_neon (NEON_CHECK_CC
| NEON_CHECK_ARCH
) == FAIL
)
19079 if (ARM_CPU_HAS_FEATURE (cpu_variant
, mve_fp_ext
))
19081 constraint (inst
.operands
[2].present
&& inst
.operands
[2].imm
== 0,
19082 _("immediate value out of range"));
19085 case neon_cvt_flavour_f16_s16
:
19086 case neon_cvt_flavour_f16_u16
:
19087 case neon_cvt_flavour_s16_f16
:
19088 case neon_cvt_flavour_u16_f16
:
19089 constraint (inst
.operands
[2].imm
> 16,
19090 _("immediate value out of range"));
19092 case neon_cvt_flavour_f32_u32
:
19093 case neon_cvt_flavour_f32_s32
:
19094 case neon_cvt_flavour_s32_f32
:
19095 case neon_cvt_flavour_u32_f32
:
19096 constraint (inst
.operands
[2].imm
> 32,
19097 _("immediate value out of range"));
19100 inst
.error
= BAD_FPU
;
19105 /* Fixed-point conversion with #0 immediate is encoded as an
19106 integer conversion. */
19107 if (inst
.operands
[2].present
&& inst
.operands
[2].imm
== 0)
19109 NEON_ENCODE (IMMED
, inst
);
19110 if (flavour
!= neon_cvt_flavour_invalid
)
19111 inst
.instruction
|= enctab
[flavour
];
19112 inst
.instruction
|= LOW4 (inst
.operands
[0].reg
) << 12;
19113 inst
.instruction
|= HI1 (inst
.operands
[0].reg
) << 22;
19114 inst
.instruction
|= LOW4 (inst
.operands
[1].reg
);
19115 inst
.instruction
|= HI1 (inst
.operands
[1].reg
) << 5;
19116 inst
.instruction
|= neon_quad (rs
) << 6;
19117 inst
.instruction
|= 1 << 21;
19118 if (flavour
< neon_cvt_flavour_s16_f16
)
19120 inst
.instruction
|= 1 << 21;
19121 immbits
= 32 - inst
.operands
[2].imm
;
19122 inst
.instruction
|= immbits
<< 16;
19126 inst
.instruction
|= 3 << 20;
19127 immbits
= 16 - inst
.operands
[2].imm
;
19128 inst
.instruction
|= immbits
<< 16;
19129 inst
.instruction
&= ~(1 << 9);
19132 neon_dp_fixup (&inst
);
19137 if ((mode
== neon_cvt_mode_a
|| mode
== neon_cvt_mode_n
19138 || mode
== neon_cvt_mode_m
|| mode
== neon_cvt_mode_p
)
19139 && (flavour
== neon_cvt_flavour_s16_f16
19140 || flavour
== neon_cvt_flavour_u16_f16
19141 || flavour
== neon_cvt_flavour_s32_f32
19142 || flavour
== neon_cvt_flavour_u32_f32
))
19144 if (!check_simd_pred_availability (TRUE
,
19145 NEON_CHECK_CC
| NEON_CHECK_ARCH8
))
19148 else if (mode
== neon_cvt_mode_z
19149 && (flavour
== neon_cvt_flavour_f16_s16
19150 || flavour
== neon_cvt_flavour_f16_u16
19151 || flavour
== neon_cvt_flavour_s16_f16
19152 || flavour
== neon_cvt_flavour_u16_f16
19153 || flavour
== neon_cvt_flavour_f32_u32
19154 || flavour
== neon_cvt_flavour_f32_s32
19155 || flavour
== neon_cvt_flavour_s32_f32
19156 || flavour
== neon_cvt_flavour_u32_f32
))
19158 if (!check_simd_pred_availability (TRUE
,
19159 NEON_CHECK_CC
| NEON_CHECK_ARCH
))
19162 /* fall through. */
19164 if (mode
!= neon_cvt_mode_x
&& mode
!= neon_cvt_mode_z
)
19167 NEON_ENCODE (FLOAT
, inst
);
19168 if (!check_simd_pred_availability (TRUE
,
19169 NEON_CHECK_CC
| NEON_CHECK_ARCH8
))
19172 inst
.instruction
|= LOW4 (inst
.operands
[0].reg
) << 12;
19173 inst
.instruction
|= HI1 (inst
.operands
[0].reg
) << 22;
19174 inst
.instruction
|= LOW4 (inst
.operands
[1].reg
);
19175 inst
.instruction
|= HI1 (inst
.operands
[1].reg
) << 5;
19176 inst
.instruction
|= neon_quad (rs
) << 6;
19177 inst
.instruction
|= (flavour
== neon_cvt_flavour_u16_f16
19178 || flavour
== neon_cvt_flavour_u32_f32
) << 7;
19179 inst
.instruction
|= mode
<< 8;
19180 if (flavour
== neon_cvt_flavour_u16_f16
19181 || flavour
== neon_cvt_flavour_s16_f16
)
19182 /* Mask off the original size bits and reencode them. */
19183 inst
.instruction
= ((inst
.instruction
& 0xfff3ffff) | (1 << 18));
19186 inst
.instruction
|= 0xfc000000;
19188 inst
.instruction
|= 0xf0000000;
19194 unsigned enctab
[] = { 0x100, 0x180, 0x0, 0x080,
19195 0x100, 0x180, 0x0, 0x080};
19197 NEON_ENCODE (INTEGER
, inst
);
19199 if (!ARM_CPU_HAS_FEATURE (cpu_variant
, mve_fp_ext
))
19201 if (vfp_or_neon_is_neon (NEON_CHECK_CC
| NEON_CHECK_ARCH
) == FAIL
)
19205 if (flavour
!= neon_cvt_flavour_invalid
)
19206 inst
.instruction
|= enctab
[flavour
];
19208 inst
.instruction
|= LOW4 (inst
.operands
[0].reg
) << 12;
19209 inst
.instruction
|= HI1 (inst
.operands
[0].reg
) << 22;
19210 inst
.instruction
|= LOW4 (inst
.operands
[1].reg
);
19211 inst
.instruction
|= HI1 (inst
.operands
[1].reg
) << 5;
19212 inst
.instruction
|= neon_quad (rs
) << 6;
19213 if (flavour
>= neon_cvt_flavour_s16_f16
19214 && flavour
<= neon_cvt_flavour_f16_u16
)
19215 /* Half precision. */
19216 inst
.instruction
|= 1 << 18;
19218 inst
.instruction
|= 2 << 18;
19220 neon_dp_fixup (&inst
);
19225 /* Half-precision conversions for Advanced SIMD -- neon. */
19228 if (vfp_or_neon_is_neon (NEON_CHECK_CC
| NEON_CHECK_ARCH
) == FAIL
)
19232 && (inst
.vectype
.el
[0].size
!= 16 || inst
.vectype
.el
[1].size
!= 32))
19234 as_bad (_("operand size must match register width"));
19239 && ((inst
.vectype
.el
[0].size
!= 32 || inst
.vectype
.el
[1].size
!= 16)))
19241 as_bad (_("operand size must match register width"));
19247 if (flavour
== neon_cvt_flavour_bf16_f32
)
19249 if (vfp_or_neon_is_neon (NEON_CHECK_ARCH8
) == FAIL
)
19251 constraint (!mark_feature_used (&arm_ext_bf16
), _(BAD_BF16
));
19252 /* VCVT.bf16.f32. */
19253 inst
.instruction
= 0x11b60640;
19256 /* VCVT.f16.f32. */
19257 inst
.instruction
= 0x3b60600;
19260 /* VCVT.f32.f16. */
19261 inst
.instruction
= 0x3b60700;
19263 inst
.instruction
|= LOW4 (inst
.operands
[0].reg
) << 12;
19264 inst
.instruction
|= HI1 (inst
.operands
[0].reg
) << 22;
19265 inst
.instruction
|= LOW4 (inst
.operands
[1].reg
);
19266 inst
.instruction
|= HI1 (inst
.operands
[1].reg
) << 5;
19267 neon_dp_fixup (&inst
);
19271 /* Some VFP conversions go here (s32 <-> f32, u32 <-> f32). */
19272 if (mode
== neon_cvt_mode_x
|| mode
== neon_cvt_mode_z
)
19273 do_vfp_nsyn_cvt (rs
, flavour
);
19275 do_vfp_nsyn_cvt_fpv8 (flavour
, mode
);
19280 do_neon_cvtr (void)
19282 do_neon_cvt_1 (neon_cvt_mode_x
);
19288 do_neon_cvt_1 (neon_cvt_mode_z
);
19292 do_neon_cvta (void)
19294 do_neon_cvt_1 (neon_cvt_mode_a
);
19298 do_neon_cvtn (void)
19300 do_neon_cvt_1 (neon_cvt_mode_n
);
19304 do_neon_cvtp (void)
19306 do_neon_cvt_1 (neon_cvt_mode_p
);
19310 do_neon_cvtm (void)
19312 do_neon_cvt_1 (neon_cvt_mode_m
);
19316 do_neon_cvttb_2 (bfd_boolean t
, bfd_boolean to
, bfd_boolean is_double
)
19319 mark_feature_used (&fpu_vfp_ext_armv8
);
19321 encode_arm_vfp_reg (inst
.operands
[0].reg
,
19322 (is_double
&& !to
) ? VFP_REG_Dd
: VFP_REG_Sd
);
19323 encode_arm_vfp_reg (inst
.operands
[1].reg
,
19324 (is_double
&& to
) ? VFP_REG_Dm
: VFP_REG_Sm
);
19325 inst
.instruction
|= to
? 0x10000 : 0;
19326 inst
.instruction
|= t
? 0x80 : 0;
19327 inst
.instruction
|= is_double
? 0x100 : 0;
19328 do_vfp_cond_or_thumb ();
19332 do_neon_cvttb_1 (bfd_boolean t
)
19334 enum neon_shape rs
= neon_select_shape (NS_HF
, NS_HD
, NS_FH
, NS_FF
, NS_FD
,
19335 NS_DF
, NS_DH
, NS_QQ
, NS_QQI
, NS_NULL
);
19339 else if (rs
== NS_QQ
|| rs
== NS_QQI
)
19341 int single_to_half
= 0;
19342 if (!check_simd_pred_availability (TRUE
, NEON_CHECK_ARCH
))
19345 enum neon_cvt_flavour flavour
= get_neon_cvt_flavour (rs
);
19347 if (ARM_CPU_HAS_FEATURE (cpu_variant
, mve_ext
)
19348 && (flavour
== neon_cvt_flavour_u16_f16
19349 || flavour
== neon_cvt_flavour_s16_f16
19350 || flavour
== neon_cvt_flavour_f16_s16
19351 || flavour
== neon_cvt_flavour_f16_u16
19352 || flavour
== neon_cvt_flavour_u32_f32
19353 || flavour
== neon_cvt_flavour_s32_f32
19354 || flavour
== neon_cvt_flavour_f32_s32
19355 || flavour
== neon_cvt_flavour_f32_u32
))
19358 inst
.instruction
= N_MNEM_vcvt
;
19359 set_pred_insn_type (INSIDE_VPT_INSN
);
19360 do_neon_cvt_1 (neon_cvt_mode_z
);
19363 else if (rs
== NS_QQ
&& flavour
== neon_cvt_flavour_f32_f16
)
19364 single_to_half
= 1;
19365 else if (rs
== NS_QQ
&& flavour
!= neon_cvt_flavour_f16_f32
)
19367 first_error (BAD_FPU
);
19371 inst
.instruction
= 0xee3f0e01;
19372 inst
.instruction
|= single_to_half
<< 28;
19373 inst
.instruction
|= HI1 (inst
.operands
[0].reg
) << 22;
19374 inst
.instruction
|= LOW4 (inst
.operands
[0].reg
) << 13;
19375 inst
.instruction
|= t
<< 12;
19376 inst
.instruction
|= HI1 (inst
.operands
[1].reg
) << 5;
19377 inst
.instruction
|= LOW4 (inst
.operands
[1].reg
) << 1;
19380 else if (neon_check_type (2, rs
, N_F16
, N_F32
| N_VFP
).type
!= NT_invtype
)
19383 do_neon_cvttb_2 (t
, /*to=*/TRUE
, /*is_double=*/FALSE
);
19385 else if (neon_check_type (2, rs
, N_F32
| N_VFP
, N_F16
).type
!= NT_invtype
)
19388 do_neon_cvttb_2 (t
, /*to=*/FALSE
, /*is_double=*/FALSE
);
19390 else if (neon_check_type (2, rs
, N_F16
, N_F64
| N_VFP
).type
!= NT_invtype
)
19392 /* The VCVTB and VCVTT instructions with D-register operands
19393 don't work for SP only targets. */
19394 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant
, fpu_vfp_ext_armv8
),
19398 do_neon_cvttb_2 (t
, /*to=*/TRUE
, /*is_double=*/TRUE
);
19400 else if (neon_check_type (2, rs
, N_F64
| N_VFP
, N_F16
).type
!= NT_invtype
)
19402 /* The VCVTB and VCVTT instructions with D-register operands
19403 don't work for SP only targets. */
19404 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant
, fpu_vfp_ext_armv8
),
19408 do_neon_cvttb_2 (t
, /*to=*/FALSE
, /*is_double=*/TRUE
);
19410 else if (neon_check_type (2, rs
, N_BF16
| N_VFP
, N_F32
).type
!= NT_invtype
)
19412 constraint (!mark_feature_used (&arm_ext_bf16
), _(BAD_BF16
));
19414 inst
.instruction
|= (1 << 8);
19415 inst
.instruction
&= ~(1 << 9);
19416 do_neon_cvttb_2 (t
, /*to=*/TRUE
, /*is_double=*/FALSE
);
19423 do_neon_cvtb (void)
19425 do_neon_cvttb_1 (FALSE
);
19430 do_neon_cvtt (void)
19432 do_neon_cvttb_1 (TRUE
);
19436 neon_move_immediate (void)
19438 enum neon_shape rs
= neon_select_shape (NS_DI
, NS_QI
, NS_NULL
);
19439 struct neon_type_el et
= neon_check_type (2, rs
,
19440 N_I8
| N_I16
| N_I32
| N_I64
| N_F32
| N_KEY
, N_EQK
);
19441 unsigned immlo
, immhi
= 0, immbits
;
19442 int op
, cmode
, float_p
;
19444 constraint (et
.type
== NT_invtype
,
19445 _("operand size must be specified for immediate VMOV"));
19447 /* We start out as an MVN instruction if OP = 1, MOV otherwise. */
19448 op
= (inst
.instruction
& (1 << 5)) != 0;
19450 immlo
= inst
.operands
[1].imm
;
19451 if (inst
.operands
[1].regisimm
)
19452 immhi
= inst
.operands
[1].reg
;
19454 constraint (et
.size
< 32 && (immlo
& ~((1 << et
.size
) - 1)) != 0,
19455 _("immediate has bits set outside the operand size"));
19457 float_p
= inst
.operands
[1].immisfloat
;
19459 if ((cmode
= neon_cmode_for_move_imm (immlo
, immhi
, float_p
, &immbits
, &op
,
19460 et
.size
, et
.type
)) == FAIL
)
19462 /* Invert relevant bits only. */
19463 neon_invert_size (&immlo
, &immhi
, et
.size
);
19464 /* Flip from VMOV/VMVN to VMVN/VMOV. Some immediate types are unavailable
19465 with one or the other; those cases are caught by
19466 neon_cmode_for_move_imm. */
19468 if ((cmode
= neon_cmode_for_move_imm (immlo
, immhi
, float_p
, &immbits
,
19469 &op
, et
.size
, et
.type
)) == FAIL
)
19471 first_error (_("immediate out of range"));
19476 inst
.instruction
&= ~(1 << 5);
19477 inst
.instruction
|= op
<< 5;
19479 inst
.instruction
|= LOW4 (inst
.operands
[0].reg
) << 12;
19480 inst
.instruction
|= HI1 (inst
.operands
[0].reg
) << 22;
19481 inst
.instruction
|= neon_quad (rs
) << 6;
19482 inst
.instruction
|= cmode
<< 8;
19484 neon_write_immbits (immbits
);
19490 if (!check_simd_pred_availability (FALSE
, NEON_CHECK_CC
| NEON_CHECK_ARCH
))
19493 if (inst
.operands
[1].isreg
)
19495 enum neon_shape rs
;
19496 if (ARM_CPU_HAS_FEATURE (cpu_variant
, mve_ext
))
19497 rs
= neon_select_shape (NS_QQ
, NS_NULL
);
19499 rs
= neon_select_shape (NS_DD
, NS_QQ
, NS_NULL
);
19501 NEON_ENCODE (INTEGER
, inst
);
19502 inst
.instruction
|= LOW4 (inst
.operands
[0].reg
) << 12;
19503 inst
.instruction
|= HI1 (inst
.operands
[0].reg
) << 22;
19504 inst
.instruction
|= LOW4 (inst
.operands
[1].reg
);
19505 inst
.instruction
|= HI1 (inst
.operands
[1].reg
) << 5;
19506 inst
.instruction
|= neon_quad (rs
) << 6;
19510 NEON_ENCODE (IMMED
, inst
);
19511 neon_move_immediate ();
19514 neon_dp_fixup (&inst
);
19516 if (ARM_CPU_HAS_FEATURE (cpu_variant
, mve_ext
))
19518 constraint (!inst
.operands
[1].isreg
&& !inst
.operands
[0].isquad
, BAD_FPU
);
19522 /* Encode instructions of form:
19524 |28/24|23|22|21 20|19 16|15 12|11 8|7|6|5|4|3 0|
19525 | U |x |D |size | Rn | Rd |x x x x|N|x|M|x| Rm | */
19528 neon_mixed_length (struct neon_type_el et
, unsigned size
)
19530 inst
.instruction
|= LOW4 (inst
.operands
[0].reg
) << 12;
19531 inst
.instruction
|= HI1 (inst
.operands
[0].reg
) << 22;
19532 inst
.instruction
|= LOW4 (inst
.operands
[1].reg
) << 16;
19533 inst
.instruction
|= HI1 (inst
.operands
[1].reg
) << 7;
19534 inst
.instruction
|= LOW4 (inst
.operands
[2].reg
);
19535 inst
.instruction
|= HI1 (inst
.operands
[2].reg
) << 5;
19536 inst
.instruction
|= (et
.type
== NT_unsigned
) << 24;
19537 inst
.instruction
|= neon_logbits (size
) << 20;
19539 neon_dp_fixup (&inst
);
19543 do_neon_dyadic_long (void)
19545 enum neon_shape rs
= neon_select_shape (NS_QDD
, NS_QQQ
, NS_QQR
, NS_NULL
);
19548 if (vfp_or_neon_is_neon (NEON_CHECK_ARCH
| NEON_CHECK_CC
) == FAIL
)
19551 NEON_ENCODE (INTEGER
, inst
);
19552 /* FIXME: Type checking for lengthening op. */
19553 struct neon_type_el et
= neon_check_type (3, NS_QDD
,
19554 N_EQK
| N_DBL
, N_EQK
, N_SU_32
| N_KEY
);
19555 neon_mixed_length (et
, et
.size
);
19557 else if (ARM_CPU_HAS_FEATURE (cpu_variant
, mve_ext
)
19558 && (inst
.cond
== 0xf || inst
.cond
== 0x10))
19560 /* If parsing for MVE, vaddl/vsubl/vabdl{e,t} can only be vadd/vsub/vabd
19561 in an IT block with le/lt conditions. */
19563 if (inst
.cond
== 0xf)
19565 else if (inst
.cond
== 0x10)
19568 inst
.pred_insn_type
= INSIDE_IT_INSN
;
19570 if (inst
.instruction
== N_MNEM_vaddl
)
19572 inst
.instruction
= N_MNEM_vadd
;
19573 do_neon_addsub_if_i ();
19575 else if (inst
.instruction
== N_MNEM_vsubl
)
19577 inst
.instruction
= N_MNEM_vsub
;
19578 do_neon_addsub_if_i ();
19580 else if (inst
.instruction
== N_MNEM_vabdl
)
19582 inst
.instruction
= N_MNEM_vabd
;
19583 do_neon_dyadic_if_su ();
19587 first_error (BAD_FPU
);
19591 do_neon_abal (void)
19593 struct neon_type_el et
= neon_check_type (3, NS_QDD
,
19594 N_EQK
| N_INT
| N_DBL
, N_EQK
, N_SU_32
| N_KEY
);
19595 neon_mixed_length (et
, et
.size
);
19599 neon_mac_reg_scalar_long (unsigned regtypes
, unsigned scalartypes
)
19601 if (inst
.operands
[2].isscalar
)
19603 struct neon_type_el et
= neon_check_type (3, NS_QDS
,
19604 N_EQK
| N_DBL
, N_EQK
, regtypes
| N_KEY
);
19605 NEON_ENCODE (SCALAR
, inst
);
19606 neon_mul_mac (et
, et
.type
== NT_unsigned
);
19610 struct neon_type_el et
= neon_check_type (3, NS_QDD
,
19611 N_EQK
| N_DBL
, N_EQK
, scalartypes
| N_KEY
);
19612 NEON_ENCODE (INTEGER
, inst
);
19613 neon_mixed_length (et
, et
.size
);
19618 do_neon_mac_maybe_scalar_long (void)
19620 neon_mac_reg_scalar_long (N_S16
| N_S32
| N_U16
| N_U32
, N_SU_32
);
19623 /* Like neon_scalar_for_mul, this function generate Rm encoding from GAS's
19624 internal SCALAR. QUAD_P is 1 if it's for Q format, otherwise it's 0. */
19627 neon_scalar_for_fmac_fp16_long (unsigned scalar
, unsigned quad_p
)
19629 unsigned regno
= NEON_SCALAR_REG (scalar
);
19630 unsigned elno
= NEON_SCALAR_INDEX (scalar
);
19634 if (regno
> 7 || elno
> 3)
19637 return ((regno
& 0x7)
19638 | ((elno
& 0x1) << 3)
19639 | (((elno
>> 1) & 0x1) << 5));
19643 if (regno
> 15 || elno
> 1)
19646 return (((regno
& 0x1) << 5)
19647 | ((regno
>> 1) & 0x7)
19648 | ((elno
& 0x1) << 3));
19652 first_error (_("scalar out of range for multiply instruction"));
19657 do_neon_fmac_maybe_scalar_long (int subtype
)
19659 enum neon_shape rs
;
19661 /* NOTE: vfmal/vfmsl use slightly different NEON three-same encoding. 'size"
19662 field (bits[21:20]) has different meaning. For scalar index variant, it's
19663 used to differentiate add and subtract, otherwise it's with fixed value
19667 /* vfmal/vfmsl are in three-same D/Q register format or the third operand can
19668 be a scalar index register. */
19669 if (inst
.operands
[2].isscalar
)
19671 high8
= 0xfe000000;
19674 rs
= neon_select_shape (NS_DHS
, NS_QDS
, NS_NULL
);
19678 high8
= 0xfc000000;
19681 inst
.instruction
|= (0x1 << 23);
19682 rs
= neon_select_shape (NS_DHH
, NS_QDD
, NS_NULL
);
19686 if (inst
.cond
!= COND_ALWAYS
)
19687 as_warn (_("vfmal/vfmsl with FP16 type cannot be conditional, the "
19688 "behaviour is UNPREDICTABLE"));
19690 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant
, arm_ext_fp16_fml
),
19693 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant
, fpu_neon_ext_armv8
),
19696 /* "opcode" from template has included "ubit", so simply pass 0 here. Also,
19697 the "S" bit in size field has been reused to differentiate vfmal and vfmsl,
19698 so we simply pass -1 as size. */
19699 unsigned quad_p
= (rs
== NS_QDD
|| rs
== NS_QDS
);
19700 neon_three_same (quad_p
, 0, size
);
19702 /* Undo neon_dp_fixup. Redo the high eight bits. */
19703 inst
.instruction
&= 0x00ffffff;
19704 inst
.instruction
|= high8
;
19706 #define LOW1(R) ((R) & 0x1)
19707 #define HI4(R) (((R) >> 1) & 0xf)
19708 /* Unlike usually NEON three-same, encoding for Vn and Vm will depend on
19709 whether the instruction is in Q form and whether Vm is a scalar indexed
19711 if (inst
.operands
[2].isscalar
)
19714 = neon_scalar_for_fmac_fp16_long (inst
.operands
[2].reg
, quad_p
);
19715 inst
.instruction
&= 0xffffffd0;
19716 inst
.instruction
|= rm
;
19720 /* Redo Rn as well. */
19721 inst
.instruction
&= 0xfff0ff7f;
19722 inst
.instruction
|= HI4 (inst
.operands
[1].reg
) << 16;
19723 inst
.instruction
|= LOW1 (inst
.operands
[1].reg
) << 7;
19728 /* Redo Rn and Rm. */
19729 inst
.instruction
&= 0xfff0ff50;
19730 inst
.instruction
|= HI4 (inst
.operands
[1].reg
) << 16;
19731 inst
.instruction
|= LOW1 (inst
.operands
[1].reg
) << 7;
19732 inst
.instruction
|= HI4 (inst
.operands
[2].reg
);
19733 inst
.instruction
|= LOW1 (inst
.operands
[2].reg
) << 5;
19738 do_neon_vfmal (void)
19740 return do_neon_fmac_maybe_scalar_long (0);
19744 do_neon_vfmsl (void)
19746 return do_neon_fmac_maybe_scalar_long (1);
19750 do_neon_dyadic_wide (void)
19752 struct neon_type_el et
= neon_check_type (3, NS_QQD
,
19753 N_EQK
| N_DBL
, N_EQK
| N_DBL
, N_SU_32
| N_KEY
);
19754 neon_mixed_length (et
, et
.size
);
19758 do_neon_dyadic_narrow (void)
19760 struct neon_type_el et
= neon_check_type (3, NS_QDD
,
19761 N_EQK
| N_DBL
, N_EQK
, N_I16
| N_I32
| N_I64
| N_KEY
);
19762 /* Operand sign is unimportant, and the U bit is part of the opcode,
19763 so force the operand type to integer. */
19764 et
.type
= NT_integer
;
19765 neon_mixed_length (et
, et
.size
/ 2);
19769 do_neon_mul_sat_scalar_long (void)
19771 neon_mac_reg_scalar_long (N_S16
| N_S32
, N_S16
| N_S32
);
19775 do_neon_vmull (void)
19777 if (inst
.operands
[2].isscalar
)
19778 do_neon_mac_maybe_scalar_long ();
19781 struct neon_type_el et
= neon_check_type (3, NS_QDD
,
19782 N_EQK
| N_DBL
, N_EQK
, N_SU_32
| N_P8
| N_P64
| N_KEY
);
19784 if (et
.type
== NT_poly
)
19785 NEON_ENCODE (POLY
, inst
);
19787 NEON_ENCODE (INTEGER
, inst
);
19789 /* For polynomial encoding the U bit must be zero, and the size must
19790 be 8 (encoded as 0b00) or, on ARMv8 or later 64 (encoded, non
19791 obviously, as 0b10). */
19794 /* Check we're on the correct architecture. */
19795 if (!mark_feature_used (&fpu_crypto_ext_armv8
))
19797 _("Instruction form not available on this architecture.");
19802 neon_mixed_length (et
, et
.size
);
19809 enum neon_shape rs
= neon_select_shape (NS_DDDI
, NS_QQQI
, NS_NULL
);
19810 struct neon_type_el et
= neon_check_type (3, rs
,
19811 N_EQK
, N_EQK
, N_8
| N_16
| N_32
| N_64
| N_KEY
);
19812 unsigned imm
= (inst
.operands
[3].imm
* et
.size
) / 8;
19814 constraint (imm
>= (unsigned) (neon_quad (rs
) ? 16 : 8),
19815 _("shift out of range"));
19816 inst
.instruction
|= LOW4 (inst
.operands
[0].reg
) << 12;
19817 inst
.instruction
|= HI1 (inst
.operands
[0].reg
) << 22;
19818 inst
.instruction
|= LOW4 (inst
.operands
[1].reg
) << 16;
19819 inst
.instruction
|= HI1 (inst
.operands
[1].reg
) << 7;
19820 inst
.instruction
|= LOW4 (inst
.operands
[2].reg
);
19821 inst
.instruction
|= HI1 (inst
.operands
[2].reg
) << 5;
19822 inst
.instruction
|= neon_quad (rs
) << 6;
19823 inst
.instruction
|= imm
<< 8;
19825 neon_dp_fixup (&inst
);
19831 if (!check_simd_pred_availability (FALSE
, NEON_CHECK_ARCH
| NEON_CHECK_CC
))
19834 enum neon_shape rs
;
19835 if (ARM_CPU_HAS_FEATURE (cpu_variant
, mve_ext
))
19836 rs
= neon_select_shape (NS_QQ
, NS_NULL
);
19838 rs
= neon_select_shape (NS_DD
, NS_QQ
, NS_NULL
);
19840 struct neon_type_el et
= neon_check_type (2, rs
,
19841 N_EQK
, N_8
| N_16
| N_32
| N_KEY
);
19843 unsigned op
= (inst
.instruction
>> 7) & 3;
19844 /* N (width of reversed regions) is encoded as part of the bitmask. We
19845 extract it here to check the elements to be reversed are smaller.
19846 Otherwise we'd get a reserved instruction. */
19847 unsigned elsize
= (op
== 2) ? 16 : (op
== 1) ? 32 : (op
== 0) ? 64 : 0;
19849 if (ARM_CPU_HAS_FEATURE (cpu_variant
, mve_ext
) && elsize
== 64
19850 && inst
.operands
[0].reg
== inst
.operands
[1].reg
)
19851 as_tsktsk (_("Warning: 64-bit element size and same destination and source"
19852 " operands makes instruction UNPREDICTABLE"));
19854 gas_assert (elsize
!= 0);
19855 constraint (et
.size
>= elsize
,
19856 _("elements must be smaller than reversal region"));
19857 neon_two_same (neon_quad (rs
), 1, et
.size
);
19863 if (inst
.operands
[1].isscalar
)
19865 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant
, fpu_neon_ext_v1
),
19867 enum neon_shape rs
= neon_select_shape (NS_DS
, NS_QS
, NS_NULL
);
19868 struct neon_type_el et
= neon_check_type (2, rs
,
19869 N_EQK
, N_8
| N_16
| N_32
| N_KEY
);
19870 unsigned sizebits
= et
.size
>> 3;
19871 unsigned dm
= NEON_SCALAR_REG (inst
.operands
[1].reg
);
19872 int logsize
= neon_logbits (et
.size
);
19873 unsigned x
= NEON_SCALAR_INDEX (inst
.operands
[1].reg
) << logsize
;
19875 if (vfp_or_neon_is_neon (NEON_CHECK_CC
) == FAIL
)
19878 NEON_ENCODE (SCALAR
, inst
);
19879 inst
.instruction
|= LOW4 (inst
.operands
[0].reg
) << 12;
19880 inst
.instruction
|= HI1 (inst
.operands
[0].reg
) << 22;
19881 inst
.instruction
|= LOW4 (dm
);
19882 inst
.instruction
|= HI1 (dm
) << 5;
19883 inst
.instruction
|= neon_quad (rs
) << 6;
19884 inst
.instruction
|= x
<< 17;
19885 inst
.instruction
|= sizebits
<< 16;
19887 neon_dp_fixup (&inst
);
19891 enum neon_shape rs
= neon_select_shape (NS_DR
, NS_QR
, NS_NULL
);
19892 struct neon_type_el et
= neon_check_type (2, rs
,
19893 N_8
| N_16
| N_32
| N_KEY
, N_EQK
);
19896 if (!check_simd_pred_availability (FALSE
, NEON_CHECK_ARCH
))
19900 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant
, fpu_neon_ext_v1
),
19903 if (ARM_CPU_HAS_FEATURE (cpu_variant
, mve_ext
))
19905 if (inst
.operands
[1].reg
== REG_SP
)
19906 as_tsktsk (MVE_BAD_SP
);
19907 else if (inst
.operands
[1].reg
== REG_PC
)
19908 as_tsktsk (MVE_BAD_PC
);
19911 /* Duplicate ARM register to lanes of vector. */
19912 NEON_ENCODE (ARMREG
, inst
);
19915 case 8: inst
.instruction
|= 0x400000; break;
19916 case 16: inst
.instruction
|= 0x000020; break;
19917 case 32: inst
.instruction
|= 0x000000; break;
19920 inst
.instruction
|= LOW4 (inst
.operands
[1].reg
) << 12;
19921 inst
.instruction
|= LOW4 (inst
.operands
[0].reg
) << 16;
19922 inst
.instruction
|= HI1 (inst
.operands
[0].reg
) << 7;
19923 inst
.instruction
|= neon_quad (rs
) << 21;
19924 /* The encoding for this instruction is identical for the ARM and Thumb
19925 variants, except for the condition field. */
19926 do_vfp_cond_or_thumb ();
19931 do_mve_mov (int toQ
)
19933 if (!ARM_CPU_HAS_FEATURE (cpu_variant
, mve_ext
))
19935 if (inst
.cond
> COND_ALWAYS
)
19936 inst
.pred_insn_type
= MVE_UNPREDICABLE_INSN
;
19938 unsigned Rt
= 0, Rt2
= 1, Q0
= 2, Q1
= 3;
19947 constraint (inst
.operands
[Q0
].reg
!= inst
.operands
[Q1
].reg
+ 2,
19948 _("Index one must be [2,3] and index two must be two less than"
19950 constraint (inst
.operands
[Rt
].reg
== inst
.operands
[Rt2
].reg
,
19951 _("General purpose registers may not be the same"));
19952 constraint (inst
.operands
[Rt
].reg
== REG_SP
19953 || inst
.operands
[Rt2
].reg
== REG_SP
,
19955 constraint (inst
.operands
[Rt
].reg
== REG_PC
19956 || inst
.operands
[Rt2
].reg
== REG_PC
,
19959 inst
.instruction
= 0xec000f00;
19960 inst
.instruction
|= HI1 (inst
.operands
[Q1
].reg
/ 32) << 23;
19961 inst
.instruction
|= !!toQ
<< 20;
19962 inst
.instruction
|= inst
.operands
[Rt2
].reg
<< 16;
19963 inst
.instruction
|= LOW4 (inst
.operands
[Q1
].reg
/ 32) << 13;
19964 inst
.instruction
|= (inst
.operands
[Q1
].reg
% 4) << 4;
19965 inst
.instruction
|= inst
.operands
[Rt
].reg
;
19971 if (!ARM_CPU_HAS_FEATURE (cpu_variant
, mve_ext
))
19974 if (inst
.cond
> COND_ALWAYS
)
19975 inst
.pred_insn_type
= INSIDE_VPT_INSN
;
19977 inst
.pred_insn_type
= MVE_OUTSIDE_PRED_INSN
;
19979 struct neon_type_el et
= neon_check_type (2, NS_QQ
, N_EQK
, N_I16
| N_I32
19982 inst
.instruction
|= HI1 (inst
.operands
[0].reg
) << 22;
19983 inst
.instruction
|= (neon_logbits (et
.size
) - 1) << 18;
19984 inst
.instruction
|= LOW4 (inst
.operands
[0].reg
) << 12;
19985 inst
.instruction
|= HI1 (inst
.operands
[1].reg
) << 5;
19986 inst
.instruction
|= LOW4 (inst
.operands
[1].reg
);
19991 /* VMOV has particularly many variations. It can be one of:
19992 0. VMOV<c><q> <Qd>, <Qm>
19993 1. VMOV<c><q> <Dd>, <Dm>
19994 (Register operations, which are VORR with Rm = Rn.)
19995 2. VMOV<c><q>.<dt> <Qd>, #<imm>
19996 3. VMOV<c><q>.<dt> <Dd>, #<imm>
19998 4. VMOV<c><q>.<size> <Dn[x]>, <Rd>
19999 (ARM register to scalar.)
20000 5. VMOV<c><q> <Dm>, <Rd>, <Rn>
20001 (Two ARM registers to vector.)
20002 6. VMOV<c><q>.<dt> <Rd>, <Dn[x]>
20003 (Scalar to ARM register.)
20004 7. VMOV<c><q> <Rd>, <Rn>, <Dm>
20005 (Vector to two ARM registers.)
20006 8. VMOV.F32 <Sd>, <Sm>
20007 9. VMOV.F64 <Dd>, <Dm>
20008 (VFP register moves.)
20009 10. VMOV.F32 <Sd>, #imm
20010 11. VMOV.F64 <Dd>, #imm
20011 (VFP float immediate load.)
20012 12. VMOV <Rd>, <Sm>
20013 (VFP single to ARM reg.)
20014 13. VMOV <Sd>, <Rm>
20015 (ARM reg to VFP single.)
20016 14. VMOV <Rd>, <Re>, <Sn>, <Sm>
20017 (Two ARM regs to two VFP singles.)
20018 15. VMOV <Sd>, <Se>, <Rn>, <Rm>
20019 (Two VFP singles to two ARM regs.)
20020 16. VMOV<c> <Rt>, <Rt2>, <Qd[idx]>, <Qd[idx2]>
20021 17. VMOV<c> <Qd[idx]>, <Qd[idx2]>, <Rt>, <Rt2>
20022 18. VMOV<c>.<dt> <Rt>, <Qn[idx]>
20023 19. VMOV<c>.<dt> <Qd[idx]>, <Rt>
20025 These cases can be disambiguated using neon_select_shape, except cases 1/9
20026 and 3/11 which depend on the operand type too.
20028 All the encoded bits are hardcoded by this function.
20030 Cases 4, 6 may be used with VFPv1 and above (only 32-bit transfers!).
20031 Cases 5, 7 may be used with VFPv2 and above.
20033 FIXME: Some of the checking may be a bit sloppy (in a couple of cases you
20034 can specify a type where it doesn't make sense to, and is ignored). */
20039 enum neon_shape rs
= neon_select_shape (NS_RRSS
, NS_SSRR
, NS_RRFF
, NS_FFRR
,
20040 NS_DRR
, NS_RRD
, NS_QQ
, NS_DD
, NS_QI
,
20041 NS_DI
, NS_SR
, NS_RS
, NS_FF
, NS_FI
,
20042 NS_RF
, NS_FR
, NS_HR
, NS_RH
, NS_HI
,
20044 struct neon_type_el et
;
20045 const char *ldconst
= 0;
20049 case NS_DD
: /* case 1/9. */
20050 et
= neon_check_type (2, rs
, N_EQK
, N_F64
| N_KEY
);
20051 /* It is not an error here if no type is given. */
20054 /* In MVE we interpret the following instructions as same, so ignoring
20055 the following type (float) and size (64) checks.
20056 a: VMOV<c><q> <Dd>, <Dm>
20057 b: VMOV<c><q>.F64 <Dd>, <Dm>. */
20058 if ((et
.type
== NT_float
&& et
.size
== 64)
20059 || (ARM_CPU_HAS_FEATURE (cpu_variant
, mve_ext
)))
20061 do_vfp_nsyn_opcode ("fcpyd");
20064 /* fall through. */
20066 case NS_QQ
: /* case 0/1. */
20068 if (!check_simd_pred_availability (FALSE
,
20069 NEON_CHECK_CC
| NEON_CHECK_ARCH
))
20071 /* The architecture manual I have doesn't explicitly state which
20072 value the U bit should have for register->register moves, but
20073 the equivalent VORR instruction has U = 0, so do that. */
20074 inst
.instruction
= 0x0200110;
20075 inst
.instruction
|= LOW4 (inst
.operands
[0].reg
) << 12;
20076 inst
.instruction
|= HI1 (inst
.operands
[0].reg
) << 22;
20077 inst
.instruction
|= LOW4 (inst
.operands
[1].reg
);
20078 inst
.instruction
|= HI1 (inst
.operands
[1].reg
) << 5;
20079 inst
.instruction
|= LOW4 (inst
.operands
[1].reg
) << 16;
20080 inst
.instruction
|= HI1 (inst
.operands
[1].reg
) << 7;
20081 inst
.instruction
|= neon_quad (rs
) << 6;
20083 neon_dp_fixup (&inst
);
20087 case NS_DI
: /* case 3/11. */
20088 et
= neon_check_type (2, rs
, N_EQK
, N_F64
| N_KEY
);
20090 if (et
.type
== NT_float
&& et
.size
== 64)
20092 /* case 11 (fconstd). */
20093 ldconst
= "fconstd";
20094 goto encode_fconstd
;
20096 /* fall through. */
20098 case NS_QI
: /* case 2/3. */
20099 if (!check_simd_pred_availability (FALSE
,
20100 NEON_CHECK_CC
| NEON_CHECK_ARCH
))
20102 inst
.instruction
= 0x0800010;
20103 neon_move_immediate ();
20104 neon_dp_fixup (&inst
);
20107 case NS_SR
: /* case 4. */
20109 unsigned bcdebits
= 0;
20111 unsigned dn
= NEON_SCALAR_REG (inst
.operands
[0].reg
);
20112 unsigned x
= NEON_SCALAR_INDEX (inst
.operands
[0].reg
);
20114 /* .<size> is optional here, defaulting to .32. */
20115 if (inst
.vectype
.elems
== 0
20116 && inst
.operands
[0].vectype
.type
== NT_invtype
20117 && inst
.operands
[1].vectype
.type
== NT_invtype
)
20119 inst
.vectype
.el
[0].type
= NT_untyped
;
20120 inst
.vectype
.el
[0].size
= 32;
20121 inst
.vectype
.elems
= 1;
20124 et
= neon_check_type (2, NS_NULL
, N_8
| N_16
| N_32
| N_KEY
, N_EQK
);
20125 logsize
= neon_logbits (et
.size
);
20129 if (!ARM_CPU_HAS_FEATURE (cpu_variant
, mve_ext
)
20130 && vfp_or_neon_is_neon (NEON_CHECK_ARCH
) == FAIL
)
20135 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant
, fpu_vfp_ext_v1
)
20136 && !ARM_CPU_HAS_FEATURE (cpu_variant
, mve_ext
),
20140 if (ARM_CPU_HAS_FEATURE (cpu_variant
, mve_ext
))
20142 if (inst
.operands
[1].reg
== REG_SP
)
20143 as_tsktsk (MVE_BAD_SP
);
20144 else if (inst
.operands
[1].reg
== REG_PC
)
20145 as_tsktsk (MVE_BAD_PC
);
20147 unsigned size
= inst
.operands
[0].isscalar
== 1 ? 64 : 128;
20149 constraint (et
.type
== NT_invtype
, _("bad type for scalar"));
20150 constraint (x
>= size
/ et
.size
, _("scalar index out of range"));
20155 case 8: bcdebits
= 0x8; break;
20156 case 16: bcdebits
= 0x1; break;
20157 case 32: bcdebits
= 0x0; break;
20161 bcdebits
|= (x
& ((1 << (3-logsize
)) - 1)) << logsize
;
20163 inst
.instruction
= 0xe000b10;
20164 do_vfp_cond_or_thumb ();
20165 inst
.instruction
|= LOW4 (dn
) << 16;
20166 inst
.instruction
|= HI1 (dn
) << 7;
20167 inst
.instruction
|= inst
.operands
[1].reg
<< 12;
20168 inst
.instruction
|= (bcdebits
& 3) << 5;
20169 inst
.instruction
|= ((bcdebits
>> 2) & 3) << 21;
20170 inst
.instruction
|= (x
>> (3-logsize
)) << 16;
20174 case NS_DRR
: /* case 5 (fmdrr). */
20175 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant
, fpu_vfp_ext_v2
)
20176 && !ARM_CPU_HAS_FEATURE (cpu_variant
, mve_ext
),
20179 inst
.instruction
= 0xc400b10;
20180 do_vfp_cond_or_thumb ();
20181 inst
.instruction
|= LOW4 (inst
.operands
[0].reg
);
20182 inst
.instruction
|= HI1 (inst
.operands
[0].reg
) << 5;
20183 inst
.instruction
|= inst
.operands
[1].reg
<< 12;
20184 inst
.instruction
|= inst
.operands
[2].reg
<< 16;
20187 case NS_RS
: /* case 6. */
20190 unsigned dn
= NEON_SCALAR_REG (inst
.operands
[1].reg
);
20191 unsigned x
= NEON_SCALAR_INDEX (inst
.operands
[1].reg
);
20192 unsigned abcdebits
= 0;
20194 /* .<dt> is optional here, defaulting to .32. */
20195 if (inst
.vectype
.elems
== 0
20196 && inst
.operands
[0].vectype
.type
== NT_invtype
20197 && inst
.operands
[1].vectype
.type
== NT_invtype
)
20199 inst
.vectype
.el
[0].type
= NT_untyped
;
20200 inst
.vectype
.el
[0].size
= 32;
20201 inst
.vectype
.elems
= 1;
20204 et
= neon_check_type (2, NS_NULL
,
20205 N_EQK
, N_S8
| N_S16
| N_U8
| N_U16
| N_32
| N_KEY
);
20206 logsize
= neon_logbits (et
.size
);
20210 if (!ARM_CPU_HAS_FEATURE (cpu_variant
, mve_ext
)
20211 && vfp_or_neon_is_neon (NEON_CHECK_CC
20212 | NEON_CHECK_ARCH
) == FAIL
)
20217 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant
, fpu_vfp_ext_v1
)
20218 && !ARM_CPU_HAS_FEATURE (cpu_variant
, mve_ext
),
20222 if (ARM_CPU_HAS_FEATURE (cpu_variant
, mve_ext
))
20224 if (inst
.operands
[0].reg
== REG_SP
)
20225 as_tsktsk (MVE_BAD_SP
);
20226 else if (inst
.operands
[0].reg
== REG_PC
)
20227 as_tsktsk (MVE_BAD_PC
);
20230 unsigned size
= inst
.operands
[1].isscalar
== 1 ? 64 : 128;
20232 constraint (et
.type
== NT_invtype
, _("bad type for scalar"));
20233 constraint (x
>= size
/ et
.size
, _("scalar index out of range"));
20237 case 8: abcdebits
= (et
.type
== NT_signed
) ? 0x08 : 0x18; break;
20238 case 16: abcdebits
= (et
.type
== NT_signed
) ? 0x01 : 0x11; break;
20239 case 32: abcdebits
= 0x00; break;
20243 abcdebits
|= (x
& ((1 << (3-logsize
)) - 1)) << logsize
;
20244 inst
.instruction
= 0xe100b10;
20245 do_vfp_cond_or_thumb ();
20246 inst
.instruction
|= LOW4 (dn
) << 16;
20247 inst
.instruction
|= HI1 (dn
) << 7;
20248 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
20249 inst
.instruction
|= (abcdebits
& 3) << 5;
20250 inst
.instruction
|= (abcdebits
>> 2) << 21;
20251 inst
.instruction
|= (x
>> (3-logsize
)) << 16;
20255 case NS_RRD
: /* case 7 (fmrrd). */
20256 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant
, fpu_vfp_ext_v2
)
20257 && !ARM_CPU_HAS_FEATURE (cpu_variant
, mve_ext
),
20260 inst
.instruction
= 0xc500b10;
20261 do_vfp_cond_or_thumb ();
20262 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
20263 inst
.instruction
|= inst
.operands
[1].reg
<< 16;
20264 inst
.instruction
|= LOW4 (inst
.operands
[2].reg
);
20265 inst
.instruction
|= HI1 (inst
.operands
[2].reg
) << 5;
20268 case NS_FF
: /* case 8 (fcpys). */
20269 do_vfp_nsyn_opcode ("fcpys");
20273 case NS_FI
: /* case 10 (fconsts). */
20274 ldconst
= "fconsts";
20276 if (!inst
.operands
[1].immisfloat
)
20279 /* Immediate has to fit in 8 bits so float is enough. */
20280 float imm
= (float) inst
.operands
[1].imm
;
20281 memcpy (&new_imm
, &imm
, sizeof (float));
20282 /* But the assembly may have been written to provide an integer
20283 bit pattern that equates to a float, so check that the
20284 conversion has worked. */
20285 if (is_quarter_float (new_imm
))
20287 if (is_quarter_float (inst
.operands
[1].imm
))
20288 as_warn (_("immediate constant is valid both as a bit-pattern and a floating point value (using the fp value)"));
20290 inst
.operands
[1].imm
= new_imm
;
20291 inst
.operands
[1].immisfloat
= 1;
20295 if (is_quarter_float (inst
.operands
[1].imm
))
20297 inst
.operands
[1].imm
= neon_qfloat_bits (inst
.operands
[1].imm
);
20298 do_vfp_nsyn_opcode (ldconst
);
20300 /* ARMv8.2 fp16 vmov.f16 instruction. */
20302 do_scalar_fp16_v82_encode ();
20305 first_error (_("immediate out of range"));
20309 case NS_RF
: /* case 12 (fmrs). */
20310 do_vfp_nsyn_opcode ("fmrs");
20311 /* ARMv8.2 fp16 vmov.f16 instruction. */
20313 do_scalar_fp16_v82_encode ();
20317 case NS_FR
: /* case 13 (fmsr). */
20318 do_vfp_nsyn_opcode ("fmsr");
20319 /* ARMv8.2 fp16 vmov.f16 instruction. */
20321 do_scalar_fp16_v82_encode ();
20331 /* The encoders for the fmrrs and fmsrr instructions expect three operands
20332 (one of which is a list), but we have parsed four. Do some fiddling to
20333 make the operands what do_vfp_reg2_from_sp2 and do_vfp_sp2_from_reg2
20335 case NS_RRFF
: /* case 14 (fmrrs). */
20336 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant
, fpu_vfp_ext_v2
)
20337 && !ARM_CPU_HAS_FEATURE (cpu_variant
, mve_ext
),
20339 constraint (inst
.operands
[3].reg
!= inst
.operands
[2].reg
+ 1,
20340 _("VFP registers must be adjacent"));
20341 inst
.operands
[2].imm
= 2;
20342 memset (&inst
.operands
[3], '\0', sizeof (inst
.operands
[3]));
20343 do_vfp_nsyn_opcode ("fmrrs");
20346 case NS_FFRR
: /* case 15 (fmsrr). */
20347 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant
, fpu_vfp_ext_v2
)
20348 && !ARM_CPU_HAS_FEATURE (cpu_variant
, mve_ext
),
20350 constraint (inst
.operands
[1].reg
!= inst
.operands
[0].reg
+ 1,
20351 _("VFP registers must be adjacent"));
20352 inst
.operands
[1] = inst
.operands
[2];
20353 inst
.operands
[2] = inst
.operands
[3];
20354 inst
.operands
[0].imm
= 2;
20355 memset (&inst
.operands
[3], '\0', sizeof (inst
.operands
[3]));
20356 do_vfp_nsyn_opcode ("fmsrr");
20360 /* neon_select_shape has determined that the instruction
20361 shape is wrong and has already set the error message. */
20372 if (!(inst
.operands
[0].present
&& inst
.operands
[0].isquad
20373 && inst
.operands
[1].present
&& inst
.operands
[1].isquad
20374 && !inst
.operands
[2].present
))
20376 inst
.instruction
= 0;
20379 set_pred_insn_type (INSIDE_IT_INSN
);
20384 if (!ARM_CPU_HAS_FEATURE (cpu_variant
, mve_ext
))
20387 if (inst
.cond
!= COND_ALWAYS
)
20388 inst
.pred_insn_type
= INSIDE_VPT_INSN
;
20390 struct neon_type_el et
= neon_check_type (2, NS_QQ
, N_EQK
, N_S8
| N_U8
20391 | N_S16
| N_U16
| N_KEY
);
20393 inst
.instruction
|= (et
.type
== NT_unsigned
) << 28;
20394 inst
.instruction
|= HI1 (inst
.operands
[0].reg
) << 22;
20395 inst
.instruction
|= (neon_logbits (et
.size
) + 1) << 19;
20396 inst
.instruction
|= LOW4 (inst
.operands
[0].reg
) << 12;
20397 inst
.instruction
|= HI1 (inst
.operands
[1].reg
) << 5;
20398 inst
.instruction
|= LOW4 (inst
.operands
[1].reg
);
20403 do_neon_rshift_round_imm (void)
20405 if (!check_simd_pred_availability (FALSE
, NEON_CHECK_ARCH
| NEON_CHECK_CC
))
20408 enum neon_shape rs
;
20409 struct neon_type_el et
;
20411 if (ARM_CPU_HAS_FEATURE (cpu_variant
, mve_ext
))
20413 rs
= neon_select_shape (NS_QQI
, NS_NULL
);
20414 et
= neon_check_type (2, rs
, N_EQK
, N_SU_MVE
| N_KEY
);
20418 rs
= neon_select_shape (NS_DDI
, NS_QQI
, NS_NULL
);
20419 et
= neon_check_type (2, rs
, N_EQK
, N_SU_ALL
| N_KEY
);
20421 int imm
= inst
.operands
[2].imm
;
20423 /* imm == 0 case is encoded as VMOV for V{R}SHR. */
20426 inst
.operands
[2].present
= 0;
20431 constraint (imm
< 1 || (unsigned)imm
> et
.size
,
20432 _("immediate out of range for shift"));
20433 neon_imm_shift (TRUE
, et
.type
== NT_unsigned
, neon_quad (rs
), et
,
20438 do_neon_movhf (void)
20440 enum neon_shape rs
= neon_select_shape (NS_HH
, NS_NULL
);
20441 constraint (rs
!= NS_HH
, _("invalid suffix"));
20443 if (inst
.cond
!= COND_ALWAYS
)
20447 as_warn (_("ARMv8.2 scalar fp16 instruction cannot be conditional,"
20448 " the behaviour is UNPREDICTABLE"));
20452 inst
.error
= BAD_COND
;
20457 do_vfp_sp_monadic ();
20460 inst
.instruction
|= 0xf0000000;
20464 do_neon_movl (void)
20466 struct neon_type_el et
= neon_check_type (2, NS_QD
,
20467 N_EQK
| N_DBL
, N_SU_32
| N_KEY
);
20468 unsigned sizebits
= et
.size
>> 3;
20469 inst
.instruction
|= sizebits
<< 19;
20470 neon_two_same (0, et
.type
== NT_unsigned
, -1);
20476 enum neon_shape rs
= neon_select_shape (NS_DD
, NS_QQ
, NS_NULL
);
20477 struct neon_type_el et
= neon_check_type (2, rs
,
20478 N_EQK
, N_8
| N_16
| N_32
| N_KEY
);
20479 NEON_ENCODE (INTEGER
, inst
);
20480 neon_two_same (neon_quad (rs
), 1, et
.size
);
20484 do_neon_zip_uzp (void)
20486 enum neon_shape rs
= neon_select_shape (NS_DD
, NS_QQ
, NS_NULL
);
20487 struct neon_type_el et
= neon_check_type (2, rs
,
20488 N_EQK
, N_8
| N_16
| N_32
| N_KEY
);
20489 if (rs
== NS_DD
&& et
.size
== 32)
20491 /* Special case: encode as VTRN.32 <Dd>, <Dm>. */
20492 inst
.instruction
= N_MNEM_vtrn
;
20496 neon_two_same (neon_quad (rs
), 1, et
.size
);
20500 do_neon_sat_abs_neg (void)
20502 if (!check_simd_pred_availability (FALSE
, NEON_CHECK_CC
| NEON_CHECK_ARCH
))
20505 enum neon_shape rs
;
20506 if (ARM_CPU_HAS_FEATURE (cpu_variant
, mve_ext
))
20507 rs
= neon_select_shape (NS_QQ
, NS_NULL
);
20509 rs
= neon_select_shape (NS_DD
, NS_QQ
, NS_NULL
);
20510 struct neon_type_el et
= neon_check_type (2, rs
,
20511 N_EQK
, N_S8
| N_S16
| N_S32
| N_KEY
);
20512 neon_two_same (neon_quad (rs
), 1, et
.size
);
20516 do_neon_pair_long (void)
20518 enum neon_shape rs
= neon_select_shape (NS_DD
, NS_QQ
, NS_NULL
);
20519 struct neon_type_el et
= neon_check_type (2, rs
, N_EQK
, N_SU_32
| N_KEY
);
20520 /* Unsigned is encoded in OP field (bit 7) for these instruction. */
20521 inst
.instruction
|= (et
.type
== NT_unsigned
) << 7;
20522 neon_two_same (neon_quad (rs
), 1, et
.size
);
20526 do_neon_recip_est (void)
20528 enum neon_shape rs
= neon_select_shape (NS_DD
, NS_QQ
, NS_NULL
);
20529 struct neon_type_el et
= neon_check_type (2, rs
,
20530 N_EQK
| N_FLT
, N_F_16_32
| N_U32
| N_KEY
);
20531 inst
.instruction
|= (et
.type
== NT_float
) << 8;
20532 neon_two_same (neon_quad (rs
), 1, et
.size
);
20538 if (!check_simd_pred_availability (FALSE
, NEON_CHECK_ARCH
| NEON_CHECK_CC
))
20541 enum neon_shape rs
;
20542 if (ARM_CPU_HAS_FEATURE (cpu_variant
, mve_ext
))
20543 rs
= neon_select_shape (NS_QQ
, NS_NULL
);
20545 rs
= neon_select_shape (NS_DD
, NS_QQ
, NS_NULL
);
20547 struct neon_type_el et
= neon_check_type (2, rs
,
20548 N_EQK
, N_S8
| N_S16
| N_S32
| N_KEY
);
20549 neon_two_same (neon_quad (rs
), 1, et
.size
);
20555 if (!check_simd_pred_availability (FALSE
, NEON_CHECK_ARCH
| NEON_CHECK_CC
))
20558 enum neon_shape rs
;
20559 if (ARM_CPU_HAS_FEATURE (cpu_variant
, mve_ext
))
20560 rs
= neon_select_shape (NS_QQ
, NS_NULL
);
20562 rs
= neon_select_shape (NS_DD
, NS_QQ
, NS_NULL
);
20564 struct neon_type_el et
= neon_check_type (2, rs
,
20565 N_EQK
, N_I8
| N_I16
| N_I32
| N_KEY
);
20566 neon_two_same (neon_quad (rs
), 1, et
.size
);
20572 enum neon_shape rs
= neon_select_shape (NS_DD
, NS_QQ
, NS_NULL
);
20573 struct neon_type_el et
= neon_check_type (2, rs
,
20574 N_EQK
| N_INT
, N_8
| N_KEY
);
20575 neon_two_same (neon_quad (rs
), 1, et
.size
);
20581 enum neon_shape rs
= neon_select_shape (NS_DD
, NS_QQ
, NS_NULL
);
20582 neon_two_same (neon_quad (rs
), 1, -1);
20586 do_neon_tbl_tbx (void)
20588 unsigned listlenbits
;
20589 neon_check_type (3, NS_DLD
, N_EQK
, N_EQK
, N_8
| N_KEY
);
20591 if (inst
.operands
[1].imm
< 1 || inst
.operands
[1].imm
> 4)
20593 first_error (_("bad list length for table lookup"));
20597 listlenbits
= inst
.operands
[1].imm
- 1;
20598 inst
.instruction
|= LOW4 (inst
.operands
[0].reg
) << 12;
20599 inst
.instruction
|= HI1 (inst
.operands
[0].reg
) << 22;
20600 inst
.instruction
|= LOW4 (inst
.operands
[1].reg
) << 16;
20601 inst
.instruction
|= HI1 (inst
.operands
[1].reg
) << 7;
20602 inst
.instruction
|= LOW4 (inst
.operands
[2].reg
);
20603 inst
.instruction
|= HI1 (inst
.operands
[2].reg
) << 5;
20604 inst
.instruction
|= listlenbits
<< 8;
20606 neon_dp_fixup (&inst
);
20610 do_neon_ldm_stm (void)
20612 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant
, fpu_vfp_ext_v1xd
)
20613 && !ARM_CPU_HAS_FEATURE (cpu_variant
, mve_ext
),
20615 /* P, U and L bits are part of bitmask. */
20616 int is_dbmode
= (inst
.instruction
& (1 << 24)) != 0;
20617 unsigned offsetbits
= inst
.operands
[1].imm
* 2;
20619 if (inst
.operands
[1].issingle
)
20621 do_vfp_nsyn_ldm_stm (is_dbmode
);
20625 constraint (is_dbmode
&& !inst
.operands
[0].writeback
,
20626 _("writeback (!) must be used for VLDMDB and VSTMDB"));
20628 constraint (inst
.operands
[1].imm
< 1 || inst
.operands
[1].imm
> 16,
20629 _("register list must contain at least 1 and at most 16 "
20632 inst
.instruction
|= inst
.operands
[0].reg
<< 16;
20633 inst
.instruction
|= inst
.operands
[0].writeback
<< 21;
20634 inst
.instruction
|= LOW4 (inst
.operands
[1].reg
) << 12;
20635 inst
.instruction
|= HI1 (inst
.operands
[1].reg
) << 22;
20637 inst
.instruction
|= offsetbits
;
20639 do_vfp_cond_or_thumb ();
20643 do_vfp_nsyn_pop (void)
20646 if (ARM_CPU_HAS_FEATURE (cpu_variant
, mve_ext
)) {
20647 return do_vfp_nsyn_opcode ("vldm");
20650 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant
, fpu_vfp_ext_v1xd
),
20653 constraint (inst
.operands
[1].imm
< 1 || inst
.operands
[1].imm
> 16,
20654 _("register list must contain at least 1 and at most 16 "
20657 if (inst
.operands
[1].issingle
)
20658 do_vfp_nsyn_opcode ("fldmias");
20660 do_vfp_nsyn_opcode ("fldmiad");
20664 do_vfp_nsyn_push (void)
20667 if (ARM_CPU_HAS_FEATURE (cpu_variant
, mve_ext
)) {
20668 return do_vfp_nsyn_opcode ("vstmdb");
20671 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant
, fpu_vfp_ext_v1xd
),
20674 constraint (inst
.operands
[1].imm
< 1 || inst
.operands
[1].imm
> 16,
20675 _("register list must contain at least 1 and at most 16 "
20678 if (inst
.operands
[1].issingle
)
20679 do_vfp_nsyn_opcode ("fstmdbs");
20681 do_vfp_nsyn_opcode ("fstmdbd");
20686 do_neon_ldr_str (void)
20688 int is_ldr
= (inst
.instruction
& (1 << 20)) != 0;
20690 /* Use of PC in vstr in ARM mode is deprecated in ARMv7.
20691 And is UNPREDICTABLE in thumb mode. */
20693 && inst
.operands
[1].reg
== REG_PC
20694 && (ARM_CPU_HAS_FEATURE (selected_cpu
, arm_ext_v7
) || thumb_mode
))
20697 inst
.error
= _("Use of PC here is UNPREDICTABLE");
20698 else if (warn_on_deprecated
)
20699 as_tsktsk (_("Use of PC here is deprecated"));
20702 if (inst
.operands
[0].issingle
)
20705 do_vfp_nsyn_opcode ("flds");
20707 do_vfp_nsyn_opcode ("fsts");
20709 /* ARMv8.2 vldr.16/vstr.16 instruction. */
20710 if (inst
.vectype
.el
[0].size
== 16)
20711 do_scalar_fp16_v82_encode ();
20716 do_vfp_nsyn_opcode ("fldd");
20718 do_vfp_nsyn_opcode ("fstd");
20723 do_t_vldr_vstr_sysreg (void)
20725 int fp_vldr_bitno
= 20, sysreg_vldr_bitno
= 20;
20726 bfd_boolean is_vldr
= ((inst
.instruction
& (1 << fp_vldr_bitno
)) != 0);
20728 /* Use of PC is UNPREDICTABLE. */
20729 if (inst
.operands
[1].reg
== REG_PC
)
20730 inst
.error
= _("Use of PC here is UNPREDICTABLE");
20732 if (inst
.operands
[1].immisreg
)
20733 inst
.error
= _("instruction does not accept register index");
20735 if (!inst
.operands
[1].isreg
)
20736 inst
.error
= _("instruction does not accept PC-relative addressing");
20738 if (abs (inst
.operands
[1].imm
) >= (1 << 7))
20739 inst
.error
= _("immediate value out of range");
20741 inst
.instruction
= 0xec000f80;
20743 inst
.instruction
|= 1 << sysreg_vldr_bitno
;
20744 encode_arm_cp_address (1, TRUE
, FALSE
, BFD_RELOC_ARM_T32_VLDR_VSTR_OFF_IMM
);
20745 inst
.instruction
|= (inst
.operands
[0].imm
& 0x7) << 13;
20746 inst
.instruction
|= (inst
.operands
[0].imm
& 0x8) << 19;
20750 do_vldr_vstr (void)
20752 bfd_boolean sysreg_op
= !inst
.operands
[0].isreg
;
20754 /* VLDR/VSTR (System Register). */
20757 if (!mark_feature_used (&arm_ext_v8_1m_main
))
20758 as_bad (_("Instruction not permitted on this architecture"));
20760 do_t_vldr_vstr_sysreg ();
20765 if (!mark_feature_used (&fpu_vfp_ext_v1xd
)
20766 && !ARM_CPU_HAS_FEATURE (cpu_variant
, mve_ext
))
20767 as_bad (_("Instruction not permitted on this architecture"));
20768 do_neon_ldr_str ();
20772 /* "interleave" version also handles non-interleaving register VLD1/VST1
20776 do_neon_ld_st_interleave (void)
20778 struct neon_type_el et
= neon_check_type (1, NS_NULL
,
20779 N_8
| N_16
| N_32
| N_64
);
20780 unsigned alignbits
= 0;
20782 /* The bits in this table go:
20783 0: register stride of one (0) or two (1)
20784 1,2: register list length, minus one (1, 2, 3, 4).
20785 3,4: <n> in instruction type, minus one (VLD<n> / VST<n>).
20786 We use -1 for invalid entries. */
20787 const int typetable
[] =
20789 0x7, -1, 0xa, -1, 0x6, -1, 0x2, -1, /* VLD1 / VST1. */
20790 -1, -1, 0x8, 0x9, -1, -1, 0x3, -1, /* VLD2 / VST2. */
20791 -1, -1, -1, -1, 0x4, 0x5, -1, -1, /* VLD3 / VST3. */
20792 -1, -1, -1, -1, -1, -1, 0x0, 0x1 /* VLD4 / VST4. */
20796 if (et
.type
== NT_invtype
)
20799 if (inst
.operands
[1].immisalign
)
20800 switch (inst
.operands
[1].imm
>> 8)
20802 case 64: alignbits
= 1; break;
20804 if (NEON_REGLIST_LENGTH (inst
.operands
[0].imm
) != 2
20805 && NEON_REGLIST_LENGTH (inst
.operands
[0].imm
) != 4)
20806 goto bad_alignment
;
20810 if (NEON_REGLIST_LENGTH (inst
.operands
[0].imm
) != 4)
20811 goto bad_alignment
;
20816 first_error (_("bad alignment"));
20820 inst
.instruction
|= alignbits
<< 4;
20821 inst
.instruction
|= neon_logbits (et
.size
) << 6;
20823 /* Bits [4:6] of the immediate in a list specifier encode register stride
20824 (minus 1) in bit 4, and list length in bits [5:6]. We put the <n> of
20825 VLD<n>/VST<n> in bits [9:8] of the initial bitmask. Suck it out here, look
20826 up the right value for "type" in a table based on this value and the given
20827 list style, then stick it back. */
20828 idx
= ((inst
.operands
[0].imm
>> 4) & 7)
20829 | (((inst
.instruction
>> 8) & 3) << 3);
20831 typebits
= typetable
[idx
];
20833 constraint (typebits
== -1, _("bad list type for instruction"));
20834 constraint (((inst
.instruction
>> 8) & 3) && et
.size
== 64,
20837 inst
.instruction
&= ~0xf00;
20838 inst
.instruction
|= typebits
<< 8;
20841 /* Check alignment is valid for do_neon_ld_st_lane and do_neon_ld_dup.
20842 *DO_ALIGN is set to 1 if the relevant alignment bit should be set, 0
20843 otherwise. The variable arguments are a list of pairs of legal (size, align)
20844 values, terminated with -1. */
20847 neon_alignment_bit (int size
, int align
, int *do_alignment
, ...)
20850 int result
= FAIL
, thissize
, thisalign
;
20852 if (!inst
.operands
[1].immisalign
)
20858 va_start (ap
, do_alignment
);
20862 thissize
= va_arg (ap
, int);
20863 if (thissize
== -1)
20865 thisalign
= va_arg (ap
, int);
20867 if (size
== thissize
&& align
== thisalign
)
20870 while (result
!= SUCCESS
);
20874 if (result
== SUCCESS
)
20877 first_error (_("unsupported alignment for instruction"));
20883 do_neon_ld_st_lane (void)
20885 struct neon_type_el et
= neon_check_type (1, NS_NULL
, N_8
| N_16
| N_32
);
20886 int align_good
, do_alignment
= 0;
20887 int logsize
= neon_logbits (et
.size
);
20888 int align
= inst
.operands
[1].imm
>> 8;
20889 int n
= (inst
.instruction
>> 8) & 3;
20890 int max_el
= 64 / et
.size
;
20892 if (et
.type
== NT_invtype
)
20895 constraint (NEON_REGLIST_LENGTH (inst
.operands
[0].imm
) != n
+ 1,
20896 _("bad list length"));
20897 constraint (NEON_LANE (inst
.operands
[0].imm
) >= max_el
,
20898 _("scalar index out of range"));
20899 constraint (n
!= 0 && NEON_REG_STRIDE (inst
.operands
[0].imm
) == 2
20901 _("stride of 2 unavailable when element size is 8"));
20905 case 0: /* VLD1 / VST1. */
20906 align_good
= neon_alignment_bit (et
.size
, align
, &do_alignment
, 16, 16,
20908 if (align_good
== FAIL
)
20912 unsigned alignbits
= 0;
20915 case 16: alignbits
= 0x1; break;
20916 case 32: alignbits
= 0x3; break;
20919 inst
.instruction
|= alignbits
<< 4;
20923 case 1: /* VLD2 / VST2. */
20924 align_good
= neon_alignment_bit (et
.size
, align
, &do_alignment
, 8, 16,
20925 16, 32, 32, 64, -1);
20926 if (align_good
== FAIL
)
20929 inst
.instruction
|= 1 << 4;
20932 case 2: /* VLD3 / VST3. */
20933 constraint (inst
.operands
[1].immisalign
,
20934 _("can't use alignment with this instruction"));
20937 case 3: /* VLD4 / VST4. */
20938 align_good
= neon_alignment_bit (et
.size
, align
, &do_alignment
, 8, 32,
20939 16, 64, 32, 64, 32, 128, -1);
20940 if (align_good
== FAIL
)
20944 unsigned alignbits
= 0;
20947 case 8: alignbits
= 0x1; break;
20948 case 16: alignbits
= 0x1; break;
20949 case 32: alignbits
= (align
== 64) ? 0x1 : 0x2; break;
20952 inst
.instruction
|= alignbits
<< 4;
20959 /* Reg stride of 2 is encoded in bit 5 when size==16, bit 6 when size==32. */
20960 if (n
!= 0 && NEON_REG_STRIDE (inst
.operands
[0].imm
) == 2)
20961 inst
.instruction
|= 1 << (4 + logsize
);
20963 inst
.instruction
|= NEON_LANE (inst
.operands
[0].imm
) << (logsize
+ 5);
20964 inst
.instruction
|= logsize
<< 10;
20967 /* Encode single n-element structure to all lanes VLD<n> instructions. */
20970 do_neon_ld_dup (void)
20972 struct neon_type_el et
= neon_check_type (1, NS_NULL
, N_8
| N_16
| N_32
);
20973 int align_good
, do_alignment
= 0;
20975 if (et
.type
== NT_invtype
)
20978 switch ((inst
.instruction
>> 8) & 3)
20980 case 0: /* VLD1. */
20981 gas_assert (NEON_REG_STRIDE (inst
.operands
[0].imm
) != 2);
20982 align_good
= neon_alignment_bit (et
.size
, inst
.operands
[1].imm
>> 8,
20983 &do_alignment
, 16, 16, 32, 32, -1);
20984 if (align_good
== FAIL
)
20986 switch (NEON_REGLIST_LENGTH (inst
.operands
[0].imm
))
20989 case 2: inst
.instruction
|= 1 << 5; break;
20990 default: first_error (_("bad list length")); return;
20992 inst
.instruction
|= neon_logbits (et
.size
) << 6;
20995 case 1: /* VLD2. */
20996 align_good
= neon_alignment_bit (et
.size
, inst
.operands
[1].imm
>> 8,
20997 &do_alignment
, 8, 16, 16, 32, 32, 64,
20999 if (align_good
== FAIL
)
21001 constraint (NEON_REGLIST_LENGTH (inst
.operands
[0].imm
) != 2,
21002 _("bad list length"));
21003 if (NEON_REG_STRIDE (inst
.operands
[0].imm
) == 2)
21004 inst
.instruction
|= 1 << 5;
21005 inst
.instruction
|= neon_logbits (et
.size
) << 6;
21008 case 2: /* VLD3. */
21009 constraint (inst
.operands
[1].immisalign
,
21010 _("can't use alignment with this instruction"));
21011 constraint (NEON_REGLIST_LENGTH (inst
.operands
[0].imm
) != 3,
21012 _("bad list length"));
21013 if (NEON_REG_STRIDE (inst
.operands
[0].imm
) == 2)
21014 inst
.instruction
|= 1 << 5;
21015 inst
.instruction
|= neon_logbits (et
.size
) << 6;
21018 case 3: /* VLD4. */
21020 int align
= inst
.operands
[1].imm
>> 8;
21021 align_good
= neon_alignment_bit (et
.size
, align
, &do_alignment
, 8, 32,
21022 16, 64, 32, 64, 32, 128, -1);
21023 if (align_good
== FAIL
)
21025 constraint (NEON_REGLIST_LENGTH (inst
.operands
[0].imm
) != 4,
21026 _("bad list length"));
21027 if (NEON_REG_STRIDE (inst
.operands
[0].imm
) == 2)
21028 inst
.instruction
|= 1 << 5;
21029 if (et
.size
== 32 && align
== 128)
21030 inst
.instruction
|= 0x3 << 6;
21032 inst
.instruction
|= neon_logbits (et
.size
) << 6;
21039 inst
.instruction
|= do_alignment
<< 4;
21042 /* Disambiguate VLD<n> and VST<n> instructions, and fill in common bits (those
21043 apart from bits [11:4]. */
21046 do_neon_ldx_stx (void)
21048 if (inst
.operands
[1].isreg
)
21049 constraint (inst
.operands
[1].reg
== REG_PC
, BAD_PC
);
21051 switch (NEON_LANE (inst
.operands
[0].imm
))
21053 case NEON_INTERLEAVE_LANES
:
21054 NEON_ENCODE (INTERLV
, inst
);
21055 do_neon_ld_st_interleave ();
21058 case NEON_ALL_LANES
:
21059 NEON_ENCODE (DUP
, inst
);
21060 if (inst
.instruction
== N_INV
)
21062 first_error ("only loads support such operands");
21069 NEON_ENCODE (LANE
, inst
);
21070 do_neon_ld_st_lane ();
21073 /* L bit comes from bit mask. */
21074 inst
.instruction
|= LOW4 (inst
.operands
[0].reg
) << 12;
21075 inst
.instruction
|= HI1 (inst
.operands
[0].reg
) << 22;
21076 inst
.instruction
|= inst
.operands
[1].reg
<< 16;
21078 if (inst
.operands
[1].postind
)
21080 int postreg
= inst
.operands
[1].imm
& 0xf;
21081 constraint (!inst
.operands
[1].immisreg
,
21082 _("post-index must be a register"));
21083 constraint (postreg
== 0xd || postreg
== 0xf,
21084 _("bad register for post-index"));
21085 inst
.instruction
|= postreg
;
21089 constraint (inst
.operands
[1].immisreg
, BAD_ADDR_MODE
);
21090 constraint (inst
.relocs
[0].exp
.X_op
!= O_constant
21091 || inst
.relocs
[0].exp
.X_add_number
!= 0,
21094 if (inst
.operands
[1].writeback
)
21096 inst
.instruction
|= 0xd;
21099 inst
.instruction
|= 0xf;
21103 inst
.instruction
|= 0xf9000000;
21105 inst
.instruction
|= 0xf4000000;
21110 do_vfp_nsyn_fpv8 (enum neon_shape rs
)
21112 /* Targets like FPv5-SP-D16 don't support FP v8 instructions with
21113 D register operands. */
21114 if (neon_shape_class
[rs
] == SC_DOUBLE
)
21115 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant
, fpu_vfp_ext_armv8
),
21118 NEON_ENCODE (FPV8
, inst
);
21120 if (rs
== NS_FFF
|| rs
== NS_HHH
)
21122 do_vfp_sp_dyadic ();
21124 /* ARMv8.2 fp16 instruction. */
21126 do_scalar_fp16_v82_encode ();
21129 do_vfp_dp_rd_rn_rm ();
21132 inst
.instruction
|= 0x100;
21134 inst
.instruction
|= 0xf0000000;
21140 set_pred_insn_type (OUTSIDE_PRED_INSN
);
21142 if (try_vfp_nsyn (3, do_vfp_nsyn_fpv8
) != SUCCESS
)
21143 first_error (_("invalid instruction shape"));
21149 if (!ARM_CPU_HAS_FEATURE (cpu_variant
, mve_ext
))
21150 set_pred_insn_type (OUTSIDE_PRED_INSN
);
21152 if (try_vfp_nsyn (3, do_vfp_nsyn_fpv8
) == SUCCESS
)
21155 if (!check_simd_pred_availability (TRUE
, NEON_CHECK_CC
| NEON_CHECK_ARCH8
))
21158 neon_dyadic_misc (NT_untyped
, N_F_16_32
, 0);
21162 do_vrint_1 (enum neon_cvt_mode mode
)
21164 enum neon_shape rs
= neon_select_shape (NS_HH
, NS_FF
, NS_DD
, NS_QQ
, NS_NULL
);
21165 struct neon_type_el et
;
21170 /* Targets like FPv5-SP-D16 don't support FP v8 instructions with
21171 D register operands. */
21172 if (neon_shape_class
[rs
] == SC_DOUBLE
)
21173 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant
, fpu_vfp_ext_armv8
),
21176 et
= neon_check_type (2, rs
, N_EQK
| N_VFP
, N_F_ALL
| N_KEY
21178 if (et
.type
!= NT_invtype
)
21180 /* VFP encodings. */
21181 if (mode
== neon_cvt_mode_a
|| mode
== neon_cvt_mode_n
21182 || mode
== neon_cvt_mode_p
|| mode
== neon_cvt_mode_m
)
21183 set_pred_insn_type (OUTSIDE_PRED_INSN
);
21185 NEON_ENCODE (FPV8
, inst
);
21186 if (rs
== NS_FF
|| rs
== NS_HH
)
21187 do_vfp_sp_monadic ();
21189 do_vfp_dp_rd_rm ();
21193 case neon_cvt_mode_r
: inst
.instruction
|= 0x00000000; break;
21194 case neon_cvt_mode_z
: inst
.instruction
|= 0x00000080; break;
21195 case neon_cvt_mode_x
: inst
.instruction
|= 0x00010000; break;
21196 case neon_cvt_mode_a
: inst
.instruction
|= 0xf0000000; break;
21197 case neon_cvt_mode_n
: inst
.instruction
|= 0xf0010000; break;
21198 case neon_cvt_mode_p
: inst
.instruction
|= 0xf0020000; break;
21199 case neon_cvt_mode_m
: inst
.instruction
|= 0xf0030000; break;
21203 inst
.instruction
|= (rs
== NS_DD
) << 8;
21204 do_vfp_cond_or_thumb ();
21206 /* ARMv8.2 fp16 vrint instruction. */
21208 do_scalar_fp16_v82_encode ();
21212 /* Neon encodings (or something broken...). */
21214 et
= neon_check_type (2, rs
, N_EQK
, N_F_16_32
| N_KEY
);
21216 if (et
.type
== NT_invtype
)
21219 if (!check_simd_pred_availability (TRUE
,
21220 NEON_CHECK_CC
| NEON_CHECK_ARCH8
))
21223 NEON_ENCODE (FLOAT
, inst
);
21225 inst
.instruction
|= LOW4 (inst
.operands
[0].reg
) << 12;
21226 inst
.instruction
|= HI1 (inst
.operands
[0].reg
) << 22;
21227 inst
.instruction
|= LOW4 (inst
.operands
[1].reg
);
21228 inst
.instruction
|= HI1 (inst
.operands
[1].reg
) << 5;
21229 inst
.instruction
|= neon_quad (rs
) << 6;
21230 /* Mask off the original size bits and reencode them. */
21231 inst
.instruction
= ((inst
.instruction
& 0xfff3ffff)
21232 | neon_logbits (et
.size
) << 18);
21236 case neon_cvt_mode_z
: inst
.instruction
|= 3 << 7; break;
21237 case neon_cvt_mode_x
: inst
.instruction
|= 1 << 7; break;
21238 case neon_cvt_mode_a
: inst
.instruction
|= 2 << 7; break;
21239 case neon_cvt_mode_n
: inst
.instruction
|= 0 << 7; break;
21240 case neon_cvt_mode_p
: inst
.instruction
|= 7 << 7; break;
21241 case neon_cvt_mode_m
: inst
.instruction
|= 5 << 7; break;
21242 case neon_cvt_mode_r
: inst
.error
= _("invalid rounding mode"); break;
21247 inst
.instruction
|= 0xfc000000;
21249 inst
.instruction
|= 0xf0000000;
21256 do_vrint_1 (neon_cvt_mode_x
);
21262 do_vrint_1 (neon_cvt_mode_z
);
21268 do_vrint_1 (neon_cvt_mode_r
);
21274 do_vrint_1 (neon_cvt_mode_a
);
21280 do_vrint_1 (neon_cvt_mode_n
);
21286 do_vrint_1 (neon_cvt_mode_p
);
21292 do_vrint_1 (neon_cvt_mode_m
);
21296 neon_scalar_for_vcmla (unsigned opnd
, unsigned elsize
)
21298 unsigned regno
= NEON_SCALAR_REG (opnd
);
21299 unsigned elno
= NEON_SCALAR_INDEX (opnd
);
21301 if (elsize
== 16 && elno
< 2 && regno
< 16)
21302 return regno
| (elno
<< 4);
21303 else if (elsize
== 32 && elno
== 0)
21306 first_error (_("scalar out of range"));
21313 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant
, mve_fp_ext
)
21314 && (!ARM_CPU_HAS_FEATURE (cpu_variant
, fpu_neon_ext_armv8
)
21315 || !mark_feature_used (&arm_ext_v8_3
)), (BAD_FPU
));
21316 constraint (inst
.relocs
[0].exp
.X_op
!= O_constant
,
21317 _("expression too complex"));
21318 unsigned rot
= inst
.relocs
[0].exp
.X_add_number
;
21319 constraint (rot
!= 0 && rot
!= 90 && rot
!= 180 && rot
!= 270,
21320 _("immediate out of range"));
21323 if (!check_simd_pred_availability (TRUE
,
21324 NEON_CHECK_ARCH8
| NEON_CHECK_CC
))
21327 if (inst
.operands
[2].isscalar
)
21329 if (ARM_CPU_HAS_FEATURE (cpu_variant
, mve_fp_ext
))
21330 first_error (_("invalid instruction shape"));
21331 enum neon_shape rs
= neon_select_shape (NS_DDSI
, NS_QQSI
, NS_NULL
);
21332 unsigned size
= neon_check_type (3, rs
, N_EQK
, N_EQK
,
21333 N_KEY
| N_F16
| N_F32
).size
;
21334 unsigned m
= neon_scalar_for_vcmla (inst
.operands
[2].reg
, size
);
21336 inst
.instruction
= 0xfe000800;
21337 inst
.instruction
|= LOW4 (inst
.operands
[0].reg
) << 12;
21338 inst
.instruction
|= HI1 (inst
.operands
[0].reg
) << 22;
21339 inst
.instruction
|= LOW4 (inst
.operands
[1].reg
) << 16;
21340 inst
.instruction
|= HI1 (inst
.operands
[1].reg
) << 7;
21341 inst
.instruction
|= LOW4 (m
);
21342 inst
.instruction
|= HI1 (m
) << 5;
21343 inst
.instruction
|= neon_quad (rs
) << 6;
21344 inst
.instruction
|= rot
<< 20;
21345 inst
.instruction
|= (size
== 32) << 23;
21349 enum neon_shape rs
;
21350 if (ARM_CPU_HAS_FEATURE (cpu_variant
, mve_fp_ext
))
21351 rs
= neon_select_shape (NS_QQQI
, NS_NULL
);
21353 rs
= neon_select_shape (NS_DDDI
, NS_QQQI
, NS_NULL
);
21355 unsigned size
= neon_check_type (3, rs
, N_EQK
, N_EQK
,
21356 N_KEY
| N_F16
| N_F32
).size
;
21357 if (ARM_CPU_HAS_FEATURE (cpu_variant
, mve_fp_ext
) && size
== 32
21358 && (inst
.operands
[0].reg
== inst
.operands
[1].reg
21359 || inst
.operands
[0].reg
== inst
.operands
[2].reg
))
21360 as_tsktsk (BAD_MVE_SRCDEST
);
21362 neon_three_same (neon_quad (rs
), 0, -1);
21363 inst
.instruction
&= 0x00ffffff; /* Undo neon_dp_fixup. */
21364 inst
.instruction
|= 0xfc200800;
21365 inst
.instruction
|= rot
<< 23;
21366 inst
.instruction
|= (size
== 32) << 20;
21373 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant
, mve_ext
)
21374 && (!ARM_CPU_HAS_FEATURE (cpu_variant
, fpu_neon_ext_armv8
)
21375 || !mark_feature_used (&arm_ext_v8_3
)), (BAD_FPU
));
21376 constraint (inst
.relocs
[0].exp
.X_op
!= O_constant
,
21377 _("expression too complex"));
21379 unsigned rot
= inst
.relocs
[0].exp
.X_add_number
;
21380 constraint (rot
!= 90 && rot
!= 270, _("immediate out of range"));
21381 enum neon_shape rs
;
21382 struct neon_type_el et
;
21383 if (!ARM_CPU_HAS_FEATURE (cpu_variant
, mve_ext
))
21385 rs
= neon_select_shape (NS_DDDI
, NS_QQQI
, NS_NULL
);
21386 et
= neon_check_type (3, rs
, N_EQK
, N_EQK
, N_KEY
| N_F16
| N_F32
);
21390 rs
= neon_select_shape (NS_QQQI
, NS_NULL
);
21391 et
= neon_check_type (3, rs
, N_EQK
, N_EQK
, N_KEY
| N_F16
| N_F32
| N_I8
21393 if (et
.size
== 32 && inst
.operands
[0].reg
== inst
.operands
[2].reg
)
21394 as_tsktsk (_("Warning: 32-bit element size and same first and third "
21395 "operand makes instruction UNPREDICTABLE"));
21398 if (et
.type
== NT_invtype
)
21401 if (!check_simd_pred_availability (et
.type
== NT_float
,
21402 NEON_CHECK_ARCH8
| NEON_CHECK_CC
))
21405 if (et
.type
== NT_float
)
21407 neon_three_same (neon_quad (rs
), 0, -1);
21408 inst
.instruction
&= 0x00ffffff; /* Undo neon_dp_fixup. */
21409 inst
.instruction
|= 0xfc800800;
21410 inst
.instruction
|= (rot
== 270) << 24;
21411 inst
.instruction
|= (et
.size
== 32) << 20;
21415 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant
, mve_ext
), BAD_FPU
);
21416 inst
.instruction
= 0xfe000f00;
21417 inst
.instruction
|= HI1 (inst
.operands
[0].reg
) << 22;
21418 inst
.instruction
|= neon_logbits (et
.size
) << 20;
21419 inst
.instruction
|= LOW4 (inst
.operands
[1].reg
) << 16;
21420 inst
.instruction
|= LOW4 (inst
.operands
[0].reg
) << 12;
21421 inst
.instruction
|= (rot
== 270) << 12;
21422 inst
.instruction
|= HI1 (inst
.operands
[1].reg
) << 7;
21423 inst
.instruction
|= HI1 (inst
.operands
[2].reg
) << 5;
21424 inst
.instruction
|= LOW4 (inst
.operands
[2].reg
);
21429 /* Dot Product instructions encoding support. */
21432 do_neon_dotproduct (int unsigned_p
)
21434 enum neon_shape rs
;
21435 unsigned scalar_oprd2
= 0;
21438 if (inst
.cond
!= COND_ALWAYS
)
21439 as_warn (_("Dot Product instructions cannot be conditional, the behaviour "
21440 "is UNPREDICTABLE"));
21442 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant
, fpu_neon_ext_armv8
),
21445 /* Dot Product instructions are in three-same D/Q register format or the third
21446 operand can be a scalar index register. */
21447 if (inst
.operands
[2].isscalar
)
21449 scalar_oprd2
= neon_scalar_for_mul (inst
.operands
[2].reg
, 32);
21450 high8
= 0xfe000000;
21451 rs
= neon_select_shape (NS_DDS
, NS_QQS
, NS_NULL
);
21455 high8
= 0xfc000000;
21456 rs
= neon_select_shape (NS_DDD
, NS_QQQ
, NS_NULL
);
21460 neon_check_type (3, rs
, N_EQK
, N_EQK
, N_KEY
| N_U8
);
21462 neon_check_type (3, rs
, N_EQK
, N_EQK
, N_KEY
| N_S8
);
21464 /* The "U" bit in traditional Three Same encoding is fixed to 0 for Dot
21465 Product instruction, so we pass 0 as the "ubit" parameter. And the
21466 "Size" field are fixed to 0x2, so we pass 32 as the "size" parameter. */
21467 neon_three_same (neon_quad (rs
), 0, 32);
21469 /* Undo neon_dp_fixup. Dot Product instructions are using a slightly
21470 different NEON three-same encoding. */
21471 inst
.instruction
&= 0x00ffffff;
21472 inst
.instruction
|= high8
;
21473 /* Encode 'U' bit which indicates signedness. */
21474 inst
.instruction
|= (unsigned_p
? 1 : 0) << 4;
21475 /* Re-encode operand2 if it's indexed scalar operand. What has been encoded
21476 from inst.operand[2].reg in neon_three_same is GAS's internal encoding, not
21477 the instruction encoding. */
21478 if (inst
.operands
[2].isscalar
)
21480 inst
.instruction
&= 0xffffffd0;
21481 inst
.instruction
|= LOW4 (scalar_oprd2
);
21482 inst
.instruction
|= HI1 (scalar_oprd2
) << 5;
21486 /* Dot Product instructions for signed integer. */
21489 do_neon_dotproduct_s (void)
21491 return do_neon_dotproduct (0);
21494 /* Dot Product instructions for unsigned integer. */
21497 do_neon_dotproduct_u (void)
21499 return do_neon_dotproduct (1);
21505 enum neon_shape rs
;
21506 set_pred_insn_type (OUTSIDE_PRED_INSN
);
21507 if (inst
.operands
[2].isscalar
)
21509 rs
= neon_select_shape (NS_DDS
, NS_QQS
, NS_NULL
);
21510 neon_check_type (3, rs
, N_EQK
, N_EQK
, N_S8
| N_KEY
);
21512 inst
.instruction
|= (1 << 25);
21513 int index
= inst
.operands
[2].reg
& 0xf;
21514 constraint ((index
!= 1 && index
!= 0), _("index must be 0 or 1"));
21515 inst
.operands
[2].reg
>>= 4;
21516 constraint (!(inst
.operands
[2].reg
< 16),
21517 _("indexed register must be less than 16"));
21518 neon_three_args (rs
== NS_QQS
);
21519 inst
.instruction
|= (index
<< 5);
21523 inst
.instruction
|= (1 << 21);
21524 rs
= neon_select_shape (NS_DDD
, NS_QQQ
, NS_NULL
);
21525 neon_check_type (3, rs
, N_EQK
, N_EQK
, N_S8
| N_KEY
);
21526 neon_three_args (rs
== NS_QQQ
);
21533 enum neon_shape rs
;
21534 set_pred_insn_type (OUTSIDE_PRED_INSN
);
21535 if (inst
.operands
[2].isscalar
)
21537 rs
= neon_select_shape (NS_DDS
, NS_QQS
, NS_NULL
);
21538 neon_check_type (3, rs
, N_EQK
, N_EQK
, N_U8
| N_KEY
);
21540 inst
.instruction
|= (1 << 25);
21541 int index
= inst
.operands
[2].reg
& 0xf;
21542 constraint ((index
!= 1 && index
!= 0), _("index must be 0 or 1"));
21543 inst
.operands
[2].reg
>>= 4;
21544 constraint (!(inst
.operands
[2].reg
< 16),
21545 _("indexed register must be less than 16"));
21546 neon_three_args (rs
== NS_QQS
);
21547 inst
.instruction
|= (index
<< 5);
21554 enum neon_shape rs
= neon_select_shape (NS_QQQ
, NS_NULL
);
21555 neon_check_type (3, rs
, N_EQK
, N_EQK
, N_S8
| N_KEY
);
21557 set_pred_insn_type (OUTSIDE_PRED_INSN
);
21559 neon_three_args (1);
21566 enum neon_shape rs
= neon_select_shape (NS_QQQ
, NS_NULL
);
21567 neon_check_type (3, rs
, N_EQK
, N_EQK
, N_U8
| N_KEY
);
21569 set_pred_insn_type (OUTSIDE_PRED_INSN
);
21571 neon_three_args (1);
21575 /* Crypto v1 instructions. */
21577 do_crypto_2op_1 (unsigned elttype
, int op
)
21579 set_pred_insn_type (OUTSIDE_PRED_INSN
);
21581 if (neon_check_type (2, NS_QQ
, N_EQK
| N_UNT
, elttype
| N_UNT
| N_KEY
).type
21587 NEON_ENCODE (INTEGER
, inst
);
21588 inst
.instruction
|= LOW4 (inst
.operands
[0].reg
) << 12;
21589 inst
.instruction
|= HI1 (inst
.operands
[0].reg
) << 22;
21590 inst
.instruction
|= LOW4 (inst
.operands
[1].reg
);
21591 inst
.instruction
|= HI1 (inst
.operands
[1].reg
) << 5;
21593 inst
.instruction
|= op
<< 6;
21596 inst
.instruction
|= 0xfc000000;
21598 inst
.instruction
|= 0xf0000000;
21602 do_crypto_3op_1 (int u
, int op
)
21604 set_pred_insn_type (OUTSIDE_PRED_INSN
);
21606 if (neon_check_type (3, NS_QQQ
, N_EQK
| N_UNT
, N_EQK
| N_UNT
,
21607 N_32
| N_UNT
| N_KEY
).type
== NT_invtype
)
21612 NEON_ENCODE (INTEGER
, inst
);
21613 neon_three_same (1, u
, 8 << op
);
21619 do_crypto_2op_1 (N_8
, 0);
21625 do_crypto_2op_1 (N_8
, 1);
21631 do_crypto_2op_1 (N_8
, 2);
21637 do_crypto_2op_1 (N_8
, 3);
21643 do_crypto_3op_1 (0, 0);
21649 do_crypto_3op_1 (0, 1);
21655 do_crypto_3op_1 (0, 2);
21661 do_crypto_3op_1 (0, 3);
21667 do_crypto_3op_1 (1, 0);
21673 do_crypto_3op_1 (1, 1);
21677 do_sha256su1 (void)
21679 do_crypto_3op_1 (1, 2);
21685 do_crypto_2op_1 (N_32
, -1);
21691 do_crypto_2op_1 (N_32
, 0);
21695 do_sha256su0 (void)
21697 do_crypto_2op_1 (N_32
, 1);
21701 do_crc32_1 (unsigned int poly
, unsigned int sz
)
21703 unsigned int Rd
= inst
.operands
[0].reg
;
21704 unsigned int Rn
= inst
.operands
[1].reg
;
21705 unsigned int Rm
= inst
.operands
[2].reg
;
21707 set_pred_insn_type (OUTSIDE_PRED_INSN
);
21708 inst
.instruction
|= LOW4 (Rd
) << (thumb_mode
? 8 : 12);
21709 inst
.instruction
|= LOW4 (Rn
) << 16;
21710 inst
.instruction
|= LOW4 (Rm
);
21711 inst
.instruction
|= sz
<< (thumb_mode
? 4 : 21);
21712 inst
.instruction
|= poly
<< (thumb_mode
? 20 : 9);
21714 if (Rd
== REG_PC
|| Rn
== REG_PC
|| Rm
== REG_PC
)
21715 as_warn (UNPRED_REG ("r15"));
21757 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant
, fpu_vfp_ext_armv8
),
21759 neon_check_type (2, NS_FD
, N_S32
, N_F64
);
21760 do_vfp_sp_dp_cvt ();
21761 do_vfp_cond_or_thumb ();
21767 enum neon_shape rs
;
21768 constraint (!mark_feature_used (&fpu_neon_ext_armv8
), _(BAD_FPU
));
21769 set_pred_insn_type (OUTSIDE_PRED_INSN
);
21770 if (inst
.operands
[2].isscalar
)
21772 rs
= neon_select_shape (NS_DDS
, NS_QQS
, NS_NULL
);
21773 neon_check_type (3, rs
, N_EQK
, N_EQK
, N_BF16
| N_KEY
);
21775 inst
.instruction
|= (1 << 25);
21776 int index
= inst
.operands
[2].reg
& 0xf;
21777 constraint ((index
!= 1 && index
!= 0), _("index must be 0 or 1"));
21778 inst
.operands
[2].reg
>>= 4;
21779 constraint (!(inst
.operands
[2].reg
< 16),
21780 _("indexed register must be less than 16"));
21781 neon_three_args (rs
== NS_QQS
);
21782 inst
.instruction
|= (index
<< 5);
21786 rs
= neon_select_shape (NS_DDD
, NS_QQQ
, NS_NULL
);
21787 neon_check_type (3, rs
, N_EQK
, N_EQK
, N_BF16
| N_KEY
);
21788 neon_three_args (rs
== NS_QQQ
);
21795 enum neon_shape rs
= neon_select_shape (NS_QQQ
, NS_NULL
);
21796 neon_check_type (3, rs
, N_EQK
, N_EQK
, N_BF16
| N_KEY
);
21798 constraint (!mark_feature_used (&fpu_neon_ext_armv8
), _(BAD_FPU
));
21799 set_pred_insn_type (OUTSIDE_PRED_INSN
);
21801 neon_three_args (1);
21805 /* Overall per-instruction processing. */
21807 /* We need to be able to fix up arbitrary expressions in some statements.
21808 This is so that we can handle symbols that are an arbitrary distance from
21809 the pc. The most common cases are of the form ((+/-sym -/+ . - 8) & mask),
21810 which returns part of an address in a form which will be valid for
21811 a data instruction. We do this by pushing the expression into a symbol
21812 in the expr_section, and creating a fix for that. */
21815 fix_new_arm (fragS
* frag
,
21829 /* Create an absolute valued symbol, so we have something to
21830 refer to in the object file. Unfortunately for us, gas's
21831 generic expression parsing will already have folded out
21832 any use of .set foo/.type foo %function that may have
21833 been used to set type information of the target location,
21834 that's being specified symbolically. We have to presume
21835 the user knows what they are doing. */
21839 sprintf (name
, "*ABS*0x%lx", (unsigned long)exp
->X_add_number
);
21841 symbol
= symbol_find_or_make (name
);
21842 S_SET_SEGMENT (symbol
, absolute_section
);
21843 symbol_set_frag (symbol
, &zero_address_frag
);
21844 S_SET_VALUE (symbol
, exp
->X_add_number
);
21845 exp
->X_op
= O_symbol
;
21846 exp
->X_add_symbol
= symbol
;
21847 exp
->X_add_number
= 0;
21853 new_fix
= fix_new_exp (frag
, where
, size
, exp
, pc_rel
,
21854 (enum bfd_reloc_code_real
) reloc
);
21858 new_fix
= (fixS
*) fix_new (frag
, where
, size
, make_expr_symbol (exp
), 0,
21859 pc_rel
, (enum bfd_reloc_code_real
) reloc
);
21863 /* Mark whether the fix is to a THUMB instruction, or an ARM
21865 new_fix
->tc_fix_data
= thumb_mode
;
21868 /* Create a frg for an instruction requiring relaxation. */
21870 output_relax_insn (void)
21876 /* The size of the instruction is unknown, so tie the debug info to the
21877 start of the instruction. */
21878 dwarf2_emit_insn (0);
21880 switch (inst
.relocs
[0].exp
.X_op
)
21883 sym
= inst
.relocs
[0].exp
.X_add_symbol
;
21884 offset
= inst
.relocs
[0].exp
.X_add_number
;
21888 offset
= inst
.relocs
[0].exp
.X_add_number
;
21891 sym
= make_expr_symbol (&inst
.relocs
[0].exp
);
21895 to
= frag_var (rs_machine_dependent
, INSN_SIZE
, THUMB_SIZE
,
21896 inst
.relax
, sym
, offset
, NULL
/*offset, opcode*/);
21897 md_number_to_chars (to
, inst
.instruction
, THUMB_SIZE
);
21900 /* Write a 32-bit thumb instruction to buf. */
21902 put_thumb32_insn (char * buf
, unsigned long insn
)
21904 md_number_to_chars (buf
, insn
>> 16, THUMB_SIZE
);
21905 md_number_to_chars (buf
+ THUMB_SIZE
, insn
, THUMB_SIZE
);
21909 output_inst (const char * str
)
21915 as_bad ("%s -- `%s'", inst
.error
, str
);
21920 output_relax_insn ();
21923 if (inst
.size
== 0)
21926 to
= frag_more (inst
.size
);
21927 /* PR 9814: Record the thumb mode into the current frag so that we know
21928 what type of NOP padding to use, if necessary. We override any previous
21929 setting so that if the mode has changed then the NOPS that we use will
21930 match the encoding of the last instruction in the frag. */
21931 frag_now
->tc_frag_data
.thumb_mode
= thumb_mode
| MODE_RECORDED
;
21933 if (thumb_mode
&& (inst
.size
> THUMB_SIZE
))
21935 gas_assert (inst
.size
== (2 * THUMB_SIZE
));
21936 put_thumb32_insn (to
, inst
.instruction
);
21938 else if (inst
.size
> INSN_SIZE
)
21940 gas_assert (inst
.size
== (2 * INSN_SIZE
));
21941 md_number_to_chars (to
, inst
.instruction
, INSN_SIZE
);
21942 md_number_to_chars (to
+ INSN_SIZE
, inst
.instruction
, INSN_SIZE
);
21945 md_number_to_chars (to
, inst
.instruction
, inst
.size
);
21948 for (r
= 0; r
< ARM_IT_MAX_RELOCS
; r
++)
21950 if (inst
.relocs
[r
].type
!= BFD_RELOC_UNUSED
)
21951 fix_new_arm (frag_now
, to
- frag_now
->fr_literal
,
21952 inst
.size
, & inst
.relocs
[r
].exp
, inst
.relocs
[r
].pc_rel
,
21953 inst
.relocs
[r
].type
);
21956 dwarf2_emit_insn (inst
.size
);
21960 output_it_inst (int cond
, int mask
, char * to
)
21962 unsigned long instruction
= 0xbf00;
21965 instruction
|= mask
;
21966 instruction
|= cond
<< 4;
21970 to
= frag_more (2);
21972 dwarf2_emit_insn (2);
21976 md_number_to_chars (to
, instruction
, 2);
21981 /* Tag values used in struct asm_opcode's tag field. */
21984 OT_unconditional
, /* Instruction cannot be conditionalized.
21985 The ARM condition field is still 0xE. */
21986 OT_unconditionalF
, /* Instruction cannot be conditionalized
21987 and carries 0xF in its ARM condition field. */
21988 OT_csuffix
, /* Instruction takes a conditional suffix. */
21989 OT_csuffixF
, /* Some forms of the instruction take a scalar
21990 conditional suffix, others place 0xF where the
21991 condition field would be, others take a vector
21992 conditional suffix. */
21993 OT_cinfix3
, /* Instruction takes a conditional infix,
21994 beginning at character index 3. (In
21995 unified mode, it becomes a suffix.) */
21996 OT_cinfix3_deprecated
, /* The same as OT_cinfix3. This is used for
21997 tsts, cmps, cmns, and teqs. */
21998 OT_cinfix3_legacy
, /* Legacy instruction takes a conditional infix at
21999 character index 3, even in unified mode. Used for
22000 legacy instructions where suffix and infix forms
22001 may be ambiguous. */
22002 OT_csuf_or_in3
, /* Instruction takes either a conditional
22003 suffix or an infix at character index 3. */
22004 OT_odd_infix_unc
, /* This is the unconditional variant of an
22005 instruction that takes a conditional infix
22006 at an unusual position. In unified mode,
22007 this variant will accept a suffix. */
22008 OT_odd_infix_0
/* Values greater than or equal to OT_odd_infix_0
22009 are the conditional variants of instructions that
22010 take conditional infixes in unusual positions.
22011 The infix appears at character index
22012 (tag - OT_odd_infix_0). These are not accepted
22013 in unified mode. */
22016 /* Subroutine of md_assemble, responsible for looking up the primary
22017 opcode from the mnemonic the user wrote. STR points to the
22018 beginning of the mnemonic.
22020 This is not simply a hash table lookup, because of conditional
22021 variants. Most instructions have conditional variants, which are
22022 expressed with a _conditional affix_ to the mnemonic. If we were
22023 to encode each conditional variant as a literal string in the opcode
22024 table, it would have approximately 20,000 entries.
22026 Most mnemonics take this affix as a suffix, and in unified syntax,
22027 'most' is upgraded to 'all'. However, in the divided syntax, some
22028 instructions take the affix as an infix, notably the s-variants of
22029 the arithmetic instructions. Of those instructions, all but six
22030 have the infix appear after the third character of the mnemonic.
22032 Accordingly, the algorithm for looking up primary opcodes given
22035 1. Look up the identifier in the opcode table.
22036 If we find a match, go to step U.
22038 2. Look up the last two characters of the identifier in the
22039 conditions table. If we find a match, look up the first N-2
22040 characters of the identifier in the opcode table. If we
22041 find a match, go to step CE.
22043 3. Look up the fourth and fifth characters of the identifier in
22044 the conditions table. If we find a match, extract those
22045 characters from the identifier, and look up the remaining
22046 characters in the opcode table. If we find a match, go
22051 U. Examine the tag field of the opcode structure, in case this is
22052 one of the six instructions with its conditional infix in an
22053 unusual place. If it is, the tag tells us where to find the
22054 infix; look it up in the conditions table and set inst.cond
22055 accordingly. Otherwise, this is an unconditional instruction.
22056 Again set inst.cond accordingly. Return the opcode structure.
22058 CE. Examine the tag field to make sure this is an instruction that
22059 should receive a conditional suffix. If it is not, fail.
22060 Otherwise, set inst.cond from the suffix we already looked up,
22061 and return the opcode structure.
22063 CM. Examine the tag field to make sure this is an instruction that
22064 should receive a conditional infix after the third character.
22065 If it is not, fail. Otherwise, undo the edits to the current
22066 line of input and proceed as for case CE. */
22068 static const struct asm_opcode
*
22069 opcode_lookup (char **str
)
22073 const struct asm_opcode
*opcode
;
22074 const struct asm_cond
*cond
;
22077 /* Scan up to the end of the mnemonic, which must end in white space,
22078 '.' (in unified mode, or for Neon/VFP instructions), or end of string. */
22079 for (base
= end
= *str
; *end
!= '\0'; end
++)
22080 if (*end
== ' ' || *end
== '.')
22086 /* Handle a possible width suffix and/or Neon type suffix. */
22091 /* The .w and .n suffixes are only valid if the unified syntax is in
22093 if (unified_syntax
&& end
[1] == 'w')
22095 else if (unified_syntax
&& end
[1] == 'n')
22100 inst
.vectype
.elems
= 0;
22102 *str
= end
+ offset
;
22104 if (end
[offset
] == '.')
22106 /* See if we have a Neon type suffix (possible in either unified or
22107 non-unified ARM syntax mode). */
22108 if (parse_neon_type (&inst
.vectype
, str
) == FAIL
)
22111 else if (end
[offset
] != '\0' && end
[offset
] != ' ')
22117 /* Look for unaffixed or special-case affixed mnemonic. */
22118 opcode
= (const struct asm_opcode
*) hash_find_n (arm_ops_hsh
, base
,
22123 if (opcode
->tag
< OT_odd_infix_0
)
22125 inst
.cond
= COND_ALWAYS
;
22129 if (warn_on_deprecated
&& unified_syntax
)
22130 as_tsktsk (_("conditional infixes are deprecated in unified syntax"));
22131 affix
= base
+ (opcode
->tag
- OT_odd_infix_0
);
22132 cond
= (const struct asm_cond
*) hash_find_n (arm_cond_hsh
, affix
, 2);
22135 inst
.cond
= cond
->value
;
22138 if (ARM_CPU_HAS_FEATURE (cpu_variant
, mve_ext
))
22140 /* Cannot have a conditional suffix on a mnemonic of less than a character.
22142 if (end
- base
< 2)
22145 cond
= (const struct asm_cond
*) hash_find_n (arm_vcond_hsh
, affix
, 1);
22146 opcode
= (const struct asm_opcode
*) hash_find_n (arm_ops_hsh
, base
,
22148 /* If this opcode can not be vector predicated then don't accept it with a
22149 vector predication code. */
22150 if (opcode
&& !opcode
->mayBeVecPred
)
22153 if (!opcode
|| !cond
)
22155 /* Cannot have a conditional suffix on a mnemonic of less than two
22157 if (end
- base
< 3)
22160 /* Look for suffixed mnemonic. */
22162 cond
= (const struct asm_cond
*) hash_find_n (arm_cond_hsh
, affix
, 2);
22163 opcode
= (const struct asm_opcode
*) hash_find_n (arm_ops_hsh
, base
,
22167 if (opcode
&& cond
)
22170 switch (opcode
->tag
)
22172 case OT_cinfix3_legacy
:
22173 /* Ignore conditional suffixes matched on infix only mnemonics. */
22177 case OT_cinfix3_deprecated
:
22178 case OT_odd_infix_unc
:
22179 if (!unified_syntax
)
22181 /* Fall through. */
22185 case OT_csuf_or_in3
:
22186 inst
.cond
= cond
->value
;
22189 case OT_unconditional
:
22190 case OT_unconditionalF
:
22192 inst
.cond
= cond
->value
;
22195 /* Delayed diagnostic. */
22196 inst
.error
= BAD_COND
;
22197 inst
.cond
= COND_ALWAYS
;
22206 /* Cannot have a usual-position infix on a mnemonic of less than
22207 six characters (five would be a suffix). */
22208 if (end
- base
< 6)
22211 /* Look for infixed mnemonic in the usual position. */
22213 cond
= (const struct asm_cond
*) hash_find_n (arm_cond_hsh
, affix
, 2);
22217 memcpy (save
, affix
, 2);
22218 memmove (affix
, affix
+ 2, (end
- affix
) - 2);
22219 opcode
= (const struct asm_opcode
*) hash_find_n (arm_ops_hsh
, base
,
22221 memmove (affix
+ 2, affix
, (end
- affix
) - 2);
22222 memcpy (affix
, save
, 2);
22225 && (opcode
->tag
== OT_cinfix3
22226 || opcode
->tag
== OT_cinfix3_deprecated
22227 || opcode
->tag
== OT_csuf_or_in3
22228 || opcode
->tag
== OT_cinfix3_legacy
))
22231 if (warn_on_deprecated
&& unified_syntax
22232 && (opcode
->tag
== OT_cinfix3
22233 || opcode
->tag
== OT_cinfix3_deprecated
))
22234 as_tsktsk (_("conditional infixes are deprecated in unified syntax"));
22236 inst
.cond
= cond
->value
;
22243 /* This function generates an initial IT instruction, leaving its block
22244 virtually open for the new instructions. Eventually,
22245 the mask will be updated by now_pred_add_mask () each time
22246 a new instruction needs to be included in the IT block.
22247 Finally, the block is closed with close_automatic_it_block ().
22248 The block closure can be requested either from md_assemble (),
22249 a tencode (), or due to a label hook. */
22252 new_automatic_it_block (int cond
)
22254 now_pred
.state
= AUTOMATIC_PRED_BLOCK
;
22255 now_pred
.mask
= 0x18;
22256 now_pred
.cc
= cond
;
22257 now_pred
.block_length
= 1;
22258 mapping_state (MAP_THUMB
);
22259 now_pred
.insn
= output_it_inst (cond
, now_pred
.mask
, NULL
);
22260 now_pred
.warn_deprecated
= FALSE
;
22261 now_pred
.insn_cond
= TRUE
;
22264 /* Close an automatic IT block.
22265 See comments in new_automatic_it_block (). */
22268 close_automatic_it_block (void)
22270 now_pred
.mask
= 0x10;
22271 now_pred
.block_length
= 0;
22274 /* Update the mask of the current automatically-generated IT
22275 instruction. See comments in new_automatic_it_block (). */
22278 now_pred_add_mask (int cond
)
22280 #define CLEAR_BIT(value, nbit) ((value) & ~(1 << (nbit)))
22281 #define SET_BIT_VALUE(value, bitvalue, nbit) (CLEAR_BIT (value, nbit) \
22282 | ((bitvalue) << (nbit)))
22283 const int resulting_bit
= (cond
& 1);
22285 now_pred
.mask
&= 0xf;
22286 now_pred
.mask
= SET_BIT_VALUE (now_pred
.mask
,
22288 (5 - now_pred
.block_length
));
22289 now_pred
.mask
= SET_BIT_VALUE (now_pred
.mask
,
22291 ((5 - now_pred
.block_length
) - 1));
22292 output_it_inst (now_pred
.cc
, now_pred
.mask
, now_pred
.insn
);
22295 #undef SET_BIT_VALUE
22298 /* The IT blocks handling machinery is accessed through the these functions:
22299 it_fsm_pre_encode () from md_assemble ()
22300 set_pred_insn_type () optional, from the tencode functions
22301 set_pred_insn_type_last () ditto
22302 in_pred_block () ditto
22303 it_fsm_post_encode () from md_assemble ()
22304 force_automatic_it_block_close () from label handling functions
22307 1) md_assemble () calls it_fsm_pre_encode () before calling tencode (),
22308 initializing the IT insn type with a generic initial value depending
22309 on the inst.condition.
22310 2) During the tencode function, two things may happen:
22311 a) The tencode function overrides the IT insn type by
22312 calling either set_pred_insn_type (type) or
22313 set_pred_insn_type_last ().
22314 b) The tencode function queries the IT block state by
22315 calling in_pred_block () (i.e. to determine narrow/not narrow mode).
22317 Both set_pred_insn_type and in_pred_block run the internal FSM state
22318 handling function (handle_pred_state), because: a) setting the IT insn
22319 type may incur in an invalid state (exiting the function),
22320 and b) querying the state requires the FSM to be updated.
22321 Specifically we want to avoid creating an IT block for conditional
22322 branches, so it_fsm_pre_encode is actually a guess and we can't
22323 determine whether an IT block is required until the tencode () routine
22324 has decided what type of instruction this actually it.
22325 Because of this, if set_pred_insn_type and in_pred_block have to be
22326 used, set_pred_insn_type has to be called first.
22328 set_pred_insn_type_last () is a wrapper of set_pred_insn_type (type),
22329 that determines the insn IT type depending on the inst.cond code.
22330 When a tencode () routine encodes an instruction that can be
22331 either outside an IT block, or, in the case of being inside, has to be
22332 the last one, set_pred_insn_type_last () will determine the proper
22333 IT instruction type based on the inst.cond code. Otherwise,
22334 set_pred_insn_type can be called for overriding that logic or
22335 for covering other cases.
22337 Calling handle_pred_state () may not transition the IT block state to
22338 OUTSIDE_PRED_BLOCK immediately, since the (current) state could be
22339 still queried. Instead, if the FSM determines that the state should
22340 be transitioned to OUTSIDE_PRED_BLOCK, a flag is marked to be closed
22341 after the tencode () function: that's what it_fsm_post_encode () does.
22343 Since in_pred_block () calls the state handling function to get an
22344 updated state, an error may occur (due to invalid insns combination).
22345 In that case, inst.error is set.
22346 Therefore, inst.error has to be checked after the execution of
22347 the tencode () routine.
22349 3) Back in md_assemble(), it_fsm_post_encode () is called to commit
22350 any pending state change (if any) that didn't take place in
22351 handle_pred_state () as explained above. */
22354 it_fsm_pre_encode (void)
22356 if (inst
.cond
!= COND_ALWAYS
)
22357 inst
.pred_insn_type
= INSIDE_IT_INSN
;
22359 inst
.pred_insn_type
= OUTSIDE_PRED_INSN
;
22361 now_pred
.state_handled
= 0;
22364 /* IT state FSM handling function. */
22365 /* MVE instructions and non-MVE instructions are handled differently because of
22366 the introduction of VPT blocks.
22367 Specifications say that any non-MVE instruction inside a VPT block is
22368 UNPREDICTABLE, with the exception of the BKPT instruction. Whereas most MVE
22369 instructions are deemed to be UNPREDICTABLE if inside an IT block. For the
22370 few exceptions we have MVE_UNPREDICABLE_INSN.
22371 The error messages provided depending on the different combinations possible
22372 are described in the cases below:
22373 For 'most' MVE instructions:
22374 1) In an IT block, with an IT code: syntax error
22375 2) In an IT block, with a VPT code: error: must be in a VPT block
22376 3) In an IT block, with no code: warning: UNPREDICTABLE
22377 4) In a VPT block, with an IT code: syntax error
22378 5) In a VPT block, with a VPT code: OK!
22379 6) In a VPT block, with no code: error: missing code
22380 7) Outside a pred block, with an IT code: error: syntax error
22381 8) Outside a pred block, with a VPT code: error: should be in a VPT block
22382 9) Outside a pred block, with no code: OK!
22383 For non-MVE instructions:
22384 10) In an IT block, with an IT code: OK!
22385 11) In an IT block, with a VPT code: syntax error
22386 12) In an IT block, with no code: error: missing code
22387 13) In a VPT block, with an IT code: error: should be in an IT block
22388 14) In a VPT block, with a VPT code: syntax error
22389 15) In a VPT block, with no code: UNPREDICTABLE
22390 16) Outside a pred block, with an IT code: error: should be in an IT block
22391 17) Outside a pred block, with a VPT code: syntax error
22392 18) Outside a pred block, with no code: OK!
22397 handle_pred_state (void)
22399 now_pred
.state_handled
= 1;
22400 now_pred
.insn_cond
= FALSE
;
22402 switch (now_pred
.state
)
22404 case OUTSIDE_PRED_BLOCK
:
22405 switch (inst
.pred_insn_type
)
22407 case MVE_UNPREDICABLE_INSN
:
22408 case MVE_OUTSIDE_PRED_INSN
:
22409 if (inst
.cond
< COND_ALWAYS
)
22411 /* Case 7: Outside a pred block, with an IT code: error: syntax
22413 inst
.error
= BAD_SYNTAX
;
22416 /* Case 9: Outside a pred block, with no code: OK! */
22418 case OUTSIDE_PRED_INSN
:
22419 if (inst
.cond
> COND_ALWAYS
)
22421 /* Case 17: Outside a pred block, with a VPT code: syntax error.
22423 inst
.error
= BAD_SYNTAX
;
22426 /* Case 18: Outside a pred block, with no code: OK! */
22429 case INSIDE_VPT_INSN
:
22430 /* Case 8: Outside a pred block, with a VPT code: error: should be in
22432 inst
.error
= BAD_OUT_VPT
;
22435 case INSIDE_IT_INSN
:
22436 case INSIDE_IT_LAST_INSN
:
22437 if (inst
.cond
< COND_ALWAYS
)
22439 /* Case 16: Outside a pred block, with an IT code: error: should
22440 be in an IT block. */
22441 if (thumb_mode
== 0)
22444 && !(implicit_it_mode
& IMPLICIT_IT_MODE_ARM
))
22445 as_tsktsk (_("Warning: conditional outside an IT block"\
22450 if ((implicit_it_mode
& IMPLICIT_IT_MODE_THUMB
)
22451 && ARM_CPU_HAS_FEATURE (cpu_variant
, arm_ext_v6t2
))
22453 /* Automatically generate the IT instruction. */
22454 new_automatic_it_block (inst
.cond
);
22455 if (inst
.pred_insn_type
== INSIDE_IT_LAST_INSN
)
22456 close_automatic_it_block ();
22460 inst
.error
= BAD_OUT_IT
;
22466 else if (inst
.cond
> COND_ALWAYS
)
22468 /* Case 17: Outside a pred block, with a VPT code: syntax error.
22470 inst
.error
= BAD_SYNTAX
;
22475 case IF_INSIDE_IT_LAST_INSN
:
22476 case NEUTRAL_IT_INSN
:
22480 if (inst
.cond
!= COND_ALWAYS
)
22481 first_error (BAD_SYNTAX
);
22482 now_pred
.state
= MANUAL_PRED_BLOCK
;
22483 now_pred
.block_length
= 0;
22484 now_pred
.type
= VECTOR_PRED
;
22488 now_pred
.state
= MANUAL_PRED_BLOCK
;
22489 now_pred
.block_length
= 0;
22490 now_pred
.type
= SCALAR_PRED
;
22495 case AUTOMATIC_PRED_BLOCK
:
22496 /* Three things may happen now:
22497 a) We should increment current it block size;
22498 b) We should close current it block (closing insn or 4 insns);
22499 c) We should close current it block and start a new one (due
22500 to incompatible conditions or
22501 4 insns-length block reached). */
22503 switch (inst
.pred_insn_type
)
22505 case INSIDE_VPT_INSN
:
22507 case MVE_UNPREDICABLE_INSN
:
22508 case MVE_OUTSIDE_PRED_INSN
:
22510 case OUTSIDE_PRED_INSN
:
22511 /* The closure of the block shall happen immediately,
22512 so any in_pred_block () call reports the block as closed. */
22513 force_automatic_it_block_close ();
22516 case INSIDE_IT_INSN
:
22517 case INSIDE_IT_LAST_INSN
:
22518 case IF_INSIDE_IT_LAST_INSN
:
22519 now_pred
.block_length
++;
22521 if (now_pred
.block_length
> 4
22522 || !now_pred_compatible (inst
.cond
))
22524 force_automatic_it_block_close ();
22525 if (inst
.pred_insn_type
!= IF_INSIDE_IT_LAST_INSN
)
22526 new_automatic_it_block (inst
.cond
);
22530 now_pred
.insn_cond
= TRUE
;
22531 now_pred_add_mask (inst
.cond
);
22534 if (now_pred
.state
== AUTOMATIC_PRED_BLOCK
22535 && (inst
.pred_insn_type
== INSIDE_IT_LAST_INSN
22536 || inst
.pred_insn_type
== IF_INSIDE_IT_LAST_INSN
))
22537 close_automatic_it_block ();
22540 case NEUTRAL_IT_INSN
:
22541 now_pred
.block_length
++;
22542 now_pred
.insn_cond
= TRUE
;
22544 if (now_pred
.block_length
> 4)
22545 force_automatic_it_block_close ();
22547 now_pred_add_mask (now_pred
.cc
& 1);
22551 close_automatic_it_block ();
22552 now_pred
.state
= MANUAL_PRED_BLOCK
;
22557 case MANUAL_PRED_BLOCK
:
22560 if (now_pred
.type
== SCALAR_PRED
)
22562 /* Check conditional suffixes. */
22563 cond
= now_pred
.cc
^ ((now_pred
.mask
>> 4) & 1) ^ 1;
22564 now_pred
.mask
<<= 1;
22565 now_pred
.mask
&= 0x1f;
22566 is_last
= (now_pred
.mask
== 0x10);
22570 now_pred
.cc
^= (now_pred
.mask
>> 4);
22571 cond
= now_pred
.cc
+ 0xf;
22572 now_pred
.mask
<<= 1;
22573 now_pred
.mask
&= 0x1f;
22574 is_last
= now_pred
.mask
== 0x10;
22576 now_pred
.insn_cond
= TRUE
;
22578 switch (inst
.pred_insn_type
)
22580 case OUTSIDE_PRED_INSN
:
22581 if (now_pred
.type
== SCALAR_PRED
)
22583 if (inst
.cond
== COND_ALWAYS
)
22585 /* Case 12: In an IT block, with no code: error: missing
22587 inst
.error
= BAD_NOT_IT
;
22590 else if (inst
.cond
> COND_ALWAYS
)
22592 /* Case 11: In an IT block, with a VPT code: syntax error.
22594 inst
.error
= BAD_SYNTAX
;
22597 else if (thumb_mode
)
22599 /* This is for some special cases where a non-MVE
22600 instruction is not allowed in an IT block, such as cbz,
22601 but are put into one with a condition code.
22602 You could argue this should be a syntax error, but we
22603 gave the 'not allowed in IT block' diagnostic in the
22604 past so we will keep doing so. */
22605 inst
.error
= BAD_NOT_IT
;
22612 /* Case 15: In a VPT block, with no code: UNPREDICTABLE. */
22613 as_tsktsk (MVE_NOT_VPT
);
22616 case MVE_OUTSIDE_PRED_INSN
:
22617 if (now_pred
.type
== SCALAR_PRED
)
22619 if (inst
.cond
== COND_ALWAYS
)
22621 /* Case 3: In an IT block, with no code: warning:
22623 as_tsktsk (MVE_NOT_IT
);
22626 else if (inst
.cond
< COND_ALWAYS
)
22628 /* Case 1: In an IT block, with an IT code: syntax error.
22630 inst
.error
= BAD_SYNTAX
;
22638 if (inst
.cond
< COND_ALWAYS
)
22640 /* Case 4: In a VPT block, with an IT code: syntax error.
22642 inst
.error
= BAD_SYNTAX
;
22645 else if (inst
.cond
== COND_ALWAYS
)
22647 /* Case 6: In a VPT block, with no code: error: missing
22649 inst
.error
= BAD_NOT_VPT
;
22657 case MVE_UNPREDICABLE_INSN
:
22658 as_tsktsk (now_pred
.type
== SCALAR_PRED
? MVE_NOT_IT
: MVE_NOT_VPT
);
22660 case INSIDE_IT_INSN
:
22661 if (inst
.cond
> COND_ALWAYS
)
22663 /* Case 11: In an IT block, with a VPT code: syntax error. */
22664 /* Case 14: In a VPT block, with a VPT code: syntax error. */
22665 inst
.error
= BAD_SYNTAX
;
22668 else if (now_pred
.type
== SCALAR_PRED
)
22670 /* Case 10: In an IT block, with an IT code: OK! */
22671 if (cond
!= inst
.cond
)
22673 inst
.error
= now_pred
.type
== SCALAR_PRED
? BAD_IT_COND
:
22680 /* Case 13: In a VPT block, with an IT code: error: should be
22682 inst
.error
= BAD_OUT_IT
;
22687 case INSIDE_VPT_INSN
:
22688 if (now_pred
.type
== SCALAR_PRED
)
22690 /* Case 2: In an IT block, with a VPT code: error: must be in a
22692 inst
.error
= BAD_OUT_VPT
;
22695 /* Case 5: In a VPT block, with a VPT code: OK! */
22696 else if (cond
!= inst
.cond
)
22698 inst
.error
= BAD_VPT_COND
;
22702 case INSIDE_IT_LAST_INSN
:
22703 case IF_INSIDE_IT_LAST_INSN
:
22704 if (now_pred
.type
== VECTOR_PRED
|| inst
.cond
> COND_ALWAYS
)
22706 /* Case 4: In a VPT block, with an IT code: syntax error. */
22707 /* Case 11: In an IT block, with a VPT code: syntax error. */
22708 inst
.error
= BAD_SYNTAX
;
22711 else if (cond
!= inst
.cond
)
22713 inst
.error
= BAD_IT_COND
;
22718 inst
.error
= BAD_BRANCH
;
22723 case NEUTRAL_IT_INSN
:
22724 /* The BKPT instruction is unconditional even in a IT or VPT
22729 if (now_pred
.type
== SCALAR_PRED
)
22731 inst
.error
= BAD_IT_IT
;
22734 /* fall through. */
22736 if (inst
.cond
== COND_ALWAYS
)
22738 /* Executing a VPT/VPST instruction inside an IT block or a
22739 VPT/VPST/IT instruction inside a VPT block is UNPREDICTABLE.
22741 if (now_pred
.type
== SCALAR_PRED
)
22742 as_tsktsk (MVE_NOT_IT
);
22744 as_tsktsk (MVE_NOT_VPT
);
22749 /* VPT/VPST do not accept condition codes. */
22750 inst
.error
= BAD_SYNTAX
;
22761 struct depr_insn_mask
22763 unsigned long pattern
;
22764 unsigned long mask
;
22765 const char* description
;
22768 /* List of 16-bit instruction patterns deprecated in an IT block in
22770 static const struct depr_insn_mask depr_it_insns
[] = {
22771 { 0xc000, 0xc000, N_("Short branches, Undefined, SVC, LDM/STM") },
22772 { 0xb000, 0xb000, N_("Miscellaneous 16-bit instructions") },
22773 { 0xa000, 0xb800, N_("ADR") },
22774 { 0x4800, 0xf800, N_("Literal loads") },
22775 { 0x4478, 0xf478, N_("Hi-register ADD, MOV, CMP, BX, BLX using pc") },
22776 { 0x4487, 0xfc87, N_("Hi-register ADD, MOV, CMP using pc") },
22777 /* NOTE: 0x00dd is not the real encoding, instead, it is the 'tvalue'
22778 field in asm_opcode. 'tvalue' is used at the stage this check happen. */
22779 { 0x00dd, 0x7fff, N_("ADD/SUB sp, sp #imm") },
22784 it_fsm_post_encode (void)
22788 if (!now_pred
.state_handled
)
22789 handle_pred_state ();
22791 if (now_pred
.insn_cond
22792 && warn_on_restrict_it
22793 && !now_pred
.warn_deprecated
22794 && warn_on_deprecated
22795 && ARM_CPU_HAS_FEATURE (cpu_variant
, arm_ext_v8
)
22796 && !ARM_CPU_HAS_FEATURE (cpu_variant
, arm_ext_m
))
22798 if (inst
.instruction
>= 0x10000)
22800 as_tsktsk (_("IT blocks containing 32-bit Thumb instructions are "
22801 "performance deprecated in ARMv8-A and ARMv8-R"));
22802 now_pred
.warn_deprecated
= TRUE
;
22806 const struct depr_insn_mask
*p
= depr_it_insns
;
22808 while (p
->mask
!= 0)
22810 if ((inst
.instruction
& p
->mask
) == p
->pattern
)
22812 as_tsktsk (_("IT blocks containing 16-bit Thumb "
22813 "instructions of the following class are "
22814 "performance deprecated in ARMv8-A and "
22815 "ARMv8-R: %s"), p
->description
);
22816 now_pred
.warn_deprecated
= TRUE
;
22824 if (now_pred
.block_length
> 1)
22826 as_tsktsk (_("IT blocks containing more than one conditional "
22827 "instruction are performance deprecated in ARMv8-A and "
22829 now_pred
.warn_deprecated
= TRUE
;
22833 is_last
= (now_pred
.mask
== 0x10);
22836 now_pred
.state
= OUTSIDE_PRED_BLOCK
;
22842 force_automatic_it_block_close (void)
22844 if (now_pred
.state
== AUTOMATIC_PRED_BLOCK
)
22846 close_automatic_it_block ();
22847 now_pred
.state
= OUTSIDE_PRED_BLOCK
;
22853 in_pred_block (void)
22855 if (!now_pred
.state_handled
)
22856 handle_pred_state ();
22858 return now_pred
.state
!= OUTSIDE_PRED_BLOCK
;
22861 /* Whether OPCODE only has T32 encoding. Since this function is only used by
22862 t32_insn_ok, OPCODE enabled by v6t2 extension bit do not need to be listed
22863 here, hence the "known" in the function name. */
22866 known_t32_only_insn (const struct asm_opcode
*opcode
)
22868 /* Original Thumb-1 wide instruction. */
22869 if (opcode
->tencode
== do_t_blx
22870 || opcode
->tencode
== do_t_branch23
22871 || ARM_CPU_HAS_FEATURE (*opcode
->tvariant
, arm_ext_msr
)
22872 || ARM_CPU_HAS_FEATURE (*opcode
->tvariant
, arm_ext_barrier
))
22875 /* Wide-only instruction added to ARMv8-M Baseline. */
22876 if (ARM_CPU_HAS_FEATURE (*opcode
->tvariant
, arm_ext_v8m_m_only
)
22877 || ARM_CPU_HAS_FEATURE (*opcode
->tvariant
, arm_ext_atomics
)
22878 || ARM_CPU_HAS_FEATURE (*opcode
->tvariant
, arm_ext_v6t2_v8m
)
22879 || ARM_CPU_HAS_FEATURE (*opcode
->tvariant
, arm_ext_div
))
22885 /* Whether wide instruction variant can be used if available for a valid OPCODE
22889 t32_insn_ok (arm_feature_set arch
, const struct asm_opcode
*opcode
)
22891 if (known_t32_only_insn (opcode
))
22894 /* Instruction with narrow and wide encoding added to ARMv8-M. Availability
22895 of variant T3 of B.W is checked in do_t_branch. */
22896 if (ARM_CPU_HAS_FEATURE (arch
, arm_ext_v8m
)
22897 && opcode
->tencode
== do_t_branch
)
22900 /* MOV accepts T1/T3 encodings under Baseline, T3 encoding is 32bit. */
22901 if (ARM_CPU_HAS_FEATURE (arch
, arm_ext_v8m
)
22902 && opcode
->tencode
== do_t_mov_cmp
22903 /* Make sure CMP instruction is not affected. */
22904 && opcode
->aencode
== do_mov
)
22907 /* Wide instruction variants of all instructions with narrow *and* wide
22908 variants become available with ARMv6t2. Other opcodes are either
22909 narrow-only or wide-only and are thus available if OPCODE is valid. */
22910 if (ARM_CPU_HAS_FEATURE (arch
, arm_ext_v6t2
))
22913 /* OPCODE with narrow only instruction variant or wide variant not
22919 md_assemble (char *str
)
22922 const struct asm_opcode
* opcode
;
22924 /* Align the previous label if needed. */
22925 if (last_label_seen
!= NULL
)
22927 symbol_set_frag (last_label_seen
, frag_now
);
22928 S_SET_VALUE (last_label_seen
, (valueT
) frag_now_fix ());
22929 S_SET_SEGMENT (last_label_seen
, now_seg
);
22932 memset (&inst
, '\0', sizeof (inst
));
22934 for (r
= 0; r
< ARM_IT_MAX_RELOCS
; r
++)
22935 inst
.relocs
[r
].type
= BFD_RELOC_UNUSED
;
22937 opcode
= opcode_lookup (&p
);
22940 /* It wasn't an instruction, but it might be a register alias of
22941 the form alias .req reg, or a Neon .dn/.qn directive. */
22942 if (! create_register_alias (str
, p
)
22943 && ! create_neon_reg_alias (str
, p
))
22944 as_bad (_("bad instruction `%s'"), str
);
22949 if (warn_on_deprecated
&& opcode
->tag
== OT_cinfix3_deprecated
)
22950 as_tsktsk (_("s suffix on comparison instruction is deprecated"));
22952 /* The value which unconditional instructions should have in place of the
22953 condition field. */
22954 inst
.uncond_value
= (opcode
->tag
== OT_csuffixF
) ? 0xf : -1;
22958 arm_feature_set variant
;
22960 variant
= cpu_variant
;
22961 /* Only allow coprocessor instructions on Thumb-2 capable devices. */
22962 if (!ARM_CPU_HAS_FEATURE (variant
, arm_arch_t2
))
22963 ARM_CLEAR_FEATURE (variant
, variant
, fpu_any_hard
);
22964 /* Check that this instruction is supported for this CPU. */
22965 if (!opcode
->tvariant
22966 || (thumb_mode
== 1
22967 && !ARM_CPU_HAS_FEATURE (variant
, *opcode
->tvariant
)))
22969 if (opcode
->tencode
== do_t_swi
)
22970 as_bad (_("SVC is not permitted on this architecture"));
22972 as_bad (_("selected processor does not support `%s' in Thumb mode"), str
);
22975 if (inst
.cond
!= COND_ALWAYS
&& !unified_syntax
22976 && opcode
->tencode
!= do_t_branch
)
22978 as_bad (_("Thumb does not support conditional execution"));
22982 /* Two things are addressed here:
22983 1) Implicit require narrow instructions on Thumb-1.
22984 This avoids relaxation accidentally introducing Thumb-2
22986 2) Reject wide instructions in non Thumb-2 cores.
22988 Only instructions with narrow and wide variants need to be handled
22989 but selecting all non wide-only instructions is easier. */
22990 if (!ARM_CPU_HAS_FEATURE (variant
, arm_ext_v6t2
)
22991 && !t32_insn_ok (variant
, opcode
))
22993 if (inst
.size_req
== 0)
22995 else if (inst
.size_req
== 4)
22997 if (ARM_CPU_HAS_FEATURE (variant
, arm_ext_v8m
))
22998 as_bad (_("selected processor does not support 32bit wide "
22999 "variant of instruction `%s'"), str
);
23001 as_bad (_("selected processor does not support `%s' in "
23002 "Thumb-2 mode"), str
);
23007 inst
.instruction
= opcode
->tvalue
;
23009 if (!parse_operands (p
, opcode
->operands
, /*thumb=*/TRUE
))
23011 /* Prepare the pred_insn_type for those encodings that don't set
23013 it_fsm_pre_encode ();
23015 opcode
->tencode ();
23017 it_fsm_post_encode ();
23020 if (!(inst
.error
|| inst
.relax
))
23022 gas_assert (inst
.instruction
< 0xe800 || inst
.instruction
> 0xffff);
23023 inst
.size
= (inst
.instruction
> 0xffff ? 4 : 2);
23024 if (inst
.size_req
&& inst
.size_req
!= inst
.size
)
23026 as_bad (_("cannot honor width suffix -- `%s'"), str
);
23031 /* Something has gone badly wrong if we try to relax a fixed size
23033 gas_assert (inst
.size_req
== 0 || !inst
.relax
);
23035 ARM_MERGE_FEATURE_SETS (thumb_arch_used
, thumb_arch_used
,
23036 *opcode
->tvariant
);
23037 /* Many Thumb-2 instructions also have Thumb-1 variants, so explicitly
23038 set those bits when Thumb-2 32-bit instructions are seen. The impact
23039 of relaxable instructions will be considered later after we finish all
23041 if (ARM_FEATURE_CORE_EQUAL (cpu_variant
, arm_arch_any
))
23042 variant
= arm_arch_none
;
23044 variant
= cpu_variant
;
23045 if (inst
.size
== 4 && !t32_insn_ok (variant
, opcode
))
23046 ARM_MERGE_FEATURE_SETS (thumb_arch_used
, thumb_arch_used
,
23049 check_neon_suffixes
;
23053 mapping_state (MAP_THUMB
);
23056 else if (ARM_CPU_HAS_FEATURE (cpu_variant
, arm_ext_v1
))
23060 /* bx is allowed on v5 cores, and sometimes on v4 cores. */
23061 is_bx
= (opcode
->aencode
== do_bx
);
23063 /* Check that this instruction is supported for this CPU. */
23064 if (!(is_bx
&& fix_v4bx
)
23065 && !(opcode
->avariant
&&
23066 ARM_CPU_HAS_FEATURE (cpu_variant
, *opcode
->avariant
)))
23068 as_bad (_("selected processor does not support `%s' in ARM mode"), str
);
23073 as_bad (_("width suffixes are invalid in ARM mode -- `%s'"), str
);
23077 inst
.instruction
= opcode
->avalue
;
23078 if (opcode
->tag
== OT_unconditionalF
)
23079 inst
.instruction
|= 0xFU
<< 28;
23081 inst
.instruction
|= inst
.cond
<< 28;
23082 inst
.size
= INSN_SIZE
;
23083 if (!parse_operands (p
, opcode
->operands
, /*thumb=*/FALSE
))
23085 it_fsm_pre_encode ();
23086 opcode
->aencode ();
23087 it_fsm_post_encode ();
23089 /* Arm mode bx is marked as both v4T and v5 because it's still required
23090 on a hypothetical non-thumb v5 core. */
23092 ARM_MERGE_FEATURE_SETS (arm_arch_used
, arm_arch_used
, arm_ext_v4t
);
23094 ARM_MERGE_FEATURE_SETS (arm_arch_used
, arm_arch_used
,
23095 *opcode
->avariant
);
23097 check_neon_suffixes
;
23101 mapping_state (MAP_ARM
);
23106 as_bad (_("attempt to use an ARM instruction on a Thumb-only processor "
23114 check_pred_blocks_finished (void)
23119 for (sect
= stdoutput
->sections
; sect
!= NULL
; sect
= sect
->next
)
23120 if (seg_info (sect
)->tc_segment_info_data
.current_pred
.state
23121 == MANUAL_PRED_BLOCK
)
23123 if (now_pred
.type
== SCALAR_PRED
)
23124 as_warn (_("section '%s' finished with an open IT block."),
23127 as_warn (_("section '%s' finished with an open VPT/VPST block."),
23131 if (now_pred
.state
== MANUAL_PRED_BLOCK
)
23133 if (now_pred
.type
== SCALAR_PRED
)
23134 as_warn (_("file finished with an open IT block."));
23136 as_warn (_("file finished with an open VPT/VPST block."));
23141 /* Various frobbings of labels and their addresses. */
23144 arm_start_line_hook (void)
23146 last_label_seen
= NULL
;
23150 arm_frob_label (symbolS
* sym
)
23152 last_label_seen
= sym
;
23154 ARM_SET_THUMB (sym
, thumb_mode
);
23156 #if defined OBJ_COFF || defined OBJ_ELF
23157 ARM_SET_INTERWORK (sym
, support_interwork
);
23160 force_automatic_it_block_close ();
23162 /* Note - do not allow local symbols (.Lxxx) to be labelled
23163 as Thumb functions. This is because these labels, whilst
23164 they exist inside Thumb code, are not the entry points for
23165 possible ARM->Thumb calls. Also, these labels can be used
23166 as part of a computed goto or switch statement. eg gcc
23167 can generate code that looks like this:
23169 ldr r2, [pc, .Laaa]
23179 The first instruction loads the address of the jump table.
23180 The second instruction converts a table index into a byte offset.
23181 The third instruction gets the jump address out of the table.
23182 The fourth instruction performs the jump.
23184 If the address stored at .Laaa is that of a symbol which has the
23185 Thumb_Func bit set, then the linker will arrange for this address
23186 to have the bottom bit set, which in turn would mean that the
23187 address computation performed by the third instruction would end
23188 up with the bottom bit set. Since the ARM is capable of unaligned
23189 word loads, the instruction would then load the incorrect address
23190 out of the jump table, and chaos would ensue. */
23191 if (label_is_thumb_function_name
23192 && (S_GET_NAME (sym
)[0] != '.' || S_GET_NAME (sym
)[1] != 'L')
23193 && (bfd_section_flags (now_seg
) & SEC_CODE
) != 0)
23195 /* When the address of a Thumb function is taken the bottom
23196 bit of that address should be set. This will allow
23197 interworking between Arm and Thumb functions to work
23200 THUMB_SET_FUNC (sym
, 1);
23202 label_is_thumb_function_name
= FALSE
;
23205 dwarf2_emit_label (sym
);
23209 arm_data_in_code (void)
23211 if (thumb_mode
&& ! strncmp (input_line_pointer
+ 1, "data:", 5))
23213 *input_line_pointer
= '/';
23214 input_line_pointer
+= 5;
23215 *input_line_pointer
= 0;
23223 arm_canonicalize_symbol_name (char * name
)
23227 if (thumb_mode
&& (len
= strlen (name
)) > 5
23228 && streq (name
+ len
- 5, "/data"))
23229 *(name
+ len
- 5) = 0;
23234 /* Table of all register names defined by default. The user can
23235 define additional names with .req. Note that all register names
23236 should appear in both upper and lowercase variants. Some registers
23237 also have mixed-case names. */
23239 #define REGDEF(s,n,t) { #s, n, REG_TYPE_##t, TRUE, 0 }
23240 #define REGNUM(p,n,t) REGDEF(p##n, n, t)
23241 #define REGNUM2(p,n,t) REGDEF(p##n, 2 * n, t)
23242 #define REGSET(p,t) \
23243 REGNUM(p, 0,t), REGNUM(p, 1,t), REGNUM(p, 2,t), REGNUM(p, 3,t), \
23244 REGNUM(p, 4,t), REGNUM(p, 5,t), REGNUM(p, 6,t), REGNUM(p, 7,t), \
23245 REGNUM(p, 8,t), REGNUM(p, 9,t), REGNUM(p,10,t), REGNUM(p,11,t), \
23246 REGNUM(p,12,t), REGNUM(p,13,t), REGNUM(p,14,t), REGNUM(p,15,t)
23247 #define REGSETH(p,t) \
23248 REGNUM(p,16,t), REGNUM(p,17,t), REGNUM(p,18,t), REGNUM(p,19,t), \
23249 REGNUM(p,20,t), REGNUM(p,21,t), REGNUM(p,22,t), REGNUM(p,23,t), \
23250 REGNUM(p,24,t), REGNUM(p,25,t), REGNUM(p,26,t), REGNUM(p,27,t), \
23251 REGNUM(p,28,t), REGNUM(p,29,t), REGNUM(p,30,t), REGNUM(p,31,t)
23252 #define REGSET2(p,t) \
23253 REGNUM2(p, 0,t), REGNUM2(p, 1,t), REGNUM2(p, 2,t), REGNUM2(p, 3,t), \
23254 REGNUM2(p, 4,t), REGNUM2(p, 5,t), REGNUM2(p, 6,t), REGNUM2(p, 7,t), \
23255 REGNUM2(p, 8,t), REGNUM2(p, 9,t), REGNUM2(p,10,t), REGNUM2(p,11,t), \
23256 REGNUM2(p,12,t), REGNUM2(p,13,t), REGNUM2(p,14,t), REGNUM2(p,15,t)
23257 #define SPLRBANK(base,bank,t) \
23258 REGDEF(lr_##bank, 768|((base+0)<<16), t), \
23259 REGDEF(sp_##bank, 768|((base+1)<<16), t), \
23260 REGDEF(spsr_##bank, 768|(base<<16)|SPSR_BIT, t), \
23261 REGDEF(LR_##bank, 768|((base+0)<<16), t), \
23262 REGDEF(SP_##bank, 768|((base+1)<<16), t), \
23263 REGDEF(SPSR_##bank, 768|(base<<16)|SPSR_BIT, t)
23265 static const struct reg_entry reg_names
[] =
23267 /* ARM integer registers. */
23268 REGSET(r
, RN
), REGSET(R
, RN
),
23270 /* ATPCS synonyms. */
23271 REGDEF(a1
,0,RN
), REGDEF(a2
,1,RN
), REGDEF(a3
, 2,RN
), REGDEF(a4
, 3,RN
),
23272 REGDEF(v1
,4,RN
), REGDEF(v2
,5,RN
), REGDEF(v3
, 6,RN
), REGDEF(v4
, 7,RN
),
23273 REGDEF(v5
,8,RN
), REGDEF(v6
,9,RN
), REGDEF(v7
,10,RN
), REGDEF(v8
,11,RN
),
23275 REGDEF(A1
,0,RN
), REGDEF(A2
,1,RN
), REGDEF(A3
, 2,RN
), REGDEF(A4
, 3,RN
),
23276 REGDEF(V1
,4,RN
), REGDEF(V2
,5,RN
), REGDEF(V3
, 6,RN
), REGDEF(V4
, 7,RN
),
23277 REGDEF(V5
,8,RN
), REGDEF(V6
,9,RN
), REGDEF(V7
,10,RN
), REGDEF(V8
,11,RN
),
23279 /* Well-known aliases. */
23280 REGDEF(wr
, 7,RN
), REGDEF(sb
, 9,RN
), REGDEF(sl
,10,RN
), REGDEF(fp
,11,RN
),
23281 REGDEF(ip
,12,RN
), REGDEF(sp
,13,RN
), REGDEF(lr
,14,RN
), REGDEF(pc
,15,RN
),
23283 REGDEF(WR
, 7,RN
), REGDEF(SB
, 9,RN
), REGDEF(SL
,10,RN
), REGDEF(FP
,11,RN
),
23284 REGDEF(IP
,12,RN
), REGDEF(SP
,13,RN
), REGDEF(LR
,14,RN
), REGDEF(PC
,15,RN
),
23286 /* Defining the new Zero register from ARMv8.1-M. */
23290 /* Coprocessor numbers. */
23291 REGSET(p
, CP
), REGSET(P
, CP
),
23293 /* Coprocessor register numbers. The "cr" variants are for backward
23295 REGSET(c
, CN
), REGSET(C
, CN
),
23296 REGSET(cr
, CN
), REGSET(CR
, CN
),
23298 /* ARM banked registers. */
23299 REGDEF(R8_usr
,512|(0<<16),RNB
), REGDEF(r8_usr
,512|(0<<16),RNB
),
23300 REGDEF(R9_usr
,512|(1<<16),RNB
), REGDEF(r9_usr
,512|(1<<16),RNB
),
23301 REGDEF(R10_usr
,512|(2<<16),RNB
), REGDEF(r10_usr
,512|(2<<16),RNB
),
23302 REGDEF(R11_usr
,512|(3<<16),RNB
), REGDEF(r11_usr
,512|(3<<16),RNB
),
23303 REGDEF(R12_usr
,512|(4<<16),RNB
), REGDEF(r12_usr
,512|(4<<16),RNB
),
23304 REGDEF(SP_usr
,512|(5<<16),RNB
), REGDEF(sp_usr
,512|(5<<16),RNB
),
23305 REGDEF(LR_usr
,512|(6<<16),RNB
), REGDEF(lr_usr
,512|(6<<16),RNB
),
23307 REGDEF(R8_fiq
,512|(8<<16),RNB
), REGDEF(r8_fiq
,512|(8<<16),RNB
),
23308 REGDEF(R9_fiq
,512|(9<<16),RNB
), REGDEF(r9_fiq
,512|(9<<16),RNB
),
23309 REGDEF(R10_fiq
,512|(10<<16),RNB
), REGDEF(r10_fiq
,512|(10<<16),RNB
),
23310 REGDEF(R11_fiq
,512|(11<<16),RNB
), REGDEF(r11_fiq
,512|(11<<16),RNB
),
23311 REGDEF(R12_fiq
,512|(12<<16),RNB
), REGDEF(r12_fiq
,512|(12<<16),RNB
),
23312 REGDEF(SP_fiq
,512|(13<<16),RNB
), REGDEF(sp_fiq
,512|(13<<16),RNB
),
23313 REGDEF(LR_fiq
,512|(14<<16),RNB
), REGDEF(lr_fiq
,512|(14<<16),RNB
),
23314 REGDEF(SPSR_fiq
,512|(14<<16)|SPSR_BIT
,RNB
), REGDEF(spsr_fiq
,512|(14<<16)|SPSR_BIT
,RNB
),
23316 SPLRBANK(0,IRQ
,RNB
), SPLRBANK(0,irq
,RNB
),
23317 SPLRBANK(2,SVC
,RNB
), SPLRBANK(2,svc
,RNB
),
23318 SPLRBANK(4,ABT
,RNB
), SPLRBANK(4,abt
,RNB
),
23319 SPLRBANK(6,UND
,RNB
), SPLRBANK(6,und
,RNB
),
23320 SPLRBANK(12,MON
,RNB
), SPLRBANK(12,mon
,RNB
),
23321 REGDEF(elr_hyp
,768|(14<<16),RNB
), REGDEF(ELR_hyp
,768|(14<<16),RNB
),
23322 REGDEF(sp_hyp
,768|(15<<16),RNB
), REGDEF(SP_hyp
,768|(15<<16),RNB
),
23323 REGDEF(spsr_hyp
,768|(14<<16)|SPSR_BIT
,RNB
),
23324 REGDEF(SPSR_hyp
,768|(14<<16)|SPSR_BIT
,RNB
),
23326 /* FPA registers. */
23327 REGNUM(f
,0,FN
), REGNUM(f
,1,FN
), REGNUM(f
,2,FN
), REGNUM(f
,3,FN
),
23328 REGNUM(f
,4,FN
), REGNUM(f
,5,FN
), REGNUM(f
,6,FN
), REGNUM(f
,7, FN
),
23330 REGNUM(F
,0,FN
), REGNUM(F
,1,FN
), REGNUM(F
,2,FN
), REGNUM(F
,3,FN
),
23331 REGNUM(F
,4,FN
), REGNUM(F
,5,FN
), REGNUM(F
,6,FN
), REGNUM(F
,7, FN
),
23333 /* VFP SP registers. */
23334 REGSET(s
,VFS
), REGSET(S
,VFS
),
23335 REGSETH(s
,VFS
), REGSETH(S
,VFS
),
23337 /* VFP DP Registers. */
23338 REGSET(d
,VFD
), REGSET(D
,VFD
),
23339 /* Extra Neon DP registers. */
23340 REGSETH(d
,VFD
), REGSETH(D
,VFD
),
23342 /* Neon QP registers. */
23343 REGSET2(q
,NQ
), REGSET2(Q
,NQ
),
23345 /* VFP control registers. */
23346 REGDEF(fpsid
,0,VFC
), REGDEF(fpscr
,1,VFC
), REGDEF(fpexc
,8,VFC
),
23347 REGDEF(FPSID
,0,VFC
), REGDEF(FPSCR
,1,VFC
), REGDEF(FPEXC
,8,VFC
),
23348 REGDEF(fpinst
,9,VFC
), REGDEF(fpinst2
,10,VFC
),
23349 REGDEF(FPINST
,9,VFC
), REGDEF(FPINST2
,10,VFC
),
23350 REGDEF(mvfr0
,7,VFC
), REGDEF(mvfr1
,6,VFC
),
23351 REGDEF(MVFR0
,7,VFC
), REGDEF(MVFR1
,6,VFC
),
23352 REGDEF(mvfr2
,5,VFC
), REGDEF(MVFR2
,5,VFC
),
23353 REGDEF(fpscr_nzcvqc
,2,VFC
), REGDEF(FPSCR_nzcvqc
,2,VFC
),
23354 REGDEF(vpr
,12,VFC
), REGDEF(VPR
,12,VFC
),
23355 REGDEF(fpcxt_ns
,14,VFC
), REGDEF(FPCXT_NS
,14,VFC
),
23356 REGDEF(fpcxt_s
,15,VFC
), REGDEF(FPCXT_S
,15,VFC
),
23358 /* Maverick DSP coprocessor registers. */
23359 REGSET(mvf
,MVF
), REGSET(mvd
,MVD
), REGSET(mvfx
,MVFX
), REGSET(mvdx
,MVDX
),
23360 REGSET(MVF
,MVF
), REGSET(MVD
,MVD
), REGSET(MVFX
,MVFX
), REGSET(MVDX
,MVDX
),
23362 REGNUM(mvax
,0,MVAX
), REGNUM(mvax
,1,MVAX
),
23363 REGNUM(mvax
,2,MVAX
), REGNUM(mvax
,3,MVAX
),
23364 REGDEF(dspsc
,0,DSPSC
),
23366 REGNUM(MVAX
,0,MVAX
), REGNUM(MVAX
,1,MVAX
),
23367 REGNUM(MVAX
,2,MVAX
), REGNUM(MVAX
,3,MVAX
),
23368 REGDEF(DSPSC
,0,DSPSC
),
23370 /* iWMMXt data registers - p0, c0-15. */
23371 REGSET(wr
,MMXWR
), REGSET(wR
,MMXWR
), REGSET(WR
, MMXWR
),
23373 /* iWMMXt control registers - p1, c0-3. */
23374 REGDEF(wcid
, 0,MMXWC
), REGDEF(wCID
, 0,MMXWC
), REGDEF(WCID
, 0,MMXWC
),
23375 REGDEF(wcon
, 1,MMXWC
), REGDEF(wCon
, 1,MMXWC
), REGDEF(WCON
, 1,MMXWC
),
23376 REGDEF(wcssf
, 2,MMXWC
), REGDEF(wCSSF
, 2,MMXWC
), REGDEF(WCSSF
, 2,MMXWC
),
23377 REGDEF(wcasf
, 3,MMXWC
), REGDEF(wCASF
, 3,MMXWC
), REGDEF(WCASF
, 3,MMXWC
),
23379 /* iWMMXt scalar (constant/offset) registers - p1, c8-11. */
23380 REGDEF(wcgr0
, 8,MMXWCG
), REGDEF(wCGR0
, 8,MMXWCG
), REGDEF(WCGR0
, 8,MMXWCG
),
23381 REGDEF(wcgr1
, 9,MMXWCG
), REGDEF(wCGR1
, 9,MMXWCG
), REGDEF(WCGR1
, 9,MMXWCG
),
23382 REGDEF(wcgr2
,10,MMXWCG
), REGDEF(wCGR2
,10,MMXWCG
), REGDEF(WCGR2
,10,MMXWCG
),
23383 REGDEF(wcgr3
,11,MMXWCG
), REGDEF(wCGR3
,11,MMXWCG
), REGDEF(WCGR3
,11,MMXWCG
),
23385 /* XScale accumulator registers. */
23386 REGNUM(acc
,0,XSCALE
), REGNUM(ACC
,0,XSCALE
),
23392 /* Table of all PSR suffixes. Bare "CPSR" and "SPSR" are handled
23393 within psr_required_here. */
23394 static const struct asm_psr psrs
[] =
23396 /* Backward compatibility notation. Note that "all" is no longer
23397 truly all possible PSR bits. */
23398 {"all", PSR_c
| PSR_f
},
23402 /* Individual flags. */
23408 /* Combinations of flags. */
23409 {"fs", PSR_f
| PSR_s
},
23410 {"fx", PSR_f
| PSR_x
},
23411 {"fc", PSR_f
| PSR_c
},
23412 {"sf", PSR_s
| PSR_f
},
23413 {"sx", PSR_s
| PSR_x
},
23414 {"sc", PSR_s
| PSR_c
},
23415 {"xf", PSR_x
| PSR_f
},
23416 {"xs", PSR_x
| PSR_s
},
23417 {"xc", PSR_x
| PSR_c
},
23418 {"cf", PSR_c
| PSR_f
},
23419 {"cs", PSR_c
| PSR_s
},
23420 {"cx", PSR_c
| PSR_x
},
23421 {"fsx", PSR_f
| PSR_s
| PSR_x
},
23422 {"fsc", PSR_f
| PSR_s
| PSR_c
},
23423 {"fxs", PSR_f
| PSR_x
| PSR_s
},
23424 {"fxc", PSR_f
| PSR_x
| PSR_c
},
23425 {"fcs", PSR_f
| PSR_c
| PSR_s
},
23426 {"fcx", PSR_f
| PSR_c
| PSR_x
},
23427 {"sfx", PSR_s
| PSR_f
| PSR_x
},
23428 {"sfc", PSR_s
| PSR_f
| PSR_c
},
23429 {"sxf", PSR_s
| PSR_x
| PSR_f
},
23430 {"sxc", PSR_s
| PSR_x
| PSR_c
},
23431 {"scf", PSR_s
| PSR_c
| PSR_f
},
23432 {"scx", PSR_s
| PSR_c
| PSR_x
},
23433 {"xfs", PSR_x
| PSR_f
| PSR_s
},
23434 {"xfc", PSR_x
| PSR_f
| PSR_c
},
23435 {"xsf", PSR_x
| PSR_s
| PSR_f
},
23436 {"xsc", PSR_x
| PSR_s
| PSR_c
},
23437 {"xcf", PSR_x
| PSR_c
| PSR_f
},
23438 {"xcs", PSR_x
| PSR_c
| PSR_s
},
23439 {"cfs", PSR_c
| PSR_f
| PSR_s
},
23440 {"cfx", PSR_c
| PSR_f
| PSR_x
},
23441 {"csf", PSR_c
| PSR_s
| PSR_f
},
23442 {"csx", PSR_c
| PSR_s
| PSR_x
},
23443 {"cxf", PSR_c
| PSR_x
| PSR_f
},
23444 {"cxs", PSR_c
| PSR_x
| PSR_s
},
23445 {"fsxc", PSR_f
| PSR_s
| PSR_x
| PSR_c
},
23446 {"fscx", PSR_f
| PSR_s
| PSR_c
| PSR_x
},
23447 {"fxsc", PSR_f
| PSR_x
| PSR_s
| PSR_c
},
23448 {"fxcs", PSR_f
| PSR_x
| PSR_c
| PSR_s
},
23449 {"fcsx", PSR_f
| PSR_c
| PSR_s
| PSR_x
},
23450 {"fcxs", PSR_f
| PSR_c
| PSR_x
| PSR_s
},
23451 {"sfxc", PSR_s
| PSR_f
| PSR_x
| PSR_c
},
23452 {"sfcx", PSR_s
| PSR_f
| PSR_c
| PSR_x
},
23453 {"sxfc", PSR_s
| PSR_x
| PSR_f
| PSR_c
},
23454 {"sxcf", PSR_s
| PSR_x
| PSR_c
| PSR_f
},
23455 {"scfx", PSR_s
| PSR_c
| PSR_f
| PSR_x
},
23456 {"scxf", PSR_s
| PSR_c
| PSR_x
| PSR_f
},
23457 {"xfsc", PSR_x
| PSR_f
| PSR_s
| PSR_c
},
23458 {"xfcs", PSR_x
| PSR_f
| PSR_c
| PSR_s
},
23459 {"xsfc", PSR_x
| PSR_s
| PSR_f
| PSR_c
},
23460 {"xscf", PSR_x
| PSR_s
| PSR_c
| PSR_f
},
23461 {"xcfs", PSR_x
| PSR_c
| PSR_f
| PSR_s
},
23462 {"xcsf", PSR_x
| PSR_c
| PSR_s
| PSR_f
},
23463 {"cfsx", PSR_c
| PSR_f
| PSR_s
| PSR_x
},
23464 {"cfxs", PSR_c
| PSR_f
| PSR_x
| PSR_s
},
23465 {"csfx", PSR_c
| PSR_s
| PSR_f
| PSR_x
},
23466 {"csxf", PSR_c
| PSR_s
| PSR_x
| PSR_f
},
23467 {"cxfs", PSR_c
| PSR_x
| PSR_f
| PSR_s
},
23468 {"cxsf", PSR_c
| PSR_x
| PSR_s
| PSR_f
},
23471 /* Table of V7M psr names. */
23472 static const struct asm_psr v7m_psrs
[] =
23474 {"apsr", 0x0 }, {"APSR", 0x0 },
23475 {"iapsr", 0x1 }, {"IAPSR", 0x1 },
23476 {"eapsr", 0x2 }, {"EAPSR", 0x2 },
23477 {"psr", 0x3 }, {"PSR", 0x3 },
23478 {"xpsr", 0x3 }, {"XPSR", 0x3 }, {"xPSR", 3 },
23479 {"ipsr", 0x5 }, {"IPSR", 0x5 },
23480 {"epsr", 0x6 }, {"EPSR", 0x6 },
23481 {"iepsr", 0x7 }, {"IEPSR", 0x7 },
23482 {"msp", 0x8 }, {"MSP", 0x8 },
23483 {"psp", 0x9 }, {"PSP", 0x9 },
23484 {"msplim", 0xa }, {"MSPLIM", 0xa },
23485 {"psplim", 0xb }, {"PSPLIM", 0xb },
23486 {"primask", 0x10}, {"PRIMASK", 0x10},
23487 {"basepri", 0x11}, {"BASEPRI", 0x11},
23488 {"basepri_max", 0x12}, {"BASEPRI_MAX", 0x12},
23489 {"faultmask", 0x13}, {"FAULTMASK", 0x13},
23490 {"control", 0x14}, {"CONTROL", 0x14},
23491 {"msp_ns", 0x88}, {"MSP_NS", 0x88},
23492 {"psp_ns", 0x89}, {"PSP_NS", 0x89},
23493 {"msplim_ns", 0x8a}, {"MSPLIM_NS", 0x8a},
23494 {"psplim_ns", 0x8b}, {"PSPLIM_NS", 0x8b},
23495 {"primask_ns", 0x90}, {"PRIMASK_NS", 0x90},
23496 {"basepri_ns", 0x91}, {"BASEPRI_NS", 0x91},
23497 {"faultmask_ns", 0x93}, {"FAULTMASK_NS", 0x93},
23498 {"control_ns", 0x94}, {"CONTROL_NS", 0x94},
23499 {"sp_ns", 0x98}, {"SP_NS", 0x98 }
23502 /* Table of all shift-in-operand names. */
23503 static const struct asm_shift_name shift_names
[] =
23505 { "asl", SHIFT_LSL
}, { "ASL", SHIFT_LSL
},
23506 { "lsl", SHIFT_LSL
}, { "LSL", SHIFT_LSL
},
23507 { "lsr", SHIFT_LSR
}, { "LSR", SHIFT_LSR
},
23508 { "asr", SHIFT_ASR
}, { "ASR", SHIFT_ASR
},
23509 { "ror", SHIFT_ROR
}, { "ROR", SHIFT_ROR
},
23510 { "rrx", SHIFT_RRX
}, { "RRX", SHIFT_RRX
},
23511 { "uxtw", SHIFT_UXTW
}, { "UXTW", SHIFT_UXTW
}
23514 /* Table of all explicit relocation names. */
23516 static struct reloc_entry reloc_names
[] =
23518 { "got", BFD_RELOC_ARM_GOT32
}, { "GOT", BFD_RELOC_ARM_GOT32
},
23519 { "gotoff", BFD_RELOC_ARM_GOTOFF
}, { "GOTOFF", BFD_RELOC_ARM_GOTOFF
},
23520 { "plt", BFD_RELOC_ARM_PLT32
}, { "PLT", BFD_RELOC_ARM_PLT32
},
23521 { "target1", BFD_RELOC_ARM_TARGET1
}, { "TARGET1", BFD_RELOC_ARM_TARGET1
},
23522 { "target2", BFD_RELOC_ARM_TARGET2
}, { "TARGET2", BFD_RELOC_ARM_TARGET2
},
23523 { "sbrel", BFD_RELOC_ARM_SBREL32
}, { "SBREL", BFD_RELOC_ARM_SBREL32
},
23524 { "tlsgd", BFD_RELOC_ARM_TLS_GD32
}, { "TLSGD", BFD_RELOC_ARM_TLS_GD32
},
23525 { "tlsldm", BFD_RELOC_ARM_TLS_LDM32
}, { "TLSLDM", BFD_RELOC_ARM_TLS_LDM32
},
23526 { "tlsldo", BFD_RELOC_ARM_TLS_LDO32
}, { "TLSLDO", BFD_RELOC_ARM_TLS_LDO32
},
23527 { "gottpoff",BFD_RELOC_ARM_TLS_IE32
}, { "GOTTPOFF",BFD_RELOC_ARM_TLS_IE32
},
23528 { "tpoff", BFD_RELOC_ARM_TLS_LE32
}, { "TPOFF", BFD_RELOC_ARM_TLS_LE32
},
23529 { "got_prel", BFD_RELOC_ARM_GOT_PREL
}, { "GOT_PREL", BFD_RELOC_ARM_GOT_PREL
},
23530 { "tlsdesc", BFD_RELOC_ARM_TLS_GOTDESC
},
23531 { "TLSDESC", BFD_RELOC_ARM_TLS_GOTDESC
},
23532 { "tlscall", BFD_RELOC_ARM_TLS_CALL
},
23533 { "TLSCALL", BFD_RELOC_ARM_TLS_CALL
},
23534 { "tlsdescseq", BFD_RELOC_ARM_TLS_DESCSEQ
},
23535 { "TLSDESCSEQ", BFD_RELOC_ARM_TLS_DESCSEQ
},
23536 { "gotfuncdesc", BFD_RELOC_ARM_GOTFUNCDESC
},
23537 { "GOTFUNCDESC", BFD_RELOC_ARM_GOTFUNCDESC
},
23538 { "gotofffuncdesc", BFD_RELOC_ARM_GOTOFFFUNCDESC
},
23539 { "GOTOFFFUNCDESC", BFD_RELOC_ARM_GOTOFFFUNCDESC
},
23540 { "funcdesc", BFD_RELOC_ARM_FUNCDESC
},
23541 { "FUNCDESC", BFD_RELOC_ARM_FUNCDESC
},
23542 { "tlsgd_fdpic", BFD_RELOC_ARM_TLS_GD32_FDPIC
}, { "TLSGD_FDPIC", BFD_RELOC_ARM_TLS_GD32_FDPIC
},
23543 { "tlsldm_fdpic", BFD_RELOC_ARM_TLS_LDM32_FDPIC
}, { "TLSLDM_FDPIC", BFD_RELOC_ARM_TLS_LDM32_FDPIC
},
23544 { "gottpoff_fdpic", BFD_RELOC_ARM_TLS_IE32_FDPIC
}, { "GOTTPOFF_FDIC", BFD_RELOC_ARM_TLS_IE32_FDPIC
},
23548 /* Table of all conditional affixes. */
23549 static const struct asm_cond conds
[] =
23553 {"cs", 0x2}, {"hs", 0x2},
23554 {"cc", 0x3}, {"ul", 0x3}, {"lo", 0x3},
23567 static const struct asm_cond vconds
[] =
23573 #define UL_BARRIER(L,U,CODE,FEAT) \
23574 { L, CODE, ARM_FEATURE_CORE_LOW (FEAT) }, \
23575 { U, CODE, ARM_FEATURE_CORE_LOW (FEAT) }
23577 static struct asm_barrier_opt barrier_opt_names
[] =
23579 UL_BARRIER ("sy", "SY", 0xf, ARM_EXT_BARRIER
),
23580 UL_BARRIER ("st", "ST", 0xe, ARM_EXT_BARRIER
),
23581 UL_BARRIER ("ld", "LD", 0xd, ARM_EXT_V8
),
23582 UL_BARRIER ("ish", "ISH", 0xb, ARM_EXT_BARRIER
),
23583 UL_BARRIER ("sh", "SH", 0xb, ARM_EXT_BARRIER
),
23584 UL_BARRIER ("ishst", "ISHST", 0xa, ARM_EXT_BARRIER
),
23585 UL_BARRIER ("shst", "SHST", 0xa, ARM_EXT_BARRIER
),
23586 UL_BARRIER ("ishld", "ISHLD", 0x9, ARM_EXT_V8
),
23587 UL_BARRIER ("un", "UN", 0x7, ARM_EXT_BARRIER
),
23588 UL_BARRIER ("nsh", "NSH", 0x7, ARM_EXT_BARRIER
),
23589 UL_BARRIER ("unst", "UNST", 0x6, ARM_EXT_BARRIER
),
23590 UL_BARRIER ("nshst", "NSHST", 0x6, ARM_EXT_BARRIER
),
23591 UL_BARRIER ("nshld", "NSHLD", 0x5, ARM_EXT_V8
),
23592 UL_BARRIER ("osh", "OSH", 0x3, ARM_EXT_BARRIER
),
23593 UL_BARRIER ("oshst", "OSHST", 0x2, ARM_EXT_BARRIER
),
23594 UL_BARRIER ("oshld", "OSHLD", 0x1, ARM_EXT_V8
)
23599 /* Table of ARM-format instructions. */
23601 /* Macros for gluing together operand strings. N.B. In all cases
23602 other than OPS0, the trailing OP_stop comes from default
23603 zero-initialization of the unspecified elements of the array. */
23604 #define OPS0() { OP_stop, }
23605 #define OPS1(a) { OP_##a, }
23606 #define OPS2(a,b) { OP_##a,OP_##b, }
23607 #define OPS3(a,b,c) { OP_##a,OP_##b,OP_##c, }
23608 #define OPS4(a,b,c,d) { OP_##a,OP_##b,OP_##c,OP_##d, }
23609 #define OPS5(a,b,c,d,e) { OP_##a,OP_##b,OP_##c,OP_##d,OP_##e, }
23610 #define OPS6(a,b,c,d,e,f) { OP_##a,OP_##b,OP_##c,OP_##d,OP_##e,OP_##f, }
23612 /* These macros are similar to the OPSn, but do not prepend the OP_ prefix.
23613 This is useful when mixing operands for ARM and THUMB, i.e. using the
23614 MIX_ARM_THUMB_OPERANDS macro.
23615 In order to use these macros, prefix the number of operands with _
23617 #define OPS_1(a) { a, }
23618 #define OPS_2(a,b) { a,b, }
23619 #define OPS_3(a,b,c) { a,b,c, }
23620 #define OPS_4(a,b,c,d) { a,b,c,d, }
23621 #define OPS_5(a,b,c,d,e) { a,b,c,d,e, }
23622 #define OPS_6(a,b,c,d,e,f) { a,b,c,d,e,f, }
23624 /* These macros abstract out the exact format of the mnemonic table and
23625 save some repeated characters. */
23627 /* The normal sort of mnemonic; has a Thumb variant; takes a conditional suffix. */
23628 #define TxCE(mnem, op, top, nops, ops, ae, te) \
23629 { mnem, OPS##nops ops, OT_csuffix, 0x##op, top, ARM_VARIANT, \
23630 THUMB_VARIANT, do_##ae, do_##te, 0 }
23632 /* Two variants of the above - TCE for a numeric Thumb opcode, tCE for
23633 a T_MNEM_xyz enumerator. */
23634 #define TCE(mnem, aop, top, nops, ops, ae, te) \
23635 TxCE (mnem, aop, 0x##top, nops, ops, ae, te)
23636 #define tCE(mnem, aop, top, nops, ops, ae, te) \
23637 TxCE (mnem, aop, T_MNEM##top, nops, ops, ae, te)
23639 /* Second most common sort of mnemonic: has a Thumb variant, takes a conditional
23640 infix after the third character. */
23641 #define TxC3(mnem, op, top, nops, ops, ae, te) \
23642 { mnem, OPS##nops ops, OT_cinfix3, 0x##op, top, ARM_VARIANT, \
23643 THUMB_VARIANT, do_##ae, do_##te, 0 }
23644 #define TxC3w(mnem, op, top, nops, ops, ae, te) \
23645 { mnem, OPS##nops ops, OT_cinfix3_deprecated, 0x##op, top, ARM_VARIANT, \
23646 THUMB_VARIANT, do_##ae, do_##te, 0 }
23647 #define TC3(mnem, aop, top, nops, ops, ae, te) \
23648 TxC3 (mnem, aop, 0x##top, nops, ops, ae, te)
23649 #define TC3w(mnem, aop, top, nops, ops, ae, te) \
23650 TxC3w (mnem, aop, 0x##top, nops, ops, ae, te)
23651 #define tC3(mnem, aop, top, nops, ops, ae, te) \
23652 TxC3 (mnem, aop, T_MNEM##top, nops, ops, ae, te)
23653 #define tC3w(mnem, aop, top, nops, ops, ae, te) \
23654 TxC3w (mnem, aop, T_MNEM##top, nops, ops, ae, te)
23656 /* Mnemonic that cannot be conditionalized. The ARM condition-code
23657 field is still 0xE. Many of the Thumb variants can be executed
23658 conditionally, so this is checked separately. */
23659 #define TUE(mnem, op, top, nops, ops, ae, te) \
23660 { mnem, OPS##nops ops, OT_unconditional, 0x##op, 0x##top, ARM_VARIANT, \
23661 THUMB_VARIANT, do_##ae, do_##te, 0 }
23663 /* Same as TUE but the encoding function for ARM and Thumb modes is the same.
23664 Used by mnemonics that have very minimal differences in the encoding for
23665 ARM and Thumb variants and can be handled in a common function. */
23666 #define TUEc(mnem, op, top, nops, ops, en) \
23667 { mnem, OPS##nops ops, OT_unconditional, 0x##op, 0x##top, ARM_VARIANT, \
23668 THUMB_VARIANT, do_##en, do_##en, 0 }
23670 /* Mnemonic that cannot be conditionalized, and bears 0xF in its ARM
23671 condition code field. */
23672 #define TUF(mnem, op, top, nops, ops, ae, te) \
23673 { mnem, OPS##nops ops, OT_unconditionalF, 0x##op, 0x##top, ARM_VARIANT, \
23674 THUMB_VARIANT, do_##ae, do_##te, 0 }
23676 /* ARM-only variants of all the above. */
23677 #define CE(mnem, op, nops, ops, ae) \
23678 { mnem, OPS##nops ops, OT_csuffix, 0x##op, 0x0, ARM_VARIANT, 0, do_##ae, NULL, 0 }
23680 #define C3(mnem, op, nops, ops, ae) \
23681 { #mnem, OPS##nops ops, OT_cinfix3, 0x##op, 0x0, ARM_VARIANT, 0, do_##ae, NULL, 0 }
23683 /* Thumb-only variants of TCE and TUE. */
23684 #define ToC(mnem, top, nops, ops, te) \
23685 { mnem, OPS##nops ops, OT_csuffix, 0x0, 0x##top, 0, THUMB_VARIANT, NULL, \
23688 #define ToU(mnem, top, nops, ops, te) \
23689 { mnem, OPS##nops ops, OT_unconditional, 0x0, 0x##top, 0, THUMB_VARIANT, \
23692 /* T_MNEM_xyz enumerator variants of ToC. */
23693 #define toC(mnem, top, nops, ops, te) \
23694 { mnem, OPS##nops ops, OT_csuffix, 0x0, T_MNEM##top, 0, THUMB_VARIANT, NULL, \
23697 /* T_MNEM_xyz enumerator variants of ToU. */
23698 #define toU(mnem, top, nops, ops, te) \
23699 { mnem, OPS##nops ops, OT_unconditional, 0x0, T_MNEM##top, 0, THUMB_VARIANT, \
23702 /* Legacy mnemonics that always have conditional infix after the third
23704 #define CL(mnem, op, nops, ops, ae) \
23705 { mnem, OPS##nops ops, OT_cinfix3_legacy, \
23706 0x##op, 0x0, ARM_VARIANT, 0, do_##ae, NULL, 0 }
23708 /* Coprocessor instructions. Isomorphic between Arm and Thumb-2. */
23709 #define cCE(mnem, op, nops, ops, ae) \
23710 { mnem, OPS##nops ops, OT_csuffix, 0x##op, 0xe##op, ARM_VARIANT, ARM_VARIANT, do_##ae, do_##ae, 0 }
23712 /* mov instructions that are shared between coprocessor and MVE. */
23713 #define mcCE(mnem, op, nops, ops, ae) \
23714 { #mnem, OPS##nops ops, OT_csuffix, 0x##op, 0xe##op, ARM_VARIANT, THUMB_VARIANT, do_##ae, do_##ae, 0 }
23716 /* Legacy coprocessor instructions where conditional infix and conditional
23717 suffix are ambiguous. For consistency this includes all FPA instructions,
23718 not just the potentially ambiguous ones. */
23719 #define cCL(mnem, op, nops, ops, ae) \
23720 { mnem, OPS##nops ops, OT_cinfix3_legacy, \
23721 0x##op, 0xe##op, ARM_VARIANT, ARM_VARIANT, do_##ae, do_##ae, 0 }
23723 /* Coprocessor, takes either a suffix or a position-3 infix
23724 (for an FPA corner case). */
23725 #define C3E(mnem, op, nops, ops, ae) \
23726 { mnem, OPS##nops ops, OT_csuf_or_in3, \
23727 0x##op, 0xe##op, ARM_VARIANT, ARM_VARIANT, do_##ae, do_##ae, 0 }
23729 #define xCM_(m1, m2, m3, op, nops, ops, ae) \
23730 { m1 #m2 m3, OPS##nops ops, \
23731 sizeof (#m2) == 1 ? OT_odd_infix_unc : OT_odd_infix_0 + sizeof (m1) - 1, \
23732 0x##op, 0x0, ARM_VARIANT, 0, do_##ae, NULL, 0 }
23734 #define CM(m1, m2, op, nops, ops, ae) \
23735 xCM_ (m1, , m2, op, nops, ops, ae), \
23736 xCM_ (m1, eq, m2, op, nops, ops, ae), \
23737 xCM_ (m1, ne, m2, op, nops, ops, ae), \
23738 xCM_ (m1, cs, m2, op, nops, ops, ae), \
23739 xCM_ (m1, hs, m2, op, nops, ops, ae), \
23740 xCM_ (m1, cc, m2, op, nops, ops, ae), \
23741 xCM_ (m1, ul, m2, op, nops, ops, ae), \
23742 xCM_ (m1, lo, m2, op, nops, ops, ae), \
23743 xCM_ (m1, mi, m2, op, nops, ops, ae), \
23744 xCM_ (m1, pl, m2, op, nops, ops, ae), \
23745 xCM_ (m1, vs, m2, op, nops, ops, ae), \
23746 xCM_ (m1, vc, m2, op, nops, ops, ae), \
23747 xCM_ (m1, hi, m2, op, nops, ops, ae), \
23748 xCM_ (m1, ls, m2, op, nops, ops, ae), \
23749 xCM_ (m1, ge, m2, op, nops, ops, ae), \
23750 xCM_ (m1, lt, m2, op, nops, ops, ae), \
23751 xCM_ (m1, gt, m2, op, nops, ops, ae), \
23752 xCM_ (m1, le, m2, op, nops, ops, ae), \
23753 xCM_ (m1, al, m2, op, nops, ops, ae)
23755 #define UE(mnem, op, nops, ops, ae) \
23756 { #mnem, OPS##nops ops, OT_unconditional, 0x##op, 0, ARM_VARIANT, 0, do_##ae, NULL, 0 }
23758 #define UF(mnem, op, nops, ops, ae) \
23759 { #mnem, OPS##nops ops, OT_unconditionalF, 0x##op, 0, ARM_VARIANT, 0, do_##ae, NULL, 0 }
23761 /* Neon data-processing. ARM versions are unconditional with cond=0xf.
23762 The Thumb and ARM variants are mostly the same (bits 0-23 and 24/28), so we
23763 use the same encoding function for each. */
23764 #define NUF(mnem, op, nops, ops, enc) \
23765 { #mnem, OPS##nops ops, OT_unconditionalF, 0x##op, 0x##op, \
23766 ARM_VARIANT, THUMB_VARIANT, do_##enc, do_##enc, 0 }
23768 /* Neon data processing, version which indirects through neon_enc_tab for
23769 the various overloaded versions of opcodes. */
23770 #define nUF(mnem, op, nops, ops, enc) \
23771 { #mnem, OPS##nops ops, OT_unconditionalF, N_MNEM##op, N_MNEM##op, \
23772 ARM_VARIANT, THUMB_VARIANT, do_##enc, do_##enc, 0 }
23774 /* Neon insn with conditional suffix for the ARM version, non-overloaded
23776 #define NCE_tag(mnem, op, nops, ops, enc, tag, mve_p) \
23777 { #mnem, OPS##nops ops, tag, 0x##op, 0x##op, ARM_VARIANT, \
23778 THUMB_VARIANT, do_##enc, do_##enc, mve_p }
23780 #define NCE(mnem, op, nops, ops, enc) \
23781 NCE_tag (mnem, op, nops, ops, enc, OT_csuffix, 0)
23783 #define NCEF(mnem, op, nops, ops, enc) \
23784 NCE_tag (mnem, op, nops, ops, enc, OT_csuffixF, 0)
23786 /* Neon insn with conditional suffix for the ARM version, overloaded types. */
23787 #define nCE_tag(mnem, op, nops, ops, enc, tag, mve_p) \
23788 { #mnem, OPS##nops ops, tag, N_MNEM##op, N_MNEM##op, \
23789 ARM_VARIANT, THUMB_VARIANT, do_##enc, do_##enc, mve_p }
23791 #define nCE(mnem, op, nops, ops, enc) \
23792 nCE_tag (mnem, op, nops, ops, enc, OT_csuffix, 0)
23794 #define nCEF(mnem, op, nops, ops, enc) \
23795 nCE_tag (mnem, op, nops, ops, enc, OT_csuffixF, 0)
23798 #define mCEF(mnem, op, nops, ops, enc) \
23799 { #mnem, OPS##nops ops, OT_csuffixF, M_MNEM##op, M_MNEM##op, \
23800 ARM_VARIANT, THUMB_VARIANT, do_##enc, do_##enc, 1 }
23803 /* nCEF but for MVE predicated instructions. */
23804 #define mnCEF(mnem, op, nops, ops, enc) \
23805 nCE_tag (mnem, op, nops, ops, enc, OT_csuffixF, 1)
23807 /* nCE but for MVE predicated instructions. */
23808 #define mnCE(mnem, op, nops, ops, enc) \
23809 nCE_tag (mnem, op, nops, ops, enc, OT_csuffix, 1)
23811 /* NUF but for potentially MVE predicated instructions. */
23812 #define MNUF(mnem, op, nops, ops, enc) \
23813 { #mnem, OPS##nops ops, OT_unconditionalF, 0x##op, 0x##op, \
23814 ARM_VARIANT, THUMB_VARIANT, do_##enc, do_##enc, 1 }
23816 /* nUF but for potentially MVE predicated instructions. */
23817 #define mnUF(mnem, op, nops, ops, enc) \
23818 { #mnem, OPS##nops ops, OT_unconditionalF, N_MNEM##op, N_MNEM##op, \
23819 ARM_VARIANT, THUMB_VARIANT, do_##enc, do_##enc, 1 }
23821 /* ToC but for potentially MVE predicated instructions. */
23822 #define mToC(mnem, top, nops, ops, te) \
23823 { mnem, OPS##nops ops, OT_csuffix, 0x0, 0x##top, 0, THUMB_VARIANT, NULL, \
23826 /* NCE but for MVE predicated instructions. */
23827 #define MNCE(mnem, op, nops, ops, enc) \
23828 NCE_tag (mnem, op, nops, ops, enc, OT_csuffix, 1)
23830 /* NCEF but for MVE predicated instructions. */
23831 #define MNCEF(mnem, op, nops, ops, enc) \
23832 NCE_tag (mnem, op, nops, ops, enc, OT_csuffixF, 1)
23835 static const struct asm_opcode insns
[] =
23837 #define ARM_VARIANT & arm_ext_v1 /* Core ARM Instructions. */
23838 #define THUMB_VARIANT & arm_ext_v4t
23839 tCE("and", 0000000, _and
, 3, (RR
, oRR
, SH
), arit
, t_arit3c
),
23840 tC3("ands", 0100000, _ands
, 3, (RR
, oRR
, SH
), arit
, t_arit3c
),
23841 tCE("eor", 0200000, _eor
, 3, (RR
, oRR
, SH
), arit
, t_arit3c
),
23842 tC3("eors", 0300000, _eors
, 3, (RR
, oRR
, SH
), arit
, t_arit3c
),
23843 tCE("sub", 0400000, _sub
, 3, (RR
, oRR
, SH
), arit
, t_add_sub
),
23844 tC3("subs", 0500000, _subs
, 3, (RR
, oRR
, SH
), arit
, t_add_sub
),
23845 tCE("add", 0800000, _add
, 3, (RR
, oRR
, SHG
), arit
, t_add_sub
),
23846 tC3("adds", 0900000, _adds
, 3, (RR
, oRR
, SHG
), arit
, t_add_sub
),
23847 tCE("adc", 0a00000
, _adc
, 3, (RR
, oRR
, SH
), arit
, t_arit3c
),
23848 tC3("adcs", 0b00000, _adcs
, 3, (RR
, oRR
, SH
), arit
, t_arit3c
),
23849 tCE("sbc", 0c00000
, _sbc
, 3, (RR
, oRR
, SH
), arit
, t_arit3
),
23850 tC3("sbcs", 0d00000
, _sbcs
, 3, (RR
, oRR
, SH
), arit
, t_arit3
),
23851 tCE("orr", 1800000, _orr
, 3, (RR
, oRR
, SH
), arit
, t_arit3c
),
23852 tC3("orrs", 1900000, _orrs
, 3, (RR
, oRR
, SH
), arit
, t_arit3c
),
23853 tCE("bic", 1c00000
, _bic
, 3, (RR
, oRR
, SH
), arit
, t_arit3
),
23854 tC3("bics", 1d00000
, _bics
, 3, (RR
, oRR
, SH
), arit
, t_arit3
),
23856 /* The p-variants of tst/cmp/cmn/teq (below) are the pre-V6 mechanism
23857 for setting PSR flag bits. They are obsolete in V6 and do not
23858 have Thumb equivalents. */
23859 tCE("tst", 1100000, _tst
, 2, (RR
, SH
), cmp
, t_mvn_tst
),
23860 tC3w("tsts", 1100000, _tst
, 2, (RR
, SH
), cmp
, t_mvn_tst
),
23861 CL("tstp", 110f000
, 2, (RR
, SH
), cmp
),
23862 tCE("cmp", 1500000, _cmp
, 2, (RR
, SH
), cmp
, t_mov_cmp
),
23863 tC3w("cmps", 1500000, _cmp
, 2, (RR
, SH
), cmp
, t_mov_cmp
),
23864 CL("cmpp", 150f000
, 2, (RR
, SH
), cmp
),
23865 tCE("cmn", 1700000, _cmn
, 2, (RR
, SH
), cmp
, t_mvn_tst
),
23866 tC3w("cmns", 1700000, _cmn
, 2, (RR
, SH
), cmp
, t_mvn_tst
),
23867 CL("cmnp", 170f000
, 2, (RR
, SH
), cmp
),
23869 tCE("mov", 1a00000
, _mov
, 2, (RR
, SH
), mov
, t_mov_cmp
),
23870 tC3("movs", 1b00000
, _movs
, 2, (RR
, SHG
), mov
, t_mov_cmp
),
23871 tCE("mvn", 1e00000
, _mvn
, 2, (RR
, SH
), mov
, t_mvn_tst
),
23872 tC3("mvns", 1f00000
, _mvns
, 2, (RR
, SH
), mov
, t_mvn_tst
),
23874 tCE("ldr", 4100000, _ldr
, 2, (RR
, ADDRGLDR
),ldst
, t_ldst
),
23875 tC3("ldrb", 4500000, _ldrb
, 2, (RRnpc_npcsp
, ADDRGLDR
),ldst
, t_ldst
),
23876 tCE("str", 4000000, _str
, _2
, (MIX_ARM_THUMB_OPERANDS (OP_RR
,
23878 OP_ADDRGLDR
),ldst
, t_ldst
),
23879 tC3("strb", 4400000, _strb
, 2, (RRnpc_npcsp
, ADDRGLDR
),ldst
, t_ldst
),
23881 tCE("stm", 8800000, _stmia
, 2, (RRw
, REGLST
), ldmstm
, t_ldmstm
),
23882 tC3("stmia", 8800000, _stmia
, 2, (RRw
, REGLST
), ldmstm
, t_ldmstm
),
23883 tC3("stmea", 8800000, _stmia
, 2, (RRw
, REGLST
), ldmstm
, t_ldmstm
),
23884 tCE("ldm", 8900000, _ldmia
, 2, (RRw
, REGLST
), ldmstm
, t_ldmstm
),
23885 tC3("ldmia", 8900000, _ldmia
, 2, (RRw
, REGLST
), ldmstm
, t_ldmstm
),
23886 tC3("ldmfd", 8900000, _ldmia
, 2, (RRw
, REGLST
), ldmstm
, t_ldmstm
),
23888 tCE("b", a000000
, _b
, 1, (EXPr
), branch
, t_branch
),
23889 TCE("bl", b000000
, f000f800
, 1, (EXPr
), bl
, t_branch23
),
23892 tCE("adr", 28f0000
, _adr
, 2, (RR
, EXP
), adr
, t_adr
),
23893 C3(adrl
, 28f0000
, 2, (RR
, EXP
), adrl
),
23894 tCE("nop", 1a00000
, _nop
, 1, (oI255c
), nop
, t_nop
),
23895 tCE("udf", 7f000f0
, _udf
, 1, (oIffffb
), bkpt
, t_udf
),
23897 /* Thumb-compatibility pseudo ops. */
23898 tCE("lsl", 1a00000
, _lsl
, 3, (RR
, oRR
, SH
), shift
, t_shift
),
23899 tC3("lsls", 1b00000
, _lsls
, 3, (RR
, oRR
, SH
), shift
, t_shift
),
23900 tCE("lsr", 1a00020
, _lsr
, 3, (RR
, oRR
, SH
), shift
, t_shift
),
23901 tC3("lsrs", 1b00020
, _lsrs
, 3, (RR
, oRR
, SH
), shift
, t_shift
),
23902 tCE("asr", 1a00040
, _asr
, 3, (RR
, oRR
, SH
), shift
, t_shift
),
23903 tC3("asrs", 1b00040
, _asrs
, 3, (RR
, oRR
, SH
), shift
, t_shift
),
23904 tCE("ror", 1a00060
, _ror
, 3, (RR
, oRR
, SH
), shift
, t_shift
),
23905 tC3("rors", 1b00060
, _rors
, 3, (RR
, oRR
, SH
), shift
, t_shift
),
23906 tCE("neg", 2600000, _neg
, 2, (RR
, RR
), rd_rn
, t_neg
),
23907 tC3("negs", 2700000, _negs
, 2, (RR
, RR
), rd_rn
, t_neg
),
23908 tCE("push", 92d0000
, _push
, 1, (REGLST
), push_pop
, t_push_pop
),
23909 tCE("pop", 8bd0000
, _pop
, 1, (REGLST
), push_pop
, t_push_pop
),
23911 /* These may simplify to neg. */
23912 TCE("rsb", 0600000, ebc00000
, 3, (RR
, oRR
, SH
), arit
, t_rsb
),
23913 TC3("rsbs", 0700000, ebd00000
, 3, (RR
, oRR
, SH
), arit
, t_rsb
),
23915 #undef THUMB_VARIANT
23916 #define THUMB_VARIANT & arm_ext_os
23918 TCE("swi", f000000
, df00
, 1, (EXPi
), swi
, t_swi
),
23919 TCE("svc", f000000
, df00
, 1, (EXPi
), swi
, t_swi
),
23921 #undef THUMB_VARIANT
23922 #define THUMB_VARIANT & arm_ext_v6
23924 TCE("cpy", 1a00000
, 4600, 2, (RR
, RR
), rd_rm
, t_cpy
),
23926 /* V1 instructions with no Thumb analogue prior to V6T2. */
23927 #undef THUMB_VARIANT
23928 #define THUMB_VARIANT & arm_ext_v6t2
23930 TCE("teq", 1300000, ea900f00
, 2, (RR
, SH
), cmp
, t_mvn_tst
),
23931 TC3w("teqs", 1300000, ea900f00
, 2, (RR
, SH
), cmp
, t_mvn_tst
),
23932 CL("teqp", 130f000
, 2, (RR
, SH
), cmp
),
23934 TC3("ldrt", 4300000, f8500e00
, 2, (RRnpc_npcsp
, ADDR
),ldstt
, t_ldstt
),
23935 TC3("ldrbt", 4700000, f8100e00
, 2, (RRnpc_npcsp
, ADDR
),ldstt
, t_ldstt
),
23936 TC3("strt", 4200000, f8400e00
, 2, (RR_npcsp
, ADDR
), ldstt
, t_ldstt
),
23937 TC3("strbt", 4600000, f8000e00
, 2, (RRnpc_npcsp
, ADDR
),ldstt
, t_ldstt
),
23939 TC3("stmdb", 9000000, e9000000
, 2, (RRw
, REGLST
), ldmstm
, t_ldmstm
),
23940 TC3("stmfd", 9000000, e9000000
, 2, (RRw
, REGLST
), ldmstm
, t_ldmstm
),
23942 TC3("ldmdb", 9100000, e9100000
, 2, (RRw
, REGLST
), ldmstm
, t_ldmstm
),
23943 TC3("ldmea", 9100000, e9100000
, 2, (RRw
, REGLST
), ldmstm
, t_ldmstm
),
23945 /* V1 instructions with no Thumb analogue at all. */
23946 CE("rsc", 0e00000
, 3, (RR
, oRR
, SH
), arit
),
23947 C3(rscs
, 0f00000
, 3, (RR
, oRR
, SH
), arit
),
23949 C3(stmib
, 9800000, 2, (RRw
, REGLST
), ldmstm
),
23950 C3(stmfa
, 9800000, 2, (RRw
, REGLST
), ldmstm
),
23951 C3(stmda
, 8000000, 2, (RRw
, REGLST
), ldmstm
),
23952 C3(stmed
, 8000000, 2, (RRw
, REGLST
), ldmstm
),
23953 C3(ldmib
, 9900000, 2, (RRw
, REGLST
), ldmstm
),
23954 C3(ldmed
, 9900000, 2, (RRw
, REGLST
), ldmstm
),
23955 C3(ldmda
, 8100000, 2, (RRw
, REGLST
), ldmstm
),
23956 C3(ldmfa
, 8100000, 2, (RRw
, REGLST
), ldmstm
),
23959 #define ARM_VARIANT & arm_ext_v2 /* ARM 2 - multiplies. */
23960 #undef THUMB_VARIANT
23961 #define THUMB_VARIANT & arm_ext_v4t
23963 tCE("mul", 0000090, _mul
, 3, (RRnpc
, RRnpc
, oRR
), mul
, t_mul
),
23964 tC3("muls", 0100090, _muls
, 3, (RRnpc
, RRnpc
, oRR
), mul
, t_mul
),
23966 #undef THUMB_VARIANT
23967 #define THUMB_VARIANT & arm_ext_v6t2
23969 TCE("mla", 0200090, fb000000
, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
), mlas
, t_mla
),
23970 C3(mlas
, 0300090, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
), mlas
),
23972 /* Generic coprocessor instructions. */
23973 TCE("cdp", e000000
, ee000000
, 6, (RCP
, I15b
, RCN
, RCN
, RCN
, oI7b
), cdp
, cdp
),
23974 TCE("ldc", c100000
, ec100000
, 3, (RCP
, RCN
, ADDRGLDC
), lstc
, lstc
),
23975 TC3("ldcl", c500000
, ec500000
, 3, (RCP
, RCN
, ADDRGLDC
), lstc
, lstc
),
23976 TCE("stc", c000000
, ec000000
, 3, (RCP
, RCN
, ADDRGLDC
), lstc
, lstc
),
23977 TC3("stcl", c400000
, ec400000
, 3, (RCP
, RCN
, ADDRGLDC
), lstc
, lstc
),
23978 TCE("mcr", e000010
, ee000010
, 6, (RCP
, I7b
, RR
, RCN
, RCN
, oI7b
), co_reg
, co_reg
),
23979 TCE("mrc", e100010
, ee100010
, 6, (RCP
, I7b
, APSR_RR
, RCN
, RCN
, oI7b
), co_reg
, co_reg
),
23982 #define ARM_VARIANT & arm_ext_v2s /* ARM 3 - swp instructions. */
23984 CE("swp", 1000090, 3, (RRnpc
, RRnpc
, RRnpcb
), rd_rm_rn
),
23985 C3(swpb
, 1400090, 3, (RRnpc
, RRnpc
, RRnpcb
), rd_rm_rn
),
23988 #define ARM_VARIANT & arm_ext_v3 /* ARM 6 Status register instructions. */
23989 #undef THUMB_VARIANT
23990 #define THUMB_VARIANT & arm_ext_msr
23992 TCE("mrs", 1000000, f3e08000
, 2, (RRnpc
, rPSR
), mrs
, t_mrs
),
23993 TCE("msr", 120f000
, f3808000
, 2, (wPSR
, RR_EXi
), msr
, t_msr
),
23996 #define ARM_VARIANT & arm_ext_v3m /* ARM 7M long multiplies. */
23997 #undef THUMB_VARIANT
23998 #define THUMB_VARIANT & arm_ext_v6t2
24000 TCE("smull", 0c00090
, fb800000
, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
), mull
, t_mull
),
24001 CM("smull","s", 0d00090
, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
), mull
),
24002 TCE("umull", 0800090, fba00000
, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
), mull
, t_mull
),
24003 CM("umull","s", 0900090, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
), mull
),
24004 TCE("smlal", 0e00090
, fbc00000
, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
), mull
, t_mull
),
24005 CM("smlal","s", 0f00090
, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
), mull
),
24006 TCE("umlal", 0a00090
, fbe00000
, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
), mull
, t_mull
),
24007 CM("umlal","s", 0b00090, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
), mull
),
24010 #define ARM_VARIANT & arm_ext_v4 /* ARM Architecture 4. */
24011 #undef THUMB_VARIANT
24012 #define THUMB_VARIANT & arm_ext_v4t
24014 tC3("ldrh", 01000b0
, _ldrh
, 2, (RRnpc_npcsp
, ADDRGLDRS
), ldstv4
, t_ldst
),
24015 tC3("strh", 00000b0
, _strh
, 2, (RRnpc_npcsp
, ADDRGLDRS
), ldstv4
, t_ldst
),
24016 tC3("ldrsh", 01000f0
, _ldrsh
, 2, (RRnpc_npcsp
, ADDRGLDRS
), ldstv4
, t_ldst
),
24017 tC3("ldrsb", 01000d0
, _ldrsb
, 2, (RRnpc_npcsp
, ADDRGLDRS
), ldstv4
, t_ldst
),
24018 tC3("ldsh", 01000f0
, _ldrsh
, 2, (RRnpc_npcsp
, ADDRGLDRS
), ldstv4
, t_ldst
),
24019 tC3("ldsb", 01000d0
, _ldrsb
, 2, (RRnpc_npcsp
, ADDRGLDRS
), ldstv4
, t_ldst
),
24022 #define ARM_VARIANT & arm_ext_v4t_5
24024 /* ARM Architecture 4T. */
24025 /* Note: bx (and blx) are required on V5, even if the processor does
24026 not support Thumb. */
24027 TCE("bx", 12fff10
, 4700, 1, (RR
), bx
, t_bx
),
24030 #define ARM_VARIANT & arm_ext_v5 /* ARM Architecture 5T. */
24031 #undef THUMB_VARIANT
24032 #define THUMB_VARIANT & arm_ext_v5t
24034 /* Note: blx has 2 variants; the .value coded here is for
24035 BLX(2). Only this variant has conditional execution. */
24036 TCE("blx", 12fff30
, 4780, 1, (RR_EXr
), blx
, t_blx
),
24037 TUE("bkpt", 1200070, be00
, 1, (oIffffb
), bkpt
, t_bkpt
),
24039 #undef THUMB_VARIANT
24040 #define THUMB_VARIANT & arm_ext_v6t2
24042 TCE("clz", 16f0f10
, fab0f080
, 2, (RRnpc
, RRnpc
), rd_rm
, t_clz
),
24043 TUF("ldc2", c100000
, fc100000
, 3, (RCP
, RCN
, ADDRGLDC
), lstc
, lstc
),
24044 TUF("ldc2l", c500000
, fc500000
, 3, (RCP
, RCN
, ADDRGLDC
), lstc
, lstc
),
24045 TUF("stc2", c000000
, fc000000
, 3, (RCP
, RCN
, ADDRGLDC
), lstc
, lstc
),
24046 TUF("stc2l", c400000
, fc400000
, 3, (RCP
, RCN
, ADDRGLDC
), lstc
, lstc
),
24047 TUF("cdp2", e000000
, fe000000
, 6, (RCP
, I15b
, RCN
, RCN
, RCN
, oI7b
), cdp
, cdp
),
24048 TUF("mcr2", e000010
, fe000010
, 6, (RCP
, I7b
, RR
, RCN
, RCN
, oI7b
), co_reg
, co_reg
),
24049 TUF("mrc2", e100010
, fe100010
, 6, (RCP
, I7b
, RR
, RCN
, RCN
, oI7b
), co_reg
, co_reg
),
24052 #define ARM_VARIANT & arm_ext_v5exp /* ARM Architecture 5TExP. */
24053 #undef THUMB_VARIANT
24054 #define THUMB_VARIANT & arm_ext_v5exp
24056 TCE("smlabb", 1000080, fb100000
, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
), smla
, t_mla
),
24057 TCE("smlatb", 10000a0
, fb100020
, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
), smla
, t_mla
),
24058 TCE("smlabt", 10000c0
, fb100010
, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
), smla
, t_mla
),
24059 TCE("smlatt", 10000e0
, fb100030
, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
), smla
, t_mla
),
24061 TCE("smlawb", 1200080, fb300000
, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
), smla
, t_mla
),
24062 TCE("smlawt", 12000c0
, fb300010
, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
), smla
, t_mla
),
24064 TCE("smlalbb", 1400080, fbc00080
, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
), smlal
, t_mlal
),
24065 TCE("smlaltb", 14000a0
, fbc000a0
, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
), smlal
, t_mlal
),
24066 TCE("smlalbt", 14000c0
, fbc00090
, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
), smlal
, t_mlal
),
24067 TCE("smlaltt", 14000e0
, fbc000b0
, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
), smlal
, t_mlal
),
24069 TCE("smulbb", 1600080, fb10f000
, 3, (RRnpc
, RRnpc
, RRnpc
), smul
, t_simd
),
24070 TCE("smultb", 16000a0
, fb10f020
, 3, (RRnpc
, RRnpc
, RRnpc
), smul
, t_simd
),
24071 TCE("smulbt", 16000c0
, fb10f010
, 3, (RRnpc
, RRnpc
, RRnpc
), smul
, t_simd
),
24072 TCE("smultt", 16000e0
, fb10f030
, 3, (RRnpc
, RRnpc
, RRnpc
), smul
, t_simd
),
24074 TCE("smulwb", 12000a0
, fb30f000
, 3, (RRnpc
, RRnpc
, RRnpc
), smul
, t_simd
),
24075 TCE("smulwt", 12000e0
, fb30f010
, 3, (RRnpc
, RRnpc
, RRnpc
), smul
, t_simd
),
24077 TCE("qadd", 1000050, fa80f080
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rm_rn
, t_simd2
),
24078 TCE("qdadd", 1400050, fa80f090
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rm_rn
, t_simd2
),
24079 TCE("qsub", 1200050, fa80f0a0
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rm_rn
, t_simd2
),
24080 TCE("qdsub", 1600050, fa80f0b0
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rm_rn
, t_simd2
),
24083 #define ARM_VARIANT & arm_ext_v5e /* ARM Architecture 5TE. */
24084 #undef THUMB_VARIANT
24085 #define THUMB_VARIANT & arm_ext_v6t2
24087 TUF("pld", 450f000
, f810f000
, 1, (ADDR
), pld
, t_pld
),
24088 TC3("ldrd", 00000d0
, e8500000
, 3, (RRnpc_npcsp
, oRRnpc_npcsp
, ADDRGLDRS
),
24090 TC3("strd", 00000f0
, e8400000
, 3, (RRnpc_npcsp
, oRRnpc_npcsp
,
24091 ADDRGLDRS
), ldrd
, t_ldstd
),
24093 TCE("mcrr", c400000
, ec400000
, 5, (RCP
, I15b
, RRnpc
, RRnpc
, RCN
), co_reg2c
, co_reg2c
),
24094 TCE("mrrc", c500000
, ec500000
, 5, (RCP
, I15b
, RRnpc
, RRnpc
, RCN
), co_reg2c
, co_reg2c
),
24097 #define ARM_VARIANT & arm_ext_v5j /* ARM Architecture 5TEJ. */
24099 TCE("bxj", 12fff20
, f3c08f00
, 1, (RR
), bxj
, t_bxj
),
24102 #define ARM_VARIANT & arm_ext_v6 /* ARM V6. */
24103 #undef THUMB_VARIANT
24104 #define THUMB_VARIANT & arm_ext_v6
24106 TUF("cpsie", 1080000, b660
, 2, (CPSF
, oI31b
), cpsi
, t_cpsi
),
24107 TUF("cpsid", 10c0000
, b670
, 2, (CPSF
, oI31b
), cpsi
, t_cpsi
),
24108 tCE("rev", 6bf0f30
, _rev
, 2, (RRnpc
, RRnpc
), rd_rm
, t_rev
),
24109 tCE("rev16", 6bf0fb0
, _rev16
, 2, (RRnpc
, RRnpc
), rd_rm
, t_rev
),
24110 tCE("revsh", 6ff0fb0
, _revsh
, 2, (RRnpc
, RRnpc
), rd_rm
, t_rev
),
24111 tCE("sxth", 6bf0070
, _sxth
, 3, (RRnpc
, RRnpc
, oROR
), sxth
, t_sxth
),
24112 tCE("uxth", 6ff0070
, _uxth
, 3, (RRnpc
, RRnpc
, oROR
), sxth
, t_sxth
),
24113 tCE("sxtb", 6af0070
, _sxtb
, 3, (RRnpc
, RRnpc
, oROR
), sxth
, t_sxth
),
24114 tCE("uxtb", 6ef0070
, _uxtb
, 3, (RRnpc
, RRnpc
, oROR
), sxth
, t_sxth
),
24115 TUF("setend", 1010000, b650
, 1, (ENDI
), setend
, t_setend
),
24117 #undef THUMB_VARIANT
24118 #define THUMB_VARIANT & arm_ext_v6t2_v8m
24120 TCE("ldrex", 1900f9f
, e8500f00
, 2, (RRnpc_npcsp
, ADDR
), ldrex
, t_ldrex
),
24121 TCE("strex", 1800f90
, e8400000
, 3, (RRnpc_npcsp
, RRnpc_npcsp
, ADDR
),
24123 #undef THUMB_VARIANT
24124 #define THUMB_VARIANT & arm_ext_v6t2
24126 TUF("mcrr2", c400000
, fc400000
, 5, (RCP
, I15b
, RRnpc
, RRnpc
, RCN
), co_reg2c
, co_reg2c
),
24127 TUF("mrrc2", c500000
, fc500000
, 5, (RCP
, I15b
, RRnpc
, RRnpc
, RCN
), co_reg2c
, co_reg2c
),
24129 TCE("ssat", 6a00010
, f3000000
, 4, (RRnpc
, I32
, RRnpc
, oSHllar
),ssat
, t_ssat
),
24130 TCE("usat", 6e00010
, f3800000
, 4, (RRnpc
, I31
, RRnpc
, oSHllar
),usat
, t_usat
),
24132 /* ARM V6 not included in V7M. */
24133 #undef THUMB_VARIANT
24134 #define THUMB_VARIANT & arm_ext_v6_notm
24135 TUF("rfeia", 8900a00
, e990c000
, 1, (RRw
), rfe
, rfe
),
24136 TUF("rfe", 8900a00
, e990c000
, 1, (RRw
), rfe
, rfe
),
24137 UF(rfeib
, 9900a00
, 1, (RRw
), rfe
),
24138 UF(rfeda
, 8100a00
, 1, (RRw
), rfe
),
24139 TUF("rfedb", 9100a00
, e810c000
, 1, (RRw
), rfe
, rfe
),
24140 TUF("rfefd", 8900a00
, e990c000
, 1, (RRw
), rfe
, rfe
),
24141 UF(rfefa
, 8100a00
, 1, (RRw
), rfe
),
24142 TUF("rfeea", 9100a00
, e810c000
, 1, (RRw
), rfe
, rfe
),
24143 UF(rfeed
, 9900a00
, 1, (RRw
), rfe
),
24144 TUF("srsia", 8c00500
, e980c000
, 2, (oRRw
, I31w
), srs
, srs
),
24145 TUF("srs", 8c00500
, e980c000
, 2, (oRRw
, I31w
), srs
, srs
),
24146 TUF("srsea", 8c00500
, e980c000
, 2, (oRRw
, I31w
), srs
, srs
),
24147 UF(srsib
, 9c00500
, 2, (oRRw
, I31w
), srs
),
24148 UF(srsfa
, 9c00500
, 2, (oRRw
, I31w
), srs
),
24149 UF(srsda
, 8400500, 2, (oRRw
, I31w
), srs
),
24150 UF(srsed
, 8400500, 2, (oRRw
, I31w
), srs
),
24151 TUF("srsdb", 9400500, e800c000
, 2, (oRRw
, I31w
), srs
, srs
),
24152 TUF("srsfd", 9400500, e800c000
, 2, (oRRw
, I31w
), srs
, srs
),
24153 TUF("cps", 1020000, f3af8100
, 1, (I31b
), imm0
, t_cps
),
24155 /* ARM V6 not included in V7M (eg. integer SIMD). */
24156 #undef THUMB_VARIANT
24157 #define THUMB_VARIANT & arm_ext_v6_dsp
24158 TCE("pkhbt", 6800010, eac00000
, 4, (RRnpc
, RRnpc
, RRnpc
, oSHll
), pkhbt
, t_pkhbt
),
24159 TCE("pkhtb", 6800050, eac00020
, 4, (RRnpc
, RRnpc
, RRnpc
, oSHar
), pkhtb
, t_pkhtb
),
24160 TCE("qadd16", 6200f10
, fa90f010
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
24161 TCE("qadd8", 6200f90
, fa80f010
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
24162 TCE("qasx", 6200f30
, faa0f010
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
24163 /* Old name for QASX. */
24164 TCE("qaddsubx",6200f30
, faa0f010
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
24165 TCE("qsax", 6200f50
, fae0f010
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
24166 /* Old name for QSAX. */
24167 TCE("qsubaddx",6200f50
, fae0f010
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
24168 TCE("qsub16", 6200f70
, fad0f010
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
24169 TCE("qsub8", 6200ff0
, fac0f010
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
24170 TCE("sadd16", 6100f10
, fa90f000
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
24171 TCE("sadd8", 6100f90
, fa80f000
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
24172 TCE("sasx", 6100f30
, faa0f000
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
24173 /* Old name for SASX. */
24174 TCE("saddsubx",6100f30
, faa0f000
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
24175 TCE("shadd16", 6300f10
, fa90f020
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
24176 TCE("shadd8", 6300f90
, fa80f020
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
24177 TCE("shasx", 6300f30
, faa0f020
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
24178 /* Old name for SHASX. */
24179 TCE("shaddsubx", 6300f30
, faa0f020
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
24180 TCE("shsax", 6300f50
, fae0f020
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
24181 /* Old name for SHSAX. */
24182 TCE("shsubaddx", 6300f50
, fae0f020
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
24183 TCE("shsub16", 6300f70
, fad0f020
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
24184 TCE("shsub8", 6300ff0
, fac0f020
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
24185 TCE("ssax", 6100f50
, fae0f000
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
24186 /* Old name for SSAX. */
24187 TCE("ssubaddx",6100f50
, fae0f000
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
24188 TCE("ssub16", 6100f70
, fad0f000
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
24189 TCE("ssub8", 6100ff0
, fac0f000
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
24190 TCE("uadd16", 6500f10
, fa90f040
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
24191 TCE("uadd8", 6500f90
, fa80f040
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
24192 TCE("uasx", 6500f30
, faa0f040
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
24193 /* Old name for UASX. */
24194 TCE("uaddsubx",6500f30
, faa0f040
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
24195 TCE("uhadd16", 6700f10
, fa90f060
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
24196 TCE("uhadd8", 6700f90
, fa80f060
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
24197 TCE("uhasx", 6700f30
, faa0f060
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
24198 /* Old name for UHASX. */
24199 TCE("uhaddsubx", 6700f30
, faa0f060
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
24200 TCE("uhsax", 6700f50
, fae0f060
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
24201 /* Old name for UHSAX. */
24202 TCE("uhsubaddx", 6700f50
, fae0f060
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
24203 TCE("uhsub16", 6700f70
, fad0f060
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
24204 TCE("uhsub8", 6700ff0
, fac0f060
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
24205 TCE("uqadd16", 6600f10
, fa90f050
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
24206 TCE("uqadd8", 6600f90
, fa80f050
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
24207 TCE("uqasx", 6600f30
, faa0f050
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
24208 /* Old name for UQASX. */
24209 TCE("uqaddsubx", 6600f30
, faa0f050
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
24210 TCE("uqsax", 6600f50
, fae0f050
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
24211 /* Old name for UQSAX. */
24212 TCE("uqsubaddx", 6600f50
, fae0f050
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
24213 TCE("uqsub16", 6600f70
, fad0f050
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
24214 TCE("uqsub8", 6600ff0
, fac0f050
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
24215 TCE("usub16", 6500f70
, fad0f040
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
24216 TCE("usax", 6500f50
, fae0f040
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
24217 /* Old name for USAX. */
24218 TCE("usubaddx",6500f50
, fae0f040
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
24219 TCE("usub8", 6500ff0
, fac0f040
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
24220 TCE("sxtah", 6b00070
, fa00f080
, 4, (RRnpc
, RRnpc
, RRnpc
, oROR
), sxtah
, t_sxtah
),
24221 TCE("sxtab16", 6800070, fa20f080
, 4, (RRnpc
, RRnpc
, RRnpc
, oROR
), sxtah
, t_sxtah
),
24222 TCE("sxtab", 6a00070
, fa40f080
, 4, (RRnpc
, RRnpc
, RRnpc
, oROR
), sxtah
, t_sxtah
),
24223 TCE("sxtb16", 68f0070
, fa2ff080
, 3, (RRnpc
, RRnpc
, oROR
), sxth
, t_sxth
),
24224 TCE("uxtah", 6f00070
, fa10f080
, 4, (RRnpc
, RRnpc
, RRnpc
, oROR
), sxtah
, t_sxtah
),
24225 TCE("uxtab16", 6c00070
, fa30f080
, 4, (RRnpc
, RRnpc
, RRnpc
, oROR
), sxtah
, t_sxtah
),
24226 TCE("uxtab", 6e00070
, fa50f080
, 4, (RRnpc
, RRnpc
, RRnpc
, oROR
), sxtah
, t_sxtah
),
24227 TCE("uxtb16", 6cf0070
, fa3ff080
, 3, (RRnpc
, RRnpc
, oROR
), sxth
, t_sxth
),
24228 TCE("sel", 6800fb0
, faa0f080
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
24229 TCE("smlad", 7000010, fb200000
, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
),smla
, t_mla
),
24230 TCE("smladx", 7000030, fb200010
, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
),smla
, t_mla
),
24231 TCE("smlald", 7400010, fbc000c0
, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
),smlal
,t_mlal
),
24232 TCE("smlaldx", 7400030, fbc000d0
, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
),smlal
,t_mlal
),
24233 TCE("smlsd", 7000050, fb400000
, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
),smla
, t_mla
),
24234 TCE("smlsdx", 7000070, fb400010
, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
),smla
, t_mla
),
24235 TCE("smlsld", 7400050, fbd000c0
, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
),smlal
,t_mlal
),
24236 TCE("smlsldx", 7400070, fbd000d0
, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
),smlal
,t_mlal
),
24237 TCE("smmla", 7500010, fb500000
, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
),smla
, t_mla
),
24238 TCE("smmlar", 7500030, fb500010
, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
),smla
, t_mla
),
24239 TCE("smmls", 75000d0
, fb600000
, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
),smla
, t_mla
),
24240 TCE("smmlsr", 75000f0
, fb600010
, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
),smla
, t_mla
),
24241 TCE("smmul", 750f010
, fb50f000
, 3, (RRnpc
, RRnpc
, RRnpc
), smul
, t_simd
),
24242 TCE("smmulr", 750f030
, fb50f010
, 3, (RRnpc
, RRnpc
, RRnpc
), smul
, t_simd
),
24243 TCE("smuad", 700f010
, fb20f000
, 3, (RRnpc
, RRnpc
, RRnpc
), smul
, t_simd
),
24244 TCE("smuadx", 700f030
, fb20f010
, 3, (RRnpc
, RRnpc
, RRnpc
), smul
, t_simd
),
24245 TCE("smusd", 700f050
, fb40f000
, 3, (RRnpc
, RRnpc
, RRnpc
), smul
, t_simd
),
24246 TCE("smusdx", 700f070
, fb40f010
, 3, (RRnpc
, RRnpc
, RRnpc
), smul
, t_simd
),
24247 TCE("ssat16", 6a00f30
, f3200000
, 3, (RRnpc
, I16
, RRnpc
), ssat16
, t_ssat16
),
24248 TCE("umaal", 0400090, fbe00060
, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
),smlal
, t_mlal
),
24249 TCE("usad8", 780f010
, fb70f000
, 3, (RRnpc
, RRnpc
, RRnpc
), smul
, t_simd
),
24250 TCE("usada8", 7800010, fb700000
, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
),smla
, t_mla
),
24251 TCE("usat16", 6e00f30
, f3a00000
, 3, (RRnpc
, I15
, RRnpc
), usat16
, t_usat16
),
24254 #define ARM_VARIANT & arm_ext_v6k_v6t2
24255 #undef THUMB_VARIANT
24256 #define THUMB_VARIANT & arm_ext_v6k_v6t2
24258 tCE("yield", 320f001
, _yield
, 0, (), noargs
, t_hint
),
24259 tCE("wfe", 320f002
, _wfe
, 0, (), noargs
, t_hint
),
24260 tCE("wfi", 320f003
, _wfi
, 0, (), noargs
, t_hint
),
24261 tCE("sev", 320f004
, _sev
, 0, (), noargs
, t_hint
),
24263 #undef THUMB_VARIANT
24264 #define THUMB_VARIANT & arm_ext_v6_notm
24265 TCE("ldrexd", 1b00f9f
, e8d0007f
, 3, (RRnpc_npcsp
, oRRnpc_npcsp
, RRnpcb
),
24267 TCE("strexd", 1a00f90
, e8c00070
, 4, (RRnpc_npcsp
, RRnpc_npcsp
, oRRnpc_npcsp
,
24268 RRnpcb
), strexd
, t_strexd
),
24270 #undef THUMB_VARIANT
24271 #define THUMB_VARIANT & arm_ext_v6t2_v8m
24272 TCE("ldrexb", 1d00f9f
, e8d00f4f
, 2, (RRnpc_npcsp
,RRnpcb
),
24274 TCE("ldrexh", 1f00f9f
, e8d00f5f
, 2, (RRnpc_npcsp
, RRnpcb
),
24276 TCE("strexb", 1c00f90
, e8c00f40
, 3, (RRnpc_npcsp
, RRnpc_npcsp
, ADDR
),
24278 TCE("strexh", 1e00f90
, e8c00f50
, 3, (RRnpc_npcsp
, RRnpc_npcsp
, ADDR
),
24280 TUF("clrex", 57ff01f
, f3bf8f2f
, 0, (), noargs
, noargs
),
24283 #define ARM_VARIANT & arm_ext_sec
24284 #undef THUMB_VARIANT
24285 #define THUMB_VARIANT & arm_ext_sec
24287 TCE("smc", 1600070, f7f08000
, 1, (EXPi
), smc
, t_smc
),
24290 #define ARM_VARIANT & arm_ext_virt
24291 #undef THUMB_VARIANT
24292 #define THUMB_VARIANT & arm_ext_virt
24294 TCE("hvc", 1400070, f7e08000
, 1, (EXPi
), hvc
, t_hvc
),
24295 TCE("eret", 160006e
, f3de8f00
, 0, (), noargs
, noargs
),
24298 #define ARM_VARIANT & arm_ext_pan
24299 #undef THUMB_VARIANT
24300 #define THUMB_VARIANT & arm_ext_pan
24302 TUF("setpan", 1100000, b610
, 1, (I7
), setpan
, t_setpan
),
24305 #define ARM_VARIANT & arm_ext_v6t2
24306 #undef THUMB_VARIANT
24307 #define THUMB_VARIANT & arm_ext_v6t2
24309 TCE("bfc", 7c0001f
, f36f0000
, 3, (RRnpc
, I31
, I32
), bfc
, t_bfc
),
24310 TCE("bfi", 7c00010
, f3600000
, 4, (RRnpc
, RRnpc_I0
, I31
, I32
), bfi
, t_bfi
),
24311 TCE("sbfx", 7a00050
, f3400000
, 4, (RR
, RR
, I31
, I32
), bfx
, t_bfx
),
24312 TCE("ubfx", 7e00050
, f3c00000
, 4, (RR
, RR
, I31
, I32
), bfx
, t_bfx
),
24314 TCE("mls", 0600090, fb000010
, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
), mlas
, t_mla
),
24315 TCE("rbit", 6ff0f30
, fa90f0a0
, 2, (RR
, RR
), rd_rm
, t_rbit
),
24317 TC3("ldrht", 03000b0
, f8300e00
, 2, (RRnpc_npcsp
, ADDR
), ldsttv4
, t_ldstt
),
24318 TC3("ldrsht", 03000f0
, f9300e00
, 2, (RRnpc_npcsp
, ADDR
), ldsttv4
, t_ldstt
),
24319 TC3("ldrsbt", 03000d0
, f9100e00
, 2, (RRnpc_npcsp
, ADDR
), ldsttv4
, t_ldstt
),
24320 TC3("strht", 02000b0
, f8200e00
, 2, (RRnpc_npcsp
, ADDR
), ldsttv4
, t_ldstt
),
24323 #define ARM_VARIANT & arm_ext_v3
24324 #undef THUMB_VARIANT
24325 #define THUMB_VARIANT & arm_ext_v6t2
24327 TUE("csdb", 320f014
, f3af8014
, 0, (), noargs
, t_csdb
),
24328 TUF("ssbb", 57ff040
, f3bf8f40
, 0, (), noargs
, t_csdb
),
24329 TUF("pssbb", 57ff044
, f3bf8f44
, 0, (), noargs
, t_csdb
),
24332 #define ARM_VARIANT & arm_ext_v6t2
24333 #undef THUMB_VARIANT
24334 #define THUMB_VARIANT & arm_ext_v6t2_v8m
24335 TCE("movw", 3000000, f2400000
, 2, (RRnpc
, HALF
), mov16
, t_mov16
),
24336 TCE("movt", 3400000, f2c00000
, 2, (RRnpc
, HALF
), mov16
, t_mov16
),
24338 /* Thumb-only instructions. */
24340 #define ARM_VARIANT NULL
24341 TUE("cbnz", 0, b900
, 2, (RR
, EXP
), 0, t_cbz
),
24342 TUE("cbz", 0, b100
, 2, (RR
, EXP
), 0, t_cbz
),
24344 /* ARM does not really have an IT instruction, so always allow it.
24345 The opcode is copied from Thumb in order to allow warnings in
24346 -mimplicit-it=[never | arm] modes. */
24348 #define ARM_VARIANT & arm_ext_v1
24349 #undef THUMB_VARIANT
24350 #define THUMB_VARIANT & arm_ext_v6t2
24352 TUE("it", bf08
, bf08
, 1, (COND
), it
, t_it
),
24353 TUE("itt", bf0c
, bf0c
, 1, (COND
), it
, t_it
),
24354 TUE("ite", bf04
, bf04
, 1, (COND
), it
, t_it
),
24355 TUE("ittt", bf0e
, bf0e
, 1, (COND
), it
, t_it
),
24356 TUE("itet", bf06
, bf06
, 1, (COND
), it
, t_it
),
24357 TUE("itte", bf0a
, bf0a
, 1, (COND
), it
, t_it
),
24358 TUE("itee", bf02
, bf02
, 1, (COND
), it
, t_it
),
24359 TUE("itttt", bf0f
, bf0f
, 1, (COND
), it
, t_it
),
24360 TUE("itett", bf07
, bf07
, 1, (COND
), it
, t_it
),
24361 TUE("ittet", bf0b
, bf0b
, 1, (COND
), it
, t_it
),
24362 TUE("iteet", bf03
, bf03
, 1, (COND
), it
, t_it
),
24363 TUE("ittte", bf0d
, bf0d
, 1, (COND
), it
, t_it
),
24364 TUE("itete", bf05
, bf05
, 1, (COND
), it
, t_it
),
24365 TUE("ittee", bf09
, bf09
, 1, (COND
), it
, t_it
),
24366 TUE("iteee", bf01
, bf01
, 1, (COND
), it
, t_it
),
24367 /* ARM/Thumb-2 instructions with no Thumb-1 equivalent. */
24368 TC3("rrx", 01a00060
, ea4f0030
, 2, (RR
, RR
), rd_rm
, t_rrx
),
24369 TC3("rrxs", 01b00060
, ea5f0030
, 2, (RR
, RR
), rd_rm
, t_rrx
),
24371 /* Thumb2 only instructions. */
24373 #define ARM_VARIANT NULL
24375 TCE("addw", 0, f2000000
, 3, (RR
, RR
, EXPi
), 0, t_add_sub_w
),
24376 TCE("subw", 0, f2a00000
, 3, (RR
, RR
, EXPi
), 0, t_add_sub_w
),
24377 TCE("orn", 0, ea600000
, 3, (RR
, oRR
, SH
), 0, t_orn
),
24378 TCE("orns", 0, ea700000
, 3, (RR
, oRR
, SH
), 0, t_orn
),
24379 TCE("tbb", 0, e8d0f000
, 1, (TB
), 0, t_tb
),
24380 TCE("tbh", 0, e8d0f010
, 1, (TB
), 0, t_tb
),
24382 /* Hardware division instructions. */
24384 #define ARM_VARIANT & arm_ext_adiv
24385 #undef THUMB_VARIANT
24386 #define THUMB_VARIANT & arm_ext_div
24388 TCE("sdiv", 710f010
, fb90f0f0
, 3, (RR
, oRR
, RR
), div
, t_div
),
24389 TCE("udiv", 730f010
, fbb0f0f0
, 3, (RR
, oRR
, RR
), div
, t_div
),
24391 /* ARM V6M/V7 instructions. */
24393 #define ARM_VARIANT & arm_ext_barrier
24394 #undef THUMB_VARIANT
24395 #define THUMB_VARIANT & arm_ext_barrier
24397 TUF("dmb", 57ff050
, f3bf8f50
, 1, (oBARRIER_I15
), barrier
, barrier
),
24398 TUF("dsb", 57ff040
, f3bf8f40
, 1, (oBARRIER_I15
), barrier
, barrier
),
24399 TUF("isb", 57ff060
, f3bf8f60
, 1, (oBARRIER_I15
), barrier
, barrier
),
24401 /* ARM V7 instructions. */
24403 #define ARM_VARIANT & arm_ext_v7
24404 #undef THUMB_VARIANT
24405 #define THUMB_VARIANT & arm_ext_v7
24407 TUF("pli", 450f000
, f910f000
, 1, (ADDR
), pli
, t_pld
),
24408 TCE("dbg", 320f0f0
, f3af80f0
, 1, (I15
), dbg
, t_dbg
),
24411 #define ARM_VARIANT & arm_ext_mp
24412 #undef THUMB_VARIANT
24413 #define THUMB_VARIANT & arm_ext_mp
24415 TUF("pldw", 410f000
, f830f000
, 1, (ADDR
), pld
, t_pld
),
24417 /* AArchv8 instructions. */
24419 #define ARM_VARIANT & arm_ext_v8
24421 /* Instructions shared between armv8-a and armv8-m. */
24422 #undef THUMB_VARIANT
24423 #define THUMB_VARIANT & arm_ext_atomics
24425 TCE("lda", 1900c9f
, e8d00faf
, 2, (RRnpc
, RRnpcb
), rd_rn
, rd_rn
),
24426 TCE("ldab", 1d00c9f
, e8d00f8f
, 2, (RRnpc
, RRnpcb
), rd_rn
, rd_rn
),
24427 TCE("ldah", 1f00c9f
, e8d00f9f
, 2, (RRnpc
, RRnpcb
), rd_rn
, rd_rn
),
24428 TCE("stl", 180fc90
, e8c00faf
, 2, (RRnpc
, RRnpcb
), rm_rn
, rd_rn
),
24429 TCE("stlb", 1c0fc90
, e8c00f8f
, 2, (RRnpc
, RRnpcb
), rm_rn
, rd_rn
),
24430 TCE("stlh", 1e0fc90
, e8c00f9f
, 2, (RRnpc
, RRnpcb
), rm_rn
, rd_rn
),
24431 TCE("ldaex", 1900e9f
, e8d00fef
, 2, (RRnpc
, RRnpcb
), rd_rn
, rd_rn
),
24432 TCE("ldaexb", 1d00e9f
, e8d00fcf
, 2, (RRnpc
,RRnpcb
), rd_rn
, rd_rn
),
24433 TCE("ldaexh", 1f00e9f
, e8d00fdf
, 2, (RRnpc
, RRnpcb
), rd_rn
, rd_rn
),
24434 TCE("stlex", 1800e90
, e8c00fe0
, 3, (RRnpc
, RRnpc
, RRnpcb
),
24436 TCE("stlexb", 1c00e90
, e8c00fc0
, 3, (RRnpc
, RRnpc
, RRnpcb
),
24438 TCE("stlexh", 1e00e90
, e8c00fd0
, 3, (RRnpc
, RRnpc
, RRnpcb
),
24440 #undef THUMB_VARIANT
24441 #define THUMB_VARIANT & arm_ext_v8
24443 tCE("sevl", 320f005
, _sevl
, 0, (), noargs
, t_hint
),
24444 TCE("ldaexd", 1b00e9f
, e8d000ff
, 3, (RRnpc
, oRRnpc
, RRnpcb
),
24446 TCE("stlexd", 1a00e90
, e8c000f0
, 4, (RRnpc
, RRnpc
, oRRnpc
, RRnpcb
),
24449 /* Defined in V8 but is in undefined encoding space for earlier
24450 architectures. However earlier architectures are required to treat
24451 this instuction as a semihosting trap as well. Hence while not explicitly
24452 defined as such, it is in fact correct to define the instruction for all
24454 #undef THUMB_VARIANT
24455 #define THUMB_VARIANT & arm_ext_v1
24457 #define ARM_VARIANT & arm_ext_v1
24458 TUE("hlt", 1000070, ba80
, 1, (oIffffb
), bkpt
, t_hlt
),
24460 /* ARMv8 T32 only. */
24462 #define ARM_VARIANT NULL
24463 TUF("dcps1", 0, f78f8001
, 0, (), noargs
, noargs
),
24464 TUF("dcps2", 0, f78f8002
, 0, (), noargs
, noargs
),
24465 TUF("dcps3", 0, f78f8003
, 0, (), noargs
, noargs
),
24467 /* FP for ARMv8. */
24469 #define ARM_VARIANT & fpu_vfp_ext_armv8xd
24470 #undef THUMB_VARIANT
24471 #define THUMB_VARIANT & fpu_vfp_ext_armv8xd
24473 nUF(vseleq
, _vseleq
, 3, (RVSD
, RVSD
, RVSD
), vsel
),
24474 nUF(vselvs
, _vselvs
, 3, (RVSD
, RVSD
, RVSD
), vsel
),
24475 nUF(vselge
, _vselge
, 3, (RVSD
, RVSD
, RVSD
), vsel
),
24476 nUF(vselgt
, _vselgt
, 3, (RVSD
, RVSD
, RVSD
), vsel
),
24477 nCE(vrintr
, _vrintr
, 2, (RNSDQ
, oRNSDQ
), vrintr
),
24478 mnCE(vrintz
, _vrintr
, 2, (RNSDQMQ
, oRNSDQMQ
), vrintz
),
24479 mnCE(vrintx
, _vrintr
, 2, (RNSDQMQ
, oRNSDQMQ
), vrintx
),
24480 mnUF(vrinta
, _vrinta
, 2, (RNSDQMQ
, oRNSDQMQ
), vrinta
),
24481 mnUF(vrintn
, _vrinta
, 2, (RNSDQMQ
, oRNSDQMQ
), vrintn
),
24482 mnUF(vrintp
, _vrinta
, 2, (RNSDQMQ
, oRNSDQMQ
), vrintp
),
24483 mnUF(vrintm
, _vrinta
, 2, (RNSDQMQ
, oRNSDQMQ
), vrintm
),
24485 /* Crypto v1 extensions. */
24487 #define ARM_VARIANT & fpu_crypto_ext_armv8
24488 #undef THUMB_VARIANT
24489 #define THUMB_VARIANT & fpu_crypto_ext_armv8
24491 nUF(aese
, _aes
, 2, (RNQ
, RNQ
), aese
),
24492 nUF(aesd
, _aes
, 2, (RNQ
, RNQ
), aesd
),
24493 nUF(aesmc
, _aes
, 2, (RNQ
, RNQ
), aesmc
),
24494 nUF(aesimc
, _aes
, 2, (RNQ
, RNQ
), aesimc
),
24495 nUF(sha1c
, _sha3op
, 3, (RNQ
, RNQ
, RNQ
), sha1c
),
24496 nUF(sha1p
, _sha3op
, 3, (RNQ
, RNQ
, RNQ
), sha1p
),
24497 nUF(sha1m
, _sha3op
, 3, (RNQ
, RNQ
, RNQ
), sha1m
),
24498 nUF(sha1su0
, _sha3op
, 3, (RNQ
, RNQ
, RNQ
), sha1su0
),
24499 nUF(sha256h
, _sha3op
, 3, (RNQ
, RNQ
, RNQ
), sha256h
),
24500 nUF(sha256h2
, _sha3op
, 3, (RNQ
, RNQ
, RNQ
), sha256h2
),
24501 nUF(sha256su1
, _sha3op
, 3, (RNQ
, RNQ
, RNQ
), sha256su1
),
24502 nUF(sha1h
, _sha1h
, 2, (RNQ
, RNQ
), sha1h
),
24503 nUF(sha1su1
, _sha2op
, 2, (RNQ
, RNQ
), sha1su1
),
24504 nUF(sha256su0
, _sha2op
, 2, (RNQ
, RNQ
), sha256su0
),
24507 #define ARM_VARIANT & arm_ext_crc
24508 #undef THUMB_VARIANT
24509 #define THUMB_VARIANT & arm_ext_crc
24510 TUEc("crc32b", 1000040, fac0f080
, 3, (RR
, oRR
, RR
), crc32b
),
24511 TUEc("crc32h", 1200040, fac0f090
, 3, (RR
, oRR
, RR
), crc32h
),
24512 TUEc("crc32w", 1400040, fac0f0a0
, 3, (RR
, oRR
, RR
), crc32w
),
24513 TUEc("crc32cb",1000240, fad0f080
, 3, (RR
, oRR
, RR
), crc32cb
),
24514 TUEc("crc32ch",1200240, fad0f090
, 3, (RR
, oRR
, RR
), crc32ch
),
24515 TUEc("crc32cw",1400240, fad0f0a0
, 3, (RR
, oRR
, RR
), crc32cw
),
24517 /* ARMv8.2 RAS extension. */
24519 #define ARM_VARIANT & arm_ext_ras
24520 #undef THUMB_VARIANT
24521 #define THUMB_VARIANT & arm_ext_ras
24522 TUE ("esb", 320f010
, f3af8010
, 0, (), noargs
, noargs
),
24525 #define ARM_VARIANT & arm_ext_v8_3
24526 #undef THUMB_VARIANT
24527 #define THUMB_VARIANT & arm_ext_v8_3
24528 NCE (vjcvt
, eb90bc0
, 2, (RVS
, RVD
), vjcvt
),
24531 #define ARM_VARIANT & fpu_neon_ext_dotprod
24532 #undef THUMB_VARIANT
24533 #define THUMB_VARIANT & fpu_neon_ext_dotprod
24534 NUF (vsdot
, d00
, 3, (RNDQ
, RNDQ
, RNDQ_RNSC
), neon_dotproduct_s
),
24535 NUF (vudot
, d00
, 3, (RNDQ
, RNDQ
, RNDQ_RNSC
), neon_dotproduct_u
),
24538 #define ARM_VARIANT & fpu_fpa_ext_v1 /* Core FPA instruction set (V1). */
24539 #undef THUMB_VARIANT
24540 #define THUMB_VARIANT NULL
24542 cCE("wfs", e200110
, 1, (RR
), rd
),
24543 cCE("rfs", e300110
, 1, (RR
), rd
),
24544 cCE("wfc", e400110
, 1, (RR
), rd
),
24545 cCE("rfc", e500110
, 1, (RR
), rd
),
24547 cCL("ldfs", c100100
, 2, (RF
, ADDRGLDC
), rd_cpaddr
),
24548 cCL("ldfd", c108100
, 2, (RF
, ADDRGLDC
), rd_cpaddr
),
24549 cCL("ldfe", c500100
, 2, (RF
, ADDRGLDC
), rd_cpaddr
),
24550 cCL("ldfp", c508100
, 2, (RF
, ADDRGLDC
), rd_cpaddr
),
24552 cCL("stfs", c000100
, 2, (RF
, ADDRGLDC
), rd_cpaddr
),
24553 cCL("stfd", c008100
, 2, (RF
, ADDRGLDC
), rd_cpaddr
),
24554 cCL("stfe", c400100
, 2, (RF
, ADDRGLDC
), rd_cpaddr
),
24555 cCL("stfp", c408100
, 2, (RF
, ADDRGLDC
), rd_cpaddr
),
24557 cCL("mvfs", e008100
, 2, (RF
, RF_IF
), rd_rm
),
24558 cCL("mvfsp", e008120
, 2, (RF
, RF_IF
), rd_rm
),
24559 cCL("mvfsm", e008140
, 2, (RF
, RF_IF
), rd_rm
),
24560 cCL("mvfsz", e008160
, 2, (RF
, RF_IF
), rd_rm
),
24561 cCL("mvfd", e008180
, 2, (RF
, RF_IF
), rd_rm
),
24562 cCL("mvfdp", e0081a0
, 2, (RF
, RF_IF
), rd_rm
),
24563 cCL("mvfdm", e0081c0
, 2, (RF
, RF_IF
), rd_rm
),
24564 cCL("mvfdz", e0081e0
, 2, (RF
, RF_IF
), rd_rm
),
24565 cCL("mvfe", e088100
, 2, (RF
, RF_IF
), rd_rm
),
24566 cCL("mvfep", e088120
, 2, (RF
, RF_IF
), rd_rm
),
24567 cCL("mvfem", e088140
, 2, (RF
, RF_IF
), rd_rm
),
24568 cCL("mvfez", e088160
, 2, (RF
, RF_IF
), rd_rm
),
24570 cCL("mnfs", e108100
, 2, (RF
, RF_IF
), rd_rm
),
24571 cCL("mnfsp", e108120
, 2, (RF
, RF_IF
), rd_rm
),
24572 cCL("mnfsm", e108140
, 2, (RF
, RF_IF
), rd_rm
),
24573 cCL("mnfsz", e108160
, 2, (RF
, RF_IF
), rd_rm
),
24574 cCL("mnfd", e108180
, 2, (RF
, RF_IF
), rd_rm
),
24575 cCL("mnfdp", e1081a0
, 2, (RF
, RF_IF
), rd_rm
),
24576 cCL("mnfdm", e1081c0
, 2, (RF
, RF_IF
), rd_rm
),
24577 cCL("mnfdz", e1081e0
, 2, (RF
, RF_IF
), rd_rm
),
24578 cCL("mnfe", e188100
, 2, (RF
, RF_IF
), rd_rm
),
24579 cCL("mnfep", e188120
, 2, (RF
, RF_IF
), rd_rm
),
24580 cCL("mnfem", e188140
, 2, (RF
, RF_IF
), rd_rm
),
24581 cCL("mnfez", e188160
, 2, (RF
, RF_IF
), rd_rm
),
24583 cCL("abss", e208100
, 2, (RF
, RF_IF
), rd_rm
),
24584 cCL("abssp", e208120
, 2, (RF
, RF_IF
), rd_rm
),
24585 cCL("abssm", e208140
, 2, (RF
, RF_IF
), rd_rm
),
24586 cCL("abssz", e208160
, 2, (RF
, RF_IF
), rd_rm
),
24587 cCL("absd", e208180
, 2, (RF
, RF_IF
), rd_rm
),
24588 cCL("absdp", e2081a0
, 2, (RF
, RF_IF
), rd_rm
),
24589 cCL("absdm", e2081c0
, 2, (RF
, RF_IF
), rd_rm
),
24590 cCL("absdz", e2081e0
, 2, (RF
, RF_IF
), rd_rm
),
24591 cCL("abse", e288100
, 2, (RF
, RF_IF
), rd_rm
),
24592 cCL("absep", e288120
, 2, (RF
, RF_IF
), rd_rm
),
24593 cCL("absem", e288140
, 2, (RF
, RF_IF
), rd_rm
),
24594 cCL("absez", e288160
, 2, (RF
, RF_IF
), rd_rm
),
24596 cCL("rnds", e308100
, 2, (RF
, RF_IF
), rd_rm
),
24597 cCL("rndsp", e308120
, 2, (RF
, RF_IF
), rd_rm
),
24598 cCL("rndsm", e308140
, 2, (RF
, RF_IF
), rd_rm
),
24599 cCL("rndsz", e308160
, 2, (RF
, RF_IF
), rd_rm
),
24600 cCL("rndd", e308180
, 2, (RF
, RF_IF
), rd_rm
),
24601 cCL("rnddp", e3081a0
, 2, (RF
, RF_IF
), rd_rm
),
24602 cCL("rnddm", e3081c0
, 2, (RF
, RF_IF
), rd_rm
),
24603 cCL("rnddz", e3081e0
, 2, (RF
, RF_IF
), rd_rm
),
24604 cCL("rnde", e388100
, 2, (RF
, RF_IF
), rd_rm
),
24605 cCL("rndep", e388120
, 2, (RF
, RF_IF
), rd_rm
),
24606 cCL("rndem", e388140
, 2, (RF
, RF_IF
), rd_rm
),
24607 cCL("rndez", e388160
, 2, (RF
, RF_IF
), rd_rm
),
24609 cCL("sqts", e408100
, 2, (RF
, RF_IF
), rd_rm
),
24610 cCL("sqtsp", e408120
, 2, (RF
, RF_IF
), rd_rm
),
24611 cCL("sqtsm", e408140
, 2, (RF
, RF_IF
), rd_rm
),
24612 cCL("sqtsz", e408160
, 2, (RF
, RF_IF
), rd_rm
),
24613 cCL("sqtd", e408180
, 2, (RF
, RF_IF
), rd_rm
),
24614 cCL("sqtdp", e4081a0
, 2, (RF
, RF_IF
), rd_rm
),
24615 cCL("sqtdm", e4081c0
, 2, (RF
, RF_IF
), rd_rm
),
24616 cCL("sqtdz", e4081e0
, 2, (RF
, RF_IF
), rd_rm
),
24617 cCL("sqte", e488100
, 2, (RF
, RF_IF
), rd_rm
),
24618 cCL("sqtep", e488120
, 2, (RF
, RF_IF
), rd_rm
),
24619 cCL("sqtem", e488140
, 2, (RF
, RF_IF
), rd_rm
),
24620 cCL("sqtez", e488160
, 2, (RF
, RF_IF
), rd_rm
),
24622 cCL("logs", e508100
, 2, (RF
, RF_IF
), rd_rm
),
24623 cCL("logsp", e508120
, 2, (RF
, RF_IF
), rd_rm
),
24624 cCL("logsm", e508140
, 2, (RF
, RF_IF
), rd_rm
),
24625 cCL("logsz", e508160
, 2, (RF
, RF_IF
), rd_rm
),
24626 cCL("logd", e508180
, 2, (RF
, RF_IF
), rd_rm
),
24627 cCL("logdp", e5081a0
, 2, (RF
, RF_IF
), rd_rm
),
24628 cCL("logdm", e5081c0
, 2, (RF
, RF_IF
), rd_rm
),
24629 cCL("logdz", e5081e0
, 2, (RF
, RF_IF
), rd_rm
),
24630 cCL("loge", e588100
, 2, (RF
, RF_IF
), rd_rm
),
24631 cCL("logep", e588120
, 2, (RF
, RF_IF
), rd_rm
),
24632 cCL("logem", e588140
, 2, (RF
, RF_IF
), rd_rm
),
24633 cCL("logez", e588160
, 2, (RF
, RF_IF
), rd_rm
),
24635 cCL("lgns", e608100
, 2, (RF
, RF_IF
), rd_rm
),
24636 cCL("lgnsp", e608120
, 2, (RF
, RF_IF
), rd_rm
),
24637 cCL("lgnsm", e608140
, 2, (RF
, RF_IF
), rd_rm
),
24638 cCL("lgnsz", e608160
, 2, (RF
, RF_IF
), rd_rm
),
24639 cCL("lgnd", e608180
, 2, (RF
, RF_IF
), rd_rm
),
24640 cCL("lgndp", e6081a0
, 2, (RF
, RF_IF
), rd_rm
),
24641 cCL("lgndm", e6081c0
, 2, (RF
, RF_IF
), rd_rm
),
24642 cCL("lgndz", e6081e0
, 2, (RF
, RF_IF
), rd_rm
),
24643 cCL("lgne", e688100
, 2, (RF
, RF_IF
), rd_rm
),
24644 cCL("lgnep", e688120
, 2, (RF
, RF_IF
), rd_rm
),
24645 cCL("lgnem", e688140
, 2, (RF
, RF_IF
), rd_rm
),
24646 cCL("lgnez", e688160
, 2, (RF
, RF_IF
), rd_rm
),
24648 cCL("exps", e708100
, 2, (RF
, RF_IF
), rd_rm
),
24649 cCL("expsp", e708120
, 2, (RF
, RF_IF
), rd_rm
),
24650 cCL("expsm", e708140
, 2, (RF
, RF_IF
), rd_rm
),
24651 cCL("expsz", e708160
, 2, (RF
, RF_IF
), rd_rm
),
24652 cCL("expd", e708180
, 2, (RF
, RF_IF
), rd_rm
),
24653 cCL("expdp", e7081a0
, 2, (RF
, RF_IF
), rd_rm
),
24654 cCL("expdm", e7081c0
, 2, (RF
, RF_IF
), rd_rm
),
24655 cCL("expdz", e7081e0
, 2, (RF
, RF_IF
), rd_rm
),
24656 cCL("expe", e788100
, 2, (RF
, RF_IF
), rd_rm
),
24657 cCL("expep", e788120
, 2, (RF
, RF_IF
), rd_rm
),
24658 cCL("expem", e788140
, 2, (RF
, RF_IF
), rd_rm
),
24659 cCL("expdz", e788160
, 2, (RF
, RF_IF
), rd_rm
),
24661 cCL("sins", e808100
, 2, (RF
, RF_IF
), rd_rm
),
24662 cCL("sinsp", e808120
, 2, (RF
, RF_IF
), rd_rm
),
24663 cCL("sinsm", e808140
, 2, (RF
, RF_IF
), rd_rm
),
24664 cCL("sinsz", e808160
, 2, (RF
, RF_IF
), rd_rm
),
24665 cCL("sind", e808180
, 2, (RF
, RF_IF
), rd_rm
),
24666 cCL("sindp", e8081a0
, 2, (RF
, RF_IF
), rd_rm
),
24667 cCL("sindm", e8081c0
, 2, (RF
, RF_IF
), rd_rm
),
24668 cCL("sindz", e8081e0
, 2, (RF
, RF_IF
), rd_rm
),
24669 cCL("sine", e888100
, 2, (RF
, RF_IF
), rd_rm
),
24670 cCL("sinep", e888120
, 2, (RF
, RF_IF
), rd_rm
),
24671 cCL("sinem", e888140
, 2, (RF
, RF_IF
), rd_rm
),
24672 cCL("sinez", e888160
, 2, (RF
, RF_IF
), rd_rm
),
24674 cCL("coss", e908100
, 2, (RF
, RF_IF
), rd_rm
),
24675 cCL("cossp", e908120
, 2, (RF
, RF_IF
), rd_rm
),
24676 cCL("cossm", e908140
, 2, (RF
, RF_IF
), rd_rm
),
24677 cCL("cossz", e908160
, 2, (RF
, RF_IF
), rd_rm
),
24678 cCL("cosd", e908180
, 2, (RF
, RF_IF
), rd_rm
),
24679 cCL("cosdp", e9081a0
, 2, (RF
, RF_IF
), rd_rm
),
24680 cCL("cosdm", e9081c0
, 2, (RF
, RF_IF
), rd_rm
),
24681 cCL("cosdz", e9081e0
, 2, (RF
, RF_IF
), rd_rm
),
24682 cCL("cose", e988100
, 2, (RF
, RF_IF
), rd_rm
),
24683 cCL("cosep", e988120
, 2, (RF
, RF_IF
), rd_rm
),
24684 cCL("cosem", e988140
, 2, (RF
, RF_IF
), rd_rm
),
24685 cCL("cosez", e988160
, 2, (RF
, RF_IF
), rd_rm
),
24687 cCL("tans", ea08100
, 2, (RF
, RF_IF
), rd_rm
),
24688 cCL("tansp", ea08120
, 2, (RF
, RF_IF
), rd_rm
),
24689 cCL("tansm", ea08140
, 2, (RF
, RF_IF
), rd_rm
),
24690 cCL("tansz", ea08160
, 2, (RF
, RF_IF
), rd_rm
),
24691 cCL("tand", ea08180
, 2, (RF
, RF_IF
), rd_rm
),
24692 cCL("tandp", ea081a0
, 2, (RF
, RF_IF
), rd_rm
),
24693 cCL("tandm", ea081c0
, 2, (RF
, RF_IF
), rd_rm
),
24694 cCL("tandz", ea081e0
, 2, (RF
, RF_IF
), rd_rm
),
24695 cCL("tane", ea88100
, 2, (RF
, RF_IF
), rd_rm
),
24696 cCL("tanep", ea88120
, 2, (RF
, RF_IF
), rd_rm
),
24697 cCL("tanem", ea88140
, 2, (RF
, RF_IF
), rd_rm
),
24698 cCL("tanez", ea88160
, 2, (RF
, RF_IF
), rd_rm
),
24700 cCL("asns", eb08100
, 2, (RF
, RF_IF
), rd_rm
),
24701 cCL("asnsp", eb08120
, 2, (RF
, RF_IF
), rd_rm
),
24702 cCL("asnsm", eb08140
, 2, (RF
, RF_IF
), rd_rm
),
24703 cCL("asnsz", eb08160
, 2, (RF
, RF_IF
), rd_rm
),
24704 cCL("asnd", eb08180
, 2, (RF
, RF_IF
), rd_rm
),
24705 cCL("asndp", eb081a0
, 2, (RF
, RF_IF
), rd_rm
),
24706 cCL("asndm", eb081c0
, 2, (RF
, RF_IF
), rd_rm
),
24707 cCL("asndz", eb081e0
, 2, (RF
, RF_IF
), rd_rm
),
24708 cCL("asne", eb88100
, 2, (RF
, RF_IF
), rd_rm
),
24709 cCL("asnep", eb88120
, 2, (RF
, RF_IF
), rd_rm
),
24710 cCL("asnem", eb88140
, 2, (RF
, RF_IF
), rd_rm
),
24711 cCL("asnez", eb88160
, 2, (RF
, RF_IF
), rd_rm
),
24713 cCL("acss", ec08100
, 2, (RF
, RF_IF
), rd_rm
),
24714 cCL("acssp", ec08120
, 2, (RF
, RF_IF
), rd_rm
),
24715 cCL("acssm", ec08140
, 2, (RF
, RF_IF
), rd_rm
),
24716 cCL("acssz", ec08160
, 2, (RF
, RF_IF
), rd_rm
),
24717 cCL("acsd", ec08180
, 2, (RF
, RF_IF
), rd_rm
),
24718 cCL("acsdp", ec081a0
, 2, (RF
, RF_IF
), rd_rm
),
24719 cCL("acsdm", ec081c0
, 2, (RF
, RF_IF
), rd_rm
),
24720 cCL("acsdz", ec081e0
, 2, (RF
, RF_IF
), rd_rm
),
24721 cCL("acse", ec88100
, 2, (RF
, RF_IF
), rd_rm
),
24722 cCL("acsep", ec88120
, 2, (RF
, RF_IF
), rd_rm
),
24723 cCL("acsem", ec88140
, 2, (RF
, RF_IF
), rd_rm
),
24724 cCL("acsez", ec88160
, 2, (RF
, RF_IF
), rd_rm
),
24726 cCL("atns", ed08100
, 2, (RF
, RF_IF
), rd_rm
),
24727 cCL("atnsp", ed08120
, 2, (RF
, RF_IF
), rd_rm
),
24728 cCL("atnsm", ed08140
, 2, (RF
, RF_IF
), rd_rm
),
24729 cCL("atnsz", ed08160
, 2, (RF
, RF_IF
), rd_rm
),
24730 cCL("atnd", ed08180
, 2, (RF
, RF_IF
), rd_rm
),
24731 cCL("atndp", ed081a0
, 2, (RF
, RF_IF
), rd_rm
),
24732 cCL("atndm", ed081c0
, 2, (RF
, RF_IF
), rd_rm
),
24733 cCL("atndz", ed081e0
, 2, (RF
, RF_IF
), rd_rm
),
24734 cCL("atne", ed88100
, 2, (RF
, RF_IF
), rd_rm
),
24735 cCL("atnep", ed88120
, 2, (RF
, RF_IF
), rd_rm
),
24736 cCL("atnem", ed88140
, 2, (RF
, RF_IF
), rd_rm
),
24737 cCL("atnez", ed88160
, 2, (RF
, RF_IF
), rd_rm
),
24739 cCL("urds", ee08100
, 2, (RF
, RF_IF
), rd_rm
),
24740 cCL("urdsp", ee08120
, 2, (RF
, RF_IF
), rd_rm
),
24741 cCL("urdsm", ee08140
, 2, (RF
, RF_IF
), rd_rm
),
24742 cCL("urdsz", ee08160
, 2, (RF
, RF_IF
), rd_rm
),
24743 cCL("urdd", ee08180
, 2, (RF
, RF_IF
), rd_rm
),
24744 cCL("urddp", ee081a0
, 2, (RF
, RF_IF
), rd_rm
),
24745 cCL("urddm", ee081c0
, 2, (RF
, RF_IF
), rd_rm
),
24746 cCL("urddz", ee081e0
, 2, (RF
, RF_IF
), rd_rm
),
24747 cCL("urde", ee88100
, 2, (RF
, RF_IF
), rd_rm
),
24748 cCL("urdep", ee88120
, 2, (RF
, RF_IF
), rd_rm
),
24749 cCL("urdem", ee88140
, 2, (RF
, RF_IF
), rd_rm
),
24750 cCL("urdez", ee88160
, 2, (RF
, RF_IF
), rd_rm
),
24752 cCL("nrms", ef08100
, 2, (RF
, RF_IF
), rd_rm
),
24753 cCL("nrmsp", ef08120
, 2, (RF
, RF_IF
), rd_rm
),
24754 cCL("nrmsm", ef08140
, 2, (RF
, RF_IF
), rd_rm
),
24755 cCL("nrmsz", ef08160
, 2, (RF
, RF_IF
), rd_rm
),
24756 cCL("nrmd", ef08180
, 2, (RF
, RF_IF
), rd_rm
),
24757 cCL("nrmdp", ef081a0
, 2, (RF
, RF_IF
), rd_rm
),
24758 cCL("nrmdm", ef081c0
, 2, (RF
, RF_IF
), rd_rm
),
24759 cCL("nrmdz", ef081e0
, 2, (RF
, RF_IF
), rd_rm
),
24760 cCL("nrme", ef88100
, 2, (RF
, RF_IF
), rd_rm
),
24761 cCL("nrmep", ef88120
, 2, (RF
, RF_IF
), rd_rm
),
24762 cCL("nrmem", ef88140
, 2, (RF
, RF_IF
), rd_rm
),
24763 cCL("nrmez", ef88160
, 2, (RF
, RF_IF
), rd_rm
),
24765 cCL("adfs", e000100
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24766 cCL("adfsp", e000120
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24767 cCL("adfsm", e000140
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24768 cCL("adfsz", e000160
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24769 cCL("adfd", e000180
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24770 cCL("adfdp", e0001a0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24771 cCL("adfdm", e0001c0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24772 cCL("adfdz", e0001e0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24773 cCL("adfe", e080100
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24774 cCL("adfep", e080120
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24775 cCL("adfem", e080140
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24776 cCL("adfez", e080160
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24778 cCL("sufs", e200100
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24779 cCL("sufsp", e200120
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24780 cCL("sufsm", e200140
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24781 cCL("sufsz", e200160
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24782 cCL("sufd", e200180
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24783 cCL("sufdp", e2001a0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24784 cCL("sufdm", e2001c0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24785 cCL("sufdz", e2001e0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24786 cCL("sufe", e280100
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24787 cCL("sufep", e280120
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24788 cCL("sufem", e280140
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24789 cCL("sufez", e280160
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24791 cCL("rsfs", e300100
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24792 cCL("rsfsp", e300120
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24793 cCL("rsfsm", e300140
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24794 cCL("rsfsz", e300160
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24795 cCL("rsfd", e300180
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24796 cCL("rsfdp", e3001a0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24797 cCL("rsfdm", e3001c0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24798 cCL("rsfdz", e3001e0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24799 cCL("rsfe", e380100
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24800 cCL("rsfep", e380120
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24801 cCL("rsfem", e380140
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24802 cCL("rsfez", e380160
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24804 cCL("mufs", e100100
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24805 cCL("mufsp", e100120
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24806 cCL("mufsm", e100140
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24807 cCL("mufsz", e100160
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24808 cCL("mufd", e100180
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24809 cCL("mufdp", e1001a0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24810 cCL("mufdm", e1001c0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24811 cCL("mufdz", e1001e0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24812 cCL("mufe", e180100
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24813 cCL("mufep", e180120
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24814 cCL("mufem", e180140
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24815 cCL("mufez", e180160
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24817 cCL("dvfs", e400100
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24818 cCL("dvfsp", e400120
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24819 cCL("dvfsm", e400140
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24820 cCL("dvfsz", e400160
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24821 cCL("dvfd", e400180
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24822 cCL("dvfdp", e4001a0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24823 cCL("dvfdm", e4001c0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24824 cCL("dvfdz", e4001e0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24825 cCL("dvfe", e480100
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24826 cCL("dvfep", e480120
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24827 cCL("dvfem", e480140
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24828 cCL("dvfez", e480160
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24830 cCL("rdfs", e500100
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24831 cCL("rdfsp", e500120
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24832 cCL("rdfsm", e500140
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24833 cCL("rdfsz", e500160
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24834 cCL("rdfd", e500180
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24835 cCL("rdfdp", e5001a0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24836 cCL("rdfdm", e5001c0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24837 cCL("rdfdz", e5001e0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24838 cCL("rdfe", e580100
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24839 cCL("rdfep", e580120
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24840 cCL("rdfem", e580140
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24841 cCL("rdfez", e580160
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24843 cCL("pows", e600100
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24844 cCL("powsp", e600120
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24845 cCL("powsm", e600140
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24846 cCL("powsz", e600160
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24847 cCL("powd", e600180
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24848 cCL("powdp", e6001a0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24849 cCL("powdm", e6001c0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24850 cCL("powdz", e6001e0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24851 cCL("powe", e680100
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24852 cCL("powep", e680120
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24853 cCL("powem", e680140
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24854 cCL("powez", e680160
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24856 cCL("rpws", e700100
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24857 cCL("rpwsp", e700120
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24858 cCL("rpwsm", e700140
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24859 cCL("rpwsz", e700160
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24860 cCL("rpwd", e700180
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24861 cCL("rpwdp", e7001a0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24862 cCL("rpwdm", e7001c0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24863 cCL("rpwdz", e7001e0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24864 cCL("rpwe", e780100
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24865 cCL("rpwep", e780120
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24866 cCL("rpwem", e780140
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24867 cCL("rpwez", e780160
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24869 cCL("rmfs", e800100
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24870 cCL("rmfsp", e800120
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24871 cCL("rmfsm", e800140
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24872 cCL("rmfsz", e800160
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24873 cCL("rmfd", e800180
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24874 cCL("rmfdp", e8001a0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24875 cCL("rmfdm", e8001c0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24876 cCL("rmfdz", e8001e0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24877 cCL("rmfe", e880100
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24878 cCL("rmfep", e880120
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24879 cCL("rmfem", e880140
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24880 cCL("rmfez", e880160
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24882 cCL("fmls", e900100
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24883 cCL("fmlsp", e900120
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24884 cCL("fmlsm", e900140
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24885 cCL("fmlsz", e900160
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24886 cCL("fmld", e900180
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24887 cCL("fmldp", e9001a0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24888 cCL("fmldm", e9001c0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24889 cCL("fmldz", e9001e0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24890 cCL("fmle", e980100
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24891 cCL("fmlep", e980120
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24892 cCL("fmlem", e980140
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24893 cCL("fmlez", e980160
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24895 cCL("fdvs", ea00100
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24896 cCL("fdvsp", ea00120
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24897 cCL("fdvsm", ea00140
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24898 cCL("fdvsz", ea00160
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24899 cCL("fdvd", ea00180
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24900 cCL("fdvdp", ea001a0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24901 cCL("fdvdm", ea001c0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24902 cCL("fdvdz", ea001e0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24903 cCL("fdve", ea80100
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24904 cCL("fdvep", ea80120
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24905 cCL("fdvem", ea80140
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24906 cCL("fdvez", ea80160
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24908 cCL("frds", eb00100
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24909 cCL("frdsp", eb00120
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24910 cCL("frdsm", eb00140
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24911 cCL("frdsz", eb00160
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24912 cCL("frdd", eb00180
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24913 cCL("frddp", eb001a0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24914 cCL("frddm", eb001c0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24915 cCL("frddz", eb001e0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24916 cCL("frde", eb80100
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24917 cCL("frdep", eb80120
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24918 cCL("frdem", eb80140
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24919 cCL("frdez", eb80160
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24921 cCL("pols", ec00100
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24922 cCL("polsp", ec00120
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24923 cCL("polsm", ec00140
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24924 cCL("polsz", ec00160
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24925 cCL("pold", ec00180
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24926 cCL("poldp", ec001a0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24927 cCL("poldm", ec001c0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24928 cCL("poldz", ec001e0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24929 cCL("pole", ec80100
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24930 cCL("polep", ec80120
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24931 cCL("polem", ec80140
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24932 cCL("polez", ec80160
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
24934 cCE("cmf", e90f110
, 2, (RF
, RF_IF
), fpa_cmp
),
24935 C3E("cmfe", ed0f110
, 2, (RF
, RF_IF
), fpa_cmp
),
24936 cCE("cnf", eb0f110
, 2, (RF
, RF_IF
), fpa_cmp
),
24937 C3E("cnfe", ef0f110
, 2, (RF
, RF_IF
), fpa_cmp
),
24939 cCL("flts", e000110
, 2, (RF
, RR
), rn_rd
),
24940 cCL("fltsp", e000130
, 2, (RF
, RR
), rn_rd
),
24941 cCL("fltsm", e000150
, 2, (RF
, RR
), rn_rd
),
24942 cCL("fltsz", e000170
, 2, (RF
, RR
), rn_rd
),
24943 cCL("fltd", e000190
, 2, (RF
, RR
), rn_rd
),
24944 cCL("fltdp", e0001b0
, 2, (RF
, RR
), rn_rd
),
24945 cCL("fltdm", e0001d0
, 2, (RF
, RR
), rn_rd
),
24946 cCL("fltdz", e0001f0
, 2, (RF
, RR
), rn_rd
),
24947 cCL("flte", e080110
, 2, (RF
, RR
), rn_rd
),
24948 cCL("fltep", e080130
, 2, (RF
, RR
), rn_rd
),
24949 cCL("fltem", e080150
, 2, (RF
, RR
), rn_rd
),
24950 cCL("fltez", e080170
, 2, (RF
, RR
), rn_rd
),
24952 /* The implementation of the FIX instruction is broken on some
24953 assemblers, in that it accepts a precision specifier as well as a
24954 rounding specifier, despite the fact that this is meaningless.
24955 To be more compatible, we accept it as well, though of course it
24956 does not set any bits. */
24957 cCE("fix", e100110
, 2, (RR
, RF
), rd_rm
),
24958 cCL("fixp", e100130
, 2, (RR
, RF
), rd_rm
),
24959 cCL("fixm", e100150
, 2, (RR
, RF
), rd_rm
),
24960 cCL("fixz", e100170
, 2, (RR
, RF
), rd_rm
),
24961 cCL("fixsp", e100130
, 2, (RR
, RF
), rd_rm
),
24962 cCL("fixsm", e100150
, 2, (RR
, RF
), rd_rm
),
24963 cCL("fixsz", e100170
, 2, (RR
, RF
), rd_rm
),
24964 cCL("fixdp", e100130
, 2, (RR
, RF
), rd_rm
),
24965 cCL("fixdm", e100150
, 2, (RR
, RF
), rd_rm
),
24966 cCL("fixdz", e100170
, 2, (RR
, RF
), rd_rm
),
24967 cCL("fixep", e100130
, 2, (RR
, RF
), rd_rm
),
24968 cCL("fixem", e100150
, 2, (RR
, RF
), rd_rm
),
24969 cCL("fixez", e100170
, 2, (RR
, RF
), rd_rm
),
24971 /* Instructions that were new with the real FPA, call them V2. */
24973 #define ARM_VARIANT & fpu_fpa_ext_v2
24975 cCE("lfm", c100200
, 3, (RF
, I4b
, ADDR
), fpa_ldmstm
),
24976 cCL("lfmfd", c900200
, 3, (RF
, I4b
, ADDR
), fpa_ldmstm
),
24977 cCL("lfmea", d100200
, 3, (RF
, I4b
, ADDR
), fpa_ldmstm
),
24978 cCE("sfm", c000200
, 3, (RF
, I4b
, ADDR
), fpa_ldmstm
),
24979 cCL("sfmfd", d000200
, 3, (RF
, I4b
, ADDR
), fpa_ldmstm
),
24980 cCL("sfmea", c800200
, 3, (RF
, I4b
, ADDR
), fpa_ldmstm
),
24983 #define ARM_VARIANT & fpu_vfp_ext_v1xd /* VFP V1xD (single precision). */
24984 #undef THUMB_VARIANT
24985 #define THUMB_VARIANT & arm_ext_v6t2
24986 mcCE(vmrs
, ef00a10
, 2, (APSR_RR
, RVC
), vmrs
),
24987 mcCE(vmsr
, ee00a10
, 2, (RVC
, RR
), vmsr
),
24988 mcCE(fldd
, d100b00
, 2, (RVD
, ADDRGLDC
), vfp_dp_ldst
),
24989 mcCE(fstd
, d000b00
, 2, (RVD
, ADDRGLDC
), vfp_dp_ldst
),
24990 mcCE(flds
, d100a00
, 2, (RVS
, ADDRGLDC
), vfp_sp_ldst
),
24991 mcCE(fsts
, d000a00
, 2, (RVS
, ADDRGLDC
), vfp_sp_ldst
),
24992 #undef THUMB_VARIANT
24994 /* Moves and type conversions. */
24995 cCE("fmstat", ef1fa10
, 0, (), noargs
),
24996 cCE("fsitos", eb80ac0
, 2, (RVS
, RVS
), vfp_sp_monadic
),
24997 cCE("fuitos", eb80a40
, 2, (RVS
, RVS
), vfp_sp_monadic
),
24998 cCE("ftosis", ebd0a40
, 2, (RVS
, RVS
), vfp_sp_monadic
),
24999 cCE("ftosizs", ebd0ac0
, 2, (RVS
, RVS
), vfp_sp_monadic
),
25000 cCE("ftouis", ebc0a40
, 2, (RVS
, RVS
), vfp_sp_monadic
),
25001 cCE("ftouizs", ebc0ac0
, 2, (RVS
, RVS
), vfp_sp_monadic
),
25002 cCE("fmrx", ef00a10
, 2, (RR
, RVC
), rd_rn
),
25003 cCE("fmxr", ee00a10
, 2, (RVC
, RR
), rn_rd
),
25005 /* Memory operations. */
25006 cCE("fldmias", c900a00
, 2, (RRnpctw
, VRSLST
), vfp_sp_ldstmia
),
25007 cCE("fldmfds", c900a00
, 2, (RRnpctw
, VRSLST
), vfp_sp_ldstmia
),
25008 cCE("fldmdbs", d300a00
, 2, (RRnpctw
, VRSLST
), vfp_sp_ldstmdb
),
25009 cCE("fldmeas", d300a00
, 2, (RRnpctw
, VRSLST
), vfp_sp_ldstmdb
),
25010 cCE("fldmiax", c900b00
, 2, (RRnpctw
, VRDLST
), vfp_xp_ldstmia
),
25011 cCE("fldmfdx", c900b00
, 2, (RRnpctw
, VRDLST
), vfp_xp_ldstmia
),
25012 cCE("fldmdbx", d300b00
, 2, (RRnpctw
, VRDLST
), vfp_xp_ldstmdb
),
25013 cCE("fldmeax", d300b00
, 2, (RRnpctw
, VRDLST
), vfp_xp_ldstmdb
),
25014 cCE("fstmias", c800a00
, 2, (RRnpctw
, VRSLST
), vfp_sp_ldstmia
),
25015 cCE("fstmeas", c800a00
, 2, (RRnpctw
, VRSLST
), vfp_sp_ldstmia
),
25016 cCE("fstmdbs", d200a00
, 2, (RRnpctw
, VRSLST
), vfp_sp_ldstmdb
),
25017 cCE("fstmfds", d200a00
, 2, (RRnpctw
, VRSLST
), vfp_sp_ldstmdb
),
25018 cCE("fstmiax", c800b00
, 2, (RRnpctw
, VRDLST
), vfp_xp_ldstmia
),
25019 cCE("fstmeax", c800b00
, 2, (RRnpctw
, VRDLST
), vfp_xp_ldstmia
),
25020 cCE("fstmdbx", d200b00
, 2, (RRnpctw
, VRDLST
), vfp_xp_ldstmdb
),
25021 cCE("fstmfdx", d200b00
, 2, (RRnpctw
, VRDLST
), vfp_xp_ldstmdb
),
25023 /* Monadic operations. */
25024 cCE("fabss", eb00ac0
, 2, (RVS
, RVS
), vfp_sp_monadic
),
25025 cCE("fnegs", eb10a40
, 2, (RVS
, RVS
), vfp_sp_monadic
),
25026 cCE("fsqrts", eb10ac0
, 2, (RVS
, RVS
), vfp_sp_monadic
),
25028 /* Dyadic operations. */
25029 cCE("fadds", e300a00
, 3, (RVS
, RVS
, RVS
), vfp_sp_dyadic
),
25030 cCE("fsubs", e300a40
, 3, (RVS
, RVS
, RVS
), vfp_sp_dyadic
),
25031 cCE("fmuls", e200a00
, 3, (RVS
, RVS
, RVS
), vfp_sp_dyadic
),
25032 cCE("fdivs", e800a00
, 3, (RVS
, RVS
, RVS
), vfp_sp_dyadic
),
25033 cCE("fmacs", e000a00
, 3, (RVS
, RVS
, RVS
), vfp_sp_dyadic
),
25034 cCE("fmscs", e100a00
, 3, (RVS
, RVS
, RVS
), vfp_sp_dyadic
),
25035 cCE("fnmuls", e200a40
, 3, (RVS
, RVS
, RVS
), vfp_sp_dyadic
),
25036 cCE("fnmacs", e000a40
, 3, (RVS
, RVS
, RVS
), vfp_sp_dyadic
),
25037 cCE("fnmscs", e100a40
, 3, (RVS
, RVS
, RVS
), vfp_sp_dyadic
),
25040 cCE("fcmps", eb40a40
, 2, (RVS
, RVS
), vfp_sp_monadic
),
25041 cCE("fcmpzs", eb50a40
, 1, (RVS
), vfp_sp_compare_z
),
25042 cCE("fcmpes", eb40ac0
, 2, (RVS
, RVS
), vfp_sp_monadic
),
25043 cCE("fcmpezs", eb50ac0
, 1, (RVS
), vfp_sp_compare_z
),
25045 /* Double precision load/store are still present on single precision
25046 implementations. */
25047 cCE("fldmiad", c900b00
, 2, (RRnpctw
, VRDLST
), vfp_dp_ldstmia
),
25048 cCE("fldmfdd", c900b00
, 2, (RRnpctw
, VRDLST
), vfp_dp_ldstmia
),
25049 cCE("fldmdbd", d300b00
, 2, (RRnpctw
, VRDLST
), vfp_dp_ldstmdb
),
25050 cCE("fldmead", d300b00
, 2, (RRnpctw
, VRDLST
), vfp_dp_ldstmdb
),
25051 cCE("fstmiad", c800b00
, 2, (RRnpctw
, VRDLST
), vfp_dp_ldstmia
),
25052 cCE("fstmead", c800b00
, 2, (RRnpctw
, VRDLST
), vfp_dp_ldstmia
),
25053 cCE("fstmdbd", d200b00
, 2, (RRnpctw
, VRDLST
), vfp_dp_ldstmdb
),
25054 cCE("fstmfdd", d200b00
, 2, (RRnpctw
, VRDLST
), vfp_dp_ldstmdb
),
25057 #define ARM_VARIANT & fpu_vfp_ext_v1 /* VFP V1 (Double precision). */
25059 /* Moves and type conversions. */
25060 cCE("fcvtds", eb70ac0
, 2, (RVD
, RVS
), vfp_dp_sp_cvt
),
25061 cCE("fcvtsd", eb70bc0
, 2, (RVS
, RVD
), vfp_sp_dp_cvt
),
25062 cCE("fmdhr", e200b10
, 2, (RVD
, RR
), vfp_dp_rn_rd
),
25063 cCE("fmdlr", e000b10
, 2, (RVD
, RR
), vfp_dp_rn_rd
),
25064 cCE("fmrdh", e300b10
, 2, (RR
, RVD
), vfp_dp_rd_rn
),
25065 cCE("fmrdl", e100b10
, 2, (RR
, RVD
), vfp_dp_rd_rn
),
25066 cCE("fsitod", eb80bc0
, 2, (RVD
, RVS
), vfp_dp_sp_cvt
),
25067 cCE("fuitod", eb80b40
, 2, (RVD
, RVS
), vfp_dp_sp_cvt
),
25068 cCE("ftosid", ebd0b40
, 2, (RVS
, RVD
), vfp_sp_dp_cvt
),
25069 cCE("ftosizd", ebd0bc0
, 2, (RVS
, RVD
), vfp_sp_dp_cvt
),
25070 cCE("ftouid", ebc0b40
, 2, (RVS
, RVD
), vfp_sp_dp_cvt
),
25071 cCE("ftouizd", ebc0bc0
, 2, (RVS
, RVD
), vfp_sp_dp_cvt
),
25073 /* Monadic operations. */
25074 cCE("fabsd", eb00bc0
, 2, (RVD
, RVD
), vfp_dp_rd_rm
),
25075 cCE("fnegd", eb10b40
, 2, (RVD
, RVD
), vfp_dp_rd_rm
),
25076 cCE("fsqrtd", eb10bc0
, 2, (RVD
, RVD
), vfp_dp_rd_rm
),
25078 /* Dyadic operations. */
25079 cCE("faddd", e300b00
, 3, (RVD
, RVD
, RVD
), vfp_dp_rd_rn_rm
),
25080 cCE("fsubd", e300b40
, 3, (RVD
, RVD
, RVD
), vfp_dp_rd_rn_rm
),
25081 cCE("fmuld", e200b00
, 3, (RVD
, RVD
, RVD
), vfp_dp_rd_rn_rm
),
25082 cCE("fdivd", e800b00
, 3, (RVD
, RVD
, RVD
), vfp_dp_rd_rn_rm
),
25083 cCE("fmacd", e000b00
, 3, (RVD
, RVD
, RVD
), vfp_dp_rd_rn_rm
),
25084 cCE("fmscd", e100b00
, 3, (RVD
, RVD
, RVD
), vfp_dp_rd_rn_rm
),
25085 cCE("fnmuld", e200b40
, 3, (RVD
, RVD
, RVD
), vfp_dp_rd_rn_rm
),
25086 cCE("fnmacd", e000b40
, 3, (RVD
, RVD
, RVD
), vfp_dp_rd_rn_rm
),
25087 cCE("fnmscd", e100b40
, 3, (RVD
, RVD
, RVD
), vfp_dp_rd_rn_rm
),
25090 cCE("fcmpd", eb40b40
, 2, (RVD
, RVD
), vfp_dp_rd_rm
),
25091 cCE("fcmpzd", eb50b40
, 1, (RVD
), vfp_dp_rd
),
25092 cCE("fcmped", eb40bc0
, 2, (RVD
, RVD
), vfp_dp_rd_rm
),
25093 cCE("fcmpezd", eb50bc0
, 1, (RVD
), vfp_dp_rd
),
25095 /* Instructions which may belong to either the Neon or VFP instruction sets.
25096 Individual encoder functions perform additional architecture checks. */
25098 #define ARM_VARIANT & fpu_vfp_ext_v1xd
25099 #undef THUMB_VARIANT
25100 #define THUMB_VARIANT & arm_ext_v6t2
25102 NCE(vldm
, c900b00
, 2, (RRnpctw
, VRSDLST
), neon_ldm_stm
),
25103 NCE(vldmia
, c900b00
, 2, (RRnpctw
, VRSDLST
), neon_ldm_stm
),
25104 NCE(vldmdb
, d100b00
, 2, (RRnpctw
, VRSDLST
), neon_ldm_stm
),
25105 NCE(vstm
, c800b00
, 2, (RRnpctw
, VRSDLST
), neon_ldm_stm
),
25106 NCE(vstmia
, c800b00
, 2, (RRnpctw
, VRSDLST
), neon_ldm_stm
),
25107 NCE(vstmdb
, d000b00
, 2, (RRnpctw
, VRSDLST
), neon_ldm_stm
),
25109 NCE(vpop
, 0, 1, (VRSDLST
), vfp_nsyn_pop
),
25110 NCE(vpush
, 0, 1, (VRSDLST
), vfp_nsyn_push
),
25112 #undef THUMB_VARIANT
25113 #define THUMB_VARIANT & fpu_vfp_ext_v1xd
25115 /* These mnemonics are unique to VFP. */
25116 NCE(vsqrt
, 0, 2, (RVSD
, RVSD
), vfp_nsyn_sqrt
),
25117 NCE(vdiv
, 0, 3, (RVSD
, RVSD
, RVSD
), vfp_nsyn_div
),
25118 nCE(vnmul
, _vnmul
, 3, (RVSD
, RVSD
, RVSD
), vfp_nsyn_nmul
),
25119 nCE(vnmla
, _vnmla
, 3, (RVSD
, RVSD
, RVSD
), vfp_nsyn_nmul
),
25120 nCE(vnmls
, _vnmls
, 3, (RVSD
, RVSD
, RVSD
), vfp_nsyn_nmul
),
25121 NCE(vcvtz
, 0, 2, (RVSD
, RVSD
), vfp_nsyn_cvtz
),
25123 /* Mnemonics shared by Neon and VFP. */
25124 nCEF(vmls
, _vmls
, 3, (RNSDQ
, oRNSDQ
, RNSDQ_RNSC
), neon_mac_maybe_scalar
),
25126 mnCEF(vcvt
, _vcvt
, 3, (RNSDQMQ
, RNSDQMQ
, oI32z
), neon_cvt
),
25127 nCEF(vcvtr
, _vcvt
, 2, (RNSDQ
, RNSDQ
), neon_cvtr
),
25128 MNCEF(vcvtb
, eb20a40
, 3, (RVSDMQ
, RVSDMQ
, oI32b
), neon_cvtb
),
25129 MNCEF(vcvtt
, eb20a40
, 3, (RVSDMQ
, RVSDMQ
, oI32b
), neon_cvtt
),
25132 /* NOTE: All VMOV encoding is special-cased! */
25133 NCE(vmovq
, 0, 1, (VMOV
), neon_mov
),
25135 #undef THUMB_VARIANT
25136 /* Could be either VLDR/VSTR or VLDR/VSTR (system register) which are guarded
25137 by different feature bits. Since we are setting the Thumb guard, we can
25138 require Thumb-1 which makes it a nop guard and set the right feature bit in
25139 do_vldr_vstr (). */
25140 #define THUMB_VARIANT & arm_ext_v4t
25141 NCE(vldr
, d100b00
, 2, (VLDR
, ADDRGLDC
), vldr_vstr
),
25142 NCE(vstr
, d000b00
, 2, (VLDR
, ADDRGLDC
), vldr_vstr
),
25145 #define ARM_VARIANT & arm_ext_fp16
25146 #undef THUMB_VARIANT
25147 #define THUMB_VARIANT & arm_ext_fp16
25148 /* New instructions added from v8.2, allowing the extraction and insertion of
25149 the upper 16 bits of a 32-bit vector register. */
25150 NCE (vmovx
, eb00a40
, 2, (RVS
, RVS
), neon_movhf
),
25151 NCE (vins
, eb00ac0
, 2, (RVS
, RVS
), neon_movhf
),
25153 /* New backported fma/fms instructions optional in v8.2. */
25154 NUF (vfmsl
, 810, 3, (RNDQ
, RNSD
, RNSD_RNSC
), neon_vfmsl
),
25155 NUF (vfmal
, 810, 3, (RNDQ
, RNSD
, RNSD_RNSC
), neon_vfmal
),
25157 #undef THUMB_VARIANT
25158 #define THUMB_VARIANT & fpu_neon_ext_v1
25160 #define ARM_VARIANT & fpu_neon_ext_v1
25162 /* Data processing with three registers of the same length. */
25163 /* integer ops, valid types S8 S16 S32 U8 U16 U32. */
25164 NUF(vaba
, 0000710, 3, (RNDQ
, RNDQ
, RNDQ
), neon_dyadic_i_su
),
25165 NUF(vabaq
, 0000710, 3, (RNQ
, RNQ
, RNQ
), neon_dyadic_i_su
),
25166 NUF(vhaddq
, 0000000, 3, (RNQ
, oRNQ
, RNQ
), neon_dyadic_i_su
),
25167 NUF(vrhaddq
, 0000100, 3, (RNQ
, oRNQ
, RNQ
), neon_dyadic_i_su
),
25168 NUF(vhsubq
, 0000200, 3, (RNQ
, oRNQ
, RNQ
), neon_dyadic_i_su
),
25169 /* integer ops, valid types S8 S16 S32 S64 U8 U16 U32 U64. */
25170 NUF(vqaddq
, 0000010, 3, (RNQ
, oRNQ
, RNQ
), neon_dyadic_i64_su
),
25171 NUF(vqsubq
, 0000210, 3, (RNQ
, oRNQ
, RNQ
), neon_dyadic_i64_su
),
25172 NUF(vrshlq
, 0000500, 3, (RNQ
, oRNQ
, RNQ
), neon_rshl
),
25173 NUF(vqrshlq
, 0000510, 3, (RNQ
, oRNQ
, RNQ
), neon_rshl
),
25174 /* If not immediate, fall back to neon_dyadic_i64_su.
25175 shl should accept I8 I16 I32 I64,
25176 qshl should accept S8 S16 S32 S64 U8 U16 U32 U64. */
25177 nUF(vshlq
, _vshl
, 3, (RNQ
, oRNQ
, RNDQ_I63b
), neon_shl
),
25178 nUF(vqshlq
, _vqshl
, 3, (RNQ
, oRNQ
, RNDQ_I63b
), neon_qshl
),
25179 /* Logic ops, types optional & ignored. */
25180 nUF(vandq
, _vand
, 3, (RNQ
, oRNQ
, RNDQ_Ibig
), neon_logic
),
25181 nUF(vbicq
, _vbic
, 3, (RNQ
, oRNQ
, RNDQ_Ibig
), neon_logic
),
25182 nUF(vorrq
, _vorr
, 3, (RNQ
, oRNQ
, RNDQ_Ibig
), neon_logic
),
25183 nUF(vornq
, _vorn
, 3, (RNQ
, oRNQ
, RNDQ_Ibig
), neon_logic
),
25184 nUF(veorq
, _veor
, 3, (RNQ
, oRNQ
, RNQ
), neon_logic
),
25185 /* Bitfield ops, untyped. */
25186 NUF(vbsl
, 1100110, 3, (RNDQ
, RNDQ
, RNDQ
), neon_bitfield
),
25187 NUF(vbslq
, 1100110, 3, (RNQ
, RNQ
, RNQ
), neon_bitfield
),
25188 NUF(vbit
, 1200110, 3, (RNDQ
, RNDQ
, RNDQ
), neon_bitfield
),
25189 NUF(vbitq
, 1200110, 3, (RNQ
, RNQ
, RNQ
), neon_bitfield
),
25190 NUF(vbif
, 1300110, 3, (RNDQ
, RNDQ
, RNDQ
), neon_bitfield
),
25191 NUF(vbifq
, 1300110, 3, (RNQ
, RNQ
, RNQ
), neon_bitfield
),
25192 /* Int and float variants, types S8 S16 S32 U8 U16 U32 F16 F32. */
25193 nUF(vabdq
, _vabd
, 3, (RNQ
, oRNQ
, RNQ
), neon_dyadic_if_su
),
25194 nUF(vmaxq
, _vmax
, 3, (RNQ
, oRNQ
, RNQ
), neon_dyadic_if_su
),
25195 nUF(vminq
, _vmin
, 3, (RNQ
, oRNQ
, RNQ
), neon_dyadic_if_su
),
25196 /* Comparisons. Types S8 S16 S32 U8 U16 U32 F32. Non-immediate versions fall
25197 back to neon_dyadic_if_su. */
25198 nUF(vcge
, _vcge
, 3, (RNDQ
, oRNDQ
, RNDQ_I0
), neon_cmp
),
25199 nUF(vcgeq
, _vcge
, 3, (RNQ
, oRNQ
, RNDQ_I0
), neon_cmp
),
25200 nUF(vcgt
, _vcgt
, 3, (RNDQ
, oRNDQ
, RNDQ_I0
), neon_cmp
),
25201 nUF(vcgtq
, _vcgt
, 3, (RNQ
, oRNQ
, RNDQ_I0
), neon_cmp
),
25202 nUF(vclt
, _vclt
, 3, (RNDQ
, oRNDQ
, RNDQ_I0
), neon_cmp_inv
),
25203 nUF(vcltq
, _vclt
, 3, (RNQ
, oRNQ
, RNDQ_I0
), neon_cmp_inv
),
25204 nUF(vcle
, _vcle
, 3, (RNDQ
, oRNDQ
, RNDQ_I0
), neon_cmp_inv
),
25205 nUF(vcleq
, _vcle
, 3, (RNQ
, oRNQ
, RNDQ_I0
), neon_cmp_inv
),
25206 /* Comparison. Type I8 I16 I32 F32. */
25207 nUF(vceq
, _vceq
, 3, (RNDQ
, oRNDQ
, RNDQ_I0
), neon_ceq
),
25208 nUF(vceqq
, _vceq
, 3, (RNQ
, oRNQ
, RNDQ_I0
), neon_ceq
),
25209 /* As above, D registers only. */
25210 nUF(vpmax
, _vpmax
, 3, (RND
, oRND
, RND
), neon_dyadic_if_su_d
),
25211 nUF(vpmin
, _vpmin
, 3, (RND
, oRND
, RND
), neon_dyadic_if_su_d
),
25212 /* Int and float variants, signedness unimportant. */
25213 nUF(vmlaq
, _vmla
, 3, (RNQ
, oRNQ
, RNDQ_RNSC
), neon_mac_maybe_scalar
),
25214 nUF(vmlsq
, _vmls
, 3, (RNQ
, oRNQ
, RNDQ_RNSC
), neon_mac_maybe_scalar
),
25215 nUF(vpadd
, _vpadd
, 3, (RND
, oRND
, RND
), neon_dyadic_if_i_d
),
25216 /* Add/sub take types I8 I16 I32 I64 F32. */
25217 nUF(vaddq
, _vadd
, 3, (RNQ
, oRNQ
, RNQ
), neon_addsub_if_i
),
25218 nUF(vsubq
, _vsub
, 3, (RNQ
, oRNQ
, RNQ
), neon_addsub_if_i
),
25219 /* vtst takes sizes 8, 16, 32. */
25220 NUF(vtst
, 0000810, 3, (RNDQ
, oRNDQ
, RNDQ
), neon_tst
),
25221 NUF(vtstq
, 0000810, 3, (RNQ
, oRNQ
, RNQ
), neon_tst
),
25222 /* VMUL takes I8 I16 I32 F32 P8. */
25223 nUF(vmulq
, _vmul
, 3, (RNQ
, oRNQ
, RNDQ_RNSC
), neon_mul
),
25224 /* VQD{R}MULH takes S16 S32. */
25225 nUF(vqdmulhq
, _vqdmulh
, 3, (RNQ
, oRNQ
, RNDQ_RNSC
), neon_qdmulh
),
25226 nUF(vqrdmulhq
, _vqrdmulh
, 3, (RNQ
, oRNQ
, RNDQ_RNSC
), neon_qdmulh
),
25227 NUF(vacge
, 0000e10
, 3, (RNDQ
, oRNDQ
, RNDQ
), neon_fcmp_absolute
),
25228 NUF(vacgeq
, 0000e10
, 3, (RNQ
, oRNQ
, RNQ
), neon_fcmp_absolute
),
25229 NUF(vacgt
, 0200e10
, 3, (RNDQ
, oRNDQ
, RNDQ
), neon_fcmp_absolute
),
25230 NUF(vacgtq
, 0200e10
, 3, (RNQ
, oRNQ
, RNQ
), neon_fcmp_absolute
),
25231 NUF(vaclt
, 0200e10
, 3, (RNDQ
, oRNDQ
, RNDQ
), neon_fcmp_absolute_inv
),
25232 NUF(vacltq
, 0200e10
, 3, (RNQ
, oRNQ
, RNQ
), neon_fcmp_absolute_inv
),
25233 NUF(vacle
, 0000e10
, 3, (RNDQ
, oRNDQ
, RNDQ
), neon_fcmp_absolute_inv
),
25234 NUF(vacleq
, 0000e10
, 3, (RNQ
, oRNQ
, RNQ
), neon_fcmp_absolute_inv
),
25235 NUF(vrecps
, 0000f10
, 3, (RNDQ
, oRNDQ
, RNDQ
), neon_step
),
25236 NUF(vrecpsq
, 0000f10
, 3, (RNQ
, oRNQ
, RNQ
), neon_step
),
25237 NUF(vrsqrts
, 0200f10
, 3, (RNDQ
, oRNDQ
, RNDQ
), neon_step
),
25238 NUF(vrsqrtsq
, 0200f10
, 3, (RNQ
, oRNQ
, RNQ
), neon_step
),
25239 /* ARM v8.1 extension. */
25240 nUF (vqrdmlahq
, _vqrdmlah
, 3, (RNQ
, oRNQ
, RNDQ_RNSC
), neon_qrdmlah
),
25241 nUF (vqrdmlsh
, _vqrdmlsh
, 3, (RNDQ
, oRNDQ
, RNDQ_RNSC
), neon_qrdmlah
),
25242 nUF (vqrdmlshq
, _vqrdmlsh
, 3, (RNQ
, oRNQ
, RNDQ_RNSC
), neon_qrdmlah
),
25244 /* Two address, int/float. Types S8 S16 S32 F32. */
25245 NUF(vabsq
, 1b10300
, 2, (RNQ
, RNQ
), neon_abs_neg
),
25246 NUF(vnegq
, 1b10380
, 2, (RNQ
, RNQ
), neon_abs_neg
),
25248 /* Data processing with two registers and a shift amount. */
25249 /* Right shifts, and variants with rounding.
25250 Types accepted S8 S16 S32 S64 U8 U16 U32 U64. */
25251 NUF(vshrq
, 0800010, 3, (RNQ
, oRNQ
, I64z
), neon_rshift_round_imm
),
25252 NUF(vrshrq
, 0800210, 3, (RNQ
, oRNQ
, I64z
), neon_rshift_round_imm
),
25253 NUF(vsra
, 0800110, 3, (RNDQ
, oRNDQ
, I64
), neon_rshift_round_imm
),
25254 NUF(vsraq
, 0800110, 3, (RNQ
, oRNQ
, I64
), neon_rshift_round_imm
),
25255 NUF(vrsra
, 0800310, 3, (RNDQ
, oRNDQ
, I64
), neon_rshift_round_imm
),
25256 NUF(vrsraq
, 0800310, 3, (RNQ
, oRNQ
, I64
), neon_rshift_round_imm
),
25257 /* Shift and insert. Sizes accepted 8 16 32 64. */
25258 NUF(vsliq
, 1800510, 3, (RNQ
, oRNQ
, I63
), neon_sli
),
25259 NUF(vsriq
, 1800410, 3, (RNQ
, oRNQ
, I64
), neon_sri
),
25260 /* QSHL{U} immediate accepts S8 S16 S32 S64 U8 U16 U32 U64. */
25261 NUF(vqshluq
, 1800610, 3, (RNQ
, oRNQ
, I63
), neon_qshlu_imm
),
25262 /* Right shift immediate, saturating & narrowing, with rounding variants.
25263 Types accepted S16 S32 S64 U16 U32 U64. */
25264 NUF(vqshrn
, 0800910, 3, (RND
, RNQ
, I32z
), neon_rshift_sat_narrow
),
25265 NUF(vqrshrn
, 0800950, 3, (RND
, RNQ
, I32z
), neon_rshift_sat_narrow
),
25266 /* As above, unsigned. Types accepted S16 S32 S64. */
25267 NUF(vqshrun
, 0800810, 3, (RND
, RNQ
, I32z
), neon_rshift_sat_narrow_u
),
25268 NUF(vqrshrun
, 0800850, 3, (RND
, RNQ
, I32z
), neon_rshift_sat_narrow_u
),
25269 /* Right shift narrowing. Types accepted I16 I32 I64. */
25270 NUF(vshrn
, 0800810, 3, (RND
, RNQ
, I32z
), neon_rshift_narrow
),
25271 NUF(vrshrn
, 0800850, 3, (RND
, RNQ
, I32z
), neon_rshift_narrow
),
25272 /* Special case. Types S8 S16 S32 U8 U16 U32. Handles max shift variant. */
25273 nUF(vshll
, _vshll
, 3, (RNQ
, RND
, I32
), neon_shll
),
25274 /* CVT with optional immediate for fixed-point variant. */
25275 nUF(vcvtq
, _vcvt
, 3, (RNQ
, RNQ
, oI32b
), neon_cvt
),
25277 nUF(vmvnq
, _vmvn
, 2, (RNQ
, RNDQ_Ibig
), neon_mvn
),
25279 /* Data processing, three registers of different lengths. */
25280 /* Dyadic, long insns. Types S8 S16 S32 U8 U16 U32. */
25281 NUF(vabal
, 0800500, 3, (RNQ
, RND
, RND
), neon_abal
),
25282 /* If not scalar, fall back to neon_dyadic_long.
25283 Vector types as above, scalar types S16 S32 U16 U32. */
25284 nUF(vmlal
, _vmlal
, 3, (RNQ
, RND
, RND_RNSC
), neon_mac_maybe_scalar_long
),
25285 nUF(vmlsl
, _vmlsl
, 3, (RNQ
, RND
, RND_RNSC
), neon_mac_maybe_scalar_long
),
25286 /* Dyadic, widening insns. Types S8 S16 S32 U8 U16 U32. */
25287 NUF(vaddw
, 0800100, 3, (RNQ
, oRNQ
, RND
), neon_dyadic_wide
),
25288 NUF(vsubw
, 0800300, 3, (RNQ
, oRNQ
, RND
), neon_dyadic_wide
),
25289 /* Dyadic, narrowing insns. Types I16 I32 I64. */
25290 NUF(vaddhn
, 0800400, 3, (RND
, RNQ
, RNQ
), neon_dyadic_narrow
),
25291 NUF(vraddhn
, 1800400, 3, (RND
, RNQ
, RNQ
), neon_dyadic_narrow
),
25292 NUF(vsubhn
, 0800600, 3, (RND
, RNQ
, RNQ
), neon_dyadic_narrow
),
25293 NUF(vrsubhn
, 1800600, 3, (RND
, RNQ
, RNQ
), neon_dyadic_narrow
),
25294 /* Saturating doubling multiplies. Types S16 S32. */
25295 nUF(vqdmlal
, _vqdmlal
, 3, (RNQ
, RND
, RND_RNSC
), neon_mul_sat_scalar_long
),
25296 nUF(vqdmlsl
, _vqdmlsl
, 3, (RNQ
, RND
, RND_RNSC
), neon_mul_sat_scalar_long
),
25297 nUF(vqdmull
, _vqdmull
, 3, (RNQ
, RND
, RND_RNSC
), neon_mul_sat_scalar_long
),
25298 /* VMULL. Vector types S8 S16 S32 U8 U16 U32 P8, scalar types
25299 S16 S32 U16 U32. */
25300 nUF(vmull
, _vmull
, 3, (RNQ
, RND
, RND_RNSC
), neon_vmull
),
25302 /* Extract. Size 8. */
25303 NUF(vext
, 0b00000, 4, (RNDQ
, oRNDQ
, RNDQ
, I15
), neon_ext
),
25304 NUF(vextq
, 0b00000, 4, (RNQ
, oRNQ
, RNQ
, I15
), neon_ext
),
25306 /* Two registers, miscellaneous. */
25307 /* Reverse. Sizes 8 16 32 (must be < size in opcode). */
25308 NUF(vrev64q
, 1b00000
, 2, (RNQ
, RNQ
), neon_rev
),
25309 NUF(vrev32q
, 1b00080
, 2, (RNQ
, RNQ
), neon_rev
),
25310 NUF(vrev16q
, 1b00100
, 2, (RNQ
, RNQ
), neon_rev
),
25311 /* Vector replicate. Sizes 8 16 32. */
25312 nCE(vdupq
, _vdup
, 2, (RNQ
, RR_RNSC
), neon_dup
),
25313 /* VMOVL. Types S8 S16 S32 U8 U16 U32. */
25314 NUF(vmovl
, 0800a10
, 2, (RNQ
, RND
), neon_movl
),
25315 /* VMOVN. Types I16 I32 I64. */
25316 nUF(vmovn
, _vmovn
, 2, (RND
, RNQ
), neon_movn
),
25317 /* VQMOVN. Types S16 S32 S64 U16 U32 U64. */
25318 nUF(vqmovn
, _vqmovn
, 2, (RND
, RNQ
), neon_qmovn
),
25319 /* VQMOVUN. Types S16 S32 S64. */
25320 nUF(vqmovun
, _vqmovun
, 2, (RND
, RNQ
), neon_qmovun
),
25321 /* VZIP / VUZP. Sizes 8 16 32. */
25322 NUF(vzip
, 1b20180
, 2, (RNDQ
, RNDQ
), neon_zip_uzp
),
25323 NUF(vzipq
, 1b20180
, 2, (RNQ
, RNQ
), neon_zip_uzp
),
25324 NUF(vuzp
, 1b20100
, 2, (RNDQ
, RNDQ
), neon_zip_uzp
),
25325 NUF(vuzpq
, 1b20100
, 2, (RNQ
, RNQ
), neon_zip_uzp
),
25326 /* VQABS / VQNEG. Types S8 S16 S32. */
25327 NUF(vqabsq
, 1b00700
, 2, (RNQ
, RNQ
), neon_sat_abs_neg
),
25328 NUF(vqnegq
, 1b00780
, 2, (RNQ
, RNQ
), neon_sat_abs_neg
),
25329 /* Pairwise, lengthening. Types S8 S16 S32 U8 U16 U32. */
25330 NUF(vpadal
, 1b00600
, 2, (RNDQ
, RNDQ
), neon_pair_long
),
25331 NUF(vpadalq
, 1b00600
, 2, (RNQ
, RNQ
), neon_pair_long
),
25332 NUF(vpaddl
, 1b00200
, 2, (RNDQ
, RNDQ
), neon_pair_long
),
25333 NUF(vpaddlq
, 1b00200
, 2, (RNQ
, RNQ
), neon_pair_long
),
25334 /* Reciprocal estimates. Types U32 F16 F32. */
25335 NUF(vrecpe
, 1b30400
, 2, (RNDQ
, RNDQ
), neon_recip_est
),
25336 NUF(vrecpeq
, 1b30400
, 2, (RNQ
, RNQ
), neon_recip_est
),
25337 NUF(vrsqrte
, 1b30480
, 2, (RNDQ
, RNDQ
), neon_recip_est
),
25338 NUF(vrsqrteq
, 1b30480
, 2, (RNQ
, RNQ
), neon_recip_est
),
25339 /* VCLS. Types S8 S16 S32. */
25340 NUF(vclsq
, 1b00400
, 2, (RNQ
, RNQ
), neon_cls
),
25341 /* VCLZ. Types I8 I16 I32. */
25342 NUF(vclzq
, 1b00480
, 2, (RNQ
, RNQ
), neon_clz
),
25343 /* VCNT. Size 8. */
25344 NUF(vcnt
, 1b00500
, 2, (RNDQ
, RNDQ
), neon_cnt
),
25345 NUF(vcntq
, 1b00500
, 2, (RNQ
, RNQ
), neon_cnt
),
25346 /* Two address, untyped. */
25347 NUF(vswp
, 1b20000
, 2, (RNDQ
, RNDQ
), neon_swp
),
25348 NUF(vswpq
, 1b20000
, 2, (RNQ
, RNQ
), neon_swp
),
25349 /* VTRN. Sizes 8 16 32. */
25350 nUF(vtrn
, _vtrn
, 2, (RNDQ
, RNDQ
), neon_trn
),
25351 nUF(vtrnq
, _vtrn
, 2, (RNQ
, RNQ
), neon_trn
),
25353 /* Table lookup. Size 8. */
25354 NUF(vtbl
, 1b00800
, 3, (RND
, NRDLST
, RND
), neon_tbl_tbx
),
25355 NUF(vtbx
, 1b00840
, 3, (RND
, NRDLST
, RND
), neon_tbl_tbx
),
25357 #undef THUMB_VARIANT
25358 #define THUMB_VARIANT & fpu_vfp_v3_or_neon_ext
25360 #define ARM_VARIANT & fpu_vfp_v3_or_neon_ext
25362 /* Neon element/structure load/store. */
25363 nUF(vld1
, _vld1
, 2, (NSTRLST
, ADDR
), neon_ldx_stx
),
25364 nUF(vst1
, _vst1
, 2, (NSTRLST
, ADDR
), neon_ldx_stx
),
25365 nUF(vld2
, _vld2
, 2, (NSTRLST
, ADDR
), neon_ldx_stx
),
25366 nUF(vst2
, _vst2
, 2, (NSTRLST
, ADDR
), neon_ldx_stx
),
25367 nUF(vld3
, _vld3
, 2, (NSTRLST
, ADDR
), neon_ldx_stx
),
25368 nUF(vst3
, _vst3
, 2, (NSTRLST
, ADDR
), neon_ldx_stx
),
25369 nUF(vld4
, _vld4
, 2, (NSTRLST
, ADDR
), neon_ldx_stx
),
25370 nUF(vst4
, _vst4
, 2, (NSTRLST
, ADDR
), neon_ldx_stx
),
25372 #undef THUMB_VARIANT
25373 #define THUMB_VARIANT & fpu_vfp_ext_v3xd
25375 #define ARM_VARIANT & fpu_vfp_ext_v3xd
25376 cCE("fconsts", eb00a00
, 2, (RVS
, I255
), vfp_sp_const
),
25377 cCE("fshtos", eba0a40
, 2, (RVS
, I16z
), vfp_sp_conv_16
),
25378 cCE("fsltos", eba0ac0
, 2, (RVS
, I32
), vfp_sp_conv_32
),
25379 cCE("fuhtos", ebb0a40
, 2, (RVS
, I16z
), vfp_sp_conv_16
),
25380 cCE("fultos", ebb0ac0
, 2, (RVS
, I32
), vfp_sp_conv_32
),
25381 cCE("ftoshs", ebe0a40
, 2, (RVS
, I16z
), vfp_sp_conv_16
),
25382 cCE("ftosls", ebe0ac0
, 2, (RVS
, I32
), vfp_sp_conv_32
),
25383 cCE("ftouhs", ebf0a40
, 2, (RVS
, I16z
), vfp_sp_conv_16
),
25384 cCE("ftouls", ebf0ac0
, 2, (RVS
, I32
), vfp_sp_conv_32
),
25386 #undef THUMB_VARIANT
25387 #define THUMB_VARIANT & fpu_vfp_ext_v3
25389 #define ARM_VARIANT & fpu_vfp_ext_v3
25391 cCE("fconstd", eb00b00
, 2, (RVD
, I255
), vfp_dp_const
),
25392 cCE("fshtod", eba0b40
, 2, (RVD
, I16z
), vfp_dp_conv_16
),
25393 cCE("fsltod", eba0bc0
, 2, (RVD
, I32
), vfp_dp_conv_32
),
25394 cCE("fuhtod", ebb0b40
, 2, (RVD
, I16z
), vfp_dp_conv_16
),
25395 cCE("fultod", ebb0bc0
, 2, (RVD
, I32
), vfp_dp_conv_32
),
25396 cCE("ftoshd", ebe0b40
, 2, (RVD
, I16z
), vfp_dp_conv_16
),
25397 cCE("ftosld", ebe0bc0
, 2, (RVD
, I32
), vfp_dp_conv_32
),
25398 cCE("ftouhd", ebf0b40
, 2, (RVD
, I16z
), vfp_dp_conv_16
),
25399 cCE("ftould", ebf0bc0
, 2, (RVD
, I32
), vfp_dp_conv_32
),
25402 #define ARM_VARIANT & fpu_vfp_ext_fma
25403 #undef THUMB_VARIANT
25404 #define THUMB_VARIANT & fpu_vfp_ext_fma
25405 /* Mnemonics shared by Neon, VFP, MVE and BF16. These are included in the
25406 VFP FMA variant; NEON and VFP FMA always includes the NEON
25407 FMA instructions. */
25408 mnCEF(vfma
, _vfma
, 3, (RNSDQMQ
, oRNSDQMQ
, RNSDQMQR
), neon_fmac
),
25409 TUF ("vfmat", c300850
, fc300850
, 3, (RNSDQMQ
, oRNSDQMQ
, RNSDQ_RNSC_MQ_RR
), mve_vfma
, mve_vfma
),
25410 mnCEF(vfms
, _vfms
, 3, (RNSDQMQ
, oRNSDQMQ
, RNSDQMQ
), neon_fmac
),
25412 /* ffmas/ffmad/ffmss/ffmsd are dummy mnemonics to satisfy gas;
25413 the v form should always be used. */
25414 cCE("ffmas", ea00a00
, 3, (RVS
, RVS
, RVS
), vfp_sp_dyadic
),
25415 cCE("ffnmas", ea00a40
, 3, (RVS
, RVS
, RVS
), vfp_sp_dyadic
),
25416 cCE("ffmad", ea00b00
, 3, (RVD
, RVD
, RVD
), vfp_dp_rd_rn_rm
),
25417 cCE("ffnmad", ea00b40
, 3, (RVD
, RVD
, RVD
), vfp_dp_rd_rn_rm
),
25418 nCE(vfnma
, _vfnma
, 3, (RVSD
, RVSD
, RVSD
), vfp_nsyn_nmul
),
25419 nCE(vfnms
, _vfnms
, 3, (RVSD
, RVSD
, RVSD
), vfp_nsyn_nmul
),
25421 #undef THUMB_VARIANT
25423 #define ARM_VARIANT & arm_cext_xscale /* Intel XScale extensions. */
25425 cCE("mia", e200010
, 3, (RXA
, RRnpc
, RRnpc
), xsc_mia
),
25426 cCE("miaph", e280010
, 3, (RXA
, RRnpc
, RRnpc
), xsc_mia
),
25427 cCE("miabb", e2c0010
, 3, (RXA
, RRnpc
, RRnpc
), xsc_mia
),
25428 cCE("miabt", e2d0010
, 3, (RXA
, RRnpc
, RRnpc
), xsc_mia
),
25429 cCE("miatb", e2e0010
, 3, (RXA
, RRnpc
, RRnpc
), xsc_mia
),
25430 cCE("miatt", e2f0010
, 3, (RXA
, RRnpc
, RRnpc
), xsc_mia
),
25431 cCE("mar", c400000
, 3, (RXA
, RRnpc
, RRnpc
), xsc_mar
),
25432 cCE("mra", c500000
, 3, (RRnpc
, RRnpc
, RXA
), xsc_mra
),
25435 #define ARM_VARIANT & arm_cext_iwmmxt /* Intel Wireless MMX technology. */
25437 cCE("tandcb", e13f130
, 1, (RR
), iwmmxt_tandorc
),
25438 cCE("tandch", e53f130
, 1, (RR
), iwmmxt_tandorc
),
25439 cCE("tandcw", e93f130
, 1, (RR
), iwmmxt_tandorc
),
25440 cCE("tbcstb", e400010
, 2, (RIWR
, RR
), rn_rd
),
25441 cCE("tbcsth", e400050
, 2, (RIWR
, RR
), rn_rd
),
25442 cCE("tbcstw", e400090
, 2, (RIWR
, RR
), rn_rd
),
25443 cCE("textrcb", e130170
, 2, (RR
, I7
), iwmmxt_textrc
),
25444 cCE("textrch", e530170
, 2, (RR
, I7
), iwmmxt_textrc
),
25445 cCE("textrcw", e930170
, 2, (RR
, I7
), iwmmxt_textrc
),
25446 cCE("textrmub",e100070
, 3, (RR
, RIWR
, I7
), iwmmxt_textrm
),
25447 cCE("textrmuh",e500070
, 3, (RR
, RIWR
, I7
), iwmmxt_textrm
),
25448 cCE("textrmuw",e900070
, 3, (RR
, RIWR
, I7
), iwmmxt_textrm
),
25449 cCE("textrmsb",e100078
, 3, (RR
, RIWR
, I7
), iwmmxt_textrm
),
25450 cCE("textrmsh",e500078
, 3, (RR
, RIWR
, I7
), iwmmxt_textrm
),
25451 cCE("textrmsw",e900078
, 3, (RR
, RIWR
, I7
), iwmmxt_textrm
),
25452 cCE("tinsrb", e600010
, 3, (RIWR
, RR
, I7
), iwmmxt_tinsr
),
25453 cCE("tinsrh", e600050
, 3, (RIWR
, RR
, I7
), iwmmxt_tinsr
),
25454 cCE("tinsrw", e600090
, 3, (RIWR
, RR
, I7
), iwmmxt_tinsr
),
25455 cCE("tmcr", e000110
, 2, (RIWC_RIWG
, RR
), rn_rd
),
25456 cCE("tmcrr", c400000
, 3, (RIWR
, RR
, RR
), rm_rd_rn
),
25457 cCE("tmia", e200010
, 3, (RIWR
, RR
, RR
), iwmmxt_tmia
),
25458 cCE("tmiaph", e280010
, 3, (RIWR
, RR
, RR
), iwmmxt_tmia
),
25459 cCE("tmiabb", e2c0010
, 3, (RIWR
, RR
, RR
), iwmmxt_tmia
),
25460 cCE("tmiabt", e2d0010
, 3, (RIWR
, RR
, RR
), iwmmxt_tmia
),
25461 cCE("tmiatb", e2e0010
, 3, (RIWR
, RR
, RR
), iwmmxt_tmia
),
25462 cCE("tmiatt", e2f0010
, 3, (RIWR
, RR
, RR
), iwmmxt_tmia
),
25463 cCE("tmovmskb",e100030
, 2, (RR
, RIWR
), rd_rn
),
25464 cCE("tmovmskh",e500030
, 2, (RR
, RIWR
), rd_rn
),
25465 cCE("tmovmskw",e900030
, 2, (RR
, RIWR
), rd_rn
),
25466 cCE("tmrc", e100110
, 2, (RR
, RIWC_RIWG
), rd_rn
),
25467 cCE("tmrrc", c500000
, 3, (RR
, RR
, RIWR
), rd_rn_rm
),
25468 cCE("torcb", e13f150
, 1, (RR
), iwmmxt_tandorc
),
25469 cCE("torch", e53f150
, 1, (RR
), iwmmxt_tandorc
),
25470 cCE("torcw", e93f150
, 1, (RR
), iwmmxt_tandorc
),
25471 cCE("waccb", e0001c0
, 2, (RIWR
, RIWR
), rd_rn
),
25472 cCE("wacch", e4001c0
, 2, (RIWR
, RIWR
), rd_rn
),
25473 cCE("waccw", e8001c0
, 2, (RIWR
, RIWR
), rd_rn
),
25474 cCE("waddbss", e300180
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25475 cCE("waddb", e000180
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25476 cCE("waddbus", e100180
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25477 cCE("waddhss", e700180
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25478 cCE("waddh", e400180
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25479 cCE("waddhus", e500180
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25480 cCE("waddwss", eb00180
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25481 cCE("waddw", e800180
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25482 cCE("waddwus", e900180
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25483 cCE("waligni", e000020
, 4, (RIWR
, RIWR
, RIWR
, I7
), iwmmxt_waligni
),
25484 cCE("walignr0",e800020
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25485 cCE("walignr1",e900020
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25486 cCE("walignr2",ea00020
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25487 cCE("walignr3",eb00020
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25488 cCE("wand", e200000
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25489 cCE("wandn", e300000
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25490 cCE("wavg2b", e800000
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25491 cCE("wavg2br", e900000
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25492 cCE("wavg2h", ec00000
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25493 cCE("wavg2hr", ed00000
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25494 cCE("wcmpeqb", e000060
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25495 cCE("wcmpeqh", e400060
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25496 cCE("wcmpeqw", e800060
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25497 cCE("wcmpgtub",e100060
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25498 cCE("wcmpgtuh",e500060
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25499 cCE("wcmpgtuw",e900060
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25500 cCE("wcmpgtsb",e300060
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25501 cCE("wcmpgtsh",e700060
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25502 cCE("wcmpgtsw",eb00060
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25503 cCE("wldrb", c100000
, 2, (RIWR
, ADDR
), iwmmxt_wldstbh
),
25504 cCE("wldrh", c500000
, 2, (RIWR
, ADDR
), iwmmxt_wldstbh
),
25505 cCE("wldrw", c100100
, 2, (RIWR_RIWC
, ADDR
), iwmmxt_wldstw
),
25506 cCE("wldrd", c500100
, 2, (RIWR
, ADDR
), iwmmxt_wldstd
),
25507 cCE("wmacs", e600100
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25508 cCE("wmacsz", e700100
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25509 cCE("wmacu", e400100
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25510 cCE("wmacuz", e500100
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25511 cCE("wmadds", ea00100
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25512 cCE("wmaddu", e800100
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25513 cCE("wmaxsb", e200160
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25514 cCE("wmaxsh", e600160
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25515 cCE("wmaxsw", ea00160
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25516 cCE("wmaxub", e000160
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25517 cCE("wmaxuh", e400160
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25518 cCE("wmaxuw", e800160
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25519 cCE("wminsb", e300160
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25520 cCE("wminsh", e700160
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25521 cCE("wminsw", eb00160
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25522 cCE("wminub", e100160
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25523 cCE("wminuh", e500160
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25524 cCE("wminuw", e900160
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25525 cCE("wmov", e000000
, 2, (RIWR
, RIWR
), iwmmxt_wmov
),
25526 cCE("wmulsm", e300100
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25527 cCE("wmulsl", e200100
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25528 cCE("wmulum", e100100
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25529 cCE("wmulul", e000100
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25530 cCE("wor", e000000
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25531 cCE("wpackhss",e700080
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25532 cCE("wpackhus",e500080
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25533 cCE("wpackwss",eb00080
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25534 cCE("wpackwus",e900080
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25535 cCE("wpackdss",ef00080
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25536 cCE("wpackdus",ed00080
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25537 cCE("wrorh", e700040
, 3, (RIWR
, RIWR
, RIWR_I32z
),iwmmxt_wrwrwr_or_imm5
),
25538 cCE("wrorhg", e700148
, 3, (RIWR
, RIWR
, RIWG
), rd_rn_rm
),
25539 cCE("wrorw", eb00040
, 3, (RIWR
, RIWR
, RIWR_I32z
),iwmmxt_wrwrwr_or_imm5
),
25540 cCE("wrorwg", eb00148
, 3, (RIWR
, RIWR
, RIWG
), rd_rn_rm
),
25541 cCE("wrord", ef00040
, 3, (RIWR
, RIWR
, RIWR_I32z
),iwmmxt_wrwrwr_or_imm5
),
25542 cCE("wrordg", ef00148
, 3, (RIWR
, RIWR
, RIWG
), rd_rn_rm
),
25543 cCE("wsadb", e000120
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25544 cCE("wsadbz", e100120
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25545 cCE("wsadh", e400120
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25546 cCE("wsadhz", e500120
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25547 cCE("wshufh", e0001e0
, 3, (RIWR
, RIWR
, I255
), iwmmxt_wshufh
),
25548 cCE("wsllh", e500040
, 3, (RIWR
, RIWR
, RIWR_I32z
),iwmmxt_wrwrwr_or_imm5
),
25549 cCE("wsllhg", e500148
, 3, (RIWR
, RIWR
, RIWG
), rd_rn_rm
),
25550 cCE("wsllw", e900040
, 3, (RIWR
, RIWR
, RIWR_I32z
),iwmmxt_wrwrwr_or_imm5
),
25551 cCE("wsllwg", e900148
, 3, (RIWR
, RIWR
, RIWG
), rd_rn_rm
),
25552 cCE("wslld", ed00040
, 3, (RIWR
, RIWR
, RIWR_I32z
),iwmmxt_wrwrwr_or_imm5
),
25553 cCE("wslldg", ed00148
, 3, (RIWR
, RIWR
, RIWG
), rd_rn_rm
),
25554 cCE("wsrah", e400040
, 3, (RIWR
, RIWR
, RIWR_I32z
),iwmmxt_wrwrwr_or_imm5
),
25555 cCE("wsrahg", e400148
, 3, (RIWR
, RIWR
, RIWG
), rd_rn_rm
),
25556 cCE("wsraw", e800040
, 3, (RIWR
, RIWR
, RIWR_I32z
),iwmmxt_wrwrwr_or_imm5
),
25557 cCE("wsrawg", e800148
, 3, (RIWR
, RIWR
, RIWG
), rd_rn_rm
),
25558 cCE("wsrad", ec00040
, 3, (RIWR
, RIWR
, RIWR_I32z
),iwmmxt_wrwrwr_or_imm5
),
25559 cCE("wsradg", ec00148
, 3, (RIWR
, RIWR
, RIWG
), rd_rn_rm
),
25560 cCE("wsrlh", e600040
, 3, (RIWR
, RIWR
, RIWR_I32z
),iwmmxt_wrwrwr_or_imm5
),
25561 cCE("wsrlhg", e600148
, 3, (RIWR
, RIWR
, RIWG
), rd_rn_rm
),
25562 cCE("wsrlw", ea00040
, 3, (RIWR
, RIWR
, RIWR_I32z
),iwmmxt_wrwrwr_or_imm5
),
25563 cCE("wsrlwg", ea00148
, 3, (RIWR
, RIWR
, RIWG
), rd_rn_rm
),
25564 cCE("wsrld", ee00040
, 3, (RIWR
, RIWR
, RIWR_I32z
),iwmmxt_wrwrwr_or_imm5
),
25565 cCE("wsrldg", ee00148
, 3, (RIWR
, RIWR
, RIWG
), rd_rn_rm
),
25566 cCE("wstrb", c000000
, 2, (RIWR
, ADDR
), iwmmxt_wldstbh
),
25567 cCE("wstrh", c400000
, 2, (RIWR
, ADDR
), iwmmxt_wldstbh
),
25568 cCE("wstrw", c000100
, 2, (RIWR_RIWC
, ADDR
), iwmmxt_wldstw
),
25569 cCE("wstrd", c400100
, 2, (RIWR
, ADDR
), iwmmxt_wldstd
),
25570 cCE("wsubbss", e3001a0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25571 cCE("wsubb", e0001a0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25572 cCE("wsubbus", e1001a0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25573 cCE("wsubhss", e7001a0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25574 cCE("wsubh", e4001a0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25575 cCE("wsubhus", e5001a0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25576 cCE("wsubwss", eb001a0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25577 cCE("wsubw", e8001a0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25578 cCE("wsubwus", e9001a0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25579 cCE("wunpckehub",e0000c0
, 2, (RIWR
, RIWR
), rd_rn
),
25580 cCE("wunpckehuh",e4000c0
, 2, (RIWR
, RIWR
), rd_rn
),
25581 cCE("wunpckehuw",e8000c0
, 2, (RIWR
, RIWR
), rd_rn
),
25582 cCE("wunpckehsb",e2000c0
, 2, (RIWR
, RIWR
), rd_rn
),
25583 cCE("wunpckehsh",e6000c0
, 2, (RIWR
, RIWR
), rd_rn
),
25584 cCE("wunpckehsw",ea000c0
, 2, (RIWR
, RIWR
), rd_rn
),
25585 cCE("wunpckihb", e1000c0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25586 cCE("wunpckihh", e5000c0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25587 cCE("wunpckihw", e9000c0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25588 cCE("wunpckelub",e0000e0
, 2, (RIWR
, RIWR
), rd_rn
),
25589 cCE("wunpckeluh",e4000e0
, 2, (RIWR
, RIWR
), rd_rn
),
25590 cCE("wunpckeluw",e8000e0
, 2, (RIWR
, RIWR
), rd_rn
),
25591 cCE("wunpckelsb",e2000e0
, 2, (RIWR
, RIWR
), rd_rn
),
25592 cCE("wunpckelsh",e6000e0
, 2, (RIWR
, RIWR
), rd_rn
),
25593 cCE("wunpckelsw",ea000e0
, 2, (RIWR
, RIWR
), rd_rn
),
25594 cCE("wunpckilb", e1000e0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25595 cCE("wunpckilh", e5000e0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25596 cCE("wunpckilw", e9000e0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25597 cCE("wxor", e100000
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25598 cCE("wzero", e300000
, 1, (RIWR
), iwmmxt_wzero
),
25601 #define ARM_VARIANT & arm_cext_iwmmxt2 /* Intel Wireless MMX technology, version 2. */
25603 cCE("torvscb", e12f190
, 1, (RR
), iwmmxt_tandorc
),
25604 cCE("torvsch", e52f190
, 1, (RR
), iwmmxt_tandorc
),
25605 cCE("torvscw", e92f190
, 1, (RR
), iwmmxt_tandorc
),
25606 cCE("wabsb", e2001c0
, 2, (RIWR
, RIWR
), rd_rn
),
25607 cCE("wabsh", e6001c0
, 2, (RIWR
, RIWR
), rd_rn
),
25608 cCE("wabsw", ea001c0
, 2, (RIWR
, RIWR
), rd_rn
),
25609 cCE("wabsdiffb", e1001c0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25610 cCE("wabsdiffh", e5001c0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25611 cCE("wabsdiffw", e9001c0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25612 cCE("waddbhusl", e2001a0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25613 cCE("waddbhusm", e6001a0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25614 cCE("waddhc", e600180
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25615 cCE("waddwc", ea00180
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25616 cCE("waddsubhx", ea001a0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25617 cCE("wavg4", e400000
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25618 cCE("wavg4r", e500000
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25619 cCE("wmaddsn", ee00100
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25620 cCE("wmaddsx", eb00100
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25621 cCE("wmaddun", ec00100
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25622 cCE("wmaddux", e900100
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25623 cCE("wmerge", e000080
, 4, (RIWR
, RIWR
, RIWR
, I7
), iwmmxt_wmerge
),
25624 cCE("wmiabb", e0000a0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25625 cCE("wmiabt", e1000a0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25626 cCE("wmiatb", e2000a0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25627 cCE("wmiatt", e3000a0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25628 cCE("wmiabbn", e4000a0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25629 cCE("wmiabtn", e5000a0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25630 cCE("wmiatbn", e6000a0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25631 cCE("wmiattn", e7000a0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25632 cCE("wmiawbb", e800120
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25633 cCE("wmiawbt", e900120
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25634 cCE("wmiawtb", ea00120
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25635 cCE("wmiawtt", eb00120
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25636 cCE("wmiawbbn", ec00120
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25637 cCE("wmiawbtn", ed00120
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25638 cCE("wmiawtbn", ee00120
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25639 cCE("wmiawttn", ef00120
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25640 cCE("wmulsmr", ef00100
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25641 cCE("wmulumr", ed00100
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25642 cCE("wmulwumr", ec000c0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25643 cCE("wmulwsmr", ee000c0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25644 cCE("wmulwum", ed000c0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25645 cCE("wmulwsm", ef000c0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25646 cCE("wmulwl", eb000c0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25647 cCE("wqmiabb", e8000a0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25648 cCE("wqmiabt", e9000a0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25649 cCE("wqmiatb", ea000a0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25650 cCE("wqmiatt", eb000a0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25651 cCE("wqmiabbn", ec000a0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25652 cCE("wqmiabtn", ed000a0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25653 cCE("wqmiatbn", ee000a0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25654 cCE("wqmiattn", ef000a0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25655 cCE("wqmulm", e100080
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25656 cCE("wqmulmr", e300080
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25657 cCE("wqmulwm", ec000e0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25658 cCE("wqmulwmr", ee000e0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25659 cCE("wsubaddhx", ed001c0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
25662 #define ARM_VARIANT & arm_cext_maverick /* Cirrus Maverick instructions. */
25664 cCE("cfldrs", c100400
, 2, (RMF
, ADDRGLDC
), rd_cpaddr
),
25665 cCE("cfldrd", c500400
, 2, (RMD
, ADDRGLDC
), rd_cpaddr
),
25666 cCE("cfldr32", c100500
, 2, (RMFX
, ADDRGLDC
), rd_cpaddr
),
25667 cCE("cfldr64", c500500
, 2, (RMDX
, ADDRGLDC
), rd_cpaddr
),
25668 cCE("cfstrs", c000400
, 2, (RMF
, ADDRGLDC
), rd_cpaddr
),
25669 cCE("cfstrd", c400400
, 2, (RMD
, ADDRGLDC
), rd_cpaddr
),
25670 cCE("cfstr32", c000500
, 2, (RMFX
, ADDRGLDC
), rd_cpaddr
),
25671 cCE("cfstr64", c400500
, 2, (RMDX
, ADDRGLDC
), rd_cpaddr
),
25672 cCE("cfmvsr", e000450
, 2, (RMF
, RR
), rn_rd
),
25673 cCE("cfmvrs", e100450
, 2, (RR
, RMF
), rd_rn
),
25674 cCE("cfmvdlr", e000410
, 2, (RMD
, RR
), rn_rd
),
25675 cCE("cfmvrdl", e100410
, 2, (RR
, RMD
), rd_rn
),
25676 cCE("cfmvdhr", e000430
, 2, (RMD
, RR
), rn_rd
),
25677 cCE("cfmvrdh", e100430
, 2, (RR
, RMD
), rd_rn
),
25678 cCE("cfmv64lr",e000510
, 2, (RMDX
, RR
), rn_rd
),
25679 cCE("cfmvr64l",e100510
, 2, (RR
, RMDX
), rd_rn
),
25680 cCE("cfmv64hr",e000530
, 2, (RMDX
, RR
), rn_rd
),
25681 cCE("cfmvr64h",e100530
, 2, (RR
, RMDX
), rd_rn
),
25682 cCE("cfmval32",e200440
, 2, (RMAX
, RMFX
), rd_rn
),
25683 cCE("cfmv32al",e100440
, 2, (RMFX
, RMAX
), rd_rn
),
25684 cCE("cfmvam32",e200460
, 2, (RMAX
, RMFX
), rd_rn
),
25685 cCE("cfmv32am",e100460
, 2, (RMFX
, RMAX
), rd_rn
),
25686 cCE("cfmvah32",e200480
, 2, (RMAX
, RMFX
), rd_rn
),
25687 cCE("cfmv32ah",e100480
, 2, (RMFX
, RMAX
), rd_rn
),
25688 cCE("cfmva32", e2004a0
, 2, (RMAX
, RMFX
), rd_rn
),
25689 cCE("cfmv32a", e1004a0
, 2, (RMFX
, RMAX
), rd_rn
),
25690 cCE("cfmva64", e2004c0
, 2, (RMAX
, RMDX
), rd_rn
),
25691 cCE("cfmv64a", e1004c0
, 2, (RMDX
, RMAX
), rd_rn
),
25692 cCE("cfmvsc32",e2004e0
, 2, (RMDS
, RMDX
), mav_dspsc
),
25693 cCE("cfmv32sc",e1004e0
, 2, (RMDX
, RMDS
), rd
),
25694 cCE("cfcpys", e000400
, 2, (RMF
, RMF
), rd_rn
),
25695 cCE("cfcpyd", e000420
, 2, (RMD
, RMD
), rd_rn
),
25696 cCE("cfcvtsd", e000460
, 2, (RMD
, RMF
), rd_rn
),
25697 cCE("cfcvtds", e000440
, 2, (RMF
, RMD
), rd_rn
),
25698 cCE("cfcvt32s",e000480
, 2, (RMF
, RMFX
), rd_rn
),
25699 cCE("cfcvt32d",e0004a0
, 2, (RMD
, RMFX
), rd_rn
),
25700 cCE("cfcvt64s",e0004c0
, 2, (RMF
, RMDX
), rd_rn
),
25701 cCE("cfcvt64d",e0004e0
, 2, (RMD
, RMDX
), rd_rn
),
25702 cCE("cfcvts32",e100580
, 2, (RMFX
, RMF
), rd_rn
),
25703 cCE("cfcvtd32",e1005a0
, 2, (RMFX
, RMD
), rd_rn
),
25704 cCE("cftruncs32",e1005c0
, 2, (RMFX
, RMF
), rd_rn
),
25705 cCE("cftruncd32",e1005e0
, 2, (RMFX
, RMD
), rd_rn
),
25706 cCE("cfrshl32",e000550
, 3, (RMFX
, RMFX
, RR
), mav_triple
),
25707 cCE("cfrshl64",e000570
, 3, (RMDX
, RMDX
, RR
), mav_triple
),
25708 cCE("cfsh32", e000500
, 3, (RMFX
, RMFX
, I63s
), mav_shift
),
25709 cCE("cfsh64", e200500
, 3, (RMDX
, RMDX
, I63s
), mav_shift
),
25710 cCE("cfcmps", e100490
, 3, (RR
, RMF
, RMF
), rd_rn_rm
),
25711 cCE("cfcmpd", e1004b0
, 3, (RR
, RMD
, RMD
), rd_rn_rm
),
25712 cCE("cfcmp32", e100590
, 3, (RR
, RMFX
, RMFX
), rd_rn_rm
),
25713 cCE("cfcmp64", e1005b0
, 3, (RR
, RMDX
, RMDX
), rd_rn_rm
),
25714 cCE("cfabss", e300400
, 2, (RMF
, RMF
), rd_rn
),
25715 cCE("cfabsd", e300420
, 2, (RMD
, RMD
), rd_rn
),
25716 cCE("cfnegs", e300440
, 2, (RMF
, RMF
), rd_rn
),
25717 cCE("cfnegd", e300460
, 2, (RMD
, RMD
), rd_rn
),
25718 cCE("cfadds", e300480
, 3, (RMF
, RMF
, RMF
), rd_rn_rm
),
25719 cCE("cfaddd", e3004a0
, 3, (RMD
, RMD
, RMD
), rd_rn_rm
),
25720 cCE("cfsubs", e3004c0
, 3, (RMF
, RMF
, RMF
), rd_rn_rm
),
25721 cCE("cfsubd", e3004e0
, 3, (RMD
, RMD
, RMD
), rd_rn_rm
),
25722 cCE("cfmuls", e100400
, 3, (RMF
, RMF
, RMF
), rd_rn_rm
),
25723 cCE("cfmuld", e100420
, 3, (RMD
, RMD
, RMD
), rd_rn_rm
),
25724 cCE("cfabs32", e300500
, 2, (RMFX
, RMFX
), rd_rn
),
25725 cCE("cfabs64", e300520
, 2, (RMDX
, RMDX
), rd_rn
),
25726 cCE("cfneg32", e300540
, 2, (RMFX
, RMFX
), rd_rn
),
25727 cCE("cfneg64", e300560
, 2, (RMDX
, RMDX
), rd_rn
),
25728 cCE("cfadd32", e300580
, 3, (RMFX
, RMFX
, RMFX
), rd_rn_rm
),
25729 cCE("cfadd64", e3005a0
, 3, (RMDX
, RMDX
, RMDX
), rd_rn_rm
),
25730 cCE("cfsub32", e3005c0
, 3, (RMFX
, RMFX
, RMFX
), rd_rn_rm
),
25731 cCE("cfsub64", e3005e0
, 3, (RMDX
, RMDX
, RMDX
), rd_rn_rm
),
25732 cCE("cfmul32", e100500
, 3, (RMFX
, RMFX
, RMFX
), rd_rn_rm
),
25733 cCE("cfmul64", e100520
, 3, (RMDX
, RMDX
, RMDX
), rd_rn_rm
),
25734 cCE("cfmac32", e100540
, 3, (RMFX
, RMFX
, RMFX
), rd_rn_rm
),
25735 cCE("cfmsc32", e100560
, 3, (RMFX
, RMFX
, RMFX
), rd_rn_rm
),
25736 cCE("cfmadd32",e000600
, 4, (RMAX
, RMFX
, RMFX
, RMFX
), mav_quad
),
25737 cCE("cfmsub32",e100600
, 4, (RMAX
, RMFX
, RMFX
, RMFX
), mav_quad
),
25738 cCE("cfmadda32", e200600
, 4, (RMAX
, RMAX
, RMFX
, RMFX
), mav_quad
),
25739 cCE("cfmsuba32", e300600
, 4, (RMAX
, RMAX
, RMFX
, RMFX
), mav_quad
),
25741 /* ARMv8.5-A instructions. */
25743 #define ARM_VARIANT & arm_ext_sb
25744 #undef THUMB_VARIANT
25745 #define THUMB_VARIANT & arm_ext_sb
25746 TUF("sb", 57ff070
, f3bf8f70
, 0, (), noargs
, noargs
),
25749 #define ARM_VARIANT & arm_ext_predres
25750 #undef THUMB_VARIANT
25751 #define THUMB_VARIANT & arm_ext_predres
25752 CE("cfprctx", e070f93
, 1, (RRnpc
), rd
),
25753 CE("dvprctx", e070fb3
, 1, (RRnpc
), rd
),
25754 CE("cpprctx", e070ff3
, 1, (RRnpc
), rd
),
25756 /* ARMv8-M instructions. */
25758 #define ARM_VARIANT NULL
25759 #undef THUMB_VARIANT
25760 #define THUMB_VARIANT & arm_ext_v8m
25761 ToU("sg", e97fe97f
, 0, (), noargs
),
25762 ToC("blxns", 4784, 1, (RRnpc
), t_blx
),
25763 ToC("bxns", 4704, 1, (RRnpc
), t_bx
),
25764 ToC("tt", e840f000
, 2, (RRnpc
, RRnpc
), tt
),
25765 ToC("ttt", e840f040
, 2, (RRnpc
, RRnpc
), tt
),
25766 ToC("tta", e840f080
, 2, (RRnpc
, RRnpc
), tt
),
25767 ToC("ttat", e840f0c0
, 2, (RRnpc
, RRnpc
), tt
),
25769 /* FP for ARMv8-M Mainline. Enabled for ARMv8-M Mainline because the
25770 instructions behave as nop if no VFP is present. */
25771 #undef THUMB_VARIANT
25772 #define THUMB_VARIANT & arm_ext_v8m_main
25773 ToC("vlldm", ec300a00
, 1, (RRnpc
), rn
),
25774 ToC("vlstm", ec200a00
, 1, (RRnpc
), rn
),
25776 /* Armv8.1-M Mainline instructions. */
25777 #undef THUMB_VARIANT
25778 #define THUMB_VARIANT & arm_ext_v8_1m_main
25779 toU("cinc", _cinc
, 3, (RRnpcsp
, RR_ZR
, COND
), t_cond
),
25780 toU("cinv", _cinv
, 3, (RRnpcsp
, RR_ZR
, COND
), t_cond
),
25781 toU("cneg", _cneg
, 3, (RRnpcsp
, RR_ZR
, COND
), t_cond
),
25782 toU("csel", _csel
, 4, (RRnpcsp
, RR_ZR
, RR_ZR
, COND
), t_cond
),
25783 toU("csetm", _csetm
, 2, (RRnpcsp
, COND
), t_cond
),
25784 toU("cset", _cset
, 2, (RRnpcsp
, COND
), t_cond
),
25785 toU("csinc", _csinc
, 4, (RRnpcsp
, RR_ZR
, RR_ZR
, COND
), t_cond
),
25786 toU("csinv", _csinv
, 4, (RRnpcsp
, RR_ZR
, RR_ZR
, COND
), t_cond
),
25787 toU("csneg", _csneg
, 4, (RRnpcsp
, RR_ZR
, RR_ZR
, COND
), t_cond
),
25789 toC("bf", _bf
, 2, (EXPs
, EXPs
), t_branch_future
),
25790 toU("bfcsel", _bfcsel
, 4, (EXPs
, EXPs
, EXPs
, COND
), t_branch_future
),
25791 toC("bfx", _bfx
, 2, (EXPs
, RRnpcsp
), t_branch_future
),
25792 toC("bfl", _bfl
, 2, (EXPs
, EXPs
), t_branch_future
),
25793 toC("bflx", _bflx
, 2, (EXPs
, RRnpcsp
), t_branch_future
),
25795 toU("dls", _dls
, 2, (LR
, RRnpcsp
), t_loloop
),
25796 toU("wls", _wls
, 3, (LR
, RRnpcsp
, EXP
), t_loloop
),
25797 toU("le", _le
, 2, (oLR
, EXP
), t_loloop
),
25799 ToC("clrm", e89f0000
, 1, (CLRMLST
), t_clrm
),
25800 ToC("vscclrm", ec9f0a00
, 1, (VRSDVLST
), t_vscclrm
),
25802 #undef THUMB_VARIANT
25803 #define THUMB_VARIANT & mve_ext
25804 ToC("lsll", ea50010d
, 3, (RRe
, RRo
, RRnpcsp_I32
), mve_scalar_shift
),
25805 ToC("lsrl", ea50011f
, 3, (RRe
, RRo
, I32
), mve_scalar_shift
),
25806 ToC("asrl", ea50012d
, 3, (RRe
, RRo
, RRnpcsp_I32
), mve_scalar_shift
),
25807 ToC("uqrshll", ea51010d
, 4, (RRe
, RRo
, I48_I64
, RRnpcsp
), mve_scalar_shift1
),
25808 ToC("sqrshrl", ea51012d
, 4, (RRe
, RRo
, I48_I64
, RRnpcsp
), mve_scalar_shift1
),
25809 ToC("uqshll", ea51010f
, 3, (RRe
, RRo
, I32
), mve_scalar_shift
),
25810 ToC("urshrl", ea51011f
, 3, (RRe
, RRo
, I32
), mve_scalar_shift
),
25811 ToC("srshrl", ea51012f
, 3, (RRe
, RRo
, I32
), mve_scalar_shift
),
25812 ToC("sqshll", ea51013f
, 3, (RRe
, RRo
, I32
), mve_scalar_shift
),
25813 ToC("uqrshl", ea500f0d
, 2, (RRnpcsp
, RRnpcsp
), mve_scalar_shift
),
25814 ToC("sqrshr", ea500f2d
, 2, (RRnpcsp
, RRnpcsp
), mve_scalar_shift
),
25815 ToC("uqshl", ea500f0f
, 2, (RRnpcsp
, I32
), mve_scalar_shift
),
25816 ToC("urshr", ea500f1f
, 2, (RRnpcsp
, I32
), mve_scalar_shift
),
25817 ToC("srshr", ea500f2f
, 2, (RRnpcsp
, I32
), mve_scalar_shift
),
25818 ToC("sqshl", ea500f3f
, 2, (RRnpcsp
, I32
), mve_scalar_shift
),
25820 ToC("vpt", ee410f00
, 3, (COND
, RMQ
, RMQRZ
), mve_vpt
),
25821 ToC("vptt", ee018f00
, 3, (COND
, RMQ
, RMQRZ
), mve_vpt
),
25822 ToC("vpte", ee418f00
, 3, (COND
, RMQ
, RMQRZ
), mve_vpt
),
25823 ToC("vpttt", ee014f00
, 3, (COND
, RMQ
, RMQRZ
), mve_vpt
),
25824 ToC("vptte", ee01cf00
, 3, (COND
, RMQ
, RMQRZ
), mve_vpt
),
25825 ToC("vptet", ee41cf00
, 3, (COND
, RMQ
, RMQRZ
), mve_vpt
),
25826 ToC("vptee", ee414f00
, 3, (COND
, RMQ
, RMQRZ
), mve_vpt
),
25827 ToC("vptttt", ee012f00
, 3, (COND
, RMQ
, RMQRZ
), mve_vpt
),
25828 ToC("vpttte", ee016f00
, 3, (COND
, RMQ
, RMQRZ
), mve_vpt
),
25829 ToC("vpttet", ee01ef00
, 3, (COND
, RMQ
, RMQRZ
), mve_vpt
),
25830 ToC("vpttee", ee01af00
, 3, (COND
, RMQ
, RMQRZ
), mve_vpt
),
25831 ToC("vptett", ee41af00
, 3, (COND
, RMQ
, RMQRZ
), mve_vpt
),
25832 ToC("vptete", ee41ef00
, 3, (COND
, RMQ
, RMQRZ
), mve_vpt
),
25833 ToC("vpteet", ee416f00
, 3, (COND
, RMQ
, RMQRZ
), mve_vpt
),
25834 ToC("vpteee", ee412f00
, 3, (COND
, RMQ
, RMQRZ
), mve_vpt
),
25836 ToC("vpst", fe710f4d
, 0, (), mve_vpt
),
25837 ToC("vpstt", fe318f4d
, 0, (), mve_vpt
),
25838 ToC("vpste", fe718f4d
, 0, (), mve_vpt
),
25839 ToC("vpsttt", fe314f4d
, 0, (), mve_vpt
),
25840 ToC("vpstte", fe31cf4d
, 0, (), mve_vpt
),
25841 ToC("vpstet", fe71cf4d
, 0, (), mve_vpt
),
25842 ToC("vpstee", fe714f4d
, 0, (), mve_vpt
),
25843 ToC("vpstttt", fe312f4d
, 0, (), mve_vpt
),
25844 ToC("vpsttte", fe316f4d
, 0, (), mve_vpt
),
25845 ToC("vpsttet", fe31ef4d
, 0, (), mve_vpt
),
25846 ToC("vpsttee", fe31af4d
, 0, (), mve_vpt
),
25847 ToC("vpstett", fe71af4d
, 0, (), mve_vpt
),
25848 ToC("vpstete", fe71ef4d
, 0, (), mve_vpt
),
25849 ToC("vpsteet", fe716f4d
, 0, (), mve_vpt
),
25850 ToC("vpsteee", fe712f4d
, 0, (), mve_vpt
),
25852 /* MVE and MVE FP only. */
25853 mToC("vhcadd", ee000f00
, 4, (RMQ
, RMQ
, RMQ
, EXPi
), mve_vhcadd
),
25854 mCEF(vctp
, _vctp
, 1, (RRnpc
), mve_vctp
),
25855 mCEF(vadc
, _vadc
, 3, (RMQ
, RMQ
, RMQ
), mve_vadc
),
25856 mCEF(vadci
, _vadci
, 3, (RMQ
, RMQ
, RMQ
), mve_vadc
),
25857 mToC("vsbc", fe300f00
, 3, (RMQ
, RMQ
, RMQ
), mve_vsbc
),
25858 mToC("vsbci", fe301f00
, 3, (RMQ
, RMQ
, RMQ
), mve_vsbc
),
25859 mCEF(vmullb
, _vmullb
, 3, (RMQ
, RMQ
, RMQ
), mve_vmull
),
25860 mCEF(vabav
, _vabav
, 3, (RRnpcsp
, RMQ
, RMQ
), mve_vabav
),
25861 mCEF(vmladav
, _vmladav
, 3, (RRe
, RMQ
, RMQ
), mve_vmladav
),
25862 mCEF(vmladava
, _vmladava
, 3, (RRe
, RMQ
, RMQ
), mve_vmladav
),
25863 mCEF(vmladavx
, _vmladavx
, 3, (RRe
, RMQ
, RMQ
), mve_vmladav
),
25864 mCEF(vmladavax
, _vmladavax
, 3, (RRe
, RMQ
, RMQ
), mve_vmladav
),
25865 mCEF(vmlav
, _vmladav
, 3, (RRe
, RMQ
, RMQ
), mve_vmladav
),
25866 mCEF(vmlava
, _vmladava
, 3, (RRe
, RMQ
, RMQ
), mve_vmladav
),
25867 mCEF(vmlsdav
, _vmlsdav
, 3, (RRe
, RMQ
, RMQ
), mve_vmladav
),
25868 mCEF(vmlsdava
, _vmlsdava
, 3, (RRe
, RMQ
, RMQ
), mve_vmladav
),
25869 mCEF(vmlsdavx
, _vmlsdavx
, 3, (RRe
, RMQ
, RMQ
), mve_vmladav
),
25870 mCEF(vmlsdavax
, _vmlsdavax
, 3, (RRe
, RMQ
, RMQ
), mve_vmladav
),
25872 mCEF(vst20
, _vst20
, 2, (MSTRLST2
, ADDRMVE
), mve_vst_vld
),
25873 mCEF(vst21
, _vst21
, 2, (MSTRLST2
, ADDRMVE
), mve_vst_vld
),
25874 mCEF(vst40
, _vst40
, 2, (MSTRLST4
, ADDRMVE
), mve_vst_vld
),
25875 mCEF(vst41
, _vst41
, 2, (MSTRLST4
, ADDRMVE
), mve_vst_vld
),
25876 mCEF(vst42
, _vst42
, 2, (MSTRLST4
, ADDRMVE
), mve_vst_vld
),
25877 mCEF(vst43
, _vst43
, 2, (MSTRLST4
, ADDRMVE
), mve_vst_vld
),
25878 mCEF(vld20
, _vld20
, 2, (MSTRLST2
, ADDRMVE
), mve_vst_vld
),
25879 mCEF(vld21
, _vld21
, 2, (MSTRLST2
, ADDRMVE
), mve_vst_vld
),
25880 mCEF(vld40
, _vld40
, 2, (MSTRLST4
, ADDRMVE
), mve_vst_vld
),
25881 mCEF(vld41
, _vld41
, 2, (MSTRLST4
, ADDRMVE
), mve_vst_vld
),
25882 mCEF(vld42
, _vld42
, 2, (MSTRLST4
, ADDRMVE
), mve_vst_vld
),
25883 mCEF(vld43
, _vld43
, 2, (MSTRLST4
, ADDRMVE
), mve_vst_vld
),
25884 mCEF(vstrb
, _vstrb
, 2, (RMQ
, ADDRMVE
), mve_vstr_vldr
),
25885 mCEF(vstrh
, _vstrh
, 2, (RMQ
, ADDRMVE
), mve_vstr_vldr
),
25886 mCEF(vstrw
, _vstrw
, 2, (RMQ
, ADDRMVE
), mve_vstr_vldr
),
25887 mCEF(vstrd
, _vstrd
, 2, (RMQ
, ADDRMVE
), mve_vstr_vldr
),
25888 mCEF(vldrb
, _vldrb
, 2, (RMQ
, ADDRMVE
), mve_vstr_vldr
),
25889 mCEF(vldrh
, _vldrh
, 2, (RMQ
, ADDRMVE
), mve_vstr_vldr
),
25890 mCEF(vldrw
, _vldrw
, 2, (RMQ
, ADDRMVE
), mve_vstr_vldr
),
25891 mCEF(vldrd
, _vldrd
, 2, (RMQ
, ADDRMVE
), mve_vstr_vldr
),
25893 mCEF(vmovnt
, _vmovnt
, 2, (RMQ
, RMQ
), mve_movn
),
25894 mCEF(vmovnb
, _vmovnb
, 2, (RMQ
, RMQ
), mve_movn
),
25895 mCEF(vbrsr
, _vbrsr
, 3, (RMQ
, RMQ
, RR
), mve_vbrsr
),
25896 mCEF(vaddlv
, _vaddlv
, 3, (RRe
, RRo
, RMQ
), mve_vaddlv
),
25897 mCEF(vaddlva
, _vaddlva
, 3, (RRe
, RRo
, RMQ
), mve_vaddlv
),
25898 mCEF(vaddv
, _vaddv
, 2, (RRe
, RMQ
), mve_vaddv
),
25899 mCEF(vaddva
, _vaddva
, 2, (RRe
, RMQ
), mve_vaddv
),
25900 mCEF(vddup
, _vddup
, 3, (RMQ
, RRe
, EXPi
), mve_viddup
),
25901 mCEF(vdwdup
, _vdwdup
, 4, (RMQ
, RRe
, RR
, EXPi
), mve_viddup
),
25902 mCEF(vidup
, _vidup
, 3, (RMQ
, RRe
, EXPi
), mve_viddup
),
25903 mCEF(viwdup
, _viwdup
, 4, (RMQ
, RRe
, RR
, EXPi
), mve_viddup
),
25904 mToC("vmaxa", ee330e81
, 2, (RMQ
, RMQ
), mve_vmaxa_vmina
),
25905 mToC("vmina", ee331e81
, 2, (RMQ
, RMQ
), mve_vmaxa_vmina
),
25906 mCEF(vmaxv
, _vmaxv
, 2, (RR
, RMQ
), mve_vmaxv
),
25907 mCEF(vmaxav
, _vmaxav
, 2, (RR
, RMQ
), mve_vmaxv
),
25908 mCEF(vminv
, _vminv
, 2, (RR
, RMQ
), mve_vmaxv
),
25909 mCEF(vminav
, _vminav
, 2, (RR
, RMQ
), mve_vmaxv
),
25911 mCEF(vmlaldav
, _vmlaldav
, 4, (RRe
, RRo
, RMQ
, RMQ
), mve_vmlaldav
),
25912 mCEF(vmlaldava
, _vmlaldava
, 4, (RRe
, RRo
, RMQ
, RMQ
), mve_vmlaldav
),
25913 mCEF(vmlaldavx
, _vmlaldavx
, 4, (RRe
, RRo
, RMQ
, RMQ
), mve_vmlaldav
),
25914 mCEF(vmlaldavax
, _vmlaldavax
, 4, (RRe
, RRo
, RMQ
, RMQ
), mve_vmlaldav
),
25915 mCEF(vmlalv
, _vmlaldav
, 4, (RRe
, RRo
, RMQ
, RMQ
), mve_vmlaldav
),
25916 mCEF(vmlalva
, _vmlaldava
, 4, (RRe
, RRo
, RMQ
, RMQ
), mve_vmlaldav
),
25917 mCEF(vmlsldav
, _vmlsldav
, 4, (RRe
, RRo
, RMQ
, RMQ
), mve_vmlaldav
),
25918 mCEF(vmlsldava
, _vmlsldava
, 4, (RRe
, RRo
, RMQ
, RMQ
), mve_vmlaldav
),
25919 mCEF(vmlsldavx
, _vmlsldavx
, 4, (RRe
, RRo
, RMQ
, RMQ
), mve_vmlaldav
),
25920 mCEF(vmlsldavax
, _vmlsldavax
, 4, (RRe
, RRo
, RMQ
, RMQ
), mve_vmlaldav
),
25921 mToC("vrmlaldavh", ee800f00
, 4, (RRe
, RR
, RMQ
, RMQ
), mve_vrmlaldavh
),
25922 mToC("vrmlaldavha",ee800f20
, 4, (RRe
, RR
, RMQ
, RMQ
), mve_vrmlaldavh
),
25923 mCEF(vrmlaldavhx
, _vrmlaldavhx
, 4, (RRe
, RR
, RMQ
, RMQ
), mve_vrmlaldavh
),
25924 mCEF(vrmlaldavhax
, _vrmlaldavhax
, 4, (RRe
, RR
, RMQ
, RMQ
), mve_vrmlaldavh
),
25925 mToC("vrmlalvh", ee800f00
, 4, (RRe
, RR
, RMQ
, RMQ
), mve_vrmlaldavh
),
25926 mToC("vrmlalvha", ee800f20
, 4, (RRe
, RR
, RMQ
, RMQ
), mve_vrmlaldavh
),
25927 mCEF(vrmlsldavh
, _vrmlsldavh
, 4, (RRe
, RR
, RMQ
, RMQ
), mve_vrmlaldavh
),
25928 mCEF(vrmlsldavha
, _vrmlsldavha
, 4, (RRe
, RR
, RMQ
, RMQ
), mve_vrmlaldavh
),
25929 mCEF(vrmlsldavhx
, _vrmlsldavhx
, 4, (RRe
, RR
, RMQ
, RMQ
), mve_vrmlaldavh
),
25930 mCEF(vrmlsldavhax
, _vrmlsldavhax
, 4, (RRe
, RR
, RMQ
, RMQ
), mve_vrmlaldavh
),
25932 mToC("vmlas", ee011e40
, 3, (RMQ
, RMQ
, RR
), mve_vmlas
),
25933 mToC("vmulh", ee010e01
, 3, (RMQ
, RMQ
, RMQ
), mve_vmulh
),
25934 mToC("vrmulh", ee011e01
, 3, (RMQ
, RMQ
, RMQ
), mve_vmulh
),
25935 mToC("vpnot", fe310f4d
, 0, (), mve_vpnot
),
25936 mToC("vpsel", fe310f01
, 3, (RMQ
, RMQ
, RMQ
), mve_vpsel
),
25938 mToC("vqdmladh", ee000e00
, 3, (RMQ
, RMQ
, RMQ
), mve_vqdmladh
),
25939 mToC("vqdmladhx", ee001e00
, 3, (RMQ
, RMQ
, RMQ
), mve_vqdmladh
),
25940 mToC("vqrdmladh", ee000e01
, 3, (RMQ
, RMQ
, RMQ
), mve_vqdmladh
),
25941 mToC("vqrdmladhx",ee001e01
, 3, (RMQ
, RMQ
, RMQ
), mve_vqdmladh
),
25942 mToC("vqdmlsdh", fe000e00
, 3, (RMQ
, RMQ
, RMQ
), mve_vqdmladh
),
25943 mToC("vqdmlsdhx", fe001e00
, 3, (RMQ
, RMQ
, RMQ
), mve_vqdmladh
),
25944 mToC("vqrdmlsdh", fe000e01
, 3, (RMQ
, RMQ
, RMQ
), mve_vqdmladh
),
25945 mToC("vqrdmlsdhx",fe001e01
, 3, (RMQ
, RMQ
, RMQ
), mve_vqdmladh
),
25946 mToC("vqdmlah", ee000e60
, 3, (RMQ
, RMQ
, RR
), mve_vqdmlah
),
25947 mToC("vqdmlash", ee001e60
, 3, (RMQ
, RMQ
, RR
), mve_vqdmlah
),
25948 mToC("vqrdmlash", ee001e40
, 3, (RMQ
, RMQ
, RR
), mve_vqdmlah
),
25949 mToC("vqdmullt", ee301f00
, 3, (RMQ
, RMQ
, RMQRR
), mve_vqdmull
),
25950 mToC("vqdmullb", ee300f00
, 3, (RMQ
, RMQ
, RMQRR
), mve_vqdmull
),
25951 mCEF(vqmovnt
, _vqmovnt
, 2, (RMQ
, RMQ
), mve_vqmovn
),
25952 mCEF(vqmovnb
, _vqmovnb
, 2, (RMQ
, RMQ
), mve_vqmovn
),
25953 mCEF(vqmovunt
, _vqmovunt
, 2, (RMQ
, RMQ
), mve_vqmovn
),
25954 mCEF(vqmovunb
, _vqmovunb
, 2, (RMQ
, RMQ
), mve_vqmovn
),
25956 mCEF(vshrnt
, _vshrnt
, 3, (RMQ
, RMQ
, I32z
), mve_vshrn
),
25957 mCEF(vshrnb
, _vshrnb
, 3, (RMQ
, RMQ
, I32z
), mve_vshrn
),
25958 mCEF(vrshrnt
, _vrshrnt
, 3, (RMQ
, RMQ
, I32z
), mve_vshrn
),
25959 mCEF(vrshrnb
, _vrshrnb
, 3, (RMQ
, RMQ
, I32z
), mve_vshrn
),
25960 mCEF(vqshrnt
, _vqrshrnt
, 3, (RMQ
, RMQ
, I32z
), mve_vshrn
),
25961 mCEF(vqshrnb
, _vqrshrnb
, 3, (RMQ
, RMQ
, I32z
), mve_vshrn
),
25962 mCEF(vqshrunt
, _vqrshrunt
, 3, (RMQ
, RMQ
, I32z
), mve_vshrn
),
25963 mCEF(vqshrunb
, _vqrshrunb
, 3, (RMQ
, RMQ
, I32z
), mve_vshrn
),
25964 mCEF(vqrshrnt
, _vqrshrnt
, 3, (RMQ
, RMQ
, I32z
), mve_vshrn
),
25965 mCEF(vqrshrnb
, _vqrshrnb
, 3, (RMQ
, RMQ
, I32z
), mve_vshrn
),
25966 mCEF(vqrshrunt
, _vqrshrunt
, 3, (RMQ
, RMQ
, I32z
), mve_vshrn
),
25967 mCEF(vqrshrunb
, _vqrshrunb
, 3, (RMQ
, RMQ
, I32z
), mve_vshrn
),
25969 mToC("vshlc", eea00fc0
, 3, (RMQ
, RR
, I32z
), mve_vshlc
),
25970 mToC("vshllt", ee201e00
, 3, (RMQ
, RMQ
, I32
), mve_vshll
),
25971 mToC("vshllb", ee200e00
, 3, (RMQ
, RMQ
, I32
), mve_vshll
),
25973 toU("dlstp", _dlstp
, 2, (LR
, RR
), t_loloop
),
25974 toU("wlstp", _wlstp
, 3, (LR
, RR
, EXP
), t_loloop
),
25975 toU("letp", _letp
, 2, (LR
, EXP
), t_loloop
),
25976 toU("lctp", _lctp
, 0, (), t_loloop
),
25978 #undef THUMB_VARIANT
25979 #define THUMB_VARIANT & mve_fp_ext
25980 mToC("vcmul", ee300e00
, 4, (RMQ
, RMQ
, RMQ
, EXPi
), mve_vcmul
),
25981 mToC("vfmas", ee311e40
, 3, (RMQ
, RMQ
, RR
), mve_vfmas
),
25982 mToC("vmaxnma", ee3f0e81
, 2, (RMQ
, RMQ
), mve_vmaxnma_vminnma
),
25983 mToC("vminnma", ee3f1e81
, 2, (RMQ
, RMQ
), mve_vmaxnma_vminnma
),
25984 mToC("vmaxnmv", eeee0f00
, 2, (RR
, RMQ
), mve_vmaxnmv
),
25985 mToC("vmaxnmav",eeec0f00
, 2, (RR
, RMQ
), mve_vmaxnmv
),
25986 mToC("vminnmv", eeee0f80
, 2, (RR
, RMQ
), mve_vmaxnmv
),
25987 mToC("vminnmav",eeec0f80
, 2, (RR
, RMQ
), mve_vmaxnmv
),
25990 #define ARM_VARIANT & fpu_vfp_ext_v1
25991 #undef THUMB_VARIANT
25992 #define THUMB_VARIANT & arm_ext_v6t2
25993 mnCEF(vmla
, _vmla
, 3, (RNSDQMQ
, oRNSDQMQ
, RNSDQ_RNSC_MQ_RR
), neon_mac_maybe_scalar
),
25994 mnCEF(vmul
, _vmul
, 3, (RNSDQMQ
, oRNSDQMQ
, RNSDQ_RNSC_MQ_RR
), neon_mul
),
25996 mcCE(fcpyd
, eb00b40
, 2, (RVD
, RVD
), vfp_dp_rd_rm
),
25999 #define ARM_VARIANT & fpu_vfp_ext_v1xd
26001 MNCE(vmov
, 0, 1, (VMOV
), neon_mov
),
26002 mcCE(fmrs
, e100a10
, 2, (RR
, RVS
), vfp_reg_from_sp
),
26003 mcCE(fmsr
, e000a10
, 2, (RVS
, RR
), vfp_sp_from_reg
),
26004 mcCE(fcpys
, eb00a40
, 2, (RVS
, RVS
), vfp_sp_monadic
),
26006 mCEF(vmullt
, _vmullt
, 3, (RNSDQMQ
, oRNSDQMQ
, RNSDQ_RNSC_MQ
), mve_vmull
),
26007 mnCEF(vadd
, _vadd
, 3, (RNSDQMQ
, oRNSDQMQ
, RNSDQMQR
), neon_addsub_if_i
),
26008 mnCEF(vsub
, _vsub
, 3, (RNSDQMQ
, oRNSDQMQ
, RNSDQMQR
), neon_addsub_if_i
),
26010 MNCEF(vabs
, 1b10300
, 2, (RNSDQMQ
, RNSDQMQ
), neon_abs_neg
),
26011 MNCEF(vneg
, 1b10380
, 2, (RNSDQMQ
, RNSDQMQ
), neon_abs_neg
),
26013 mCEF(vmovlt
, _vmovlt
, 1, (VMOV
), mve_movl
),
26014 mCEF(vmovlb
, _vmovlb
, 1, (VMOV
), mve_movl
),
26016 mnCE(vcmp
, _vcmp
, 3, (RVSD_COND
, RSVDMQ_FI0
, oRMQRZ
), vfp_nsyn_cmp
),
26017 mnCE(vcmpe
, _vcmpe
, 3, (RVSD_COND
, RSVDMQ_FI0
, oRMQRZ
), vfp_nsyn_cmp
),
26020 #define ARM_VARIANT & fpu_vfp_ext_v2
26022 mcCE(fmsrr
, c400a10
, 3, (VRSLST
, RR
, RR
), vfp_sp2_from_reg2
),
26023 mcCE(fmrrs
, c500a10
, 3, (RR
, RR
, VRSLST
), vfp_reg2_from_sp2
),
26024 mcCE(fmdrr
, c400b10
, 3, (RVD
, RR
, RR
), vfp_dp_rm_rd_rn
),
26025 mcCE(fmrrd
, c500b10
, 3, (RR
, RR
, RVD
), vfp_dp_rd_rn_rm
),
26028 #define ARM_VARIANT & fpu_vfp_ext_armv8xd
26029 mnUF(vcvta
, _vcvta
, 2, (RNSDQMQ
, oRNSDQMQ
), neon_cvta
),
26030 mnUF(vcvtp
, _vcvta
, 2, (RNSDQMQ
, oRNSDQMQ
), neon_cvtp
),
26031 mnUF(vcvtn
, _vcvta
, 3, (RNSDQMQ
, oRNSDQMQ
, oI32z
), neon_cvtn
),
26032 mnUF(vcvtm
, _vcvta
, 2, (RNSDQMQ
, oRNSDQMQ
), neon_cvtm
),
26033 mnUF(vmaxnm
, _vmaxnm
, 3, (RNSDQMQ
, oRNSDQMQ
, RNSDQMQ
), vmaxnm
),
26034 mnUF(vminnm
, _vminnm
, 3, (RNSDQMQ
, oRNSDQMQ
, RNSDQMQ
), vmaxnm
),
26037 #define ARM_VARIANT & fpu_neon_ext_v1
26038 mnUF(vabd
, _vabd
, 3, (RNDQMQ
, oRNDQMQ
, RNDQMQ
), neon_dyadic_if_su
),
26039 mnUF(vabdl
, _vabdl
, 3, (RNQMQ
, RNDMQ
, RNDMQ
), neon_dyadic_long
),
26040 mnUF(vaddl
, _vaddl
, 3, (RNQMQ
, RNDMQ
, RNDMQR
), neon_dyadic_long
),
26041 mnUF(vsubl
, _vsubl
, 3, (RNQMQ
, RNDMQ
, RNDMQR
), neon_dyadic_long
),
26042 mnUF(vand
, _vand
, 3, (RNDQMQ
, oRNDQMQ
, RNDQMQ_Ibig
), neon_logic
),
26043 mnUF(vbic
, _vbic
, 3, (RNDQMQ
, oRNDQMQ
, RNDQMQ_Ibig
), neon_logic
),
26044 mnUF(vorr
, _vorr
, 3, (RNDQMQ
, oRNDQMQ
, RNDQMQ_Ibig
), neon_logic
),
26045 mnUF(vorn
, _vorn
, 3, (RNDQMQ
, oRNDQMQ
, RNDQMQ_Ibig
), neon_logic
),
26046 mnUF(veor
, _veor
, 3, (RNDQMQ
, oRNDQMQ
, RNDQMQ
), neon_logic
),
26047 MNUF(vcls
, 1b00400
, 2, (RNDQMQ
, RNDQMQ
), neon_cls
),
26048 MNUF(vclz
, 1b00480
, 2, (RNDQMQ
, RNDQMQ
), neon_clz
),
26049 mnCE(vdup
, _vdup
, 2, (RNDQMQ
, RR_RNSC
), neon_dup
),
26050 MNUF(vhadd
, 00000000, 3, (RNDQMQ
, oRNDQMQ
, RNDQMQR
), neon_dyadic_i_su
),
26051 MNUF(vrhadd
, 00000100, 3, (RNDQMQ
, oRNDQMQ
, RNDQMQ
), neon_dyadic_i_su
),
26052 MNUF(vhsub
, 00000200, 3, (RNDQMQ
, oRNDQMQ
, RNDQMQR
), neon_dyadic_i_su
),
26053 mnUF(vmin
, _vmin
, 3, (RNDQMQ
, oRNDQMQ
, RNDQMQ
), neon_dyadic_if_su
),
26054 mnUF(vmax
, _vmax
, 3, (RNDQMQ
, oRNDQMQ
, RNDQMQ
), neon_dyadic_if_su
),
26055 MNUF(vqadd
, 0000010, 3, (RNDQMQ
, oRNDQMQ
, RNDQMQR
), neon_dyadic_i64_su
),
26056 MNUF(vqsub
, 0000210, 3, (RNDQMQ
, oRNDQMQ
, RNDQMQR
), neon_dyadic_i64_su
),
26057 mnUF(vmvn
, _vmvn
, 2, (RNDQMQ
, RNDQMQ_Ibig
), neon_mvn
),
26058 MNUF(vqabs
, 1b00700
, 2, (RNDQMQ
, RNDQMQ
), neon_sat_abs_neg
),
26059 MNUF(vqneg
, 1b00780
, 2, (RNDQMQ
, RNDQMQ
), neon_sat_abs_neg
),
26060 mnUF(vqrdmlah
, _vqrdmlah
,3, (RNDQMQ
, oRNDQMQ
, RNDQ_RNSC_RR
), neon_qrdmlah
),
26061 mnUF(vqdmulh
, _vqdmulh
, 3, (RNDQMQ
, oRNDQMQ
, RNDQMQ_RNSC_RR
), neon_qdmulh
),
26062 mnUF(vqrdmulh
, _vqrdmulh
,3, (RNDQMQ
, oRNDQMQ
, RNDQMQ_RNSC_RR
), neon_qdmulh
),
26063 MNUF(vqrshl
, 0000510, 3, (RNDQMQ
, oRNDQMQ
, RNDQMQR
), neon_rshl
),
26064 MNUF(vrshl
, 0000500, 3, (RNDQMQ
, oRNDQMQ
, RNDQMQR
), neon_rshl
),
26065 MNUF(vshr
, 0800010, 3, (RNDQMQ
, oRNDQMQ
, I64z
), neon_rshift_round_imm
),
26066 MNUF(vrshr
, 0800210, 3, (RNDQMQ
, oRNDQMQ
, I64z
), neon_rshift_round_imm
),
26067 MNUF(vsli
, 1800510, 3, (RNDQMQ
, oRNDQMQ
, I63
), neon_sli
),
26068 MNUF(vsri
, 1800410, 3, (RNDQMQ
, oRNDQMQ
, I64z
), neon_sri
),
26069 MNUF(vrev64
, 1b00000
, 2, (RNDQMQ
, RNDQMQ
), neon_rev
),
26070 MNUF(vrev32
, 1b00080
, 2, (RNDQMQ
, RNDQMQ
), neon_rev
),
26071 MNUF(vrev16
, 1b00100
, 2, (RNDQMQ
, RNDQMQ
), neon_rev
),
26072 mnUF(vshl
, _vshl
, 3, (RNDQMQ
, oRNDQMQ
, RNDQMQ_I63b_RR
), neon_shl
),
26073 mnUF(vqshl
, _vqshl
, 3, (RNDQMQ
, oRNDQMQ
, RNDQMQ_I63b_RR
), neon_qshl
),
26074 MNUF(vqshlu
, 1800610, 3, (RNDQMQ
, oRNDQMQ
, I63
), neon_qshlu_imm
),
26077 #define ARM_VARIANT & arm_ext_v8_3
26078 #undef THUMB_VARIANT
26079 #define THUMB_VARIANT & arm_ext_v6t2_v8m
26080 MNUF (vcadd
, 0, 4, (RNDQMQ
, RNDQMQ
, RNDQMQ
, EXPi
), vcadd
),
26081 MNUF (vcmla
, 0, 4, (RNDQMQ
, RNDQMQ
, RNDQMQ_RNSC
, EXPi
), vcmla
),
26084 #define ARM_VARIANT &arm_ext_bf16
26085 #undef THUMB_VARIANT
26086 #define THUMB_VARIANT &arm_ext_bf16
26087 TUF ("vdot", c000d00
, fc000d00
, 3, (RNDQ
, RNDQ
, RNDQ_RNSC
), vdot
, vdot
),
26088 TUF ("vmmla", c000c40
, fc000c40
, 3, (RNQ
, RNQ
, RNQ
), vmmla
, vmmla
),
26089 TUF ("vfmab", c300810
, fc300810
, 3, (RNDQ
, RNDQ
, RNDQ_RNSC
), bfloat_vfma
, bfloat_vfma
),
26092 #define ARM_VARIANT &arm_ext_i8mm
26093 #undef THUMB_VARIANT
26094 #define THUMB_VARIANT &arm_ext_i8mm
26095 TUF ("vsmmla", c200c40
, fc200c40
, 3, (RNQ
, RNQ
, RNQ
), vsmmla
, vsmmla
),
26096 TUF ("vummla", c200c50
, fc200c50
, 3, (RNQ
, RNQ
, RNQ
), vummla
, vummla
),
26097 TUF ("vusmmla", ca00c40
, fca00c40
, 3, (RNQ
, RNQ
, RNQ
), vsmmla
, vsmmla
),
26098 TUF ("vusdot", c800d00
, fc800d00
, 3, (RNDQ
, RNDQ
, RNDQ_RNSC
), vusdot
, vusdot
),
26099 TUF ("vsudot", c800d10
, fc800d10
, 3, (RNDQ
, RNDQ
, RNSC
), vsudot
, vsudot
),
26102 #undef THUMB_VARIANT
26134 /* MD interface: bits in the object file. */
26136 /* Turn an integer of n bytes (in val) into a stream of bytes appropriate
26137 for use in the a.out file, and stores them in the array pointed to by buf.
26138 This knows about the endian-ness of the target machine and does
26139 THE RIGHT THING, whatever it is. Possible values for n are 1 (byte)
26140 2 (short) and 4 (long) Floating numbers are put out as a series of
26141 LITTLENUMS (shorts, here at least). */
26144 md_number_to_chars (char * buf
, valueT val
, int n
)
26146 if (target_big_endian
)
26147 number_to_chars_bigendian (buf
, val
, n
);
26149 number_to_chars_littleendian (buf
, val
, n
);
26153 md_chars_to_number (char * buf
, int n
)
26156 unsigned char * where
= (unsigned char *) buf
;
26158 if (target_big_endian
)
26163 result
|= (*where
++ & 255);
26171 result
|= (where
[n
] & 255);
26178 /* MD interface: Sections. */
26180 /* Calculate the maximum variable size (i.e., excluding fr_fix)
26181 that an rs_machine_dependent frag may reach. */
26184 arm_frag_max_var (fragS
*fragp
)
26186 /* We only use rs_machine_dependent for variable-size Thumb instructions,
26187 which are either THUMB_SIZE (2) or INSN_SIZE (4).
26189 Note that we generate relaxable instructions even for cases that don't
26190 really need it, like an immediate that's a trivial constant. So we're
26191 overestimating the instruction size for some of those cases. Rather
26192 than putting more intelligence here, it would probably be better to
26193 avoid generating a relaxation frag in the first place when it can be
26194 determined up front that a short instruction will suffice. */
26196 gas_assert (fragp
->fr_type
== rs_machine_dependent
);
26200 /* Estimate the size of a frag before relaxing. Assume everything fits in
26204 md_estimate_size_before_relax (fragS
* fragp
,
26205 segT segtype ATTRIBUTE_UNUSED
)
26211 /* Convert a machine dependent frag. */
26214 md_convert_frag (bfd
*abfd
, segT asec ATTRIBUTE_UNUSED
, fragS
*fragp
)
26216 unsigned long insn
;
26217 unsigned long old_op
;
26225 buf
= fragp
->fr_literal
+ fragp
->fr_fix
;
26227 old_op
= bfd_get_16(abfd
, buf
);
26228 if (fragp
->fr_symbol
)
26230 exp
.X_op
= O_symbol
;
26231 exp
.X_add_symbol
= fragp
->fr_symbol
;
26235 exp
.X_op
= O_constant
;
26237 exp
.X_add_number
= fragp
->fr_offset
;
26238 opcode
= fragp
->fr_subtype
;
26241 case T_MNEM_ldr_pc
:
26242 case T_MNEM_ldr_pc2
:
26243 case T_MNEM_ldr_sp
:
26244 case T_MNEM_str_sp
:
26251 if (fragp
->fr_var
== 4)
26253 insn
= THUMB_OP32 (opcode
);
26254 if ((old_op
>> 12) == 4 || (old_op
>> 12) == 9)
26256 insn
|= (old_op
& 0x700) << 4;
26260 insn
|= (old_op
& 7) << 12;
26261 insn
|= (old_op
& 0x38) << 13;
26263 insn
|= 0x00000c00;
26264 put_thumb32_insn (buf
, insn
);
26265 reloc_type
= BFD_RELOC_ARM_T32_OFFSET_IMM
;
26269 reloc_type
= BFD_RELOC_ARM_THUMB_OFFSET
;
26271 pc_rel
= (opcode
== T_MNEM_ldr_pc2
);
26274 if (fragp
->fr_var
== 4)
26276 insn
= THUMB_OP32 (opcode
);
26277 insn
|= (old_op
& 0xf0) << 4;
26278 put_thumb32_insn (buf
, insn
);
26279 reloc_type
= BFD_RELOC_ARM_T32_ADD_PC12
;
26283 reloc_type
= BFD_RELOC_ARM_THUMB_ADD
;
26284 exp
.X_add_number
-= 4;
26292 if (fragp
->fr_var
== 4)
26294 int r0off
= (opcode
== T_MNEM_mov
26295 || opcode
== T_MNEM_movs
) ? 0 : 8;
26296 insn
= THUMB_OP32 (opcode
);
26297 insn
= (insn
& 0xe1ffffff) | 0x10000000;
26298 insn
|= (old_op
& 0x700) << r0off
;
26299 put_thumb32_insn (buf
, insn
);
26300 reloc_type
= BFD_RELOC_ARM_T32_IMMEDIATE
;
26304 reloc_type
= BFD_RELOC_ARM_THUMB_IMM
;
26309 if (fragp
->fr_var
== 4)
26311 insn
= THUMB_OP32(opcode
);
26312 put_thumb32_insn (buf
, insn
);
26313 reloc_type
= BFD_RELOC_THUMB_PCREL_BRANCH25
;
26316 reloc_type
= BFD_RELOC_THUMB_PCREL_BRANCH12
;
26320 if (fragp
->fr_var
== 4)
26322 insn
= THUMB_OP32(opcode
);
26323 insn
|= (old_op
& 0xf00) << 14;
26324 put_thumb32_insn (buf
, insn
);
26325 reloc_type
= BFD_RELOC_THUMB_PCREL_BRANCH20
;
26328 reloc_type
= BFD_RELOC_THUMB_PCREL_BRANCH9
;
26331 case T_MNEM_add_sp
:
26332 case T_MNEM_add_pc
:
26333 case T_MNEM_inc_sp
:
26334 case T_MNEM_dec_sp
:
26335 if (fragp
->fr_var
== 4)
26337 /* ??? Choose between add and addw. */
26338 insn
= THUMB_OP32 (opcode
);
26339 insn
|= (old_op
& 0xf0) << 4;
26340 put_thumb32_insn (buf
, insn
);
26341 if (opcode
== T_MNEM_add_pc
)
26342 reloc_type
= BFD_RELOC_ARM_T32_IMM12
;
26344 reloc_type
= BFD_RELOC_ARM_T32_ADD_IMM
;
26347 reloc_type
= BFD_RELOC_ARM_THUMB_ADD
;
26355 if (fragp
->fr_var
== 4)
26357 insn
= THUMB_OP32 (opcode
);
26358 insn
|= (old_op
& 0xf0) << 4;
26359 insn
|= (old_op
& 0xf) << 16;
26360 put_thumb32_insn (buf
, insn
);
26361 if (insn
& (1 << 20))
26362 reloc_type
= BFD_RELOC_ARM_T32_ADD_IMM
;
26364 reloc_type
= BFD_RELOC_ARM_T32_IMMEDIATE
;
26367 reloc_type
= BFD_RELOC_ARM_THUMB_ADD
;
26373 fixp
= fix_new_exp (fragp
, fragp
->fr_fix
, fragp
->fr_var
, &exp
, pc_rel
,
26374 (enum bfd_reloc_code_real
) reloc_type
);
26375 fixp
->fx_file
= fragp
->fr_file
;
26376 fixp
->fx_line
= fragp
->fr_line
;
26377 fragp
->fr_fix
+= fragp
->fr_var
;
26379 /* Set whether we use thumb-2 ISA based on final relaxation results. */
26380 if (thumb_mode
&& fragp
->fr_var
== 4 && no_cpu_selected ()
26381 && !ARM_CPU_HAS_FEATURE (thumb_arch_used
, arm_arch_t2
))
26382 ARM_MERGE_FEATURE_SETS (arm_arch_used
, thumb_arch_used
, arm_ext_v6t2
);
26385 /* Return the size of a relaxable immediate operand instruction.
26386 SHIFT and SIZE specify the form of the allowable immediate. */
26388 relax_immediate (fragS
*fragp
, int size
, int shift
)
26394 /* ??? Should be able to do better than this. */
26395 if (fragp
->fr_symbol
)
26398 low
= (1 << shift
) - 1;
26399 mask
= (1 << (shift
+ size
)) - (1 << shift
);
26400 offset
= fragp
->fr_offset
;
26401 /* Force misaligned offsets to 32-bit variant. */
26404 if (offset
& ~mask
)
26409 /* Get the address of a symbol during relaxation. */
26411 relaxed_symbol_addr (fragS
*fragp
, long stretch
)
26417 sym
= fragp
->fr_symbol
;
26418 sym_frag
= symbol_get_frag (sym
);
26419 know (S_GET_SEGMENT (sym
) != absolute_section
26420 || sym_frag
== &zero_address_frag
);
26421 addr
= S_GET_VALUE (sym
) + fragp
->fr_offset
;
26423 /* If frag has yet to be reached on this pass, assume it will
26424 move by STRETCH just as we did. If this is not so, it will
26425 be because some frag between grows, and that will force
26429 && sym_frag
->relax_marker
!= fragp
->relax_marker
)
26433 /* Adjust stretch for any alignment frag. Note that if have
26434 been expanding the earlier code, the symbol may be
26435 defined in what appears to be an earlier frag. FIXME:
26436 This doesn't handle the fr_subtype field, which specifies
26437 a maximum number of bytes to skip when doing an
26439 for (f
= fragp
; f
!= NULL
&& f
!= sym_frag
; f
= f
->fr_next
)
26441 if (f
->fr_type
== rs_align
|| f
->fr_type
== rs_align_code
)
26444 stretch
= - ((- stretch
)
26445 & ~ ((1 << (int) f
->fr_offset
) - 1));
26447 stretch
&= ~ ((1 << (int) f
->fr_offset
) - 1);
26459 /* Return the size of a relaxable adr pseudo-instruction or PC-relative
26462 relax_adr (fragS
*fragp
, asection
*sec
, long stretch
)
26467 /* Assume worst case for symbols not known to be in the same section. */
26468 if (fragp
->fr_symbol
== NULL
26469 || !S_IS_DEFINED (fragp
->fr_symbol
)
26470 || sec
!= S_GET_SEGMENT (fragp
->fr_symbol
)
26471 || S_IS_WEAK (fragp
->fr_symbol
))
26474 val
= relaxed_symbol_addr (fragp
, stretch
);
26475 addr
= fragp
->fr_address
+ fragp
->fr_fix
;
26476 addr
= (addr
+ 4) & ~3;
26477 /* Force misaligned targets to 32-bit variant. */
26481 if (val
< 0 || val
> 1020)
26486 /* Return the size of a relaxable add/sub immediate instruction. */
26488 relax_addsub (fragS
*fragp
, asection
*sec
)
26493 buf
= fragp
->fr_literal
+ fragp
->fr_fix
;
26494 op
= bfd_get_16(sec
->owner
, buf
);
26495 if ((op
& 0xf) == ((op
>> 4) & 0xf))
26496 return relax_immediate (fragp
, 8, 0);
26498 return relax_immediate (fragp
, 3, 0);
26501 /* Return TRUE iff the definition of symbol S could be pre-empted
26502 (overridden) at link or load time. */
26504 symbol_preemptible (symbolS
*s
)
26506 /* Weak symbols can always be pre-empted. */
26510 /* Non-global symbols cannot be pre-empted. */
26511 if (! S_IS_EXTERNAL (s
))
26515 /* In ELF, a global symbol can be marked protected, or private. In that
26516 case it can't be pre-empted (other definitions in the same link unit
26517 would violate the ODR). */
26518 if (ELF_ST_VISIBILITY (S_GET_OTHER (s
)) > STV_DEFAULT
)
26522 /* Other global symbols might be pre-empted. */
26526 /* Return the size of a relaxable branch instruction. BITS is the
26527 size of the offset field in the narrow instruction. */
26530 relax_branch (fragS
*fragp
, asection
*sec
, int bits
, long stretch
)
26536 /* Assume worst case for symbols not known to be in the same section. */
26537 if (!S_IS_DEFINED (fragp
->fr_symbol
)
26538 || sec
!= S_GET_SEGMENT (fragp
->fr_symbol
)
26539 || S_IS_WEAK (fragp
->fr_symbol
))
26543 /* A branch to a function in ARM state will require interworking. */
26544 if (S_IS_DEFINED (fragp
->fr_symbol
)
26545 && ARM_IS_FUNC (fragp
->fr_symbol
))
26549 if (symbol_preemptible (fragp
->fr_symbol
))
26552 val
= relaxed_symbol_addr (fragp
, stretch
);
26553 addr
= fragp
->fr_address
+ fragp
->fr_fix
+ 4;
26556 /* Offset is a signed value *2 */
26558 if (val
>= limit
|| val
< -limit
)
26564 /* Relax a machine dependent frag. This returns the amount by which
26565 the current size of the frag should change. */
26568 arm_relax_frag (asection
*sec
, fragS
*fragp
, long stretch
)
26573 oldsize
= fragp
->fr_var
;
26574 switch (fragp
->fr_subtype
)
26576 case T_MNEM_ldr_pc2
:
26577 newsize
= relax_adr (fragp
, sec
, stretch
);
26579 case T_MNEM_ldr_pc
:
26580 case T_MNEM_ldr_sp
:
26581 case T_MNEM_str_sp
:
26582 newsize
= relax_immediate (fragp
, 8, 2);
26586 newsize
= relax_immediate (fragp
, 5, 2);
26590 newsize
= relax_immediate (fragp
, 5, 1);
26594 newsize
= relax_immediate (fragp
, 5, 0);
26597 newsize
= relax_adr (fragp
, sec
, stretch
);
26603 newsize
= relax_immediate (fragp
, 8, 0);
26606 newsize
= relax_branch (fragp
, sec
, 11, stretch
);
26609 newsize
= relax_branch (fragp
, sec
, 8, stretch
);
26611 case T_MNEM_add_sp
:
26612 case T_MNEM_add_pc
:
26613 newsize
= relax_immediate (fragp
, 8, 2);
26615 case T_MNEM_inc_sp
:
26616 case T_MNEM_dec_sp
:
26617 newsize
= relax_immediate (fragp
, 7, 2);
26623 newsize
= relax_addsub (fragp
, sec
);
26629 fragp
->fr_var
= newsize
;
26630 /* Freeze wide instructions that are at or before the same location as
26631 in the previous pass. This avoids infinite loops.
26632 Don't freeze them unconditionally because targets may be artificially
26633 misaligned by the expansion of preceding frags. */
26634 if (stretch
<= 0 && newsize
> 2)
26636 md_convert_frag (sec
->owner
, sec
, fragp
);
26640 return newsize
- oldsize
;
26643 /* Round up a section size to the appropriate boundary. */
26646 md_section_align (segT segment ATTRIBUTE_UNUSED
,
26652 /* This is called from HANDLE_ALIGN in write.c. Fill in the contents
26653 of an rs_align_code fragment. */
26656 arm_handle_align (fragS
* fragP
)
26658 static unsigned char const arm_noop
[2][2][4] =
26661 {0x00, 0x00, 0xa0, 0xe1}, /* LE */
26662 {0xe1, 0xa0, 0x00, 0x00}, /* BE */
26665 {0x00, 0xf0, 0x20, 0xe3}, /* LE */
26666 {0xe3, 0x20, 0xf0, 0x00}, /* BE */
26669 static unsigned char const thumb_noop
[2][2][2] =
26672 {0xc0, 0x46}, /* LE */
26673 {0x46, 0xc0}, /* BE */
26676 {0x00, 0xbf}, /* LE */
26677 {0xbf, 0x00} /* BE */
26680 static unsigned char const wide_thumb_noop
[2][4] =
26681 { /* Wide Thumb-2 */
26682 {0xaf, 0xf3, 0x00, 0x80}, /* LE */
26683 {0xf3, 0xaf, 0x80, 0x00}, /* BE */
26686 unsigned bytes
, fix
, noop_size
;
26688 const unsigned char * noop
;
26689 const unsigned char *narrow_noop
= NULL
;
26694 if (fragP
->fr_type
!= rs_align_code
)
26697 bytes
= fragP
->fr_next
->fr_address
- fragP
->fr_address
- fragP
->fr_fix
;
26698 p
= fragP
->fr_literal
+ fragP
->fr_fix
;
26701 if (bytes
> MAX_MEM_FOR_RS_ALIGN_CODE
)
26702 bytes
&= MAX_MEM_FOR_RS_ALIGN_CODE
;
26704 gas_assert ((fragP
->tc_frag_data
.thumb_mode
& MODE_RECORDED
) != 0);
26706 if (fragP
->tc_frag_data
.thumb_mode
& (~ MODE_RECORDED
))
26708 if (ARM_CPU_HAS_FEATURE (selected_cpu_name
[0]
26709 ? selected_cpu
: arm_arch_none
, arm_ext_v6t2
))
26711 narrow_noop
= thumb_noop
[1][target_big_endian
];
26712 noop
= wide_thumb_noop
[target_big_endian
];
26715 noop
= thumb_noop
[0][target_big_endian
];
26723 noop
= arm_noop
[ARM_CPU_HAS_FEATURE (selected_cpu_name
[0]
26724 ? selected_cpu
: arm_arch_none
,
26726 [target_big_endian
];
26733 fragP
->fr_var
= noop_size
;
26735 if (bytes
& (noop_size
- 1))
26737 fix
= bytes
& (noop_size
- 1);
26739 insert_data_mapping_symbol (state
, fragP
->fr_fix
, fragP
, fix
);
26741 memset (p
, 0, fix
);
26748 if (bytes
& noop_size
)
26750 /* Insert a narrow noop. */
26751 memcpy (p
, narrow_noop
, noop_size
);
26753 bytes
-= noop_size
;
26757 /* Use wide noops for the remainder */
26761 while (bytes
>= noop_size
)
26763 memcpy (p
, noop
, noop_size
);
26765 bytes
-= noop_size
;
26769 fragP
->fr_fix
+= fix
;
26772 /* Called from md_do_align. Used to create an alignment
26773 frag in a code section. */
26776 arm_frag_align_code (int n
, int max
)
26780 /* We assume that there will never be a requirement
26781 to support alignments greater than MAX_MEM_FOR_RS_ALIGN_CODE bytes. */
26782 if (max
> MAX_MEM_FOR_RS_ALIGN_CODE
)
26787 _("alignments greater than %d bytes not supported in .text sections."),
26788 MAX_MEM_FOR_RS_ALIGN_CODE
+ 1);
26789 as_fatal ("%s", err_msg
);
26792 p
= frag_var (rs_align_code
,
26793 MAX_MEM_FOR_RS_ALIGN_CODE
,
26795 (relax_substateT
) max
,
26802 /* Perform target specific initialisation of a frag.
26803 Note - despite the name this initialisation is not done when the frag
26804 is created, but only when its type is assigned. A frag can be created
26805 and used a long time before its type is set, so beware of assuming that
26806 this initialisation is performed first. */
26810 arm_init_frag (fragS
* fragP
, int max_chars ATTRIBUTE_UNUSED
)
26812 /* Record whether this frag is in an ARM or a THUMB area. */
26813 fragP
->tc_frag_data
.thumb_mode
= thumb_mode
| MODE_RECORDED
;
26816 #else /* OBJ_ELF is defined. */
26818 arm_init_frag (fragS
* fragP
, int max_chars
)
26820 bfd_boolean frag_thumb_mode
;
26822 /* If the current ARM vs THUMB mode has not already
26823 been recorded into this frag then do so now. */
26824 if ((fragP
->tc_frag_data
.thumb_mode
& MODE_RECORDED
) == 0)
26825 fragP
->tc_frag_data
.thumb_mode
= thumb_mode
| MODE_RECORDED
;
26827 /* PR 21809: Do not set a mapping state for debug sections
26828 - it just confuses other tools. */
26829 if (bfd_section_flags (now_seg
) & SEC_DEBUGGING
)
26832 frag_thumb_mode
= fragP
->tc_frag_data
.thumb_mode
^ MODE_RECORDED
;
26834 /* Record a mapping symbol for alignment frags. We will delete this
26835 later if the alignment ends up empty. */
26836 switch (fragP
->fr_type
)
26839 case rs_align_test
:
26841 mapping_state_2 (MAP_DATA
, max_chars
);
26843 case rs_align_code
:
26844 mapping_state_2 (frag_thumb_mode
? MAP_THUMB
: MAP_ARM
, max_chars
);
26851 /* When we change sections we need to issue a new mapping symbol. */
26854 arm_elf_change_section (void)
26856 /* Link an unlinked unwind index table section to the .text section. */
26857 if (elf_section_type (now_seg
) == SHT_ARM_EXIDX
26858 && elf_linked_to_section (now_seg
) == NULL
)
26859 elf_linked_to_section (now_seg
) = text_section
;
26863 arm_elf_section_type (const char * str
, size_t len
)
26865 if (len
== 5 && strncmp (str
, "exidx", 5) == 0)
26866 return SHT_ARM_EXIDX
;
26871 /* Code to deal with unwinding tables. */
26873 static void add_unwind_adjustsp (offsetT
);
26875 /* Generate any deferred unwind frame offset. */
26878 flush_pending_unwind (void)
26882 offset
= unwind
.pending_offset
;
26883 unwind
.pending_offset
= 0;
26885 add_unwind_adjustsp (offset
);
26888 /* Add an opcode to this list for this function. Two-byte opcodes should
26889 be passed as op[0] << 8 | op[1]. The list of opcodes is built in reverse
26893 add_unwind_opcode (valueT op
, int length
)
26895 /* Add any deferred stack adjustment. */
26896 if (unwind
.pending_offset
)
26897 flush_pending_unwind ();
26899 unwind
.sp_restored
= 0;
26901 if (unwind
.opcode_count
+ length
> unwind
.opcode_alloc
)
26903 unwind
.opcode_alloc
+= ARM_OPCODE_CHUNK_SIZE
;
26904 if (unwind
.opcodes
)
26905 unwind
.opcodes
= XRESIZEVEC (unsigned char, unwind
.opcodes
,
26906 unwind
.opcode_alloc
);
26908 unwind
.opcodes
= XNEWVEC (unsigned char, unwind
.opcode_alloc
);
26913 unwind
.opcodes
[unwind
.opcode_count
] = op
& 0xff;
26915 unwind
.opcode_count
++;
26919 /* Add unwind opcodes to adjust the stack pointer. */
26922 add_unwind_adjustsp (offsetT offset
)
26926 if (offset
> 0x200)
26928 /* We need at most 5 bytes to hold a 32-bit value in a uleb128. */
26933 /* Long form: 0xb2, uleb128. */
26934 /* This might not fit in a word so add the individual bytes,
26935 remembering the list is built in reverse order. */
26936 o
= (valueT
) ((offset
- 0x204) >> 2);
26938 add_unwind_opcode (0, 1);
26940 /* Calculate the uleb128 encoding of the offset. */
26944 bytes
[n
] = o
& 0x7f;
26950 /* Add the insn. */
26952 add_unwind_opcode (bytes
[n
- 1], 1);
26953 add_unwind_opcode (0xb2, 1);
26955 else if (offset
> 0x100)
26957 /* Two short opcodes. */
26958 add_unwind_opcode (0x3f, 1);
26959 op
= (offset
- 0x104) >> 2;
26960 add_unwind_opcode (op
, 1);
26962 else if (offset
> 0)
26964 /* Short opcode. */
26965 op
= (offset
- 4) >> 2;
26966 add_unwind_opcode (op
, 1);
26968 else if (offset
< 0)
26971 while (offset
> 0x100)
26973 add_unwind_opcode (0x7f, 1);
26976 op
= ((offset
- 4) >> 2) | 0x40;
26977 add_unwind_opcode (op
, 1);
26981 /* Finish the list of unwind opcodes for this function. */
26984 finish_unwind_opcodes (void)
26988 if (unwind
.fp_used
)
26990 /* Adjust sp as necessary. */
26991 unwind
.pending_offset
+= unwind
.fp_offset
- unwind
.frame_size
;
26992 flush_pending_unwind ();
26994 /* After restoring sp from the frame pointer. */
26995 op
= 0x90 | unwind
.fp_reg
;
26996 add_unwind_opcode (op
, 1);
26999 flush_pending_unwind ();
27003 /* Start an exception table entry. If idx is nonzero this is an index table
27007 start_unwind_section (const segT text_seg
, int idx
)
27009 const char * text_name
;
27010 const char * prefix
;
27011 const char * prefix_once
;
27012 const char * group_name
;
27020 prefix
= ELF_STRING_ARM_unwind
;
27021 prefix_once
= ELF_STRING_ARM_unwind_once
;
27022 type
= SHT_ARM_EXIDX
;
27026 prefix
= ELF_STRING_ARM_unwind_info
;
27027 prefix_once
= ELF_STRING_ARM_unwind_info_once
;
27028 type
= SHT_PROGBITS
;
27031 text_name
= segment_name (text_seg
);
27032 if (streq (text_name
, ".text"))
27035 if (strncmp (text_name
, ".gnu.linkonce.t.",
27036 strlen (".gnu.linkonce.t.")) == 0)
27038 prefix
= prefix_once
;
27039 text_name
+= strlen (".gnu.linkonce.t.");
27042 sec_name
= concat (prefix
, text_name
, (char *) NULL
);
27048 /* Handle COMDAT group. */
27049 if (prefix
!= prefix_once
&& (text_seg
->flags
& SEC_LINK_ONCE
) != 0)
27051 group_name
= elf_group_name (text_seg
);
27052 if (group_name
== NULL
)
27054 as_bad (_("Group section `%s' has no group signature"),
27055 segment_name (text_seg
));
27056 ignore_rest_of_line ();
27059 flags
|= SHF_GROUP
;
27063 obj_elf_change_section (sec_name
, type
, 0, flags
, 0, group_name
,
27066 /* Set the section link for index tables. */
27068 elf_linked_to_section (now_seg
) = text_seg
;
27072 /* Start an unwind table entry. HAVE_DATA is nonzero if we have additional
27073 personality routine data. Returns zero, or the index table value for
27074 an inline entry. */
27077 create_unwind_entry (int have_data
)
27082 /* The current word of data. */
27084 /* The number of bytes left in this word. */
27087 finish_unwind_opcodes ();
27089 /* Remember the current text section. */
27090 unwind
.saved_seg
= now_seg
;
27091 unwind
.saved_subseg
= now_subseg
;
27093 start_unwind_section (now_seg
, 0);
27095 if (unwind
.personality_routine
== NULL
)
27097 if (unwind
.personality_index
== -2)
27100 as_bad (_("handlerdata in cantunwind frame"));
27101 return 1; /* EXIDX_CANTUNWIND. */
27104 /* Use a default personality routine if none is specified. */
27105 if (unwind
.personality_index
== -1)
27107 if (unwind
.opcode_count
> 3)
27108 unwind
.personality_index
= 1;
27110 unwind
.personality_index
= 0;
27113 /* Space for the personality routine entry. */
27114 if (unwind
.personality_index
== 0)
27116 if (unwind
.opcode_count
> 3)
27117 as_bad (_("too many unwind opcodes for personality routine 0"));
27121 /* All the data is inline in the index table. */
27124 while (unwind
.opcode_count
> 0)
27126 unwind
.opcode_count
--;
27127 data
= (data
<< 8) | unwind
.opcodes
[unwind
.opcode_count
];
27131 /* Pad with "finish" opcodes. */
27133 data
= (data
<< 8) | 0xb0;
27140 /* We get two opcodes "free" in the first word. */
27141 size
= unwind
.opcode_count
- 2;
27145 /* PR 16765: Missing or misplaced unwind directives can trigger this. */
27146 if (unwind
.personality_index
!= -1)
27148 as_bad (_("attempt to recreate an unwind entry"));
27152 /* An extra byte is required for the opcode count. */
27153 size
= unwind
.opcode_count
+ 1;
27156 size
= (size
+ 3) >> 2;
27158 as_bad (_("too many unwind opcodes"));
27160 frag_align (2, 0, 0);
27161 record_alignment (now_seg
, 2);
27162 unwind
.table_entry
= expr_build_dot ();
27164 /* Allocate the table entry. */
27165 ptr
= frag_more ((size
<< 2) + 4);
27166 /* PR 13449: Zero the table entries in case some of them are not used. */
27167 memset (ptr
, 0, (size
<< 2) + 4);
27168 where
= frag_now_fix () - ((size
<< 2) + 4);
27170 switch (unwind
.personality_index
)
27173 /* ??? Should this be a PLT generating relocation? */
27174 /* Custom personality routine. */
27175 fix_new (frag_now
, where
, 4, unwind
.personality_routine
, 0, 1,
27176 BFD_RELOC_ARM_PREL31
);
27181 /* Set the first byte to the number of additional words. */
27182 data
= size
> 0 ? size
- 1 : 0;
27186 /* ABI defined personality routines. */
27188 /* Three opcodes bytes are packed into the first word. */
27195 /* The size and first two opcode bytes go in the first word. */
27196 data
= ((0x80 + unwind
.personality_index
) << 8) | size
;
27201 /* Should never happen. */
27205 /* Pack the opcodes into words (MSB first), reversing the list at the same
27207 while (unwind
.opcode_count
> 0)
27211 md_number_to_chars (ptr
, data
, 4);
27216 unwind
.opcode_count
--;
27218 data
= (data
<< 8) | unwind
.opcodes
[unwind
.opcode_count
];
27221 /* Finish off the last word. */
27224 /* Pad with "finish" opcodes. */
27226 data
= (data
<< 8) | 0xb0;
27228 md_number_to_chars (ptr
, data
, 4);
27233 /* Add an empty descriptor if there is no user-specified data. */
27234 ptr
= frag_more (4);
27235 md_number_to_chars (ptr
, 0, 4);
27242 /* Initialize the DWARF-2 unwind information for this procedure. */
27245 tc_arm_frame_initial_instructions (void)
27247 cfi_add_CFA_def_cfa (REG_SP
, 0);
27249 #endif /* OBJ_ELF */
27251 /* Convert REGNAME to a DWARF-2 register number. */
27254 tc_arm_regname_to_dw2regnum (char *regname
)
27256 int reg
= arm_reg_parse (®name
, REG_TYPE_RN
);
27260 /* PR 16694: Allow VFP registers as well. */
27261 reg
= arm_reg_parse (®name
, REG_TYPE_VFS
);
27265 reg
= arm_reg_parse (®name
, REG_TYPE_VFD
);
27274 tc_pe_dwarf2_emit_offset (symbolS
*symbol
, unsigned int size
)
27278 exp
.X_op
= O_secrel
;
27279 exp
.X_add_symbol
= symbol
;
27280 exp
.X_add_number
= 0;
27281 emit_expr (&exp
, size
);
27285 /* MD interface: Symbol and relocation handling. */
27287 /* Return the address within the segment that a PC-relative fixup is
27288 relative to. For ARM, PC-relative fixups applied to instructions
27289 are generally relative to the location of the fixup plus 8 bytes.
27290 Thumb branches are offset by 4, and Thumb loads relative to PC
27291 require special handling. */
27294 md_pcrel_from_section (fixS
* fixP
, segT seg
)
27296 offsetT base
= fixP
->fx_where
+ fixP
->fx_frag
->fr_address
;
27298 /* If this is pc-relative and we are going to emit a relocation
27299 then we just want to put out any pipeline compensation that the linker
27300 will need. Otherwise we want to use the calculated base.
27301 For WinCE we skip the bias for externals as well, since this
27302 is how the MS ARM-CE assembler behaves and we want to be compatible. */
27304 && ((fixP
->fx_addsy
&& S_GET_SEGMENT (fixP
->fx_addsy
) != seg
)
27305 || (arm_force_relocation (fixP
)
27307 && !S_IS_EXTERNAL (fixP
->fx_addsy
)
27313 switch (fixP
->fx_r_type
)
27315 /* PC relative addressing on the Thumb is slightly odd as the
27316 bottom two bits of the PC are forced to zero for the
27317 calculation. This happens *after* application of the
27318 pipeline offset. However, Thumb adrl already adjusts for
27319 this, so we need not do it again. */
27320 case BFD_RELOC_ARM_THUMB_ADD
:
27323 case BFD_RELOC_ARM_THUMB_OFFSET
:
27324 case BFD_RELOC_ARM_T32_OFFSET_IMM
:
27325 case BFD_RELOC_ARM_T32_ADD_PC12
:
27326 case BFD_RELOC_ARM_T32_CP_OFF_IMM
:
27327 return (base
+ 4) & ~3;
27329 /* Thumb branches are simply offset by +4. */
27330 case BFD_RELOC_THUMB_PCREL_BRANCH5
:
27331 case BFD_RELOC_THUMB_PCREL_BRANCH7
:
27332 case BFD_RELOC_THUMB_PCREL_BRANCH9
:
27333 case BFD_RELOC_THUMB_PCREL_BRANCH12
:
27334 case BFD_RELOC_THUMB_PCREL_BRANCH20
:
27335 case BFD_RELOC_THUMB_PCREL_BRANCH25
:
27336 case BFD_RELOC_THUMB_PCREL_BFCSEL
:
27337 case BFD_RELOC_ARM_THUMB_BF17
:
27338 case BFD_RELOC_ARM_THUMB_BF19
:
27339 case BFD_RELOC_ARM_THUMB_BF13
:
27340 case BFD_RELOC_ARM_THUMB_LOOP12
:
27343 case BFD_RELOC_THUMB_PCREL_BRANCH23
:
27345 && (S_GET_SEGMENT (fixP
->fx_addsy
) == seg
)
27346 && !S_FORCE_RELOC (fixP
->fx_addsy
, TRUE
)
27347 && ARM_IS_FUNC (fixP
->fx_addsy
)
27348 && ARM_CPU_HAS_FEATURE (selected_cpu
, arm_ext_v5t
))
27349 base
= fixP
->fx_where
+ fixP
->fx_frag
->fr_address
;
27352 /* BLX is like branches above, but forces the low two bits of PC to
27354 case BFD_RELOC_THUMB_PCREL_BLX
:
27356 && (S_GET_SEGMENT (fixP
->fx_addsy
) == seg
)
27357 && !S_FORCE_RELOC (fixP
->fx_addsy
, TRUE
)
27358 && THUMB_IS_FUNC (fixP
->fx_addsy
)
27359 && ARM_CPU_HAS_FEATURE (selected_cpu
, arm_ext_v5t
))
27360 base
= fixP
->fx_where
+ fixP
->fx_frag
->fr_address
;
27361 return (base
+ 4) & ~3;
27363 /* ARM mode branches are offset by +8. However, the Windows CE
27364 loader expects the relocation not to take this into account. */
27365 case BFD_RELOC_ARM_PCREL_BLX
:
27367 && (S_GET_SEGMENT (fixP
->fx_addsy
) == seg
)
27368 && !S_FORCE_RELOC (fixP
->fx_addsy
, TRUE
)
27369 && ARM_IS_FUNC (fixP
->fx_addsy
)
27370 && ARM_CPU_HAS_FEATURE (selected_cpu
, arm_ext_v5t
))
27371 base
= fixP
->fx_where
+ fixP
->fx_frag
->fr_address
;
27374 case BFD_RELOC_ARM_PCREL_CALL
:
27376 && (S_GET_SEGMENT (fixP
->fx_addsy
) == seg
)
27377 && !S_FORCE_RELOC (fixP
->fx_addsy
, TRUE
)
27378 && THUMB_IS_FUNC (fixP
->fx_addsy
)
27379 && ARM_CPU_HAS_FEATURE (selected_cpu
, arm_ext_v5t
))
27380 base
= fixP
->fx_where
+ fixP
->fx_frag
->fr_address
;
27383 case BFD_RELOC_ARM_PCREL_BRANCH
:
27384 case BFD_RELOC_ARM_PCREL_JUMP
:
27385 case BFD_RELOC_ARM_PLT32
:
27387 /* When handling fixups immediately, because we have already
27388 discovered the value of a symbol, or the address of the frag involved
27389 we must account for the offset by +8, as the OS loader will never see the reloc.
27390 see fixup_segment() in write.c
27391 The S_IS_EXTERNAL test handles the case of global symbols.
27392 Those need the calculated base, not just the pipe compensation the linker will need. */
27394 && fixP
->fx_addsy
!= NULL
27395 && (S_GET_SEGMENT (fixP
->fx_addsy
) == seg
)
27396 && (S_IS_EXTERNAL (fixP
->fx_addsy
) || !arm_force_relocation (fixP
)))
27404 /* ARM mode loads relative to PC are also offset by +8. Unlike
27405 branches, the Windows CE loader *does* expect the relocation
27406 to take this into account. */
27407 case BFD_RELOC_ARM_OFFSET_IMM
:
27408 case BFD_RELOC_ARM_OFFSET_IMM8
:
27409 case BFD_RELOC_ARM_HWLITERAL
:
27410 case BFD_RELOC_ARM_LITERAL
:
27411 case BFD_RELOC_ARM_CP_OFF_IMM
:
27415 /* Other PC-relative relocations are un-offset. */
27421 static bfd_boolean flag_warn_syms
= TRUE
;
27424 arm_tc_equal_in_insn (int c ATTRIBUTE_UNUSED
, char * name
)
27426 /* PR 18347 - Warn if the user attempts to create a symbol with the same
27427 name as an ARM instruction. Whilst strictly speaking it is allowed, it
27428 does mean that the resulting code might be very confusing to the reader.
27429 Also this warning can be triggered if the user omits an operand before
27430 an immediate address, eg:
27434 GAS treats this as an assignment of the value of the symbol foo to a
27435 symbol LDR, and so (without this code) it will not issue any kind of
27436 warning or error message.
27438 Note - ARM instructions are case-insensitive but the strings in the hash
27439 table are all stored in lower case, so we must first ensure that name is
27441 if (flag_warn_syms
&& arm_ops_hsh
)
27443 char * nbuf
= strdup (name
);
27446 for (p
= nbuf
; *p
; p
++)
27448 if (hash_find (arm_ops_hsh
, nbuf
) != NULL
)
27450 static struct hash_control
* already_warned
= NULL
;
27452 if (already_warned
== NULL
)
27453 already_warned
= hash_new ();
27454 /* Only warn about the symbol once. To keep the code
27455 simple we let hash_insert do the lookup for us. */
27456 if (hash_insert (already_warned
, nbuf
, NULL
) == NULL
)
27457 as_warn (_("[-mwarn-syms]: Assignment makes a symbol match an ARM instruction: %s"), name
);
27466 /* Under ELF we need to default _GLOBAL_OFFSET_TABLE.
27467 Otherwise we have no need to default values of symbols. */
27470 md_undefined_symbol (char * name ATTRIBUTE_UNUSED
)
27473 if (name
[0] == '_' && name
[1] == 'G'
27474 && streq (name
, GLOBAL_OFFSET_TABLE_NAME
))
27478 if (symbol_find (name
))
27479 as_bad (_("GOT already in the symbol table"));
27481 GOT_symbol
= symbol_new (name
, undefined_section
,
27482 (valueT
) 0, & zero_address_frag
);
27492 /* Subroutine of md_apply_fix. Check to see if an immediate can be
27493 computed as two separate immediate values, added together. We
27494 already know that this value cannot be computed by just one ARM
27497 static unsigned int
27498 validate_immediate_twopart (unsigned int val
,
27499 unsigned int * highpart
)
27504 for (i
= 0; i
< 32; i
+= 2)
27505 if (((a
= rotate_left (val
, i
)) & 0xff) != 0)
27511 * highpart
= (a
>> 8) | ((i
+ 24) << 7);
27513 else if (a
& 0xff0000)
27515 if (a
& 0xff000000)
27517 * highpart
= (a
>> 16) | ((i
+ 16) << 7);
27521 gas_assert (a
& 0xff000000);
27522 * highpart
= (a
>> 24) | ((i
+ 8) << 7);
27525 return (a
& 0xff) | (i
<< 7);
27532 validate_offset_imm (unsigned int val
, int hwse
)
27534 if ((hwse
&& val
> 255) || val
> 4095)
27539 /* Subroutine of md_apply_fix. Do those data_ops which can take a
27540 negative immediate constant by altering the instruction. A bit of
27545 by inverting the second operand, and
27548 by negating the second operand. */
27551 negate_data_op (unsigned long * instruction
,
27552 unsigned long value
)
27555 unsigned long negated
, inverted
;
27557 negated
= encode_arm_immediate (-value
);
27558 inverted
= encode_arm_immediate (~value
);
27560 op
= (*instruction
>> DATA_OP_SHIFT
) & 0xf;
27563 /* First negates. */
27564 case OPCODE_SUB
: /* ADD <-> SUB */
27565 new_inst
= OPCODE_ADD
;
27570 new_inst
= OPCODE_SUB
;
27574 case OPCODE_CMP
: /* CMP <-> CMN */
27575 new_inst
= OPCODE_CMN
;
27580 new_inst
= OPCODE_CMP
;
27584 /* Now Inverted ops. */
27585 case OPCODE_MOV
: /* MOV <-> MVN */
27586 new_inst
= OPCODE_MVN
;
27591 new_inst
= OPCODE_MOV
;
27595 case OPCODE_AND
: /* AND <-> BIC */
27596 new_inst
= OPCODE_BIC
;
27601 new_inst
= OPCODE_AND
;
27605 case OPCODE_ADC
: /* ADC <-> SBC */
27606 new_inst
= OPCODE_SBC
;
27611 new_inst
= OPCODE_ADC
;
27615 /* We cannot do anything. */
27620 if (value
== (unsigned) FAIL
)
27623 *instruction
&= OPCODE_MASK
;
27624 *instruction
|= new_inst
<< DATA_OP_SHIFT
;
27628 /* Like negate_data_op, but for Thumb-2. */
27630 static unsigned int
27631 thumb32_negate_data_op (offsetT
*instruction
, unsigned int value
)
27635 unsigned int negated
, inverted
;
27637 negated
= encode_thumb32_immediate (-value
);
27638 inverted
= encode_thumb32_immediate (~value
);
27640 rd
= (*instruction
>> 8) & 0xf;
27641 op
= (*instruction
>> T2_DATA_OP_SHIFT
) & 0xf;
27644 /* ADD <-> SUB. Includes CMP <-> CMN. */
27645 case T2_OPCODE_SUB
:
27646 new_inst
= T2_OPCODE_ADD
;
27650 case T2_OPCODE_ADD
:
27651 new_inst
= T2_OPCODE_SUB
;
27655 /* ORR <-> ORN. Includes MOV <-> MVN. */
27656 case T2_OPCODE_ORR
:
27657 new_inst
= T2_OPCODE_ORN
;
27661 case T2_OPCODE_ORN
:
27662 new_inst
= T2_OPCODE_ORR
;
27666 /* AND <-> BIC. TST has no inverted equivalent. */
27667 case T2_OPCODE_AND
:
27668 new_inst
= T2_OPCODE_BIC
;
27675 case T2_OPCODE_BIC
:
27676 new_inst
= T2_OPCODE_AND
;
27681 case T2_OPCODE_ADC
:
27682 new_inst
= T2_OPCODE_SBC
;
27686 case T2_OPCODE_SBC
:
27687 new_inst
= T2_OPCODE_ADC
;
27691 /* We cannot do anything. */
27696 if (value
== (unsigned int)FAIL
)
27699 *instruction
&= T2_OPCODE_MASK
;
27700 *instruction
|= new_inst
<< T2_DATA_OP_SHIFT
;
27704 /* Read a 32-bit thumb instruction from buf. */
27706 static unsigned long
27707 get_thumb32_insn (char * buf
)
27709 unsigned long insn
;
27710 insn
= md_chars_to_number (buf
, THUMB_SIZE
) << 16;
27711 insn
|= md_chars_to_number (buf
+ THUMB_SIZE
, THUMB_SIZE
);
27716 /* We usually want to set the low bit on the address of thumb function
27717 symbols. In particular .word foo - . should have the low bit set.
27718 Generic code tries to fold the difference of two symbols to
27719 a constant. Prevent this and force a relocation when the first symbols
27720 is a thumb function. */
27723 arm_optimize_expr (expressionS
*l
, operatorT op
, expressionS
*r
)
27725 if (op
== O_subtract
27726 && l
->X_op
== O_symbol
27727 && r
->X_op
== O_symbol
27728 && THUMB_IS_FUNC (l
->X_add_symbol
))
27730 l
->X_op
= O_subtract
;
27731 l
->X_op_symbol
= r
->X_add_symbol
;
27732 l
->X_add_number
-= r
->X_add_number
;
27736 /* Process as normal. */
27740 /* Encode Thumb2 unconditional branches and calls. The encoding
27741 for the 2 are identical for the immediate values. */
27744 encode_thumb2_b_bl_offset (char * buf
, offsetT value
)
27746 #define T2I1I2MASK ((1 << 13) | (1 << 11))
27749 addressT S
, I1
, I2
, lo
, hi
;
27751 S
= (value
>> 24) & 0x01;
27752 I1
= (value
>> 23) & 0x01;
27753 I2
= (value
>> 22) & 0x01;
27754 hi
= (value
>> 12) & 0x3ff;
27755 lo
= (value
>> 1) & 0x7ff;
27756 newval
= md_chars_to_number (buf
, THUMB_SIZE
);
27757 newval2
= md_chars_to_number (buf
+ THUMB_SIZE
, THUMB_SIZE
);
27758 newval
|= (S
<< 10) | hi
;
27759 newval2
&= ~T2I1I2MASK
;
27760 newval2
|= (((I1
^ S
) << 13) | ((I2
^ S
) << 11) | lo
) ^ T2I1I2MASK
;
27761 md_number_to_chars (buf
, newval
, THUMB_SIZE
);
27762 md_number_to_chars (buf
+ THUMB_SIZE
, newval2
, THUMB_SIZE
);
27766 md_apply_fix (fixS
* fixP
,
27770 offsetT value
= * valP
;
27772 unsigned int newimm
;
27773 unsigned long temp
;
27775 char * buf
= fixP
->fx_where
+ fixP
->fx_frag
->fr_literal
;
27777 gas_assert (fixP
->fx_r_type
<= BFD_RELOC_UNUSED
);
27779 /* Note whether this will delete the relocation. */
27781 if (fixP
->fx_addsy
== 0 && !fixP
->fx_pcrel
)
27784 /* On a 64-bit host, silently truncate 'value' to 32 bits for
27785 consistency with the behaviour on 32-bit hosts. Remember value
27787 value
&= 0xffffffff;
27788 value
^= 0x80000000;
27789 value
-= 0x80000000;
27792 fixP
->fx_addnumber
= value
;
27794 /* Same treatment for fixP->fx_offset. */
27795 fixP
->fx_offset
&= 0xffffffff;
27796 fixP
->fx_offset
^= 0x80000000;
27797 fixP
->fx_offset
-= 0x80000000;
27799 switch (fixP
->fx_r_type
)
27801 case BFD_RELOC_NONE
:
27802 /* This will need to go in the object file. */
27806 case BFD_RELOC_ARM_IMMEDIATE
:
27807 /* We claim that this fixup has been processed here,
27808 even if in fact we generate an error because we do
27809 not have a reloc for it, so tc_gen_reloc will reject it. */
27812 if (fixP
->fx_addsy
)
27814 const char *msg
= 0;
27816 if (! S_IS_DEFINED (fixP
->fx_addsy
))
27817 msg
= _("undefined symbol %s used as an immediate value");
27818 else if (S_GET_SEGMENT (fixP
->fx_addsy
) != seg
)
27819 msg
= _("symbol %s is in a different section");
27820 else if (S_IS_WEAK (fixP
->fx_addsy
))
27821 msg
= _("symbol %s is weak and may be overridden later");
27825 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
27826 msg
, S_GET_NAME (fixP
->fx_addsy
));
27831 temp
= md_chars_to_number (buf
, INSN_SIZE
);
27833 /* If the offset is negative, we should use encoding A2 for ADR. */
27834 if ((temp
& 0xfff0000) == 0x28f0000 && value
< 0)
27835 newimm
= negate_data_op (&temp
, value
);
27838 newimm
= encode_arm_immediate (value
);
27840 /* If the instruction will fail, see if we can fix things up by
27841 changing the opcode. */
27842 if (newimm
== (unsigned int) FAIL
)
27843 newimm
= negate_data_op (&temp
, value
);
27844 /* MOV accepts both ARM modified immediate (A1 encoding) and
27845 UINT16 (A2 encoding) when possible, MOVW only accepts UINT16.
27846 When disassembling, MOV is preferred when there is no encoding
27848 if (newimm
== (unsigned int) FAIL
27849 && ((temp
>> DATA_OP_SHIFT
) & 0xf) == OPCODE_MOV
27850 && ARM_CPU_HAS_FEATURE (cpu_variant
, arm_ext_v6t2
)
27851 && !((temp
>> SBIT_SHIFT
) & 0x1)
27852 && value
>= 0 && value
<= 0xffff)
27854 /* Clear bits[23:20] to change encoding from A1 to A2. */
27855 temp
&= 0xff0fffff;
27856 /* Encoding high 4bits imm. Code below will encode the remaining
27858 temp
|= (value
& 0x0000f000) << 4;
27859 newimm
= value
& 0x00000fff;
27863 if (newimm
== (unsigned int) FAIL
)
27865 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
27866 _("invalid constant (%lx) after fixup"),
27867 (unsigned long) value
);
27871 newimm
|= (temp
& 0xfffff000);
27872 md_number_to_chars (buf
, (valueT
) newimm
, INSN_SIZE
);
27875 case BFD_RELOC_ARM_ADRL_IMMEDIATE
:
27877 unsigned int highpart
= 0;
27878 unsigned int newinsn
= 0xe1a00000; /* nop. */
27880 if (fixP
->fx_addsy
)
27882 const char *msg
= 0;
27884 if (! S_IS_DEFINED (fixP
->fx_addsy
))
27885 msg
= _("undefined symbol %s used as an immediate value");
27886 else if (S_GET_SEGMENT (fixP
->fx_addsy
) != seg
)
27887 msg
= _("symbol %s is in a different section");
27888 else if (S_IS_WEAK (fixP
->fx_addsy
))
27889 msg
= _("symbol %s is weak and may be overridden later");
27893 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
27894 msg
, S_GET_NAME (fixP
->fx_addsy
));
27899 newimm
= encode_arm_immediate (value
);
27900 temp
= md_chars_to_number (buf
, INSN_SIZE
);
27902 /* If the instruction will fail, see if we can fix things up by
27903 changing the opcode. */
27904 if (newimm
== (unsigned int) FAIL
27905 && (newimm
= negate_data_op (& temp
, value
)) == (unsigned int) FAIL
)
27907 /* No ? OK - try using two ADD instructions to generate
27909 newimm
= validate_immediate_twopart (value
, & highpart
);
27911 /* Yes - then make sure that the second instruction is
27913 if (newimm
!= (unsigned int) FAIL
)
27915 /* Still No ? Try using a negated value. */
27916 else if ((newimm
= validate_immediate_twopart (- value
, & highpart
)) != (unsigned int) FAIL
)
27917 temp
= newinsn
= (temp
& OPCODE_MASK
) | OPCODE_SUB
<< DATA_OP_SHIFT
;
27918 /* Otherwise - give up. */
27921 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
27922 _("unable to compute ADRL instructions for PC offset of 0x%lx"),
27927 /* Replace the first operand in the 2nd instruction (which
27928 is the PC) with the destination register. We have
27929 already added in the PC in the first instruction and we
27930 do not want to do it again. */
27931 newinsn
&= ~ 0xf0000;
27932 newinsn
|= ((newinsn
& 0x0f000) << 4);
27935 newimm
|= (temp
& 0xfffff000);
27936 md_number_to_chars (buf
, (valueT
) newimm
, INSN_SIZE
);
27938 highpart
|= (newinsn
& 0xfffff000);
27939 md_number_to_chars (buf
+ INSN_SIZE
, (valueT
) highpart
, INSN_SIZE
);
27943 case BFD_RELOC_ARM_OFFSET_IMM
:
27944 if (!fixP
->fx_done
&& seg
->use_rela_p
)
27946 /* Fall through. */
27948 case BFD_RELOC_ARM_LITERAL
:
27954 if (validate_offset_imm (value
, 0) == FAIL
)
27956 if (fixP
->fx_r_type
== BFD_RELOC_ARM_LITERAL
)
27957 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
27958 _("invalid literal constant: pool needs to be closer"));
27960 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
27961 _("bad immediate value for offset (%ld)"),
27966 newval
= md_chars_to_number (buf
, INSN_SIZE
);
27968 newval
&= 0xfffff000;
27971 newval
&= 0xff7ff000;
27972 newval
|= value
| (sign
? INDEX_UP
: 0);
27974 md_number_to_chars (buf
, newval
, INSN_SIZE
);
27977 case BFD_RELOC_ARM_OFFSET_IMM8
:
27978 case BFD_RELOC_ARM_HWLITERAL
:
27984 if (validate_offset_imm (value
, 1) == FAIL
)
27986 if (fixP
->fx_r_type
== BFD_RELOC_ARM_HWLITERAL
)
27987 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
27988 _("invalid literal constant: pool needs to be closer"));
27990 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
27991 _("bad immediate value for 8-bit offset (%ld)"),
27996 newval
= md_chars_to_number (buf
, INSN_SIZE
);
27998 newval
&= 0xfffff0f0;
28001 newval
&= 0xff7ff0f0;
28002 newval
|= ((value
>> 4) << 8) | (value
& 0xf) | (sign
? INDEX_UP
: 0);
28004 md_number_to_chars (buf
, newval
, INSN_SIZE
);
28007 case BFD_RELOC_ARM_T32_OFFSET_U8
:
28008 if (value
< 0 || value
> 1020 || value
% 4 != 0)
28009 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
28010 _("bad immediate value for offset (%ld)"), (long) value
);
28013 newval
= md_chars_to_number (buf
+2, THUMB_SIZE
);
28015 md_number_to_chars (buf
+2, newval
, THUMB_SIZE
);
28018 case BFD_RELOC_ARM_T32_OFFSET_IMM
:
28019 /* This is a complicated relocation used for all varieties of Thumb32
28020 load/store instruction with immediate offset:
28022 1110 100P u1WL NNNN XXXX YYYY iiii iiii - +/-(U) pre/post(P) 8-bit,
28023 *4, optional writeback(W)
28024 (doubleword load/store)
28026 1111 100S uTTL 1111 XXXX iiii iiii iiii - +/-(U) 12-bit PC-rel
28027 1111 100S 0TTL NNNN XXXX 1Pu1 iiii iiii - +/-(U) pre/post(P) 8-bit
28028 1111 100S 0TTL NNNN XXXX 1110 iiii iiii - positive 8-bit (T instruction)
28029 1111 100S 1TTL NNNN XXXX iiii iiii iiii - positive 12-bit
28030 1111 100S 0TTL NNNN XXXX 1100 iiii iiii - negative 8-bit
28032 Uppercase letters indicate bits that are already encoded at
28033 this point. Lowercase letters are our problem. For the
28034 second block of instructions, the secondary opcode nybble
28035 (bits 8..11) is present, and bit 23 is zero, even if this is
28036 a PC-relative operation. */
28037 newval
= md_chars_to_number (buf
, THUMB_SIZE
);
28039 newval
|= md_chars_to_number (buf
+THUMB_SIZE
, THUMB_SIZE
);
28041 if ((newval
& 0xf0000000) == 0xe0000000)
28043 /* Doubleword load/store: 8-bit offset, scaled by 4. */
28045 newval
|= (1 << 23);
28048 if (value
% 4 != 0)
28050 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
28051 _("offset not a multiple of 4"));
28057 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
28058 _("offset out of range"));
28063 else if ((newval
& 0x000f0000) == 0x000f0000)
28065 /* PC-relative, 12-bit offset. */
28067 newval
|= (1 << 23);
28072 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
28073 _("offset out of range"));
28078 else if ((newval
& 0x00000100) == 0x00000100)
28080 /* Writeback: 8-bit, +/- offset. */
28082 newval
|= (1 << 9);
28087 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
28088 _("offset out of range"));
28093 else if ((newval
& 0x00000f00) == 0x00000e00)
28095 /* T-instruction: positive 8-bit offset. */
28096 if (value
< 0 || value
> 0xff)
28098 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
28099 _("offset out of range"));
28107 /* Positive 12-bit or negative 8-bit offset. */
28111 newval
|= (1 << 23);
28121 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
28122 _("offset out of range"));
28129 md_number_to_chars (buf
, (newval
>> 16) & 0xffff, THUMB_SIZE
);
28130 md_number_to_chars (buf
+ THUMB_SIZE
, newval
& 0xffff, THUMB_SIZE
);
28133 case BFD_RELOC_ARM_SHIFT_IMM
:
28134 newval
= md_chars_to_number (buf
, INSN_SIZE
);
28135 if (((unsigned long) value
) > 32
28137 && (((newval
& 0x60) == 0) || (newval
& 0x60) == 0x60)))
28139 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
28140 _("shift expression is too large"));
28145 /* Shifts of zero must be done as lsl. */
28147 else if (value
== 32)
28149 newval
&= 0xfffff07f;
28150 newval
|= (value
& 0x1f) << 7;
28151 md_number_to_chars (buf
, newval
, INSN_SIZE
);
28154 case BFD_RELOC_ARM_T32_IMMEDIATE
:
28155 case BFD_RELOC_ARM_T32_ADD_IMM
:
28156 case BFD_RELOC_ARM_T32_IMM12
:
28157 case BFD_RELOC_ARM_T32_ADD_PC12
:
28158 /* We claim that this fixup has been processed here,
28159 even if in fact we generate an error because we do
28160 not have a reloc for it, so tc_gen_reloc will reject it. */
28164 && ! S_IS_DEFINED (fixP
->fx_addsy
))
28166 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
28167 _("undefined symbol %s used as an immediate value"),
28168 S_GET_NAME (fixP
->fx_addsy
));
28172 newval
= md_chars_to_number (buf
, THUMB_SIZE
);
28174 newval
|= md_chars_to_number (buf
+2, THUMB_SIZE
);
28177 if ((fixP
->fx_r_type
== BFD_RELOC_ARM_T32_IMMEDIATE
28178 /* ARMv8-M Baseline MOV will reach here, but it doesn't support
28179 Thumb2 modified immediate encoding (T2). */
28180 && ARM_CPU_HAS_FEATURE (cpu_variant
, arm_ext_v6t2
))
28181 || fixP
->fx_r_type
== BFD_RELOC_ARM_T32_ADD_IMM
)
28183 newimm
= encode_thumb32_immediate (value
);
28184 if (newimm
== (unsigned int) FAIL
)
28185 newimm
= thumb32_negate_data_op (&newval
, value
);
28187 if (newimm
== (unsigned int) FAIL
)
28189 if (fixP
->fx_r_type
!= BFD_RELOC_ARM_T32_IMMEDIATE
)
28191 /* Turn add/sum into addw/subw. */
28192 if (fixP
->fx_r_type
== BFD_RELOC_ARM_T32_ADD_IMM
)
28193 newval
= (newval
& 0xfeffffff) | 0x02000000;
28194 /* No flat 12-bit imm encoding for addsw/subsw. */
28195 if ((newval
& 0x00100000) == 0)
28197 /* 12 bit immediate for addw/subw. */
28201 newval
^= 0x00a00000;
28204 newimm
= (unsigned int) FAIL
;
28211 /* MOV accepts both Thumb2 modified immediate (T2 encoding) and
28212 UINT16 (T3 encoding), MOVW only accepts UINT16. When
28213 disassembling, MOV is preferred when there is no encoding
28215 if (((newval
>> T2_DATA_OP_SHIFT
) & 0xf) == T2_OPCODE_ORR
28216 /* NOTE: MOV uses the ORR opcode in Thumb 2 mode
28217 but with the Rn field [19:16] set to 1111. */
28218 && (((newval
>> 16) & 0xf) == 0xf)
28219 && ARM_CPU_HAS_FEATURE (cpu_variant
, arm_ext_v6t2_v8m
)
28220 && !((newval
>> T2_SBIT_SHIFT
) & 0x1)
28221 && value
>= 0 && value
<= 0xffff)
28223 /* Toggle bit[25] to change encoding from T2 to T3. */
28225 /* Clear bits[19:16]. */
28226 newval
&= 0xfff0ffff;
28227 /* Encoding high 4bits imm. Code below will encode the
28228 remaining low 12bits. */
28229 newval
|= (value
& 0x0000f000) << 4;
28230 newimm
= value
& 0x00000fff;
28235 if (newimm
== (unsigned int)FAIL
)
28237 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
28238 _("invalid constant (%lx) after fixup"),
28239 (unsigned long) value
);
28243 newval
|= (newimm
& 0x800) << 15;
28244 newval
|= (newimm
& 0x700) << 4;
28245 newval
|= (newimm
& 0x0ff);
28247 md_number_to_chars (buf
, (valueT
) ((newval
>> 16) & 0xffff), THUMB_SIZE
);
28248 md_number_to_chars (buf
+2, (valueT
) (newval
& 0xffff), THUMB_SIZE
);
28251 case BFD_RELOC_ARM_SMC
:
28252 if (((unsigned long) value
) > 0xf)
28253 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
28254 _("invalid smc expression"));
28256 newval
= md_chars_to_number (buf
, INSN_SIZE
);
28257 newval
|= (value
& 0xf);
28258 md_number_to_chars (buf
, newval
, INSN_SIZE
);
28261 case BFD_RELOC_ARM_HVC
:
28262 if (((unsigned long) value
) > 0xffff)
28263 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
28264 _("invalid hvc expression"));
28265 newval
= md_chars_to_number (buf
, INSN_SIZE
);
28266 newval
|= (value
& 0xf) | ((value
& 0xfff0) << 4);
28267 md_number_to_chars (buf
, newval
, INSN_SIZE
);
28270 case BFD_RELOC_ARM_SWI
:
28271 if (fixP
->tc_fix_data
!= 0)
28273 if (((unsigned long) value
) > 0xff)
28274 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
28275 _("invalid swi expression"));
28276 newval
= md_chars_to_number (buf
, THUMB_SIZE
);
28278 md_number_to_chars (buf
, newval
, THUMB_SIZE
);
28282 if (((unsigned long) value
) > 0x00ffffff)
28283 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
28284 _("invalid swi expression"));
28285 newval
= md_chars_to_number (buf
, INSN_SIZE
);
28287 md_number_to_chars (buf
, newval
, INSN_SIZE
);
28291 case BFD_RELOC_ARM_MULTI
:
28292 if (((unsigned long) value
) > 0xffff)
28293 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
28294 _("invalid expression in load/store multiple"));
28295 newval
= value
| md_chars_to_number (buf
, INSN_SIZE
);
28296 md_number_to_chars (buf
, newval
, INSN_SIZE
);
28300 case BFD_RELOC_ARM_PCREL_CALL
:
28302 if (ARM_CPU_HAS_FEATURE (selected_cpu
, arm_ext_v5t
)
28304 && !S_FORCE_RELOC (fixP
->fx_addsy
, TRUE
)
28305 && (S_GET_SEGMENT (fixP
->fx_addsy
) == seg
)
28306 && THUMB_IS_FUNC (fixP
->fx_addsy
))
28307 /* Flip the bl to blx. This is a simple flip
28308 bit here because we generate PCREL_CALL for
28309 unconditional bls. */
28311 newval
= md_chars_to_number (buf
, INSN_SIZE
);
28312 newval
= newval
| 0x10000000;
28313 md_number_to_chars (buf
, newval
, INSN_SIZE
);
28319 goto arm_branch_common
;
28321 case BFD_RELOC_ARM_PCREL_JUMP
:
28322 if (ARM_CPU_HAS_FEATURE (selected_cpu
, arm_ext_v5t
)
28324 && !S_FORCE_RELOC (fixP
->fx_addsy
, TRUE
)
28325 && (S_GET_SEGMENT (fixP
->fx_addsy
) == seg
)
28326 && THUMB_IS_FUNC (fixP
->fx_addsy
))
28328 /* This would map to a bl<cond>, b<cond>,
28329 b<always> to a Thumb function. We
28330 need to force a relocation for this particular
28332 newval
= md_chars_to_number (buf
, INSN_SIZE
);
28335 /* Fall through. */
28337 case BFD_RELOC_ARM_PLT32
:
28339 case BFD_RELOC_ARM_PCREL_BRANCH
:
28341 goto arm_branch_common
;
28343 case BFD_RELOC_ARM_PCREL_BLX
:
28346 if (ARM_CPU_HAS_FEATURE (selected_cpu
, arm_ext_v5t
)
28348 && !S_FORCE_RELOC (fixP
->fx_addsy
, TRUE
)
28349 && (S_GET_SEGMENT (fixP
->fx_addsy
) == seg
)
28350 && ARM_IS_FUNC (fixP
->fx_addsy
))
28352 /* Flip the blx to a bl and warn. */
28353 const char *name
= S_GET_NAME (fixP
->fx_addsy
);
28354 newval
= 0xeb000000;
28355 as_warn_where (fixP
->fx_file
, fixP
->fx_line
,
28356 _("blx to '%s' an ARM ISA state function changed to bl"),
28358 md_number_to_chars (buf
, newval
, INSN_SIZE
);
28364 if (EF_ARM_EABI_VERSION (meabi_flags
) >= EF_ARM_EABI_VER4
)
28365 fixP
->fx_r_type
= BFD_RELOC_ARM_PCREL_CALL
;
28369 /* We are going to store value (shifted right by two) in the
28370 instruction, in a 24 bit, signed field. Bits 26 through 32 either
28371 all clear or all set and bit 0 must be clear. For B/BL bit 1 must
28374 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
28375 _("misaligned branch destination"));
28376 if ((value
& (offsetT
)0xfe000000) != (offsetT
)0
28377 && (value
& (offsetT
)0xfe000000) != (offsetT
)0xfe000000)
28378 as_bad_where (fixP
->fx_file
, fixP
->fx_line
, BAD_RANGE
);
28380 if (fixP
->fx_done
|| !seg
->use_rela_p
)
28382 newval
= md_chars_to_number (buf
, INSN_SIZE
);
28383 newval
|= (value
>> 2) & 0x00ffffff;
28384 /* Set the H bit on BLX instructions. */
28388 newval
|= 0x01000000;
28390 newval
&= ~0x01000000;
28392 md_number_to_chars (buf
, newval
, INSN_SIZE
);
28396 case BFD_RELOC_THUMB_PCREL_BRANCH7
: /* CBZ */
28397 /* CBZ can only branch forward. */
28399 /* Attempts to use CBZ to branch to the next instruction
28400 (which, strictly speaking, are prohibited) will be turned into
28403 FIXME: It may be better to remove the instruction completely and
28404 perform relaxation. */
28407 newval
= md_chars_to_number (buf
, THUMB_SIZE
);
28408 newval
= 0xbf00; /* NOP encoding T1 */
28409 md_number_to_chars (buf
, newval
, THUMB_SIZE
);
28414 as_bad_where (fixP
->fx_file
, fixP
->fx_line
, BAD_RANGE
);
28416 if (fixP
->fx_done
|| !seg
->use_rela_p
)
28418 newval
= md_chars_to_number (buf
, THUMB_SIZE
);
28419 newval
|= ((value
& 0x3e) << 2) | ((value
& 0x40) << 3);
28420 md_number_to_chars (buf
, newval
, THUMB_SIZE
);
28425 case BFD_RELOC_THUMB_PCREL_BRANCH9
: /* Conditional branch. */
28426 if (out_of_range_p (value
, 8))
28427 as_bad_where (fixP
->fx_file
, fixP
->fx_line
, BAD_RANGE
);
28429 if (fixP
->fx_done
|| !seg
->use_rela_p
)
28431 newval
= md_chars_to_number (buf
, THUMB_SIZE
);
28432 newval
|= (value
& 0x1ff) >> 1;
28433 md_number_to_chars (buf
, newval
, THUMB_SIZE
);
28437 case BFD_RELOC_THUMB_PCREL_BRANCH12
: /* Unconditional branch. */
28438 if (out_of_range_p (value
, 11))
28439 as_bad_where (fixP
->fx_file
, fixP
->fx_line
, BAD_RANGE
);
28441 if (fixP
->fx_done
|| !seg
->use_rela_p
)
28443 newval
= md_chars_to_number (buf
, THUMB_SIZE
);
28444 newval
|= (value
& 0xfff) >> 1;
28445 md_number_to_chars (buf
, newval
, THUMB_SIZE
);
28449 /* This relocation is misnamed, it should be BRANCH21. */
28450 case BFD_RELOC_THUMB_PCREL_BRANCH20
:
28452 && (S_GET_SEGMENT (fixP
->fx_addsy
) == seg
)
28453 && !S_FORCE_RELOC (fixP
->fx_addsy
, TRUE
)
28454 && ARM_IS_FUNC (fixP
->fx_addsy
)
28455 && ARM_CPU_HAS_FEATURE (selected_cpu
, arm_ext_v5t
))
28457 /* Force a relocation for a branch 20 bits wide. */
28460 if (out_of_range_p (value
, 20))
28461 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
28462 _("conditional branch out of range"));
28464 if (fixP
->fx_done
|| !seg
->use_rela_p
)
28467 addressT S
, J1
, J2
, lo
, hi
;
28469 S
= (value
& 0x00100000) >> 20;
28470 J2
= (value
& 0x00080000) >> 19;
28471 J1
= (value
& 0x00040000) >> 18;
28472 hi
= (value
& 0x0003f000) >> 12;
28473 lo
= (value
& 0x00000ffe) >> 1;
28475 newval
= md_chars_to_number (buf
, THUMB_SIZE
);
28476 newval2
= md_chars_to_number (buf
+ THUMB_SIZE
, THUMB_SIZE
);
28477 newval
|= (S
<< 10) | hi
;
28478 newval2
|= (J1
<< 13) | (J2
<< 11) | lo
;
28479 md_number_to_chars (buf
, newval
, THUMB_SIZE
);
28480 md_number_to_chars (buf
+ THUMB_SIZE
, newval2
, THUMB_SIZE
);
28484 case BFD_RELOC_THUMB_PCREL_BLX
:
28485 /* If there is a blx from a thumb state function to
28486 another thumb function flip this to a bl and warn
28490 && !S_FORCE_RELOC (fixP
->fx_addsy
, TRUE
)
28491 && (S_GET_SEGMENT (fixP
->fx_addsy
) == seg
)
28492 && THUMB_IS_FUNC (fixP
->fx_addsy
))
28494 const char *name
= S_GET_NAME (fixP
->fx_addsy
);
28495 as_warn_where (fixP
->fx_file
, fixP
->fx_line
,
28496 _("blx to Thumb func '%s' from Thumb ISA state changed to bl"),
28498 newval
= md_chars_to_number (buf
+ THUMB_SIZE
, THUMB_SIZE
);
28499 newval
= newval
| 0x1000;
28500 md_number_to_chars (buf
+THUMB_SIZE
, newval
, THUMB_SIZE
);
28501 fixP
->fx_r_type
= BFD_RELOC_THUMB_PCREL_BRANCH23
;
28506 goto thumb_bl_common
;
28508 case BFD_RELOC_THUMB_PCREL_BRANCH23
:
28509 /* A bl from Thumb state ISA to an internal ARM state function
28510 is converted to a blx. */
28512 && (S_GET_SEGMENT (fixP
->fx_addsy
) == seg
)
28513 && !S_FORCE_RELOC (fixP
->fx_addsy
, TRUE
)
28514 && ARM_IS_FUNC (fixP
->fx_addsy
)
28515 && ARM_CPU_HAS_FEATURE (selected_cpu
, arm_ext_v5t
))
28517 newval
= md_chars_to_number (buf
+ THUMB_SIZE
, THUMB_SIZE
);
28518 newval
= newval
& ~0x1000;
28519 md_number_to_chars (buf
+THUMB_SIZE
, newval
, THUMB_SIZE
);
28520 fixP
->fx_r_type
= BFD_RELOC_THUMB_PCREL_BLX
;
28526 if (fixP
->fx_r_type
== BFD_RELOC_THUMB_PCREL_BLX
)
28527 /* For a BLX instruction, make sure that the relocation is rounded up
28528 to a word boundary. This follows the semantics of the instruction
28529 which specifies that bit 1 of the target address will come from bit
28530 1 of the base address. */
28531 value
= (value
+ 3) & ~ 3;
28534 if (EF_ARM_EABI_VERSION (meabi_flags
) >= EF_ARM_EABI_VER4
28535 && fixP
->fx_r_type
== BFD_RELOC_THUMB_PCREL_BLX
)
28536 fixP
->fx_r_type
= BFD_RELOC_THUMB_PCREL_BRANCH23
;
28539 if (out_of_range_p (value
, 22))
28541 if (!(ARM_CPU_HAS_FEATURE (cpu_variant
, arm_ext_v6t2
)))
28542 as_bad_where (fixP
->fx_file
, fixP
->fx_line
, BAD_RANGE
);
28543 else if (out_of_range_p (value
, 24))
28544 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
28545 _("Thumb2 branch out of range"));
28548 if (fixP
->fx_done
|| !seg
->use_rela_p
)
28549 encode_thumb2_b_bl_offset (buf
, value
);
28553 case BFD_RELOC_THUMB_PCREL_BRANCH25
:
28554 if (out_of_range_p (value
, 24))
28555 as_bad_where (fixP
->fx_file
, fixP
->fx_line
, BAD_RANGE
);
28557 if (fixP
->fx_done
|| !seg
->use_rela_p
)
28558 encode_thumb2_b_bl_offset (buf
, value
);
28563 if (fixP
->fx_done
|| !seg
->use_rela_p
)
28568 if (fixP
->fx_done
|| !seg
->use_rela_p
)
28569 md_number_to_chars (buf
, value
, 2);
28573 case BFD_RELOC_ARM_TLS_CALL
:
28574 case BFD_RELOC_ARM_THM_TLS_CALL
:
28575 case BFD_RELOC_ARM_TLS_DESCSEQ
:
28576 case BFD_RELOC_ARM_THM_TLS_DESCSEQ
:
28577 case BFD_RELOC_ARM_TLS_GOTDESC
:
28578 case BFD_RELOC_ARM_TLS_GD32
:
28579 case BFD_RELOC_ARM_TLS_LE32
:
28580 case BFD_RELOC_ARM_TLS_IE32
:
28581 case BFD_RELOC_ARM_TLS_LDM32
:
28582 case BFD_RELOC_ARM_TLS_LDO32
:
28583 S_SET_THREAD_LOCAL (fixP
->fx_addsy
);
28586 /* Same handling as above, but with the arm_fdpic guard. */
28587 case BFD_RELOC_ARM_TLS_GD32_FDPIC
:
28588 case BFD_RELOC_ARM_TLS_IE32_FDPIC
:
28589 case BFD_RELOC_ARM_TLS_LDM32_FDPIC
:
28592 S_SET_THREAD_LOCAL (fixP
->fx_addsy
);
28596 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
28597 _("Relocation supported only in FDPIC mode"));
28601 case BFD_RELOC_ARM_GOT32
:
28602 case BFD_RELOC_ARM_GOTOFF
:
28605 case BFD_RELOC_ARM_GOT_PREL
:
28606 if (fixP
->fx_done
|| !seg
->use_rela_p
)
28607 md_number_to_chars (buf
, value
, 4);
28610 case BFD_RELOC_ARM_TARGET2
:
28611 /* TARGET2 is not partial-inplace, so we need to write the
28612 addend here for REL targets, because it won't be written out
28613 during reloc processing later. */
28614 if (fixP
->fx_done
|| !seg
->use_rela_p
)
28615 md_number_to_chars (buf
, fixP
->fx_offset
, 4);
28618 /* Relocations for FDPIC. */
28619 case BFD_RELOC_ARM_GOTFUNCDESC
:
28620 case BFD_RELOC_ARM_GOTOFFFUNCDESC
:
28621 case BFD_RELOC_ARM_FUNCDESC
:
28624 if (fixP
->fx_done
|| !seg
->use_rela_p
)
28625 md_number_to_chars (buf
, 0, 4);
28629 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
28630 _("Relocation supported only in FDPIC mode"));
28635 case BFD_RELOC_RVA
:
28637 case BFD_RELOC_ARM_TARGET1
:
28638 case BFD_RELOC_ARM_ROSEGREL32
:
28639 case BFD_RELOC_ARM_SBREL32
:
28640 case BFD_RELOC_32_PCREL
:
28642 case BFD_RELOC_32_SECREL
:
28644 if (fixP
->fx_done
|| !seg
->use_rela_p
)
28646 /* For WinCE we only do this for pcrel fixups. */
28647 if (fixP
->fx_done
|| fixP
->fx_pcrel
)
28649 md_number_to_chars (buf
, value
, 4);
28653 case BFD_RELOC_ARM_PREL31
:
28654 if (fixP
->fx_done
|| !seg
->use_rela_p
)
28656 newval
= md_chars_to_number (buf
, 4) & 0x80000000;
28657 if ((value
^ (value
>> 1)) & 0x40000000)
28659 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
28660 _("rel31 relocation overflow"));
28662 newval
|= value
& 0x7fffffff;
28663 md_number_to_chars (buf
, newval
, 4);
28668 case BFD_RELOC_ARM_CP_OFF_IMM
:
28669 case BFD_RELOC_ARM_T32_CP_OFF_IMM
:
28670 case BFD_RELOC_ARM_T32_VLDR_VSTR_OFF_IMM
:
28671 if (fixP
->fx_r_type
== BFD_RELOC_ARM_CP_OFF_IMM
)
28672 newval
= md_chars_to_number (buf
, INSN_SIZE
);
28674 newval
= get_thumb32_insn (buf
);
28675 if ((newval
& 0x0f200f00) == 0x0d000900)
28677 /* This is a fp16 vstr/vldr. The immediate offset in the mnemonic
28678 has permitted values that are multiples of 2, in the range 0
28680 if (value
< -510 || value
> 510 || (value
& 1))
28681 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
28682 _("co-processor offset out of range"));
28684 else if ((newval
& 0xfe001f80) == 0xec000f80)
28686 if (value
< -511 || value
> 512 || (value
& 3))
28687 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
28688 _("co-processor offset out of range"));
28690 else if (value
< -1023 || value
> 1023 || (value
& 3))
28691 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
28692 _("co-processor offset out of range"));
28697 if (fixP
->fx_r_type
== BFD_RELOC_ARM_CP_OFF_IMM
28698 || fixP
->fx_r_type
== BFD_RELOC_ARM_CP_OFF_IMM_S2
)
28699 newval
= md_chars_to_number (buf
, INSN_SIZE
);
28701 newval
= get_thumb32_insn (buf
);
28704 if (fixP
->fx_r_type
== BFD_RELOC_ARM_T32_VLDR_VSTR_OFF_IMM
)
28705 newval
&= 0xffffff80;
28707 newval
&= 0xffffff00;
28711 if (fixP
->fx_r_type
== BFD_RELOC_ARM_T32_VLDR_VSTR_OFF_IMM
)
28712 newval
&= 0xff7fff80;
28714 newval
&= 0xff7fff00;
28715 if ((newval
& 0x0f200f00) == 0x0d000900)
28717 /* This is a fp16 vstr/vldr.
28719 It requires the immediate offset in the instruction is shifted
28720 left by 1 to be a half-word offset.
28722 Here, left shift by 1 first, and later right shift by 2
28723 should get the right offset. */
28726 newval
|= (value
>> 2) | (sign
? INDEX_UP
: 0);
28728 if (fixP
->fx_r_type
== BFD_RELOC_ARM_CP_OFF_IMM
28729 || fixP
->fx_r_type
== BFD_RELOC_ARM_CP_OFF_IMM_S2
)
28730 md_number_to_chars (buf
, newval
, INSN_SIZE
);
28732 put_thumb32_insn (buf
, newval
);
28735 case BFD_RELOC_ARM_CP_OFF_IMM_S2
:
28736 case BFD_RELOC_ARM_T32_CP_OFF_IMM_S2
:
28737 if (value
< -255 || value
> 255)
28738 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
28739 _("co-processor offset out of range"));
28741 goto cp_off_common
;
28743 case BFD_RELOC_ARM_THUMB_OFFSET
:
28744 newval
= md_chars_to_number (buf
, THUMB_SIZE
);
28745 /* Exactly what ranges, and where the offset is inserted depends
28746 on the type of instruction, we can establish this from the
28748 switch (newval
>> 12)
28750 case 4: /* PC load. */
28751 /* Thumb PC loads are somewhat odd, bit 1 of the PC is
28752 forced to zero for these loads; md_pcrel_from has already
28753 compensated for this. */
28755 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
28756 _("invalid offset, target not word aligned (0x%08lX)"),
28757 (((unsigned long) fixP
->fx_frag
->fr_address
28758 + (unsigned long) fixP
->fx_where
) & ~3)
28759 + (unsigned long) value
);
28761 if (value
& ~0x3fc)
28762 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
28763 _("invalid offset, value too big (0x%08lX)"),
28766 newval
|= value
>> 2;
28769 case 9: /* SP load/store. */
28770 if (value
& ~0x3fc)
28771 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
28772 _("invalid offset, value too big (0x%08lX)"),
28774 newval
|= value
>> 2;
28777 case 6: /* Word load/store. */
28779 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
28780 _("invalid offset, value too big (0x%08lX)"),
28782 newval
|= value
<< 4; /* 6 - 2. */
28785 case 7: /* Byte load/store. */
28787 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
28788 _("invalid offset, value too big (0x%08lX)"),
28790 newval
|= value
<< 6;
28793 case 8: /* Halfword load/store. */
28795 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
28796 _("invalid offset, value too big (0x%08lX)"),
28798 newval
|= value
<< 5; /* 6 - 1. */
28802 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
28803 "Unable to process relocation for thumb opcode: %lx",
28804 (unsigned long) newval
);
28807 md_number_to_chars (buf
, newval
, THUMB_SIZE
);
28810 case BFD_RELOC_ARM_THUMB_ADD
:
28811 /* This is a complicated relocation, since we use it for all of
28812 the following immediate relocations:
28816 9bit ADD/SUB SP word-aligned
28817 10bit ADD PC/SP word-aligned
28819 The type of instruction being processed is encoded in the
28826 newval
= md_chars_to_number (buf
, THUMB_SIZE
);
28828 int rd
= (newval
>> 4) & 0xf;
28829 int rs
= newval
& 0xf;
28830 int subtract
= !!(newval
& 0x8000);
28832 /* Check for HI regs, only very restricted cases allowed:
28833 Adjusting SP, and using PC or SP to get an address. */
28834 if ((rd
> 7 && (rd
!= REG_SP
|| rs
!= REG_SP
))
28835 || (rs
> 7 && rs
!= REG_SP
&& rs
!= REG_PC
))
28836 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
28837 _("invalid Hi register with immediate"));
28839 /* If value is negative, choose the opposite instruction. */
28843 subtract
= !subtract
;
28845 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
28846 _("immediate value out of range"));
28851 if (value
& ~0x1fc)
28852 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
28853 _("invalid immediate for stack address calculation"));
28854 newval
= subtract
? T_OPCODE_SUB_ST
: T_OPCODE_ADD_ST
;
28855 newval
|= value
>> 2;
28857 else if (rs
== REG_PC
|| rs
== REG_SP
)
28859 /* PR gas/18541. If the addition is for a defined symbol
28860 within range of an ADR instruction then accept it. */
28863 && fixP
->fx_addsy
!= NULL
)
28867 if (! S_IS_DEFINED (fixP
->fx_addsy
)
28868 || S_GET_SEGMENT (fixP
->fx_addsy
) != seg
28869 || S_IS_WEAK (fixP
->fx_addsy
))
28871 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
28872 _("address calculation needs a strongly defined nearby symbol"));
28876 offsetT v
= fixP
->fx_where
+ fixP
->fx_frag
->fr_address
;
28878 /* Round up to the next 4-byte boundary. */
28883 v
= S_GET_VALUE (fixP
->fx_addsy
) - v
;
28887 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
28888 _("symbol too far away"));
28898 if (subtract
|| value
& ~0x3fc)
28899 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
28900 _("invalid immediate for address calculation (value = 0x%08lX)"),
28901 (unsigned long) (subtract
? - value
: value
));
28902 newval
= (rs
== REG_PC
? T_OPCODE_ADD_PC
: T_OPCODE_ADD_SP
);
28904 newval
|= value
>> 2;
28909 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
28910 _("immediate value out of range"));
28911 newval
= subtract
? T_OPCODE_SUB_I8
: T_OPCODE_ADD_I8
;
28912 newval
|= (rd
<< 8) | value
;
28917 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
28918 _("immediate value out of range"));
28919 newval
= subtract
? T_OPCODE_SUB_I3
: T_OPCODE_ADD_I3
;
28920 newval
|= rd
| (rs
<< 3) | (value
<< 6);
28923 md_number_to_chars (buf
, newval
, THUMB_SIZE
);
28926 case BFD_RELOC_ARM_THUMB_IMM
:
28927 newval
= md_chars_to_number (buf
, THUMB_SIZE
);
28928 if (value
< 0 || value
> 255)
28929 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
28930 _("invalid immediate: %ld is out of range"),
28933 md_number_to_chars (buf
, newval
, THUMB_SIZE
);
28936 case BFD_RELOC_ARM_THUMB_SHIFT
:
28937 /* 5bit shift value (0..32). LSL cannot take 32. */
28938 newval
= md_chars_to_number (buf
, THUMB_SIZE
) & 0xf83f;
28939 temp
= newval
& 0xf800;
28940 if (value
< 0 || value
> 32 || (value
== 32 && temp
== T_OPCODE_LSL_I
))
28941 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
28942 _("invalid shift value: %ld"), (long) value
);
28943 /* Shifts of zero must be encoded as LSL. */
28945 newval
= (newval
& 0x003f) | T_OPCODE_LSL_I
;
28946 /* Shifts of 32 are encoded as zero. */
28947 else if (value
== 32)
28949 newval
|= value
<< 6;
28950 md_number_to_chars (buf
, newval
, THUMB_SIZE
);
28953 case BFD_RELOC_VTABLE_INHERIT
:
28954 case BFD_RELOC_VTABLE_ENTRY
:
28958 case BFD_RELOC_ARM_MOVW
:
28959 case BFD_RELOC_ARM_MOVT
:
28960 case BFD_RELOC_ARM_THUMB_MOVW
:
28961 case BFD_RELOC_ARM_THUMB_MOVT
:
28962 if (fixP
->fx_done
|| !seg
->use_rela_p
)
28964 /* REL format relocations are limited to a 16-bit addend. */
28965 if (!fixP
->fx_done
)
28967 if (value
< -0x8000 || value
> 0x7fff)
28968 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
28969 _("offset out of range"));
28971 else if (fixP
->fx_r_type
== BFD_RELOC_ARM_MOVT
28972 || fixP
->fx_r_type
== BFD_RELOC_ARM_THUMB_MOVT
)
28977 if (fixP
->fx_r_type
== BFD_RELOC_ARM_THUMB_MOVW
28978 || fixP
->fx_r_type
== BFD_RELOC_ARM_THUMB_MOVT
)
28980 newval
= get_thumb32_insn (buf
);
28981 newval
&= 0xfbf08f00;
28982 newval
|= (value
& 0xf000) << 4;
28983 newval
|= (value
& 0x0800) << 15;
28984 newval
|= (value
& 0x0700) << 4;
28985 newval
|= (value
& 0x00ff);
28986 put_thumb32_insn (buf
, newval
);
28990 newval
= md_chars_to_number (buf
, 4);
28991 newval
&= 0xfff0f000;
28992 newval
|= value
& 0x0fff;
28993 newval
|= (value
& 0xf000) << 4;
28994 md_number_to_chars (buf
, newval
, 4);
28999 case BFD_RELOC_ARM_THUMB_ALU_ABS_G0_NC
:
29000 case BFD_RELOC_ARM_THUMB_ALU_ABS_G1_NC
:
29001 case BFD_RELOC_ARM_THUMB_ALU_ABS_G2_NC
:
29002 case BFD_RELOC_ARM_THUMB_ALU_ABS_G3_NC
:
29003 gas_assert (!fixP
->fx_done
);
29006 bfd_boolean is_mov
;
29007 bfd_vma encoded_addend
= value
;
29009 /* Check that addend can be encoded in instruction. */
29010 if (!seg
->use_rela_p
&& (value
< 0 || value
> 255))
29011 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
29012 _("the offset 0x%08lX is not representable"),
29013 (unsigned long) encoded_addend
);
29015 /* Extract the instruction. */
29016 insn
= md_chars_to_number (buf
, THUMB_SIZE
);
29017 is_mov
= (insn
& 0xf800) == 0x2000;
29022 if (!seg
->use_rela_p
)
29023 insn
|= encoded_addend
;
29029 /* Extract the instruction. */
29030 /* Encoding is the following
29035 /* The following conditions must be true :
29040 rd
= (insn
>> 4) & 0xf;
29042 if ((insn
& 0x8000) || (rd
!= rs
) || rd
> 7)
29043 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
29044 _("Unable to process relocation for thumb opcode: %lx"),
29045 (unsigned long) insn
);
29047 /* Encode as ADD immediate8 thumb 1 code. */
29048 insn
= 0x3000 | (rd
<< 8);
29050 /* Place the encoded addend into the first 8 bits of the
29052 if (!seg
->use_rela_p
)
29053 insn
|= encoded_addend
;
29056 /* Update the instruction. */
29057 md_number_to_chars (buf
, insn
, THUMB_SIZE
);
29061 case BFD_RELOC_ARM_ALU_PC_G0_NC
:
29062 case BFD_RELOC_ARM_ALU_PC_G0
:
29063 case BFD_RELOC_ARM_ALU_PC_G1_NC
:
29064 case BFD_RELOC_ARM_ALU_PC_G1
:
29065 case BFD_RELOC_ARM_ALU_PC_G2
:
29066 case BFD_RELOC_ARM_ALU_SB_G0_NC
:
29067 case BFD_RELOC_ARM_ALU_SB_G0
:
29068 case BFD_RELOC_ARM_ALU_SB_G1_NC
:
29069 case BFD_RELOC_ARM_ALU_SB_G1
:
29070 case BFD_RELOC_ARM_ALU_SB_G2
:
29071 gas_assert (!fixP
->fx_done
);
29072 if (!seg
->use_rela_p
)
29075 bfd_vma encoded_addend
;
29076 bfd_vma addend_abs
= llabs (value
);
29078 /* Check that the absolute value of the addend can be
29079 expressed as an 8-bit constant plus a rotation. */
29080 encoded_addend
= encode_arm_immediate (addend_abs
);
29081 if (encoded_addend
== (unsigned int) FAIL
)
29082 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
29083 _("the offset 0x%08lX is not representable"),
29084 (unsigned long) addend_abs
);
29086 /* Extract the instruction. */
29087 insn
= md_chars_to_number (buf
, INSN_SIZE
);
29089 /* If the addend is positive, use an ADD instruction.
29090 Otherwise use a SUB. Take care not to destroy the S bit. */
29091 insn
&= 0xff1fffff;
29097 /* Place the encoded addend into the first 12 bits of the
29099 insn
&= 0xfffff000;
29100 insn
|= encoded_addend
;
29102 /* Update the instruction. */
29103 md_number_to_chars (buf
, insn
, INSN_SIZE
);
29107 case BFD_RELOC_ARM_LDR_PC_G0
:
29108 case BFD_RELOC_ARM_LDR_PC_G1
:
29109 case BFD_RELOC_ARM_LDR_PC_G2
:
29110 case BFD_RELOC_ARM_LDR_SB_G0
:
29111 case BFD_RELOC_ARM_LDR_SB_G1
:
29112 case BFD_RELOC_ARM_LDR_SB_G2
:
29113 gas_assert (!fixP
->fx_done
);
29114 if (!seg
->use_rela_p
)
29117 bfd_vma addend_abs
= llabs (value
);
29119 /* Check that the absolute value of the addend can be
29120 encoded in 12 bits. */
29121 if (addend_abs
>= 0x1000)
29122 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
29123 _("bad offset 0x%08lX (only 12 bits available for the magnitude)"),
29124 (unsigned long) addend_abs
);
29126 /* Extract the instruction. */
29127 insn
= md_chars_to_number (buf
, INSN_SIZE
);
29129 /* If the addend is negative, clear bit 23 of the instruction.
29130 Otherwise set it. */
29132 insn
&= ~(1 << 23);
29136 /* Place the absolute value of the addend into the first 12 bits
29137 of the instruction. */
29138 insn
&= 0xfffff000;
29139 insn
|= addend_abs
;
29141 /* Update the instruction. */
29142 md_number_to_chars (buf
, insn
, INSN_SIZE
);
29146 case BFD_RELOC_ARM_LDRS_PC_G0
:
29147 case BFD_RELOC_ARM_LDRS_PC_G1
:
29148 case BFD_RELOC_ARM_LDRS_PC_G2
:
29149 case BFD_RELOC_ARM_LDRS_SB_G0
:
29150 case BFD_RELOC_ARM_LDRS_SB_G1
:
29151 case BFD_RELOC_ARM_LDRS_SB_G2
:
29152 gas_assert (!fixP
->fx_done
);
29153 if (!seg
->use_rela_p
)
29156 bfd_vma addend_abs
= llabs (value
);
29158 /* Check that the absolute value of the addend can be
29159 encoded in 8 bits. */
29160 if (addend_abs
>= 0x100)
29161 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
29162 _("bad offset 0x%08lX (only 8 bits available for the magnitude)"),
29163 (unsigned long) addend_abs
);
29165 /* Extract the instruction. */
29166 insn
= md_chars_to_number (buf
, INSN_SIZE
);
29168 /* If the addend is negative, clear bit 23 of the instruction.
29169 Otherwise set it. */
29171 insn
&= ~(1 << 23);
29175 /* Place the first four bits of the absolute value of the addend
29176 into the first 4 bits of the instruction, and the remaining
29177 four into bits 8 .. 11. */
29178 insn
&= 0xfffff0f0;
29179 insn
|= (addend_abs
& 0xf) | ((addend_abs
& 0xf0) << 4);
29181 /* Update the instruction. */
29182 md_number_to_chars (buf
, insn
, INSN_SIZE
);
29186 case BFD_RELOC_ARM_LDC_PC_G0
:
29187 case BFD_RELOC_ARM_LDC_PC_G1
:
29188 case BFD_RELOC_ARM_LDC_PC_G2
:
29189 case BFD_RELOC_ARM_LDC_SB_G0
:
29190 case BFD_RELOC_ARM_LDC_SB_G1
:
29191 case BFD_RELOC_ARM_LDC_SB_G2
:
29192 gas_assert (!fixP
->fx_done
);
29193 if (!seg
->use_rela_p
)
29196 bfd_vma addend_abs
= llabs (value
);
29198 /* Check that the absolute value of the addend is a multiple of
29199 four and, when divided by four, fits in 8 bits. */
29200 if (addend_abs
& 0x3)
29201 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
29202 _("bad offset 0x%08lX (must be word-aligned)"),
29203 (unsigned long) addend_abs
);
29205 if ((addend_abs
>> 2) > 0xff)
29206 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
29207 _("bad offset 0x%08lX (must be an 8-bit number of words)"),
29208 (unsigned long) addend_abs
);
29210 /* Extract the instruction. */
29211 insn
= md_chars_to_number (buf
, INSN_SIZE
);
29213 /* If the addend is negative, clear bit 23 of the instruction.
29214 Otherwise set it. */
29216 insn
&= ~(1 << 23);
29220 /* Place the addend (divided by four) into the first eight
29221 bits of the instruction. */
29222 insn
&= 0xfffffff0;
29223 insn
|= addend_abs
>> 2;
29225 /* Update the instruction. */
29226 md_number_to_chars (buf
, insn
, INSN_SIZE
);
29230 case BFD_RELOC_THUMB_PCREL_BRANCH5
:
29232 && (S_GET_SEGMENT (fixP
->fx_addsy
) == seg
)
29233 && !S_FORCE_RELOC (fixP
->fx_addsy
, TRUE
)
29234 && ARM_IS_FUNC (fixP
->fx_addsy
)
29235 && ARM_CPU_HAS_FEATURE (selected_cpu
, arm_ext_v8_1m_main
))
29237 /* Force a relocation for a branch 5 bits wide. */
29240 if (v8_1_branch_value_check (value
, 5, FALSE
) == FAIL
)
29241 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
29244 if (fixP
->fx_done
|| !seg
->use_rela_p
)
29246 addressT boff
= value
>> 1;
29248 newval
= md_chars_to_number (buf
, THUMB_SIZE
);
29249 newval
|= (boff
<< 7);
29250 md_number_to_chars (buf
, newval
, THUMB_SIZE
);
29254 case BFD_RELOC_THUMB_PCREL_BFCSEL
:
29256 && (S_GET_SEGMENT (fixP
->fx_addsy
) == seg
)
29257 && !S_FORCE_RELOC (fixP
->fx_addsy
, TRUE
)
29258 && ARM_IS_FUNC (fixP
->fx_addsy
)
29259 && ARM_CPU_HAS_FEATURE (selected_cpu
, arm_ext_v8_1m_main
))
29263 if ((value
& ~0x7f) && ((value
& ~0x3f) != ~0x3f))
29264 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
29265 _("branch out of range"));
29267 if (fixP
->fx_done
|| !seg
->use_rela_p
)
29269 newval
= md_chars_to_number (buf
, THUMB_SIZE
);
29271 addressT boff
= ((newval
& 0x0780) >> 7) << 1;
29272 addressT diff
= value
- boff
;
29276 newval
|= 1 << 1; /* T bit. */
29278 else if (diff
!= 2)
29280 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
29281 _("out of range label-relative fixup value"));
29283 md_number_to_chars (buf
, newval
, THUMB_SIZE
);
29287 case BFD_RELOC_ARM_THUMB_BF17
:
29289 && (S_GET_SEGMENT (fixP
->fx_addsy
) == seg
)
29290 && !S_FORCE_RELOC (fixP
->fx_addsy
, TRUE
)
29291 && ARM_IS_FUNC (fixP
->fx_addsy
)
29292 && ARM_CPU_HAS_FEATURE (selected_cpu
, arm_ext_v8_1m_main
))
29294 /* Force a relocation for a branch 17 bits wide. */
29298 if (v8_1_branch_value_check (value
, 17, TRUE
) == FAIL
)
29299 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
29302 if (fixP
->fx_done
|| !seg
->use_rela_p
)
29305 addressT immA
, immB
, immC
;
29307 immA
= (value
& 0x0001f000) >> 12;
29308 immB
= (value
& 0x00000ffc) >> 2;
29309 immC
= (value
& 0x00000002) >> 1;
29311 newval
= md_chars_to_number (buf
, THUMB_SIZE
);
29312 newval2
= md_chars_to_number (buf
+ THUMB_SIZE
, THUMB_SIZE
);
29314 newval2
|= (immC
<< 11) | (immB
<< 1);
29315 md_number_to_chars (buf
, newval
, THUMB_SIZE
);
29316 md_number_to_chars (buf
+ THUMB_SIZE
, newval2
, THUMB_SIZE
);
29320 case BFD_RELOC_ARM_THUMB_BF19
:
29322 && (S_GET_SEGMENT (fixP
->fx_addsy
) == seg
)
29323 && !S_FORCE_RELOC (fixP
->fx_addsy
, TRUE
)
29324 && ARM_IS_FUNC (fixP
->fx_addsy
)
29325 && ARM_CPU_HAS_FEATURE (selected_cpu
, arm_ext_v8_1m_main
))
29327 /* Force a relocation for a branch 19 bits wide. */
29331 if (v8_1_branch_value_check (value
, 19, TRUE
) == FAIL
)
29332 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
29335 if (fixP
->fx_done
|| !seg
->use_rela_p
)
29338 addressT immA
, immB
, immC
;
29340 immA
= (value
& 0x0007f000) >> 12;
29341 immB
= (value
& 0x00000ffc) >> 2;
29342 immC
= (value
& 0x00000002) >> 1;
29344 newval
= md_chars_to_number (buf
, THUMB_SIZE
);
29345 newval2
= md_chars_to_number (buf
+ THUMB_SIZE
, THUMB_SIZE
);
29347 newval2
|= (immC
<< 11) | (immB
<< 1);
29348 md_number_to_chars (buf
, newval
, THUMB_SIZE
);
29349 md_number_to_chars (buf
+ THUMB_SIZE
, newval2
, THUMB_SIZE
);
29353 case BFD_RELOC_ARM_THUMB_BF13
:
29355 && (S_GET_SEGMENT (fixP
->fx_addsy
) == seg
)
29356 && !S_FORCE_RELOC (fixP
->fx_addsy
, TRUE
)
29357 && ARM_IS_FUNC (fixP
->fx_addsy
)
29358 && ARM_CPU_HAS_FEATURE (selected_cpu
, arm_ext_v8_1m_main
))
29360 /* Force a relocation for a branch 13 bits wide. */
29364 if (v8_1_branch_value_check (value
, 13, TRUE
) == FAIL
)
29365 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
29368 if (fixP
->fx_done
|| !seg
->use_rela_p
)
29371 addressT immA
, immB
, immC
;
29373 immA
= (value
& 0x00001000) >> 12;
29374 immB
= (value
& 0x00000ffc) >> 2;
29375 immC
= (value
& 0x00000002) >> 1;
29377 newval
= md_chars_to_number (buf
, THUMB_SIZE
);
29378 newval2
= md_chars_to_number (buf
+ THUMB_SIZE
, THUMB_SIZE
);
29380 newval2
|= (immC
<< 11) | (immB
<< 1);
29381 md_number_to_chars (buf
, newval
, THUMB_SIZE
);
29382 md_number_to_chars (buf
+ THUMB_SIZE
, newval2
, THUMB_SIZE
);
29386 case BFD_RELOC_ARM_THUMB_LOOP12
:
29388 && (S_GET_SEGMENT (fixP
->fx_addsy
) == seg
)
29389 && !S_FORCE_RELOC (fixP
->fx_addsy
, TRUE
)
29390 && ARM_IS_FUNC (fixP
->fx_addsy
)
29391 && ARM_CPU_HAS_FEATURE (selected_cpu
, arm_ext_v8_1m_main
))
29393 /* Force a relocation for a branch 12 bits wide. */
29397 bfd_vma insn
= get_thumb32_insn (buf
);
29398 /* le lr, <label>, le <label> or letp lr, <label> */
29399 if (((insn
& 0xffffffff) == 0xf00fc001)
29400 || ((insn
& 0xffffffff) == 0xf02fc001)
29401 || ((insn
& 0xffffffff) == 0xf01fc001))
29404 if (v8_1_branch_value_check (value
, 12, FALSE
) == FAIL
)
29405 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
29407 if (fixP
->fx_done
|| !seg
->use_rela_p
)
29409 addressT imml
, immh
;
29411 immh
= (value
& 0x00000ffc) >> 2;
29412 imml
= (value
& 0x00000002) >> 1;
29414 newval
= md_chars_to_number (buf
+ THUMB_SIZE
, THUMB_SIZE
);
29415 newval
|= (imml
<< 11) | (immh
<< 1);
29416 md_number_to_chars (buf
+ THUMB_SIZE
, newval
, THUMB_SIZE
);
29420 case BFD_RELOC_ARM_V4BX
:
29421 /* This will need to go in the object file. */
29425 case BFD_RELOC_UNUSED
:
29427 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
29428 _("bad relocation fixup type (%d)"), fixP
->fx_r_type
);
29432 /* Translate internal representation of relocation info to BFD target
29436 tc_gen_reloc (asection
*section
, fixS
*fixp
)
29439 bfd_reloc_code_real_type code
;
29441 reloc
= XNEW (arelent
);
29443 reloc
->sym_ptr_ptr
= XNEW (asymbol
*);
29444 *reloc
->sym_ptr_ptr
= symbol_get_bfdsym (fixp
->fx_addsy
);
29445 reloc
->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
29447 if (fixp
->fx_pcrel
)
29449 if (section
->use_rela_p
)
29450 fixp
->fx_offset
-= md_pcrel_from_section (fixp
, section
);
29452 fixp
->fx_offset
= reloc
->address
;
29454 reloc
->addend
= fixp
->fx_offset
;
29456 switch (fixp
->fx_r_type
)
29459 if (fixp
->fx_pcrel
)
29461 code
= BFD_RELOC_8_PCREL
;
29464 /* Fall through. */
29467 if (fixp
->fx_pcrel
)
29469 code
= BFD_RELOC_16_PCREL
;
29472 /* Fall through. */
29475 if (fixp
->fx_pcrel
)
29477 code
= BFD_RELOC_32_PCREL
;
29480 /* Fall through. */
29482 case BFD_RELOC_ARM_MOVW
:
29483 if (fixp
->fx_pcrel
)
29485 code
= BFD_RELOC_ARM_MOVW_PCREL
;
29488 /* Fall through. */
29490 case BFD_RELOC_ARM_MOVT
:
29491 if (fixp
->fx_pcrel
)
29493 code
= BFD_RELOC_ARM_MOVT_PCREL
;
29496 /* Fall through. */
29498 case BFD_RELOC_ARM_THUMB_MOVW
:
29499 if (fixp
->fx_pcrel
)
29501 code
= BFD_RELOC_ARM_THUMB_MOVW_PCREL
;
29504 /* Fall through. */
29506 case BFD_RELOC_ARM_THUMB_MOVT
:
29507 if (fixp
->fx_pcrel
)
29509 code
= BFD_RELOC_ARM_THUMB_MOVT_PCREL
;
29512 /* Fall through. */
29514 case BFD_RELOC_NONE
:
29515 case BFD_RELOC_ARM_PCREL_BRANCH
:
29516 case BFD_RELOC_ARM_PCREL_BLX
:
29517 case BFD_RELOC_RVA
:
29518 case BFD_RELOC_THUMB_PCREL_BRANCH7
:
29519 case BFD_RELOC_THUMB_PCREL_BRANCH9
:
29520 case BFD_RELOC_THUMB_PCREL_BRANCH12
:
29521 case BFD_RELOC_THUMB_PCREL_BRANCH20
:
29522 case BFD_RELOC_THUMB_PCREL_BRANCH23
:
29523 case BFD_RELOC_THUMB_PCREL_BRANCH25
:
29524 case BFD_RELOC_VTABLE_ENTRY
:
29525 case BFD_RELOC_VTABLE_INHERIT
:
29527 case BFD_RELOC_32_SECREL
:
29529 code
= fixp
->fx_r_type
;
29532 case BFD_RELOC_THUMB_PCREL_BLX
:
29534 if (EF_ARM_EABI_VERSION (meabi_flags
) >= EF_ARM_EABI_VER4
)
29535 code
= BFD_RELOC_THUMB_PCREL_BRANCH23
;
29538 code
= BFD_RELOC_THUMB_PCREL_BLX
;
29541 case BFD_RELOC_ARM_LITERAL
:
29542 case BFD_RELOC_ARM_HWLITERAL
:
29543 /* If this is called then the a literal has
29544 been referenced across a section boundary. */
29545 as_bad_where (fixp
->fx_file
, fixp
->fx_line
,
29546 _("literal referenced across section boundary"));
29550 case BFD_RELOC_ARM_TLS_CALL
:
29551 case BFD_RELOC_ARM_THM_TLS_CALL
:
29552 case BFD_RELOC_ARM_TLS_DESCSEQ
:
29553 case BFD_RELOC_ARM_THM_TLS_DESCSEQ
:
29554 case BFD_RELOC_ARM_GOT32
:
29555 case BFD_RELOC_ARM_GOTOFF
:
29556 case BFD_RELOC_ARM_GOT_PREL
:
29557 case BFD_RELOC_ARM_PLT32
:
29558 case BFD_RELOC_ARM_TARGET1
:
29559 case BFD_RELOC_ARM_ROSEGREL32
:
29560 case BFD_RELOC_ARM_SBREL32
:
29561 case BFD_RELOC_ARM_PREL31
:
29562 case BFD_RELOC_ARM_TARGET2
:
29563 case BFD_RELOC_ARM_TLS_LDO32
:
29564 case BFD_RELOC_ARM_PCREL_CALL
:
29565 case BFD_RELOC_ARM_PCREL_JUMP
:
29566 case BFD_RELOC_ARM_ALU_PC_G0_NC
:
29567 case BFD_RELOC_ARM_ALU_PC_G0
:
29568 case BFD_RELOC_ARM_ALU_PC_G1_NC
:
29569 case BFD_RELOC_ARM_ALU_PC_G1
:
29570 case BFD_RELOC_ARM_ALU_PC_G2
:
29571 case BFD_RELOC_ARM_LDR_PC_G0
:
29572 case BFD_RELOC_ARM_LDR_PC_G1
:
29573 case BFD_RELOC_ARM_LDR_PC_G2
:
29574 case BFD_RELOC_ARM_LDRS_PC_G0
:
29575 case BFD_RELOC_ARM_LDRS_PC_G1
:
29576 case BFD_RELOC_ARM_LDRS_PC_G2
:
29577 case BFD_RELOC_ARM_LDC_PC_G0
:
29578 case BFD_RELOC_ARM_LDC_PC_G1
:
29579 case BFD_RELOC_ARM_LDC_PC_G2
:
29580 case BFD_RELOC_ARM_ALU_SB_G0_NC
:
29581 case BFD_RELOC_ARM_ALU_SB_G0
:
29582 case BFD_RELOC_ARM_ALU_SB_G1_NC
:
29583 case BFD_RELOC_ARM_ALU_SB_G1
:
29584 case BFD_RELOC_ARM_ALU_SB_G2
:
29585 case BFD_RELOC_ARM_LDR_SB_G0
:
29586 case BFD_RELOC_ARM_LDR_SB_G1
:
29587 case BFD_RELOC_ARM_LDR_SB_G2
:
29588 case BFD_RELOC_ARM_LDRS_SB_G0
:
29589 case BFD_RELOC_ARM_LDRS_SB_G1
:
29590 case BFD_RELOC_ARM_LDRS_SB_G2
:
29591 case BFD_RELOC_ARM_LDC_SB_G0
:
29592 case BFD_RELOC_ARM_LDC_SB_G1
:
29593 case BFD_RELOC_ARM_LDC_SB_G2
:
29594 case BFD_RELOC_ARM_V4BX
:
29595 case BFD_RELOC_ARM_THUMB_ALU_ABS_G0_NC
:
29596 case BFD_RELOC_ARM_THUMB_ALU_ABS_G1_NC
:
29597 case BFD_RELOC_ARM_THUMB_ALU_ABS_G2_NC
:
29598 case BFD_RELOC_ARM_THUMB_ALU_ABS_G3_NC
:
29599 case BFD_RELOC_ARM_GOTFUNCDESC
:
29600 case BFD_RELOC_ARM_GOTOFFFUNCDESC
:
29601 case BFD_RELOC_ARM_FUNCDESC
:
29602 case BFD_RELOC_ARM_THUMB_BF17
:
29603 case BFD_RELOC_ARM_THUMB_BF19
:
29604 case BFD_RELOC_ARM_THUMB_BF13
:
29605 code
= fixp
->fx_r_type
;
29608 case BFD_RELOC_ARM_TLS_GOTDESC
:
29609 case BFD_RELOC_ARM_TLS_GD32
:
29610 case BFD_RELOC_ARM_TLS_GD32_FDPIC
:
29611 case BFD_RELOC_ARM_TLS_LE32
:
29612 case BFD_RELOC_ARM_TLS_IE32
:
29613 case BFD_RELOC_ARM_TLS_IE32_FDPIC
:
29614 case BFD_RELOC_ARM_TLS_LDM32
:
29615 case BFD_RELOC_ARM_TLS_LDM32_FDPIC
:
29616 /* BFD will include the symbol's address in the addend.
29617 But we don't want that, so subtract it out again here. */
29618 if (!S_IS_COMMON (fixp
->fx_addsy
))
29619 reloc
->addend
-= (*reloc
->sym_ptr_ptr
)->value
;
29620 code
= fixp
->fx_r_type
;
29624 case BFD_RELOC_ARM_IMMEDIATE
:
29625 as_bad_where (fixp
->fx_file
, fixp
->fx_line
,
29626 _("internal relocation (type: IMMEDIATE) not fixed up"));
29629 case BFD_RELOC_ARM_ADRL_IMMEDIATE
:
29630 as_bad_where (fixp
->fx_file
, fixp
->fx_line
,
29631 _("ADRL used for a symbol not defined in the same file"));
29634 case BFD_RELOC_THUMB_PCREL_BRANCH5
:
29635 case BFD_RELOC_THUMB_PCREL_BFCSEL
:
29636 case BFD_RELOC_ARM_THUMB_LOOP12
:
29637 as_bad_where (fixp
->fx_file
, fixp
->fx_line
,
29638 _("%s used for a symbol not defined in the same file"),
29639 bfd_get_reloc_code_name (fixp
->fx_r_type
));
29642 case BFD_RELOC_ARM_OFFSET_IMM
:
29643 if (section
->use_rela_p
)
29645 code
= fixp
->fx_r_type
;
29649 if (fixp
->fx_addsy
!= NULL
29650 && !S_IS_DEFINED (fixp
->fx_addsy
)
29651 && S_IS_LOCAL (fixp
->fx_addsy
))
29653 as_bad_where (fixp
->fx_file
, fixp
->fx_line
,
29654 _("undefined local label `%s'"),
29655 S_GET_NAME (fixp
->fx_addsy
));
29659 as_bad_where (fixp
->fx_file
, fixp
->fx_line
,
29660 _("internal_relocation (type: OFFSET_IMM) not fixed up"));
29667 switch (fixp
->fx_r_type
)
29669 case BFD_RELOC_NONE
: type
= "NONE"; break;
29670 case BFD_RELOC_ARM_OFFSET_IMM8
: type
= "OFFSET_IMM8"; break;
29671 case BFD_RELOC_ARM_SHIFT_IMM
: type
= "SHIFT_IMM"; break;
29672 case BFD_RELOC_ARM_SMC
: type
= "SMC"; break;
29673 case BFD_RELOC_ARM_SWI
: type
= "SWI"; break;
29674 case BFD_RELOC_ARM_MULTI
: type
= "MULTI"; break;
29675 case BFD_RELOC_ARM_CP_OFF_IMM
: type
= "CP_OFF_IMM"; break;
29676 case BFD_RELOC_ARM_T32_OFFSET_IMM
: type
= "T32_OFFSET_IMM"; break;
29677 case BFD_RELOC_ARM_T32_CP_OFF_IMM
: type
= "T32_CP_OFF_IMM"; break;
29678 case BFD_RELOC_ARM_THUMB_ADD
: type
= "THUMB_ADD"; break;
29679 case BFD_RELOC_ARM_THUMB_SHIFT
: type
= "THUMB_SHIFT"; break;
29680 case BFD_RELOC_ARM_THUMB_IMM
: type
= "THUMB_IMM"; break;
29681 case BFD_RELOC_ARM_THUMB_OFFSET
: type
= "THUMB_OFFSET"; break;
29682 default: type
= _("<unknown>"); break;
29684 as_bad_where (fixp
->fx_file
, fixp
->fx_line
,
29685 _("cannot represent %s relocation in this object file format"),
29692 if ((code
== BFD_RELOC_32_PCREL
|| code
== BFD_RELOC_32
)
29694 && fixp
->fx_addsy
== GOT_symbol
)
29696 code
= BFD_RELOC_ARM_GOTPC
;
29697 reloc
->addend
= fixp
->fx_offset
= reloc
->address
;
29701 reloc
->howto
= bfd_reloc_type_lookup (stdoutput
, code
);
29703 if (reloc
->howto
== NULL
)
29705 as_bad_where (fixp
->fx_file
, fixp
->fx_line
,
29706 _("cannot represent %s relocation in this object file format"),
29707 bfd_get_reloc_code_name (code
));
29711 /* HACK: Since arm ELF uses Rel instead of Rela, encode the
29712 vtable entry to be used in the relocation's section offset. */
29713 if (fixp
->fx_r_type
== BFD_RELOC_VTABLE_ENTRY
)
29714 reloc
->address
= fixp
->fx_offset
;
29719 /* This fix_new is called by cons via TC_CONS_FIX_NEW. */
29722 cons_fix_new_arm (fragS
* frag
,
29726 bfd_reloc_code_real_type reloc
)
29731 FIXME: @@ Should look at CPU word size. */
29735 reloc
= BFD_RELOC_8
;
29738 reloc
= BFD_RELOC_16
;
29742 reloc
= BFD_RELOC_32
;
29745 reloc
= BFD_RELOC_64
;
29750 if (exp
->X_op
== O_secrel
)
29752 exp
->X_op
= O_symbol
;
29753 reloc
= BFD_RELOC_32_SECREL
;
29757 fix_new_exp (frag
, where
, size
, exp
, pcrel
, reloc
);
29760 #if defined (OBJ_COFF)
29762 arm_validate_fix (fixS
* fixP
)
29764 /* If the destination of the branch is a defined symbol which does not have
29765 the THUMB_FUNC attribute, then we must be calling a function which has
29766 the (interfacearm) attribute. We look for the Thumb entry point to that
29767 function and change the branch to refer to that function instead. */
29768 if (fixP
->fx_r_type
== BFD_RELOC_THUMB_PCREL_BRANCH23
29769 && fixP
->fx_addsy
!= NULL
29770 && S_IS_DEFINED (fixP
->fx_addsy
)
29771 && ! THUMB_IS_FUNC (fixP
->fx_addsy
))
29773 fixP
->fx_addsy
= find_real_start (fixP
->fx_addsy
);
29780 arm_force_relocation (struct fix
* fixp
)
29782 #if defined (OBJ_COFF) && defined (TE_PE)
29783 if (fixp
->fx_r_type
== BFD_RELOC_RVA
)
29787 /* In case we have a call or a branch to a function in ARM ISA mode from
29788 a thumb function or vice-versa force the relocation. These relocations
29789 are cleared off for some cores that might have blx and simple transformations
29793 switch (fixp
->fx_r_type
)
29795 case BFD_RELOC_ARM_PCREL_JUMP
:
29796 case BFD_RELOC_ARM_PCREL_CALL
:
29797 case BFD_RELOC_THUMB_PCREL_BLX
:
29798 if (THUMB_IS_FUNC (fixp
->fx_addsy
))
29802 case BFD_RELOC_ARM_PCREL_BLX
:
29803 case BFD_RELOC_THUMB_PCREL_BRANCH25
:
29804 case BFD_RELOC_THUMB_PCREL_BRANCH20
:
29805 case BFD_RELOC_THUMB_PCREL_BRANCH23
:
29806 if (ARM_IS_FUNC (fixp
->fx_addsy
))
29815 /* Resolve these relocations even if the symbol is extern or weak.
29816 Technically this is probably wrong due to symbol preemption.
29817 In practice these relocations do not have enough range to be useful
29818 at dynamic link time, and some code (e.g. in the Linux kernel)
29819 expects these references to be resolved. */
29820 if (fixp
->fx_r_type
== BFD_RELOC_ARM_IMMEDIATE
29821 || fixp
->fx_r_type
== BFD_RELOC_ARM_OFFSET_IMM
29822 || fixp
->fx_r_type
== BFD_RELOC_ARM_OFFSET_IMM8
29823 || fixp
->fx_r_type
== BFD_RELOC_ARM_ADRL_IMMEDIATE
29824 || fixp
->fx_r_type
== BFD_RELOC_ARM_CP_OFF_IMM
29825 || fixp
->fx_r_type
== BFD_RELOC_ARM_CP_OFF_IMM_S2
29826 || fixp
->fx_r_type
== BFD_RELOC_ARM_THUMB_OFFSET
29827 || fixp
->fx_r_type
== BFD_RELOC_ARM_T32_ADD_IMM
29828 || fixp
->fx_r_type
== BFD_RELOC_ARM_T32_IMMEDIATE
29829 || fixp
->fx_r_type
== BFD_RELOC_ARM_T32_IMM12
29830 || fixp
->fx_r_type
== BFD_RELOC_ARM_T32_OFFSET_IMM
29831 || fixp
->fx_r_type
== BFD_RELOC_ARM_T32_ADD_PC12
29832 || fixp
->fx_r_type
== BFD_RELOC_ARM_T32_CP_OFF_IMM
29833 || fixp
->fx_r_type
== BFD_RELOC_ARM_T32_CP_OFF_IMM_S2
)
29836 /* Always leave these relocations for the linker. */
29837 if ((fixp
->fx_r_type
>= BFD_RELOC_ARM_ALU_PC_G0_NC
29838 && fixp
->fx_r_type
<= BFD_RELOC_ARM_LDC_SB_G2
)
29839 || fixp
->fx_r_type
== BFD_RELOC_ARM_LDR_PC_G0
)
29842 /* Always generate relocations against function symbols. */
29843 if (fixp
->fx_r_type
== BFD_RELOC_32
29845 && (symbol_get_bfdsym (fixp
->fx_addsy
)->flags
& BSF_FUNCTION
))
29848 return generic_force_reloc (fixp
);
29851 #if defined (OBJ_ELF) || defined (OBJ_COFF)
29852 /* Relocations against function names must be left unadjusted,
29853 so that the linker can use this information to generate interworking
29854 stubs. The MIPS version of this function
29855 also prevents relocations that are mips-16 specific, but I do not
29856 know why it does this.
29859 There is one other problem that ought to be addressed here, but
29860 which currently is not: Taking the address of a label (rather
29861 than a function) and then later jumping to that address. Such
29862 addresses also ought to have their bottom bit set (assuming that
29863 they reside in Thumb code), but at the moment they will not. */
29866 arm_fix_adjustable (fixS
* fixP
)
29868 if (fixP
->fx_addsy
== NULL
)
29871 /* Preserve relocations against symbols with function type. */
29872 if (symbol_get_bfdsym (fixP
->fx_addsy
)->flags
& BSF_FUNCTION
)
29875 if (THUMB_IS_FUNC (fixP
->fx_addsy
)
29876 && fixP
->fx_subsy
== NULL
)
29879 /* We need the symbol name for the VTABLE entries. */
29880 if ( fixP
->fx_r_type
== BFD_RELOC_VTABLE_INHERIT
29881 || fixP
->fx_r_type
== BFD_RELOC_VTABLE_ENTRY
)
29884 /* Don't allow symbols to be discarded on GOT related relocs. */
29885 if (fixP
->fx_r_type
== BFD_RELOC_ARM_PLT32
29886 || fixP
->fx_r_type
== BFD_RELOC_ARM_GOT32
29887 || fixP
->fx_r_type
== BFD_RELOC_ARM_GOTOFF
29888 || fixP
->fx_r_type
== BFD_RELOC_ARM_TLS_GD32
29889 || fixP
->fx_r_type
== BFD_RELOC_ARM_TLS_GD32_FDPIC
29890 || fixP
->fx_r_type
== BFD_RELOC_ARM_TLS_LE32
29891 || fixP
->fx_r_type
== BFD_RELOC_ARM_TLS_IE32
29892 || fixP
->fx_r_type
== BFD_RELOC_ARM_TLS_IE32_FDPIC
29893 || fixP
->fx_r_type
== BFD_RELOC_ARM_TLS_LDM32
29894 || fixP
->fx_r_type
== BFD_RELOC_ARM_TLS_LDM32_FDPIC
29895 || fixP
->fx_r_type
== BFD_RELOC_ARM_TLS_LDO32
29896 || fixP
->fx_r_type
== BFD_RELOC_ARM_TLS_GOTDESC
29897 || fixP
->fx_r_type
== BFD_RELOC_ARM_TLS_CALL
29898 || fixP
->fx_r_type
== BFD_RELOC_ARM_THM_TLS_CALL
29899 || fixP
->fx_r_type
== BFD_RELOC_ARM_TLS_DESCSEQ
29900 || fixP
->fx_r_type
== BFD_RELOC_ARM_THM_TLS_DESCSEQ
29901 || fixP
->fx_r_type
== BFD_RELOC_ARM_TARGET2
)
29904 /* Similarly for group relocations. */
29905 if ((fixP
->fx_r_type
>= BFD_RELOC_ARM_ALU_PC_G0_NC
29906 && fixP
->fx_r_type
<= BFD_RELOC_ARM_LDC_SB_G2
)
29907 || fixP
->fx_r_type
== BFD_RELOC_ARM_LDR_PC_G0
)
29910 /* MOVW/MOVT REL relocations have limited offsets, so keep the symbols. */
29911 if (fixP
->fx_r_type
== BFD_RELOC_ARM_MOVW
29912 || fixP
->fx_r_type
== BFD_RELOC_ARM_MOVT
29913 || fixP
->fx_r_type
== BFD_RELOC_ARM_MOVW_PCREL
29914 || fixP
->fx_r_type
== BFD_RELOC_ARM_MOVT_PCREL
29915 || fixP
->fx_r_type
== BFD_RELOC_ARM_THUMB_MOVW
29916 || fixP
->fx_r_type
== BFD_RELOC_ARM_THUMB_MOVT
29917 || fixP
->fx_r_type
== BFD_RELOC_ARM_THUMB_MOVW_PCREL
29918 || fixP
->fx_r_type
== BFD_RELOC_ARM_THUMB_MOVT_PCREL
)
29921 /* BFD_RELOC_ARM_THUMB_ALU_ABS_Gx_NC relocations have VERY limited
29922 offsets, so keep these symbols. */
29923 if (fixP
->fx_r_type
>= BFD_RELOC_ARM_THUMB_ALU_ABS_G0_NC
29924 && fixP
->fx_r_type
<= BFD_RELOC_ARM_THUMB_ALU_ABS_G3_NC
)
29929 #endif /* defined (OBJ_ELF) || defined (OBJ_COFF) */
29933 elf32_arm_target_format (void)
29936 return (target_big_endian
29937 ? "elf32-bigarm-symbian"
29938 : "elf32-littlearm-symbian");
29939 #elif defined (TE_VXWORKS)
29940 return (target_big_endian
29941 ? "elf32-bigarm-vxworks"
29942 : "elf32-littlearm-vxworks");
29943 #elif defined (TE_NACL)
29944 return (target_big_endian
29945 ? "elf32-bigarm-nacl"
29946 : "elf32-littlearm-nacl");
29950 if (target_big_endian
)
29951 return "elf32-bigarm-fdpic";
29953 return "elf32-littlearm-fdpic";
29957 if (target_big_endian
)
29958 return "elf32-bigarm";
29960 return "elf32-littlearm";
29966 armelf_frob_symbol (symbolS
* symp
,
29969 elf_frob_symbol (symp
, puntp
);
29973 /* MD interface: Finalization. */
29978 literal_pool
* pool
;
29980 /* Ensure that all the predication blocks are properly closed. */
29981 check_pred_blocks_finished ();
29983 for (pool
= list_of_pools
; pool
; pool
= pool
->next
)
29985 /* Put it at the end of the relevant section. */
29986 subseg_set (pool
->section
, pool
->sub_section
);
29988 arm_elf_change_section ();
29995 /* Remove any excess mapping symbols generated for alignment frags in
29996 SEC. We may have created a mapping symbol before a zero byte
29997 alignment; remove it if there's a mapping symbol after the
30000 check_mapping_symbols (bfd
*abfd ATTRIBUTE_UNUSED
, asection
*sec
,
30001 void *dummy ATTRIBUTE_UNUSED
)
30003 segment_info_type
*seginfo
= seg_info (sec
);
30006 if (seginfo
== NULL
|| seginfo
->frchainP
== NULL
)
30009 for (fragp
= seginfo
->frchainP
->frch_root
;
30011 fragp
= fragp
->fr_next
)
30013 symbolS
*sym
= fragp
->tc_frag_data
.last_map
;
30014 fragS
*next
= fragp
->fr_next
;
30016 /* Variable-sized frags have been converted to fixed size by
30017 this point. But if this was variable-sized to start with,
30018 there will be a fixed-size frag after it. So don't handle
30020 if (sym
== NULL
|| next
== NULL
)
30023 if (S_GET_VALUE (sym
) < next
->fr_address
)
30024 /* Not at the end of this frag. */
30026 know (S_GET_VALUE (sym
) == next
->fr_address
);
30030 if (next
->tc_frag_data
.first_map
!= NULL
)
30032 /* Next frag starts with a mapping symbol. Discard this
30034 symbol_remove (sym
, &symbol_rootP
, &symbol_lastP
);
30038 if (next
->fr_next
== NULL
)
30040 /* This mapping symbol is at the end of the section. Discard
30042 know (next
->fr_fix
== 0 && next
->fr_var
== 0);
30043 symbol_remove (sym
, &symbol_rootP
, &symbol_lastP
);
30047 /* As long as we have empty frags without any mapping symbols,
30049 /* If the next frag is non-empty and does not start with a
30050 mapping symbol, then this mapping symbol is required. */
30051 if (next
->fr_address
!= next
->fr_next
->fr_address
)
30054 next
= next
->fr_next
;
30056 while (next
!= NULL
);
30061 /* Adjust the symbol table. This marks Thumb symbols as distinct from
30065 arm_adjust_symtab (void)
30070 for (sym
= symbol_rootP
; sym
!= NULL
; sym
= symbol_next (sym
))
30072 if (ARM_IS_THUMB (sym
))
30074 if (THUMB_IS_FUNC (sym
))
30076 /* Mark the symbol as a Thumb function. */
30077 if ( S_GET_STORAGE_CLASS (sym
) == C_STAT
30078 || S_GET_STORAGE_CLASS (sym
) == C_LABEL
) /* This can happen! */
30079 S_SET_STORAGE_CLASS (sym
, C_THUMBSTATFUNC
);
30081 else if (S_GET_STORAGE_CLASS (sym
) == C_EXT
)
30082 S_SET_STORAGE_CLASS (sym
, C_THUMBEXTFUNC
);
30084 as_bad (_("%s: unexpected function type: %d"),
30085 S_GET_NAME (sym
), S_GET_STORAGE_CLASS (sym
));
30087 else switch (S_GET_STORAGE_CLASS (sym
))
30090 S_SET_STORAGE_CLASS (sym
, C_THUMBEXT
);
30093 S_SET_STORAGE_CLASS (sym
, C_THUMBSTAT
);
30096 S_SET_STORAGE_CLASS (sym
, C_THUMBLABEL
);
30104 if (ARM_IS_INTERWORK (sym
))
30105 coffsymbol (symbol_get_bfdsym (sym
))->native
->u
.syment
.n_flags
= 0xFF;
30112 for (sym
= symbol_rootP
; sym
!= NULL
; sym
= symbol_next (sym
))
30114 if (ARM_IS_THUMB (sym
))
30116 elf_symbol_type
* elf_sym
;
30118 elf_sym
= elf_symbol (symbol_get_bfdsym (sym
));
30119 bind
= ELF_ST_BIND (elf_sym
->internal_elf_sym
.st_info
);
30121 if (! bfd_is_arm_special_symbol_name (elf_sym
->symbol
.name
,
30122 BFD_ARM_SPECIAL_SYM_TYPE_ANY
))
30124 /* If it's a .thumb_func, declare it as so,
30125 otherwise tag label as .code 16. */
30126 if (THUMB_IS_FUNC (sym
))
30127 ARM_SET_SYM_BRANCH_TYPE (elf_sym
->internal_elf_sym
.st_target_internal
,
30128 ST_BRANCH_TO_THUMB
);
30129 else if (EF_ARM_EABI_VERSION (meabi_flags
) < EF_ARM_EABI_VER4
)
30130 elf_sym
->internal_elf_sym
.st_info
=
30131 ELF_ST_INFO (bind
, STT_ARM_16BIT
);
30136 /* Remove any overlapping mapping symbols generated by alignment frags. */
30137 bfd_map_over_sections (stdoutput
, check_mapping_symbols
, (char *) 0);
30138 /* Now do generic ELF adjustments. */
30139 elf_adjust_symtab ();
30143 /* MD interface: Initialization. */
30146 set_constant_flonums (void)
30150 for (i
= 0; i
< NUM_FLOAT_VALS
; i
++)
30151 if (atof_ieee ((char *) fp_const
[i
], 'x', fp_values
[i
]) == NULL
)
30155 /* Auto-select Thumb mode if it's the only available instruction set for the
30156 given architecture. */
30159 autoselect_thumb_from_cpu_variant (void)
30161 if (!ARM_CPU_HAS_FEATURE (cpu_variant
, arm_ext_v1
))
30162 opcode_select (16);
30171 if ( (arm_ops_hsh
= hash_new ()) == NULL
30172 || (arm_cond_hsh
= hash_new ()) == NULL
30173 || (arm_vcond_hsh
= hash_new ()) == NULL
30174 || (arm_shift_hsh
= hash_new ()) == NULL
30175 || (arm_psr_hsh
= hash_new ()) == NULL
30176 || (arm_v7m_psr_hsh
= hash_new ()) == NULL
30177 || (arm_reg_hsh
= hash_new ()) == NULL
30178 || (arm_reloc_hsh
= hash_new ()) == NULL
30179 || (arm_barrier_opt_hsh
= hash_new ()) == NULL
)
30180 as_fatal (_("virtual memory exhausted"));
30182 for (i
= 0; i
< sizeof (insns
) / sizeof (struct asm_opcode
); i
++)
30183 hash_insert (arm_ops_hsh
, insns
[i
].template_name
, (void *) (insns
+ i
));
30184 for (i
= 0; i
< sizeof (conds
) / sizeof (struct asm_cond
); i
++)
30185 hash_insert (arm_cond_hsh
, conds
[i
].template_name
, (void *) (conds
+ i
));
30186 for (i
= 0; i
< sizeof (vconds
) / sizeof (struct asm_cond
); i
++)
30187 hash_insert (arm_vcond_hsh
, vconds
[i
].template_name
, (void *) (vconds
+ i
));
30188 for (i
= 0; i
< sizeof (shift_names
) / sizeof (struct asm_shift_name
); i
++)
30189 hash_insert (arm_shift_hsh
, shift_names
[i
].name
, (void *) (shift_names
+ i
));
30190 for (i
= 0; i
< sizeof (psrs
) / sizeof (struct asm_psr
); i
++)
30191 hash_insert (arm_psr_hsh
, psrs
[i
].template_name
, (void *) (psrs
+ i
));
30192 for (i
= 0; i
< sizeof (v7m_psrs
) / sizeof (struct asm_psr
); i
++)
30193 hash_insert (arm_v7m_psr_hsh
, v7m_psrs
[i
].template_name
,
30194 (void *) (v7m_psrs
+ i
));
30195 for (i
= 0; i
< sizeof (reg_names
) / sizeof (struct reg_entry
); i
++)
30196 hash_insert (arm_reg_hsh
, reg_names
[i
].name
, (void *) (reg_names
+ i
));
30198 i
< sizeof (barrier_opt_names
) / sizeof (struct asm_barrier_opt
);
30200 hash_insert (arm_barrier_opt_hsh
, barrier_opt_names
[i
].template_name
,
30201 (void *) (barrier_opt_names
+ i
));
30203 for (i
= 0; i
< ARRAY_SIZE (reloc_names
); i
++)
30205 struct reloc_entry
* entry
= reloc_names
+ i
;
30207 if (arm_is_eabi() && entry
->reloc
== BFD_RELOC_ARM_PLT32
)
30208 /* This makes encode_branch() use the EABI versions of this relocation. */
30209 entry
->reloc
= BFD_RELOC_UNUSED
;
30211 hash_insert (arm_reloc_hsh
, entry
->name
, (void *) entry
);
30215 set_constant_flonums ();
30217 /* Set the cpu variant based on the command-line options. We prefer
30218 -mcpu= over -march= if both are set (as for GCC); and we prefer
30219 -mfpu= over any other way of setting the floating point unit.
30220 Use of legacy options with new options are faulted. */
30223 if (mcpu_cpu_opt
|| march_cpu_opt
)
30224 as_bad (_("use of old and new-style options to set CPU type"));
30226 selected_arch
= *legacy_cpu
;
30228 else if (mcpu_cpu_opt
)
30230 selected_arch
= *mcpu_cpu_opt
;
30231 selected_ext
= *mcpu_ext_opt
;
30233 else if (march_cpu_opt
)
30235 selected_arch
= *march_cpu_opt
;
30236 selected_ext
= *march_ext_opt
;
30238 ARM_MERGE_FEATURE_SETS (selected_cpu
, selected_arch
, selected_ext
);
30243 as_bad (_("use of old and new-style options to set FPU type"));
30245 selected_fpu
= *legacy_fpu
;
30248 selected_fpu
= *mfpu_opt
;
30251 #if !(defined (EABI_DEFAULT) || defined (TE_LINUX) \
30252 || defined (TE_NetBSD) || defined (TE_VXWORKS))
30253 /* Some environments specify a default FPU. If they don't, infer it
30254 from the processor. */
30256 selected_fpu
= *mcpu_fpu_opt
;
30257 else if (march_fpu_opt
)
30258 selected_fpu
= *march_fpu_opt
;
30260 selected_fpu
= fpu_default
;
30264 if (ARM_FEATURE_ZERO (selected_fpu
))
30266 if (!no_cpu_selected ())
30267 selected_fpu
= fpu_default
;
30269 selected_fpu
= fpu_arch_fpa
;
30273 if (ARM_FEATURE_ZERO (selected_arch
))
30275 selected_arch
= cpu_default
;
30276 selected_cpu
= selected_arch
;
30278 ARM_MERGE_FEATURE_SETS (cpu_variant
, selected_cpu
, selected_fpu
);
30280 /* Autodection of feature mode: allow all features in cpu_variant but leave
30281 selected_cpu unset. It will be set in aeabi_set_public_attributes ()
30282 after all instruction have been processed and we can decide what CPU
30283 should be selected. */
30284 if (ARM_FEATURE_ZERO (selected_arch
))
30285 ARM_MERGE_FEATURE_SETS (cpu_variant
, arm_arch_any
, selected_fpu
);
30287 ARM_MERGE_FEATURE_SETS (cpu_variant
, selected_cpu
, selected_fpu
);
30290 autoselect_thumb_from_cpu_variant ();
30292 arm_arch_used
= thumb_arch_used
= arm_arch_none
;
30294 #if defined OBJ_COFF || defined OBJ_ELF
30296 unsigned int flags
= 0;
30298 #if defined OBJ_ELF
30299 flags
= meabi_flags
;
30301 switch (meabi_flags
)
30303 case EF_ARM_EABI_UNKNOWN
:
30305 /* Set the flags in the private structure. */
30306 if (uses_apcs_26
) flags
|= F_APCS26
;
30307 if (support_interwork
) flags
|= F_INTERWORK
;
30308 if (uses_apcs_float
) flags
|= F_APCS_FLOAT
;
30309 if (pic_code
) flags
|= F_PIC
;
30310 if (!ARM_CPU_HAS_FEATURE (cpu_variant
, fpu_any_hard
))
30311 flags
|= F_SOFT_FLOAT
;
30313 switch (mfloat_abi_opt
)
30315 case ARM_FLOAT_ABI_SOFT
:
30316 case ARM_FLOAT_ABI_SOFTFP
:
30317 flags
|= F_SOFT_FLOAT
;
30320 case ARM_FLOAT_ABI_HARD
:
30321 if (flags
& F_SOFT_FLOAT
)
30322 as_bad (_("hard-float conflicts with specified fpu"));
30326 /* Using pure-endian doubles (even if soft-float). */
30327 if (ARM_CPU_HAS_FEATURE (cpu_variant
, fpu_endian_pure
))
30328 flags
|= F_VFP_FLOAT
;
30330 #if defined OBJ_ELF
30331 if (ARM_CPU_HAS_FEATURE (cpu_variant
, fpu_arch_maverick
))
30332 flags
|= EF_ARM_MAVERICK_FLOAT
;
30335 case EF_ARM_EABI_VER4
:
30336 case EF_ARM_EABI_VER5
:
30337 /* No additional flags to set. */
30344 bfd_set_private_flags (stdoutput
, flags
);
30346 /* We have run out flags in the COFF header to encode the
30347 status of ATPCS support, so instead we create a dummy,
30348 empty, debug section called .arm.atpcs. */
30353 sec
= bfd_make_section (stdoutput
, ".arm.atpcs");
30357 bfd_set_section_flags (sec
, SEC_READONLY
| SEC_DEBUGGING
);
30358 bfd_set_section_size (sec
, 0);
30359 bfd_set_section_contents (stdoutput
, sec
, NULL
, 0, 0);
30365 /* Record the CPU type as well. */
30366 if (ARM_CPU_HAS_FEATURE (cpu_variant
, arm_cext_iwmmxt2
))
30367 mach
= bfd_mach_arm_iWMMXt2
;
30368 else if (ARM_CPU_HAS_FEATURE (cpu_variant
, arm_cext_iwmmxt
))
30369 mach
= bfd_mach_arm_iWMMXt
;
30370 else if (ARM_CPU_HAS_FEATURE (cpu_variant
, arm_cext_xscale
))
30371 mach
= bfd_mach_arm_XScale
;
30372 else if (ARM_CPU_HAS_FEATURE (cpu_variant
, arm_cext_maverick
))
30373 mach
= bfd_mach_arm_ep9312
;
30374 else if (ARM_CPU_HAS_FEATURE (cpu_variant
, arm_ext_v5e
))
30375 mach
= bfd_mach_arm_5TE
;
30376 else if (ARM_CPU_HAS_FEATURE (cpu_variant
, arm_ext_v5
))
30378 if (ARM_CPU_HAS_FEATURE (cpu_variant
, arm_ext_v4t
))
30379 mach
= bfd_mach_arm_5T
;
30381 mach
= bfd_mach_arm_5
;
30383 else if (ARM_CPU_HAS_FEATURE (cpu_variant
, arm_ext_v4
))
30385 if (ARM_CPU_HAS_FEATURE (cpu_variant
, arm_ext_v4t
))
30386 mach
= bfd_mach_arm_4T
;
30388 mach
= bfd_mach_arm_4
;
30390 else if (ARM_CPU_HAS_FEATURE (cpu_variant
, arm_ext_v3m
))
30391 mach
= bfd_mach_arm_3M
;
30392 else if (ARM_CPU_HAS_FEATURE (cpu_variant
, arm_ext_v3
))
30393 mach
= bfd_mach_arm_3
;
30394 else if (ARM_CPU_HAS_FEATURE (cpu_variant
, arm_ext_v2s
))
30395 mach
= bfd_mach_arm_2a
;
30396 else if (ARM_CPU_HAS_FEATURE (cpu_variant
, arm_ext_v2
))
30397 mach
= bfd_mach_arm_2
;
30399 mach
= bfd_mach_arm_unknown
;
30401 bfd_set_arch_mach (stdoutput
, TARGET_ARCH
, mach
);
30404 /* Command line processing. */
30407 Invocation line includes a switch not recognized by the base assembler.
30408 See if it's a processor-specific option.
30410 This routine is somewhat complicated by the need for backwards
30411 compatibility (since older releases of gcc can't be changed).
30412 The new options try to make the interface as compatible as
30415 New options (supported) are:
30417 -mcpu=<cpu name> Assemble for selected processor
30418 -march=<architecture name> Assemble for selected architecture
30419 -mfpu=<fpu architecture> Assemble for selected FPU.
30420 -EB/-mbig-endian Big-endian
30421 -EL/-mlittle-endian Little-endian
30422 -k Generate PIC code
30423 -mthumb Start in Thumb mode
30424 -mthumb-interwork Code supports ARM/Thumb interworking
30426 -m[no-]warn-deprecated Warn about deprecated features
30427 -m[no-]warn-syms Warn when symbols match instructions
30429 For now we will also provide support for:
30431 -mapcs-32 32-bit Program counter
30432 -mapcs-26 26-bit Program counter
30433 -macps-float Floats passed in FP registers
30434 -mapcs-reentrant Reentrant code
30436 (sometime these will probably be replaced with -mapcs=<list of options>
30437 and -matpcs=<list of options>)
30439 The remaining options are only supported for back-wards compatibility.
30440 Cpu variants, the arm part is optional:
30441 -m[arm]1 Currently not supported.
30442 -m[arm]2, -m[arm]250 Arm 2 and Arm 250 processor
30443 -m[arm]3 Arm 3 processor
30444 -m[arm]6[xx], Arm 6 processors
30445 -m[arm]7[xx][t][[d]m] Arm 7 processors
30446 -m[arm]8[10] Arm 8 processors
30447 -m[arm]9[20][tdmi] Arm 9 processors
30448 -mstrongarm[110[0]] StrongARM processors
30449 -mxscale XScale processors
30450 -m[arm]v[2345[t[e]]] Arm architectures
30451 -mall All (except the ARM1)
30453 -mfpa10, -mfpa11 FPA10 and 11 co-processor instructions
30454 -mfpe-old (No float load/store multiples)
30455 -mvfpxd VFP Single precision
30457 -mno-fpu Disable all floating point instructions
30459 The following CPU names are recognized:
30460 arm1, arm2, arm250, arm3, arm6, arm600, arm610, arm620,
30461 arm7, arm7m, arm7d, arm7dm, arm7di, arm7dmi, arm70, arm700,
30462 arm700i, arm710 arm710t, arm720, arm720t, arm740t, arm710c,
30463 arm7100, arm7500, arm7500fe, arm7tdmi, arm8, arm810, arm9,
30464 arm920, arm920t, arm940t, arm946, arm966, arm9tdmi, arm9e,
30465 arm10t arm10e, arm1020t, arm1020e, arm10200e,
30466 strongarm, strongarm110, strongarm1100, strongarm1110, xscale.
30470 const char * md_shortopts
= "m:k";
30472 #ifdef ARM_BI_ENDIAN
30473 #define OPTION_EB (OPTION_MD_BASE + 0)
30474 #define OPTION_EL (OPTION_MD_BASE + 1)
30476 #if TARGET_BYTES_BIG_ENDIAN
30477 #define OPTION_EB (OPTION_MD_BASE + 0)
30479 #define OPTION_EL (OPTION_MD_BASE + 1)
30482 #define OPTION_FIX_V4BX (OPTION_MD_BASE + 2)
30483 #define OPTION_FDPIC (OPTION_MD_BASE + 3)
30485 struct option md_longopts
[] =
30488 {"EB", no_argument
, NULL
, OPTION_EB
},
30491 {"EL", no_argument
, NULL
, OPTION_EL
},
30493 {"fix-v4bx", no_argument
, NULL
, OPTION_FIX_V4BX
},
30495 {"fdpic", no_argument
, NULL
, OPTION_FDPIC
},
30497 {NULL
, no_argument
, NULL
, 0}
30500 size_t md_longopts_size
= sizeof (md_longopts
);
30502 struct arm_option_table
30504 const char * option
; /* Option name to match. */
30505 const char * help
; /* Help information. */
30506 int * var
; /* Variable to change. */
30507 int value
; /* What to change it to. */
30508 const char * deprecated
; /* If non-null, print this message. */
30511 struct arm_option_table arm_opts
[] =
30513 {"k", N_("generate PIC code"), &pic_code
, 1, NULL
},
30514 {"mthumb", N_("assemble Thumb code"), &thumb_mode
, 1, NULL
},
30515 {"mthumb-interwork", N_("support ARM/Thumb interworking"),
30516 &support_interwork
, 1, NULL
},
30517 {"mapcs-32", N_("code uses 32-bit program counter"), &uses_apcs_26
, 0, NULL
},
30518 {"mapcs-26", N_("code uses 26-bit program counter"), &uses_apcs_26
, 1, NULL
},
30519 {"mapcs-float", N_("floating point args are in fp regs"), &uses_apcs_float
,
30521 {"mapcs-reentrant", N_("re-entrant code"), &pic_code
, 1, NULL
},
30522 {"matpcs", N_("code is ATPCS conformant"), &atpcs
, 1, NULL
},
30523 {"mbig-endian", N_("assemble for big-endian"), &target_big_endian
, 1, NULL
},
30524 {"mlittle-endian", N_("assemble for little-endian"), &target_big_endian
, 0,
30527 /* These are recognized by the assembler, but have no affect on code. */
30528 {"mapcs-frame", N_("use frame pointer"), NULL
, 0, NULL
},
30529 {"mapcs-stack-check", N_("use stack size checking"), NULL
, 0, NULL
},
30531 {"mwarn-deprecated", NULL
, &warn_on_deprecated
, 1, NULL
},
30532 {"mno-warn-deprecated", N_("do not warn on use of deprecated feature"),
30533 &warn_on_deprecated
, 0, NULL
},
30535 {"mwarn-restrict-it", N_("warn about performance deprecated IT instructions"
30536 " in ARMv8-A and ARMv8-R"), &warn_on_restrict_it
, 1, NULL
},
30537 {"mno-warn-restrict-it", NULL
, &warn_on_restrict_it
, 0, NULL
},
30539 {"mwarn-syms", N_("warn about symbols that match instruction names [default]"), (int *) (& flag_warn_syms
), TRUE
, NULL
},
30540 {"mno-warn-syms", N_("disable warnings about symobls that match instructions"), (int *) (& flag_warn_syms
), FALSE
, NULL
},
30541 {NULL
, NULL
, NULL
, 0, NULL
}
30544 struct arm_legacy_option_table
30546 const char * option
; /* Option name to match. */
30547 const arm_feature_set
** var
; /* Variable to change. */
30548 const arm_feature_set value
; /* What to change it to. */
30549 const char * deprecated
; /* If non-null, print this message. */
30552 const struct arm_legacy_option_table arm_legacy_opts
[] =
30554 /* DON'T add any new processors to this list -- we want the whole list
30555 to go away... Add them to the processors table instead. */
30556 {"marm1", &legacy_cpu
, ARM_ARCH_V1
, N_("use -mcpu=arm1")},
30557 {"m1", &legacy_cpu
, ARM_ARCH_V1
, N_("use -mcpu=arm1")},
30558 {"marm2", &legacy_cpu
, ARM_ARCH_V2
, N_("use -mcpu=arm2")},
30559 {"m2", &legacy_cpu
, ARM_ARCH_V2
, N_("use -mcpu=arm2")},
30560 {"marm250", &legacy_cpu
, ARM_ARCH_V2S
, N_("use -mcpu=arm250")},
30561 {"m250", &legacy_cpu
, ARM_ARCH_V2S
, N_("use -mcpu=arm250")},
30562 {"marm3", &legacy_cpu
, ARM_ARCH_V2S
, N_("use -mcpu=arm3")},
30563 {"m3", &legacy_cpu
, ARM_ARCH_V2S
, N_("use -mcpu=arm3")},
30564 {"marm6", &legacy_cpu
, ARM_ARCH_V3
, N_("use -mcpu=arm6")},
30565 {"m6", &legacy_cpu
, ARM_ARCH_V3
, N_("use -mcpu=arm6")},
30566 {"marm600", &legacy_cpu
, ARM_ARCH_V3
, N_("use -mcpu=arm600")},
30567 {"m600", &legacy_cpu
, ARM_ARCH_V3
, N_("use -mcpu=arm600")},
30568 {"marm610", &legacy_cpu
, ARM_ARCH_V3
, N_("use -mcpu=arm610")},
30569 {"m610", &legacy_cpu
, ARM_ARCH_V3
, N_("use -mcpu=arm610")},
30570 {"marm620", &legacy_cpu
, ARM_ARCH_V3
, N_("use -mcpu=arm620")},
30571 {"m620", &legacy_cpu
, ARM_ARCH_V3
, N_("use -mcpu=arm620")},
30572 {"marm7", &legacy_cpu
, ARM_ARCH_V3
, N_("use -mcpu=arm7")},
30573 {"m7", &legacy_cpu
, ARM_ARCH_V3
, N_("use -mcpu=arm7")},
30574 {"marm70", &legacy_cpu
, ARM_ARCH_V3
, N_("use -mcpu=arm70")},
30575 {"m70", &legacy_cpu
, ARM_ARCH_V3
, N_("use -mcpu=arm70")},
30576 {"marm700", &legacy_cpu
, ARM_ARCH_V3
, N_("use -mcpu=arm700")},
30577 {"m700", &legacy_cpu
, ARM_ARCH_V3
, N_("use -mcpu=arm700")},
30578 {"marm700i", &legacy_cpu
, ARM_ARCH_V3
, N_("use -mcpu=arm700i")},
30579 {"m700i", &legacy_cpu
, ARM_ARCH_V3
, N_("use -mcpu=arm700i")},
30580 {"marm710", &legacy_cpu
, ARM_ARCH_V3
, N_("use -mcpu=arm710")},
30581 {"m710", &legacy_cpu
, ARM_ARCH_V3
, N_("use -mcpu=arm710")},
30582 {"marm710c", &legacy_cpu
, ARM_ARCH_V3
, N_("use -mcpu=arm710c")},
30583 {"m710c", &legacy_cpu
, ARM_ARCH_V3
, N_("use -mcpu=arm710c")},
30584 {"marm720", &legacy_cpu
, ARM_ARCH_V3
, N_("use -mcpu=arm720")},
30585 {"m720", &legacy_cpu
, ARM_ARCH_V3
, N_("use -mcpu=arm720")},
30586 {"marm7d", &legacy_cpu
, ARM_ARCH_V3
, N_("use -mcpu=arm7d")},
30587 {"m7d", &legacy_cpu
, ARM_ARCH_V3
, N_("use -mcpu=arm7d")},
30588 {"marm7di", &legacy_cpu
, ARM_ARCH_V3
, N_("use -mcpu=arm7di")},
30589 {"m7di", &legacy_cpu
, ARM_ARCH_V3
, N_("use -mcpu=arm7di")},
30590 {"marm7m", &legacy_cpu
, ARM_ARCH_V3M
, N_("use -mcpu=arm7m")},
30591 {"m7m", &legacy_cpu
, ARM_ARCH_V3M
, N_("use -mcpu=arm7m")},
30592 {"marm7dm", &legacy_cpu
, ARM_ARCH_V3M
, N_("use -mcpu=arm7dm")},
30593 {"m7dm", &legacy_cpu
, ARM_ARCH_V3M
, N_("use -mcpu=arm7dm")},
30594 {"marm7dmi", &legacy_cpu
, ARM_ARCH_V3M
, N_("use -mcpu=arm7dmi")},
30595 {"m7dmi", &legacy_cpu
, ARM_ARCH_V3M
, N_("use -mcpu=arm7dmi")},
30596 {"marm7100", &legacy_cpu
, ARM_ARCH_V3
, N_("use -mcpu=arm7100")},
30597 {"m7100", &legacy_cpu
, ARM_ARCH_V3
, N_("use -mcpu=arm7100")},
30598 {"marm7500", &legacy_cpu
, ARM_ARCH_V3
, N_("use -mcpu=arm7500")},
30599 {"m7500", &legacy_cpu
, ARM_ARCH_V3
, N_("use -mcpu=arm7500")},
30600 {"marm7500fe", &legacy_cpu
, ARM_ARCH_V3
, N_("use -mcpu=arm7500fe")},
30601 {"m7500fe", &legacy_cpu
, ARM_ARCH_V3
, N_("use -mcpu=arm7500fe")},
30602 {"marm7t", &legacy_cpu
, ARM_ARCH_V4T
, N_("use -mcpu=arm7tdmi")},
30603 {"m7t", &legacy_cpu
, ARM_ARCH_V4T
, N_("use -mcpu=arm7tdmi")},
30604 {"marm7tdmi", &legacy_cpu
, ARM_ARCH_V4T
, N_("use -mcpu=arm7tdmi")},
30605 {"m7tdmi", &legacy_cpu
, ARM_ARCH_V4T
, N_("use -mcpu=arm7tdmi")},
30606 {"marm710t", &legacy_cpu
, ARM_ARCH_V4T
, N_("use -mcpu=arm710t")},
30607 {"m710t", &legacy_cpu
, ARM_ARCH_V4T
, N_("use -mcpu=arm710t")},
30608 {"marm720t", &legacy_cpu
, ARM_ARCH_V4T
, N_("use -mcpu=arm720t")},
30609 {"m720t", &legacy_cpu
, ARM_ARCH_V4T
, N_("use -mcpu=arm720t")},
30610 {"marm740t", &legacy_cpu
, ARM_ARCH_V4T
, N_("use -mcpu=arm740t")},
30611 {"m740t", &legacy_cpu
, ARM_ARCH_V4T
, N_("use -mcpu=arm740t")},
30612 {"marm8", &legacy_cpu
, ARM_ARCH_V4
, N_("use -mcpu=arm8")},
30613 {"m8", &legacy_cpu
, ARM_ARCH_V4
, N_("use -mcpu=arm8")},
30614 {"marm810", &legacy_cpu
, ARM_ARCH_V4
, N_("use -mcpu=arm810")},
30615 {"m810", &legacy_cpu
, ARM_ARCH_V4
, N_("use -mcpu=arm810")},
30616 {"marm9", &legacy_cpu
, ARM_ARCH_V4T
, N_("use -mcpu=arm9")},
30617 {"m9", &legacy_cpu
, ARM_ARCH_V4T
, N_("use -mcpu=arm9")},
30618 {"marm9tdmi", &legacy_cpu
, ARM_ARCH_V4T
, N_("use -mcpu=arm9tdmi")},
30619 {"m9tdmi", &legacy_cpu
, ARM_ARCH_V4T
, N_("use -mcpu=arm9tdmi")},
30620 {"marm920", &legacy_cpu
, ARM_ARCH_V4T
, N_("use -mcpu=arm920")},
30621 {"m920", &legacy_cpu
, ARM_ARCH_V4T
, N_("use -mcpu=arm920")},
30622 {"marm940", &legacy_cpu
, ARM_ARCH_V4T
, N_("use -mcpu=arm940")},
30623 {"m940", &legacy_cpu
, ARM_ARCH_V4T
, N_("use -mcpu=arm940")},
30624 {"mstrongarm", &legacy_cpu
, ARM_ARCH_V4
, N_("use -mcpu=strongarm")},
30625 {"mstrongarm110", &legacy_cpu
, ARM_ARCH_V4
,
30626 N_("use -mcpu=strongarm110")},
30627 {"mstrongarm1100", &legacy_cpu
, ARM_ARCH_V4
,
30628 N_("use -mcpu=strongarm1100")},
30629 {"mstrongarm1110", &legacy_cpu
, ARM_ARCH_V4
,
30630 N_("use -mcpu=strongarm1110")},
30631 {"mxscale", &legacy_cpu
, ARM_ARCH_XSCALE
, N_("use -mcpu=xscale")},
30632 {"miwmmxt", &legacy_cpu
, ARM_ARCH_IWMMXT
, N_("use -mcpu=iwmmxt")},
30633 {"mall", &legacy_cpu
, ARM_ANY
, N_("use -mcpu=all")},
30635 /* Architecture variants -- don't add any more to this list either. */
30636 {"mv2", &legacy_cpu
, ARM_ARCH_V2
, N_("use -march=armv2")},
30637 {"marmv2", &legacy_cpu
, ARM_ARCH_V2
, N_("use -march=armv2")},
30638 {"mv2a", &legacy_cpu
, ARM_ARCH_V2S
, N_("use -march=armv2a")},
30639 {"marmv2a", &legacy_cpu
, ARM_ARCH_V2S
, N_("use -march=armv2a")},
30640 {"mv3", &legacy_cpu
, ARM_ARCH_V3
, N_("use -march=armv3")},
30641 {"marmv3", &legacy_cpu
, ARM_ARCH_V3
, N_("use -march=armv3")},
30642 {"mv3m", &legacy_cpu
, ARM_ARCH_V3M
, N_("use -march=armv3m")},
30643 {"marmv3m", &legacy_cpu
, ARM_ARCH_V3M
, N_("use -march=armv3m")},
30644 {"mv4", &legacy_cpu
, ARM_ARCH_V4
, N_("use -march=armv4")},
30645 {"marmv4", &legacy_cpu
, ARM_ARCH_V4
, N_("use -march=armv4")},
30646 {"mv4t", &legacy_cpu
, ARM_ARCH_V4T
, N_("use -march=armv4t")},
30647 {"marmv4t", &legacy_cpu
, ARM_ARCH_V4T
, N_("use -march=armv4t")},
30648 {"mv5", &legacy_cpu
, ARM_ARCH_V5
, N_("use -march=armv5")},
30649 {"marmv5", &legacy_cpu
, ARM_ARCH_V5
, N_("use -march=armv5")},
30650 {"mv5t", &legacy_cpu
, ARM_ARCH_V5T
, N_("use -march=armv5t")},
30651 {"marmv5t", &legacy_cpu
, ARM_ARCH_V5T
, N_("use -march=armv5t")},
30652 {"mv5e", &legacy_cpu
, ARM_ARCH_V5TE
, N_("use -march=armv5te")},
30653 {"marmv5e", &legacy_cpu
, ARM_ARCH_V5TE
, N_("use -march=armv5te")},
30655 /* Floating point variants -- don't add any more to this list either. */
30656 {"mfpe-old", &legacy_fpu
, FPU_ARCH_FPE
, N_("use -mfpu=fpe")},
30657 {"mfpa10", &legacy_fpu
, FPU_ARCH_FPA
, N_("use -mfpu=fpa10")},
30658 {"mfpa11", &legacy_fpu
, FPU_ARCH_FPA
, N_("use -mfpu=fpa11")},
30659 {"mno-fpu", &legacy_fpu
, ARM_ARCH_NONE
,
30660 N_("use either -mfpu=softfpa or -mfpu=softvfp")},
30662 {NULL
, NULL
, ARM_ARCH_NONE
, NULL
}
30665 struct arm_cpu_option_table
30669 const arm_feature_set value
;
30670 const arm_feature_set ext
;
30671 /* For some CPUs we assume an FPU unless the user explicitly sets
30673 const arm_feature_set default_fpu
;
30674 /* The canonical name of the CPU, or NULL to use NAME converted to upper
30676 const char * canonical_name
;
30679 /* This list should, at a minimum, contain all the cpu names
30680 recognized by GCC. */
30681 #define ARM_CPU_OPT(N, CN, V, E, DF) { N, sizeof (N) - 1, V, E, DF, CN }
30683 static const struct arm_cpu_option_table arm_cpus
[] =
30685 ARM_CPU_OPT ("all", NULL
, ARM_ANY
,
30688 ARM_CPU_OPT ("arm1", NULL
, ARM_ARCH_V1
,
30691 ARM_CPU_OPT ("arm2", NULL
, ARM_ARCH_V2
,
30694 ARM_CPU_OPT ("arm250", NULL
, ARM_ARCH_V2S
,
30697 ARM_CPU_OPT ("arm3", NULL
, ARM_ARCH_V2S
,
30700 ARM_CPU_OPT ("arm6", NULL
, ARM_ARCH_V3
,
30703 ARM_CPU_OPT ("arm60", NULL
, ARM_ARCH_V3
,
30706 ARM_CPU_OPT ("arm600", NULL
, ARM_ARCH_V3
,
30709 ARM_CPU_OPT ("arm610", NULL
, ARM_ARCH_V3
,
30712 ARM_CPU_OPT ("arm620", NULL
, ARM_ARCH_V3
,
30715 ARM_CPU_OPT ("arm7", NULL
, ARM_ARCH_V3
,
30718 ARM_CPU_OPT ("arm7m", NULL
, ARM_ARCH_V3M
,
30721 ARM_CPU_OPT ("arm7d", NULL
, ARM_ARCH_V3
,
30724 ARM_CPU_OPT ("arm7dm", NULL
, ARM_ARCH_V3M
,
30727 ARM_CPU_OPT ("arm7di", NULL
, ARM_ARCH_V3
,
30730 ARM_CPU_OPT ("arm7dmi", NULL
, ARM_ARCH_V3M
,
30733 ARM_CPU_OPT ("arm70", NULL
, ARM_ARCH_V3
,
30736 ARM_CPU_OPT ("arm700", NULL
, ARM_ARCH_V3
,
30739 ARM_CPU_OPT ("arm700i", NULL
, ARM_ARCH_V3
,
30742 ARM_CPU_OPT ("arm710", NULL
, ARM_ARCH_V3
,
30745 ARM_CPU_OPT ("arm710t", NULL
, ARM_ARCH_V4T
,
30748 ARM_CPU_OPT ("arm720", NULL
, ARM_ARCH_V3
,
30751 ARM_CPU_OPT ("arm720t", NULL
, ARM_ARCH_V4T
,
30754 ARM_CPU_OPT ("arm740t", NULL
, ARM_ARCH_V4T
,
30757 ARM_CPU_OPT ("arm710c", NULL
, ARM_ARCH_V3
,
30760 ARM_CPU_OPT ("arm7100", NULL
, ARM_ARCH_V3
,
30763 ARM_CPU_OPT ("arm7500", NULL
, ARM_ARCH_V3
,
30766 ARM_CPU_OPT ("arm7500fe", NULL
, ARM_ARCH_V3
,
30769 ARM_CPU_OPT ("arm7t", NULL
, ARM_ARCH_V4T
,
30772 ARM_CPU_OPT ("arm7tdmi", NULL
, ARM_ARCH_V4T
,
30775 ARM_CPU_OPT ("arm7tdmi-s", NULL
, ARM_ARCH_V4T
,
30778 ARM_CPU_OPT ("arm8", NULL
, ARM_ARCH_V4
,
30781 ARM_CPU_OPT ("arm810", NULL
, ARM_ARCH_V4
,
30784 ARM_CPU_OPT ("strongarm", NULL
, ARM_ARCH_V4
,
30787 ARM_CPU_OPT ("strongarm1", NULL
, ARM_ARCH_V4
,
30790 ARM_CPU_OPT ("strongarm110", NULL
, ARM_ARCH_V4
,
30793 ARM_CPU_OPT ("strongarm1100", NULL
, ARM_ARCH_V4
,
30796 ARM_CPU_OPT ("strongarm1110", NULL
, ARM_ARCH_V4
,
30799 ARM_CPU_OPT ("arm9", NULL
, ARM_ARCH_V4T
,
30802 ARM_CPU_OPT ("arm920", "ARM920T", ARM_ARCH_V4T
,
30805 ARM_CPU_OPT ("arm920t", NULL
, ARM_ARCH_V4T
,
30808 ARM_CPU_OPT ("arm922t", NULL
, ARM_ARCH_V4T
,
30811 ARM_CPU_OPT ("arm940t", NULL
, ARM_ARCH_V4T
,
30814 ARM_CPU_OPT ("arm9tdmi", NULL
, ARM_ARCH_V4T
,
30817 ARM_CPU_OPT ("fa526", NULL
, ARM_ARCH_V4
,
30820 ARM_CPU_OPT ("fa626", NULL
, ARM_ARCH_V4
,
30824 /* For V5 or later processors we default to using VFP; but the user
30825 should really set the FPU type explicitly. */
30826 ARM_CPU_OPT ("arm9e-r0", NULL
, ARM_ARCH_V5TExP
,
30829 ARM_CPU_OPT ("arm9e", NULL
, ARM_ARCH_V5TE
,
30832 ARM_CPU_OPT ("arm926ej", "ARM926EJ-S", ARM_ARCH_V5TEJ
,
30835 ARM_CPU_OPT ("arm926ejs", "ARM926EJ-S", ARM_ARCH_V5TEJ
,
30838 ARM_CPU_OPT ("arm926ej-s", NULL
, ARM_ARCH_V5TEJ
,
30841 ARM_CPU_OPT ("arm946e-r0", NULL
, ARM_ARCH_V5TExP
,
30844 ARM_CPU_OPT ("arm946e", "ARM946E-S", ARM_ARCH_V5TE
,
30847 ARM_CPU_OPT ("arm946e-s", NULL
, ARM_ARCH_V5TE
,
30850 ARM_CPU_OPT ("arm966e-r0", NULL
, ARM_ARCH_V5TExP
,
30853 ARM_CPU_OPT ("arm966e", "ARM966E-S", ARM_ARCH_V5TE
,
30856 ARM_CPU_OPT ("arm966e-s", NULL
, ARM_ARCH_V5TE
,
30859 ARM_CPU_OPT ("arm968e-s", NULL
, ARM_ARCH_V5TE
,
30862 ARM_CPU_OPT ("arm10t", NULL
, ARM_ARCH_V5T
,
30865 ARM_CPU_OPT ("arm10tdmi", NULL
, ARM_ARCH_V5T
,
30868 ARM_CPU_OPT ("arm10e", NULL
, ARM_ARCH_V5TE
,
30871 ARM_CPU_OPT ("arm1020", "ARM1020E", ARM_ARCH_V5TE
,
30874 ARM_CPU_OPT ("arm1020t", NULL
, ARM_ARCH_V5T
,
30877 ARM_CPU_OPT ("arm1020e", NULL
, ARM_ARCH_V5TE
,
30880 ARM_CPU_OPT ("arm1022e", NULL
, ARM_ARCH_V5TE
,
30883 ARM_CPU_OPT ("arm1026ejs", "ARM1026EJ-S", ARM_ARCH_V5TEJ
,
30886 ARM_CPU_OPT ("arm1026ej-s", NULL
, ARM_ARCH_V5TEJ
,
30889 ARM_CPU_OPT ("fa606te", NULL
, ARM_ARCH_V5TE
,
30892 ARM_CPU_OPT ("fa616te", NULL
, ARM_ARCH_V5TE
,
30895 ARM_CPU_OPT ("fa626te", NULL
, ARM_ARCH_V5TE
,
30898 ARM_CPU_OPT ("fmp626", NULL
, ARM_ARCH_V5TE
,
30901 ARM_CPU_OPT ("fa726te", NULL
, ARM_ARCH_V5TE
,
30904 ARM_CPU_OPT ("arm1136js", "ARM1136J-S", ARM_ARCH_V6
,
30907 ARM_CPU_OPT ("arm1136j-s", NULL
, ARM_ARCH_V6
,
30910 ARM_CPU_OPT ("arm1136jfs", "ARM1136JF-S", ARM_ARCH_V6
,
30913 ARM_CPU_OPT ("arm1136jf-s", NULL
, ARM_ARCH_V6
,
30916 ARM_CPU_OPT ("mpcore", "MPCore", ARM_ARCH_V6K
,
30919 ARM_CPU_OPT ("mpcorenovfp", "MPCore", ARM_ARCH_V6K
,
30922 ARM_CPU_OPT ("arm1156t2-s", NULL
, ARM_ARCH_V6T2
,
30925 ARM_CPU_OPT ("arm1156t2f-s", NULL
, ARM_ARCH_V6T2
,
30928 ARM_CPU_OPT ("arm1176jz-s", NULL
, ARM_ARCH_V6KZ
,
30931 ARM_CPU_OPT ("arm1176jzf-s", NULL
, ARM_ARCH_V6KZ
,
30934 ARM_CPU_OPT ("cortex-a5", "Cortex-A5", ARM_ARCH_V7A
,
30935 ARM_FEATURE_CORE_LOW (ARM_EXT_MP
| ARM_EXT_SEC
),
30937 ARM_CPU_OPT ("cortex-a7", "Cortex-A7", ARM_ARCH_V7VE
,
30939 FPU_ARCH_NEON_VFP_V4
),
30940 ARM_CPU_OPT ("cortex-a8", "Cortex-A8", ARM_ARCH_V7A
,
30941 ARM_FEATURE_CORE_LOW (ARM_EXT_SEC
),
30942 ARM_FEATURE_COPROC (FPU_VFP_V3
| FPU_NEON_EXT_V1
)),
30943 ARM_CPU_OPT ("cortex-a9", "Cortex-A9", ARM_ARCH_V7A
,
30944 ARM_FEATURE_CORE_LOW (ARM_EXT_MP
| ARM_EXT_SEC
),
30945 ARM_FEATURE_COPROC (FPU_VFP_V3
| FPU_NEON_EXT_V1
)),
30946 ARM_CPU_OPT ("cortex-a12", "Cortex-A12", ARM_ARCH_V7VE
,
30948 FPU_ARCH_NEON_VFP_V4
),
30949 ARM_CPU_OPT ("cortex-a15", "Cortex-A15", ARM_ARCH_V7VE
,
30951 FPU_ARCH_NEON_VFP_V4
),
30952 ARM_CPU_OPT ("cortex-a17", "Cortex-A17", ARM_ARCH_V7VE
,
30954 FPU_ARCH_NEON_VFP_V4
),
30955 ARM_CPU_OPT ("cortex-a32", "Cortex-A32", ARM_ARCH_V8A
,
30956 ARM_FEATURE_CORE_HIGH (ARM_EXT2_CRC
),
30957 FPU_ARCH_CRYPTO_NEON_VFP_ARMV8
),
30958 ARM_CPU_OPT ("cortex-a35", "Cortex-A35", ARM_ARCH_V8A
,
30959 ARM_FEATURE_CORE_HIGH (ARM_EXT2_CRC
),
30960 FPU_ARCH_CRYPTO_NEON_VFP_ARMV8
),
30961 ARM_CPU_OPT ("cortex-a53", "Cortex-A53", ARM_ARCH_V8A
,
30962 ARM_FEATURE_CORE_HIGH (ARM_EXT2_CRC
),
30963 FPU_ARCH_CRYPTO_NEON_VFP_ARMV8
),
30964 ARM_CPU_OPT ("cortex-a55", "Cortex-A55", ARM_ARCH_V8_2A
,
30965 ARM_FEATURE_CORE_HIGH (ARM_EXT2_FP16_INST
),
30966 FPU_ARCH_CRYPTO_NEON_VFP_ARMV8_DOTPROD
),
30967 ARM_CPU_OPT ("cortex-a57", "Cortex-A57", ARM_ARCH_V8A
,
30968 ARM_FEATURE_CORE_HIGH (ARM_EXT2_CRC
),
30969 FPU_ARCH_CRYPTO_NEON_VFP_ARMV8
),
30970 ARM_CPU_OPT ("cortex-a72", "Cortex-A72", ARM_ARCH_V8A
,
30971 ARM_FEATURE_CORE_HIGH (ARM_EXT2_CRC
),
30972 FPU_ARCH_CRYPTO_NEON_VFP_ARMV8
),
30973 ARM_CPU_OPT ("cortex-a73", "Cortex-A73", ARM_ARCH_V8A
,
30974 ARM_FEATURE_CORE_HIGH (ARM_EXT2_CRC
),
30975 FPU_ARCH_CRYPTO_NEON_VFP_ARMV8
),
30976 ARM_CPU_OPT ("cortex-a75", "Cortex-A75", ARM_ARCH_V8_2A
,
30977 ARM_FEATURE_CORE_HIGH (ARM_EXT2_FP16_INST
),
30978 FPU_ARCH_CRYPTO_NEON_VFP_ARMV8_DOTPROD
),
30979 ARM_CPU_OPT ("cortex-a76", "Cortex-A76", ARM_ARCH_V8_2A
,
30980 ARM_FEATURE_CORE_HIGH (ARM_EXT2_FP16_INST
),
30981 FPU_ARCH_CRYPTO_NEON_VFP_ARMV8_DOTPROD
),
30982 ARM_CPU_OPT ("cortex-a76ae", "Cortex-A76AE", ARM_ARCH_V8_2A
,
30983 ARM_FEATURE_CORE_HIGH (ARM_EXT2_FP16_INST
),
30984 FPU_ARCH_CRYPTO_NEON_VFP_ARMV8_DOTPROD
),
30985 ARM_CPU_OPT ("cortex-a77", "Cortex-A77", ARM_ARCH_V8_2A
,
30986 ARM_FEATURE_CORE_HIGH (ARM_EXT2_FP16_INST
),
30987 FPU_ARCH_CRYPTO_NEON_VFP_ARMV8_DOTPROD
),
30988 ARM_CPU_OPT ("ares", "Ares", ARM_ARCH_V8_2A
,
30989 ARM_FEATURE_CORE_HIGH (ARM_EXT2_FP16_INST
),
30990 FPU_ARCH_CRYPTO_NEON_VFP_ARMV8_DOTPROD
),
30991 ARM_CPU_OPT ("cortex-r4", "Cortex-R4", ARM_ARCH_V7R
,
30994 ARM_CPU_OPT ("cortex-r4f", "Cortex-R4F", ARM_ARCH_V7R
,
30996 FPU_ARCH_VFP_V3D16
),
30997 ARM_CPU_OPT ("cortex-r5", "Cortex-R5", ARM_ARCH_V7R
,
30998 ARM_FEATURE_CORE_LOW (ARM_EXT_ADIV
),
31000 ARM_CPU_OPT ("cortex-r7", "Cortex-R7", ARM_ARCH_V7R
,
31001 ARM_FEATURE_CORE_LOW (ARM_EXT_ADIV
),
31002 FPU_ARCH_VFP_V3D16
),
31003 ARM_CPU_OPT ("cortex-r8", "Cortex-R8", ARM_ARCH_V7R
,
31004 ARM_FEATURE_CORE_LOW (ARM_EXT_ADIV
),
31005 FPU_ARCH_VFP_V3D16
),
31006 ARM_CPU_OPT ("cortex-r52", "Cortex-R52", ARM_ARCH_V8R
,
31007 ARM_FEATURE_CORE_HIGH (ARM_EXT2_CRC
),
31008 FPU_ARCH_NEON_VFP_ARMV8
),
31009 ARM_CPU_OPT ("cortex-m35p", "Cortex-M35P", ARM_ARCH_V8M_MAIN
,
31010 ARM_FEATURE_CORE_LOW (ARM_EXT_V5ExP
| ARM_EXT_V6_DSP
),
31012 ARM_CPU_OPT ("cortex-m33", "Cortex-M33", ARM_ARCH_V8M_MAIN
,
31013 ARM_FEATURE_CORE_LOW (ARM_EXT_V5ExP
| ARM_EXT_V6_DSP
),
31015 ARM_CPU_OPT ("cortex-m23", "Cortex-M23", ARM_ARCH_V8M_BASE
,
31018 ARM_CPU_OPT ("cortex-m7", "Cortex-M7", ARM_ARCH_V7EM
,
31021 ARM_CPU_OPT ("cortex-m4", "Cortex-M4", ARM_ARCH_V7EM
,
31024 ARM_CPU_OPT ("cortex-m3", "Cortex-M3", ARM_ARCH_V7M
,
31027 ARM_CPU_OPT ("cortex-m1", "Cortex-M1", ARM_ARCH_V6SM
,
31030 ARM_CPU_OPT ("cortex-m0", "Cortex-M0", ARM_ARCH_V6SM
,
31033 ARM_CPU_OPT ("cortex-m0plus", "Cortex-M0+", ARM_ARCH_V6SM
,
31036 ARM_CPU_OPT ("exynos-m1", "Samsung Exynos M1", ARM_ARCH_V8A
,
31037 ARM_FEATURE_CORE_HIGH (ARM_EXT2_CRC
),
31038 FPU_ARCH_CRYPTO_NEON_VFP_ARMV8
),
31039 ARM_CPU_OPT ("neoverse-n1", "Neoverse N1", ARM_ARCH_V8_2A
,
31040 ARM_FEATURE_CORE_HIGH (ARM_EXT2_FP16_INST
),
31041 FPU_ARCH_CRYPTO_NEON_VFP_ARMV8_DOTPROD
),
31042 /* ??? XSCALE is really an architecture. */
31043 ARM_CPU_OPT ("xscale", NULL
, ARM_ARCH_XSCALE
,
31047 /* ??? iwmmxt is not a processor. */
31048 ARM_CPU_OPT ("iwmmxt", NULL
, ARM_ARCH_IWMMXT
,
31051 ARM_CPU_OPT ("iwmmxt2", NULL
, ARM_ARCH_IWMMXT2
,
31054 ARM_CPU_OPT ("i80200", NULL
, ARM_ARCH_XSCALE
,
31059 ARM_CPU_OPT ("ep9312", "ARM920T",
31060 ARM_FEATURE_LOW (ARM_AEXT_V4T
, ARM_CEXT_MAVERICK
),
31061 ARM_ARCH_NONE
, FPU_ARCH_MAVERICK
),
31063 /* Marvell processors. */
31064 ARM_CPU_OPT ("marvell-pj4", NULL
, ARM_ARCH_V7A
,
31065 ARM_FEATURE_CORE_LOW (ARM_EXT_MP
| ARM_EXT_SEC
),
31066 FPU_ARCH_VFP_V3D16
),
31067 ARM_CPU_OPT ("marvell-whitney", NULL
, ARM_ARCH_V7A
,
31068 ARM_FEATURE_CORE_LOW (ARM_EXT_MP
| ARM_EXT_SEC
),
31069 FPU_ARCH_NEON_VFP_V4
),
31071 /* APM X-Gene family. */
31072 ARM_CPU_OPT ("xgene1", "APM X-Gene 1", ARM_ARCH_V8A
,
31074 FPU_ARCH_CRYPTO_NEON_VFP_ARMV8
),
31075 ARM_CPU_OPT ("xgene2", "APM X-Gene 2", ARM_ARCH_V8A
,
31076 ARM_FEATURE_CORE_HIGH (ARM_EXT2_CRC
),
31077 FPU_ARCH_CRYPTO_NEON_VFP_ARMV8
),
31079 { NULL
, 0, ARM_ARCH_NONE
, ARM_ARCH_NONE
, ARM_ARCH_NONE
, NULL
}
31083 struct arm_ext_table
31087 const arm_feature_set merge
;
31088 const arm_feature_set clear
;
31091 struct arm_arch_option_table
31095 const arm_feature_set value
;
31096 const arm_feature_set default_fpu
;
31097 const struct arm_ext_table
* ext_table
;
31100 /* Used to add support for +E and +noE extension. */
31101 #define ARM_EXT(E, M, C) { E, sizeof (E) - 1, M, C }
31102 /* Used to add support for a +E extension. */
31103 #define ARM_ADD(E, M) { E, sizeof(E) - 1, M, ARM_ARCH_NONE }
31104 /* Used to add support for a +noE extension. */
31105 #define ARM_REMOVE(E, C) { E, sizeof(E) -1, ARM_ARCH_NONE, C }
31107 #define ALL_FP ARM_FEATURE (0, ARM_EXT2_FP16_INST | ARM_EXT2_FP16_FML, \
31108 ~0 & ~FPU_ENDIAN_PURE)
31110 static const struct arm_ext_table armv5te_ext_table
[] =
31112 ARM_EXT ("fp", FPU_ARCH_VFP_V2
, ALL_FP
),
31113 { NULL
, 0, ARM_ARCH_NONE
, ARM_ARCH_NONE
}
31116 static const struct arm_ext_table armv7_ext_table
[] =
31118 ARM_EXT ("fp", FPU_ARCH_VFP_V3D16
, ALL_FP
),
31119 { NULL
, 0, ARM_ARCH_NONE
, ARM_ARCH_NONE
}
31122 static const struct arm_ext_table armv7ve_ext_table
[] =
31124 ARM_EXT ("fp", FPU_ARCH_VFP_V4D16
, ALL_FP
),
31125 ARM_ADD ("vfpv3-d16", FPU_ARCH_VFP_V3D16
),
31126 ARM_ADD ("vfpv3", FPU_ARCH_VFP_V3
),
31127 ARM_ADD ("vfpv3-d16-fp16", FPU_ARCH_VFP_V3D16_FP16
),
31128 ARM_ADD ("vfpv3-fp16", FPU_ARCH_VFP_V3_FP16
),
31129 ARM_ADD ("vfpv4-d16", FPU_ARCH_VFP_V4D16
), /* Alias for +fp. */
31130 ARM_ADD ("vfpv4", FPU_ARCH_VFP_V4
),
31132 ARM_EXT ("simd", FPU_ARCH_NEON_VFP_V4
,
31133 ARM_FEATURE_COPROC (FPU_NEON_EXT_V1
| FPU_NEON_EXT_FMA
)),
31135 /* Aliases for +simd. */
31136 ARM_ADD ("neon-vfpv4", FPU_ARCH_NEON_VFP_V4
),
31138 ARM_ADD ("neon", FPU_ARCH_VFP_V3_PLUS_NEON_V1
),
31139 ARM_ADD ("neon-vfpv3", FPU_ARCH_VFP_V3_PLUS_NEON_V1
),
31140 ARM_ADD ("neon-fp16", FPU_ARCH_NEON_FP16
),
31142 { NULL
, 0, ARM_ARCH_NONE
, ARM_ARCH_NONE
}
31145 static const struct arm_ext_table armv7a_ext_table
[] =
31147 ARM_EXT ("fp", FPU_ARCH_VFP_V3D16
, ALL_FP
),
31148 ARM_ADD ("vfpv3-d16", FPU_ARCH_VFP_V3D16
), /* Alias for +fp. */
31149 ARM_ADD ("vfpv3", FPU_ARCH_VFP_V3
),
31150 ARM_ADD ("vfpv3-d16-fp16", FPU_ARCH_VFP_V3D16_FP16
),
31151 ARM_ADD ("vfpv3-fp16", FPU_ARCH_VFP_V3_FP16
),
31152 ARM_ADD ("vfpv4-d16", FPU_ARCH_VFP_V4D16
),
31153 ARM_ADD ("vfpv4", FPU_ARCH_VFP_V4
),
31155 ARM_EXT ("simd", FPU_ARCH_VFP_V3_PLUS_NEON_V1
,
31156 ARM_FEATURE_COPROC (FPU_NEON_EXT_V1
| FPU_NEON_EXT_FMA
)),
31158 /* Aliases for +simd. */
31159 ARM_ADD ("neon", FPU_ARCH_VFP_V3_PLUS_NEON_V1
),
31160 ARM_ADD ("neon-vfpv3", FPU_ARCH_VFP_V3_PLUS_NEON_V1
),
31162 ARM_ADD ("neon-fp16", FPU_ARCH_NEON_FP16
),
31163 ARM_ADD ("neon-vfpv4", FPU_ARCH_NEON_VFP_V4
),
31165 ARM_ADD ("mp", ARM_FEATURE_CORE_LOW (ARM_EXT_MP
)),
31166 ARM_ADD ("sec", ARM_FEATURE_CORE_LOW (ARM_EXT_SEC
)),
31167 { NULL
, 0, ARM_ARCH_NONE
, ARM_ARCH_NONE
}
31170 static const struct arm_ext_table armv7r_ext_table
[] =
31172 ARM_ADD ("fp.sp", FPU_ARCH_VFP_V3xD
),
31173 ARM_ADD ("vfpv3xd", FPU_ARCH_VFP_V3xD
), /* Alias for +fp.sp. */
31174 ARM_EXT ("fp", FPU_ARCH_VFP_V3D16
, ALL_FP
),
31175 ARM_ADD ("vfpv3-d16", FPU_ARCH_VFP_V3D16
), /* Alias for +fp. */
31176 ARM_ADD ("vfpv3xd-fp16", FPU_ARCH_VFP_V3xD_FP16
),
31177 ARM_ADD ("vfpv3-d16-fp16", FPU_ARCH_VFP_V3D16_FP16
),
31178 ARM_EXT ("idiv", ARM_FEATURE_CORE_LOW (ARM_EXT_ADIV
| ARM_EXT_DIV
),
31179 ARM_FEATURE_CORE_LOW (ARM_EXT_ADIV
| ARM_EXT_DIV
)),
31180 { NULL
, 0, ARM_ARCH_NONE
, ARM_ARCH_NONE
}
31183 static const struct arm_ext_table armv7em_ext_table
[] =
31185 ARM_EXT ("fp", FPU_ARCH_VFP_V4_SP_D16
, ALL_FP
),
31186 /* Alias for +fp, used to be known as fpv4-sp-d16. */
31187 ARM_ADD ("vfpv4-sp-d16", FPU_ARCH_VFP_V4_SP_D16
),
31188 ARM_ADD ("fpv5", FPU_ARCH_VFP_V5_SP_D16
),
31189 ARM_ADD ("fp.dp", FPU_ARCH_VFP_V5D16
),
31190 ARM_ADD ("fpv5-d16", FPU_ARCH_VFP_V5D16
),
31191 { NULL
, 0, ARM_ARCH_NONE
, ARM_ARCH_NONE
}
31194 static const struct arm_ext_table armv8a_ext_table
[] =
31196 ARM_ADD ("crc", ARM_FEATURE_CORE_HIGH (ARM_EXT2_CRC
)),
31197 ARM_ADD ("simd", FPU_ARCH_NEON_VFP_ARMV8
),
31198 ARM_EXT ("crypto", FPU_ARCH_CRYPTO_NEON_VFP_ARMV8
,
31199 ARM_FEATURE_COPROC (FPU_CRYPTO_ARMV8
)),
31201 /* Armv8-a does not allow an FP implementation without SIMD, so the user
31202 should use the +simd option to turn on FP. */
31203 ARM_REMOVE ("fp", ALL_FP
),
31204 ARM_ADD ("sb", ARM_FEATURE_CORE_HIGH (ARM_EXT2_SB
)),
31205 ARM_ADD ("predres", ARM_FEATURE_CORE_HIGH (ARM_EXT2_PREDRES
)),
31206 { NULL
, 0, ARM_ARCH_NONE
, ARM_ARCH_NONE
}
31210 static const struct arm_ext_table armv81a_ext_table
[] =
31212 ARM_ADD ("simd", FPU_ARCH_NEON_VFP_ARMV8_1
),
31213 ARM_EXT ("crypto", FPU_ARCH_CRYPTO_NEON_VFP_ARMV8_1
,
31214 ARM_FEATURE_COPROC (FPU_CRYPTO_ARMV8
)),
31216 /* Armv8-a does not allow an FP implementation without SIMD, so the user
31217 should use the +simd option to turn on FP. */
31218 ARM_REMOVE ("fp", ALL_FP
),
31219 ARM_ADD ("sb", ARM_FEATURE_CORE_HIGH (ARM_EXT2_SB
)),
31220 ARM_ADD ("predres", ARM_FEATURE_CORE_HIGH (ARM_EXT2_PREDRES
)),
31221 { NULL
, 0, ARM_ARCH_NONE
, ARM_ARCH_NONE
}
31224 static const struct arm_ext_table armv82a_ext_table
[] =
31226 ARM_ADD ("simd", FPU_ARCH_NEON_VFP_ARMV8_1
),
31227 ARM_ADD ("fp16", FPU_ARCH_NEON_VFP_ARMV8_2_FP16
),
31228 ARM_ADD ("fp16fml", FPU_ARCH_NEON_VFP_ARMV8_2_FP16FML
),
31229 ARM_ADD ("bf16", ARM_FEATURE_CORE_HIGH (ARM_EXT2_BF16
)),
31230 ARM_ADD ("i8mm", ARM_FEATURE_CORE_HIGH (ARM_EXT2_I8MM
)),
31231 ARM_EXT ("crypto", FPU_ARCH_CRYPTO_NEON_VFP_ARMV8_1
,
31232 ARM_FEATURE_COPROC (FPU_CRYPTO_ARMV8
)),
31233 ARM_ADD ("dotprod", FPU_ARCH_DOTPROD_NEON_VFP_ARMV8
),
31235 /* Armv8-a does not allow an FP implementation without SIMD, so the user
31236 should use the +simd option to turn on FP. */
31237 ARM_REMOVE ("fp", ALL_FP
),
31238 ARM_ADD ("sb", ARM_FEATURE_CORE_HIGH (ARM_EXT2_SB
)),
31239 ARM_ADD ("predres", ARM_FEATURE_CORE_HIGH (ARM_EXT2_PREDRES
)),
31240 { NULL
, 0, ARM_ARCH_NONE
, ARM_ARCH_NONE
}
31243 static const struct arm_ext_table armv84a_ext_table
[] =
31245 ARM_ADD ("simd", FPU_ARCH_DOTPROD_NEON_VFP_ARMV8
),
31246 ARM_ADD ("fp16", FPU_ARCH_NEON_VFP_ARMV8_4_FP16FML
),
31247 ARM_ADD ("bf16", ARM_FEATURE_CORE_HIGH (ARM_EXT2_BF16
)),
31248 ARM_ADD ("i8mm", ARM_FEATURE_CORE_HIGH (ARM_EXT2_I8MM
)),
31249 ARM_EXT ("crypto", FPU_ARCH_CRYPTO_NEON_VFP_ARMV8_4
,
31250 ARM_FEATURE_COPROC (FPU_CRYPTO_ARMV8
)),
31252 /* Armv8-a does not allow an FP implementation without SIMD, so the user
31253 should use the +simd option to turn on FP. */
31254 ARM_REMOVE ("fp", ALL_FP
),
31255 ARM_ADD ("sb", ARM_FEATURE_CORE_HIGH (ARM_EXT2_SB
)),
31256 ARM_ADD ("predres", ARM_FEATURE_CORE_HIGH (ARM_EXT2_PREDRES
)),
31257 { NULL
, 0, ARM_ARCH_NONE
, ARM_ARCH_NONE
}
31260 static const struct arm_ext_table armv85a_ext_table
[] =
31262 ARM_ADD ("simd", FPU_ARCH_DOTPROD_NEON_VFP_ARMV8
),
31263 ARM_ADD ("fp16", FPU_ARCH_NEON_VFP_ARMV8_4_FP16FML
),
31264 ARM_ADD ("bf16", ARM_FEATURE_CORE_HIGH (ARM_EXT2_BF16
)),
31265 ARM_ADD ("i8mm", ARM_FEATURE_CORE_HIGH (ARM_EXT2_I8MM
)),
31266 ARM_EXT ("crypto", FPU_ARCH_CRYPTO_NEON_VFP_ARMV8_4
,
31267 ARM_FEATURE_COPROC (FPU_CRYPTO_ARMV8
)),
31269 /* Armv8-a does not allow an FP implementation without SIMD, so the user
31270 should use the +simd option to turn on FP. */
31271 ARM_REMOVE ("fp", ALL_FP
),
31272 { NULL
, 0, ARM_ARCH_NONE
, ARM_ARCH_NONE
}
31275 static const struct arm_ext_table armv86a_ext_table
[] =
31277 ARM_ADD ("i8mm", ARM_FEATURE_CORE_HIGH (ARM_EXT2_I8MM
)),
31278 { NULL
, 0, ARM_ARCH_NONE
, ARM_ARCH_NONE
}
31281 static const struct arm_ext_table armv8m_main_ext_table
[] =
31283 ARM_EXT ("dsp", ARM_FEATURE_CORE_LOW (ARM_EXT_V5ExP
| ARM_EXT_V6_DSP
),
31284 ARM_FEATURE_CORE_LOW (ARM_EXT_V5ExP
| ARM_EXT_V6_DSP
)),
31285 ARM_EXT ("fp", FPU_ARCH_VFP_V5_SP_D16
, ALL_FP
),
31286 ARM_ADD ("fp.dp", FPU_ARCH_VFP_V5D16
),
31287 { NULL
, 0, ARM_ARCH_NONE
, ARM_ARCH_NONE
}
31290 static const struct arm_ext_table armv8_1m_main_ext_table
[] =
31292 ARM_EXT ("dsp", ARM_FEATURE_CORE_LOW (ARM_EXT_V5ExP
| ARM_EXT_V6_DSP
),
31293 ARM_FEATURE_CORE_LOW (ARM_EXT_V5ExP
| ARM_EXT_V6_DSP
)),
31295 ARM_FEATURE (0, ARM_EXT2_FP16_INST
,
31296 FPU_VFP_V5_SP_D16
| FPU_VFP_EXT_FP16
| FPU_VFP_EXT_FMA
),
31299 ARM_FEATURE (0, ARM_EXT2_FP16_INST
,
31300 FPU_VFP_V5D16
| FPU_VFP_EXT_FP16
| FPU_VFP_EXT_FMA
)),
31301 ARM_EXT ("mve", ARM_FEATURE_COPROC (FPU_MVE
),
31302 ARM_FEATURE_COPROC (FPU_MVE
| FPU_MVE_FP
)),
31304 ARM_FEATURE (0, ARM_EXT2_FP16_INST
,
31305 FPU_MVE
| FPU_MVE_FP
| FPU_VFP_V5_SP_D16
|
31306 FPU_VFP_EXT_FP16
| FPU_VFP_EXT_FMA
)),
31307 { NULL
, 0, ARM_ARCH_NONE
, ARM_ARCH_NONE
}
31310 static const struct arm_ext_table armv8r_ext_table
[] =
31312 ARM_ADD ("crc", ARM_FEATURE_CORE_HIGH (ARM_EXT2_CRC
)),
31313 ARM_ADD ("simd", FPU_ARCH_NEON_VFP_ARMV8
),
31314 ARM_EXT ("crypto", FPU_ARCH_CRYPTO_NEON_VFP_ARMV8
,
31315 ARM_FEATURE_COPROC (FPU_CRYPTO_ARMV8
)),
31316 ARM_REMOVE ("fp", ALL_FP
),
31317 ARM_ADD ("fp.sp", FPU_ARCH_VFP_V5_SP_D16
),
31318 { NULL
, 0, ARM_ARCH_NONE
, ARM_ARCH_NONE
}
31321 /* This list should, at a minimum, contain all the architecture names
31322 recognized by GCC. */
31323 #define ARM_ARCH_OPT(N, V, DF) { N, sizeof (N) - 1, V, DF, NULL }
31324 #define ARM_ARCH_OPT2(N, V, DF, ext) \
31325 { N, sizeof (N) - 1, V, DF, ext##_ext_table }
31327 static const struct arm_arch_option_table arm_archs
[] =
31329 ARM_ARCH_OPT ("all", ARM_ANY
, FPU_ARCH_FPA
),
31330 ARM_ARCH_OPT ("armv1", ARM_ARCH_V1
, FPU_ARCH_FPA
),
31331 ARM_ARCH_OPT ("armv2", ARM_ARCH_V2
, FPU_ARCH_FPA
),
31332 ARM_ARCH_OPT ("armv2a", ARM_ARCH_V2S
, FPU_ARCH_FPA
),
31333 ARM_ARCH_OPT ("armv2s", ARM_ARCH_V2S
, FPU_ARCH_FPA
),
31334 ARM_ARCH_OPT ("armv3", ARM_ARCH_V3
, FPU_ARCH_FPA
),
31335 ARM_ARCH_OPT ("armv3m", ARM_ARCH_V3M
, FPU_ARCH_FPA
),
31336 ARM_ARCH_OPT ("armv4", ARM_ARCH_V4
, FPU_ARCH_FPA
),
31337 ARM_ARCH_OPT ("armv4xm", ARM_ARCH_V4xM
, FPU_ARCH_FPA
),
31338 ARM_ARCH_OPT ("armv4t", ARM_ARCH_V4T
, FPU_ARCH_FPA
),
31339 ARM_ARCH_OPT ("armv4txm", ARM_ARCH_V4TxM
, FPU_ARCH_FPA
),
31340 ARM_ARCH_OPT ("armv5", ARM_ARCH_V5
, FPU_ARCH_VFP
),
31341 ARM_ARCH_OPT ("armv5t", ARM_ARCH_V5T
, FPU_ARCH_VFP
),
31342 ARM_ARCH_OPT ("armv5txm", ARM_ARCH_V5TxM
, FPU_ARCH_VFP
),
31343 ARM_ARCH_OPT2 ("armv5te", ARM_ARCH_V5TE
, FPU_ARCH_VFP
, armv5te
),
31344 ARM_ARCH_OPT2 ("armv5texp", ARM_ARCH_V5TExP
, FPU_ARCH_VFP
, armv5te
),
31345 ARM_ARCH_OPT2 ("armv5tej", ARM_ARCH_V5TEJ
, FPU_ARCH_VFP
, armv5te
),
31346 ARM_ARCH_OPT2 ("armv6", ARM_ARCH_V6
, FPU_ARCH_VFP
, armv5te
),
31347 ARM_ARCH_OPT2 ("armv6j", ARM_ARCH_V6
, FPU_ARCH_VFP
, armv5te
),
31348 ARM_ARCH_OPT2 ("armv6k", ARM_ARCH_V6K
, FPU_ARCH_VFP
, armv5te
),
31349 ARM_ARCH_OPT2 ("armv6z", ARM_ARCH_V6Z
, FPU_ARCH_VFP
, armv5te
),
31350 /* The official spelling of this variant is ARMv6KZ, the name "armv6zk" is
31351 kept to preserve existing behaviour. */
31352 ARM_ARCH_OPT2 ("armv6kz", ARM_ARCH_V6KZ
, FPU_ARCH_VFP
, armv5te
),
31353 ARM_ARCH_OPT2 ("armv6zk", ARM_ARCH_V6KZ
, FPU_ARCH_VFP
, armv5te
),
31354 ARM_ARCH_OPT2 ("armv6t2", ARM_ARCH_V6T2
, FPU_ARCH_VFP
, armv5te
),
31355 ARM_ARCH_OPT2 ("armv6kt2", ARM_ARCH_V6KT2
, FPU_ARCH_VFP
, armv5te
),
31356 ARM_ARCH_OPT2 ("armv6zt2", ARM_ARCH_V6ZT2
, FPU_ARCH_VFP
, armv5te
),
31357 /* The official spelling of this variant is ARMv6KZ, the name "armv6zkt2" is
31358 kept to preserve existing behaviour. */
31359 ARM_ARCH_OPT2 ("armv6kzt2", ARM_ARCH_V6KZT2
, FPU_ARCH_VFP
, armv5te
),
31360 ARM_ARCH_OPT2 ("armv6zkt2", ARM_ARCH_V6KZT2
, FPU_ARCH_VFP
, armv5te
),
31361 ARM_ARCH_OPT ("armv6-m", ARM_ARCH_V6M
, FPU_ARCH_VFP
),
31362 ARM_ARCH_OPT ("armv6s-m", ARM_ARCH_V6SM
, FPU_ARCH_VFP
),
31363 ARM_ARCH_OPT2 ("armv7", ARM_ARCH_V7
, FPU_ARCH_VFP
, armv7
),
31364 /* The official spelling of the ARMv7 profile variants is the dashed form.
31365 Accept the non-dashed form for compatibility with old toolchains. */
31366 ARM_ARCH_OPT2 ("armv7a", ARM_ARCH_V7A
, FPU_ARCH_VFP
, armv7a
),
31367 ARM_ARCH_OPT2 ("armv7ve", ARM_ARCH_V7VE
, FPU_ARCH_VFP
, armv7ve
),
31368 ARM_ARCH_OPT2 ("armv7r", ARM_ARCH_V7R
, FPU_ARCH_VFP
, armv7r
),
31369 ARM_ARCH_OPT ("armv7m", ARM_ARCH_V7M
, FPU_ARCH_VFP
),
31370 ARM_ARCH_OPT2 ("armv7-a", ARM_ARCH_V7A
, FPU_ARCH_VFP
, armv7a
),
31371 ARM_ARCH_OPT2 ("armv7-r", ARM_ARCH_V7R
, FPU_ARCH_VFP
, armv7r
),
31372 ARM_ARCH_OPT ("armv7-m", ARM_ARCH_V7M
, FPU_ARCH_VFP
),
31373 ARM_ARCH_OPT2 ("armv7e-m", ARM_ARCH_V7EM
, FPU_ARCH_VFP
, armv7em
),
31374 ARM_ARCH_OPT ("armv8-m.base", ARM_ARCH_V8M_BASE
, FPU_ARCH_VFP
),
31375 ARM_ARCH_OPT2 ("armv8-m.main", ARM_ARCH_V8M_MAIN
, FPU_ARCH_VFP
,
31377 ARM_ARCH_OPT2 ("armv8.1-m.main", ARM_ARCH_V8_1M_MAIN
, FPU_ARCH_VFP
,
31379 ARM_ARCH_OPT2 ("armv8-a", ARM_ARCH_V8A
, FPU_ARCH_VFP
, armv8a
),
31380 ARM_ARCH_OPT2 ("armv8.1-a", ARM_ARCH_V8_1A
, FPU_ARCH_VFP
, armv81a
),
31381 ARM_ARCH_OPT2 ("armv8.2-a", ARM_ARCH_V8_2A
, FPU_ARCH_VFP
, armv82a
),
31382 ARM_ARCH_OPT2 ("armv8.3-a", ARM_ARCH_V8_3A
, FPU_ARCH_VFP
, armv82a
),
31383 ARM_ARCH_OPT2 ("armv8-r", ARM_ARCH_V8R
, FPU_ARCH_VFP
, armv8r
),
31384 ARM_ARCH_OPT2 ("armv8.4-a", ARM_ARCH_V8_4A
, FPU_ARCH_VFP
, armv84a
),
31385 ARM_ARCH_OPT2 ("armv8.5-a", ARM_ARCH_V8_5A
, FPU_ARCH_VFP
, armv85a
),
31386 ARM_ARCH_OPT2 ("armv8.6-a", ARM_ARCH_V8_6A
, FPU_ARCH_VFP
, armv86a
),
31387 ARM_ARCH_OPT ("xscale", ARM_ARCH_XSCALE
, FPU_ARCH_VFP
),
31388 ARM_ARCH_OPT ("iwmmxt", ARM_ARCH_IWMMXT
, FPU_ARCH_VFP
),
31389 ARM_ARCH_OPT ("iwmmxt2", ARM_ARCH_IWMMXT2
, FPU_ARCH_VFP
),
31390 { NULL
, 0, ARM_ARCH_NONE
, ARM_ARCH_NONE
, NULL
}
31392 #undef ARM_ARCH_OPT
31394 /* ISA extensions in the co-processor and main instruction set space. */
31396 struct arm_option_extension_value_table
31400 const arm_feature_set merge_value
;
31401 const arm_feature_set clear_value
;
31402 /* List of architectures for which an extension is available. ARM_ARCH_NONE
31403 indicates that an extension is available for all architectures while
31404 ARM_ANY marks an empty entry. */
31405 const arm_feature_set allowed_archs
[2];
31408 /* The following table must be in alphabetical order with a NULL last entry. */
31410 #define ARM_EXT_OPT(N, M, C, AA) { N, sizeof (N) - 1, M, C, { AA, ARM_ANY } }
31411 #define ARM_EXT_OPT2(N, M, C, AA1, AA2) { N, sizeof (N) - 1, M, C, {AA1, AA2} }
31413 /* DEPRECATED: Refrain from using this table to add any new extensions, instead
31414 use the context sensitive approach using arm_ext_table's. */
31415 static const struct arm_option_extension_value_table arm_extensions
[] =
31417 ARM_EXT_OPT ("crc", ARM_FEATURE_CORE_HIGH(ARM_EXT2_CRC
),
31418 ARM_FEATURE_CORE_HIGH(ARM_EXT2_CRC
),
31419 ARM_FEATURE_CORE_LOW (ARM_EXT_V8
)),
31420 ARM_EXT_OPT ("crypto", FPU_ARCH_CRYPTO_NEON_VFP_ARMV8
,
31421 ARM_FEATURE_COPROC (FPU_CRYPTO_ARMV8
),
31422 ARM_FEATURE_CORE_LOW (ARM_EXT_V8
)),
31423 ARM_EXT_OPT ("dotprod", FPU_ARCH_DOTPROD_NEON_VFP_ARMV8
,
31424 ARM_FEATURE_COPROC (FPU_NEON_EXT_DOTPROD
),
31426 ARM_EXT_OPT ("dsp", ARM_FEATURE_CORE_LOW (ARM_EXT_V5ExP
| ARM_EXT_V6_DSP
),
31427 ARM_FEATURE_CORE_LOW (ARM_EXT_V5ExP
| ARM_EXT_V6_DSP
),
31428 ARM_FEATURE_CORE (ARM_EXT_V7M
, ARM_EXT2_V8M
)),
31429 ARM_EXT_OPT ("fp", FPU_ARCH_VFP_ARMV8
, ARM_FEATURE_COPROC (FPU_VFP_ARMV8
),
31430 ARM_FEATURE_CORE_LOW (ARM_EXT_V8
)),
31431 ARM_EXT_OPT ("fp16", ARM_FEATURE_CORE_HIGH (ARM_EXT2_FP16_INST
),
31432 ARM_FEATURE_CORE_HIGH (ARM_EXT2_FP16_INST
),
31434 ARM_EXT_OPT ("fp16fml", ARM_FEATURE_CORE_HIGH (ARM_EXT2_FP16_INST
31435 | ARM_EXT2_FP16_FML
),
31436 ARM_FEATURE_CORE_HIGH (ARM_EXT2_FP16_INST
31437 | ARM_EXT2_FP16_FML
),
31439 ARM_EXT_OPT2 ("idiv", ARM_FEATURE_CORE_LOW (ARM_EXT_ADIV
| ARM_EXT_DIV
),
31440 ARM_FEATURE_CORE_LOW (ARM_EXT_ADIV
| ARM_EXT_DIV
),
31441 ARM_FEATURE_CORE_LOW (ARM_EXT_V7A
),
31442 ARM_FEATURE_CORE_LOW (ARM_EXT_V7R
)),
31443 /* Duplicate entry for the purpose of allowing ARMv7 to match in presence of
31444 Thumb divide instruction. Due to this having the same name as the
31445 previous entry, this will be ignored when doing command-line parsing and
31446 only considered by build attribute selection code. */
31447 ARM_EXT_OPT ("idiv", ARM_FEATURE_CORE_LOW (ARM_EXT_DIV
),
31448 ARM_FEATURE_CORE_LOW (ARM_EXT_DIV
),
31449 ARM_FEATURE_CORE_LOW (ARM_EXT_V7
)),
31450 ARM_EXT_OPT ("iwmmxt",ARM_FEATURE_COPROC (ARM_CEXT_IWMMXT
),
31451 ARM_FEATURE_COPROC (ARM_CEXT_IWMMXT
), ARM_ARCH_NONE
),
31452 ARM_EXT_OPT ("iwmmxt2", ARM_FEATURE_COPROC (ARM_CEXT_IWMMXT2
),
31453 ARM_FEATURE_COPROC (ARM_CEXT_IWMMXT2
), ARM_ARCH_NONE
),
31454 ARM_EXT_OPT ("maverick", ARM_FEATURE_COPROC (ARM_CEXT_MAVERICK
),
31455 ARM_FEATURE_COPROC (ARM_CEXT_MAVERICK
), ARM_ARCH_NONE
),
31456 ARM_EXT_OPT2 ("mp", ARM_FEATURE_CORE_LOW (ARM_EXT_MP
),
31457 ARM_FEATURE_CORE_LOW (ARM_EXT_MP
),
31458 ARM_FEATURE_CORE_LOW (ARM_EXT_V7A
),
31459 ARM_FEATURE_CORE_LOW (ARM_EXT_V7R
)),
31460 ARM_EXT_OPT ("os", ARM_FEATURE_CORE_LOW (ARM_EXT_OS
),
31461 ARM_FEATURE_CORE_LOW (ARM_EXT_OS
),
31462 ARM_FEATURE_CORE_LOW (ARM_EXT_V6M
)),
31463 ARM_EXT_OPT ("pan", ARM_FEATURE_CORE_HIGH (ARM_EXT2_PAN
),
31464 ARM_FEATURE (ARM_EXT_V8
, ARM_EXT2_PAN
, 0),
31465 ARM_FEATURE_CORE_HIGH (ARM_EXT2_V8A
)),
31466 ARM_EXT_OPT ("predres", ARM_FEATURE_CORE_HIGH (ARM_EXT2_PREDRES
),
31467 ARM_FEATURE_CORE_HIGH (ARM_EXT2_PREDRES
),
31469 ARM_EXT_OPT ("ras", ARM_FEATURE_CORE_HIGH (ARM_EXT2_RAS
),
31470 ARM_FEATURE (ARM_EXT_V8
, ARM_EXT2_RAS
, 0),
31471 ARM_FEATURE_CORE_HIGH (ARM_EXT2_V8A
)),
31472 ARM_EXT_OPT ("rdma", FPU_ARCH_NEON_VFP_ARMV8_1
,
31473 ARM_FEATURE_COPROC (FPU_NEON_ARMV8
| FPU_NEON_EXT_RDMA
),
31474 ARM_FEATURE_CORE_HIGH (ARM_EXT2_V8A
)),
31475 ARM_EXT_OPT ("sb", ARM_FEATURE_CORE_HIGH (ARM_EXT2_SB
),
31476 ARM_FEATURE_CORE_HIGH (ARM_EXT2_SB
),
31478 ARM_EXT_OPT2 ("sec", ARM_FEATURE_CORE_LOW (ARM_EXT_SEC
),
31479 ARM_FEATURE_CORE_LOW (ARM_EXT_SEC
),
31480 ARM_FEATURE_CORE_LOW (ARM_EXT_V6K
),
31481 ARM_FEATURE_CORE_LOW (ARM_EXT_V7A
)),
31482 ARM_EXT_OPT ("simd", FPU_ARCH_NEON_VFP_ARMV8
,
31483 ARM_FEATURE_COPROC (FPU_NEON_ARMV8
),
31484 ARM_FEATURE_CORE_LOW (ARM_EXT_V8
)),
31485 ARM_EXT_OPT ("virt", ARM_FEATURE_CORE_LOW (ARM_EXT_VIRT
| ARM_EXT_ADIV
31487 ARM_FEATURE_CORE_LOW (ARM_EXT_VIRT
),
31488 ARM_FEATURE_CORE_LOW (ARM_EXT_V7A
)),
31489 ARM_EXT_OPT ("xscale",ARM_FEATURE_COPROC (ARM_CEXT_XSCALE
),
31490 ARM_FEATURE_COPROC (ARM_CEXT_XSCALE
), ARM_ARCH_NONE
),
31491 { NULL
, 0, ARM_ARCH_NONE
, ARM_ARCH_NONE
, { ARM_ARCH_NONE
, ARM_ARCH_NONE
} }
31495 /* ISA floating-point and Advanced SIMD extensions. */
31496 struct arm_option_fpu_value_table
31499 const arm_feature_set value
;
31502 /* This list should, at a minimum, contain all the fpu names
31503 recognized by GCC. */
31504 static const struct arm_option_fpu_value_table arm_fpus
[] =
31506 {"softfpa", FPU_NONE
},
31507 {"fpe", FPU_ARCH_FPE
},
31508 {"fpe2", FPU_ARCH_FPE
},
31509 {"fpe3", FPU_ARCH_FPA
}, /* Third release supports LFM/SFM. */
31510 {"fpa", FPU_ARCH_FPA
},
31511 {"fpa10", FPU_ARCH_FPA
},
31512 {"fpa11", FPU_ARCH_FPA
},
31513 {"arm7500fe", FPU_ARCH_FPA
},
31514 {"softvfp", FPU_ARCH_VFP
},
31515 {"softvfp+vfp", FPU_ARCH_VFP_V2
},
31516 {"vfp", FPU_ARCH_VFP_V2
},
31517 {"vfp9", FPU_ARCH_VFP_V2
},
31518 {"vfp3", FPU_ARCH_VFP_V3
}, /* Undocumented, use vfpv3. */
31519 {"vfp10", FPU_ARCH_VFP_V2
},
31520 {"vfp10-r0", FPU_ARCH_VFP_V1
},
31521 {"vfpxd", FPU_ARCH_VFP_V1xD
},
31522 {"vfpv2", FPU_ARCH_VFP_V2
},
31523 {"vfpv3", FPU_ARCH_VFP_V3
},
31524 {"vfpv3-fp16", FPU_ARCH_VFP_V3_FP16
},
31525 {"vfpv3-d16", FPU_ARCH_VFP_V3D16
},
31526 {"vfpv3-d16-fp16", FPU_ARCH_VFP_V3D16_FP16
},
31527 {"vfpv3xd", FPU_ARCH_VFP_V3xD
},
31528 {"vfpv3xd-fp16", FPU_ARCH_VFP_V3xD_FP16
},
31529 {"arm1020t", FPU_ARCH_VFP_V1
},
31530 {"arm1020e", FPU_ARCH_VFP_V2
},
31531 {"arm1136jfs", FPU_ARCH_VFP_V2
}, /* Undocumented, use arm1136jf-s. */
31532 {"arm1136jf-s", FPU_ARCH_VFP_V2
},
31533 {"maverick", FPU_ARCH_MAVERICK
},
31534 {"neon", FPU_ARCH_VFP_V3_PLUS_NEON_V1
},
31535 {"neon-vfpv3", FPU_ARCH_VFP_V3_PLUS_NEON_V1
},
31536 {"neon-fp16", FPU_ARCH_NEON_FP16
},
31537 {"vfpv4", FPU_ARCH_VFP_V4
},
31538 {"vfpv4-d16", FPU_ARCH_VFP_V4D16
},
31539 {"fpv4-sp-d16", FPU_ARCH_VFP_V4_SP_D16
},
31540 {"fpv5-d16", FPU_ARCH_VFP_V5D16
},
31541 {"fpv5-sp-d16", FPU_ARCH_VFP_V5_SP_D16
},
31542 {"neon-vfpv4", FPU_ARCH_NEON_VFP_V4
},
31543 {"fp-armv8", FPU_ARCH_VFP_ARMV8
},
31544 {"neon-fp-armv8", FPU_ARCH_NEON_VFP_ARMV8
},
31545 {"crypto-neon-fp-armv8",
31546 FPU_ARCH_CRYPTO_NEON_VFP_ARMV8
},
31547 {"neon-fp-armv8.1", FPU_ARCH_NEON_VFP_ARMV8_1
},
31548 {"crypto-neon-fp-armv8.1",
31549 FPU_ARCH_CRYPTO_NEON_VFP_ARMV8_1
},
31550 {NULL
, ARM_ARCH_NONE
}
31553 struct arm_option_value_table
31559 static const struct arm_option_value_table arm_float_abis
[] =
31561 {"hard", ARM_FLOAT_ABI_HARD
},
31562 {"softfp", ARM_FLOAT_ABI_SOFTFP
},
31563 {"soft", ARM_FLOAT_ABI_SOFT
},
31568 /* We only know how to output GNU and ver 4/5 (AAELF) formats. */
31569 static const struct arm_option_value_table arm_eabis
[] =
31571 {"gnu", EF_ARM_EABI_UNKNOWN
},
31572 {"4", EF_ARM_EABI_VER4
},
31573 {"5", EF_ARM_EABI_VER5
},
31578 struct arm_long_option_table
31580 const char * option
; /* Substring to match. */
31581 const char * help
; /* Help information. */
31582 int (* func
) (const char * subopt
); /* Function to decode sub-option. */
31583 const char * deprecated
; /* If non-null, print this message. */
31587 arm_parse_extension (const char *str
, const arm_feature_set
*opt_set
,
31588 arm_feature_set
*ext_set
,
31589 const struct arm_ext_table
*ext_table
)
31591 /* We insist on extensions being specified in alphabetical order, and with
31592 extensions being added before being removed. We achieve this by having
31593 the global ARM_EXTENSIONS table in alphabetical order, and using the
31594 ADDING_VALUE variable to indicate whether we are adding an extension (1)
31595 or removing it (0) and only allowing it to change in the order
31597 const struct arm_option_extension_value_table
* opt
= NULL
;
31598 const arm_feature_set arm_any
= ARM_ANY
;
31599 int adding_value
= -1;
31601 while (str
!= NULL
&& *str
!= 0)
31608 as_bad (_("invalid architectural extension"));
31613 ext
= strchr (str
, '+');
31618 len
= strlen (str
);
31620 if (len
>= 2 && strncmp (str
, "no", 2) == 0)
31622 if (adding_value
!= 0)
31625 opt
= arm_extensions
;
31633 if (adding_value
== -1)
31636 opt
= arm_extensions
;
31638 else if (adding_value
!= 1)
31640 as_bad (_("must specify extensions to add before specifying "
31641 "those to remove"));
31648 as_bad (_("missing architectural extension"));
31652 gas_assert (adding_value
!= -1);
31653 gas_assert (opt
!= NULL
);
31655 if (ext_table
!= NULL
)
31657 const struct arm_ext_table
* ext_opt
= ext_table
;
31658 bfd_boolean found
= FALSE
;
31659 for (; ext_opt
->name
!= NULL
; ext_opt
++)
31660 if (ext_opt
->name_len
== len
31661 && strncmp (ext_opt
->name
, str
, len
) == 0)
31665 if (ARM_FEATURE_ZERO (ext_opt
->merge
))
31666 /* TODO: Option not supported. When we remove the
31667 legacy table this case should error out. */
31670 ARM_MERGE_FEATURE_SETS (*ext_set
, *ext_set
, ext_opt
->merge
);
31674 if (ARM_FEATURE_ZERO (ext_opt
->clear
))
31675 /* TODO: Option not supported. When we remove the
31676 legacy table this case should error out. */
31678 ARM_CLEAR_FEATURE (*ext_set
, *ext_set
, ext_opt
->clear
);
31690 /* Scan over the options table trying to find an exact match. */
31691 for (; opt
->name
!= NULL
; opt
++)
31692 if (opt
->name_len
== len
&& strncmp (opt
->name
, str
, len
) == 0)
31694 int i
, nb_allowed_archs
=
31695 sizeof (opt
->allowed_archs
) / sizeof (opt
->allowed_archs
[0]);
31696 /* Check we can apply the extension to this architecture. */
31697 for (i
= 0; i
< nb_allowed_archs
; i
++)
31700 if (ARM_FEATURE_EQUAL (opt
->allowed_archs
[i
], arm_any
))
31702 if (ARM_FSET_CPU_SUBSET (opt
->allowed_archs
[i
], *opt_set
))
31705 if (i
== nb_allowed_archs
)
31707 as_bad (_("extension does not apply to the base architecture"));
31711 /* Add or remove the extension. */
31713 ARM_MERGE_FEATURE_SETS (*ext_set
, *ext_set
, opt
->merge_value
);
31715 ARM_CLEAR_FEATURE (*ext_set
, *ext_set
, opt
->clear_value
);
31717 /* Allowing Thumb division instructions for ARMv7 in autodetection
31718 rely on this break so that duplicate extensions (extensions
31719 with the same name as a previous extension in the list) are not
31720 considered for command-line parsing. */
31724 if (opt
->name
== NULL
)
31726 /* Did we fail to find an extension because it wasn't specified in
31727 alphabetical order, or because it does not exist? */
31729 for (opt
= arm_extensions
; opt
->name
!= NULL
; opt
++)
31730 if (opt
->name_len
== len
&& strncmp (opt
->name
, str
, len
) == 0)
31733 if (opt
->name
== NULL
)
31734 as_bad (_("unknown architectural extension `%s'"), str
);
31736 as_bad (_("architectural extensions must be specified in "
31737 "alphabetical order"));
31743 /* We should skip the extension we've just matched the next time
31755 arm_parse_fp16_opt (const char *str
)
31757 if (strcasecmp (str
, "ieee") == 0)
31758 fp16_format
= ARM_FP16_FORMAT_IEEE
;
31759 else if (strcasecmp (str
, "alternative") == 0)
31760 fp16_format
= ARM_FP16_FORMAT_ALTERNATIVE
;
31763 as_bad (_("unrecognised float16 format \"%s\""), str
);
31771 arm_parse_cpu (const char *str
)
31773 const struct arm_cpu_option_table
*opt
;
31774 const char *ext
= strchr (str
, '+');
31780 len
= strlen (str
);
31784 as_bad (_("missing cpu name `%s'"), str
);
31788 for (opt
= arm_cpus
; opt
->name
!= NULL
; opt
++)
31789 if (opt
->name_len
== len
&& strncmp (opt
->name
, str
, len
) == 0)
31791 mcpu_cpu_opt
= &opt
->value
;
31792 if (mcpu_ext_opt
== NULL
)
31793 mcpu_ext_opt
= XNEW (arm_feature_set
);
31794 *mcpu_ext_opt
= opt
->ext
;
31795 mcpu_fpu_opt
= &opt
->default_fpu
;
31796 if (opt
->canonical_name
)
31798 gas_assert (sizeof selected_cpu_name
> strlen (opt
->canonical_name
));
31799 strcpy (selected_cpu_name
, opt
->canonical_name
);
31805 if (len
>= sizeof selected_cpu_name
)
31806 len
= (sizeof selected_cpu_name
) - 1;
31808 for (i
= 0; i
< len
; i
++)
31809 selected_cpu_name
[i
] = TOUPPER (opt
->name
[i
]);
31810 selected_cpu_name
[i
] = 0;
31814 return arm_parse_extension (ext
, mcpu_cpu_opt
, mcpu_ext_opt
, NULL
);
31819 as_bad (_("unknown cpu `%s'"), str
);
31824 arm_parse_arch (const char *str
)
31826 const struct arm_arch_option_table
*opt
;
31827 const char *ext
= strchr (str
, '+');
31833 len
= strlen (str
);
31837 as_bad (_("missing architecture name `%s'"), str
);
31841 for (opt
= arm_archs
; opt
->name
!= NULL
; opt
++)
31842 if (opt
->name_len
== len
&& strncmp (opt
->name
, str
, len
) == 0)
31844 march_cpu_opt
= &opt
->value
;
31845 if (march_ext_opt
== NULL
)
31846 march_ext_opt
= XNEW (arm_feature_set
);
31847 *march_ext_opt
= arm_arch_none
;
31848 march_fpu_opt
= &opt
->default_fpu
;
31849 selected_ctx_ext_table
= opt
->ext_table
;
31850 strcpy (selected_cpu_name
, opt
->name
);
31853 return arm_parse_extension (ext
, march_cpu_opt
, march_ext_opt
,
31859 as_bad (_("unknown architecture `%s'\n"), str
);
31864 arm_parse_fpu (const char * str
)
31866 const struct arm_option_fpu_value_table
* opt
;
31868 for (opt
= arm_fpus
; opt
->name
!= NULL
; opt
++)
31869 if (streq (opt
->name
, str
))
31871 mfpu_opt
= &opt
->value
;
31875 as_bad (_("unknown floating point format `%s'\n"), str
);
31880 arm_parse_float_abi (const char * str
)
31882 const struct arm_option_value_table
* opt
;
31884 for (opt
= arm_float_abis
; opt
->name
!= NULL
; opt
++)
31885 if (streq (opt
->name
, str
))
31887 mfloat_abi_opt
= opt
->value
;
31891 as_bad (_("unknown floating point abi `%s'\n"), str
);
31897 arm_parse_eabi (const char * str
)
31899 const struct arm_option_value_table
*opt
;
31901 for (opt
= arm_eabis
; opt
->name
!= NULL
; opt
++)
31902 if (streq (opt
->name
, str
))
31904 meabi_flags
= opt
->value
;
31907 as_bad (_("unknown EABI `%s'\n"), str
);
31913 arm_parse_it_mode (const char * str
)
31915 bfd_boolean ret
= TRUE
;
31917 if (streq ("arm", str
))
31918 implicit_it_mode
= IMPLICIT_IT_MODE_ARM
;
31919 else if (streq ("thumb", str
))
31920 implicit_it_mode
= IMPLICIT_IT_MODE_THUMB
;
31921 else if (streq ("always", str
))
31922 implicit_it_mode
= IMPLICIT_IT_MODE_ALWAYS
;
31923 else if (streq ("never", str
))
31924 implicit_it_mode
= IMPLICIT_IT_MODE_NEVER
;
31927 as_bad (_("unknown implicit IT mode `%s', should be "\
31928 "arm, thumb, always, or never."), str
);
31936 arm_ccs_mode (const char * unused ATTRIBUTE_UNUSED
)
31938 codecomposer_syntax
= TRUE
;
31939 arm_comment_chars
[0] = ';';
31940 arm_line_separator_chars
[0] = 0;
31944 struct arm_long_option_table arm_long_opts
[] =
31946 {"mcpu=", N_("<cpu name>\t assemble for CPU <cpu name>"),
31947 arm_parse_cpu
, NULL
},
31948 {"march=", N_("<arch name>\t assemble for architecture <arch name>"),
31949 arm_parse_arch
, NULL
},
31950 {"mfpu=", N_("<fpu name>\t assemble for FPU architecture <fpu name>"),
31951 arm_parse_fpu
, NULL
},
31952 {"mfloat-abi=", N_("<abi>\t assemble for floating point ABI <abi>"),
31953 arm_parse_float_abi
, NULL
},
31955 {"meabi=", N_("<ver>\t\t assemble for eabi version <ver>"),
31956 arm_parse_eabi
, NULL
},
31958 {"mimplicit-it=", N_("<mode>\t controls implicit insertion of IT instructions"),
31959 arm_parse_it_mode
, NULL
},
31960 {"mccs", N_("\t\t\t TI CodeComposer Studio syntax compatibility mode"),
31961 arm_ccs_mode
, NULL
},
31963 N_("[ieee|alternative]\n\
31964 set the encoding for half precision floating point "
31965 "numbers to IEEE\n\
31966 or Arm alternative format."),
31967 arm_parse_fp16_opt
, NULL
},
31968 {NULL
, NULL
, 0, NULL
}
31972 md_parse_option (int c
, const char * arg
)
31974 struct arm_option_table
*opt
;
31975 const struct arm_legacy_option_table
*fopt
;
31976 struct arm_long_option_table
*lopt
;
31982 target_big_endian
= 1;
31988 target_big_endian
= 0;
31992 case OPTION_FIX_V4BX
:
32000 #endif /* OBJ_ELF */
32003 /* Listing option. Just ignore these, we don't support additional
32008 for (opt
= arm_opts
; opt
->option
!= NULL
; opt
++)
32010 if (c
== opt
->option
[0]
32011 && ((arg
== NULL
&& opt
->option
[1] == 0)
32012 || streq (arg
, opt
->option
+ 1)))
32014 /* If the option is deprecated, tell the user. */
32015 if (warn_on_deprecated
&& opt
->deprecated
!= NULL
)
32016 as_tsktsk (_("option `-%c%s' is deprecated: %s"), c
,
32017 arg
? arg
: "", _(opt
->deprecated
));
32019 if (opt
->var
!= NULL
)
32020 *opt
->var
= opt
->value
;
32026 for (fopt
= arm_legacy_opts
; fopt
->option
!= NULL
; fopt
++)
32028 if (c
== fopt
->option
[0]
32029 && ((arg
== NULL
&& fopt
->option
[1] == 0)
32030 || streq (arg
, fopt
->option
+ 1)))
32032 /* If the option is deprecated, tell the user. */
32033 if (warn_on_deprecated
&& fopt
->deprecated
!= NULL
)
32034 as_tsktsk (_("option `-%c%s' is deprecated: %s"), c
,
32035 arg
? arg
: "", _(fopt
->deprecated
));
32037 if (fopt
->var
!= NULL
)
32038 *fopt
->var
= &fopt
->value
;
32044 for (lopt
= arm_long_opts
; lopt
->option
!= NULL
; lopt
++)
32046 /* These options are expected to have an argument. */
32047 if (c
== lopt
->option
[0]
32049 && strncmp (arg
, lopt
->option
+ 1,
32050 strlen (lopt
->option
+ 1)) == 0)
32052 /* If the option is deprecated, tell the user. */
32053 if (warn_on_deprecated
&& lopt
->deprecated
!= NULL
)
32054 as_tsktsk (_("option `-%c%s' is deprecated: %s"), c
, arg
,
32055 _(lopt
->deprecated
));
32057 /* Call the sup-option parser. */
32058 return lopt
->func (arg
+ strlen (lopt
->option
) - 1);
32069 md_show_usage (FILE * fp
)
32071 struct arm_option_table
*opt
;
32072 struct arm_long_option_table
*lopt
;
32074 fprintf (fp
, _(" ARM-specific assembler options:\n"));
32076 for (opt
= arm_opts
; opt
->option
!= NULL
; opt
++)
32077 if (opt
->help
!= NULL
)
32078 fprintf (fp
, " -%-23s%s\n", opt
->option
, _(opt
->help
));
32080 for (lopt
= arm_long_opts
; lopt
->option
!= NULL
; lopt
++)
32081 if (lopt
->help
!= NULL
)
32082 fprintf (fp
, " -%s%s\n", lopt
->option
, _(lopt
->help
));
32086 -EB assemble code for a big-endian cpu\n"));
32091 -EL assemble code for a little-endian cpu\n"));
32095 --fix-v4bx Allow BX in ARMv4 code\n"));
32099 --fdpic generate an FDPIC object file\n"));
32100 #endif /* OBJ_ELF */
32108 arm_feature_set flags
;
32109 } cpu_arch_ver_table
;
32111 /* Mapping from CPU features to EABI CPU arch values. Table must be sorted
32112 chronologically for architectures, with an exception for ARMv6-M and
32113 ARMv6S-M due to legacy reasons. No new architecture should have a
32114 special case. This allows for build attribute selection results to be
32115 stable when new architectures are added. */
32116 static const cpu_arch_ver_table cpu_arch_ver
[] =
32118 {TAG_CPU_ARCH_PRE_V4
, ARM_ARCH_V1
},
32119 {TAG_CPU_ARCH_PRE_V4
, ARM_ARCH_V2
},
32120 {TAG_CPU_ARCH_PRE_V4
, ARM_ARCH_V2S
},
32121 {TAG_CPU_ARCH_PRE_V4
, ARM_ARCH_V3
},
32122 {TAG_CPU_ARCH_PRE_V4
, ARM_ARCH_V3M
},
32123 {TAG_CPU_ARCH_V4
, ARM_ARCH_V4xM
},
32124 {TAG_CPU_ARCH_V4
, ARM_ARCH_V4
},
32125 {TAG_CPU_ARCH_V4T
, ARM_ARCH_V4TxM
},
32126 {TAG_CPU_ARCH_V4T
, ARM_ARCH_V4T
},
32127 {TAG_CPU_ARCH_V5T
, ARM_ARCH_V5xM
},
32128 {TAG_CPU_ARCH_V5T
, ARM_ARCH_V5
},
32129 {TAG_CPU_ARCH_V5T
, ARM_ARCH_V5TxM
},
32130 {TAG_CPU_ARCH_V5T
, ARM_ARCH_V5T
},
32131 {TAG_CPU_ARCH_V5TE
, ARM_ARCH_V5TExP
},
32132 {TAG_CPU_ARCH_V5TE
, ARM_ARCH_V5TE
},
32133 {TAG_CPU_ARCH_V5TEJ
, ARM_ARCH_V5TEJ
},
32134 {TAG_CPU_ARCH_V6
, ARM_ARCH_V6
},
32135 {TAG_CPU_ARCH_V6KZ
, ARM_ARCH_V6Z
},
32136 {TAG_CPU_ARCH_V6KZ
, ARM_ARCH_V6KZ
},
32137 {TAG_CPU_ARCH_V6K
, ARM_ARCH_V6K
},
32138 {TAG_CPU_ARCH_V6T2
, ARM_ARCH_V6T2
},
32139 {TAG_CPU_ARCH_V6T2
, ARM_ARCH_V6KT2
},
32140 {TAG_CPU_ARCH_V6T2
, ARM_ARCH_V6ZT2
},
32141 {TAG_CPU_ARCH_V6T2
, ARM_ARCH_V6KZT2
},
32143 /* When assembling a file with only ARMv6-M or ARMv6S-M instruction, GNU as
32144 always selected build attributes to match those of ARMv6-M
32145 (resp. ARMv6S-M). However, due to these architectures being a strict
32146 subset of ARMv7-M in terms of instructions available, ARMv7-M attributes
32147 would be selected when fully respecting chronology of architectures.
32148 It is thus necessary to make a special case of ARMv6-M and ARMv6S-M and
32149 move them before ARMv7 architectures. */
32150 {TAG_CPU_ARCH_V6_M
, ARM_ARCH_V6M
},
32151 {TAG_CPU_ARCH_V6S_M
, ARM_ARCH_V6SM
},
32153 {TAG_CPU_ARCH_V7
, ARM_ARCH_V7
},
32154 {TAG_CPU_ARCH_V7
, ARM_ARCH_V7A
},
32155 {TAG_CPU_ARCH_V7
, ARM_ARCH_V7R
},
32156 {TAG_CPU_ARCH_V7
, ARM_ARCH_V7M
},
32157 {TAG_CPU_ARCH_V7
, ARM_ARCH_V7VE
},
32158 {TAG_CPU_ARCH_V7E_M
, ARM_ARCH_V7EM
},
32159 {TAG_CPU_ARCH_V8
, ARM_ARCH_V8A
},
32160 {TAG_CPU_ARCH_V8
, ARM_ARCH_V8_1A
},
32161 {TAG_CPU_ARCH_V8
, ARM_ARCH_V8_2A
},
32162 {TAG_CPU_ARCH_V8
, ARM_ARCH_V8_3A
},
32163 {TAG_CPU_ARCH_V8M_BASE
, ARM_ARCH_V8M_BASE
},
32164 {TAG_CPU_ARCH_V8M_MAIN
, ARM_ARCH_V8M_MAIN
},
32165 {TAG_CPU_ARCH_V8R
, ARM_ARCH_V8R
},
32166 {TAG_CPU_ARCH_V8
, ARM_ARCH_V8_4A
},
32167 {TAG_CPU_ARCH_V8
, ARM_ARCH_V8_5A
},
32168 {TAG_CPU_ARCH_V8_1M_MAIN
, ARM_ARCH_V8_1M_MAIN
},
32169 {TAG_CPU_ARCH_V8
, ARM_ARCH_V8_6A
},
32170 {-1, ARM_ARCH_NONE
}
32173 /* Set an attribute if it has not already been set by the user. */
32176 aeabi_set_attribute_int (int tag
, int value
)
32179 || tag
>= NUM_KNOWN_OBJ_ATTRIBUTES
32180 || !attributes_set_explicitly
[tag
])
32181 bfd_elf_add_proc_attr_int (stdoutput
, tag
, value
);
32185 aeabi_set_attribute_string (int tag
, const char *value
)
32188 || tag
>= NUM_KNOWN_OBJ_ATTRIBUTES
32189 || !attributes_set_explicitly
[tag
])
32190 bfd_elf_add_proc_attr_string (stdoutput
, tag
, value
);
32193 /* Return whether features in the *NEEDED feature set are available via
32194 extensions for the architecture whose feature set is *ARCH_FSET. */
32197 have_ext_for_needed_feat_p (const arm_feature_set
*arch_fset
,
32198 const arm_feature_set
*needed
)
32200 int i
, nb_allowed_archs
;
32201 arm_feature_set ext_fset
;
32202 const struct arm_option_extension_value_table
*opt
;
32204 ext_fset
= arm_arch_none
;
32205 for (opt
= arm_extensions
; opt
->name
!= NULL
; opt
++)
32207 /* Extension does not provide any feature we need. */
32208 if (!ARM_CPU_HAS_FEATURE (*needed
, opt
->merge_value
))
32212 sizeof (opt
->allowed_archs
) / sizeof (opt
->allowed_archs
[0]);
32213 for (i
= 0; i
< nb_allowed_archs
; i
++)
32216 if (ARM_FEATURE_EQUAL (opt
->allowed_archs
[i
], arm_arch_any
))
32219 /* Extension is available, add it. */
32220 if (ARM_FSET_CPU_SUBSET (opt
->allowed_archs
[i
], *arch_fset
))
32221 ARM_MERGE_FEATURE_SETS (ext_fset
, ext_fset
, opt
->merge_value
);
32225 /* Can we enable all features in *needed? */
32226 return ARM_FSET_CPU_SUBSET (*needed
, ext_fset
);
32229 /* Select value for Tag_CPU_arch and Tag_CPU_arch_profile build attributes for
32230 a given architecture feature set *ARCH_EXT_FSET including extension feature
32231 set *EXT_FSET. Selection logic used depend on EXACT_MATCH:
32232 - if true, check for an exact match of the architecture modulo extensions;
32233 - otherwise, select build attribute value of the first superset
32234 architecture released so that results remains stable when new architectures
32236 For -march/-mcpu=all the build attribute value of the most featureful
32237 architecture is returned. Tag_CPU_arch_profile result is returned in
32241 get_aeabi_cpu_arch_from_fset (const arm_feature_set
*arch_ext_fset
,
32242 const arm_feature_set
*ext_fset
,
32243 char *profile
, int exact_match
)
32245 arm_feature_set arch_fset
;
32246 const cpu_arch_ver_table
*p_ver
, *p_ver_ret
= NULL
;
32248 /* Select most featureful architecture with all its extensions if building
32249 for -march=all as the feature sets used to set build attributes. */
32250 if (ARM_FEATURE_EQUAL (*arch_ext_fset
, arm_arch_any
))
32252 /* Force revisiting of decision for each new architecture. */
32253 gas_assert (MAX_TAG_CPU_ARCH
<= TAG_CPU_ARCH_V8_1M_MAIN
);
32255 return TAG_CPU_ARCH_V8
;
32258 ARM_CLEAR_FEATURE (arch_fset
, *arch_ext_fset
, *ext_fset
);
32260 for (p_ver
= cpu_arch_ver
; p_ver
->val
!= -1; p_ver
++)
32262 arm_feature_set known_arch_fset
;
32264 ARM_CLEAR_FEATURE (known_arch_fset
, p_ver
->flags
, fpu_any
);
32267 /* Base architecture match user-specified architecture and
32268 extensions, eg. ARMv6S-M matching -march=armv6-m+os. */
32269 if (ARM_FEATURE_EQUAL (*arch_ext_fset
, known_arch_fset
))
32274 /* Base architecture match user-specified architecture only
32275 (eg. ARMv6-M in the same case as above). Record it in case we
32276 find a match with above condition. */
32277 else if (p_ver_ret
== NULL
32278 && ARM_FEATURE_EQUAL (arch_fset
, known_arch_fset
))
32284 /* Architecture has all features wanted. */
32285 if (ARM_FSET_CPU_SUBSET (arch_fset
, known_arch_fset
))
32287 arm_feature_set added_fset
;
32289 /* Compute features added by this architecture over the one
32290 recorded in p_ver_ret. */
32291 if (p_ver_ret
!= NULL
)
32292 ARM_CLEAR_FEATURE (added_fset
, known_arch_fset
,
32294 /* First architecture that match incl. with extensions, or the
32295 only difference in features over the recorded match is
32296 features that were optional and are now mandatory. */
32297 if (p_ver_ret
== NULL
32298 || ARM_FSET_CPU_SUBSET (added_fset
, arch_fset
))
32304 else if (p_ver_ret
== NULL
)
32306 arm_feature_set needed_ext_fset
;
32308 ARM_CLEAR_FEATURE (needed_ext_fset
, arch_fset
, known_arch_fset
);
32310 /* Architecture has all features needed when using some
32311 extensions. Record it and continue searching in case there
32312 exist an architecture providing all needed features without
32313 the need for extensions (eg. ARMv6S-M Vs ARMv6-M with
32315 if (have_ext_for_needed_feat_p (&known_arch_fset
,
32322 if (p_ver_ret
== NULL
)
32326 /* Tag_CPU_arch_profile. */
32327 if (ARM_CPU_HAS_FEATURE (p_ver_ret
->flags
, arm_ext_v7a
)
32328 || ARM_CPU_HAS_FEATURE (p_ver_ret
->flags
, arm_ext_v8
)
32329 || (ARM_CPU_HAS_FEATURE (p_ver_ret
->flags
, arm_ext_atomics
)
32330 && !ARM_CPU_HAS_FEATURE (p_ver_ret
->flags
, arm_ext_v8m_m_only
)))
32332 else if (ARM_CPU_HAS_FEATURE (p_ver_ret
->flags
, arm_ext_v7r
))
32334 else if (ARM_CPU_HAS_FEATURE (p_ver_ret
->flags
, arm_ext_m
))
32338 return p_ver_ret
->val
;
32341 /* Set the public EABI object attributes. */
32344 aeabi_set_public_attributes (void)
32346 char profile
= '\0';
32349 int fp16_optional
= 0;
32350 int skip_exact_match
= 0;
32351 arm_feature_set flags
, flags_arch
, flags_ext
;
32353 /* Autodetection mode, choose the architecture based the instructions
32355 if (no_cpu_selected ())
32357 ARM_MERGE_FEATURE_SETS (flags
, arm_arch_used
, thumb_arch_used
);
32359 if (ARM_CPU_HAS_FEATURE (arm_arch_used
, arm_arch_any
))
32360 ARM_MERGE_FEATURE_SETS (flags
, flags
, arm_ext_v1
);
32362 if (ARM_CPU_HAS_FEATURE (thumb_arch_used
, arm_arch_any
))
32363 ARM_MERGE_FEATURE_SETS (flags
, flags
, arm_ext_v4t
);
32365 /* Code run during relaxation relies on selected_cpu being set. */
32366 ARM_CLEAR_FEATURE (flags_arch
, flags
, fpu_any
);
32367 flags_ext
= arm_arch_none
;
32368 ARM_CLEAR_FEATURE (selected_arch
, flags_arch
, flags_ext
);
32369 selected_ext
= flags_ext
;
32370 selected_cpu
= flags
;
32372 /* Otherwise, choose the architecture based on the capabilities of the
32376 ARM_MERGE_FEATURE_SETS (flags_arch
, selected_arch
, selected_ext
);
32377 ARM_CLEAR_FEATURE (flags_arch
, flags_arch
, fpu_any
);
32378 flags_ext
= selected_ext
;
32379 flags
= selected_cpu
;
32381 ARM_MERGE_FEATURE_SETS (flags
, flags
, selected_fpu
);
32383 /* Allow the user to override the reported architecture. */
32384 if (!ARM_FEATURE_ZERO (selected_object_arch
))
32386 ARM_CLEAR_FEATURE (flags_arch
, selected_object_arch
, fpu_any
);
32387 flags_ext
= arm_arch_none
;
32390 skip_exact_match
= ARM_FEATURE_EQUAL (selected_cpu
, arm_arch_any
);
32392 /* When this function is run again after relaxation has happened there is no
32393 way to determine whether an architecture or CPU was specified by the user:
32394 - selected_cpu is set above for relaxation to work;
32395 - march_cpu_opt is not set if only -mcpu or .cpu is used;
32396 - mcpu_cpu_opt is set to arm_arch_any for autodetection.
32397 Therefore, if not in -march=all case we first try an exact match and fall
32398 back to autodetection. */
32399 if (!skip_exact_match
)
32400 arch
= get_aeabi_cpu_arch_from_fset (&flags_arch
, &flags_ext
, &profile
, 1);
32402 arch
= get_aeabi_cpu_arch_from_fset (&flags_arch
, &flags_ext
, &profile
, 0);
32404 as_bad (_("no architecture contains all the instructions used\n"));
32406 /* Tag_CPU_name. */
32407 if (selected_cpu_name
[0])
32411 q
= selected_cpu_name
;
32412 if (strncmp (q
, "armv", 4) == 0)
32417 for (i
= 0; q
[i
]; i
++)
32418 q
[i
] = TOUPPER (q
[i
]);
32420 aeabi_set_attribute_string (Tag_CPU_name
, q
);
32423 /* Tag_CPU_arch. */
32424 aeabi_set_attribute_int (Tag_CPU_arch
, arch
);
32426 /* Tag_CPU_arch_profile. */
32427 if (profile
!= '\0')
32428 aeabi_set_attribute_int (Tag_CPU_arch_profile
, profile
);
32430 /* Tag_DSP_extension. */
32431 if (ARM_CPU_HAS_FEATURE (selected_ext
, arm_ext_dsp
))
32432 aeabi_set_attribute_int (Tag_DSP_extension
, 1);
32434 ARM_CLEAR_FEATURE (flags_arch
, flags
, fpu_any
);
32435 /* Tag_ARM_ISA_use. */
32436 if (ARM_CPU_HAS_FEATURE (flags
, arm_ext_v1
)
32437 || ARM_FEATURE_ZERO (flags_arch
))
32438 aeabi_set_attribute_int (Tag_ARM_ISA_use
, 1);
32440 /* Tag_THUMB_ISA_use. */
32441 if (ARM_CPU_HAS_FEATURE (flags
, arm_ext_v4t
)
32442 || ARM_FEATURE_ZERO (flags_arch
))
32446 if (!ARM_CPU_HAS_FEATURE (flags
, arm_ext_v8
)
32447 && ARM_CPU_HAS_FEATURE (flags
, arm_ext_v8m_m_only
))
32449 else if (ARM_CPU_HAS_FEATURE (flags
, arm_arch_t2
))
32453 aeabi_set_attribute_int (Tag_THUMB_ISA_use
, thumb_isa_use
);
32456 /* Tag_VFP_arch. */
32457 if (ARM_CPU_HAS_FEATURE (flags
, fpu_vfp_ext_armv8xd
))
32458 aeabi_set_attribute_int (Tag_VFP_arch
,
32459 ARM_CPU_HAS_FEATURE (flags
, fpu_vfp_ext_d32
)
32461 else if (ARM_CPU_HAS_FEATURE (flags
, fpu_vfp_ext_fma
))
32462 aeabi_set_attribute_int (Tag_VFP_arch
,
32463 ARM_CPU_HAS_FEATURE (flags
, fpu_vfp_ext_d32
)
32465 else if (ARM_CPU_HAS_FEATURE (flags
, fpu_vfp_ext_d32
))
32468 aeabi_set_attribute_int (Tag_VFP_arch
, 3);
32470 else if (ARM_CPU_HAS_FEATURE (flags
, fpu_vfp_ext_v3xd
))
32472 aeabi_set_attribute_int (Tag_VFP_arch
, 4);
32475 else if (ARM_CPU_HAS_FEATURE (flags
, fpu_vfp_ext_v2
))
32476 aeabi_set_attribute_int (Tag_VFP_arch
, 2);
32477 else if (ARM_CPU_HAS_FEATURE (flags
, fpu_vfp_ext_v1
)
32478 || ARM_CPU_HAS_FEATURE (flags
, fpu_vfp_ext_v1xd
))
32479 aeabi_set_attribute_int (Tag_VFP_arch
, 1);
32481 /* Tag_ABI_HardFP_use. */
32482 if (ARM_CPU_HAS_FEATURE (flags
, fpu_vfp_ext_v1xd
)
32483 && !ARM_CPU_HAS_FEATURE (flags
, fpu_vfp_ext_v1
))
32484 aeabi_set_attribute_int (Tag_ABI_HardFP_use
, 1);
32486 /* Tag_WMMX_arch. */
32487 if (ARM_CPU_HAS_FEATURE (flags
, arm_cext_iwmmxt2
))
32488 aeabi_set_attribute_int (Tag_WMMX_arch
, 2);
32489 else if (ARM_CPU_HAS_FEATURE (flags
, arm_cext_iwmmxt
))
32490 aeabi_set_attribute_int (Tag_WMMX_arch
, 1);
32492 /* Tag_Advanced_SIMD_arch (formerly Tag_NEON_arch). */
32493 if (ARM_CPU_HAS_FEATURE (flags
, fpu_neon_ext_v8_1
))
32494 aeabi_set_attribute_int (Tag_Advanced_SIMD_arch
, 4);
32495 else if (ARM_CPU_HAS_FEATURE (flags
, fpu_neon_ext_armv8
))
32496 aeabi_set_attribute_int (Tag_Advanced_SIMD_arch
, 3);
32497 else if (ARM_CPU_HAS_FEATURE (flags
, fpu_neon_ext_v1
))
32499 if (ARM_CPU_HAS_FEATURE (flags
, fpu_neon_ext_fma
))
32501 aeabi_set_attribute_int (Tag_Advanced_SIMD_arch
, 2);
32505 aeabi_set_attribute_int (Tag_Advanced_SIMD_arch
, 1);
32510 if (ARM_CPU_HAS_FEATURE (flags
, mve_fp_ext
))
32511 aeabi_set_attribute_int (Tag_MVE_arch
, 2);
32512 else if (ARM_CPU_HAS_FEATURE (flags
, mve_ext
))
32513 aeabi_set_attribute_int (Tag_MVE_arch
, 1);
32515 /* Tag_VFP_HP_extension (formerly Tag_NEON_FP16_arch). */
32516 if (ARM_CPU_HAS_FEATURE (flags
, fpu_vfp_fp16
) && fp16_optional
)
32517 aeabi_set_attribute_int (Tag_VFP_HP_extension
, 1);
32521 We set Tag_DIV_use to two when integer divide instructions have been used
32522 in ARM state, or when Thumb integer divide instructions have been used,
32523 but we have no architecture profile set, nor have we any ARM instructions.
32525 For ARMv8-A and ARMv8-M we set the tag to 0 as integer divide is implied
32526 by the base architecture.
32528 For new architectures we will have to check these tests. */
32529 gas_assert (arch
<= TAG_CPU_ARCH_V8_1M_MAIN
);
32530 if (ARM_CPU_HAS_FEATURE (flags
, arm_ext_v8
)
32531 || ARM_CPU_HAS_FEATURE (flags
, arm_ext_v8m
))
32532 aeabi_set_attribute_int (Tag_DIV_use
, 0);
32533 else if (ARM_CPU_HAS_FEATURE (flags
, arm_ext_adiv
)
32534 || (profile
== '\0'
32535 && ARM_CPU_HAS_FEATURE (flags
, arm_ext_div
)
32536 && !ARM_CPU_HAS_FEATURE (arm_arch_used
, arm_arch_any
)))
32537 aeabi_set_attribute_int (Tag_DIV_use
, 2);
32539 /* Tag_MP_extension_use. */
32540 if (ARM_CPU_HAS_FEATURE (flags
, arm_ext_mp
))
32541 aeabi_set_attribute_int (Tag_MPextension_use
, 1);
32543 /* Tag Virtualization_use. */
32544 if (ARM_CPU_HAS_FEATURE (flags
, arm_ext_sec
))
32546 if (ARM_CPU_HAS_FEATURE (flags
, arm_ext_virt
))
32549 aeabi_set_attribute_int (Tag_Virtualization_use
, virt_sec
);
32551 if (fp16_format
!= ARM_FP16_FORMAT_DEFAULT
)
32552 aeabi_set_attribute_int (Tag_ABI_FP_16bit_format
, fp16_format
);
32555 /* Post relaxation hook. Recompute ARM attributes now that relaxation is
32556 finished and free extension feature bits which will not be used anymore. */
32559 arm_md_post_relax (void)
32561 aeabi_set_public_attributes ();
32562 XDELETE (mcpu_ext_opt
);
32563 mcpu_ext_opt
= NULL
;
32564 XDELETE (march_ext_opt
);
32565 march_ext_opt
= NULL
;
32568 /* Add the default contents for the .ARM.attributes section. */
32573 if (EF_ARM_EABI_VERSION (meabi_flags
) < EF_ARM_EABI_VER4
)
32576 aeabi_set_public_attributes ();
32578 #endif /* OBJ_ELF */
32580 /* Parse a .cpu directive. */
32583 s_arm_cpu (int ignored ATTRIBUTE_UNUSED
)
32585 const struct arm_cpu_option_table
*opt
;
32589 name
= input_line_pointer
;
32590 while (*input_line_pointer
&& !ISSPACE (*input_line_pointer
))
32591 input_line_pointer
++;
32592 saved_char
= *input_line_pointer
;
32593 *input_line_pointer
= 0;
32595 /* Skip the first "all" entry. */
32596 for (opt
= arm_cpus
+ 1; opt
->name
!= NULL
; opt
++)
32597 if (streq (opt
->name
, name
))
32599 selected_arch
= opt
->value
;
32600 selected_ext
= opt
->ext
;
32601 ARM_MERGE_FEATURE_SETS (selected_cpu
, selected_arch
, selected_ext
);
32602 if (opt
->canonical_name
)
32603 strcpy (selected_cpu_name
, opt
->canonical_name
);
32607 for (i
= 0; opt
->name
[i
]; i
++)
32608 selected_cpu_name
[i
] = TOUPPER (opt
->name
[i
]);
32610 selected_cpu_name
[i
] = 0;
32612 ARM_MERGE_FEATURE_SETS (cpu_variant
, selected_cpu
, selected_fpu
);
32614 *input_line_pointer
= saved_char
;
32615 demand_empty_rest_of_line ();
32618 as_bad (_("unknown cpu `%s'"), name
);
32619 *input_line_pointer
= saved_char
;
32620 ignore_rest_of_line ();
32623 /* Parse a .arch directive. */
32626 s_arm_arch (int ignored ATTRIBUTE_UNUSED
)
32628 const struct arm_arch_option_table
*opt
;
32632 name
= input_line_pointer
;
32633 while (*input_line_pointer
&& !ISSPACE (*input_line_pointer
))
32634 input_line_pointer
++;
32635 saved_char
= *input_line_pointer
;
32636 *input_line_pointer
= 0;
32638 /* Skip the first "all" entry. */
32639 for (opt
= arm_archs
+ 1; opt
->name
!= NULL
; opt
++)
32640 if (streq (opt
->name
, name
))
32642 selected_arch
= opt
->value
;
32643 selected_ctx_ext_table
= opt
->ext_table
;
32644 selected_ext
= arm_arch_none
;
32645 selected_cpu
= selected_arch
;
32646 strcpy (selected_cpu_name
, opt
->name
);
32647 ARM_MERGE_FEATURE_SETS (cpu_variant
, selected_cpu
, selected_fpu
);
32648 *input_line_pointer
= saved_char
;
32649 demand_empty_rest_of_line ();
32653 as_bad (_("unknown architecture `%s'\n"), name
);
32654 *input_line_pointer
= saved_char
;
32655 ignore_rest_of_line ();
32658 /* Parse a .object_arch directive. */
32661 s_arm_object_arch (int ignored ATTRIBUTE_UNUSED
)
32663 const struct arm_arch_option_table
*opt
;
32667 name
= input_line_pointer
;
32668 while (*input_line_pointer
&& !ISSPACE (*input_line_pointer
))
32669 input_line_pointer
++;
32670 saved_char
= *input_line_pointer
;
32671 *input_line_pointer
= 0;
32673 /* Skip the first "all" entry. */
32674 for (opt
= arm_archs
+ 1; opt
->name
!= NULL
; opt
++)
32675 if (streq (opt
->name
, name
))
32677 selected_object_arch
= opt
->value
;
32678 *input_line_pointer
= saved_char
;
32679 demand_empty_rest_of_line ();
32683 as_bad (_("unknown architecture `%s'\n"), name
);
32684 *input_line_pointer
= saved_char
;
32685 ignore_rest_of_line ();
32688 /* Parse a .arch_extension directive. */
32691 s_arm_arch_extension (int ignored ATTRIBUTE_UNUSED
)
32693 const struct arm_option_extension_value_table
*opt
;
32696 int adding_value
= 1;
32698 name
= input_line_pointer
;
32699 while (*input_line_pointer
&& !ISSPACE (*input_line_pointer
))
32700 input_line_pointer
++;
32701 saved_char
= *input_line_pointer
;
32702 *input_line_pointer
= 0;
32704 if (strlen (name
) >= 2
32705 && strncmp (name
, "no", 2) == 0)
32711 /* Check the context specific extension table */
32712 if (selected_ctx_ext_table
)
32714 const struct arm_ext_table
* ext_opt
;
32715 for (ext_opt
= selected_ctx_ext_table
; ext_opt
->name
!= NULL
; ext_opt
++)
32717 if (streq (ext_opt
->name
, name
))
32721 if (ARM_FEATURE_ZERO (ext_opt
->merge
))
32722 /* TODO: Option not supported. When we remove the
32723 legacy table this case should error out. */
32725 ARM_MERGE_FEATURE_SETS (selected_ext
, selected_ext
,
32729 ARM_CLEAR_FEATURE (selected_ext
, selected_ext
, ext_opt
->clear
);
32731 ARM_MERGE_FEATURE_SETS (selected_cpu
, selected_arch
, selected_ext
);
32732 ARM_MERGE_FEATURE_SETS (cpu_variant
, selected_cpu
, selected_fpu
);
32733 *input_line_pointer
= saved_char
;
32734 demand_empty_rest_of_line ();
32740 for (opt
= arm_extensions
; opt
->name
!= NULL
; opt
++)
32741 if (streq (opt
->name
, name
))
32743 int i
, nb_allowed_archs
=
32744 sizeof (opt
->allowed_archs
) / sizeof (opt
->allowed_archs
[i
]);
32745 for (i
= 0; i
< nb_allowed_archs
; i
++)
32748 if (ARM_CPU_IS_ANY (opt
->allowed_archs
[i
]))
32750 if (ARM_FSET_CPU_SUBSET (opt
->allowed_archs
[i
], selected_arch
))
32754 if (i
== nb_allowed_archs
)
32756 as_bad (_("architectural extension `%s' is not allowed for the "
32757 "current base architecture"), name
);
32762 ARM_MERGE_FEATURE_SETS (selected_ext
, selected_ext
,
32765 ARM_CLEAR_FEATURE (selected_ext
, selected_ext
, opt
->clear_value
);
32767 ARM_MERGE_FEATURE_SETS (selected_cpu
, selected_arch
, selected_ext
);
32768 ARM_MERGE_FEATURE_SETS (cpu_variant
, selected_cpu
, selected_fpu
);
32769 *input_line_pointer
= saved_char
;
32770 demand_empty_rest_of_line ();
32771 /* Allowing Thumb division instructions for ARMv7 in autodetection rely
32772 on this return so that duplicate extensions (extensions with the
32773 same name as a previous extension in the list) are not considered
32774 for command-line parsing. */
32778 if (opt
->name
== NULL
)
32779 as_bad (_("unknown architecture extension `%s'\n"), name
);
32781 *input_line_pointer
= saved_char
;
32782 ignore_rest_of_line ();
32785 /* Parse a .fpu directive. */
32788 s_arm_fpu (int ignored ATTRIBUTE_UNUSED
)
32790 const struct arm_option_fpu_value_table
*opt
;
32794 name
= input_line_pointer
;
32795 while (*input_line_pointer
&& !ISSPACE (*input_line_pointer
))
32796 input_line_pointer
++;
32797 saved_char
= *input_line_pointer
;
32798 *input_line_pointer
= 0;
32800 for (opt
= arm_fpus
; opt
->name
!= NULL
; opt
++)
32801 if (streq (opt
->name
, name
))
32803 selected_fpu
= opt
->value
;
32804 ARM_CLEAR_FEATURE (selected_cpu
, selected_cpu
, fpu_any
);
32805 #ifndef CPU_DEFAULT
32806 if (no_cpu_selected ())
32807 ARM_MERGE_FEATURE_SETS (cpu_variant
, arm_arch_any
, selected_fpu
);
32810 ARM_MERGE_FEATURE_SETS (cpu_variant
, selected_cpu
, selected_fpu
);
32811 *input_line_pointer
= saved_char
;
32812 demand_empty_rest_of_line ();
32816 as_bad (_("unknown floating point format `%s'\n"), name
);
32817 *input_line_pointer
= saved_char
;
32818 ignore_rest_of_line ();
32821 /* Copy symbol information. */
32824 arm_copy_symbol_attributes (symbolS
*dest
, symbolS
*src
)
32826 ARM_GET_FLAG (dest
) = ARM_GET_FLAG (src
);
32830 /* Given a symbolic attribute NAME, return the proper integer value.
32831 Returns -1 if the attribute is not known. */
32834 arm_convert_symbolic_attribute (const char *name
)
32836 static const struct
32841 attribute_table
[] =
32843 /* When you modify this table you should
32844 also modify the list in doc/c-arm.texi. */
32845 #define T(tag) {#tag, tag}
32846 T (Tag_CPU_raw_name
),
32849 T (Tag_CPU_arch_profile
),
32850 T (Tag_ARM_ISA_use
),
32851 T (Tag_THUMB_ISA_use
),
32855 T (Tag_Advanced_SIMD_arch
),
32856 T (Tag_PCS_config
),
32857 T (Tag_ABI_PCS_R9_use
),
32858 T (Tag_ABI_PCS_RW_data
),
32859 T (Tag_ABI_PCS_RO_data
),
32860 T (Tag_ABI_PCS_GOT_use
),
32861 T (Tag_ABI_PCS_wchar_t
),
32862 T (Tag_ABI_FP_rounding
),
32863 T (Tag_ABI_FP_denormal
),
32864 T (Tag_ABI_FP_exceptions
),
32865 T (Tag_ABI_FP_user_exceptions
),
32866 T (Tag_ABI_FP_number_model
),
32867 T (Tag_ABI_align_needed
),
32868 T (Tag_ABI_align8_needed
),
32869 T (Tag_ABI_align_preserved
),
32870 T (Tag_ABI_align8_preserved
),
32871 T (Tag_ABI_enum_size
),
32872 T (Tag_ABI_HardFP_use
),
32873 T (Tag_ABI_VFP_args
),
32874 T (Tag_ABI_WMMX_args
),
32875 T (Tag_ABI_optimization_goals
),
32876 T (Tag_ABI_FP_optimization_goals
),
32877 T (Tag_compatibility
),
32878 T (Tag_CPU_unaligned_access
),
32879 T (Tag_FP_HP_extension
),
32880 T (Tag_VFP_HP_extension
),
32881 T (Tag_ABI_FP_16bit_format
),
32882 T (Tag_MPextension_use
),
32884 T (Tag_nodefaults
),
32885 T (Tag_also_compatible_with
),
32886 T (Tag_conformance
),
32888 T (Tag_Virtualization_use
),
32889 T (Tag_DSP_extension
),
32891 /* We deliberately do not include Tag_MPextension_use_legacy. */
32899 for (i
= 0; i
< ARRAY_SIZE (attribute_table
); i
++)
32900 if (streq (name
, attribute_table
[i
].name
))
32901 return attribute_table
[i
].tag
;
32906 /* Apply sym value for relocations only in the case that they are for
32907 local symbols in the same segment as the fixup and you have the
32908 respective architectural feature for blx and simple switches. */
32911 arm_apply_sym_value (struct fix
* fixP
, segT this_seg
)
32914 && ARM_CPU_HAS_FEATURE (selected_cpu
, arm_ext_v5t
)
32915 /* PR 17444: If the local symbol is in a different section then a reloc
32916 will always be generated for it, so applying the symbol value now
32917 will result in a double offset being stored in the relocation. */
32918 && (S_GET_SEGMENT (fixP
->fx_addsy
) == this_seg
)
32919 && !S_FORCE_RELOC (fixP
->fx_addsy
, TRUE
))
32921 switch (fixP
->fx_r_type
)
32923 case BFD_RELOC_ARM_PCREL_BLX
:
32924 case BFD_RELOC_THUMB_PCREL_BRANCH23
:
32925 if (ARM_IS_FUNC (fixP
->fx_addsy
))
32929 case BFD_RELOC_ARM_PCREL_CALL
:
32930 case BFD_RELOC_THUMB_PCREL_BLX
:
32931 if (THUMB_IS_FUNC (fixP
->fx_addsy
))
32942 #endif /* OBJ_ELF */