1 /* tc-arm.c -- Assemble for the ARM
2 Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
3 2004, 2005, 2006, 2007, 2008, 2009
4 Free Software Foundation, Inc.
5 Contributed by Richard Earnshaw (rwe@pegasus.esprit.ec.org)
6 Modified by David Taylor (dtaylor@armltd.co.uk)
7 Cirrus coprocessor mods by Aldy Hernandez (aldyh@redhat.com)
8 Cirrus coprocessor fixes by Petko Manolov (petkan@nucleusys.com)
9 Cirrus coprocessor fixes by Vladimir Ivanov (vladitx@nucleusys.com)
11 This file is part of GAS, the GNU Assembler.
13 GAS is free software; you can redistribute it and/or modify
14 it under the terms of the GNU General Public License as published by
15 the Free Software Foundation; either version 3, or (at your option)
18 GAS is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 GNU General Public License for more details.
23 You should have received a copy of the GNU General Public License
24 along with GAS; see the file COPYING. If not, write to the Free
25 Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
32 #include "safe-ctype.h"
36 #include "opcode/arm.h"
40 #include "dw2gencfi.h"
43 #include "dwarf2dbg.h"
46 /* Must be at least the size of the largest unwind opcode (currently two). */
47 #define ARM_OPCODE_CHUNK_SIZE 8
49 /* This structure holds the unwinding state. */
54 symbolS
* table_entry
;
55 symbolS
* personality_routine
;
56 int personality_index
;
57 /* The segment containing the function. */
60 /* Opcodes generated from this function. */
61 unsigned char * opcodes
;
64 /* The number of bytes pushed to the stack. */
66 /* We don't add stack adjustment opcodes immediately so that we can merge
67 multiple adjustments. We can also omit the final adjustment
68 when using a frame pointer. */
69 offsetT pending_offset
;
70 /* These two fields are set by both unwind_movsp and unwind_setfp. They
71 hold the reg+offset to use when restoring sp from a frame pointer. */
74 /* Nonzero if an unwind_setfp directive has been seen. */
76 /* Nonzero if the last opcode restores sp from fp_reg. */
77 unsigned sp_restored
:1;
80 /* Bit N indicates that an R_ARM_NONE relocation has been output for
81 __aeabi_unwind_cpp_prN already if set. This enables dependencies to be
82 emitted only once per section, to save unnecessary bloat. */
83 static unsigned int marked_pr_dependency
= 0;
87 /* Results from operand parsing worker functions. */
91 PARSE_OPERAND_SUCCESS
,
93 PARSE_OPERAND_FAIL_NO_BACKTRACK
94 } parse_operand_result
;
103 /* Types of processor to assemble for. */
105 #if defined __XSCALE__
106 #define CPU_DEFAULT ARM_ARCH_XSCALE
108 #if defined __thumb__
109 #define CPU_DEFAULT ARM_ARCH_V5T
116 # define FPU_DEFAULT FPU_ARCH_FPA
117 # elif defined (TE_NetBSD)
119 # define FPU_DEFAULT FPU_ARCH_VFP /* Soft-float, but VFP order. */
121 /* Legacy a.out format. */
122 # define FPU_DEFAULT FPU_ARCH_FPA /* Soft-float, but FPA order. */
124 # elif defined (TE_VXWORKS)
125 # define FPU_DEFAULT FPU_ARCH_VFP /* Soft-float, VFP order. */
127 /* For backwards compatibility, default to FPA. */
128 # define FPU_DEFAULT FPU_ARCH_FPA
130 #endif /* ifndef FPU_DEFAULT */
132 #define streq(a, b) (strcmp (a, b) == 0)
134 static arm_feature_set cpu_variant
;
135 static arm_feature_set arm_arch_used
;
136 static arm_feature_set thumb_arch_used
;
138 /* Flags stored in private area of BFD structure. */
139 static int uses_apcs_26
= FALSE
;
140 static int atpcs
= FALSE
;
141 static int support_interwork
= FALSE
;
142 static int uses_apcs_float
= FALSE
;
143 static int pic_code
= FALSE
;
144 static int fix_v4bx
= FALSE
;
145 /* Warn on using deprecated features. */
146 static int warn_on_deprecated
= TRUE
;
149 /* Variables that we set while parsing command-line options. Once all
150 options have been read we re-process these values to set the real
152 static const arm_feature_set
*legacy_cpu
= NULL
;
153 static const arm_feature_set
*legacy_fpu
= NULL
;
155 static const arm_feature_set
*mcpu_cpu_opt
= NULL
;
156 static const arm_feature_set
*mcpu_fpu_opt
= NULL
;
157 static const arm_feature_set
*march_cpu_opt
= NULL
;
158 static const arm_feature_set
*march_fpu_opt
= NULL
;
159 static const arm_feature_set
*mfpu_opt
= NULL
;
160 static const arm_feature_set
*object_arch
= NULL
;
162 /* Constants for known architecture features. */
163 static const arm_feature_set fpu_default
= FPU_DEFAULT
;
164 static const arm_feature_set fpu_arch_vfp_v1
= FPU_ARCH_VFP_V1
;
165 static const arm_feature_set fpu_arch_vfp_v2
= FPU_ARCH_VFP_V2
;
166 static const arm_feature_set fpu_arch_vfp_v3
= FPU_ARCH_VFP_V3
;
167 static const arm_feature_set fpu_arch_neon_v1
= FPU_ARCH_NEON_V1
;
168 static const arm_feature_set fpu_arch_fpa
= FPU_ARCH_FPA
;
169 static const arm_feature_set fpu_any_hard
= FPU_ANY_HARD
;
170 static const arm_feature_set fpu_arch_maverick
= FPU_ARCH_MAVERICK
;
171 static const arm_feature_set fpu_endian_pure
= FPU_ARCH_ENDIAN_PURE
;
174 static const arm_feature_set cpu_default
= CPU_DEFAULT
;
177 static const arm_feature_set arm_ext_v1
= ARM_FEATURE (ARM_EXT_V1
, 0);
178 static const arm_feature_set arm_ext_v2
= ARM_FEATURE (ARM_EXT_V1
, 0);
179 static const arm_feature_set arm_ext_v2s
= ARM_FEATURE (ARM_EXT_V2S
, 0);
180 static const arm_feature_set arm_ext_v3
= ARM_FEATURE (ARM_EXT_V3
, 0);
181 static const arm_feature_set arm_ext_v3m
= ARM_FEATURE (ARM_EXT_V3M
, 0);
182 static const arm_feature_set arm_ext_v4
= ARM_FEATURE (ARM_EXT_V4
, 0);
183 static const arm_feature_set arm_ext_v4t
= ARM_FEATURE (ARM_EXT_V4T
, 0);
184 static const arm_feature_set arm_ext_v5
= ARM_FEATURE (ARM_EXT_V5
, 0);
185 static const arm_feature_set arm_ext_v4t_5
=
186 ARM_FEATURE (ARM_EXT_V4T
| ARM_EXT_V5
, 0);
187 static const arm_feature_set arm_ext_v5t
= ARM_FEATURE (ARM_EXT_V5T
, 0);
188 static const arm_feature_set arm_ext_v5e
= ARM_FEATURE (ARM_EXT_V5E
, 0);
189 static const arm_feature_set arm_ext_v5exp
= ARM_FEATURE (ARM_EXT_V5ExP
, 0);
190 static const arm_feature_set arm_ext_v5j
= ARM_FEATURE (ARM_EXT_V5J
, 0);
191 static const arm_feature_set arm_ext_v6
= ARM_FEATURE (ARM_EXT_V6
, 0);
192 static const arm_feature_set arm_ext_v6k
= ARM_FEATURE (ARM_EXT_V6K
, 0);
193 static const arm_feature_set arm_ext_v6z
= ARM_FEATURE (ARM_EXT_V6Z
, 0);
194 static const arm_feature_set arm_ext_v6t2
= ARM_FEATURE (ARM_EXT_V6T2
, 0);
195 static const arm_feature_set arm_ext_v6_notm
= ARM_FEATURE (ARM_EXT_V6_NOTM
, 0);
196 static const arm_feature_set arm_ext_barrier
= ARM_FEATURE (ARM_EXT_BARRIER
, 0);
197 static const arm_feature_set arm_ext_msr
= ARM_FEATURE (ARM_EXT_THUMB_MSR
, 0);
198 static const arm_feature_set arm_ext_div
= ARM_FEATURE (ARM_EXT_DIV
, 0);
199 static const arm_feature_set arm_ext_v7
= ARM_FEATURE (ARM_EXT_V7
, 0);
200 static const arm_feature_set arm_ext_v7a
= ARM_FEATURE (ARM_EXT_V7A
, 0);
201 static const arm_feature_set arm_ext_v7r
= ARM_FEATURE (ARM_EXT_V7R
, 0);
202 static const arm_feature_set arm_ext_m
=
203 ARM_FEATURE (ARM_EXT_V6M
| ARM_EXT_V7M
, 0);
205 static const arm_feature_set arm_arch_any
= ARM_ANY
;
206 static const arm_feature_set arm_arch_full
= ARM_FEATURE (-1, -1);
207 static const arm_feature_set arm_arch_t2
= ARM_ARCH_THUMB2
;
208 static const arm_feature_set arm_arch_none
= ARM_ARCH_NONE
;
210 static const arm_feature_set arm_cext_iwmmxt2
=
211 ARM_FEATURE (0, ARM_CEXT_IWMMXT2
);
212 static const arm_feature_set arm_cext_iwmmxt
=
213 ARM_FEATURE (0, ARM_CEXT_IWMMXT
);
214 static const arm_feature_set arm_cext_xscale
=
215 ARM_FEATURE (0, ARM_CEXT_XSCALE
);
216 static const arm_feature_set arm_cext_maverick
=
217 ARM_FEATURE (0, ARM_CEXT_MAVERICK
);
218 static const arm_feature_set fpu_fpa_ext_v1
= ARM_FEATURE (0, FPU_FPA_EXT_V1
);
219 static const arm_feature_set fpu_fpa_ext_v2
= ARM_FEATURE (0, FPU_FPA_EXT_V2
);
220 static const arm_feature_set fpu_vfp_ext_v1xd
=
221 ARM_FEATURE (0, FPU_VFP_EXT_V1xD
);
222 static const arm_feature_set fpu_vfp_ext_v1
= ARM_FEATURE (0, FPU_VFP_EXT_V1
);
223 static const arm_feature_set fpu_vfp_ext_v2
= ARM_FEATURE (0, FPU_VFP_EXT_V2
);
224 static const arm_feature_set fpu_vfp_ext_v3
= ARM_FEATURE (0, FPU_VFP_EXT_V3
);
225 static const arm_feature_set fpu_vfp_ext_d32
=
226 ARM_FEATURE (0, FPU_VFP_EXT_D32
);
227 static const arm_feature_set fpu_neon_ext_v1
= ARM_FEATURE (0, FPU_NEON_EXT_V1
);
228 static const arm_feature_set fpu_vfp_v3_or_neon_ext
=
229 ARM_FEATURE (0, FPU_NEON_EXT_V1
| FPU_VFP_EXT_V3
);
230 static const arm_feature_set fpu_neon_fp16
= ARM_FEATURE (0, FPU_NEON_FP16
);
232 static int mfloat_abi_opt
= -1;
233 /* Record user cpu selection for object attributes. */
234 static arm_feature_set selected_cpu
= ARM_ARCH_NONE
;
235 /* Must be long enough to hold any of the names in arm_cpus. */
236 static char selected_cpu_name
[16];
239 static int meabi_flags
= EABI_DEFAULT
;
241 static int meabi_flags
= EF_ARM_EABI_UNKNOWN
;
244 static int attributes_set_explicitly
[NUM_KNOWN_OBJ_ATTRIBUTES
];
249 return (EF_ARM_EABI_VERSION (meabi_flags
) >= EF_ARM_EABI_VER4
);
254 /* Pre-defined "_GLOBAL_OFFSET_TABLE_" */
255 symbolS
* GOT_symbol
;
258 /* 0: assemble for ARM,
259 1: assemble for Thumb,
260 2: assemble for Thumb even though target CPU does not support thumb
262 static int thumb_mode
= 0;
263 /* A value distinct from the possible values for thumb_mode that we
264 can use to record whether thumb_mode has been copied into the
265 tc_frag_data field of a frag. */
266 #define MODE_RECORDED (1 << 4)
268 /* Specifies the intrinsic IT insn behavior mode. */
269 enum implicit_it_mode
271 IMPLICIT_IT_MODE_NEVER
= 0x00,
272 IMPLICIT_IT_MODE_ARM
= 0x01,
273 IMPLICIT_IT_MODE_THUMB
= 0x02,
274 IMPLICIT_IT_MODE_ALWAYS
= (IMPLICIT_IT_MODE_ARM
| IMPLICIT_IT_MODE_THUMB
)
276 static int implicit_it_mode
= IMPLICIT_IT_MODE_ARM
;
278 /* If unified_syntax is true, we are processing the new unified
279 ARM/Thumb syntax. Important differences from the old ARM mode:
281 - Immediate operands do not require a # prefix.
282 - Conditional affixes always appear at the end of the
283 instruction. (For backward compatibility, those instructions
284 that formerly had them in the middle, continue to accept them
286 - The IT instruction may appear, and if it does is validated
287 against subsequent conditional affixes. It does not generate
290 Important differences from the old Thumb mode:
292 - Immediate operands do not require a # prefix.
293 - Most of the V6T2 instructions are only available in unified mode.
294 - The .N and .W suffixes are recognized and honored (it is an error
295 if they cannot be honored).
296 - All instructions set the flags if and only if they have an 's' affix.
297 - Conditional affixes may be used. They are validated against
298 preceding IT instructions. Unlike ARM mode, you cannot use a
299 conditional affix except in the scope of an IT instruction. */
301 static bfd_boolean unified_syntax
= FALSE
;
316 enum neon_el_type type
;
320 #define NEON_MAX_TYPE_ELS 4
324 struct neon_type_el el
[NEON_MAX_TYPE_ELS
];
328 enum it_instruction_type
333 IF_INSIDE_IT_LAST_INSN
, /* Either outside or inside;
334 if inside, should be the last one. */
335 NEUTRAL_IT_INSN
, /* This could be either inside or outside,
336 i.e. BKPT and NOP. */
337 IT_INSN
/* The IT insn has been parsed. */
343 unsigned long instruction
;
347 /* "uncond_value" is set to the value in place of the conditional field in
348 unconditional versions of the instruction, or -1 if nothing is
351 struct neon_type vectype
;
352 /* Set to the opcode if the instruction needs relaxation.
353 Zero if the instruction is not relaxed. */
357 bfd_reloc_code_real_type type
;
362 enum it_instruction_type it_insn_type
;
368 struct neon_type_el vectype
;
369 unsigned present
: 1; /* Operand present. */
370 unsigned isreg
: 1; /* Operand was a register. */
371 unsigned immisreg
: 1; /* .imm field is a second register. */
372 unsigned isscalar
: 1; /* Operand is a (Neon) scalar. */
373 unsigned immisalign
: 1; /* Immediate is an alignment specifier. */
374 unsigned immisfloat
: 1; /* Immediate was parsed as a float. */
375 /* Note: we abuse "regisimm" to mean "is Neon register" in VMOV
376 instructions. This allows us to disambiguate ARM <-> vector insns. */
377 unsigned regisimm
: 1; /* 64-bit immediate, reg forms high 32 bits. */
378 unsigned isvec
: 1; /* Is a single, double or quad VFP/Neon reg. */
379 unsigned isquad
: 1; /* Operand is Neon quad-precision register. */
380 unsigned issingle
: 1; /* Operand is VFP single-precision register. */
381 unsigned hasreloc
: 1; /* Operand has relocation suffix. */
382 unsigned writeback
: 1; /* Operand has trailing ! */
383 unsigned preind
: 1; /* Preindexed address. */
384 unsigned postind
: 1; /* Postindexed address. */
385 unsigned negative
: 1; /* Index register was negated. */
386 unsigned shifted
: 1; /* Shift applied to operation. */
387 unsigned shift_kind
: 3; /* Shift operation (enum shift_kind). */
391 static struct arm_it inst
;
393 #define NUM_FLOAT_VALS 8
395 const char * fp_const
[] =
397 "0.0", "1.0", "2.0", "3.0", "4.0", "5.0", "0.5", "10.0", 0
400 /* Number of littlenums required to hold an extended precision number. */
401 #define MAX_LITTLENUMS 6
403 LITTLENUM_TYPE fp_values
[NUM_FLOAT_VALS
][MAX_LITTLENUMS
];
413 #define CP_T_X 0x00008000
414 #define CP_T_Y 0x00400000
416 #define CONDS_BIT 0x00100000
417 #define LOAD_BIT 0x00100000
419 #define DOUBLE_LOAD_FLAG 0x00000001
423 const char * template;
427 #define COND_ALWAYS 0xE
431 const char *template;
435 struct asm_barrier_opt
437 const char *template;
441 /* The bit that distinguishes CPSR and SPSR. */
442 #define SPSR_BIT (1 << 22)
444 /* The individual PSR flag bits. */
445 #define PSR_c (1 << 16)
446 #define PSR_x (1 << 17)
447 #define PSR_s (1 << 18)
448 #define PSR_f (1 << 19)
453 bfd_reloc_code_real_type reloc
;
458 VFP_REG_Sd
, VFP_REG_Sm
, VFP_REG_Sn
,
459 VFP_REG_Dd
, VFP_REG_Dm
, VFP_REG_Dn
464 VFP_LDSTMIA
, VFP_LDSTMDB
, VFP_LDSTMIAX
, VFP_LDSTMDBX
467 /* Bits for DEFINED field in neon_typed_alias. */
468 #define NTA_HASTYPE 1
469 #define NTA_HASINDEX 2
471 struct neon_typed_alias
473 unsigned char defined
;
475 struct neon_type_el eltype
;
478 /* ARM register categories. This includes coprocessor numbers and various
479 architecture extensions' registers. */
505 /* Structure for a hash table entry for a register.
506 If TYPE is REG_TYPE_VFD or REG_TYPE_NQ, the NEON field can point to extra
507 information which states whether a vector type or index is specified (for a
508 register alias created with .dn or .qn). Otherwise NEON should be NULL. */
512 unsigned char number
;
514 unsigned char builtin
;
515 struct neon_typed_alias
*neon
;
518 /* Diagnostics used when we don't get a register of the expected type. */
519 const char *const reg_expected_msgs
[] =
521 N_("ARM register expected"),
522 N_("bad or missing co-processor number"),
523 N_("co-processor register expected"),
524 N_("FPA register expected"),
525 N_("VFP single precision register expected"),
526 N_("VFP/Neon double precision register expected"),
527 N_("Neon quad precision register expected"),
528 N_("VFP single or double precision register expected"),
529 N_("Neon double or quad precision register expected"),
530 N_("VFP single, double or Neon quad precision register expected"),
531 N_("VFP system register expected"),
532 N_("Maverick MVF register expected"),
533 N_("Maverick MVD register expected"),
534 N_("Maverick MVFX register expected"),
535 N_("Maverick MVDX register expected"),
536 N_("Maverick MVAX register expected"),
537 N_("Maverick DSPSC register expected"),
538 N_("iWMMXt data register expected"),
539 N_("iWMMXt control register expected"),
540 N_("iWMMXt scalar register expected"),
541 N_("XScale accumulator register expected"),
544 /* Some well known registers that we refer to directly elsewhere. */
549 /* ARM instructions take 4bytes in the object file, Thumb instructions
555 /* Basic string to match. */
556 const char *template;
558 /* Parameters to instruction. */
559 unsigned char operands
[8];
561 /* Conditional tag - see opcode_lookup. */
562 unsigned int tag
: 4;
564 /* Basic instruction code. */
565 unsigned int avalue
: 28;
567 /* Thumb-format instruction code. */
570 /* Which architecture variant provides this instruction. */
571 const arm_feature_set
*avariant
;
572 const arm_feature_set
*tvariant
;
574 /* Function to call to encode instruction in ARM format. */
575 void (* aencode
) (void);
577 /* Function to call to encode instruction in Thumb format. */
578 void (* tencode
) (void);
581 /* Defines for various bits that we will want to toggle. */
582 #define INST_IMMEDIATE 0x02000000
583 #define OFFSET_REG 0x02000000
584 #define HWOFFSET_IMM 0x00400000
585 #define SHIFT_BY_REG 0x00000010
586 #define PRE_INDEX 0x01000000
587 #define INDEX_UP 0x00800000
588 #define WRITE_BACK 0x00200000
589 #define LDM_TYPE_2_OR_3 0x00400000
590 #define CPSI_MMOD 0x00020000
592 #define LITERAL_MASK 0xf000f000
593 #define OPCODE_MASK 0xfe1fffff
594 #define V4_STR_BIT 0x00000020
596 #define T2_SUBS_PC_LR 0xf3de8f00
598 #define DATA_OP_SHIFT 21
600 #define T2_OPCODE_MASK 0xfe1fffff
601 #define T2_DATA_OP_SHIFT 21
603 /* Codes to distinguish the arithmetic instructions. */
614 #define OPCODE_CMP 10
615 #define OPCODE_CMN 11
616 #define OPCODE_ORR 12
617 #define OPCODE_MOV 13
618 #define OPCODE_BIC 14
619 #define OPCODE_MVN 15
621 #define T2_OPCODE_AND 0
622 #define T2_OPCODE_BIC 1
623 #define T2_OPCODE_ORR 2
624 #define T2_OPCODE_ORN 3
625 #define T2_OPCODE_EOR 4
626 #define T2_OPCODE_ADD 8
627 #define T2_OPCODE_ADC 10
628 #define T2_OPCODE_SBC 11
629 #define T2_OPCODE_SUB 13
630 #define T2_OPCODE_RSB 14
632 #define T_OPCODE_MUL 0x4340
633 #define T_OPCODE_TST 0x4200
634 #define T_OPCODE_CMN 0x42c0
635 #define T_OPCODE_NEG 0x4240
636 #define T_OPCODE_MVN 0x43c0
638 #define T_OPCODE_ADD_R3 0x1800
639 #define T_OPCODE_SUB_R3 0x1a00
640 #define T_OPCODE_ADD_HI 0x4400
641 #define T_OPCODE_ADD_ST 0xb000
642 #define T_OPCODE_SUB_ST 0xb080
643 #define T_OPCODE_ADD_SP 0xa800
644 #define T_OPCODE_ADD_PC 0xa000
645 #define T_OPCODE_ADD_I8 0x3000
646 #define T_OPCODE_SUB_I8 0x3800
647 #define T_OPCODE_ADD_I3 0x1c00
648 #define T_OPCODE_SUB_I3 0x1e00
650 #define T_OPCODE_ASR_R 0x4100
651 #define T_OPCODE_LSL_R 0x4080
652 #define T_OPCODE_LSR_R 0x40c0
653 #define T_OPCODE_ROR_R 0x41c0
654 #define T_OPCODE_ASR_I 0x1000
655 #define T_OPCODE_LSL_I 0x0000
656 #define T_OPCODE_LSR_I 0x0800
658 #define T_OPCODE_MOV_I8 0x2000
659 #define T_OPCODE_CMP_I8 0x2800
660 #define T_OPCODE_CMP_LR 0x4280
661 #define T_OPCODE_MOV_HR 0x4600
662 #define T_OPCODE_CMP_HR 0x4500
664 #define T_OPCODE_LDR_PC 0x4800
665 #define T_OPCODE_LDR_SP 0x9800
666 #define T_OPCODE_STR_SP 0x9000
667 #define T_OPCODE_LDR_IW 0x6800
668 #define T_OPCODE_STR_IW 0x6000
669 #define T_OPCODE_LDR_IH 0x8800
670 #define T_OPCODE_STR_IH 0x8000
671 #define T_OPCODE_LDR_IB 0x7800
672 #define T_OPCODE_STR_IB 0x7000
673 #define T_OPCODE_LDR_RW 0x5800
674 #define T_OPCODE_STR_RW 0x5000
675 #define T_OPCODE_LDR_RH 0x5a00
676 #define T_OPCODE_STR_RH 0x5200
677 #define T_OPCODE_LDR_RB 0x5c00
678 #define T_OPCODE_STR_RB 0x5400
680 #define T_OPCODE_PUSH 0xb400
681 #define T_OPCODE_POP 0xbc00
683 #define T_OPCODE_BRANCH 0xe000
685 #define THUMB_SIZE 2 /* Size of thumb instruction. */
686 #define THUMB_PP_PC_LR 0x0100
687 #define THUMB_LOAD_BIT 0x0800
688 #define THUMB2_LOAD_BIT 0x00100000
690 #define BAD_ARGS _("bad arguments to instruction")
691 #define BAD_SP _("r13 not allowed here")
692 #define BAD_PC _("r15 not allowed here")
693 #define BAD_COND _("instruction cannot be conditional")
694 #define BAD_OVERLAP _("registers may not be the same")
695 #define BAD_HIREG _("lo register required")
696 #define BAD_THUMB32 _("instruction not supported in Thumb16 mode")
697 #define BAD_ADDR_MODE _("instruction does not accept this addressing mode");
698 #define BAD_BRANCH _("branch must be last instruction in IT block")
699 #define BAD_NOT_IT _("instruction not allowed in IT block")
700 #define BAD_FPU _("selected FPU does not support instruction")
701 #define BAD_OUT_IT _("thumb conditional instruction should be in IT block")
702 #define BAD_IT_COND _("incorrect condition in IT block")
703 #define BAD_IT_IT _("IT falling in the range of a previous IT block")
705 static struct hash_control
*arm_ops_hsh
;
706 static struct hash_control
*arm_cond_hsh
;
707 static struct hash_control
*arm_shift_hsh
;
708 static struct hash_control
*arm_psr_hsh
;
709 static struct hash_control
*arm_v7m_psr_hsh
;
710 static struct hash_control
*arm_reg_hsh
;
711 static struct hash_control
*arm_reloc_hsh
;
712 static struct hash_control
*arm_barrier_opt_hsh
;
714 /* Stuff needed to resolve the label ambiguity
723 symbolS
* last_label_seen
;
724 static int label_is_thumb_function_name
= FALSE
;
726 /* Literal pool structure. Held on a per-section
727 and per-sub-section basis. */
729 #define MAX_LITERAL_POOL_SIZE 1024
730 typedef struct literal_pool
732 expressionS literals
[MAX_LITERAL_POOL_SIZE
];
733 unsigned int next_free_entry
;
738 struct literal_pool
* next
;
741 /* Pointer to a linked list of literal pools. */
742 literal_pool
* list_of_pools
= NULL
;
745 # define now_it seg_info (now_seg)->tc_segment_info_data.current_it
747 static struct current_it now_it
;
751 now_it_compatible (int cond
)
753 return (cond
& ~1) == (now_it
.cc
& ~1);
757 conditional_insn (void)
759 return inst
.cond
!= COND_ALWAYS
;
762 static int in_it_block (void);
764 static int handle_it_state (void);
766 static void force_automatic_it_block_close (void);
768 #define set_it_insn_type(type) \
771 inst.it_insn_type = type; \
772 if (handle_it_state () == FAIL) \
777 #define set_it_insn_type_last() \
780 if (inst.cond == COND_ALWAYS) \
781 set_it_insn_type (IF_INSIDE_IT_LAST_INSN); \
783 set_it_insn_type (INSIDE_IT_LAST_INSN); \
789 /* This array holds the chars that always start a comment. If the
790 pre-processor is disabled, these aren't very useful. */
791 const char comment_chars
[] = "@";
793 /* This array holds the chars that only start a comment at the beginning of
794 a line. If the line seems to have the form '# 123 filename'
795 .line and .file directives will appear in the pre-processed output. */
796 /* Note that input_file.c hand checks for '#' at the beginning of the
797 first line of the input file. This is because the compiler outputs
798 #NO_APP at the beginning of its output. */
799 /* Also note that comments like this one will always work. */
800 const char line_comment_chars
[] = "#";
802 const char line_separator_chars
[] = ";";
804 /* Chars that can be used to separate mant
805 from exp in floating point numbers. */
806 const char EXP_CHARS
[] = "eE";
808 /* Chars that mean this number is a floating point constant. */
812 const char FLT_CHARS
[] = "rRsSfFdDxXeEpP";
814 /* Prefix characters that indicate the start of an immediate
816 #define is_immediate_prefix(C) ((C) == '#' || (C) == '$')
818 /* Separator character handling. */
820 #define skip_whitespace(str) do { if (*(str) == ' ') ++(str); } while (0)
823 skip_past_char (char ** str
, char c
)
833 #define skip_past_comma(str) skip_past_char (str, ',')
835 /* Arithmetic expressions (possibly involving symbols). */
837 /* Return TRUE if anything in the expression is a bignum. */
840 walk_no_bignums (symbolS
* sp
)
842 if (symbol_get_value_expression (sp
)->X_op
== O_big
)
845 if (symbol_get_value_expression (sp
)->X_add_symbol
)
847 return (walk_no_bignums (symbol_get_value_expression (sp
)->X_add_symbol
)
848 || (symbol_get_value_expression (sp
)->X_op_symbol
849 && walk_no_bignums (symbol_get_value_expression (sp
)->X_op_symbol
)));
855 static int in_my_get_expression
= 0;
857 /* Third argument to my_get_expression. */
858 #define GE_NO_PREFIX 0
859 #define GE_IMM_PREFIX 1
860 #define GE_OPT_PREFIX 2
861 /* This is a bit of a hack. Use an optional prefix, and also allow big (64-bit)
862 immediates, as can be used in Neon VMVN and VMOV immediate instructions. */
863 #define GE_OPT_PREFIX_BIG 3
866 my_get_expression (expressionS
* ep
, char ** str
, int prefix_mode
)
871 /* In unified syntax, all prefixes are optional. */
873 prefix_mode
= (prefix_mode
== GE_OPT_PREFIX_BIG
) ? prefix_mode
878 case GE_NO_PREFIX
: break;
880 if (!is_immediate_prefix (**str
))
882 inst
.error
= _("immediate expression requires a # prefix");
888 case GE_OPT_PREFIX_BIG
:
889 if (is_immediate_prefix (**str
))
895 memset (ep
, 0, sizeof (expressionS
));
897 save_in
= input_line_pointer
;
898 input_line_pointer
= *str
;
899 in_my_get_expression
= 1;
900 seg
= expression (ep
);
901 in_my_get_expression
= 0;
903 if (ep
->X_op
== O_illegal
)
905 /* We found a bad expression in md_operand(). */
906 *str
= input_line_pointer
;
907 input_line_pointer
= save_in
;
908 if (inst
.error
== NULL
)
909 inst
.error
= _("bad expression");
914 if (seg
!= absolute_section
915 && seg
!= text_section
916 && seg
!= data_section
917 && seg
!= bss_section
918 && seg
!= undefined_section
)
920 inst
.error
= _("bad segment");
921 *str
= input_line_pointer
;
922 input_line_pointer
= save_in
;
927 /* Get rid of any bignums now, so that we don't generate an error for which
928 we can't establish a line number later on. Big numbers are never valid
929 in instructions, which is where this routine is always called. */
930 if (prefix_mode
!= GE_OPT_PREFIX_BIG
931 && (ep
->X_op
== O_big
933 && (walk_no_bignums (ep
->X_add_symbol
)
935 && walk_no_bignums (ep
->X_op_symbol
))))))
937 inst
.error
= _("invalid constant");
938 *str
= input_line_pointer
;
939 input_line_pointer
= save_in
;
943 *str
= input_line_pointer
;
944 input_line_pointer
= save_in
;
948 /* Turn a string in input_line_pointer into a floating point constant
949 of type TYPE, and store the appropriate bytes in *LITP. The number
950 of LITTLENUMS emitted is stored in *SIZEP. An error message is
951 returned, or NULL on OK.
953 Note that fp constants aren't represent in the normal way on the ARM.
954 In big endian mode, things are as expected. However, in little endian
955 mode fp constants are big-endian word-wise, and little-endian byte-wise
956 within the words. For example, (double) 1.1 in big endian mode is
957 the byte sequence 3f f1 99 99 99 99 99 9a, and in little endian mode is
958 the byte sequence 99 99 f1 3f 9a 99 99 99.
960 ??? The format of 12 byte floats is uncertain according to gcc's arm.h. */
963 md_atof (int type
, char * litP
, int * sizeP
)
966 LITTLENUM_TYPE words
[MAX_LITTLENUMS
];
998 return _("Unrecognized or unsupported floating point constant");
1001 t
= atof_ieee (input_line_pointer
, type
, words
);
1003 input_line_pointer
= t
;
1004 *sizeP
= prec
* sizeof (LITTLENUM_TYPE
);
1006 if (target_big_endian
)
1008 for (i
= 0; i
< prec
; i
++)
1010 md_number_to_chars (litP
, (valueT
) words
[i
], sizeof (LITTLENUM_TYPE
));
1011 litP
+= sizeof (LITTLENUM_TYPE
);
1016 if (ARM_CPU_HAS_FEATURE (cpu_variant
, fpu_endian_pure
))
1017 for (i
= prec
- 1; i
>= 0; i
--)
1019 md_number_to_chars (litP
, (valueT
) words
[i
], sizeof (LITTLENUM_TYPE
));
1020 litP
+= sizeof (LITTLENUM_TYPE
);
1023 /* For a 4 byte float the order of elements in `words' is 1 0.
1024 For an 8 byte float the order is 1 0 3 2. */
1025 for (i
= 0; i
< prec
; i
+= 2)
1027 md_number_to_chars (litP
, (valueT
) words
[i
+ 1],
1028 sizeof (LITTLENUM_TYPE
));
1029 md_number_to_chars (litP
+ sizeof (LITTLENUM_TYPE
),
1030 (valueT
) words
[i
], sizeof (LITTLENUM_TYPE
));
1031 litP
+= 2 * sizeof (LITTLENUM_TYPE
);
1038 /* We handle all bad expressions here, so that we can report the faulty
1039 instruction in the error message. */
1041 md_operand (expressionS
* expr
)
1043 if (in_my_get_expression
)
1044 expr
->X_op
= O_illegal
;
1047 /* Immediate values. */
1049 /* Generic immediate-value read function for use in directives.
1050 Accepts anything that 'expression' can fold to a constant.
1051 *val receives the number. */
1054 immediate_for_directive (int *val
)
1057 exp
.X_op
= O_illegal
;
1059 if (is_immediate_prefix (*input_line_pointer
))
1061 input_line_pointer
++;
1065 if (exp
.X_op
!= O_constant
)
1067 as_bad (_("expected #constant"));
1068 ignore_rest_of_line ();
1071 *val
= exp
.X_add_number
;
1076 /* Register parsing. */
1078 /* Generic register parser. CCP points to what should be the
1079 beginning of a register name. If it is indeed a valid register
1080 name, advance CCP over it and return the reg_entry structure;
1081 otherwise return NULL. Does not issue diagnostics. */
1083 static struct reg_entry
*
1084 arm_reg_parse_multi (char **ccp
)
1088 struct reg_entry
*reg
;
1090 #ifdef REGISTER_PREFIX
1091 if (*start
!= REGISTER_PREFIX
)
1095 #ifdef OPTIONAL_REGISTER_PREFIX
1096 if (*start
== OPTIONAL_REGISTER_PREFIX
)
1101 if (!ISALPHA (*p
) || !is_name_beginner (*p
))
1106 while (ISALPHA (*p
) || ISDIGIT (*p
) || *p
== '_');
1108 reg
= (struct reg_entry
*) hash_find_n (arm_reg_hsh
, start
, p
- start
);
1118 arm_reg_alt_syntax (char **ccp
, char *start
, struct reg_entry
*reg
,
1119 enum arm_reg_type type
)
1121 /* Alternative syntaxes are accepted for a few register classes. */
1128 /* Generic coprocessor register names are allowed for these. */
1129 if (reg
&& reg
->type
== REG_TYPE_CN
)
1134 /* For backward compatibility, a bare number is valid here. */
1136 unsigned long processor
= strtoul (start
, ccp
, 10);
1137 if (*ccp
!= start
&& processor
<= 15)
1141 case REG_TYPE_MMXWC
:
1142 /* WC includes WCG. ??? I'm not sure this is true for all
1143 instructions that take WC registers. */
1144 if (reg
&& reg
->type
== REG_TYPE_MMXWCG
)
1155 /* As arm_reg_parse_multi, but the register must be of type TYPE, and the
1156 return value is the register number or FAIL. */
1159 arm_reg_parse (char **ccp
, enum arm_reg_type type
)
1162 struct reg_entry
*reg
= arm_reg_parse_multi (ccp
);
1165 /* Do not allow a scalar (reg+index) to parse as a register. */
1166 if (reg
&& reg
->neon
&& (reg
->neon
->defined
& NTA_HASINDEX
))
1169 if (reg
&& reg
->type
== type
)
1172 if ((ret
= arm_reg_alt_syntax (ccp
, start
, reg
, type
)) != FAIL
)
1179 /* Parse a Neon type specifier. *STR should point at the leading '.'
1180 character. Does no verification at this stage that the type fits the opcode
1187 Can all be legally parsed by this function.
1189 Fills in neon_type struct pointer with parsed information, and updates STR
1190 to point after the parsed type specifier. Returns SUCCESS if this was a legal
1191 type, FAIL if not. */
1194 parse_neon_type (struct neon_type
*type
, char **str
)
1201 while (type
->elems
< NEON_MAX_TYPE_ELS
)
1203 enum neon_el_type thistype
= NT_untyped
;
1204 unsigned thissize
= -1u;
1211 /* Just a size without an explicit type. */
1215 switch (TOLOWER (*ptr
))
1217 case 'i': thistype
= NT_integer
; break;
1218 case 'f': thistype
= NT_float
; break;
1219 case 'p': thistype
= NT_poly
; break;
1220 case 's': thistype
= NT_signed
; break;
1221 case 'u': thistype
= NT_unsigned
; break;
1223 thistype
= NT_float
;
1228 as_bad (_("unexpected character `%c' in type specifier"), *ptr
);
1234 /* .f is an abbreviation for .f32. */
1235 if (thistype
== NT_float
&& !ISDIGIT (*ptr
))
1240 thissize
= strtoul (ptr
, &ptr
, 10);
1242 if (thissize
!= 8 && thissize
!= 16 && thissize
!= 32
1245 as_bad (_("bad size %d in type specifier"), thissize
);
1253 type
->el
[type
->elems
].type
= thistype
;
1254 type
->el
[type
->elems
].size
= thissize
;
1259 /* Empty/missing type is not a successful parse. */
1260 if (type
->elems
== 0)
1268 /* Errors may be set multiple times during parsing or bit encoding
1269 (particularly in the Neon bits), but usually the earliest error which is set
1270 will be the most meaningful. Avoid overwriting it with later (cascading)
1271 errors by calling this function. */
1274 first_error (const char *err
)
1280 /* Parse a single type, e.g. ".s32", leading period included. */
1282 parse_neon_operand_type (struct neon_type_el
*vectype
, char **ccp
)
1285 struct neon_type optype
;
1289 if (parse_neon_type (&optype
, &str
) == SUCCESS
)
1291 if (optype
.elems
== 1)
1292 *vectype
= optype
.el
[0];
1295 first_error (_("only one type should be specified for operand"));
1301 first_error (_("vector type expected"));
1313 /* Special meanings for indices (which have a range of 0-7), which will fit into
1316 #define NEON_ALL_LANES 15
1317 #define NEON_INTERLEAVE_LANES 14
1319 /* Parse either a register or a scalar, with an optional type. Return the
1320 register number, and optionally fill in the actual type of the register
1321 when multiple alternatives were given (NEON_TYPE_NDQ) in *RTYPE, and
1322 type/index information in *TYPEINFO. */
1325 parse_typed_reg_or_scalar (char **ccp
, enum arm_reg_type type
,
1326 enum arm_reg_type
*rtype
,
1327 struct neon_typed_alias
*typeinfo
)
1330 struct reg_entry
*reg
= arm_reg_parse_multi (&str
);
1331 struct neon_typed_alias atype
;
1332 struct neon_type_el parsetype
;
1336 atype
.eltype
.type
= NT_invtype
;
1337 atype
.eltype
.size
= -1;
1339 /* Try alternate syntax for some types of register. Note these are mutually
1340 exclusive with the Neon syntax extensions. */
1343 int altreg
= arm_reg_alt_syntax (&str
, *ccp
, reg
, type
);
1351 /* Undo polymorphism when a set of register types may be accepted. */
1352 if ((type
== REG_TYPE_NDQ
1353 && (reg
->type
== REG_TYPE_NQ
|| reg
->type
== REG_TYPE_VFD
))
1354 || (type
== REG_TYPE_VFSD
1355 && (reg
->type
== REG_TYPE_VFS
|| reg
->type
== REG_TYPE_VFD
))
1356 || (type
== REG_TYPE_NSDQ
1357 && (reg
->type
== REG_TYPE_VFS
|| reg
->type
== REG_TYPE_VFD
1358 || reg
->type
== REG_TYPE_NQ
))
1359 || (type
== REG_TYPE_MMXWC
1360 && (reg
->type
== REG_TYPE_MMXWCG
)))
1363 if (type
!= reg
->type
)
1369 if (parse_neon_operand_type (&parsetype
, &str
) == SUCCESS
)
1371 if ((atype
.defined
& NTA_HASTYPE
) != 0)
1373 first_error (_("can't redefine type for operand"));
1376 atype
.defined
|= NTA_HASTYPE
;
1377 atype
.eltype
= parsetype
;
1380 if (skip_past_char (&str
, '[') == SUCCESS
)
1382 if (type
!= REG_TYPE_VFD
)
1384 first_error (_("only D registers may be indexed"));
1388 if ((atype
.defined
& NTA_HASINDEX
) != 0)
1390 first_error (_("can't change index for operand"));
1394 atype
.defined
|= NTA_HASINDEX
;
1396 if (skip_past_char (&str
, ']') == SUCCESS
)
1397 atype
.index
= NEON_ALL_LANES
;
1402 my_get_expression (&exp
, &str
, GE_NO_PREFIX
);
1404 if (exp
.X_op
!= O_constant
)
1406 first_error (_("constant expression required"));
1410 if (skip_past_char (&str
, ']') == FAIL
)
1413 atype
.index
= exp
.X_add_number
;
1428 /* Like arm_reg_parse, but allow allow the following extra features:
1429 - If RTYPE is non-zero, return the (possibly restricted) type of the
1430 register (e.g. Neon double or quad reg when either has been requested).
1431 - If this is a Neon vector type with additional type information, fill
1432 in the struct pointed to by VECTYPE (if non-NULL).
1433 This function will fault on encountering a scalar. */
1436 arm_typed_reg_parse (char **ccp
, enum arm_reg_type type
,
1437 enum arm_reg_type
*rtype
, struct neon_type_el
*vectype
)
1439 struct neon_typed_alias atype
;
1441 int reg
= parse_typed_reg_or_scalar (&str
, type
, rtype
, &atype
);
1446 /* Do not allow a scalar (reg+index) to parse as a register. */
1447 if ((atype
.defined
& NTA_HASINDEX
) != 0)
1449 first_error (_("register operand expected, but got scalar"));
1454 *vectype
= atype
.eltype
;
1461 #define NEON_SCALAR_REG(X) ((X) >> 4)
1462 #define NEON_SCALAR_INDEX(X) ((X) & 15)
1464 /* Parse a Neon scalar. Most of the time when we're parsing a scalar, we don't
1465 have enough information to be able to do a good job bounds-checking. So, we
1466 just do easy checks here, and do further checks later. */
1469 parse_scalar (char **ccp
, int elsize
, struct neon_type_el
*type
)
1473 struct neon_typed_alias atype
;
1475 reg
= parse_typed_reg_or_scalar (&str
, REG_TYPE_VFD
, NULL
, &atype
);
1477 if (reg
== FAIL
|| (atype
.defined
& NTA_HASINDEX
) == 0)
1480 if (atype
.index
== NEON_ALL_LANES
)
1482 first_error (_("scalar must have an index"));
1485 else if (atype
.index
>= 64 / elsize
)
1487 first_error (_("scalar index out of range"));
1492 *type
= atype
.eltype
;
1496 return reg
* 16 + atype
.index
;
1499 /* Parse an ARM register list. Returns the bitmask, or FAIL. */
1502 parse_reg_list (char ** strp
)
1504 char * str
= * strp
;
1508 /* We come back here if we get ranges concatenated by '+' or '|'. */
1523 if ((reg
= arm_reg_parse (&str
, REG_TYPE_RN
)) == FAIL
)
1525 first_error (_(reg_expected_msgs
[REG_TYPE_RN
]));
1535 first_error (_("bad range in register list"));
1539 for (i
= cur_reg
+ 1; i
< reg
; i
++)
1541 if (range
& (1 << i
))
1543 (_("Warning: duplicated register (r%d) in register list"),
1551 if (range
& (1 << reg
))
1552 as_tsktsk (_("Warning: duplicated register (r%d) in register list"),
1554 else if (reg
<= cur_reg
)
1555 as_tsktsk (_("Warning: register range not in ascending order"));
1560 while (skip_past_comma (&str
) != FAIL
1561 || (in_range
= 1, *str
++ == '-'));
1566 first_error (_("missing `}'"));
1574 if (my_get_expression (&expr
, &str
, GE_NO_PREFIX
))
1577 if (expr
.X_op
== O_constant
)
1579 if (expr
.X_add_number
1580 != (expr
.X_add_number
& 0x0000ffff))
1582 inst
.error
= _("invalid register mask");
1586 if ((range
& expr
.X_add_number
) != 0)
1588 int regno
= range
& expr
.X_add_number
;
1591 regno
= (1 << regno
) - 1;
1593 (_("Warning: duplicated register (r%d) in register list"),
1597 range
|= expr
.X_add_number
;
1601 if (inst
.reloc
.type
!= 0)
1603 inst
.error
= _("expression too complex");
1607 memcpy (&inst
.reloc
.exp
, &expr
, sizeof (expressionS
));
1608 inst
.reloc
.type
= BFD_RELOC_ARM_MULTI
;
1609 inst
.reloc
.pc_rel
= 0;
1613 if (*str
== '|' || *str
== '+')
1619 while (another_range
);
1625 /* Types of registers in a list. */
1634 /* Parse a VFP register list. If the string is invalid return FAIL.
1635 Otherwise return the number of registers, and set PBASE to the first
1636 register. Parses registers of type ETYPE.
1637 If REGLIST_NEON_D is used, several syntax enhancements are enabled:
1638 - Q registers can be used to specify pairs of D registers
1639 - { } can be omitted from around a singleton register list
1640 FIXME: This is not implemented, as it would require backtracking in
1643 This could be done (the meaning isn't really ambiguous), but doesn't
1644 fit in well with the current parsing framework.
1645 - 32 D registers may be used (also true for VFPv3).
1646 FIXME: Types are ignored in these register lists, which is probably a
1650 parse_vfp_reg_list (char **ccp
, unsigned int *pbase
, enum reg_list_els etype
)
1655 enum arm_reg_type regtype
= 0;
1659 unsigned long mask
= 0;
1664 inst
.error
= _("expecting {");
1673 regtype
= REG_TYPE_VFS
;
1678 regtype
= REG_TYPE_VFD
;
1681 case REGLIST_NEON_D
:
1682 regtype
= REG_TYPE_NDQ
;
1686 if (etype
!= REGLIST_VFP_S
)
1688 /* VFPv3 allows 32 D registers, except for the VFPv3-D16 variant. */
1689 if (ARM_CPU_HAS_FEATURE (cpu_variant
, fpu_vfp_ext_d32
))
1693 ARM_MERGE_FEATURE_SETS (thumb_arch_used
, thumb_arch_used
,
1696 ARM_MERGE_FEATURE_SETS (arm_arch_used
, arm_arch_used
,
1703 base_reg
= max_regs
;
1707 int setmask
= 1, addregs
= 1;
1709 new_base
= arm_typed_reg_parse (&str
, regtype
, ®type
, NULL
);
1711 if (new_base
== FAIL
)
1713 first_error (_(reg_expected_msgs
[regtype
]));
1717 if (new_base
>= max_regs
)
1719 first_error (_("register out of range in list"));
1723 /* Note: a value of 2 * n is returned for the register Q<n>. */
1724 if (regtype
== REG_TYPE_NQ
)
1730 if (new_base
< base_reg
)
1731 base_reg
= new_base
;
1733 if (mask
& (setmask
<< new_base
))
1735 first_error (_("invalid register list"));
1739 if ((mask
>> new_base
) != 0 && ! warned
)
1741 as_tsktsk (_("register list not in ascending order"));
1745 mask
|= setmask
<< new_base
;
1748 if (*str
== '-') /* We have the start of a range expression */
1754 if ((high_range
= arm_typed_reg_parse (&str
, regtype
, NULL
, NULL
))
1757 inst
.error
= gettext (reg_expected_msgs
[regtype
]);
1761 if (high_range
>= max_regs
)
1763 first_error (_("register out of range in list"));
1767 if (regtype
== REG_TYPE_NQ
)
1768 high_range
= high_range
+ 1;
1770 if (high_range
<= new_base
)
1772 inst
.error
= _("register range not in ascending order");
1776 for (new_base
+= addregs
; new_base
<= high_range
; new_base
+= addregs
)
1778 if (mask
& (setmask
<< new_base
))
1780 inst
.error
= _("invalid register list");
1784 mask
|= setmask
<< new_base
;
1789 while (skip_past_comma (&str
) != FAIL
);
1793 /* Sanity check -- should have raised a parse error above. */
1794 if (count
== 0 || count
> max_regs
)
1799 /* Final test -- the registers must be consecutive. */
1801 for (i
= 0; i
< count
; i
++)
1803 if ((mask
& (1u << i
)) == 0)
1805 inst
.error
= _("non-contiguous register range");
1815 /* True if two alias types are the same. */
1818 neon_alias_types_same (struct neon_typed_alias
*a
, struct neon_typed_alias
*b
)
1826 if (a
->defined
!= b
->defined
)
1829 if ((a
->defined
& NTA_HASTYPE
) != 0
1830 && (a
->eltype
.type
!= b
->eltype
.type
1831 || a
->eltype
.size
!= b
->eltype
.size
))
1834 if ((a
->defined
& NTA_HASINDEX
) != 0
1835 && (a
->index
!= b
->index
))
1841 /* Parse element/structure lists for Neon VLD<n> and VST<n> instructions.
1842 The base register is put in *PBASE.
1843 The lane (or one of the NEON_*_LANES constants) is placed in bits [3:0] of
1845 The register stride (minus one) is put in bit 4 of the return value.
1846 Bits [6:5] encode the list length (minus one).
1847 The type of the list elements is put in *ELTYPE, if non-NULL. */
1849 #define NEON_LANE(X) ((X) & 0xf)
1850 #define NEON_REG_STRIDE(X) ((((X) >> 4) & 1) + 1)
1851 #define NEON_REGLIST_LENGTH(X) ((((X) >> 5) & 3) + 1)
1854 parse_neon_el_struct_list (char **str
, unsigned *pbase
,
1855 struct neon_type_el
*eltype
)
1862 int leading_brace
= 0;
1863 enum arm_reg_type rtype
= REG_TYPE_NDQ
;
1865 const char *const incr_error
= "register stride must be 1 or 2";
1866 const char *const type_error
= "mismatched element/structure types in list";
1867 struct neon_typed_alias firsttype
;
1869 if (skip_past_char (&ptr
, '{') == SUCCESS
)
1874 struct neon_typed_alias atype
;
1875 int getreg
= parse_typed_reg_or_scalar (&ptr
, rtype
, &rtype
, &atype
);
1879 first_error (_(reg_expected_msgs
[rtype
]));
1886 if (rtype
== REG_TYPE_NQ
)
1893 else if (reg_incr
== -1)
1895 reg_incr
= getreg
- base_reg
;
1896 if (reg_incr
< 1 || reg_incr
> 2)
1898 first_error (_(incr_error
));
1902 else if (getreg
!= base_reg
+ reg_incr
* count
)
1904 first_error (_(incr_error
));
1908 if (!neon_alias_types_same (&atype
, &firsttype
))
1910 first_error (_(type_error
));
1914 /* Handle Dn-Dm or Qn-Qm syntax. Can only be used with non-indexed list
1918 struct neon_typed_alias htype
;
1919 int hireg
, dregs
= (rtype
== REG_TYPE_NQ
) ? 2 : 1;
1921 lane
= NEON_INTERLEAVE_LANES
;
1922 else if (lane
!= NEON_INTERLEAVE_LANES
)
1924 first_error (_(type_error
));
1929 else if (reg_incr
!= 1)
1931 first_error (_("don't use Rn-Rm syntax with non-unit stride"));
1935 hireg
= parse_typed_reg_or_scalar (&ptr
, rtype
, NULL
, &htype
);
1938 first_error (_(reg_expected_msgs
[rtype
]));
1941 if (!neon_alias_types_same (&htype
, &firsttype
))
1943 first_error (_(type_error
));
1946 count
+= hireg
+ dregs
- getreg
;
1950 /* If we're using Q registers, we can't use [] or [n] syntax. */
1951 if (rtype
== REG_TYPE_NQ
)
1957 if ((atype
.defined
& NTA_HASINDEX
) != 0)
1961 else if (lane
!= atype
.index
)
1963 first_error (_(type_error
));
1967 else if (lane
== -1)
1968 lane
= NEON_INTERLEAVE_LANES
;
1969 else if (lane
!= NEON_INTERLEAVE_LANES
)
1971 first_error (_(type_error
));
1976 while ((count
!= 1 || leading_brace
) && skip_past_comma (&ptr
) != FAIL
);
1978 /* No lane set by [x]. We must be interleaving structures. */
1980 lane
= NEON_INTERLEAVE_LANES
;
1983 if (lane
== -1 || base_reg
== -1 || count
< 1 || count
> 4
1984 || (count
> 1 && reg_incr
== -1))
1986 first_error (_("error parsing element/structure list"));
1990 if ((count
> 1 || leading_brace
) && skip_past_char (&ptr
, '}') == FAIL
)
1992 first_error (_("expected }"));
2000 *eltype
= firsttype
.eltype
;
2005 return lane
| ((reg_incr
- 1) << 4) | ((count
- 1) << 5);
2008 /* Parse an explicit relocation suffix on an expression. This is
2009 either nothing, or a word in parentheses. Note that if !OBJ_ELF,
2010 arm_reloc_hsh contains no entries, so this function can only
2011 succeed if there is no () after the word. Returns -1 on error,
2012 BFD_RELOC_UNUSED if there wasn't any suffix. */
2014 parse_reloc (char **str
)
2016 struct reloc_entry
*r
;
2020 return BFD_RELOC_UNUSED
;
2025 while (*q
&& *q
!= ')' && *q
!= ',')
2030 if ((r
= hash_find_n (arm_reloc_hsh
, p
, q
- p
)) == NULL
)
2037 /* Directives: register aliases. */
2039 static struct reg_entry
*
2040 insert_reg_alias (char *str
, int number
, int type
)
2042 struct reg_entry
*new;
2045 if ((new = hash_find (arm_reg_hsh
, str
)) != 0)
2048 as_warn (_("ignoring attempt to redefine built-in register '%s'"), str
);
2050 /* Only warn about a redefinition if it's not defined as the
2052 else if (new->number
!= number
|| new->type
!= type
)
2053 as_warn (_("ignoring redefinition of register alias '%s'"), str
);
2058 name
= xstrdup (str
);
2059 new = xmalloc (sizeof (struct reg_entry
));
2062 new->number
= number
;
2064 new->builtin
= FALSE
;
2067 if (hash_insert (arm_reg_hsh
, name
, (void *) new))
2074 insert_neon_reg_alias (char *str
, int number
, int type
,
2075 struct neon_typed_alias
*atype
)
2077 struct reg_entry
*reg
= insert_reg_alias (str
, number
, type
);
2081 first_error (_("attempt to redefine typed alias"));
2087 reg
->neon
= xmalloc (sizeof (struct neon_typed_alias
));
2088 *reg
->neon
= *atype
;
2092 /* Look for the .req directive. This is of the form:
2094 new_register_name .req existing_register_name
2096 If we find one, or if it looks sufficiently like one that we want to
2097 handle any error here, return TRUE. Otherwise return FALSE. */
2100 create_register_alias (char * newname
, char *p
)
2102 struct reg_entry
*old
;
2103 char *oldname
, *nbuf
;
2106 /* The input scrubber ensures that whitespace after the mnemonic is
2107 collapsed to single spaces. */
2109 if (strncmp (oldname
, " .req ", 6) != 0)
2113 if (*oldname
== '\0')
2116 old
= hash_find (arm_reg_hsh
, oldname
);
2119 as_warn (_("unknown register '%s' -- .req ignored"), oldname
);
2123 /* If TC_CASE_SENSITIVE is defined, then newname already points to
2124 the desired alias name, and p points to its end. If not, then
2125 the desired alias name is in the global original_case_string. */
2126 #ifdef TC_CASE_SENSITIVE
2129 newname
= original_case_string
;
2130 nlen
= strlen (newname
);
2133 nbuf
= alloca (nlen
+ 1);
2134 memcpy (nbuf
, newname
, nlen
);
2137 /* Create aliases under the new name as stated; an all-lowercase
2138 version of the new name; and an all-uppercase version of the new
2140 if (insert_reg_alias (nbuf
, old
->number
, old
->type
) != NULL
)
2142 for (p
= nbuf
; *p
; p
++)
2145 if (strncmp (nbuf
, newname
, nlen
))
2147 /* If this attempt to create an additional alias fails, do not bother
2148 trying to create the all-lower case alias. We will fail and issue
2149 a second, duplicate error message. This situation arises when the
2150 programmer does something like:
2153 The second .req creates the "Foo" alias but then fails to create
2154 the artificial FOO alias because it has already been created by the
2156 if (insert_reg_alias (nbuf
, old
->number
, old
->type
) == NULL
)
2160 for (p
= nbuf
; *p
; p
++)
2163 if (strncmp (nbuf
, newname
, nlen
))
2164 insert_reg_alias (nbuf
, old
->number
, old
->type
);
2170 /* Create a Neon typed/indexed register alias using directives, e.g.:
2175 These typed registers can be used instead of the types specified after the
2176 Neon mnemonic, so long as all operands given have types. Types can also be
2177 specified directly, e.g.:
2178 vadd d0.s32, d1.s32, d2.s32 */
2181 create_neon_reg_alias (char *newname
, char *p
)
2183 enum arm_reg_type basetype
;
2184 struct reg_entry
*basereg
;
2185 struct reg_entry mybasereg
;
2186 struct neon_type ntype
;
2187 struct neon_typed_alias typeinfo
;
2188 char *namebuf
, *nameend
;
2191 typeinfo
.defined
= 0;
2192 typeinfo
.eltype
.type
= NT_invtype
;
2193 typeinfo
.eltype
.size
= -1;
2194 typeinfo
.index
= -1;
2198 if (strncmp (p
, " .dn ", 5) == 0)
2199 basetype
= REG_TYPE_VFD
;
2200 else if (strncmp (p
, " .qn ", 5) == 0)
2201 basetype
= REG_TYPE_NQ
;
2210 basereg
= arm_reg_parse_multi (&p
);
2212 if (basereg
&& basereg
->type
!= basetype
)
2214 as_bad (_("bad type for register"));
2218 if (basereg
== NULL
)
2221 /* Try parsing as an integer. */
2222 my_get_expression (&exp
, &p
, GE_NO_PREFIX
);
2223 if (exp
.X_op
!= O_constant
)
2225 as_bad (_("expression must be constant"));
2228 basereg
= &mybasereg
;
2229 basereg
->number
= (basetype
== REG_TYPE_NQ
) ? exp
.X_add_number
* 2
2235 typeinfo
= *basereg
->neon
;
2237 if (parse_neon_type (&ntype
, &p
) == SUCCESS
)
2239 /* We got a type. */
2240 if (typeinfo
.defined
& NTA_HASTYPE
)
2242 as_bad (_("can't redefine the type of a register alias"));
2246 typeinfo
.defined
|= NTA_HASTYPE
;
2247 if (ntype
.elems
!= 1)
2249 as_bad (_("you must specify a single type only"));
2252 typeinfo
.eltype
= ntype
.el
[0];
2255 if (skip_past_char (&p
, '[') == SUCCESS
)
2258 /* We got a scalar index. */
2260 if (typeinfo
.defined
& NTA_HASINDEX
)
2262 as_bad (_("can't redefine the index of a scalar alias"));
2266 my_get_expression (&exp
, &p
, GE_NO_PREFIX
);
2268 if (exp
.X_op
!= O_constant
)
2270 as_bad (_("scalar index must be constant"));
2274 typeinfo
.defined
|= NTA_HASINDEX
;
2275 typeinfo
.index
= exp
.X_add_number
;
2277 if (skip_past_char (&p
, ']') == FAIL
)
2279 as_bad (_("expecting ]"));
2284 namelen
= nameend
- newname
;
2285 namebuf
= alloca (namelen
+ 1);
2286 strncpy (namebuf
, newname
, namelen
);
2287 namebuf
[namelen
] = '\0';
2289 insert_neon_reg_alias (namebuf
, basereg
->number
, basetype
,
2290 typeinfo
.defined
!= 0 ? &typeinfo
: NULL
);
2292 /* Insert name in all uppercase. */
2293 for (p
= namebuf
; *p
; p
++)
2296 if (strncmp (namebuf
, newname
, namelen
))
2297 insert_neon_reg_alias (namebuf
, basereg
->number
, basetype
,
2298 typeinfo
.defined
!= 0 ? &typeinfo
: NULL
);
2300 /* Insert name in all lowercase. */
2301 for (p
= namebuf
; *p
; p
++)
2304 if (strncmp (namebuf
, newname
, namelen
))
2305 insert_neon_reg_alias (namebuf
, basereg
->number
, basetype
,
2306 typeinfo
.defined
!= 0 ? &typeinfo
: NULL
);
2311 /* Should never be called, as .req goes between the alias and the
2312 register name, not at the beginning of the line. */
2314 s_req (int a ATTRIBUTE_UNUSED
)
2316 as_bad (_("invalid syntax for .req directive"));
2320 s_dn (int a ATTRIBUTE_UNUSED
)
2322 as_bad (_("invalid syntax for .dn directive"));
2326 s_qn (int a ATTRIBUTE_UNUSED
)
2328 as_bad (_("invalid syntax for .qn directive"));
2331 /* The .unreq directive deletes an alias which was previously defined
2332 by .req. For example:
2338 s_unreq (int a ATTRIBUTE_UNUSED
)
2343 name
= input_line_pointer
;
2345 while (*input_line_pointer
!= 0
2346 && *input_line_pointer
!= ' '
2347 && *input_line_pointer
!= '\n')
2348 ++input_line_pointer
;
2350 saved_char
= *input_line_pointer
;
2351 *input_line_pointer
= 0;
2354 as_bad (_("invalid syntax for .unreq directive"));
2357 struct reg_entry
*reg
= hash_find (arm_reg_hsh
, name
);
2360 as_bad (_("unknown register alias '%s'"), name
);
2361 else if (reg
->builtin
)
2362 as_warn (_("ignoring attempt to undefine built-in register '%s'"),
2369 hash_delete (arm_reg_hsh
, name
, FALSE
);
2370 free ((char *) reg
->name
);
2375 /* Also locate the all upper case and all lower case versions.
2376 Do not complain if we cannot find one or the other as it
2377 was probably deleted above. */
2379 nbuf
= strdup (name
);
2380 for (p
= nbuf
; *p
; p
++)
2382 reg
= hash_find (arm_reg_hsh
, nbuf
);
2385 hash_delete (arm_reg_hsh
, nbuf
, FALSE
);
2386 free ((char *) reg
->name
);
2392 for (p
= nbuf
; *p
; p
++)
2394 reg
= hash_find (arm_reg_hsh
, nbuf
);
2397 hash_delete (arm_reg_hsh
, nbuf
, FALSE
);
2398 free ((char *) reg
->name
);
2408 *input_line_pointer
= saved_char
;
2409 demand_empty_rest_of_line ();
2412 /* Directives: Instruction set selection. */
2415 /* This code is to handle mapping symbols as defined in the ARM ELF spec.
2416 (See "Mapping symbols", section 4.5.5, ARM AAELF version 1.0).
2417 Note that previously, $a and $t has type STT_FUNC (BSF_OBJECT flag),
2418 and $d has type STT_OBJECT (BSF_OBJECT flag). Now all three are untyped. */
2420 static enum mstate mapstate
= MAP_UNDEFINED
;
2423 mapping_state (enum mstate state
)
2426 const char * symname
;
2429 if (mapstate
== state
)
2430 /* The mapping symbol has already been emitted.
2431 There is nothing else to do. */
2440 type
= BSF_NO_FLAGS
;
2444 type
= BSF_NO_FLAGS
;
2448 type
= BSF_NO_FLAGS
;
2456 seg_info (now_seg
)->tc_segment_info_data
.mapstate
= state
;
2458 symbolP
= symbol_new (symname
, now_seg
, (valueT
) frag_now_fix (), frag_now
);
2459 symbol_table_insert (symbolP
);
2460 symbol_get_bfdsym (symbolP
)->flags
|= type
| BSF_LOCAL
;
2465 THUMB_SET_FUNC (symbolP
, 0);
2466 ARM_SET_THUMB (symbolP
, 0);
2467 ARM_SET_INTERWORK (symbolP
, support_interwork
);
2471 THUMB_SET_FUNC (symbolP
, 1);
2472 ARM_SET_THUMB (symbolP
, 1);
2473 ARM_SET_INTERWORK (symbolP
, support_interwork
);
2482 #define mapping_state(x) /* nothing */
2485 /* Find the real, Thumb encoded start of a Thumb function. */
2489 find_real_start (symbolS
* symbolP
)
2492 const char * name
= S_GET_NAME (symbolP
);
2493 symbolS
* new_target
;
2495 /* This definition must agree with the one in gcc/config/arm/thumb.c. */
2496 #define STUB_NAME ".real_start_of"
2501 /* The compiler may generate BL instructions to local labels because
2502 it needs to perform a branch to a far away location. These labels
2503 do not have a corresponding ".real_start_of" label. We check
2504 both for S_IS_LOCAL and for a leading dot, to give a way to bypass
2505 the ".real_start_of" convention for nonlocal branches. */
2506 if (S_IS_LOCAL (symbolP
) || name
[0] == '.')
2509 real_start
= ACONCAT ((STUB_NAME
, name
, NULL
));
2510 new_target
= symbol_find (real_start
);
2512 if (new_target
== NULL
)
2514 as_warn (_("Failed to find real start of function: %s\n"), name
);
2515 new_target
= symbolP
;
2523 opcode_select (int width
)
2530 if (!ARM_CPU_HAS_FEATURE (cpu_variant
, arm_ext_v4t
))
2531 as_bad (_("selected processor does not support THUMB opcodes"));
2534 /* No need to force the alignment, since we will have been
2535 coming from ARM mode, which is word-aligned. */
2536 record_alignment (now_seg
, 1);
2538 mapping_state (MAP_THUMB
);
2544 if (!ARM_CPU_HAS_FEATURE (cpu_variant
, arm_ext_v1
))
2545 as_bad (_("selected processor does not support ARM opcodes"));
2550 frag_align (2, 0, 0);
2552 record_alignment (now_seg
, 1);
2554 mapping_state (MAP_ARM
);
2558 as_bad (_("invalid instruction size selected (%d)"), width
);
2563 s_arm (int ignore ATTRIBUTE_UNUSED
)
2566 demand_empty_rest_of_line ();
2570 s_thumb (int ignore ATTRIBUTE_UNUSED
)
2573 demand_empty_rest_of_line ();
2577 s_code (int unused ATTRIBUTE_UNUSED
)
2581 temp
= get_absolute_expression ();
2586 opcode_select (temp
);
2590 as_bad (_("invalid operand to .code directive (%d) (expecting 16 or 32)"), temp
);
2595 s_force_thumb (int ignore ATTRIBUTE_UNUSED
)
2597 /* If we are not already in thumb mode go into it, EVEN if
2598 the target processor does not support thumb instructions.
2599 This is used by gcc/config/arm/lib1funcs.asm for example
2600 to compile interworking support functions even if the
2601 target processor should not support interworking. */
2605 record_alignment (now_seg
, 1);
2608 demand_empty_rest_of_line ();
2612 s_thumb_func (int ignore ATTRIBUTE_UNUSED
)
2616 /* The following label is the name/address of the start of a Thumb function.
2617 We need to know this for the interworking support. */
2618 label_is_thumb_function_name
= TRUE
;
2621 /* Perform a .set directive, but also mark the alias as
2622 being a thumb function. */
2625 s_thumb_set (int equiv
)
2627 /* XXX the following is a duplicate of the code for s_set() in read.c
2628 We cannot just call that code as we need to get at the symbol that
2635 /* Especial apologies for the random logic:
2636 This just grew, and could be parsed much more simply!
2638 name
= input_line_pointer
;
2639 delim
= get_symbol_end ();
2640 end_name
= input_line_pointer
;
2643 if (*input_line_pointer
!= ',')
2646 as_bad (_("expected comma after name \"%s\""), name
);
2648 ignore_rest_of_line ();
2652 input_line_pointer
++;
2655 if (name
[0] == '.' && name
[1] == '\0')
2657 /* XXX - this should not happen to .thumb_set. */
2661 if ((symbolP
= symbol_find (name
)) == NULL
2662 && (symbolP
= md_undefined_symbol (name
)) == NULL
)
2665 /* When doing symbol listings, play games with dummy fragments living
2666 outside the normal fragment chain to record the file and line info
2668 if (listing
& LISTING_SYMBOLS
)
2670 extern struct list_info_struct
* listing_tail
;
2671 fragS
* dummy_frag
= xmalloc (sizeof (fragS
));
2673 memset (dummy_frag
, 0, sizeof (fragS
));
2674 dummy_frag
->fr_type
= rs_fill
;
2675 dummy_frag
->line
= listing_tail
;
2676 symbolP
= symbol_new (name
, undefined_section
, 0, dummy_frag
);
2677 dummy_frag
->fr_symbol
= symbolP
;
2681 symbolP
= symbol_new (name
, undefined_section
, 0, &zero_address_frag
);
2684 /* "set" symbols are local unless otherwise specified. */
2685 SF_SET_LOCAL (symbolP
);
2686 #endif /* OBJ_COFF */
2687 } /* Make a new symbol. */
2689 symbol_table_insert (symbolP
);
2694 && S_IS_DEFINED (symbolP
)
2695 && S_GET_SEGMENT (symbolP
) != reg_section
)
2696 as_bad (_("symbol `%s' already defined"), S_GET_NAME (symbolP
));
2698 pseudo_set (symbolP
);
2700 demand_empty_rest_of_line ();
2702 /* XXX Now we come to the Thumb specific bit of code. */
2704 THUMB_SET_FUNC (symbolP
, 1);
2705 ARM_SET_THUMB (symbolP
, 1);
2706 #if defined OBJ_ELF || defined OBJ_COFF
2707 ARM_SET_INTERWORK (symbolP
, support_interwork
);
2711 /* Directives: Mode selection. */
2713 /* .syntax [unified|divided] - choose the new unified syntax
2714 (same for Arm and Thumb encoding, modulo slight differences in what
2715 can be represented) or the old divergent syntax for each mode. */
2717 s_syntax (int unused ATTRIBUTE_UNUSED
)
2721 name
= input_line_pointer
;
2722 delim
= get_symbol_end ();
2724 if (!strcasecmp (name
, "unified"))
2725 unified_syntax
= TRUE
;
2726 else if (!strcasecmp (name
, "divided"))
2727 unified_syntax
= FALSE
;
2730 as_bad (_("unrecognized syntax mode \"%s\""), name
);
2733 *input_line_pointer
= delim
;
2734 demand_empty_rest_of_line ();
2737 /* Directives: sectioning and alignment. */
2739 /* Same as s_align_ptwo but align 0 => align 2. */
2742 s_align (int unused ATTRIBUTE_UNUSED
)
2747 long max_alignment
= 15;
2749 temp
= get_absolute_expression ();
2750 if (temp
> max_alignment
)
2751 as_bad (_("alignment too large: %d assumed"), temp
= max_alignment
);
2754 as_bad (_("alignment negative. 0 assumed."));
2758 if (*input_line_pointer
== ',')
2760 input_line_pointer
++;
2761 temp_fill
= get_absolute_expression ();
2773 /* Only make a frag if we HAVE to. */
2774 if (temp
&& !need_pass_2
)
2776 if (!fill_p
&& subseg_text_p (now_seg
))
2777 frag_align_code (temp
, 0);
2779 frag_align (temp
, (int) temp_fill
, 0);
2781 demand_empty_rest_of_line ();
2783 record_alignment (now_seg
, temp
);
2787 s_bss (int ignore ATTRIBUTE_UNUSED
)
2789 /* We don't support putting frags in the BSS segment, we fake it by
2790 marking in_bss, then looking at s_skip for clues. */
2791 subseg_set (bss_section
, 0);
2792 demand_empty_rest_of_line ();
2793 mapping_state (MAP_DATA
);
2797 s_even (int ignore ATTRIBUTE_UNUSED
)
2799 /* Never make frag if expect extra pass. */
2801 frag_align (1, 0, 0);
2803 record_alignment (now_seg
, 1);
2805 demand_empty_rest_of_line ();
2808 /* Directives: Literal pools. */
2810 static literal_pool
*
2811 find_literal_pool (void)
2813 literal_pool
* pool
;
2815 for (pool
= list_of_pools
; pool
!= NULL
; pool
= pool
->next
)
2817 if (pool
->section
== now_seg
2818 && pool
->sub_section
== now_subseg
)
2825 static literal_pool
*
2826 find_or_make_literal_pool (void)
2828 /* Next literal pool ID number. */
2829 static unsigned int latest_pool_num
= 1;
2830 literal_pool
* pool
;
2832 pool
= find_literal_pool ();
2836 /* Create a new pool. */
2837 pool
= xmalloc (sizeof (* pool
));
2841 pool
->next_free_entry
= 0;
2842 pool
->section
= now_seg
;
2843 pool
->sub_section
= now_subseg
;
2844 pool
->next
= list_of_pools
;
2845 pool
->symbol
= NULL
;
2847 /* Add it to the list. */
2848 list_of_pools
= pool
;
2851 /* New pools, and emptied pools, will have a NULL symbol. */
2852 if (pool
->symbol
== NULL
)
2854 pool
->symbol
= symbol_create (FAKE_LABEL_NAME
, undefined_section
,
2855 (valueT
) 0, &zero_address_frag
);
2856 pool
->id
= latest_pool_num
++;
2863 /* Add the literal in the global 'inst'
2864 structure to the relevant literal pool. */
2867 add_to_lit_pool (void)
2869 literal_pool
* pool
;
2872 pool
= find_or_make_literal_pool ();
2874 /* Check if this literal value is already in the pool. */
2875 for (entry
= 0; entry
< pool
->next_free_entry
; entry
++)
2877 if ((pool
->literals
[entry
].X_op
== inst
.reloc
.exp
.X_op
)
2878 && (inst
.reloc
.exp
.X_op
== O_constant
)
2879 && (pool
->literals
[entry
].X_add_number
2880 == inst
.reloc
.exp
.X_add_number
)
2881 && (pool
->literals
[entry
].X_unsigned
2882 == inst
.reloc
.exp
.X_unsigned
))
2885 if ((pool
->literals
[entry
].X_op
== inst
.reloc
.exp
.X_op
)
2886 && (inst
.reloc
.exp
.X_op
== O_symbol
)
2887 && (pool
->literals
[entry
].X_add_number
2888 == inst
.reloc
.exp
.X_add_number
)
2889 && (pool
->literals
[entry
].X_add_symbol
2890 == inst
.reloc
.exp
.X_add_symbol
)
2891 && (pool
->literals
[entry
].X_op_symbol
2892 == inst
.reloc
.exp
.X_op_symbol
))
2896 /* Do we need to create a new entry? */
2897 if (entry
== pool
->next_free_entry
)
2899 if (entry
>= MAX_LITERAL_POOL_SIZE
)
2901 inst
.error
= _("literal pool overflow");
2905 pool
->literals
[entry
] = inst
.reloc
.exp
;
2906 pool
->next_free_entry
+= 1;
2909 inst
.reloc
.exp
.X_op
= O_symbol
;
2910 inst
.reloc
.exp
.X_add_number
= ((int) entry
) * 4;
2911 inst
.reloc
.exp
.X_add_symbol
= pool
->symbol
;
2916 /* Can't use symbol_new here, so have to create a symbol and then at
2917 a later date assign it a value. Thats what these functions do. */
2920 symbol_locate (symbolS
* symbolP
,
2921 const char * name
, /* It is copied, the caller can modify. */
2922 segT segment
, /* Segment identifier (SEG_<something>). */
2923 valueT valu
, /* Symbol value. */
2924 fragS
* frag
) /* Associated fragment. */
2926 unsigned int name_length
;
2927 char * preserved_copy_of_name
;
2929 name_length
= strlen (name
) + 1; /* +1 for \0. */
2930 obstack_grow (¬es
, name
, name_length
);
2931 preserved_copy_of_name
= obstack_finish (¬es
);
2933 #ifdef tc_canonicalize_symbol_name
2934 preserved_copy_of_name
=
2935 tc_canonicalize_symbol_name (preserved_copy_of_name
);
2938 S_SET_NAME (symbolP
, preserved_copy_of_name
);
2940 S_SET_SEGMENT (symbolP
, segment
);
2941 S_SET_VALUE (symbolP
, valu
);
2942 symbol_clear_list_pointers (symbolP
);
2944 symbol_set_frag (symbolP
, frag
);
2946 /* Link to end of symbol chain. */
2948 extern int symbol_table_frozen
;
2950 if (symbol_table_frozen
)
2954 symbol_append (symbolP
, symbol_lastP
, & symbol_rootP
, & symbol_lastP
);
2956 obj_symbol_new_hook (symbolP
);
2958 #ifdef tc_symbol_new_hook
2959 tc_symbol_new_hook (symbolP
);
2963 verify_symbol_chain (symbol_rootP
, symbol_lastP
);
2964 #endif /* DEBUG_SYMS */
2969 s_ltorg (int ignored ATTRIBUTE_UNUSED
)
2972 literal_pool
* pool
;
2975 pool
= find_literal_pool ();
2977 || pool
->symbol
== NULL
2978 || pool
->next_free_entry
== 0)
2981 mapping_state (MAP_DATA
);
2983 /* Align pool as you have word accesses.
2984 Only make a frag if we have to. */
2986 frag_align (2, 0, 0);
2988 record_alignment (now_seg
, 2);
2990 sprintf (sym_name
, "$$lit_\002%x", pool
->id
);
2992 symbol_locate (pool
->symbol
, sym_name
, now_seg
,
2993 (valueT
) frag_now_fix (), frag_now
);
2994 symbol_table_insert (pool
->symbol
);
2996 ARM_SET_THUMB (pool
->symbol
, thumb_mode
);
2998 #if defined OBJ_COFF || defined OBJ_ELF
2999 ARM_SET_INTERWORK (pool
->symbol
, support_interwork
);
3002 for (entry
= 0; entry
< pool
->next_free_entry
; entry
++)
3003 /* First output the expression in the instruction to the pool. */
3004 emit_expr (&(pool
->literals
[entry
]), 4); /* .word */
3006 /* Mark the pool as empty. */
3007 pool
->next_free_entry
= 0;
3008 pool
->symbol
= NULL
;
3012 /* Forward declarations for functions below, in the MD interface
3014 static void fix_new_arm (fragS
*, int, short, expressionS
*, int, int);
3015 static valueT
create_unwind_entry (int);
3016 static void start_unwind_section (const segT
, int);
3017 static void add_unwind_opcode (valueT
, int);
3018 static void flush_pending_unwind (void);
3020 /* Directives: Data. */
3023 s_arm_elf_cons (int nbytes
)
3027 #ifdef md_flush_pending_output
3028 md_flush_pending_output ();
3031 if (is_it_end_of_statement ())
3033 demand_empty_rest_of_line ();
3037 #ifdef md_cons_align
3038 md_cons_align (nbytes
);
3041 mapping_state (MAP_DATA
);
3045 char *base
= input_line_pointer
;
3049 if (exp
.X_op
!= O_symbol
)
3050 emit_expr (&exp
, (unsigned int) nbytes
);
3053 char *before_reloc
= input_line_pointer
;
3054 reloc
= parse_reloc (&input_line_pointer
);
3057 as_bad (_("unrecognized relocation suffix"));
3058 ignore_rest_of_line ();
3061 else if (reloc
== BFD_RELOC_UNUSED
)
3062 emit_expr (&exp
, (unsigned int) nbytes
);
3065 reloc_howto_type
*howto
= bfd_reloc_type_lookup (stdoutput
, reloc
);
3066 int size
= bfd_get_reloc_size (howto
);
3068 if (reloc
== BFD_RELOC_ARM_PLT32
)
3070 as_bad (_("(plt) is only valid on branch targets"));
3071 reloc
= BFD_RELOC_UNUSED
;
3076 as_bad (_("%s relocations do not fit in %d bytes"),
3077 howto
->name
, nbytes
);
3080 /* We've parsed an expression stopping at O_symbol.
3081 But there may be more expression left now that we
3082 have parsed the relocation marker. Parse it again.
3083 XXX Surely there is a cleaner way to do this. */
3084 char *p
= input_line_pointer
;
3086 char *save_buf
= alloca (input_line_pointer
- base
);
3087 memcpy (save_buf
, base
, input_line_pointer
- base
);
3088 memmove (base
+ (input_line_pointer
- before_reloc
),
3089 base
, before_reloc
- base
);
3091 input_line_pointer
= base
+ (input_line_pointer
-before_reloc
);
3093 memcpy (base
, save_buf
, p
- base
);
3095 offset
= nbytes
- size
;
3096 p
= frag_more ((int) nbytes
);
3097 fix_new_exp (frag_now
, p
- frag_now
->fr_literal
+ offset
,
3098 size
, &exp
, 0, reloc
);
3103 while (*input_line_pointer
++ == ',');
3105 /* Put terminator back into stream. */
3106 input_line_pointer
--;
3107 demand_empty_rest_of_line ();
3111 /* Parse a .rel31 directive. */
3114 s_arm_rel31 (int ignored ATTRIBUTE_UNUSED
)
3121 if (*input_line_pointer
== '1')
3122 highbit
= 0x80000000;
3123 else if (*input_line_pointer
!= '0')
3124 as_bad (_("expected 0 or 1"));
3126 input_line_pointer
++;
3127 if (*input_line_pointer
!= ',')
3128 as_bad (_("missing comma"));
3129 input_line_pointer
++;
3131 #ifdef md_flush_pending_output
3132 md_flush_pending_output ();
3135 #ifdef md_cons_align
3139 mapping_state (MAP_DATA
);
3144 md_number_to_chars (p
, highbit
, 4);
3145 fix_new_arm (frag_now
, p
- frag_now
->fr_literal
, 4, &exp
, 1,
3146 BFD_RELOC_ARM_PREL31
);
3148 demand_empty_rest_of_line ();
3151 /* Directives: AEABI stack-unwind tables. */
3153 /* Parse an unwind_fnstart directive. Simply records the current location. */
3156 s_arm_unwind_fnstart (int ignored ATTRIBUTE_UNUSED
)
3158 demand_empty_rest_of_line ();
3159 /* Mark the start of the function. */
3160 unwind
.proc_start
= expr_build_dot ();
3162 /* Reset the rest of the unwind info. */
3163 unwind
.opcode_count
= 0;
3164 unwind
.table_entry
= NULL
;
3165 unwind
.personality_routine
= NULL
;
3166 unwind
.personality_index
= -1;
3167 unwind
.frame_size
= 0;
3168 unwind
.fp_offset
= 0;
3169 unwind
.fp_reg
= REG_SP
;
3171 unwind
.sp_restored
= 0;
3175 /* Parse a handlerdata directive. Creates the exception handling table entry
3176 for the function. */
3179 s_arm_unwind_handlerdata (int ignored ATTRIBUTE_UNUSED
)
3181 demand_empty_rest_of_line ();
3182 if (unwind
.table_entry
)
3183 as_bad (_("duplicate .handlerdata directive"));
3185 create_unwind_entry (1);
3188 /* Parse an unwind_fnend directive. Generates the index table entry. */
3191 s_arm_unwind_fnend (int ignored ATTRIBUTE_UNUSED
)
3197 demand_empty_rest_of_line ();
3199 /* Add eh table entry. */
3200 if (unwind
.table_entry
== NULL
)
3201 val
= create_unwind_entry (0);
3205 /* Add index table entry. This is two words. */
3206 start_unwind_section (unwind
.saved_seg
, 1);
3207 frag_align (2, 0, 0);
3208 record_alignment (now_seg
, 2);
3210 ptr
= frag_more (8);
3211 where
= frag_now_fix () - 8;
3213 /* Self relative offset of the function start. */
3214 fix_new (frag_now
, where
, 4, unwind
.proc_start
, 0, 1,
3215 BFD_RELOC_ARM_PREL31
);
3217 /* Indicate dependency on EHABI-defined personality routines to the
3218 linker, if it hasn't been done already. */
3219 if (unwind
.personality_index
>= 0 && unwind
.personality_index
< 3
3220 && !(marked_pr_dependency
& (1 << unwind
.personality_index
)))
3222 static const char *const name
[] =
3224 "__aeabi_unwind_cpp_pr0",
3225 "__aeabi_unwind_cpp_pr1",
3226 "__aeabi_unwind_cpp_pr2"
3228 symbolS
*pr
= symbol_find_or_make (name
[unwind
.personality_index
]);
3229 fix_new (frag_now
, where
, 0, pr
, 0, 1, BFD_RELOC_NONE
);
3230 marked_pr_dependency
|= 1 << unwind
.personality_index
;
3231 seg_info (now_seg
)->tc_segment_info_data
.marked_pr_dependency
3232 = marked_pr_dependency
;
3236 /* Inline exception table entry. */
3237 md_number_to_chars (ptr
+ 4, val
, 4);
3239 /* Self relative offset of the table entry. */
3240 fix_new (frag_now
, where
+ 4, 4, unwind
.table_entry
, 0, 1,
3241 BFD_RELOC_ARM_PREL31
);
3243 /* Restore the original section. */
3244 subseg_set (unwind
.saved_seg
, unwind
.saved_subseg
);
3248 /* Parse an unwind_cantunwind directive. */
3251 s_arm_unwind_cantunwind (int ignored ATTRIBUTE_UNUSED
)
3253 demand_empty_rest_of_line ();
3254 if (unwind
.personality_routine
|| unwind
.personality_index
!= -1)
3255 as_bad (_("personality routine specified for cantunwind frame"));
3257 unwind
.personality_index
= -2;
3261 /* Parse a personalityindex directive. */
3264 s_arm_unwind_personalityindex (int ignored ATTRIBUTE_UNUSED
)
3268 if (unwind
.personality_routine
|| unwind
.personality_index
!= -1)
3269 as_bad (_("duplicate .personalityindex directive"));
3273 if (exp
.X_op
!= O_constant
3274 || exp
.X_add_number
< 0 || exp
.X_add_number
> 15)
3276 as_bad (_("bad personality routine number"));
3277 ignore_rest_of_line ();
3281 unwind
.personality_index
= exp
.X_add_number
;
3283 demand_empty_rest_of_line ();
3287 /* Parse a personality directive. */
3290 s_arm_unwind_personality (int ignored ATTRIBUTE_UNUSED
)
3294 if (unwind
.personality_routine
|| unwind
.personality_index
!= -1)
3295 as_bad (_("duplicate .personality directive"));
3297 name
= input_line_pointer
;
3298 c
= get_symbol_end ();
3299 p
= input_line_pointer
;
3300 unwind
.personality_routine
= symbol_find_or_make (name
);
3302 demand_empty_rest_of_line ();
3306 /* Parse a directive saving core registers. */
3309 s_arm_unwind_save_core (void)
3315 range
= parse_reg_list (&input_line_pointer
);
3318 as_bad (_("expected register list"));
3319 ignore_rest_of_line ();
3323 demand_empty_rest_of_line ();
3325 /* Turn .unwind_movsp ip followed by .unwind_save {..., ip, ...}
3326 into .unwind_save {..., sp...}. We aren't bothered about the value of
3327 ip because it is clobbered by calls. */
3328 if (unwind
.sp_restored
&& unwind
.fp_reg
== 12
3329 && (range
& 0x3000) == 0x1000)
3331 unwind
.opcode_count
--;
3332 unwind
.sp_restored
= 0;
3333 range
= (range
| 0x2000) & ~0x1000;
3334 unwind
.pending_offset
= 0;
3340 /* See if we can use the short opcodes. These pop a block of up to 8
3341 registers starting with r4, plus maybe r14. */
3342 for (n
= 0; n
< 8; n
++)
3344 /* Break at the first non-saved register. */
3345 if ((range
& (1 << (n
+ 4))) == 0)
3348 /* See if there are any other bits set. */
3349 if (n
== 0 || (range
& (0xfff0 << n
) & 0xbff0) != 0)
3351 /* Use the long form. */
3352 op
= 0x8000 | ((range
>> 4) & 0xfff);
3353 add_unwind_opcode (op
, 2);
3357 /* Use the short form. */
3359 op
= 0xa8; /* Pop r14. */
3361 op
= 0xa0; /* Do not pop r14. */
3363 add_unwind_opcode (op
, 1);
3370 op
= 0xb100 | (range
& 0xf);
3371 add_unwind_opcode (op
, 2);
3374 /* Record the number of bytes pushed. */
3375 for (n
= 0; n
< 16; n
++)
3377 if (range
& (1 << n
))
3378 unwind
.frame_size
+= 4;
3383 /* Parse a directive saving FPA registers. */
3386 s_arm_unwind_save_fpa (int reg
)
3392 /* Get Number of registers to transfer. */
3393 if (skip_past_comma (&input_line_pointer
) != FAIL
)
3396 exp
.X_op
= O_illegal
;
3398 if (exp
.X_op
!= O_constant
)
3400 as_bad (_("expected , <constant>"));
3401 ignore_rest_of_line ();
3405 num_regs
= exp
.X_add_number
;
3407 if (num_regs
< 1 || num_regs
> 4)
3409 as_bad (_("number of registers must be in the range [1:4]"));
3410 ignore_rest_of_line ();
3414 demand_empty_rest_of_line ();
3419 op
= 0xb4 | (num_regs
- 1);
3420 add_unwind_opcode (op
, 1);
3425 op
= 0xc800 | (reg
<< 4) | (num_regs
- 1);
3426 add_unwind_opcode (op
, 2);
3428 unwind
.frame_size
+= num_regs
* 12;
3432 /* Parse a directive saving VFP registers for ARMv6 and above. */
3435 s_arm_unwind_save_vfp_armv6 (void)
3440 int num_vfpv3_regs
= 0;
3441 int num_regs_below_16
;
3443 count
= parse_vfp_reg_list (&input_line_pointer
, &start
, REGLIST_VFP_D
);
3446 as_bad (_("expected register list"));
3447 ignore_rest_of_line ();
3451 demand_empty_rest_of_line ();
3453 /* We always generate FSTMD/FLDMD-style unwinding opcodes (rather
3454 than FSTMX/FLDMX-style ones). */
3456 /* Generate opcode for (VFPv3) registers numbered in the range 16 .. 31. */
3458 num_vfpv3_regs
= count
;
3459 else if (start
+ count
> 16)
3460 num_vfpv3_regs
= start
+ count
- 16;
3462 if (num_vfpv3_regs
> 0)
3464 int start_offset
= start
> 16 ? start
- 16 : 0;
3465 op
= 0xc800 | (start_offset
<< 4) | (num_vfpv3_regs
- 1);
3466 add_unwind_opcode (op
, 2);
3469 /* Generate opcode for registers numbered in the range 0 .. 15. */
3470 num_regs_below_16
= num_vfpv3_regs
> 0 ? 16 - (int) start
: count
;
3471 gas_assert (num_regs_below_16
+ num_vfpv3_regs
== count
);
3472 if (num_regs_below_16
> 0)
3474 op
= 0xc900 | (start
<< 4) | (num_regs_below_16
- 1);
3475 add_unwind_opcode (op
, 2);
3478 unwind
.frame_size
+= count
* 8;
3482 /* Parse a directive saving VFP registers for pre-ARMv6. */
3485 s_arm_unwind_save_vfp (void)
3491 count
= parse_vfp_reg_list (&input_line_pointer
, ®
, REGLIST_VFP_D
);
3494 as_bad (_("expected register list"));
3495 ignore_rest_of_line ();
3499 demand_empty_rest_of_line ();
3504 op
= 0xb8 | (count
- 1);
3505 add_unwind_opcode (op
, 1);
3510 op
= 0xb300 | (reg
<< 4) | (count
- 1);
3511 add_unwind_opcode (op
, 2);
3513 unwind
.frame_size
+= count
* 8 + 4;
3517 /* Parse a directive saving iWMMXt data registers. */
3520 s_arm_unwind_save_mmxwr (void)
3528 if (*input_line_pointer
== '{')
3529 input_line_pointer
++;
3533 reg
= arm_reg_parse (&input_line_pointer
, REG_TYPE_MMXWR
);
3537 as_bad ("%s", _(reg_expected_msgs
[REG_TYPE_MMXWR
]));
3542 as_tsktsk (_("register list not in ascending order"));
3545 if (*input_line_pointer
== '-')
3547 input_line_pointer
++;
3548 hi_reg
= arm_reg_parse (&input_line_pointer
, REG_TYPE_MMXWR
);
3551 as_bad ("%s", _(reg_expected_msgs
[REG_TYPE_MMXWR
]));
3554 else if (reg
>= hi_reg
)
3556 as_bad (_("bad register range"));
3559 for (; reg
< hi_reg
; reg
++)
3563 while (skip_past_comma (&input_line_pointer
) != FAIL
);
3565 if (*input_line_pointer
== '}')
3566 input_line_pointer
++;
3568 demand_empty_rest_of_line ();
3570 /* Generate any deferred opcodes because we're going to be looking at
3572 flush_pending_unwind ();
3574 for (i
= 0; i
< 16; i
++)
3576 if (mask
& (1 << i
))
3577 unwind
.frame_size
+= 8;
3580 /* Attempt to combine with a previous opcode. We do this because gcc
3581 likes to output separate unwind directives for a single block of
3583 if (unwind
.opcode_count
> 0)
3585 i
= unwind
.opcodes
[unwind
.opcode_count
- 1];
3586 if ((i
& 0xf8) == 0xc0)
3589 /* Only merge if the blocks are contiguous. */
3592 if ((mask
& 0xfe00) == (1 << 9))
3594 mask
|= ((1 << (i
+ 11)) - 1) & 0xfc00;
3595 unwind
.opcode_count
--;
3598 else if (i
== 6 && unwind
.opcode_count
>= 2)
3600 i
= unwind
.opcodes
[unwind
.opcode_count
- 2];
3604 op
= 0xffff << (reg
- 1);
3606 && ((mask
& op
) == (1u << (reg
- 1))))
3608 op
= (1 << (reg
+ i
+ 1)) - 1;
3609 op
&= ~((1 << reg
) - 1);
3611 unwind
.opcode_count
-= 2;
3618 /* We want to generate opcodes in the order the registers have been
3619 saved, ie. descending order. */
3620 for (reg
= 15; reg
>= -1; reg
--)
3622 /* Save registers in blocks. */
3624 || !(mask
& (1 << reg
)))
3626 /* We found an unsaved reg. Generate opcodes to save the
3633 op
= 0xc0 | (hi_reg
- 10);
3634 add_unwind_opcode (op
, 1);
3639 op
= 0xc600 | ((reg
+ 1) << 4) | ((hi_reg
- reg
) - 1);
3640 add_unwind_opcode (op
, 2);
3649 ignore_rest_of_line ();
3653 s_arm_unwind_save_mmxwcg (void)
3660 if (*input_line_pointer
== '{')
3661 input_line_pointer
++;
3665 reg
= arm_reg_parse (&input_line_pointer
, REG_TYPE_MMXWCG
);
3669 as_bad ("%s", _(reg_expected_msgs
[REG_TYPE_MMXWCG
]));
3675 as_tsktsk (_("register list not in ascending order"));
3678 if (*input_line_pointer
== '-')
3680 input_line_pointer
++;
3681 hi_reg
= arm_reg_parse (&input_line_pointer
, REG_TYPE_MMXWCG
);
3684 as_bad ("%s", _(reg_expected_msgs
[REG_TYPE_MMXWCG
]));
3687 else if (reg
>= hi_reg
)
3689 as_bad (_("bad register range"));
3692 for (; reg
< hi_reg
; reg
++)
3696 while (skip_past_comma (&input_line_pointer
) != FAIL
);
3698 if (*input_line_pointer
== '}')
3699 input_line_pointer
++;
3701 demand_empty_rest_of_line ();
3703 /* Generate any deferred opcodes because we're going to be looking at
3705 flush_pending_unwind ();
3707 for (reg
= 0; reg
< 16; reg
++)
3709 if (mask
& (1 << reg
))
3710 unwind
.frame_size
+= 4;
3713 add_unwind_opcode (op
, 2);
3716 ignore_rest_of_line ();
3720 /* Parse an unwind_save directive.
3721 If the argument is non-zero, this is a .vsave directive. */
3724 s_arm_unwind_save (int arch_v6
)
3727 struct reg_entry
*reg
;
3728 bfd_boolean had_brace
= FALSE
;
3730 /* Figure out what sort of save we have. */
3731 peek
= input_line_pointer
;
3739 reg
= arm_reg_parse_multi (&peek
);
3743 as_bad (_("register expected"));
3744 ignore_rest_of_line ();
3753 as_bad (_("FPA .unwind_save does not take a register list"));
3754 ignore_rest_of_line ();
3757 input_line_pointer
= peek
;
3758 s_arm_unwind_save_fpa (reg
->number
);
3761 case REG_TYPE_RN
: s_arm_unwind_save_core (); return;
3764 s_arm_unwind_save_vfp_armv6 ();
3766 s_arm_unwind_save_vfp ();
3768 case REG_TYPE_MMXWR
: s_arm_unwind_save_mmxwr (); return;
3769 case REG_TYPE_MMXWCG
: s_arm_unwind_save_mmxwcg (); return;
3772 as_bad (_(".unwind_save does not support this kind of register"));
3773 ignore_rest_of_line ();
3778 /* Parse an unwind_movsp directive. */
3781 s_arm_unwind_movsp (int ignored ATTRIBUTE_UNUSED
)
3787 reg
= arm_reg_parse (&input_line_pointer
, REG_TYPE_RN
);
3790 as_bad ("%s", _(reg_expected_msgs
[REG_TYPE_RN
]));
3791 ignore_rest_of_line ();
3795 /* Optional constant. */
3796 if (skip_past_comma (&input_line_pointer
) != FAIL
)
3798 if (immediate_for_directive (&offset
) == FAIL
)
3804 demand_empty_rest_of_line ();
3806 if (reg
== REG_SP
|| reg
== REG_PC
)
3808 as_bad (_("SP and PC not permitted in .unwind_movsp directive"));
3812 if (unwind
.fp_reg
!= REG_SP
)
3813 as_bad (_("unexpected .unwind_movsp directive"));
3815 /* Generate opcode to restore the value. */
3817 add_unwind_opcode (op
, 1);
3819 /* Record the information for later. */
3820 unwind
.fp_reg
= reg
;
3821 unwind
.fp_offset
= unwind
.frame_size
- offset
;
3822 unwind
.sp_restored
= 1;
3825 /* Parse an unwind_pad directive. */
3828 s_arm_unwind_pad (int ignored ATTRIBUTE_UNUSED
)
3832 if (immediate_for_directive (&offset
) == FAIL
)
3837 as_bad (_("stack increment must be multiple of 4"));
3838 ignore_rest_of_line ();
3842 /* Don't generate any opcodes, just record the details for later. */
3843 unwind
.frame_size
+= offset
;
3844 unwind
.pending_offset
+= offset
;
3846 demand_empty_rest_of_line ();
3849 /* Parse an unwind_setfp directive. */
3852 s_arm_unwind_setfp (int ignored ATTRIBUTE_UNUSED
)
3858 fp_reg
= arm_reg_parse (&input_line_pointer
, REG_TYPE_RN
);
3859 if (skip_past_comma (&input_line_pointer
) == FAIL
)
3862 sp_reg
= arm_reg_parse (&input_line_pointer
, REG_TYPE_RN
);
3864 if (fp_reg
== FAIL
|| sp_reg
== FAIL
)
3866 as_bad (_("expected <reg>, <reg>"));
3867 ignore_rest_of_line ();
3871 /* Optional constant. */
3872 if (skip_past_comma (&input_line_pointer
) != FAIL
)
3874 if (immediate_for_directive (&offset
) == FAIL
)
3880 demand_empty_rest_of_line ();
3882 if (sp_reg
!= REG_SP
&& sp_reg
!= unwind
.fp_reg
)
3884 as_bad (_("register must be either sp or set by a previous"
3885 "unwind_movsp directive"));
3889 /* Don't generate any opcodes, just record the information for later. */
3890 unwind
.fp_reg
= fp_reg
;
3892 if (sp_reg
== REG_SP
)
3893 unwind
.fp_offset
= unwind
.frame_size
- offset
;
3895 unwind
.fp_offset
-= offset
;
3898 /* Parse an unwind_raw directive. */
3901 s_arm_unwind_raw (int ignored ATTRIBUTE_UNUSED
)
3904 /* This is an arbitrary limit. */
3905 unsigned char op
[16];
3909 if (exp
.X_op
== O_constant
3910 && skip_past_comma (&input_line_pointer
) != FAIL
)
3912 unwind
.frame_size
+= exp
.X_add_number
;
3916 exp
.X_op
= O_illegal
;
3918 if (exp
.X_op
!= O_constant
)
3920 as_bad (_("expected <offset>, <opcode>"));
3921 ignore_rest_of_line ();
3927 /* Parse the opcode. */
3932 as_bad (_("unwind opcode too long"));
3933 ignore_rest_of_line ();
3935 if (exp
.X_op
!= O_constant
|| exp
.X_add_number
& ~0xff)
3937 as_bad (_("invalid unwind opcode"));
3938 ignore_rest_of_line ();
3941 op
[count
++] = exp
.X_add_number
;
3943 /* Parse the next byte. */
3944 if (skip_past_comma (&input_line_pointer
) == FAIL
)
3950 /* Add the opcode bytes in reverse order. */
3952 add_unwind_opcode (op
[count
], 1);
3954 demand_empty_rest_of_line ();
3958 /* Parse a .eabi_attribute directive. */
3961 s_arm_eabi_attribute (int ignored ATTRIBUTE_UNUSED
)
3963 int tag
= s_vendor_attribute (OBJ_ATTR_PROC
);
3965 if (tag
< NUM_KNOWN_OBJ_ATTRIBUTES
)
3966 attributes_set_explicitly
[tag
] = 1;
3968 #endif /* OBJ_ELF */
3970 static void s_arm_arch (int);
3971 static void s_arm_object_arch (int);
3972 static void s_arm_cpu (int);
3973 static void s_arm_fpu (int);
3978 pe_directive_secrel (int dummy ATTRIBUTE_UNUSED
)
3985 if (exp
.X_op
== O_symbol
)
3986 exp
.X_op
= O_secrel
;
3988 emit_expr (&exp
, 4);
3990 while (*input_line_pointer
++ == ',');
3992 input_line_pointer
--;
3993 demand_empty_rest_of_line ();
3997 /* This table describes all the machine specific pseudo-ops the assembler
3998 has to support. The fields are:
3999 pseudo-op name without dot
4000 function to call to execute this pseudo-op
4001 Integer arg to pass to the function. */
4003 const pseudo_typeS md_pseudo_table
[] =
4005 /* Never called because '.req' does not start a line. */
4006 { "req", s_req
, 0 },
4007 /* Following two are likewise never called. */
4010 { "unreq", s_unreq
, 0 },
4011 { "bss", s_bss
, 0 },
4012 { "align", s_align
, 0 },
4013 { "arm", s_arm
, 0 },
4014 { "thumb", s_thumb
, 0 },
4015 { "code", s_code
, 0 },
4016 { "force_thumb", s_force_thumb
, 0 },
4017 { "thumb_func", s_thumb_func
, 0 },
4018 { "thumb_set", s_thumb_set
, 0 },
4019 { "even", s_even
, 0 },
4020 { "ltorg", s_ltorg
, 0 },
4021 { "pool", s_ltorg
, 0 },
4022 { "syntax", s_syntax
, 0 },
4023 { "cpu", s_arm_cpu
, 0 },
4024 { "arch", s_arm_arch
, 0 },
4025 { "object_arch", s_arm_object_arch
, 0 },
4026 { "fpu", s_arm_fpu
, 0 },
4028 { "word", s_arm_elf_cons
, 4 },
4029 { "long", s_arm_elf_cons
, 4 },
4030 { "rel31", s_arm_rel31
, 0 },
4031 { "fnstart", s_arm_unwind_fnstart
, 0 },
4032 { "fnend", s_arm_unwind_fnend
, 0 },
4033 { "cantunwind", s_arm_unwind_cantunwind
, 0 },
4034 { "personality", s_arm_unwind_personality
, 0 },
4035 { "personalityindex", s_arm_unwind_personalityindex
, 0 },
4036 { "handlerdata", s_arm_unwind_handlerdata
, 0 },
4037 { "save", s_arm_unwind_save
, 0 },
4038 { "vsave", s_arm_unwind_save
, 1 },
4039 { "movsp", s_arm_unwind_movsp
, 0 },
4040 { "pad", s_arm_unwind_pad
, 0 },
4041 { "setfp", s_arm_unwind_setfp
, 0 },
4042 { "unwind_raw", s_arm_unwind_raw
, 0 },
4043 { "eabi_attribute", s_arm_eabi_attribute
, 0 },
4047 /* These are used for dwarf. */
4051 /* These are used for dwarf2. */
4052 { "file", (void (*) (int)) dwarf2_directive_file
, 0 },
4053 { "loc", dwarf2_directive_loc
, 0 },
4054 { "loc_mark_labels", dwarf2_directive_loc_mark_labels
, 0 },
4056 { "extend", float_cons
, 'x' },
4057 { "ldouble", float_cons
, 'x' },
4058 { "packed", float_cons
, 'p' },
4060 {"secrel32", pe_directive_secrel
, 0},
4065 /* Parser functions used exclusively in instruction operands. */
4067 /* Generic immediate-value read function for use in insn parsing.
4068 STR points to the beginning of the immediate (the leading #);
4069 VAL receives the value; if the value is outside [MIN, MAX]
4070 issue an error. PREFIX_OPT is true if the immediate prefix is
4074 parse_immediate (char **str
, int *val
, int min
, int max
,
4075 bfd_boolean prefix_opt
)
4078 my_get_expression (&exp
, str
, prefix_opt
? GE_OPT_PREFIX
: GE_IMM_PREFIX
);
4079 if (exp
.X_op
!= O_constant
)
4081 inst
.error
= _("constant expression required");
4085 if (exp
.X_add_number
< min
|| exp
.X_add_number
> max
)
4087 inst
.error
= _("immediate value out of range");
4091 *val
= exp
.X_add_number
;
4095 /* Less-generic immediate-value read function with the possibility of loading a
4096 big (64-bit) immediate, as required by Neon VMOV, VMVN and logic immediate
4097 instructions. Puts the result directly in inst.operands[i]. */
4100 parse_big_immediate (char **str
, int i
)
4105 my_get_expression (&exp
, &ptr
, GE_OPT_PREFIX_BIG
);
4107 if (exp
.X_op
== O_constant
)
4109 inst
.operands
[i
].imm
= exp
.X_add_number
& 0xffffffff;
4110 /* If we're on a 64-bit host, then a 64-bit number can be returned using
4111 O_constant. We have to be careful not to break compilation for
4112 32-bit X_add_number, though. */
4113 if ((exp
.X_add_number
& ~0xffffffffl
) != 0)
4115 /* X >> 32 is illegal if sizeof (exp.X_add_number) == 4. */
4116 inst
.operands
[i
].reg
= ((exp
.X_add_number
>> 16) >> 16) & 0xffffffff;
4117 inst
.operands
[i
].regisimm
= 1;
4120 else if (exp
.X_op
== O_big
4121 && LITTLENUM_NUMBER_OF_BITS
* exp
.X_add_number
> 32
4122 && LITTLENUM_NUMBER_OF_BITS
* exp
.X_add_number
<= 64)
4124 unsigned parts
= 32 / LITTLENUM_NUMBER_OF_BITS
, j
, idx
= 0;
4125 /* Bignums have their least significant bits in
4126 generic_bignum[0]. Make sure we put 32 bits in imm and
4127 32 bits in reg, in a (hopefully) portable way. */
4128 gas_assert (parts
!= 0);
4129 inst
.operands
[i
].imm
= 0;
4130 for (j
= 0; j
< parts
; j
++, idx
++)
4131 inst
.operands
[i
].imm
|= generic_bignum
[idx
]
4132 << (LITTLENUM_NUMBER_OF_BITS
* j
);
4133 inst
.operands
[i
].reg
= 0;
4134 for (j
= 0; j
< parts
; j
++, idx
++)
4135 inst
.operands
[i
].reg
|= generic_bignum
[idx
]
4136 << (LITTLENUM_NUMBER_OF_BITS
* j
);
4137 inst
.operands
[i
].regisimm
= 1;
4147 /* Returns the pseudo-register number of an FPA immediate constant,
4148 or FAIL if there isn't a valid constant here. */
4151 parse_fpa_immediate (char ** str
)
4153 LITTLENUM_TYPE words
[MAX_LITTLENUMS
];
4159 /* First try and match exact strings, this is to guarantee
4160 that some formats will work even for cross assembly. */
4162 for (i
= 0; fp_const
[i
]; i
++)
4164 if (strncmp (*str
, fp_const
[i
], strlen (fp_const
[i
])) == 0)
4168 *str
+= strlen (fp_const
[i
]);
4169 if (is_end_of_line
[(unsigned char) **str
])
4175 /* Just because we didn't get a match doesn't mean that the constant
4176 isn't valid, just that it is in a format that we don't
4177 automatically recognize. Try parsing it with the standard
4178 expression routines. */
4180 memset (words
, 0, MAX_LITTLENUMS
* sizeof (LITTLENUM_TYPE
));
4182 /* Look for a raw floating point number. */
4183 if ((save_in
= atof_ieee (*str
, 'x', words
)) != NULL
4184 && is_end_of_line
[(unsigned char) *save_in
])
4186 for (i
= 0; i
< NUM_FLOAT_VALS
; i
++)
4188 for (j
= 0; j
< MAX_LITTLENUMS
; j
++)
4190 if (words
[j
] != fp_values
[i
][j
])
4194 if (j
== MAX_LITTLENUMS
)
4202 /* Try and parse a more complex expression, this will probably fail
4203 unless the code uses a floating point prefix (eg "0f"). */
4204 save_in
= input_line_pointer
;
4205 input_line_pointer
= *str
;
4206 if (expression (&exp
) == absolute_section
4207 && exp
.X_op
== O_big
4208 && exp
.X_add_number
< 0)
4210 /* FIXME: 5 = X_PRECISION, should be #define'd where we can use it.
4212 if (gen_to_words (words
, 5, (long) 15) == 0)
4214 for (i
= 0; i
< NUM_FLOAT_VALS
; i
++)
4216 for (j
= 0; j
< MAX_LITTLENUMS
; j
++)
4218 if (words
[j
] != fp_values
[i
][j
])
4222 if (j
== MAX_LITTLENUMS
)
4224 *str
= input_line_pointer
;
4225 input_line_pointer
= save_in
;
4232 *str
= input_line_pointer
;
4233 input_line_pointer
= save_in
;
4234 inst
.error
= _("invalid FPA immediate expression");
4238 /* Returns 1 if a number has "quarter-precision" float format
4239 0baBbbbbbc defgh000 00000000 00000000. */
4242 is_quarter_float (unsigned imm
)
4244 int bs
= (imm
& 0x20000000) ? 0x3e000000 : 0x40000000;
4245 return (imm
& 0x7ffff) == 0 && ((imm
& 0x7e000000) ^ bs
) == 0;
4248 /* Parse an 8-bit "quarter-precision" floating point number of the form:
4249 0baBbbbbbc defgh000 00000000 00000000.
4250 The zero and minus-zero cases need special handling, since they can't be
4251 encoded in the "quarter-precision" float format, but can nonetheless be
4252 loaded as integer constants. */
4255 parse_qfloat_immediate (char **ccp
, int *immed
)
4259 LITTLENUM_TYPE words
[MAX_LITTLENUMS
];
4260 int found_fpchar
= 0;
4262 skip_past_char (&str
, '#');
4264 /* We must not accidentally parse an integer as a floating-point number. Make
4265 sure that the value we parse is not an integer by checking for special
4266 characters '.' or 'e'.
4267 FIXME: This is a horrible hack, but doing better is tricky because type
4268 information isn't in a very usable state at parse time. */
4270 skip_whitespace (fpnum
);
4272 if (strncmp (fpnum
, "0x", 2) == 0)
4276 for (; *fpnum
!= '\0' && *fpnum
!= ' ' && *fpnum
!= '\n'; fpnum
++)
4277 if (*fpnum
== '.' || *fpnum
== 'e' || *fpnum
== 'E')
4287 if ((str
= atof_ieee (str
, 's', words
)) != NULL
)
4289 unsigned fpword
= 0;
4292 /* Our FP word must be 32 bits (single-precision FP). */
4293 for (i
= 0; i
< 32 / LITTLENUM_NUMBER_OF_BITS
; i
++)
4295 fpword
<<= LITTLENUM_NUMBER_OF_BITS
;
4299 if (is_quarter_float (fpword
) || (fpword
& 0x7fffffff) == 0)
4312 /* Shift operands. */
4315 SHIFT_LSL
, SHIFT_LSR
, SHIFT_ASR
, SHIFT_ROR
, SHIFT_RRX
4318 struct asm_shift_name
4321 enum shift_kind kind
;
4324 /* Third argument to parse_shift. */
4325 enum parse_shift_mode
4327 NO_SHIFT_RESTRICT
, /* Any kind of shift is accepted. */
4328 SHIFT_IMMEDIATE
, /* Shift operand must be an immediate. */
4329 SHIFT_LSL_OR_ASR_IMMEDIATE
, /* Shift must be LSL or ASR immediate. */
4330 SHIFT_ASR_IMMEDIATE
, /* Shift must be ASR immediate. */
4331 SHIFT_LSL_IMMEDIATE
, /* Shift must be LSL immediate. */
4334 /* Parse a <shift> specifier on an ARM data processing instruction.
4335 This has three forms:
4337 (LSL|LSR|ASL|ASR|ROR) Rs
4338 (LSL|LSR|ASL|ASR|ROR) #imm
4341 Note that ASL is assimilated to LSL in the instruction encoding, and
4342 RRX to ROR #0 (which cannot be written as such). */
4345 parse_shift (char **str
, int i
, enum parse_shift_mode mode
)
4347 const struct asm_shift_name
*shift_name
;
4348 enum shift_kind shift
;
4353 for (p
= *str
; ISALPHA (*p
); p
++)
4358 inst
.error
= _("shift expression expected");
4362 shift_name
= hash_find_n (arm_shift_hsh
, *str
, p
- *str
);
4364 if (shift_name
== NULL
)
4366 inst
.error
= _("shift expression expected");
4370 shift
= shift_name
->kind
;
4374 case NO_SHIFT_RESTRICT
:
4375 case SHIFT_IMMEDIATE
: break;
4377 case SHIFT_LSL_OR_ASR_IMMEDIATE
:
4378 if (shift
!= SHIFT_LSL
&& shift
!= SHIFT_ASR
)
4380 inst
.error
= _("'LSL' or 'ASR' required");
4385 case SHIFT_LSL_IMMEDIATE
:
4386 if (shift
!= SHIFT_LSL
)
4388 inst
.error
= _("'LSL' required");
4393 case SHIFT_ASR_IMMEDIATE
:
4394 if (shift
!= SHIFT_ASR
)
4396 inst
.error
= _("'ASR' required");
4404 if (shift
!= SHIFT_RRX
)
4406 /* Whitespace can appear here if the next thing is a bare digit. */
4407 skip_whitespace (p
);
4409 if (mode
== NO_SHIFT_RESTRICT
4410 && (reg
= arm_reg_parse (&p
, REG_TYPE_RN
)) != FAIL
)
4412 inst
.operands
[i
].imm
= reg
;
4413 inst
.operands
[i
].immisreg
= 1;
4415 else if (my_get_expression (&inst
.reloc
.exp
, &p
, GE_IMM_PREFIX
))
4418 inst
.operands
[i
].shift_kind
= shift
;
4419 inst
.operands
[i
].shifted
= 1;
4424 /* Parse a <shifter_operand> for an ARM data processing instruction:
4427 #<immediate>, <rotate>
4431 where <shift> is defined by parse_shift above, and <rotate> is a
4432 multiple of 2 between 0 and 30. Validation of immediate operands
4433 is deferred to md_apply_fix. */
4436 parse_shifter_operand (char **str
, int i
)
4441 if ((value
= arm_reg_parse (str
, REG_TYPE_RN
)) != FAIL
)
4443 inst
.operands
[i
].reg
= value
;
4444 inst
.operands
[i
].isreg
= 1;
4446 /* parse_shift will override this if appropriate */
4447 inst
.reloc
.exp
.X_op
= O_constant
;
4448 inst
.reloc
.exp
.X_add_number
= 0;
4450 if (skip_past_comma (str
) == FAIL
)
4453 /* Shift operation on register. */
4454 return parse_shift (str
, i
, NO_SHIFT_RESTRICT
);
4457 if (my_get_expression (&inst
.reloc
.exp
, str
, GE_IMM_PREFIX
))
4460 if (skip_past_comma (str
) == SUCCESS
)
4462 /* #x, y -- ie explicit rotation by Y. */
4463 if (my_get_expression (&expr
, str
, GE_NO_PREFIX
))
4466 if (expr
.X_op
!= O_constant
|| inst
.reloc
.exp
.X_op
!= O_constant
)
4468 inst
.error
= _("constant expression expected");
4472 value
= expr
.X_add_number
;
4473 if (value
< 0 || value
> 30 || value
% 2 != 0)
4475 inst
.error
= _("invalid rotation");
4478 if (inst
.reloc
.exp
.X_add_number
< 0 || inst
.reloc
.exp
.X_add_number
> 255)
4480 inst
.error
= _("invalid constant");
4484 /* Convert to decoded value. md_apply_fix will put it back. */
4485 inst
.reloc
.exp
.X_add_number
4486 = (((inst
.reloc
.exp
.X_add_number
<< (32 - value
))
4487 | (inst
.reloc
.exp
.X_add_number
>> value
)) & 0xffffffff);
4490 inst
.reloc
.type
= BFD_RELOC_ARM_IMMEDIATE
;
4491 inst
.reloc
.pc_rel
= 0;
4495 /* Group relocation information. Each entry in the table contains the
4496 textual name of the relocation as may appear in assembler source
4497 and must end with a colon.
4498 Along with this textual name are the relocation codes to be used if
4499 the corresponding instruction is an ALU instruction (ADD or SUB only),
4500 an LDR, an LDRS, or an LDC. */
4502 struct group_reloc_table_entry
4513 /* Varieties of non-ALU group relocation. */
4520 static struct group_reloc_table_entry group_reloc_table
[] =
4521 { /* Program counter relative: */
4523 BFD_RELOC_ARM_ALU_PC_G0_NC
, /* ALU */
4528 BFD_RELOC_ARM_ALU_PC_G0
, /* ALU */
4529 BFD_RELOC_ARM_LDR_PC_G0
, /* LDR */
4530 BFD_RELOC_ARM_LDRS_PC_G0
, /* LDRS */
4531 BFD_RELOC_ARM_LDC_PC_G0
}, /* LDC */
4533 BFD_RELOC_ARM_ALU_PC_G1_NC
, /* ALU */
4538 BFD_RELOC_ARM_ALU_PC_G1
, /* ALU */
4539 BFD_RELOC_ARM_LDR_PC_G1
, /* LDR */
4540 BFD_RELOC_ARM_LDRS_PC_G1
, /* LDRS */
4541 BFD_RELOC_ARM_LDC_PC_G1
}, /* LDC */
4543 BFD_RELOC_ARM_ALU_PC_G2
, /* ALU */
4544 BFD_RELOC_ARM_LDR_PC_G2
, /* LDR */
4545 BFD_RELOC_ARM_LDRS_PC_G2
, /* LDRS */
4546 BFD_RELOC_ARM_LDC_PC_G2
}, /* LDC */
4547 /* Section base relative */
4549 BFD_RELOC_ARM_ALU_SB_G0_NC
, /* ALU */
4554 BFD_RELOC_ARM_ALU_SB_G0
, /* ALU */
4555 BFD_RELOC_ARM_LDR_SB_G0
, /* LDR */
4556 BFD_RELOC_ARM_LDRS_SB_G0
, /* LDRS */
4557 BFD_RELOC_ARM_LDC_SB_G0
}, /* LDC */
4559 BFD_RELOC_ARM_ALU_SB_G1_NC
, /* ALU */
4564 BFD_RELOC_ARM_ALU_SB_G1
, /* ALU */
4565 BFD_RELOC_ARM_LDR_SB_G1
, /* LDR */
4566 BFD_RELOC_ARM_LDRS_SB_G1
, /* LDRS */
4567 BFD_RELOC_ARM_LDC_SB_G1
}, /* LDC */
4569 BFD_RELOC_ARM_ALU_SB_G2
, /* ALU */
4570 BFD_RELOC_ARM_LDR_SB_G2
, /* LDR */
4571 BFD_RELOC_ARM_LDRS_SB_G2
, /* LDRS */
4572 BFD_RELOC_ARM_LDC_SB_G2
} }; /* LDC */
4574 /* Given the address of a pointer pointing to the textual name of a group
4575 relocation as may appear in assembler source, attempt to find its details
4576 in group_reloc_table. The pointer will be updated to the character after
4577 the trailing colon. On failure, FAIL will be returned; SUCCESS
4578 otherwise. On success, *entry will be updated to point at the relevant
4579 group_reloc_table entry. */
4582 find_group_reloc_table_entry (char **str
, struct group_reloc_table_entry
**out
)
4585 for (i
= 0; i
< ARRAY_SIZE (group_reloc_table
); i
++)
4587 int length
= strlen (group_reloc_table
[i
].name
);
4589 if (strncasecmp (group_reloc_table
[i
].name
, *str
, length
) == 0
4590 && (*str
)[length
] == ':')
4592 *out
= &group_reloc_table
[i
];
4593 *str
+= (length
+ 1);
4601 /* Parse a <shifter_operand> for an ARM data processing instruction
4602 (as for parse_shifter_operand) where group relocations are allowed:
4605 #<immediate>, <rotate>
4606 #:<group_reloc>:<expression>
4610 where <group_reloc> is one of the strings defined in group_reloc_table.
4611 The hashes are optional.
4613 Everything else is as for parse_shifter_operand. */
4615 static parse_operand_result
4616 parse_shifter_operand_group_reloc (char **str
, int i
)
4618 /* Determine if we have the sequence of characters #: or just :
4619 coming next. If we do, then we check for a group relocation.
4620 If we don't, punt the whole lot to parse_shifter_operand. */
4622 if (((*str
)[0] == '#' && (*str
)[1] == ':')
4623 || (*str
)[0] == ':')
4625 struct group_reloc_table_entry
*entry
;
4627 if ((*str
)[0] == '#')
4632 /* Try to parse a group relocation. Anything else is an error. */
4633 if (find_group_reloc_table_entry (str
, &entry
) == FAIL
)
4635 inst
.error
= _("unknown group relocation");
4636 return PARSE_OPERAND_FAIL_NO_BACKTRACK
;
4639 /* We now have the group relocation table entry corresponding to
4640 the name in the assembler source. Next, we parse the expression. */
4641 if (my_get_expression (&inst
.reloc
.exp
, str
, GE_NO_PREFIX
))
4642 return PARSE_OPERAND_FAIL_NO_BACKTRACK
;
4644 /* Record the relocation type (always the ALU variant here). */
4645 inst
.reloc
.type
= entry
->alu_code
;
4646 gas_assert (inst
.reloc
.type
!= 0);
4648 return PARSE_OPERAND_SUCCESS
;
4651 return parse_shifter_operand (str
, i
) == SUCCESS
4652 ? PARSE_OPERAND_SUCCESS
: PARSE_OPERAND_FAIL
;
4654 /* Never reached. */
4657 /* Parse all forms of an ARM address expression. Information is written
4658 to inst.operands[i] and/or inst.reloc.
4660 Preindexed addressing (.preind=1):
4662 [Rn, #offset] .reg=Rn .reloc.exp=offset
4663 [Rn, +/-Rm] .reg=Rn .imm=Rm .immisreg=1 .negative=0/1
4664 [Rn, +/-Rm, shift] .reg=Rn .imm=Rm .immisreg=1 .negative=0/1
4665 .shift_kind=shift .reloc.exp=shift_imm
4667 These three may have a trailing ! which causes .writeback to be set also.
4669 Postindexed addressing (.postind=1, .writeback=1):
4671 [Rn], #offset .reg=Rn .reloc.exp=offset
4672 [Rn], +/-Rm .reg=Rn .imm=Rm .immisreg=1 .negative=0/1
4673 [Rn], +/-Rm, shift .reg=Rn .imm=Rm .immisreg=1 .negative=0/1
4674 .shift_kind=shift .reloc.exp=shift_imm
4676 Unindexed addressing (.preind=0, .postind=0):
4678 [Rn], {option} .reg=Rn .imm=option .immisreg=0
4682 [Rn]{!} shorthand for [Rn,#0]{!}
4683 =immediate .isreg=0 .reloc.exp=immediate
4684 label .reg=PC .reloc.pc_rel=1 .reloc.exp=label
4686 It is the caller's responsibility to check for addressing modes not
4687 supported by the instruction, and to set inst.reloc.type. */
4689 static parse_operand_result
4690 parse_address_main (char **str
, int i
, int group_relocations
,
4691 group_reloc_type group_type
)
4696 if (skip_past_char (&p
, '[') == FAIL
)
4698 if (skip_past_char (&p
, '=') == FAIL
)
4700 /* bare address - translate to PC-relative offset */
4701 inst
.reloc
.pc_rel
= 1;
4702 inst
.operands
[i
].reg
= REG_PC
;
4703 inst
.operands
[i
].isreg
= 1;
4704 inst
.operands
[i
].preind
= 1;
4706 /* else a load-constant pseudo op, no special treatment needed here */
4708 if (my_get_expression (&inst
.reloc
.exp
, &p
, GE_NO_PREFIX
))
4709 return PARSE_OPERAND_FAIL
;
4712 return PARSE_OPERAND_SUCCESS
;
4715 if ((reg
= arm_reg_parse (&p
, REG_TYPE_RN
)) == FAIL
)
4717 inst
.error
= _(reg_expected_msgs
[REG_TYPE_RN
]);
4718 return PARSE_OPERAND_FAIL
;
4720 inst
.operands
[i
].reg
= reg
;
4721 inst
.operands
[i
].isreg
= 1;
4723 if (skip_past_comma (&p
) == SUCCESS
)
4725 inst
.operands
[i
].preind
= 1;
4728 else if (*p
== '-') p
++, inst
.operands
[i
].negative
= 1;
4730 if ((reg
= arm_reg_parse (&p
, REG_TYPE_RN
)) != FAIL
)
4732 inst
.operands
[i
].imm
= reg
;
4733 inst
.operands
[i
].immisreg
= 1;
4735 if (skip_past_comma (&p
) == SUCCESS
)
4736 if (parse_shift (&p
, i
, SHIFT_IMMEDIATE
) == FAIL
)
4737 return PARSE_OPERAND_FAIL
;
4739 else if (skip_past_char (&p
, ':') == SUCCESS
)
4741 /* FIXME: '@' should be used here, but it's filtered out by generic
4742 code before we get to see it here. This may be subject to
4745 my_get_expression (&exp
, &p
, GE_NO_PREFIX
);
4746 if (exp
.X_op
!= O_constant
)
4748 inst
.error
= _("alignment must be constant");
4749 return PARSE_OPERAND_FAIL
;
4751 inst
.operands
[i
].imm
= exp
.X_add_number
<< 8;
4752 inst
.operands
[i
].immisalign
= 1;
4753 /* Alignments are not pre-indexes. */
4754 inst
.operands
[i
].preind
= 0;
4758 if (inst
.operands
[i
].negative
)
4760 inst
.operands
[i
].negative
= 0;
4764 if (group_relocations
4765 && ((*p
== '#' && *(p
+ 1) == ':') || *p
== ':'))
4767 struct group_reloc_table_entry
*entry
;
4769 /* Skip over the #: or : sequence. */
4775 /* Try to parse a group relocation. Anything else is an
4777 if (find_group_reloc_table_entry (&p
, &entry
) == FAIL
)
4779 inst
.error
= _("unknown group relocation");
4780 return PARSE_OPERAND_FAIL_NO_BACKTRACK
;
4783 /* We now have the group relocation table entry corresponding to
4784 the name in the assembler source. Next, we parse the
4786 if (my_get_expression (&inst
.reloc
.exp
, &p
, GE_NO_PREFIX
))
4787 return PARSE_OPERAND_FAIL_NO_BACKTRACK
;
4789 /* Record the relocation type. */
4793 inst
.reloc
.type
= entry
->ldr_code
;
4797 inst
.reloc
.type
= entry
->ldrs_code
;
4801 inst
.reloc
.type
= entry
->ldc_code
;
4808 if (inst
.reloc
.type
== 0)
4810 inst
.error
= _("this group relocation is not allowed on this instruction");
4811 return PARSE_OPERAND_FAIL_NO_BACKTRACK
;
4815 if (my_get_expression (&inst
.reloc
.exp
, &p
, GE_IMM_PREFIX
))
4816 return PARSE_OPERAND_FAIL
;
4820 if (skip_past_char (&p
, ']') == FAIL
)
4822 inst
.error
= _("']' expected");
4823 return PARSE_OPERAND_FAIL
;
4826 if (skip_past_char (&p
, '!') == SUCCESS
)
4827 inst
.operands
[i
].writeback
= 1;
4829 else if (skip_past_comma (&p
) == SUCCESS
)
4831 if (skip_past_char (&p
, '{') == SUCCESS
)
4833 /* [Rn], {expr} - unindexed, with option */
4834 if (parse_immediate (&p
, &inst
.operands
[i
].imm
,
4835 0, 255, TRUE
) == FAIL
)
4836 return PARSE_OPERAND_FAIL
;
4838 if (skip_past_char (&p
, '}') == FAIL
)
4840 inst
.error
= _("'}' expected at end of 'option' field");
4841 return PARSE_OPERAND_FAIL
;
4843 if (inst
.operands
[i
].preind
)
4845 inst
.error
= _("cannot combine index with option");
4846 return PARSE_OPERAND_FAIL
;
4849 return PARSE_OPERAND_SUCCESS
;
4853 inst
.operands
[i
].postind
= 1;
4854 inst
.operands
[i
].writeback
= 1;
4856 if (inst
.operands
[i
].preind
)
4858 inst
.error
= _("cannot combine pre- and post-indexing");
4859 return PARSE_OPERAND_FAIL
;
4863 else if (*p
== '-') p
++, inst
.operands
[i
].negative
= 1;
4865 if ((reg
= arm_reg_parse (&p
, REG_TYPE_RN
)) != FAIL
)
4867 /* We might be using the immediate for alignment already. If we
4868 are, OR the register number into the low-order bits. */
4869 if (inst
.operands
[i
].immisalign
)
4870 inst
.operands
[i
].imm
|= reg
;
4872 inst
.operands
[i
].imm
= reg
;
4873 inst
.operands
[i
].immisreg
= 1;
4875 if (skip_past_comma (&p
) == SUCCESS
)
4876 if (parse_shift (&p
, i
, SHIFT_IMMEDIATE
) == FAIL
)
4877 return PARSE_OPERAND_FAIL
;
4881 if (inst
.operands
[i
].negative
)
4883 inst
.operands
[i
].negative
= 0;
4886 if (my_get_expression (&inst
.reloc
.exp
, &p
, GE_IMM_PREFIX
))
4887 return PARSE_OPERAND_FAIL
;
4892 /* If at this point neither .preind nor .postind is set, we have a
4893 bare [Rn]{!}, which is shorthand for [Rn,#0]{!}. */
4894 if (inst
.operands
[i
].preind
== 0 && inst
.operands
[i
].postind
== 0)
4896 inst
.operands
[i
].preind
= 1;
4897 inst
.reloc
.exp
.X_op
= O_constant
;
4898 inst
.reloc
.exp
.X_add_number
= 0;
4901 return PARSE_OPERAND_SUCCESS
;
4905 parse_address (char **str
, int i
)
4907 return parse_address_main (str
, i
, 0, 0) == PARSE_OPERAND_SUCCESS
4911 static parse_operand_result
4912 parse_address_group_reloc (char **str
, int i
, group_reloc_type type
)
4914 return parse_address_main (str
, i
, 1, type
);
4917 /* Parse an operand for a MOVW or MOVT instruction. */
4919 parse_half (char **str
)
4924 skip_past_char (&p
, '#');
4925 if (strncasecmp (p
, ":lower16:", 9) == 0)
4926 inst
.reloc
.type
= BFD_RELOC_ARM_MOVW
;
4927 else if (strncasecmp (p
, ":upper16:", 9) == 0)
4928 inst
.reloc
.type
= BFD_RELOC_ARM_MOVT
;
4930 if (inst
.reloc
.type
!= BFD_RELOC_UNUSED
)
4933 skip_whitespace (p
);
4936 if (my_get_expression (&inst
.reloc
.exp
, &p
, GE_NO_PREFIX
))
4939 if (inst
.reloc
.type
== BFD_RELOC_UNUSED
)
4941 if (inst
.reloc
.exp
.X_op
!= O_constant
)
4943 inst
.error
= _("constant expression expected");
4946 if (inst
.reloc
.exp
.X_add_number
< 0
4947 || inst
.reloc
.exp
.X_add_number
> 0xffff)
4949 inst
.error
= _("immediate value out of range");
4957 /* Miscellaneous. */
4959 /* Parse a PSR flag operand. The value returned is FAIL on syntax error,
4960 or a bitmask suitable to be or-ed into the ARM msr instruction. */
4962 parse_psr (char **str
)
4965 unsigned long psr_field
;
4966 const struct asm_psr
*psr
;
4969 /* CPSR's and SPSR's can now be lowercase. This is just a convenience
4970 feature for ease of use and backwards compatibility. */
4972 if (strncasecmp (p
, "SPSR", 4) == 0)
4973 psr_field
= SPSR_BIT
;
4974 else if (strncasecmp (p
, "CPSR", 4) == 0)
4981 while (ISALNUM (*p
) || *p
== '_');
4983 psr
= hash_find_n (arm_v7m_psr_hsh
, start
, p
- start
);
4994 /* A suffix follows. */
5000 while (ISALNUM (*p
) || *p
== '_');
5002 psr
= hash_find_n (arm_psr_hsh
, start
, p
- start
);
5006 psr_field
|= psr
->field
;
5011 goto error
; /* Garbage after "[CS]PSR". */
5013 psr_field
|= (PSR_c
| PSR_f
);
5019 inst
.error
= _("flag for {c}psr instruction expected");
5023 /* Parse the flags argument to CPSI[ED]. Returns FAIL on error, or a
5024 value suitable for splatting into the AIF field of the instruction. */
5027 parse_cps_flags (char **str
)
5036 case '\0': case ',':
5039 case 'a': case 'A': saw_a_flag
= 1; val
|= 0x4; break;
5040 case 'i': case 'I': saw_a_flag
= 1; val
|= 0x2; break;
5041 case 'f': case 'F': saw_a_flag
= 1; val
|= 0x1; break;
5044 inst
.error
= _("unrecognized CPS flag");
5049 if (saw_a_flag
== 0)
5051 inst
.error
= _("missing CPS flags");
5059 /* Parse an endian specifier ("BE" or "LE", case insensitive);
5060 returns 0 for big-endian, 1 for little-endian, FAIL for an error. */
5063 parse_endian_specifier (char **str
)
5068 if (strncasecmp (s
, "BE", 2))
5070 else if (strncasecmp (s
, "LE", 2))
5074 inst
.error
= _("valid endian specifiers are be or le");
5078 if (ISALNUM (s
[2]) || s
[2] == '_')
5080 inst
.error
= _("valid endian specifiers are be or le");
5085 return little_endian
;
5088 /* Parse a rotation specifier: ROR #0, #8, #16, #24. *val receives a
5089 value suitable for poking into the rotate field of an sxt or sxta
5090 instruction, or FAIL on error. */
5093 parse_ror (char **str
)
5098 if (strncasecmp (s
, "ROR", 3) == 0)
5102 inst
.error
= _("missing rotation field after comma");
5106 if (parse_immediate (&s
, &rot
, 0, 24, FALSE
) == FAIL
)
5111 case 0: *str
= s
; return 0x0;
5112 case 8: *str
= s
; return 0x1;
5113 case 16: *str
= s
; return 0x2;
5114 case 24: *str
= s
; return 0x3;
5117 inst
.error
= _("rotation can only be 0, 8, 16, or 24");
5122 /* Parse a conditional code (from conds[] below). The value returned is in the
5123 range 0 .. 14, or FAIL. */
5125 parse_cond (char **str
)
5128 const struct asm_cond
*c
;
5130 /* Condition codes are always 2 characters, so matching up to
5131 3 characters is sufficient. */
5136 while (ISALPHA (*q
) && n
< 3)
5138 cond
[n
] = TOLOWER (*q
);
5143 c
= hash_find_n (arm_cond_hsh
, cond
, n
);
5146 inst
.error
= _("condition required");
5154 /* Parse an option for a barrier instruction. Returns the encoding for the
5157 parse_barrier (char **str
)
5160 const struct asm_barrier_opt
*o
;
5163 while (ISALPHA (*q
))
5166 o
= hash_find_n (arm_barrier_opt_hsh
, p
, q
- p
);
5174 /* Parse the operands of a table branch instruction. Similar to a memory
5177 parse_tb (char **str
)
5182 if (skip_past_char (&p
, '[') == FAIL
)
5184 inst
.error
= _("'[' expected");
5188 if ((reg
= arm_reg_parse (&p
, REG_TYPE_RN
)) == FAIL
)
5190 inst
.error
= _(reg_expected_msgs
[REG_TYPE_RN
]);
5193 inst
.operands
[0].reg
= reg
;
5195 if (skip_past_comma (&p
) == FAIL
)
5197 inst
.error
= _("',' expected");
5201 if ((reg
= arm_reg_parse (&p
, REG_TYPE_RN
)) == FAIL
)
5203 inst
.error
= _(reg_expected_msgs
[REG_TYPE_RN
]);
5206 inst
.operands
[0].imm
= reg
;
5208 if (skip_past_comma (&p
) == SUCCESS
)
5210 if (parse_shift (&p
, 0, SHIFT_LSL_IMMEDIATE
) == FAIL
)
5212 if (inst
.reloc
.exp
.X_add_number
!= 1)
5214 inst
.error
= _("invalid shift");
5217 inst
.operands
[0].shifted
= 1;
5220 if (skip_past_char (&p
, ']') == FAIL
)
5222 inst
.error
= _("']' expected");
5229 /* Parse the operands of a Neon VMOV instruction. See do_neon_mov for more
5230 information on the types the operands can take and how they are encoded.
5231 Up to four operands may be read; this function handles setting the
5232 ".present" field for each read operand itself.
5233 Updates STR and WHICH_OPERAND if parsing is successful and returns SUCCESS,
5234 else returns FAIL. */
5237 parse_neon_mov (char **str
, int *which_operand
)
5239 int i
= *which_operand
, val
;
5240 enum arm_reg_type rtype
;
5242 struct neon_type_el optype
;
5244 if ((val
= parse_scalar (&ptr
, 8, &optype
)) != FAIL
)
5246 /* Case 4: VMOV<c><q>.<size> <Dn[x]>, <Rd>. */
5247 inst
.operands
[i
].reg
= val
;
5248 inst
.operands
[i
].isscalar
= 1;
5249 inst
.operands
[i
].vectype
= optype
;
5250 inst
.operands
[i
++].present
= 1;
5252 if (skip_past_comma (&ptr
) == FAIL
)
5255 if ((val
= arm_reg_parse (&ptr
, REG_TYPE_RN
)) == FAIL
)
5258 inst
.operands
[i
].reg
= val
;
5259 inst
.operands
[i
].isreg
= 1;
5260 inst
.operands
[i
].present
= 1;
5262 else if ((val
= arm_typed_reg_parse (&ptr
, REG_TYPE_NSDQ
, &rtype
, &optype
))
5265 /* Cases 0, 1, 2, 3, 5 (D only). */
5266 if (skip_past_comma (&ptr
) == FAIL
)
5269 inst
.operands
[i
].reg
= val
;
5270 inst
.operands
[i
].isreg
= 1;
5271 inst
.operands
[i
].isquad
= (rtype
== REG_TYPE_NQ
);
5272 inst
.operands
[i
].issingle
= (rtype
== REG_TYPE_VFS
);
5273 inst
.operands
[i
].isvec
= 1;
5274 inst
.operands
[i
].vectype
= optype
;
5275 inst
.operands
[i
++].present
= 1;
5277 if ((val
= arm_reg_parse (&ptr
, REG_TYPE_RN
)) != FAIL
)
5279 /* Case 5: VMOV<c><q> <Dm>, <Rd>, <Rn>.
5280 Case 13: VMOV <Sd>, <Rm> */
5281 inst
.operands
[i
].reg
= val
;
5282 inst
.operands
[i
].isreg
= 1;
5283 inst
.operands
[i
].present
= 1;
5285 if (rtype
== REG_TYPE_NQ
)
5287 first_error (_("can't use Neon quad register here"));
5290 else if (rtype
!= REG_TYPE_VFS
)
5293 if (skip_past_comma (&ptr
) == FAIL
)
5295 if ((val
= arm_reg_parse (&ptr
, REG_TYPE_RN
)) == FAIL
)
5297 inst
.operands
[i
].reg
= val
;
5298 inst
.operands
[i
].isreg
= 1;
5299 inst
.operands
[i
].present
= 1;
5302 else if ((val
= arm_typed_reg_parse (&ptr
, REG_TYPE_NSDQ
, &rtype
,
5305 /* Case 0: VMOV<c><q> <Qd>, <Qm>
5306 Case 1: VMOV<c><q> <Dd>, <Dm>
5307 Case 8: VMOV.F32 <Sd>, <Sm>
5308 Case 15: VMOV <Sd>, <Se>, <Rn>, <Rm> */
5310 inst
.operands
[i
].reg
= val
;
5311 inst
.operands
[i
].isreg
= 1;
5312 inst
.operands
[i
].isquad
= (rtype
== REG_TYPE_NQ
);
5313 inst
.operands
[i
].issingle
= (rtype
== REG_TYPE_VFS
);
5314 inst
.operands
[i
].isvec
= 1;
5315 inst
.operands
[i
].vectype
= optype
;
5316 inst
.operands
[i
].present
= 1;
5318 if (skip_past_comma (&ptr
) == SUCCESS
)
5323 if ((val
= arm_reg_parse (&ptr
, REG_TYPE_RN
)) == FAIL
)
5326 inst
.operands
[i
].reg
= val
;
5327 inst
.operands
[i
].isreg
= 1;
5328 inst
.operands
[i
++].present
= 1;
5330 if (skip_past_comma (&ptr
) == FAIL
)
5333 if ((val
= arm_reg_parse (&ptr
, REG_TYPE_RN
)) == FAIL
)
5336 inst
.operands
[i
].reg
= val
;
5337 inst
.operands
[i
].isreg
= 1;
5338 inst
.operands
[i
++].present
= 1;
5341 else if (parse_qfloat_immediate (&ptr
, &inst
.operands
[i
].imm
) == SUCCESS
)
5342 /* Case 2: VMOV<c><q>.<dt> <Qd>, #<float-imm>
5343 Case 3: VMOV<c><q>.<dt> <Dd>, #<float-imm>
5344 Case 10: VMOV.F32 <Sd>, #<imm>
5345 Case 11: VMOV.F64 <Dd>, #<imm> */
5346 inst
.operands
[i
].immisfloat
= 1;
5347 else if (parse_big_immediate (&ptr
, i
) == SUCCESS
)
5348 /* Case 2: VMOV<c><q>.<dt> <Qd>, #<imm>
5349 Case 3: VMOV<c><q>.<dt> <Dd>, #<imm> */
5353 first_error (_("expected <Rm> or <Dm> or <Qm> operand"));
5357 else if ((val
= arm_reg_parse (&ptr
, REG_TYPE_RN
)) != FAIL
)
5360 inst
.operands
[i
].reg
= val
;
5361 inst
.operands
[i
].isreg
= 1;
5362 inst
.operands
[i
++].present
= 1;
5364 if (skip_past_comma (&ptr
) == FAIL
)
5367 if ((val
= parse_scalar (&ptr
, 8, &optype
)) != FAIL
)
5369 /* Case 6: VMOV<c><q>.<dt> <Rd>, <Dn[x]> */
5370 inst
.operands
[i
].reg
= val
;
5371 inst
.operands
[i
].isscalar
= 1;
5372 inst
.operands
[i
].present
= 1;
5373 inst
.operands
[i
].vectype
= optype
;
5375 else if ((val
= arm_reg_parse (&ptr
, REG_TYPE_RN
)) != FAIL
)
5377 /* Case 7: VMOV<c><q> <Rd>, <Rn>, <Dm> */
5378 inst
.operands
[i
].reg
= val
;
5379 inst
.operands
[i
].isreg
= 1;
5380 inst
.operands
[i
++].present
= 1;
5382 if (skip_past_comma (&ptr
) == FAIL
)
5385 if ((val
= arm_typed_reg_parse (&ptr
, REG_TYPE_VFSD
, &rtype
, &optype
))
5388 first_error (_(reg_expected_msgs
[REG_TYPE_VFSD
]));
5392 inst
.operands
[i
].reg
= val
;
5393 inst
.operands
[i
].isreg
= 1;
5394 inst
.operands
[i
].isvec
= 1;
5395 inst
.operands
[i
].issingle
= (rtype
== REG_TYPE_VFS
);
5396 inst
.operands
[i
].vectype
= optype
;
5397 inst
.operands
[i
].present
= 1;
5399 if (rtype
== REG_TYPE_VFS
)
5403 if (skip_past_comma (&ptr
) == FAIL
)
5405 if ((val
= arm_typed_reg_parse (&ptr
, REG_TYPE_VFS
, NULL
,
5408 first_error (_(reg_expected_msgs
[REG_TYPE_VFS
]));
5411 inst
.operands
[i
].reg
= val
;
5412 inst
.operands
[i
].isreg
= 1;
5413 inst
.operands
[i
].isvec
= 1;
5414 inst
.operands
[i
].issingle
= 1;
5415 inst
.operands
[i
].vectype
= optype
;
5416 inst
.operands
[i
].present
= 1;
5419 else if ((val
= arm_typed_reg_parse (&ptr
, REG_TYPE_VFS
, NULL
, &optype
))
5423 inst
.operands
[i
].reg
= val
;
5424 inst
.operands
[i
].isreg
= 1;
5425 inst
.operands
[i
].isvec
= 1;
5426 inst
.operands
[i
].issingle
= 1;
5427 inst
.operands
[i
].vectype
= optype
;
5428 inst
.operands
[i
++].present
= 1;
5433 first_error (_("parse error"));
5437 /* Successfully parsed the operands. Update args. */
5443 first_error (_("expected comma"));
5447 first_error (_(reg_expected_msgs
[REG_TYPE_RN
]));
5451 /* Matcher codes for parse_operands. */
5452 enum operand_parse_code
5454 OP_stop
, /* end of line */
5456 OP_RR
, /* ARM register */
5457 OP_RRnpc
, /* ARM register, not r15 */
5458 OP_RRnpcb
, /* ARM register, not r15, in square brackets */
5459 OP_RRw
, /* ARM register, not r15, optional trailing ! */
5460 OP_RCP
, /* Coprocessor number */
5461 OP_RCN
, /* Coprocessor register */
5462 OP_RF
, /* FPA register */
5463 OP_RVS
, /* VFP single precision register */
5464 OP_RVD
, /* VFP double precision register (0..15) */
5465 OP_RND
, /* Neon double precision register (0..31) */
5466 OP_RNQ
, /* Neon quad precision register */
5467 OP_RVSD
, /* VFP single or double precision register */
5468 OP_RNDQ
, /* Neon double or quad precision register */
5469 OP_RNSDQ
, /* Neon single, double or quad precision register */
5470 OP_RNSC
, /* Neon scalar D[X] */
5471 OP_RVC
, /* VFP control register */
5472 OP_RMF
, /* Maverick F register */
5473 OP_RMD
, /* Maverick D register */
5474 OP_RMFX
, /* Maverick FX register */
5475 OP_RMDX
, /* Maverick DX register */
5476 OP_RMAX
, /* Maverick AX register */
5477 OP_RMDS
, /* Maverick DSPSC register */
5478 OP_RIWR
, /* iWMMXt wR register */
5479 OP_RIWC
, /* iWMMXt wC register */
5480 OP_RIWG
, /* iWMMXt wCG register */
5481 OP_RXA
, /* XScale accumulator register */
5483 OP_REGLST
, /* ARM register list */
5484 OP_VRSLST
, /* VFP single-precision register list */
5485 OP_VRDLST
, /* VFP double-precision register list */
5486 OP_VRSDLST
, /* VFP single or double-precision register list (& quad) */
5487 OP_NRDLST
, /* Neon double-precision register list (d0-d31, qN aliases) */
5488 OP_NSTRLST
, /* Neon element/structure list */
5490 OP_NILO
, /* Neon immediate/logic operands 2 or 2+3. (VBIC, VORR...) */
5491 OP_RNDQ_I0
, /* Neon D or Q reg, or immediate zero. */
5492 OP_RVSD_I0
, /* VFP S or D reg, or immediate zero. */
5493 OP_RR_RNSC
, /* ARM reg or Neon scalar. */
5494 OP_RNSDQ_RNSC
, /* Vector S, D or Q reg, or Neon scalar. */
5495 OP_RNDQ_RNSC
, /* Neon D or Q reg, or Neon scalar. */
5496 OP_RND_RNSC
, /* Neon D reg, or Neon scalar. */
5497 OP_VMOV
, /* Neon VMOV operands. */
5498 OP_RNDQ_IMVNb
,/* Neon D or Q reg, or immediate good for VMVN. */
5499 OP_RNDQ_I63b
, /* Neon D or Q reg, or immediate for shift. */
5500 OP_RIWR_I32z
, /* iWMMXt wR register, or immediate 0 .. 32 for iWMMXt2. */
5502 OP_I0
, /* immediate zero */
5503 OP_I7
, /* immediate value 0 .. 7 */
5504 OP_I15
, /* 0 .. 15 */
5505 OP_I16
, /* 1 .. 16 */
5506 OP_I16z
, /* 0 .. 16 */
5507 OP_I31
, /* 0 .. 31 */
5508 OP_I31w
, /* 0 .. 31, optional trailing ! */
5509 OP_I32
, /* 1 .. 32 */
5510 OP_I32z
, /* 0 .. 32 */
5511 OP_I63
, /* 0 .. 63 */
5512 OP_I63s
, /* -64 .. 63 */
5513 OP_I64
, /* 1 .. 64 */
5514 OP_I64z
, /* 0 .. 64 */
5515 OP_I255
, /* 0 .. 255 */
5517 OP_I4b
, /* immediate, prefix optional, 1 .. 4 */
5518 OP_I7b
, /* 0 .. 7 */
5519 OP_I15b
, /* 0 .. 15 */
5520 OP_I31b
, /* 0 .. 31 */
5522 OP_SH
, /* shifter operand */
5523 OP_SHG
, /* shifter operand with possible group relocation */
5524 OP_ADDR
, /* Memory address expression (any mode) */
5525 OP_ADDRGLDR
, /* Mem addr expr (any mode) with possible LDR group reloc */
5526 OP_ADDRGLDRS
, /* Mem addr expr (any mode) with possible LDRS group reloc */
5527 OP_ADDRGLDC
, /* Mem addr expr (any mode) with possible LDC group reloc */
5528 OP_EXP
, /* arbitrary expression */
5529 OP_EXPi
, /* same, with optional immediate prefix */
5530 OP_EXPr
, /* same, with optional relocation suffix */
5531 OP_HALF
, /* 0 .. 65535 or low/high reloc. */
5533 OP_CPSF
, /* CPS flags */
5534 OP_ENDI
, /* Endianness specifier */
5535 OP_PSR
, /* CPSR/SPSR mask for msr */
5536 OP_COND
, /* conditional code */
5537 OP_TB
, /* Table branch. */
5539 OP_RVC_PSR
, /* CPSR/SPSR mask for msr, or VFP control register. */
5540 OP_APSR_RR
, /* ARM register or "APSR_nzcv". */
5542 OP_RRnpc_I0
, /* ARM register or literal 0 */
5543 OP_RR_EXr
, /* ARM register or expression with opt. reloc suff. */
5544 OP_RR_EXi
, /* ARM register or expression with imm prefix */
5545 OP_RF_IF
, /* FPA register or immediate */
5546 OP_RIWR_RIWC
, /* iWMMXt R or C reg */
5547 OP_RIWC_RIWG
, /* iWMMXt wC or wCG reg */
5549 /* Optional operands. */
5550 OP_oI7b
, /* immediate, prefix optional, 0 .. 7 */
5551 OP_oI31b
, /* 0 .. 31 */
5552 OP_oI32b
, /* 1 .. 32 */
5553 OP_oIffffb
, /* 0 .. 65535 */
5554 OP_oI255c
, /* curly-brace enclosed, 0 .. 255 */
5556 OP_oRR
, /* ARM register */
5557 OP_oRRnpc
, /* ARM register, not the PC */
5558 OP_oRRw
, /* ARM register, not r15, optional trailing ! */
5559 OP_oRND
, /* Optional Neon double precision register */
5560 OP_oRNQ
, /* Optional Neon quad precision register */
5561 OP_oRNDQ
, /* Optional Neon double or quad precision register */
5562 OP_oRNSDQ
, /* Optional single, double or quad precision vector register */
5563 OP_oSHll
, /* LSL immediate */
5564 OP_oSHar
, /* ASR immediate */
5565 OP_oSHllar
, /* LSL or ASR immediate */
5566 OP_oROR
, /* ROR 0/8/16/24 */
5567 OP_oBARRIER
, /* Option argument for a barrier instruction. */
5569 OP_FIRST_OPTIONAL
= OP_oI7b
5572 /* Generic instruction operand parser. This does no encoding and no
5573 semantic validation; it merely squirrels values away in the inst
5574 structure. Returns SUCCESS or FAIL depending on whether the
5575 specified grammar matched. */
5577 parse_operands (char *str
, const unsigned char *pattern
)
5579 unsigned const char *upat
= pattern
;
5580 char *backtrack_pos
= 0;
5581 const char *backtrack_error
= 0;
5582 int i
, val
, backtrack_index
= 0;
5583 enum arm_reg_type rtype
;
5584 parse_operand_result result
;
5586 #define po_char_or_fail(chr) \
5589 if (skip_past_char (&str, chr) == FAIL) \
5594 #define po_reg_or_fail(regtype) \
5597 val = arm_typed_reg_parse (& str, regtype, & rtype, \
5598 & inst.operands[i].vectype); \
5601 first_error (_(reg_expected_msgs[regtype])); \
5604 inst.operands[i].reg = val; \
5605 inst.operands[i].isreg = 1; \
5606 inst.operands[i].isquad = (rtype == REG_TYPE_NQ); \
5607 inst.operands[i].issingle = (rtype == REG_TYPE_VFS); \
5608 inst.operands[i].isvec = (rtype == REG_TYPE_VFS \
5609 || rtype == REG_TYPE_VFD \
5610 || rtype == REG_TYPE_NQ); \
5614 #define po_reg_or_goto(regtype, label) \
5617 val = arm_typed_reg_parse (& str, regtype, & rtype, \
5618 & inst.operands[i].vectype); \
5622 inst.operands[i].reg = val; \
5623 inst.operands[i].isreg = 1; \
5624 inst.operands[i].isquad = (rtype == REG_TYPE_NQ); \
5625 inst.operands[i].issingle = (rtype == REG_TYPE_VFS); \
5626 inst.operands[i].isvec = (rtype == REG_TYPE_VFS \
5627 || rtype == REG_TYPE_VFD \
5628 || rtype == REG_TYPE_NQ); \
5632 #define po_imm_or_fail(min, max, popt) \
5635 if (parse_immediate (&str, &val, min, max, popt) == FAIL) \
5637 inst.operands[i].imm = val; \
5641 #define po_scalar_or_goto(elsz, label) \
5644 val = parse_scalar (& str, elsz, & inst.operands[i].vectype); \
5647 inst.operands[i].reg = val; \
5648 inst.operands[i].isscalar = 1; \
5652 #define po_misc_or_fail(expr) \
5660 #define po_misc_or_fail_no_backtrack(expr) \
5664 if (result == PARSE_OPERAND_FAIL_NO_BACKTRACK) \
5665 backtrack_pos = 0; \
5666 if (result != PARSE_OPERAND_SUCCESS) \
5671 skip_whitespace (str
);
5673 for (i
= 0; upat
[i
] != OP_stop
; i
++)
5675 if (upat
[i
] >= OP_FIRST_OPTIONAL
)
5677 /* Remember where we are in case we need to backtrack. */
5678 gas_assert (!backtrack_pos
);
5679 backtrack_pos
= str
;
5680 backtrack_error
= inst
.error
;
5681 backtrack_index
= i
;
5684 if (i
> 0 && (i
> 1 || inst
.operands
[0].present
))
5685 po_char_or_fail (',');
5693 case OP_RR
: po_reg_or_fail (REG_TYPE_RN
); break;
5694 case OP_RCP
: po_reg_or_fail (REG_TYPE_CP
); break;
5695 case OP_RCN
: po_reg_or_fail (REG_TYPE_CN
); break;
5696 case OP_RF
: po_reg_or_fail (REG_TYPE_FN
); break;
5697 case OP_RVS
: po_reg_or_fail (REG_TYPE_VFS
); break;
5698 case OP_RVD
: po_reg_or_fail (REG_TYPE_VFD
); break;
5700 case OP_RND
: po_reg_or_fail (REG_TYPE_VFD
); break;
5702 po_reg_or_goto (REG_TYPE_VFC
, coproc_reg
);
5704 /* Also accept generic coprocessor regs for unknown registers. */
5706 po_reg_or_fail (REG_TYPE_CN
);
5708 case OP_RMF
: po_reg_or_fail (REG_TYPE_MVF
); break;
5709 case OP_RMD
: po_reg_or_fail (REG_TYPE_MVD
); break;
5710 case OP_RMFX
: po_reg_or_fail (REG_TYPE_MVFX
); break;
5711 case OP_RMDX
: po_reg_or_fail (REG_TYPE_MVDX
); break;
5712 case OP_RMAX
: po_reg_or_fail (REG_TYPE_MVAX
); break;
5713 case OP_RMDS
: po_reg_or_fail (REG_TYPE_DSPSC
); break;
5714 case OP_RIWR
: po_reg_or_fail (REG_TYPE_MMXWR
); break;
5715 case OP_RIWC
: po_reg_or_fail (REG_TYPE_MMXWC
); break;
5716 case OP_RIWG
: po_reg_or_fail (REG_TYPE_MMXWCG
); break;
5717 case OP_RXA
: po_reg_or_fail (REG_TYPE_XSCALE
); break;
5719 case OP_RNQ
: po_reg_or_fail (REG_TYPE_NQ
); break;
5721 case OP_RNDQ
: po_reg_or_fail (REG_TYPE_NDQ
); break;
5722 case OP_RVSD
: po_reg_or_fail (REG_TYPE_VFSD
); break;
5724 case OP_RNSDQ
: po_reg_or_fail (REG_TYPE_NSDQ
); break;
5726 /* Neon scalar. Using an element size of 8 means that some invalid
5727 scalars are accepted here, so deal with those in later code. */
5728 case OP_RNSC
: po_scalar_or_goto (8, failure
); break;
5730 /* WARNING: We can expand to two operands here. This has the potential
5731 to totally confuse the backtracking mechanism! It will be OK at
5732 least as long as we don't try to use optional args as well,
5736 po_reg_or_goto (REG_TYPE_NDQ
, try_imm
);
5737 inst
.operands
[i
].present
= 1;
5739 skip_past_comma (&str
);
5740 po_reg_or_goto (REG_TYPE_NDQ
, one_reg_only
);
5743 /* Optional register operand was omitted. Unfortunately, it's in
5744 operands[i-1] and we need it to be in inst.operands[i]. Fix that
5745 here (this is a bit grotty). */
5746 inst
.operands
[i
] = inst
.operands
[i
-1];
5747 inst
.operands
[i
-1].present
= 0;
5750 /* There's a possibility of getting a 64-bit immediate here, so
5751 we need special handling. */
5752 if (parse_big_immediate (&str
, i
) == FAIL
)
5754 inst
.error
= _("immediate value is out of range");
5762 po_reg_or_goto (REG_TYPE_NDQ
, try_imm0
);
5765 po_imm_or_fail (0, 0, TRUE
);
5770 po_reg_or_goto (REG_TYPE_VFSD
, try_imm0
);
5775 po_scalar_or_goto (8, try_rr
);
5778 po_reg_or_fail (REG_TYPE_RN
);
5784 po_scalar_or_goto (8, try_nsdq
);
5787 po_reg_or_fail (REG_TYPE_NSDQ
);
5793 po_scalar_or_goto (8, try_ndq
);
5796 po_reg_or_fail (REG_TYPE_NDQ
);
5802 po_scalar_or_goto (8, try_vfd
);
5805 po_reg_or_fail (REG_TYPE_VFD
);
5810 /* WARNING: parse_neon_mov can move the operand counter, i. If we're
5811 not careful then bad things might happen. */
5812 po_misc_or_fail (parse_neon_mov (&str
, &i
) == FAIL
);
5817 po_reg_or_goto (REG_TYPE_NDQ
, try_mvnimm
);
5820 /* There's a possibility of getting a 64-bit immediate here, so
5821 we need special handling. */
5822 if (parse_big_immediate (&str
, i
) == FAIL
)
5824 inst
.error
= _("immediate value is out of range");
5832 po_reg_or_goto (REG_TYPE_NDQ
, try_shimm
);
5835 po_imm_or_fail (0, 63, TRUE
);
5840 po_char_or_fail ('[');
5841 po_reg_or_fail (REG_TYPE_RN
);
5842 po_char_or_fail (']');
5847 po_reg_or_fail (REG_TYPE_RN
);
5848 if (skip_past_char (&str
, '!') == SUCCESS
)
5849 inst
.operands
[i
].writeback
= 1;
5853 case OP_I7
: po_imm_or_fail ( 0, 7, FALSE
); break;
5854 case OP_I15
: po_imm_or_fail ( 0, 15, FALSE
); break;
5855 case OP_I16
: po_imm_or_fail ( 1, 16, FALSE
); break;
5856 case OP_I16z
: po_imm_or_fail ( 0, 16, FALSE
); break;
5857 case OP_I31
: po_imm_or_fail ( 0, 31, FALSE
); break;
5858 case OP_I32
: po_imm_or_fail ( 1, 32, FALSE
); break;
5859 case OP_I32z
: po_imm_or_fail ( 0, 32, FALSE
); break;
5860 case OP_I63s
: po_imm_or_fail (-64, 63, FALSE
); break;
5861 case OP_I63
: po_imm_or_fail ( 0, 63, FALSE
); break;
5862 case OP_I64
: po_imm_or_fail ( 1, 64, FALSE
); break;
5863 case OP_I64z
: po_imm_or_fail ( 0, 64, FALSE
); break;
5864 case OP_I255
: po_imm_or_fail ( 0, 255, FALSE
); break;
5866 case OP_I4b
: po_imm_or_fail ( 1, 4, TRUE
); break;
5868 case OP_I7b
: po_imm_or_fail ( 0, 7, TRUE
); break;
5869 case OP_I15b
: po_imm_or_fail ( 0, 15, TRUE
); break;
5871 case OP_I31b
: po_imm_or_fail ( 0, 31, TRUE
); break;
5872 case OP_oI32b
: po_imm_or_fail ( 1, 32, TRUE
); break;
5873 case OP_oIffffb
: po_imm_or_fail ( 0, 0xffff, TRUE
); break;
5875 /* Immediate variants */
5877 po_char_or_fail ('{');
5878 po_imm_or_fail (0, 255, TRUE
);
5879 po_char_or_fail ('}');
5883 /* The expression parser chokes on a trailing !, so we have
5884 to find it first and zap it. */
5887 while (*s
&& *s
!= ',')
5892 inst
.operands
[i
].writeback
= 1;
5894 po_imm_or_fail (0, 31, TRUE
);
5902 po_misc_or_fail (my_get_expression (&inst
.reloc
.exp
, &str
,
5907 po_misc_or_fail (my_get_expression (&inst
.reloc
.exp
, &str
,
5912 po_misc_or_fail (my_get_expression (&inst
.reloc
.exp
, &str
,
5914 if (inst
.reloc
.exp
.X_op
== O_symbol
)
5916 val
= parse_reloc (&str
);
5919 inst
.error
= _("unrecognized relocation suffix");
5922 else if (val
!= BFD_RELOC_UNUSED
)
5924 inst
.operands
[i
].imm
= val
;
5925 inst
.operands
[i
].hasreloc
= 1;
5930 /* Operand for MOVW or MOVT. */
5932 po_misc_or_fail (parse_half (&str
));
5935 /* Register or expression. */
5936 case OP_RR_EXr
: po_reg_or_goto (REG_TYPE_RN
, EXPr
); break;
5937 case OP_RR_EXi
: po_reg_or_goto (REG_TYPE_RN
, EXPi
); break;
5939 /* Register or immediate. */
5940 case OP_RRnpc_I0
: po_reg_or_goto (REG_TYPE_RN
, I0
); break;
5941 I0
: po_imm_or_fail (0, 0, FALSE
); break;
5943 case OP_RF_IF
: po_reg_or_goto (REG_TYPE_FN
, IF
); break;
5945 if (!is_immediate_prefix (*str
))
5948 val
= parse_fpa_immediate (&str
);
5951 /* FPA immediates are encoded as registers 8-15.
5952 parse_fpa_immediate has already applied the offset. */
5953 inst
.operands
[i
].reg
= val
;
5954 inst
.operands
[i
].isreg
= 1;
5957 case OP_RIWR_I32z
: po_reg_or_goto (REG_TYPE_MMXWR
, I32z
); break;
5958 I32z
: po_imm_or_fail (0, 32, FALSE
); break;
5960 /* Two kinds of register. */
5963 struct reg_entry
*rege
= arm_reg_parse_multi (&str
);
5965 || (rege
->type
!= REG_TYPE_MMXWR
5966 && rege
->type
!= REG_TYPE_MMXWC
5967 && rege
->type
!= REG_TYPE_MMXWCG
))
5969 inst
.error
= _("iWMMXt data or control register expected");
5972 inst
.operands
[i
].reg
= rege
->number
;
5973 inst
.operands
[i
].isreg
= (rege
->type
== REG_TYPE_MMXWR
);
5979 struct reg_entry
*rege
= arm_reg_parse_multi (&str
);
5981 || (rege
->type
!= REG_TYPE_MMXWC
5982 && rege
->type
!= REG_TYPE_MMXWCG
))
5984 inst
.error
= _("iWMMXt control register expected");
5987 inst
.operands
[i
].reg
= rege
->number
;
5988 inst
.operands
[i
].isreg
= 1;
5993 case OP_CPSF
: val
= parse_cps_flags (&str
); break;
5994 case OP_ENDI
: val
= parse_endian_specifier (&str
); break;
5995 case OP_oROR
: val
= parse_ror (&str
); break;
5996 case OP_PSR
: val
= parse_psr (&str
); break;
5997 case OP_COND
: val
= parse_cond (&str
); break;
5998 case OP_oBARRIER
:val
= parse_barrier (&str
); break;
6001 po_reg_or_goto (REG_TYPE_VFC
, try_psr
);
6002 inst
.operands
[i
].isvec
= 1; /* Mark VFP control reg as vector. */
6005 val
= parse_psr (&str
);
6009 po_reg_or_goto (REG_TYPE_RN
, try_apsr
);
6012 /* Parse "APSR_nvzc" operand (for FMSTAT-equivalent MRS
6014 if (strncasecmp (str
, "APSR_", 5) == 0)
6021 case 'c': found
= (found
& 1) ? 16 : found
| 1; break;
6022 case 'n': found
= (found
& 2) ? 16 : found
| 2; break;
6023 case 'z': found
= (found
& 4) ? 16 : found
| 4; break;
6024 case 'v': found
= (found
& 8) ? 16 : found
| 8; break;
6025 default: found
= 16;
6029 inst
.operands
[i
].isvec
= 1;
6036 po_misc_or_fail (parse_tb (&str
));
6039 /* Register lists. */
6041 val
= parse_reg_list (&str
);
6044 inst
.operands
[1].writeback
= 1;
6050 val
= parse_vfp_reg_list (&str
, &inst
.operands
[i
].reg
, REGLIST_VFP_S
);
6054 val
= parse_vfp_reg_list (&str
, &inst
.operands
[i
].reg
, REGLIST_VFP_D
);
6058 /* Allow Q registers too. */
6059 val
= parse_vfp_reg_list (&str
, &inst
.operands
[i
].reg
,
6064 val
= parse_vfp_reg_list (&str
, &inst
.operands
[i
].reg
,
6066 inst
.operands
[i
].issingle
= 1;
6071 val
= parse_vfp_reg_list (&str
, &inst
.operands
[i
].reg
,
6076 val
= parse_neon_el_struct_list (&str
, &inst
.operands
[i
].reg
,
6077 &inst
.operands
[i
].vectype
);
6080 /* Addressing modes */
6082 po_misc_or_fail (parse_address (&str
, i
));
6086 po_misc_or_fail_no_backtrack (
6087 parse_address_group_reloc (&str
, i
, GROUP_LDR
));
6091 po_misc_or_fail_no_backtrack (
6092 parse_address_group_reloc (&str
, i
, GROUP_LDRS
));
6096 po_misc_or_fail_no_backtrack (
6097 parse_address_group_reloc (&str
, i
, GROUP_LDC
));
6101 po_misc_or_fail (parse_shifter_operand (&str
, i
));
6105 po_misc_or_fail_no_backtrack (
6106 parse_shifter_operand_group_reloc (&str
, i
));
6110 po_misc_or_fail (parse_shift (&str
, i
, SHIFT_LSL_IMMEDIATE
));
6114 po_misc_or_fail (parse_shift (&str
, i
, SHIFT_ASR_IMMEDIATE
));
6118 po_misc_or_fail (parse_shift (&str
, i
, SHIFT_LSL_OR_ASR_IMMEDIATE
));
6122 as_fatal (_("unhandled operand code %d"), upat
[i
]);
6125 /* Various value-based sanity checks and shared operations. We
6126 do not signal immediate failures for the register constraints;
6127 this allows a syntax error to take precedence. */
6136 if (inst
.operands
[i
].isreg
&& inst
.operands
[i
].reg
== REG_PC
)
6137 inst
.error
= BAD_PC
;
6155 inst
.operands
[i
].imm
= val
;
6162 /* If we get here, this operand was successfully parsed. */
6163 inst
.operands
[i
].present
= 1;
6167 inst
.error
= BAD_ARGS
;
6172 /* The parse routine should already have set inst.error, but set a
6173 default here just in case. */
6175 inst
.error
= _("syntax error");
6179 /* Do not backtrack over a trailing optional argument that
6180 absorbed some text. We will only fail again, with the
6181 'garbage following instruction' error message, which is
6182 probably less helpful than the current one. */
6183 if (backtrack_index
== i
&& backtrack_pos
!= str
6184 && upat
[i
+1] == OP_stop
)
6187 inst
.error
= _("syntax error");
6191 /* Try again, skipping the optional argument at backtrack_pos. */
6192 str
= backtrack_pos
;
6193 inst
.error
= backtrack_error
;
6194 inst
.operands
[backtrack_index
].present
= 0;
6195 i
= backtrack_index
;
6199 /* Check that we have parsed all the arguments. */
6200 if (*str
!= '\0' && !inst
.error
)
6201 inst
.error
= _("garbage following instruction");
6203 return inst
.error
? FAIL
: SUCCESS
;
6206 #undef po_char_or_fail
6207 #undef po_reg_or_fail
6208 #undef po_reg_or_goto
6209 #undef po_imm_or_fail
6210 #undef po_scalar_or_fail
6212 /* Shorthand macro for instruction encoding functions issuing errors. */
6213 #define constraint(expr, err) \
6224 /* Reject "bad registers" for Thumb-2 instructions. Many Thumb-2
6225 instructions are unpredictable if these registers are used. This
6226 is the BadReg predicate in ARM's Thumb-2 documentation. */
6227 #define reject_bad_reg(reg) \
6229 if (reg == REG_SP || reg == REG_PC) \
6231 inst.error = (reg == REG_SP) ? BAD_SP : BAD_PC; \
6236 /* If REG is R13 (the stack pointer), warn that its use is
6238 #define warn_deprecated_sp(reg) \
6240 if (warn_on_deprecated && reg == REG_SP) \
6241 as_warn (_("use of r13 is deprecated")); \
6244 /* Functions for operand encoding. ARM, then Thumb. */
6246 #define rotate_left(v, n) (v << n | v >> (32 - n))
6248 /* If VAL can be encoded in the immediate field of an ARM instruction,
6249 return the encoded form. Otherwise, return FAIL. */
6252 encode_arm_immediate (unsigned int val
)
6256 for (i
= 0; i
< 32; i
+= 2)
6257 if ((a
= rotate_left (val
, i
)) <= 0xff)
6258 return a
| (i
<< 7); /* 12-bit pack: [shift-cnt,const]. */
6263 /* If VAL can be encoded in the immediate field of a Thumb32 instruction,
6264 return the encoded form. Otherwise, return FAIL. */
6266 encode_thumb32_immediate (unsigned int val
)
6273 for (i
= 1; i
<= 24; i
++)
6276 if ((val
& ~(0xff << i
)) == 0)
6277 return ((val
>> i
) & 0x7f) | ((32 - i
) << 7);
6281 if (val
== ((a
<< 16) | a
))
6283 if (val
== ((a
<< 24) | (a
<< 16) | (a
<< 8) | a
))
6287 if (val
== ((a
<< 16) | a
))
6288 return 0x200 | (a
>> 8);
6292 /* Encode a VFP SP or DP register number into inst.instruction. */
6295 encode_arm_vfp_reg (int reg
, enum vfp_reg_pos pos
)
6297 if ((pos
== VFP_REG_Dd
|| pos
== VFP_REG_Dn
|| pos
== VFP_REG_Dm
)
6300 if (ARM_CPU_HAS_FEATURE (cpu_variant
, fpu_vfp_ext_d32
))
6303 ARM_MERGE_FEATURE_SETS (thumb_arch_used
, thumb_arch_used
,
6306 ARM_MERGE_FEATURE_SETS (arm_arch_used
, arm_arch_used
,
6311 first_error (_("D register out of range for selected VFP version"));
6319 inst
.instruction
|= ((reg
>> 1) << 12) | ((reg
& 1) << 22);
6323 inst
.instruction
|= ((reg
>> 1) << 16) | ((reg
& 1) << 7);
6327 inst
.instruction
|= ((reg
>> 1) << 0) | ((reg
& 1) << 5);
6331 inst
.instruction
|= ((reg
& 15) << 12) | ((reg
>> 4) << 22);
6335 inst
.instruction
|= ((reg
& 15) << 16) | ((reg
>> 4) << 7);
6339 inst
.instruction
|= (reg
& 15) | ((reg
>> 4) << 5);
6347 /* Encode a <shift> in an ARM-format instruction. The immediate,
6348 if any, is handled by md_apply_fix. */
6350 encode_arm_shift (int i
)
6352 if (inst
.operands
[i
].shift_kind
== SHIFT_RRX
)
6353 inst
.instruction
|= SHIFT_ROR
<< 5;
6356 inst
.instruction
|= inst
.operands
[i
].shift_kind
<< 5;
6357 if (inst
.operands
[i
].immisreg
)
6359 inst
.instruction
|= SHIFT_BY_REG
;
6360 inst
.instruction
|= inst
.operands
[i
].imm
<< 8;
6363 inst
.reloc
.type
= BFD_RELOC_ARM_SHIFT_IMM
;
6368 encode_arm_shifter_operand (int i
)
6370 if (inst
.operands
[i
].isreg
)
6372 inst
.instruction
|= inst
.operands
[i
].reg
;
6373 encode_arm_shift (i
);
6376 inst
.instruction
|= INST_IMMEDIATE
;
6379 /* Subroutine of encode_arm_addr_mode_2 and encode_arm_addr_mode_3. */
6381 encode_arm_addr_mode_common (int i
, bfd_boolean is_t
)
6383 gas_assert (inst
.operands
[i
].isreg
);
6384 inst
.instruction
|= inst
.operands
[i
].reg
<< 16;
6386 if (inst
.operands
[i
].preind
)
6390 inst
.error
= _("instruction does not accept preindexed addressing");
6393 inst
.instruction
|= PRE_INDEX
;
6394 if (inst
.operands
[i
].writeback
)
6395 inst
.instruction
|= WRITE_BACK
;
6398 else if (inst
.operands
[i
].postind
)
6400 gas_assert (inst
.operands
[i
].writeback
);
6402 inst
.instruction
|= WRITE_BACK
;
6404 else /* unindexed - only for coprocessor */
6406 inst
.error
= _("instruction does not accept unindexed addressing");
6410 if (((inst
.instruction
& WRITE_BACK
) || !(inst
.instruction
& PRE_INDEX
))
6411 && (((inst
.instruction
& 0x000f0000) >> 16)
6412 == ((inst
.instruction
& 0x0000f000) >> 12)))
6413 as_warn ((inst
.instruction
& LOAD_BIT
)
6414 ? _("destination register same as write-back base")
6415 : _("source register same as write-back base"));
6418 /* inst.operands[i] was set up by parse_address. Encode it into an
6419 ARM-format mode 2 load or store instruction. If is_t is true,
6420 reject forms that cannot be used with a T instruction (i.e. not
6423 encode_arm_addr_mode_2 (int i
, bfd_boolean is_t
)
6425 encode_arm_addr_mode_common (i
, is_t
);
6427 if (inst
.operands
[i
].immisreg
)
6429 inst
.instruction
|= INST_IMMEDIATE
; /* yes, this is backwards */
6430 inst
.instruction
|= inst
.operands
[i
].imm
;
6431 if (!inst
.operands
[i
].negative
)
6432 inst
.instruction
|= INDEX_UP
;
6433 if (inst
.operands
[i
].shifted
)
6435 if (inst
.operands
[i
].shift_kind
== SHIFT_RRX
)
6436 inst
.instruction
|= SHIFT_ROR
<< 5;
6439 inst
.instruction
|= inst
.operands
[i
].shift_kind
<< 5;
6440 inst
.reloc
.type
= BFD_RELOC_ARM_SHIFT_IMM
;
6444 else /* immediate offset in inst.reloc */
6446 if (inst
.reloc
.type
== BFD_RELOC_UNUSED
)
6447 inst
.reloc
.type
= BFD_RELOC_ARM_OFFSET_IMM
;
6451 /* inst.operands[i] was set up by parse_address. Encode it into an
6452 ARM-format mode 3 load or store instruction. Reject forms that
6453 cannot be used with such instructions. If is_t is true, reject
6454 forms that cannot be used with a T instruction (i.e. not
6457 encode_arm_addr_mode_3 (int i
, bfd_boolean is_t
)
6459 if (inst
.operands
[i
].immisreg
&& inst
.operands
[i
].shifted
)
6461 inst
.error
= _("instruction does not accept scaled register index");
6465 encode_arm_addr_mode_common (i
, is_t
);
6467 if (inst
.operands
[i
].immisreg
)
6469 inst
.instruction
|= inst
.operands
[i
].imm
;
6470 if (!inst
.operands
[i
].negative
)
6471 inst
.instruction
|= INDEX_UP
;
6473 else /* immediate offset in inst.reloc */
6475 inst
.instruction
|= HWOFFSET_IMM
;
6476 if (inst
.reloc
.type
== BFD_RELOC_UNUSED
)
6477 inst
.reloc
.type
= BFD_RELOC_ARM_OFFSET_IMM8
;
6481 /* inst.operands[i] was set up by parse_address. Encode it into an
6482 ARM-format instruction. Reject all forms which cannot be encoded
6483 into a coprocessor load/store instruction. If wb_ok is false,
6484 reject use of writeback; if unind_ok is false, reject use of
6485 unindexed addressing. If reloc_override is not 0, use it instead
6486 of BFD_ARM_CP_OFF_IMM, unless the initial relocation is a group one
6487 (in which case it is preserved). */
6490 encode_arm_cp_address (int i
, int wb_ok
, int unind_ok
, int reloc_override
)
6492 inst
.instruction
|= inst
.operands
[i
].reg
<< 16;
6494 gas_assert (!(inst
.operands
[i
].preind
&& inst
.operands
[i
].postind
));
6496 if (!inst
.operands
[i
].preind
&& !inst
.operands
[i
].postind
) /* unindexed */
6498 gas_assert (!inst
.operands
[i
].writeback
);
6501 inst
.error
= _("instruction does not support unindexed addressing");
6504 inst
.instruction
|= inst
.operands
[i
].imm
;
6505 inst
.instruction
|= INDEX_UP
;
6509 if (inst
.operands
[i
].preind
)
6510 inst
.instruction
|= PRE_INDEX
;
6512 if (inst
.operands
[i
].writeback
)
6514 if (inst
.operands
[i
].reg
== REG_PC
)
6516 inst
.error
= _("pc may not be used with write-back");
6521 inst
.error
= _("instruction does not support writeback");
6524 inst
.instruction
|= WRITE_BACK
;
6528 inst
.reloc
.type
= reloc_override
;
6529 else if ((inst
.reloc
.type
< BFD_RELOC_ARM_ALU_PC_G0_NC
6530 || inst
.reloc
.type
> BFD_RELOC_ARM_LDC_SB_G2
)
6531 && inst
.reloc
.type
!= BFD_RELOC_ARM_LDR_PC_G0
)
6534 inst
.reloc
.type
= BFD_RELOC_ARM_T32_CP_OFF_IMM
;
6536 inst
.reloc
.type
= BFD_RELOC_ARM_CP_OFF_IMM
;
6542 /* inst.reloc.exp describes an "=expr" load pseudo-operation.
6543 Determine whether it can be performed with a move instruction; if
6544 it can, convert inst.instruction to that move instruction and
6545 return 1; if it can't, convert inst.instruction to a literal-pool
6546 load and return 0. If this is not a valid thing to do in the
6547 current context, set inst.error and return 1.
6549 inst.operands[i] describes the destination register. */
6552 move_or_literal_pool (int i
, bfd_boolean thumb_p
, bfd_boolean mode_3
)
6557 tbit
= (inst
.instruction
> 0xffff) ? THUMB2_LOAD_BIT
: THUMB_LOAD_BIT
;
6561 if ((inst
.instruction
& tbit
) == 0)
6563 inst
.error
= _("invalid pseudo operation");
6566 if (inst
.reloc
.exp
.X_op
!= O_constant
&& inst
.reloc
.exp
.X_op
!= O_symbol
)
6568 inst
.error
= _("constant expression expected");
6571 if (inst
.reloc
.exp
.X_op
== O_constant
)
6575 if (!unified_syntax
&& (inst
.reloc
.exp
.X_add_number
& ~0xFF) == 0)
6577 /* This can be done with a mov(1) instruction. */
6578 inst
.instruction
= T_OPCODE_MOV_I8
| (inst
.operands
[i
].reg
<< 8);
6579 inst
.instruction
|= inst
.reloc
.exp
.X_add_number
;
6585 int value
= encode_arm_immediate (inst
.reloc
.exp
.X_add_number
);
6588 /* This can be done with a mov instruction. */
6589 inst
.instruction
&= LITERAL_MASK
;
6590 inst
.instruction
|= INST_IMMEDIATE
| (OPCODE_MOV
<< DATA_OP_SHIFT
);
6591 inst
.instruction
|= value
& 0xfff;
6595 value
= encode_arm_immediate (~inst
.reloc
.exp
.X_add_number
);
6598 /* This can be done with a mvn instruction. */
6599 inst
.instruction
&= LITERAL_MASK
;
6600 inst
.instruction
|= INST_IMMEDIATE
| (OPCODE_MVN
<< DATA_OP_SHIFT
);
6601 inst
.instruction
|= value
& 0xfff;
6607 if (add_to_lit_pool () == FAIL
)
6609 inst
.error
= _("literal pool insertion failed");
6612 inst
.operands
[1].reg
= REG_PC
;
6613 inst
.operands
[1].isreg
= 1;
6614 inst
.operands
[1].preind
= 1;
6615 inst
.reloc
.pc_rel
= 1;
6616 inst
.reloc
.type
= (thumb_p
6617 ? BFD_RELOC_ARM_THUMB_OFFSET
6619 ? BFD_RELOC_ARM_HWLITERAL
6620 : BFD_RELOC_ARM_LITERAL
));
6624 /* Functions for instruction encoding, sorted by sub-architecture.
6625 First some generics; their names are taken from the conventional
6626 bit positions for register arguments in ARM format instructions. */
6636 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
6642 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
6643 inst
.instruction
|= inst
.operands
[1].reg
;
6649 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
6650 inst
.instruction
|= inst
.operands
[1].reg
<< 16;
6656 inst
.instruction
|= inst
.operands
[0].reg
<< 16;
6657 inst
.instruction
|= inst
.operands
[1].reg
<< 12;
6663 unsigned Rn
= inst
.operands
[2].reg
;
6664 /* Enforce restrictions on SWP instruction. */
6665 if ((inst
.instruction
& 0x0fbfffff) == 0x01000090)
6666 constraint (Rn
== inst
.operands
[0].reg
|| Rn
== inst
.operands
[1].reg
,
6667 _("Rn must not overlap other operands"));
6668 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
6669 inst
.instruction
|= inst
.operands
[1].reg
;
6670 inst
.instruction
|= Rn
<< 16;
6676 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
6677 inst
.instruction
|= inst
.operands
[1].reg
<< 16;
6678 inst
.instruction
|= inst
.operands
[2].reg
;
6684 inst
.instruction
|= inst
.operands
[0].reg
;
6685 inst
.instruction
|= inst
.operands
[1].reg
<< 12;
6686 inst
.instruction
|= inst
.operands
[2].reg
<< 16;
6692 inst
.instruction
|= inst
.operands
[0].imm
;
6698 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
6699 encode_arm_cp_address (1, TRUE
, TRUE
, 0);
6702 /* ARM instructions, in alphabetical order by function name (except
6703 that wrapper functions appear immediately after the function they
6706 /* This is a pseudo-op of the form "adr rd, label" to be converted
6707 into a relative address of the form "add rd, pc, #label-.-8". */
6712 inst
.instruction
|= (inst
.operands
[0].reg
<< 12); /* Rd */
6714 /* Frag hacking will turn this into a sub instruction if the offset turns
6715 out to be negative. */
6716 inst
.reloc
.type
= BFD_RELOC_ARM_IMMEDIATE
;
6717 inst
.reloc
.pc_rel
= 1;
6718 inst
.reloc
.exp
.X_add_number
-= 8;
6721 /* This is a pseudo-op of the form "adrl rd, label" to be converted
6722 into a relative address of the form:
6723 add rd, pc, #low(label-.-8)"
6724 add rd, rd, #high(label-.-8)" */
6729 inst
.instruction
|= (inst
.operands
[0].reg
<< 12); /* Rd */
6731 /* Frag hacking will turn this into a sub instruction if the offset turns
6732 out to be negative. */
6733 inst
.reloc
.type
= BFD_RELOC_ARM_ADRL_IMMEDIATE
;
6734 inst
.reloc
.pc_rel
= 1;
6735 inst
.size
= INSN_SIZE
* 2;
6736 inst
.reloc
.exp
.X_add_number
-= 8;
6742 if (!inst
.operands
[1].present
)
6743 inst
.operands
[1].reg
= inst
.operands
[0].reg
;
6744 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
6745 inst
.instruction
|= inst
.operands
[1].reg
<< 16;
6746 encode_arm_shifter_operand (2);
6752 if (inst
.operands
[0].present
)
6754 constraint ((inst
.instruction
& 0xf0) != 0x40
6755 && inst
.operands
[0].imm
!= 0xf,
6756 _("bad barrier type"));
6757 inst
.instruction
|= inst
.operands
[0].imm
;
6760 inst
.instruction
|= 0xf;
6766 unsigned int msb
= inst
.operands
[1].imm
+ inst
.operands
[2].imm
;
6767 constraint (msb
> 32, _("bit-field extends past end of register"));
6768 /* The instruction encoding stores the LSB and MSB,
6769 not the LSB and width. */
6770 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
6771 inst
.instruction
|= inst
.operands
[1].imm
<< 7;
6772 inst
.instruction
|= (msb
- 1) << 16;
6780 /* #0 in second position is alternative syntax for bfc, which is
6781 the same instruction but with REG_PC in the Rm field. */
6782 if (!inst
.operands
[1].isreg
)
6783 inst
.operands
[1].reg
= REG_PC
;
6785 msb
= inst
.operands
[2].imm
+ inst
.operands
[3].imm
;
6786 constraint (msb
> 32, _("bit-field extends past end of register"));
6787 /* The instruction encoding stores the LSB and MSB,
6788 not the LSB and width. */
6789 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
6790 inst
.instruction
|= inst
.operands
[1].reg
;
6791 inst
.instruction
|= inst
.operands
[2].imm
<< 7;
6792 inst
.instruction
|= (msb
- 1) << 16;
6798 constraint (inst
.operands
[2].imm
+ inst
.operands
[3].imm
> 32,
6799 _("bit-field extends past end of register"));
6800 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
6801 inst
.instruction
|= inst
.operands
[1].reg
;
6802 inst
.instruction
|= inst
.operands
[2].imm
<< 7;
6803 inst
.instruction
|= (inst
.operands
[3].imm
- 1) << 16;
6806 /* ARM V5 breakpoint instruction (argument parse)
6807 BKPT <16 bit unsigned immediate>
6808 Instruction is not conditional.
6809 The bit pattern given in insns[] has the COND_ALWAYS condition,
6810 and it is an error if the caller tried to override that. */
6815 /* Top 12 of 16 bits to bits 19:8. */
6816 inst
.instruction
|= (inst
.operands
[0].imm
& 0xfff0) << 4;
6818 /* Bottom 4 of 16 bits to bits 3:0. */
6819 inst
.instruction
|= inst
.operands
[0].imm
& 0xf;
6823 encode_branch (int default_reloc
)
6825 if (inst
.operands
[0].hasreloc
)
6827 constraint (inst
.operands
[0].imm
!= BFD_RELOC_ARM_PLT32
,
6828 _("the only suffix valid here is '(plt)'"));
6829 inst
.reloc
.type
= BFD_RELOC_ARM_PLT32
;
6833 inst
.reloc
.type
= default_reloc
;
6835 inst
.reloc
.pc_rel
= 1;
6842 if (EF_ARM_EABI_VERSION (meabi_flags
) >= EF_ARM_EABI_VER4
)
6843 encode_branch (BFD_RELOC_ARM_PCREL_JUMP
);
6846 encode_branch (BFD_RELOC_ARM_PCREL_BRANCH
);
6853 if (EF_ARM_EABI_VERSION (meabi_flags
) >= EF_ARM_EABI_VER4
)
6855 if (inst
.cond
== COND_ALWAYS
)
6856 encode_branch (BFD_RELOC_ARM_PCREL_CALL
);
6858 encode_branch (BFD_RELOC_ARM_PCREL_JUMP
);
6862 encode_branch (BFD_RELOC_ARM_PCREL_BRANCH
);
6865 /* ARM V5 branch-link-exchange instruction (argument parse)
6866 BLX <target_addr> ie BLX(1)
6867 BLX{<condition>} <Rm> ie BLX(2)
6868 Unfortunately, there are two different opcodes for this mnemonic.
6869 So, the insns[].value is not used, and the code here zaps values
6870 into inst.instruction.
6871 Also, the <target_addr> can be 25 bits, hence has its own reloc. */
6876 if (inst
.operands
[0].isreg
)
6878 /* Arg is a register; the opcode provided by insns[] is correct.
6879 It is not illegal to do "blx pc", just useless. */
6880 if (inst
.operands
[0].reg
== REG_PC
)
6881 as_tsktsk (_("use of r15 in blx in ARM mode is not really useful"));
6883 inst
.instruction
|= inst
.operands
[0].reg
;
6887 /* Arg is an address; this instruction cannot be executed
6888 conditionally, and the opcode must be adjusted.
6889 We retain the BFD_RELOC_ARM_PCREL_BLX till the very end
6890 where we generate out a BFD_RELOC_ARM_PCREL_CALL instead. */
6891 constraint (inst
.cond
!= COND_ALWAYS
, BAD_COND
);
6892 inst
.instruction
= 0xfa000000;
6893 encode_branch (BFD_RELOC_ARM_PCREL_BLX
);
6900 bfd_boolean want_reloc
;
6902 if (inst
.operands
[0].reg
== REG_PC
)
6903 as_tsktsk (_("use of r15 in bx in ARM mode is not really useful"));
6905 inst
.instruction
|= inst
.operands
[0].reg
;
6906 /* Output R_ARM_V4BX relocations if is an EABI object that looks like
6907 it is for ARMv4t or earlier. */
6908 want_reloc
= !ARM_CPU_HAS_FEATURE (selected_cpu
, arm_ext_v5
);
6909 if (object_arch
&& !ARM_CPU_HAS_FEATURE (*object_arch
, arm_ext_v5
))
6913 if (EF_ARM_EABI_VERSION (meabi_flags
) < EF_ARM_EABI_VER4
)
6918 inst
.reloc
.type
= BFD_RELOC_ARM_V4BX
;
6922 /* ARM v5TEJ. Jump to Jazelle code. */
6927 if (inst
.operands
[0].reg
== REG_PC
)
6928 as_tsktsk (_("use of r15 in bxj is not really useful"));
6930 inst
.instruction
|= inst
.operands
[0].reg
;
6933 /* Co-processor data operation:
6934 CDP{cond} <coproc>, <opcode_1>, <CRd>, <CRn>, <CRm>{, <opcode_2>}
6935 CDP2 <coproc>, <opcode_1>, <CRd>, <CRn>, <CRm>{, <opcode_2>} */
6939 inst
.instruction
|= inst
.operands
[0].reg
<< 8;
6940 inst
.instruction
|= inst
.operands
[1].imm
<< 20;
6941 inst
.instruction
|= inst
.operands
[2].reg
<< 12;
6942 inst
.instruction
|= inst
.operands
[3].reg
<< 16;
6943 inst
.instruction
|= inst
.operands
[4].reg
;
6944 inst
.instruction
|= inst
.operands
[5].imm
<< 5;
6950 inst
.instruction
|= inst
.operands
[0].reg
<< 16;
6951 encode_arm_shifter_operand (1);
6954 /* Transfer between coprocessor and ARM registers.
6955 MRC{cond} <coproc>, <opcode_1>, <Rd>, <CRn>, <CRm>{, <opcode_2>}
6960 No special properties. */
6967 Rd
= inst
.operands
[2].reg
;
6970 if (inst
.instruction
== 0xee000010
6971 || inst
.instruction
== 0xfe000010)
6973 reject_bad_reg (Rd
);
6976 constraint (Rd
== REG_SP
, BAD_SP
);
6981 if (inst
.instruction
== 0xe000010)
6982 constraint (Rd
== REG_PC
, BAD_PC
);
6986 inst
.instruction
|= inst
.operands
[0].reg
<< 8;
6987 inst
.instruction
|= inst
.operands
[1].imm
<< 21;
6988 inst
.instruction
|= Rd
<< 12;
6989 inst
.instruction
|= inst
.operands
[3].reg
<< 16;
6990 inst
.instruction
|= inst
.operands
[4].reg
;
6991 inst
.instruction
|= inst
.operands
[5].imm
<< 5;
6994 /* Transfer between coprocessor register and pair of ARM registers.
6995 MCRR{cond} <coproc>, <opcode>, <Rd>, <Rn>, <CRm>.
7000 Two XScale instructions are special cases of these:
7002 MAR{cond} acc0, <RdLo>, <RdHi> == MCRR{cond} p0, #0, <RdLo>, <RdHi>, c0
7003 MRA{cond} acc0, <RdLo>, <RdHi> == MRRC{cond} p0, #0, <RdLo>, <RdHi>, c0
7005 Result unpredictable if Rd or Rn is R15. */
7012 Rd
= inst
.operands
[2].reg
;
7013 Rn
= inst
.operands
[3].reg
;
7017 reject_bad_reg (Rd
);
7018 reject_bad_reg (Rn
);
7022 constraint (Rd
== REG_PC
, BAD_PC
);
7023 constraint (Rn
== REG_PC
, BAD_PC
);
7026 inst
.instruction
|= inst
.operands
[0].reg
<< 8;
7027 inst
.instruction
|= inst
.operands
[1].imm
<< 4;
7028 inst
.instruction
|= Rd
<< 12;
7029 inst
.instruction
|= Rn
<< 16;
7030 inst
.instruction
|= inst
.operands
[4].reg
;
7036 inst
.instruction
|= inst
.operands
[0].imm
<< 6;
7037 if (inst
.operands
[1].present
)
7039 inst
.instruction
|= CPSI_MMOD
;
7040 inst
.instruction
|= inst
.operands
[1].imm
;
7047 inst
.instruction
|= inst
.operands
[0].imm
;
7053 /* There is no IT instruction in ARM mode. We
7054 process it to do the validation as if in
7055 thumb mode, just in case the code gets
7056 assembled for thumb using the unified syntax. */
7061 set_it_insn_type (IT_INSN
);
7062 now_it
.mask
= (inst
.instruction
& 0xf) | 0x10;
7063 now_it
.cc
= inst
.operands
[0].imm
;
7070 int base_reg
= inst
.operands
[0].reg
;
7071 int range
= inst
.operands
[1].imm
;
7073 inst
.instruction
|= base_reg
<< 16;
7074 inst
.instruction
|= range
;
7076 if (inst
.operands
[1].writeback
)
7077 inst
.instruction
|= LDM_TYPE_2_OR_3
;
7079 if (inst
.operands
[0].writeback
)
7081 inst
.instruction
|= WRITE_BACK
;
7082 /* Check for unpredictable uses of writeback. */
7083 if (inst
.instruction
& LOAD_BIT
)
7085 /* Not allowed in LDM type 2. */
7086 if ((inst
.instruction
& LDM_TYPE_2_OR_3
)
7087 && ((range
& (1 << REG_PC
)) == 0))
7088 as_warn (_("writeback of base register is UNPREDICTABLE"));
7089 /* Only allowed if base reg not in list for other types. */
7090 else if (range
& (1 << base_reg
))
7091 as_warn (_("writeback of base register when in register list is UNPREDICTABLE"));
7095 /* Not allowed for type 2. */
7096 if (inst
.instruction
& LDM_TYPE_2_OR_3
)
7097 as_warn (_("writeback of base register is UNPREDICTABLE"));
7098 /* Only allowed if base reg not in list, or first in list. */
7099 else if ((range
& (1 << base_reg
))
7100 && (range
& ((1 << base_reg
) - 1)))
7101 as_warn (_("if writeback register is in list, it must be the lowest reg in the list"));
7106 /* ARMv5TE load-consecutive (argument parse)
7115 constraint (inst
.operands
[0].reg
% 2 != 0,
7116 _("first destination register must be even"));
7117 constraint (inst
.operands
[1].present
7118 && inst
.operands
[1].reg
!= inst
.operands
[0].reg
+ 1,
7119 _("can only load two consecutive registers"));
7120 constraint (inst
.operands
[0].reg
== REG_LR
, _("r14 not allowed here"));
7121 constraint (!inst
.operands
[2].isreg
, _("'[' expected"));
7123 if (!inst
.operands
[1].present
)
7124 inst
.operands
[1].reg
= inst
.operands
[0].reg
+ 1;
7126 if (inst
.instruction
& LOAD_BIT
)
7128 /* encode_arm_addr_mode_3 will diagnose overlap between the base
7129 register and the first register written; we have to diagnose
7130 overlap between the base and the second register written here. */
7132 if (inst
.operands
[2].reg
== inst
.operands
[1].reg
7133 && (inst
.operands
[2].writeback
|| inst
.operands
[2].postind
))
7134 as_warn (_("base register written back, and overlaps "
7135 "second destination register"));
7137 /* For an index-register load, the index register must not overlap the
7138 destination (even if not write-back). */
7139 else if (inst
.operands
[2].immisreg
7140 && ((unsigned) inst
.operands
[2].imm
== inst
.operands
[0].reg
7141 || (unsigned) inst
.operands
[2].imm
== inst
.operands
[1].reg
))
7142 as_warn (_("index register overlaps destination register"));
7145 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
7146 encode_arm_addr_mode_3 (2, /*is_t=*/FALSE
);
7152 constraint (!inst
.operands
[1].isreg
|| !inst
.operands
[1].preind
7153 || inst
.operands
[1].postind
|| inst
.operands
[1].writeback
7154 || inst
.operands
[1].immisreg
|| inst
.operands
[1].shifted
7155 || inst
.operands
[1].negative
7156 /* This can arise if the programmer has written
7158 or if they have mistakenly used a register name as the last
7161 It is very difficult to distinguish between these two cases
7162 because "rX" might actually be a label. ie the register
7163 name has been occluded by a symbol of the same name. So we
7164 just generate a general 'bad addressing mode' type error
7165 message and leave it up to the programmer to discover the
7166 true cause and fix their mistake. */
7167 || (inst
.operands
[1].reg
== REG_PC
),
7170 constraint (inst
.reloc
.exp
.X_op
!= O_constant
7171 || inst
.reloc
.exp
.X_add_number
!= 0,
7172 _("offset must be zero in ARM encoding"));
7174 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
7175 inst
.instruction
|= inst
.operands
[1].reg
<< 16;
7176 inst
.reloc
.type
= BFD_RELOC_UNUSED
;
7182 constraint (inst
.operands
[0].reg
% 2 != 0,
7183 _("even register required"));
7184 constraint (inst
.operands
[1].present
7185 && inst
.operands
[1].reg
!= inst
.operands
[0].reg
+ 1,
7186 _("can only load two consecutive registers"));
7187 /* If op 1 were present and equal to PC, this function wouldn't
7188 have been called in the first place. */
7189 constraint (inst
.operands
[0].reg
== REG_LR
, _("r14 not allowed here"));
7191 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
7192 inst
.instruction
|= inst
.operands
[2].reg
<< 16;
7198 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
7199 if (!inst
.operands
[1].isreg
)
7200 if (move_or_literal_pool (0, /*thumb_p=*/FALSE
, /*mode_3=*/FALSE
))
7202 encode_arm_addr_mode_2 (1, /*is_t=*/FALSE
);
7208 /* ldrt/strt always use post-indexed addressing. Turn [Rn] into [Rn]! and
7210 if (inst
.operands
[1].preind
)
7212 constraint (inst
.reloc
.exp
.X_op
!= O_constant
7213 || inst
.reloc
.exp
.X_add_number
!= 0,
7214 _("this instruction requires a post-indexed address"));
7216 inst
.operands
[1].preind
= 0;
7217 inst
.operands
[1].postind
= 1;
7218 inst
.operands
[1].writeback
= 1;
7220 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
7221 encode_arm_addr_mode_2 (1, /*is_t=*/TRUE
);
7224 /* Halfword and signed-byte load/store operations. */
7229 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
7230 if (!inst
.operands
[1].isreg
)
7231 if (move_or_literal_pool (0, /*thumb_p=*/FALSE
, /*mode_3=*/TRUE
))
7233 encode_arm_addr_mode_3 (1, /*is_t=*/FALSE
);
7239 /* ldrt/strt always use post-indexed addressing. Turn [Rn] into [Rn]! and
7241 if (inst
.operands
[1].preind
)
7243 constraint (inst
.reloc
.exp
.X_op
!= O_constant
7244 || inst
.reloc
.exp
.X_add_number
!= 0,
7245 _("this instruction requires a post-indexed address"));
7247 inst
.operands
[1].preind
= 0;
7248 inst
.operands
[1].postind
= 1;
7249 inst
.operands
[1].writeback
= 1;
7251 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
7252 encode_arm_addr_mode_3 (1, /*is_t=*/TRUE
);
7255 /* Co-processor register load/store.
7256 Format: <LDC|STC>{cond}[L] CP#,CRd,<address> */
7260 inst
.instruction
|= inst
.operands
[0].reg
<< 8;
7261 inst
.instruction
|= inst
.operands
[1].reg
<< 12;
7262 encode_arm_cp_address (2, TRUE
, TRUE
, 0);
7268 /* This restriction does not apply to mls (nor to mla in v6 or later). */
7269 if (inst
.operands
[0].reg
== inst
.operands
[1].reg
7270 && !ARM_CPU_HAS_FEATURE (selected_cpu
, arm_ext_v6
)
7271 && !(inst
.instruction
& 0x00400000))
7272 as_tsktsk (_("Rd and Rm should be different in mla"));
7274 inst
.instruction
|= inst
.operands
[0].reg
<< 16;
7275 inst
.instruction
|= inst
.operands
[1].reg
;
7276 inst
.instruction
|= inst
.operands
[2].reg
<< 8;
7277 inst
.instruction
|= inst
.operands
[3].reg
<< 12;
7283 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
7284 encode_arm_shifter_operand (1);
7287 /* ARM V6T2 16-bit immediate register load: MOV[WT]{cond} Rd, #<imm16>. */
7294 top
= (inst
.instruction
& 0x00400000) != 0;
7295 constraint (top
&& inst
.reloc
.type
== BFD_RELOC_ARM_MOVW
,
7296 _(":lower16: not allowed this instruction"));
7297 constraint (!top
&& inst
.reloc
.type
== BFD_RELOC_ARM_MOVT
,
7298 _(":upper16: not allowed instruction"));
7299 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
7300 if (inst
.reloc
.type
== BFD_RELOC_UNUSED
)
7302 imm
= inst
.reloc
.exp
.X_add_number
;
7303 /* The value is in two pieces: 0:11, 16:19. */
7304 inst
.instruction
|= (imm
& 0x00000fff);
7305 inst
.instruction
|= (imm
& 0x0000f000) << 4;
7309 static void do_vfp_nsyn_opcode (const char *);
7312 do_vfp_nsyn_mrs (void)
7314 if (inst
.operands
[0].isvec
)
7316 if (inst
.operands
[1].reg
!= 1)
7317 first_error (_("operand 1 must be FPSCR"));
7318 memset (&inst
.operands
[0], '\0', sizeof (inst
.operands
[0]));
7319 memset (&inst
.operands
[1], '\0', sizeof (inst
.operands
[1]));
7320 do_vfp_nsyn_opcode ("fmstat");
7322 else if (inst
.operands
[1].isvec
)
7323 do_vfp_nsyn_opcode ("fmrx");
7331 do_vfp_nsyn_msr (void)
7333 if (inst
.operands
[0].isvec
)
7334 do_vfp_nsyn_opcode ("fmxr");
7344 if (do_vfp_nsyn_mrs () == SUCCESS
)
7347 /* mrs only accepts CPSR/SPSR/CPSR_all/SPSR_all. */
7348 constraint ((inst
.operands
[1].imm
& (PSR_c
|PSR_x
|PSR_s
|PSR_f
))
7350 _("'CPSR' or 'SPSR' expected"));
7351 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
7352 inst
.instruction
|= (inst
.operands
[1].imm
& SPSR_BIT
);
7355 /* Two possible forms:
7356 "{C|S}PSR_<field>, Rm",
7357 "{C|S}PSR_f, #expression". */
7362 if (do_vfp_nsyn_msr () == SUCCESS
)
7365 inst
.instruction
|= inst
.operands
[0].imm
;
7366 if (inst
.operands
[1].isreg
)
7367 inst
.instruction
|= inst
.operands
[1].reg
;
7370 inst
.instruction
|= INST_IMMEDIATE
;
7371 inst
.reloc
.type
= BFD_RELOC_ARM_IMMEDIATE
;
7372 inst
.reloc
.pc_rel
= 0;
7379 if (!inst
.operands
[2].present
)
7380 inst
.operands
[2].reg
= inst
.operands
[0].reg
;
7381 inst
.instruction
|= inst
.operands
[0].reg
<< 16;
7382 inst
.instruction
|= inst
.operands
[1].reg
;
7383 inst
.instruction
|= inst
.operands
[2].reg
<< 8;
7385 if (inst
.operands
[0].reg
== inst
.operands
[1].reg
7386 && !ARM_CPU_HAS_FEATURE (selected_cpu
, arm_ext_v6
))
7387 as_tsktsk (_("Rd and Rm should be different in mul"));
7390 /* Long Multiply Parser
7391 UMULL RdLo, RdHi, Rm, Rs
7392 SMULL RdLo, RdHi, Rm, Rs
7393 UMLAL RdLo, RdHi, Rm, Rs
7394 SMLAL RdLo, RdHi, Rm, Rs. */
7399 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
7400 inst
.instruction
|= inst
.operands
[1].reg
<< 16;
7401 inst
.instruction
|= inst
.operands
[2].reg
;
7402 inst
.instruction
|= inst
.operands
[3].reg
<< 8;
7404 /* rdhi and rdlo must be different. */
7405 if (inst
.operands
[0].reg
== inst
.operands
[1].reg
)
7406 as_tsktsk (_("rdhi and rdlo must be different"));
7408 /* rdhi, rdlo and rm must all be different before armv6. */
7409 if ((inst
.operands
[0].reg
== inst
.operands
[2].reg
7410 || inst
.operands
[1].reg
== inst
.operands
[2].reg
)
7411 && !ARM_CPU_HAS_FEATURE (selected_cpu
, arm_ext_v6
))
7412 as_tsktsk (_("rdhi, rdlo and rm must all be different"));
7418 if (inst
.operands
[0].present
7419 || ARM_CPU_HAS_FEATURE (selected_cpu
, arm_ext_v6k
))
7421 /* Architectural NOP hints are CPSR sets with no bits selected. */
7422 inst
.instruction
&= 0xf0000000;
7423 inst
.instruction
|= 0x0320f000;
7424 if (inst
.operands
[0].present
)
7425 inst
.instruction
|= inst
.operands
[0].imm
;
7429 /* ARM V6 Pack Halfword Bottom Top instruction (argument parse).
7430 PKHBT {<cond>} <Rd>, <Rn>, <Rm> {, LSL #<shift_imm>}
7431 Condition defaults to COND_ALWAYS.
7432 Error if Rd, Rn or Rm are R15. */
7437 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
7438 inst
.instruction
|= inst
.operands
[1].reg
<< 16;
7439 inst
.instruction
|= inst
.operands
[2].reg
;
7440 if (inst
.operands
[3].present
)
7441 encode_arm_shift (3);
7444 /* ARM V6 PKHTB (Argument Parse). */
7449 if (!inst
.operands
[3].present
)
7451 /* If the shift specifier is omitted, turn the instruction
7452 into pkhbt rd, rm, rn. */
7453 inst
.instruction
&= 0xfff00010;
7454 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
7455 inst
.instruction
|= inst
.operands
[1].reg
;
7456 inst
.instruction
|= inst
.operands
[2].reg
<< 16;
7460 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
7461 inst
.instruction
|= inst
.operands
[1].reg
<< 16;
7462 inst
.instruction
|= inst
.operands
[2].reg
;
7463 encode_arm_shift (3);
7467 /* ARMv5TE: Preload-Cache
7471 Syntactically, like LDR with B=1, W=0, L=1. */
7476 constraint (!inst
.operands
[0].isreg
,
7477 _("'[' expected after PLD mnemonic"));
7478 constraint (inst
.operands
[0].postind
,
7479 _("post-indexed expression used in preload instruction"));
7480 constraint (inst
.operands
[0].writeback
,
7481 _("writeback used in preload instruction"));
7482 constraint (!inst
.operands
[0].preind
,
7483 _("unindexed addressing used in preload instruction"));
7484 encode_arm_addr_mode_2 (0, /*is_t=*/FALSE
);
7487 /* ARMv7: PLI <addr_mode> */
7491 constraint (!inst
.operands
[0].isreg
,
7492 _("'[' expected after PLI mnemonic"));
7493 constraint (inst
.operands
[0].postind
,
7494 _("post-indexed expression used in preload instruction"));
7495 constraint (inst
.operands
[0].writeback
,
7496 _("writeback used in preload instruction"));
7497 constraint (!inst
.operands
[0].preind
,
7498 _("unindexed addressing used in preload instruction"));
7499 encode_arm_addr_mode_2 (0, /*is_t=*/FALSE
);
7500 inst
.instruction
&= ~PRE_INDEX
;
7506 inst
.operands
[1] = inst
.operands
[0];
7507 memset (&inst
.operands
[0], 0, sizeof inst
.operands
[0]);
7508 inst
.operands
[0].isreg
= 1;
7509 inst
.operands
[0].writeback
= 1;
7510 inst
.operands
[0].reg
= REG_SP
;
7514 /* ARM V6 RFE (Return from Exception) loads the PC and CPSR from the
7515 word at the specified address and the following word
7517 Unconditionally executed.
7518 Error if Rn is R15. */
7523 inst
.instruction
|= inst
.operands
[0].reg
<< 16;
7524 if (inst
.operands
[0].writeback
)
7525 inst
.instruction
|= WRITE_BACK
;
7528 /* ARM V6 ssat (argument parse). */
7533 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
7534 inst
.instruction
|= (inst
.operands
[1].imm
- 1) << 16;
7535 inst
.instruction
|= inst
.operands
[2].reg
;
7537 if (inst
.operands
[3].present
)
7538 encode_arm_shift (3);
7541 /* ARM V6 usat (argument parse). */
7546 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
7547 inst
.instruction
|= inst
.operands
[1].imm
<< 16;
7548 inst
.instruction
|= inst
.operands
[2].reg
;
7550 if (inst
.operands
[3].present
)
7551 encode_arm_shift (3);
7554 /* ARM V6 ssat16 (argument parse). */
7559 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
7560 inst
.instruction
|= ((inst
.operands
[1].imm
- 1) << 16);
7561 inst
.instruction
|= inst
.operands
[2].reg
;
7567 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
7568 inst
.instruction
|= inst
.operands
[1].imm
<< 16;
7569 inst
.instruction
|= inst
.operands
[2].reg
;
7572 /* ARM V6 SETEND (argument parse). Sets the E bit in the CPSR while
7573 preserving the other bits.
7575 setend <endian_specifier>, where <endian_specifier> is either
7581 if (inst
.operands
[0].imm
)
7582 inst
.instruction
|= 0x200;
7588 unsigned int Rm
= (inst
.operands
[1].present
7589 ? inst
.operands
[1].reg
7590 : inst
.operands
[0].reg
);
7592 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
7593 inst
.instruction
|= Rm
;
7594 if (inst
.operands
[2].isreg
) /* Rd, {Rm,} Rs */
7596 inst
.instruction
|= inst
.operands
[2].reg
<< 8;
7597 inst
.instruction
|= SHIFT_BY_REG
;
7600 inst
.reloc
.type
= BFD_RELOC_ARM_SHIFT_IMM
;
7606 inst
.reloc
.type
= BFD_RELOC_ARM_SMC
;
7607 inst
.reloc
.pc_rel
= 0;
7613 inst
.reloc
.type
= BFD_RELOC_ARM_SWI
;
7614 inst
.reloc
.pc_rel
= 0;
7617 /* ARM V5E (El Segundo) signed-multiply-accumulate (argument parse)
7618 SMLAxy{cond} Rd,Rm,Rs,Rn
7619 SMLAWy{cond} Rd,Rm,Rs,Rn
7620 Error if any register is R15. */
7625 inst
.instruction
|= inst
.operands
[0].reg
<< 16;
7626 inst
.instruction
|= inst
.operands
[1].reg
;
7627 inst
.instruction
|= inst
.operands
[2].reg
<< 8;
7628 inst
.instruction
|= inst
.operands
[3].reg
<< 12;
7631 /* ARM V5E (El Segundo) signed-multiply-accumulate-long (argument parse)
7632 SMLALxy{cond} Rdlo,Rdhi,Rm,Rs
7633 Error if any register is R15.
7634 Warning if Rdlo == Rdhi. */
7639 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
7640 inst
.instruction
|= inst
.operands
[1].reg
<< 16;
7641 inst
.instruction
|= inst
.operands
[2].reg
;
7642 inst
.instruction
|= inst
.operands
[3].reg
<< 8;
7644 if (inst
.operands
[0].reg
== inst
.operands
[1].reg
)
7645 as_tsktsk (_("rdhi and rdlo must be different"));
7648 /* ARM V5E (El Segundo) signed-multiply (argument parse)
7649 SMULxy{cond} Rd,Rm,Rs
7650 Error if any register is R15. */
7655 inst
.instruction
|= inst
.operands
[0].reg
<< 16;
7656 inst
.instruction
|= inst
.operands
[1].reg
;
7657 inst
.instruction
|= inst
.operands
[2].reg
<< 8;
7660 /* ARM V6 srs (argument parse). The variable fields in the encoding are
7661 the same for both ARM and Thumb-2. */
7668 if (inst
.operands
[0].present
)
7670 reg
= inst
.operands
[0].reg
;
7671 constraint (reg
!= REG_SP
, _("SRS base register must be r13"));
7676 inst
.instruction
|= reg
<< 16;
7677 inst
.instruction
|= inst
.operands
[1].imm
;
7678 if (inst
.operands
[0].writeback
|| inst
.operands
[1].writeback
)
7679 inst
.instruction
|= WRITE_BACK
;
7682 /* ARM V6 strex (argument parse). */
7687 constraint (!inst
.operands
[2].isreg
|| !inst
.operands
[2].preind
7688 || inst
.operands
[2].postind
|| inst
.operands
[2].writeback
7689 || inst
.operands
[2].immisreg
|| inst
.operands
[2].shifted
7690 || inst
.operands
[2].negative
7691 /* See comment in do_ldrex(). */
7692 || (inst
.operands
[2].reg
== REG_PC
),
7695 constraint (inst
.operands
[0].reg
== inst
.operands
[1].reg
7696 || inst
.operands
[0].reg
== inst
.operands
[2].reg
, BAD_OVERLAP
);
7698 constraint (inst
.reloc
.exp
.X_op
!= O_constant
7699 || inst
.reloc
.exp
.X_add_number
!= 0,
7700 _("offset must be zero in ARM encoding"));
7702 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
7703 inst
.instruction
|= inst
.operands
[1].reg
;
7704 inst
.instruction
|= inst
.operands
[2].reg
<< 16;
7705 inst
.reloc
.type
= BFD_RELOC_UNUSED
;
7711 constraint (inst
.operands
[1].reg
% 2 != 0,
7712 _("even register required"));
7713 constraint (inst
.operands
[2].present
7714 && inst
.operands
[2].reg
!= inst
.operands
[1].reg
+ 1,
7715 _("can only store two consecutive registers"));
7716 /* If op 2 were present and equal to PC, this function wouldn't
7717 have been called in the first place. */
7718 constraint (inst
.operands
[1].reg
== REG_LR
, _("r14 not allowed here"));
7720 constraint (inst
.operands
[0].reg
== inst
.operands
[1].reg
7721 || inst
.operands
[0].reg
== inst
.operands
[1].reg
+ 1
7722 || inst
.operands
[0].reg
== inst
.operands
[3].reg
,
7725 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
7726 inst
.instruction
|= inst
.operands
[1].reg
;
7727 inst
.instruction
|= inst
.operands
[3].reg
<< 16;
7730 /* ARM V6 SXTAH extracts a 16-bit value from a register, sign
7731 extends it to 32-bits, and adds the result to a value in another
7732 register. You can specify a rotation by 0, 8, 16, or 24 bits
7733 before extracting the 16-bit value.
7734 SXTAH{<cond>} <Rd>, <Rn>, <Rm>{, <rotation>}
7735 Condition defaults to COND_ALWAYS.
7736 Error if any register uses R15. */
7741 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
7742 inst
.instruction
|= inst
.operands
[1].reg
<< 16;
7743 inst
.instruction
|= inst
.operands
[2].reg
;
7744 inst
.instruction
|= inst
.operands
[3].imm
<< 10;
7749 SXTH {<cond>} <Rd>, <Rm>{, <rotation>}
7750 Condition defaults to COND_ALWAYS.
7751 Error if any register uses R15. */
7756 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
7757 inst
.instruction
|= inst
.operands
[1].reg
;
7758 inst
.instruction
|= inst
.operands
[2].imm
<< 10;
7761 /* VFP instructions. In a logical order: SP variant first, monad
7762 before dyad, arithmetic then move then load/store. */
7765 do_vfp_sp_monadic (void)
7767 encode_arm_vfp_reg (inst
.operands
[0].reg
, VFP_REG_Sd
);
7768 encode_arm_vfp_reg (inst
.operands
[1].reg
, VFP_REG_Sm
);
7772 do_vfp_sp_dyadic (void)
7774 encode_arm_vfp_reg (inst
.operands
[0].reg
, VFP_REG_Sd
);
7775 encode_arm_vfp_reg (inst
.operands
[1].reg
, VFP_REG_Sn
);
7776 encode_arm_vfp_reg (inst
.operands
[2].reg
, VFP_REG_Sm
);
7780 do_vfp_sp_compare_z (void)
7782 encode_arm_vfp_reg (inst
.operands
[0].reg
, VFP_REG_Sd
);
7786 do_vfp_dp_sp_cvt (void)
7788 encode_arm_vfp_reg (inst
.operands
[0].reg
, VFP_REG_Dd
);
7789 encode_arm_vfp_reg (inst
.operands
[1].reg
, VFP_REG_Sm
);
7793 do_vfp_sp_dp_cvt (void)
7795 encode_arm_vfp_reg (inst
.operands
[0].reg
, VFP_REG_Sd
);
7796 encode_arm_vfp_reg (inst
.operands
[1].reg
, VFP_REG_Dm
);
7800 do_vfp_reg_from_sp (void)
7802 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
7803 encode_arm_vfp_reg (inst
.operands
[1].reg
, VFP_REG_Sn
);
7807 do_vfp_reg2_from_sp2 (void)
7809 constraint (inst
.operands
[2].imm
!= 2,
7810 _("only two consecutive VFP SP registers allowed here"));
7811 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
7812 inst
.instruction
|= inst
.operands
[1].reg
<< 16;
7813 encode_arm_vfp_reg (inst
.operands
[2].reg
, VFP_REG_Sm
);
7817 do_vfp_sp_from_reg (void)
7819 encode_arm_vfp_reg (inst
.operands
[0].reg
, VFP_REG_Sn
);
7820 inst
.instruction
|= inst
.operands
[1].reg
<< 12;
7824 do_vfp_sp2_from_reg2 (void)
7826 constraint (inst
.operands
[0].imm
!= 2,
7827 _("only two consecutive VFP SP registers allowed here"));
7828 encode_arm_vfp_reg (inst
.operands
[0].reg
, VFP_REG_Sm
);
7829 inst
.instruction
|= inst
.operands
[1].reg
<< 12;
7830 inst
.instruction
|= inst
.operands
[2].reg
<< 16;
7834 do_vfp_sp_ldst (void)
7836 encode_arm_vfp_reg (inst
.operands
[0].reg
, VFP_REG_Sd
);
7837 encode_arm_cp_address (1, FALSE
, TRUE
, 0);
7841 do_vfp_dp_ldst (void)
7843 encode_arm_vfp_reg (inst
.operands
[0].reg
, VFP_REG_Dd
);
7844 encode_arm_cp_address (1, FALSE
, TRUE
, 0);
7849 vfp_sp_ldstm (enum vfp_ldstm_type ldstm_type
)
7851 if (inst
.operands
[0].writeback
)
7852 inst
.instruction
|= WRITE_BACK
;
7854 constraint (ldstm_type
!= VFP_LDSTMIA
,
7855 _("this addressing mode requires base-register writeback"));
7856 inst
.instruction
|= inst
.operands
[0].reg
<< 16;
7857 encode_arm_vfp_reg (inst
.operands
[1].reg
, VFP_REG_Sd
);
7858 inst
.instruction
|= inst
.operands
[1].imm
;
7862 vfp_dp_ldstm (enum vfp_ldstm_type ldstm_type
)
7866 if (inst
.operands
[0].writeback
)
7867 inst
.instruction
|= WRITE_BACK
;
7869 constraint (ldstm_type
!= VFP_LDSTMIA
&& ldstm_type
!= VFP_LDSTMIAX
,
7870 _("this addressing mode requires base-register writeback"));
7872 inst
.instruction
|= inst
.operands
[0].reg
<< 16;
7873 encode_arm_vfp_reg (inst
.operands
[1].reg
, VFP_REG_Dd
);
7875 count
= inst
.operands
[1].imm
<< 1;
7876 if (ldstm_type
== VFP_LDSTMIAX
|| ldstm_type
== VFP_LDSTMDBX
)
7879 inst
.instruction
|= count
;
7883 do_vfp_sp_ldstmia (void)
7885 vfp_sp_ldstm (VFP_LDSTMIA
);
7889 do_vfp_sp_ldstmdb (void)
7891 vfp_sp_ldstm (VFP_LDSTMDB
);
7895 do_vfp_dp_ldstmia (void)
7897 vfp_dp_ldstm (VFP_LDSTMIA
);
7901 do_vfp_dp_ldstmdb (void)
7903 vfp_dp_ldstm (VFP_LDSTMDB
);
7907 do_vfp_xp_ldstmia (void)
7909 vfp_dp_ldstm (VFP_LDSTMIAX
);
7913 do_vfp_xp_ldstmdb (void)
7915 vfp_dp_ldstm (VFP_LDSTMDBX
);
7919 do_vfp_dp_rd_rm (void)
7921 encode_arm_vfp_reg (inst
.operands
[0].reg
, VFP_REG_Dd
);
7922 encode_arm_vfp_reg (inst
.operands
[1].reg
, VFP_REG_Dm
);
7926 do_vfp_dp_rn_rd (void)
7928 encode_arm_vfp_reg (inst
.operands
[0].reg
, VFP_REG_Dn
);
7929 encode_arm_vfp_reg (inst
.operands
[1].reg
, VFP_REG_Dd
);
7933 do_vfp_dp_rd_rn (void)
7935 encode_arm_vfp_reg (inst
.operands
[0].reg
, VFP_REG_Dd
);
7936 encode_arm_vfp_reg (inst
.operands
[1].reg
, VFP_REG_Dn
);
7940 do_vfp_dp_rd_rn_rm (void)
7942 encode_arm_vfp_reg (inst
.operands
[0].reg
, VFP_REG_Dd
);
7943 encode_arm_vfp_reg (inst
.operands
[1].reg
, VFP_REG_Dn
);
7944 encode_arm_vfp_reg (inst
.operands
[2].reg
, VFP_REG_Dm
);
7950 encode_arm_vfp_reg (inst
.operands
[0].reg
, VFP_REG_Dd
);
7954 do_vfp_dp_rm_rd_rn (void)
7956 encode_arm_vfp_reg (inst
.operands
[0].reg
, VFP_REG_Dm
);
7957 encode_arm_vfp_reg (inst
.operands
[1].reg
, VFP_REG_Dd
);
7958 encode_arm_vfp_reg (inst
.operands
[2].reg
, VFP_REG_Dn
);
7961 /* VFPv3 instructions. */
7963 do_vfp_sp_const (void)
7965 encode_arm_vfp_reg (inst
.operands
[0].reg
, VFP_REG_Sd
);
7966 inst
.instruction
|= (inst
.operands
[1].imm
& 0xf0) << 12;
7967 inst
.instruction
|= (inst
.operands
[1].imm
& 0x0f);
7971 do_vfp_dp_const (void)
7973 encode_arm_vfp_reg (inst
.operands
[0].reg
, VFP_REG_Dd
);
7974 inst
.instruction
|= (inst
.operands
[1].imm
& 0xf0) << 12;
7975 inst
.instruction
|= (inst
.operands
[1].imm
& 0x0f);
7979 vfp_conv (int srcsize
)
7981 unsigned immbits
= srcsize
- inst
.operands
[1].imm
;
7982 inst
.instruction
|= (immbits
& 1) << 5;
7983 inst
.instruction
|= (immbits
>> 1);
7987 do_vfp_sp_conv_16 (void)
7989 encode_arm_vfp_reg (inst
.operands
[0].reg
, VFP_REG_Sd
);
7994 do_vfp_dp_conv_16 (void)
7996 encode_arm_vfp_reg (inst
.operands
[0].reg
, VFP_REG_Dd
);
8001 do_vfp_sp_conv_32 (void)
8003 encode_arm_vfp_reg (inst
.operands
[0].reg
, VFP_REG_Sd
);
8008 do_vfp_dp_conv_32 (void)
8010 encode_arm_vfp_reg (inst
.operands
[0].reg
, VFP_REG_Dd
);
8014 /* FPA instructions. Also in a logical order. */
8019 inst
.instruction
|= inst
.operands
[0].reg
<< 16;
8020 inst
.instruction
|= inst
.operands
[1].reg
;
8024 do_fpa_ldmstm (void)
8026 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
8027 switch (inst
.operands
[1].imm
)
8029 case 1: inst
.instruction
|= CP_T_X
; break;
8030 case 2: inst
.instruction
|= CP_T_Y
; break;
8031 case 3: inst
.instruction
|= CP_T_Y
| CP_T_X
; break;
8036 if (inst
.instruction
& (PRE_INDEX
| INDEX_UP
))
8038 /* The instruction specified "ea" or "fd", so we can only accept
8039 [Rn]{!}. The instruction does not really support stacking or
8040 unstacking, so we have to emulate these by setting appropriate
8041 bits and offsets. */
8042 constraint (inst
.reloc
.exp
.X_op
!= O_constant
8043 || inst
.reloc
.exp
.X_add_number
!= 0,
8044 _("this instruction does not support indexing"));
8046 if ((inst
.instruction
& PRE_INDEX
) || inst
.operands
[2].writeback
)
8047 inst
.reloc
.exp
.X_add_number
= 12 * inst
.operands
[1].imm
;
8049 if (!(inst
.instruction
& INDEX_UP
))
8050 inst
.reloc
.exp
.X_add_number
= -inst
.reloc
.exp
.X_add_number
;
8052 if (!(inst
.instruction
& PRE_INDEX
) && inst
.operands
[2].writeback
)
8054 inst
.operands
[2].preind
= 0;
8055 inst
.operands
[2].postind
= 1;
8059 encode_arm_cp_address (2, TRUE
, TRUE
, 0);
8062 /* iWMMXt instructions: strictly in alphabetical order. */
8065 do_iwmmxt_tandorc (void)
8067 constraint (inst
.operands
[0].reg
!= REG_PC
, _("only r15 allowed here"));
8071 do_iwmmxt_textrc (void)
8073 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
8074 inst
.instruction
|= inst
.operands
[1].imm
;
8078 do_iwmmxt_textrm (void)
8080 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
8081 inst
.instruction
|= inst
.operands
[1].reg
<< 16;
8082 inst
.instruction
|= inst
.operands
[2].imm
;
8086 do_iwmmxt_tinsr (void)
8088 inst
.instruction
|= inst
.operands
[0].reg
<< 16;
8089 inst
.instruction
|= inst
.operands
[1].reg
<< 12;
8090 inst
.instruction
|= inst
.operands
[2].imm
;
8094 do_iwmmxt_tmia (void)
8096 inst
.instruction
|= inst
.operands
[0].reg
<< 5;
8097 inst
.instruction
|= inst
.operands
[1].reg
;
8098 inst
.instruction
|= inst
.operands
[2].reg
<< 12;
8102 do_iwmmxt_waligni (void)
8104 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
8105 inst
.instruction
|= inst
.operands
[1].reg
<< 16;
8106 inst
.instruction
|= inst
.operands
[2].reg
;
8107 inst
.instruction
|= inst
.operands
[3].imm
<< 20;
8111 do_iwmmxt_wmerge (void)
8113 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
8114 inst
.instruction
|= inst
.operands
[1].reg
<< 16;
8115 inst
.instruction
|= inst
.operands
[2].reg
;
8116 inst
.instruction
|= inst
.operands
[3].imm
<< 21;
8120 do_iwmmxt_wmov (void)
8122 /* WMOV rD, rN is an alias for WOR rD, rN, rN. */
8123 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
8124 inst
.instruction
|= inst
.operands
[1].reg
<< 16;
8125 inst
.instruction
|= inst
.operands
[1].reg
;
8129 do_iwmmxt_wldstbh (void)
8132 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
8134 reloc
= BFD_RELOC_ARM_T32_CP_OFF_IMM_S2
;
8136 reloc
= BFD_RELOC_ARM_CP_OFF_IMM_S2
;
8137 encode_arm_cp_address (1, TRUE
, FALSE
, reloc
);
8141 do_iwmmxt_wldstw (void)
8143 /* RIWR_RIWC clears .isreg for a control register. */
8144 if (!inst
.operands
[0].isreg
)
8146 constraint (inst
.cond
!= COND_ALWAYS
, BAD_COND
);
8147 inst
.instruction
|= 0xf0000000;
8150 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
8151 encode_arm_cp_address (1, TRUE
, TRUE
, 0);
8155 do_iwmmxt_wldstd (void)
8157 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
8158 if (ARM_CPU_HAS_FEATURE (cpu_variant
, arm_cext_iwmmxt2
)
8159 && inst
.operands
[1].immisreg
)
8161 inst
.instruction
&= ~0x1a000ff;
8162 inst
.instruction
|= (0xf << 28);
8163 if (inst
.operands
[1].preind
)
8164 inst
.instruction
|= PRE_INDEX
;
8165 if (!inst
.operands
[1].negative
)
8166 inst
.instruction
|= INDEX_UP
;
8167 if (inst
.operands
[1].writeback
)
8168 inst
.instruction
|= WRITE_BACK
;
8169 inst
.instruction
|= inst
.operands
[1].reg
<< 16;
8170 inst
.instruction
|= inst
.reloc
.exp
.X_add_number
<< 4;
8171 inst
.instruction
|= inst
.operands
[1].imm
;
8174 encode_arm_cp_address (1, TRUE
, FALSE
, 0);
8178 do_iwmmxt_wshufh (void)
8180 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
8181 inst
.instruction
|= inst
.operands
[1].reg
<< 16;
8182 inst
.instruction
|= ((inst
.operands
[2].imm
& 0xf0) << 16);
8183 inst
.instruction
|= (inst
.operands
[2].imm
& 0x0f);
8187 do_iwmmxt_wzero (void)
8189 /* WZERO reg is an alias for WANDN reg, reg, reg. */
8190 inst
.instruction
|= inst
.operands
[0].reg
;
8191 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
8192 inst
.instruction
|= inst
.operands
[0].reg
<< 16;
8196 do_iwmmxt_wrwrwr_or_imm5 (void)
8198 if (inst
.operands
[2].isreg
)
8201 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant
, arm_cext_iwmmxt2
),
8202 _("immediate operand requires iWMMXt2"));
8204 if (inst
.operands
[2].imm
== 0)
8206 switch ((inst
.instruction
>> 20) & 0xf)
8212 /* w...h wrd, wrn, #0 -> wrorh wrd, wrn, #16. */
8213 inst
.operands
[2].imm
= 16;
8214 inst
.instruction
= (inst
.instruction
& 0xff0fffff) | (0x7 << 20);
8220 /* w...w wrd, wrn, #0 -> wrorw wrd, wrn, #32. */
8221 inst
.operands
[2].imm
= 32;
8222 inst
.instruction
= (inst
.instruction
& 0xff0fffff) | (0xb << 20);
8229 /* w...d wrd, wrn, #0 -> wor wrd, wrn, wrn. */
8231 wrn
= (inst
.instruction
>> 16) & 0xf;
8232 inst
.instruction
&= 0xff0fff0f;
8233 inst
.instruction
|= wrn
;
8234 /* Bail out here; the instruction is now assembled. */
8239 /* Map 32 -> 0, etc. */
8240 inst
.operands
[2].imm
&= 0x1f;
8241 inst
.instruction
|= (0xf << 28) | ((inst
.operands
[2].imm
& 0x10) << 4) | (inst
.operands
[2].imm
& 0xf);
8245 /* Cirrus Maverick instructions. Simple 2-, 3-, and 4-register
8246 operations first, then control, shift, and load/store. */
8248 /* Insns like "foo X,Y,Z". */
8251 do_mav_triple (void)
8253 inst
.instruction
|= inst
.operands
[0].reg
<< 16;
8254 inst
.instruction
|= inst
.operands
[1].reg
;
8255 inst
.instruction
|= inst
.operands
[2].reg
<< 12;
8258 /* Insns like "foo W,X,Y,Z".
8259 where W=MVAX[0:3] and X,Y,Z=MVFX[0:15]. */
8264 inst
.instruction
|= inst
.operands
[0].reg
<< 5;
8265 inst
.instruction
|= inst
.operands
[1].reg
<< 12;
8266 inst
.instruction
|= inst
.operands
[2].reg
<< 16;
8267 inst
.instruction
|= inst
.operands
[3].reg
;
8270 /* cfmvsc32<cond> DSPSC,MVDX[15:0]. */
8274 inst
.instruction
|= inst
.operands
[1].reg
<< 12;
8277 /* Maverick shift immediate instructions.
8278 cfsh32<cond> MVFX[15:0],MVFX[15:0],Shift[6:0].
8279 cfsh64<cond> MVDX[15:0],MVDX[15:0],Shift[6:0]. */
8284 int imm
= inst
.operands
[2].imm
;
8286 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
8287 inst
.instruction
|= inst
.operands
[1].reg
<< 16;
8289 /* Bits 0-3 of the insn should have bits 0-3 of the immediate.
8290 Bits 5-7 of the insn should have bits 4-6 of the immediate.
8291 Bit 4 should be 0. */
8292 imm
= (imm
& 0xf) | ((imm
& 0x70) << 1);
8294 inst
.instruction
|= imm
;
8297 /* XScale instructions. Also sorted arithmetic before move. */
8299 /* Xscale multiply-accumulate (argument parse)
8302 MIAxycc acc0,Rm,Rs. */
8307 inst
.instruction
|= inst
.operands
[1].reg
;
8308 inst
.instruction
|= inst
.operands
[2].reg
<< 12;
8311 /* Xscale move-accumulator-register (argument parse)
8313 MARcc acc0,RdLo,RdHi. */
8318 inst
.instruction
|= inst
.operands
[1].reg
<< 12;
8319 inst
.instruction
|= inst
.operands
[2].reg
<< 16;
8322 /* Xscale move-register-accumulator (argument parse)
8324 MRAcc RdLo,RdHi,acc0. */
8329 constraint (inst
.operands
[0].reg
== inst
.operands
[1].reg
, BAD_OVERLAP
);
8330 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
8331 inst
.instruction
|= inst
.operands
[1].reg
<< 16;
8334 /* Encoding functions relevant only to Thumb. */
8336 /* inst.operands[i] is a shifted-register operand; encode
8337 it into inst.instruction in the format used by Thumb32. */
8340 encode_thumb32_shifted_operand (int i
)
8342 unsigned int value
= inst
.reloc
.exp
.X_add_number
;
8343 unsigned int shift
= inst
.operands
[i
].shift_kind
;
8345 constraint (inst
.operands
[i
].immisreg
,
8346 _("shift by register not allowed in thumb mode"));
8347 inst
.instruction
|= inst
.operands
[i
].reg
;
8348 if (shift
== SHIFT_RRX
)
8349 inst
.instruction
|= SHIFT_ROR
<< 4;
8352 constraint (inst
.reloc
.exp
.X_op
!= O_constant
,
8353 _("expression too complex"));
8355 constraint (value
> 32
8356 || (value
== 32 && (shift
== SHIFT_LSL
8357 || shift
== SHIFT_ROR
)),
8358 _("shift expression is too large"));
8362 else if (value
== 32)
8365 inst
.instruction
|= shift
<< 4;
8366 inst
.instruction
|= (value
& 0x1c) << 10;
8367 inst
.instruction
|= (value
& 0x03) << 6;
8372 /* inst.operands[i] was set up by parse_address. Encode it into a
8373 Thumb32 format load or store instruction. Reject forms that cannot
8374 be used with such instructions. If is_t is true, reject forms that
8375 cannot be used with a T instruction; if is_d is true, reject forms
8376 that cannot be used with a D instruction. */
8379 encode_thumb32_addr_mode (int i
, bfd_boolean is_t
, bfd_boolean is_d
)
8381 bfd_boolean is_pc
= (inst
.operands
[i
].reg
== REG_PC
);
8383 constraint (!inst
.operands
[i
].isreg
,
8384 _("Instruction does not support =N addresses"));
8386 inst
.instruction
|= inst
.operands
[i
].reg
<< 16;
8387 if (inst
.operands
[i
].immisreg
)
8389 constraint (is_pc
, _("cannot use register index with PC-relative addressing"));
8390 constraint (is_t
|| is_d
, _("cannot use register index with this instruction"));
8391 constraint (inst
.operands
[i
].negative
,
8392 _("Thumb does not support negative register indexing"));
8393 constraint (inst
.operands
[i
].postind
,
8394 _("Thumb does not support register post-indexing"));
8395 constraint (inst
.operands
[i
].writeback
,
8396 _("Thumb does not support register indexing with writeback"));
8397 constraint (inst
.operands
[i
].shifted
&& inst
.operands
[i
].shift_kind
!= SHIFT_LSL
,
8398 _("Thumb supports only LSL in shifted register indexing"));
8400 inst
.instruction
|= inst
.operands
[i
].imm
;
8401 if (inst
.operands
[i
].shifted
)
8403 constraint (inst
.reloc
.exp
.X_op
!= O_constant
,
8404 _("expression too complex"));
8405 constraint (inst
.reloc
.exp
.X_add_number
< 0
8406 || inst
.reloc
.exp
.X_add_number
> 3,
8407 _("shift out of range"));
8408 inst
.instruction
|= inst
.reloc
.exp
.X_add_number
<< 4;
8410 inst
.reloc
.type
= BFD_RELOC_UNUSED
;
8412 else if (inst
.operands
[i
].preind
)
8414 constraint (is_pc
&& inst
.operands
[i
].writeback
,
8415 _("cannot use writeback with PC-relative addressing"));
8416 constraint (is_t
&& inst
.operands
[i
].writeback
,
8417 _("cannot use writeback with this instruction"));
8421 inst
.instruction
|= 0x01000000;
8422 if (inst
.operands
[i
].writeback
)
8423 inst
.instruction
|= 0x00200000;
8427 inst
.instruction
|= 0x00000c00;
8428 if (inst
.operands
[i
].writeback
)
8429 inst
.instruction
|= 0x00000100;
8431 inst
.reloc
.type
= BFD_RELOC_ARM_T32_OFFSET_IMM
;
8433 else if (inst
.operands
[i
].postind
)
8435 gas_assert (inst
.operands
[i
].writeback
);
8436 constraint (is_pc
, _("cannot use post-indexing with PC-relative addressing"));
8437 constraint (is_t
, _("cannot use post-indexing with this instruction"));
8440 inst
.instruction
|= 0x00200000;
8442 inst
.instruction
|= 0x00000900;
8443 inst
.reloc
.type
= BFD_RELOC_ARM_T32_OFFSET_IMM
;
8445 else /* unindexed - only for coprocessor */
8446 inst
.error
= _("instruction does not accept unindexed addressing");
8449 /* Table of Thumb instructions which exist in both 16- and 32-bit
8450 encodings (the latter only in post-V6T2 cores). The index is the
8451 value used in the insns table below. When there is more than one
8452 possible 16-bit encoding for the instruction, this table always
8454 Also contains several pseudo-instructions used during relaxation. */
8455 #define T16_32_TAB \
8456 X(adc, 4140, eb400000), \
8457 X(adcs, 4140, eb500000), \
8458 X(add, 1c00, eb000000), \
8459 X(adds, 1c00, eb100000), \
8460 X(addi, 0000, f1000000), \
8461 X(addis, 0000, f1100000), \
8462 X(add_pc,000f, f20f0000), \
8463 X(add_sp,000d, f10d0000), \
8464 X(adr, 000f, f20f0000), \
8465 X(and, 4000, ea000000), \
8466 X(ands, 4000, ea100000), \
8467 X(asr, 1000, fa40f000), \
8468 X(asrs, 1000, fa50f000), \
8469 X(b, e000, f000b000), \
8470 X(bcond, d000, f0008000), \
8471 X(bic, 4380, ea200000), \
8472 X(bics, 4380, ea300000), \
8473 X(cmn, 42c0, eb100f00), \
8474 X(cmp, 2800, ebb00f00), \
8475 X(cpsie, b660, f3af8400), \
8476 X(cpsid, b670, f3af8600), \
8477 X(cpy, 4600, ea4f0000), \
8478 X(dec_sp,80dd, f1ad0d00), \
8479 X(eor, 4040, ea800000), \
8480 X(eors, 4040, ea900000), \
8481 X(inc_sp,00dd, f10d0d00), \
8482 X(ldmia, c800, e8900000), \
8483 X(ldr, 6800, f8500000), \
8484 X(ldrb, 7800, f8100000), \
8485 X(ldrh, 8800, f8300000), \
8486 X(ldrsb, 5600, f9100000), \
8487 X(ldrsh, 5e00, f9300000), \
8488 X(ldr_pc,4800, f85f0000), \
8489 X(ldr_pc2,4800, f85f0000), \
8490 X(ldr_sp,9800, f85d0000), \
8491 X(lsl, 0000, fa00f000), \
8492 X(lsls, 0000, fa10f000), \
8493 X(lsr, 0800, fa20f000), \
8494 X(lsrs, 0800, fa30f000), \
8495 X(mov, 2000, ea4f0000), \
8496 X(movs, 2000, ea5f0000), \
8497 X(mul, 4340, fb00f000), \
8498 X(muls, 4340, ffffffff), /* no 32b muls */ \
8499 X(mvn, 43c0, ea6f0000), \
8500 X(mvns, 43c0, ea7f0000), \
8501 X(neg, 4240, f1c00000), /* rsb #0 */ \
8502 X(negs, 4240, f1d00000), /* rsbs #0 */ \
8503 X(orr, 4300, ea400000), \
8504 X(orrs, 4300, ea500000), \
8505 X(pop, bc00, e8bd0000), /* ldmia sp!,... */ \
8506 X(push, b400, e92d0000), /* stmdb sp!,... */ \
8507 X(rev, ba00, fa90f080), \
8508 X(rev16, ba40, fa90f090), \
8509 X(revsh, bac0, fa90f0b0), \
8510 X(ror, 41c0, fa60f000), \
8511 X(rors, 41c0, fa70f000), \
8512 X(sbc, 4180, eb600000), \
8513 X(sbcs, 4180, eb700000), \
8514 X(stmia, c000, e8800000), \
8515 X(str, 6000, f8400000), \
8516 X(strb, 7000, f8000000), \
8517 X(strh, 8000, f8200000), \
8518 X(str_sp,9000, f84d0000), \
8519 X(sub, 1e00, eba00000), \
8520 X(subs, 1e00, ebb00000), \
8521 X(subi, 8000, f1a00000), \
8522 X(subis, 8000, f1b00000), \
8523 X(sxtb, b240, fa4ff080), \
8524 X(sxth, b200, fa0ff080), \
8525 X(tst, 4200, ea100f00), \
8526 X(uxtb, b2c0, fa5ff080), \
8527 X(uxth, b280, fa1ff080), \
8528 X(nop, bf00, f3af8000), \
8529 X(yield, bf10, f3af8001), \
8530 X(wfe, bf20, f3af8002), \
8531 X(wfi, bf30, f3af8003), \
8532 X(sev, bf40, f3af8004),
8534 /* To catch errors in encoding functions, the codes are all offset by
8535 0xF800, putting them in one of the 32-bit prefix ranges, ergo undefined
8536 as 16-bit instructions. */
8537 #define X(a,b,c) T_MNEM_##a
8538 enum t16_32_codes
{ T16_32_OFFSET
= 0xF7FF, T16_32_TAB
};
8541 #define X(a,b,c) 0x##b
8542 static const unsigned short thumb_op16
[] = { T16_32_TAB
};
8543 #define THUMB_OP16(n) (thumb_op16[(n) - (T16_32_OFFSET + 1)])
8546 #define X(a,b,c) 0x##c
8547 static const unsigned int thumb_op32
[] = { T16_32_TAB
};
8548 #define THUMB_OP32(n) (thumb_op32[(n) - (T16_32_OFFSET + 1)])
8549 #define THUMB_SETS_FLAGS(n) (THUMB_OP32 (n) & 0x00100000)
8553 /* Thumb instruction encoders, in alphabetical order. */
8557 do_t_add_sub_w (void)
8561 Rd
= inst
.operands
[0].reg
;
8562 Rn
= inst
.operands
[1].reg
;
8564 /* If Rn is REG_PC, this is ADR; if Rn is REG_SP, then this is the
8565 SP-{plus,minute}-immediate form of the instruction. */
8566 reject_bad_reg (Rd
);
8568 inst
.instruction
|= (Rn
<< 16) | (Rd
<< 8);
8569 inst
.reloc
.type
= BFD_RELOC_ARM_T32_IMM12
;
8572 /* Parse an add or subtract instruction. We get here with inst.instruction
8573 equalling any of THUMB_OPCODE_add, adds, sub, or subs. */
8580 Rd
= inst
.operands
[0].reg
;
8581 Rs
= (inst
.operands
[1].present
8582 ? inst
.operands
[1].reg
/* Rd, Rs, foo */
8583 : inst
.operands
[0].reg
); /* Rd, foo -> Rd, Rd, foo */
8586 set_it_insn_type_last ();
8594 flags
= (inst
.instruction
== T_MNEM_adds
8595 || inst
.instruction
== T_MNEM_subs
);
8597 narrow
= !in_it_block ();
8599 narrow
= in_it_block ();
8600 if (!inst
.operands
[2].isreg
)
8604 constraint (Rd
== REG_SP
&& Rs
!= REG_SP
, BAD_SP
);
8606 add
= (inst
.instruction
== T_MNEM_add
8607 || inst
.instruction
== T_MNEM_adds
);
8609 if (inst
.size_req
!= 4)
8611 /* Attempt to use a narrow opcode, with relaxation if
8613 if (Rd
== REG_SP
&& Rs
== REG_SP
&& !flags
)
8614 opcode
= add
? T_MNEM_inc_sp
: T_MNEM_dec_sp
;
8615 else if (Rd
<= 7 && Rs
== REG_SP
&& add
&& !flags
)
8616 opcode
= T_MNEM_add_sp
;
8617 else if (Rd
<= 7 && Rs
== REG_PC
&& add
&& !flags
)
8618 opcode
= T_MNEM_add_pc
;
8619 else if (Rd
<= 7 && Rs
<= 7 && narrow
)
8622 opcode
= add
? T_MNEM_addis
: T_MNEM_subis
;
8624 opcode
= add
? T_MNEM_addi
: T_MNEM_subi
;
8628 inst
.instruction
= THUMB_OP16(opcode
);
8629 inst
.instruction
|= (Rd
<< 4) | Rs
;
8630 inst
.reloc
.type
= BFD_RELOC_ARM_THUMB_ADD
;
8631 if (inst
.size_req
!= 2)
8632 inst
.relax
= opcode
;
8635 constraint (inst
.size_req
== 2, BAD_HIREG
);
8637 if (inst
.size_req
== 4
8638 || (inst
.size_req
!= 2 && !opcode
))
8642 constraint (add
, BAD_PC
);
8643 constraint (Rs
!= REG_LR
|| inst
.instruction
!= T_MNEM_subs
,
8644 _("only SUBS PC, LR, #const allowed"));
8645 constraint (inst
.reloc
.exp
.X_op
!= O_constant
,
8646 _("expression too complex"));
8647 constraint (inst
.reloc
.exp
.X_add_number
< 0
8648 || inst
.reloc
.exp
.X_add_number
> 0xff,
8649 _("immediate value out of range"));
8650 inst
.instruction
= T2_SUBS_PC_LR
8651 | inst
.reloc
.exp
.X_add_number
;
8652 inst
.reloc
.type
= BFD_RELOC_UNUSED
;
8655 else if (Rs
== REG_PC
)
8657 /* Always use addw/subw. */
8658 inst
.instruction
= add
? 0xf20f0000 : 0xf2af0000;
8659 inst
.reloc
.type
= BFD_RELOC_ARM_T32_IMM12
;
8663 inst
.instruction
= THUMB_OP32 (inst
.instruction
);
8664 inst
.instruction
= (inst
.instruction
& 0xe1ffffff)
8667 inst
.reloc
.type
= BFD_RELOC_ARM_T32_IMMEDIATE
;
8669 inst
.reloc
.type
= BFD_RELOC_ARM_T32_ADD_IMM
;
8671 inst
.instruction
|= Rd
<< 8;
8672 inst
.instruction
|= Rs
<< 16;
8677 Rn
= inst
.operands
[2].reg
;
8678 /* See if we can do this with a 16-bit instruction. */
8679 if (!inst
.operands
[2].shifted
&& inst
.size_req
!= 4)
8681 if (Rd
> 7 || Rs
> 7 || Rn
> 7)
8686 inst
.instruction
= ((inst
.instruction
== T_MNEM_adds
8687 || inst
.instruction
== T_MNEM_add
)
8690 inst
.instruction
|= Rd
| (Rs
<< 3) | (Rn
<< 6);
8694 if (inst
.instruction
== T_MNEM_add
&& (Rd
== Rs
|| Rd
== Rn
))
8696 /* Thumb-1 cores (except v6-M) require at least one high
8697 register in a narrow non flag setting add. */
8698 if (Rd
> 7 || Rn
> 7
8699 || ARM_CPU_HAS_FEATURE (selected_cpu
, arm_ext_v6t2
)
8700 || ARM_CPU_HAS_FEATURE (selected_cpu
, arm_ext_msr
))
8707 inst
.instruction
= T_OPCODE_ADD_HI
;
8708 inst
.instruction
|= (Rd
& 8) << 4;
8709 inst
.instruction
|= (Rd
& 7);
8710 inst
.instruction
|= Rn
<< 3;
8716 constraint (Rd
== REG_PC
, BAD_PC
);
8717 constraint (Rd
== REG_SP
&& Rs
!= REG_SP
, BAD_SP
);
8718 constraint (Rs
== REG_PC
, BAD_PC
);
8719 reject_bad_reg (Rn
);
8721 /* If we get here, it can't be done in 16 bits. */
8722 constraint (inst
.operands
[2].shifted
&& inst
.operands
[2].immisreg
,
8723 _("shift must be constant"));
8724 inst
.instruction
= THUMB_OP32 (inst
.instruction
);
8725 inst
.instruction
|= Rd
<< 8;
8726 inst
.instruction
|= Rs
<< 16;
8727 encode_thumb32_shifted_operand (2);
8732 constraint (inst
.instruction
== T_MNEM_adds
8733 || inst
.instruction
== T_MNEM_subs
,
8736 if (!inst
.operands
[2].isreg
) /* Rd, Rs, #imm */
8738 constraint ((Rd
> 7 && (Rd
!= REG_SP
|| Rs
!= REG_SP
))
8739 || (Rs
> 7 && Rs
!= REG_SP
&& Rs
!= REG_PC
),
8742 inst
.instruction
= (inst
.instruction
== T_MNEM_add
8744 inst
.instruction
|= (Rd
<< 4) | Rs
;
8745 inst
.reloc
.type
= BFD_RELOC_ARM_THUMB_ADD
;
8749 Rn
= inst
.operands
[2].reg
;
8750 constraint (inst
.operands
[2].shifted
, _("unshifted register required"));
8752 /* We now have Rd, Rs, and Rn set to registers. */
8753 if (Rd
> 7 || Rs
> 7 || Rn
> 7)
8755 /* Can't do this for SUB. */
8756 constraint (inst
.instruction
== T_MNEM_sub
, BAD_HIREG
);
8757 inst
.instruction
= T_OPCODE_ADD_HI
;
8758 inst
.instruction
|= (Rd
& 8) << 4;
8759 inst
.instruction
|= (Rd
& 7);
8761 inst
.instruction
|= Rn
<< 3;
8763 inst
.instruction
|= Rs
<< 3;
8765 constraint (1, _("dest must overlap one source register"));
8769 inst
.instruction
= (inst
.instruction
== T_MNEM_add
8770 ? T_OPCODE_ADD_R3
: T_OPCODE_SUB_R3
);
8771 inst
.instruction
|= Rd
| (Rs
<< 3) | (Rn
<< 6);
8781 Rd
= inst
.operands
[0].reg
;
8782 reject_bad_reg (Rd
);
8784 if (unified_syntax
&& inst
.size_req
== 0 && Rd
<= 7)
8786 /* Defer to section relaxation. */
8787 inst
.relax
= inst
.instruction
;
8788 inst
.instruction
= THUMB_OP16 (inst
.instruction
);
8789 inst
.instruction
|= Rd
<< 4;
8791 else if (unified_syntax
&& inst
.size_req
!= 2)
8793 /* Generate a 32-bit opcode. */
8794 inst
.instruction
= THUMB_OP32 (inst
.instruction
);
8795 inst
.instruction
|= Rd
<< 8;
8796 inst
.reloc
.type
= BFD_RELOC_ARM_T32_ADD_PC12
;
8797 inst
.reloc
.pc_rel
= 1;
8801 /* Generate a 16-bit opcode. */
8802 inst
.instruction
= THUMB_OP16 (inst
.instruction
);
8803 inst
.reloc
.type
= BFD_RELOC_ARM_THUMB_ADD
;
8804 inst
.reloc
.exp
.X_add_number
-= 4; /* PC relative adjust. */
8805 inst
.reloc
.pc_rel
= 1;
8807 inst
.instruction
|= Rd
<< 4;
8811 /* Arithmetic instructions for which there is just one 16-bit
8812 instruction encoding, and it allows only two low registers.
8813 For maximal compatibility with ARM syntax, we allow three register
8814 operands even when Thumb-32 instructions are not available, as long
8815 as the first two are identical. For instance, both "sbc r0,r1" and
8816 "sbc r0,r0,r1" are allowed. */
8822 Rd
= inst
.operands
[0].reg
;
8823 Rs
= (inst
.operands
[1].present
8824 ? inst
.operands
[1].reg
/* Rd, Rs, foo */
8825 : inst
.operands
[0].reg
); /* Rd, foo -> Rd, Rd, foo */
8826 Rn
= inst
.operands
[2].reg
;
8828 reject_bad_reg (Rd
);
8829 reject_bad_reg (Rs
);
8830 if (inst
.operands
[2].isreg
)
8831 reject_bad_reg (Rn
);
8835 if (!inst
.operands
[2].isreg
)
8837 /* For an immediate, we always generate a 32-bit opcode;
8838 section relaxation will shrink it later if possible. */
8839 inst
.instruction
= THUMB_OP32 (inst
.instruction
);
8840 inst
.instruction
= (inst
.instruction
& 0xe1ffffff) | 0x10000000;
8841 inst
.instruction
|= Rd
<< 8;
8842 inst
.instruction
|= Rs
<< 16;
8843 inst
.reloc
.type
= BFD_RELOC_ARM_T32_IMMEDIATE
;
8849 /* See if we can do this with a 16-bit instruction. */
8850 if (THUMB_SETS_FLAGS (inst
.instruction
))
8851 narrow
= !in_it_block ();
8853 narrow
= in_it_block ();
8855 if (Rd
> 7 || Rn
> 7 || Rs
> 7)
8857 if (inst
.operands
[2].shifted
)
8859 if (inst
.size_req
== 4)
8865 inst
.instruction
= THUMB_OP16 (inst
.instruction
);
8866 inst
.instruction
|= Rd
;
8867 inst
.instruction
|= Rn
<< 3;
8871 /* If we get here, it can't be done in 16 bits. */
8872 constraint (inst
.operands
[2].shifted
8873 && inst
.operands
[2].immisreg
,
8874 _("shift must be constant"));
8875 inst
.instruction
= THUMB_OP32 (inst
.instruction
);
8876 inst
.instruction
|= Rd
<< 8;
8877 inst
.instruction
|= Rs
<< 16;
8878 encode_thumb32_shifted_operand (2);
8883 /* On its face this is a lie - the instruction does set the
8884 flags. However, the only supported mnemonic in this mode
8886 constraint (THUMB_SETS_FLAGS (inst
.instruction
), BAD_THUMB32
);
8888 constraint (!inst
.operands
[2].isreg
|| inst
.operands
[2].shifted
,
8889 _("unshifted register required"));
8890 constraint (Rd
> 7 || Rs
> 7 || Rn
> 7, BAD_HIREG
);
8891 constraint (Rd
!= Rs
,
8892 _("dest and source1 must be the same register"));
8894 inst
.instruction
= THUMB_OP16 (inst
.instruction
);
8895 inst
.instruction
|= Rd
;
8896 inst
.instruction
|= Rn
<< 3;
8900 /* Similarly, but for instructions where the arithmetic operation is
8901 commutative, so we can allow either of them to be different from
8902 the destination operand in a 16-bit instruction. For instance, all
8903 three of "adc r0,r1", "adc r0,r0,r1", and "adc r0,r1,r0" are
8910 Rd
= inst
.operands
[0].reg
;
8911 Rs
= (inst
.operands
[1].present
8912 ? inst
.operands
[1].reg
/* Rd, Rs, foo */
8913 : inst
.operands
[0].reg
); /* Rd, foo -> Rd, Rd, foo */
8914 Rn
= inst
.operands
[2].reg
;
8916 reject_bad_reg (Rd
);
8917 reject_bad_reg (Rs
);
8918 if (inst
.operands
[2].isreg
)
8919 reject_bad_reg (Rn
);
8923 if (!inst
.operands
[2].isreg
)
8925 /* For an immediate, we always generate a 32-bit opcode;
8926 section relaxation will shrink it later if possible. */
8927 inst
.instruction
= THUMB_OP32 (inst
.instruction
);
8928 inst
.instruction
= (inst
.instruction
& 0xe1ffffff) | 0x10000000;
8929 inst
.instruction
|= Rd
<< 8;
8930 inst
.instruction
|= Rs
<< 16;
8931 inst
.reloc
.type
= BFD_RELOC_ARM_T32_IMMEDIATE
;
8937 /* See if we can do this with a 16-bit instruction. */
8938 if (THUMB_SETS_FLAGS (inst
.instruction
))
8939 narrow
= !in_it_block ();
8941 narrow
= in_it_block ();
8943 if (Rd
> 7 || Rn
> 7 || Rs
> 7)
8945 if (inst
.operands
[2].shifted
)
8947 if (inst
.size_req
== 4)
8954 inst
.instruction
= THUMB_OP16 (inst
.instruction
);
8955 inst
.instruction
|= Rd
;
8956 inst
.instruction
|= Rn
<< 3;
8961 inst
.instruction
= THUMB_OP16 (inst
.instruction
);
8962 inst
.instruction
|= Rd
;
8963 inst
.instruction
|= Rs
<< 3;
8968 /* If we get here, it can't be done in 16 bits. */
8969 constraint (inst
.operands
[2].shifted
8970 && inst
.operands
[2].immisreg
,
8971 _("shift must be constant"));
8972 inst
.instruction
= THUMB_OP32 (inst
.instruction
);
8973 inst
.instruction
|= Rd
<< 8;
8974 inst
.instruction
|= Rs
<< 16;
8975 encode_thumb32_shifted_operand (2);
8980 /* On its face this is a lie - the instruction does set the
8981 flags. However, the only supported mnemonic in this mode
8983 constraint (THUMB_SETS_FLAGS (inst
.instruction
), BAD_THUMB32
);
8985 constraint (!inst
.operands
[2].isreg
|| inst
.operands
[2].shifted
,
8986 _("unshifted register required"));
8987 constraint (Rd
> 7 || Rs
> 7 || Rn
> 7, BAD_HIREG
);
8989 inst
.instruction
= THUMB_OP16 (inst
.instruction
);
8990 inst
.instruction
|= Rd
;
8993 inst
.instruction
|= Rn
<< 3;
8995 inst
.instruction
|= Rs
<< 3;
8997 constraint (1, _("dest must overlap one source register"));
9004 if (inst
.operands
[0].present
)
9006 constraint ((inst
.instruction
& 0xf0) != 0x40
9007 && inst
.operands
[0].imm
!= 0xf,
9008 _("bad barrier type"));
9009 inst
.instruction
|= inst
.operands
[0].imm
;
9012 inst
.instruction
|= 0xf;
9019 unsigned int msb
= inst
.operands
[1].imm
+ inst
.operands
[2].imm
;
9020 constraint (msb
> 32, _("bit-field extends past end of register"));
9021 /* The instruction encoding stores the LSB and MSB,
9022 not the LSB and width. */
9023 Rd
= inst
.operands
[0].reg
;
9024 reject_bad_reg (Rd
);
9025 inst
.instruction
|= Rd
<< 8;
9026 inst
.instruction
|= (inst
.operands
[1].imm
& 0x1c) << 10;
9027 inst
.instruction
|= (inst
.operands
[1].imm
& 0x03) << 6;
9028 inst
.instruction
|= msb
- 1;
9037 Rd
= inst
.operands
[0].reg
;
9038 reject_bad_reg (Rd
);
9040 /* #0 in second position is alternative syntax for bfc, which is
9041 the same instruction but with REG_PC in the Rm field. */
9042 if (!inst
.operands
[1].isreg
)
9046 Rn
= inst
.operands
[1].reg
;
9047 reject_bad_reg (Rn
);
9050 msb
= inst
.operands
[2].imm
+ inst
.operands
[3].imm
;
9051 constraint (msb
> 32, _("bit-field extends past end of register"));
9052 /* The instruction encoding stores the LSB and MSB,
9053 not the LSB and width. */
9054 inst
.instruction
|= Rd
<< 8;
9055 inst
.instruction
|= Rn
<< 16;
9056 inst
.instruction
|= (inst
.operands
[2].imm
& 0x1c) << 10;
9057 inst
.instruction
|= (inst
.operands
[2].imm
& 0x03) << 6;
9058 inst
.instruction
|= msb
- 1;
9066 Rd
= inst
.operands
[0].reg
;
9067 Rn
= inst
.operands
[1].reg
;
9069 reject_bad_reg (Rd
);
9070 reject_bad_reg (Rn
);
9072 constraint (inst
.operands
[2].imm
+ inst
.operands
[3].imm
> 32,
9073 _("bit-field extends past end of register"));
9074 inst
.instruction
|= Rd
<< 8;
9075 inst
.instruction
|= Rn
<< 16;
9076 inst
.instruction
|= (inst
.operands
[2].imm
& 0x1c) << 10;
9077 inst
.instruction
|= (inst
.operands
[2].imm
& 0x03) << 6;
9078 inst
.instruction
|= inst
.operands
[3].imm
- 1;
9081 /* ARM V5 Thumb BLX (argument parse)
9082 BLX <target_addr> which is BLX(1)
9083 BLX <Rm> which is BLX(2)
9084 Unfortunately, there are two different opcodes for this mnemonic.
9085 So, the insns[].value is not used, and the code here zaps values
9086 into inst.instruction.
9088 ??? How to take advantage of the additional two bits of displacement
9089 available in Thumb32 mode? Need new relocation? */
9094 set_it_insn_type_last ();
9096 if (inst
.operands
[0].isreg
)
9098 constraint (inst
.operands
[0].reg
== REG_PC
, BAD_PC
);
9099 /* We have a register, so this is BLX(2). */
9100 inst
.instruction
|= inst
.operands
[0].reg
<< 3;
9104 /* No register. This must be BLX(1). */
9105 inst
.instruction
= 0xf000e800;
9106 inst
.reloc
.type
= BFD_RELOC_THUMB_PCREL_BLX
;
9107 inst
.reloc
.pc_rel
= 1;
9118 set_it_insn_type (IF_INSIDE_IT_LAST_INSN
);
9122 /* Conditional branches inside IT blocks are encoded as unconditional
9129 if (cond
!= COND_ALWAYS
)
9130 opcode
= T_MNEM_bcond
;
9132 opcode
= inst
.instruction
;
9134 if (unified_syntax
&& inst
.size_req
== 4)
9136 inst
.instruction
= THUMB_OP32(opcode
);
9137 if (cond
== COND_ALWAYS
)
9138 inst
.reloc
.type
= BFD_RELOC_THUMB_PCREL_BRANCH25
;
9141 gas_assert (cond
!= 0xF);
9142 inst
.instruction
|= cond
<< 22;
9143 inst
.reloc
.type
= BFD_RELOC_THUMB_PCREL_BRANCH20
;
9148 inst
.instruction
= THUMB_OP16(opcode
);
9149 if (cond
== COND_ALWAYS
)
9150 inst
.reloc
.type
= BFD_RELOC_THUMB_PCREL_BRANCH12
;
9153 inst
.instruction
|= cond
<< 8;
9154 inst
.reloc
.type
= BFD_RELOC_THUMB_PCREL_BRANCH9
;
9156 /* Allow section relaxation. */
9157 if (unified_syntax
&& inst
.size_req
!= 2)
9158 inst
.relax
= opcode
;
9161 inst
.reloc
.pc_rel
= 1;
9167 constraint (inst
.cond
!= COND_ALWAYS
,
9168 _("instruction is always unconditional"));
9169 if (inst
.operands
[0].present
)
9171 constraint (inst
.operands
[0].imm
> 255,
9172 _("immediate value out of range"));
9173 inst
.instruction
|= inst
.operands
[0].imm
;
9174 set_it_insn_type (NEUTRAL_IT_INSN
);
9179 do_t_branch23 (void)
9181 set_it_insn_type_last ();
9182 inst
.reloc
.type
= BFD_RELOC_THUMB_PCREL_BRANCH23
;
9183 inst
.reloc
.pc_rel
= 1;
9185 #if defined(OBJ_COFF)
9186 /* If the destination of the branch is a defined symbol which does not have
9187 the THUMB_FUNC attribute, then we must be calling a function which has
9188 the (interfacearm) attribute. We look for the Thumb entry point to that
9189 function and change the branch to refer to that function instead. */
9190 if ( inst
.reloc
.exp
.X_op
== O_symbol
9191 && inst
.reloc
.exp
.X_add_symbol
!= NULL
9192 && S_IS_DEFINED (inst
.reloc
.exp
.X_add_symbol
)
9193 && ! THUMB_IS_FUNC (inst
.reloc
.exp
.X_add_symbol
))
9194 inst
.reloc
.exp
.X_add_symbol
=
9195 find_real_start (inst
.reloc
.exp
.X_add_symbol
);
9202 set_it_insn_type_last ();
9203 inst
.instruction
|= inst
.operands
[0].reg
<< 3;
9204 /* ??? FIXME: Should add a hacky reloc here if reg is REG_PC. The reloc
9205 should cause the alignment to be checked once it is known. This is
9206 because BX PC only works if the instruction is word aligned. */
9214 set_it_insn_type_last ();
9215 Rm
= inst
.operands
[0].reg
;
9216 reject_bad_reg (Rm
);
9217 inst
.instruction
|= Rm
<< 16;
9226 Rd
= inst
.operands
[0].reg
;
9227 Rm
= inst
.operands
[1].reg
;
9229 reject_bad_reg (Rd
);
9230 reject_bad_reg (Rm
);
9232 inst
.instruction
|= Rd
<< 8;
9233 inst
.instruction
|= Rm
<< 16;
9234 inst
.instruction
|= Rm
;
9240 set_it_insn_type (OUTSIDE_IT_INSN
);
9241 inst
.instruction
|= inst
.operands
[0].imm
;
9247 set_it_insn_type (OUTSIDE_IT_INSN
);
9249 && (inst
.operands
[1].present
|| inst
.size_req
== 4)
9250 && ARM_CPU_HAS_FEATURE (cpu_variant
, arm_ext_v6_notm
))
9252 unsigned int imod
= (inst
.instruction
& 0x0030) >> 4;
9253 inst
.instruction
= 0xf3af8000;
9254 inst
.instruction
|= imod
<< 9;
9255 inst
.instruction
|= inst
.operands
[0].imm
<< 5;
9256 if (inst
.operands
[1].present
)
9257 inst
.instruction
|= 0x100 | inst
.operands
[1].imm
;
9261 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant
, arm_ext_v1
)
9262 && (inst
.operands
[0].imm
& 4),
9263 _("selected processor does not support 'A' form "
9264 "of this instruction"));
9265 constraint (inst
.operands
[1].present
|| inst
.size_req
== 4,
9266 _("Thumb does not support the 2-argument "
9267 "form of this instruction"));
9268 inst
.instruction
|= inst
.operands
[0].imm
;
9272 /* THUMB CPY instruction (argument parse). */
9277 if (inst
.size_req
== 4)
9279 inst
.instruction
= THUMB_OP32 (T_MNEM_mov
);
9280 inst
.instruction
|= inst
.operands
[0].reg
<< 8;
9281 inst
.instruction
|= inst
.operands
[1].reg
;
9285 inst
.instruction
|= (inst
.operands
[0].reg
& 0x8) << 4;
9286 inst
.instruction
|= (inst
.operands
[0].reg
& 0x7);
9287 inst
.instruction
|= inst
.operands
[1].reg
<< 3;
9294 set_it_insn_type (OUTSIDE_IT_INSN
);
9295 constraint (inst
.operands
[0].reg
> 7, BAD_HIREG
);
9296 inst
.instruction
|= inst
.operands
[0].reg
;
9297 inst
.reloc
.pc_rel
= 1;
9298 inst
.reloc
.type
= BFD_RELOC_THUMB_PCREL_BRANCH7
;
9304 inst
.instruction
|= inst
.operands
[0].imm
;
9310 unsigned Rd
, Rn
, Rm
;
9312 Rd
= inst
.operands
[0].reg
;
9313 Rn
= (inst
.operands
[1].present
9314 ? inst
.operands
[1].reg
: Rd
);
9315 Rm
= inst
.operands
[2].reg
;
9317 reject_bad_reg (Rd
);
9318 reject_bad_reg (Rn
);
9319 reject_bad_reg (Rm
);
9321 inst
.instruction
|= Rd
<< 8;
9322 inst
.instruction
|= Rn
<< 16;
9323 inst
.instruction
|= Rm
;
9329 if (unified_syntax
&& inst
.size_req
== 4)
9330 inst
.instruction
= THUMB_OP32 (inst
.instruction
);
9332 inst
.instruction
= THUMB_OP16 (inst
.instruction
);
9338 unsigned int cond
= inst
.operands
[0].imm
;
9340 set_it_insn_type (IT_INSN
);
9341 now_it
.mask
= (inst
.instruction
& 0xf) | 0x10;
9344 /* If the condition is a negative condition, invert the mask. */
9345 if ((cond
& 0x1) == 0x0)
9347 unsigned int mask
= inst
.instruction
& 0x000f;
9349 if ((mask
& 0x7) == 0)
9350 /* no conversion needed */;
9351 else if ((mask
& 0x3) == 0)
9353 else if ((mask
& 0x1) == 0)
9358 inst
.instruction
&= 0xfff0;
9359 inst
.instruction
|= mask
;
9362 inst
.instruction
|= cond
<< 4;
9365 /* Helper function used for both push/pop and ldm/stm. */
9367 encode_thumb2_ldmstm (int base
, unsigned mask
, bfd_boolean writeback
)
9371 load
= (inst
.instruction
& (1 << 20)) != 0;
9373 if (mask
& (1 << 13))
9374 inst
.error
= _("SP not allowed in register list");
9377 if (mask
& (1 << 15))
9379 if (mask
& (1 << 14))
9380 inst
.error
= _("LR and PC should not both be in register list");
9382 set_it_insn_type_last ();
9385 if ((mask
& (1 << base
)) != 0
9387 as_warn (_("base register should not be in register list "
9388 "when written back"));
9392 if (mask
& (1 << 15))
9393 inst
.error
= _("PC not allowed in register list");
9395 if (mask
& (1 << base
))
9396 as_warn (_("value stored for r%d is UNPREDICTABLE"), base
);
9399 if ((mask
& (mask
- 1)) == 0)
9401 /* Single register transfers implemented as str/ldr. */
9404 if (inst
.instruction
& (1 << 23))
9405 inst
.instruction
= 0x00000b04; /* ia! -> [base], #4 */
9407 inst
.instruction
= 0x00000d04; /* db! -> [base, #-4]! */
9411 if (inst
.instruction
& (1 << 23))
9412 inst
.instruction
= 0x00800000; /* ia -> [base] */
9414 inst
.instruction
= 0x00000c04; /* db -> [base, #-4] */
9417 inst
.instruction
|= 0xf8400000;
9419 inst
.instruction
|= 0x00100000;
9421 mask
= ffs (mask
) - 1;
9425 inst
.instruction
|= WRITE_BACK
;
9427 inst
.instruction
|= mask
;
9428 inst
.instruction
|= base
<< 16;
9434 /* This really doesn't seem worth it. */
9435 constraint (inst
.reloc
.type
!= BFD_RELOC_UNUSED
,
9436 _("expression too complex"));
9437 constraint (inst
.operands
[1].writeback
,
9438 _("Thumb load/store multiple does not support {reglist}^"));
9446 /* See if we can use a 16-bit instruction. */
9447 if (inst
.instruction
< 0xffff /* not ldmdb/stmdb */
9448 && inst
.size_req
!= 4
9449 && !(inst
.operands
[1].imm
& ~0xff))
9451 mask
= 1 << inst
.operands
[0].reg
;
9453 if (inst
.operands
[0].reg
<= 7
9454 && (inst
.instruction
== T_MNEM_stmia
9455 ? inst
.operands
[0].writeback
9456 : (inst
.operands
[0].writeback
9457 == !(inst
.operands
[1].imm
& mask
))))
9459 if (inst
.instruction
== T_MNEM_stmia
9460 && (inst
.operands
[1].imm
& mask
)
9461 && (inst
.operands
[1].imm
& (mask
- 1)))
9462 as_warn (_("value stored for r%d is UNPREDICTABLE"),
9463 inst
.operands
[0].reg
);
9465 inst
.instruction
= THUMB_OP16 (inst
.instruction
);
9466 inst
.instruction
|= inst
.operands
[0].reg
<< 8;
9467 inst
.instruction
|= inst
.operands
[1].imm
;
9470 else if (inst
.operands
[0] .reg
== REG_SP
9471 && inst
.operands
[0].writeback
)
9473 inst
.instruction
= THUMB_OP16 (inst
.instruction
== T_MNEM_stmia
9474 ? T_MNEM_push
: T_MNEM_pop
);
9475 inst
.instruction
|= inst
.operands
[1].imm
;
9482 if (inst
.instruction
< 0xffff)
9483 inst
.instruction
= THUMB_OP32 (inst
.instruction
);
9485 encode_thumb2_ldmstm (inst
.operands
[0].reg
, inst
.operands
[1].imm
,
9486 inst
.operands
[0].writeback
);
9491 constraint (inst
.operands
[0].reg
> 7
9492 || (inst
.operands
[1].imm
& ~0xff), BAD_HIREG
);
9493 constraint (inst
.instruction
!= T_MNEM_ldmia
9494 && inst
.instruction
!= T_MNEM_stmia
,
9495 _("Thumb-2 instruction only valid in unified syntax"));
9496 if (inst
.instruction
== T_MNEM_stmia
)
9498 if (!inst
.operands
[0].writeback
)
9499 as_warn (_("this instruction will write back the base register"));
9500 if ((inst
.operands
[1].imm
& (1 << inst
.operands
[0].reg
))
9501 && (inst
.operands
[1].imm
& ((1 << inst
.operands
[0].reg
) - 1)))
9502 as_warn (_("value stored for r%d is UNPREDICTABLE"),
9503 inst
.operands
[0].reg
);
9507 if (!inst
.operands
[0].writeback
9508 && !(inst
.operands
[1].imm
& (1 << inst
.operands
[0].reg
)))
9509 as_warn (_("this instruction will write back the base register"));
9510 else if (inst
.operands
[0].writeback
9511 && (inst
.operands
[1].imm
& (1 << inst
.operands
[0].reg
)))
9512 as_warn (_("this instruction will not write back the base register"));
9515 inst
.instruction
= THUMB_OP16 (inst
.instruction
);
9516 inst
.instruction
|= inst
.operands
[0].reg
<< 8;
9517 inst
.instruction
|= inst
.operands
[1].imm
;
9524 constraint (!inst
.operands
[1].isreg
|| !inst
.operands
[1].preind
9525 || inst
.operands
[1].postind
|| inst
.operands
[1].writeback
9526 || inst
.operands
[1].immisreg
|| inst
.operands
[1].shifted
9527 || inst
.operands
[1].negative
,
9530 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
9531 inst
.instruction
|= inst
.operands
[1].reg
<< 16;
9532 inst
.reloc
.type
= BFD_RELOC_ARM_T32_OFFSET_U8
;
9538 if (!inst
.operands
[1].present
)
9540 constraint (inst
.operands
[0].reg
== REG_LR
,
9541 _("r14 not allowed as first register "
9542 "when second register is omitted"));
9543 inst
.operands
[1].reg
= inst
.operands
[0].reg
+ 1;
9545 constraint (inst
.operands
[0].reg
== inst
.operands
[1].reg
,
9548 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
9549 inst
.instruction
|= inst
.operands
[1].reg
<< 8;
9550 inst
.instruction
|= inst
.operands
[2].reg
<< 16;
9556 unsigned long opcode
;
9559 if (inst
.operands
[0].isreg
9560 && !inst
.operands
[0].preind
9561 && inst
.operands
[0].reg
== REG_PC
)
9562 set_it_insn_type_last ();
9564 opcode
= inst
.instruction
;
9567 if (!inst
.operands
[1].isreg
)
9569 if (opcode
<= 0xffff)
9570 inst
.instruction
= THUMB_OP32 (opcode
);
9571 if (move_or_literal_pool (0, /*thumb_p=*/TRUE
, /*mode_3=*/FALSE
))
9574 if (inst
.operands
[1].isreg
9575 && !inst
.operands
[1].writeback
9576 && !inst
.operands
[1].shifted
&& !inst
.operands
[1].postind
9577 && !inst
.operands
[1].negative
&& inst
.operands
[0].reg
<= 7
9579 && inst
.size_req
!= 4)
9581 /* Insn may have a 16-bit form. */
9582 Rn
= inst
.operands
[1].reg
;
9583 if (inst
.operands
[1].immisreg
)
9585 inst
.instruction
= THUMB_OP16 (opcode
);
9587 if (Rn
<= 7 && inst
.operands
[1].imm
<= 7)
9590 else if ((Rn
<= 7 && opcode
!= T_MNEM_ldrsh
9591 && opcode
!= T_MNEM_ldrsb
)
9592 || ((Rn
== REG_PC
|| Rn
== REG_SP
) && opcode
== T_MNEM_ldr
)
9593 || (Rn
== REG_SP
&& opcode
== T_MNEM_str
))
9600 if (inst
.reloc
.pc_rel
)
9601 opcode
= T_MNEM_ldr_pc2
;
9603 opcode
= T_MNEM_ldr_pc
;
9607 if (opcode
== T_MNEM_ldr
)
9608 opcode
= T_MNEM_ldr_sp
;
9610 opcode
= T_MNEM_str_sp
;
9612 inst
.instruction
= inst
.operands
[0].reg
<< 8;
9616 inst
.instruction
= inst
.operands
[0].reg
;
9617 inst
.instruction
|= inst
.operands
[1].reg
<< 3;
9619 inst
.instruction
|= THUMB_OP16 (opcode
);
9620 if (inst
.size_req
== 2)
9621 inst
.reloc
.type
= BFD_RELOC_ARM_THUMB_OFFSET
;
9623 inst
.relax
= opcode
;
9627 /* Definitely a 32-bit variant. */
9628 inst
.instruction
= THUMB_OP32 (opcode
);
9629 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
9630 encode_thumb32_addr_mode (1, /*is_t=*/FALSE
, /*is_d=*/FALSE
);
9634 constraint (inst
.operands
[0].reg
> 7, BAD_HIREG
);
9636 if (inst
.instruction
== T_MNEM_ldrsh
|| inst
.instruction
== T_MNEM_ldrsb
)
9638 /* Only [Rn,Rm] is acceptable. */
9639 constraint (inst
.operands
[1].reg
> 7 || inst
.operands
[1].imm
> 7, BAD_HIREG
);
9640 constraint (!inst
.operands
[1].isreg
|| !inst
.operands
[1].immisreg
9641 || inst
.operands
[1].postind
|| inst
.operands
[1].shifted
9642 || inst
.operands
[1].negative
,
9643 _("Thumb does not support this addressing mode"));
9644 inst
.instruction
= THUMB_OP16 (inst
.instruction
);
9648 inst
.instruction
= THUMB_OP16 (inst
.instruction
);
9649 if (!inst
.operands
[1].isreg
)
9650 if (move_or_literal_pool (0, /*thumb_p=*/TRUE
, /*mode_3=*/FALSE
))
9653 constraint (!inst
.operands
[1].preind
9654 || inst
.operands
[1].shifted
9655 || inst
.operands
[1].writeback
,
9656 _("Thumb does not support this addressing mode"));
9657 if (inst
.operands
[1].reg
== REG_PC
|| inst
.operands
[1].reg
== REG_SP
)
9659 constraint (inst
.instruction
& 0x0600,
9660 _("byte or halfword not valid for base register"));
9661 constraint (inst
.operands
[1].reg
== REG_PC
9662 && !(inst
.instruction
& THUMB_LOAD_BIT
),
9663 _("r15 based store not allowed"));
9664 constraint (inst
.operands
[1].immisreg
,
9665 _("invalid base register for register offset"));
9667 if (inst
.operands
[1].reg
== REG_PC
)
9668 inst
.instruction
= T_OPCODE_LDR_PC
;
9669 else if (inst
.instruction
& THUMB_LOAD_BIT
)
9670 inst
.instruction
= T_OPCODE_LDR_SP
;
9672 inst
.instruction
= T_OPCODE_STR_SP
;
9674 inst
.instruction
|= inst
.operands
[0].reg
<< 8;
9675 inst
.reloc
.type
= BFD_RELOC_ARM_THUMB_OFFSET
;
9679 constraint (inst
.operands
[1].reg
> 7, BAD_HIREG
);
9680 if (!inst
.operands
[1].immisreg
)
9682 /* Immediate offset. */
9683 inst
.instruction
|= inst
.operands
[0].reg
;
9684 inst
.instruction
|= inst
.operands
[1].reg
<< 3;
9685 inst
.reloc
.type
= BFD_RELOC_ARM_THUMB_OFFSET
;
9689 /* Register offset. */
9690 constraint (inst
.operands
[1].imm
> 7, BAD_HIREG
);
9691 constraint (inst
.operands
[1].negative
,
9692 _("Thumb does not support this addressing mode"));
9695 switch (inst
.instruction
)
9697 case T_OPCODE_STR_IW
: inst
.instruction
= T_OPCODE_STR_RW
; break;
9698 case T_OPCODE_STR_IH
: inst
.instruction
= T_OPCODE_STR_RH
; break;
9699 case T_OPCODE_STR_IB
: inst
.instruction
= T_OPCODE_STR_RB
; break;
9700 case T_OPCODE_LDR_IW
: inst
.instruction
= T_OPCODE_LDR_RW
; break;
9701 case T_OPCODE_LDR_IH
: inst
.instruction
= T_OPCODE_LDR_RH
; break;
9702 case T_OPCODE_LDR_IB
: inst
.instruction
= T_OPCODE_LDR_RB
; break;
9703 case 0x5600 /* ldrsb */:
9704 case 0x5e00 /* ldrsh */: break;
9708 inst
.instruction
|= inst
.operands
[0].reg
;
9709 inst
.instruction
|= inst
.operands
[1].reg
<< 3;
9710 inst
.instruction
|= inst
.operands
[1].imm
<< 6;
9716 if (!inst
.operands
[1].present
)
9718 inst
.operands
[1].reg
= inst
.operands
[0].reg
+ 1;
9719 constraint (inst
.operands
[0].reg
== REG_LR
,
9720 _("r14 not allowed here"));
9722 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
9723 inst
.instruction
|= inst
.operands
[1].reg
<< 8;
9724 encode_thumb32_addr_mode (2, /*is_t=*/FALSE
, /*is_d=*/TRUE
);
9730 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
9731 encode_thumb32_addr_mode (1, /*is_t=*/TRUE
, /*is_d=*/FALSE
);
9737 unsigned Rd
, Rn
, Rm
, Ra
;
9739 Rd
= inst
.operands
[0].reg
;
9740 Rn
= inst
.operands
[1].reg
;
9741 Rm
= inst
.operands
[2].reg
;
9742 Ra
= inst
.operands
[3].reg
;
9744 reject_bad_reg (Rd
);
9745 reject_bad_reg (Rn
);
9746 reject_bad_reg (Rm
);
9747 reject_bad_reg (Ra
);
9749 inst
.instruction
|= Rd
<< 8;
9750 inst
.instruction
|= Rn
<< 16;
9751 inst
.instruction
|= Rm
;
9752 inst
.instruction
|= Ra
<< 12;
9758 unsigned RdLo
, RdHi
, Rn
, Rm
;
9760 RdLo
= inst
.operands
[0].reg
;
9761 RdHi
= inst
.operands
[1].reg
;
9762 Rn
= inst
.operands
[2].reg
;
9763 Rm
= inst
.operands
[3].reg
;
9765 reject_bad_reg (RdLo
);
9766 reject_bad_reg (RdHi
);
9767 reject_bad_reg (Rn
);
9768 reject_bad_reg (Rm
);
9770 inst
.instruction
|= RdLo
<< 12;
9771 inst
.instruction
|= RdHi
<< 8;
9772 inst
.instruction
|= Rn
<< 16;
9773 inst
.instruction
|= Rm
;
9781 Rn
= inst
.operands
[0].reg
;
9782 Rm
= inst
.operands
[1].reg
;
9785 set_it_insn_type_last ();
9789 int r0off
= (inst
.instruction
== T_MNEM_mov
9790 || inst
.instruction
== T_MNEM_movs
) ? 8 : 16;
9791 unsigned long opcode
;
9793 bfd_boolean low_regs
;
9795 low_regs
= (Rn
<= 7 && Rm
<= 7);
9796 opcode
= inst
.instruction
;
9798 narrow
= opcode
!= T_MNEM_movs
;
9800 narrow
= opcode
!= T_MNEM_movs
|| low_regs
;
9801 if (inst
.size_req
== 4
9802 || inst
.operands
[1].shifted
)
9805 /* MOVS PC, LR is encoded as SUBS PC, LR, #0. */
9806 if (opcode
== T_MNEM_movs
&& inst
.operands
[1].isreg
9807 && !inst
.operands
[1].shifted
9811 inst
.instruction
= T2_SUBS_PC_LR
;
9815 if (opcode
== T_MNEM_cmp
)
9817 constraint (Rn
== REG_PC
, BAD_PC
);
9820 /* In the Thumb-2 ISA, use of R13 as Rm is deprecated,
9822 warn_deprecated_sp (Rm
);
9823 /* R15 was documented as a valid choice for Rm in ARMv6,
9824 but as UNPREDICTABLE in ARMv7. ARM's proprietary
9825 tools reject R15, so we do too. */
9826 constraint (Rm
== REG_PC
, BAD_PC
);
9829 reject_bad_reg (Rm
);
9831 else if (opcode
== T_MNEM_mov
9832 || opcode
== T_MNEM_movs
)
9834 if (inst
.operands
[1].isreg
)
9836 if (opcode
== T_MNEM_movs
)
9838 reject_bad_reg (Rn
);
9839 reject_bad_reg (Rm
);
9841 else if ((Rn
== REG_SP
|| Rn
== REG_PC
)
9842 && (Rm
== REG_SP
|| Rm
== REG_PC
))
9843 reject_bad_reg (Rm
);
9846 reject_bad_reg (Rn
);
9849 if (!inst
.operands
[1].isreg
)
9851 /* Immediate operand. */
9852 if (!in_it_block () && opcode
== T_MNEM_mov
)
9854 if (low_regs
&& narrow
)
9856 inst
.instruction
= THUMB_OP16 (opcode
);
9857 inst
.instruction
|= Rn
<< 8;
9858 if (inst
.size_req
== 2)
9859 inst
.reloc
.type
= BFD_RELOC_ARM_THUMB_IMM
;
9861 inst
.relax
= opcode
;
9865 inst
.instruction
= THUMB_OP32 (inst
.instruction
);
9866 inst
.instruction
= (inst
.instruction
& 0xe1ffffff) | 0x10000000;
9867 inst
.instruction
|= Rn
<< r0off
;
9868 inst
.reloc
.type
= BFD_RELOC_ARM_T32_IMMEDIATE
;
9871 else if (inst
.operands
[1].shifted
&& inst
.operands
[1].immisreg
9872 && (inst
.instruction
== T_MNEM_mov
9873 || inst
.instruction
== T_MNEM_movs
))
9875 /* Register shifts are encoded as separate shift instructions. */
9876 bfd_boolean flags
= (inst
.instruction
== T_MNEM_movs
);
9883 if (inst
.size_req
== 4)
9886 if (!low_regs
|| inst
.operands
[1].imm
> 7)
9892 switch (inst
.operands
[1].shift_kind
)
9895 opcode
= narrow
? T_OPCODE_LSL_R
: THUMB_OP32 (T_MNEM_lsl
);
9898 opcode
= narrow
? T_OPCODE_ASR_R
: THUMB_OP32 (T_MNEM_asr
);
9901 opcode
= narrow
? T_OPCODE_LSR_R
: THUMB_OP32 (T_MNEM_lsr
);
9904 opcode
= narrow
? T_OPCODE_ROR_R
: THUMB_OP32 (T_MNEM_ror
);
9910 inst
.instruction
= opcode
;
9913 inst
.instruction
|= Rn
;
9914 inst
.instruction
|= inst
.operands
[1].imm
<< 3;
9919 inst
.instruction
|= CONDS_BIT
;
9921 inst
.instruction
|= Rn
<< 8;
9922 inst
.instruction
|= Rm
<< 16;
9923 inst
.instruction
|= inst
.operands
[1].imm
;
9928 /* Some mov with immediate shift have narrow variants.
9929 Register shifts are handled above. */
9930 if (low_regs
&& inst
.operands
[1].shifted
9931 && (inst
.instruction
== T_MNEM_mov
9932 || inst
.instruction
== T_MNEM_movs
))
9935 narrow
= (inst
.instruction
== T_MNEM_mov
);
9937 narrow
= (inst
.instruction
== T_MNEM_movs
);
9942 switch (inst
.operands
[1].shift_kind
)
9944 case SHIFT_LSL
: inst
.instruction
= T_OPCODE_LSL_I
; break;
9945 case SHIFT_LSR
: inst
.instruction
= T_OPCODE_LSR_I
; break;
9946 case SHIFT_ASR
: inst
.instruction
= T_OPCODE_ASR_I
; break;
9947 default: narrow
= FALSE
; break;
9953 inst
.instruction
|= Rn
;
9954 inst
.instruction
|= Rm
<< 3;
9955 inst
.reloc
.type
= BFD_RELOC_ARM_THUMB_SHIFT
;
9959 inst
.instruction
= THUMB_OP32 (inst
.instruction
);
9960 inst
.instruction
|= Rn
<< r0off
;
9961 encode_thumb32_shifted_operand (1);
9965 switch (inst
.instruction
)
9968 inst
.instruction
= T_OPCODE_MOV_HR
;
9969 inst
.instruction
|= (Rn
& 0x8) << 4;
9970 inst
.instruction
|= (Rn
& 0x7);
9971 inst
.instruction
|= Rm
<< 3;
9975 /* We know we have low registers at this point.
9976 Generate ADD Rd, Rs, #0. */
9977 inst
.instruction
= T_OPCODE_ADD_I3
;
9978 inst
.instruction
|= Rn
;
9979 inst
.instruction
|= Rm
<< 3;
9985 inst
.instruction
= T_OPCODE_CMP_LR
;
9986 inst
.instruction
|= Rn
;
9987 inst
.instruction
|= Rm
<< 3;
9991 inst
.instruction
= T_OPCODE_CMP_HR
;
9992 inst
.instruction
|= (Rn
& 0x8) << 4;
9993 inst
.instruction
|= (Rn
& 0x7);
9994 inst
.instruction
|= Rm
<< 3;
10001 inst
.instruction
= THUMB_OP16 (inst
.instruction
);
10002 if (inst
.operands
[1].isreg
)
10004 if (Rn
< 8 && Rm
< 8)
10006 /* A move of two lowregs is encoded as ADD Rd, Rs, #0
10007 since a MOV instruction produces unpredictable results. */
10008 if (inst
.instruction
== T_OPCODE_MOV_I8
)
10009 inst
.instruction
= T_OPCODE_ADD_I3
;
10011 inst
.instruction
= T_OPCODE_CMP_LR
;
10013 inst
.instruction
|= Rn
;
10014 inst
.instruction
|= Rm
<< 3;
10018 if (inst
.instruction
== T_OPCODE_MOV_I8
)
10019 inst
.instruction
= T_OPCODE_MOV_HR
;
10021 inst
.instruction
= T_OPCODE_CMP_HR
;
10027 constraint (Rn
> 7,
10028 _("only lo regs allowed with immediate"));
10029 inst
.instruction
|= Rn
<< 8;
10030 inst
.reloc
.type
= BFD_RELOC_ARM_THUMB_IMM
;
10041 top
= (inst
.instruction
& 0x00800000) != 0;
10042 if (inst
.reloc
.type
== BFD_RELOC_ARM_MOVW
)
10044 constraint (top
, _(":lower16: not allowed this instruction"));
10045 inst
.reloc
.type
= BFD_RELOC_ARM_THUMB_MOVW
;
10047 else if (inst
.reloc
.type
== BFD_RELOC_ARM_MOVT
)
10049 constraint (!top
, _(":upper16: not allowed this instruction"));
10050 inst
.reloc
.type
= BFD_RELOC_ARM_THUMB_MOVT
;
10053 Rd
= inst
.operands
[0].reg
;
10054 reject_bad_reg (Rd
);
10056 inst
.instruction
|= Rd
<< 8;
10057 if (inst
.reloc
.type
== BFD_RELOC_UNUSED
)
10059 imm
= inst
.reloc
.exp
.X_add_number
;
10060 inst
.instruction
|= (imm
& 0xf000) << 4;
10061 inst
.instruction
|= (imm
& 0x0800) << 15;
10062 inst
.instruction
|= (imm
& 0x0700) << 4;
10063 inst
.instruction
|= (imm
& 0x00ff);
10068 do_t_mvn_tst (void)
10072 Rn
= inst
.operands
[0].reg
;
10073 Rm
= inst
.operands
[1].reg
;
10075 if (inst
.instruction
== T_MNEM_cmp
10076 || inst
.instruction
== T_MNEM_cmn
)
10077 constraint (Rn
== REG_PC
, BAD_PC
);
10079 reject_bad_reg (Rn
);
10080 reject_bad_reg (Rm
);
10082 if (unified_syntax
)
10084 int r0off
= (inst
.instruction
== T_MNEM_mvn
10085 || inst
.instruction
== T_MNEM_mvns
) ? 8 : 16;
10086 bfd_boolean narrow
;
10088 if (inst
.size_req
== 4
10089 || inst
.instruction
> 0xffff
10090 || inst
.operands
[1].shifted
10091 || Rn
> 7 || Rm
> 7)
10093 else if (inst
.instruction
== T_MNEM_cmn
)
10095 else if (THUMB_SETS_FLAGS (inst
.instruction
))
10096 narrow
= !in_it_block ();
10098 narrow
= in_it_block ();
10100 if (!inst
.operands
[1].isreg
)
10102 /* For an immediate, we always generate a 32-bit opcode;
10103 section relaxation will shrink it later if possible. */
10104 if (inst
.instruction
< 0xffff)
10105 inst
.instruction
= THUMB_OP32 (inst
.instruction
);
10106 inst
.instruction
= (inst
.instruction
& 0xe1ffffff) | 0x10000000;
10107 inst
.instruction
|= Rn
<< r0off
;
10108 inst
.reloc
.type
= BFD_RELOC_ARM_T32_IMMEDIATE
;
10112 /* See if we can do this with a 16-bit instruction. */
10115 inst
.instruction
= THUMB_OP16 (inst
.instruction
);
10116 inst
.instruction
|= Rn
;
10117 inst
.instruction
|= Rm
<< 3;
10121 constraint (inst
.operands
[1].shifted
10122 && inst
.operands
[1].immisreg
,
10123 _("shift must be constant"));
10124 if (inst
.instruction
< 0xffff)
10125 inst
.instruction
= THUMB_OP32 (inst
.instruction
);
10126 inst
.instruction
|= Rn
<< r0off
;
10127 encode_thumb32_shifted_operand (1);
10133 constraint (inst
.instruction
> 0xffff
10134 || inst
.instruction
== T_MNEM_mvns
, BAD_THUMB32
);
10135 constraint (!inst
.operands
[1].isreg
|| inst
.operands
[1].shifted
,
10136 _("unshifted register required"));
10137 constraint (Rn
> 7 || Rm
> 7,
10140 inst
.instruction
= THUMB_OP16 (inst
.instruction
);
10141 inst
.instruction
|= Rn
;
10142 inst
.instruction
|= Rm
<< 3;
10152 if (do_vfp_nsyn_mrs () == SUCCESS
)
10155 flags
= inst
.operands
[1].imm
& (PSR_c
|PSR_x
|PSR_s
|PSR_f
|SPSR_BIT
);
10158 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant
, arm_ext_m
),
10159 _("selected processor does not support "
10160 "requested special purpose register"));
10164 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant
, arm_ext_v1
),
10165 _("selected processor does not support "
10166 "requested special purpose register"));
10167 /* mrs only accepts CPSR/SPSR/CPSR_all/SPSR_all. */
10168 constraint ((flags
& ~SPSR_BIT
) != (PSR_c
|PSR_f
),
10169 _("'CPSR' or 'SPSR' expected"));
10172 Rd
= inst
.operands
[0].reg
;
10173 reject_bad_reg (Rd
);
10175 inst
.instruction
|= Rd
<< 8;
10176 inst
.instruction
|= (flags
& SPSR_BIT
) >> 2;
10177 inst
.instruction
|= inst
.operands
[1].imm
& 0xff;
10186 if (do_vfp_nsyn_msr () == SUCCESS
)
10189 constraint (!inst
.operands
[1].isreg
,
10190 _("Thumb encoding does not support an immediate here"));
10191 flags
= inst
.operands
[0].imm
;
10194 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant
, arm_ext_v1
),
10195 _("selected processor does not support "
10196 "requested special purpose register"));
10200 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant
, arm_ext_m
),
10201 _("selected processor does not support "
10202 "requested special purpose register"));
10206 Rn
= inst
.operands
[1].reg
;
10207 reject_bad_reg (Rn
);
10209 inst
.instruction
|= (flags
& SPSR_BIT
) >> 2;
10210 inst
.instruction
|= (flags
& ~SPSR_BIT
) >> 8;
10211 inst
.instruction
|= (flags
& 0xff);
10212 inst
.instruction
|= Rn
<< 16;
10218 bfd_boolean narrow
;
10219 unsigned Rd
, Rn
, Rm
;
10221 if (!inst
.operands
[2].present
)
10222 inst
.operands
[2].reg
= inst
.operands
[0].reg
;
10224 Rd
= inst
.operands
[0].reg
;
10225 Rn
= inst
.operands
[1].reg
;
10226 Rm
= inst
.operands
[2].reg
;
10228 if (unified_syntax
)
10230 if (inst
.size_req
== 4
10236 else if (inst
.instruction
== T_MNEM_muls
)
10237 narrow
= !in_it_block ();
10239 narrow
= in_it_block ();
10243 constraint (inst
.instruction
== T_MNEM_muls
, BAD_THUMB32
);
10244 constraint (Rn
> 7 || Rm
> 7,
10251 /* 16-bit MULS/Conditional MUL. */
10252 inst
.instruction
= THUMB_OP16 (inst
.instruction
);
10253 inst
.instruction
|= Rd
;
10256 inst
.instruction
|= Rm
<< 3;
10258 inst
.instruction
|= Rn
<< 3;
10260 constraint (1, _("dest must overlap one source register"));
10264 constraint (inst
.instruction
!= T_MNEM_mul
,
10265 _("Thumb-2 MUL must not set flags"));
10267 inst
.instruction
= THUMB_OP32 (inst
.instruction
);
10268 inst
.instruction
|= Rd
<< 8;
10269 inst
.instruction
|= Rn
<< 16;
10270 inst
.instruction
|= Rm
<< 0;
10272 reject_bad_reg (Rd
);
10273 reject_bad_reg (Rn
);
10274 reject_bad_reg (Rm
);
10281 unsigned RdLo
, RdHi
, Rn
, Rm
;
10283 RdLo
= inst
.operands
[0].reg
;
10284 RdHi
= inst
.operands
[1].reg
;
10285 Rn
= inst
.operands
[2].reg
;
10286 Rm
= inst
.operands
[3].reg
;
10288 reject_bad_reg (RdLo
);
10289 reject_bad_reg (RdHi
);
10290 reject_bad_reg (Rn
);
10291 reject_bad_reg (Rm
);
10293 inst
.instruction
|= RdLo
<< 12;
10294 inst
.instruction
|= RdHi
<< 8;
10295 inst
.instruction
|= Rn
<< 16;
10296 inst
.instruction
|= Rm
;
10299 as_tsktsk (_("rdhi and rdlo must be different"));
10305 set_it_insn_type (NEUTRAL_IT_INSN
);
10307 if (unified_syntax
)
10309 if (inst
.size_req
== 4 || inst
.operands
[0].imm
> 15)
10311 inst
.instruction
= THUMB_OP32 (inst
.instruction
);
10312 inst
.instruction
|= inst
.operands
[0].imm
;
10316 /* PR9722: Check for Thumb2 availability before
10317 generating a thumb2 nop instruction. */
10318 if (ARM_CPU_HAS_FEATURE (cpu_variant
, arm_arch_t2
))
10320 inst
.instruction
= THUMB_OP16 (inst
.instruction
);
10321 inst
.instruction
|= inst
.operands
[0].imm
<< 4;
10324 inst
.instruction
= 0x46c0;
10329 constraint (inst
.operands
[0].present
,
10330 _("Thumb does not support NOP with hints"));
10331 inst
.instruction
= 0x46c0;
10338 if (unified_syntax
)
10340 bfd_boolean narrow
;
10342 if (THUMB_SETS_FLAGS (inst
.instruction
))
10343 narrow
= !in_it_block ();
10345 narrow
= in_it_block ();
10346 if (inst
.operands
[0].reg
> 7 || inst
.operands
[1].reg
> 7)
10348 if (inst
.size_req
== 4)
10353 inst
.instruction
= THUMB_OP32 (inst
.instruction
);
10354 inst
.instruction
|= inst
.operands
[0].reg
<< 8;
10355 inst
.instruction
|= inst
.operands
[1].reg
<< 16;
10359 inst
.instruction
= THUMB_OP16 (inst
.instruction
);
10360 inst
.instruction
|= inst
.operands
[0].reg
;
10361 inst
.instruction
|= inst
.operands
[1].reg
<< 3;
10366 constraint (inst
.operands
[0].reg
> 7 || inst
.operands
[1].reg
> 7,
10368 constraint (THUMB_SETS_FLAGS (inst
.instruction
), BAD_THUMB32
);
10370 inst
.instruction
= THUMB_OP16 (inst
.instruction
);
10371 inst
.instruction
|= inst
.operands
[0].reg
;
10372 inst
.instruction
|= inst
.operands
[1].reg
<< 3;
10381 Rd
= inst
.operands
[0].reg
;
10382 Rn
= inst
.operands
[1].present
? inst
.operands
[1].reg
: Rd
;
10384 reject_bad_reg (Rd
);
10385 /* Rn == REG_SP is unpredictable; Rn == REG_PC is MVN. */
10386 reject_bad_reg (Rn
);
10388 inst
.instruction
|= Rd
<< 8;
10389 inst
.instruction
|= Rn
<< 16;
10391 if (!inst
.operands
[2].isreg
)
10393 inst
.instruction
= (inst
.instruction
& 0xe1ffffff) | 0x10000000;
10394 inst
.reloc
.type
= BFD_RELOC_ARM_T32_IMMEDIATE
;
10400 Rm
= inst
.operands
[2].reg
;
10401 reject_bad_reg (Rm
);
10403 constraint (inst
.operands
[2].shifted
10404 && inst
.operands
[2].immisreg
,
10405 _("shift must be constant"));
10406 encode_thumb32_shifted_operand (2);
10413 unsigned Rd
, Rn
, Rm
;
10415 Rd
= inst
.operands
[0].reg
;
10416 Rn
= inst
.operands
[1].reg
;
10417 Rm
= inst
.operands
[2].reg
;
10419 reject_bad_reg (Rd
);
10420 reject_bad_reg (Rn
);
10421 reject_bad_reg (Rm
);
10423 inst
.instruction
|= Rd
<< 8;
10424 inst
.instruction
|= Rn
<< 16;
10425 inst
.instruction
|= Rm
;
10426 if (inst
.operands
[3].present
)
10428 unsigned int val
= inst
.reloc
.exp
.X_add_number
;
10429 constraint (inst
.reloc
.exp
.X_op
!= O_constant
,
10430 _("expression too complex"));
10431 inst
.instruction
|= (val
& 0x1c) << 10;
10432 inst
.instruction
|= (val
& 0x03) << 6;
10439 if (!inst
.operands
[3].present
)
10440 inst
.instruction
&= ~0x00000020;
10447 if (inst
.operands
[0].immisreg
)
10448 reject_bad_reg (inst
.operands
[0].imm
);
10450 encode_thumb32_addr_mode (0, /*is_t=*/FALSE
, /*is_d=*/FALSE
);
10454 do_t_push_pop (void)
10458 constraint (inst
.operands
[0].writeback
,
10459 _("push/pop do not support {reglist}^"));
10460 constraint (inst
.reloc
.type
!= BFD_RELOC_UNUSED
,
10461 _("expression too complex"));
10463 mask
= inst
.operands
[0].imm
;
10464 if ((mask
& ~0xff) == 0)
10465 inst
.instruction
= THUMB_OP16 (inst
.instruction
) | mask
;
10466 else if ((inst
.instruction
== T_MNEM_push
10467 && (mask
& ~0xff) == 1 << REG_LR
)
10468 || (inst
.instruction
== T_MNEM_pop
10469 && (mask
& ~0xff) == 1 << REG_PC
))
10471 inst
.instruction
= THUMB_OP16 (inst
.instruction
);
10472 inst
.instruction
|= THUMB_PP_PC_LR
;
10473 inst
.instruction
|= mask
& 0xff;
10475 else if (unified_syntax
)
10477 inst
.instruction
= THUMB_OP32 (inst
.instruction
);
10478 encode_thumb2_ldmstm (13, mask
, TRUE
);
10482 inst
.error
= _("invalid register list to push/pop instruction");
10492 Rd
= inst
.operands
[0].reg
;
10493 Rm
= inst
.operands
[1].reg
;
10495 reject_bad_reg (Rd
);
10496 reject_bad_reg (Rm
);
10498 inst
.instruction
|= Rd
<< 8;
10499 inst
.instruction
|= Rm
<< 16;
10500 inst
.instruction
|= Rm
;
10508 Rd
= inst
.operands
[0].reg
;
10509 Rm
= inst
.operands
[1].reg
;
10511 reject_bad_reg (Rd
);
10512 reject_bad_reg (Rm
);
10514 if (Rd
<= 7 && Rm
<= 7
10515 && inst
.size_req
!= 4)
10517 inst
.instruction
= THUMB_OP16 (inst
.instruction
);
10518 inst
.instruction
|= Rd
;
10519 inst
.instruction
|= Rm
<< 3;
10521 else if (unified_syntax
)
10523 inst
.instruction
= THUMB_OP32 (inst
.instruction
);
10524 inst
.instruction
|= Rd
<< 8;
10525 inst
.instruction
|= Rm
<< 16;
10526 inst
.instruction
|= Rm
;
10529 inst
.error
= BAD_HIREG
;
10537 Rd
= inst
.operands
[0].reg
;
10538 Rm
= inst
.operands
[1].reg
;
10540 reject_bad_reg (Rd
);
10541 reject_bad_reg (Rm
);
10543 inst
.instruction
|= Rd
<< 8;
10544 inst
.instruction
|= Rm
;
10552 Rd
= inst
.operands
[0].reg
;
10553 Rs
= (inst
.operands
[1].present
10554 ? inst
.operands
[1].reg
/* Rd, Rs, foo */
10555 : inst
.operands
[0].reg
); /* Rd, foo -> Rd, Rd, foo */
10557 reject_bad_reg (Rd
);
10558 reject_bad_reg (Rs
);
10559 if (inst
.operands
[2].isreg
)
10560 reject_bad_reg (inst
.operands
[2].reg
);
10562 inst
.instruction
|= Rd
<< 8;
10563 inst
.instruction
|= Rs
<< 16;
10564 if (!inst
.operands
[2].isreg
)
10566 bfd_boolean narrow
;
10568 if ((inst
.instruction
& 0x00100000) != 0)
10569 narrow
= !in_it_block ();
10571 narrow
= in_it_block ();
10573 if (Rd
> 7 || Rs
> 7)
10576 if (inst
.size_req
== 4 || !unified_syntax
)
10579 if (inst
.reloc
.exp
.X_op
!= O_constant
10580 || inst
.reloc
.exp
.X_add_number
!= 0)
10583 /* Turn rsb #0 into 16-bit neg. We should probably do this via
10584 relaxation, but it doesn't seem worth the hassle. */
10587 inst
.reloc
.type
= BFD_RELOC_UNUSED
;
10588 inst
.instruction
= THUMB_OP16 (T_MNEM_negs
);
10589 inst
.instruction
|= Rs
<< 3;
10590 inst
.instruction
|= Rd
;
10594 inst
.instruction
= (inst
.instruction
& 0xe1ffffff) | 0x10000000;
10595 inst
.reloc
.type
= BFD_RELOC_ARM_T32_IMMEDIATE
;
10599 encode_thumb32_shifted_operand (2);
10605 set_it_insn_type (OUTSIDE_IT_INSN
);
10606 if (inst
.operands
[0].imm
)
10607 inst
.instruction
|= 0x8;
10613 if (!inst
.operands
[1].present
)
10614 inst
.operands
[1].reg
= inst
.operands
[0].reg
;
10616 if (unified_syntax
)
10618 bfd_boolean narrow
;
10621 switch (inst
.instruction
)
10624 case T_MNEM_asrs
: shift_kind
= SHIFT_ASR
; break;
10626 case T_MNEM_lsls
: shift_kind
= SHIFT_LSL
; break;
10628 case T_MNEM_lsrs
: shift_kind
= SHIFT_LSR
; break;
10630 case T_MNEM_rors
: shift_kind
= SHIFT_ROR
; break;
10634 if (THUMB_SETS_FLAGS (inst
.instruction
))
10635 narrow
= !in_it_block ();
10637 narrow
= in_it_block ();
10638 if (inst
.operands
[0].reg
> 7 || inst
.operands
[1].reg
> 7)
10640 if (!inst
.operands
[2].isreg
&& shift_kind
== SHIFT_ROR
)
10642 if (inst
.operands
[2].isreg
10643 && (inst
.operands
[1].reg
!= inst
.operands
[0].reg
10644 || inst
.operands
[2].reg
> 7))
10646 if (inst
.size_req
== 4)
10649 reject_bad_reg (inst
.operands
[0].reg
);
10650 reject_bad_reg (inst
.operands
[1].reg
);
10654 if (inst
.operands
[2].isreg
)
10656 reject_bad_reg (inst
.operands
[2].reg
);
10657 inst
.instruction
= THUMB_OP32 (inst
.instruction
);
10658 inst
.instruction
|= inst
.operands
[0].reg
<< 8;
10659 inst
.instruction
|= inst
.operands
[1].reg
<< 16;
10660 inst
.instruction
|= inst
.operands
[2].reg
;
10664 inst
.operands
[1].shifted
= 1;
10665 inst
.operands
[1].shift_kind
= shift_kind
;
10666 inst
.instruction
= THUMB_OP32 (THUMB_SETS_FLAGS (inst
.instruction
)
10667 ? T_MNEM_movs
: T_MNEM_mov
);
10668 inst
.instruction
|= inst
.operands
[0].reg
<< 8;
10669 encode_thumb32_shifted_operand (1);
10670 /* Prevent the incorrect generation of an ARM_IMMEDIATE fixup. */
10671 inst
.reloc
.type
= BFD_RELOC_UNUSED
;
10676 if (inst
.operands
[2].isreg
)
10678 switch (shift_kind
)
10680 case SHIFT_ASR
: inst
.instruction
= T_OPCODE_ASR_R
; break;
10681 case SHIFT_LSL
: inst
.instruction
= T_OPCODE_LSL_R
; break;
10682 case SHIFT_LSR
: inst
.instruction
= T_OPCODE_LSR_R
; break;
10683 case SHIFT_ROR
: inst
.instruction
= T_OPCODE_ROR_R
; break;
10687 inst
.instruction
|= inst
.operands
[0].reg
;
10688 inst
.instruction
|= inst
.operands
[2].reg
<< 3;
10692 switch (shift_kind
)
10694 case SHIFT_ASR
: inst
.instruction
= T_OPCODE_ASR_I
; break;
10695 case SHIFT_LSL
: inst
.instruction
= T_OPCODE_LSL_I
; break;
10696 case SHIFT_LSR
: inst
.instruction
= T_OPCODE_LSR_I
; break;
10699 inst
.reloc
.type
= BFD_RELOC_ARM_THUMB_SHIFT
;
10700 inst
.instruction
|= inst
.operands
[0].reg
;
10701 inst
.instruction
|= inst
.operands
[1].reg
<< 3;
10707 constraint (inst
.operands
[0].reg
> 7
10708 || inst
.operands
[1].reg
> 7, BAD_HIREG
);
10709 constraint (THUMB_SETS_FLAGS (inst
.instruction
), BAD_THUMB32
);
10711 if (inst
.operands
[2].isreg
) /* Rd, {Rs,} Rn */
10713 constraint (inst
.operands
[2].reg
> 7, BAD_HIREG
);
10714 constraint (inst
.operands
[0].reg
!= inst
.operands
[1].reg
,
10715 _("source1 and dest must be same register"));
10717 switch (inst
.instruction
)
10719 case T_MNEM_asr
: inst
.instruction
= T_OPCODE_ASR_R
; break;
10720 case T_MNEM_lsl
: inst
.instruction
= T_OPCODE_LSL_R
; break;
10721 case T_MNEM_lsr
: inst
.instruction
= T_OPCODE_LSR_R
; break;
10722 case T_MNEM_ror
: inst
.instruction
= T_OPCODE_ROR_R
; break;
10726 inst
.instruction
|= inst
.operands
[0].reg
;
10727 inst
.instruction
|= inst
.operands
[2].reg
<< 3;
10731 switch (inst
.instruction
)
10733 case T_MNEM_asr
: inst
.instruction
= T_OPCODE_ASR_I
; break;
10734 case T_MNEM_lsl
: inst
.instruction
= T_OPCODE_LSL_I
; break;
10735 case T_MNEM_lsr
: inst
.instruction
= T_OPCODE_LSR_I
; break;
10736 case T_MNEM_ror
: inst
.error
= _("ror #imm not supported"); return;
10739 inst
.reloc
.type
= BFD_RELOC_ARM_THUMB_SHIFT
;
10740 inst
.instruction
|= inst
.operands
[0].reg
;
10741 inst
.instruction
|= inst
.operands
[1].reg
<< 3;
10749 unsigned Rd
, Rn
, Rm
;
10751 Rd
= inst
.operands
[0].reg
;
10752 Rn
= inst
.operands
[1].reg
;
10753 Rm
= inst
.operands
[2].reg
;
10755 reject_bad_reg (Rd
);
10756 reject_bad_reg (Rn
);
10757 reject_bad_reg (Rm
);
10759 inst
.instruction
|= Rd
<< 8;
10760 inst
.instruction
|= Rn
<< 16;
10761 inst
.instruction
|= Rm
;
10767 unsigned int value
= inst
.reloc
.exp
.X_add_number
;
10768 constraint (inst
.reloc
.exp
.X_op
!= O_constant
,
10769 _("expression too complex"));
10770 inst
.reloc
.type
= BFD_RELOC_UNUSED
;
10771 inst
.instruction
|= (value
& 0xf000) >> 12;
10772 inst
.instruction
|= (value
& 0x0ff0);
10773 inst
.instruction
|= (value
& 0x000f) << 16;
10777 do_t_ssat_usat (int bias
)
10781 Rd
= inst
.operands
[0].reg
;
10782 Rn
= inst
.operands
[2].reg
;
10784 reject_bad_reg (Rd
);
10785 reject_bad_reg (Rn
);
10787 inst
.instruction
|= Rd
<< 8;
10788 inst
.instruction
|= inst
.operands
[1].imm
- bias
;
10789 inst
.instruction
|= Rn
<< 16;
10791 if (inst
.operands
[3].present
)
10793 offsetT shift_amount
= inst
.reloc
.exp
.X_add_number
;
10795 inst
.reloc
.type
= BFD_RELOC_UNUSED
;
10797 constraint (inst
.reloc
.exp
.X_op
!= O_constant
,
10798 _("expression too complex"));
10800 if (shift_amount
!= 0)
10802 constraint (shift_amount
> 31,
10803 _("shift expression is too large"));
10805 if (inst
.operands
[3].shift_kind
== SHIFT_ASR
)
10806 inst
.instruction
|= 0x00200000; /* sh bit. */
10808 inst
.instruction
|= (shift_amount
& 0x1c) << 10;
10809 inst
.instruction
|= (shift_amount
& 0x03) << 6;
10817 do_t_ssat_usat (1);
10825 Rd
= inst
.operands
[0].reg
;
10826 Rn
= inst
.operands
[2].reg
;
10828 reject_bad_reg (Rd
);
10829 reject_bad_reg (Rn
);
10831 inst
.instruction
|= Rd
<< 8;
10832 inst
.instruction
|= inst
.operands
[1].imm
- 1;
10833 inst
.instruction
|= Rn
<< 16;
10839 constraint (!inst
.operands
[2].isreg
|| !inst
.operands
[2].preind
10840 || inst
.operands
[2].postind
|| inst
.operands
[2].writeback
10841 || inst
.operands
[2].immisreg
|| inst
.operands
[2].shifted
10842 || inst
.operands
[2].negative
,
10845 inst
.instruction
|= inst
.operands
[0].reg
<< 8;
10846 inst
.instruction
|= inst
.operands
[1].reg
<< 12;
10847 inst
.instruction
|= inst
.operands
[2].reg
<< 16;
10848 inst
.reloc
.type
= BFD_RELOC_ARM_T32_OFFSET_U8
;
10854 if (!inst
.operands
[2].present
)
10855 inst
.operands
[2].reg
= inst
.operands
[1].reg
+ 1;
10857 constraint (inst
.operands
[0].reg
== inst
.operands
[1].reg
10858 || inst
.operands
[0].reg
== inst
.operands
[2].reg
10859 || inst
.operands
[0].reg
== inst
.operands
[3].reg
10860 || inst
.operands
[1].reg
== inst
.operands
[2].reg
,
10863 inst
.instruction
|= inst
.operands
[0].reg
;
10864 inst
.instruction
|= inst
.operands
[1].reg
<< 12;
10865 inst
.instruction
|= inst
.operands
[2].reg
<< 8;
10866 inst
.instruction
|= inst
.operands
[3].reg
<< 16;
10872 unsigned Rd
, Rn
, Rm
;
10874 Rd
= inst
.operands
[0].reg
;
10875 Rn
= inst
.operands
[1].reg
;
10876 Rm
= inst
.operands
[2].reg
;
10878 reject_bad_reg (Rd
);
10879 reject_bad_reg (Rn
);
10880 reject_bad_reg (Rm
);
10882 inst
.instruction
|= Rd
<< 8;
10883 inst
.instruction
|= Rn
<< 16;
10884 inst
.instruction
|= Rm
;
10885 inst
.instruction
|= inst
.operands
[3].imm
<< 4;
10893 Rd
= inst
.operands
[0].reg
;
10894 Rm
= inst
.operands
[1].reg
;
10896 reject_bad_reg (Rd
);
10897 reject_bad_reg (Rm
);
10899 if (inst
.instruction
<= 0xffff && inst
.size_req
!= 4
10900 && Rd
<= 7 && Rm
<= 7
10901 && (!inst
.operands
[2].present
|| inst
.operands
[2].imm
== 0))
10903 inst
.instruction
= THUMB_OP16 (inst
.instruction
);
10904 inst
.instruction
|= Rd
;
10905 inst
.instruction
|= Rm
<< 3;
10907 else if (unified_syntax
)
10909 if (inst
.instruction
<= 0xffff)
10910 inst
.instruction
= THUMB_OP32 (inst
.instruction
);
10911 inst
.instruction
|= Rd
<< 8;
10912 inst
.instruction
|= Rm
;
10913 inst
.instruction
|= inst
.operands
[2].imm
<< 4;
10917 constraint (inst
.operands
[2].present
&& inst
.operands
[2].imm
!= 0,
10918 _("Thumb encoding does not support rotation"));
10919 constraint (1, BAD_HIREG
);
10926 inst
.reloc
.type
= BFD_RELOC_ARM_SWI
;
10935 half
= (inst
.instruction
& 0x10) != 0;
10936 set_it_insn_type_last ();
10937 constraint (inst
.operands
[0].immisreg
,
10938 _("instruction requires register index"));
10940 Rn
= inst
.operands
[0].reg
;
10941 Rm
= inst
.operands
[0].imm
;
10943 constraint (Rn
== REG_SP
, BAD_SP
);
10944 reject_bad_reg (Rm
);
10946 constraint (!half
&& inst
.operands
[0].shifted
,
10947 _("instruction does not allow shifted index"));
10948 inst
.instruction
|= (Rn
<< 16) | Rm
;
10954 do_t_ssat_usat (0);
10962 Rd
= inst
.operands
[0].reg
;
10963 Rn
= inst
.operands
[2].reg
;
10965 reject_bad_reg (Rd
);
10966 reject_bad_reg (Rn
);
10968 inst
.instruction
|= Rd
<< 8;
10969 inst
.instruction
|= inst
.operands
[1].imm
;
10970 inst
.instruction
|= Rn
<< 16;
10973 /* Neon instruction encoder helpers. */
10975 /* Encodings for the different types for various Neon opcodes. */
10977 /* An "invalid" code for the following tables. */
10980 struct neon_tab_entry
10983 unsigned float_or_poly
;
10984 unsigned scalar_or_imm
;
10987 /* Map overloaded Neon opcodes to their respective encodings. */
10988 #define NEON_ENC_TAB \
10989 X(vabd, 0x0000700, 0x1200d00, N_INV), \
10990 X(vmax, 0x0000600, 0x0000f00, N_INV), \
10991 X(vmin, 0x0000610, 0x0200f00, N_INV), \
10992 X(vpadd, 0x0000b10, 0x1000d00, N_INV), \
10993 X(vpmax, 0x0000a00, 0x1000f00, N_INV), \
10994 X(vpmin, 0x0000a10, 0x1200f00, N_INV), \
10995 X(vadd, 0x0000800, 0x0000d00, N_INV), \
10996 X(vsub, 0x1000800, 0x0200d00, N_INV), \
10997 X(vceq, 0x1000810, 0x0000e00, 0x1b10100), \
10998 X(vcge, 0x0000310, 0x1000e00, 0x1b10080), \
10999 X(vcgt, 0x0000300, 0x1200e00, 0x1b10000), \
11000 /* Register variants of the following two instructions are encoded as
11001 vcge / vcgt with the operands reversed. */ \
11002 X(vclt, 0x0000300, 0x1200e00, 0x1b10200), \
11003 X(vcle, 0x0000310, 0x1000e00, 0x1b10180), \
11004 X(vmla, 0x0000900, 0x0000d10, 0x0800040), \
11005 X(vmls, 0x1000900, 0x0200d10, 0x0800440), \
11006 X(vmul, 0x0000910, 0x1000d10, 0x0800840), \
11007 X(vmull, 0x0800c00, 0x0800e00, 0x0800a40), /* polynomial not float. */ \
11008 X(vmlal, 0x0800800, N_INV, 0x0800240), \
11009 X(vmlsl, 0x0800a00, N_INV, 0x0800640), \
11010 X(vqdmlal, 0x0800900, N_INV, 0x0800340), \
11011 X(vqdmlsl, 0x0800b00, N_INV, 0x0800740), \
11012 X(vqdmull, 0x0800d00, N_INV, 0x0800b40), \
11013 X(vqdmulh, 0x0000b00, N_INV, 0x0800c40), \
11014 X(vqrdmulh, 0x1000b00, N_INV, 0x0800d40), \
11015 X(vshl, 0x0000400, N_INV, 0x0800510), \
11016 X(vqshl, 0x0000410, N_INV, 0x0800710), \
11017 X(vand, 0x0000110, N_INV, 0x0800030), \
11018 X(vbic, 0x0100110, N_INV, 0x0800030), \
11019 X(veor, 0x1000110, N_INV, N_INV), \
11020 X(vorn, 0x0300110, N_INV, 0x0800010), \
11021 X(vorr, 0x0200110, N_INV, 0x0800010), \
11022 X(vmvn, 0x1b00580, N_INV, 0x0800030), \
11023 X(vshll, 0x1b20300, N_INV, 0x0800a10), /* max shift, immediate. */ \
11024 X(vcvt, 0x1b30600, N_INV, 0x0800e10), /* integer, fixed-point. */ \
11025 X(vdup, 0xe800b10, N_INV, 0x1b00c00), /* arm, scalar. */ \
11026 X(vld1, 0x0200000, 0x0a00000, 0x0a00c00), /* interlv, lane, dup. */ \
11027 X(vst1, 0x0000000, 0x0800000, N_INV), \
11028 X(vld2, 0x0200100, 0x0a00100, 0x0a00d00), \
11029 X(vst2, 0x0000100, 0x0800100, N_INV), \
11030 X(vld3, 0x0200200, 0x0a00200, 0x0a00e00), \
11031 X(vst3, 0x0000200, 0x0800200, N_INV), \
11032 X(vld4, 0x0200300, 0x0a00300, 0x0a00f00), \
11033 X(vst4, 0x0000300, 0x0800300, N_INV), \
11034 X(vmovn, 0x1b20200, N_INV, N_INV), \
11035 X(vtrn, 0x1b20080, N_INV, N_INV), \
11036 X(vqmovn, 0x1b20200, N_INV, N_INV), \
11037 X(vqmovun, 0x1b20240, N_INV, N_INV), \
11038 X(vnmul, 0xe200a40, 0xe200b40, N_INV), \
11039 X(vnmla, 0xe000a40, 0xe000b40, N_INV), \
11040 X(vnmls, 0xe100a40, 0xe100b40, N_INV), \
11041 X(vcmp, 0xeb40a40, 0xeb40b40, N_INV), \
11042 X(vcmpz, 0xeb50a40, 0xeb50b40, N_INV), \
11043 X(vcmpe, 0xeb40ac0, 0xeb40bc0, N_INV), \
11044 X(vcmpez, 0xeb50ac0, 0xeb50bc0, N_INV)
11048 #define X(OPC,I,F,S) N_MNEM_##OPC
11053 static const struct neon_tab_entry neon_enc_tab
[] =
11055 #define X(OPC,I,F,S) { (I), (F), (S) }
11060 #define NEON_ENC_INTEGER(X) (neon_enc_tab[(X) & 0x0fffffff].integer)
11061 #define NEON_ENC_ARMREG(X) (neon_enc_tab[(X) & 0x0fffffff].integer)
11062 #define NEON_ENC_POLY(X) (neon_enc_tab[(X) & 0x0fffffff].float_or_poly)
11063 #define NEON_ENC_FLOAT(X) (neon_enc_tab[(X) & 0x0fffffff].float_or_poly)
11064 #define NEON_ENC_SCALAR(X) (neon_enc_tab[(X) & 0x0fffffff].scalar_or_imm)
11065 #define NEON_ENC_IMMED(X) (neon_enc_tab[(X) & 0x0fffffff].scalar_or_imm)
11066 #define NEON_ENC_INTERLV(X) (neon_enc_tab[(X) & 0x0fffffff].integer)
11067 #define NEON_ENC_LANE(X) (neon_enc_tab[(X) & 0x0fffffff].float_or_poly)
11068 #define NEON_ENC_DUP(X) (neon_enc_tab[(X) & 0x0fffffff].scalar_or_imm)
11069 #define NEON_ENC_SINGLE(X) \
11070 ((neon_enc_tab[(X) & 0x0fffffff].integer) | ((X) & 0xf0000000))
11071 #define NEON_ENC_DOUBLE(X) \
11072 ((neon_enc_tab[(X) & 0x0fffffff].float_or_poly) | ((X) & 0xf0000000))
11074 /* Define shapes for instruction operands. The following mnemonic characters
11075 are used in this table:
11077 F - VFP S<n> register
11078 D - Neon D<n> register
11079 Q - Neon Q<n> register
11083 L - D<n> register list
11085 This table is used to generate various data:
11086 - enumerations of the form NS_DDR to be used as arguments to
11088 - a table classifying shapes into single, double, quad, mixed.
11089 - a table used to drive neon_select_shape. */
11091 #define NEON_SHAPE_DEF \
11092 X(3, (D, D, D), DOUBLE), \
11093 X(3, (Q, Q, Q), QUAD), \
11094 X(3, (D, D, I), DOUBLE), \
11095 X(3, (Q, Q, I), QUAD), \
11096 X(3, (D, D, S), DOUBLE), \
11097 X(3, (Q, Q, S), QUAD), \
11098 X(2, (D, D), DOUBLE), \
11099 X(2, (Q, Q), QUAD), \
11100 X(2, (D, S), DOUBLE), \
11101 X(2, (Q, S), QUAD), \
11102 X(2, (D, R), DOUBLE), \
11103 X(2, (Q, R), QUAD), \
11104 X(2, (D, I), DOUBLE), \
11105 X(2, (Q, I), QUAD), \
11106 X(3, (D, L, D), DOUBLE), \
11107 X(2, (D, Q), MIXED), \
11108 X(2, (Q, D), MIXED), \
11109 X(3, (D, Q, I), MIXED), \
11110 X(3, (Q, D, I), MIXED), \
11111 X(3, (Q, D, D), MIXED), \
11112 X(3, (D, Q, Q), MIXED), \
11113 X(3, (Q, Q, D), MIXED), \
11114 X(3, (Q, D, S), MIXED), \
11115 X(3, (D, Q, S), MIXED), \
11116 X(4, (D, D, D, I), DOUBLE), \
11117 X(4, (Q, Q, Q, I), QUAD), \
11118 X(2, (F, F), SINGLE), \
11119 X(3, (F, F, F), SINGLE), \
11120 X(2, (F, I), SINGLE), \
11121 X(2, (F, D), MIXED), \
11122 X(2, (D, F), MIXED), \
11123 X(3, (F, F, I), MIXED), \
11124 X(4, (R, R, F, F), SINGLE), \
11125 X(4, (F, F, R, R), SINGLE), \
11126 X(3, (D, R, R), DOUBLE), \
11127 X(3, (R, R, D), DOUBLE), \
11128 X(2, (S, R), SINGLE), \
11129 X(2, (R, S), SINGLE), \
11130 X(2, (F, R), SINGLE), \
11131 X(2, (R, F), SINGLE)
11133 #define S2(A,B) NS_##A##B
11134 #define S3(A,B,C) NS_##A##B##C
11135 #define S4(A,B,C,D) NS_##A##B##C##D
11137 #define X(N, L, C) S##N L
11150 enum neon_shape_class
11158 #define X(N, L, C) SC_##C
11160 static enum neon_shape_class neon_shape_class
[] =
11178 /* Register widths of above. */
11179 static unsigned neon_shape_el_size
[] =
11190 struct neon_shape_info
11193 enum neon_shape_el el
[NEON_MAX_TYPE_ELS
];
11196 #define S2(A,B) { SE_##A, SE_##B }
11197 #define S3(A,B,C) { SE_##A, SE_##B, SE_##C }
11198 #define S4(A,B,C,D) { SE_##A, SE_##B, SE_##C, SE_##D }
11200 #define X(N, L, C) { N, S##N L }
11202 static struct neon_shape_info neon_shape_tab
[] =
11212 /* Bit masks used in type checking given instructions.
11213 'N_EQK' means the type must be the same as (or based on in some way) the key
11214 type, which itself is marked with the 'N_KEY' bit. If the 'N_EQK' bit is
11215 set, various other bits can be set as well in order to modify the meaning of
11216 the type constraint. */
11218 enum neon_type_mask
11241 N_KEY
= 0x1000000, /* key element (main type specifier). */
11242 N_EQK
= 0x2000000, /* given operand has the same type & size as the key. */
11243 N_VFP
= 0x4000000, /* VFP mode: operand size must match register width. */
11244 N_DBL
= 0x0000001, /* if N_EQK, this operand is twice the size. */
11245 N_HLF
= 0x0000002, /* if N_EQK, this operand is half the size. */
11246 N_SGN
= 0x0000004, /* if N_EQK, this operand is forced to be signed. */
11247 N_UNS
= 0x0000008, /* if N_EQK, this operand is forced to be unsigned. */
11248 N_INT
= 0x0000010, /* if N_EQK, this operand is forced to be integer. */
11249 N_FLT
= 0x0000020, /* if N_EQK, this operand is forced to be float. */
11250 N_SIZ
= 0x0000040, /* if N_EQK, this operand is forced to be size-only. */
11252 N_MAX_NONSPECIAL
= N_F64
11255 #define N_ALLMODS (N_DBL | N_HLF | N_SGN | N_UNS | N_INT | N_FLT | N_SIZ)
11257 #define N_SU_ALL (N_S8 | N_S16 | N_S32 | N_S64 | N_U8 | N_U16 | N_U32 | N_U64)
11258 #define N_SU_32 (N_S8 | N_S16 | N_S32 | N_U8 | N_U16 | N_U32)
11259 #define N_SU_16_64 (N_S16 | N_S32 | N_S64 | N_U16 | N_U32 | N_U64)
11260 #define N_SUF_32 (N_SU_32 | N_F32)
11261 #define N_I_ALL (N_I8 | N_I16 | N_I32 | N_I64)
11262 #define N_IF_32 (N_I8 | N_I16 | N_I32 | N_F32)
11264 /* Pass this as the first type argument to neon_check_type to ignore types
11266 #define N_IGNORE_TYPE (N_KEY | N_EQK)
11268 /* Select a "shape" for the current instruction (describing register types or
11269 sizes) from a list of alternatives. Return NS_NULL if the current instruction
11270 doesn't fit. For non-polymorphic shapes, checking is usually done as a
11271 function of operand parsing, so this function doesn't need to be called.
11272 Shapes should be listed in order of decreasing length. */
11274 static enum neon_shape
11275 neon_select_shape (enum neon_shape shape
, ...)
11278 enum neon_shape first_shape
= shape
;
11280 /* Fix missing optional operands. FIXME: we don't know at this point how
11281 many arguments we should have, so this makes the assumption that we have
11282 > 1. This is true of all current Neon opcodes, I think, but may not be
11283 true in the future. */
11284 if (!inst
.operands
[1].present
)
11285 inst
.operands
[1] = inst
.operands
[0];
11287 va_start (ap
, shape
);
11289 for (; shape
!= NS_NULL
; shape
= va_arg (ap
, int))
11294 for (j
= 0; j
< neon_shape_tab
[shape
].els
; j
++)
11296 if (!inst
.operands
[j
].present
)
11302 switch (neon_shape_tab
[shape
].el
[j
])
11305 if (!(inst
.operands
[j
].isreg
11306 && inst
.operands
[j
].isvec
11307 && inst
.operands
[j
].issingle
11308 && !inst
.operands
[j
].isquad
))
11313 if (!(inst
.operands
[j
].isreg
11314 && inst
.operands
[j
].isvec
11315 && !inst
.operands
[j
].isquad
11316 && !inst
.operands
[j
].issingle
))
11321 if (!(inst
.operands
[j
].isreg
11322 && !inst
.operands
[j
].isvec
))
11327 if (!(inst
.operands
[j
].isreg
11328 && inst
.operands
[j
].isvec
11329 && inst
.operands
[j
].isquad
11330 && !inst
.operands
[j
].issingle
))
11335 if (!(!inst
.operands
[j
].isreg
11336 && !inst
.operands
[j
].isscalar
))
11341 if (!(!inst
.operands
[j
].isreg
11342 && inst
.operands
[j
].isscalar
))
11356 if (shape
== NS_NULL
&& first_shape
!= NS_NULL
)
11357 first_error (_("invalid instruction shape"));
11362 /* True if SHAPE is predominantly a quadword operation (most of the time, this
11363 means the Q bit should be set). */
11366 neon_quad (enum neon_shape shape
)
11368 return neon_shape_class
[shape
] == SC_QUAD
;
11372 neon_modify_type_size (unsigned typebits
, enum neon_el_type
*g_type
,
11375 /* Allow modification to be made to types which are constrained to be
11376 based on the key element, based on bits set alongside N_EQK. */
11377 if ((typebits
& N_EQK
) != 0)
11379 if ((typebits
& N_HLF
) != 0)
11381 else if ((typebits
& N_DBL
) != 0)
11383 if ((typebits
& N_SGN
) != 0)
11384 *g_type
= NT_signed
;
11385 else if ((typebits
& N_UNS
) != 0)
11386 *g_type
= NT_unsigned
;
11387 else if ((typebits
& N_INT
) != 0)
11388 *g_type
= NT_integer
;
11389 else if ((typebits
& N_FLT
) != 0)
11390 *g_type
= NT_float
;
11391 else if ((typebits
& N_SIZ
) != 0)
11392 *g_type
= NT_untyped
;
11396 /* Return operand OPNO promoted by bits set in THISARG. KEY should be the "key"
11397 operand type, i.e. the single type specified in a Neon instruction when it
11398 is the only one given. */
11400 static struct neon_type_el
11401 neon_type_promote (struct neon_type_el
*key
, unsigned thisarg
)
11403 struct neon_type_el dest
= *key
;
11405 gas_assert ((thisarg
& N_EQK
) != 0);
11407 neon_modify_type_size (thisarg
, &dest
.type
, &dest
.size
);
11412 /* Convert Neon type and size into compact bitmask representation. */
11414 static enum neon_type_mask
11415 type_chk_of_el_type (enum neon_el_type type
, unsigned size
)
11422 case 8: return N_8
;
11423 case 16: return N_16
;
11424 case 32: return N_32
;
11425 case 64: return N_64
;
11433 case 8: return N_I8
;
11434 case 16: return N_I16
;
11435 case 32: return N_I32
;
11436 case 64: return N_I64
;
11444 case 16: return N_F16
;
11445 case 32: return N_F32
;
11446 case 64: return N_F64
;
11454 case 8: return N_P8
;
11455 case 16: return N_P16
;
11463 case 8: return N_S8
;
11464 case 16: return N_S16
;
11465 case 32: return N_S32
;
11466 case 64: return N_S64
;
11474 case 8: return N_U8
;
11475 case 16: return N_U16
;
11476 case 32: return N_U32
;
11477 case 64: return N_U64
;
11488 /* Convert compact Neon bitmask type representation to a type and size. Only
11489 handles the case where a single bit is set in the mask. */
11492 el_type_of_type_chk (enum neon_el_type
*type
, unsigned *size
,
11493 enum neon_type_mask mask
)
11495 if ((mask
& N_EQK
) != 0)
11498 if ((mask
& (N_S8
| N_U8
| N_I8
| N_8
| N_P8
)) != 0)
11500 else if ((mask
& (N_S16
| N_U16
| N_I16
| N_16
| N_P16
)) != 0)
11502 else if ((mask
& (N_S32
| N_U32
| N_I32
| N_32
| N_F32
)) != 0)
11504 else if ((mask
& (N_S64
| N_U64
| N_I64
| N_64
| N_F64
)) != 0)
11509 if ((mask
& (N_S8
| N_S16
| N_S32
| N_S64
)) != 0)
11511 else if ((mask
& (N_U8
| N_U16
| N_U32
| N_U64
)) != 0)
11512 *type
= NT_unsigned
;
11513 else if ((mask
& (N_I8
| N_I16
| N_I32
| N_I64
)) != 0)
11514 *type
= NT_integer
;
11515 else if ((mask
& (N_8
| N_16
| N_32
| N_64
)) != 0)
11516 *type
= NT_untyped
;
11517 else if ((mask
& (N_P8
| N_P16
)) != 0)
11519 else if ((mask
& (N_F32
| N_F64
)) != 0)
11527 /* Modify a bitmask of allowed types. This is only needed for type
11531 modify_types_allowed (unsigned allowed
, unsigned mods
)
11534 enum neon_el_type type
;
11540 for (i
= 1; i
<= N_MAX_NONSPECIAL
; i
<<= 1)
11542 if (el_type_of_type_chk (&type
, &size
, allowed
& i
) == SUCCESS
)
11544 neon_modify_type_size (mods
, &type
, &size
);
11545 destmask
|= type_chk_of_el_type (type
, size
);
11552 /* Check type and return type classification.
11553 The manual states (paraphrase): If one datatype is given, it indicates the
11555 - the second operand, if there is one
11556 - the operand, if there is no second operand
11557 - the result, if there are no operands.
11558 This isn't quite good enough though, so we use a concept of a "key" datatype
11559 which is set on a per-instruction basis, which is the one which matters when
11560 only one data type is written.
11561 Note: this function has side-effects (e.g. filling in missing operands). All
11562 Neon instructions should call it before performing bit encoding. */
11564 static struct neon_type_el
11565 neon_check_type (unsigned els
, enum neon_shape ns
, ...)
11568 unsigned i
, pass
, key_el
= 0;
11569 unsigned types
[NEON_MAX_TYPE_ELS
];
11570 enum neon_el_type k_type
= NT_invtype
;
11571 unsigned k_size
= -1u;
11572 struct neon_type_el badtype
= {NT_invtype
, -1};
11573 unsigned key_allowed
= 0;
11575 /* Optional registers in Neon instructions are always (not) in operand 1.
11576 Fill in the missing operand here, if it was omitted. */
11577 if (els
> 1 && !inst
.operands
[1].present
)
11578 inst
.operands
[1] = inst
.operands
[0];
11580 /* Suck up all the varargs. */
11582 for (i
= 0; i
< els
; i
++)
11584 unsigned thisarg
= va_arg (ap
, unsigned);
11585 if (thisarg
== N_IGNORE_TYPE
)
11590 types
[i
] = thisarg
;
11591 if ((thisarg
& N_KEY
) != 0)
11596 if (inst
.vectype
.elems
> 0)
11597 for (i
= 0; i
< els
; i
++)
11598 if (inst
.operands
[i
].vectype
.type
!= NT_invtype
)
11600 first_error (_("types specified in both the mnemonic and operands"));
11604 /* Duplicate inst.vectype elements here as necessary.
11605 FIXME: No idea if this is exactly the same as the ARM assembler,
11606 particularly when an insn takes one register and one non-register
11608 if (inst
.vectype
.elems
== 1 && els
> 1)
11611 inst
.vectype
.elems
= els
;
11612 inst
.vectype
.el
[key_el
] = inst
.vectype
.el
[0];
11613 for (j
= 0; j
< els
; j
++)
11615 inst
.vectype
.el
[j
] = neon_type_promote (&inst
.vectype
.el
[key_el
],
11618 else if (inst
.vectype
.elems
== 0 && els
> 0)
11621 /* No types were given after the mnemonic, so look for types specified
11622 after each operand. We allow some flexibility here; as long as the
11623 "key" operand has a type, we can infer the others. */
11624 for (j
= 0; j
< els
; j
++)
11625 if (inst
.operands
[j
].vectype
.type
!= NT_invtype
)
11626 inst
.vectype
.el
[j
] = inst
.operands
[j
].vectype
;
11628 if (inst
.operands
[key_el
].vectype
.type
!= NT_invtype
)
11630 for (j
= 0; j
< els
; j
++)
11631 if (inst
.operands
[j
].vectype
.type
== NT_invtype
)
11632 inst
.vectype
.el
[j
] = neon_type_promote (&inst
.vectype
.el
[key_el
],
11637 first_error (_("operand types can't be inferred"));
11641 else if (inst
.vectype
.elems
!= els
)
11643 first_error (_("type specifier has the wrong number of parts"));
11647 for (pass
= 0; pass
< 2; pass
++)
11649 for (i
= 0; i
< els
; i
++)
11651 unsigned thisarg
= types
[i
];
11652 unsigned types_allowed
= ((thisarg
& N_EQK
) != 0 && pass
!= 0)
11653 ? modify_types_allowed (key_allowed
, thisarg
) : thisarg
;
11654 enum neon_el_type g_type
= inst
.vectype
.el
[i
].type
;
11655 unsigned g_size
= inst
.vectype
.el
[i
].size
;
11657 /* Decay more-specific signed & unsigned types to sign-insensitive
11658 integer types if sign-specific variants are unavailable. */
11659 if ((g_type
== NT_signed
|| g_type
== NT_unsigned
)
11660 && (types_allowed
& N_SU_ALL
) == 0)
11661 g_type
= NT_integer
;
11663 /* If only untyped args are allowed, decay any more specific types to
11664 them. Some instructions only care about signs for some element
11665 sizes, so handle that properly. */
11666 if ((g_size
== 8 && (types_allowed
& N_8
) != 0)
11667 || (g_size
== 16 && (types_allowed
& N_16
) != 0)
11668 || (g_size
== 32 && (types_allowed
& N_32
) != 0)
11669 || (g_size
== 64 && (types_allowed
& N_64
) != 0))
11670 g_type
= NT_untyped
;
11674 if ((thisarg
& N_KEY
) != 0)
11678 key_allowed
= thisarg
& ~N_KEY
;
11683 if ((thisarg
& N_VFP
) != 0)
11685 enum neon_shape_el regshape
= neon_shape_tab
[ns
].el
[i
];
11686 unsigned regwidth
= neon_shape_el_size
[regshape
], match
;
11688 /* In VFP mode, operands must match register widths. If we
11689 have a key operand, use its width, else use the width of
11690 the current operand. */
11696 if (regwidth
!= match
)
11698 first_error (_("operand size must match register width"));
11703 if ((thisarg
& N_EQK
) == 0)
11705 unsigned given_type
= type_chk_of_el_type (g_type
, g_size
);
11707 if ((given_type
& types_allowed
) == 0)
11709 first_error (_("bad type in Neon instruction"));
11715 enum neon_el_type mod_k_type
= k_type
;
11716 unsigned mod_k_size
= k_size
;
11717 neon_modify_type_size (thisarg
, &mod_k_type
, &mod_k_size
);
11718 if (g_type
!= mod_k_type
|| g_size
!= mod_k_size
)
11720 first_error (_("inconsistent types in Neon instruction"));
11728 return inst
.vectype
.el
[key_el
];
11731 /* Neon-style VFP instruction forwarding. */
11733 /* Thumb VFP instructions have 0xE in the condition field. */
11736 do_vfp_cond_or_thumb (void)
11739 inst
.instruction
|= 0xe0000000;
11741 inst
.instruction
|= inst
.cond
<< 28;
11744 /* Look up and encode a simple mnemonic, for use as a helper function for the
11745 Neon-style VFP syntax. This avoids duplication of bits of the insns table,
11746 etc. It is assumed that operand parsing has already been done, and that the
11747 operands are in the form expected by the given opcode (this isn't necessarily
11748 the same as the form in which they were parsed, hence some massaging must
11749 take place before this function is called).
11750 Checks current arch version against that in the looked-up opcode. */
11753 do_vfp_nsyn_opcode (const char *opname
)
11755 const struct asm_opcode
*opcode
;
11757 opcode
= hash_find (arm_ops_hsh
, opname
);
11762 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant
,
11763 thumb_mode
? *opcode
->tvariant
: *opcode
->avariant
),
11768 inst
.instruction
= opcode
->tvalue
;
11769 opcode
->tencode ();
11773 inst
.instruction
= (inst
.cond
<< 28) | opcode
->avalue
;
11774 opcode
->aencode ();
11779 do_vfp_nsyn_add_sub (enum neon_shape rs
)
11781 int is_add
= (inst
.instruction
& 0x0fffffff) == N_MNEM_vadd
;
11786 do_vfp_nsyn_opcode ("fadds");
11788 do_vfp_nsyn_opcode ("fsubs");
11793 do_vfp_nsyn_opcode ("faddd");
11795 do_vfp_nsyn_opcode ("fsubd");
11799 /* Check operand types to see if this is a VFP instruction, and if so call
11803 try_vfp_nsyn (int args
, void (*pfn
) (enum neon_shape
))
11805 enum neon_shape rs
;
11806 struct neon_type_el et
;
11811 rs
= neon_select_shape (NS_FF
, NS_DD
, NS_NULL
);
11812 et
= neon_check_type (2, rs
,
11813 N_EQK
| N_VFP
, N_F32
| N_F64
| N_KEY
| N_VFP
);
11817 rs
= neon_select_shape (NS_FFF
, NS_DDD
, NS_NULL
);
11818 et
= neon_check_type (3, rs
,
11819 N_EQK
| N_VFP
, N_EQK
| N_VFP
, N_F32
| N_F64
| N_KEY
| N_VFP
);
11826 if (et
.type
!= NT_invtype
)
11838 do_vfp_nsyn_mla_mls (enum neon_shape rs
)
11840 int is_mla
= (inst
.instruction
& 0x0fffffff) == N_MNEM_vmla
;
11845 do_vfp_nsyn_opcode ("fmacs");
11847 do_vfp_nsyn_opcode ("fmscs");
11852 do_vfp_nsyn_opcode ("fmacd");
11854 do_vfp_nsyn_opcode ("fmscd");
11859 do_vfp_nsyn_mul (enum neon_shape rs
)
11862 do_vfp_nsyn_opcode ("fmuls");
11864 do_vfp_nsyn_opcode ("fmuld");
11868 do_vfp_nsyn_abs_neg (enum neon_shape rs
)
11870 int is_neg
= (inst
.instruction
& 0x80) != 0;
11871 neon_check_type (2, rs
, N_EQK
| N_VFP
, N_F32
| N_F64
| N_VFP
| N_KEY
);
11876 do_vfp_nsyn_opcode ("fnegs");
11878 do_vfp_nsyn_opcode ("fabss");
11883 do_vfp_nsyn_opcode ("fnegd");
11885 do_vfp_nsyn_opcode ("fabsd");
11889 /* Encode single-precision (only!) VFP fldm/fstm instructions. Double precision
11890 insns belong to Neon, and are handled elsewhere. */
11893 do_vfp_nsyn_ldm_stm (int is_dbmode
)
11895 int is_ldm
= (inst
.instruction
& (1 << 20)) != 0;
11899 do_vfp_nsyn_opcode ("fldmdbs");
11901 do_vfp_nsyn_opcode ("fldmias");
11906 do_vfp_nsyn_opcode ("fstmdbs");
11908 do_vfp_nsyn_opcode ("fstmias");
11913 do_vfp_nsyn_sqrt (void)
11915 enum neon_shape rs
= neon_select_shape (NS_FF
, NS_DD
, NS_NULL
);
11916 neon_check_type (2, rs
, N_EQK
| N_VFP
, N_F32
| N_F64
| N_KEY
| N_VFP
);
11919 do_vfp_nsyn_opcode ("fsqrts");
11921 do_vfp_nsyn_opcode ("fsqrtd");
11925 do_vfp_nsyn_div (void)
11927 enum neon_shape rs
= neon_select_shape (NS_FFF
, NS_DDD
, NS_NULL
);
11928 neon_check_type (3, rs
, N_EQK
| N_VFP
, N_EQK
| N_VFP
,
11929 N_F32
| N_F64
| N_KEY
| N_VFP
);
11932 do_vfp_nsyn_opcode ("fdivs");
11934 do_vfp_nsyn_opcode ("fdivd");
11938 do_vfp_nsyn_nmul (void)
11940 enum neon_shape rs
= neon_select_shape (NS_FFF
, NS_DDD
, NS_NULL
);
11941 neon_check_type (3, rs
, N_EQK
| N_VFP
, N_EQK
| N_VFP
,
11942 N_F32
| N_F64
| N_KEY
| N_VFP
);
11946 inst
.instruction
= NEON_ENC_SINGLE (inst
.instruction
);
11947 do_vfp_sp_dyadic ();
11951 inst
.instruction
= NEON_ENC_DOUBLE (inst
.instruction
);
11952 do_vfp_dp_rd_rn_rm ();
11954 do_vfp_cond_or_thumb ();
11958 do_vfp_nsyn_cmp (void)
11960 if (inst
.operands
[1].isreg
)
11962 enum neon_shape rs
= neon_select_shape (NS_FF
, NS_DD
, NS_NULL
);
11963 neon_check_type (2, rs
, N_EQK
| N_VFP
, N_F32
| N_F64
| N_KEY
| N_VFP
);
11967 inst
.instruction
= NEON_ENC_SINGLE (inst
.instruction
);
11968 do_vfp_sp_monadic ();
11972 inst
.instruction
= NEON_ENC_DOUBLE (inst
.instruction
);
11973 do_vfp_dp_rd_rm ();
11978 enum neon_shape rs
= neon_select_shape (NS_FI
, NS_DI
, NS_NULL
);
11979 neon_check_type (2, rs
, N_F32
| N_F64
| N_KEY
| N_VFP
, N_EQK
);
11981 switch (inst
.instruction
& 0x0fffffff)
11984 inst
.instruction
+= N_MNEM_vcmpz
- N_MNEM_vcmp
;
11987 inst
.instruction
+= N_MNEM_vcmpez
- N_MNEM_vcmpe
;
11995 inst
.instruction
= NEON_ENC_SINGLE (inst
.instruction
);
11996 do_vfp_sp_compare_z ();
12000 inst
.instruction
= NEON_ENC_DOUBLE (inst
.instruction
);
12004 do_vfp_cond_or_thumb ();
12008 nsyn_insert_sp (void)
12010 inst
.operands
[1] = inst
.operands
[0];
12011 memset (&inst
.operands
[0], '\0', sizeof (inst
.operands
[0]));
12012 inst
.operands
[0].reg
= REG_SP
;
12013 inst
.operands
[0].isreg
= 1;
12014 inst
.operands
[0].writeback
= 1;
12015 inst
.operands
[0].present
= 1;
12019 do_vfp_nsyn_push (void)
12022 if (inst
.operands
[1].issingle
)
12023 do_vfp_nsyn_opcode ("fstmdbs");
12025 do_vfp_nsyn_opcode ("fstmdbd");
12029 do_vfp_nsyn_pop (void)
12032 if (inst
.operands
[1].issingle
)
12033 do_vfp_nsyn_opcode ("fldmias");
12035 do_vfp_nsyn_opcode ("fldmiad");
12038 /* Fix up Neon data-processing instructions, ORing in the correct bits for
12039 ARM mode or Thumb mode and moving the encoded bit 24 to bit 28. */
12042 neon_dp_fixup (unsigned i
)
12046 /* The U bit is at bit 24 by default. Move to bit 28 in Thumb mode. */
12060 /* Turn a size (8, 16, 32, 64) into the respective bit number minus 3
12064 neon_logbits (unsigned x
)
12066 return ffs (x
) - 4;
12069 #define LOW4(R) ((R) & 0xf)
12070 #define HI1(R) (((R) >> 4) & 1)
12072 /* Encode insns with bit pattern:
12074 |28/24|23|22 |21 20|19 16|15 12|11 8|7|6|5|4|3 0|
12075 | U |x |D |size | Rn | Rd |x x x x|N|Q|M|x| Rm |
12077 SIZE is passed in bits. -1 means size field isn't changed, in case it has a
12078 different meaning for some instruction. */
12081 neon_three_same (int isquad
, int ubit
, int size
)
12083 inst
.instruction
|= LOW4 (inst
.operands
[0].reg
) << 12;
12084 inst
.instruction
|= HI1 (inst
.operands
[0].reg
) << 22;
12085 inst
.instruction
|= LOW4 (inst
.operands
[1].reg
) << 16;
12086 inst
.instruction
|= HI1 (inst
.operands
[1].reg
) << 7;
12087 inst
.instruction
|= LOW4 (inst
.operands
[2].reg
);
12088 inst
.instruction
|= HI1 (inst
.operands
[2].reg
) << 5;
12089 inst
.instruction
|= (isquad
!= 0) << 6;
12090 inst
.instruction
|= (ubit
!= 0) << 24;
12092 inst
.instruction
|= neon_logbits (size
) << 20;
12094 inst
.instruction
= neon_dp_fixup (inst
.instruction
);
12097 /* Encode instructions of the form:
12099 |28/24|23|22|21 20|19 18|17 16|15 12|11 7|6|5|4|3 0|
12100 | U |x |D |x x |size |x x | Rd |x x x x x|Q|M|x| Rm |
12102 Don't write size if SIZE == -1. */
12105 neon_two_same (int qbit
, int ubit
, int size
)
12107 inst
.instruction
|= LOW4 (inst
.operands
[0].reg
) << 12;
12108 inst
.instruction
|= HI1 (inst
.operands
[0].reg
) << 22;
12109 inst
.instruction
|= LOW4 (inst
.operands
[1].reg
);
12110 inst
.instruction
|= HI1 (inst
.operands
[1].reg
) << 5;
12111 inst
.instruction
|= (qbit
!= 0) << 6;
12112 inst
.instruction
|= (ubit
!= 0) << 24;
12115 inst
.instruction
|= neon_logbits (size
) << 18;
12117 inst
.instruction
= neon_dp_fixup (inst
.instruction
);
12120 /* Neon instruction encoders, in approximate order of appearance. */
12123 do_neon_dyadic_i_su (void)
12125 enum neon_shape rs
= neon_select_shape (NS_DDD
, NS_QQQ
, NS_NULL
);
12126 struct neon_type_el et
= neon_check_type (3, rs
,
12127 N_EQK
, N_EQK
, N_SU_32
| N_KEY
);
12128 neon_three_same (neon_quad (rs
), et
.type
== NT_unsigned
, et
.size
);
12132 do_neon_dyadic_i64_su (void)
12134 enum neon_shape rs
= neon_select_shape (NS_DDD
, NS_QQQ
, NS_NULL
);
12135 struct neon_type_el et
= neon_check_type (3, rs
,
12136 N_EQK
, N_EQK
, N_SU_ALL
| N_KEY
);
12137 neon_three_same (neon_quad (rs
), et
.type
== NT_unsigned
, et
.size
);
12141 neon_imm_shift (int write_ubit
, int uval
, int isquad
, struct neon_type_el et
,
12144 unsigned size
= et
.size
>> 3;
12145 inst
.instruction
|= LOW4 (inst
.operands
[0].reg
) << 12;
12146 inst
.instruction
|= HI1 (inst
.operands
[0].reg
) << 22;
12147 inst
.instruction
|= LOW4 (inst
.operands
[1].reg
);
12148 inst
.instruction
|= HI1 (inst
.operands
[1].reg
) << 5;
12149 inst
.instruction
|= (isquad
!= 0) << 6;
12150 inst
.instruction
|= immbits
<< 16;
12151 inst
.instruction
|= (size
>> 3) << 7;
12152 inst
.instruction
|= (size
& 0x7) << 19;
12154 inst
.instruction
|= (uval
!= 0) << 24;
12156 inst
.instruction
= neon_dp_fixup (inst
.instruction
);
12160 do_neon_shl_imm (void)
12162 if (!inst
.operands
[2].isreg
)
12164 enum neon_shape rs
= neon_select_shape (NS_DDI
, NS_QQI
, NS_NULL
);
12165 struct neon_type_el et
= neon_check_type (2, rs
, N_EQK
, N_KEY
| N_I_ALL
);
12166 inst
.instruction
= NEON_ENC_IMMED (inst
.instruction
);
12167 neon_imm_shift (FALSE
, 0, neon_quad (rs
), et
, inst
.operands
[2].imm
);
12171 enum neon_shape rs
= neon_select_shape (NS_DDD
, NS_QQQ
, NS_NULL
);
12172 struct neon_type_el et
= neon_check_type (3, rs
,
12173 N_EQK
, N_SU_ALL
| N_KEY
, N_EQK
| N_SGN
);
12176 /* VSHL/VQSHL 3-register variants have syntax such as:
12178 whereas other 3-register operations encoded by neon_three_same have
12181 (i.e. with Dn & Dm reversed). Swap operands[1].reg and operands[2].reg
12183 tmp
= inst
.operands
[2].reg
;
12184 inst
.operands
[2].reg
= inst
.operands
[1].reg
;
12185 inst
.operands
[1].reg
= tmp
;
12186 inst
.instruction
= NEON_ENC_INTEGER (inst
.instruction
);
12187 neon_three_same (neon_quad (rs
), et
.type
== NT_unsigned
, et
.size
);
12192 do_neon_qshl_imm (void)
12194 if (!inst
.operands
[2].isreg
)
12196 enum neon_shape rs
= neon_select_shape (NS_DDI
, NS_QQI
, NS_NULL
);
12197 struct neon_type_el et
= neon_check_type (2, rs
, N_EQK
, N_SU_ALL
| N_KEY
);
12199 inst
.instruction
= NEON_ENC_IMMED (inst
.instruction
);
12200 neon_imm_shift (TRUE
, et
.type
== NT_unsigned
, neon_quad (rs
), et
,
12201 inst
.operands
[2].imm
);
12205 enum neon_shape rs
= neon_select_shape (NS_DDD
, NS_QQQ
, NS_NULL
);
12206 struct neon_type_el et
= neon_check_type (3, rs
,
12207 N_EQK
, N_SU_ALL
| N_KEY
, N_EQK
| N_SGN
);
12210 /* See note in do_neon_shl_imm. */
12211 tmp
= inst
.operands
[2].reg
;
12212 inst
.operands
[2].reg
= inst
.operands
[1].reg
;
12213 inst
.operands
[1].reg
= tmp
;
12214 inst
.instruction
= NEON_ENC_INTEGER (inst
.instruction
);
12215 neon_three_same (neon_quad (rs
), et
.type
== NT_unsigned
, et
.size
);
12220 do_neon_rshl (void)
12222 enum neon_shape rs
= neon_select_shape (NS_DDD
, NS_QQQ
, NS_NULL
);
12223 struct neon_type_el et
= neon_check_type (3, rs
,
12224 N_EQK
, N_EQK
, N_SU_ALL
| N_KEY
);
12227 tmp
= inst
.operands
[2].reg
;
12228 inst
.operands
[2].reg
= inst
.operands
[1].reg
;
12229 inst
.operands
[1].reg
= tmp
;
12230 neon_three_same (neon_quad (rs
), et
.type
== NT_unsigned
, et
.size
);
12234 neon_cmode_for_logic_imm (unsigned immediate
, unsigned *immbits
, int size
)
12236 /* Handle .I8 pseudo-instructions. */
12239 /* Unfortunately, this will make everything apart from zero out-of-range.
12240 FIXME is this the intended semantics? There doesn't seem much point in
12241 accepting .I8 if so. */
12242 immediate
|= immediate
<< 8;
12248 if (immediate
== (immediate
& 0x000000ff))
12250 *immbits
= immediate
;
12253 else if (immediate
== (immediate
& 0x0000ff00))
12255 *immbits
= immediate
>> 8;
12258 else if (immediate
== (immediate
& 0x00ff0000))
12260 *immbits
= immediate
>> 16;
12263 else if (immediate
== (immediate
& 0xff000000))
12265 *immbits
= immediate
>> 24;
12268 if ((immediate
& 0xffff) != (immediate
>> 16))
12269 goto bad_immediate
;
12270 immediate
&= 0xffff;
12273 if (immediate
== (immediate
& 0x000000ff))
12275 *immbits
= immediate
;
12278 else if (immediate
== (immediate
& 0x0000ff00))
12280 *immbits
= immediate
>> 8;
12285 first_error (_("immediate value out of range"));
12289 /* True if IMM has form 0bAAAAAAAABBBBBBBBCCCCCCCCDDDDDDDD for bits
12293 neon_bits_same_in_bytes (unsigned imm
)
12295 return ((imm
& 0x000000ff) == 0 || (imm
& 0x000000ff) == 0x000000ff)
12296 && ((imm
& 0x0000ff00) == 0 || (imm
& 0x0000ff00) == 0x0000ff00)
12297 && ((imm
& 0x00ff0000) == 0 || (imm
& 0x00ff0000) == 0x00ff0000)
12298 && ((imm
& 0xff000000) == 0 || (imm
& 0xff000000) == 0xff000000);
12301 /* For immediate of above form, return 0bABCD. */
12304 neon_squash_bits (unsigned imm
)
12306 return (imm
& 0x01) | ((imm
& 0x0100) >> 7) | ((imm
& 0x010000) >> 14)
12307 | ((imm
& 0x01000000) >> 21);
12310 /* Compress quarter-float representation to 0b...000 abcdefgh. */
12313 neon_qfloat_bits (unsigned imm
)
12315 return ((imm
>> 19) & 0x7f) | ((imm
>> 24) & 0x80);
12318 /* Returns CMODE. IMMBITS [7:0] is set to bits suitable for inserting into
12319 the instruction. *OP is passed as the initial value of the op field, and
12320 may be set to a different value depending on the constant (i.e.
12321 "MOV I64, 0bAAAAAAAABBBB..." which uses OP = 1 despite being MOV not
12322 MVN). If the immediate looks like a repeated pattern then also
12323 try smaller element sizes. */
12326 neon_cmode_for_move_imm (unsigned immlo
, unsigned immhi
, int float_p
,
12327 unsigned *immbits
, int *op
, int size
,
12328 enum neon_el_type type
)
12330 /* Only permit float immediates (including 0.0/-0.0) if the operand type is
12332 if (type
== NT_float
&& !float_p
)
12335 if (type
== NT_float
&& is_quarter_float (immlo
) && immhi
== 0)
12337 if (size
!= 32 || *op
== 1)
12339 *immbits
= neon_qfloat_bits (immlo
);
12345 if (neon_bits_same_in_bytes (immhi
)
12346 && neon_bits_same_in_bytes (immlo
))
12350 *immbits
= (neon_squash_bits (immhi
) << 4)
12351 | neon_squash_bits (immlo
);
12356 if (immhi
!= immlo
)
12362 if (immlo
== (immlo
& 0x000000ff))
12367 else if (immlo
== (immlo
& 0x0000ff00))
12369 *immbits
= immlo
>> 8;
12372 else if (immlo
== (immlo
& 0x00ff0000))
12374 *immbits
= immlo
>> 16;
12377 else if (immlo
== (immlo
& 0xff000000))
12379 *immbits
= immlo
>> 24;
12382 else if (immlo
== ((immlo
& 0x0000ff00) | 0x000000ff))
12384 *immbits
= (immlo
>> 8) & 0xff;
12387 else if (immlo
== ((immlo
& 0x00ff0000) | 0x0000ffff))
12389 *immbits
= (immlo
>> 16) & 0xff;
12393 if ((immlo
& 0xffff) != (immlo
>> 16))
12400 if (immlo
== (immlo
& 0x000000ff))
12405 else if (immlo
== (immlo
& 0x0000ff00))
12407 *immbits
= immlo
>> 8;
12411 if ((immlo
& 0xff) != (immlo
>> 8))
12416 if (immlo
== (immlo
& 0x000000ff))
12418 /* Don't allow MVN with 8-bit immediate. */
12428 /* Write immediate bits [7:0] to the following locations:
12430 |28/24|23 19|18 16|15 4|3 0|
12431 | 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|
12433 This function is used by VMOV/VMVN/VORR/VBIC. */
12436 neon_write_immbits (unsigned immbits
)
12438 inst
.instruction
|= immbits
& 0xf;
12439 inst
.instruction
|= ((immbits
>> 4) & 0x7) << 16;
12440 inst
.instruction
|= ((immbits
>> 7) & 0x1) << 24;
12443 /* Invert low-order SIZE bits of XHI:XLO. */
12446 neon_invert_size (unsigned *xlo
, unsigned *xhi
, int size
)
12448 unsigned immlo
= xlo
? *xlo
: 0;
12449 unsigned immhi
= xhi
? *xhi
: 0;
12454 immlo
= (~immlo
) & 0xff;
12458 immlo
= (~immlo
) & 0xffff;
12462 immhi
= (~immhi
) & 0xffffffff;
12463 /* fall through. */
12466 immlo
= (~immlo
) & 0xffffffff;
12481 do_neon_logic (void)
12483 if (inst
.operands
[2].present
&& inst
.operands
[2].isreg
)
12485 enum neon_shape rs
= neon_select_shape (NS_DDD
, NS_QQQ
, NS_NULL
);
12486 neon_check_type (3, rs
, N_IGNORE_TYPE
);
12487 /* U bit and size field were set as part of the bitmask. */
12488 inst
.instruction
= NEON_ENC_INTEGER (inst
.instruction
);
12489 neon_three_same (neon_quad (rs
), 0, -1);
12493 enum neon_shape rs
= neon_select_shape (NS_DI
, NS_QI
, NS_NULL
);
12494 struct neon_type_el et
= neon_check_type (2, rs
,
12495 N_I8
| N_I16
| N_I32
| N_I64
| N_F32
| N_KEY
, N_EQK
);
12496 enum neon_opc opcode
= inst
.instruction
& 0x0fffffff;
12500 if (et
.type
== NT_invtype
)
12503 inst
.instruction
= NEON_ENC_IMMED (inst
.instruction
);
12505 immbits
= inst
.operands
[1].imm
;
12508 /* .i64 is a pseudo-op, so the immediate must be a repeating
12510 if (immbits
!= (inst
.operands
[1].regisimm
?
12511 inst
.operands
[1].reg
: 0))
12513 /* Set immbits to an invalid constant. */
12514 immbits
= 0xdeadbeef;
12521 cmode
= neon_cmode_for_logic_imm (immbits
, &immbits
, et
.size
);
12525 cmode
= neon_cmode_for_logic_imm (immbits
, &immbits
, et
.size
);
12529 /* Pseudo-instruction for VBIC. */
12530 neon_invert_size (&immbits
, 0, et
.size
);
12531 cmode
= neon_cmode_for_logic_imm (immbits
, &immbits
, et
.size
);
12535 /* Pseudo-instruction for VORR. */
12536 neon_invert_size (&immbits
, 0, et
.size
);
12537 cmode
= neon_cmode_for_logic_imm (immbits
, &immbits
, et
.size
);
12547 inst
.instruction
|= neon_quad (rs
) << 6;
12548 inst
.instruction
|= LOW4 (inst
.operands
[0].reg
) << 12;
12549 inst
.instruction
|= HI1 (inst
.operands
[0].reg
) << 22;
12550 inst
.instruction
|= cmode
<< 8;
12551 neon_write_immbits (immbits
);
12553 inst
.instruction
= neon_dp_fixup (inst
.instruction
);
12558 do_neon_bitfield (void)
12560 enum neon_shape rs
= neon_select_shape (NS_DDD
, NS_QQQ
, NS_NULL
);
12561 neon_check_type (3, rs
, N_IGNORE_TYPE
);
12562 neon_three_same (neon_quad (rs
), 0, -1);
12566 neon_dyadic_misc (enum neon_el_type ubit_meaning
, unsigned types
,
12569 enum neon_shape rs
= neon_select_shape (NS_DDD
, NS_QQQ
, NS_NULL
);
12570 struct neon_type_el et
= neon_check_type (3, rs
, N_EQK
| destbits
, N_EQK
,
12572 if (et
.type
== NT_float
)
12574 inst
.instruction
= NEON_ENC_FLOAT (inst
.instruction
);
12575 neon_three_same (neon_quad (rs
), 0, -1);
12579 inst
.instruction
= NEON_ENC_INTEGER (inst
.instruction
);
12580 neon_three_same (neon_quad (rs
), et
.type
== ubit_meaning
, et
.size
);
12585 do_neon_dyadic_if_su (void)
12587 neon_dyadic_misc (NT_unsigned
, N_SUF_32
, 0);
12591 do_neon_dyadic_if_su_d (void)
12593 /* This version only allow D registers, but that constraint is enforced during
12594 operand parsing so we don't need to do anything extra here. */
12595 neon_dyadic_misc (NT_unsigned
, N_SUF_32
, 0);
12599 do_neon_dyadic_if_i_d (void)
12601 /* The "untyped" case can't happen. Do this to stop the "U" bit being
12602 affected if we specify unsigned args. */
12603 neon_dyadic_misc (NT_untyped
, N_IF_32
, 0);
12606 enum vfp_or_neon_is_neon_bits
12609 NEON_CHECK_ARCH
= 2
12612 /* Call this function if an instruction which may have belonged to the VFP or
12613 Neon instruction sets, but turned out to be a Neon instruction (due to the
12614 operand types involved, etc.). We have to check and/or fix-up a couple of
12617 - Make sure the user hasn't attempted to make a Neon instruction
12619 - Alter the value in the condition code field if necessary.
12620 - Make sure that the arch supports Neon instructions.
12622 Which of these operations take place depends on bits from enum
12623 vfp_or_neon_is_neon_bits.
12625 WARNING: This function has side effects! If NEON_CHECK_CC is used and the
12626 current instruction's condition is COND_ALWAYS, the condition field is
12627 changed to inst.uncond_value. This is necessary because instructions shared
12628 between VFP and Neon may be conditional for the VFP variants only, and the
12629 unconditional Neon version must have, e.g., 0xF in the condition field. */
12632 vfp_or_neon_is_neon (unsigned check
)
12634 /* Conditions are always legal in Thumb mode (IT blocks). */
12635 if (!thumb_mode
&& (check
& NEON_CHECK_CC
))
12637 if (inst
.cond
!= COND_ALWAYS
)
12639 first_error (_(BAD_COND
));
12642 if (inst
.uncond_value
!= -1)
12643 inst
.instruction
|= inst
.uncond_value
<< 28;
12646 if ((check
& NEON_CHECK_ARCH
)
12647 && !ARM_CPU_HAS_FEATURE (cpu_variant
, fpu_neon_ext_v1
))
12649 first_error (_(BAD_FPU
));
12657 do_neon_addsub_if_i (void)
12659 if (try_vfp_nsyn (3, do_vfp_nsyn_add_sub
) == SUCCESS
)
12662 if (vfp_or_neon_is_neon (NEON_CHECK_CC
| NEON_CHECK_ARCH
) == FAIL
)
12665 /* The "untyped" case can't happen. Do this to stop the "U" bit being
12666 affected if we specify unsigned args. */
12667 neon_dyadic_misc (NT_untyped
, N_IF_32
| N_I64
, 0);
12670 /* Swaps operands 1 and 2. If operand 1 (optional arg) was omitted, we want the
12672 V<op> A,B (A is operand 0, B is operand 2)
12677 so handle that case specially. */
12680 neon_exchange_operands (void)
12682 void *scratch
= alloca (sizeof (inst
.operands
[0]));
12683 if (inst
.operands
[1].present
)
12685 /* Swap operands[1] and operands[2]. */
12686 memcpy (scratch
, &inst
.operands
[1], sizeof (inst
.operands
[0]));
12687 inst
.operands
[1] = inst
.operands
[2];
12688 memcpy (&inst
.operands
[2], scratch
, sizeof (inst
.operands
[0]));
12692 inst
.operands
[1] = inst
.operands
[2];
12693 inst
.operands
[2] = inst
.operands
[0];
12698 neon_compare (unsigned regtypes
, unsigned immtypes
, int invert
)
12700 if (inst
.operands
[2].isreg
)
12703 neon_exchange_operands ();
12704 neon_dyadic_misc (NT_unsigned
, regtypes
, N_SIZ
);
12708 enum neon_shape rs
= neon_select_shape (NS_DDI
, NS_QQI
, NS_NULL
);
12709 struct neon_type_el et
= neon_check_type (2, rs
,
12710 N_EQK
| N_SIZ
, immtypes
| N_KEY
);
12712 inst
.instruction
= NEON_ENC_IMMED (inst
.instruction
);
12713 inst
.instruction
|= LOW4 (inst
.operands
[0].reg
) << 12;
12714 inst
.instruction
|= HI1 (inst
.operands
[0].reg
) << 22;
12715 inst
.instruction
|= LOW4 (inst
.operands
[1].reg
);
12716 inst
.instruction
|= HI1 (inst
.operands
[1].reg
) << 5;
12717 inst
.instruction
|= neon_quad (rs
) << 6;
12718 inst
.instruction
|= (et
.type
== NT_float
) << 10;
12719 inst
.instruction
|= neon_logbits (et
.size
) << 18;
12721 inst
.instruction
= neon_dp_fixup (inst
.instruction
);
12728 neon_compare (N_SUF_32
, N_S8
| N_S16
| N_S32
| N_F32
, FALSE
);
12732 do_neon_cmp_inv (void)
12734 neon_compare (N_SUF_32
, N_S8
| N_S16
| N_S32
| N_F32
, TRUE
);
12740 neon_compare (N_IF_32
, N_IF_32
, FALSE
);
12743 /* For multiply instructions, we have the possibility of 16-bit or 32-bit
12744 scalars, which are encoded in 5 bits, M : Rm.
12745 For 16-bit scalars, the register is encoded in Rm[2:0] and the index in
12746 M:Rm[3], and for 32-bit scalars, the register is encoded in Rm[3:0] and the
12750 neon_scalar_for_mul (unsigned scalar
, unsigned elsize
)
12752 unsigned regno
= NEON_SCALAR_REG (scalar
);
12753 unsigned elno
= NEON_SCALAR_INDEX (scalar
);
12758 if (regno
> 7 || elno
> 3)
12760 return regno
| (elno
<< 3);
12763 if (regno
> 15 || elno
> 1)
12765 return regno
| (elno
<< 4);
12769 first_error (_("scalar out of range for multiply instruction"));
12775 /* Encode multiply / multiply-accumulate scalar instructions. */
12778 neon_mul_mac (struct neon_type_el et
, int ubit
)
12782 /* Give a more helpful error message if we have an invalid type. */
12783 if (et
.type
== NT_invtype
)
12786 scalar
= neon_scalar_for_mul (inst
.operands
[2].reg
, et
.size
);
12787 inst
.instruction
|= LOW4 (inst
.operands
[0].reg
) << 12;
12788 inst
.instruction
|= HI1 (inst
.operands
[0].reg
) << 22;
12789 inst
.instruction
|= LOW4 (inst
.operands
[1].reg
) << 16;
12790 inst
.instruction
|= HI1 (inst
.operands
[1].reg
) << 7;
12791 inst
.instruction
|= LOW4 (scalar
);
12792 inst
.instruction
|= HI1 (scalar
) << 5;
12793 inst
.instruction
|= (et
.type
== NT_float
) << 8;
12794 inst
.instruction
|= neon_logbits (et
.size
) << 20;
12795 inst
.instruction
|= (ubit
!= 0) << 24;
12797 inst
.instruction
= neon_dp_fixup (inst
.instruction
);
12801 do_neon_mac_maybe_scalar (void)
12803 if (try_vfp_nsyn (3, do_vfp_nsyn_mla_mls
) == SUCCESS
)
12806 if (vfp_or_neon_is_neon (NEON_CHECK_CC
| NEON_CHECK_ARCH
) == FAIL
)
12809 if (inst
.operands
[2].isscalar
)
12811 enum neon_shape rs
= neon_select_shape (NS_DDS
, NS_QQS
, NS_NULL
);
12812 struct neon_type_el et
= neon_check_type (3, rs
,
12813 N_EQK
, N_EQK
, N_I16
| N_I32
| N_F32
| N_KEY
);
12814 inst
.instruction
= NEON_ENC_SCALAR (inst
.instruction
);
12815 neon_mul_mac (et
, neon_quad (rs
));
12819 /* The "untyped" case can't happen. Do this to stop the "U" bit being
12820 affected if we specify unsigned args. */
12821 neon_dyadic_misc (NT_untyped
, N_IF_32
, 0);
12828 enum neon_shape rs
= neon_select_shape (NS_DDD
, NS_QQQ
, NS_NULL
);
12829 struct neon_type_el et
= neon_check_type (3, rs
,
12830 N_EQK
, N_EQK
, N_8
| N_16
| N_32
| N_KEY
);
12831 neon_three_same (neon_quad (rs
), 0, et
.size
);
12834 /* VMUL with 3 registers allows the P8 type. The scalar version supports the
12835 same types as the MAC equivalents. The polynomial type for this instruction
12836 is encoded the same as the integer type. */
12841 if (try_vfp_nsyn (3, do_vfp_nsyn_mul
) == SUCCESS
)
12844 if (vfp_or_neon_is_neon (NEON_CHECK_CC
| NEON_CHECK_ARCH
) == FAIL
)
12847 if (inst
.operands
[2].isscalar
)
12848 do_neon_mac_maybe_scalar ();
12850 neon_dyadic_misc (NT_poly
, N_I8
| N_I16
| N_I32
| N_F32
| N_P8
, 0);
12854 do_neon_qdmulh (void)
12856 if (inst
.operands
[2].isscalar
)
12858 enum neon_shape rs
= neon_select_shape (NS_DDS
, NS_QQS
, NS_NULL
);
12859 struct neon_type_el et
= neon_check_type (3, rs
,
12860 N_EQK
, N_EQK
, N_S16
| N_S32
| N_KEY
);
12861 inst
.instruction
= NEON_ENC_SCALAR (inst
.instruction
);
12862 neon_mul_mac (et
, neon_quad (rs
));
12866 enum neon_shape rs
= neon_select_shape (NS_DDD
, NS_QQQ
, NS_NULL
);
12867 struct neon_type_el et
= neon_check_type (3, rs
,
12868 N_EQK
, N_EQK
, N_S16
| N_S32
| N_KEY
);
12869 inst
.instruction
= NEON_ENC_INTEGER (inst
.instruction
);
12870 /* The U bit (rounding) comes from bit mask. */
12871 neon_three_same (neon_quad (rs
), 0, et
.size
);
12876 do_neon_fcmp_absolute (void)
12878 enum neon_shape rs
= neon_select_shape (NS_DDD
, NS_QQQ
, NS_NULL
);
12879 neon_check_type (3, rs
, N_EQK
, N_EQK
, N_F32
| N_KEY
);
12880 /* Size field comes from bit mask. */
12881 neon_three_same (neon_quad (rs
), 1, -1);
12885 do_neon_fcmp_absolute_inv (void)
12887 neon_exchange_operands ();
12888 do_neon_fcmp_absolute ();
12892 do_neon_step (void)
12894 enum neon_shape rs
= neon_select_shape (NS_DDD
, NS_QQQ
, NS_NULL
);
12895 neon_check_type (3, rs
, N_EQK
, N_EQK
, N_F32
| N_KEY
);
12896 neon_three_same (neon_quad (rs
), 0, -1);
12900 do_neon_abs_neg (void)
12902 enum neon_shape rs
;
12903 struct neon_type_el et
;
12905 if (try_vfp_nsyn (2, do_vfp_nsyn_abs_neg
) == SUCCESS
)
12908 if (vfp_or_neon_is_neon (NEON_CHECK_CC
| NEON_CHECK_ARCH
) == FAIL
)
12911 rs
= neon_select_shape (NS_DD
, NS_QQ
, NS_NULL
);
12912 et
= neon_check_type (2, rs
, N_EQK
, N_S8
| N_S16
| N_S32
| N_F32
| N_KEY
);
12914 inst
.instruction
|= LOW4 (inst
.operands
[0].reg
) << 12;
12915 inst
.instruction
|= HI1 (inst
.operands
[0].reg
) << 22;
12916 inst
.instruction
|= LOW4 (inst
.operands
[1].reg
);
12917 inst
.instruction
|= HI1 (inst
.operands
[1].reg
) << 5;
12918 inst
.instruction
|= neon_quad (rs
) << 6;
12919 inst
.instruction
|= (et
.type
== NT_float
) << 10;
12920 inst
.instruction
|= neon_logbits (et
.size
) << 18;
12922 inst
.instruction
= neon_dp_fixup (inst
.instruction
);
12928 enum neon_shape rs
= neon_select_shape (NS_DDI
, NS_QQI
, NS_NULL
);
12929 struct neon_type_el et
= neon_check_type (2, rs
,
12930 N_EQK
, N_8
| N_16
| N_32
| N_64
| N_KEY
);
12931 int imm
= inst
.operands
[2].imm
;
12932 constraint (imm
< 0 || (unsigned)imm
>= et
.size
,
12933 _("immediate out of range for insert"));
12934 neon_imm_shift (FALSE
, 0, neon_quad (rs
), et
, imm
);
12940 enum neon_shape rs
= neon_select_shape (NS_DDI
, NS_QQI
, NS_NULL
);
12941 struct neon_type_el et
= neon_check_type (2, rs
,
12942 N_EQK
, N_8
| N_16
| N_32
| N_64
| N_KEY
);
12943 int imm
= inst
.operands
[2].imm
;
12944 constraint (imm
< 1 || (unsigned)imm
> et
.size
,
12945 _("immediate out of range for insert"));
12946 neon_imm_shift (FALSE
, 0, neon_quad (rs
), et
, et
.size
- imm
);
12950 do_neon_qshlu_imm (void)
12952 enum neon_shape rs
= neon_select_shape (NS_DDI
, NS_QQI
, NS_NULL
);
12953 struct neon_type_el et
= neon_check_type (2, rs
,
12954 N_EQK
| N_UNS
, N_S8
| N_S16
| N_S32
| N_S64
| N_KEY
);
12955 int imm
= inst
.operands
[2].imm
;
12956 constraint (imm
< 0 || (unsigned)imm
>= et
.size
,
12957 _("immediate out of range for shift"));
12958 /* Only encodes the 'U present' variant of the instruction.
12959 In this case, signed types have OP (bit 8) set to 0.
12960 Unsigned types have OP set to 1. */
12961 inst
.instruction
|= (et
.type
== NT_unsigned
) << 8;
12962 /* The rest of the bits are the same as other immediate shifts. */
12963 neon_imm_shift (FALSE
, 0, neon_quad (rs
), et
, imm
);
12967 do_neon_qmovn (void)
12969 struct neon_type_el et
= neon_check_type (2, NS_DQ
,
12970 N_EQK
| N_HLF
, N_SU_16_64
| N_KEY
);
12971 /* Saturating move where operands can be signed or unsigned, and the
12972 destination has the same signedness. */
12973 inst
.instruction
= NEON_ENC_INTEGER (inst
.instruction
);
12974 if (et
.type
== NT_unsigned
)
12975 inst
.instruction
|= 0xc0;
12977 inst
.instruction
|= 0x80;
12978 neon_two_same (0, 1, et
.size
/ 2);
12982 do_neon_qmovun (void)
12984 struct neon_type_el et
= neon_check_type (2, NS_DQ
,
12985 N_EQK
| N_HLF
| N_UNS
, N_S16
| N_S32
| N_S64
| N_KEY
);
12986 /* Saturating move with unsigned results. Operands must be signed. */
12987 inst
.instruction
= NEON_ENC_INTEGER (inst
.instruction
);
12988 neon_two_same (0, 1, et
.size
/ 2);
12992 do_neon_rshift_sat_narrow (void)
12994 /* FIXME: Types for narrowing. If operands are signed, results can be signed
12995 or unsigned. If operands are unsigned, results must also be unsigned. */
12996 struct neon_type_el et
= neon_check_type (2, NS_DQI
,
12997 N_EQK
| N_HLF
, N_SU_16_64
| N_KEY
);
12998 int imm
= inst
.operands
[2].imm
;
12999 /* This gets the bounds check, size encoding and immediate bits calculation
13003 /* VQ{R}SHRN.I<size> <Dd>, <Qm>, #0 is a synonym for
13004 VQMOVN.I<size> <Dd>, <Qm>. */
13007 inst
.operands
[2].present
= 0;
13008 inst
.instruction
= N_MNEM_vqmovn
;
13013 constraint (imm
< 1 || (unsigned)imm
> et
.size
,
13014 _("immediate out of range"));
13015 neon_imm_shift (TRUE
, et
.type
== NT_unsigned
, 0, et
, et
.size
- imm
);
13019 do_neon_rshift_sat_narrow_u (void)
13021 /* FIXME: Types for narrowing. If operands are signed, results can be signed
13022 or unsigned. If operands are unsigned, results must also be unsigned. */
13023 struct neon_type_el et
= neon_check_type (2, NS_DQI
,
13024 N_EQK
| N_HLF
| N_UNS
, N_S16
| N_S32
| N_S64
| N_KEY
);
13025 int imm
= inst
.operands
[2].imm
;
13026 /* This gets the bounds check, size encoding and immediate bits calculation
13030 /* VQSHRUN.I<size> <Dd>, <Qm>, #0 is a synonym for
13031 VQMOVUN.I<size> <Dd>, <Qm>. */
13034 inst
.operands
[2].present
= 0;
13035 inst
.instruction
= N_MNEM_vqmovun
;
13040 constraint (imm
< 1 || (unsigned)imm
> et
.size
,
13041 _("immediate out of range"));
13042 /* FIXME: The manual is kind of unclear about what value U should have in
13043 VQ{R}SHRUN instructions, but U=0, op=0 definitely encodes VRSHR, so it
13045 neon_imm_shift (TRUE
, 1, 0, et
, et
.size
- imm
);
13049 do_neon_movn (void)
13051 struct neon_type_el et
= neon_check_type (2, NS_DQ
,
13052 N_EQK
| N_HLF
, N_I16
| N_I32
| N_I64
| N_KEY
);
13053 inst
.instruction
= NEON_ENC_INTEGER (inst
.instruction
);
13054 neon_two_same (0, 1, et
.size
/ 2);
13058 do_neon_rshift_narrow (void)
13060 struct neon_type_el et
= neon_check_type (2, NS_DQI
,
13061 N_EQK
| N_HLF
, N_I16
| N_I32
| N_I64
| N_KEY
);
13062 int imm
= inst
.operands
[2].imm
;
13063 /* This gets the bounds check, size encoding and immediate bits calculation
13067 /* If immediate is zero then we are a pseudo-instruction for
13068 VMOVN.I<size> <Dd>, <Qm> */
13071 inst
.operands
[2].present
= 0;
13072 inst
.instruction
= N_MNEM_vmovn
;
13077 constraint (imm
< 1 || (unsigned)imm
> et
.size
,
13078 _("immediate out of range for narrowing operation"));
13079 neon_imm_shift (FALSE
, 0, 0, et
, et
.size
- imm
);
13083 do_neon_shll (void)
13085 /* FIXME: Type checking when lengthening. */
13086 struct neon_type_el et
= neon_check_type (2, NS_QDI
,
13087 N_EQK
| N_DBL
, N_I8
| N_I16
| N_I32
| N_KEY
);
13088 unsigned imm
= inst
.operands
[2].imm
;
13090 if (imm
== et
.size
)
13092 /* Maximum shift variant. */
13093 inst
.instruction
= NEON_ENC_INTEGER (inst
.instruction
);
13094 inst
.instruction
|= LOW4 (inst
.operands
[0].reg
) << 12;
13095 inst
.instruction
|= HI1 (inst
.operands
[0].reg
) << 22;
13096 inst
.instruction
|= LOW4 (inst
.operands
[1].reg
);
13097 inst
.instruction
|= HI1 (inst
.operands
[1].reg
) << 5;
13098 inst
.instruction
|= neon_logbits (et
.size
) << 18;
13100 inst
.instruction
= neon_dp_fixup (inst
.instruction
);
13104 /* A more-specific type check for non-max versions. */
13105 et
= neon_check_type (2, NS_QDI
,
13106 N_EQK
| N_DBL
, N_SU_32
| N_KEY
);
13107 inst
.instruction
= NEON_ENC_IMMED (inst
.instruction
);
13108 neon_imm_shift (TRUE
, et
.type
== NT_unsigned
, 0, et
, imm
);
13112 /* Check the various types for the VCVT instruction, and return which version
13113 the current instruction is. */
13116 neon_cvt_flavour (enum neon_shape rs
)
13118 #define CVT_VAR(C,X,Y) \
13119 et = neon_check_type (2, rs, whole_reg | (X), whole_reg | (Y)); \
13120 if (et.type != NT_invtype) \
13122 inst.error = NULL; \
13125 struct neon_type_el et
;
13126 unsigned whole_reg
= (rs
== NS_FFI
|| rs
== NS_FD
|| rs
== NS_DF
13127 || rs
== NS_FF
) ? N_VFP
: 0;
13128 /* The instruction versions which take an immediate take one register
13129 argument, which is extended to the width of the full register. Thus the
13130 "source" and "destination" registers must have the same width. Hack that
13131 here by making the size equal to the key (wider, in this case) operand. */
13132 unsigned key
= (rs
== NS_QQI
|| rs
== NS_DDI
|| rs
== NS_FFI
) ? N_KEY
: 0;
13134 CVT_VAR (0, N_S32
, N_F32
);
13135 CVT_VAR (1, N_U32
, N_F32
);
13136 CVT_VAR (2, N_F32
, N_S32
);
13137 CVT_VAR (3, N_F32
, N_U32
);
13138 /* Half-precision conversions. */
13139 CVT_VAR (4, N_F32
, N_F16
);
13140 CVT_VAR (5, N_F16
, N_F32
);
13144 /* VFP instructions. */
13145 CVT_VAR (6, N_F32
, N_F64
);
13146 CVT_VAR (7, N_F64
, N_F32
);
13147 CVT_VAR (8, N_S32
, N_F64
| key
);
13148 CVT_VAR (9, N_U32
, N_F64
| key
);
13149 CVT_VAR (10, N_F64
| key
, N_S32
);
13150 CVT_VAR (11, N_F64
| key
, N_U32
);
13151 /* VFP instructions with bitshift. */
13152 CVT_VAR (12, N_F32
| key
, N_S16
);
13153 CVT_VAR (13, N_F32
| key
, N_U16
);
13154 CVT_VAR (14, N_F64
| key
, N_S16
);
13155 CVT_VAR (15, N_F64
| key
, N_U16
);
13156 CVT_VAR (16, N_S16
, N_F32
| key
);
13157 CVT_VAR (17, N_U16
, N_F32
| key
);
13158 CVT_VAR (18, N_S16
, N_F64
| key
);
13159 CVT_VAR (19, N_U16
, N_F64
| key
);
13165 /* Neon-syntax VFP conversions. */
13168 do_vfp_nsyn_cvt (enum neon_shape rs
, int flavour
)
13170 const char *opname
= 0;
13172 if (rs
== NS_DDI
|| rs
== NS_QQI
|| rs
== NS_FFI
)
13174 /* Conversions with immediate bitshift. */
13175 const char *enc
[] =
13199 if (flavour
>= 0 && flavour
< (int) ARRAY_SIZE (enc
))
13201 opname
= enc
[flavour
];
13202 constraint (inst
.operands
[0].reg
!= inst
.operands
[1].reg
,
13203 _("operands 0 and 1 must be the same register"));
13204 inst
.operands
[1] = inst
.operands
[2];
13205 memset (&inst
.operands
[2], '\0', sizeof (inst
.operands
[2]));
13210 /* Conversions without bitshift. */
13211 const char *enc
[] =
13227 if (flavour
>= 0 && flavour
< (int) ARRAY_SIZE (enc
))
13228 opname
= enc
[flavour
];
13232 do_vfp_nsyn_opcode (opname
);
13236 do_vfp_nsyn_cvtz (void)
13238 enum neon_shape rs
= neon_select_shape (NS_FF
, NS_FD
, NS_NULL
);
13239 int flavour
= neon_cvt_flavour (rs
);
13240 const char *enc
[] =
13254 if (flavour
>= 0 && flavour
< (int) ARRAY_SIZE (enc
) && enc
[flavour
])
13255 do_vfp_nsyn_opcode (enc
[flavour
]);
13261 enum neon_shape rs
= neon_select_shape (NS_DDI
, NS_QQI
, NS_FFI
, NS_DD
, NS_QQ
,
13262 NS_FD
, NS_DF
, NS_FF
, NS_QD
, NS_DQ
, NS_NULL
);
13263 int flavour
= neon_cvt_flavour (rs
);
13265 /* VFP rather than Neon conversions. */
13268 do_vfp_nsyn_cvt (rs
, flavour
);
13278 unsigned enctab
[] = { 0x0000100, 0x1000100, 0x0, 0x1000000 };
13280 if (vfp_or_neon_is_neon (NEON_CHECK_CC
| NEON_CHECK_ARCH
) == FAIL
)
13283 /* Fixed-point conversion with #0 immediate is encoded as an
13284 integer conversion. */
13285 if (inst
.operands
[2].present
&& inst
.operands
[2].imm
== 0)
13287 immbits
= 32 - inst
.operands
[2].imm
;
13288 inst
.instruction
= NEON_ENC_IMMED (inst
.instruction
);
13290 inst
.instruction
|= enctab
[flavour
];
13291 inst
.instruction
|= LOW4 (inst
.operands
[0].reg
) << 12;
13292 inst
.instruction
|= HI1 (inst
.operands
[0].reg
) << 22;
13293 inst
.instruction
|= LOW4 (inst
.operands
[1].reg
);
13294 inst
.instruction
|= HI1 (inst
.operands
[1].reg
) << 5;
13295 inst
.instruction
|= neon_quad (rs
) << 6;
13296 inst
.instruction
|= 1 << 21;
13297 inst
.instruction
|= immbits
<< 16;
13299 inst
.instruction
= neon_dp_fixup (inst
.instruction
);
13307 unsigned enctab
[] = { 0x100, 0x180, 0x0, 0x080 };
13309 inst
.instruction
= NEON_ENC_INTEGER (inst
.instruction
);
13311 if (vfp_or_neon_is_neon (NEON_CHECK_CC
| NEON_CHECK_ARCH
) == FAIL
)
13315 inst
.instruction
|= enctab
[flavour
];
13317 inst
.instruction
|= LOW4 (inst
.operands
[0].reg
) << 12;
13318 inst
.instruction
|= HI1 (inst
.operands
[0].reg
) << 22;
13319 inst
.instruction
|= LOW4 (inst
.operands
[1].reg
);
13320 inst
.instruction
|= HI1 (inst
.operands
[1].reg
) << 5;
13321 inst
.instruction
|= neon_quad (rs
) << 6;
13322 inst
.instruction
|= 2 << 18;
13324 inst
.instruction
= neon_dp_fixup (inst
.instruction
);
13328 /* Half-precision conversions for Advanced SIMD -- neon. */
13333 && (inst
.vectype
.el
[0].size
!= 16 || inst
.vectype
.el
[1].size
!= 32))
13335 as_bad (_("operand size must match register width"));
13340 && ((inst
.vectype
.el
[0].size
!= 32 || inst
.vectype
.el
[1].size
!= 16)))
13342 as_bad (_("operand size must match register width"));
13347 inst
.instruction
= 0x3b60600;
13349 inst
.instruction
= 0x3b60700;
13351 inst
.instruction
|= LOW4 (inst
.operands
[0].reg
) << 12;
13352 inst
.instruction
|= HI1 (inst
.operands
[0].reg
) << 22;
13353 inst
.instruction
|= LOW4 (inst
.operands
[1].reg
);
13354 inst
.instruction
|= HI1 (inst
.operands
[1].reg
) << 5;
13355 inst
.instruction
= neon_dp_fixup (inst
.instruction
);
13359 /* Some VFP conversions go here (s32 <-> f32, u32 <-> f32). */
13360 do_vfp_nsyn_cvt (rs
, flavour
);
13365 do_neon_cvtb (void)
13367 inst
.instruction
= 0xeb20a40;
13369 /* The sizes are attached to the mnemonic. */
13370 if (inst
.vectype
.el
[0].type
!= NT_invtype
13371 && inst
.vectype
.el
[0].size
== 16)
13372 inst
.instruction
|= 0x00010000;
13374 /* Programmer's syntax: the sizes are attached to the operands. */
13375 else if (inst
.operands
[0].vectype
.type
!= NT_invtype
13376 && inst
.operands
[0].vectype
.size
== 16)
13377 inst
.instruction
|= 0x00010000;
13379 encode_arm_vfp_reg (inst
.operands
[0].reg
, VFP_REG_Sd
);
13380 encode_arm_vfp_reg (inst
.operands
[1].reg
, VFP_REG_Sm
);
13381 do_vfp_cond_or_thumb ();
13386 do_neon_cvtt (void)
13389 inst
.instruction
|= 0x80;
13393 neon_move_immediate (void)
13395 enum neon_shape rs
= neon_select_shape (NS_DI
, NS_QI
, NS_NULL
);
13396 struct neon_type_el et
= neon_check_type (2, rs
,
13397 N_I8
| N_I16
| N_I32
| N_I64
| N_F32
| N_KEY
, N_EQK
);
13398 unsigned immlo
, immhi
= 0, immbits
;
13399 int op
, cmode
, float_p
;
13401 constraint (et
.type
== NT_invtype
,
13402 _("operand size must be specified for immediate VMOV"));
13404 /* We start out as an MVN instruction if OP = 1, MOV otherwise. */
13405 op
= (inst
.instruction
& (1 << 5)) != 0;
13407 immlo
= inst
.operands
[1].imm
;
13408 if (inst
.operands
[1].regisimm
)
13409 immhi
= inst
.operands
[1].reg
;
13411 constraint (et
.size
< 32 && (immlo
& ~((1 << et
.size
) - 1)) != 0,
13412 _("immediate has bits set outside the operand size"));
13414 float_p
= inst
.operands
[1].immisfloat
;
13416 if ((cmode
= neon_cmode_for_move_imm (immlo
, immhi
, float_p
, &immbits
, &op
,
13417 et
.size
, et
.type
)) == FAIL
)
13419 /* Invert relevant bits only. */
13420 neon_invert_size (&immlo
, &immhi
, et
.size
);
13421 /* Flip from VMOV/VMVN to VMVN/VMOV. Some immediate types are unavailable
13422 with one or the other; those cases are caught by
13423 neon_cmode_for_move_imm. */
13425 if ((cmode
= neon_cmode_for_move_imm (immlo
, immhi
, float_p
, &immbits
,
13426 &op
, et
.size
, et
.type
)) == FAIL
)
13428 first_error (_("immediate out of range"));
13433 inst
.instruction
&= ~(1 << 5);
13434 inst
.instruction
|= op
<< 5;
13436 inst
.instruction
|= LOW4 (inst
.operands
[0].reg
) << 12;
13437 inst
.instruction
|= HI1 (inst
.operands
[0].reg
) << 22;
13438 inst
.instruction
|= neon_quad (rs
) << 6;
13439 inst
.instruction
|= cmode
<< 8;
13441 neon_write_immbits (immbits
);
13447 if (inst
.operands
[1].isreg
)
13449 enum neon_shape rs
= neon_select_shape (NS_DD
, NS_QQ
, NS_NULL
);
13451 inst
.instruction
= NEON_ENC_INTEGER (inst
.instruction
);
13452 inst
.instruction
|= LOW4 (inst
.operands
[0].reg
) << 12;
13453 inst
.instruction
|= HI1 (inst
.operands
[0].reg
) << 22;
13454 inst
.instruction
|= LOW4 (inst
.operands
[1].reg
);
13455 inst
.instruction
|= HI1 (inst
.operands
[1].reg
) << 5;
13456 inst
.instruction
|= neon_quad (rs
) << 6;
13460 inst
.instruction
= NEON_ENC_IMMED (inst
.instruction
);
13461 neon_move_immediate ();
13464 inst
.instruction
= neon_dp_fixup (inst
.instruction
);
13467 /* Encode instructions of form:
13469 |28/24|23|22|21 20|19 16|15 12|11 8|7|6|5|4|3 0|
13470 | U |x |D |size | Rn | Rd |x x x x|N|x|M|x| Rm | */
13473 neon_mixed_length (struct neon_type_el et
, unsigned size
)
13475 inst
.instruction
|= LOW4 (inst
.operands
[0].reg
) << 12;
13476 inst
.instruction
|= HI1 (inst
.operands
[0].reg
) << 22;
13477 inst
.instruction
|= LOW4 (inst
.operands
[1].reg
) << 16;
13478 inst
.instruction
|= HI1 (inst
.operands
[1].reg
) << 7;
13479 inst
.instruction
|= LOW4 (inst
.operands
[2].reg
);
13480 inst
.instruction
|= HI1 (inst
.operands
[2].reg
) << 5;
13481 inst
.instruction
|= (et
.type
== NT_unsigned
) << 24;
13482 inst
.instruction
|= neon_logbits (size
) << 20;
13484 inst
.instruction
= neon_dp_fixup (inst
.instruction
);
13488 do_neon_dyadic_long (void)
13490 /* FIXME: Type checking for lengthening op. */
13491 struct neon_type_el et
= neon_check_type (3, NS_QDD
,
13492 N_EQK
| N_DBL
, N_EQK
, N_SU_32
| N_KEY
);
13493 neon_mixed_length (et
, et
.size
);
13497 do_neon_abal (void)
13499 struct neon_type_el et
= neon_check_type (3, NS_QDD
,
13500 N_EQK
| N_INT
| N_DBL
, N_EQK
, N_SU_32
| N_KEY
);
13501 neon_mixed_length (et
, et
.size
);
13505 neon_mac_reg_scalar_long (unsigned regtypes
, unsigned scalartypes
)
13507 if (inst
.operands
[2].isscalar
)
13509 struct neon_type_el et
= neon_check_type (3, NS_QDS
,
13510 N_EQK
| N_DBL
, N_EQK
, regtypes
| N_KEY
);
13511 inst
.instruction
= NEON_ENC_SCALAR (inst
.instruction
);
13512 neon_mul_mac (et
, et
.type
== NT_unsigned
);
13516 struct neon_type_el et
= neon_check_type (3, NS_QDD
,
13517 N_EQK
| N_DBL
, N_EQK
, scalartypes
| N_KEY
);
13518 inst
.instruction
= NEON_ENC_INTEGER (inst
.instruction
);
13519 neon_mixed_length (et
, et
.size
);
13524 do_neon_mac_maybe_scalar_long (void)
13526 neon_mac_reg_scalar_long (N_S16
| N_S32
| N_U16
| N_U32
, N_SU_32
);
13530 do_neon_dyadic_wide (void)
13532 struct neon_type_el et
= neon_check_type (3, NS_QQD
,
13533 N_EQK
| N_DBL
, N_EQK
| N_DBL
, N_SU_32
| N_KEY
);
13534 neon_mixed_length (et
, et
.size
);
13538 do_neon_dyadic_narrow (void)
13540 struct neon_type_el et
= neon_check_type (3, NS_QDD
,
13541 N_EQK
| N_DBL
, N_EQK
, N_I16
| N_I32
| N_I64
| N_KEY
);
13542 /* Operand sign is unimportant, and the U bit is part of the opcode,
13543 so force the operand type to integer. */
13544 et
.type
= NT_integer
;
13545 neon_mixed_length (et
, et
.size
/ 2);
13549 do_neon_mul_sat_scalar_long (void)
13551 neon_mac_reg_scalar_long (N_S16
| N_S32
, N_S16
| N_S32
);
13555 do_neon_vmull (void)
13557 if (inst
.operands
[2].isscalar
)
13558 do_neon_mac_maybe_scalar_long ();
13561 struct neon_type_el et
= neon_check_type (3, NS_QDD
,
13562 N_EQK
| N_DBL
, N_EQK
, N_SU_32
| N_P8
| N_KEY
);
13563 if (et
.type
== NT_poly
)
13564 inst
.instruction
= NEON_ENC_POLY (inst
.instruction
);
13566 inst
.instruction
= NEON_ENC_INTEGER (inst
.instruction
);
13567 /* For polynomial encoding, size field must be 0b00 and the U bit must be
13568 zero. Should be OK as-is. */
13569 neon_mixed_length (et
, et
.size
);
13576 enum neon_shape rs
= neon_select_shape (NS_DDDI
, NS_QQQI
, NS_NULL
);
13577 struct neon_type_el et
= neon_check_type (3, rs
,
13578 N_EQK
, N_EQK
, N_8
| N_16
| N_32
| N_64
| N_KEY
);
13579 unsigned imm
= (inst
.operands
[3].imm
* et
.size
) / 8;
13581 constraint (imm
>= (unsigned) (neon_quad (rs
) ? 16 : 8),
13582 _("shift out of range"));
13583 inst
.instruction
|= LOW4 (inst
.operands
[0].reg
) << 12;
13584 inst
.instruction
|= HI1 (inst
.operands
[0].reg
) << 22;
13585 inst
.instruction
|= LOW4 (inst
.operands
[1].reg
) << 16;
13586 inst
.instruction
|= HI1 (inst
.operands
[1].reg
) << 7;
13587 inst
.instruction
|= LOW4 (inst
.operands
[2].reg
);
13588 inst
.instruction
|= HI1 (inst
.operands
[2].reg
) << 5;
13589 inst
.instruction
|= neon_quad (rs
) << 6;
13590 inst
.instruction
|= imm
<< 8;
13592 inst
.instruction
= neon_dp_fixup (inst
.instruction
);
13598 enum neon_shape rs
= neon_select_shape (NS_DD
, NS_QQ
, NS_NULL
);
13599 struct neon_type_el et
= neon_check_type (2, rs
,
13600 N_EQK
, N_8
| N_16
| N_32
| N_KEY
);
13601 unsigned op
= (inst
.instruction
>> 7) & 3;
13602 /* N (width of reversed regions) is encoded as part of the bitmask. We
13603 extract it here to check the elements to be reversed are smaller.
13604 Otherwise we'd get a reserved instruction. */
13605 unsigned elsize
= (op
== 2) ? 16 : (op
== 1) ? 32 : (op
== 0) ? 64 : 0;
13606 gas_assert (elsize
!= 0);
13607 constraint (et
.size
>= elsize
,
13608 _("elements must be smaller than reversal region"));
13609 neon_two_same (neon_quad (rs
), 1, et
.size
);
13615 if (inst
.operands
[1].isscalar
)
13617 enum neon_shape rs
= neon_select_shape (NS_DS
, NS_QS
, NS_NULL
);
13618 struct neon_type_el et
= neon_check_type (2, rs
,
13619 N_EQK
, N_8
| N_16
| N_32
| N_KEY
);
13620 unsigned sizebits
= et
.size
>> 3;
13621 unsigned dm
= NEON_SCALAR_REG (inst
.operands
[1].reg
);
13622 int logsize
= neon_logbits (et
.size
);
13623 unsigned x
= NEON_SCALAR_INDEX (inst
.operands
[1].reg
) << logsize
;
13625 if (vfp_or_neon_is_neon (NEON_CHECK_CC
) == FAIL
)
13628 inst
.instruction
= NEON_ENC_SCALAR (inst
.instruction
);
13629 inst
.instruction
|= LOW4 (inst
.operands
[0].reg
) << 12;
13630 inst
.instruction
|= HI1 (inst
.operands
[0].reg
) << 22;
13631 inst
.instruction
|= LOW4 (dm
);
13632 inst
.instruction
|= HI1 (dm
) << 5;
13633 inst
.instruction
|= neon_quad (rs
) << 6;
13634 inst
.instruction
|= x
<< 17;
13635 inst
.instruction
|= sizebits
<< 16;
13637 inst
.instruction
= neon_dp_fixup (inst
.instruction
);
13641 enum neon_shape rs
= neon_select_shape (NS_DR
, NS_QR
, NS_NULL
);
13642 struct neon_type_el et
= neon_check_type (2, rs
,
13643 N_8
| N_16
| N_32
| N_KEY
, N_EQK
);
13644 /* Duplicate ARM register to lanes of vector. */
13645 inst
.instruction
= NEON_ENC_ARMREG (inst
.instruction
);
13648 case 8: inst
.instruction
|= 0x400000; break;
13649 case 16: inst
.instruction
|= 0x000020; break;
13650 case 32: inst
.instruction
|= 0x000000; break;
13653 inst
.instruction
|= LOW4 (inst
.operands
[1].reg
) << 12;
13654 inst
.instruction
|= LOW4 (inst
.operands
[0].reg
) << 16;
13655 inst
.instruction
|= HI1 (inst
.operands
[0].reg
) << 7;
13656 inst
.instruction
|= neon_quad (rs
) << 21;
13657 /* The encoding for this instruction is identical for the ARM and Thumb
13658 variants, except for the condition field. */
13659 do_vfp_cond_or_thumb ();
13663 /* VMOV has particularly many variations. It can be one of:
13664 0. VMOV<c><q> <Qd>, <Qm>
13665 1. VMOV<c><q> <Dd>, <Dm>
13666 (Register operations, which are VORR with Rm = Rn.)
13667 2. VMOV<c><q>.<dt> <Qd>, #<imm>
13668 3. VMOV<c><q>.<dt> <Dd>, #<imm>
13670 4. VMOV<c><q>.<size> <Dn[x]>, <Rd>
13671 (ARM register to scalar.)
13672 5. VMOV<c><q> <Dm>, <Rd>, <Rn>
13673 (Two ARM registers to vector.)
13674 6. VMOV<c><q>.<dt> <Rd>, <Dn[x]>
13675 (Scalar to ARM register.)
13676 7. VMOV<c><q> <Rd>, <Rn>, <Dm>
13677 (Vector to two ARM registers.)
13678 8. VMOV.F32 <Sd>, <Sm>
13679 9. VMOV.F64 <Dd>, <Dm>
13680 (VFP register moves.)
13681 10. VMOV.F32 <Sd>, #imm
13682 11. VMOV.F64 <Dd>, #imm
13683 (VFP float immediate load.)
13684 12. VMOV <Rd>, <Sm>
13685 (VFP single to ARM reg.)
13686 13. VMOV <Sd>, <Rm>
13687 (ARM reg to VFP single.)
13688 14. VMOV <Rd>, <Re>, <Sn>, <Sm>
13689 (Two ARM regs to two VFP singles.)
13690 15. VMOV <Sd>, <Se>, <Rn>, <Rm>
13691 (Two VFP singles to two ARM regs.)
13693 These cases can be disambiguated using neon_select_shape, except cases 1/9
13694 and 3/11 which depend on the operand type too.
13696 All the encoded bits are hardcoded by this function.
13698 Cases 4, 6 may be used with VFPv1 and above (only 32-bit transfers!).
13699 Cases 5, 7 may be used with VFPv2 and above.
13701 FIXME: Some of the checking may be a bit sloppy (in a couple of cases you
13702 can specify a type where it doesn't make sense to, and is ignored). */
13707 enum neon_shape rs
= neon_select_shape (NS_RRFF
, NS_FFRR
, NS_DRR
, NS_RRD
,
13708 NS_QQ
, NS_DD
, NS_QI
, NS_DI
, NS_SR
, NS_RS
, NS_FF
, NS_FI
, NS_RF
, NS_FR
,
13710 struct neon_type_el et
;
13711 const char *ldconst
= 0;
13715 case NS_DD
: /* case 1/9. */
13716 et
= neon_check_type (2, rs
, N_EQK
, N_F64
| N_KEY
);
13717 /* It is not an error here if no type is given. */
13719 if (et
.type
== NT_float
&& et
.size
== 64)
13721 do_vfp_nsyn_opcode ("fcpyd");
13724 /* fall through. */
13726 case NS_QQ
: /* case 0/1. */
13728 if (vfp_or_neon_is_neon (NEON_CHECK_CC
| NEON_CHECK_ARCH
) == FAIL
)
13730 /* The architecture manual I have doesn't explicitly state which
13731 value the U bit should have for register->register moves, but
13732 the equivalent VORR instruction has U = 0, so do that. */
13733 inst
.instruction
= 0x0200110;
13734 inst
.instruction
|= LOW4 (inst
.operands
[0].reg
) << 12;
13735 inst
.instruction
|= HI1 (inst
.operands
[0].reg
) << 22;
13736 inst
.instruction
|= LOW4 (inst
.operands
[1].reg
);
13737 inst
.instruction
|= HI1 (inst
.operands
[1].reg
) << 5;
13738 inst
.instruction
|= LOW4 (inst
.operands
[1].reg
) << 16;
13739 inst
.instruction
|= HI1 (inst
.operands
[1].reg
) << 7;
13740 inst
.instruction
|= neon_quad (rs
) << 6;
13742 inst
.instruction
= neon_dp_fixup (inst
.instruction
);
13746 case NS_DI
: /* case 3/11. */
13747 et
= neon_check_type (2, rs
, N_EQK
, N_F64
| N_KEY
);
13749 if (et
.type
== NT_float
&& et
.size
== 64)
13751 /* case 11 (fconstd). */
13752 ldconst
= "fconstd";
13753 goto encode_fconstd
;
13755 /* fall through. */
13757 case NS_QI
: /* case 2/3. */
13758 if (vfp_or_neon_is_neon (NEON_CHECK_CC
| NEON_CHECK_ARCH
) == FAIL
)
13760 inst
.instruction
= 0x0800010;
13761 neon_move_immediate ();
13762 inst
.instruction
= neon_dp_fixup (inst
.instruction
);
13765 case NS_SR
: /* case 4. */
13767 unsigned bcdebits
= 0;
13768 struct neon_type_el et
= neon_check_type (2, NS_NULL
,
13769 N_8
| N_16
| N_32
| N_KEY
, N_EQK
);
13770 int logsize
= neon_logbits (et
.size
);
13771 unsigned dn
= NEON_SCALAR_REG (inst
.operands
[0].reg
);
13772 unsigned x
= NEON_SCALAR_INDEX (inst
.operands
[0].reg
);
13774 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant
, fpu_vfp_ext_v1
),
13776 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant
, fpu_neon_ext_v1
)
13777 && et
.size
!= 32, _(BAD_FPU
));
13778 constraint (et
.type
== NT_invtype
, _("bad type for scalar"));
13779 constraint (x
>= 64 / et
.size
, _("scalar index out of range"));
13783 case 8: bcdebits
= 0x8; break;
13784 case 16: bcdebits
= 0x1; break;
13785 case 32: bcdebits
= 0x0; break;
13789 bcdebits
|= x
<< logsize
;
13791 inst
.instruction
= 0xe000b10;
13792 do_vfp_cond_or_thumb ();
13793 inst
.instruction
|= LOW4 (dn
) << 16;
13794 inst
.instruction
|= HI1 (dn
) << 7;
13795 inst
.instruction
|= inst
.operands
[1].reg
<< 12;
13796 inst
.instruction
|= (bcdebits
& 3) << 5;
13797 inst
.instruction
|= (bcdebits
>> 2) << 21;
13801 case NS_DRR
: /* case 5 (fmdrr). */
13802 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant
, fpu_vfp_ext_v2
),
13805 inst
.instruction
= 0xc400b10;
13806 do_vfp_cond_or_thumb ();
13807 inst
.instruction
|= LOW4 (inst
.operands
[0].reg
);
13808 inst
.instruction
|= HI1 (inst
.operands
[0].reg
) << 5;
13809 inst
.instruction
|= inst
.operands
[1].reg
<< 12;
13810 inst
.instruction
|= inst
.operands
[2].reg
<< 16;
13813 case NS_RS
: /* case 6. */
13815 struct neon_type_el et
= neon_check_type (2, NS_NULL
,
13816 N_EQK
, N_S8
| N_S16
| N_U8
| N_U16
| N_32
| N_KEY
);
13817 unsigned logsize
= neon_logbits (et
.size
);
13818 unsigned dn
= NEON_SCALAR_REG (inst
.operands
[1].reg
);
13819 unsigned x
= NEON_SCALAR_INDEX (inst
.operands
[1].reg
);
13820 unsigned abcdebits
= 0;
13822 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant
, fpu_vfp_ext_v1
),
13824 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant
, fpu_neon_ext_v1
)
13825 && et
.size
!= 32, _(BAD_FPU
));
13826 constraint (et
.type
== NT_invtype
, _("bad type for scalar"));
13827 constraint (x
>= 64 / et
.size
, _("scalar index out of range"));
13831 case 8: abcdebits
= (et
.type
== NT_signed
) ? 0x08 : 0x18; break;
13832 case 16: abcdebits
= (et
.type
== NT_signed
) ? 0x01 : 0x11; break;
13833 case 32: abcdebits
= 0x00; break;
13837 abcdebits
|= x
<< logsize
;
13838 inst
.instruction
= 0xe100b10;
13839 do_vfp_cond_or_thumb ();
13840 inst
.instruction
|= LOW4 (dn
) << 16;
13841 inst
.instruction
|= HI1 (dn
) << 7;
13842 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
13843 inst
.instruction
|= (abcdebits
& 3) << 5;
13844 inst
.instruction
|= (abcdebits
>> 2) << 21;
13848 case NS_RRD
: /* case 7 (fmrrd). */
13849 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant
, fpu_vfp_ext_v2
),
13852 inst
.instruction
= 0xc500b10;
13853 do_vfp_cond_or_thumb ();
13854 inst
.instruction
|= inst
.operands
[0].reg
<< 12;
13855 inst
.instruction
|= inst
.operands
[1].reg
<< 16;
13856 inst
.instruction
|= LOW4 (inst
.operands
[2].reg
);
13857 inst
.instruction
|= HI1 (inst
.operands
[2].reg
) << 5;
13860 case NS_FF
: /* case 8 (fcpys). */
13861 do_vfp_nsyn_opcode ("fcpys");
13864 case NS_FI
: /* case 10 (fconsts). */
13865 ldconst
= "fconsts";
13867 if (is_quarter_float (inst
.operands
[1].imm
))
13869 inst
.operands
[1].imm
= neon_qfloat_bits (inst
.operands
[1].imm
);
13870 do_vfp_nsyn_opcode (ldconst
);
13873 first_error (_("immediate out of range"));
13876 case NS_RF
: /* case 12 (fmrs). */
13877 do_vfp_nsyn_opcode ("fmrs");
13880 case NS_FR
: /* case 13 (fmsr). */
13881 do_vfp_nsyn_opcode ("fmsr");
13884 /* The encoders for the fmrrs and fmsrr instructions expect three operands
13885 (one of which is a list), but we have parsed four. Do some fiddling to
13886 make the operands what do_vfp_reg2_from_sp2 and do_vfp_sp2_from_reg2
13888 case NS_RRFF
: /* case 14 (fmrrs). */
13889 constraint (inst
.operands
[3].reg
!= inst
.operands
[2].reg
+ 1,
13890 _("VFP registers must be adjacent"));
13891 inst
.operands
[2].imm
= 2;
13892 memset (&inst
.operands
[3], '\0', sizeof (inst
.operands
[3]));
13893 do_vfp_nsyn_opcode ("fmrrs");
13896 case NS_FFRR
: /* case 15 (fmsrr). */
13897 constraint (inst
.operands
[1].reg
!= inst
.operands
[0].reg
+ 1,
13898 _("VFP registers must be adjacent"));
13899 inst
.operands
[1] = inst
.operands
[2];
13900 inst
.operands
[2] = inst
.operands
[3];
13901 inst
.operands
[0].imm
= 2;
13902 memset (&inst
.operands
[3], '\0', sizeof (inst
.operands
[3]));
13903 do_vfp_nsyn_opcode ("fmsrr");
13912 do_neon_rshift_round_imm (void)
13914 enum neon_shape rs
= neon_select_shape (NS_DDI
, NS_QQI
, NS_NULL
);
13915 struct neon_type_el et
= neon_check_type (2, rs
, N_EQK
, N_SU_ALL
| N_KEY
);
13916 int imm
= inst
.operands
[2].imm
;
13918 /* imm == 0 case is encoded as VMOV for V{R}SHR. */
13921 inst
.operands
[2].present
= 0;
13926 constraint (imm
< 1 || (unsigned)imm
> et
.size
,
13927 _("immediate out of range for shift"));
13928 neon_imm_shift (TRUE
, et
.type
== NT_unsigned
, neon_quad (rs
), et
,
13933 do_neon_movl (void)
13935 struct neon_type_el et
= neon_check_type (2, NS_QD
,
13936 N_EQK
| N_DBL
, N_SU_32
| N_KEY
);
13937 unsigned sizebits
= et
.size
>> 3;
13938 inst
.instruction
|= sizebits
<< 19;
13939 neon_two_same (0, et
.type
== NT_unsigned
, -1);
13945 enum neon_shape rs
= neon_select_shape (NS_DD
, NS_QQ
, NS_NULL
);
13946 struct neon_type_el et
= neon_check_type (2, rs
,
13947 N_EQK
, N_8
| N_16
| N_32
| N_KEY
);
13948 inst
.instruction
= NEON_ENC_INTEGER (inst
.instruction
);
13949 neon_two_same (neon_quad (rs
), 1, et
.size
);
13953 do_neon_zip_uzp (void)
13955 enum neon_shape rs
= neon_select_shape (NS_DD
, NS_QQ
, NS_NULL
);
13956 struct neon_type_el et
= neon_check_type (2, rs
,
13957 N_EQK
, N_8
| N_16
| N_32
| N_KEY
);
13958 if (rs
== NS_DD
&& et
.size
== 32)
13960 /* Special case: encode as VTRN.32 <Dd>, <Dm>. */
13961 inst
.instruction
= N_MNEM_vtrn
;
13965 neon_two_same (neon_quad (rs
), 1, et
.size
);
13969 do_neon_sat_abs_neg (void)
13971 enum neon_shape rs
= neon_select_shape (NS_DD
, NS_QQ
, NS_NULL
);
13972 struct neon_type_el et
= neon_check_type (2, rs
,
13973 N_EQK
, N_S8
| N_S16
| N_S32
| N_KEY
);
13974 neon_two_same (neon_quad (rs
), 1, et
.size
);
13978 do_neon_pair_long (void)
13980 enum neon_shape rs
= neon_select_shape (NS_DD
, NS_QQ
, NS_NULL
);
13981 struct neon_type_el et
= neon_check_type (2, rs
, N_EQK
, N_SU_32
| N_KEY
);
13982 /* Unsigned is encoded in OP field (bit 7) for these instruction. */
13983 inst
.instruction
|= (et
.type
== NT_unsigned
) << 7;
13984 neon_two_same (neon_quad (rs
), 1, et
.size
);
13988 do_neon_recip_est (void)
13990 enum neon_shape rs
= neon_select_shape (NS_DD
, NS_QQ
, NS_NULL
);
13991 struct neon_type_el et
= neon_check_type (2, rs
,
13992 N_EQK
| N_FLT
, N_F32
| N_U32
| N_KEY
);
13993 inst
.instruction
|= (et
.type
== NT_float
) << 8;
13994 neon_two_same (neon_quad (rs
), 1, et
.size
);
14000 enum neon_shape rs
= neon_select_shape (NS_DD
, NS_QQ
, NS_NULL
);
14001 struct neon_type_el et
= neon_check_type (2, rs
,
14002 N_EQK
, N_S8
| N_S16
| N_S32
| N_KEY
);
14003 neon_two_same (neon_quad (rs
), 1, et
.size
);
14009 enum neon_shape rs
= neon_select_shape (NS_DD
, NS_QQ
, NS_NULL
);
14010 struct neon_type_el et
= neon_check_type (2, rs
,
14011 N_EQK
, N_I8
| N_I16
| N_I32
| N_KEY
);
14012 neon_two_same (neon_quad (rs
), 1, et
.size
);
14018 enum neon_shape rs
= neon_select_shape (NS_DD
, NS_QQ
, NS_NULL
);
14019 struct neon_type_el et
= neon_check_type (2, rs
,
14020 N_EQK
| N_INT
, N_8
| N_KEY
);
14021 neon_two_same (neon_quad (rs
), 1, et
.size
);
14027 enum neon_shape rs
= neon_select_shape (NS_DD
, NS_QQ
, NS_NULL
);
14028 neon_two_same (neon_quad (rs
), 1, -1);
14032 do_neon_tbl_tbx (void)
14034 unsigned listlenbits
;
14035 neon_check_type (3, NS_DLD
, N_EQK
, N_EQK
, N_8
| N_KEY
);
14037 if (inst
.operands
[1].imm
< 1 || inst
.operands
[1].imm
> 4)
14039 first_error (_("bad list length for table lookup"));
14043 listlenbits
= inst
.operands
[1].imm
- 1;
14044 inst
.instruction
|= LOW4 (inst
.operands
[0].reg
) << 12;
14045 inst
.instruction
|= HI1 (inst
.operands
[0].reg
) << 22;
14046 inst
.instruction
|= LOW4 (inst
.operands
[1].reg
) << 16;
14047 inst
.instruction
|= HI1 (inst
.operands
[1].reg
) << 7;
14048 inst
.instruction
|= LOW4 (inst
.operands
[2].reg
);
14049 inst
.instruction
|= HI1 (inst
.operands
[2].reg
) << 5;
14050 inst
.instruction
|= listlenbits
<< 8;
14052 inst
.instruction
= neon_dp_fixup (inst
.instruction
);
14056 do_neon_ldm_stm (void)
14058 /* P, U and L bits are part of bitmask. */
14059 int is_dbmode
= (inst
.instruction
& (1 << 24)) != 0;
14060 unsigned offsetbits
= inst
.operands
[1].imm
* 2;
14062 if (inst
.operands
[1].issingle
)
14064 do_vfp_nsyn_ldm_stm (is_dbmode
);
14068 constraint (is_dbmode
&& !inst
.operands
[0].writeback
,
14069 _("writeback (!) must be used for VLDMDB and VSTMDB"));
14071 constraint (inst
.operands
[1].imm
< 1 || inst
.operands
[1].imm
> 16,
14072 _("register list must contain at least 1 and at most 16 "
14075 inst
.instruction
|= inst
.operands
[0].reg
<< 16;
14076 inst
.instruction
|= inst
.operands
[0].writeback
<< 21;
14077 inst
.instruction
|= LOW4 (inst
.operands
[1].reg
) << 12;
14078 inst
.instruction
|= HI1 (inst
.operands
[1].reg
) << 22;
14080 inst
.instruction
|= offsetbits
;
14082 do_vfp_cond_or_thumb ();
14086 do_neon_ldr_str (void)
14088 int is_ldr
= (inst
.instruction
& (1 << 20)) != 0;
14090 if (inst
.operands
[0].issingle
)
14093 do_vfp_nsyn_opcode ("flds");
14095 do_vfp_nsyn_opcode ("fsts");
14100 do_vfp_nsyn_opcode ("fldd");
14102 do_vfp_nsyn_opcode ("fstd");
14106 /* "interleave" version also handles non-interleaving register VLD1/VST1
14110 do_neon_ld_st_interleave (void)
14112 struct neon_type_el et
= neon_check_type (1, NS_NULL
,
14113 N_8
| N_16
| N_32
| N_64
);
14114 unsigned alignbits
= 0;
14116 /* The bits in this table go:
14117 0: register stride of one (0) or two (1)
14118 1,2: register list length, minus one (1, 2, 3, 4).
14119 3,4: <n> in instruction type, minus one (VLD<n> / VST<n>).
14120 We use -1 for invalid entries. */
14121 const int typetable
[] =
14123 0x7, -1, 0xa, -1, 0x6, -1, 0x2, -1, /* VLD1 / VST1. */
14124 -1, -1, 0x8, 0x9, -1, -1, 0x3, -1, /* VLD2 / VST2. */
14125 -1, -1, -1, -1, 0x4, 0x5, -1, -1, /* VLD3 / VST3. */
14126 -1, -1, -1, -1, -1, -1, 0x0, 0x1 /* VLD4 / VST4. */
14130 if (et
.type
== NT_invtype
)
14133 if (inst
.operands
[1].immisalign
)
14134 switch (inst
.operands
[1].imm
>> 8)
14136 case 64: alignbits
= 1; break;
14138 if (NEON_REGLIST_LENGTH (inst
.operands
[0].imm
) == 3)
14139 goto bad_alignment
;
14143 if (NEON_REGLIST_LENGTH (inst
.operands
[0].imm
) == 3)
14144 goto bad_alignment
;
14149 first_error (_("bad alignment"));
14153 inst
.instruction
|= alignbits
<< 4;
14154 inst
.instruction
|= neon_logbits (et
.size
) << 6;
14156 /* Bits [4:6] of the immediate in a list specifier encode register stride
14157 (minus 1) in bit 4, and list length in bits [5:6]. We put the <n> of
14158 VLD<n>/VST<n> in bits [9:8] of the initial bitmask. Suck it out here, look
14159 up the right value for "type" in a table based on this value and the given
14160 list style, then stick it back. */
14161 idx
= ((inst
.operands
[0].imm
>> 4) & 7)
14162 | (((inst
.instruction
>> 8) & 3) << 3);
14164 typebits
= typetable
[idx
];
14166 constraint (typebits
== -1, _("bad list type for instruction"));
14168 inst
.instruction
&= ~0xf00;
14169 inst
.instruction
|= typebits
<< 8;
14172 /* Check alignment is valid for do_neon_ld_st_lane and do_neon_ld_dup.
14173 *DO_ALIGN is set to 1 if the relevant alignment bit should be set, 0
14174 otherwise. The variable arguments are a list of pairs of legal (size, align)
14175 values, terminated with -1. */
14178 neon_alignment_bit (int size
, int align
, int *do_align
, ...)
14181 int result
= FAIL
, thissize
, thisalign
;
14183 if (!inst
.operands
[1].immisalign
)
14189 va_start (ap
, do_align
);
14193 thissize
= va_arg (ap
, int);
14194 if (thissize
== -1)
14196 thisalign
= va_arg (ap
, int);
14198 if (size
== thissize
&& align
== thisalign
)
14201 while (result
!= SUCCESS
);
14205 if (result
== SUCCESS
)
14208 first_error (_("unsupported alignment for instruction"));
14214 do_neon_ld_st_lane (void)
14216 struct neon_type_el et
= neon_check_type (1, NS_NULL
, N_8
| N_16
| N_32
);
14217 int align_good
, do_align
= 0;
14218 int logsize
= neon_logbits (et
.size
);
14219 int align
= inst
.operands
[1].imm
>> 8;
14220 int n
= (inst
.instruction
>> 8) & 3;
14221 int max_el
= 64 / et
.size
;
14223 if (et
.type
== NT_invtype
)
14226 constraint (NEON_REGLIST_LENGTH (inst
.operands
[0].imm
) != n
+ 1,
14227 _("bad list length"));
14228 constraint (NEON_LANE (inst
.operands
[0].imm
) >= max_el
,
14229 _("scalar index out of range"));
14230 constraint (n
!= 0 && NEON_REG_STRIDE (inst
.operands
[0].imm
) == 2
14232 _("stride of 2 unavailable when element size is 8"));
14236 case 0: /* VLD1 / VST1. */
14237 align_good
= neon_alignment_bit (et
.size
, align
, &do_align
, 16, 16,
14239 if (align_good
== FAIL
)
14243 unsigned alignbits
= 0;
14246 case 16: alignbits
= 0x1; break;
14247 case 32: alignbits
= 0x3; break;
14250 inst
.instruction
|= alignbits
<< 4;
14254 case 1: /* VLD2 / VST2. */
14255 align_good
= neon_alignment_bit (et
.size
, align
, &do_align
, 8, 16, 16, 32,
14257 if (align_good
== FAIL
)
14260 inst
.instruction
|= 1 << 4;
14263 case 2: /* VLD3 / VST3. */
14264 constraint (inst
.operands
[1].immisalign
,
14265 _("can't use alignment with this instruction"));
14268 case 3: /* VLD4 / VST4. */
14269 align_good
= neon_alignment_bit (et
.size
, align
, &do_align
, 8, 32,
14270 16, 64, 32, 64, 32, 128, -1);
14271 if (align_good
== FAIL
)
14275 unsigned alignbits
= 0;
14278 case 8: alignbits
= 0x1; break;
14279 case 16: alignbits
= 0x1; break;
14280 case 32: alignbits
= (align
== 64) ? 0x1 : 0x2; break;
14283 inst
.instruction
|= alignbits
<< 4;
14290 /* Reg stride of 2 is encoded in bit 5 when size==16, bit 6 when size==32. */
14291 if (n
!= 0 && NEON_REG_STRIDE (inst
.operands
[0].imm
) == 2)
14292 inst
.instruction
|= 1 << (4 + logsize
);
14294 inst
.instruction
|= NEON_LANE (inst
.operands
[0].imm
) << (logsize
+ 5);
14295 inst
.instruction
|= logsize
<< 10;
14298 /* Encode single n-element structure to all lanes VLD<n> instructions. */
14301 do_neon_ld_dup (void)
14303 struct neon_type_el et
= neon_check_type (1, NS_NULL
, N_8
| N_16
| N_32
);
14304 int align_good
, do_align
= 0;
14306 if (et
.type
== NT_invtype
)
14309 switch ((inst
.instruction
>> 8) & 3)
14311 case 0: /* VLD1. */
14312 gas_assert (NEON_REG_STRIDE (inst
.operands
[0].imm
) != 2);
14313 align_good
= neon_alignment_bit (et
.size
, inst
.operands
[1].imm
>> 8,
14314 &do_align
, 16, 16, 32, 32, -1);
14315 if (align_good
== FAIL
)
14317 switch (NEON_REGLIST_LENGTH (inst
.operands
[0].imm
))
14320 case 2: inst
.instruction
|= 1 << 5; break;
14321 default: first_error (_("bad list length")); return;
14323 inst
.instruction
|= neon_logbits (et
.size
) << 6;
14326 case 1: /* VLD2. */
14327 align_good
= neon_alignment_bit (et
.size
, inst
.operands
[1].imm
>> 8,
14328 &do_align
, 8, 16, 16, 32, 32, 64, -1);
14329 if (align_good
== FAIL
)
14331 constraint (NEON_REGLIST_LENGTH (inst
.operands
[0].imm
) != 2,
14332 _("bad list length"));
14333 if (NEON_REG_STRIDE (inst
.operands
[0].imm
) == 2)
14334 inst
.instruction
|= 1 << 5;
14335 inst
.instruction
|= neon_logbits (et
.size
) << 6;
14338 case 2: /* VLD3. */
14339 constraint (inst
.operands
[1].immisalign
,
14340 _("can't use alignment with this instruction"));
14341 constraint (NEON_REGLIST_LENGTH (inst
.operands
[0].imm
) != 3,
14342 _("bad list length"));
14343 if (NEON_REG_STRIDE (inst
.operands
[0].imm
) == 2)
14344 inst
.instruction
|= 1 << 5;
14345 inst
.instruction
|= neon_logbits (et
.size
) << 6;
14348 case 3: /* VLD4. */
14350 int align
= inst
.operands
[1].imm
>> 8;
14351 align_good
= neon_alignment_bit (et
.size
, align
, &do_align
, 8, 32,
14352 16, 64, 32, 64, 32, 128, -1);
14353 if (align_good
== FAIL
)
14355 constraint (NEON_REGLIST_LENGTH (inst
.operands
[0].imm
) != 4,
14356 _("bad list length"));
14357 if (NEON_REG_STRIDE (inst
.operands
[0].imm
) == 2)
14358 inst
.instruction
|= 1 << 5;
14359 if (et
.size
== 32 && align
== 128)
14360 inst
.instruction
|= 0x3 << 6;
14362 inst
.instruction
|= neon_logbits (et
.size
) << 6;
14369 inst
.instruction
|= do_align
<< 4;
14372 /* Disambiguate VLD<n> and VST<n> instructions, and fill in common bits (those
14373 apart from bits [11:4]. */
14376 do_neon_ldx_stx (void)
14378 switch (NEON_LANE (inst
.operands
[0].imm
))
14380 case NEON_INTERLEAVE_LANES
:
14381 inst
.instruction
= NEON_ENC_INTERLV (inst
.instruction
);
14382 do_neon_ld_st_interleave ();
14385 case NEON_ALL_LANES
:
14386 inst
.instruction
= NEON_ENC_DUP (inst
.instruction
);
14391 inst
.instruction
= NEON_ENC_LANE (inst
.instruction
);
14392 do_neon_ld_st_lane ();
14395 /* L bit comes from bit mask. */
14396 inst
.instruction
|= LOW4 (inst
.operands
[0].reg
) << 12;
14397 inst
.instruction
|= HI1 (inst
.operands
[0].reg
) << 22;
14398 inst
.instruction
|= inst
.operands
[1].reg
<< 16;
14400 if (inst
.operands
[1].postind
)
14402 int postreg
= inst
.operands
[1].imm
& 0xf;
14403 constraint (!inst
.operands
[1].immisreg
,
14404 _("post-index must be a register"));
14405 constraint (postreg
== 0xd || postreg
== 0xf,
14406 _("bad register for post-index"));
14407 inst
.instruction
|= postreg
;
14409 else if (inst
.operands
[1].writeback
)
14411 inst
.instruction
|= 0xd;
14414 inst
.instruction
|= 0xf;
14417 inst
.instruction
|= 0xf9000000;
14419 inst
.instruction
|= 0xf4000000;
14422 /* Overall per-instruction processing. */
14424 /* We need to be able to fix up arbitrary expressions in some statements.
14425 This is so that we can handle symbols that are an arbitrary distance from
14426 the pc. The most common cases are of the form ((+/-sym -/+ . - 8) & mask),
14427 which returns part of an address in a form which will be valid for
14428 a data instruction. We do this by pushing the expression into a symbol
14429 in the expr_section, and creating a fix for that. */
14432 fix_new_arm (fragS
* frag
,
14447 new_fix
= fix_new_exp (frag
, where
, size
, exp
, pc_rel
, reloc
);
14451 new_fix
= fix_new (frag
, where
, size
, make_expr_symbol (exp
), 0,
14456 /* Mark whether the fix is to a THUMB instruction, or an ARM
14458 new_fix
->tc_fix_data
= thumb_mode
;
14461 /* Create a frg for an instruction requiring relaxation. */
14463 output_relax_insn (void)
14469 /* The size of the instruction is unknown, so tie the debug info to the
14470 start of the instruction. */
14471 dwarf2_emit_insn (0);
14473 switch (inst
.reloc
.exp
.X_op
)
14476 sym
= inst
.reloc
.exp
.X_add_symbol
;
14477 offset
= inst
.reloc
.exp
.X_add_number
;
14481 offset
= inst
.reloc
.exp
.X_add_number
;
14484 sym
= make_expr_symbol (&inst
.reloc
.exp
);
14488 to
= frag_var (rs_machine_dependent
, INSN_SIZE
, THUMB_SIZE
,
14489 inst
.relax
, sym
, offset
, NULL
/*offset, opcode*/);
14490 md_number_to_chars (to
, inst
.instruction
, THUMB_SIZE
);
14493 /* Write a 32-bit thumb instruction to buf. */
14495 put_thumb32_insn (char * buf
, unsigned long insn
)
14497 md_number_to_chars (buf
, insn
>> 16, THUMB_SIZE
);
14498 md_number_to_chars (buf
+ THUMB_SIZE
, insn
, THUMB_SIZE
);
14502 output_inst (const char * str
)
14508 as_bad ("%s -- `%s'", inst
.error
, str
);
14513 output_relax_insn ();
14516 if (inst
.size
== 0)
14519 to
= frag_more (inst
.size
);
14520 /* PR 9814: Record the thumb mode into the current frag so that we know
14521 what type of NOP padding to use, if necessary. We override any previous
14522 setting so that if the mode has changed then the NOPS that we use will
14523 match the encoding of the last instruction in the frag. */
14524 frag_now
->tc_frag_data
= thumb_mode
| MODE_RECORDED
;
14526 if (thumb_mode
&& (inst
.size
> THUMB_SIZE
))
14528 gas_assert (inst
.size
== (2 * THUMB_SIZE
));
14529 put_thumb32_insn (to
, inst
.instruction
);
14531 else if (inst
.size
> INSN_SIZE
)
14533 gas_assert (inst
.size
== (2 * INSN_SIZE
));
14534 md_number_to_chars (to
, inst
.instruction
, INSN_SIZE
);
14535 md_number_to_chars (to
+ INSN_SIZE
, inst
.instruction
, INSN_SIZE
);
14538 md_number_to_chars (to
, inst
.instruction
, inst
.size
);
14540 if (inst
.reloc
.type
!= BFD_RELOC_UNUSED
)
14541 fix_new_arm (frag_now
, to
- frag_now
->fr_literal
,
14542 inst
.size
, & inst
.reloc
.exp
, inst
.reloc
.pc_rel
,
14545 dwarf2_emit_insn (inst
.size
);
14549 output_it_inst (int cond
, int mask
, char * to
)
14551 unsigned long instruction
= 0xbf00;
14554 instruction
|= mask
;
14555 instruction
|= cond
<< 4;
14559 to
= frag_more (2);
14561 dwarf2_emit_insn (2);
14565 md_number_to_chars (to
, instruction
, 2);
14570 /* Tag values used in struct asm_opcode's tag field. */
14573 OT_unconditional
, /* Instruction cannot be conditionalized.
14574 The ARM condition field is still 0xE. */
14575 OT_unconditionalF
, /* Instruction cannot be conditionalized
14576 and carries 0xF in its ARM condition field. */
14577 OT_csuffix
, /* Instruction takes a conditional suffix. */
14578 OT_csuffixF
, /* Some forms of the instruction take a conditional
14579 suffix, others place 0xF where the condition field
14581 OT_cinfix3
, /* Instruction takes a conditional infix,
14582 beginning at character index 3. (In
14583 unified mode, it becomes a suffix.) */
14584 OT_cinfix3_deprecated
, /* The same as OT_cinfix3. This is used for
14585 tsts, cmps, cmns, and teqs. */
14586 OT_cinfix3_legacy
, /* Legacy instruction takes a conditional infix at
14587 character index 3, even in unified mode. Used for
14588 legacy instructions where suffix and infix forms
14589 may be ambiguous. */
14590 OT_csuf_or_in3
, /* Instruction takes either a conditional
14591 suffix or an infix at character index 3. */
14592 OT_odd_infix_unc
, /* This is the unconditional variant of an
14593 instruction that takes a conditional infix
14594 at an unusual position. In unified mode,
14595 this variant will accept a suffix. */
14596 OT_odd_infix_0
/* Values greater than or equal to OT_odd_infix_0
14597 are the conditional variants of instructions that
14598 take conditional infixes in unusual positions.
14599 The infix appears at character index
14600 (tag - OT_odd_infix_0). These are not accepted
14601 in unified mode. */
14604 /* Subroutine of md_assemble, responsible for looking up the primary
14605 opcode from the mnemonic the user wrote. STR points to the
14606 beginning of the mnemonic.
14608 This is not simply a hash table lookup, because of conditional
14609 variants. Most instructions have conditional variants, which are
14610 expressed with a _conditional affix_ to the mnemonic. If we were
14611 to encode each conditional variant as a literal string in the opcode
14612 table, it would have approximately 20,000 entries.
14614 Most mnemonics take this affix as a suffix, and in unified syntax,
14615 'most' is upgraded to 'all'. However, in the divided syntax, some
14616 instructions take the affix as an infix, notably the s-variants of
14617 the arithmetic instructions. Of those instructions, all but six
14618 have the infix appear after the third character of the mnemonic.
14620 Accordingly, the algorithm for looking up primary opcodes given
14623 1. Look up the identifier in the opcode table.
14624 If we find a match, go to step U.
14626 2. Look up the last two characters of the identifier in the
14627 conditions table. If we find a match, look up the first N-2
14628 characters of the identifier in the opcode table. If we
14629 find a match, go to step CE.
14631 3. Look up the fourth and fifth characters of the identifier in
14632 the conditions table. If we find a match, extract those
14633 characters from the identifier, and look up the remaining
14634 characters in the opcode table. If we find a match, go
14639 U. Examine the tag field of the opcode structure, in case this is
14640 one of the six instructions with its conditional infix in an
14641 unusual place. If it is, the tag tells us where to find the
14642 infix; look it up in the conditions table and set inst.cond
14643 accordingly. Otherwise, this is an unconditional instruction.
14644 Again set inst.cond accordingly. Return the opcode structure.
14646 CE. Examine the tag field to make sure this is an instruction that
14647 should receive a conditional suffix. If it is not, fail.
14648 Otherwise, set inst.cond from the suffix we already looked up,
14649 and return the opcode structure.
14651 CM. Examine the tag field to make sure this is an instruction that
14652 should receive a conditional infix after the third character.
14653 If it is not, fail. Otherwise, undo the edits to the current
14654 line of input and proceed as for case CE. */
14656 static const struct asm_opcode
*
14657 opcode_lookup (char **str
)
14661 const struct asm_opcode
*opcode
;
14662 const struct asm_cond
*cond
;
14664 bfd_boolean neon_supported
;
14666 neon_supported
= ARM_CPU_HAS_FEATURE (cpu_variant
, fpu_neon_ext_v1
);
14668 /* Scan up to the end of the mnemonic, which must end in white space,
14669 '.' (in unified mode, or for Neon instructions), or end of string. */
14670 for (base
= end
= *str
; *end
!= '\0'; end
++)
14671 if (*end
== ' ' || ((unified_syntax
|| neon_supported
) && *end
== '.'))
14677 /* Handle a possible width suffix and/or Neon type suffix. */
14682 /* The .w and .n suffixes are only valid if the unified syntax is in
14684 if (unified_syntax
&& end
[1] == 'w')
14686 else if (unified_syntax
&& end
[1] == 'n')
14691 inst
.vectype
.elems
= 0;
14693 *str
= end
+ offset
;
14695 if (end
[offset
] == '.')
14697 /* See if we have a Neon type suffix (possible in either unified or
14698 non-unified ARM syntax mode). */
14699 if (parse_neon_type (&inst
.vectype
, str
) == FAIL
)
14702 else if (end
[offset
] != '\0' && end
[offset
] != ' ')
14708 /* Look for unaffixed or special-case affixed mnemonic. */
14709 opcode
= hash_find_n (arm_ops_hsh
, base
, end
- base
);
14713 if (opcode
->tag
< OT_odd_infix_0
)
14715 inst
.cond
= COND_ALWAYS
;
14719 if (warn_on_deprecated
&& unified_syntax
)
14720 as_warn (_("conditional infixes are deprecated in unified syntax"));
14721 affix
= base
+ (opcode
->tag
- OT_odd_infix_0
);
14722 cond
= hash_find_n (arm_cond_hsh
, affix
, 2);
14725 inst
.cond
= cond
->value
;
14729 /* Cannot have a conditional suffix on a mnemonic of less than two
14731 if (end
- base
< 3)
14734 /* Look for suffixed mnemonic. */
14736 cond
= hash_find_n (arm_cond_hsh
, affix
, 2);
14737 opcode
= hash_find_n (arm_ops_hsh
, base
, affix
- base
);
14738 if (opcode
&& cond
)
14741 switch (opcode
->tag
)
14743 case OT_cinfix3_legacy
:
14744 /* Ignore conditional suffixes matched on infix only mnemonics. */
14748 case OT_cinfix3_deprecated
:
14749 case OT_odd_infix_unc
:
14750 if (!unified_syntax
)
14752 /* else fall through */
14756 case OT_csuf_or_in3
:
14757 inst
.cond
= cond
->value
;
14760 case OT_unconditional
:
14761 case OT_unconditionalF
:
14764 inst
.cond
= cond
->value
;
14768 /* delayed diagnostic */
14769 inst
.error
= BAD_COND
;
14770 inst
.cond
= COND_ALWAYS
;
14779 /* Cannot have a usual-position infix on a mnemonic of less than
14780 six characters (five would be a suffix). */
14781 if (end
- base
< 6)
14784 /* Look for infixed mnemonic in the usual position. */
14786 cond
= hash_find_n (arm_cond_hsh
, affix
, 2);
14790 memcpy (save
, affix
, 2);
14791 memmove (affix
, affix
+ 2, (end
- affix
) - 2);
14792 opcode
= hash_find_n (arm_ops_hsh
, base
, (end
- base
) - 2);
14793 memmove (affix
+ 2, affix
, (end
- affix
) - 2);
14794 memcpy (affix
, save
, 2);
14797 && (opcode
->tag
== OT_cinfix3
14798 || opcode
->tag
== OT_cinfix3_deprecated
14799 || opcode
->tag
== OT_csuf_or_in3
14800 || opcode
->tag
== OT_cinfix3_legacy
))
14803 if (warn_on_deprecated
&& unified_syntax
14804 && (opcode
->tag
== OT_cinfix3
14805 || opcode
->tag
== OT_cinfix3_deprecated
))
14806 as_warn (_("conditional infixes are deprecated in unified syntax"));
14808 inst
.cond
= cond
->value
;
14815 /* This function generates an initial IT instruction, leaving its block
14816 virtually open for the new instructions. Eventually,
14817 the mask will be updated by now_it_add_mask () each time
14818 a new instruction needs to be included in the IT block.
14819 Finally, the block is closed with close_automatic_it_block ().
14820 The block closure can be requested either from md_assemble (),
14821 a tencode (), or due to a label hook. */
14824 new_automatic_it_block (int cond
)
14826 now_it
.state
= AUTOMATIC_IT_BLOCK
;
14827 now_it
.mask
= 0x18;
14829 now_it
.block_length
= 1;
14830 now_it
.insn
= output_it_inst (cond
, now_it
.mask
, NULL
);
14833 /* Close an automatic IT block.
14834 See comments in new_automatic_it_block (). */
14837 close_automatic_it_block (void)
14839 now_it
.mask
= 0x10;
14840 now_it
.block_length
= 0;
14843 /* Update the mask of the current automatically-generated IT
14844 instruction. See comments in new_automatic_it_block (). */
14847 now_it_add_mask (int cond
)
14849 #define CLEAR_BIT(value, nbit) ((value) & ~(1 << (nbit)))
14850 #define SET_BIT_VALUE(value, bitvalue, nbit) (CLEAR_BIT (value, nbit) \
14851 | ((bitvalue) << (nbit)))
14853 const int resulting_bit
= (cond
& 1);
14854 now_it
.mask
&= 0xf;
14855 now_it
.mask
= SET_BIT_VALUE (now_it
.mask
,
14857 (5 - now_it
.block_length
));
14858 now_it
.mask
= SET_BIT_VALUE (now_it
.mask
,
14860 ((5 - now_it
.block_length
) - 1) );
14861 output_it_inst (now_it
.cc
, now_it
.mask
, now_it
.insn
);
14864 #undef SET_BIT_VALUE
14868 /* The IT blocks handling machinery is accessed through the these functions:
14869 it_fsm_pre_encode () from md_assemble ()
14870 set_it_insn_type () optional, from the tencode functions
14871 set_it_insn_type_last () ditto
14872 in_it_block () ditto
14873 it_fsm_post_encode () from md_assemble ()
14874 force_automatic_it_block_close () from label habdling functions
14877 1) md_assemble () calls it_fsm_pre_encode () before calling tencode (),
14878 initializing the IT insn type with a generic initial value depending
14879 on the inst.condition.
14880 2) During the tencode function, two things may happen:
14881 a) The tencode function overrides the IT insn type by
14882 calling either set_it_insn_type (type) or set_it_insn_type_last ().
14883 b) The tencode function queries the IT block state by
14884 calling in_it_block () (i.e. to determine narrow/not narrow mode).
14886 Both set_it_insn_type and in_it_block run the internal FSM state
14887 handling function (handle_it_state), because: a) setting the IT insn
14888 type may incur in an invalid state (exiting the function),
14889 and b) querying the state requires the FSM to be updated.
14890 Specifically we want to avoid creating an IT block for conditional
14891 branches, so it_fsm_pre_encode is actually a guess and we can't
14892 determine whether an IT block is required until the tencode () routine
14893 has decided what type of instruction this actually it.
14894 Because of this, if set_it_insn_type and in_it_block have to be used,
14895 set_it_insn_type has to be called first.
14897 set_it_insn_type_last () is a wrapper of set_it_insn_type (type), that
14898 determines the insn IT type depending on the inst.cond code.
14899 When a tencode () routine encodes an instruction that can be
14900 either outside an IT block, or, in the case of being inside, has to be
14901 the last one, set_it_insn_type_last () will determine the proper
14902 IT instruction type based on the inst.cond code. Otherwise,
14903 set_it_insn_type can be called for overriding that logic or
14904 for covering other cases.
14906 Calling handle_it_state () may not transition the IT block state to
14907 OUTSIDE_IT_BLOCK immediatelly, since the (current) state could be
14908 still queried. Instead, if the FSM determines that the state should
14909 be transitioned to OUTSIDE_IT_BLOCK, a flag is marked to be closed
14910 after the tencode () function: that's what it_fsm_post_encode () does.
14912 Since in_it_block () calls the state handling function to get an
14913 updated state, an error may occur (due to invalid insns combination).
14914 In that case, inst.error is set.
14915 Therefore, inst.error has to be checked after the execution of
14916 the tencode () routine.
14918 3) Back in md_assemble(), it_fsm_post_encode () is called to commit
14919 any pending state change (if any) that didn't take place in
14920 handle_it_state () as explained above. */
14923 it_fsm_pre_encode (void)
14925 if (inst
.cond
!= COND_ALWAYS
)
14926 inst
.it_insn_type
= INSIDE_IT_INSN
;
14928 inst
.it_insn_type
= OUTSIDE_IT_INSN
;
14930 now_it
.state_handled
= 0;
14933 /* IT state FSM handling function. */
14936 handle_it_state (void)
14938 now_it
.state_handled
= 1;
14940 switch (now_it
.state
)
14942 case OUTSIDE_IT_BLOCK
:
14943 switch (inst
.it_insn_type
)
14945 case OUTSIDE_IT_INSN
:
14948 case INSIDE_IT_INSN
:
14949 case INSIDE_IT_LAST_INSN
:
14950 if (thumb_mode
== 0)
14953 && !(implicit_it_mode
& IMPLICIT_IT_MODE_ARM
))
14954 as_tsktsk (_("Warning: conditional outside an IT block"\
14959 if ((implicit_it_mode
& IMPLICIT_IT_MODE_THUMB
)
14960 && ARM_CPU_HAS_FEATURE (cpu_variant
, arm_arch_t2
))
14962 /* Automatically generate the IT instruction. */
14963 new_automatic_it_block (inst
.cond
);
14964 if (inst
.it_insn_type
== INSIDE_IT_LAST_INSN
)
14965 close_automatic_it_block ();
14969 inst
.error
= BAD_OUT_IT
;
14975 case IF_INSIDE_IT_LAST_INSN
:
14976 case NEUTRAL_IT_INSN
:
14980 now_it
.state
= MANUAL_IT_BLOCK
;
14981 now_it
.block_length
= 0;
14986 case AUTOMATIC_IT_BLOCK
:
14987 /* Three things may happen now:
14988 a) We should increment current it block size;
14989 b) We should close current it block (closing insn or 4 insns);
14990 c) We should close current it block and start a new one (due
14991 to incompatible conditions or
14992 4 insns-length block reached). */
14994 switch (inst
.it_insn_type
)
14996 case OUTSIDE_IT_INSN
:
14997 /* The closure of the block shall happen immediatelly,
14998 so any in_it_block () call reports the block as closed. */
14999 force_automatic_it_block_close ();
15002 case INSIDE_IT_INSN
:
15003 case INSIDE_IT_LAST_INSN
:
15004 case IF_INSIDE_IT_LAST_INSN
:
15005 now_it
.block_length
++;
15007 if (now_it
.block_length
> 4
15008 || !now_it_compatible (inst
.cond
))
15010 force_automatic_it_block_close ();
15011 if (inst
.it_insn_type
!= IF_INSIDE_IT_LAST_INSN
)
15012 new_automatic_it_block (inst
.cond
);
15016 now_it_add_mask (inst
.cond
);
15019 if (now_it
.state
== AUTOMATIC_IT_BLOCK
15020 && (inst
.it_insn_type
== INSIDE_IT_LAST_INSN
15021 || inst
.it_insn_type
== IF_INSIDE_IT_LAST_INSN
))
15022 close_automatic_it_block ();
15025 case NEUTRAL_IT_INSN
:
15026 now_it
.block_length
++;
15028 if (now_it
.block_length
> 4)
15029 force_automatic_it_block_close ();
15031 now_it_add_mask (now_it
.cc
& 1);
15035 close_automatic_it_block ();
15036 now_it
.state
= MANUAL_IT_BLOCK
;
15041 case MANUAL_IT_BLOCK
:
15043 /* Check conditional suffixes. */
15044 const int cond
= now_it
.cc
^ ((now_it
.mask
>> 4) & 1) ^ 1;
15047 now_it
.mask
&= 0x1f;
15048 is_last
= (now_it
.mask
== 0x10);
15050 switch (inst
.it_insn_type
)
15052 case OUTSIDE_IT_INSN
:
15053 inst
.error
= BAD_NOT_IT
;
15056 case INSIDE_IT_INSN
:
15057 if (cond
!= inst
.cond
)
15059 inst
.error
= BAD_IT_COND
;
15064 case INSIDE_IT_LAST_INSN
:
15065 case IF_INSIDE_IT_LAST_INSN
:
15066 if (cond
!= inst
.cond
)
15068 inst
.error
= BAD_IT_COND
;
15073 inst
.error
= BAD_BRANCH
;
15078 case NEUTRAL_IT_INSN
:
15079 /* The BKPT instruction is unconditional even in an IT block. */
15083 inst
.error
= BAD_IT_IT
;
15094 it_fsm_post_encode (void)
15098 if (!now_it
.state_handled
)
15099 handle_it_state ();
15101 is_last
= (now_it
.mask
== 0x10);
15104 now_it
.state
= OUTSIDE_IT_BLOCK
;
15110 force_automatic_it_block_close (void)
15112 if (now_it
.state
== AUTOMATIC_IT_BLOCK
)
15114 close_automatic_it_block ();
15115 now_it
.state
= OUTSIDE_IT_BLOCK
;
15123 if (!now_it
.state_handled
)
15124 handle_it_state ();
15126 return now_it
.state
!= OUTSIDE_IT_BLOCK
;
15130 md_assemble (char *str
)
15133 const struct asm_opcode
* opcode
;
15135 /* Align the previous label if needed. */
15136 if (last_label_seen
!= NULL
)
15138 symbol_set_frag (last_label_seen
, frag_now
);
15139 S_SET_VALUE (last_label_seen
, (valueT
) frag_now_fix ());
15140 S_SET_SEGMENT (last_label_seen
, now_seg
);
15143 memset (&inst
, '\0', sizeof (inst
));
15144 inst
.reloc
.type
= BFD_RELOC_UNUSED
;
15146 opcode
= opcode_lookup (&p
);
15149 /* It wasn't an instruction, but it might be a register alias of
15150 the form alias .req reg, or a Neon .dn/.qn directive. */
15151 if (!create_register_alias (str
, p
)
15152 && !create_neon_reg_alias (str
, p
))
15153 as_bad (_("bad instruction `%s'"), str
);
15158 if (warn_on_deprecated
&& opcode
->tag
== OT_cinfix3_deprecated
)
15159 as_warn (_("s suffix on comparison instruction is deprecated"));
15161 /* The value which unconditional instructions should have in place of the
15162 condition field. */
15163 inst
.uncond_value
= (opcode
->tag
== OT_csuffixF
) ? 0xf : -1;
15167 arm_feature_set variant
;
15169 variant
= cpu_variant
;
15170 /* Only allow coprocessor instructions on Thumb-2 capable devices. */
15171 if (!ARM_CPU_HAS_FEATURE (variant
, arm_arch_t2
))
15172 ARM_CLEAR_FEATURE (variant
, variant
, fpu_any_hard
);
15173 /* Check that this instruction is supported for this CPU. */
15174 if (!opcode
->tvariant
15175 || (thumb_mode
== 1
15176 && !ARM_CPU_HAS_FEATURE (variant
, *opcode
->tvariant
)))
15178 as_bad (_("selected processor does not support `%s'"), str
);
15181 if (inst
.cond
!= COND_ALWAYS
&& !unified_syntax
15182 && opcode
->tencode
!= do_t_branch
)
15184 as_bad (_("Thumb does not support conditional execution"));
15188 if (!ARM_CPU_HAS_FEATURE (variant
, arm_ext_v6t2
) && !inst
.size_req
)
15190 /* Implicit require narrow instructions on Thumb-1. This avoids
15191 relaxation accidentally introducing Thumb-2 instructions. */
15192 if (opcode
->tencode
!= do_t_blx
&& opcode
->tencode
!= do_t_branch23
15193 && !(ARM_CPU_HAS_FEATURE (*opcode
->tvariant
, arm_ext_msr
)
15194 || ARM_CPU_HAS_FEATURE (*opcode
->tvariant
, arm_ext_barrier
)))
15198 mapping_state (MAP_THUMB
);
15199 inst
.instruction
= opcode
->tvalue
;
15201 if (!parse_operands (p
, opcode
->operands
))
15203 /* Prepare the it_insn_type for those encodings that don't set
15205 it_fsm_pre_encode ();
15207 opcode
->tencode ();
15209 it_fsm_post_encode ();
15212 if (!(inst
.error
|| inst
.relax
))
15214 gas_assert (inst
.instruction
< 0xe800 || inst
.instruction
> 0xffff);
15215 inst
.size
= (inst
.instruction
> 0xffff ? 4 : 2);
15216 if (inst
.size_req
&& inst
.size_req
!= inst
.size
)
15218 as_bad (_("cannot honor width suffix -- `%s'"), str
);
15223 /* Something has gone badly wrong if we try to relax a fixed size
15225 gas_assert (inst
.size_req
== 0 || !inst
.relax
);
15227 ARM_MERGE_FEATURE_SETS (thumb_arch_used
, thumb_arch_used
,
15228 *opcode
->tvariant
);
15229 /* Many Thumb-2 instructions also have Thumb-1 variants, so explicitly
15230 set those bits when Thumb-2 32-bit instructions are seen. ie.
15231 anything other than bl/blx and v6-M instructions.
15232 This is overly pessimistic for relaxable instructions. */
15233 if (((inst
.size
== 4 && (inst
.instruction
& 0xf800e800) != 0xf000e800)
15235 && !(ARM_CPU_HAS_FEATURE (*opcode
->tvariant
, arm_ext_msr
)
15236 || ARM_CPU_HAS_FEATURE (*opcode
->tvariant
, arm_ext_barrier
)))
15237 ARM_MERGE_FEATURE_SETS (thumb_arch_used
, thumb_arch_used
,
15240 else if (ARM_CPU_HAS_FEATURE (cpu_variant
, arm_ext_v1
))
15244 /* bx is allowed on v5 cores, and sometimes on v4 cores. */
15245 is_bx
= (opcode
->aencode
== do_bx
);
15247 /* Check that this instruction is supported for this CPU. */
15248 if (!(is_bx
&& fix_v4bx
)
15249 && !(opcode
->avariant
&&
15250 ARM_CPU_HAS_FEATURE (cpu_variant
, *opcode
->avariant
)))
15252 as_bad (_("selected processor does not support `%s'"), str
);
15257 as_bad (_("width suffixes are invalid in ARM mode -- `%s'"), str
);
15261 mapping_state (MAP_ARM
);
15262 inst
.instruction
= opcode
->avalue
;
15263 if (opcode
->tag
== OT_unconditionalF
)
15264 inst
.instruction
|= 0xF << 28;
15266 inst
.instruction
|= inst
.cond
<< 28;
15267 inst
.size
= INSN_SIZE
;
15268 if (!parse_operands (p
, opcode
->operands
))
15270 it_fsm_pre_encode ();
15271 opcode
->aencode ();
15272 it_fsm_post_encode ();
15274 /* Arm mode bx is marked as both v4T and v5 because it's still required
15275 on a hypothetical non-thumb v5 core. */
15277 ARM_MERGE_FEATURE_SETS (arm_arch_used
, arm_arch_used
, arm_ext_v4t
);
15279 ARM_MERGE_FEATURE_SETS (arm_arch_used
, arm_arch_used
,
15280 *opcode
->avariant
);
15284 as_bad (_("attempt to use an ARM instruction on a Thumb-only processor "
15292 check_it_blocks_finished (void)
15297 for (sect
= stdoutput
->sections
; sect
!= NULL
; sect
= sect
->next
)
15298 if (seg_info (sect
)->tc_segment_info_data
.current_it
.state
15299 == MANUAL_IT_BLOCK
)
15301 as_warn (_("section '%s' finished with an open IT block."),
15305 if (now_it
.state
== MANUAL_IT_BLOCK
)
15306 as_warn (_("file finished with an open IT block."));
15310 /* Various frobbings of labels and their addresses. */
15313 arm_start_line_hook (void)
15315 last_label_seen
= NULL
;
15319 arm_frob_label (symbolS
* sym
)
15321 last_label_seen
= sym
;
15323 ARM_SET_THUMB (sym
, thumb_mode
);
15325 #if defined OBJ_COFF || defined OBJ_ELF
15326 ARM_SET_INTERWORK (sym
, support_interwork
);
15329 force_automatic_it_block_close ();
15331 /* Note - do not allow local symbols (.Lxxx) to be labelled
15332 as Thumb functions. This is because these labels, whilst
15333 they exist inside Thumb code, are not the entry points for
15334 possible ARM->Thumb calls. Also, these labels can be used
15335 as part of a computed goto or switch statement. eg gcc
15336 can generate code that looks like this:
15338 ldr r2, [pc, .Laaa]
15348 The first instruction loads the address of the jump table.
15349 The second instruction converts a table index into a byte offset.
15350 The third instruction gets the jump address out of the table.
15351 The fourth instruction performs the jump.
15353 If the address stored at .Laaa is that of a symbol which has the
15354 Thumb_Func bit set, then the linker will arrange for this address
15355 to have the bottom bit set, which in turn would mean that the
15356 address computation performed by the third instruction would end
15357 up with the bottom bit set. Since the ARM is capable of unaligned
15358 word loads, the instruction would then load the incorrect address
15359 out of the jump table, and chaos would ensue. */
15360 if (label_is_thumb_function_name
15361 && (S_GET_NAME (sym
)[0] != '.' || S_GET_NAME (sym
)[1] != 'L')
15362 && (bfd_get_section_flags (stdoutput
, now_seg
) & SEC_CODE
) != 0)
15364 /* When the address of a Thumb function is taken the bottom
15365 bit of that address should be set. This will allow
15366 interworking between Arm and Thumb functions to work
15369 THUMB_SET_FUNC (sym
, 1);
15371 label_is_thumb_function_name
= FALSE
;
15374 dwarf2_emit_label (sym
);
15378 arm_data_in_code (void)
15380 if (thumb_mode
&& ! strncmp (input_line_pointer
+ 1, "data:", 5))
15382 *input_line_pointer
= '/';
15383 input_line_pointer
+= 5;
15384 *input_line_pointer
= 0;
15392 arm_canonicalize_symbol_name (char * name
)
15396 if (thumb_mode
&& (len
= strlen (name
)) > 5
15397 && streq (name
+ len
- 5, "/data"))
15398 *(name
+ len
- 5) = 0;
15403 /* Table of all register names defined by default. The user can
15404 define additional names with .req. Note that all register names
15405 should appear in both upper and lowercase variants. Some registers
15406 also have mixed-case names. */
15408 #define REGDEF(s,n,t) { #s, n, REG_TYPE_##t, TRUE, 0 }
15409 #define REGNUM(p,n,t) REGDEF(p##n, n, t)
15410 #define REGNUM2(p,n,t) REGDEF(p##n, 2 * n, t)
15411 #define REGSET(p,t) \
15412 REGNUM(p, 0,t), REGNUM(p, 1,t), REGNUM(p, 2,t), REGNUM(p, 3,t), \
15413 REGNUM(p, 4,t), REGNUM(p, 5,t), REGNUM(p, 6,t), REGNUM(p, 7,t), \
15414 REGNUM(p, 8,t), REGNUM(p, 9,t), REGNUM(p,10,t), REGNUM(p,11,t), \
15415 REGNUM(p,12,t), REGNUM(p,13,t), REGNUM(p,14,t), REGNUM(p,15,t)
15416 #define REGSETH(p,t) \
15417 REGNUM(p,16,t), REGNUM(p,17,t), REGNUM(p,18,t), REGNUM(p,19,t), \
15418 REGNUM(p,20,t), REGNUM(p,21,t), REGNUM(p,22,t), REGNUM(p,23,t), \
15419 REGNUM(p,24,t), REGNUM(p,25,t), REGNUM(p,26,t), REGNUM(p,27,t), \
15420 REGNUM(p,28,t), REGNUM(p,29,t), REGNUM(p,30,t), REGNUM(p,31,t)
15421 #define REGSET2(p,t) \
15422 REGNUM2(p, 0,t), REGNUM2(p, 1,t), REGNUM2(p, 2,t), REGNUM2(p, 3,t), \
15423 REGNUM2(p, 4,t), REGNUM2(p, 5,t), REGNUM2(p, 6,t), REGNUM2(p, 7,t), \
15424 REGNUM2(p, 8,t), REGNUM2(p, 9,t), REGNUM2(p,10,t), REGNUM2(p,11,t), \
15425 REGNUM2(p,12,t), REGNUM2(p,13,t), REGNUM2(p,14,t), REGNUM2(p,15,t)
15427 static const struct reg_entry reg_names
[] =
15429 /* ARM integer registers. */
15430 REGSET(r
, RN
), REGSET(R
, RN
),
15432 /* ATPCS synonyms. */
15433 REGDEF(a1
,0,RN
), REGDEF(a2
,1,RN
), REGDEF(a3
, 2,RN
), REGDEF(a4
, 3,RN
),
15434 REGDEF(v1
,4,RN
), REGDEF(v2
,5,RN
), REGDEF(v3
, 6,RN
), REGDEF(v4
, 7,RN
),
15435 REGDEF(v5
,8,RN
), REGDEF(v6
,9,RN
), REGDEF(v7
,10,RN
), REGDEF(v8
,11,RN
),
15437 REGDEF(A1
,0,RN
), REGDEF(A2
,1,RN
), REGDEF(A3
, 2,RN
), REGDEF(A4
, 3,RN
),
15438 REGDEF(V1
,4,RN
), REGDEF(V2
,5,RN
), REGDEF(V3
, 6,RN
), REGDEF(V4
, 7,RN
),
15439 REGDEF(V5
,8,RN
), REGDEF(V6
,9,RN
), REGDEF(V7
,10,RN
), REGDEF(V8
,11,RN
),
15441 /* Well-known aliases. */
15442 REGDEF(wr
, 7,RN
), REGDEF(sb
, 9,RN
), REGDEF(sl
,10,RN
), REGDEF(fp
,11,RN
),
15443 REGDEF(ip
,12,RN
), REGDEF(sp
,13,RN
), REGDEF(lr
,14,RN
), REGDEF(pc
,15,RN
),
15445 REGDEF(WR
, 7,RN
), REGDEF(SB
, 9,RN
), REGDEF(SL
,10,RN
), REGDEF(FP
,11,RN
),
15446 REGDEF(IP
,12,RN
), REGDEF(SP
,13,RN
), REGDEF(LR
,14,RN
), REGDEF(PC
,15,RN
),
15448 /* Coprocessor numbers. */
15449 REGSET(p
, CP
), REGSET(P
, CP
),
15451 /* Coprocessor register numbers. The "cr" variants are for backward
15453 REGSET(c
, CN
), REGSET(C
, CN
),
15454 REGSET(cr
, CN
), REGSET(CR
, CN
),
15456 /* FPA registers. */
15457 REGNUM(f
,0,FN
), REGNUM(f
,1,FN
), REGNUM(f
,2,FN
), REGNUM(f
,3,FN
),
15458 REGNUM(f
,4,FN
), REGNUM(f
,5,FN
), REGNUM(f
,6,FN
), REGNUM(f
,7, FN
),
15460 REGNUM(F
,0,FN
), REGNUM(F
,1,FN
), REGNUM(F
,2,FN
), REGNUM(F
,3,FN
),
15461 REGNUM(F
,4,FN
), REGNUM(F
,5,FN
), REGNUM(F
,6,FN
), REGNUM(F
,7, FN
),
15463 /* VFP SP registers. */
15464 REGSET(s
,VFS
), REGSET(S
,VFS
),
15465 REGSETH(s
,VFS
), REGSETH(S
,VFS
),
15467 /* VFP DP Registers. */
15468 REGSET(d
,VFD
), REGSET(D
,VFD
),
15469 /* Extra Neon DP registers. */
15470 REGSETH(d
,VFD
), REGSETH(D
,VFD
),
15472 /* Neon QP registers. */
15473 REGSET2(q
,NQ
), REGSET2(Q
,NQ
),
15475 /* VFP control registers. */
15476 REGDEF(fpsid
,0,VFC
), REGDEF(fpscr
,1,VFC
), REGDEF(fpexc
,8,VFC
),
15477 REGDEF(FPSID
,0,VFC
), REGDEF(FPSCR
,1,VFC
), REGDEF(FPEXC
,8,VFC
),
15478 REGDEF(fpinst
,9,VFC
), REGDEF(fpinst2
,10,VFC
),
15479 REGDEF(FPINST
,9,VFC
), REGDEF(FPINST2
,10,VFC
),
15480 REGDEF(mvfr0
,7,VFC
), REGDEF(mvfr1
,6,VFC
),
15481 REGDEF(MVFR0
,7,VFC
), REGDEF(MVFR1
,6,VFC
),
15483 /* Maverick DSP coprocessor registers. */
15484 REGSET(mvf
,MVF
), REGSET(mvd
,MVD
), REGSET(mvfx
,MVFX
), REGSET(mvdx
,MVDX
),
15485 REGSET(MVF
,MVF
), REGSET(MVD
,MVD
), REGSET(MVFX
,MVFX
), REGSET(MVDX
,MVDX
),
15487 REGNUM(mvax
,0,MVAX
), REGNUM(mvax
,1,MVAX
),
15488 REGNUM(mvax
,2,MVAX
), REGNUM(mvax
,3,MVAX
),
15489 REGDEF(dspsc
,0,DSPSC
),
15491 REGNUM(MVAX
,0,MVAX
), REGNUM(MVAX
,1,MVAX
),
15492 REGNUM(MVAX
,2,MVAX
), REGNUM(MVAX
,3,MVAX
),
15493 REGDEF(DSPSC
,0,DSPSC
),
15495 /* iWMMXt data registers - p0, c0-15. */
15496 REGSET(wr
,MMXWR
), REGSET(wR
,MMXWR
), REGSET(WR
, MMXWR
),
15498 /* iWMMXt control registers - p1, c0-3. */
15499 REGDEF(wcid
, 0,MMXWC
), REGDEF(wCID
, 0,MMXWC
), REGDEF(WCID
, 0,MMXWC
),
15500 REGDEF(wcon
, 1,MMXWC
), REGDEF(wCon
, 1,MMXWC
), REGDEF(WCON
, 1,MMXWC
),
15501 REGDEF(wcssf
, 2,MMXWC
), REGDEF(wCSSF
, 2,MMXWC
), REGDEF(WCSSF
, 2,MMXWC
),
15502 REGDEF(wcasf
, 3,MMXWC
), REGDEF(wCASF
, 3,MMXWC
), REGDEF(WCASF
, 3,MMXWC
),
15504 /* iWMMXt scalar (constant/offset) registers - p1, c8-11. */
15505 REGDEF(wcgr0
, 8,MMXWCG
), REGDEF(wCGR0
, 8,MMXWCG
), REGDEF(WCGR0
, 8,MMXWCG
),
15506 REGDEF(wcgr1
, 9,MMXWCG
), REGDEF(wCGR1
, 9,MMXWCG
), REGDEF(WCGR1
, 9,MMXWCG
),
15507 REGDEF(wcgr2
,10,MMXWCG
), REGDEF(wCGR2
,10,MMXWCG
), REGDEF(WCGR2
,10,MMXWCG
),
15508 REGDEF(wcgr3
,11,MMXWCG
), REGDEF(wCGR3
,11,MMXWCG
), REGDEF(WCGR3
,11,MMXWCG
),
15510 /* XScale accumulator registers. */
15511 REGNUM(acc
,0,XSCALE
), REGNUM(ACC
,0,XSCALE
),
15517 /* Table of all PSR suffixes. Bare "CPSR" and "SPSR" are handled
15518 within psr_required_here. */
15519 static const struct asm_psr psrs
[] =
15521 /* Backward compatibility notation. Note that "all" is no longer
15522 truly all possible PSR bits. */
15523 {"all", PSR_c
| PSR_f
},
15527 /* Individual flags. */
15532 /* Combinations of flags. */
15533 {"fs", PSR_f
| PSR_s
},
15534 {"fx", PSR_f
| PSR_x
},
15535 {"fc", PSR_f
| PSR_c
},
15536 {"sf", PSR_s
| PSR_f
},
15537 {"sx", PSR_s
| PSR_x
},
15538 {"sc", PSR_s
| PSR_c
},
15539 {"xf", PSR_x
| PSR_f
},
15540 {"xs", PSR_x
| PSR_s
},
15541 {"xc", PSR_x
| PSR_c
},
15542 {"cf", PSR_c
| PSR_f
},
15543 {"cs", PSR_c
| PSR_s
},
15544 {"cx", PSR_c
| PSR_x
},
15545 {"fsx", PSR_f
| PSR_s
| PSR_x
},
15546 {"fsc", PSR_f
| PSR_s
| PSR_c
},
15547 {"fxs", PSR_f
| PSR_x
| PSR_s
},
15548 {"fxc", PSR_f
| PSR_x
| PSR_c
},
15549 {"fcs", PSR_f
| PSR_c
| PSR_s
},
15550 {"fcx", PSR_f
| PSR_c
| PSR_x
},
15551 {"sfx", PSR_s
| PSR_f
| PSR_x
},
15552 {"sfc", PSR_s
| PSR_f
| PSR_c
},
15553 {"sxf", PSR_s
| PSR_x
| PSR_f
},
15554 {"sxc", PSR_s
| PSR_x
| PSR_c
},
15555 {"scf", PSR_s
| PSR_c
| PSR_f
},
15556 {"scx", PSR_s
| PSR_c
| PSR_x
},
15557 {"xfs", PSR_x
| PSR_f
| PSR_s
},
15558 {"xfc", PSR_x
| PSR_f
| PSR_c
},
15559 {"xsf", PSR_x
| PSR_s
| PSR_f
},
15560 {"xsc", PSR_x
| PSR_s
| PSR_c
},
15561 {"xcf", PSR_x
| PSR_c
| PSR_f
},
15562 {"xcs", PSR_x
| PSR_c
| PSR_s
},
15563 {"cfs", PSR_c
| PSR_f
| PSR_s
},
15564 {"cfx", PSR_c
| PSR_f
| PSR_x
},
15565 {"csf", PSR_c
| PSR_s
| PSR_f
},
15566 {"csx", PSR_c
| PSR_s
| PSR_x
},
15567 {"cxf", PSR_c
| PSR_x
| PSR_f
},
15568 {"cxs", PSR_c
| PSR_x
| PSR_s
},
15569 {"fsxc", PSR_f
| PSR_s
| PSR_x
| PSR_c
},
15570 {"fscx", PSR_f
| PSR_s
| PSR_c
| PSR_x
},
15571 {"fxsc", PSR_f
| PSR_x
| PSR_s
| PSR_c
},
15572 {"fxcs", PSR_f
| PSR_x
| PSR_c
| PSR_s
},
15573 {"fcsx", PSR_f
| PSR_c
| PSR_s
| PSR_x
},
15574 {"fcxs", PSR_f
| PSR_c
| PSR_x
| PSR_s
},
15575 {"sfxc", PSR_s
| PSR_f
| PSR_x
| PSR_c
},
15576 {"sfcx", PSR_s
| PSR_f
| PSR_c
| PSR_x
},
15577 {"sxfc", PSR_s
| PSR_x
| PSR_f
| PSR_c
},
15578 {"sxcf", PSR_s
| PSR_x
| PSR_c
| PSR_f
},
15579 {"scfx", PSR_s
| PSR_c
| PSR_f
| PSR_x
},
15580 {"scxf", PSR_s
| PSR_c
| PSR_x
| PSR_f
},
15581 {"xfsc", PSR_x
| PSR_f
| PSR_s
| PSR_c
},
15582 {"xfcs", PSR_x
| PSR_f
| PSR_c
| PSR_s
},
15583 {"xsfc", PSR_x
| PSR_s
| PSR_f
| PSR_c
},
15584 {"xscf", PSR_x
| PSR_s
| PSR_c
| PSR_f
},
15585 {"xcfs", PSR_x
| PSR_c
| PSR_f
| PSR_s
},
15586 {"xcsf", PSR_x
| PSR_c
| PSR_s
| PSR_f
},
15587 {"cfsx", PSR_c
| PSR_f
| PSR_s
| PSR_x
},
15588 {"cfxs", PSR_c
| PSR_f
| PSR_x
| PSR_s
},
15589 {"csfx", PSR_c
| PSR_s
| PSR_f
| PSR_x
},
15590 {"csxf", PSR_c
| PSR_s
| PSR_x
| PSR_f
},
15591 {"cxfs", PSR_c
| PSR_x
| PSR_f
| PSR_s
},
15592 {"cxsf", PSR_c
| PSR_x
| PSR_s
| PSR_f
},
15595 /* Table of V7M psr names. */
15596 static const struct asm_psr v7m_psrs
[] =
15598 {"apsr", 0 }, {"APSR", 0 },
15599 {"iapsr", 1 }, {"IAPSR", 1 },
15600 {"eapsr", 2 }, {"EAPSR", 2 },
15601 {"psr", 3 }, {"PSR", 3 },
15602 {"xpsr", 3 }, {"XPSR", 3 }, {"xPSR", 3 },
15603 {"ipsr", 5 }, {"IPSR", 5 },
15604 {"epsr", 6 }, {"EPSR", 6 },
15605 {"iepsr", 7 }, {"IEPSR", 7 },
15606 {"msp", 8 }, {"MSP", 8 },
15607 {"psp", 9 }, {"PSP", 9 },
15608 {"primask", 16}, {"PRIMASK", 16},
15609 {"basepri", 17}, {"BASEPRI", 17},
15610 {"basepri_max", 18}, {"BASEPRI_MAX", 18},
15611 {"faultmask", 19}, {"FAULTMASK", 19},
15612 {"control", 20}, {"CONTROL", 20}
15615 /* Table of all shift-in-operand names. */
15616 static const struct asm_shift_name shift_names
[] =
15618 { "asl", SHIFT_LSL
}, { "ASL", SHIFT_LSL
},
15619 { "lsl", SHIFT_LSL
}, { "LSL", SHIFT_LSL
},
15620 { "lsr", SHIFT_LSR
}, { "LSR", SHIFT_LSR
},
15621 { "asr", SHIFT_ASR
}, { "ASR", SHIFT_ASR
},
15622 { "ror", SHIFT_ROR
}, { "ROR", SHIFT_ROR
},
15623 { "rrx", SHIFT_RRX
}, { "RRX", SHIFT_RRX
}
15626 /* Table of all explicit relocation names. */
15628 static struct reloc_entry reloc_names
[] =
15630 { "got", BFD_RELOC_ARM_GOT32
}, { "GOT", BFD_RELOC_ARM_GOT32
},
15631 { "gotoff", BFD_RELOC_ARM_GOTOFF
}, { "GOTOFF", BFD_RELOC_ARM_GOTOFF
},
15632 { "plt", BFD_RELOC_ARM_PLT32
}, { "PLT", BFD_RELOC_ARM_PLT32
},
15633 { "target1", BFD_RELOC_ARM_TARGET1
}, { "TARGET1", BFD_RELOC_ARM_TARGET1
},
15634 { "target2", BFD_RELOC_ARM_TARGET2
}, { "TARGET2", BFD_RELOC_ARM_TARGET2
},
15635 { "sbrel", BFD_RELOC_ARM_SBREL32
}, { "SBREL", BFD_RELOC_ARM_SBREL32
},
15636 { "tlsgd", BFD_RELOC_ARM_TLS_GD32
}, { "TLSGD", BFD_RELOC_ARM_TLS_GD32
},
15637 { "tlsldm", BFD_RELOC_ARM_TLS_LDM32
}, { "TLSLDM", BFD_RELOC_ARM_TLS_LDM32
},
15638 { "tlsldo", BFD_RELOC_ARM_TLS_LDO32
}, { "TLSLDO", BFD_RELOC_ARM_TLS_LDO32
},
15639 { "gottpoff",BFD_RELOC_ARM_TLS_IE32
}, { "GOTTPOFF",BFD_RELOC_ARM_TLS_IE32
},
15640 { "tpoff", BFD_RELOC_ARM_TLS_LE32
}, { "TPOFF", BFD_RELOC_ARM_TLS_LE32
}
15644 /* Table of all conditional affixes. 0xF is not defined as a condition code. */
15645 static const struct asm_cond conds
[] =
15649 {"cs", 0x2}, {"hs", 0x2},
15650 {"cc", 0x3}, {"ul", 0x3}, {"lo", 0x3},
15664 static struct asm_barrier_opt barrier_opt_names
[] =
15672 /* Table of ARM-format instructions. */
15674 /* Macros for gluing together operand strings. N.B. In all cases
15675 other than OPS0, the trailing OP_stop comes from default
15676 zero-initialization of the unspecified elements of the array. */
15677 #define OPS0() { OP_stop, }
15678 #define OPS1(a) { OP_##a, }
15679 #define OPS2(a,b) { OP_##a,OP_##b, }
15680 #define OPS3(a,b,c) { OP_##a,OP_##b,OP_##c, }
15681 #define OPS4(a,b,c,d) { OP_##a,OP_##b,OP_##c,OP_##d, }
15682 #define OPS5(a,b,c,d,e) { OP_##a,OP_##b,OP_##c,OP_##d,OP_##e, }
15683 #define OPS6(a,b,c,d,e,f) { OP_##a,OP_##b,OP_##c,OP_##d,OP_##e,OP_##f, }
15685 /* These macros abstract out the exact format of the mnemonic table and
15686 save some repeated characters. */
15688 /* The normal sort of mnemonic; has a Thumb variant; takes a conditional suffix. */
15689 #define TxCE(mnem, op, top, nops, ops, ae, te) \
15690 { #mnem, OPS##nops ops, OT_csuffix, 0x##op, top, ARM_VARIANT, \
15691 THUMB_VARIANT, do_##ae, do_##te }
15693 /* Two variants of the above - TCE for a numeric Thumb opcode, tCE for
15694 a T_MNEM_xyz enumerator. */
15695 #define TCE(mnem, aop, top, nops, ops, ae, te) \
15696 TxCE (mnem, aop, 0x##top, nops, ops, ae, te)
15697 #define tCE(mnem, aop, top, nops, ops, ae, te) \
15698 TxCE (mnem, aop, T_MNEM_##top, nops, ops, ae, te)
15700 /* Second most common sort of mnemonic: has a Thumb variant, takes a conditional
15701 infix after the third character. */
15702 #define TxC3(mnem, op, top, nops, ops, ae, te) \
15703 { #mnem, OPS##nops ops, OT_cinfix3, 0x##op, top, ARM_VARIANT, \
15704 THUMB_VARIANT, do_##ae, do_##te }
15705 #define TxC3w(mnem, op, top, nops, ops, ae, te) \
15706 { #mnem, OPS##nops ops, OT_cinfix3_deprecated, 0x##op, top, ARM_VARIANT, \
15707 THUMB_VARIANT, do_##ae, do_##te }
15708 #define TC3(mnem, aop, top, nops, ops, ae, te) \
15709 TxC3 (mnem, aop, 0x##top, nops, ops, ae, te)
15710 #define TC3w(mnem, aop, top, nops, ops, ae, te) \
15711 TxC3w (mnem, aop, 0x##top, nops, ops, ae, te)
15712 #define tC3(mnem, aop, top, nops, ops, ae, te) \
15713 TxC3 (mnem, aop, T_MNEM_##top, nops, ops, ae, te)
15714 #define tC3w(mnem, aop, top, nops, ops, ae, te) \
15715 TxC3w (mnem, aop, T_MNEM_##top, nops, ops, ae, te)
15717 /* Mnemonic with a conditional infix in an unusual place. Each and every variant has to
15718 appear in the condition table. */
15719 #define TxCM_(m1, m2, m3, op, top, nops, ops, ae, te) \
15720 { #m1 #m2 #m3, OPS##nops ops, sizeof (#m2) == 1 ? OT_odd_infix_unc : OT_odd_infix_0 + sizeof (#m1) - 1, \
15721 0x##op, top, ARM_VARIANT, THUMB_VARIANT, do_##ae, do_##te }
15723 #define TxCM(m1, m2, op, top, nops, ops, ae, te) \
15724 TxCM_ (m1, , m2, op, top, nops, ops, ae, te), \
15725 TxCM_ (m1, eq, m2, op, top, nops, ops, ae, te), \
15726 TxCM_ (m1, ne, m2, op, top, nops, ops, ae, te), \
15727 TxCM_ (m1, cs, m2, op, top, nops, ops, ae, te), \
15728 TxCM_ (m1, hs, m2, op, top, nops, ops, ae, te), \
15729 TxCM_ (m1, cc, m2, op, top, nops, ops, ae, te), \
15730 TxCM_ (m1, ul, m2, op, top, nops, ops, ae, te), \
15731 TxCM_ (m1, lo, m2, op, top, nops, ops, ae, te), \
15732 TxCM_ (m1, mi, m2, op, top, nops, ops, ae, te), \
15733 TxCM_ (m1, pl, m2, op, top, nops, ops, ae, te), \
15734 TxCM_ (m1, vs, m2, op, top, nops, ops, ae, te), \
15735 TxCM_ (m1, vc, m2, op, top, nops, ops, ae, te), \
15736 TxCM_ (m1, hi, m2, op, top, nops, ops, ae, te), \
15737 TxCM_ (m1, ls, m2, op, top, nops, ops, ae, te), \
15738 TxCM_ (m1, ge, m2, op, top, nops, ops, ae, te), \
15739 TxCM_ (m1, lt, m2, op, top, nops, ops, ae, te), \
15740 TxCM_ (m1, gt, m2, op, top, nops, ops, ae, te), \
15741 TxCM_ (m1, le, m2, op, top, nops, ops, ae, te), \
15742 TxCM_ (m1, al, m2, op, top, nops, ops, ae, te)
15744 #define TCM(m1,m2, aop, top, nops, ops, ae, te) \
15745 TxCM (m1,m2, aop, 0x##top, nops, ops, ae, te)
15746 #define tCM(m1,m2, aop, top, nops, ops, ae, te) \
15747 TxCM (m1,m2, aop, T_MNEM_##top, nops, ops, ae, te)
15749 /* Mnemonic that cannot be conditionalized. The ARM condition-code
15750 field is still 0xE. Many of the Thumb variants can be executed
15751 conditionally, so this is checked separately. */
15752 #define TUE(mnem, op, top, nops, ops, ae, te) \
15753 { #mnem, OPS##nops ops, OT_unconditional, 0x##op, 0x##top, ARM_VARIANT, \
15754 THUMB_VARIANT, do_##ae, do_##te }
15756 /* Mnemonic that cannot be conditionalized, and bears 0xF in its ARM
15757 condition code field. */
15758 #define TUF(mnem, op, top, nops, ops, ae, te) \
15759 { #mnem, OPS##nops ops, OT_unconditionalF, 0x##op, 0x##top, ARM_VARIANT, \
15760 THUMB_VARIANT, do_##ae, do_##te }
15762 /* ARM-only variants of all the above. */
15763 #define CE(mnem, op, nops, ops, ae) \
15764 { #mnem, OPS##nops ops, OT_csuffix, 0x##op, 0x0, ARM_VARIANT, 0, do_##ae, NULL }
15766 #define C3(mnem, op, nops, ops, ae) \
15767 { #mnem, OPS##nops ops, OT_cinfix3, 0x##op, 0x0, ARM_VARIANT, 0, do_##ae, NULL }
15769 /* Legacy mnemonics that always have conditional infix after the third
15771 #define CL(mnem, op, nops, ops, ae) \
15772 { #mnem, OPS##nops ops, OT_cinfix3_legacy, \
15773 0x##op, 0x0, ARM_VARIANT, 0, do_##ae, NULL }
15775 /* Coprocessor instructions. Isomorphic between Arm and Thumb-2. */
15776 #define cCE(mnem, op, nops, ops, ae) \
15777 { #mnem, OPS##nops ops, OT_csuffix, 0x##op, 0xe##op, ARM_VARIANT, ARM_VARIANT, do_##ae, do_##ae }
15779 /* Legacy coprocessor instructions where conditional infix and conditional
15780 suffix are ambiguous. For consistency this includes all FPA instructions,
15781 not just the potentially ambiguous ones. */
15782 #define cCL(mnem, op, nops, ops, ae) \
15783 { #mnem, OPS##nops ops, OT_cinfix3_legacy, \
15784 0x##op, 0xe##op, ARM_VARIANT, ARM_VARIANT, do_##ae, do_##ae }
15786 /* Coprocessor, takes either a suffix or a position-3 infix
15787 (for an FPA corner case). */
15788 #define C3E(mnem, op, nops, ops, ae) \
15789 { #mnem, OPS##nops ops, OT_csuf_or_in3, \
15790 0x##op, 0xe##op, ARM_VARIANT, ARM_VARIANT, do_##ae, do_##ae }
15792 #define xCM_(m1, m2, m3, op, nops, ops, ae) \
15793 { #m1 #m2 #m3, OPS##nops ops, \
15794 sizeof (#m2) == 1 ? OT_odd_infix_unc : OT_odd_infix_0 + sizeof (#m1) - 1, \
15795 0x##op, 0x0, ARM_VARIANT, 0, do_##ae, NULL }
15797 #define CM(m1, m2, op, nops, ops, ae) \
15798 xCM_ (m1, , m2, op, nops, ops, ae), \
15799 xCM_ (m1, eq, m2, op, nops, ops, ae), \
15800 xCM_ (m1, ne, m2, op, nops, ops, ae), \
15801 xCM_ (m1, cs, m2, op, nops, ops, ae), \
15802 xCM_ (m1, hs, m2, op, nops, ops, ae), \
15803 xCM_ (m1, cc, m2, op, nops, ops, ae), \
15804 xCM_ (m1, ul, m2, op, nops, ops, ae), \
15805 xCM_ (m1, lo, m2, op, nops, ops, ae), \
15806 xCM_ (m1, mi, m2, op, nops, ops, ae), \
15807 xCM_ (m1, pl, m2, op, nops, ops, ae), \
15808 xCM_ (m1, vs, m2, op, nops, ops, ae), \
15809 xCM_ (m1, vc, m2, op, nops, ops, ae), \
15810 xCM_ (m1, hi, m2, op, nops, ops, ae), \
15811 xCM_ (m1, ls, m2, op, nops, ops, ae), \
15812 xCM_ (m1, ge, m2, op, nops, ops, ae), \
15813 xCM_ (m1, lt, m2, op, nops, ops, ae), \
15814 xCM_ (m1, gt, m2, op, nops, ops, ae), \
15815 xCM_ (m1, le, m2, op, nops, ops, ae), \
15816 xCM_ (m1, al, m2, op, nops, ops, ae)
15818 #define UE(mnem, op, nops, ops, ae) \
15819 { #mnem, OPS##nops ops, OT_unconditional, 0x##op, 0, ARM_VARIANT, 0, do_##ae, NULL }
15821 #define UF(mnem, op, nops, ops, ae) \
15822 { #mnem, OPS##nops ops, OT_unconditionalF, 0x##op, 0, ARM_VARIANT, 0, do_##ae, NULL }
15824 /* Neon data-processing. ARM versions are unconditional with cond=0xf.
15825 The Thumb and ARM variants are mostly the same (bits 0-23 and 24/28), so we
15826 use the same encoding function for each. */
15827 #define NUF(mnem, op, nops, ops, enc) \
15828 { #mnem, OPS##nops ops, OT_unconditionalF, 0x##op, 0x##op, \
15829 ARM_VARIANT, THUMB_VARIANT, do_##enc, do_##enc }
15831 /* Neon data processing, version which indirects through neon_enc_tab for
15832 the various overloaded versions of opcodes. */
15833 #define nUF(mnem, op, nops, ops, enc) \
15834 { #mnem, OPS##nops ops, OT_unconditionalF, N_MNEM_##op, N_MNEM_##op, \
15835 ARM_VARIANT, THUMB_VARIANT, do_##enc, do_##enc }
15837 /* Neon insn with conditional suffix for the ARM version, non-overloaded
15839 #define NCE_tag(mnem, op, nops, ops, enc, tag) \
15840 { #mnem, OPS##nops ops, tag, 0x##op, 0x##op, ARM_VARIANT, \
15841 THUMB_VARIANT, do_##enc, do_##enc }
15843 #define NCE(mnem, op, nops, ops, enc) \
15844 NCE_tag (mnem, op, nops, ops, enc, OT_csuffix)
15846 #define NCEF(mnem, op, nops, ops, enc) \
15847 NCE_tag (mnem, op, nops, ops, enc, OT_csuffixF)
15849 /* Neon insn with conditional suffix for the ARM version, overloaded types. */
15850 #define nCE_tag(mnem, op, nops, ops, enc, tag) \
15851 { #mnem, OPS##nops ops, tag, N_MNEM_##op, N_MNEM_##op, \
15852 ARM_VARIANT, THUMB_VARIANT, do_##enc, do_##enc }
15854 #define nCE(mnem, op, nops, ops, enc) \
15855 nCE_tag (mnem, op, nops, ops, enc, OT_csuffix)
15857 #define nCEF(mnem, op, nops, ops, enc) \
15858 nCE_tag (mnem, op, nops, ops, enc, OT_csuffixF)
15862 /* Thumb-only, unconditional. */
15863 #define UT(mnem, op, nops, ops, te) TUE (mnem, 0, op, nops, ops, 0, te)
15865 static const struct asm_opcode insns
[] =
15867 #define ARM_VARIANT &arm_ext_v1 /* Core ARM Instructions. */
15868 #define THUMB_VARIANT &arm_ext_v4t
15869 tCE(and, 0000000, and, 3, (RR
, oRR
, SH
), arit
, t_arit3c
),
15870 tC3(ands
, 0100000, ands
, 3, (RR
, oRR
, SH
), arit
, t_arit3c
),
15871 tCE(eor
, 0200000, eor
, 3, (RR
, oRR
, SH
), arit
, t_arit3c
),
15872 tC3(eors
, 0300000, eors
, 3, (RR
, oRR
, SH
), arit
, t_arit3c
),
15873 tCE(sub
, 0400000, sub
, 3, (RR
, oRR
, SH
), arit
, t_add_sub
),
15874 tC3(subs
, 0500000, subs
, 3, (RR
, oRR
, SH
), arit
, t_add_sub
),
15875 tCE(add
, 0800000, add
, 3, (RR
, oRR
, SHG
), arit
, t_add_sub
),
15876 tC3(adds
, 0900000, adds
, 3, (RR
, oRR
, SHG
), arit
, t_add_sub
),
15877 tCE(adc
, 0a00000
, adc
, 3, (RR
, oRR
, SH
), arit
, t_arit3c
),
15878 tC3(adcs
, 0b00000, adcs
, 3, (RR
, oRR
, SH
), arit
, t_arit3c
),
15879 tCE(sbc
, 0c00000
, sbc
, 3, (RR
, oRR
, SH
), arit
, t_arit3
),
15880 tC3(sbcs
, 0d00000
, sbcs
, 3, (RR
, oRR
, SH
), arit
, t_arit3
),
15881 tCE(orr
, 1800000, orr
, 3, (RR
, oRR
, SH
), arit
, t_arit3c
),
15882 tC3(orrs
, 1900000, orrs
, 3, (RR
, oRR
, SH
), arit
, t_arit3c
),
15883 tCE(bic
, 1c00000
, bic
, 3, (RR
, oRR
, SH
), arit
, t_arit3
),
15884 tC3(bics
, 1d00000
, bics
, 3, (RR
, oRR
, SH
), arit
, t_arit3
),
15886 /* The p-variants of tst/cmp/cmn/teq (below) are the pre-V6 mechanism
15887 for setting PSR flag bits. They are obsolete in V6 and do not
15888 have Thumb equivalents. */
15889 tCE(tst
, 1100000, tst
, 2, (RR
, SH
), cmp
, t_mvn_tst
),
15890 tC3w(tsts
, 1100000, tst
, 2, (RR
, SH
), cmp
, t_mvn_tst
),
15891 CL(tstp
, 110f000
, 2, (RR
, SH
), cmp
),
15892 tCE(cmp
, 1500000, cmp
, 2, (RR
, SH
), cmp
, t_mov_cmp
),
15893 tC3w(cmps
, 1500000, cmp
, 2, (RR
, SH
), cmp
, t_mov_cmp
),
15894 CL(cmpp
, 150f000
, 2, (RR
, SH
), cmp
),
15895 tCE(cmn
, 1700000, cmn
, 2, (RR
, SH
), cmp
, t_mvn_tst
),
15896 tC3w(cmns
, 1700000, cmn
, 2, (RR
, SH
), cmp
, t_mvn_tst
),
15897 CL(cmnp
, 170f000
, 2, (RR
, SH
), cmp
),
15899 tCE(mov
, 1a00000
, mov
, 2, (RR
, SH
), mov
, t_mov_cmp
),
15900 tC3(movs
, 1b00000
, movs
, 2, (RR
, SH
), mov
, t_mov_cmp
),
15901 tCE(mvn
, 1e00000
, mvn
, 2, (RR
, SH
), mov
, t_mvn_tst
),
15902 tC3(mvns
, 1f00000
, mvns
, 2, (RR
, SH
), mov
, t_mvn_tst
),
15904 tCE(ldr
, 4100000, ldr
, 2, (RR
, ADDRGLDR
),ldst
, t_ldst
),
15905 tC3(ldrb
, 4500000, ldrb
, 2, (RR
, ADDRGLDR
),ldst
, t_ldst
),
15906 tCE(str
, 4000000, str
, 2, (RR
, ADDRGLDR
),ldst
, t_ldst
),
15907 tC3(strb
, 4400000, strb
, 2, (RR
, ADDRGLDR
),ldst
, t_ldst
),
15909 tCE(stm
, 8800000, stmia
, 2, (RRw
, REGLST
), ldmstm
, t_ldmstm
),
15910 tC3(stmia
, 8800000, stmia
, 2, (RRw
, REGLST
), ldmstm
, t_ldmstm
),
15911 tC3(stmea
, 8800000, stmia
, 2, (RRw
, REGLST
), ldmstm
, t_ldmstm
),
15912 tCE(ldm
, 8900000, ldmia
, 2, (RRw
, REGLST
), ldmstm
, t_ldmstm
),
15913 tC3(ldmia
, 8900000, ldmia
, 2, (RRw
, REGLST
), ldmstm
, t_ldmstm
),
15914 tC3(ldmfd
, 8900000, ldmia
, 2, (RRw
, REGLST
), ldmstm
, t_ldmstm
),
15916 TCE(swi
, f000000
, df00
, 1, (EXPi
), swi
, t_swi
),
15917 TCE(svc
, f000000
, df00
, 1, (EXPi
), swi
, t_swi
),
15918 tCE(b
, a000000
, b
, 1, (EXPr
), branch
, t_branch
),
15919 TCE(bl
, b000000
, f000f800
, 1, (EXPr
), bl
, t_branch23
),
15922 tCE(adr
, 28f0000
, adr
, 2, (RR
, EXP
), adr
, t_adr
),
15923 C3(adrl
, 28f0000
, 2, (RR
, EXP
), adrl
),
15924 tCE(nop
, 1a00000
, nop
, 1, (oI255c
), nop
, t_nop
),
15926 /* Thumb-compatibility pseudo ops. */
15927 tCE(lsl
, 1a00000
, lsl
, 3, (RR
, oRR
, SH
), shift
, t_shift
),
15928 tC3(lsls
, 1b00000
, lsls
, 3, (RR
, oRR
, SH
), shift
, t_shift
),
15929 tCE(lsr
, 1a00020
, lsr
, 3, (RR
, oRR
, SH
), shift
, t_shift
),
15930 tC3(lsrs
, 1b00020
, lsrs
, 3, (RR
, oRR
, SH
), shift
, t_shift
),
15931 tCE(asr
, 1a00040
, asr
, 3, (RR
, oRR
, SH
), shift
, t_shift
),
15932 tC3(asrs
, 1b00040
, asrs
, 3, (RR
, oRR
, SH
), shift
, t_shift
),
15933 tCE(ror
, 1a00060
, ror
, 3, (RR
, oRR
, SH
), shift
, t_shift
),
15934 tC3(rors
, 1b00060
, rors
, 3, (RR
, oRR
, SH
), shift
, t_shift
),
15935 tCE(neg
, 2600000, neg
, 2, (RR
, RR
), rd_rn
, t_neg
),
15936 tC3(negs
, 2700000, negs
, 2, (RR
, RR
), rd_rn
, t_neg
),
15937 tCE(push
, 92d0000
, push
, 1, (REGLST
), push_pop
, t_push_pop
),
15938 tCE(pop
, 8bd0000
, pop
, 1, (REGLST
), push_pop
, t_push_pop
),
15940 /* These may simplify to neg. */
15941 TCE(rsb
, 0600000, ebc00000
, 3, (RR
, oRR
, SH
), arit
, t_rsb
),
15942 TC3(rsbs
, 0700000, ebd00000
, 3, (RR
, oRR
, SH
), arit
, t_rsb
),
15944 #undef THUMB_VARIANT
15945 #define THUMB_VARIANT &arm_ext_v6
15946 TCE(cpy
, 1a00000
, 4600, 2, (RR
, RR
), rd_rm
, t_cpy
),
15948 /* V1 instructions with no Thumb analogue prior to V6T2. */
15949 #undef THUMB_VARIANT
15950 #define THUMB_VARIANT &arm_ext_v6t2
15951 TCE(teq
, 1300000, ea900f00
, 2, (RR
, SH
), cmp
, t_mvn_tst
),
15952 TC3w(teqs
, 1300000, ea900f00
, 2, (RR
, SH
), cmp
, t_mvn_tst
),
15953 CL(teqp
, 130f000
, 2, (RR
, SH
), cmp
),
15955 TC3(ldrt
, 4300000, f8500e00
, 2, (RR
, ADDR
), ldstt
, t_ldstt
),
15956 TC3(ldrbt
, 4700000, f8100e00
, 2, (RR
, ADDR
), ldstt
, t_ldstt
),
15957 TC3(strt
, 4200000, f8400e00
, 2, (RR
, ADDR
), ldstt
, t_ldstt
),
15958 TC3(strbt
, 4600000, f8000e00
, 2, (RR
, ADDR
), ldstt
, t_ldstt
),
15960 TC3(stmdb
, 9000000, e9000000
, 2, (RRw
, REGLST
), ldmstm
, t_ldmstm
),
15961 TC3(stmfd
, 9000000, e9000000
, 2, (RRw
, REGLST
), ldmstm
, t_ldmstm
),
15963 TC3(ldmdb
, 9100000, e9100000
, 2, (RRw
, REGLST
), ldmstm
, t_ldmstm
),
15964 TC3(ldmea
, 9100000, e9100000
, 2, (RRw
, REGLST
), ldmstm
, t_ldmstm
),
15966 /* V1 instructions with no Thumb analogue at all. */
15967 CE(rsc
, 0e00000
, 3, (RR
, oRR
, SH
), arit
),
15968 C3(rscs
, 0f00000
, 3, (RR
, oRR
, SH
), arit
),
15970 C3(stmib
, 9800000, 2, (RRw
, REGLST
), ldmstm
),
15971 C3(stmfa
, 9800000, 2, (RRw
, REGLST
), ldmstm
),
15972 C3(stmda
, 8000000, 2, (RRw
, REGLST
), ldmstm
),
15973 C3(stmed
, 8000000, 2, (RRw
, REGLST
), ldmstm
),
15974 C3(ldmib
, 9900000, 2, (RRw
, REGLST
), ldmstm
),
15975 C3(ldmed
, 9900000, 2, (RRw
, REGLST
), ldmstm
),
15976 C3(ldmda
, 8100000, 2, (RRw
, REGLST
), ldmstm
),
15977 C3(ldmfa
, 8100000, 2, (RRw
, REGLST
), ldmstm
),
15980 #define ARM_VARIANT &arm_ext_v2 /* ARM 2 - multiplies. */
15981 #undef THUMB_VARIANT
15982 #define THUMB_VARIANT &arm_ext_v4t
15983 tCE(mul
, 0000090, mul
, 3, (RRnpc
, RRnpc
, oRR
), mul
, t_mul
),
15984 tC3(muls
, 0100090, muls
, 3, (RRnpc
, RRnpc
, oRR
), mul
, t_mul
),
15986 #undef THUMB_VARIANT
15987 #define THUMB_VARIANT &arm_ext_v6t2
15988 TCE(mla
, 0200090, fb000000
, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
), mlas
, t_mla
),
15989 C3(mlas
, 0300090, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
), mlas
),
15991 /* Generic coprocessor instructions. */
15992 TCE(cdp
, e000000
, ee000000
, 6, (RCP
, I15b
, RCN
, RCN
, RCN
, oI7b
), cdp
, cdp
),
15993 TCE(ldc
, c100000
, ec100000
, 3, (RCP
, RCN
, ADDRGLDC
), lstc
, lstc
),
15994 TC3(ldcl
, c500000
, ec500000
, 3, (RCP
, RCN
, ADDRGLDC
), lstc
, lstc
),
15995 TCE(stc
, c000000
, ec000000
, 3, (RCP
, RCN
, ADDRGLDC
), lstc
, lstc
),
15996 TC3(stcl
, c400000
, ec400000
, 3, (RCP
, RCN
, ADDRGLDC
), lstc
, lstc
),
15997 TCE(mcr
, e000010
, ee000010
, 6, (RCP
, I7b
, RR
, RCN
, RCN
, oI7b
), co_reg
, co_reg
),
15998 TCE(mrc
, e100010
, ee100010
, 6, (RCP
, I7b
, RR
, RCN
, RCN
, oI7b
), co_reg
, co_reg
),
16001 #define ARM_VARIANT &arm_ext_v2s /* ARM 3 - swp instructions. */
16002 CE(swp
, 1000090, 3, (RRnpc
, RRnpc
, RRnpcb
), rd_rm_rn
),
16003 C3(swpb
, 1400090, 3, (RRnpc
, RRnpc
, RRnpcb
), rd_rm_rn
),
16006 #define ARM_VARIANT &arm_ext_v3 /* ARM 6 Status register instructions. */
16007 #undef THUMB_VARIANT
16008 #define THUMB_VARIANT &arm_ext_msr
16009 TCE(mrs
, 10f0000
, f3ef8000
, 2, (APSR_RR
, RVC_PSR
), mrs
, t_mrs
),
16010 TCE(msr
, 120f000
, f3808000
, 2, (RVC_PSR
, RR_EXi
), msr
, t_msr
),
16013 #define ARM_VARIANT &arm_ext_v3m /* ARM 7M long multiplies. */
16014 #undef THUMB_VARIANT
16015 #define THUMB_VARIANT &arm_ext_v6t2
16016 TCE(smull
, 0c00090
, fb800000
, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
), mull
, t_mull
),
16017 CM(smull
,s
, 0d00090
, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
), mull
),
16018 TCE(umull
, 0800090, fba00000
, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
), mull
, t_mull
),
16019 CM(umull
,s
, 0900090, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
), mull
),
16020 TCE(smlal
, 0e00090
, fbc00000
, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
), mull
, t_mull
),
16021 CM(smlal
,s
, 0f00090
, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
), mull
),
16022 TCE(umlal
, 0a00090
, fbe00000
, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
), mull
, t_mull
),
16023 CM(umlal
,s
, 0b00090, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
), mull
),
16026 #define ARM_VARIANT &arm_ext_v4 /* ARM Architecture 4. */
16027 #undef THUMB_VARIANT
16028 #define THUMB_VARIANT &arm_ext_v4t
16029 tC3(ldrh
, 01000b0
, ldrh
, 2, (RR
, ADDRGLDRS
), ldstv4
, t_ldst
),
16030 tC3(strh
, 00000b0
, strh
, 2, (RR
, ADDRGLDRS
), ldstv4
, t_ldst
),
16031 tC3(ldrsh
, 01000f0
, ldrsh
, 2, (RR
, ADDRGLDRS
), ldstv4
, t_ldst
),
16032 tC3(ldrsb
, 01000d0
, ldrsb
, 2, (RR
, ADDRGLDRS
), ldstv4
, t_ldst
),
16033 tCM(ld
,sh
, 01000f0
, ldrsh
, 2, (RR
, ADDRGLDRS
), ldstv4
, t_ldst
),
16034 tCM(ld
,sb
, 01000d0
, ldrsb
, 2, (RR
, ADDRGLDRS
), ldstv4
, t_ldst
),
16037 #define ARM_VARIANT &arm_ext_v4t_5
16038 /* ARM Architecture 4T. */
16039 /* Note: bx (and blx) are required on V5, even if the processor does
16040 not support Thumb. */
16041 TCE(bx
, 12fff10
, 4700, 1, (RR
), bx
, t_bx
),
16044 #define ARM_VARIANT &arm_ext_v5 /* ARM Architecture 5T. */
16045 #undef THUMB_VARIANT
16046 #define THUMB_VARIANT &arm_ext_v5t
16047 /* Note: blx has 2 variants; the .value coded here is for
16048 BLX(2). Only this variant has conditional execution. */
16049 TCE(blx
, 12fff30
, 4780, 1, (RR_EXr
), blx
, t_blx
),
16050 TUE(bkpt
, 1200070, be00
, 1, (oIffffb
), bkpt
, t_bkpt
),
16052 #undef THUMB_VARIANT
16053 #define THUMB_VARIANT &arm_ext_v6t2
16054 TCE(clz
, 16f0f10
, fab0f080
, 2, (RRnpc
, RRnpc
), rd_rm
, t_clz
),
16055 TUF(ldc2
, c100000
, fc100000
, 3, (RCP
, RCN
, ADDRGLDC
), lstc
, lstc
),
16056 TUF(ldc2l
, c500000
, fc500000
, 3, (RCP
, RCN
, ADDRGLDC
), lstc
, lstc
),
16057 TUF(stc2
, c000000
, fc000000
, 3, (RCP
, RCN
, ADDRGLDC
), lstc
, lstc
),
16058 TUF(stc2l
, c400000
, fc400000
, 3, (RCP
, RCN
, ADDRGLDC
), lstc
, lstc
),
16059 TUF(cdp2
, e000000
, fe000000
, 6, (RCP
, I15b
, RCN
, RCN
, RCN
, oI7b
), cdp
, cdp
),
16060 TUF(mcr2
, e000010
, fe000010
, 6, (RCP
, I7b
, RR
, RCN
, RCN
, oI7b
), co_reg
, co_reg
),
16061 TUF(mrc2
, e100010
, fe100010
, 6, (RCP
, I7b
, RR
, RCN
, RCN
, oI7b
), co_reg
, co_reg
),
16064 #define ARM_VARIANT &arm_ext_v5exp /* ARM Architecture 5TExP. */
16065 TCE(smlabb
, 1000080, fb100000
, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
), smla
, t_mla
),
16066 TCE(smlatb
, 10000a0
, fb100020
, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
), smla
, t_mla
),
16067 TCE(smlabt
, 10000c0
, fb100010
, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
), smla
, t_mla
),
16068 TCE(smlatt
, 10000e0
, fb100030
, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
), smla
, t_mla
),
16070 TCE(smlawb
, 1200080, fb300000
, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
), smla
, t_mla
),
16071 TCE(smlawt
, 12000c0
, fb300010
, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
), smla
, t_mla
),
16073 TCE(smlalbb
, 1400080, fbc00080
, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
), smlal
, t_mlal
),
16074 TCE(smlaltb
, 14000a0
, fbc000a0
, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
), smlal
, t_mlal
),
16075 TCE(smlalbt
, 14000c0
, fbc00090
, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
), smlal
, t_mlal
),
16076 TCE(smlaltt
, 14000e0
, fbc000b0
, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
), smlal
, t_mlal
),
16078 TCE(smulbb
, 1600080, fb10f000
, 3, (RRnpc
, RRnpc
, RRnpc
), smul
, t_simd
),
16079 TCE(smultb
, 16000a0
, fb10f020
, 3, (RRnpc
, RRnpc
, RRnpc
), smul
, t_simd
),
16080 TCE(smulbt
, 16000c0
, fb10f010
, 3, (RRnpc
, RRnpc
, RRnpc
), smul
, t_simd
),
16081 TCE(smultt
, 16000e0
, fb10f030
, 3, (RRnpc
, RRnpc
, RRnpc
), smul
, t_simd
),
16083 TCE(smulwb
, 12000a0
, fb30f000
, 3, (RRnpc
, RRnpc
, RRnpc
), smul
, t_simd
),
16084 TCE(smulwt
, 12000e0
, fb30f010
, 3, (RRnpc
, RRnpc
, RRnpc
), smul
, t_simd
),
16086 TCE(qadd
, 1000050, fa80f080
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rm_rn
, t_simd
),
16087 TCE(qdadd
, 1400050, fa80f090
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rm_rn
, t_simd
),
16088 TCE(qsub
, 1200050, fa80f0a0
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rm_rn
, t_simd
),
16089 TCE(qdsub
, 1600050, fa80f0b0
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rm_rn
, t_simd
),
16092 #define ARM_VARIANT &arm_ext_v5e /* ARM Architecture 5TE. */
16093 TUF(pld
, 450f000
, f810f000
, 1, (ADDR
), pld
, t_pld
),
16094 TC3(ldrd
, 00000d0
, e8500000
, 3, (RRnpc
, oRRnpc
, ADDRGLDRS
), ldrd
, t_ldstd
),
16095 TC3(strd
, 00000f0
, e8400000
, 3, (RRnpc
, oRRnpc
, ADDRGLDRS
), ldrd
, t_ldstd
),
16097 TCE(mcrr
, c400000
, ec400000
, 5, (RCP
, I15b
, RRnpc
, RRnpc
, RCN
), co_reg2c
, co_reg2c
),
16098 TCE(mrrc
, c500000
, ec500000
, 5, (RCP
, I15b
, RRnpc
, RRnpc
, RCN
), co_reg2c
, co_reg2c
),
16101 #define ARM_VARIANT &arm_ext_v5j /* ARM Architecture 5TEJ. */
16102 TCE(bxj
, 12fff20
, f3c08f00
, 1, (RR
), bxj
, t_bxj
),
16105 #define ARM_VARIANT &arm_ext_v6 /* ARM V6. */
16106 #undef THUMB_VARIANT
16107 #define THUMB_VARIANT &arm_ext_v6
16108 TUF(cpsie
, 1080000, b660
, 2, (CPSF
, oI31b
), cpsi
, t_cpsi
),
16109 TUF(cpsid
, 10c0000
, b670
, 2, (CPSF
, oI31b
), cpsi
, t_cpsi
),
16110 tCE(rev
, 6bf0f30
, rev
, 2, (RRnpc
, RRnpc
), rd_rm
, t_rev
),
16111 tCE(rev16
, 6bf0fb0
, rev16
, 2, (RRnpc
, RRnpc
), rd_rm
, t_rev
),
16112 tCE(revsh
, 6ff0fb0
, revsh
, 2, (RRnpc
, RRnpc
), rd_rm
, t_rev
),
16113 tCE(sxth
, 6bf0070
, sxth
, 3, (RRnpc
, RRnpc
, oROR
), sxth
, t_sxth
),
16114 tCE(uxth
, 6ff0070
, uxth
, 3, (RRnpc
, RRnpc
, oROR
), sxth
, t_sxth
),
16115 tCE(sxtb
, 6af0070
, sxtb
, 3, (RRnpc
, RRnpc
, oROR
), sxth
, t_sxth
),
16116 tCE(uxtb
, 6ef0070
, uxtb
, 3, (RRnpc
, RRnpc
, oROR
), sxth
, t_sxth
),
16117 TUF(setend
, 1010000, b650
, 1, (ENDI
), setend
, t_setend
),
16119 #undef THUMB_VARIANT
16120 #define THUMB_VARIANT &arm_ext_v6t2
16121 TCE(ldrex
, 1900f9f
, e8500f00
, 2, (RRnpc
, ADDR
), ldrex
, t_ldrex
),
16122 TCE(strex
, 1800f90
, e8400000
, 3, (RRnpc
, RRnpc
, ADDR
), strex
, t_strex
),
16123 TUF(mcrr2
, c400000
, fc400000
, 5, (RCP
, I15b
, RRnpc
, RRnpc
, RCN
), co_reg2c
, co_reg2c
),
16124 TUF(mrrc2
, c500000
, fc500000
, 5, (RCP
, I15b
, RRnpc
, RRnpc
, RCN
), co_reg2c
, co_reg2c
),
16126 TCE(ssat
, 6a00010
, f3000000
, 4, (RRnpc
, I32
, RRnpc
, oSHllar
),ssat
, t_ssat
),
16127 TCE(usat
, 6e00010
, f3800000
, 4, (RRnpc
, I31
, RRnpc
, oSHllar
),usat
, t_usat
),
16129 /* ARM V6 not included in V7M (eg. integer SIMD). */
16130 #undef THUMB_VARIANT
16131 #define THUMB_VARIANT &arm_ext_v6_notm
16132 TUF(cps
, 1020000, f3af8100
, 1, (I31b
), imm0
, t_cps
),
16133 TCE(pkhbt
, 6800010, eac00000
, 4, (RRnpc
, RRnpc
, RRnpc
, oSHll
), pkhbt
, t_pkhbt
),
16134 TCE(pkhtb
, 6800050, eac00020
, 4, (RRnpc
, RRnpc
, RRnpc
, oSHar
), pkhtb
, t_pkhtb
),
16135 TCE(qadd16
, 6200f10
, fa90f010
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
16136 TCE(qadd8
, 6200f90
, fa80f010
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
16137 TCE(qasx
, 6200f30
, faa0f010
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
16138 /* Old name for QASX. */
16139 TCE(qaddsubx
, 6200f30
, faa0f010
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
16140 TCE(qsax
, 6200f50
, fae0f010
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
16141 /* Old name for QSAX. */
16142 TCE(qsubaddx
, 6200f50
, fae0f010
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
16143 TCE(qsub16
, 6200f70
, fad0f010
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
16144 TCE(qsub8
, 6200ff0
, fac0f010
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
16145 TCE(sadd16
, 6100f10
, fa90f000
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
16146 TCE(sadd8
, 6100f90
, fa80f000
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
16147 TCE(sasx
, 6100f30
, faa0f000
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
16148 /* Old name for SASX. */
16149 TCE(saddsubx
, 6100f30
, faa0f000
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
16150 TCE(shadd16
, 6300f10
, fa90f020
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
16151 TCE(shadd8
, 6300f90
, fa80f020
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
16152 TCE(shasx
, 6300f30
, faa0f020
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
16153 /* Old name for SHASX. */
16154 TCE(shaddsubx
, 6300f30
, faa0f020
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
16155 TCE(shsax
, 6300f50
, fae0f020
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
16156 /* Old name for SHSAX. */
16157 TCE(shsubaddx
, 6300f50
, fae0f020
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
16158 TCE(shsub16
, 6300f70
, fad0f020
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
16159 TCE(shsub8
, 6300ff0
, fac0f020
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
16160 TCE(ssax
, 6100f50
, fae0f000
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
16161 /* Old name for SSAX. */
16162 TCE(ssubaddx
, 6100f50
, fae0f000
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
16163 TCE(ssub16
, 6100f70
, fad0f000
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
16164 TCE(ssub8
, 6100ff0
, fac0f000
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
16165 TCE(uadd16
, 6500f10
, fa90f040
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
16166 TCE(uadd8
, 6500f90
, fa80f040
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
16167 TCE(uasx
, 6500f30
, faa0f040
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
16168 /* Old name for UASX. */
16169 TCE(uaddsubx
, 6500f30
, faa0f040
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
16170 TCE(uhadd16
, 6700f10
, fa90f060
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
16171 TCE(uhadd8
, 6700f90
, fa80f060
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
16172 TCE(uhasx
, 6700f30
, faa0f060
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
16173 /* Old name for UHASX. */
16174 TCE(uhaddsubx
, 6700f30
, faa0f060
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
16175 TCE(uhsax
, 6700f50
, fae0f060
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
16176 /* Old name for UHSAX. */
16177 TCE(uhsubaddx
, 6700f50
, fae0f060
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
16178 TCE(uhsub16
, 6700f70
, fad0f060
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
16179 TCE(uhsub8
, 6700ff0
, fac0f060
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
16180 TCE(uqadd16
, 6600f10
, fa90f050
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
16181 TCE(uqadd8
, 6600f90
, fa80f050
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
16182 TCE(uqasx
, 6600f30
, faa0f050
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
16183 /* Old name for UQASX. */
16184 TCE(uqaddsubx
, 6600f30
, faa0f050
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
16185 TCE(uqsax
, 6600f50
, fae0f050
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
16186 /* Old name for UQSAX. */
16187 TCE(uqsubaddx
, 6600f50
, fae0f050
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
16188 TCE(uqsub16
, 6600f70
, fad0f050
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
16189 TCE(uqsub8
, 6600ff0
, fac0f050
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
16190 TCE(usub16
, 6500f70
, fad0f040
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
16191 TCE(usax
, 6500f50
, fae0f040
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
16192 /* Old name for USAX. */
16193 TCE(usubaddx
, 6500f50
, fae0f040
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
16194 TCE(usub8
, 6500ff0
, fac0f040
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
16195 TUF(rfeia
, 8900a00
, e990c000
, 1, (RRw
), rfe
, rfe
),
16196 UF(rfeib
, 9900a00
, 1, (RRw
), rfe
),
16197 UF(rfeda
, 8100a00
, 1, (RRw
), rfe
),
16198 TUF(rfedb
, 9100a00
, e810c000
, 1, (RRw
), rfe
, rfe
),
16199 TUF(rfefd
, 8900a00
, e990c000
, 1, (RRw
), rfe
, rfe
),
16200 UF(rfefa
, 9900a00
, 1, (RRw
), rfe
),
16201 UF(rfeea
, 8100a00
, 1, (RRw
), rfe
),
16202 TUF(rfeed
, 9100a00
, e810c000
, 1, (RRw
), rfe
, rfe
),
16203 TCE(sxtah
, 6b00070
, fa00f080
, 4, (RRnpc
, RRnpc
, RRnpc
, oROR
), sxtah
, t_sxtah
),
16204 TCE(sxtab16
, 6800070, fa20f080
, 4, (RRnpc
, RRnpc
, RRnpc
, oROR
), sxtah
, t_sxtah
),
16205 TCE(sxtab
, 6a00070
, fa40f080
, 4, (RRnpc
, RRnpc
, RRnpc
, oROR
), sxtah
, t_sxtah
),
16206 TCE(sxtb16
, 68f0070
, fa2ff080
, 3, (RRnpc
, RRnpc
, oROR
), sxth
, t_sxth
),
16207 TCE(uxtah
, 6f00070
, fa10f080
, 4, (RRnpc
, RRnpc
, RRnpc
, oROR
), sxtah
, t_sxtah
),
16208 TCE(uxtab16
, 6c00070
, fa30f080
, 4, (RRnpc
, RRnpc
, RRnpc
, oROR
), sxtah
, t_sxtah
),
16209 TCE(uxtab
, 6e00070
, fa50f080
, 4, (RRnpc
, RRnpc
, RRnpc
, oROR
), sxtah
, t_sxtah
),
16210 TCE(uxtb16
, 6cf0070
, fa3ff080
, 3, (RRnpc
, RRnpc
, oROR
), sxth
, t_sxth
),
16211 TCE(sel
, 6800fb0
, faa0f080
, 3, (RRnpc
, RRnpc
, RRnpc
), rd_rn_rm
, t_simd
),
16212 TCE(smlad
, 7000010, fb200000
, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
),smla
, t_mla
),
16213 TCE(smladx
, 7000030, fb200010
, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
),smla
, t_mla
),
16214 TCE(smlald
, 7400010, fbc000c0
, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
),smlal
,t_mlal
),
16215 TCE(smlaldx
, 7400030, fbc000d0
, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
),smlal
,t_mlal
),
16216 TCE(smlsd
, 7000050, fb400000
, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
),smla
, t_mla
),
16217 TCE(smlsdx
, 7000070, fb400010
, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
),smla
, t_mla
),
16218 TCE(smlsld
, 7400050, fbd000c0
, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
),smlal
,t_mlal
),
16219 TCE(smlsldx
, 7400070, fbd000d0
, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
),smlal
,t_mlal
),
16220 TCE(smmla
, 7500010, fb500000
, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
),smla
, t_mla
),
16221 TCE(smmlar
, 7500030, fb500010
, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
),smla
, t_mla
),
16222 TCE(smmls
, 75000d0
, fb600000
, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
),smla
, t_mla
),
16223 TCE(smmlsr
, 75000f0
, fb600010
, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
),smla
, t_mla
),
16224 TCE(smmul
, 750f010
, fb50f000
, 3, (RRnpc
, RRnpc
, RRnpc
), smul
, t_simd
),
16225 TCE(smmulr
, 750f030
, fb50f010
, 3, (RRnpc
, RRnpc
, RRnpc
), smul
, t_simd
),
16226 TCE(smuad
, 700f010
, fb20f000
, 3, (RRnpc
, RRnpc
, RRnpc
), smul
, t_simd
),
16227 TCE(smuadx
, 700f030
, fb20f010
, 3, (RRnpc
, RRnpc
, RRnpc
), smul
, t_simd
),
16228 TCE(smusd
, 700f050
, fb40f000
, 3, (RRnpc
, RRnpc
, RRnpc
), smul
, t_simd
),
16229 TCE(smusdx
, 700f070
, fb40f010
, 3, (RRnpc
, RRnpc
, RRnpc
), smul
, t_simd
),
16230 TUF(srsia
, 8c00500
, e980c000
, 2, (oRRw
, I31w
), srs
, srs
),
16231 UF(srsib
, 9c00500
, 2, (oRRw
, I31w
), srs
),
16232 UF(srsda
, 8400500, 2, (oRRw
, I31w
), srs
),
16233 TUF(srsdb
, 9400500, e800c000
, 2, (oRRw
, I31w
), srs
, srs
),
16234 TCE(ssat16
, 6a00f30
, f3200000
, 3, (RRnpc
, I16
, RRnpc
), ssat16
, t_ssat16
),
16235 TCE(umaal
, 0400090, fbe00060
, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
),smlal
, t_mlal
),
16236 TCE(usad8
, 780f010
, fb70f000
, 3, (RRnpc
, RRnpc
, RRnpc
), smul
, t_simd
),
16237 TCE(usada8
, 7800010, fb700000
, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
),smla
, t_mla
),
16238 TCE(usat16
, 6e00f30
, f3a00000
, 3, (RRnpc
, I15
, RRnpc
), usat16
, t_usat16
),
16241 #define ARM_VARIANT &arm_ext_v6k
16242 #undef THUMB_VARIANT
16243 #define THUMB_VARIANT &arm_ext_v6k
16244 tCE(yield
, 320f001
, yield
, 0, (), noargs
, t_hint
),
16245 tCE(wfe
, 320f002
, wfe
, 0, (), noargs
, t_hint
),
16246 tCE(wfi
, 320f003
, wfi
, 0, (), noargs
, t_hint
),
16247 tCE(sev
, 320f004
, sev
, 0, (), noargs
, t_hint
),
16249 #undef THUMB_VARIANT
16250 #define THUMB_VARIANT &arm_ext_v6_notm
16251 TCE(ldrexd
, 1b00f9f
, e8d0007f
, 3, (RRnpc
, oRRnpc
, RRnpcb
), ldrexd
, t_ldrexd
),
16252 TCE(strexd
, 1a00f90
, e8c00070
, 4, (RRnpc
, RRnpc
, oRRnpc
, RRnpcb
), strexd
, t_strexd
),
16254 #undef THUMB_VARIANT
16255 #define THUMB_VARIANT &arm_ext_v6t2
16256 TCE(ldrexb
, 1d00f9f
, e8d00f4f
, 2, (RRnpc
, RRnpcb
), rd_rn
, rd_rn
),
16257 TCE(ldrexh
, 1f00f9f
, e8d00f5f
, 2, (RRnpc
, RRnpcb
), rd_rn
, rd_rn
),
16258 TCE(strexb
, 1c00f90
, e8c00f40
, 3, (RRnpc
, RRnpc
, ADDR
), strex
, rm_rd_rn
),
16259 TCE(strexh
, 1e00f90
, e8c00f50
, 3, (RRnpc
, RRnpc
, ADDR
), strex
, rm_rd_rn
),
16260 TUF(clrex
, 57ff01f
, f3bf8f2f
, 0, (), noargs
, noargs
),
16263 #define ARM_VARIANT &arm_ext_v6z
16264 TCE(smc
, 1600070, f7f08000
, 1, (EXPi
), smc
, t_smc
),
16267 #define ARM_VARIANT &arm_ext_v6t2
16268 TCE(bfc
, 7c0001f
, f36f0000
, 3, (RRnpc
, I31
, I32
), bfc
, t_bfc
),
16269 TCE(bfi
, 7c00010
, f3600000
, 4, (RRnpc
, RRnpc_I0
, I31
, I32
), bfi
, t_bfi
),
16270 TCE(sbfx
, 7a00050
, f3400000
, 4, (RR
, RR
, I31
, I32
), bfx
, t_bfx
),
16271 TCE(ubfx
, 7e00050
, f3c00000
, 4, (RR
, RR
, I31
, I32
), bfx
, t_bfx
),
16273 TCE(mls
, 0600090, fb000010
, 4, (RRnpc
, RRnpc
, RRnpc
, RRnpc
), mlas
, t_mla
),
16274 TCE(movw
, 3000000, f2400000
, 2, (RRnpc
, HALF
), mov16
, t_mov16
),
16275 TCE(movt
, 3400000, f2c00000
, 2, (RRnpc
, HALF
), mov16
, t_mov16
),
16276 TCE(rbit
, 6ff0f30
, fa90f0a0
, 2, (RR
, RR
), rd_rm
, t_rbit
),
16278 TC3(ldrht
, 03000b0
, f8300e00
, 2, (RR
, ADDR
), ldsttv4
, t_ldstt
),
16279 TC3(ldrsht
, 03000f0
, f9300e00
, 2, (RR
, ADDR
), ldsttv4
, t_ldstt
),
16280 TC3(ldrsbt
, 03000d0
, f9100e00
, 2, (RR
, ADDR
), ldsttv4
, t_ldstt
),
16281 TC3(strht
, 02000b0
, f8200e00
, 2, (RR
, ADDR
), ldsttv4
, t_ldstt
),
16283 UT(cbnz
, b900
, 2, (RR
, EXP
), t_cbz
),
16284 UT(cbz
, b100
, 2, (RR
, EXP
), t_cbz
),
16285 /* ARM does not really have an IT instruction, so always allow it. The opcode
16286 is copied from Thumb in order to allow warnings
16287 in -mimplicit-it=[never | arm] modes. */
16289 #define ARM_VARIANT &arm_ext_v1
16290 TUE(it
, bf08
, bf08
, 1, (COND
), it
, t_it
),
16291 TUE(itt
, bf0c
, bf0c
, 1, (COND
), it
, t_it
),
16292 TUE(ite
, bf04
, bf04
, 1, (COND
), it
, t_it
),
16293 TUE(ittt
, bf0e
, bf0e
, 1, (COND
), it
, t_it
),
16294 TUE(itet
, bf06
, bf06
, 1, (COND
), it
, t_it
),
16295 TUE(itte
, bf0a
, bf0a
, 1, (COND
), it
, t_it
),
16296 TUE(itee
, bf02
, bf02
, 1, (COND
), it
, t_it
),
16297 TUE(itttt
, bf0f
, bf0f
, 1, (COND
), it
, t_it
),
16298 TUE(itett
, bf07
, bf07
, 1, (COND
), it
, t_it
),
16299 TUE(ittet
, bf0b
, bf0b
, 1, (COND
), it
, t_it
),
16300 TUE(iteet
, bf03
, bf03
, 1, (COND
), it
, t_it
),
16301 TUE(ittte
, bf0d
, bf0d
, 1, (COND
), it
, t_it
),
16302 TUE(itete
, bf05
, bf05
, 1, (COND
), it
, t_it
),
16303 TUE(ittee
, bf09
, bf09
, 1, (COND
), it
, t_it
),
16304 TUE(iteee
, bf01
, bf01
, 1, (COND
), it
, t_it
),
16305 /* ARM/Thumb-2 instructions with no Thumb-1 equivalent. */
16306 TC3(rrx
, 01a00060
, ea4f0030
, 2, (RR
, RR
), rd_rm
, t_rrx
),
16307 TC3(rrxs
, 01b00060
, ea5f0030
, 2, (RR
, RR
), rd_rm
, t_rrx
),
16309 /* Thumb2 only instructions. */
16311 #define ARM_VARIANT NULL
16313 TCE(addw
, 0, f2000000
, 3, (RR
, RR
, EXPi
), 0, t_add_sub_w
),
16314 TCE(subw
, 0, f2a00000
, 3, (RR
, RR
, EXPi
), 0, t_add_sub_w
),
16315 TCE(orn
, 0, ea600000
, 3, (RR
, oRR
, SH
), 0, t_orn
),
16316 TCE(orns
, 0, ea700000
, 3, (RR
, oRR
, SH
), 0, t_orn
),
16317 TCE(tbb
, 0, e8d0f000
, 1, (TB
), 0, t_tb
),
16318 TCE(tbh
, 0, e8d0f010
, 1, (TB
), 0, t_tb
),
16320 /* Thumb-2 hardware division instructions (R and M profiles only). */
16321 #undef THUMB_VARIANT
16322 #define THUMB_VARIANT &arm_ext_div
16323 TCE(sdiv
, 0, fb90f0f0
, 3, (RR
, oRR
, RR
), 0, t_div
),
16324 TCE(udiv
, 0, fbb0f0f0
, 3, (RR
, oRR
, RR
), 0, t_div
),
16326 /* ARM V6M/V7 instructions. */
16328 #define ARM_VARIANT &arm_ext_barrier
16329 #undef THUMB_VARIANT
16330 #define THUMB_VARIANT &arm_ext_barrier
16331 TUF(dmb
, 57ff050
, f3bf8f50
, 1, (oBARRIER
), barrier
, t_barrier
),
16332 TUF(dsb
, 57ff040
, f3bf8f40
, 1, (oBARRIER
), barrier
, t_barrier
),
16333 TUF(isb
, 57ff060
, f3bf8f60
, 1, (oBARRIER
), barrier
, t_barrier
),
16335 /* ARM V7 instructions. */
16337 #define ARM_VARIANT &arm_ext_v7
16338 #undef THUMB_VARIANT
16339 #define THUMB_VARIANT &arm_ext_v7
16340 TUF(pli
, 450f000
, f910f000
, 1, (ADDR
), pli
, t_pld
),
16341 TCE(dbg
, 320f0f0
, f3af80f0
, 1, (I15
), dbg
, t_dbg
),
16344 #define ARM_VARIANT &fpu_fpa_ext_v1 /* Core FPA instruction set (V1). */
16345 cCE(wfs
, e200110
, 1, (RR
), rd
),
16346 cCE(rfs
, e300110
, 1, (RR
), rd
),
16347 cCE(wfc
, e400110
, 1, (RR
), rd
),
16348 cCE(rfc
, e500110
, 1, (RR
), rd
),
16350 cCL(ldfs
, c100100
, 2, (RF
, ADDRGLDC
), rd_cpaddr
),
16351 cCL(ldfd
, c108100
, 2, (RF
, ADDRGLDC
), rd_cpaddr
),
16352 cCL(ldfe
, c500100
, 2, (RF
, ADDRGLDC
), rd_cpaddr
),
16353 cCL(ldfp
, c508100
, 2, (RF
, ADDRGLDC
), rd_cpaddr
),
16355 cCL(stfs
, c000100
, 2, (RF
, ADDRGLDC
), rd_cpaddr
),
16356 cCL(stfd
, c008100
, 2, (RF
, ADDRGLDC
), rd_cpaddr
),
16357 cCL(stfe
, c400100
, 2, (RF
, ADDRGLDC
), rd_cpaddr
),
16358 cCL(stfp
, c408100
, 2, (RF
, ADDRGLDC
), rd_cpaddr
),
16360 cCL(mvfs
, e008100
, 2, (RF
, RF_IF
), rd_rm
),
16361 cCL(mvfsp
, e008120
, 2, (RF
, RF_IF
), rd_rm
),
16362 cCL(mvfsm
, e008140
, 2, (RF
, RF_IF
), rd_rm
),
16363 cCL(mvfsz
, e008160
, 2, (RF
, RF_IF
), rd_rm
),
16364 cCL(mvfd
, e008180
, 2, (RF
, RF_IF
), rd_rm
),
16365 cCL(mvfdp
, e0081a0
, 2, (RF
, RF_IF
), rd_rm
),
16366 cCL(mvfdm
, e0081c0
, 2, (RF
, RF_IF
), rd_rm
),
16367 cCL(mvfdz
, e0081e0
, 2, (RF
, RF_IF
), rd_rm
),
16368 cCL(mvfe
, e088100
, 2, (RF
, RF_IF
), rd_rm
),
16369 cCL(mvfep
, e088120
, 2, (RF
, RF_IF
), rd_rm
),
16370 cCL(mvfem
, e088140
, 2, (RF
, RF_IF
), rd_rm
),
16371 cCL(mvfez
, e088160
, 2, (RF
, RF_IF
), rd_rm
),
16373 cCL(mnfs
, e108100
, 2, (RF
, RF_IF
), rd_rm
),
16374 cCL(mnfsp
, e108120
, 2, (RF
, RF_IF
), rd_rm
),
16375 cCL(mnfsm
, e108140
, 2, (RF
, RF_IF
), rd_rm
),
16376 cCL(mnfsz
, e108160
, 2, (RF
, RF_IF
), rd_rm
),
16377 cCL(mnfd
, e108180
, 2, (RF
, RF_IF
), rd_rm
),
16378 cCL(mnfdp
, e1081a0
, 2, (RF
, RF_IF
), rd_rm
),
16379 cCL(mnfdm
, e1081c0
, 2, (RF
, RF_IF
), rd_rm
),
16380 cCL(mnfdz
, e1081e0
, 2, (RF
, RF_IF
), rd_rm
),
16381 cCL(mnfe
, e188100
, 2, (RF
, RF_IF
), rd_rm
),
16382 cCL(mnfep
, e188120
, 2, (RF
, RF_IF
), rd_rm
),
16383 cCL(mnfem
, e188140
, 2, (RF
, RF_IF
), rd_rm
),
16384 cCL(mnfez
, e188160
, 2, (RF
, RF_IF
), rd_rm
),
16386 cCL(abss
, e208100
, 2, (RF
, RF_IF
), rd_rm
),
16387 cCL(abssp
, e208120
, 2, (RF
, RF_IF
), rd_rm
),
16388 cCL(abssm
, e208140
, 2, (RF
, RF_IF
), rd_rm
),
16389 cCL(abssz
, e208160
, 2, (RF
, RF_IF
), rd_rm
),
16390 cCL(absd
, e208180
, 2, (RF
, RF_IF
), rd_rm
),
16391 cCL(absdp
, e2081a0
, 2, (RF
, RF_IF
), rd_rm
),
16392 cCL(absdm
, e2081c0
, 2, (RF
, RF_IF
), rd_rm
),
16393 cCL(absdz
, e2081e0
, 2, (RF
, RF_IF
), rd_rm
),
16394 cCL(abse
, e288100
, 2, (RF
, RF_IF
), rd_rm
),
16395 cCL(absep
, e288120
, 2, (RF
, RF_IF
), rd_rm
),
16396 cCL(absem
, e288140
, 2, (RF
, RF_IF
), rd_rm
),
16397 cCL(absez
, e288160
, 2, (RF
, RF_IF
), rd_rm
),
16399 cCL(rnds
, e308100
, 2, (RF
, RF_IF
), rd_rm
),
16400 cCL(rndsp
, e308120
, 2, (RF
, RF_IF
), rd_rm
),
16401 cCL(rndsm
, e308140
, 2, (RF
, RF_IF
), rd_rm
),
16402 cCL(rndsz
, e308160
, 2, (RF
, RF_IF
), rd_rm
),
16403 cCL(rndd
, e308180
, 2, (RF
, RF_IF
), rd_rm
),
16404 cCL(rnddp
, e3081a0
, 2, (RF
, RF_IF
), rd_rm
),
16405 cCL(rnddm
, e3081c0
, 2, (RF
, RF_IF
), rd_rm
),
16406 cCL(rnddz
, e3081e0
, 2, (RF
, RF_IF
), rd_rm
),
16407 cCL(rnde
, e388100
, 2, (RF
, RF_IF
), rd_rm
),
16408 cCL(rndep
, e388120
, 2, (RF
, RF_IF
), rd_rm
),
16409 cCL(rndem
, e388140
, 2, (RF
, RF_IF
), rd_rm
),
16410 cCL(rndez
, e388160
, 2, (RF
, RF_IF
), rd_rm
),
16412 cCL(sqts
, e408100
, 2, (RF
, RF_IF
), rd_rm
),
16413 cCL(sqtsp
, e408120
, 2, (RF
, RF_IF
), rd_rm
),
16414 cCL(sqtsm
, e408140
, 2, (RF
, RF_IF
), rd_rm
),
16415 cCL(sqtsz
, e408160
, 2, (RF
, RF_IF
), rd_rm
),
16416 cCL(sqtd
, e408180
, 2, (RF
, RF_IF
), rd_rm
),
16417 cCL(sqtdp
, e4081a0
, 2, (RF
, RF_IF
), rd_rm
),
16418 cCL(sqtdm
, e4081c0
, 2, (RF
, RF_IF
), rd_rm
),
16419 cCL(sqtdz
, e4081e0
, 2, (RF
, RF_IF
), rd_rm
),
16420 cCL(sqte
, e488100
, 2, (RF
, RF_IF
), rd_rm
),
16421 cCL(sqtep
, e488120
, 2, (RF
, RF_IF
), rd_rm
),
16422 cCL(sqtem
, e488140
, 2, (RF
, RF_IF
), rd_rm
),
16423 cCL(sqtez
, e488160
, 2, (RF
, RF_IF
), rd_rm
),
16425 cCL(logs
, e508100
, 2, (RF
, RF_IF
), rd_rm
),
16426 cCL(logsp
, e508120
, 2, (RF
, RF_IF
), rd_rm
),
16427 cCL(logsm
, e508140
, 2, (RF
, RF_IF
), rd_rm
),
16428 cCL(logsz
, e508160
, 2, (RF
, RF_IF
), rd_rm
),
16429 cCL(logd
, e508180
, 2, (RF
, RF_IF
), rd_rm
),
16430 cCL(logdp
, e5081a0
, 2, (RF
, RF_IF
), rd_rm
),
16431 cCL(logdm
, e5081c0
, 2, (RF
, RF_IF
), rd_rm
),
16432 cCL(logdz
, e5081e0
, 2, (RF
, RF_IF
), rd_rm
),
16433 cCL(loge
, e588100
, 2, (RF
, RF_IF
), rd_rm
),
16434 cCL(logep
, e588120
, 2, (RF
, RF_IF
), rd_rm
),
16435 cCL(logem
, e588140
, 2, (RF
, RF_IF
), rd_rm
),
16436 cCL(logez
, e588160
, 2, (RF
, RF_IF
), rd_rm
),
16438 cCL(lgns
, e608100
, 2, (RF
, RF_IF
), rd_rm
),
16439 cCL(lgnsp
, e608120
, 2, (RF
, RF_IF
), rd_rm
),
16440 cCL(lgnsm
, e608140
, 2, (RF
, RF_IF
), rd_rm
),
16441 cCL(lgnsz
, e608160
, 2, (RF
, RF_IF
), rd_rm
),
16442 cCL(lgnd
, e608180
, 2, (RF
, RF_IF
), rd_rm
),
16443 cCL(lgndp
, e6081a0
, 2, (RF
, RF_IF
), rd_rm
),
16444 cCL(lgndm
, e6081c0
, 2, (RF
, RF_IF
), rd_rm
),
16445 cCL(lgndz
, e6081e0
, 2, (RF
, RF_IF
), rd_rm
),
16446 cCL(lgne
, e688100
, 2, (RF
, RF_IF
), rd_rm
),
16447 cCL(lgnep
, e688120
, 2, (RF
, RF_IF
), rd_rm
),
16448 cCL(lgnem
, e688140
, 2, (RF
, RF_IF
), rd_rm
),
16449 cCL(lgnez
, e688160
, 2, (RF
, RF_IF
), rd_rm
),
16451 cCL(exps
, e708100
, 2, (RF
, RF_IF
), rd_rm
),
16452 cCL(expsp
, e708120
, 2, (RF
, RF_IF
), rd_rm
),
16453 cCL(expsm
, e708140
, 2, (RF
, RF_IF
), rd_rm
),
16454 cCL(expsz
, e708160
, 2, (RF
, RF_IF
), rd_rm
),
16455 cCL(expd
, e708180
, 2, (RF
, RF_IF
), rd_rm
),
16456 cCL(expdp
, e7081a0
, 2, (RF
, RF_IF
), rd_rm
),
16457 cCL(expdm
, e7081c0
, 2, (RF
, RF_IF
), rd_rm
),
16458 cCL(expdz
, e7081e0
, 2, (RF
, RF_IF
), rd_rm
),
16459 cCL(expe
, e788100
, 2, (RF
, RF_IF
), rd_rm
),
16460 cCL(expep
, e788120
, 2, (RF
, RF_IF
), rd_rm
),
16461 cCL(expem
, e788140
, 2, (RF
, RF_IF
), rd_rm
),
16462 cCL(expdz
, e788160
, 2, (RF
, RF_IF
), rd_rm
),
16464 cCL(sins
, e808100
, 2, (RF
, RF_IF
), rd_rm
),
16465 cCL(sinsp
, e808120
, 2, (RF
, RF_IF
), rd_rm
),
16466 cCL(sinsm
, e808140
, 2, (RF
, RF_IF
), rd_rm
),
16467 cCL(sinsz
, e808160
, 2, (RF
, RF_IF
), rd_rm
),
16468 cCL(sind
, e808180
, 2, (RF
, RF_IF
), rd_rm
),
16469 cCL(sindp
, e8081a0
, 2, (RF
, RF_IF
), rd_rm
),
16470 cCL(sindm
, e8081c0
, 2, (RF
, RF_IF
), rd_rm
),
16471 cCL(sindz
, e8081e0
, 2, (RF
, RF_IF
), rd_rm
),
16472 cCL(sine
, e888100
, 2, (RF
, RF_IF
), rd_rm
),
16473 cCL(sinep
, e888120
, 2, (RF
, RF_IF
), rd_rm
),
16474 cCL(sinem
, e888140
, 2, (RF
, RF_IF
), rd_rm
),
16475 cCL(sinez
, e888160
, 2, (RF
, RF_IF
), rd_rm
),
16477 cCL(coss
, e908100
, 2, (RF
, RF_IF
), rd_rm
),
16478 cCL(cossp
, e908120
, 2, (RF
, RF_IF
), rd_rm
),
16479 cCL(cossm
, e908140
, 2, (RF
, RF_IF
), rd_rm
),
16480 cCL(cossz
, e908160
, 2, (RF
, RF_IF
), rd_rm
),
16481 cCL(cosd
, e908180
, 2, (RF
, RF_IF
), rd_rm
),
16482 cCL(cosdp
, e9081a0
, 2, (RF
, RF_IF
), rd_rm
),
16483 cCL(cosdm
, e9081c0
, 2, (RF
, RF_IF
), rd_rm
),
16484 cCL(cosdz
, e9081e0
, 2, (RF
, RF_IF
), rd_rm
),
16485 cCL(cose
, e988100
, 2, (RF
, RF_IF
), rd_rm
),
16486 cCL(cosep
, e988120
, 2, (RF
, RF_IF
), rd_rm
),
16487 cCL(cosem
, e988140
, 2, (RF
, RF_IF
), rd_rm
),
16488 cCL(cosez
, e988160
, 2, (RF
, RF_IF
), rd_rm
),
16490 cCL(tans
, ea08100
, 2, (RF
, RF_IF
), rd_rm
),
16491 cCL(tansp
, ea08120
, 2, (RF
, RF_IF
), rd_rm
),
16492 cCL(tansm
, ea08140
, 2, (RF
, RF_IF
), rd_rm
),
16493 cCL(tansz
, ea08160
, 2, (RF
, RF_IF
), rd_rm
),
16494 cCL(tand
, ea08180
, 2, (RF
, RF_IF
), rd_rm
),
16495 cCL(tandp
, ea081a0
, 2, (RF
, RF_IF
), rd_rm
),
16496 cCL(tandm
, ea081c0
, 2, (RF
, RF_IF
), rd_rm
),
16497 cCL(tandz
, ea081e0
, 2, (RF
, RF_IF
), rd_rm
),
16498 cCL(tane
, ea88100
, 2, (RF
, RF_IF
), rd_rm
),
16499 cCL(tanep
, ea88120
, 2, (RF
, RF_IF
), rd_rm
),
16500 cCL(tanem
, ea88140
, 2, (RF
, RF_IF
), rd_rm
),
16501 cCL(tanez
, ea88160
, 2, (RF
, RF_IF
), rd_rm
),
16503 cCL(asns
, eb08100
, 2, (RF
, RF_IF
), rd_rm
),
16504 cCL(asnsp
, eb08120
, 2, (RF
, RF_IF
), rd_rm
),
16505 cCL(asnsm
, eb08140
, 2, (RF
, RF_IF
), rd_rm
),
16506 cCL(asnsz
, eb08160
, 2, (RF
, RF_IF
), rd_rm
),
16507 cCL(asnd
, eb08180
, 2, (RF
, RF_IF
), rd_rm
),
16508 cCL(asndp
, eb081a0
, 2, (RF
, RF_IF
), rd_rm
),
16509 cCL(asndm
, eb081c0
, 2, (RF
, RF_IF
), rd_rm
),
16510 cCL(asndz
, eb081e0
, 2, (RF
, RF_IF
), rd_rm
),
16511 cCL(asne
, eb88100
, 2, (RF
, RF_IF
), rd_rm
),
16512 cCL(asnep
, eb88120
, 2, (RF
, RF_IF
), rd_rm
),
16513 cCL(asnem
, eb88140
, 2, (RF
, RF_IF
), rd_rm
),
16514 cCL(asnez
, eb88160
, 2, (RF
, RF_IF
), rd_rm
),
16516 cCL(acss
, ec08100
, 2, (RF
, RF_IF
), rd_rm
),
16517 cCL(acssp
, ec08120
, 2, (RF
, RF_IF
), rd_rm
),
16518 cCL(acssm
, ec08140
, 2, (RF
, RF_IF
), rd_rm
),
16519 cCL(acssz
, ec08160
, 2, (RF
, RF_IF
), rd_rm
),
16520 cCL(acsd
, ec08180
, 2, (RF
, RF_IF
), rd_rm
),
16521 cCL(acsdp
, ec081a0
, 2, (RF
, RF_IF
), rd_rm
),
16522 cCL(acsdm
, ec081c0
, 2, (RF
, RF_IF
), rd_rm
),
16523 cCL(acsdz
, ec081e0
, 2, (RF
, RF_IF
), rd_rm
),
16524 cCL(acse
, ec88100
, 2, (RF
, RF_IF
), rd_rm
),
16525 cCL(acsep
, ec88120
, 2, (RF
, RF_IF
), rd_rm
),
16526 cCL(acsem
, ec88140
, 2, (RF
, RF_IF
), rd_rm
),
16527 cCL(acsez
, ec88160
, 2, (RF
, RF_IF
), rd_rm
),
16529 cCL(atns
, ed08100
, 2, (RF
, RF_IF
), rd_rm
),
16530 cCL(atnsp
, ed08120
, 2, (RF
, RF_IF
), rd_rm
),
16531 cCL(atnsm
, ed08140
, 2, (RF
, RF_IF
), rd_rm
),
16532 cCL(atnsz
, ed08160
, 2, (RF
, RF_IF
), rd_rm
),
16533 cCL(atnd
, ed08180
, 2, (RF
, RF_IF
), rd_rm
),
16534 cCL(atndp
, ed081a0
, 2, (RF
, RF_IF
), rd_rm
),
16535 cCL(atndm
, ed081c0
, 2, (RF
, RF_IF
), rd_rm
),
16536 cCL(atndz
, ed081e0
, 2, (RF
, RF_IF
), rd_rm
),
16537 cCL(atne
, ed88100
, 2, (RF
, RF_IF
), rd_rm
),
16538 cCL(atnep
, ed88120
, 2, (RF
, RF_IF
), rd_rm
),
16539 cCL(atnem
, ed88140
, 2, (RF
, RF_IF
), rd_rm
),
16540 cCL(atnez
, ed88160
, 2, (RF
, RF_IF
), rd_rm
),
16542 cCL(urds
, ee08100
, 2, (RF
, RF_IF
), rd_rm
),
16543 cCL(urdsp
, ee08120
, 2, (RF
, RF_IF
), rd_rm
),
16544 cCL(urdsm
, ee08140
, 2, (RF
, RF_IF
), rd_rm
),
16545 cCL(urdsz
, ee08160
, 2, (RF
, RF_IF
), rd_rm
),
16546 cCL(urdd
, ee08180
, 2, (RF
, RF_IF
), rd_rm
),
16547 cCL(urddp
, ee081a0
, 2, (RF
, RF_IF
), rd_rm
),
16548 cCL(urddm
, ee081c0
, 2, (RF
, RF_IF
), rd_rm
),
16549 cCL(urddz
, ee081e0
, 2, (RF
, RF_IF
), rd_rm
),
16550 cCL(urde
, ee88100
, 2, (RF
, RF_IF
), rd_rm
),
16551 cCL(urdep
, ee88120
, 2, (RF
, RF_IF
), rd_rm
),
16552 cCL(urdem
, ee88140
, 2, (RF
, RF_IF
), rd_rm
),
16553 cCL(urdez
, ee88160
, 2, (RF
, RF_IF
), rd_rm
),
16555 cCL(nrms
, ef08100
, 2, (RF
, RF_IF
), rd_rm
),
16556 cCL(nrmsp
, ef08120
, 2, (RF
, RF_IF
), rd_rm
),
16557 cCL(nrmsm
, ef08140
, 2, (RF
, RF_IF
), rd_rm
),
16558 cCL(nrmsz
, ef08160
, 2, (RF
, RF_IF
), rd_rm
),
16559 cCL(nrmd
, ef08180
, 2, (RF
, RF_IF
), rd_rm
),
16560 cCL(nrmdp
, ef081a0
, 2, (RF
, RF_IF
), rd_rm
),
16561 cCL(nrmdm
, ef081c0
, 2, (RF
, RF_IF
), rd_rm
),
16562 cCL(nrmdz
, ef081e0
, 2, (RF
, RF_IF
), rd_rm
),
16563 cCL(nrme
, ef88100
, 2, (RF
, RF_IF
), rd_rm
),
16564 cCL(nrmep
, ef88120
, 2, (RF
, RF_IF
), rd_rm
),
16565 cCL(nrmem
, ef88140
, 2, (RF
, RF_IF
), rd_rm
),
16566 cCL(nrmez
, ef88160
, 2, (RF
, RF_IF
), rd_rm
),
16568 cCL(adfs
, e000100
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16569 cCL(adfsp
, e000120
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16570 cCL(adfsm
, e000140
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16571 cCL(adfsz
, e000160
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16572 cCL(adfd
, e000180
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16573 cCL(adfdp
, e0001a0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16574 cCL(adfdm
, e0001c0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16575 cCL(adfdz
, e0001e0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16576 cCL(adfe
, e080100
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16577 cCL(adfep
, e080120
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16578 cCL(adfem
, e080140
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16579 cCL(adfez
, e080160
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16581 cCL(sufs
, e200100
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16582 cCL(sufsp
, e200120
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16583 cCL(sufsm
, e200140
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16584 cCL(sufsz
, e200160
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16585 cCL(sufd
, e200180
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16586 cCL(sufdp
, e2001a0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16587 cCL(sufdm
, e2001c0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16588 cCL(sufdz
, e2001e0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16589 cCL(sufe
, e280100
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16590 cCL(sufep
, e280120
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16591 cCL(sufem
, e280140
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16592 cCL(sufez
, e280160
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16594 cCL(rsfs
, e300100
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16595 cCL(rsfsp
, e300120
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16596 cCL(rsfsm
, e300140
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16597 cCL(rsfsz
, e300160
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16598 cCL(rsfd
, e300180
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16599 cCL(rsfdp
, e3001a0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16600 cCL(rsfdm
, e3001c0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16601 cCL(rsfdz
, e3001e0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16602 cCL(rsfe
, e380100
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16603 cCL(rsfep
, e380120
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16604 cCL(rsfem
, e380140
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16605 cCL(rsfez
, e380160
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16607 cCL(mufs
, e100100
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16608 cCL(mufsp
, e100120
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16609 cCL(mufsm
, e100140
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16610 cCL(mufsz
, e100160
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16611 cCL(mufd
, e100180
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16612 cCL(mufdp
, e1001a0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16613 cCL(mufdm
, e1001c0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16614 cCL(mufdz
, e1001e0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16615 cCL(mufe
, e180100
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16616 cCL(mufep
, e180120
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16617 cCL(mufem
, e180140
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16618 cCL(mufez
, e180160
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16620 cCL(dvfs
, e400100
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16621 cCL(dvfsp
, e400120
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16622 cCL(dvfsm
, e400140
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16623 cCL(dvfsz
, e400160
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16624 cCL(dvfd
, e400180
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16625 cCL(dvfdp
, e4001a0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16626 cCL(dvfdm
, e4001c0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16627 cCL(dvfdz
, e4001e0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16628 cCL(dvfe
, e480100
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16629 cCL(dvfep
, e480120
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16630 cCL(dvfem
, e480140
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16631 cCL(dvfez
, e480160
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16633 cCL(rdfs
, e500100
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16634 cCL(rdfsp
, e500120
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16635 cCL(rdfsm
, e500140
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16636 cCL(rdfsz
, e500160
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16637 cCL(rdfd
, e500180
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16638 cCL(rdfdp
, e5001a0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16639 cCL(rdfdm
, e5001c0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16640 cCL(rdfdz
, e5001e0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16641 cCL(rdfe
, e580100
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16642 cCL(rdfep
, e580120
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16643 cCL(rdfem
, e580140
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16644 cCL(rdfez
, e580160
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16646 cCL(pows
, e600100
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16647 cCL(powsp
, e600120
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16648 cCL(powsm
, e600140
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16649 cCL(powsz
, e600160
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16650 cCL(powd
, e600180
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16651 cCL(powdp
, e6001a0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16652 cCL(powdm
, e6001c0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16653 cCL(powdz
, e6001e0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16654 cCL(powe
, e680100
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16655 cCL(powep
, e680120
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16656 cCL(powem
, e680140
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16657 cCL(powez
, e680160
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16659 cCL(rpws
, e700100
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16660 cCL(rpwsp
, e700120
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16661 cCL(rpwsm
, e700140
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16662 cCL(rpwsz
, e700160
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16663 cCL(rpwd
, e700180
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16664 cCL(rpwdp
, e7001a0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16665 cCL(rpwdm
, e7001c0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16666 cCL(rpwdz
, e7001e0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16667 cCL(rpwe
, e780100
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16668 cCL(rpwep
, e780120
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16669 cCL(rpwem
, e780140
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16670 cCL(rpwez
, e780160
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16672 cCL(rmfs
, e800100
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16673 cCL(rmfsp
, e800120
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16674 cCL(rmfsm
, e800140
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16675 cCL(rmfsz
, e800160
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16676 cCL(rmfd
, e800180
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16677 cCL(rmfdp
, e8001a0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16678 cCL(rmfdm
, e8001c0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16679 cCL(rmfdz
, e8001e0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16680 cCL(rmfe
, e880100
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16681 cCL(rmfep
, e880120
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16682 cCL(rmfem
, e880140
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16683 cCL(rmfez
, e880160
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16685 cCL(fmls
, e900100
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16686 cCL(fmlsp
, e900120
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16687 cCL(fmlsm
, e900140
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16688 cCL(fmlsz
, e900160
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16689 cCL(fmld
, e900180
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16690 cCL(fmldp
, e9001a0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16691 cCL(fmldm
, e9001c0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16692 cCL(fmldz
, e9001e0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16693 cCL(fmle
, e980100
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16694 cCL(fmlep
, e980120
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16695 cCL(fmlem
, e980140
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16696 cCL(fmlez
, e980160
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16698 cCL(fdvs
, ea00100
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16699 cCL(fdvsp
, ea00120
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16700 cCL(fdvsm
, ea00140
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16701 cCL(fdvsz
, ea00160
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16702 cCL(fdvd
, ea00180
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16703 cCL(fdvdp
, ea001a0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16704 cCL(fdvdm
, ea001c0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16705 cCL(fdvdz
, ea001e0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16706 cCL(fdve
, ea80100
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16707 cCL(fdvep
, ea80120
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16708 cCL(fdvem
, ea80140
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16709 cCL(fdvez
, ea80160
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16711 cCL(frds
, eb00100
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16712 cCL(frdsp
, eb00120
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16713 cCL(frdsm
, eb00140
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16714 cCL(frdsz
, eb00160
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16715 cCL(frdd
, eb00180
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16716 cCL(frddp
, eb001a0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16717 cCL(frddm
, eb001c0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16718 cCL(frddz
, eb001e0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16719 cCL(frde
, eb80100
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16720 cCL(frdep
, eb80120
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16721 cCL(frdem
, eb80140
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16722 cCL(frdez
, eb80160
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16724 cCL(pols
, ec00100
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16725 cCL(polsp
, ec00120
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16726 cCL(polsm
, ec00140
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16727 cCL(polsz
, ec00160
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16728 cCL(pold
, ec00180
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16729 cCL(poldp
, ec001a0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16730 cCL(poldm
, ec001c0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16731 cCL(poldz
, ec001e0
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16732 cCL(pole
, ec80100
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16733 cCL(polep
, ec80120
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16734 cCL(polem
, ec80140
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16735 cCL(polez
, ec80160
, 3, (RF
, RF
, RF_IF
), rd_rn_rm
),
16737 cCE(cmf
, e90f110
, 2, (RF
, RF_IF
), fpa_cmp
),
16738 C3E(cmfe
, ed0f110
, 2, (RF
, RF_IF
), fpa_cmp
),
16739 cCE(cnf
, eb0f110
, 2, (RF
, RF_IF
), fpa_cmp
),
16740 C3E(cnfe
, ef0f110
, 2, (RF
, RF_IF
), fpa_cmp
),
16742 cCL(flts
, e000110
, 2, (RF
, RR
), rn_rd
),
16743 cCL(fltsp
, e000130
, 2, (RF
, RR
), rn_rd
),
16744 cCL(fltsm
, e000150
, 2, (RF
, RR
), rn_rd
),
16745 cCL(fltsz
, e000170
, 2, (RF
, RR
), rn_rd
),
16746 cCL(fltd
, e000190
, 2, (RF
, RR
), rn_rd
),
16747 cCL(fltdp
, e0001b0
, 2, (RF
, RR
), rn_rd
),
16748 cCL(fltdm
, e0001d0
, 2, (RF
, RR
), rn_rd
),
16749 cCL(fltdz
, e0001f0
, 2, (RF
, RR
), rn_rd
),
16750 cCL(flte
, e080110
, 2, (RF
, RR
), rn_rd
),
16751 cCL(fltep
, e080130
, 2, (RF
, RR
), rn_rd
),
16752 cCL(fltem
, e080150
, 2, (RF
, RR
), rn_rd
),
16753 cCL(fltez
, e080170
, 2, (RF
, RR
), rn_rd
),
16755 /* The implementation of the FIX instruction is broken on some
16756 assemblers, in that it accepts a precision specifier as well as a
16757 rounding specifier, despite the fact that this is meaningless.
16758 To be more compatible, we accept it as well, though of course it
16759 does not set any bits. */
16760 cCE(fix
, e100110
, 2, (RR
, RF
), rd_rm
),
16761 cCL(fixp
, e100130
, 2, (RR
, RF
), rd_rm
),
16762 cCL(fixm
, e100150
, 2, (RR
, RF
), rd_rm
),
16763 cCL(fixz
, e100170
, 2, (RR
, RF
), rd_rm
),
16764 cCL(fixsp
, e100130
, 2, (RR
, RF
), rd_rm
),
16765 cCL(fixsm
, e100150
, 2, (RR
, RF
), rd_rm
),
16766 cCL(fixsz
, e100170
, 2, (RR
, RF
), rd_rm
),
16767 cCL(fixdp
, e100130
, 2, (RR
, RF
), rd_rm
),
16768 cCL(fixdm
, e100150
, 2, (RR
, RF
), rd_rm
),
16769 cCL(fixdz
, e100170
, 2, (RR
, RF
), rd_rm
),
16770 cCL(fixep
, e100130
, 2, (RR
, RF
), rd_rm
),
16771 cCL(fixem
, e100150
, 2, (RR
, RF
), rd_rm
),
16772 cCL(fixez
, e100170
, 2, (RR
, RF
), rd_rm
),
16774 /* Instructions that were new with the real FPA, call them V2. */
16776 #define ARM_VARIANT &fpu_fpa_ext_v2
16777 cCE(lfm
, c100200
, 3, (RF
, I4b
, ADDR
), fpa_ldmstm
),
16778 cCL(lfmfd
, c900200
, 3, (RF
, I4b
, ADDR
), fpa_ldmstm
),
16779 cCL(lfmea
, d100200
, 3, (RF
, I4b
, ADDR
), fpa_ldmstm
),
16780 cCE(sfm
, c000200
, 3, (RF
, I4b
, ADDR
), fpa_ldmstm
),
16781 cCL(sfmfd
, d000200
, 3, (RF
, I4b
, ADDR
), fpa_ldmstm
),
16782 cCL(sfmea
, c800200
, 3, (RF
, I4b
, ADDR
), fpa_ldmstm
),
16785 #define ARM_VARIANT &fpu_vfp_ext_v1xd /* VFP V1xD (single precision). */
16786 /* Moves and type conversions. */
16787 cCE(fcpys
, eb00a40
, 2, (RVS
, RVS
), vfp_sp_monadic
),
16788 cCE(fmrs
, e100a10
, 2, (RR
, RVS
), vfp_reg_from_sp
),
16789 cCE(fmsr
, e000a10
, 2, (RVS
, RR
), vfp_sp_from_reg
),
16790 cCE(fmstat
, ef1fa10
, 0, (), noargs
),
16791 cCE(fsitos
, eb80ac0
, 2, (RVS
, RVS
), vfp_sp_monadic
),
16792 cCE(fuitos
, eb80a40
, 2, (RVS
, RVS
), vfp_sp_monadic
),
16793 cCE(ftosis
, ebd0a40
, 2, (RVS
, RVS
), vfp_sp_monadic
),
16794 cCE(ftosizs
, ebd0ac0
, 2, (RVS
, RVS
), vfp_sp_monadic
),
16795 cCE(ftouis
, ebc0a40
, 2, (RVS
, RVS
), vfp_sp_monadic
),
16796 cCE(ftouizs
, ebc0ac0
, 2, (RVS
, RVS
), vfp_sp_monadic
),
16797 cCE(fmrx
, ef00a10
, 2, (RR
, RVC
), rd_rn
),
16798 cCE(fmxr
, ee00a10
, 2, (RVC
, RR
), rn_rd
),
16800 /* Memory operations. */
16801 cCE(flds
, d100a00
, 2, (RVS
, ADDRGLDC
), vfp_sp_ldst
),
16802 cCE(fsts
, d000a00
, 2, (RVS
, ADDRGLDC
), vfp_sp_ldst
),
16803 cCE(fldmias
, c900a00
, 2, (RRw
, VRSLST
), vfp_sp_ldstmia
),
16804 cCE(fldmfds
, c900a00
, 2, (RRw
, VRSLST
), vfp_sp_ldstmia
),
16805 cCE(fldmdbs
, d300a00
, 2, (RRw
, VRSLST
), vfp_sp_ldstmdb
),
16806 cCE(fldmeas
, d300a00
, 2, (RRw
, VRSLST
), vfp_sp_ldstmdb
),
16807 cCE(fldmiax
, c900b00
, 2, (RRw
, VRDLST
), vfp_xp_ldstmia
),
16808 cCE(fldmfdx
, c900b00
, 2, (RRw
, VRDLST
), vfp_xp_ldstmia
),
16809 cCE(fldmdbx
, d300b00
, 2, (RRw
, VRDLST
), vfp_xp_ldstmdb
),
16810 cCE(fldmeax
, d300b00
, 2, (RRw
, VRDLST
), vfp_xp_ldstmdb
),
16811 cCE(fstmias
, c800a00
, 2, (RRw
, VRSLST
), vfp_sp_ldstmia
),
16812 cCE(fstmeas
, c800a00
, 2, (RRw
, VRSLST
), vfp_sp_ldstmia
),
16813 cCE(fstmdbs
, d200a00
, 2, (RRw
, VRSLST
), vfp_sp_ldstmdb
),
16814 cCE(fstmfds
, d200a00
, 2, (RRw
, VRSLST
), vfp_sp_ldstmdb
),
16815 cCE(fstmiax
, c800b00
, 2, (RRw
, VRDLST
), vfp_xp_ldstmia
),
16816 cCE(fstmeax
, c800b00
, 2, (RRw
, VRDLST
), vfp_xp_ldstmia
),
16817 cCE(fstmdbx
, d200b00
, 2, (RRw
, VRDLST
), vfp_xp_ldstmdb
),
16818 cCE(fstmfdx
, d200b00
, 2, (RRw
, VRDLST
), vfp_xp_ldstmdb
),
16820 /* Monadic operations. */
16821 cCE(fabss
, eb00ac0
, 2, (RVS
, RVS
), vfp_sp_monadic
),
16822 cCE(fnegs
, eb10a40
, 2, (RVS
, RVS
), vfp_sp_monadic
),
16823 cCE(fsqrts
, eb10ac0
, 2, (RVS
, RVS
), vfp_sp_monadic
),
16825 /* Dyadic operations. */
16826 cCE(fadds
, e300a00
, 3, (RVS
, RVS
, RVS
), vfp_sp_dyadic
),
16827 cCE(fsubs
, e300a40
, 3, (RVS
, RVS
, RVS
), vfp_sp_dyadic
),
16828 cCE(fmuls
, e200a00
, 3, (RVS
, RVS
, RVS
), vfp_sp_dyadic
),
16829 cCE(fdivs
, e800a00
, 3, (RVS
, RVS
, RVS
), vfp_sp_dyadic
),
16830 cCE(fmacs
, e000a00
, 3, (RVS
, RVS
, RVS
), vfp_sp_dyadic
),
16831 cCE(fmscs
, e100a00
, 3, (RVS
, RVS
, RVS
), vfp_sp_dyadic
),
16832 cCE(fnmuls
, e200a40
, 3, (RVS
, RVS
, RVS
), vfp_sp_dyadic
),
16833 cCE(fnmacs
, e000a40
, 3, (RVS
, RVS
, RVS
), vfp_sp_dyadic
),
16834 cCE(fnmscs
, e100a40
, 3, (RVS
, RVS
, RVS
), vfp_sp_dyadic
),
16837 cCE(fcmps
, eb40a40
, 2, (RVS
, RVS
), vfp_sp_monadic
),
16838 cCE(fcmpzs
, eb50a40
, 1, (RVS
), vfp_sp_compare_z
),
16839 cCE(fcmpes
, eb40ac0
, 2, (RVS
, RVS
), vfp_sp_monadic
),
16840 cCE(fcmpezs
, eb50ac0
, 1, (RVS
), vfp_sp_compare_z
),
16843 #define ARM_VARIANT &fpu_vfp_ext_v1 /* VFP V1 (Double precision). */
16844 /* Moves and type conversions. */
16845 cCE(fcpyd
, eb00b40
, 2, (RVD
, RVD
), vfp_dp_rd_rm
),
16846 cCE(fcvtds
, eb70ac0
, 2, (RVD
, RVS
), vfp_dp_sp_cvt
),
16847 cCE(fcvtsd
, eb70bc0
, 2, (RVS
, RVD
), vfp_sp_dp_cvt
),
16848 cCE(fmdhr
, e200b10
, 2, (RVD
, RR
), vfp_dp_rn_rd
),
16849 cCE(fmdlr
, e000b10
, 2, (RVD
, RR
), vfp_dp_rn_rd
),
16850 cCE(fmrdh
, e300b10
, 2, (RR
, RVD
), vfp_dp_rd_rn
),
16851 cCE(fmrdl
, e100b10
, 2, (RR
, RVD
), vfp_dp_rd_rn
),
16852 cCE(fsitod
, eb80bc0
, 2, (RVD
, RVS
), vfp_dp_sp_cvt
),
16853 cCE(fuitod
, eb80b40
, 2, (RVD
, RVS
), vfp_dp_sp_cvt
),
16854 cCE(ftosid
, ebd0b40
, 2, (RVS
, RVD
), vfp_sp_dp_cvt
),
16855 cCE(ftosizd
, ebd0bc0
, 2, (RVS
, RVD
), vfp_sp_dp_cvt
),
16856 cCE(ftouid
, ebc0b40
, 2, (RVS
, RVD
), vfp_sp_dp_cvt
),
16857 cCE(ftouizd
, ebc0bc0
, 2, (RVS
, RVD
), vfp_sp_dp_cvt
),
16859 /* Memory operations. */
16860 cCE(fldd
, d100b00
, 2, (RVD
, ADDRGLDC
), vfp_dp_ldst
),
16861 cCE(fstd
, d000b00
, 2, (RVD
, ADDRGLDC
), vfp_dp_ldst
),
16862 cCE(fldmiad
, c900b00
, 2, (RRw
, VRDLST
), vfp_dp_ldstmia
),
16863 cCE(fldmfdd
, c900b00
, 2, (RRw
, VRDLST
), vfp_dp_ldstmia
),
16864 cCE(fldmdbd
, d300b00
, 2, (RRw
, VRDLST
), vfp_dp_ldstmdb
),
16865 cCE(fldmead
, d300b00
, 2, (RRw
, VRDLST
), vfp_dp_ldstmdb
),
16866 cCE(fstmiad
, c800b00
, 2, (RRw
, VRDLST
), vfp_dp_ldstmia
),
16867 cCE(fstmead
, c800b00
, 2, (RRw
, VRDLST
), vfp_dp_ldstmia
),
16868 cCE(fstmdbd
, d200b00
, 2, (RRw
, VRDLST
), vfp_dp_ldstmdb
),
16869 cCE(fstmfdd
, d200b00
, 2, (RRw
, VRDLST
), vfp_dp_ldstmdb
),
16871 /* Monadic operations. */
16872 cCE(fabsd
, eb00bc0
, 2, (RVD
, RVD
), vfp_dp_rd_rm
),
16873 cCE(fnegd
, eb10b40
, 2, (RVD
, RVD
), vfp_dp_rd_rm
),
16874 cCE(fsqrtd
, eb10bc0
, 2, (RVD
, RVD
), vfp_dp_rd_rm
),
16876 /* Dyadic operations. */
16877 cCE(faddd
, e300b00
, 3, (RVD
, RVD
, RVD
), vfp_dp_rd_rn_rm
),
16878 cCE(fsubd
, e300b40
, 3, (RVD
, RVD
, RVD
), vfp_dp_rd_rn_rm
),
16879 cCE(fmuld
, e200b00
, 3, (RVD
, RVD
, RVD
), vfp_dp_rd_rn_rm
),
16880 cCE(fdivd
, e800b00
, 3, (RVD
, RVD
, RVD
), vfp_dp_rd_rn_rm
),
16881 cCE(fmacd
, e000b00
, 3, (RVD
, RVD
, RVD
), vfp_dp_rd_rn_rm
),
16882 cCE(fmscd
, e100b00
, 3, (RVD
, RVD
, RVD
), vfp_dp_rd_rn_rm
),
16883 cCE(fnmuld
, e200b40
, 3, (RVD
, RVD
, RVD
), vfp_dp_rd_rn_rm
),
16884 cCE(fnmacd
, e000b40
, 3, (RVD
, RVD
, RVD
), vfp_dp_rd_rn_rm
),
16885 cCE(fnmscd
, e100b40
, 3, (RVD
, RVD
, RVD
), vfp_dp_rd_rn_rm
),
16888 cCE(fcmpd
, eb40b40
, 2, (RVD
, RVD
), vfp_dp_rd_rm
),
16889 cCE(fcmpzd
, eb50b40
, 1, (RVD
), vfp_dp_rd
),
16890 cCE(fcmped
, eb40bc0
, 2, (RVD
, RVD
), vfp_dp_rd_rm
),
16891 cCE(fcmpezd
, eb50bc0
, 1, (RVD
), vfp_dp_rd
),
16894 #define ARM_VARIANT &fpu_vfp_ext_v2
16895 cCE(fmsrr
, c400a10
, 3, (VRSLST
, RR
, RR
), vfp_sp2_from_reg2
),
16896 cCE(fmrrs
, c500a10
, 3, (RR
, RR
, VRSLST
), vfp_reg2_from_sp2
),
16897 cCE(fmdrr
, c400b10
, 3, (RVD
, RR
, RR
), vfp_dp_rm_rd_rn
),
16898 cCE(fmrrd
, c500b10
, 3, (RR
, RR
, RVD
), vfp_dp_rd_rn_rm
),
16900 /* Instructions which may belong to either the Neon or VFP instruction sets.
16901 Individual encoder functions perform additional architecture checks. */
16903 #define ARM_VARIANT &fpu_vfp_ext_v1xd
16904 #undef THUMB_VARIANT
16905 #define THUMB_VARIANT &fpu_vfp_ext_v1xd
16906 /* These mnemonics are unique to VFP. */
16907 NCE(vsqrt
, 0, 2, (RVSD
, RVSD
), vfp_nsyn_sqrt
),
16908 NCE(vdiv
, 0, 3, (RVSD
, RVSD
, RVSD
), vfp_nsyn_div
),
16909 nCE(vnmul
, vnmul
, 3, (RVSD
, RVSD
, RVSD
), vfp_nsyn_nmul
),
16910 nCE(vnmla
, vnmla
, 3, (RVSD
, RVSD
, RVSD
), vfp_nsyn_nmul
),
16911 nCE(vnmls
, vnmls
, 3, (RVSD
, RVSD
, RVSD
), vfp_nsyn_nmul
),
16912 nCE(vcmp
, vcmp
, 2, (RVSD
, RVSD_I0
), vfp_nsyn_cmp
),
16913 nCE(vcmpe
, vcmpe
, 2, (RVSD
, RVSD_I0
), vfp_nsyn_cmp
),
16914 NCE(vpush
, 0, 1, (VRSDLST
), vfp_nsyn_push
),
16915 NCE(vpop
, 0, 1, (VRSDLST
), vfp_nsyn_pop
),
16916 NCE(vcvtz
, 0, 2, (RVSD
, RVSD
), vfp_nsyn_cvtz
),
16918 /* Mnemonics shared by Neon and VFP. */
16919 nCEF(vmul
, vmul
, 3, (RNSDQ
, oRNSDQ
, RNSDQ_RNSC
), neon_mul
),
16920 nCEF(vmla
, vmla
, 3, (RNSDQ
, oRNSDQ
, RNSDQ_RNSC
), neon_mac_maybe_scalar
),
16921 nCEF(vmls
, vmls
, 3, (RNSDQ
, oRNSDQ
, RNSDQ_RNSC
), neon_mac_maybe_scalar
),
16923 nCEF(vadd
, vadd
, 3, (RNSDQ
, oRNSDQ
, RNSDQ
), neon_addsub_if_i
),
16924 nCEF(vsub
, vsub
, 3, (RNSDQ
, oRNSDQ
, RNSDQ
), neon_addsub_if_i
),
16926 NCEF(vabs
, 1b10300
, 2, (RNSDQ
, RNSDQ
), neon_abs_neg
),
16927 NCEF(vneg
, 1b10380
, 2, (RNSDQ
, RNSDQ
), neon_abs_neg
),
16929 NCE(vldm
, c900b00
, 2, (RRw
, VRSDLST
), neon_ldm_stm
),
16930 NCE(vldmia
, c900b00
, 2, (RRw
, VRSDLST
), neon_ldm_stm
),
16931 NCE(vldmdb
, d100b00
, 2, (RRw
, VRSDLST
), neon_ldm_stm
),
16932 NCE(vstm
, c800b00
, 2, (RRw
, VRSDLST
), neon_ldm_stm
),
16933 NCE(vstmia
, c800b00
, 2, (RRw
, VRSDLST
), neon_ldm_stm
),
16934 NCE(vstmdb
, d000b00
, 2, (RRw
, VRSDLST
), neon_ldm_stm
),
16935 NCE(vldr
, d100b00
, 2, (RVSD
, ADDRGLDC
), neon_ldr_str
),
16936 NCE(vstr
, d000b00
, 2, (RVSD
, ADDRGLDC
), neon_ldr_str
),
16938 nCEF(vcvt
, vcvt
, 3, (RNSDQ
, RNSDQ
, oI32b
), neon_cvt
),
16939 nCEF(vcvtb
, vcvt
, 2, (RVS
, RVS
), neon_cvtb
),
16940 nCEF(vcvtt
, vcvt
, 2, (RVS
, RVS
), neon_cvtt
),
16943 /* NOTE: All VMOV encoding is special-cased! */
16944 NCE(vmov
, 0, 1, (VMOV
), neon_mov
),
16945 NCE(vmovq
, 0, 1, (VMOV
), neon_mov
),
16947 #undef THUMB_VARIANT
16948 #define THUMB_VARIANT &fpu_neon_ext_v1
16950 #define ARM_VARIANT &fpu_neon_ext_v1
16951 /* Data processing with three registers of the same length. */
16952 /* integer ops, valid types S8 S16 S32 U8 U16 U32. */
16953 NUF(vaba
, 0000710, 3, (RNDQ
, RNDQ
, RNDQ
), neon_dyadic_i_su
),
16954 NUF(vabaq
, 0000710, 3, (RNQ
, RNQ
, RNQ
), neon_dyadic_i_su
),
16955 NUF(vhadd
, 0000000, 3, (RNDQ
, oRNDQ
, RNDQ
), neon_dyadic_i_su
),
16956 NUF(vhaddq
, 0000000, 3, (RNQ
, oRNQ
, RNQ
), neon_dyadic_i_su
),
16957 NUF(vrhadd
, 0000100, 3, (RNDQ
, oRNDQ
, RNDQ
), neon_dyadic_i_su
),
16958 NUF(vrhaddq
, 0000100, 3, (RNQ
, oRNQ
, RNQ
), neon_dyadic_i_su
),
16959 NUF(vhsub
, 0000200, 3, (RNDQ
, oRNDQ
, RNDQ
), neon_dyadic_i_su
),
16960 NUF(vhsubq
, 0000200, 3, (RNQ
, oRNQ
, RNQ
), neon_dyadic_i_su
),
16961 /* integer ops, valid types S8 S16 S32 S64 U8 U16 U32 U64. */
16962 NUF(vqadd
, 0000010, 3, (RNDQ
, oRNDQ
, RNDQ
), neon_dyadic_i64_su
),
16963 NUF(vqaddq
, 0000010, 3, (RNQ
, oRNQ
, RNQ
), neon_dyadic_i64_su
),
16964 NUF(vqsub
, 0000210, 3, (RNDQ
, oRNDQ
, RNDQ
), neon_dyadic_i64_su
),
16965 NUF(vqsubq
, 0000210, 3, (RNQ
, oRNQ
, RNQ
), neon_dyadic_i64_su
),
16966 NUF(vrshl
, 0000500, 3, (RNDQ
, oRNDQ
, RNDQ
), neon_rshl
),
16967 NUF(vrshlq
, 0000500, 3, (RNQ
, oRNQ
, RNQ
), neon_rshl
),
16968 NUF(vqrshl
, 0000510, 3, (RNDQ
, oRNDQ
, RNDQ
), neon_rshl
),
16969 NUF(vqrshlq
, 0000510, 3, (RNQ
, oRNQ
, RNQ
), neon_rshl
),
16970 /* If not immediate, fall back to neon_dyadic_i64_su.
16971 shl_imm should accept I8 I16 I32 I64,
16972 qshl_imm should accept S8 S16 S32 S64 U8 U16 U32 U64. */
16973 nUF(vshl
, vshl
, 3, (RNDQ
, oRNDQ
, RNDQ_I63b
), neon_shl_imm
),
16974 nUF(vshlq
, vshl
, 3, (RNQ
, oRNQ
, RNDQ_I63b
), neon_shl_imm
),
16975 nUF(vqshl
, vqshl
, 3, (RNDQ
, oRNDQ
, RNDQ_I63b
), neon_qshl_imm
),
16976 nUF(vqshlq
, vqshl
, 3, (RNQ
, oRNQ
, RNDQ_I63b
), neon_qshl_imm
),
16977 /* Logic ops, types optional & ignored. */
16978 nUF(vand
, vand
, 2, (RNDQ
, NILO
), neon_logic
),
16979 nUF(vandq
, vand
, 2, (RNQ
, NILO
), neon_logic
),
16980 nUF(vbic
, vbic
, 2, (RNDQ
, NILO
), neon_logic
),
16981 nUF(vbicq
, vbic
, 2, (RNQ
, NILO
), neon_logic
),
16982 nUF(vorr
, vorr
, 2, (RNDQ
, NILO
), neon_logic
),
16983 nUF(vorrq
, vorr
, 2, (RNQ
, NILO
), neon_logic
),
16984 nUF(vorn
, vorn
, 2, (RNDQ
, NILO
), neon_logic
),
16985 nUF(vornq
, vorn
, 2, (RNQ
, NILO
), neon_logic
),
16986 nUF(veor
, veor
, 3, (RNDQ
, oRNDQ
, RNDQ
), neon_logic
),
16987 nUF(veorq
, veor
, 3, (RNQ
, oRNQ
, RNQ
), neon_logic
),
16988 /* Bitfield ops, untyped. */
16989 NUF(vbsl
, 1100110, 3, (RNDQ
, RNDQ
, RNDQ
), neon_bitfield
),
16990 NUF(vbslq
, 1100110, 3, (RNQ
, RNQ
, RNQ
), neon_bitfield
),
16991 NUF(vbit
, 1200110, 3, (RNDQ
, RNDQ
, RNDQ
), neon_bitfield
),
16992 NUF(vbitq
, 1200110, 3, (RNQ
, RNQ
, RNQ
), neon_bitfield
),
16993 NUF(vbif
, 1300110, 3, (RNDQ
, RNDQ
, RNDQ
), neon_bitfield
),
16994 NUF(vbifq
, 1300110, 3, (RNQ
, RNQ
, RNQ
), neon_bitfield
),
16995 /* Int and float variants, types S8 S16 S32 U8 U16 U32 F32. */
16996 nUF(vabd
, vabd
, 3, (RNDQ
, oRNDQ
, RNDQ
), neon_dyadic_if_su
),
16997 nUF(vabdq
, vabd
, 3, (RNQ
, oRNQ
, RNQ
), neon_dyadic_if_su
),
16998 nUF(vmax
, vmax
, 3, (RNDQ
, oRNDQ
, RNDQ
), neon_dyadic_if_su
),
16999 nUF(vmaxq
, vmax
, 3, (RNQ
, oRNQ
, RNQ
), neon_dyadic_if_su
),
17000 nUF(vmin
, vmin
, 3, (RNDQ
, oRNDQ
, RNDQ
), neon_dyadic_if_su
),
17001 nUF(vminq
, vmin
, 3, (RNQ
, oRNQ
, RNQ
), neon_dyadic_if_su
),
17002 /* Comparisons. Types S8 S16 S32 U8 U16 U32 F32. Non-immediate versions fall
17003 back to neon_dyadic_if_su. */
17004 nUF(vcge
, vcge
, 3, (RNDQ
, oRNDQ
, RNDQ_I0
), neon_cmp
),
17005 nUF(vcgeq
, vcge
, 3, (RNQ
, oRNQ
, RNDQ_I0
), neon_cmp
),
17006 nUF(vcgt
, vcgt
, 3, (RNDQ
, oRNDQ
, RNDQ_I0
), neon_cmp
),
17007 nUF(vcgtq
, vcgt
, 3, (RNQ
, oRNQ
, RNDQ_I0
), neon_cmp
),
17008 nUF(vclt
, vclt
, 3, (RNDQ
, oRNDQ
, RNDQ_I0
), neon_cmp_inv
),
17009 nUF(vcltq
, vclt
, 3, (RNQ
, oRNQ
, RNDQ_I0
), neon_cmp_inv
),
17010 nUF(vcle
, vcle
, 3, (RNDQ
, oRNDQ
, RNDQ_I0
), neon_cmp_inv
),
17011 nUF(vcleq
, vcle
, 3, (RNQ
, oRNQ
, RNDQ_I0
), neon_cmp_inv
),
17012 /* Comparison. Type I8 I16 I32 F32. */
17013 nUF(vceq
, vceq
, 3, (RNDQ
, oRNDQ
, RNDQ_I0
), neon_ceq
),
17014 nUF(vceqq
, vceq
, 3, (RNQ
, oRNQ
, RNDQ_I0
), neon_ceq
),
17015 /* As above, D registers only. */
17016 nUF(vpmax
, vpmax
, 3, (RND
, oRND
, RND
), neon_dyadic_if_su_d
),
17017 nUF(vpmin
, vpmin
, 3, (RND
, oRND
, RND
), neon_dyadic_if_su_d
),
17018 /* Int and float variants, signedness unimportant. */
17019 nUF(vmlaq
, vmla
, 3, (RNQ
, oRNQ
, RNDQ_RNSC
), neon_mac_maybe_scalar
),
17020 nUF(vmlsq
, vmls
, 3, (RNQ
, oRNQ
, RNDQ_RNSC
), neon_mac_maybe_scalar
),
17021 nUF(vpadd
, vpadd
, 3, (RND
, oRND
, RND
), neon_dyadic_if_i_d
),
17022 /* Add/sub take types I8 I16 I32 I64 F32. */
17023 nUF(vaddq
, vadd
, 3, (RNQ
, oRNQ
, RNQ
), neon_addsub_if_i
),
17024 nUF(vsubq
, vsub
, 3, (RNQ
, oRNQ
, RNQ
), neon_addsub_if_i
),
17025 /* vtst takes sizes 8, 16, 32. */
17026 NUF(vtst
, 0000810, 3, (RNDQ
, oRNDQ
, RNDQ
), neon_tst
),
17027 NUF(vtstq
, 0000810, 3, (RNQ
, oRNQ
, RNQ
), neon_tst
),
17028 /* VMUL takes I8 I16 I32 F32 P8. */
17029 nUF(vmulq
, vmul
, 3, (RNQ
, oRNQ
, RNDQ_RNSC
), neon_mul
),
17030 /* VQD{R}MULH takes S16 S32. */
17031 nUF(vqdmulh
, vqdmulh
, 3, (RNDQ
, oRNDQ
, RNDQ_RNSC
), neon_qdmulh
),
17032 nUF(vqdmulhq
, vqdmulh
, 3, (RNQ
, oRNQ
, RNDQ_RNSC
), neon_qdmulh
),
17033 nUF(vqrdmulh
, vqrdmulh
, 3, (RNDQ
, oRNDQ
, RNDQ_RNSC
), neon_qdmulh
),
17034 nUF(vqrdmulhq
, vqrdmulh
, 3, (RNQ
, oRNQ
, RNDQ_RNSC
), neon_qdmulh
),
17035 NUF(vacge
, 0000e10
, 3, (RNDQ
, oRNDQ
, RNDQ
), neon_fcmp_absolute
),
17036 NUF(vacgeq
, 0000e10
, 3, (RNQ
, oRNQ
, RNQ
), neon_fcmp_absolute
),
17037 NUF(vacgt
, 0200e10
, 3, (RNDQ
, oRNDQ
, RNDQ
), neon_fcmp_absolute
),
17038 NUF(vacgtq
, 0200e10
, 3, (RNQ
, oRNQ
, RNQ
), neon_fcmp_absolute
),
17039 NUF(vaclt
, 0200e10
, 3, (RNDQ
, oRNDQ
, RNDQ
), neon_fcmp_absolute_inv
),
17040 NUF(vacltq
, 0200e10
, 3, (RNQ
, oRNQ
, RNQ
), neon_fcmp_absolute_inv
),
17041 NUF(vacle
, 0000e10
, 3, (RNDQ
, oRNDQ
, RNDQ
), neon_fcmp_absolute_inv
),
17042 NUF(vacleq
, 0000e10
, 3, (RNQ
, oRNQ
, RNQ
), neon_fcmp_absolute_inv
),
17043 NUF(vrecps
, 0000f10
, 3, (RNDQ
, oRNDQ
, RNDQ
), neon_step
),
17044 NUF(vrecpsq
, 0000f10
, 3, (RNQ
, oRNQ
, RNQ
), neon_step
),
17045 NUF(vrsqrts
, 0200f10
, 3, (RNDQ
, oRNDQ
, RNDQ
), neon_step
),
17046 NUF(vrsqrtsq
, 0200f10
, 3, (RNQ
, oRNQ
, RNQ
), neon_step
),
17048 /* Two address, int/float. Types S8 S16 S32 F32. */
17049 NUF(vabsq
, 1b10300
, 2, (RNQ
, RNQ
), neon_abs_neg
),
17050 NUF(vnegq
, 1b10380
, 2, (RNQ
, RNQ
), neon_abs_neg
),
17052 /* Data processing with two registers and a shift amount. */
17053 /* Right shifts, and variants with rounding.
17054 Types accepted S8 S16 S32 S64 U8 U16 U32 U64. */
17055 NUF(vshr
, 0800010, 3, (RNDQ
, oRNDQ
, I64z
), neon_rshift_round_imm
),
17056 NUF(vshrq
, 0800010, 3, (RNQ
, oRNQ
, I64z
), neon_rshift_round_imm
),
17057 NUF(vrshr
, 0800210, 3, (RNDQ
, oRNDQ
, I64z
), neon_rshift_round_imm
),
17058 NUF(vrshrq
, 0800210, 3, (RNQ
, oRNQ
, I64z
), neon_rshift_round_imm
),
17059 NUF(vsra
, 0800110, 3, (RNDQ
, oRNDQ
, I64
), neon_rshift_round_imm
),
17060 NUF(vsraq
, 0800110, 3, (RNQ
, oRNQ
, I64
), neon_rshift_round_imm
),
17061 NUF(vrsra
, 0800310, 3, (RNDQ
, oRNDQ
, I64
), neon_rshift_round_imm
),
17062 NUF(vrsraq
, 0800310, 3, (RNQ
, oRNQ
, I64
), neon_rshift_round_imm
),
17063 /* Shift and insert. Sizes accepted 8 16 32 64. */
17064 NUF(vsli
, 1800510, 3, (RNDQ
, oRNDQ
, I63
), neon_sli
),
17065 NUF(vsliq
, 1800510, 3, (RNQ
, oRNQ
, I63
), neon_sli
),
17066 NUF(vsri
, 1800410, 3, (RNDQ
, oRNDQ
, I64
), neon_sri
),
17067 NUF(vsriq
, 1800410, 3, (RNQ
, oRNQ
, I64
), neon_sri
),
17068 /* QSHL{U} immediate accepts S8 S16 S32 S64 U8 U16 U32 U64. */
17069 NUF(vqshlu
, 1800610, 3, (RNDQ
, oRNDQ
, I63
), neon_qshlu_imm
),
17070 NUF(vqshluq
, 1800610, 3, (RNQ
, oRNQ
, I63
), neon_qshlu_imm
),
17071 /* Right shift immediate, saturating & narrowing, with rounding variants.
17072 Types accepted S16 S32 S64 U16 U32 U64. */
17073 NUF(vqshrn
, 0800910, 3, (RND
, RNQ
, I32z
), neon_rshift_sat_narrow
),
17074 NUF(vqrshrn
, 0800950, 3, (RND
, RNQ
, I32z
), neon_rshift_sat_narrow
),
17075 /* As above, unsigned. Types accepted S16 S32 S64. */
17076 NUF(vqshrun
, 0800810, 3, (RND
, RNQ
, I32z
), neon_rshift_sat_narrow_u
),
17077 NUF(vqrshrun
, 0800850, 3, (RND
, RNQ
, I32z
), neon_rshift_sat_narrow_u
),
17078 /* Right shift narrowing. Types accepted I16 I32 I64. */
17079 NUF(vshrn
, 0800810, 3, (RND
, RNQ
, I32z
), neon_rshift_narrow
),
17080 NUF(vrshrn
, 0800850, 3, (RND
, RNQ
, I32z
), neon_rshift_narrow
),
17081 /* Special case. Types S8 S16 S32 U8 U16 U32. Handles max shift variant. */
17082 nUF(vshll
, vshll
, 3, (RNQ
, RND
, I32
), neon_shll
),
17083 /* CVT with optional immediate for fixed-point variant. */
17084 nUF(vcvtq
, vcvt
, 3, (RNQ
, RNQ
, oI32b
), neon_cvt
),
17086 nUF(vmvn
, vmvn
, 2, (RNDQ
, RNDQ_IMVNb
), neon_mvn
),
17087 nUF(vmvnq
, vmvn
, 2, (RNQ
, RNDQ_IMVNb
), neon_mvn
),
17089 /* Data processing, three registers of different lengths. */
17090 /* Dyadic, long insns. Types S8 S16 S32 U8 U16 U32. */
17091 NUF(vabal
, 0800500, 3, (RNQ
, RND
, RND
), neon_abal
),
17092 NUF(vabdl
, 0800700, 3, (RNQ
, RND
, RND
), neon_dyadic_long
),
17093 NUF(vaddl
, 0800000, 3, (RNQ
, RND
, RND
), neon_dyadic_long
),
17094 NUF(vsubl
, 0800200, 3, (RNQ
, RND
, RND
), neon_dyadic_long
),
17095 /* If not scalar, fall back to neon_dyadic_long.
17096 Vector types as above, scalar types S16 S32 U16 U32. */
17097 nUF(vmlal
, vmlal
, 3, (RNQ
, RND
, RND_RNSC
), neon_mac_maybe_scalar_long
),
17098 nUF(vmlsl
, vmlsl
, 3, (RNQ
, RND
, RND_RNSC
), neon_mac_maybe_scalar_long
),
17099 /* Dyadic, widening insns. Types S8 S16 S32 U8 U16 U32. */
17100 NUF(vaddw
, 0800100, 3, (RNQ
, oRNQ
, RND
), neon_dyadic_wide
),
17101 NUF(vsubw
, 0800300, 3, (RNQ
, oRNQ
, RND
), neon_dyadic_wide
),
17102 /* Dyadic, narrowing insns. Types I16 I32 I64. */
17103 NUF(vaddhn
, 0800400, 3, (RND
, RNQ
, RNQ
), neon_dyadic_narrow
),
17104 NUF(vraddhn
, 1800400, 3, (RND
, RNQ
, RNQ
), neon_dyadic_narrow
),
17105 NUF(vsubhn
, 0800600, 3, (RND
, RNQ
, RNQ
), neon_dyadic_narrow
),
17106 NUF(vrsubhn
, 1800600, 3, (RND
, RNQ
, RNQ
), neon_dyadic_narrow
),
17107 /* Saturating doubling multiplies. Types S16 S32. */
17108 nUF(vqdmlal
, vqdmlal
, 3, (RNQ
, RND
, RND_RNSC
), neon_mul_sat_scalar_long
),
17109 nUF(vqdmlsl
, vqdmlsl
, 3, (RNQ
, RND
, RND_RNSC
), neon_mul_sat_scalar_long
),
17110 nUF(vqdmull
, vqdmull
, 3, (RNQ
, RND
, RND_RNSC
), neon_mul_sat_scalar_long
),
17111 /* VMULL. Vector types S8 S16 S32 U8 U16 U32 P8, scalar types
17112 S16 S32 U16 U32. */
17113 nUF(vmull
, vmull
, 3, (RNQ
, RND
, RND_RNSC
), neon_vmull
),
17115 /* Extract. Size 8. */
17116 NUF(vext
, 0b00000, 4, (RNDQ
, oRNDQ
, RNDQ
, I15
), neon_ext
),
17117 NUF(vextq
, 0b00000, 4, (RNQ
, oRNQ
, RNQ
, I15
), neon_ext
),
17119 /* Two registers, miscellaneous. */
17120 /* Reverse. Sizes 8 16 32 (must be < size in opcode). */
17121 NUF(vrev64
, 1b00000
, 2, (RNDQ
, RNDQ
), neon_rev
),
17122 NUF(vrev64q
, 1b00000
, 2, (RNQ
, RNQ
), neon_rev
),
17123 NUF(vrev32
, 1b00080
, 2, (RNDQ
, RNDQ
), neon_rev
),
17124 NUF(vrev32q
, 1b00080
, 2, (RNQ
, RNQ
), neon_rev
),
17125 NUF(vrev16
, 1b00100
, 2, (RNDQ
, RNDQ
), neon_rev
),
17126 NUF(vrev16q
, 1b00100
, 2, (RNQ
, RNQ
), neon_rev
),
17127 /* Vector replicate. Sizes 8 16 32. */
17128 nCE(vdup
, vdup
, 2, (RNDQ
, RR_RNSC
), neon_dup
),
17129 nCE(vdupq
, vdup
, 2, (RNQ
, RR_RNSC
), neon_dup
),
17130 /* VMOVL. Types S8 S16 S32 U8 U16 U32. */
17131 NUF(vmovl
, 0800a10
, 2, (RNQ
, RND
), neon_movl
),
17132 /* VMOVN. Types I16 I32 I64. */
17133 nUF(vmovn
, vmovn
, 2, (RND
, RNQ
), neon_movn
),
17134 /* VQMOVN. Types S16 S32 S64 U16 U32 U64. */
17135 nUF(vqmovn
, vqmovn
, 2, (RND
, RNQ
), neon_qmovn
),
17136 /* VQMOVUN. Types S16 S32 S64. */
17137 nUF(vqmovun
, vqmovun
, 2, (RND
, RNQ
), neon_qmovun
),
17138 /* VZIP / VUZP. Sizes 8 16 32. */
17139 NUF(vzip
, 1b20180
, 2, (RNDQ
, RNDQ
), neon_zip_uzp
),
17140 NUF(vzipq
, 1b20180
, 2, (RNQ
, RNQ
), neon_zip_uzp
),
17141 NUF(vuzp
, 1b20100
, 2, (RNDQ
, RNDQ
), neon_zip_uzp
),
17142 NUF(vuzpq
, 1b20100
, 2, (RNQ
, RNQ
), neon_zip_uzp
),
17143 /* VQABS / VQNEG. Types S8 S16 S32. */
17144 NUF(vqabs
, 1b00700
, 2, (RNDQ
, RNDQ
), neon_sat_abs_neg
),
17145 NUF(vqabsq
, 1b00700
, 2, (RNQ
, RNQ
), neon_sat_abs_neg
),
17146 NUF(vqneg
, 1b00780
, 2, (RNDQ
, RNDQ
), neon_sat_abs_neg
),
17147 NUF(vqnegq
, 1b00780
, 2, (RNQ
, RNQ
), neon_sat_abs_neg
),
17148 /* Pairwise, lengthening. Types S8 S16 S32 U8 U16 U32. */
17149 NUF(vpadal
, 1b00600
, 2, (RNDQ
, RNDQ
), neon_pair_long
),
17150 NUF(vpadalq
, 1b00600
, 2, (RNQ
, RNQ
), neon_pair_long
),
17151 NUF(vpaddl
, 1b00200
, 2, (RNDQ
, RNDQ
), neon_pair_long
),
17152 NUF(vpaddlq
, 1b00200
, 2, (RNQ
, RNQ
), neon_pair_long
),
17153 /* Reciprocal estimates. Types U32 F32. */
17154 NUF(vrecpe
, 1b30400
, 2, (RNDQ
, RNDQ
), neon_recip_est
),
17155 NUF(vrecpeq
, 1b30400
, 2, (RNQ
, RNQ
), neon_recip_est
),
17156 NUF(vrsqrte
, 1b30480
, 2, (RNDQ
, RNDQ
), neon_recip_est
),
17157 NUF(vrsqrteq
, 1b30480
, 2, (RNQ
, RNQ
), neon_recip_est
),
17158 /* VCLS. Types S8 S16 S32. */
17159 NUF(vcls
, 1b00400
, 2, (RNDQ
, RNDQ
), neon_cls
),
17160 NUF(vclsq
, 1b00400
, 2, (RNQ
, RNQ
), neon_cls
),
17161 /* VCLZ. Types I8 I16 I32. */
17162 NUF(vclz
, 1b00480
, 2, (RNDQ
, RNDQ
), neon_clz
),
17163 NUF(vclzq
, 1b00480
, 2, (RNQ
, RNQ
), neon_clz
),
17164 /* VCNT. Size 8. */
17165 NUF(vcnt
, 1b00500
, 2, (RNDQ
, RNDQ
), neon_cnt
),
17166 NUF(vcntq
, 1b00500
, 2, (RNQ
, RNQ
), neon_cnt
),
17167 /* Two address, untyped. */
17168 NUF(vswp
, 1b20000
, 2, (RNDQ
, RNDQ
), neon_swp
),
17169 NUF(vswpq
, 1b20000
, 2, (RNQ
, RNQ
), neon_swp
),
17170 /* VTRN. Sizes 8 16 32. */
17171 nUF(vtrn
, vtrn
, 2, (RNDQ
, RNDQ
), neon_trn
),
17172 nUF(vtrnq
, vtrn
, 2, (RNQ
, RNQ
), neon_trn
),
17174 /* Table lookup. Size 8. */
17175 NUF(vtbl
, 1b00800
, 3, (RND
, NRDLST
, RND
), neon_tbl_tbx
),
17176 NUF(vtbx
, 1b00840
, 3, (RND
, NRDLST
, RND
), neon_tbl_tbx
),
17178 #undef THUMB_VARIANT
17179 #define THUMB_VARIANT &fpu_vfp_v3_or_neon_ext
17181 #define ARM_VARIANT &fpu_vfp_v3_or_neon_ext
17182 /* Neon element/structure load/store. */
17183 nUF(vld1
, vld1
, 2, (NSTRLST
, ADDR
), neon_ldx_stx
),
17184 nUF(vst1
, vst1
, 2, (NSTRLST
, ADDR
), neon_ldx_stx
),
17185 nUF(vld2
, vld2
, 2, (NSTRLST
, ADDR
), neon_ldx_stx
),
17186 nUF(vst2
, vst2
, 2, (NSTRLST
, ADDR
), neon_ldx_stx
),
17187 nUF(vld3
, vld3
, 2, (NSTRLST
, ADDR
), neon_ldx_stx
),
17188 nUF(vst3
, vst3
, 2, (NSTRLST
, ADDR
), neon_ldx_stx
),
17189 nUF(vld4
, vld4
, 2, (NSTRLST
, ADDR
), neon_ldx_stx
),
17190 nUF(vst4
, vst4
, 2, (NSTRLST
, ADDR
), neon_ldx_stx
),
17192 #undef THUMB_VARIANT
17193 #define THUMB_VARIANT &fpu_vfp_ext_v3
17195 #define ARM_VARIANT &fpu_vfp_ext_v3
17196 cCE(fconsts
, eb00a00
, 2, (RVS
, I255
), vfp_sp_const
),
17197 cCE(fconstd
, eb00b00
, 2, (RVD
, I255
), vfp_dp_const
),
17198 cCE(fshtos
, eba0a40
, 2, (RVS
, I16z
), vfp_sp_conv_16
),
17199 cCE(fshtod
, eba0b40
, 2, (RVD
, I16z
), vfp_dp_conv_16
),
17200 cCE(fsltos
, eba0ac0
, 2, (RVS
, I32
), vfp_sp_conv_32
),
17201 cCE(fsltod
, eba0bc0
, 2, (RVD
, I32
), vfp_dp_conv_32
),
17202 cCE(fuhtos
, ebb0a40
, 2, (RVS
, I16z
), vfp_sp_conv_16
),
17203 cCE(fuhtod
, ebb0b40
, 2, (RVD
, I16z
), vfp_dp_conv_16
),
17204 cCE(fultos
, ebb0ac0
, 2, (RVS
, I32
), vfp_sp_conv_32
),
17205 cCE(fultod
, ebb0bc0
, 2, (RVD
, I32
), vfp_dp_conv_32
),
17206 cCE(ftoshs
, ebe0a40
, 2, (RVS
, I16z
), vfp_sp_conv_16
),
17207 cCE(ftoshd
, ebe0b40
, 2, (RVD
, I16z
), vfp_dp_conv_16
),
17208 cCE(ftosls
, ebe0ac0
, 2, (RVS
, I32
), vfp_sp_conv_32
),
17209 cCE(ftosld
, ebe0bc0
, 2, (RVD
, I32
), vfp_dp_conv_32
),
17210 cCE(ftouhs
, ebf0a40
, 2, (RVS
, I16z
), vfp_sp_conv_16
),
17211 cCE(ftouhd
, ebf0b40
, 2, (RVD
, I16z
), vfp_dp_conv_16
),
17212 cCE(ftouls
, ebf0ac0
, 2, (RVS
, I32
), vfp_sp_conv_32
),
17213 cCE(ftould
, ebf0bc0
, 2, (RVD
, I32
), vfp_dp_conv_32
),
17215 #undef THUMB_VARIANT
17217 #define ARM_VARIANT &arm_cext_xscale /* Intel XScale extensions. */
17218 cCE(mia
, e200010
, 3, (RXA
, RRnpc
, RRnpc
), xsc_mia
),
17219 cCE(miaph
, e280010
, 3, (RXA
, RRnpc
, RRnpc
), xsc_mia
),
17220 cCE(miabb
, e2c0010
, 3, (RXA
, RRnpc
, RRnpc
), xsc_mia
),
17221 cCE(miabt
, e2d0010
, 3, (RXA
, RRnpc
, RRnpc
), xsc_mia
),
17222 cCE(miatb
, e2e0010
, 3, (RXA
, RRnpc
, RRnpc
), xsc_mia
),
17223 cCE(miatt
, e2f0010
, 3, (RXA
, RRnpc
, RRnpc
), xsc_mia
),
17224 cCE(mar
, c400000
, 3, (RXA
, RRnpc
, RRnpc
), xsc_mar
),
17225 cCE(mra
, c500000
, 3, (RRnpc
, RRnpc
, RXA
), xsc_mra
),
17228 #define ARM_VARIANT &arm_cext_iwmmxt /* Intel Wireless MMX technology. */
17229 cCE(tandcb
, e13f130
, 1, (RR
), iwmmxt_tandorc
),
17230 cCE(tandch
, e53f130
, 1, (RR
), iwmmxt_tandorc
),
17231 cCE(tandcw
, e93f130
, 1, (RR
), iwmmxt_tandorc
),
17232 cCE(tbcstb
, e400010
, 2, (RIWR
, RR
), rn_rd
),
17233 cCE(tbcsth
, e400050
, 2, (RIWR
, RR
), rn_rd
),
17234 cCE(tbcstw
, e400090
, 2, (RIWR
, RR
), rn_rd
),
17235 cCE(textrcb
, e130170
, 2, (RR
, I7
), iwmmxt_textrc
),
17236 cCE(textrch
, e530170
, 2, (RR
, I7
), iwmmxt_textrc
),
17237 cCE(textrcw
, e930170
, 2, (RR
, I7
), iwmmxt_textrc
),
17238 cCE(textrmub
, e100070
, 3, (RR
, RIWR
, I7
), iwmmxt_textrm
),
17239 cCE(textrmuh
, e500070
, 3, (RR
, RIWR
, I7
), iwmmxt_textrm
),
17240 cCE(textrmuw
, e900070
, 3, (RR
, RIWR
, I7
), iwmmxt_textrm
),
17241 cCE(textrmsb
, e100078
, 3, (RR
, RIWR
, I7
), iwmmxt_textrm
),
17242 cCE(textrmsh
, e500078
, 3, (RR
, RIWR
, I7
), iwmmxt_textrm
),
17243 cCE(textrmsw
, e900078
, 3, (RR
, RIWR
, I7
), iwmmxt_textrm
),
17244 cCE(tinsrb
, e600010
, 3, (RIWR
, RR
, I7
), iwmmxt_tinsr
),
17245 cCE(tinsrh
, e600050
, 3, (RIWR
, RR
, I7
), iwmmxt_tinsr
),
17246 cCE(tinsrw
, e600090
, 3, (RIWR
, RR
, I7
), iwmmxt_tinsr
),
17247 cCE(tmcr
, e000110
, 2, (RIWC_RIWG
, RR
), rn_rd
),
17248 cCE(tmcrr
, c400000
, 3, (RIWR
, RR
, RR
), rm_rd_rn
),
17249 cCE(tmia
, e200010
, 3, (RIWR
, RR
, RR
), iwmmxt_tmia
),
17250 cCE(tmiaph
, e280010
, 3, (RIWR
, RR
, RR
), iwmmxt_tmia
),
17251 cCE(tmiabb
, e2c0010
, 3, (RIWR
, RR
, RR
), iwmmxt_tmia
),
17252 cCE(tmiabt
, e2d0010
, 3, (RIWR
, RR
, RR
), iwmmxt_tmia
),
17253 cCE(tmiatb
, e2e0010
, 3, (RIWR
, RR
, RR
), iwmmxt_tmia
),
17254 cCE(tmiatt
, e2f0010
, 3, (RIWR
, RR
, RR
), iwmmxt_tmia
),
17255 cCE(tmovmskb
, e100030
, 2, (RR
, RIWR
), rd_rn
),
17256 cCE(tmovmskh
, e500030
, 2, (RR
, RIWR
), rd_rn
),
17257 cCE(tmovmskw
, e900030
, 2, (RR
, RIWR
), rd_rn
),
17258 cCE(tmrc
, e100110
, 2, (RR
, RIWC_RIWG
), rd_rn
),
17259 cCE(tmrrc
, c500000
, 3, (RR
, RR
, RIWR
), rd_rn_rm
),
17260 cCE(torcb
, e13f150
, 1, (RR
), iwmmxt_tandorc
),
17261 cCE(torch
, e53f150
, 1, (RR
), iwmmxt_tandorc
),
17262 cCE(torcw
, e93f150
, 1, (RR
), iwmmxt_tandorc
),
17263 cCE(waccb
, e0001c0
, 2, (RIWR
, RIWR
), rd_rn
),
17264 cCE(wacch
, e4001c0
, 2, (RIWR
, RIWR
), rd_rn
),
17265 cCE(waccw
, e8001c0
, 2, (RIWR
, RIWR
), rd_rn
),
17266 cCE(waddbss
, e300180
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17267 cCE(waddb
, e000180
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17268 cCE(waddbus
, e100180
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17269 cCE(waddhss
, e700180
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17270 cCE(waddh
, e400180
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17271 cCE(waddhus
, e500180
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17272 cCE(waddwss
, eb00180
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17273 cCE(waddw
, e800180
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17274 cCE(waddwus
, e900180
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17275 cCE(waligni
, e000020
, 4, (RIWR
, RIWR
, RIWR
, I7
), iwmmxt_waligni
),
17276 cCE(walignr0
, e800020
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17277 cCE(walignr1
, e900020
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17278 cCE(walignr2
, ea00020
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17279 cCE(walignr3
, eb00020
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17280 cCE(wand
, e200000
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17281 cCE(wandn
, e300000
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17282 cCE(wavg2b
, e800000
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17283 cCE(wavg2br
, e900000
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17284 cCE(wavg2h
, ec00000
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17285 cCE(wavg2hr
, ed00000
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17286 cCE(wcmpeqb
, e000060
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17287 cCE(wcmpeqh
, e400060
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17288 cCE(wcmpeqw
, e800060
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17289 cCE(wcmpgtub
, e100060
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17290 cCE(wcmpgtuh
, e500060
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17291 cCE(wcmpgtuw
, e900060
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17292 cCE(wcmpgtsb
, e300060
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17293 cCE(wcmpgtsh
, e700060
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17294 cCE(wcmpgtsw
, eb00060
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17295 cCE(wldrb
, c100000
, 2, (RIWR
, ADDR
), iwmmxt_wldstbh
),
17296 cCE(wldrh
, c500000
, 2, (RIWR
, ADDR
), iwmmxt_wldstbh
),
17297 cCE(wldrw
, c100100
, 2, (RIWR_RIWC
, ADDR
), iwmmxt_wldstw
),
17298 cCE(wldrd
, c500100
, 2, (RIWR
, ADDR
), iwmmxt_wldstd
),
17299 cCE(wmacs
, e600100
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17300 cCE(wmacsz
, e700100
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17301 cCE(wmacu
, e400100
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17302 cCE(wmacuz
, e500100
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17303 cCE(wmadds
, ea00100
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17304 cCE(wmaddu
, e800100
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17305 cCE(wmaxsb
, e200160
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17306 cCE(wmaxsh
, e600160
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17307 cCE(wmaxsw
, ea00160
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17308 cCE(wmaxub
, e000160
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17309 cCE(wmaxuh
, e400160
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17310 cCE(wmaxuw
, e800160
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17311 cCE(wminsb
, e300160
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17312 cCE(wminsh
, e700160
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17313 cCE(wminsw
, eb00160
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17314 cCE(wminub
, e100160
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17315 cCE(wminuh
, e500160
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17316 cCE(wminuw
, e900160
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17317 cCE(wmov
, e000000
, 2, (RIWR
, RIWR
), iwmmxt_wmov
),
17318 cCE(wmulsm
, e300100
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17319 cCE(wmulsl
, e200100
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17320 cCE(wmulum
, e100100
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17321 cCE(wmulul
, e000100
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17322 cCE(wor
, e000000
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17323 cCE(wpackhss
, e700080
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17324 cCE(wpackhus
, e500080
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17325 cCE(wpackwss
, eb00080
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17326 cCE(wpackwus
, e900080
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17327 cCE(wpackdss
, ef00080
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17328 cCE(wpackdus
, ed00080
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17329 cCE(wrorh
, e700040
, 3, (RIWR
, RIWR
, RIWR_I32z
),iwmmxt_wrwrwr_or_imm5
),
17330 cCE(wrorhg
, e700148
, 3, (RIWR
, RIWR
, RIWG
), rd_rn_rm
),
17331 cCE(wrorw
, eb00040
, 3, (RIWR
, RIWR
, RIWR_I32z
),iwmmxt_wrwrwr_or_imm5
),
17332 cCE(wrorwg
, eb00148
, 3, (RIWR
, RIWR
, RIWG
), rd_rn_rm
),
17333 cCE(wrord
, ef00040
, 3, (RIWR
, RIWR
, RIWR_I32z
),iwmmxt_wrwrwr_or_imm5
),
17334 cCE(wrordg
, ef00148
, 3, (RIWR
, RIWR
, RIWG
), rd_rn_rm
),
17335 cCE(wsadb
, e000120
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17336 cCE(wsadbz
, e100120
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17337 cCE(wsadh
, e400120
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17338 cCE(wsadhz
, e500120
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17339 cCE(wshufh
, e0001e0
, 3, (RIWR
, RIWR
, I255
), iwmmxt_wshufh
),
17340 cCE(wsllh
, e500040
, 3, (RIWR
, RIWR
, RIWR_I32z
),iwmmxt_wrwrwr_or_imm5
),
17341 cCE(wsllhg
, e500148
, 3, (RIWR
, RIWR
, RIWG
), rd_rn_rm
),
17342 cCE(wsllw
, e900040
, 3, (RIWR
, RIWR
, RIWR_I32z
),iwmmxt_wrwrwr_or_imm5
),
17343 cCE(wsllwg
, e900148
, 3, (RIWR
, RIWR
, RIWG
), rd_rn_rm
),
17344 cCE(wslld
, ed00040
, 3, (RIWR
, RIWR
, RIWR_I32z
),iwmmxt_wrwrwr_or_imm5
),
17345 cCE(wslldg
, ed00148
, 3, (RIWR
, RIWR
, RIWG
), rd_rn_rm
),
17346 cCE(wsrah
, e400040
, 3, (RIWR
, RIWR
, RIWR_I32z
),iwmmxt_wrwrwr_or_imm5
),
17347 cCE(wsrahg
, e400148
, 3, (RIWR
, RIWR
, RIWG
), rd_rn_rm
),
17348 cCE(wsraw
, e800040
, 3, (RIWR
, RIWR
, RIWR_I32z
),iwmmxt_wrwrwr_or_imm5
),
17349 cCE(wsrawg
, e800148
, 3, (RIWR
, RIWR
, RIWG
), rd_rn_rm
),
17350 cCE(wsrad
, ec00040
, 3, (RIWR
, RIWR
, RIWR_I32z
),iwmmxt_wrwrwr_or_imm5
),
17351 cCE(wsradg
, ec00148
, 3, (RIWR
, RIWR
, RIWG
), rd_rn_rm
),
17352 cCE(wsrlh
, e600040
, 3, (RIWR
, RIWR
, RIWR_I32z
),iwmmxt_wrwrwr_or_imm5
),
17353 cCE(wsrlhg
, e600148
, 3, (RIWR
, RIWR
, RIWG
), rd_rn_rm
),
17354 cCE(wsrlw
, ea00040
, 3, (RIWR
, RIWR
, RIWR_I32z
),iwmmxt_wrwrwr_or_imm5
),
17355 cCE(wsrlwg
, ea00148
, 3, (RIWR
, RIWR
, RIWG
), rd_rn_rm
),
17356 cCE(wsrld
, ee00040
, 3, (RIWR
, RIWR
, RIWR_I32z
),iwmmxt_wrwrwr_or_imm5
),
17357 cCE(wsrldg
, ee00148
, 3, (RIWR
, RIWR
, RIWG
), rd_rn_rm
),
17358 cCE(wstrb
, c000000
, 2, (RIWR
, ADDR
), iwmmxt_wldstbh
),
17359 cCE(wstrh
, c400000
, 2, (RIWR
, ADDR
), iwmmxt_wldstbh
),
17360 cCE(wstrw
, c000100
, 2, (RIWR_RIWC
, ADDR
), iwmmxt_wldstw
),
17361 cCE(wstrd
, c400100
, 2, (RIWR
, ADDR
), iwmmxt_wldstd
),
17362 cCE(wsubbss
, e3001a0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17363 cCE(wsubb
, e0001a0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17364 cCE(wsubbus
, e1001a0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17365 cCE(wsubhss
, e7001a0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17366 cCE(wsubh
, e4001a0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17367 cCE(wsubhus
, e5001a0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17368 cCE(wsubwss
, eb001a0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17369 cCE(wsubw
, e8001a0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17370 cCE(wsubwus
, e9001a0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17371 cCE(wunpckehub
,e0000c0
, 2, (RIWR
, RIWR
), rd_rn
),
17372 cCE(wunpckehuh
,e4000c0
, 2, (RIWR
, RIWR
), rd_rn
),
17373 cCE(wunpckehuw
,e8000c0
, 2, (RIWR
, RIWR
), rd_rn
),
17374 cCE(wunpckehsb
,e2000c0
, 2, (RIWR
, RIWR
), rd_rn
),
17375 cCE(wunpckehsh
,e6000c0
, 2, (RIWR
, RIWR
), rd_rn
),
17376 cCE(wunpckehsw
,ea000c0
, 2, (RIWR
, RIWR
), rd_rn
),
17377 cCE(wunpckihb
, e1000c0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17378 cCE(wunpckihh
, e5000c0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17379 cCE(wunpckihw
, e9000c0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17380 cCE(wunpckelub
,e0000e0
, 2, (RIWR
, RIWR
), rd_rn
),
17381 cCE(wunpckeluh
,e4000e0
, 2, (RIWR
, RIWR
), rd_rn
),
17382 cCE(wunpckeluw
,e8000e0
, 2, (RIWR
, RIWR
), rd_rn
),
17383 cCE(wunpckelsb
,e2000e0
, 2, (RIWR
, RIWR
), rd_rn
),
17384 cCE(wunpckelsh
,e6000e0
, 2, (RIWR
, RIWR
), rd_rn
),
17385 cCE(wunpckelsw
,ea000e0
, 2, (RIWR
, RIWR
), rd_rn
),
17386 cCE(wunpckilb
, e1000e0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17387 cCE(wunpckilh
, e5000e0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17388 cCE(wunpckilw
, e9000e0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17389 cCE(wxor
, e100000
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17390 cCE(wzero
, e300000
, 1, (RIWR
), iwmmxt_wzero
),
17393 #define ARM_VARIANT &arm_cext_iwmmxt2 /* Intel Wireless MMX technology, version 2. */
17394 cCE(torvscb
, e13f190
, 1, (RR
), iwmmxt_tandorc
),
17395 cCE(torvsch
, e53f190
, 1, (RR
), iwmmxt_tandorc
),
17396 cCE(torvscw
, e93f190
, 1, (RR
), iwmmxt_tandorc
),
17397 cCE(wabsb
, e2001c0
, 2, (RIWR
, RIWR
), rd_rn
),
17398 cCE(wabsh
, e6001c0
, 2, (RIWR
, RIWR
), rd_rn
),
17399 cCE(wabsw
, ea001c0
, 2, (RIWR
, RIWR
), rd_rn
),
17400 cCE(wabsdiffb
, e1001c0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17401 cCE(wabsdiffh
, e5001c0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17402 cCE(wabsdiffw
, e9001c0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17403 cCE(waddbhusl
, e2001a0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17404 cCE(waddbhusm
, e6001a0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17405 cCE(waddhc
, e600180
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17406 cCE(waddwc
, ea00180
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17407 cCE(waddsubhx
, ea001a0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17408 cCE(wavg4
, e400000
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17409 cCE(wavg4r
, e500000
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17410 cCE(wmaddsn
, ee00100
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17411 cCE(wmaddsx
, eb00100
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17412 cCE(wmaddun
, ec00100
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17413 cCE(wmaddux
, e900100
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17414 cCE(wmerge
, e000080
, 4, (RIWR
, RIWR
, RIWR
, I7
), iwmmxt_wmerge
),
17415 cCE(wmiabb
, e0000a0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17416 cCE(wmiabt
, e1000a0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17417 cCE(wmiatb
, e2000a0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17418 cCE(wmiatt
, e3000a0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17419 cCE(wmiabbn
, e4000a0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17420 cCE(wmiabtn
, e5000a0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17421 cCE(wmiatbn
, e6000a0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17422 cCE(wmiattn
, e7000a0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17423 cCE(wmiawbb
, e800120
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17424 cCE(wmiawbt
, e900120
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17425 cCE(wmiawtb
, ea00120
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17426 cCE(wmiawtt
, eb00120
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17427 cCE(wmiawbbn
, ec00120
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17428 cCE(wmiawbtn
, ed00120
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17429 cCE(wmiawtbn
, ee00120
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17430 cCE(wmiawttn
, ef00120
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17431 cCE(wmulsmr
, ef00100
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17432 cCE(wmulumr
, ed00100
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17433 cCE(wmulwumr
, ec000c0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17434 cCE(wmulwsmr
, ee000c0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17435 cCE(wmulwum
, ed000c0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17436 cCE(wmulwsm
, ef000c0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17437 cCE(wmulwl
, eb000c0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17438 cCE(wqmiabb
, e8000a0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17439 cCE(wqmiabt
, e9000a0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17440 cCE(wqmiatb
, ea000a0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17441 cCE(wqmiatt
, eb000a0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17442 cCE(wqmiabbn
, ec000a0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17443 cCE(wqmiabtn
, ed000a0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17444 cCE(wqmiatbn
, ee000a0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17445 cCE(wqmiattn
, ef000a0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17446 cCE(wqmulm
, e100080
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17447 cCE(wqmulmr
, e300080
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17448 cCE(wqmulwm
, ec000e0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17449 cCE(wqmulwmr
, ee000e0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17450 cCE(wsubaddhx
, ed001c0
, 3, (RIWR
, RIWR
, RIWR
), rd_rn_rm
),
17453 #define ARM_VARIANT &arm_cext_maverick /* Cirrus Maverick instructions. */
17454 cCE(cfldrs
, c100400
, 2, (RMF
, ADDRGLDC
), rd_cpaddr
),
17455 cCE(cfldrd
, c500400
, 2, (RMD
, ADDRGLDC
), rd_cpaddr
),
17456 cCE(cfldr32
, c100500
, 2, (RMFX
, ADDRGLDC
), rd_cpaddr
),
17457 cCE(cfldr64
, c500500
, 2, (RMDX
, ADDRGLDC
), rd_cpaddr
),
17458 cCE(cfstrs
, c000400
, 2, (RMF
, ADDRGLDC
), rd_cpaddr
),
17459 cCE(cfstrd
, c400400
, 2, (RMD
, ADDRGLDC
), rd_cpaddr
),
17460 cCE(cfstr32
, c000500
, 2, (RMFX
, ADDRGLDC
), rd_cpaddr
),
17461 cCE(cfstr64
, c400500
, 2, (RMDX
, ADDRGLDC
), rd_cpaddr
),
17462 cCE(cfmvsr
, e000450
, 2, (RMF
, RR
), rn_rd
),
17463 cCE(cfmvrs
, e100450
, 2, (RR
, RMF
), rd_rn
),
17464 cCE(cfmvdlr
, e000410
, 2, (RMD
, RR
), rn_rd
),
17465 cCE(cfmvrdl
, e100410
, 2, (RR
, RMD
), rd_rn
),
17466 cCE(cfmvdhr
, e000430
, 2, (RMD
, RR
), rn_rd
),
17467 cCE(cfmvrdh
, e100430
, 2, (RR
, RMD
), rd_rn
),
17468 cCE(cfmv64lr
, e000510
, 2, (RMDX
, RR
), rn_rd
),
17469 cCE(cfmvr64l
, e100510
, 2, (RR
, RMDX
), rd_rn
),
17470 cCE(cfmv64hr
, e000530
, 2, (RMDX
, RR
), rn_rd
),
17471 cCE(cfmvr64h
, e100530
, 2, (RR
, RMDX
), rd_rn
),
17472 cCE(cfmval32
, e200440
, 2, (RMAX
, RMFX
), rd_rn
),
17473 cCE(cfmv32al
, e100440
, 2, (RMFX
, RMAX
), rd_rn
),
17474 cCE(cfmvam32
, e200460
, 2, (RMAX
, RMFX
), rd_rn
),
17475 cCE(cfmv32am
, e100460
, 2, (RMFX
, RMAX
), rd_rn
),
17476 cCE(cfmvah32
, e200480
, 2, (RMAX
, RMFX
), rd_rn
),
17477 cCE(cfmv32ah
, e100480
, 2, (RMFX
, RMAX
), rd_rn
),
17478 cCE(cfmva32
, e2004a0
, 2, (RMAX
, RMFX
), rd_rn
),
17479 cCE(cfmv32a
, e1004a0
, 2, (RMFX
, RMAX
), rd_rn
),
17480 cCE(cfmva64
, e2004c0
, 2, (RMAX
, RMDX
), rd_rn
),
17481 cCE(cfmv64a
, e1004c0
, 2, (RMDX
, RMAX
), rd_rn
),
17482 cCE(cfmvsc32
, e2004e0
, 2, (RMDS
, RMDX
), mav_dspsc
),
17483 cCE(cfmv32sc
, e1004e0
, 2, (RMDX
, RMDS
), rd
),
17484 cCE(cfcpys
, e000400
, 2, (RMF
, RMF
), rd_rn
),
17485 cCE(cfcpyd
, e000420
, 2, (RMD
, RMD
), rd_rn
),
17486 cCE(cfcvtsd
, e000460
, 2, (RMD
, RMF
), rd_rn
),
17487 cCE(cfcvtds
, e000440
, 2, (RMF
, RMD
), rd_rn
),
17488 cCE(cfcvt32s
, e000480
, 2, (RMF
, RMFX
), rd_rn
),
17489 cCE(cfcvt32d
, e0004a0
, 2, (RMD
, RMFX
), rd_rn
),
17490 cCE(cfcvt64s
, e0004c0
, 2, (RMF
, RMDX
), rd_rn
),
17491 cCE(cfcvt64d
, e0004e0
, 2, (RMD
, RMDX
), rd_rn
),
17492 cCE(cfcvts32
, e100580
, 2, (RMFX
, RMF
), rd_rn
),
17493 cCE(cfcvtd32
, e1005a0
, 2, (RMFX
, RMD
), rd_rn
),
17494 cCE(cftruncs32
,e1005c0
, 2, (RMFX
, RMF
), rd_rn
),
17495 cCE(cftruncd32
,e1005e0
, 2, (RMFX
, RMD
), rd_rn
),
17496 cCE(cfrshl32
, e000550
, 3, (RMFX
, RMFX
, RR
), mav_triple
),
17497 cCE(cfrshl64
, e000570
, 3, (RMDX
, RMDX
, RR
), mav_triple
),
17498 cCE(cfsh32
, e000500
, 3, (RMFX
, RMFX
, I63s
), mav_shift
),
17499 cCE(cfsh64
, e200500
, 3, (RMDX
, RMDX
, I63s
), mav_shift
),
17500 cCE(cfcmps
, e100490
, 3, (RR
, RMF
, RMF
), rd_rn_rm
),
17501 cCE(cfcmpd
, e1004b0
, 3, (RR
, RMD
, RMD
), rd_rn_rm
),
17502 cCE(cfcmp32
, e100590
, 3, (RR
, RMFX
, RMFX
), rd_rn_rm
),
17503 cCE(cfcmp64
, e1005b0
, 3, (RR
, RMDX
, RMDX
), rd_rn_rm
),
17504 cCE(cfabss
, e300400
, 2, (RMF
, RMF
), rd_rn
),
17505 cCE(cfabsd
, e300420
, 2, (RMD
, RMD
), rd_rn
),
17506 cCE(cfnegs
, e300440
, 2, (RMF
, RMF
), rd_rn
),
17507 cCE(cfnegd
, e300460
, 2, (RMD
, RMD
), rd_rn
),
17508 cCE(cfadds
, e300480
, 3, (RMF
, RMF
, RMF
), rd_rn_rm
),
17509 cCE(cfaddd
, e3004a0
, 3, (RMD
, RMD
, RMD
), rd_rn_rm
),
17510 cCE(cfsubs
, e3004c0
, 3, (RMF
, RMF
, RMF
), rd_rn_rm
),
17511 cCE(cfsubd
, e3004e0
, 3, (RMD
, RMD
, RMD
), rd_rn_rm
),
17512 cCE(cfmuls
, e100400
, 3, (RMF
, RMF
, RMF
), rd_rn_rm
),
17513 cCE(cfmuld
, e100420
, 3, (RMD
, RMD
, RMD
), rd_rn_rm
),
17514 cCE(cfabs32
, e300500
, 2, (RMFX
, RMFX
), rd_rn
),
17515 cCE(cfabs64
, e300520
, 2, (RMDX
, RMDX
), rd_rn
),
17516 cCE(cfneg32
, e300540
, 2, (RMFX
, RMFX
), rd_rn
),
17517 cCE(cfneg64
, e300560
, 2, (RMDX
, RMDX
), rd_rn
),
17518 cCE(cfadd32
, e300580
, 3, (RMFX
, RMFX
, RMFX
), rd_rn_rm
),
17519 cCE(cfadd64
, e3005a0
, 3, (RMDX
, RMDX
, RMDX
), rd_rn_rm
),
17520 cCE(cfsub32
, e3005c0
, 3, (RMFX
, RMFX
, RMFX
), rd_rn_rm
),
17521 cCE(cfsub64
, e3005e0
, 3, (RMDX
, RMDX
, RMDX
), rd_rn_rm
),
17522 cCE(cfmul32
, e100500
, 3, (RMFX
, RMFX
, RMFX
), rd_rn_rm
),
17523 cCE(cfmul64
, e100520
, 3, (RMDX
, RMDX
, RMDX
), rd_rn_rm
),
17524 cCE(cfmac32
, e100540
, 3, (RMFX
, RMFX
, RMFX
), rd_rn_rm
),
17525 cCE(cfmsc32
, e100560
, 3, (RMFX
, RMFX
, RMFX
), rd_rn_rm
),
17526 cCE(cfmadd32
, e000600
, 4, (RMAX
, RMFX
, RMFX
, RMFX
), mav_quad
),
17527 cCE(cfmsub32
, e100600
, 4, (RMAX
, RMFX
, RMFX
, RMFX
), mav_quad
),
17528 cCE(cfmadda32
, e200600
, 4, (RMAX
, RMAX
, RMFX
, RMFX
), mav_quad
),
17529 cCE(cfmsuba32
, e300600
, 4, (RMAX
, RMAX
, RMFX
, RMFX
), mav_quad
),
17532 #undef THUMB_VARIANT
17559 /* MD interface: bits in the object file. */
17561 /* Turn an integer of n bytes (in val) into a stream of bytes appropriate
17562 for use in the a.out file, and stores them in the array pointed to by buf.
17563 This knows about the endian-ness of the target machine and does
17564 THE RIGHT THING, whatever it is. Possible values for n are 1 (byte)
17565 2 (short) and 4 (long) Floating numbers are put out as a series of
17566 LITTLENUMS (shorts, here at least). */
17569 md_number_to_chars (char * buf
, valueT val
, int n
)
17571 if (target_big_endian
)
17572 number_to_chars_bigendian (buf
, val
, n
);
17574 number_to_chars_littleendian (buf
, val
, n
);
17578 md_chars_to_number (char * buf
, int n
)
17581 unsigned char * where
= (unsigned char *) buf
;
17583 if (target_big_endian
)
17588 result
|= (*where
++ & 255);
17596 result
|= (where
[n
] & 255);
17603 /* MD interface: Sections. */
17605 /* Estimate the size of a frag before relaxing. Assume everything fits in
17609 md_estimate_size_before_relax (fragS
* fragp
,
17610 segT segtype ATTRIBUTE_UNUSED
)
17616 /* Convert a machine dependent frag. */
17619 md_convert_frag (bfd
*abfd
, segT asec ATTRIBUTE_UNUSED
, fragS
*fragp
)
17621 unsigned long insn
;
17622 unsigned long old_op
;
17630 buf
= fragp
->fr_literal
+ fragp
->fr_fix
;
17632 old_op
= bfd_get_16(abfd
, buf
);
17633 if (fragp
->fr_symbol
)
17635 exp
.X_op
= O_symbol
;
17636 exp
.X_add_symbol
= fragp
->fr_symbol
;
17640 exp
.X_op
= O_constant
;
17642 exp
.X_add_number
= fragp
->fr_offset
;
17643 opcode
= fragp
->fr_subtype
;
17646 case T_MNEM_ldr_pc
:
17647 case T_MNEM_ldr_pc2
:
17648 case T_MNEM_ldr_sp
:
17649 case T_MNEM_str_sp
:
17656 if (fragp
->fr_var
== 4)
17658 insn
= THUMB_OP32 (opcode
);
17659 if ((old_op
>> 12) == 4 || (old_op
>> 12) == 9)
17661 insn
|= (old_op
& 0x700) << 4;
17665 insn
|= (old_op
& 7) << 12;
17666 insn
|= (old_op
& 0x38) << 13;
17668 insn
|= 0x00000c00;
17669 put_thumb32_insn (buf
, insn
);
17670 reloc_type
= BFD_RELOC_ARM_T32_OFFSET_IMM
;
17674 reloc_type
= BFD_RELOC_ARM_THUMB_OFFSET
;
17676 pc_rel
= (opcode
== T_MNEM_ldr_pc2
);
17679 if (fragp
->fr_var
== 4)
17681 insn
= THUMB_OP32 (opcode
);
17682 insn
|= (old_op
& 0xf0) << 4;
17683 put_thumb32_insn (buf
, insn
);
17684 reloc_type
= BFD_RELOC_ARM_T32_ADD_PC12
;
17688 reloc_type
= BFD_RELOC_ARM_THUMB_ADD
;
17689 exp
.X_add_number
-= 4;
17697 if (fragp
->fr_var
== 4)
17699 int r0off
= (opcode
== T_MNEM_mov
17700 || opcode
== T_MNEM_movs
) ? 0 : 8;
17701 insn
= THUMB_OP32 (opcode
);
17702 insn
= (insn
& 0xe1ffffff) | 0x10000000;
17703 insn
|= (old_op
& 0x700) << r0off
;
17704 put_thumb32_insn (buf
, insn
);
17705 reloc_type
= BFD_RELOC_ARM_T32_IMMEDIATE
;
17709 reloc_type
= BFD_RELOC_ARM_THUMB_IMM
;
17714 if (fragp
->fr_var
== 4)
17716 insn
= THUMB_OP32(opcode
);
17717 put_thumb32_insn (buf
, insn
);
17718 reloc_type
= BFD_RELOC_THUMB_PCREL_BRANCH25
;
17721 reloc_type
= BFD_RELOC_THUMB_PCREL_BRANCH12
;
17725 if (fragp
->fr_var
== 4)
17727 insn
= THUMB_OP32(opcode
);
17728 insn
|= (old_op
& 0xf00) << 14;
17729 put_thumb32_insn (buf
, insn
);
17730 reloc_type
= BFD_RELOC_THUMB_PCREL_BRANCH20
;
17733 reloc_type
= BFD_RELOC_THUMB_PCREL_BRANCH9
;
17736 case T_MNEM_add_sp
:
17737 case T_MNEM_add_pc
:
17738 case T_MNEM_inc_sp
:
17739 case T_MNEM_dec_sp
:
17740 if (fragp
->fr_var
== 4)
17742 /* ??? Choose between add and addw. */
17743 insn
= THUMB_OP32 (opcode
);
17744 insn
|= (old_op
& 0xf0) << 4;
17745 put_thumb32_insn (buf
, insn
);
17746 if (opcode
== T_MNEM_add_pc
)
17747 reloc_type
= BFD_RELOC_ARM_T32_IMM12
;
17749 reloc_type
= BFD_RELOC_ARM_T32_ADD_IMM
;
17752 reloc_type
= BFD_RELOC_ARM_THUMB_ADD
;
17760 if (fragp
->fr_var
== 4)
17762 insn
= THUMB_OP32 (opcode
);
17763 insn
|= (old_op
& 0xf0) << 4;
17764 insn
|= (old_op
& 0xf) << 16;
17765 put_thumb32_insn (buf
, insn
);
17766 if (insn
& (1 << 20))
17767 reloc_type
= BFD_RELOC_ARM_T32_ADD_IMM
;
17769 reloc_type
= BFD_RELOC_ARM_T32_IMMEDIATE
;
17772 reloc_type
= BFD_RELOC_ARM_THUMB_ADD
;
17778 fixp
= fix_new_exp (fragp
, fragp
->fr_fix
, fragp
->fr_var
, &exp
, pc_rel
,
17780 fixp
->fx_file
= fragp
->fr_file
;
17781 fixp
->fx_line
= fragp
->fr_line
;
17782 fragp
->fr_fix
+= fragp
->fr_var
;
17785 /* Return the size of a relaxable immediate operand instruction.
17786 SHIFT and SIZE specify the form of the allowable immediate. */
17788 relax_immediate (fragS
*fragp
, int size
, int shift
)
17794 /* ??? Should be able to do better than this. */
17795 if (fragp
->fr_symbol
)
17798 low
= (1 << shift
) - 1;
17799 mask
= (1 << (shift
+ size
)) - (1 << shift
);
17800 offset
= fragp
->fr_offset
;
17801 /* Force misaligned offsets to 32-bit variant. */
17804 if (offset
& ~mask
)
17809 /* Get the address of a symbol during relaxation. */
17811 relaxed_symbol_addr (fragS
*fragp
, long stretch
)
17817 sym
= fragp
->fr_symbol
;
17818 sym_frag
= symbol_get_frag (sym
);
17819 know (S_GET_SEGMENT (sym
) != absolute_section
17820 || sym_frag
== &zero_address_frag
);
17821 addr
= S_GET_VALUE (sym
) + fragp
->fr_offset
;
17823 /* If frag has yet to be reached on this pass, assume it will
17824 move by STRETCH just as we did. If this is not so, it will
17825 be because some frag between grows, and that will force
17829 && sym_frag
->relax_marker
!= fragp
->relax_marker
)
17833 /* Adjust stretch for any alignment frag. Note that if have
17834 been expanding the earlier code, the symbol may be
17835 defined in what appears to be an earlier frag. FIXME:
17836 This doesn't handle the fr_subtype field, which specifies
17837 a maximum number of bytes to skip when doing an
17839 for (f
= fragp
; f
!= NULL
&& f
!= sym_frag
; f
= f
->fr_next
)
17841 if (f
->fr_type
== rs_align
|| f
->fr_type
== rs_align_code
)
17844 stretch
= - ((- stretch
)
17845 & ~ ((1 << (int) f
->fr_offset
) - 1));
17847 stretch
&= ~ ((1 << (int) f
->fr_offset
) - 1);
17859 /* Return the size of a relaxable adr pseudo-instruction or PC-relative
17862 relax_adr (fragS
*fragp
, asection
*sec
, long stretch
)
17867 /* Assume worst case for symbols not known to be in the same section. */
17868 if (!S_IS_DEFINED (fragp
->fr_symbol
)
17869 || sec
!= S_GET_SEGMENT (fragp
->fr_symbol
))
17872 val
= relaxed_symbol_addr (fragp
, stretch
);
17873 addr
= fragp
->fr_address
+ fragp
->fr_fix
;
17874 addr
= (addr
+ 4) & ~3;
17875 /* Force misaligned targets to 32-bit variant. */
17879 if (val
< 0 || val
> 1020)
17884 /* Return the size of a relaxable add/sub immediate instruction. */
17886 relax_addsub (fragS
*fragp
, asection
*sec
)
17891 buf
= fragp
->fr_literal
+ fragp
->fr_fix
;
17892 op
= bfd_get_16(sec
->owner
, buf
);
17893 if ((op
& 0xf) == ((op
>> 4) & 0xf))
17894 return relax_immediate (fragp
, 8, 0);
17896 return relax_immediate (fragp
, 3, 0);
17900 /* Return the size of a relaxable branch instruction. BITS is the
17901 size of the offset field in the narrow instruction. */
17904 relax_branch (fragS
*fragp
, asection
*sec
, int bits
, long stretch
)
17910 /* Assume worst case for symbols not known to be in the same section. */
17911 if (!S_IS_DEFINED (fragp
->fr_symbol
)
17912 || sec
!= S_GET_SEGMENT (fragp
->fr_symbol
))
17916 if (S_IS_DEFINED (fragp
->fr_symbol
)
17917 && ARM_IS_FUNC (fragp
->fr_symbol
))
17921 val
= relaxed_symbol_addr (fragp
, stretch
);
17922 addr
= fragp
->fr_address
+ fragp
->fr_fix
+ 4;
17925 /* Offset is a signed value *2 */
17927 if (val
>= limit
|| val
< -limit
)
17933 /* Relax a machine dependent frag. This returns the amount by which
17934 the current size of the frag should change. */
17937 arm_relax_frag (asection
*sec
, fragS
*fragp
, long stretch
)
17942 oldsize
= fragp
->fr_var
;
17943 switch (fragp
->fr_subtype
)
17945 case T_MNEM_ldr_pc2
:
17946 newsize
= relax_adr (fragp
, sec
, stretch
);
17948 case T_MNEM_ldr_pc
:
17949 case T_MNEM_ldr_sp
:
17950 case T_MNEM_str_sp
:
17951 newsize
= relax_immediate (fragp
, 8, 2);
17955 newsize
= relax_immediate (fragp
, 5, 2);
17959 newsize
= relax_immediate (fragp
, 5, 1);
17963 newsize
= relax_immediate (fragp
, 5, 0);
17966 newsize
= relax_adr (fragp
, sec
, stretch
);
17972 newsize
= relax_immediate (fragp
, 8, 0);
17975 newsize
= relax_branch (fragp
, sec
, 11, stretch
);
17978 newsize
= relax_branch (fragp
, sec
, 8, stretch
);
17980 case T_MNEM_add_sp
:
17981 case T_MNEM_add_pc
:
17982 newsize
= relax_immediate (fragp
, 8, 2);
17984 case T_MNEM_inc_sp
:
17985 case T_MNEM_dec_sp
:
17986 newsize
= relax_immediate (fragp
, 7, 2);
17992 newsize
= relax_addsub (fragp
, sec
);
17998 fragp
->fr_var
= newsize
;
17999 /* Freeze wide instructions that are at or before the same location as
18000 in the previous pass. This avoids infinite loops.
18001 Don't freeze them unconditionally because targets may be artificially
18002 misaligned by the expansion of preceding frags. */
18003 if (stretch
<= 0 && newsize
> 2)
18005 md_convert_frag (sec
->owner
, sec
, fragp
);
18009 return newsize
- oldsize
;
18012 /* Round up a section size to the appropriate boundary. */
18015 md_section_align (segT segment ATTRIBUTE_UNUSED
,
18018 #if (defined (OBJ_AOUT) || defined (OBJ_MAYBE_AOUT))
18019 if (OUTPUT_FLAVOR
== bfd_target_aout_flavour
)
18021 /* For a.out, force the section size to be aligned. If we don't do
18022 this, BFD will align it for us, but it will not write out the
18023 final bytes of the section. This may be a bug in BFD, but it is
18024 easier to fix it here since that is how the other a.out targets
18028 align
= bfd_get_section_alignment (stdoutput
, segment
);
18029 size
= ((size
+ (1 << align
) - 1) & ((valueT
) -1 << align
));
18036 /* This is called from HANDLE_ALIGN in write.c. Fill in the contents
18037 of an rs_align_code fragment. */
18040 arm_handle_align (fragS
* fragP
)
18042 static char const arm_noop
[2][2][4] =
18045 {0x00, 0x00, 0xa0, 0xe1}, /* LE */
18046 {0xe1, 0xa0, 0x00, 0x00}, /* BE */
18049 {0x00, 0xf0, 0x20, 0xe3}, /* LE */
18050 {0xe3, 0x20, 0xf0, 0x00}, /* BE */
18053 static char const thumb_noop
[2][2][2] =
18056 {0xc0, 0x46}, /* LE */
18057 {0x46, 0xc0}, /* BE */
18060 {0x00, 0xbf}, /* LE */
18061 {0xbf, 0x00} /* BE */
18064 static char const wide_thumb_noop
[2][4] =
18065 { /* Wide Thumb-2 */
18066 {0xaf, 0xf3, 0x00, 0x80}, /* LE */
18067 {0xf3, 0xaf, 0x80, 0x00}, /* BE */
18070 unsigned bytes
, fix
, noop_size
;
18073 const char *narrow_noop
= NULL
;
18075 if (fragP
->fr_type
!= rs_align_code
)
18078 bytes
= fragP
->fr_next
->fr_address
- fragP
->fr_address
- fragP
->fr_fix
;
18079 p
= fragP
->fr_literal
+ fragP
->fr_fix
;
18082 if (bytes
> MAX_MEM_FOR_RS_ALIGN_CODE
)
18083 bytes
&= MAX_MEM_FOR_RS_ALIGN_CODE
;
18085 gas_assert ((fragP
->tc_frag_data
& MODE_RECORDED
) != 0);
18087 if (fragP
->tc_frag_data
& (~ MODE_RECORDED
))
18089 if (ARM_CPU_HAS_FEATURE (selected_cpu
, arm_ext_v6t2
))
18091 narrow_noop
= thumb_noop
[1][target_big_endian
];
18092 noop
= wide_thumb_noop
[target_big_endian
];
18095 noop
= thumb_noop
[0][target_big_endian
];
18100 noop
= arm_noop
[ARM_CPU_HAS_FEATURE (selected_cpu
, arm_ext_v6k
) != 0]
18101 [target_big_endian
];
18105 fragP
->fr_var
= noop_size
;
18107 if (bytes
& (noop_size
- 1))
18109 fix
= bytes
& (noop_size
- 1);
18110 memset (p
, 0, fix
);
18117 if (bytes
& noop_size
)
18119 /* Insert a narrow noop. */
18120 memcpy (p
, narrow_noop
, noop_size
);
18122 bytes
-= noop_size
;
18126 /* Use wide noops for the remainder */
18130 while (bytes
>= noop_size
)
18132 memcpy (p
, noop
, noop_size
);
18134 bytes
-= noop_size
;
18138 fragP
->fr_fix
+= fix
;
18141 /* Called from md_do_align. Used to create an alignment
18142 frag in a code section. */
18145 arm_frag_align_code (int n
, int max
)
18149 /* We assume that there will never be a requirement
18150 to support alignments greater than 32 bytes. */
18151 if (max
> MAX_MEM_FOR_RS_ALIGN_CODE
)
18152 as_fatal (_("alignments greater than 32 bytes not supported in .text sections."));
18154 p
= frag_var (rs_align_code
,
18155 MAX_MEM_FOR_RS_ALIGN_CODE
,
18157 (relax_substateT
) max
,
18164 /* Perform target specific initialisation of a frag.
18165 Note - despite the name this initialisation is not done when the frag
18166 is created, but only when its type is assigned. A frag can be created
18167 and used a long time before its type is set, so beware of assuming that
18168 this initialisationis performed first. */
18171 arm_init_frag (fragS
* fragP
)
18173 /* If the current ARM vs THUMB mode has not already
18174 been recorded into this frag then do so now. */
18175 if ((fragP
->tc_frag_data
& MODE_RECORDED
) == 0)
18176 fragP
->tc_frag_data
= thumb_mode
| MODE_RECORDED
;
18180 /* When we change sections we need to issue a new mapping symbol. */
18183 arm_elf_change_section (void)
18186 segment_info_type
*seginfo
;
18188 /* Link an unlinked unwind index table section to the .text section. */
18189 if (elf_section_type (now_seg
) == SHT_ARM_EXIDX
18190 && elf_linked_to_section (now_seg
) == NULL
)
18191 elf_linked_to_section (now_seg
) = text_section
;
18193 if (!SEG_NORMAL (now_seg
))
18196 flags
= bfd_get_section_flags (stdoutput
, now_seg
);
18198 /* We can ignore sections that only contain debug info. */
18199 if ((flags
& SEC_ALLOC
) == 0)
18202 seginfo
= seg_info (now_seg
);
18203 mapstate
= seginfo
->tc_segment_info_data
.mapstate
;
18204 marked_pr_dependency
= seginfo
->tc_segment_info_data
.marked_pr_dependency
;
18208 arm_elf_section_type (const char * str
, size_t len
)
18210 if (len
== 5 && strncmp (str
, "exidx", 5) == 0)
18211 return SHT_ARM_EXIDX
;
18216 /* Code to deal with unwinding tables. */
18218 static void add_unwind_adjustsp (offsetT
);
18220 /* Generate any deferred unwind frame offset. */
18223 flush_pending_unwind (void)
18227 offset
= unwind
.pending_offset
;
18228 unwind
.pending_offset
= 0;
18230 add_unwind_adjustsp (offset
);
18233 /* Add an opcode to this list for this function. Two-byte opcodes should
18234 be passed as op[0] << 8 | op[1]. The list of opcodes is built in reverse
18238 add_unwind_opcode (valueT op
, int length
)
18240 /* Add any deferred stack adjustment. */
18241 if (unwind
.pending_offset
)
18242 flush_pending_unwind ();
18244 unwind
.sp_restored
= 0;
18246 if (unwind
.opcode_count
+ length
> unwind
.opcode_alloc
)
18248 unwind
.opcode_alloc
+= ARM_OPCODE_CHUNK_SIZE
;
18249 if (unwind
.opcodes
)
18250 unwind
.opcodes
= xrealloc (unwind
.opcodes
,
18251 unwind
.opcode_alloc
);
18253 unwind
.opcodes
= xmalloc (unwind
.opcode_alloc
);
18258 unwind
.opcodes
[unwind
.opcode_count
] = op
& 0xff;
18260 unwind
.opcode_count
++;
18264 /* Add unwind opcodes to adjust the stack pointer. */
18267 add_unwind_adjustsp (offsetT offset
)
18271 if (offset
> 0x200)
18273 /* We need at most 5 bytes to hold a 32-bit value in a uleb128. */
18278 /* Long form: 0xb2, uleb128. */
18279 /* This might not fit in a word so add the individual bytes,
18280 remembering the list is built in reverse order. */
18281 o
= (valueT
) ((offset
- 0x204) >> 2);
18283 add_unwind_opcode (0, 1);
18285 /* Calculate the uleb128 encoding of the offset. */
18289 bytes
[n
] = o
& 0x7f;
18295 /* Add the insn. */
18297 add_unwind_opcode (bytes
[n
- 1], 1);
18298 add_unwind_opcode (0xb2, 1);
18300 else if (offset
> 0x100)
18302 /* Two short opcodes. */
18303 add_unwind_opcode (0x3f, 1);
18304 op
= (offset
- 0x104) >> 2;
18305 add_unwind_opcode (op
, 1);
18307 else if (offset
> 0)
18309 /* Short opcode. */
18310 op
= (offset
- 4) >> 2;
18311 add_unwind_opcode (op
, 1);
18313 else if (offset
< 0)
18316 while (offset
> 0x100)
18318 add_unwind_opcode (0x7f, 1);
18321 op
= ((offset
- 4) >> 2) | 0x40;
18322 add_unwind_opcode (op
, 1);
18326 /* Finish the list of unwind opcodes for this function. */
18328 finish_unwind_opcodes (void)
18332 if (unwind
.fp_used
)
18334 /* Adjust sp as necessary. */
18335 unwind
.pending_offset
+= unwind
.fp_offset
- unwind
.frame_size
;
18336 flush_pending_unwind ();
18338 /* After restoring sp from the frame pointer. */
18339 op
= 0x90 | unwind
.fp_reg
;
18340 add_unwind_opcode (op
, 1);
18343 flush_pending_unwind ();
18347 /* Start an exception table entry. If idx is nonzero this is an index table
18351 start_unwind_section (const segT text_seg
, int idx
)
18353 const char * text_name
;
18354 const char * prefix
;
18355 const char * prefix_once
;
18356 const char * group_name
;
18360 size_t sec_name_len
;
18367 prefix
= ELF_STRING_ARM_unwind
;
18368 prefix_once
= ELF_STRING_ARM_unwind_once
;
18369 type
= SHT_ARM_EXIDX
;
18373 prefix
= ELF_STRING_ARM_unwind_info
;
18374 prefix_once
= ELF_STRING_ARM_unwind_info_once
;
18375 type
= SHT_PROGBITS
;
18378 text_name
= segment_name (text_seg
);
18379 if (streq (text_name
, ".text"))
18382 if (strncmp (text_name
, ".gnu.linkonce.t.",
18383 strlen (".gnu.linkonce.t.")) == 0)
18385 prefix
= prefix_once
;
18386 text_name
+= strlen (".gnu.linkonce.t.");
18389 prefix_len
= strlen (prefix
);
18390 text_len
= strlen (text_name
);
18391 sec_name_len
= prefix_len
+ text_len
;
18392 sec_name
= xmalloc (sec_name_len
+ 1);
18393 memcpy (sec_name
, prefix
, prefix_len
);
18394 memcpy (sec_name
+ prefix_len
, text_name
, text_len
);
18395 sec_name
[prefix_len
+ text_len
] = '\0';
18401 /* Handle COMDAT group. */
18402 if (prefix
!= prefix_once
&& (text_seg
->flags
& SEC_LINK_ONCE
) != 0)
18404 group_name
= elf_group_name (text_seg
);
18405 if (group_name
== NULL
)
18407 as_bad (_("Group section `%s' has no group signature"),
18408 segment_name (text_seg
));
18409 ignore_rest_of_line ();
18412 flags
|= SHF_GROUP
;
18416 obj_elf_change_section (sec_name
, type
, flags
, 0, group_name
, linkonce
, 0);
18418 /* Set the section link for index tables. */
18420 elf_linked_to_section (now_seg
) = text_seg
;
18424 /* Start an unwind table entry. HAVE_DATA is nonzero if we have additional
18425 personality routine data. Returns zero, or the index table value for
18426 and inline entry. */
18429 create_unwind_entry (int have_data
)
18434 /* The current word of data. */
18436 /* The number of bytes left in this word. */
18439 finish_unwind_opcodes ();
18441 /* Remember the current text section. */
18442 unwind
.saved_seg
= now_seg
;
18443 unwind
.saved_subseg
= now_subseg
;
18445 start_unwind_section (now_seg
, 0);
18447 if (unwind
.personality_routine
== NULL
)
18449 if (unwind
.personality_index
== -2)
18452 as_bad (_("handlerdata in cantunwind frame"));
18453 return 1; /* EXIDX_CANTUNWIND. */
18456 /* Use a default personality routine if none is specified. */
18457 if (unwind
.personality_index
== -1)
18459 if (unwind
.opcode_count
> 3)
18460 unwind
.personality_index
= 1;
18462 unwind
.personality_index
= 0;
18465 /* Space for the personality routine entry. */
18466 if (unwind
.personality_index
== 0)
18468 if (unwind
.opcode_count
> 3)
18469 as_bad (_("too many unwind opcodes for personality routine 0"));
18473 /* All the data is inline in the index table. */
18476 while (unwind
.opcode_count
> 0)
18478 unwind
.opcode_count
--;
18479 data
= (data
<< 8) | unwind
.opcodes
[unwind
.opcode_count
];
18483 /* Pad with "finish" opcodes. */
18485 data
= (data
<< 8) | 0xb0;
18492 /* We get two opcodes "free" in the first word. */
18493 size
= unwind
.opcode_count
- 2;
18496 /* An extra byte is required for the opcode count. */
18497 size
= unwind
.opcode_count
+ 1;
18499 size
= (size
+ 3) >> 2;
18501 as_bad (_("too many unwind opcodes"));
18503 frag_align (2, 0, 0);
18504 record_alignment (now_seg
, 2);
18505 unwind
.table_entry
= expr_build_dot ();
18507 /* Allocate the table entry. */
18508 ptr
= frag_more ((size
<< 2) + 4);
18509 where
= frag_now_fix () - ((size
<< 2) + 4);
18511 switch (unwind
.personality_index
)
18514 /* ??? Should this be a PLT generating relocation? */
18515 /* Custom personality routine. */
18516 fix_new (frag_now
, where
, 4, unwind
.personality_routine
, 0, 1,
18517 BFD_RELOC_ARM_PREL31
);
18522 /* Set the first byte to the number of additional words. */
18527 /* ABI defined personality routines. */
18529 /* Three opcodes bytes are packed into the first word. */
18536 /* The size and first two opcode bytes go in the first word. */
18537 data
= ((0x80 + unwind
.personality_index
) << 8) | size
;
18542 /* Should never happen. */
18546 /* Pack the opcodes into words (MSB first), reversing the list at the same
18548 while (unwind
.opcode_count
> 0)
18552 md_number_to_chars (ptr
, data
, 4);
18557 unwind
.opcode_count
--;
18559 data
= (data
<< 8) | unwind
.opcodes
[unwind
.opcode_count
];
18562 /* Finish off the last word. */
18565 /* Pad with "finish" opcodes. */
18567 data
= (data
<< 8) | 0xb0;
18569 md_number_to_chars (ptr
, data
, 4);
18574 /* Add an empty descriptor if there is no user-specified data. */
18575 ptr
= frag_more (4);
18576 md_number_to_chars (ptr
, 0, 4);
18583 /* Initialize the DWARF-2 unwind information for this procedure. */
18586 tc_arm_frame_initial_instructions (void)
18588 cfi_add_CFA_def_cfa (REG_SP
, 0);
18590 #endif /* OBJ_ELF */
18592 /* Convert REGNAME to a DWARF-2 register number. */
18595 tc_arm_regname_to_dw2regnum (char *regname
)
18597 int reg
= arm_reg_parse (®name
, REG_TYPE_RN
);
18607 tc_pe_dwarf2_emit_offset (symbolS
*symbol
, unsigned int size
)
18611 expr
.X_op
= O_secrel
;
18612 expr
.X_add_symbol
= symbol
;
18613 expr
.X_add_number
= 0;
18614 emit_expr (&expr
, size
);
18618 /* MD interface: Symbol and relocation handling. */
18620 /* Return the address within the segment that a PC-relative fixup is
18621 relative to. For ARM, PC-relative fixups applied to instructions
18622 are generally relative to the location of the fixup plus 8 bytes.
18623 Thumb branches are offset by 4, and Thumb loads relative to PC
18624 require special handling. */
18627 md_pcrel_from_section (fixS
* fixP
, segT seg
)
18629 offsetT base
= fixP
->fx_where
+ fixP
->fx_frag
->fr_address
;
18631 /* If this is pc-relative and we are going to emit a relocation
18632 then we just want to put out any pipeline compensation that the linker
18633 will need. Otherwise we want to use the calculated base.
18634 For WinCE we skip the bias for externals as well, since this
18635 is how the MS ARM-CE assembler behaves and we want to be compatible. */
18637 && ((fixP
->fx_addsy
&& S_GET_SEGMENT (fixP
->fx_addsy
) != seg
)
18638 || (arm_force_relocation (fixP
)
18640 && !S_IS_EXTERNAL (fixP
->fx_addsy
)
18646 switch (fixP
->fx_r_type
)
18648 /* PC relative addressing on the Thumb is slightly odd as the
18649 bottom two bits of the PC are forced to zero for the
18650 calculation. This happens *after* application of the
18651 pipeline offset. However, Thumb adrl already adjusts for
18652 this, so we need not do it again. */
18653 case BFD_RELOC_ARM_THUMB_ADD
:
18656 case BFD_RELOC_ARM_THUMB_OFFSET
:
18657 case BFD_RELOC_ARM_T32_OFFSET_IMM
:
18658 case BFD_RELOC_ARM_T32_ADD_PC12
:
18659 case BFD_RELOC_ARM_T32_CP_OFF_IMM
:
18660 return (base
+ 4) & ~3;
18662 /* Thumb branches are simply offset by +4. */
18663 case BFD_RELOC_THUMB_PCREL_BRANCH7
:
18664 case BFD_RELOC_THUMB_PCREL_BRANCH9
:
18665 case BFD_RELOC_THUMB_PCREL_BRANCH12
:
18666 case BFD_RELOC_THUMB_PCREL_BRANCH20
:
18667 case BFD_RELOC_THUMB_PCREL_BRANCH25
:
18670 case BFD_RELOC_THUMB_PCREL_BRANCH23
:
18672 && ARM_IS_FUNC (fixP
->fx_addsy
)
18673 && ARM_CPU_HAS_FEATURE (selected_cpu
, arm_ext_v5t
))
18674 base
= fixP
->fx_where
+ fixP
->fx_frag
->fr_address
;
18677 /* BLX is like branches above, but forces the low two bits of PC to
18679 case BFD_RELOC_THUMB_PCREL_BLX
:
18681 && THUMB_IS_FUNC (fixP
->fx_addsy
)
18682 && ARM_CPU_HAS_FEATURE (selected_cpu
, arm_ext_v5t
))
18683 base
= fixP
->fx_where
+ fixP
->fx_frag
->fr_address
;
18684 return (base
+ 4) & ~3;
18686 /* ARM mode branches are offset by +8. However, the Windows CE
18687 loader expects the relocation not to take this into account. */
18688 case BFD_RELOC_ARM_PCREL_BLX
:
18690 && ARM_IS_FUNC (fixP
->fx_addsy
)
18691 && ARM_CPU_HAS_FEATURE (selected_cpu
, arm_ext_v5t
))
18692 base
= fixP
->fx_where
+ fixP
->fx_frag
->fr_address
;
18695 case BFD_RELOC_ARM_PCREL_CALL
:
18697 && THUMB_IS_FUNC (fixP
->fx_addsy
)
18698 && ARM_CPU_HAS_FEATURE (selected_cpu
, arm_ext_v5t
))
18699 base
= fixP
->fx_where
+ fixP
->fx_frag
->fr_address
;
18702 case BFD_RELOC_ARM_PCREL_BRANCH
:
18703 case BFD_RELOC_ARM_PCREL_JUMP
:
18704 case BFD_RELOC_ARM_PLT32
:
18706 /* When handling fixups immediately, because we have already
18707 discovered the value of a symbol, or the address of the frag involved
18708 we must account for the offset by +8, as the OS loader will never see the reloc.
18709 see fixup_segment() in write.c
18710 The S_IS_EXTERNAL test handles the case of global symbols.
18711 Those need the calculated base, not just the pipe compensation the linker will need. */
18713 && fixP
->fx_addsy
!= NULL
18714 && (S_GET_SEGMENT (fixP
->fx_addsy
) == seg
)
18715 && (S_IS_EXTERNAL (fixP
->fx_addsy
) || !arm_force_relocation (fixP
)))
18723 /* ARM mode loads relative to PC are also offset by +8. Unlike
18724 branches, the Windows CE loader *does* expect the relocation
18725 to take this into account. */
18726 case BFD_RELOC_ARM_OFFSET_IMM
:
18727 case BFD_RELOC_ARM_OFFSET_IMM8
:
18728 case BFD_RELOC_ARM_HWLITERAL
:
18729 case BFD_RELOC_ARM_LITERAL
:
18730 case BFD_RELOC_ARM_CP_OFF_IMM
:
18734 /* Other PC-relative relocations are un-offset. */
18740 /* Under ELF we need to default _GLOBAL_OFFSET_TABLE.
18741 Otherwise we have no need to default values of symbols. */
18744 md_undefined_symbol (char * name ATTRIBUTE_UNUSED
)
18747 if (name
[0] == '_' && name
[1] == 'G'
18748 && streq (name
, GLOBAL_OFFSET_TABLE_NAME
))
18752 if (symbol_find (name
))
18753 as_bad (_("GOT already in the symbol table"));
18755 GOT_symbol
= symbol_new (name
, undefined_section
,
18756 (valueT
) 0, & zero_address_frag
);
18766 /* Subroutine of md_apply_fix. Check to see if an immediate can be
18767 computed as two separate immediate values, added together. We
18768 already know that this value cannot be computed by just one ARM
18771 static unsigned int
18772 validate_immediate_twopart (unsigned int val
,
18773 unsigned int * highpart
)
18778 for (i
= 0; i
< 32; i
+= 2)
18779 if (((a
= rotate_left (val
, i
)) & 0xff) != 0)
18785 * highpart
= (a
>> 8) | ((i
+ 24) << 7);
18787 else if (a
& 0xff0000)
18789 if (a
& 0xff000000)
18791 * highpart
= (a
>> 16) | ((i
+ 16) << 7);
18795 gas_assert (a
& 0xff000000);
18796 * highpart
= (a
>> 24) | ((i
+ 8) << 7);
18799 return (a
& 0xff) | (i
<< 7);
18806 validate_offset_imm (unsigned int val
, int hwse
)
18808 if ((hwse
&& val
> 255) || val
> 4095)
18813 /* Subroutine of md_apply_fix. Do those data_ops which can take a
18814 negative immediate constant by altering the instruction. A bit of
18819 by inverting the second operand, and
18822 by negating the second operand. */
18825 negate_data_op (unsigned long * instruction
,
18826 unsigned long value
)
18829 unsigned long negated
, inverted
;
18831 negated
= encode_arm_immediate (-value
);
18832 inverted
= encode_arm_immediate (~value
);
18834 op
= (*instruction
>> DATA_OP_SHIFT
) & 0xf;
18837 /* First negates. */
18838 case OPCODE_SUB
: /* ADD <-> SUB */
18839 new_inst
= OPCODE_ADD
;
18844 new_inst
= OPCODE_SUB
;
18848 case OPCODE_CMP
: /* CMP <-> CMN */
18849 new_inst
= OPCODE_CMN
;
18854 new_inst
= OPCODE_CMP
;
18858 /* Now Inverted ops. */
18859 case OPCODE_MOV
: /* MOV <-> MVN */
18860 new_inst
= OPCODE_MVN
;
18865 new_inst
= OPCODE_MOV
;
18869 case OPCODE_AND
: /* AND <-> BIC */
18870 new_inst
= OPCODE_BIC
;
18875 new_inst
= OPCODE_AND
;
18879 case OPCODE_ADC
: /* ADC <-> SBC */
18880 new_inst
= OPCODE_SBC
;
18885 new_inst
= OPCODE_ADC
;
18889 /* We cannot do anything. */
18894 if (value
== (unsigned) FAIL
)
18897 *instruction
&= OPCODE_MASK
;
18898 *instruction
|= new_inst
<< DATA_OP_SHIFT
;
18902 /* Like negate_data_op, but for Thumb-2. */
18904 static unsigned int
18905 thumb32_negate_data_op (offsetT
*instruction
, unsigned int value
)
18909 unsigned int negated
, inverted
;
18911 negated
= encode_thumb32_immediate (-value
);
18912 inverted
= encode_thumb32_immediate (~value
);
18914 rd
= (*instruction
>> 8) & 0xf;
18915 op
= (*instruction
>> T2_DATA_OP_SHIFT
) & 0xf;
18918 /* ADD <-> SUB. Includes CMP <-> CMN. */
18919 case T2_OPCODE_SUB
:
18920 new_inst
= T2_OPCODE_ADD
;
18924 case T2_OPCODE_ADD
:
18925 new_inst
= T2_OPCODE_SUB
;
18929 /* ORR <-> ORN. Includes MOV <-> MVN. */
18930 case T2_OPCODE_ORR
:
18931 new_inst
= T2_OPCODE_ORN
;
18935 case T2_OPCODE_ORN
:
18936 new_inst
= T2_OPCODE_ORR
;
18940 /* AND <-> BIC. TST has no inverted equivalent. */
18941 case T2_OPCODE_AND
:
18942 new_inst
= T2_OPCODE_BIC
;
18949 case T2_OPCODE_BIC
:
18950 new_inst
= T2_OPCODE_AND
;
18955 case T2_OPCODE_ADC
:
18956 new_inst
= T2_OPCODE_SBC
;
18960 case T2_OPCODE_SBC
:
18961 new_inst
= T2_OPCODE_ADC
;
18965 /* We cannot do anything. */
18970 if (value
== (unsigned int)FAIL
)
18973 *instruction
&= T2_OPCODE_MASK
;
18974 *instruction
|= new_inst
<< T2_DATA_OP_SHIFT
;
18978 /* Read a 32-bit thumb instruction from buf. */
18979 static unsigned long
18980 get_thumb32_insn (char * buf
)
18982 unsigned long insn
;
18983 insn
= md_chars_to_number (buf
, THUMB_SIZE
) << 16;
18984 insn
|= md_chars_to_number (buf
+ THUMB_SIZE
, THUMB_SIZE
);
18990 /* We usually want to set the low bit on the address of thumb function
18991 symbols. In particular .word foo - . should have the low bit set.
18992 Generic code tries to fold the difference of two symbols to
18993 a constant. Prevent this and force a relocation when the first symbols
18994 is a thumb function. */
18996 arm_optimize_expr (expressionS
*l
, operatorT op
, expressionS
*r
)
18998 if (op
== O_subtract
18999 && l
->X_op
== O_symbol
19000 && r
->X_op
== O_symbol
19001 && THUMB_IS_FUNC (l
->X_add_symbol
))
19003 l
->X_op
= O_subtract
;
19004 l
->X_op_symbol
= r
->X_add_symbol
;
19005 l
->X_add_number
-= r
->X_add_number
;
19008 /* Process as normal. */
19013 md_apply_fix (fixS
* fixP
,
19017 offsetT value
= * valP
;
19019 unsigned int newimm
;
19020 unsigned long temp
;
19022 char * buf
= fixP
->fx_where
+ fixP
->fx_frag
->fr_literal
;
19024 gas_assert (fixP
->fx_r_type
<= BFD_RELOC_UNUSED
);
19026 /* Note whether this will delete the relocation. */
19028 if (fixP
->fx_addsy
== 0 && !fixP
->fx_pcrel
)
19031 /* On a 64-bit host, silently truncate 'value' to 32 bits for
19032 consistency with the behaviour on 32-bit hosts. Remember value
19034 value
&= 0xffffffff;
19035 value
^= 0x80000000;
19036 value
-= 0x80000000;
19039 fixP
->fx_addnumber
= value
;
19041 /* Same treatment for fixP->fx_offset. */
19042 fixP
->fx_offset
&= 0xffffffff;
19043 fixP
->fx_offset
^= 0x80000000;
19044 fixP
->fx_offset
-= 0x80000000;
19046 switch (fixP
->fx_r_type
)
19048 case BFD_RELOC_NONE
:
19049 /* This will need to go in the object file. */
19053 case BFD_RELOC_ARM_IMMEDIATE
:
19054 /* We claim that this fixup has been processed here,
19055 even if in fact we generate an error because we do
19056 not have a reloc for it, so tc_gen_reloc will reject it. */
19060 && ! S_IS_DEFINED (fixP
->fx_addsy
))
19062 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
19063 _("undefined symbol %s used as an immediate value"),
19064 S_GET_NAME (fixP
->fx_addsy
));
19069 && S_GET_SEGMENT (fixP
->fx_addsy
) != seg
)
19071 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
19072 _("symbol %s is in a different section"),
19073 S_GET_NAME (fixP
->fx_addsy
));
19077 newimm
= encode_arm_immediate (value
);
19078 temp
= md_chars_to_number (buf
, INSN_SIZE
);
19080 /* If the instruction will fail, see if we can fix things up by
19081 changing the opcode. */
19082 if (newimm
== (unsigned int) FAIL
19083 && (newimm
= negate_data_op (&temp
, value
)) == (unsigned int) FAIL
)
19085 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
19086 _("invalid constant (%lx) after fixup"),
19087 (unsigned long) value
);
19091 newimm
|= (temp
& 0xfffff000);
19092 md_number_to_chars (buf
, (valueT
) newimm
, INSN_SIZE
);
19095 case BFD_RELOC_ARM_ADRL_IMMEDIATE
:
19097 unsigned int highpart
= 0;
19098 unsigned int newinsn
= 0xe1a00000; /* nop. */
19101 && ! S_IS_DEFINED (fixP
->fx_addsy
))
19103 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
19104 _("undefined symbol %s used as an immediate value"),
19105 S_GET_NAME (fixP
->fx_addsy
));
19110 && S_GET_SEGMENT (fixP
->fx_addsy
) != seg
)
19112 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
19113 _("symbol %s is in a different section"),
19114 S_GET_NAME (fixP
->fx_addsy
));
19118 newimm
= encode_arm_immediate (value
);
19119 temp
= md_chars_to_number (buf
, INSN_SIZE
);
19121 /* If the instruction will fail, see if we can fix things up by
19122 changing the opcode. */
19123 if (newimm
== (unsigned int) FAIL
19124 && (newimm
= negate_data_op (& temp
, value
)) == (unsigned int) FAIL
)
19126 /* No ? OK - try using two ADD instructions to generate
19128 newimm
= validate_immediate_twopart (value
, & highpart
);
19130 /* Yes - then make sure that the second instruction is
19132 if (newimm
!= (unsigned int) FAIL
)
19134 /* Still No ? Try using a negated value. */
19135 else if ((newimm
= validate_immediate_twopart (- value
, & highpart
)) != (unsigned int) FAIL
)
19136 temp
= newinsn
= (temp
& OPCODE_MASK
) | OPCODE_SUB
<< DATA_OP_SHIFT
;
19137 /* Otherwise - give up. */
19140 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
19141 _("unable to compute ADRL instructions for PC offset of 0x%lx"),
19146 /* Replace the first operand in the 2nd instruction (which
19147 is the PC) with the destination register. We have
19148 already added in the PC in the first instruction and we
19149 do not want to do it again. */
19150 newinsn
&= ~ 0xf0000;
19151 newinsn
|= ((newinsn
& 0x0f000) << 4);
19154 newimm
|= (temp
& 0xfffff000);
19155 md_number_to_chars (buf
, (valueT
) newimm
, INSN_SIZE
);
19157 highpart
|= (newinsn
& 0xfffff000);
19158 md_number_to_chars (buf
+ INSN_SIZE
, (valueT
) highpart
, INSN_SIZE
);
19162 case BFD_RELOC_ARM_OFFSET_IMM
:
19163 if (!fixP
->fx_done
&& seg
->use_rela_p
)
19166 case BFD_RELOC_ARM_LITERAL
:
19172 if (validate_offset_imm (value
, 0) == FAIL
)
19174 if (fixP
->fx_r_type
== BFD_RELOC_ARM_LITERAL
)
19175 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
19176 _("invalid literal constant: pool needs to be closer"));
19178 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
19179 _("bad immediate value for offset (%ld)"),
19184 newval
= md_chars_to_number (buf
, INSN_SIZE
);
19185 newval
&= 0xff7ff000;
19186 newval
|= value
| (sign
? INDEX_UP
: 0);
19187 md_number_to_chars (buf
, newval
, INSN_SIZE
);
19190 case BFD_RELOC_ARM_OFFSET_IMM8
:
19191 case BFD_RELOC_ARM_HWLITERAL
:
19197 if (validate_offset_imm (value
, 1) == FAIL
)
19199 if (fixP
->fx_r_type
== BFD_RELOC_ARM_HWLITERAL
)
19200 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
19201 _("invalid literal constant: pool needs to be closer"));
19203 as_bad (_("bad immediate value for 8-bit offset (%ld)"),
19208 newval
= md_chars_to_number (buf
, INSN_SIZE
);
19209 newval
&= 0xff7ff0f0;
19210 newval
|= ((value
>> 4) << 8) | (value
& 0xf) | (sign
? INDEX_UP
: 0);
19211 md_number_to_chars (buf
, newval
, INSN_SIZE
);
19214 case BFD_RELOC_ARM_T32_OFFSET_U8
:
19215 if (value
< 0 || value
> 1020 || value
% 4 != 0)
19216 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
19217 _("bad immediate value for offset (%ld)"), (long) value
);
19220 newval
= md_chars_to_number (buf
+2, THUMB_SIZE
);
19222 md_number_to_chars (buf
+2, newval
, THUMB_SIZE
);
19225 case BFD_RELOC_ARM_T32_OFFSET_IMM
:
19226 /* This is a complicated relocation used for all varieties of Thumb32
19227 load/store instruction with immediate offset:
19229 1110 100P u1WL NNNN XXXX YYYY iiii iiii - +/-(U) pre/post(P) 8-bit,
19230 *4, optional writeback(W)
19231 (doubleword load/store)
19233 1111 100S uTTL 1111 XXXX iiii iiii iiii - +/-(U) 12-bit PC-rel
19234 1111 100S 0TTL NNNN XXXX 1Pu1 iiii iiii - +/-(U) pre/post(P) 8-bit
19235 1111 100S 0TTL NNNN XXXX 1110 iiii iiii - positive 8-bit (T instruction)
19236 1111 100S 1TTL NNNN XXXX iiii iiii iiii - positive 12-bit
19237 1111 100S 0TTL NNNN XXXX 1100 iiii iiii - negative 8-bit
19239 Uppercase letters indicate bits that are already encoded at
19240 this point. Lowercase letters are our problem. For the
19241 second block of instructions, the secondary opcode nybble
19242 (bits 8..11) is present, and bit 23 is zero, even if this is
19243 a PC-relative operation. */
19244 newval
= md_chars_to_number (buf
, THUMB_SIZE
);
19246 newval
|= md_chars_to_number (buf
+THUMB_SIZE
, THUMB_SIZE
);
19248 if ((newval
& 0xf0000000) == 0xe0000000)
19250 /* Doubleword load/store: 8-bit offset, scaled by 4. */
19252 newval
|= (1 << 23);
19255 if (value
% 4 != 0)
19257 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
19258 _("offset not a multiple of 4"));
19264 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
19265 _("offset out of range"));
19270 else if ((newval
& 0x000f0000) == 0x000f0000)
19272 /* PC-relative, 12-bit offset. */
19274 newval
|= (1 << 23);
19279 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
19280 _("offset out of range"));
19285 else if ((newval
& 0x00000100) == 0x00000100)
19287 /* Writeback: 8-bit, +/- offset. */
19289 newval
|= (1 << 9);
19294 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
19295 _("offset out of range"));
19300 else if ((newval
& 0x00000f00) == 0x00000e00)
19302 /* T-instruction: positive 8-bit offset. */
19303 if (value
< 0 || value
> 0xff)
19305 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
19306 _("offset out of range"));
19314 /* Positive 12-bit or negative 8-bit offset. */
19318 newval
|= (1 << 23);
19328 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
19329 _("offset out of range"));
19336 md_number_to_chars (buf
, (newval
>> 16) & 0xffff, THUMB_SIZE
);
19337 md_number_to_chars (buf
+ THUMB_SIZE
, newval
& 0xffff, THUMB_SIZE
);
19340 case BFD_RELOC_ARM_SHIFT_IMM
:
19341 newval
= md_chars_to_number (buf
, INSN_SIZE
);
19342 if (((unsigned long) value
) > 32
19344 && (((newval
& 0x60) == 0) || (newval
& 0x60) == 0x60)))
19346 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
19347 _("shift expression is too large"));
19352 /* Shifts of zero must be done as lsl. */
19354 else if (value
== 32)
19356 newval
&= 0xfffff07f;
19357 newval
|= (value
& 0x1f) << 7;
19358 md_number_to_chars (buf
, newval
, INSN_SIZE
);
19361 case BFD_RELOC_ARM_T32_IMMEDIATE
:
19362 case BFD_RELOC_ARM_T32_ADD_IMM
:
19363 case BFD_RELOC_ARM_T32_IMM12
:
19364 case BFD_RELOC_ARM_T32_ADD_PC12
:
19365 /* We claim that this fixup has been processed here,
19366 even if in fact we generate an error because we do
19367 not have a reloc for it, so tc_gen_reloc will reject it. */
19371 && ! S_IS_DEFINED (fixP
->fx_addsy
))
19373 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
19374 _("undefined symbol %s used as an immediate value"),
19375 S_GET_NAME (fixP
->fx_addsy
));
19379 newval
= md_chars_to_number (buf
, THUMB_SIZE
);
19381 newval
|= md_chars_to_number (buf
+2, THUMB_SIZE
);
19384 if (fixP
->fx_r_type
== BFD_RELOC_ARM_T32_IMMEDIATE
19385 || fixP
->fx_r_type
== BFD_RELOC_ARM_T32_ADD_IMM
)
19387 newimm
= encode_thumb32_immediate (value
);
19388 if (newimm
== (unsigned int) FAIL
)
19389 newimm
= thumb32_negate_data_op (&newval
, value
);
19391 if (fixP
->fx_r_type
!= BFD_RELOC_ARM_T32_IMMEDIATE
19392 && newimm
== (unsigned int) FAIL
)
19394 /* Turn add/sum into addw/subw. */
19395 if (fixP
->fx_r_type
== BFD_RELOC_ARM_T32_ADD_IMM
)
19396 newval
= (newval
& 0xfeffffff) | 0x02000000;
19398 /* 12 bit immediate for addw/subw. */
19402 newval
^= 0x00a00000;
19405 newimm
= (unsigned int) FAIL
;
19410 if (newimm
== (unsigned int)FAIL
)
19412 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
19413 _("invalid constant (%lx) after fixup"),
19414 (unsigned long) value
);
19418 newval
|= (newimm
& 0x800) << 15;
19419 newval
|= (newimm
& 0x700) << 4;
19420 newval
|= (newimm
& 0x0ff);
19422 md_number_to_chars (buf
, (valueT
) ((newval
>> 16) & 0xffff), THUMB_SIZE
);
19423 md_number_to_chars (buf
+2, (valueT
) (newval
& 0xffff), THUMB_SIZE
);
19426 case BFD_RELOC_ARM_SMC
:
19427 if (((unsigned long) value
) > 0xffff)
19428 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
19429 _("invalid smc expression"));
19430 newval
= md_chars_to_number (buf
, INSN_SIZE
);
19431 newval
|= (value
& 0xf) | ((value
& 0xfff0) << 4);
19432 md_number_to_chars (buf
, newval
, INSN_SIZE
);
19435 case BFD_RELOC_ARM_SWI
:
19436 if (fixP
->tc_fix_data
!= 0)
19438 if (((unsigned long) value
) > 0xff)
19439 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
19440 _("invalid swi expression"));
19441 newval
= md_chars_to_number (buf
, THUMB_SIZE
);
19443 md_number_to_chars (buf
, newval
, THUMB_SIZE
);
19447 if (((unsigned long) value
) > 0x00ffffff)
19448 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
19449 _("invalid swi expression"));
19450 newval
= md_chars_to_number (buf
, INSN_SIZE
);
19452 md_number_to_chars (buf
, newval
, INSN_SIZE
);
19456 case BFD_RELOC_ARM_MULTI
:
19457 if (((unsigned long) value
) > 0xffff)
19458 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
19459 _("invalid expression in load/store multiple"));
19460 newval
= value
| md_chars_to_number (buf
, INSN_SIZE
);
19461 md_number_to_chars (buf
, newval
, INSN_SIZE
);
19465 case BFD_RELOC_ARM_PCREL_CALL
:
19467 if (ARM_CPU_HAS_FEATURE (selected_cpu
, arm_ext_v5t
)
19469 && !S_IS_EXTERNAL (fixP
->fx_addsy
)
19470 && (S_GET_SEGMENT (fixP
->fx_addsy
) == seg
)
19471 && THUMB_IS_FUNC (fixP
->fx_addsy
))
19472 /* Flip the bl to blx. This is a simple flip
19473 bit here because we generate PCREL_CALL for
19474 unconditional bls. */
19476 newval
= md_chars_to_number (buf
, INSN_SIZE
);
19477 newval
= newval
| 0x10000000;
19478 md_number_to_chars (buf
, newval
, INSN_SIZE
);
19484 goto arm_branch_common
;
19486 case BFD_RELOC_ARM_PCREL_JUMP
:
19487 if (ARM_CPU_HAS_FEATURE (selected_cpu
, arm_ext_v5t
)
19489 && !S_IS_EXTERNAL (fixP
->fx_addsy
)
19490 && (S_GET_SEGMENT (fixP
->fx_addsy
) == seg
)
19491 && THUMB_IS_FUNC (fixP
->fx_addsy
))
19493 /* This would map to a bl<cond>, b<cond>,
19494 b<always> to a Thumb function. We
19495 need to force a relocation for this particular
19497 newval
= md_chars_to_number (buf
, INSN_SIZE
);
19501 case BFD_RELOC_ARM_PLT32
:
19503 case BFD_RELOC_ARM_PCREL_BRANCH
:
19505 goto arm_branch_common
;
19507 case BFD_RELOC_ARM_PCREL_BLX
:
19510 if (ARM_CPU_HAS_FEATURE (selected_cpu
, arm_ext_v5t
)
19512 && !S_IS_EXTERNAL (fixP
->fx_addsy
)
19513 && (S_GET_SEGMENT (fixP
->fx_addsy
) == seg
)
19514 && ARM_IS_FUNC (fixP
->fx_addsy
))
19516 /* Flip the blx to a bl and warn. */
19517 const char *name
= S_GET_NAME (fixP
->fx_addsy
);
19518 newval
= 0xeb000000;
19519 as_warn_where (fixP
->fx_file
, fixP
->fx_line
,
19520 _("blx to '%s' an ARM ISA state function changed to bl"),
19522 md_number_to_chars (buf
, newval
, INSN_SIZE
);
19528 if (EF_ARM_EABI_VERSION (meabi_flags
) >= EF_ARM_EABI_VER4
)
19529 fixP
->fx_r_type
= BFD_RELOC_ARM_PCREL_CALL
;
19533 /* We are going to store value (shifted right by two) in the
19534 instruction, in a 24 bit, signed field. Bits 26 through 32 either
19535 all clear or all set and bit 0 must be clear. For B/BL bit 1 must
19536 also be be clear. */
19538 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
19539 _("misaligned branch destination"));
19540 if ((value
& (offsetT
)0xfe000000) != (offsetT
)0
19541 && (value
& (offsetT
)0xfe000000) != (offsetT
)0xfe000000)
19542 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
19543 _("branch out of range"));
19545 if (fixP
->fx_done
|| !seg
->use_rela_p
)
19547 newval
= md_chars_to_number (buf
, INSN_SIZE
);
19548 newval
|= (value
>> 2) & 0x00ffffff;
19549 /* Set the H bit on BLX instructions. */
19553 newval
|= 0x01000000;
19555 newval
&= ~0x01000000;
19557 md_number_to_chars (buf
, newval
, INSN_SIZE
);
19561 case BFD_RELOC_THUMB_PCREL_BRANCH7
: /* CBZ */
19562 /* CBZ can only branch forward. */
19564 /* Attempts to use CBZ to branch to the next instruction
19565 (which, strictly speaking, are prohibited) will be turned into
19568 FIXME: It may be better to remove the instruction completely and
19569 perform relaxation. */
19572 newval
= md_chars_to_number (buf
, THUMB_SIZE
);
19573 newval
= 0xbf00; /* NOP encoding T1 */
19574 md_number_to_chars (buf
, newval
, THUMB_SIZE
);
19579 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
19580 _("branch out of range"));
19582 if (fixP
->fx_done
|| !seg
->use_rela_p
)
19584 newval
= md_chars_to_number (buf
, THUMB_SIZE
);
19585 newval
|= ((value
& 0x3e) << 2) | ((value
& 0x40) << 3);
19586 md_number_to_chars (buf
, newval
, THUMB_SIZE
);
19591 case BFD_RELOC_THUMB_PCREL_BRANCH9
: /* Conditional branch. */
19592 if ((value
& ~0xff) && ((value
& ~0xff) != ~0xff))
19593 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
19594 _("branch out of range"));
19596 if (fixP
->fx_done
|| !seg
->use_rela_p
)
19598 newval
= md_chars_to_number (buf
, THUMB_SIZE
);
19599 newval
|= (value
& 0x1ff) >> 1;
19600 md_number_to_chars (buf
, newval
, THUMB_SIZE
);
19604 case BFD_RELOC_THUMB_PCREL_BRANCH12
: /* Unconditional branch. */
19605 if ((value
& ~0x7ff) && ((value
& ~0x7ff) != ~0x7ff))
19606 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
19607 _("branch out of range"));
19609 if (fixP
->fx_done
|| !seg
->use_rela_p
)
19611 newval
= md_chars_to_number (buf
, THUMB_SIZE
);
19612 newval
|= (value
& 0xfff) >> 1;
19613 md_number_to_chars (buf
, newval
, THUMB_SIZE
);
19617 case BFD_RELOC_THUMB_PCREL_BRANCH20
:
19619 && (S_GET_SEGMENT (fixP
->fx_addsy
) == seg
)
19620 && !S_IS_EXTERNAL (fixP
->fx_addsy
)
19621 && S_IS_DEFINED (fixP
->fx_addsy
)
19622 && ARM_IS_FUNC (fixP
->fx_addsy
)
19623 && ARM_CPU_HAS_FEATURE (selected_cpu
, arm_ext_v5t
))
19625 /* Force a relocation for a branch 20 bits wide. */
19628 if ((value
& ~0x1fffff) && ((value
& ~0x1fffff) != ~0x1fffff))
19629 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
19630 _("conditional branch out of range"));
19632 if (fixP
->fx_done
|| !seg
->use_rela_p
)
19635 addressT S
, J1
, J2
, lo
, hi
;
19637 S
= (value
& 0x00100000) >> 20;
19638 J2
= (value
& 0x00080000) >> 19;
19639 J1
= (value
& 0x00040000) >> 18;
19640 hi
= (value
& 0x0003f000) >> 12;
19641 lo
= (value
& 0x00000ffe) >> 1;
19643 newval
= md_chars_to_number (buf
, THUMB_SIZE
);
19644 newval2
= md_chars_to_number (buf
+ THUMB_SIZE
, THUMB_SIZE
);
19645 newval
|= (S
<< 10) | hi
;
19646 newval2
|= (J1
<< 13) | (J2
<< 11) | lo
;
19647 md_number_to_chars (buf
, newval
, THUMB_SIZE
);
19648 md_number_to_chars (buf
+ THUMB_SIZE
, newval2
, THUMB_SIZE
);
19652 case BFD_RELOC_THUMB_PCREL_BLX
:
19654 /* If there is a blx from a thumb state function to
19655 another thumb function flip this to a bl and warn
19659 && S_IS_DEFINED (fixP
->fx_addsy
)
19660 && !S_IS_EXTERNAL (fixP
->fx_addsy
)
19661 && (S_GET_SEGMENT (fixP
->fx_addsy
) == seg
)
19662 && THUMB_IS_FUNC (fixP
->fx_addsy
))
19664 const char *name
= S_GET_NAME (fixP
->fx_addsy
);
19665 as_warn_where (fixP
->fx_file
, fixP
->fx_line
,
19666 _("blx to Thumb func '%s' from Thumb ISA state changed to bl"),
19668 newval
= md_chars_to_number (buf
+ THUMB_SIZE
, THUMB_SIZE
);
19669 newval
= newval
| 0x1000;
19670 md_number_to_chars (buf
+THUMB_SIZE
, newval
, THUMB_SIZE
);
19671 fixP
->fx_r_type
= BFD_RELOC_THUMB_PCREL_BRANCH23
;
19676 goto thumb_bl_common
;
19678 case BFD_RELOC_THUMB_PCREL_BRANCH23
:
19680 /* A bl from Thumb state ISA to an internal ARM state function
19681 is converted to a blx. */
19683 && (S_GET_SEGMENT (fixP
->fx_addsy
) == seg
)
19684 && !S_IS_EXTERNAL (fixP
->fx_addsy
)
19685 && S_IS_DEFINED (fixP
->fx_addsy
)
19686 && ARM_IS_FUNC (fixP
->fx_addsy
)
19687 && ARM_CPU_HAS_FEATURE (selected_cpu
, arm_ext_v5t
))
19689 newval
= md_chars_to_number (buf
+ THUMB_SIZE
, THUMB_SIZE
);
19690 newval
= newval
& ~0x1000;
19691 md_number_to_chars (buf
+THUMB_SIZE
, newval
, THUMB_SIZE
);
19692 fixP
->fx_r_type
= BFD_RELOC_THUMB_PCREL_BLX
;
19699 if (EF_ARM_EABI_VERSION (meabi_flags
) >= EF_ARM_EABI_VER4
&&
19700 fixP
->fx_r_type
== BFD_RELOC_THUMB_PCREL_BLX
)
19701 fixP
->fx_r_type
= BFD_RELOC_THUMB_PCREL_BRANCH23
;
19704 if ((value
& ~0x3fffff) && ((value
& ~0x3fffff) != ~0x3fffff))
19705 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
19706 _("branch out of range"));
19708 if (fixP
->fx_r_type
== BFD_RELOC_THUMB_PCREL_BLX
)
19709 /* For a BLX instruction, make sure that the relocation is rounded up
19710 to a word boundary. This follows the semantics of the instruction
19711 which specifies that bit 1 of the target address will come from bit
19712 1 of the base address. */
19713 value
= (value
+ 1) & ~ 1;
19715 if (fixP
->fx_done
|| !seg
->use_rela_p
)
19719 newval
= md_chars_to_number (buf
, THUMB_SIZE
);
19720 newval2
= md_chars_to_number (buf
+ THUMB_SIZE
, THUMB_SIZE
);
19721 newval
|= (value
& 0x7fffff) >> 12;
19722 newval2
|= (value
& 0xfff) >> 1;
19723 md_number_to_chars (buf
, newval
, THUMB_SIZE
);
19724 md_number_to_chars (buf
+ THUMB_SIZE
, newval2
, THUMB_SIZE
);
19728 case BFD_RELOC_THUMB_PCREL_BRANCH25
:
19729 if ((value
& ~0x1ffffff) && ((value
& ~0x1ffffff) != ~0x1ffffff))
19730 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
19731 _("branch out of range"));
19733 if (fixP
->fx_done
|| !seg
->use_rela_p
)
19736 addressT S
, I1
, I2
, lo
, hi
;
19738 S
= (value
& 0x01000000) >> 24;
19739 I1
= (value
& 0x00800000) >> 23;
19740 I2
= (value
& 0x00400000) >> 22;
19741 hi
= (value
& 0x003ff000) >> 12;
19742 lo
= (value
& 0x00000ffe) >> 1;
19747 newval
= md_chars_to_number (buf
, THUMB_SIZE
);
19748 newval2
= md_chars_to_number (buf
+ THUMB_SIZE
, THUMB_SIZE
);
19749 newval
|= (S
<< 10) | hi
;
19750 newval2
|= (I1
<< 13) | (I2
<< 11) | lo
;
19751 md_number_to_chars (buf
, newval
, THUMB_SIZE
);
19752 md_number_to_chars (buf
+ THUMB_SIZE
, newval2
, THUMB_SIZE
);
19757 if (fixP
->fx_done
|| !seg
->use_rela_p
)
19758 md_number_to_chars (buf
, value
, 1);
19762 if (fixP
->fx_done
|| !seg
->use_rela_p
)
19763 md_number_to_chars (buf
, value
, 2);
19767 case BFD_RELOC_ARM_TLS_GD32
:
19768 case BFD_RELOC_ARM_TLS_LE32
:
19769 case BFD_RELOC_ARM_TLS_IE32
:
19770 case BFD_RELOC_ARM_TLS_LDM32
:
19771 case BFD_RELOC_ARM_TLS_LDO32
:
19772 S_SET_THREAD_LOCAL (fixP
->fx_addsy
);
19775 case BFD_RELOC_ARM_GOT32
:
19776 case BFD_RELOC_ARM_GOTOFF
:
19777 case BFD_RELOC_ARM_TARGET2
:
19778 if (fixP
->fx_done
|| !seg
->use_rela_p
)
19779 md_number_to_chars (buf
, 0, 4);
19783 case BFD_RELOC_RVA
:
19785 case BFD_RELOC_ARM_TARGET1
:
19786 case BFD_RELOC_ARM_ROSEGREL32
:
19787 case BFD_RELOC_ARM_SBREL32
:
19788 case BFD_RELOC_32_PCREL
:
19790 case BFD_RELOC_32_SECREL
:
19792 if (fixP
->fx_done
|| !seg
->use_rela_p
)
19794 /* For WinCE we only do this for pcrel fixups. */
19795 if (fixP
->fx_done
|| fixP
->fx_pcrel
)
19797 md_number_to_chars (buf
, value
, 4);
19801 case BFD_RELOC_ARM_PREL31
:
19802 if (fixP
->fx_done
|| !seg
->use_rela_p
)
19804 newval
= md_chars_to_number (buf
, 4) & 0x80000000;
19805 if ((value
^ (value
>> 1)) & 0x40000000)
19807 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
19808 _("rel31 relocation overflow"));
19810 newval
|= value
& 0x7fffffff;
19811 md_number_to_chars (buf
, newval
, 4);
19816 case BFD_RELOC_ARM_CP_OFF_IMM
:
19817 case BFD_RELOC_ARM_T32_CP_OFF_IMM
:
19818 if (value
< -1023 || value
> 1023 || (value
& 3))
19819 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
19820 _("co-processor offset out of range"));
19825 if (fixP
->fx_r_type
== BFD_RELOC_ARM_CP_OFF_IMM
19826 || fixP
->fx_r_type
== BFD_RELOC_ARM_CP_OFF_IMM_S2
)
19827 newval
= md_chars_to_number (buf
, INSN_SIZE
);
19829 newval
= get_thumb32_insn (buf
);
19830 newval
&= 0xff7fff00;
19831 newval
|= (value
>> 2) | (sign
? INDEX_UP
: 0);
19832 if (fixP
->fx_r_type
== BFD_RELOC_ARM_CP_OFF_IMM
19833 || fixP
->fx_r_type
== BFD_RELOC_ARM_CP_OFF_IMM_S2
)
19834 md_number_to_chars (buf
, newval
, INSN_SIZE
);
19836 put_thumb32_insn (buf
, newval
);
19839 case BFD_RELOC_ARM_CP_OFF_IMM_S2
:
19840 case BFD_RELOC_ARM_T32_CP_OFF_IMM_S2
:
19841 if (value
< -255 || value
> 255)
19842 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
19843 _("co-processor offset out of range"));
19845 goto cp_off_common
;
19847 case BFD_RELOC_ARM_THUMB_OFFSET
:
19848 newval
= md_chars_to_number (buf
, THUMB_SIZE
);
19849 /* Exactly what ranges, and where the offset is inserted depends
19850 on the type of instruction, we can establish this from the
19852 switch (newval
>> 12)
19854 case 4: /* PC load. */
19855 /* Thumb PC loads are somewhat odd, bit 1 of the PC is
19856 forced to zero for these loads; md_pcrel_from has already
19857 compensated for this. */
19859 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
19860 _("invalid offset, target not word aligned (0x%08lX)"),
19861 (((unsigned long) fixP
->fx_frag
->fr_address
19862 + (unsigned long) fixP
->fx_where
) & ~3)
19863 + (unsigned long) value
);
19865 if (value
& ~0x3fc)
19866 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
19867 _("invalid offset, value too big (0x%08lX)"),
19870 newval
|= value
>> 2;
19873 case 9: /* SP load/store. */
19874 if (value
& ~0x3fc)
19875 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
19876 _("invalid offset, value too big (0x%08lX)"),
19878 newval
|= value
>> 2;
19881 case 6: /* Word load/store. */
19883 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
19884 _("invalid offset, value too big (0x%08lX)"),
19886 newval
|= value
<< 4; /* 6 - 2. */
19889 case 7: /* Byte load/store. */
19891 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
19892 _("invalid offset, value too big (0x%08lX)"),
19894 newval
|= value
<< 6;
19897 case 8: /* Halfword load/store. */
19899 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
19900 _("invalid offset, value too big (0x%08lX)"),
19902 newval
|= value
<< 5; /* 6 - 1. */
19906 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
19907 "Unable to process relocation for thumb opcode: %lx",
19908 (unsigned long) newval
);
19911 md_number_to_chars (buf
, newval
, THUMB_SIZE
);
19914 case BFD_RELOC_ARM_THUMB_ADD
:
19915 /* This is a complicated relocation, since we use it for all of
19916 the following immediate relocations:
19920 9bit ADD/SUB SP word-aligned
19921 10bit ADD PC/SP word-aligned
19923 The type of instruction being processed is encoded in the
19930 newval
= md_chars_to_number (buf
, THUMB_SIZE
);
19932 int rd
= (newval
>> 4) & 0xf;
19933 int rs
= newval
& 0xf;
19934 int subtract
= !!(newval
& 0x8000);
19936 /* Check for HI regs, only very restricted cases allowed:
19937 Adjusting SP, and using PC or SP to get an address. */
19938 if ((rd
> 7 && (rd
!= REG_SP
|| rs
!= REG_SP
))
19939 || (rs
> 7 && rs
!= REG_SP
&& rs
!= REG_PC
))
19940 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
19941 _("invalid Hi register with immediate"));
19943 /* If value is negative, choose the opposite instruction. */
19947 subtract
= !subtract
;
19949 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
19950 _("immediate value out of range"));
19955 if (value
& ~0x1fc)
19956 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
19957 _("invalid immediate for stack address calculation"));
19958 newval
= subtract
? T_OPCODE_SUB_ST
: T_OPCODE_ADD_ST
;
19959 newval
|= value
>> 2;
19961 else if (rs
== REG_PC
|| rs
== REG_SP
)
19963 if (subtract
|| value
& ~0x3fc)
19964 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
19965 _("invalid immediate for address calculation (value = 0x%08lX)"),
19966 (unsigned long) value
);
19967 newval
= (rs
== REG_PC
? T_OPCODE_ADD_PC
: T_OPCODE_ADD_SP
);
19969 newval
|= value
>> 2;
19974 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
19975 _("immediate value out of range"));
19976 newval
= subtract
? T_OPCODE_SUB_I8
: T_OPCODE_ADD_I8
;
19977 newval
|= (rd
<< 8) | value
;
19982 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
19983 _("immediate value out of range"));
19984 newval
= subtract
? T_OPCODE_SUB_I3
: T_OPCODE_ADD_I3
;
19985 newval
|= rd
| (rs
<< 3) | (value
<< 6);
19988 md_number_to_chars (buf
, newval
, THUMB_SIZE
);
19991 case BFD_RELOC_ARM_THUMB_IMM
:
19992 newval
= md_chars_to_number (buf
, THUMB_SIZE
);
19993 if (value
< 0 || value
> 255)
19994 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
19995 _("invalid immediate: %ld is out of range"),
19998 md_number_to_chars (buf
, newval
, THUMB_SIZE
);
20001 case BFD_RELOC_ARM_THUMB_SHIFT
:
20002 /* 5bit shift value (0..32). LSL cannot take 32. */
20003 newval
= md_chars_to_number (buf
, THUMB_SIZE
) & 0xf83f;
20004 temp
= newval
& 0xf800;
20005 if (value
< 0 || value
> 32 || (value
== 32 && temp
== T_OPCODE_LSL_I
))
20006 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
20007 _("invalid shift value: %ld"), (long) value
);
20008 /* Shifts of zero must be encoded as LSL. */
20010 newval
= (newval
& 0x003f) | T_OPCODE_LSL_I
;
20011 /* Shifts of 32 are encoded as zero. */
20012 else if (value
== 32)
20014 newval
|= value
<< 6;
20015 md_number_to_chars (buf
, newval
, THUMB_SIZE
);
20018 case BFD_RELOC_VTABLE_INHERIT
:
20019 case BFD_RELOC_VTABLE_ENTRY
:
20023 case BFD_RELOC_ARM_MOVW
:
20024 case BFD_RELOC_ARM_MOVT
:
20025 case BFD_RELOC_ARM_THUMB_MOVW
:
20026 case BFD_RELOC_ARM_THUMB_MOVT
:
20027 if (fixP
->fx_done
|| !seg
->use_rela_p
)
20029 /* REL format relocations are limited to a 16-bit addend. */
20030 if (!fixP
->fx_done
)
20032 if (value
< -0x8000 || value
> 0x7fff)
20033 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
20034 _("offset out of range"));
20036 else if (fixP
->fx_r_type
== BFD_RELOC_ARM_MOVT
20037 || fixP
->fx_r_type
== BFD_RELOC_ARM_THUMB_MOVT
)
20042 if (fixP
->fx_r_type
== BFD_RELOC_ARM_THUMB_MOVW
20043 || fixP
->fx_r_type
== BFD_RELOC_ARM_THUMB_MOVT
)
20045 newval
= get_thumb32_insn (buf
);
20046 newval
&= 0xfbf08f00;
20047 newval
|= (value
& 0xf000) << 4;
20048 newval
|= (value
& 0x0800) << 15;
20049 newval
|= (value
& 0x0700) << 4;
20050 newval
|= (value
& 0x00ff);
20051 put_thumb32_insn (buf
, newval
);
20055 newval
= md_chars_to_number (buf
, 4);
20056 newval
&= 0xfff0f000;
20057 newval
|= value
& 0x0fff;
20058 newval
|= (value
& 0xf000) << 4;
20059 md_number_to_chars (buf
, newval
, 4);
20064 case BFD_RELOC_ARM_ALU_PC_G0_NC
:
20065 case BFD_RELOC_ARM_ALU_PC_G0
:
20066 case BFD_RELOC_ARM_ALU_PC_G1_NC
:
20067 case BFD_RELOC_ARM_ALU_PC_G1
:
20068 case BFD_RELOC_ARM_ALU_PC_G2
:
20069 case BFD_RELOC_ARM_ALU_SB_G0_NC
:
20070 case BFD_RELOC_ARM_ALU_SB_G0
:
20071 case BFD_RELOC_ARM_ALU_SB_G1_NC
:
20072 case BFD_RELOC_ARM_ALU_SB_G1
:
20073 case BFD_RELOC_ARM_ALU_SB_G2
:
20074 gas_assert (!fixP
->fx_done
);
20075 if (!seg
->use_rela_p
)
20078 bfd_vma encoded_addend
;
20079 bfd_vma addend_abs
= abs (value
);
20081 /* Check that the absolute value of the addend can be
20082 expressed as an 8-bit constant plus a rotation. */
20083 encoded_addend
= encode_arm_immediate (addend_abs
);
20084 if (encoded_addend
== (unsigned int) FAIL
)
20085 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
20086 _("the offset 0x%08lX is not representable"),
20087 (unsigned long) addend_abs
);
20089 /* Extract the instruction. */
20090 insn
= md_chars_to_number (buf
, INSN_SIZE
);
20092 /* If the addend is positive, use an ADD instruction.
20093 Otherwise use a SUB. Take care not to destroy the S bit. */
20094 insn
&= 0xff1fffff;
20100 /* Place the encoded addend into the first 12 bits of the
20102 insn
&= 0xfffff000;
20103 insn
|= encoded_addend
;
20105 /* Update the instruction. */
20106 md_number_to_chars (buf
, insn
, INSN_SIZE
);
20110 case BFD_RELOC_ARM_LDR_PC_G0
:
20111 case BFD_RELOC_ARM_LDR_PC_G1
:
20112 case BFD_RELOC_ARM_LDR_PC_G2
:
20113 case BFD_RELOC_ARM_LDR_SB_G0
:
20114 case BFD_RELOC_ARM_LDR_SB_G1
:
20115 case BFD_RELOC_ARM_LDR_SB_G2
:
20116 gas_assert (!fixP
->fx_done
);
20117 if (!seg
->use_rela_p
)
20120 bfd_vma addend_abs
= abs (value
);
20122 /* Check that the absolute value of the addend can be
20123 encoded in 12 bits. */
20124 if (addend_abs
>= 0x1000)
20125 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
20126 _("bad offset 0x%08lX (only 12 bits available for the magnitude)"),
20127 (unsigned long) addend_abs
);
20129 /* Extract the instruction. */
20130 insn
= md_chars_to_number (buf
, INSN_SIZE
);
20132 /* If the addend is negative, clear bit 23 of the instruction.
20133 Otherwise set it. */
20135 insn
&= ~(1 << 23);
20139 /* Place the absolute value of the addend into the first 12 bits
20140 of the instruction. */
20141 insn
&= 0xfffff000;
20142 insn
|= addend_abs
;
20144 /* Update the instruction. */
20145 md_number_to_chars (buf
, insn
, INSN_SIZE
);
20149 case BFD_RELOC_ARM_LDRS_PC_G0
:
20150 case BFD_RELOC_ARM_LDRS_PC_G1
:
20151 case BFD_RELOC_ARM_LDRS_PC_G2
:
20152 case BFD_RELOC_ARM_LDRS_SB_G0
:
20153 case BFD_RELOC_ARM_LDRS_SB_G1
:
20154 case BFD_RELOC_ARM_LDRS_SB_G2
:
20155 gas_assert (!fixP
->fx_done
);
20156 if (!seg
->use_rela_p
)
20159 bfd_vma addend_abs
= abs (value
);
20161 /* Check that the absolute value of the addend can be
20162 encoded in 8 bits. */
20163 if (addend_abs
>= 0x100)
20164 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
20165 _("bad offset 0x%08lX (only 8 bits available for the magnitude)"),
20166 (unsigned long) addend_abs
);
20168 /* Extract the instruction. */
20169 insn
= md_chars_to_number (buf
, INSN_SIZE
);
20171 /* If the addend is negative, clear bit 23 of the instruction.
20172 Otherwise set it. */
20174 insn
&= ~(1 << 23);
20178 /* Place the first four bits of the absolute value of the addend
20179 into the first 4 bits of the instruction, and the remaining
20180 four into bits 8 .. 11. */
20181 insn
&= 0xfffff0f0;
20182 insn
|= (addend_abs
& 0xf) | ((addend_abs
& 0xf0) << 4);
20184 /* Update the instruction. */
20185 md_number_to_chars (buf
, insn
, INSN_SIZE
);
20189 case BFD_RELOC_ARM_LDC_PC_G0
:
20190 case BFD_RELOC_ARM_LDC_PC_G1
:
20191 case BFD_RELOC_ARM_LDC_PC_G2
:
20192 case BFD_RELOC_ARM_LDC_SB_G0
:
20193 case BFD_RELOC_ARM_LDC_SB_G1
:
20194 case BFD_RELOC_ARM_LDC_SB_G2
:
20195 gas_assert (!fixP
->fx_done
);
20196 if (!seg
->use_rela_p
)
20199 bfd_vma addend_abs
= abs (value
);
20201 /* Check that the absolute value of the addend is a multiple of
20202 four and, when divided by four, fits in 8 bits. */
20203 if (addend_abs
& 0x3)
20204 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
20205 _("bad offset 0x%08lX (must be word-aligned)"),
20206 (unsigned long) addend_abs
);
20208 if ((addend_abs
>> 2) > 0xff)
20209 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
20210 _("bad offset 0x%08lX (must be an 8-bit number of words)"),
20211 (unsigned long) addend_abs
);
20213 /* Extract the instruction. */
20214 insn
= md_chars_to_number (buf
, INSN_SIZE
);
20216 /* If the addend is negative, clear bit 23 of the instruction.
20217 Otherwise set it. */
20219 insn
&= ~(1 << 23);
20223 /* Place the addend (divided by four) into the first eight
20224 bits of the instruction. */
20225 insn
&= 0xfffffff0;
20226 insn
|= addend_abs
>> 2;
20228 /* Update the instruction. */
20229 md_number_to_chars (buf
, insn
, INSN_SIZE
);
20233 case BFD_RELOC_ARM_V4BX
:
20234 /* This will need to go in the object file. */
20238 case BFD_RELOC_UNUSED
:
20240 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
20241 _("bad relocation fixup type (%d)"), fixP
->fx_r_type
);
20245 /* Translate internal representation of relocation info to BFD target
20249 tc_gen_reloc (asection
*section
, fixS
*fixp
)
20252 bfd_reloc_code_real_type code
;
20254 reloc
= xmalloc (sizeof (arelent
));
20256 reloc
->sym_ptr_ptr
= xmalloc (sizeof (asymbol
*));
20257 *reloc
->sym_ptr_ptr
= symbol_get_bfdsym (fixp
->fx_addsy
);
20258 reloc
->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
20260 if (fixp
->fx_pcrel
)
20262 if (section
->use_rela_p
)
20263 fixp
->fx_offset
-= md_pcrel_from_section (fixp
, section
);
20265 fixp
->fx_offset
= reloc
->address
;
20267 reloc
->addend
= fixp
->fx_offset
;
20269 switch (fixp
->fx_r_type
)
20272 if (fixp
->fx_pcrel
)
20274 code
= BFD_RELOC_8_PCREL
;
20279 if (fixp
->fx_pcrel
)
20281 code
= BFD_RELOC_16_PCREL
;
20286 if (fixp
->fx_pcrel
)
20288 code
= BFD_RELOC_32_PCREL
;
20292 case BFD_RELOC_ARM_MOVW
:
20293 if (fixp
->fx_pcrel
)
20295 code
= BFD_RELOC_ARM_MOVW_PCREL
;
20299 case BFD_RELOC_ARM_MOVT
:
20300 if (fixp
->fx_pcrel
)
20302 code
= BFD_RELOC_ARM_MOVT_PCREL
;
20306 case BFD_RELOC_ARM_THUMB_MOVW
:
20307 if (fixp
->fx_pcrel
)
20309 code
= BFD_RELOC_ARM_THUMB_MOVW_PCREL
;
20313 case BFD_RELOC_ARM_THUMB_MOVT
:
20314 if (fixp
->fx_pcrel
)
20316 code
= BFD_RELOC_ARM_THUMB_MOVT_PCREL
;
20320 case BFD_RELOC_NONE
:
20321 case BFD_RELOC_ARM_PCREL_BRANCH
:
20322 case BFD_RELOC_ARM_PCREL_BLX
:
20323 case BFD_RELOC_RVA
:
20324 case BFD_RELOC_THUMB_PCREL_BRANCH7
:
20325 case BFD_RELOC_THUMB_PCREL_BRANCH9
:
20326 case BFD_RELOC_THUMB_PCREL_BRANCH12
:
20327 case BFD_RELOC_THUMB_PCREL_BRANCH20
:
20328 case BFD_RELOC_THUMB_PCREL_BRANCH23
:
20329 case BFD_RELOC_THUMB_PCREL_BRANCH25
:
20330 case BFD_RELOC_VTABLE_ENTRY
:
20331 case BFD_RELOC_VTABLE_INHERIT
:
20333 case BFD_RELOC_32_SECREL
:
20335 code
= fixp
->fx_r_type
;
20338 case BFD_RELOC_THUMB_PCREL_BLX
:
20340 if (EF_ARM_EABI_VERSION (meabi_flags
) >= EF_ARM_EABI_VER4
)
20341 code
= BFD_RELOC_THUMB_PCREL_BRANCH23
;
20344 code
= BFD_RELOC_THUMB_PCREL_BLX
;
20347 case BFD_RELOC_ARM_LITERAL
:
20348 case BFD_RELOC_ARM_HWLITERAL
:
20349 /* If this is called then the a literal has
20350 been referenced across a section boundary. */
20351 as_bad_where (fixp
->fx_file
, fixp
->fx_line
,
20352 _("literal referenced across section boundary"));
20356 case BFD_RELOC_ARM_GOT32
:
20357 case BFD_RELOC_ARM_GOTOFF
:
20358 case BFD_RELOC_ARM_PLT32
:
20359 case BFD_RELOC_ARM_TARGET1
:
20360 case BFD_RELOC_ARM_ROSEGREL32
:
20361 case BFD_RELOC_ARM_SBREL32
:
20362 case BFD_RELOC_ARM_PREL31
:
20363 case BFD_RELOC_ARM_TARGET2
:
20364 case BFD_RELOC_ARM_TLS_LE32
:
20365 case BFD_RELOC_ARM_TLS_LDO32
:
20366 case BFD_RELOC_ARM_PCREL_CALL
:
20367 case BFD_RELOC_ARM_PCREL_JUMP
:
20368 case BFD_RELOC_ARM_ALU_PC_G0_NC
:
20369 case BFD_RELOC_ARM_ALU_PC_G0
:
20370 case BFD_RELOC_ARM_ALU_PC_G1_NC
:
20371 case BFD_RELOC_ARM_ALU_PC_G1
:
20372 case BFD_RELOC_ARM_ALU_PC_G2
:
20373 case BFD_RELOC_ARM_LDR_PC_G0
:
20374 case BFD_RELOC_ARM_LDR_PC_G1
:
20375 case BFD_RELOC_ARM_LDR_PC_G2
:
20376 case BFD_RELOC_ARM_LDRS_PC_G0
:
20377 case BFD_RELOC_ARM_LDRS_PC_G1
:
20378 case BFD_RELOC_ARM_LDRS_PC_G2
:
20379 case BFD_RELOC_ARM_LDC_PC_G0
:
20380 case BFD_RELOC_ARM_LDC_PC_G1
:
20381 case BFD_RELOC_ARM_LDC_PC_G2
:
20382 case BFD_RELOC_ARM_ALU_SB_G0_NC
:
20383 case BFD_RELOC_ARM_ALU_SB_G0
:
20384 case BFD_RELOC_ARM_ALU_SB_G1_NC
:
20385 case BFD_RELOC_ARM_ALU_SB_G1
:
20386 case BFD_RELOC_ARM_ALU_SB_G2
:
20387 case BFD_RELOC_ARM_LDR_SB_G0
:
20388 case BFD_RELOC_ARM_LDR_SB_G1
:
20389 case BFD_RELOC_ARM_LDR_SB_G2
:
20390 case BFD_RELOC_ARM_LDRS_SB_G0
:
20391 case BFD_RELOC_ARM_LDRS_SB_G1
:
20392 case BFD_RELOC_ARM_LDRS_SB_G2
:
20393 case BFD_RELOC_ARM_LDC_SB_G0
:
20394 case BFD_RELOC_ARM_LDC_SB_G1
:
20395 case BFD_RELOC_ARM_LDC_SB_G2
:
20396 case BFD_RELOC_ARM_V4BX
:
20397 code
= fixp
->fx_r_type
;
20400 case BFD_RELOC_ARM_TLS_GD32
:
20401 case BFD_RELOC_ARM_TLS_IE32
:
20402 case BFD_RELOC_ARM_TLS_LDM32
:
20403 /* BFD will include the symbol's address in the addend.
20404 But we don't want that, so subtract it out again here. */
20405 if (!S_IS_COMMON (fixp
->fx_addsy
))
20406 reloc
->addend
-= (*reloc
->sym_ptr_ptr
)->value
;
20407 code
= fixp
->fx_r_type
;
20411 case BFD_RELOC_ARM_IMMEDIATE
:
20412 as_bad_where (fixp
->fx_file
, fixp
->fx_line
,
20413 _("internal relocation (type: IMMEDIATE) not fixed up"));
20416 case BFD_RELOC_ARM_ADRL_IMMEDIATE
:
20417 as_bad_where (fixp
->fx_file
, fixp
->fx_line
,
20418 _("ADRL used for a symbol not defined in the same file"));
20421 case BFD_RELOC_ARM_OFFSET_IMM
:
20422 if (section
->use_rela_p
)
20424 code
= fixp
->fx_r_type
;
20428 if (fixp
->fx_addsy
!= NULL
20429 && !S_IS_DEFINED (fixp
->fx_addsy
)
20430 && S_IS_LOCAL (fixp
->fx_addsy
))
20432 as_bad_where (fixp
->fx_file
, fixp
->fx_line
,
20433 _("undefined local label `%s'"),
20434 S_GET_NAME (fixp
->fx_addsy
));
20438 as_bad_where (fixp
->fx_file
, fixp
->fx_line
,
20439 _("internal_relocation (type: OFFSET_IMM) not fixed up"));
20446 switch (fixp
->fx_r_type
)
20448 case BFD_RELOC_NONE
: type
= "NONE"; break;
20449 case BFD_RELOC_ARM_OFFSET_IMM8
: type
= "OFFSET_IMM8"; break;
20450 case BFD_RELOC_ARM_SHIFT_IMM
: type
= "SHIFT_IMM"; break;
20451 case BFD_RELOC_ARM_SMC
: type
= "SMC"; break;
20452 case BFD_RELOC_ARM_SWI
: type
= "SWI"; break;
20453 case BFD_RELOC_ARM_MULTI
: type
= "MULTI"; break;
20454 case BFD_RELOC_ARM_CP_OFF_IMM
: type
= "CP_OFF_IMM"; break;
20455 case BFD_RELOC_ARM_T32_CP_OFF_IMM
: type
= "T32_CP_OFF_IMM"; break;
20456 case BFD_RELOC_ARM_THUMB_ADD
: type
= "THUMB_ADD"; break;
20457 case BFD_RELOC_ARM_THUMB_SHIFT
: type
= "THUMB_SHIFT"; break;
20458 case BFD_RELOC_ARM_THUMB_IMM
: type
= "THUMB_IMM"; break;
20459 case BFD_RELOC_ARM_THUMB_OFFSET
: type
= "THUMB_OFFSET"; break;
20460 default: type
= _("<unknown>"); break;
20462 as_bad_where (fixp
->fx_file
, fixp
->fx_line
,
20463 _("cannot represent %s relocation in this object file format"),
20470 if ((code
== BFD_RELOC_32_PCREL
|| code
== BFD_RELOC_32
)
20472 && fixp
->fx_addsy
== GOT_symbol
)
20474 code
= BFD_RELOC_ARM_GOTPC
;
20475 reloc
->addend
= fixp
->fx_offset
= reloc
->address
;
20479 reloc
->howto
= bfd_reloc_type_lookup (stdoutput
, code
);
20481 if (reloc
->howto
== NULL
)
20483 as_bad_where (fixp
->fx_file
, fixp
->fx_line
,
20484 _("cannot represent %s relocation in this object file format"),
20485 bfd_get_reloc_code_name (code
));
20489 /* HACK: Since arm ELF uses Rel instead of Rela, encode the
20490 vtable entry to be used in the relocation's section offset. */
20491 if (fixp
->fx_r_type
== BFD_RELOC_VTABLE_ENTRY
)
20492 reloc
->address
= fixp
->fx_offset
;
20497 /* This fix_new is called by cons via TC_CONS_FIX_NEW. */
20500 cons_fix_new_arm (fragS
* frag
,
20505 bfd_reloc_code_real_type type
;
20509 FIXME: @@ Should look at CPU word size. */
20513 type
= BFD_RELOC_8
;
20516 type
= BFD_RELOC_16
;
20520 type
= BFD_RELOC_32
;
20523 type
= BFD_RELOC_64
;
20528 if (exp
->X_op
== O_secrel
)
20530 exp
->X_op
= O_symbol
;
20531 type
= BFD_RELOC_32_SECREL
;
20535 fix_new_exp (frag
, where
, (int) size
, exp
, pcrel
, type
);
20538 #if defined (OBJ_COFF)
20540 arm_validate_fix (fixS
* fixP
)
20542 /* If the destination of the branch is a defined symbol which does not have
20543 the THUMB_FUNC attribute, then we must be calling a function which has
20544 the (interfacearm) attribute. We look for the Thumb entry point to that
20545 function and change the branch to refer to that function instead. */
20546 if (fixP
->fx_r_type
== BFD_RELOC_THUMB_PCREL_BRANCH23
20547 && fixP
->fx_addsy
!= NULL
20548 && S_IS_DEFINED (fixP
->fx_addsy
)
20549 && ! THUMB_IS_FUNC (fixP
->fx_addsy
))
20551 fixP
->fx_addsy
= find_real_start (fixP
->fx_addsy
);
20558 arm_force_relocation (struct fix
* fixp
)
20560 #if defined (OBJ_COFF) && defined (TE_PE)
20561 if (fixp
->fx_r_type
== BFD_RELOC_RVA
)
20565 /* In case we have a call or a branch to a function in ARM ISA mode from
20566 a thumb function or vice-versa force the relocation. These relocations
20567 are cleared off for some cores that might have blx and simple transformations
20571 switch (fixp
->fx_r_type
)
20573 case BFD_RELOC_ARM_PCREL_JUMP
:
20574 case BFD_RELOC_ARM_PCREL_CALL
:
20575 case BFD_RELOC_THUMB_PCREL_BLX
:
20576 if (THUMB_IS_FUNC (fixp
->fx_addsy
))
20580 case BFD_RELOC_ARM_PCREL_BLX
:
20581 case BFD_RELOC_THUMB_PCREL_BRANCH25
:
20582 case BFD_RELOC_THUMB_PCREL_BRANCH20
:
20583 case BFD_RELOC_THUMB_PCREL_BRANCH23
:
20584 if (ARM_IS_FUNC (fixp
->fx_addsy
))
20593 /* Resolve these relocations even if the symbol is extern or weak. */
20594 if (fixp
->fx_r_type
== BFD_RELOC_ARM_IMMEDIATE
20595 || fixp
->fx_r_type
== BFD_RELOC_ARM_OFFSET_IMM
20596 || fixp
->fx_r_type
== BFD_RELOC_ARM_ADRL_IMMEDIATE
20597 || fixp
->fx_r_type
== BFD_RELOC_ARM_T32_ADD_IMM
20598 || fixp
->fx_r_type
== BFD_RELOC_ARM_T32_IMMEDIATE
20599 || fixp
->fx_r_type
== BFD_RELOC_ARM_T32_IMM12
20600 || fixp
->fx_r_type
== BFD_RELOC_ARM_T32_ADD_PC12
)
20603 /* Always leave these relocations for the linker. */
20604 if ((fixp
->fx_r_type
>= BFD_RELOC_ARM_ALU_PC_G0_NC
20605 && fixp
->fx_r_type
<= BFD_RELOC_ARM_LDC_SB_G2
)
20606 || fixp
->fx_r_type
== BFD_RELOC_ARM_LDR_PC_G0
)
20609 /* Always generate relocations against function symbols. */
20610 if (fixp
->fx_r_type
== BFD_RELOC_32
20612 && (symbol_get_bfdsym (fixp
->fx_addsy
)->flags
& BSF_FUNCTION
))
20615 return generic_force_reloc (fixp
);
20618 #if defined (OBJ_ELF) || defined (OBJ_COFF)
20619 /* Relocations against function names must be left unadjusted,
20620 so that the linker can use this information to generate interworking
20621 stubs. The MIPS version of this function
20622 also prevents relocations that are mips-16 specific, but I do not
20623 know why it does this.
20626 There is one other problem that ought to be addressed here, but
20627 which currently is not: Taking the address of a label (rather
20628 than a function) and then later jumping to that address. Such
20629 addresses also ought to have their bottom bit set (assuming that
20630 they reside in Thumb code), but at the moment they will not. */
20633 arm_fix_adjustable (fixS
* fixP
)
20635 if (fixP
->fx_addsy
== NULL
)
20638 /* Preserve relocations against symbols with function type. */
20639 if (symbol_get_bfdsym (fixP
->fx_addsy
)->flags
& BSF_FUNCTION
)
20642 if (THUMB_IS_FUNC (fixP
->fx_addsy
)
20643 && fixP
->fx_subsy
== NULL
)
20646 /* We need the symbol name for the VTABLE entries. */
20647 if ( fixP
->fx_r_type
== BFD_RELOC_VTABLE_INHERIT
20648 || fixP
->fx_r_type
== BFD_RELOC_VTABLE_ENTRY
)
20651 /* Don't allow symbols to be discarded on GOT related relocs. */
20652 if (fixP
->fx_r_type
== BFD_RELOC_ARM_PLT32
20653 || fixP
->fx_r_type
== BFD_RELOC_ARM_GOT32
20654 || fixP
->fx_r_type
== BFD_RELOC_ARM_GOTOFF
20655 || fixP
->fx_r_type
== BFD_RELOC_ARM_TLS_GD32
20656 || fixP
->fx_r_type
== BFD_RELOC_ARM_TLS_LE32
20657 || fixP
->fx_r_type
== BFD_RELOC_ARM_TLS_IE32
20658 || fixP
->fx_r_type
== BFD_RELOC_ARM_TLS_LDM32
20659 || fixP
->fx_r_type
== BFD_RELOC_ARM_TLS_LDO32
20660 || fixP
->fx_r_type
== BFD_RELOC_ARM_TARGET2
)
20663 /* Similarly for group relocations. */
20664 if ((fixP
->fx_r_type
>= BFD_RELOC_ARM_ALU_PC_G0_NC
20665 && fixP
->fx_r_type
<= BFD_RELOC_ARM_LDC_SB_G2
)
20666 || fixP
->fx_r_type
== BFD_RELOC_ARM_LDR_PC_G0
)
20669 /* MOVW/MOVT REL relocations have limited offsets, so keep the symbols. */
20670 if (fixP
->fx_r_type
== BFD_RELOC_ARM_MOVW
20671 || fixP
->fx_r_type
== BFD_RELOC_ARM_MOVT
20672 || fixP
->fx_r_type
== BFD_RELOC_ARM_MOVW_PCREL
20673 || fixP
->fx_r_type
== BFD_RELOC_ARM_MOVT_PCREL
20674 || fixP
->fx_r_type
== BFD_RELOC_ARM_THUMB_MOVW
20675 || fixP
->fx_r_type
== BFD_RELOC_ARM_THUMB_MOVT
20676 || fixP
->fx_r_type
== BFD_RELOC_ARM_THUMB_MOVW_PCREL
20677 || fixP
->fx_r_type
== BFD_RELOC_ARM_THUMB_MOVT_PCREL
)
20682 #endif /* defined (OBJ_ELF) || defined (OBJ_COFF) */
20687 elf32_arm_target_format (void)
20690 return (target_big_endian
20691 ? "elf32-bigarm-symbian"
20692 : "elf32-littlearm-symbian");
20693 #elif defined (TE_VXWORKS)
20694 return (target_big_endian
20695 ? "elf32-bigarm-vxworks"
20696 : "elf32-littlearm-vxworks");
20698 if (target_big_endian
)
20699 return "elf32-bigarm";
20701 return "elf32-littlearm";
20706 armelf_frob_symbol (symbolS
* symp
,
20709 elf_frob_symbol (symp
, puntp
);
20713 /* MD interface: Finalization. */
20718 literal_pool
* pool
;
20720 /* Ensure that all the IT blocks are properly closed. */
20721 check_it_blocks_finished ();
20723 for (pool
= list_of_pools
; pool
; pool
= pool
->next
)
20725 /* Put it at the end of the relevant section. */
20726 subseg_set (pool
->section
, pool
->sub_section
);
20728 arm_elf_change_section ();
20734 /* Adjust the symbol table. This marks Thumb symbols as distinct from
20738 arm_adjust_symtab (void)
20743 for (sym
= symbol_rootP
; sym
!= NULL
; sym
= symbol_next (sym
))
20745 if (ARM_IS_THUMB (sym
))
20747 if (THUMB_IS_FUNC (sym
))
20749 /* Mark the symbol as a Thumb function. */
20750 if ( S_GET_STORAGE_CLASS (sym
) == C_STAT
20751 || S_GET_STORAGE_CLASS (sym
) == C_LABEL
) /* This can happen! */
20752 S_SET_STORAGE_CLASS (sym
, C_THUMBSTATFUNC
);
20754 else if (S_GET_STORAGE_CLASS (sym
) == C_EXT
)
20755 S_SET_STORAGE_CLASS (sym
, C_THUMBEXTFUNC
);
20757 as_bad (_("%s: unexpected function type: %d"),
20758 S_GET_NAME (sym
), S_GET_STORAGE_CLASS (sym
));
20760 else switch (S_GET_STORAGE_CLASS (sym
))
20763 S_SET_STORAGE_CLASS (sym
, C_THUMBEXT
);
20766 S_SET_STORAGE_CLASS (sym
, C_THUMBSTAT
);
20769 S_SET_STORAGE_CLASS (sym
, C_THUMBLABEL
);
20777 if (ARM_IS_INTERWORK (sym
))
20778 coffsymbol (symbol_get_bfdsym (sym
))->native
->u
.syment
.n_flags
= 0xFF;
20785 for (sym
= symbol_rootP
; sym
!= NULL
; sym
= symbol_next (sym
))
20787 if (ARM_IS_THUMB (sym
))
20789 elf_symbol_type
* elf_sym
;
20791 elf_sym
= elf_symbol (symbol_get_bfdsym (sym
));
20792 bind
= ELF_ST_BIND (elf_sym
->internal_elf_sym
.st_info
);
20794 if (! bfd_is_arm_special_symbol_name (elf_sym
->symbol
.name
,
20795 BFD_ARM_SPECIAL_SYM_TYPE_ANY
))
20797 /* If it's a .thumb_func, declare it as so,
20798 otherwise tag label as .code 16. */
20799 if (THUMB_IS_FUNC (sym
))
20800 elf_sym
->internal_elf_sym
.st_info
=
20801 ELF_ST_INFO (bind
, STT_ARM_TFUNC
);
20802 else if (EF_ARM_EABI_VERSION (meabi_flags
) < EF_ARM_EABI_VER4
)
20803 elf_sym
->internal_elf_sym
.st_info
=
20804 ELF_ST_INFO (bind
, STT_ARM_16BIT
);
20811 /* MD interface: Initialization. */
20814 set_constant_flonums (void)
20818 for (i
= 0; i
< NUM_FLOAT_VALS
; i
++)
20819 if (atof_ieee ((char *) fp_const
[i
], 'x', fp_values
[i
]) == NULL
)
20823 /* Auto-select Thumb mode if it's the only available instruction set for the
20824 given architecture. */
20827 autoselect_thumb_from_cpu_variant (void)
20829 if (!ARM_CPU_HAS_FEATURE (cpu_variant
, arm_ext_v1
))
20830 opcode_select (16);
20839 if ( (arm_ops_hsh
= hash_new ()) == NULL
20840 || (arm_cond_hsh
= hash_new ()) == NULL
20841 || (arm_shift_hsh
= hash_new ()) == NULL
20842 || (arm_psr_hsh
= hash_new ()) == NULL
20843 || (arm_v7m_psr_hsh
= hash_new ()) == NULL
20844 || (arm_reg_hsh
= hash_new ()) == NULL
20845 || (arm_reloc_hsh
= hash_new ()) == NULL
20846 || (arm_barrier_opt_hsh
= hash_new ()) == NULL
)
20847 as_fatal (_("virtual memory exhausted"));
20849 for (i
= 0; i
< sizeof (insns
) / sizeof (struct asm_opcode
); i
++)
20850 hash_insert (arm_ops_hsh
, insns
[i
].template, (void *) (insns
+ i
));
20851 for (i
= 0; i
< sizeof (conds
) / sizeof (struct asm_cond
); i
++)
20852 hash_insert (arm_cond_hsh
, conds
[i
].template, (void *) (conds
+ i
));
20853 for (i
= 0; i
< sizeof (shift_names
) / sizeof (struct asm_shift_name
); i
++)
20854 hash_insert (arm_shift_hsh
, shift_names
[i
].name
, (void *) (shift_names
+ i
));
20855 for (i
= 0; i
< sizeof (psrs
) / sizeof (struct asm_psr
); i
++)
20856 hash_insert (arm_psr_hsh
, psrs
[i
].template, (void *) (psrs
+ i
));
20857 for (i
= 0; i
< sizeof (v7m_psrs
) / sizeof (struct asm_psr
); i
++)
20858 hash_insert (arm_v7m_psr_hsh
, v7m_psrs
[i
].template, (void *) (v7m_psrs
+ i
));
20859 for (i
= 0; i
< sizeof (reg_names
) / sizeof (struct reg_entry
); i
++)
20860 hash_insert (arm_reg_hsh
, reg_names
[i
].name
, (void *) (reg_names
+ i
));
20862 i
< sizeof (barrier_opt_names
) / sizeof (struct asm_barrier_opt
);
20864 hash_insert (arm_barrier_opt_hsh
, barrier_opt_names
[i
].template,
20865 (void *) (barrier_opt_names
+ i
));
20867 for (i
= 0; i
< sizeof (reloc_names
) / sizeof (struct reloc_entry
); i
++)
20868 hash_insert (arm_reloc_hsh
, reloc_names
[i
].name
, (void *) (reloc_names
+ i
));
20871 set_constant_flonums ();
20873 /* Set the cpu variant based on the command-line options. We prefer
20874 -mcpu= over -march= if both are set (as for GCC); and we prefer
20875 -mfpu= over any other way of setting the floating point unit.
20876 Use of legacy options with new options are faulted. */
20879 if (mcpu_cpu_opt
|| march_cpu_opt
)
20880 as_bad (_("use of old and new-style options to set CPU type"));
20882 mcpu_cpu_opt
= legacy_cpu
;
20884 else if (!mcpu_cpu_opt
)
20885 mcpu_cpu_opt
= march_cpu_opt
;
20890 as_bad (_("use of old and new-style options to set FPU type"));
20892 mfpu_opt
= legacy_fpu
;
20894 else if (!mfpu_opt
)
20896 #if !(defined (EABI_DEFAULT) || defined (TE_LINUX) \
20897 || defined (TE_NetBSD) || defined (TE_VXWORKS))
20898 /* Some environments specify a default FPU. If they don't, infer it
20899 from the processor. */
20901 mfpu_opt
= mcpu_fpu_opt
;
20903 mfpu_opt
= march_fpu_opt
;
20905 mfpu_opt
= &fpu_default
;
20911 if (mcpu_cpu_opt
!= NULL
)
20912 mfpu_opt
= &fpu_default
;
20913 else if (mcpu_fpu_opt
!= NULL
&& ARM_CPU_HAS_FEATURE (*mcpu_fpu_opt
, arm_ext_v5
))
20914 mfpu_opt
= &fpu_arch_vfp_v2
;
20916 mfpu_opt
= &fpu_arch_fpa
;
20922 mcpu_cpu_opt
= &cpu_default
;
20923 selected_cpu
= cpu_default
;
20927 selected_cpu
= *mcpu_cpu_opt
;
20929 mcpu_cpu_opt
= &arm_arch_any
;
20932 ARM_MERGE_FEATURE_SETS (cpu_variant
, *mcpu_cpu_opt
, *mfpu_opt
);
20934 autoselect_thumb_from_cpu_variant ();
20936 arm_arch_used
= thumb_arch_used
= arm_arch_none
;
20938 #if defined OBJ_COFF || defined OBJ_ELF
20940 unsigned int flags
= 0;
20942 #if defined OBJ_ELF
20943 flags
= meabi_flags
;
20945 switch (meabi_flags
)
20947 case EF_ARM_EABI_UNKNOWN
:
20949 /* Set the flags in the private structure. */
20950 if (uses_apcs_26
) flags
|= F_APCS26
;
20951 if (support_interwork
) flags
|= F_INTERWORK
;
20952 if (uses_apcs_float
) flags
|= F_APCS_FLOAT
;
20953 if (pic_code
) flags
|= F_PIC
;
20954 if (!ARM_CPU_HAS_FEATURE (cpu_variant
, fpu_any_hard
))
20955 flags
|= F_SOFT_FLOAT
;
20957 switch (mfloat_abi_opt
)
20959 case ARM_FLOAT_ABI_SOFT
:
20960 case ARM_FLOAT_ABI_SOFTFP
:
20961 flags
|= F_SOFT_FLOAT
;
20964 case ARM_FLOAT_ABI_HARD
:
20965 if (flags
& F_SOFT_FLOAT
)
20966 as_bad (_("hard-float conflicts with specified fpu"));
20970 /* Using pure-endian doubles (even if soft-float). */
20971 if (ARM_CPU_HAS_FEATURE (cpu_variant
, fpu_endian_pure
))
20972 flags
|= F_VFP_FLOAT
;
20974 #if defined OBJ_ELF
20975 if (ARM_CPU_HAS_FEATURE (cpu_variant
, fpu_arch_maverick
))
20976 flags
|= EF_ARM_MAVERICK_FLOAT
;
20979 case EF_ARM_EABI_VER4
:
20980 case EF_ARM_EABI_VER5
:
20981 /* No additional flags to set. */
20988 bfd_set_private_flags (stdoutput
, flags
);
20990 /* We have run out flags in the COFF header to encode the
20991 status of ATPCS support, so instead we create a dummy,
20992 empty, debug section called .arm.atpcs. */
20997 sec
= bfd_make_section (stdoutput
, ".arm.atpcs");
21001 bfd_set_section_flags
21002 (stdoutput
, sec
, SEC_READONLY
| SEC_DEBUGGING
/* | SEC_HAS_CONTENTS */);
21003 bfd_set_section_size (stdoutput
, sec
, 0);
21004 bfd_set_section_contents (stdoutput
, sec
, NULL
, 0, 0);
21010 /* Record the CPU type as well. */
21011 if (ARM_CPU_HAS_FEATURE (cpu_variant
, arm_cext_iwmmxt2
))
21012 mach
= bfd_mach_arm_iWMMXt2
;
21013 else if (ARM_CPU_HAS_FEATURE (cpu_variant
, arm_cext_iwmmxt
))
21014 mach
= bfd_mach_arm_iWMMXt
;
21015 else if (ARM_CPU_HAS_FEATURE (cpu_variant
, arm_cext_xscale
))
21016 mach
= bfd_mach_arm_XScale
;
21017 else if (ARM_CPU_HAS_FEATURE (cpu_variant
, arm_cext_maverick
))
21018 mach
= bfd_mach_arm_ep9312
;
21019 else if (ARM_CPU_HAS_FEATURE (cpu_variant
, arm_ext_v5e
))
21020 mach
= bfd_mach_arm_5TE
;
21021 else if (ARM_CPU_HAS_FEATURE (cpu_variant
, arm_ext_v5
))
21023 if (ARM_CPU_HAS_FEATURE (cpu_variant
, arm_ext_v4t
))
21024 mach
= bfd_mach_arm_5T
;
21026 mach
= bfd_mach_arm_5
;
21028 else if (ARM_CPU_HAS_FEATURE (cpu_variant
, arm_ext_v4
))
21030 if (ARM_CPU_HAS_FEATURE (cpu_variant
, arm_ext_v4t
))
21031 mach
= bfd_mach_arm_4T
;
21033 mach
= bfd_mach_arm_4
;
21035 else if (ARM_CPU_HAS_FEATURE (cpu_variant
, arm_ext_v3m
))
21036 mach
= bfd_mach_arm_3M
;
21037 else if (ARM_CPU_HAS_FEATURE (cpu_variant
, arm_ext_v3
))
21038 mach
= bfd_mach_arm_3
;
21039 else if (ARM_CPU_HAS_FEATURE (cpu_variant
, arm_ext_v2s
))
21040 mach
= bfd_mach_arm_2a
;
21041 else if (ARM_CPU_HAS_FEATURE (cpu_variant
, arm_ext_v2
))
21042 mach
= bfd_mach_arm_2
;
21044 mach
= bfd_mach_arm_unknown
;
21046 bfd_set_arch_mach (stdoutput
, TARGET_ARCH
, mach
);
21049 /* Command line processing. */
21052 Invocation line includes a switch not recognized by the base assembler.
21053 See if it's a processor-specific option.
21055 This routine is somewhat complicated by the need for backwards
21056 compatibility (since older releases of gcc can't be changed).
21057 The new options try to make the interface as compatible as
21060 New options (supported) are:
21062 -mcpu=<cpu name> Assemble for selected processor
21063 -march=<architecture name> Assemble for selected architecture
21064 -mfpu=<fpu architecture> Assemble for selected FPU.
21065 -EB/-mbig-endian Big-endian
21066 -EL/-mlittle-endian Little-endian
21067 -k Generate PIC code
21068 -mthumb Start in Thumb mode
21069 -mthumb-interwork Code supports ARM/Thumb interworking
21071 -m[no-]warn-deprecated Warn about deprecated features
21073 For now we will also provide support for:
21075 -mapcs-32 32-bit Program counter
21076 -mapcs-26 26-bit Program counter
21077 -macps-float Floats passed in FP registers
21078 -mapcs-reentrant Reentrant code
21080 (sometime these will probably be replaced with -mapcs=<list of options>
21081 and -matpcs=<list of options>)
21083 The remaining options are only supported for back-wards compatibility.
21084 Cpu variants, the arm part is optional:
21085 -m[arm]1 Currently not supported.
21086 -m[arm]2, -m[arm]250 Arm 2 and Arm 250 processor
21087 -m[arm]3 Arm 3 processor
21088 -m[arm]6[xx], Arm 6 processors
21089 -m[arm]7[xx][t][[d]m] Arm 7 processors
21090 -m[arm]8[10] Arm 8 processors
21091 -m[arm]9[20][tdmi] Arm 9 processors
21092 -mstrongarm[110[0]] StrongARM processors
21093 -mxscale XScale processors
21094 -m[arm]v[2345[t[e]]] Arm architectures
21095 -mall All (except the ARM1)
21097 -mfpa10, -mfpa11 FPA10 and 11 co-processor instructions
21098 -mfpe-old (No float load/store multiples)
21099 -mvfpxd VFP Single precision
21101 -mno-fpu Disable all floating point instructions
21103 The following CPU names are recognized:
21104 arm1, arm2, arm250, arm3, arm6, arm600, arm610, arm620,
21105 arm7, arm7m, arm7d, arm7dm, arm7di, arm7dmi, arm70, arm700,
21106 arm700i, arm710 arm710t, arm720, arm720t, arm740t, arm710c,
21107 arm7100, arm7500, arm7500fe, arm7tdmi, arm8, arm810, arm9,
21108 arm920, arm920t, arm940t, arm946, arm966, arm9tdmi, arm9e,
21109 arm10t arm10e, arm1020t, arm1020e, arm10200e,
21110 strongarm, strongarm110, strongarm1100, strongarm1110, xscale.
21114 const char * md_shortopts
= "m:k";
21116 #ifdef ARM_BI_ENDIAN
21117 #define OPTION_EB (OPTION_MD_BASE + 0)
21118 #define OPTION_EL (OPTION_MD_BASE + 1)
21120 #if TARGET_BYTES_BIG_ENDIAN
21121 #define OPTION_EB (OPTION_MD_BASE + 0)
21123 #define OPTION_EL (OPTION_MD_BASE + 1)
21126 #define OPTION_FIX_V4BX (OPTION_MD_BASE + 2)
21128 struct option md_longopts
[] =
21131 {"EB", no_argument
, NULL
, OPTION_EB
},
21134 {"EL", no_argument
, NULL
, OPTION_EL
},
21136 {"fix-v4bx", no_argument
, NULL
, OPTION_FIX_V4BX
},
21137 {NULL
, no_argument
, NULL
, 0}
21140 size_t md_longopts_size
= sizeof (md_longopts
);
21142 struct arm_option_table
21144 char *option
; /* Option name to match. */
21145 char *help
; /* Help information. */
21146 int *var
; /* Variable to change. */
21147 int value
; /* What to change it to. */
21148 char *deprecated
; /* If non-null, print this message. */
21151 struct arm_option_table arm_opts
[] =
21153 {"k", N_("generate PIC code"), &pic_code
, 1, NULL
},
21154 {"mthumb", N_("assemble Thumb code"), &thumb_mode
, 1, NULL
},
21155 {"mthumb-interwork", N_("support ARM/Thumb interworking"),
21156 &support_interwork
, 1, NULL
},
21157 {"mapcs-32", N_("code uses 32-bit program counter"), &uses_apcs_26
, 0, NULL
},
21158 {"mapcs-26", N_("code uses 26-bit program counter"), &uses_apcs_26
, 1, NULL
},
21159 {"mapcs-float", N_("floating point args are in fp regs"), &uses_apcs_float
,
21161 {"mapcs-reentrant", N_("re-entrant code"), &pic_code
, 1, NULL
},
21162 {"matpcs", N_("code is ATPCS conformant"), &atpcs
, 1, NULL
},
21163 {"mbig-endian", N_("assemble for big-endian"), &target_big_endian
, 1, NULL
},
21164 {"mlittle-endian", N_("assemble for little-endian"), &target_big_endian
, 0,
21167 /* These are recognized by the assembler, but have no affect on code. */
21168 {"mapcs-frame", N_("use frame pointer"), NULL
, 0, NULL
},
21169 {"mapcs-stack-check", N_("use stack size checking"), NULL
, 0, NULL
},
21171 {"mwarn-deprecated", NULL
, &warn_on_deprecated
, 1, NULL
},
21172 {"mno-warn-deprecated", N_("do not warn on use of deprecated feature"),
21173 &warn_on_deprecated
, 0, NULL
},
21174 {NULL
, NULL
, NULL
, 0, NULL
}
21177 struct arm_legacy_option_table
21179 char *option
; /* Option name to match. */
21180 const arm_feature_set
**var
; /* Variable to change. */
21181 const arm_feature_set value
; /* What to change it to. */
21182 char *deprecated
; /* If non-null, print this message. */
21185 const struct arm_legacy_option_table arm_legacy_opts
[] =
21187 /* DON'T add any new processors to this list -- we want the whole list
21188 to go away... Add them to the processors table instead. */
21189 {"marm1", &legacy_cpu
, ARM_ARCH_V1
, N_("use -mcpu=arm1")},
21190 {"m1", &legacy_cpu
, ARM_ARCH_V1
, N_("use -mcpu=arm1")},
21191 {"marm2", &legacy_cpu
, ARM_ARCH_V2
, N_("use -mcpu=arm2")},
21192 {"m2", &legacy_cpu
, ARM_ARCH_V2
, N_("use -mcpu=arm2")},
21193 {"marm250", &legacy_cpu
, ARM_ARCH_V2S
, N_("use -mcpu=arm250")},
21194 {"m250", &legacy_cpu
, ARM_ARCH_V2S
, N_("use -mcpu=arm250")},
21195 {"marm3", &legacy_cpu
, ARM_ARCH_V2S
, N_("use -mcpu=arm3")},
21196 {"m3", &legacy_cpu
, ARM_ARCH_V2S
, N_("use -mcpu=arm3")},
21197 {"marm6", &legacy_cpu
, ARM_ARCH_V3
, N_("use -mcpu=arm6")},
21198 {"m6", &legacy_cpu
, ARM_ARCH_V3
, N_("use -mcpu=arm6")},
21199 {"marm600", &legacy_cpu
, ARM_ARCH_V3
, N_("use -mcpu=arm600")},
21200 {"m600", &legacy_cpu
, ARM_ARCH_V3
, N_("use -mcpu=arm600")},
21201 {"marm610", &legacy_cpu
, ARM_ARCH_V3
, N_("use -mcpu=arm610")},
21202 {"m610", &legacy_cpu
, ARM_ARCH_V3
, N_("use -mcpu=arm610")},
21203 {"marm620", &legacy_cpu
, ARM_ARCH_V3
, N_("use -mcpu=arm620")},
21204 {"m620", &legacy_cpu
, ARM_ARCH_V3
, N_("use -mcpu=arm620")},
21205 {"marm7", &legacy_cpu
, ARM_ARCH_V3
, N_("use -mcpu=arm7")},
21206 {"m7", &legacy_cpu
, ARM_ARCH_V3
, N_("use -mcpu=arm7")},
21207 {"marm70", &legacy_cpu
, ARM_ARCH_V3
, N_("use -mcpu=arm70")},
21208 {"m70", &legacy_cpu
, ARM_ARCH_V3
, N_("use -mcpu=arm70")},
21209 {"marm700", &legacy_cpu
, ARM_ARCH_V3
, N_("use -mcpu=arm700")},
21210 {"m700", &legacy_cpu
, ARM_ARCH_V3
, N_("use -mcpu=arm700")},
21211 {"marm700i", &legacy_cpu
, ARM_ARCH_V3
, N_("use -mcpu=arm700i")},
21212 {"m700i", &legacy_cpu
, ARM_ARCH_V3
, N_("use -mcpu=arm700i")},
21213 {"marm710", &legacy_cpu
, ARM_ARCH_V3
, N_("use -mcpu=arm710")},
21214 {"m710", &legacy_cpu
, ARM_ARCH_V3
, N_("use -mcpu=arm710")},
21215 {"marm710c", &legacy_cpu
, ARM_ARCH_V3
, N_("use -mcpu=arm710c")},
21216 {"m710c", &legacy_cpu
, ARM_ARCH_V3
, N_("use -mcpu=arm710c")},
21217 {"marm720", &legacy_cpu
, ARM_ARCH_V3
, N_("use -mcpu=arm720")},
21218 {"m720", &legacy_cpu
, ARM_ARCH_V3
, N_("use -mcpu=arm720")},
21219 {"marm7d", &legacy_cpu
, ARM_ARCH_V3
, N_("use -mcpu=arm7d")},
21220 {"m7d", &legacy_cpu
, ARM_ARCH_V3
, N_("use -mcpu=arm7d")},
21221 {"marm7di", &legacy_cpu
, ARM_ARCH_V3
, N_("use -mcpu=arm7di")},
21222 {"m7di", &legacy_cpu
, ARM_ARCH_V3
, N_("use -mcpu=arm7di")},
21223 {"marm7m", &legacy_cpu
, ARM_ARCH_V3M
, N_("use -mcpu=arm7m")},
21224 {"m7m", &legacy_cpu
, ARM_ARCH_V3M
, N_("use -mcpu=arm7m")},
21225 {"marm7dm", &legacy_cpu
, ARM_ARCH_V3M
, N_("use -mcpu=arm7dm")},
21226 {"m7dm", &legacy_cpu
, ARM_ARCH_V3M
, N_("use -mcpu=arm7dm")},
21227 {"marm7dmi", &legacy_cpu
, ARM_ARCH_V3M
, N_("use -mcpu=arm7dmi")},
21228 {"m7dmi", &legacy_cpu
, ARM_ARCH_V3M
, N_("use -mcpu=arm7dmi")},
21229 {"marm7100", &legacy_cpu
, ARM_ARCH_V3
, N_("use -mcpu=arm7100")},
21230 {"m7100", &legacy_cpu
, ARM_ARCH_V3
, N_("use -mcpu=arm7100")},
21231 {"marm7500", &legacy_cpu
, ARM_ARCH_V3
, N_("use -mcpu=arm7500")},
21232 {"m7500", &legacy_cpu
, ARM_ARCH_V3
, N_("use -mcpu=arm7500")},
21233 {"marm7500fe", &legacy_cpu
, ARM_ARCH_V3
, N_("use -mcpu=arm7500fe")},
21234 {"m7500fe", &legacy_cpu
, ARM_ARCH_V3
, N_("use -mcpu=arm7500fe")},
21235 {"marm7t", &legacy_cpu
, ARM_ARCH_V4T
, N_("use -mcpu=arm7tdmi")},
21236 {"m7t", &legacy_cpu
, ARM_ARCH_V4T
, N_("use -mcpu=arm7tdmi")},
21237 {"marm7tdmi", &legacy_cpu
, ARM_ARCH_V4T
, N_("use -mcpu=arm7tdmi")},
21238 {"m7tdmi", &legacy_cpu
, ARM_ARCH_V4T
, N_("use -mcpu=arm7tdmi")},
21239 {"marm710t", &legacy_cpu
, ARM_ARCH_V4T
, N_("use -mcpu=arm710t")},
21240 {"m710t", &legacy_cpu
, ARM_ARCH_V4T
, N_("use -mcpu=arm710t")},
21241 {"marm720t", &legacy_cpu
, ARM_ARCH_V4T
, N_("use -mcpu=arm720t")},
21242 {"m720t", &legacy_cpu
, ARM_ARCH_V4T
, N_("use -mcpu=arm720t")},
21243 {"marm740t", &legacy_cpu
, ARM_ARCH_V4T
, N_("use -mcpu=arm740t")},
21244 {"m740t", &legacy_cpu
, ARM_ARCH_V4T
, N_("use -mcpu=arm740t")},
21245 {"marm8", &legacy_cpu
, ARM_ARCH_V4
, N_("use -mcpu=arm8")},
21246 {"m8", &legacy_cpu
, ARM_ARCH_V4
, N_("use -mcpu=arm8")},
21247 {"marm810", &legacy_cpu
, ARM_ARCH_V4
, N_("use -mcpu=arm810")},
21248 {"m810", &legacy_cpu
, ARM_ARCH_V4
, N_("use -mcpu=arm810")},
21249 {"marm9", &legacy_cpu
, ARM_ARCH_V4T
, N_("use -mcpu=arm9")},
21250 {"m9", &legacy_cpu
, ARM_ARCH_V4T
, N_("use -mcpu=arm9")},
21251 {"marm9tdmi", &legacy_cpu
, ARM_ARCH_V4T
, N_("use -mcpu=arm9tdmi")},
21252 {"m9tdmi", &legacy_cpu
, ARM_ARCH_V4T
, N_("use -mcpu=arm9tdmi")},
21253 {"marm920", &legacy_cpu
, ARM_ARCH_V4T
, N_("use -mcpu=arm920")},
21254 {"m920", &legacy_cpu
, ARM_ARCH_V4T
, N_("use -mcpu=arm920")},
21255 {"marm940", &legacy_cpu
, ARM_ARCH_V4T
, N_("use -mcpu=arm940")},
21256 {"m940", &legacy_cpu
, ARM_ARCH_V4T
, N_("use -mcpu=arm940")},
21257 {"mstrongarm", &legacy_cpu
, ARM_ARCH_V4
, N_("use -mcpu=strongarm")},
21258 {"mstrongarm110", &legacy_cpu
, ARM_ARCH_V4
,
21259 N_("use -mcpu=strongarm110")},
21260 {"mstrongarm1100", &legacy_cpu
, ARM_ARCH_V4
,
21261 N_("use -mcpu=strongarm1100")},
21262 {"mstrongarm1110", &legacy_cpu
, ARM_ARCH_V4
,
21263 N_("use -mcpu=strongarm1110")},
21264 {"mxscale", &legacy_cpu
, ARM_ARCH_XSCALE
, N_("use -mcpu=xscale")},
21265 {"miwmmxt", &legacy_cpu
, ARM_ARCH_IWMMXT
, N_("use -mcpu=iwmmxt")},
21266 {"mall", &legacy_cpu
, ARM_ANY
, N_("use -mcpu=all")},
21268 /* Architecture variants -- don't add any more to this list either. */
21269 {"mv2", &legacy_cpu
, ARM_ARCH_V2
, N_("use -march=armv2")},
21270 {"marmv2", &legacy_cpu
, ARM_ARCH_V2
, N_("use -march=armv2")},
21271 {"mv2a", &legacy_cpu
, ARM_ARCH_V2S
, N_("use -march=armv2a")},
21272 {"marmv2a", &legacy_cpu
, ARM_ARCH_V2S
, N_("use -march=armv2a")},
21273 {"mv3", &legacy_cpu
, ARM_ARCH_V3
, N_("use -march=armv3")},
21274 {"marmv3", &legacy_cpu
, ARM_ARCH_V3
, N_("use -march=armv3")},
21275 {"mv3m", &legacy_cpu
, ARM_ARCH_V3M
, N_("use -march=armv3m")},
21276 {"marmv3m", &legacy_cpu
, ARM_ARCH_V3M
, N_("use -march=armv3m")},
21277 {"mv4", &legacy_cpu
, ARM_ARCH_V4
, N_("use -march=armv4")},
21278 {"marmv4", &legacy_cpu
, ARM_ARCH_V4
, N_("use -march=armv4")},
21279 {"mv4t", &legacy_cpu
, ARM_ARCH_V4T
, N_("use -march=armv4t")},
21280 {"marmv4t", &legacy_cpu
, ARM_ARCH_V4T
, N_("use -march=armv4t")},
21281 {"mv5", &legacy_cpu
, ARM_ARCH_V5
, N_("use -march=armv5")},
21282 {"marmv5", &legacy_cpu
, ARM_ARCH_V5
, N_("use -march=armv5")},
21283 {"mv5t", &legacy_cpu
, ARM_ARCH_V5T
, N_("use -march=armv5t")},
21284 {"marmv5t", &legacy_cpu
, ARM_ARCH_V5T
, N_("use -march=armv5t")},
21285 {"mv5e", &legacy_cpu
, ARM_ARCH_V5TE
, N_("use -march=armv5te")},
21286 {"marmv5e", &legacy_cpu
, ARM_ARCH_V5TE
, N_("use -march=armv5te")},
21288 /* Floating point variants -- don't add any more to this list either. */
21289 {"mfpe-old", &legacy_fpu
, FPU_ARCH_FPE
, N_("use -mfpu=fpe")},
21290 {"mfpa10", &legacy_fpu
, FPU_ARCH_FPA
, N_("use -mfpu=fpa10")},
21291 {"mfpa11", &legacy_fpu
, FPU_ARCH_FPA
, N_("use -mfpu=fpa11")},
21292 {"mno-fpu", &legacy_fpu
, ARM_ARCH_NONE
,
21293 N_("use either -mfpu=softfpa or -mfpu=softvfp")},
21295 {NULL
, NULL
, ARM_ARCH_NONE
, NULL
}
21298 struct arm_cpu_option_table
21301 const arm_feature_set value
;
21302 /* For some CPUs we assume an FPU unless the user explicitly sets
21304 const arm_feature_set default_fpu
;
21305 /* The canonical name of the CPU, or NULL to use NAME converted to upper
21307 const char *canonical_name
;
21310 /* This list should, at a minimum, contain all the cpu names
21311 recognized by GCC. */
21312 static const struct arm_cpu_option_table arm_cpus
[] =
21314 {"all", ARM_ANY
, FPU_ARCH_FPA
, NULL
},
21315 {"arm1", ARM_ARCH_V1
, FPU_ARCH_FPA
, NULL
},
21316 {"arm2", ARM_ARCH_V2
, FPU_ARCH_FPA
, NULL
},
21317 {"arm250", ARM_ARCH_V2S
, FPU_ARCH_FPA
, NULL
},
21318 {"arm3", ARM_ARCH_V2S
, FPU_ARCH_FPA
, NULL
},
21319 {"arm6", ARM_ARCH_V3
, FPU_ARCH_FPA
, NULL
},
21320 {"arm60", ARM_ARCH_V3
, FPU_ARCH_FPA
, NULL
},
21321 {"arm600", ARM_ARCH_V3
, FPU_ARCH_FPA
, NULL
},
21322 {"arm610", ARM_ARCH_V3
, FPU_ARCH_FPA
, NULL
},
21323 {"arm620", ARM_ARCH_V3
, FPU_ARCH_FPA
, NULL
},
21324 {"arm7", ARM_ARCH_V3
, FPU_ARCH_FPA
, NULL
},
21325 {"arm7m", ARM_ARCH_V3M
, FPU_ARCH_FPA
, NULL
},
21326 {"arm7d", ARM_ARCH_V3
, FPU_ARCH_FPA
, NULL
},
21327 {"arm7dm", ARM_ARCH_V3M
, FPU_ARCH_FPA
, NULL
},
21328 {"arm7di", ARM_ARCH_V3
, FPU_ARCH_FPA
, NULL
},
21329 {"arm7dmi", ARM_ARCH_V3M
, FPU_ARCH_FPA
, NULL
},
21330 {"arm70", ARM_ARCH_V3
, FPU_ARCH_FPA
, NULL
},
21331 {"arm700", ARM_ARCH_V3
, FPU_ARCH_FPA
, NULL
},
21332 {"arm700i", ARM_ARCH_V3
, FPU_ARCH_FPA
, NULL
},
21333 {"arm710", ARM_ARCH_V3
, FPU_ARCH_FPA
, NULL
},
21334 {"arm710t", ARM_ARCH_V4T
, FPU_ARCH_FPA
, NULL
},
21335 {"arm720", ARM_ARCH_V3
, FPU_ARCH_FPA
, NULL
},
21336 {"arm720t", ARM_ARCH_V4T
, FPU_ARCH_FPA
, NULL
},
21337 {"arm740t", ARM_ARCH_V4T
, FPU_ARCH_FPA
, NULL
},
21338 {"arm710c", ARM_ARCH_V3
, FPU_ARCH_FPA
, NULL
},
21339 {"arm7100", ARM_ARCH_V3
, FPU_ARCH_FPA
, NULL
},
21340 {"arm7500", ARM_ARCH_V3
, FPU_ARCH_FPA
, NULL
},
21341 {"arm7500fe", ARM_ARCH_V3
, FPU_ARCH_FPA
, NULL
},
21342 {"arm7t", ARM_ARCH_V4T
, FPU_ARCH_FPA
, NULL
},
21343 {"arm7tdmi", ARM_ARCH_V4T
, FPU_ARCH_FPA
, NULL
},
21344 {"arm7tdmi-s", ARM_ARCH_V4T
, FPU_ARCH_FPA
, NULL
},
21345 {"arm8", ARM_ARCH_V4
, FPU_ARCH_FPA
, NULL
},
21346 {"arm810", ARM_ARCH_V4
, FPU_ARCH_FPA
, NULL
},
21347 {"strongarm", ARM_ARCH_V4
, FPU_ARCH_FPA
, NULL
},
21348 {"strongarm1", ARM_ARCH_V4
, FPU_ARCH_FPA
, NULL
},
21349 {"strongarm110", ARM_ARCH_V4
, FPU_ARCH_FPA
, NULL
},
21350 {"strongarm1100", ARM_ARCH_V4
, FPU_ARCH_FPA
, NULL
},
21351 {"strongarm1110", ARM_ARCH_V4
, FPU_ARCH_FPA
, NULL
},
21352 {"arm9", ARM_ARCH_V4T
, FPU_ARCH_FPA
, NULL
},
21353 {"arm920", ARM_ARCH_V4T
, FPU_ARCH_FPA
, "ARM920T"},
21354 {"arm920t", ARM_ARCH_V4T
, FPU_ARCH_FPA
, NULL
},
21355 {"arm922t", ARM_ARCH_V4T
, FPU_ARCH_FPA
, NULL
},
21356 {"arm940t", ARM_ARCH_V4T
, FPU_ARCH_FPA
, NULL
},
21357 {"arm9tdmi", ARM_ARCH_V4T
, FPU_ARCH_FPA
, NULL
},
21358 {"fa526", ARM_ARCH_V4
, FPU_ARCH_FPA
, NULL
},
21359 {"fa626", ARM_ARCH_V4
, FPU_ARCH_FPA
, NULL
},
21360 /* For V5 or later processors we default to using VFP; but the user
21361 should really set the FPU type explicitly. */
21362 {"arm9e-r0", ARM_ARCH_V5TExP
, FPU_ARCH_VFP_V2
, NULL
},
21363 {"arm9e", ARM_ARCH_V5TE
, FPU_ARCH_VFP_V2
, NULL
},
21364 {"arm926ej", ARM_ARCH_V5TEJ
, FPU_ARCH_VFP_V2
, "ARM926EJ-S"},
21365 {"arm926ejs", ARM_ARCH_V5TEJ
, FPU_ARCH_VFP_V2
, "ARM926EJ-S"},
21366 {"arm926ej-s", ARM_ARCH_V5TEJ
, FPU_ARCH_VFP_V2
, NULL
},
21367 {"arm946e-r0", ARM_ARCH_V5TExP
, FPU_ARCH_VFP_V2
, NULL
},
21368 {"arm946e", ARM_ARCH_V5TE
, FPU_ARCH_VFP_V2
, "ARM946E-S"},
21369 {"arm946e-s", ARM_ARCH_V5TE
, FPU_ARCH_VFP_V2
, NULL
},
21370 {"arm966e-r0", ARM_ARCH_V5TExP
, FPU_ARCH_VFP_V2
, NULL
},
21371 {"arm966e", ARM_ARCH_V5TE
, FPU_ARCH_VFP_V2
, "ARM966E-S"},
21372 {"arm966e-s", ARM_ARCH_V5TE
, FPU_ARCH_VFP_V2
, NULL
},
21373 {"arm968e-s", ARM_ARCH_V5TE
, FPU_ARCH_VFP_V2
, NULL
},
21374 {"arm10t", ARM_ARCH_V5T
, FPU_ARCH_VFP_V1
, NULL
},
21375 {"arm10tdmi", ARM_ARCH_V5T
, FPU_ARCH_VFP_V1
, NULL
},
21376 {"arm10e", ARM_ARCH_V5TE
, FPU_ARCH_VFP_V2
, NULL
},
21377 {"arm1020", ARM_ARCH_V5TE
, FPU_ARCH_VFP_V2
, "ARM1020E"},
21378 {"arm1020t", ARM_ARCH_V5T
, FPU_ARCH_VFP_V1
, NULL
},
21379 {"arm1020e", ARM_ARCH_V5TE
, FPU_ARCH_VFP_V2
, NULL
},
21380 {"arm1022e", ARM_ARCH_V5TE
, FPU_ARCH_VFP_V2
, NULL
},
21381 {"arm1026ejs", ARM_ARCH_V5TEJ
, FPU_ARCH_VFP_V2
, "ARM1026EJ-S"},
21382 {"arm1026ej-s", ARM_ARCH_V5TEJ
, FPU_ARCH_VFP_V2
, NULL
},
21383 {"fa626te", ARM_ARCH_V5TE
, FPU_NONE
, NULL
},
21384 {"fa726te", ARM_ARCH_V5TE
, FPU_ARCH_VFP_V2
, NULL
},
21385 {"arm1136js", ARM_ARCH_V6
, FPU_NONE
, "ARM1136J-S"},
21386 {"arm1136j-s", ARM_ARCH_V6
, FPU_NONE
, NULL
},
21387 {"arm1136jfs", ARM_ARCH_V6
, FPU_ARCH_VFP_V2
, "ARM1136JF-S"},
21388 {"arm1136jf-s", ARM_ARCH_V6
, FPU_ARCH_VFP_V2
, NULL
},
21389 {"mpcore", ARM_ARCH_V6K
, FPU_ARCH_VFP_V2
, NULL
},
21390 {"mpcorenovfp", ARM_ARCH_V6K
, FPU_NONE
, NULL
},
21391 {"arm1156t2-s", ARM_ARCH_V6T2
, FPU_NONE
, NULL
},
21392 {"arm1156t2f-s", ARM_ARCH_V6T2
, FPU_ARCH_VFP_V2
, NULL
},
21393 {"arm1176jz-s", ARM_ARCH_V6ZK
, FPU_NONE
, NULL
},
21394 {"arm1176jzf-s", ARM_ARCH_V6ZK
, FPU_ARCH_VFP_V2
, NULL
},
21395 {"cortex-a8", ARM_ARCH_V7A
, ARM_FEATURE (0, FPU_VFP_V3
21396 | FPU_NEON_EXT_V1
),
21398 {"cortex-a9", ARM_ARCH_V7A
, ARM_FEATURE (0, FPU_VFP_V3
21399 | FPU_NEON_EXT_V1
),
21401 {"cortex-r4", ARM_ARCH_V7R
, FPU_NONE
, NULL
},
21402 {"cortex-m3", ARM_ARCH_V7M
, FPU_NONE
, NULL
},
21403 {"cortex-m1", ARM_ARCH_V6M
, FPU_NONE
, NULL
},
21404 {"cortex-m0", ARM_ARCH_V6M
, FPU_NONE
, NULL
},
21405 /* ??? XSCALE is really an architecture. */
21406 {"xscale", ARM_ARCH_XSCALE
, FPU_ARCH_VFP_V2
, NULL
},
21407 /* ??? iwmmxt is not a processor. */
21408 {"iwmmxt", ARM_ARCH_IWMMXT
, FPU_ARCH_VFP_V2
, NULL
},
21409 {"iwmmxt2", ARM_ARCH_IWMMXT2
,FPU_ARCH_VFP_V2
, NULL
},
21410 {"i80200", ARM_ARCH_XSCALE
, FPU_ARCH_VFP_V2
, NULL
},
21412 {"ep9312", ARM_FEATURE (ARM_AEXT_V4T
, ARM_CEXT_MAVERICK
), FPU_ARCH_MAVERICK
, "ARM920T"},
21413 {NULL
, ARM_ARCH_NONE
, ARM_ARCH_NONE
, NULL
}
21416 struct arm_arch_option_table
21419 const arm_feature_set value
;
21420 const arm_feature_set default_fpu
;
21423 /* This list should, at a minimum, contain all the architecture names
21424 recognized by GCC. */
21425 static const struct arm_arch_option_table arm_archs
[] =
21427 {"all", ARM_ANY
, FPU_ARCH_FPA
},
21428 {"armv1", ARM_ARCH_V1
, FPU_ARCH_FPA
},
21429 {"armv2", ARM_ARCH_V2
, FPU_ARCH_FPA
},
21430 {"armv2a", ARM_ARCH_V2S
, FPU_ARCH_FPA
},
21431 {"armv2s", ARM_ARCH_V2S
, FPU_ARCH_FPA
},
21432 {"armv3", ARM_ARCH_V3
, FPU_ARCH_FPA
},
21433 {"armv3m", ARM_ARCH_V3M
, FPU_ARCH_FPA
},
21434 {"armv4", ARM_ARCH_V4
, FPU_ARCH_FPA
},
21435 {"armv4xm", ARM_ARCH_V4xM
, FPU_ARCH_FPA
},
21436 {"armv4t", ARM_ARCH_V4T
, FPU_ARCH_FPA
},
21437 {"armv4txm", ARM_ARCH_V4TxM
, FPU_ARCH_FPA
},
21438 {"armv5", ARM_ARCH_V5
, FPU_ARCH_VFP
},
21439 {"armv5t", ARM_ARCH_V5T
, FPU_ARCH_VFP
},
21440 {"armv5txm", ARM_ARCH_V5TxM
, FPU_ARCH_VFP
},
21441 {"armv5te", ARM_ARCH_V5TE
, FPU_ARCH_VFP
},
21442 {"armv5texp", ARM_ARCH_V5TExP
, FPU_ARCH_VFP
},
21443 {"armv5tej", ARM_ARCH_V5TEJ
, FPU_ARCH_VFP
},
21444 {"armv6", ARM_ARCH_V6
, FPU_ARCH_VFP
},
21445 {"armv6j", ARM_ARCH_V6
, FPU_ARCH_VFP
},
21446 {"armv6k", ARM_ARCH_V6K
, FPU_ARCH_VFP
},
21447 {"armv6z", ARM_ARCH_V6Z
, FPU_ARCH_VFP
},
21448 {"armv6zk", ARM_ARCH_V6ZK
, FPU_ARCH_VFP
},
21449 {"armv6t2", ARM_ARCH_V6T2
, FPU_ARCH_VFP
},
21450 {"armv6kt2", ARM_ARCH_V6KT2
, FPU_ARCH_VFP
},
21451 {"armv6zt2", ARM_ARCH_V6ZT2
, FPU_ARCH_VFP
},
21452 {"armv6zkt2", ARM_ARCH_V6ZKT2
, FPU_ARCH_VFP
},
21453 {"armv6-m", ARM_ARCH_V6M
, FPU_ARCH_VFP
},
21454 {"armv7", ARM_ARCH_V7
, FPU_ARCH_VFP
},
21455 /* The official spelling of the ARMv7 profile variants is the dashed form.
21456 Accept the non-dashed form for compatibility with old toolchains. */
21457 {"armv7a", ARM_ARCH_V7A
, FPU_ARCH_VFP
},
21458 {"armv7r", ARM_ARCH_V7R
, FPU_ARCH_VFP
},
21459 {"armv7m", ARM_ARCH_V7M
, FPU_ARCH_VFP
},
21460 {"armv7-a", ARM_ARCH_V7A
, FPU_ARCH_VFP
},
21461 {"armv7-r", ARM_ARCH_V7R
, FPU_ARCH_VFP
},
21462 {"armv7-m", ARM_ARCH_V7M
, FPU_ARCH_VFP
},
21463 {"xscale", ARM_ARCH_XSCALE
, FPU_ARCH_VFP
},
21464 {"iwmmxt", ARM_ARCH_IWMMXT
, FPU_ARCH_VFP
},
21465 {"iwmmxt2", ARM_ARCH_IWMMXT2
,FPU_ARCH_VFP
},
21466 {NULL
, ARM_ARCH_NONE
, ARM_ARCH_NONE
}
21469 /* ISA extensions in the co-processor space. */
21470 struct arm_option_cpu_value_table
21473 const arm_feature_set value
;
21476 static const struct arm_option_cpu_value_table arm_extensions
[] =
21478 {"maverick", ARM_FEATURE (0, ARM_CEXT_MAVERICK
)},
21479 {"xscale", ARM_FEATURE (0, ARM_CEXT_XSCALE
)},
21480 {"iwmmxt", ARM_FEATURE (0, ARM_CEXT_IWMMXT
)},
21481 {"iwmmxt2", ARM_FEATURE (0, ARM_CEXT_IWMMXT2
)},
21482 {NULL
, ARM_ARCH_NONE
}
21485 /* This list should, at a minimum, contain all the fpu names
21486 recognized by GCC. */
21487 static const struct arm_option_cpu_value_table arm_fpus
[] =
21489 {"softfpa", FPU_NONE
},
21490 {"fpe", FPU_ARCH_FPE
},
21491 {"fpe2", FPU_ARCH_FPE
},
21492 {"fpe3", FPU_ARCH_FPA
}, /* Third release supports LFM/SFM. */
21493 {"fpa", FPU_ARCH_FPA
},
21494 {"fpa10", FPU_ARCH_FPA
},
21495 {"fpa11", FPU_ARCH_FPA
},
21496 {"arm7500fe", FPU_ARCH_FPA
},
21497 {"softvfp", FPU_ARCH_VFP
},
21498 {"softvfp+vfp", FPU_ARCH_VFP_V2
},
21499 {"vfp", FPU_ARCH_VFP_V2
},
21500 {"vfp9", FPU_ARCH_VFP_V2
},
21501 {"vfp3", FPU_ARCH_VFP_V3
}, /* For backwards compatbility. */
21502 {"vfp10", FPU_ARCH_VFP_V2
},
21503 {"vfp10-r0", FPU_ARCH_VFP_V1
},
21504 {"vfpxd", FPU_ARCH_VFP_V1xD
},
21505 {"vfpv2", FPU_ARCH_VFP_V2
},
21506 {"vfpv3", FPU_ARCH_VFP_V3
},
21507 {"vfpv3-d16", FPU_ARCH_VFP_V3D16
},
21508 {"arm1020t", FPU_ARCH_VFP_V1
},
21509 {"arm1020e", FPU_ARCH_VFP_V2
},
21510 {"arm1136jfs", FPU_ARCH_VFP_V2
},
21511 {"arm1136jf-s", FPU_ARCH_VFP_V2
},
21512 {"maverick", FPU_ARCH_MAVERICK
},
21513 {"neon", FPU_ARCH_VFP_V3_PLUS_NEON_V1
},
21514 {"neon-fp16", FPU_ARCH_NEON_FP16
},
21515 {NULL
, ARM_ARCH_NONE
}
21518 struct arm_option_value_table
21524 static const struct arm_option_value_table arm_float_abis
[] =
21526 {"hard", ARM_FLOAT_ABI_HARD
},
21527 {"softfp", ARM_FLOAT_ABI_SOFTFP
},
21528 {"soft", ARM_FLOAT_ABI_SOFT
},
21533 /* We only know how to output GNU and ver 4/5 (AAELF) formats. */
21534 static const struct arm_option_value_table arm_eabis
[] =
21536 {"gnu", EF_ARM_EABI_UNKNOWN
},
21537 {"4", EF_ARM_EABI_VER4
},
21538 {"5", EF_ARM_EABI_VER5
},
21543 struct arm_long_option_table
21545 char * option
; /* Substring to match. */
21546 char * help
; /* Help information. */
21547 int (* func
) (char * subopt
); /* Function to decode sub-option. */
21548 char * deprecated
; /* If non-null, print this message. */
21552 arm_parse_extension (char * str
, const arm_feature_set
**opt_p
)
21554 arm_feature_set
*ext_set
= xmalloc (sizeof (arm_feature_set
));
21556 /* Copy the feature set, so that we can modify it. */
21557 *ext_set
= **opt_p
;
21560 while (str
!= NULL
&& *str
!= 0)
21562 const struct arm_option_cpu_value_table
* opt
;
21568 as_bad (_("invalid architectural extension"));
21573 ext
= strchr (str
, '+');
21576 optlen
= ext
- str
;
21578 optlen
= strlen (str
);
21582 as_bad (_("missing architectural extension"));
21586 for (opt
= arm_extensions
; opt
->name
!= NULL
; opt
++)
21587 if (strncmp (opt
->name
, str
, optlen
) == 0)
21589 ARM_MERGE_FEATURE_SETS (*ext_set
, *ext_set
, opt
->value
);
21593 if (opt
->name
== NULL
)
21595 as_bad (_("unknown architectural extension `%s'"), str
);
21606 arm_parse_cpu (char * str
)
21608 const struct arm_cpu_option_table
* opt
;
21609 char * ext
= strchr (str
, '+');
21613 optlen
= ext
- str
;
21615 optlen
= strlen (str
);
21619 as_bad (_("missing cpu name `%s'"), str
);
21623 for (opt
= arm_cpus
; opt
->name
!= NULL
; opt
++)
21624 if (strncmp (opt
->name
, str
, optlen
) == 0)
21626 mcpu_cpu_opt
= &opt
->value
;
21627 mcpu_fpu_opt
= &opt
->default_fpu
;
21628 if (opt
->canonical_name
)
21629 strcpy (selected_cpu_name
, opt
->canonical_name
);
21633 for (i
= 0; i
< optlen
; i
++)
21634 selected_cpu_name
[i
] = TOUPPER (opt
->name
[i
]);
21635 selected_cpu_name
[i
] = 0;
21639 return arm_parse_extension (ext
, &mcpu_cpu_opt
);
21644 as_bad (_("unknown cpu `%s'"), str
);
21649 arm_parse_arch (char * str
)
21651 const struct arm_arch_option_table
*opt
;
21652 char *ext
= strchr (str
, '+');
21656 optlen
= ext
- str
;
21658 optlen
= strlen (str
);
21662 as_bad (_("missing architecture name `%s'"), str
);
21666 for (opt
= arm_archs
; opt
->name
!= NULL
; opt
++)
21667 if (streq (opt
->name
, str
))
21669 march_cpu_opt
= &opt
->value
;
21670 march_fpu_opt
= &opt
->default_fpu
;
21671 strcpy (selected_cpu_name
, opt
->name
);
21674 return arm_parse_extension (ext
, &march_cpu_opt
);
21679 as_bad (_("unknown architecture `%s'\n"), str
);
21684 arm_parse_fpu (char * str
)
21686 const struct arm_option_cpu_value_table
* opt
;
21688 for (opt
= arm_fpus
; opt
->name
!= NULL
; opt
++)
21689 if (streq (opt
->name
, str
))
21691 mfpu_opt
= &opt
->value
;
21695 as_bad (_("unknown floating point format `%s'\n"), str
);
21700 arm_parse_float_abi (char * str
)
21702 const struct arm_option_value_table
* opt
;
21704 for (opt
= arm_float_abis
; opt
->name
!= NULL
; opt
++)
21705 if (streq (opt
->name
, str
))
21707 mfloat_abi_opt
= opt
->value
;
21711 as_bad (_("unknown floating point abi `%s'\n"), str
);
21717 arm_parse_eabi (char * str
)
21719 const struct arm_option_value_table
*opt
;
21721 for (opt
= arm_eabis
; opt
->name
!= NULL
; opt
++)
21722 if (streq (opt
->name
, str
))
21724 meabi_flags
= opt
->value
;
21727 as_bad (_("unknown EABI `%s'\n"), str
);
21733 arm_parse_it_mode (char * str
)
21737 if (streq ("arm", str
))
21738 implicit_it_mode
= IMPLICIT_IT_MODE_ARM
;
21739 else if (streq ("thumb", str
))
21740 implicit_it_mode
= IMPLICIT_IT_MODE_THUMB
;
21741 else if (streq ("always", str
))
21742 implicit_it_mode
= IMPLICIT_IT_MODE_ALWAYS
;
21743 else if (streq ("never", str
))
21744 implicit_it_mode
= IMPLICIT_IT_MODE_NEVER
;
21747 as_bad (_("unknown implicit IT mode `%s', should be "\
21748 "arm, thumb, always, or never."), str
);
21755 struct arm_long_option_table arm_long_opts
[] =
21757 {"mcpu=", N_("<cpu name>\t assemble for CPU <cpu name>"),
21758 arm_parse_cpu
, NULL
},
21759 {"march=", N_("<arch name>\t assemble for architecture <arch name>"),
21760 arm_parse_arch
, NULL
},
21761 {"mfpu=", N_("<fpu name>\t assemble for FPU architecture <fpu name>"),
21762 arm_parse_fpu
, NULL
},
21763 {"mfloat-abi=", N_("<abi>\t assemble for floating point ABI <abi>"),
21764 arm_parse_float_abi
, NULL
},
21766 {"meabi=", N_("<ver>\t\t assemble for eabi version <ver>"),
21767 arm_parse_eabi
, NULL
},
21769 {"mimplicit-it=", N_("<mode>\t controls implicit insertion of IT instructions"),
21770 arm_parse_it_mode
, NULL
},
21771 {NULL
, NULL
, 0, NULL
}
21775 md_parse_option (int c
, char * arg
)
21777 struct arm_option_table
*opt
;
21778 const struct arm_legacy_option_table
*fopt
;
21779 struct arm_long_option_table
*lopt
;
21785 target_big_endian
= 1;
21791 target_big_endian
= 0;
21795 case OPTION_FIX_V4BX
:
21800 /* Listing option. Just ignore these, we don't support additional
21805 for (opt
= arm_opts
; opt
->option
!= NULL
; opt
++)
21807 if (c
== opt
->option
[0]
21808 && ((arg
== NULL
&& opt
->option
[1] == 0)
21809 || streq (arg
, opt
->option
+ 1)))
21811 /* If the option is deprecated, tell the user. */
21812 if (warn_on_deprecated
&& opt
->deprecated
!= NULL
)
21813 as_tsktsk (_("option `-%c%s' is deprecated: %s"), c
,
21814 arg
? arg
: "", _(opt
->deprecated
));
21816 if (opt
->var
!= NULL
)
21817 *opt
->var
= opt
->value
;
21823 for (fopt
= arm_legacy_opts
; fopt
->option
!= NULL
; fopt
++)
21825 if (c
== fopt
->option
[0]
21826 && ((arg
== NULL
&& fopt
->option
[1] == 0)
21827 || streq (arg
, fopt
->option
+ 1)))
21829 /* If the option is deprecated, tell the user. */
21830 if (warn_on_deprecated
&& fopt
->deprecated
!= NULL
)
21831 as_tsktsk (_("option `-%c%s' is deprecated: %s"), c
,
21832 arg
? arg
: "", _(fopt
->deprecated
));
21834 if (fopt
->var
!= NULL
)
21835 *fopt
->var
= &fopt
->value
;
21841 for (lopt
= arm_long_opts
; lopt
->option
!= NULL
; lopt
++)
21843 /* These options are expected to have an argument. */
21844 if (c
== lopt
->option
[0]
21846 && strncmp (arg
, lopt
->option
+ 1,
21847 strlen (lopt
->option
+ 1)) == 0)
21849 /* If the option is deprecated, tell the user. */
21850 if (warn_on_deprecated
&& lopt
->deprecated
!= NULL
)
21851 as_tsktsk (_("option `-%c%s' is deprecated: %s"), c
, arg
,
21852 _(lopt
->deprecated
));
21854 /* Call the sup-option parser. */
21855 return lopt
->func (arg
+ strlen (lopt
->option
) - 1);
21866 md_show_usage (FILE * fp
)
21868 struct arm_option_table
*opt
;
21869 struct arm_long_option_table
*lopt
;
21871 fprintf (fp
, _(" ARM-specific assembler options:\n"));
21873 for (opt
= arm_opts
; opt
->option
!= NULL
; opt
++)
21874 if (opt
->help
!= NULL
)
21875 fprintf (fp
, " -%-23s%s\n", opt
->option
, _(opt
->help
));
21877 for (lopt
= arm_long_opts
; lopt
->option
!= NULL
; lopt
++)
21878 if (lopt
->help
!= NULL
)
21879 fprintf (fp
, " -%s%s\n", lopt
->option
, _(lopt
->help
));
21883 -EB assemble code for a big-endian cpu\n"));
21888 -EL assemble code for a little-endian cpu\n"));
21892 --fix-v4bx Allow BX in ARMv4 code\n"));
21900 arm_feature_set flags
;
21901 } cpu_arch_ver_table
;
21903 /* Mapping from CPU features to EABI CPU arch values. Table must be sorted
21904 least features first. */
21905 static const cpu_arch_ver_table cpu_arch_ver
[] =
21911 {4, ARM_ARCH_V5TE
},
21912 {5, ARM_ARCH_V5TEJ
},
21916 {11, ARM_ARCH_V6M
},
21917 {8, ARM_ARCH_V6T2
},
21918 {10, ARM_ARCH_V7A
},
21919 {10, ARM_ARCH_V7R
},
21920 {10, ARM_ARCH_V7M
},
21924 /* Set an attribute if it has not already been set by the user. */
21926 aeabi_set_attribute_int (int tag
, int value
)
21929 || tag
>= NUM_KNOWN_OBJ_ATTRIBUTES
21930 || !attributes_set_explicitly
[tag
])
21931 bfd_elf_add_proc_attr_int (stdoutput
, tag
, value
);
21935 aeabi_set_attribute_string (int tag
, const char *value
)
21938 || tag
>= NUM_KNOWN_OBJ_ATTRIBUTES
21939 || !attributes_set_explicitly
[tag
])
21940 bfd_elf_add_proc_attr_string (stdoutput
, tag
, value
);
21943 /* Set the public EABI object attributes. */
21945 aeabi_set_public_attributes (void)
21948 arm_feature_set flags
;
21949 arm_feature_set tmp
;
21950 const cpu_arch_ver_table
*p
;
21952 /* Choose the architecture based on the capabilities of the requested cpu
21953 (if any) and/or the instructions actually used. */
21954 ARM_MERGE_FEATURE_SETS (flags
, arm_arch_used
, thumb_arch_used
);
21955 ARM_MERGE_FEATURE_SETS (flags
, flags
, *mfpu_opt
);
21956 ARM_MERGE_FEATURE_SETS (flags
, flags
, selected_cpu
);
21957 /*Allow the user to override the reported architecture. */
21960 ARM_CLEAR_FEATURE (flags
, flags
, arm_arch_any
);
21961 ARM_MERGE_FEATURE_SETS (flags
, flags
, *object_arch
);
21966 for (p
= cpu_arch_ver
; p
->val
; p
++)
21968 if (ARM_CPU_HAS_FEATURE (tmp
, p
->flags
))
21971 ARM_CLEAR_FEATURE (tmp
, tmp
, p
->flags
);
21975 /* Tag_CPU_name. */
21976 if (selected_cpu_name
[0])
21980 p
= selected_cpu_name
;
21981 if (strncmp (p
, "armv", 4) == 0)
21986 for (i
= 0; p
[i
]; i
++)
21987 p
[i
] = TOUPPER (p
[i
]);
21989 aeabi_set_attribute_string (Tag_CPU_name
, p
);
21991 /* Tag_CPU_arch. */
21992 aeabi_set_attribute_int (Tag_CPU_arch
, arch
);
21993 /* Tag_CPU_arch_profile. */
21994 if (ARM_CPU_HAS_FEATURE (flags
, arm_ext_v7a
))
21995 aeabi_set_attribute_int (Tag_CPU_arch_profile
, 'A');
21996 else if (ARM_CPU_HAS_FEATURE (flags
, arm_ext_v7r
))
21997 aeabi_set_attribute_int (Tag_CPU_arch_profile
, 'R');
21998 else if (ARM_CPU_HAS_FEATURE (flags
, arm_ext_m
))
21999 aeabi_set_attribute_int (Tag_CPU_arch_profile
, 'M');
22000 /* Tag_ARM_ISA_use. */
22001 if (ARM_CPU_HAS_FEATURE (flags
, arm_ext_v1
)
22003 aeabi_set_attribute_int (Tag_ARM_ISA_use
, 1);
22004 /* Tag_THUMB_ISA_use. */
22005 if (ARM_CPU_HAS_FEATURE (flags
, arm_ext_v4t
)
22007 aeabi_set_attribute_int (Tag_THUMB_ISA_use
,
22008 ARM_CPU_HAS_FEATURE (flags
, arm_arch_t2
) ? 2 : 1);
22009 /* Tag_VFP_arch. */
22010 if (ARM_CPU_HAS_FEATURE (flags
, fpu_vfp_ext_d32
))
22011 aeabi_set_attribute_int (Tag_VFP_arch
, 3);
22012 else if (ARM_CPU_HAS_FEATURE (flags
, fpu_vfp_ext_v3
))
22013 aeabi_set_attribute_int (Tag_VFP_arch
, 4);
22014 else if (ARM_CPU_HAS_FEATURE (flags
, fpu_vfp_ext_v2
))
22015 aeabi_set_attribute_int (Tag_VFP_arch
, 2);
22016 else if (ARM_CPU_HAS_FEATURE (flags
, fpu_vfp_ext_v1
)
22017 || ARM_CPU_HAS_FEATURE (flags
, fpu_vfp_ext_v1xd
))
22018 aeabi_set_attribute_int (Tag_VFP_arch
, 1);
22019 /* Tag_WMMX_arch. */
22020 if (ARM_CPU_HAS_FEATURE (flags
, arm_cext_iwmmxt2
))
22021 aeabi_set_attribute_int (Tag_WMMX_arch
, 2);
22022 else if (ARM_CPU_HAS_FEATURE (flags
, arm_cext_iwmmxt
))
22023 aeabi_set_attribute_int (Tag_WMMX_arch
, 1);
22024 /* Tag_Advanced_SIMD_arch (formerly Tag_NEON_arch). */
22025 if (ARM_CPU_HAS_FEATURE (flags
, fpu_neon_ext_v1
))
22026 aeabi_set_attribute_int (Tag_Advanced_SIMD_arch
, 1);
22027 /* Tag_VFP_HP_extension (formerly Tag_NEON_FP16_arch). */
22028 if (ARM_CPU_HAS_FEATURE (flags
, fpu_neon_fp16
))
22029 aeabi_set_attribute_int (Tag_VFP_HP_extension
, 1);
22032 /* Add the default contents for the .ARM.attributes section. */
22036 if (EF_ARM_EABI_VERSION (meabi_flags
) < EF_ARM_EABI_VER4
)
22039 aeabi_set_public_attributes ();
22041 #endif /* OBJ_ELF */
22044 /* Parse a .cpu directive. */
22047 s_arm_cpu (int ignored ATTRIBUTE_UNUSED
)
22049 const struct arm_cpu_option_table
*opt
;
22053 name
= input_line_pointer
;
22054 while (*input_line_pointer
&& !ISSPACE (*input_line_pointer
))
22055 input_line_pointer
++;
22056 saved_char
= *input_line_pointer
;
22057 *input_line_pointer
= 0;
22059 /* Skip the first "all" entry. */
22060 for (opt
= arm_cpus
+ 1; opt
->name
!= NULL
; opt
++)
22061 if (streq (opt
->name
, name
))
22063 mcpu_cpu_opt
= &opt
->value
;
22064 selected_cpu
= opt
->value
;
22065 if (opt
->canonical_name
)
22066 strcpy (selected_cpu_name
, opt
->canonical_name
);
22070 for (i
= 0; opt
->name
[i
]; i
++)
22071 selected_cpu_name
[i
] = TOUPPER (opt
->name
[i
]);
22072 selected_cpu_name
[i
] = 0;
22074 ARM_MERGE_FEATURE_SETS (cpu_variant
, *mcpu_cpu_opt
, *mfpu_opt
);
22075 *input_line_pointer
= saved_char
;
22076 demand_empty_rest_of_line ();
22079 as_bad (_("unknown cpu `%s'"), name
);
22080 *input_line_pointer
= saved_char
;
22081 ignore_rest_of_line ();
22085 /* Parse a .arch directive. */
22088 s_arm_arch (int ignored ATTRIBUTE_UNUSED
)
22090 const struct arm_arch_option_table
*opt
;
22094 name
= input_line_pointer
;
22095 while (*input_line_pointer
&& !ISSPACE (*input_line_pointer
))
22096 input_line_pointer
++;
22097 saved_char
= *input_line_pointer
;
22098 *input_line_pointer
= 0;
22100 /* Skip the first "all" entry. */
22101 for (opt
= arm_archs
+ 1; opt
->name
!= NULL
; opt
++)
22102 if (streq (opt
->name
, name
))
22104 mcpu_cpu_opt
= &opt
->value
;
22105 selected_cpu
= opt
->value
;
22106 strcpy (selected_cpu_name
, opt
->name
);
22107 ARM_MERGE_FEATURE_SETS (cpu_variant
, *mcpu_cpu_opt
, *mfpu_opt
);
22108 *input_line_pointer
= saved_char
;
22109 demand_empty_rest_of_line ();
22113 as_bad (_("unknown architecture `%s'\n"), name
);
22114 *input_line_pointer
= saved_char
;
22115 ignore_rest_of_line ();
22119 /* Parse a .object_arch directive. */
22122 s_arm_object_arch (int ignored ATTRIBUTE_UNUSED
)
22124 const struct arm_arch_option_table
*opt
;
22128 name
= input_line_pointer
;
22129 while (*input_line_pointer
&& !ISSPACE (*input_line_pointer
))
22130 input_line_pointer
++;
22131 saved_char
= *input_line_pointer
;
22132 *input_line_pointer
= 0;
22134 /* Skip the first "all" entry. */
22135 for (opt
= arm_archs
+ 1; opt
->name
!= NULL
; opt
++)
22136 if (streq (opt
->name
, name
))
22138 object_arch
= &opt
->value
;
22139 *input_line_pointer
= saved_char
;
22140 demand_empty_rest_of_line ();
22144 as_bad (_("unknown architecture `%s'\n"), name
);
22145 *input_line_pointer
= saved_char
;
22146 ignore_rest_of_line ();
22149 /* Parse a .fpu directive. */
22152 s_arm_fpu (int ignored ATTRIBUTE_UNUSED
)
22154 const struct arm_option_cpu_value_table
*opt
;
22158 name
= input_line_pointer
;
22159 while (*input_line_pointer
&& !ISSPACE (*input_line_pointer
))
22160 input_line_pointer
++;
22161 saved_char
= *input_line_pointer
;
22162 *input_line_pointer
= 0;
22164 for (opt
= arm_fpus
; opt
->name
!= NULL
; opt
++)
22165 if (streq (opt
->name
, name
))
22167 mfpu_opt
= &opt
->value
;
22168 ARM_MERGE_FEATURE_SETS (cpu_variant
, *mcpu_cpu_opt
, *mfpu_opt
);
22169 *input_line_pointer
= saved_char
;
22170 demand_empty_rest_of_line ();
22174 as_bad (_("unknown floating point format `%s'\n"), name
);
22175 *input_line_pointer
= saved_char
;
22176 ignore_rest_of_line ();
22179 /* Copy symbol information. */
22182 arm_copy_symbol_attributes (symbolS
*dest
, symbolS
*src
)
22184 ARM_GET_FLAG (dest
) = ARM_GET_FLAG (src
);
22188 /* Given a symbolic attribute NAME, return the proper integer value.
22189 Returns -1 if the attribute is not known. */
22192 arm_convert_symbolic_attribute (const char *name
)
22194 static const struct
22199 attribute_table
[] =
22201 /* When you modify this table you should
22202 also modify the list in doc/c-arm.texi. */
22203 #define T(tag) {#tag, tag}
22204 T (Tag_CPU_raw_name
),
22207 T (Tag_CPU_arch_profile
),
22208 T (Tag_ARM_ISA_use
),
22209 T (Tag_THUMB_ISA_use
),
22212 T (Tag_Advanced_SIMD_arch
),
22213 T (Tag_PCS_config
),
22214 T (Tag_ABI_PCS_R9_use
),
22215 T (Tag_ABI_PCS_RW_data
),
22216 T (Tag_ABI_PCS_RO_data
),
22217 T (Tag_ABI_PCS_GOT_use
),
22218 T (Tag_ABI_PCS_wchar_t
),
22219 T (Tag_ABI_FP_rounding
),
22220 T (Tag_ABI_FP_denormal
),
22221 T (Tag_ABI_FP_exceptions
),
22222 T (Tag_ABI_FP_user_exceptions
),
22223 T (Tag_ABI_FP_number_model
),
22224 T (Tag_ABI_align8_needed
),
22225 T (Tag_ABI_align8_preserved
),
22226 T (Tag_ABI_enum_size
),
22227 T (Tag_ABI_HardFP_use
),
22228 T (Tag_ABI_VFP_args
),
22229 T (Tag_ABI_WMMX_args
),
22230 T (Tag_ABI_optimization_goals
),
22231 T (Tag_ABI_FP_optimization_goals
),
22232 T (Tag_compatibility
),
22233 T (Tag_CPU_unaligned_access
),
22234 T (Tag_VFP_HP_extension
),
22235 T (Tag_ABI_FP_16bit_format
),
22236 T (Tag_nodefaults
),
22237 T (Tag_also_compatible_with
),
22238 T (Tag_conformance
),
22240 T (Tag_Virtualization_use
),
22241 T (Tag_MPextension_use
)
22249 for (i
= 0; i
< ARRAY_SIZE (attribute_table
); i
++)
22250 if (strcmp (name
, attribute_table
[i
].name
) == 0)
22251 return attribute_table
[i
].tag
;
22257 /* Apply sym value for relocations only in the case that
22258 they are for local symbols and you have the respective
22259 architectural feature for blx and simple switches. */
22261 arm_apply_sym_value (struct fix
* fixP
)
22264 && ARM_CPU_HAS_FEATURE (selected_cpu
, arm_ext_v5t
)
22265 && !S_IS_EXTERNAL (fixP
->fx_addsy
))
22267 switch (fixP
->fx_r_type
)
22269 case BFD_RELOC_ARM_PCREL_BLX
:
22270 case BFD_RELOC_THUMB_PCREL_BRANCH23
:
22271 if (ARM_IS_FUNC (fixP
->fx_addsy
))
22275 case BFD_RELOC_ARM_PCREL_CALL
:
22276 case BFD_RELOC_THUMB_PCREL_BLX
:
22277 if (THUMB_IS_FUNC (fixP
->fx_addsy
))
22288 #endif /* OBJ_ELF */