1 /* tc-aarch64.c -- Assemble for the AArch64 ISA
3 Copyright (C) 2009-2018 Free Software Foundation, Inc.
4 Contributed by ARM Ltd.
6 This file is part of GAS.
8 GAS is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the license, or
11 (at your option) any later version.
13 GAS is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; see the file COPYING3. If not,
20 see <http://www.gnu.org/licenses/>. */
25 #include "bfd_stdint.h"
27 #include "safe-ctype.h"
32 #include "elf/aarch64.h"
33 #include "dw2gencfi.h"
36 #include "dwarf2dbg.h"
38 /* Types of processor to assemble for. */
40 #define CPU_DEFAULT AARCH64_ARCH_V8
43 #define streq(a, b) (strcmp (a, b) == 0)
45 #define END_OF_INSN '\0'
47 static aarch64_feature_set cpu_variant
;
49 /* Variables that we set while parsing command-line options. Once all
50 options have been read we re-process these values to set the real
52 static const aarch64_feature_set
*mcpu_cpu_opt
= NULL
;
53 static const aarch64_feature_set
*march_cpu_opt
= NULL
;
55 /* Constants for known architecture features. */
56 static const aarch64_feature_set cpu_default
= CPU_DEFAULT
;
59 /* Pre-defined "_GLOBAL_OFFSET_TABLE_" */
60 static symbolS
*GOT_symbol
;
62 /* Which ABI to use. */
71 #define DEFAULT_ARCH "aarch64"
74 /* DEFAULT_ARCH is initialized in gas/configure.tgt. */
75 static const char *default_arch
= DEFAULT_ARCH
;
77 /* AArch64 ABI for the output file. */
78 static enum aarch64_abi_type aarch64_abi
= AARCH64_ABI_NONE
;
80 /* When non-zero, program to a 32-bit model, in which the C data types
81 int, long and all pointer types are 32-bit objects (ILP32); or to a
82 64-bit model, in which the C int type is 32-bits but the C long type
83 and all pointer types are 64-bit objects (LP64). */
84 #define ilp32_p (aarch64_abi == AARCH64_ABI_ILP32)
99 /* Bits for DEFINED field in vector_type_el. */
100 #define NTA_HASTYPE 1
101 #define NTA_HASINDEX 2
102 #define NTA_HASVARWIDTH 4
104 struct vector_type_el
106 enum vector_el_type type
;
107 unsigned char defined
;
112 #define FIXUP_F_HAS_EXPLICIT_SHIFT 0x00000001
116 bfd_reloc_code_real_type type
;
119 enum aarch64_opnd opnd
;
121 unsigned need_libopcodes_p
: 1;
124 struct aarch64_instruction
126 /* libopcodes structure for instruction intermediate representation. */
128 /* Record assembly errors found during the parsing. */
131 enum aarch64_operand_error_kind kind
;
134 /* The condition that appears in the assembly line. */
136 /* Relocation information (including the GAS internal fixup). */
138 /* Need to generate an immediate in the literal pool. */
139 unsigned gen_lit_pool
: 1;
142 typedef struct aarch64_instruction aarch64_instruction
;
144 static aarch64_instruction inst
;
146 static bfd_boolean
parse_operands (char *, const aarch64_opcode
*);
147 static bfd_boolean
programmer_friendly_fixup (aarch64_instruction
*);
149 /* Diagnostics inline function utilities.
151 These are lightweight utilities which should only be called by parse_operands
152 and other parsers. GAS processes each assembly line by parsing it against
153 instruction template(s), in the case of multiple templates (for the same
154 mnemonic name), those templates are tried one by one until one succeeds or
155 all fail. An assembly line may fail a few templates before being
156 successfully parsed; an error saved here in most cases is not a user error
157 but an error indicating the current template is not the right template.
158 Therefore it is very important that errors can be saved at a low cost during
159 the parsing; we don't want to slow down the whole parsing by recording
160 non-user errors in detail.
162 Remember that the objective is to help GAS pick up the most appropriate
163 error message in the case of multiple templates, e.g. FMOV which has 8
169 inst
.parsing_error
.kind
= AARCH64_OPDE_NIL
;
170 inst
.parsing_error
.error
= NULL
;
173 static inline bfd_boolean
176 return inst
.parsing_error
.kind
!= AARCH64_OPDE_NIL
;
179 static inline const char *
180 get_error_message (void)
182 return inst
.parsing_error
.error
;
185 static inline enum aarch64_operand_error_kind
186 get_error_kind (void)
188 return inst
.parsing_error
.kind
;
192 set_error (enum aarch64_operand_error_kind kind
, const char *error
)
194 inst
.parsing_error
.kind
= kind
;
195 inst
.parsing_error
.error
= error
;
199 set_recoverable_error (const char *error
)
201 set_error (AARCH64_OPDE_RECOVERABLE
, error
);
204 /* Use the DESC field of the corresponding aarch64_operand entry to compose
205 the error message. */
207 set_default_error (void)
209 set_error (AARCH64_OPDE_SYNTAX_ERROR
, NULL
);
213 set_syntax_error (const char *error
)
215 set_error (AARCH64_OPDE_SYNTAX_ERROR
, error
);
219 set_first_syntax_error (const char *error
)
222 set_error (AARCH64_OPDE_SYNTAX_ERROR
, error
);
226 set_fatal_syntax_error (const char *error
)
228 set_error (AARCH64_OPDE_FATAL_SYNTAX_ERROR
, error
);
231 /* Number of littlenums required to hold an extended precision number. */
232 #define MAX_LITTLENUMS 6
234 /* Return value for certain parsers when the parsing fails; those parsers
235 return the information of the parsed result, e.g. register number, on
237 #define PARSE_FAIL -1
239 /* This is an invalid condition code that means no conditional field is
241 #define COND_ALWAYS 0x10
245 const char *template;
251 const char *template;
258 bfd_reloc_code_real_type reloc
;
261 /* Macros to define the register types and masks for the purpose
264 #undef AARCH64_REG_TYPES
265 #define AARCH64_REG_TYPES \
266 BASIC_REG_TYPE(R_32) /* w[0-30] */ \
267 BASIC_REG_TYPE(R_64) /* x[0-30] */ \
268 BASIC_REG_TYPE(SP_32) /* wsp */ \
269 BASIC_REG_TYPE(SP_64) /* sp */ \
270 BASIC_REG_TYPE(Z_32) /* wzr */ \
271 BASIC_REG_TYPE(Z_64) /* xzr */ \
272 BASIC_REG_TYPE(FP_B) /* b[0-31] *//* NOTE: keep FP_[BHSDQ] consecutive! */\
273 BASIC_REG_TYPE(FP_H) /* h[0-31] */ \
274 BASIC_REG_TYPE(FP_S) /* s[0-31] */ \
275 BASIC_REG_TYPE(FP_D) /* d[0-31] */ \
276 BASIC_REG_TYPE(FP_Q) /* q[0-31] */ \
277 BASIC_REG_TYPE(VN) /* v[0-31] */ \
278 BASIC_REG_TYPE(ZN) /* z[0-31] */ \
279 BASIC_REG_TYPE(PN) /* p[0-15] */ \
280 /* Typecheck: any 64-bit int reg (inc SP exc XZR). */ \
281 MULTI_REG_TYPE(R64_SP, REG_TYPE(R_64) | REG_TYPE(SP_64)) \
282 /* Typecheck: same, plus SVE registers. */ \
283 MULTI_REG_TYPE(SVE_BASE, REG_TYPE(R_64) | REG_TYPE(SP_64) \
285 /* Typecheck: x[0-30], w[0-30] or [xw]zr. */ \
286 MULTI_REG_TYPE(R_Z, REG_TYPE(R_32) | REG_TYPE(R_64) \
287 | REG_TYPE(Z_32) | REG_TYPE(Z_64)) \
288 /* Typecheck: same, plus SVE registers. */ \
289 MULTI_REG_TYPE(SVE_OFFSET, REG_TYPE(R_32) | REG_TYPE(R_64) \
290 | REG_TYPE(Z_32) | REG_TYPE(Z_64) \
292 /* Typecheck: x[0-30], w[0-30] or {w}sp. */ \
293 MULTI_REG_TYPE(R_SP, REG_TYPE(R_32) | REG_TYPE(R_64) \
294 | REG_TYPE(SP_32) | REG_TYPE(SP_64)) \
295 /* Typecheck: any int (inc {W}SP inc [WX]ZR). */ \
296 MULTI_REG_TYPE(R_Z_SP, REG_TYPE(R_32) | REG_TYPE(R_64) \
297 | REG_TYPE(SP_32) | REG_TYPE(SP_64) \
298 | REG_TYPE(Z_32) | REG_TYPE(Z_64)) \
299 /* Typecheck: any [BHSDQ]P FP. */ \
300 MULTI_REG_TYPE(BHSDQ, REG_TYPE(FP_B) | REG_TYPE(FP_H) \
301 | REG_TYPE(FP_S) | REG_TYPE(FP_D) | REG_TYPE(FP_Q)) \
302 /* Typecheck: any int or [BHSDQ]P FP or V reg (exc SP inc [WX]ZR). */ \
303 MULTI_REG_TYPE(R_Z_BHSDQ_V, REG_TYPE(R_32) | REG_TYPE(R_64) \
304 | REG_TYPE(Z_32) | REG_TYPE(Z_64) | REG_TYPE(VN) \
305 | REG_TYPE(FP_B) | REG_TYPE(FP_H) \
306 | REG_TYPE(FP_S) | REG_TYPE(FP_D) | REG_TYPE(FP_Q)) \
307 /* Typecheck: as above, but also Zn, Pn, and {W}SP. This should only \
308 be used for SVE instructions, since Zn and Pn are valid symbols \
309 in other contexts. */ \
310 MULTI_REG_TYPE(R_Z_SP_BHSDQ_VZP, REG_TYPE(R_32) | REG_TYPE(R_64) \
311 | REG_TYPE(SP_32) | REG_TYPE(SP_64) \
312 | REG_TYPE(Z_32) | REG_TYPE(Z_64) | REG_TYPE(VN) \
313 | REG_TYPE(FP_B) | REG_TYPE(FP_H) \
314 | REG_TYPE(FP_S) | REG_TYPE(FP_D) | REG_TYPE(FP_Q) \
315 | REG_TYPE(ZN) | REG_TYPE(PN)) \
316 /* Any integer register; used for error messages only. */ \
317 MULTI_REG_TYPE(R_N, REG_TYPE(R_32) | REG_TYPE(R_64) \
318 | REG_TYPE(SP_32) | REG_TYPE(SP_64) \
319 | REG_TYPE(Z_32) | REG_TYPE(Z_64)) \
320 /* Pseudo type to mark the end of the enumerator sequence. */ \
323 #undef BASIC_REG_TYPE
324 #define BASIC_REG_TYPE(T) REG_TYPE_##T,
325 #undef MULTI_REG_TYPE
326 #define MULTI_REG_TYPE(T,V) BASIC_REG_TYPE(T)
328 /* Register type enumerators. */
329 typedef enum aarch64_reg_type_
331 /* A list of REG_TYPE_*. */
335 #undef BASIC_REG_TYPE
336 #define BASIC_REG_TYPE(T) 1 << REG_TYPE_##T,
338 #define REG_TYPE(T) (1 << REG_TYPE_##T)
339 #undef MULTI_REG_TYPE
340 #define MULTI_REG_TYPE(T,V) V,
342 /* Structure for a hash table entry for a register. */
346 unsigned char number
;
347 ENUM_BITFIELD (aarch64_reg_type_
) type
: 8;
348 unsigned char builtin
;
351 /* Values indexed by aarch64_reg_type to assist the type checking. */
352 static const unsigned reg_type_masks
[] =
357 #undef BASIC_REG_TYPE
359 #undef MULTI_REG_TYPE
360 #undef AARCH64_REG_TYPES
362 /* Diagnostics used when we don't get a register of the expected type.
363 Note: this has to synchronized with aarch64_reg_type definitions
366 get_reg_expected_msg (aarch64_reg_type reg_type
)
373 msg
= N_("integer 32-bit register expected");
376 msg
= N_("integer 64-bit register expected");
379 msg
= N_("integer register expected");
381 case REG_TYPE_R64_SP
:
382 msg
= N_("64-bit integer or SP register expected");
384 case REG_TYPE_SVE_BASE
:
385 msg
= N_("base register expected");
388 msg
= N_("integer or zero register expected");
390 case REG_TYPE_SVE_OFFSET
:
391 msg
= N_("offset register expected");
394 msg
= N_("integer or SP register expected");
396 case REG_TYPE_R_Z_SP
:
397 msg
= N_("integer, zero or SP register expected");
400 msg
= N_("8-bit SIMD scalar register expected");
403 msg
= N_("16-bit SIMD scalar or floating-point half precision "
404 "register expected");
407 msg
= N_("32-bit SIMD scalar or floating-point single precision "
408 "register expected");
411 msg
= N_("64-bit SIMD scalar or floating-point double precision "
412 "register expected");
415 msg
= N_("128-bit SIMD scalar or floating-point quad precision "
416 "register expected");
418 case REG_TYPE_R_Z_BHSDQ_V
:
419 case REG_TYPE_R_Z_SP_BHSDQ_VZP
:
420 msg
= N_("register expected");
422 case REG_TYPE_BHSDQ
: /* any [BHSDQ]P FP */
423 msg
= N_("SIMD scalar or floating-point register expected");
425 case REG_TYPE_VN
: /* any V reg */
426 msg
= N_("vector register expected");
429 msg
= N_("SVE vector register expected");
432 msg
= N_("SVE predicate register expected");
435 as_fatal (_("invalid register type %d"), reg_type
);
440 /* Some well known registers that we refer to directly elsewhere. */
443 /* Instructions take 4 bytes in the object file. */
446 static struct hash_control
*aarch64_ops_hsh
;
447 static struct hash_control
*aarch64_cond_hsh
;
448 static struct hash_control
*aarch64_shift_hsh
;
449 static struct hash_control
*aarch64_sys_regs_hsh
;
450 static struct hash_control
*aarch64_pstatefield_hsh
;
451 static struct hash_control
*aarch64_sys_regs_ic_hsh
;
452 static struct hash_control
*aarch64_sys_regs_dc_hsh
;
453 static struct hash_control
*aarch64_sys_regs_at_hsh
;
454 static struct hash_control
*aarch64_sys_regs_tlbi_hsh
;
455 static struct hash_control
*aarch64_reg_hsh
;
456 static struct hash_control
*aarch64_barrier_opt_hsh
;
457 static struct hash_control
*aarch64_nzcv_hsh
;
458 static struct hash_control
*aarch64_pldop_hsh
;
459 static struct hash_control
*aarch64_hint_opt_hsh
;
461 /* Stuff needed to resolve the label ambiguity
470 static symbolS
*last_label_seen
;
472 /* Literal pool structure. Held on a per-section
473 and per-sub-section basis. */
475 #define MAX_LITERAL_POOL_SIZE 1024
476 typedef struct literal_expression
479 /* If exp.op == O_big then this bignum holds a copy of the global bignum value. */
480 LITTLENUM_TYPE
* bignum
;
481 } literal_expression
;
483 typedef struct literal_pool
485 literal_expression literals
[MAX_LITERAL_POOL_SIZE
];
486 unsigned int next_free_entry
;
492 struct literal_pool
*next
;
495 /* Pointer to a linked list of literal pools. */
496 static literal_pool
*list_of_pools
= NULL
;
500 /* This array holds the chars that always start a comment. If the
501 pre-processor is disabled, these aren't very useful. */
502 const char comment_chars
[] = "";
504 /* This array holds the chars that only start a comment at the beginning of
505 a line. If the line seems to have the form '# 123 filename'
506 .line and .file directives will appear in the pre-processed output. */
507 /* Note that input_file.c hand checks for '#' at the beginning of the
508 first line of the input file. This is because the compiler outputs
509 #NO_APP at the beginning of its output. */
510 /* Also note that comments like this one will always work. */
511 const char line_comment_chars
[] = "#";
513 const char line_separator_chars
[] = ";";
515 /* Chars that can be used to separate mant
516 from exp in floating point numbers. */
517 const char EXP_CHARS
[] = "eE";
519 /* Chars that mean this number is a floating point constant. */
523 const char FLT_CHARS
[] = "rRsSfFdDxXeEpP";
525 /* Prefix character that indicates the start of an immediate value. */
526 #define is_immediate_prefix(C) ((C) == '#')
528 /* Separator character handling. */
530 #define skip_whitespace(str) do { if (*(str) == ' ') ++(str); } while (0)
532 static inline bfd_boolean
533 skip_past_char (char **str
, char c
)
544 #define skip_past_comma(str) skip_past_char (str, ',')
546 /* Arithmetic expressions (possibly involving symbols). */
548 static bfd_boolean in_my_get_expression_p
= FALSE
;
550 /* Third argument to my_get_expression. */
551 #define GE_NO_PREFIX 0
552 #define GE_OPT_PREFIX 1
554 /* Return TRUE if the string pointed by *STR is successfully parsed
555 as an valid expression; *EP will be filled with the information of
556 such an expression. Otherwise return FALSE. */
559 my_get_expression (expressionS
* ep
, char **str
, int prefix_mode
,
564 int prefix_present_p
= 0;
571 if (is_immediate_prefix (**str
))
574 prefix_present_p
= 1;
581 memset (ep
, 0, sizeof (expressionS
));
583 save_in
= input_line_pointer
;
584 input_line_pointer
= *str
;
585 in_my_get_expression_p
= TRUE
;
586 seg
= expression (ep
);
587 in_my_get_expression_p
= FALSE
;
589 if (ep
->X_op
== O_illegal
|| (reject_absent
&& ep
->X_op
== O_absent
))
591 /* We found a bad expression in md_operand(). */
592 *str
= input_line_pointer
;
593 input_line_pointer
= save_in
;
594 if (prefix_present_p
&& ! error_p ())
595 set_fatal_syntax_error (_("bad expression"));
597 set_first_syntax_error (_("bad expression"));
602 if (seg
!= absolute_section
603 && seg
!= text_section
604 && seg
!= data_section
605 && seg
!= bss_section
&& seg
!= undefined_section
)
607 set_syntax_error (_("bad segment"));
608 *str
= input_line_pointer
;
609 input_line_pointer
= save_in
;
616 *str
= input_line_pointer
;
617 input_line_pointer
= save_in
;
621 /* Turn a string in input_line_pointer into a floating point constant
622 of type TYPE, and store the appropriate bytes in *LITP. The number
623 of LITTLENUMS emitted is stored in *SIZEP. An error message is
624 returned, or NULL on OK. */
627 md_atof (int type
, char *litP
, int *sizeP
)
629 return ieee_md_atof (type
, litP
, sizeP
, target_big_endian
);
632 /* We handle all bad expressions here, so that we can report the faulty
633 instruction in the error message. */
635 md_operand (expressionS
* exp
)
637 if (in_my_get_expression_p
)
638 exp
->X_op
= O_illegal
;
641 /* Immediate values. */
643 /* Errors may be set multiple times during parsing or bit encoding
644 (particularly in the Neon bits), but usually the earliest error which is set
645 will be the most meaningful. Avoid overwriting it with later (cascading)
646 errors by calling this function. */
649 first_error (const char *error
)
652 set_syntax_error (error
);
655 /* Similar to first_error, but this function accepts formatted error
658 first_error_fmt (const char *format
, ...)
663 /* N.B. this single buffer will not cause error messages for different
664 instructions to pollute each other; this is because at the end of
665 processing of each assembly line, error message if any will be
666 collected by as_bad. */
667 static char buffer
[size
];
671 int ret ATTRIBUTE_UNUSED
;
672 va_start (args
, format
);
673 ret
= vsnprintf (buffer
, size
, format
, args
);
674 know (ret
<= size
- 1 && ret
>= 0);
676 set_syntax_error (buffer
);
680 /* Register parsing. */
682 /* Generic register parser which is called by other specialized
684 CCP points to what should be the beginning of a register name.
685 If it is indeed a valid register name, advance CCP over it and
686 return the reg_entry structure; otherwise return NULL.
687 It does not issue diagnostics. */
690 parse_reg (char **ccp
)
696 #ifdef REGISTER_PREFIX
697 if (*start
!= REGISTER_PREFIX
)
703 if (!ISALPHA (*p
) || !is_name_beginner (*p
))
708 while (ISALPHA (*p
) || ISDIGIT (*p
) || *p
== '_');
710 reg
= (reg_entry
*) hash_find_n (aarch64_reg_hsh
, start
, p
- start
);
719 /* Return TRUE if REG->TYPE is a valid type of TYPE; otherwise
722 aarch64_check_reg_type (const reg_entry
*reg
, aarch64_reg_type type
)
724 return (reg_type_masks
[type
] & (1 << reg
->type
)) != 0;
727 /* Try to parse a base or offset register. Allow SVE base and offset
728 registers if REG_TYPE includes SVE registers. Return the register
729 entry on success, setting *QUALIFIER to the register qualifier.
730 Return null otherwise.
732 Note that this function does not issue any diagnostics. */
734 static const reg_entry
*
735 aarch64_addr_reg_parse (char **ccp
, aarch64_reg_type reg_type
,
736 aarch64_opnd_qualifier_t
*qualifier
)
739 const reg_entry
*reg
= parse_reg (&str
);
749 *qualifier
= AARCH64_OPND_QLF_W
;
755 *qualifier
= AARCH64_OPND_QLF_X
;
759 if ((reg_type_masks
[reg_type
] & (1 << REG_TYPE_ZN
)) == 0
762 switch (TOLOWER (str
[1]))
765 *qualifier
= AARCH64_OPND_QLF_S_S
;
768 *qualifier
= AARCH64_OPND_QLF_S_D
;
785 /* Try to parse a base or offset register. Return the register entry
786 on success, setting *QUALIFIER to the register qualifier. Return null
789 Note that this function does not issue any diagnostics. */
791 static const reg_entry
*
792 aarch64_reg_parse_32_64 (char **ccp
, aarch64_opnd_qualifier_t
*qualifier
)
794 return aarch64_addr_reg_parse (ccp
, REG_TYPE_R_Z_SP
, qualifier
);
797 /* Parse the qualifier of a vector register or vector element of type
798 REG_TYPE. Fill in *PARSED_TYPE and return TRUE if the parsing
799 succeeds; otherwise return FALSE.
801 Accept only one occurrence of:
802 4b 8b 16b 2h 4h 8h 2s 4s 1d 2d
805 parse_vector_type_for_operand (aarch64_reg_type reg_type
,
806 struct vector_type_el
*parsed_type
, char **str
)
810 unsigned element_size
;
811 enum vector_el_type type
;
814 gas_assert (*ptr
== '.');
817 if (reg_type
== REG_TYPE_ZN
|| reg_type
== REG_TYPE_PN
|| !ISDIGIT (*ptr
))
822 width
= strtoul (ptr
, &ptr
, 10);
823 if (width
!= 1 && width
!= 2 && width
!= 4 && width
!= 8 && width
!= 16)
825 first_error_fmt (_("bad size %d in vector width specifier"), width
);
830 switch (TOLOWER (*ptr
))
849 if (reg_type
== REG_TYPE_ZN
|| width
== 1)
858 first_error_fmt (_("unexpected character `%c' in element size"), *ptr
);
860 first_error (_("missing element size"));
863 if (width
!= 0 && width
* element_size
!= 64
864 && width
* element_size
!= 128
865 && !(width
== 2 && element_size
== 16)
866 && !(width
== 4 && element_size
== 8))
869 ("invalid element size %d and vector size combination %c"),
875 parsed_type
->type
= type
;
876 parsed_type
->width
= width
;
883 /* *STR contains an SVE zero/merge predication suffix. Parse it into
884 *PARSED_TYPE and point *STR at the end of the suffix. */
887 parse_predication_for_operand (struct vector_type_el
*parsed_type
, char **str
)
892 gas_assert (*ptr
== '/');
894 switch (TOLOWER (*ptr
))
897 parsed_type
->type
= NT_zero
;
900 parsed_type
->type
= NT_merge
;
903 if (*ptr
!= '\0' && *ptr
!= ',')
904 first_error_fmt (_("unexpected character `%c' in predication type"),
907 first_error (_("missing predication type"));
910 parsed_type
->width
= 0;
915 /* Parse a register of the type TYPE.
917 Return PARSE_FAIL if the string pointed by *CCP is not a valid register
918 name or the parsed register is not of TYPE.
920 Otherwise return the register number, and optionally fill in the actual
921 type of the register in *RTYPE when multiple alternatives were given, and
922 return the register shape and element index information in *TYPEINFO.
924 IN_REG_LIST should be set with TRUE if the caller is parsing a register
928 parse_typed_reg (char **ccp
, aarch64_reg_type type
, aarch64_reg_type
*rtype
,
929 struct vector_type_el
*typeinfo
, bfd_boolean in_reg_list
)
932 const reg_entry
*reg
= parse_reg (&str
);
933 struct vector_type_el atype
;
934 struct vector_type_el parsetype
;
935 bfd_boolean is_typed_vecreg
= FALSE
;
938 atype
.type
= NT_invtype
;
946 set_default_error ();
950 if (! aarch64_check_reg_type (reg
, type
))
952 DEBUG_TRACE ("reg type check failed");
953 set_default_error ();
958 if ((type
== REG_TYPE_VN
|| type
== REG_TYPE_ZN
|| type
== REG_TYPE_PN
)
959 && (*str
== '.' || (type
== REG_TYPE_PN
&& *str
== '/')))
963 if (!parse_vector_type_for_operand (type
, &parsetype
, &str
))
968 if (!parse_predication_for_operand (&parsetype
, &str
))
972 /* Register if of the form Vn.[bhsdq]. */
973 is_typed_vecreg
= TRUE
;
975 if (type
== REG_TYPE_ZN
|| type
== REG_TYPE_PN
)
977 /* The width is always variable; we don't allow an integer width
979 gas_assert (parsetype
.width
== 0);
980 atype
.defined
|= NTA_HASVARWIDTH
| NTA_HASTYPE
;
982 else if (parsetype
.width
== 0)
983 /* Expect index. In the new scheme we cannot have
984 Vn.[bhsdq] represent a scalar. Therefore any
985 Vn.[bhsdq] should have an index following it.
986 Except in reglists of course. */
987 atype
.defined
|= NTA_HASINDEX
;
989 atype
.defined
|= NTA_HASTYPE
;
991 atype
.type
= parsetype
.type
;
992 atype
.width
= parsetype
.width
;
995 if (skip_past_char (&str
, '['))
999 /* Reject Sn[index] syntax. */
1000 if (!is_typed_vecreg
)
1002 first_error (_("this type of register can't be indexed"));
1008 first_error (_("index not allowed inside register list"));
1012 atype
.defined
|= NTA_HASINDEX
;
1014 my_get_expression (&exp
, &str
, GE_NO_PREFIX
, 1);
1016 if (exp
.X_op
!= O_constant
)
1018 first_error (_("constant expression required"));
1022 if (! skip_past_char (&str
, ']'))
1025 atype
.index
= exp
.X_add_number
;
1027 else if (!in_reg_list
&& (atype
.defined
& NTA_HASINDEX
) != 0)
1029 /* Indexed vector register expected. */
1030 first_error (_("indexed vector register expected"));
1034 /* A vector reg Vn should be typed or indexed. */
1035 if (type
== REG_TYPE_VN
&& atype
.defined
== 0)
1037 first_error (_("invalid use of vector register"));
1053 Return the register number on success; return PARSE_FAIL otherwise.
1055 If RTYPE is not NULL, return in *RTYPE the (possibly restricted) type of
1056 the register (e.g. NEON double or quad reg when either has been requested).
1058 If this is a NEON vector register with additional type information, fill
1059 in the struct pointed to by VECTYPE (if non-NULL).
1061 This parser does not handle register list. */
1064 aarch64_reg_parse (char **ccp
, aarch64_reg_type type
,
1065 aarch64_reg_type
*rtype
, struct vector_type_el
*vectype
)
1067 struct vector_type_el atype
;
1069 int reg
= parse_typed_reg (&str
, type
, rtype
, &atype
,
1070 /*in_reg_list= */ FALSE
);
1072 if (reg
== PARSE_FAIL
)
1083 static inline bfd_boolean
1084 eq_vector_type_el (struct vector_type_el e1
, struct vector_type_el e2
)
1088 && e1
.defined
== e2
.defined
1089 && e1
.width
== e2
.width
&& e1
.index
== e2
.index
;
1092 /* This function parses a list of vector registers of type TYPE.
1093 On success, it returns the parsed register list information in the
1094 following encoded format:
1096 bit 18-22 | 13-17 | 7-11 | 2-6 | 0-1
1097 4th regno | 3rd regno | 2nd regno | 1st regno | num_of_reg
1099 The information of the register shape and/or index is returned in
1102 It returns PARSE_FAIL if the register list is invalid.
1104 The list contains one to four registers.
1105 Each register can be one of:
1108 All <T> should be identical.
1109 All <index> should be identical.
1110 There are restrictions on <Vt> numbers which are checked later
1111 (by reg_list_valid_p). */
1114 parse_vector_reg_list (char **ccp
, aarch64_reg_type type
,
1115 struct vector_type_el
*vectype
)
1119 struct vector_type_el typeinfo
, typeinfo_first
;
1124 bfd_boolean error
= FALSE
;
1125 bfd_boolean expect_index
= FALSE
;
1129 set_syntax_error (_("expecting {"));
1135 typeinfo_first
.defined
= 0;
1136 typeinfo_first
.type
= NT_invtype
;
1137 typeinfo_first
.width
= -1;
1138 typeinfo_first
.index
= 0;
1147 str
++; /* skip over '-' */
1150 val
= parse_typed_reg (&str
, type
, NULL
, &typeinfo
,
1151 /*in_reg_list= */ TRUE
);
1152 if (val
== PARSE_FAIL
)
1154 set_first_syntax_error (_("invalid vector register in list"));
1158 /* reject [bhsd]n */
1159 if (type
== REG_TYPE_VN
&& typeinfo
.defined
== 0)
1161 set_first_syntax_error (_("invalid scalar register in list"));
1166 if (typeinfo
.defined
& NTA_HASINDEX
)
1167 expect_index
= TRUE
;
1171 if (val
< val_range
)
1173 set_first_syntax_error
1174 (_("invalid range in vector register list"));
1183 typeinfo_first
= typeinfo
;
1184 else if (! eq_vector_type_el (typeinfo_first
, typeinfo
))
1186 set_first_syntax_error
1187 (_("type mismatch in vector register list"));
1192 for (i
= val_range
; i
<= val
; i
++)
1194 ret_val
|= i
<< (5 * nb_regs
);
1199 while (skip_past_comma (&str
) || (in_range
= 1, *str
== '-'));
1201 skip_whitespace (str
);
1204 set_first_syntax_error (_("end of vector register list not found"));
1209 skip_whitespace (str
);
1213 if (skip_past_char (&str
, '['))
1217 my_get_expression (&exp
, &str
, GE_NO_PREFIX
, 1);
1218 if (exp
.X_op
!= O_constant
)
1220 set_first_syntax_error (_("constant expression required."));
1223 if (! skip_past_char (&str
, ']'))
1226 typeinfo_first
.index
= exp
.X_add_number
;
1230 set_first_syntax_error (_("expected index"));
1237 set_first_syntax_error (_("too many registers in vector register list"));
1240 else if (nb_regs
== 0)
1242 set_first_syntax_error (_("empty vector register list"));
1248 *vectype
= typeinfo_first
;
1250 return error
? PARSE_FAIL
: (ret_val
<< 2) | (nb_regs
- 1);
1253 /* Directives: register aliases. */
1256 insert_reg_alias (char *str
, int number
, aarch64_reg_type type
)
1261 if ((new = hash_find (aarch64_reg_hsh
, str
)) != 0)
1264 as_warn (_("ignoring attempt to redefine built-in register '%s'"),
1267 /* Only warn about a redefinition if it's not defined as the
1269 else if (new->number
!= number
|| new->type
!= type
)
1270 as_warn (_("ignoring redefinition of register alias '%s'"), str
);
1275 name
= xstrdup (str
);
1276 new = XNEW (reg_entry
);
1279 new->number
= number
;
1281 new->builtin
= FALSE
;
1283 if (hash_insert (aarch64_reg_hsh
, name
, (void *) new))
1289 /* Look for the .req directive. This is of the form:
1291 new_register_name .req existing_register_name
1293 If we find one, or if it looks sufficiently like one that we want to
1294 handle any error here, return TRUE. Otherwise return FALSE. */
1297 create_register_alias (char *newname
, char *p
)
1299 const reg_entry
*old
;
1300 char *oldname
, *nbuf
;
1303 /* The input scrubber ensures that whitespace after the mnemonic is
1304 collapsed to single spaces. */
1306 if (strncmp (oldname
, " .req ", 6) != 0)
1310 if (*oldname
== '\0')
1313 old
= hash_find (aarch64_reg_hsh
, oldname
);
1316 as_warn (_("unknown register '%s' -- .req ignored"), oldname
);
1320 /* If TC_CASE_SENSITIVE is defined, then newname already points to
1321 the desired alias name, and p points to its end. If not, then
1322 the desired alias name is in the global original_case_string. */
1323 #ifdef TC_CASE_SENSITIVE
1326 newname
= original_case_string
;
1327 nlen
= strlen (newname
);
1330 nbuf
= xmemdup0 (newname
, nlen
);
1332 /* Create aliases under the new name as stated; an all-lowercase
1333 version of the new name; and an all-uppercase version of the new
1335 if (insert_reg_alias (nbuf
, old
->number
, old
->type
) != NULL
)
1337 for (p
= nbuf
; *p
; p
++)
1340 if (strncmp (nbuf
, newname
, nlen
))
1342 /* If this attempt to create an additional alias fails, do not bother
1343 trying to create the all-lower case alias. We will fail and issue
1344 a second, duplicate error message. This situation arises when the
1345 programmer does something like:
1348 The second .req creates the "Foo" alias but then fails to create
1349 the artificial FOO alias because it has already been created by the
1351 if (insert_reg_alias (nbuf
, old
->number
, old
->type
) == NULL
)
1358 for (p
= nbuf
; *p
; p
++)
1361 if (strncmp (nbuf
, newname
, nlen
))
1362 insert_reg_alias (nbuf
, old
->number
, old
->type
);
1369 /* Should never be called, as .req goes between the alias and the
1370 register name, not at the beginning of the line. */
1372 s_req (int a ATTRIBUTE_UNUSED
)
1374 as_bad (_("invalid syntax for .req directive"));
1377 /* The .unreq directive deletes an alias which was previously defined
1378 by .req. For example:
1384 s_unreq (int a ATTRIBUTE_UNUSED
)
1389 name
= input_line_pointer
;
1391 while (*input_line_pointer
!= 0
1392 && *input_line_pointer
!= ' ' && *input_line_pointer
!= '\n')
1393 ++input_line_pointer
;
1395 saved_char
= *input_line_pointer
;
1396 *input_line_pointer
= 0;
1399 as_bad (_("invalid syntax for .unreq directive"));
1402 reg_entry
*reg
= hash_find (aarch64_reg_hsh
, name
);
1405 as_bad (_("unknown register alias '%s'"), name
);
1406 else if (reg
->builtin
)
1407 as_warn (_("ignoring attempt to undefine built-in register '%s'"),
1414 hash_delete (aarch64_reg_hsh
, name
, FALSE
);
1415 free ((char *) reg
->name
);
1418 /* Also locate the all upper case and all lower case versions.
1419 Do not complain if we cannot find one or the other as it
1420 was probably deleted above. */
1422 nbuf
= strdup (name
);
1423 for (p
= nbuf
; *p
; p
++)
1425 reg
= hash_find (aarch64_reg_hsh
, nbuf
);
1428 hash_delete (aarch64_reg_hsh
, nbuf
, FALSE
);
1429 free ((char *) reg
->name
);
1433 for (p
= nbuf
; *p
; p
++)
1435 reg
= hash_find (aarch64_reg_hsh
, nbuf
);
1438 hash_delete (aarch64_reg_hsh
, nbuf
, FALSE
);
1439 free ((char *) reg
->name
);
1447 *input_line_pointer
= saved_char
;
1448 demand_empty_rest_of_line ();
1451 /* Directives: Instruction set selection. */
1454 /* This code is to handle mapping symbols as defined in the ARM AArch64 ELF
1455 spec. (See "Mapping symbols", section 4.5.4, ARM AAELF64 version 0.05).
1456 Note that previously, $a and $t has type STT_FUNC (BSF_OBJECT flag),
1457 and $d has type STT_OBJECT (BSF_OBJECT flag). Now all three are untyped. */
1459 /* Create a new mapping symbol for the transition to STATE. */
1462 make_mapping_symbol (enum mstate state
, valueT value
, fragS
* frag
)
1465 const char *symname
;
1472 type
= BSF_NO_FLAGS
;
1476 type
= BSF_NO_FLAGS
;
1482 symbolP
= symbol_new (symname
, now_seg
, value
, frag
);
1483 symbol_get_bfdsym (symbolP
)->flags
|= type
| BSF_LOCAL
;
1485 /* Save the mapping symbols for future reference. Also check that
1486 we do not place two mapping symbols at the same offset within a
1487 frag. We'll handle overlap between frags in
1488 check_mapping_symbols.
1490 If .fill or other data filling directive generates zero sized data,
1491 the mapping symbol for the following code will have the same value
1492 as the one generated for the data filling directive. In this case,
1493 we replace the old symbol with the new one at the same address. */
1496 if (frag
->tc_frag_data
.first_map
!= NULL
)
1498 know (S_GET_VALUE (frag
->tc_frag_data
.first_map
) == 0);
1499 symbol_remove (frag
->tc_frag_data
.first_map
, &symbol_rootP
,
1502 frag
->tc_frag_data
.first_map
= symbolP
;
1504 if (frag
->tc_frag_data
.last_map
!= NULL
)
1506 know (S_GET_VALUE (frag
->tc_frag_data
.last_map
) <=
1507 S_GET_VALUE (symbolP
));
1508 if (S_GET_VALUE (frag
->tc_frag_data
.last_map
) == S_GET_VALUE (symbolP
))
1509 symbol_remove (frag
->tc_frag_data
.last_map
, &symbol_rootP
,
1512 frag
->tc_frag_data
.last_map
= symbolP
;
1515 /* We must sometimes convert a region marked as code to data during
1516 code alignment, if an odd number of bytes have to be padded. The
1517 code mapping symbol is pushed to an aligned address. */
1520 insert_data_mapping_symbol (enum mstate state
,
1521 valueT value
, fragS
* frag
, offsetT bytes
)
1523 /* If there was already a mapping symbol, remove it. */
1524 if (frag
->tc_frag_data
.last_map
!= NULL
1525 && S_GET_VALUE (frag
->tc_frag_data
.last_map
) ==
1526 frag
->fr_address
+ value
)
1528 symbolS
*symp
= frag
->tc_frag_data
.last_map
;
1532 know (frag
->tc_frag_data
.first_map
== symp
);
1533 frag
->tc_frag_data
.first_map
= NULL
;
1535 frag
->tc_frag_data
.last_map
= NULL
;
1536 symbol_remove (symp
, &symbol_rootP
, &symbol_lastP
);
1539 make_mapping_symbol (MAP_DATA
, value
, frag
);
1540 make_mapping_symbol (state
, value
+ bytes
, frag
);
1543 static void mapping_state_2 (enum mstate state
, int max_chars
);
1545 /* Set the mapping state to STATE. Only call this when about to
1546 emit some STATE bytes to the file. */
1549 mapping_state (enum mstate state
)
1551 enum mstate mapstate
= seg_info (now_seg
)->tc_segment_info_data
.mapstate
;
1553 if (state
== MAP_INSN
)
1554 /* AArch64 instructions require 4-byte alignment. When emitting
1555 instructions into any section, record the appropriate section
1557 record_alignment (now_seg
, 2);
1559 if (mapstate
== state
)
1560 /* The mapping symbol has already been emitted.
1561 There is nothing else to do. */
1564 #define TRANSITION(from, to) (mapstate == (from) && state == (to))
1565 if (TRANSITION (MAP_UNDEFINED
, MAP_DATA
) && !subseg_text_p (now_seg
))
1566 /* Emit MAP_DATA within executable section in order. Otherwise, it will be
1567 evaluated later in the next else. */
1569 else if (TRANSITION (MAP_UNDEFINED
, MAP_INSN
))
1571 /* Only add the symbol if the offset is > 0:
1572 if we're at the first frag, check it's size > 0;
1573 if we're not at the first frag, then for sure
1574 the offset is > 0. */
1575 struct frag
*const frag_first
= seg_info (now_seg
)->frchainP
->frch_root
;
1576 const int add_symbol
= (frag_now
!= frag_first
)
1577 || (frag_now_fix () > 0);
1580 make_mapping_symbol (MAP_DATA
, (valueT
) 0, frag_first
);
1584 mapping_state_2 (state
, 0);
1587 /* Same as mapping_state, but MAX_CHARS bytes have already been
1588 allocated. Put the mapping symbol that far back. */
1591 mapping_state_2 (enum mstate state
, int max_chars
)
1593 enum mstate mapstate
= seg_info (now_seg
)->tc_segment_info_data
.mapstate
;
1595 if (!SEG_NORMAL (now_seg
))
1598 if (mapstate
== state
)
1599 /* The mapping symbol has already been emitted.
1600 There is nothing else to do. */
1603 seg_info (now_seg
)->tc_segment_info_data
.mapstate
= state
;
1604 make_mapping_symbol (state
, (valueT
) frag_now_fix () - max_chars
, frag_now
);
1607 #define mapping_state(x) /* nothing */
1608 #define mapping_state_2(x, y) /* nothing */
1611 /* Directives: sectioning and alignment. */
1614 s_bss (int ignore ATTRIBUTE_UNUSED
)
1616 /* We don't support putting frags in the BSS segment, we fake it by
1617 marking in_bss, then looking at s_skip for clues. */
1618 subseg_set (bss_section
, 0);
1619 demand_empty_rest_of_line ();
1620 mapping_state (MAP_DATA
);
1624 s_even (int ignore ATTRIBUTE_UNUSED
)
1626 /* Never make frag if expect extra pass. */
1628 frag_align (1, 0, 0);
1630 record_alignment (now_seg
, 1);
1632 demand_empty_rest_of_line ();
1635 /* Directives: Literal pools. */
1637 static literal_pool
*
1638 find_literal_pool (int size
)
1642 for (pool
= list_of_pools
; pool
!= NULL
; pool
= pool
->next
)
1644 if (pool
->section
== now_seg
1645 && pool
->sub_section
== now_subseg
&& pool
->size
== size
)
1652 static literal_pool
*
1653 find_or_make_literal_pool (int size
)
1655 /* Next literal pool ID number. */
1656 static unsigned int latest_pool_num
= 1;
1659 pool
= find_literal_pool (size
);
1663 /* Create a new pool. */
1664 pool
= XNEW (literal_pool
);
1668 /* Currently we always put the literal pool in the current text
1669 section. If we were generating "small" model code where we
1670 knew that all code and initialised data was within 1MB then
1671 we could output literals to mergeable, read-only data
1674 pool
->next_free_entry
= 0;
1675 pool
->section
= now_seg
;
1676 pool
->sub_section
= now_subseg
;
1678 pool
->next
= list_of_pools
;
1679 pool
->symbol
= NULL
;
1681 /* Add it to the list. */
1682 list_of_pools
= pool
;
1685 /* New pools, and emptied pools, will have a NULL symbol. */
1686 if (pool
->symbol
== NULL
)
1688 pool
->symbol
= symbol_create (FAKE_LABEL_NAME
, undefined_section
,
1689 (valueT
) 0, &zero_address_frag
);
1690 pool
->id
= latest_pool_num
++;
1697 /* Add the literal of size SIZE in *EXP to the relevant literal pool.
1698 Return TRUE on success, otherwise return FALSE. */
1700 add_to_lit_pool (expressionS
*exp
, int size
)
1705 pool
= find_or_make_literal_pool (size
);
1707 /* Check if this literal value is already in the pool. */
1708 for (entry
= 0; entry
< pool
->next_free_entry
; entry
++)
1710 expressionS
* litexp
= & pool
->literals
[entry
].exp
;
1712 if ((litexp
->X_op
== exp
->X_op
)
1713 && (exp
->X_op
== O_constant
)
1714 && (litexp
->X_add_number
== exp
->X_add_number
)
1715 && (litexp
->X_unsigned
== exp
->X_unsigned
))
1718 if ((litexp
->X_op
== exp
->X_op
)
1719 && (exp
->X_op
== O_symbol
)
1720 && (litexp
->X_add_number
== exp
->X_add_number
)
1721 && (litexp
->X_add_symbol
== exp
->X_add_symbol
)
1722 && (litexp
->X_op_symbol
== exp
->X_op_symbol
))
1726 /* Do we need to create a new entry? */
1727 if (entry
== pool
->next_free_entry
)
1729 if (entry
>= MAX_LITERAL_POOL_SIZE
)
1731 set_syntax_error (_("literal pool overflow"));
1735 pool
->literals
[entry
].exp
= *exp
;
1736 pool
->next_free_entry
+= 1;
1737 if (exp
->X_op
== O_big
)
1739 /* PR 16688: Bignums are held in a single global array. We must
1740 copy and preserve that value now, before it is overwritten. */
1741 pool
->literals
[entry
].bignum
= XNEWVEC (LITTLENUM_TYPE
,
1743 memcpy (pool
->literals
[entry
].bignum
, generic_bignum
,
1744 CHARS_PER_LITTLENUM
* exp
->X_add_number
);
1747 pool
->literals
[entry
].bignum
= NULL
;
1750 exp
->X_op
= O_symbol
;
1751 exp
->X_add_number
= ((int) entry
) * size
;
1752 exp
->X_add_symbol
= pool
->symbol
;
1757 /* Can't use symbol_new here, so have to create a symbol and then at
1758 a later date assign it a value. That's what these functions do. */
1761 symbol_locate (symbolS
* symbolP
,
1762 const char *name
,/* It is copied, the caller can modify. */
1763 segT segment
, /* Segment identifier (SEG_<something>). */
1764 valueT valu
, /* Symbol value. */
1765 fragS
* frag
) /* Associated fragment. */
1768 char *preserved_copy_of_name
;
1770 name_length
= strlen (name
) + 1; /* +1 for \0. */
1771 obstack_grow (¬es
, name
, name_length
);
1772 preserved_copy_of_name
= obstack_finish (¬es
);
1774 #ifdef tc_canonicalize_symbol_name
1775 preserved_copy_of_name
=
1776 tc_canonicalize_symbol_name (preserved_copy_of_name
);
1779 S_SET_NAME (symbolP
, preserved_copy_of_name
);
1781 S_SET_SEGMENT (symbolP
, segment
);
1782 S_SET_VALUE (symbolP
, valu
);
1783 symbol_clear_list_pointers (symbolP
);
1785 symbol_set_frag (symbolP
, frag
);
1787 /* Link to end of symbol chain. */
1789 extern int symbol_table_frozen
;
1791 if (symbol_table_frozen
)
1795 symbol_append (symbolP
, symbol_lastP
, &symbol_rootP
, &symbol_lastP
);
1797 obj_symbol_new_hook (symbolP
);
1799 #ifdef tc_symbol_new_hook
1800 tc_symbol_new_hook (symbolP
);
1804 verify_symbol_chain (symbol_rootP
, symbol_lastP
);
1805 #endif /* DEBUG_SYMS */
1810 s_ltorg (int ignored ATTRIBUTE_UNUSED
)
1817 for (align
= 2; align
<= 4; align
++)
1819 int size
= 1 << align
;
1821 pool
= find_literal_pool (size
);
1822 if (pool
== NULL
|| pool
->symbol
== NULL
|| pool
->next_free_entry
== 0)
1825 /* Align pool as you have word accesses.
1826 Only make a frag if we have to. */
1828 frag_align (align
, 0, 0);
1830 mapping_state (MAP_DATA
);
1832 record_alignment (now_seg
, align
);
1834 sprintf (sym_name
, "$$lit_\002%x", pool
->id
);
1836 symbol_locate (pool
->symbol
, sym_name
, now_seg
,
1837 (valueT
) frag_now_fix (), frag_now
);
1838 symbol_table_insert (pool
->symbol
);
1840 for (entry
= 0; entry
< pool
->next_free_entry
; entry
++)
1842 expressionS
* exp
= & pool
->literals
[entry
].exp
;
1844 if (exp
->X_op
== O_big
)
1846 /* PR 16688: Restore the global bignum value. */
1847 gas_assert (pool
->literals
[entry
].bignum
!= NULL
);
1848 memcpy (generic_bignum
, pool
->literals
[entry
].bignum
,
1849 CHARS_PER_LITTLENUM
* exp
->X_add_number
);
1852 /* First output the expression in the instruction to the pool. */
1853 emit_expr (exp
, size
); /* .word|.xword */
1855 if (exp
->X_op
== O_big
)
1857 free (pool
->literals
[entry
].bignum
);
1858 pool
->literals
[entry
].bignum
= NULL
;
1862 /* Mark the pool as empty. */
1863 pool
->next_free_entry
= 0;
1864 pool
->symbol
= NULL
;
1869 /* Forward declarations for functions below, in the MD interface
1871 static fixS
*fix_new_aarch64 (fragS
*, int, short, expressionS
*, int, int);
1872 static struct reloc_table_entry
* find_reloc_table_entry (char **);
1874 /* Directives: Data. */
1875 /* N.B. the support for relocation suffix in this directive needs to be
1876 implemented properly. */
1879 s_aarch64_elf_cons (int nbytes
)
1883 #ifdef md_flush_pending_output
1884 md_flush_pending_output ();
1887 if (is_it_end_of_statement ())
1889 demand_empty_rest_of_line ();
1893 #ifdef md_cons_align
1894 md_cons_align (nbytes
);
1897 mapping_state (MAP_DATA
);
1900 struct reloc_table_entry
*reloc
;
1904 if (exp
.X_op
!= O_symbol
)
1905 emit_expr (&exp
, (unsigned int) nbytes
);
1908 skip_past_char (&input_line_pointer
, '#');
1909 if (skip_past_char (&input_line_pointer
, ':'))
1911 reloc
= find_reloc_table_entry (&input_line_pointer
);
1913 as_bad (_("unrecognized relocation suffix"));
1915 as_bad (_("unimplemented relocation suffix"));
1916 ignore_rest_of_line ();
1920 emit_expr (&exp
, (unsigned int) nbytes
);
1923 while (*input_line_pointer
++ == ',');
1925 /* Put terminator back into stream. */
1926 input_line_pointer
--;
1927 demand_empty_rest_of_line ();
1930 #endif /* OBJ_ELF */
1932 /* Output a 32-bit word, but mark as an instruction. */
1935 s_aarch64_inst (int ignored ATTRIBUTE_UNUSED
)
1939 #ifdef md_flush_pending_output
1940 md_flush_pending_output ();
1943 if (is_it_end_of_statement ())
1945 demand_empty_rest_of_line ();
1949 /* Sections are assumed to start aligned. In executable section, there is no
1950 MAP_DATA symbol pending. So we only align the address during
1951 MAP_DATA --> MAP_INSN transition.
1952 For other sections, this is not guaranteed. */
1953 enum mstate mapstate
= seg_info (now_seg
)->tc_segment_info_data
.mapstate
;
1954 if (!need_pass_2
&& subseg_text_p (now_seg
) && mapstate
== MAP_DATA
)
1955 frag_align_code (2, 0);
1958 mapping_state (MAP_INSN
);
1964 if (exp
.X_op
!= O_constant
)
1966 as_bad (_("constant expression required"));
1967 ignore_rest_of_line ();
1971 if (target_big_endian
)
1973 unsigned int val
= exp
.X_add_number
;
1974 exp
.X_add_number
= SWAP_32 (val
);
1976 emit_expr (&exp
, 4);
1978 while (*input_line_pointer
++ == ',');
1980 /* Put terminator back into stream. */
1981 input_line_pointer
--;
1982 demand_empty_rest_of_line ();
1986 /* Emit BFD_RELOC_AARCH64_TLSDESC_ADD on the next ADD instruction. */
1989 s_tlsdescadd (int ignored ATTRIBUTE_UNUSED
)
1995 fix_new_aarch64 (frag_now
, frag_more (0) - frag_now
->fr_literal
, 4, &exp
, 0,
1996 BFD_RELOC_AARCH64_TLSDESC_ADD
);
1998 demand_empty_rest_of_line ();
2001 /* Emit BFD_RELOC_AARCH64_TLSDESC_CALL on the next BLR instruction. */
2004 s_tlsdesccall (int ignored ATTRIBUTE_UNUSED
)
2008 /* Since we're just labelling the code, there's no need to define a
2011 /* Make sure there is enough room in this frag for the following
2012 blr. This trick only works if the blr follows immediately after
2013 the .tlsdesc directive. */
2015 fix_new_aarch64 (frag_now
, frag_more (0) - frag_now
->fr_literal
, 4, &exp
, 0,
2016 BFD_RELOC_AARCH64_TLSDESC_CALL
);
2018 demand_empty_rest_of_line ();
2021 /* Emit BFD_RELOC_AARCH64_TLSDESC_LDR on the next LDR instruction. */
2024 s_tlsdescldr (int ignored ATTRIBUTE_UNUSED
)
2030 fix_new_aarch64 (frag_now
, frag_more (0) - frag_now
->fr_literal
, 4, &exp
, 0,
2031 BFD_RELOC_AARCH64_TLSDESC_LDR
);
2033 demand_empty_rest_of_line ();
2035 #endif /* OBJ_ELF */
2037 static void s_aarch64_arch (int);
2038 static void s_aarch64_cpu (int);
2039 static void s_aarch64_arch_extension (int);
2041 /* This table describes all the machine specific pseudo-ops the assembler
2042 has to support. The fields are:
2043 pseudo-op name without dot
2044 function to call to execute this pseudo-op
2045 Integer arg to pass to the function. */
2047 const pseudo_typeS md_pseudo_table
[] = {
2048 /* Never called because '.req' does not start a line. */
2050 {"unreq", s_unreq
, 0},
2052 {"even", s_even
, 0},
2053 {"ltorg", s_ltorg
, 0},
2054 {"pool", s_ltorg
, 0},
2055 {"cpu", s_aarch64_cpu
, 0},
2056 {"arch", s_aarch64_arch
, 0},
2057 {"arch_extension", s_aarch64_arch_extension
, 0},
2058 {"inst", s_aarch64_inst
, 0},
2060 {"tlsdescadd", s_tlsdescadd
, 0},
2061 {"tlsdesccall", s_tlsdesccall
, 0},
2062 {"tlsdescldr", s_tlsdescldr
, 0},
2063 {"word", s_aarch64_elf_cons
, 4},
2064 {"long", s_aarch64_elf_cons
, 4},
2065 {"xword", s_aarch64_elf_cons
, 8},
2066 {"dword", s_aarch64_elf_cons
, 8},
2072 /* Check whether STR points to a register name followed by a comma or the
2073 end of line; REG_TYPE indicates which register types are checked
2074 against. Return TRUE if STR is such a register name; otherwise return
2075 FALSE. The function does not intend to produce any diagnostics, but since
2076 the register parser aarch64_reg_parse, which is called by this function,
2077 does produce diagnostics, we call clear_error to clear any diagnostics
2078 that may be generated by aarch64_reg_parse.
2079 Also, the function returns FALSE directly if there is any user error
2080 present at the function entry. This prevents the existing diagnostics
2081 state from being spoiled.
2082 The function currently serves parse_constant_immediate and
2083 parse_big_immediate only. */
2085 reg_name_p (char *str
, aarch64_reg_type reg_type
)
2089 /* Prevent the diagnostics state from being spoiled. */
2093 reg
= aarch64_reg_parse (&str
, reg_type
, NULL
, NULL
);
2095 /* Clear the parsing error that may be set by the reg parser. */
2098 if (reg
== PARSE_FAIL
)
2101 skip_whitespace (str
);
2102 if (*str
== ',' || is_end_of_line
[(unsigned int) *str
])
2108 /* Parser functions used exclusively in instruction operands. */
2110 /* Parse an immediate expression which may not be constant.
2112 To prevent the expression parser from pushing a register name
2113 into the symbol table as an undefined symbol, firstly a check is
2114 done to find out whether STR is a register of type REG_TYPE followed
2115 by a comma or the end of line. Return FALSE if STR is such a string. */
2118 parse_immediate_expression (char **str
, expressionS
*exp
,
2119 aarch64_reg_type reg_type
)
2121 if (reg_name_p (*str
, reg_type
))
2123 set_recoverable_error (_("immediate operand required"));
2127 my_get_expression (exp
, str
, GE_OPT_PREFIX
, 1);
2129 if (exp
->X_op
== O_absent
)
2131 set_fatal_syntax_error (_("missing immediate expression"));
2138 /* Constant immediate-value read function for use in insn parsing.
2139 STR points to the beginning of the immediate (with the optional
2140 leading #); *VAL receives the value. REG_TYPE says which register
2141 names should be treated as registers rather than as symbolic immediates.
2143 Return TRUE on success; otherwise return FALSE. */
2146 parse_constant_immediate (char **str
, int64_t *val
, aarch64_reg_type reg_type
)
2150 if (! parse_immediate_expression (str
, &exp
, reg_type
))
2153 if (exp
.X_op
!= O_constant
)
2155 set_syntax_error (_("constant expression required"));
2159 *val
= exp
.X_add_number
;
2164 encode_imm_float_bits (uint32_t imm
)
2166 return ((imm
>> 19) & 0x7f) /* b[25:19] -> b[6:0] */
2167 | ((imm
>> (31 - 7)) & 0x80); /* b[31] -> b[7] */
2170 /* Return TRUE if the single-precision floating-point value encoded in IMM
2171 can be expressed in the AArch64 8-bit signed floating-point format with
2172 3-bit exponent and normalized 4 bits of precision; in other words, the
2173 floating-point value must be expressable as
2174 (+/-) n / 16 * power (2, r)
2175 where n and r are integers such that 16 <= n <=31 and -3 <= r <= 4. */
2178 aarch64_imm_float_p (uint32_t imm
)
2180 /* If a single-precision floating-point value has the following bit
2181 pattern, it can be expressed in the AArch64 8-bit floating-point
2184 3 32222222 2221111111111
2185 1 09876543 21098765432109876543210
2186 n Eeeeeexx xxxx0000000000000000000
2188 where n, e and each x are either 0 or 1 independently, with
2193 /* Prepare the pattern for 'Eeeeee'. */
2194 if (((imm
>> 30) & 0x1) == 0)
2195 pattern
= 0x3e000000;
2197 pattern
= 0x40000000;
2199 return (imm
& 0x7ffff) == 0 /* lower 19 bits are 0. */
2200 && ((imm
& 0x7e000000) == pattern
); /* bits 25 - 29 == ~ bit 30. */
2203 /* Return TRUE if the IEEE double value encoded in IMM can be expressed
2204 as an IEEE float without any loss of precision. Store the value in
2208 can_convert_double_to_float (uint64_t imm
, uint32_t *fpword
)
2210 /* If a double-precision floating-point value has the following bit
2211 pattern, it can be expressed in a float:
2213 6 66655555555 5544 44444444 33333333 33222222 22221111 111111
2214 3 21098765432 1098 76543210 98765432 10987654 32109876 54321098 76543210
2215 n E~~~eeeeeee ssss ssssssss ssssssss SSS00000 00000000 00000000 00000000
2217 -----------------------------> nEeeeeee esssssss ssssssss sssssSSS
2218 if Eeee_eeee != 1111_1111
2220 where n, e, s and S are either 0 or 1 independently and where ~ is the
2224 uint32_t high32
= imm
>> 32;
2225 uint32_t low32
= imm
;
2227 /* Lower 29 bits need to be 0s. */
2228 if ((imm
& 0x1fffffff) != 0)
2231 /* Prepare the pattern for 'Eeeeeeeee'. */
2232 if (((high32
>> 30) & 0x1) == 0)
2233 pattern
= 0x38000000;
2235 pattern
= 0x40000000;
2238 if ((high32
& 0x78000000) != pattern
)
2241 /* Check Eeee_eeee != 1111_1111. */
2242 if ((high32
& 0x7ff00000) == 0x47f00000)
2245 *fpword
= ((high32
& 0xc0000000) /* 1 n bit and 1 E bit. */
2246 | ((high32
<< 3) & 0x3ffffff8) /* 7 e and 20 s bits. */
2247 | (low32
>> 29)); /* 3 S bits. */
2251 /* Return true if we should treat OPERAND as a double-precision
2252 floating-point operand rather than a single-precision one. */
2254 double_precision_operand_p (const aarch64_opnd_info
*operand
)
2256 /* Check for unsuffixed SVE registers, which are allowed
2257 for LDR and STR but not in instructions that require an
2258 immediate. We get better error messages if we arbitrarily
2259 pick one size, parse the immediate normally, and then
2260 report the match failure in the normal way. */
2261 return (operand
->qualifier
== AARCH64_OPND_QLF_NIL
2262 || aarch64_get_qualifier_esize (operand
->qualifier
) == 8);
2265 /* Parse a floating-point immediate. Return TRUE on success and return the
2266 value in *IMMED in the format of IEEE754 single-precision encoding.
2267 *CCP points to the start of the string; DP_P is TRUE when the immediate
2268 is expected to be in double-precision (N.B. this only matters when
2269 hexadecimal representation is involved). REG_TYPE says which register
2270 names should be treated as registers rather than as symbolic immediates.
2272 This routine accepts any IEEE float; it is up to the callers to reject
2276 parse_aarch64_imm_float (char **ccp
, int *immed
, bfd_boolean dp_p
,
2277 aarch64_reg_type reg_type
)
2281 LITTLENUM_TYPE words
[MAX_LITTLENUMS
];
2282 int found_fpchar
= 0;
2284 unsigned fpword
= 0;
2285 bfd_boolean hex_p
= FALSE
;
2287 skip_past_char (&str
, '#');
2290 skip_whitespace (fpnum
);
2292 if (strncmp (fpnum
, "0x", 2) == 0)
2294 /* Support the hexadecimal representation of the IEEE754 encoding.
2295 Double-precision is expected when DP_P is TRUE, otherwise the
2296 representation should be in single-precision. */
2297 if (! parse_constant_immediate (&str
, &val
, reg_type
))
2302 if (!can_convert_double_to_float (val
, &fpword
))
2305 else if ((uint64_t) val
> 0xffffffff)
2314 if (reg_name_p (str
, reg_type
))
2316 set_recoverable_error (_("immediate operand required"));
2320 /* We must not accidentally parse an integer as a floating-point number.
2321 Make sure that the value we parse is not an integer by checking for
2322 special characters '.' or 'e'. */
2323 for (; *fpnum
!= '\0' && *fpnum
!= ' ' && *fpnum
!= '\n'; fpnum
++)
2324 if (*fpnum
== '.' || *fpnum
== 'e' || *fpnum
== 'E')
2338 if ((str
= atof_ieee (str
, 's', words
)) == NULL
)
2341 /* Our FP word must be 32 bits (single-precision FP). */
2342 for (i
= 0; i
< 32 / LITTLENUM_NUMBER_OF_BITS
; i
++)
2344 fpword
<<= LITTLENUM_NUMBER_OF_BITS
;
2354 set_fatal_syntax_error (_("invalid floating-point constant"));
2358 /* Less-generic immediate-value read function with the possibility of loading
2359 a big (64-bit) immediate, as required by AdvSIMD Modified immediate
2362 To prevent the expression parser from pushing a register name into the
2363 symbol table as an undefined symbol, a check is firstly done to find
2364 out whether STR is a register of type REG_TYPE followed by a comma or
2365 the end of line. Return FALSE if STR is such a register. */
2368 parse_big_immediate (char **str
, int64_t *imm
, aarch64_reg_type reg_type
)
2372 if (reg_name_p (ptr
, reg_type
))
2374 set_syntax_error (_("immediate operand required"));
2378 my_get_expression (&inst
.reloc
.exp
, &ptr
, GE_OPT_PREFIX
, 1);
2380 if (inst
.reloc
.exp
.X_op
== O_constant
)
2381 *imm
= inst
.reloc
.exp
.X_add_number
;
2388 /* Set operand IDX of the *INSTR that needs a GAS internal fixup.
2389 if NEED_LIBOPCODES is non-zero, the fixup will need
2390 assistance from the libopcodes. */
2393 aarch64_set_gas_internal_fixup (struct reloc
*reloc
,
2394 const aarch64_opnd_info
*operand
,
2395 int need_libopcodes_p
)
2397 reloc
->type
= BFD_RELOC_AARCH64_GAS_INTERNAL_FIXUP
;
2398 reloc
->opnd
= operand
->type
;
2399 if (need_libopcodes_p
)
2400 reloc
->need_libopcodes_p
= 1;
2403 /* Return TRUE if the instruction needs to be fixed up later internally by
2404 the GAS; otherwise return FALSE. */
2406 static inline bfd_boolean
2407 aarch64_gas_internal_fixup_p (void)
2409 return inst
.reloc
.type
== BFD_RELOC_AARCH64_GAS_INTERNAL_FIXUP
;
2412 /* Assign the immediate value to the relevant field in *OPERAND if
2413 RELOC->EXP is a constant expression; otherwise, flag that *OPERAND
2414 needs an internal fixup in a later stage.
2415 ADDR_OFF_P determines whether it is the field ADDR.OFFSET.IMM or
2416 IMM.VALUE that may get assigned with the constant. */
2418 assign_imm_if_const_or_fixup_later (struct reloc
*reloc
,
2419 aarch64_opnd_info
*operand
,
2421 int need_libopcodes_p
,
2424 if (reloc
->exp
.X_op
== O_constant
)
2427 operand
->addr
.offset
.imm
= reloc
->exp
.X_add_number
;
2429 operand
->imm
.value
= reloc
->exp
.X_add_number
;
2430 reloc
->type
= BFD_RELOC_UNUSED
;
2434 aarch64_set_gas_internal_fixup (reloc
, operand
, need_libopcodes_p
);
2435 /* Tell libopcodes to ignore this operand or not. This is helpful
2436 when one of the operands needs to be fixed up later but we need
2437 libopcodes to check the other operands. */
2438 operand
->skip
= skip_p
;
2442 /* Relocation modifiers. Each entry in the table contains the textual
2443 name for the relocation which may be placed before a symbol used as
2444 a load/store offset, or add immediate. It must be surrounded by a
2445 leading and trailing colon, for example:
2447 ldr x0, [x1, #:rello:varsym]
2448 add x0, x1, #:rello:varsym */
2450 struct reloc_table_entry
2454 bfd_reloc_code_real_type adr_type
;
2455 bfd_reloc_code_real_type adrp_type
;
2456 bfd_reloc_code_real_type movw_type
;
2457 bfd_reloc_code_real_type add_type
;
2458 bfd_reloc_code_real_type ldst_type
;
2459 bfd_reloc_code_real_type ld_literal_type
;
2462 static struct reloc_table_entry reloc_table
[] = {
2463 /* Low 12 bits of absolute address: ADD/i and LDR/STR */
2468 BFD_RELOC_AARCH64_ADD_LO12
,
2469 BFD_RELOC_AARCH64_LDST_LO12
,
2472 /* Higher 21 bits of pc-relative page offset: ADRP */
2475 BFD_RELOC_AARCH64_ADR_HI21_PCREL
,
2481 /* Higher 21 bits of pc-relative page offset: ADRP, no check */
2484 BFD_RELOC_AARCH64_ADR_HI21_NC_PCREL
,
2490 /* Most significant bits 0-15 of unsigned address/value: MOVZ */
2494 BFD_RELOC_AARCH64_MOVW_G0
,
2499 /* Most significant bits 0-15 of signed address/value: MOVN/Z */
2503 BFD_RELOC_AARCH64_MOVW_G0_S
,
2508 /* Less significant bits 0-15 of address/value: MOVK, no check */
2512 BFD_RELOC_AARCH64_MOVW_G0_NC
,
2517 /* Most significant bits 16-31 of unsigned address/value: MOVZ */
2521 BFD_RELOC_AARCH64_MOVW_G1
,
2526 /* Most significant bits 16-31 of signed address/value: MOVN/Z */
2530 BFD_RELOC_AARCH64_MOVW_G1_S
,
2535 /* Less significant bits 16-31 of address/value: MOVK, no check */
2539 BFD_RELOC_AARCH64_MOVW_G1_NC
,
2544 /* Most significant bits 32-47 of unsigned address/value: MOVZ */
2548 BFD_RELOC_AARCH64_MOVW_G2
,
2553 /* Most significant bits 32-47 of signed address/value: MOVN/Z */
2557 BFD_RELOC_AARCH64_MOVW_G2_S
,
2562 /* Less significant bits 32-47 of address/value: MOVK, no check */
2566 BFD_RELOC_AARCH64_MOVW_G2_NC
,
2571 /* Most significant bits 48-63 of signed/unsigned address/value: MOVZ */
2575 BFD_RELOC_AARCH64_MOVW_G3
,
2580 /* Most significant bits 0-15 of signed/unsigned address/value: MOVZ */
2584 BFD_RELOC_AARCH64_MOVW_PREL_G0
,
2589 /* Most significant bits 0-15 of signed/unsigned address/value: MOVK */
2593 BFD_RELOC_AARCH64_MOVW_PREL_G0_NC
,
2598 /* Most significant bits 16-31 of signed/unsigned address/value: MOVZ */
2602 BFD_RELOC_AARCH64_MOVW_PREL_G1
,
2607 /* Most significant bits 16-31 of signed/unsigned address/value: MOVK */
2611 BFD_RELOC_AARCH64_MOVW_PREL_G1_NC
,
2616 /* Most significant bits 32-47 of signed/unsigned address/value: MOVZ */
2620 BFD_RELOC_AARCH64_MOVW_PREL_G2
,
2625 /* Most significant bits 32-47 of signed/unsigned address/value: MOVK */
2629 BFD_RELOC_AARCH64_MOVW_PREL_G2_NC
,
2634 /* Most significant bits 48-63 of signed/unsigned address/value: MOVZ */
2638 BFD_RELOC_AARCH64_MOVW_PREL_G3
,
2643 /* Get to the page containing GOT entry for a symbol. */
2646 BFD_RELOC_AARCH64_ADR_GOT_PAGE
,
2650 BFD_RELOC_AARCH64_GOT_LD_PREL19
},
2652 /* 12 bit offset into the page containing GOT entry for that symbol. */
2658 BFD_RELOC_AARCH64_LD_GOT_LO12_NC
,
2661 /* 0-15 bits of address/value: MOVk, no check. */
2665 BFD_RELOC_AARCH64_MOVW_GOTOFF_G0_NC
,
2670 /* Most significant bits 16-31 of address/value: MOVZ. */
2674 BFD_RELOC_AARCH64_MOVW_GOTOFF_G1
,
2679 /* 15 bit offset into the page containing GOT entry for that symbol. */
2685 BFD_RELOC_AARCH64_LD64_GOTOFF_LO15
,
2688 /* Get to the page containing GOT TLS entry for a symbol */
2689 {"gottprel_g0_nc", 0,
2692 BFD_RELOC_AARCH64_TLSIE_MOVW_GOTTPREL_G0_NC
,
2697 /* Get to the page containing GOT TLS entry for a symbol */
2701 BFD_RELOC_AARCH64_TLSIE_MOVW_GOTTPREL_G1
,
2706 /* Get to the page containing GOT TLS entry for a symbol */
2708 BFD_RELOC_AARCH64_TLSGD_ADR_PREL21
, /* adr_type */
2709 BFD_RELOC_AARCH64_TLSGD_ADR_PAGE21
,
2715 /* 12 bit offset into the page containing GOT TLS entry for a symbol */
2720 BFD_RELOC_AARCH64_TLSGD_ADD_LO12_NC
,
2724 /* Lower 16 bits address/value: MOVk. */
2728 BFD_RELOC_AARCH64_TLSGD_MOVW_G0_NC
,
2733 /* Most significant bits 16-31 of address/value: MOVZ. */
2737 BFD_RELOC_AARCH64_TLSGD_MOVW_G1
,
2742 /* Get to the page containing GOT TLS entry for a symbol */
2744 BFD_RELOC_AARCH64_TLSDESC_ADR_PREL21
, /* adr_type */
2745 BFD_RELOC_AARCH64_TLSDESC_ADR_PAGE21
,
2749 BFD_RELOC_AARCH64_TLSDESC_LD_PREL19
},
2751 /* 12 bit offset into the page containing GOT TLS entry for a symbol */
2756 BFD_RELOC_AARCH64_TLSDESC_ADD_LO12
,
2757 BFD_RELOC_AARCH64_TLSDESC_LD_LO12_NC
,
2760 /* Get to the page containing GOT TLS entry for a symbol.
2761 The same as GD, we allocate two consecutive GOT slots
2762 for module index and module offset, the only difference
2763 with GD is the module offset should be initialized to
2764 zero without any outstanding runtime relocation. */
2766 BFD_RELOC_AARCH64_TLSLD_ADR_PREL21
, /* adr_type */
2767 BFD_RELOC_AARCH64_TLSLD_ADR_PAGE21
,
2773 /* 12 bit offset into the page containing GOT TLS entry for a symbol */
2774 {"tlsldm_lo12_nc", 0,
2778 BFD_RELOC_AARCH64_TLSLD_ADD_LO12_NC
,
2782 /* 12 bit offset into the module TLS base address. */
2787 BFD_RELOC_AARCH64_TLSLD_ADD_DTPREL_LO12
,
2788 BFD_RELOC_AARCH64_TLSLD_LDST_DTPREL_LO12
,
2791 /* Same as dtprel_lo12, no overflow check. */
2792 {"dtprel_lo12_nc", 0,
2796 BFD_RELOC_AARCH64_TLSLD_ADD_DTPREL_LO12_NC
,
2797 BFD_RELOC_AARCH64_TLSLD_LDST_DTPREL_LO12_NC
,
2800 /* bits[23:12] of offset to the module TLS base address. */
2805 BFD_RELOC_AARCH64_TLSLD_ADD_DTPREL_HI12
,
2809 /* bits[15:0] of offset to the module TLS base address. */
2813 BFD_RELOC_AARCH64_TLSLD_MOVW_DTPREL_G0
,
2818 /* No overflow check version of BFD_RELOC_AARCH64_TLSLD_MOVW_DTPREL_G0. */
2822 BFD_RELOC_AARCH64_TLSLD_MOVW_DTPREL_G0_NC
,
2827 /* bits[31:16] of offset to the module TLS base address. */
2831 BFD_RELOC_AARCH64_TLSLD_MOVW_DTPREL_G1
,
2836 /* No overflow check version of BFD_RELOC_AARCH64_TLSLD_MOVW_DTPREL_G1. */
2840 BFD_RELOC_AARCH64_TLSLD_MOVW_DTPREL_G1_NC
,
2845 /* bits[47:32] of offset to the module TLS base address. */
2849 BFD_RELOC_AARCH64_TLSLD_MOVW_DTPREL_G2
,
2854 /* Lower 16 bit offset into GOT entry for a symbol */
2855 {"tlsdesc_off_g0_nc", 0,
2858 BFD_RELOC_AARCH64_TLSDESC_OFF_G0_NC
,
2863 /* Higher 16 bit offset into GOT entry for a symbol */
2864 {"tlsdesc_off_g1", 0,
2867 BFD_RELOC_AARCH64_TLSDESC_OFF_G1
,
2872 /* Get to the page containing GOT TLS entry for a symbol */
2875 BFD_RELOC_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21
,
2879 BFD_RELOC_AARCH64_TLSIE_LD_GOTTPREL_PREL19
},
2881 /* 12 bit offset into the page containing GOT TLS entry for a symbol */
2882 {"gottprel_lo12", 0,
2887 BFD_RELOC_AARCH64_TLSIE_LD_GOTTPREL_LO12_NC
,
2890 /* Get tp offset for a symbol. */
2895 BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_LO12
,
2899 /* Get tp offset for a symbol. */
2904 BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_LO12
,
2905 BFD_RELOC_AARCH64_TLSLE_LDST_TPREL_LO12
,
2908 /* Get tp offset for a symbol. */
2913 BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_HI12
,
2917 /* Get tp offset for a symbol. */
2918 {"tprel_lo12_nc", 0,
2922 BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_LO12_NC
,
2923 BFD_RELOC_AARCH64_TLSLE_LDST_TPREL_LO12_NC
,
2926 /* Most significant bits 32-47 of address/value: MOVZ. */
2930 BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G2
,
2935 /* Most significant bits 16-31 of address/value: MOVZ. */
2939 BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G1
,
2944 /* Most significant bits 16-31 of address/value: MOVZ, no check. */
2948 BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G1_NC
,
2953 /* Most significant bits 0-15 of address/value: MOVZ. */
2957 BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G0
,
2962 /* Most significant bits 0-15 of address/value: MOVZ, no check. */
2966 BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G0_NC
,
2971 /* 15bit offset from got entry to base address of GOT table. */
2977 BFD_RELOC_AARCH64_LD64_GOTPAGE_LO15
,
2980 /* 14bit offset from got entry to base address of GOT table. */
2986 BFD_RELOC_AARCH64_LD32_GOTPAGE_LO14
,
2990 /* Given the address of a pointer pointing to the textual name of a
2991 relocation as may appear in assembler source, attempt to find its
2992 details in reloc_table. The pointer will be updated to the character
2993 after the trailing colon. On failure, NULL will be returned;
2994 otherwise return the reloc_table_entry. */
2996 static struct reloc_table_entry
*
2997 find_reloc_table_entry (char **str
)
3000 for (i
= 0; i
< ARRAY_SIZE (reloc_table
); i
++)
3002 int length
= strlen (reloc_table
[i
].name
);
3004 if (strncasecmp (reloc_table
[i
].name
, *str
, length
) == 0
3005 && (*str
)[length
] == ':')
3007 *str
+= (length
+ 1);
3008 return &reloc_table
[i
];
3015 /* Mode argument to parse_shift and parser_shifter_operand. */
3016 enum parse_shift_mode
3018 SHIFTED_NONE
, /* no shifter allowed */
3019 SHIFTED_ARITH_IMM
, /* "rn{,lsl|lsr|asl|asr|uxt|sxt #n}" or
3021 SHIFTED_LOGIC_IMM
, /* "rn{,lsl|lsr|asl|asr|ror #n}" or
3023 SHIFTED_LSL
, /* bare "lsl #n" */
3024 SHIFTED_MUL
, /* bare "mul #n" */
3025 SHIFTED_LSL_MSL
, /* "lsl|msl #n" */
3026 SHIFTED_MUL_VL
, /* "mul vl" */
3027 SHIFTED_REG_OFFSET
/* [su]xtw|sxtx {#n} or lsl #n */
3030 /* Parse a <shift> operator on an AArch64 data processing instruction.
3031 Return TRUE on success; otherwise return FALSE. */
3033 parse_shift (char **str
, aarch64_opnd_info
*operand
, enum parse_shift_mode mode
)
3035 const struct aarch64_name_value_pair
*shift_op
;
3036 enum aarch64_modifier_kind kind
;
3042 for (p
= *str
; ISALPHA (*p
); p
++)
3047 set_syntax_error (_("shift expression expected"));
3051 shift_op
= hash_find_n (aarch64_shift_hsh
, *str
, p
- *str
);
3053 if (shift_op
== NULL
)
3055 set_syntax_error (_("shift operator expected"));
3059 kind
= aarch64_get_operand_modifier (shift_op
);
3061 if (kind
== AARCH64_MOD_MSL
&& mode
!= SHIFTED_LSL_MSL
)
3063 set_syntax_error (_("invalid use of 'MSL'"));
3067 if (kind
== AARCH64_MOD_MUL
3068 && mode
!= SHIFTED_MUL
3069 && mode
!= SHIFTED_MUL_VL
)
3071 set_syntax_error (_("invalid use of 'MUL'"));
3077 case SHIFTED_LOGIC_IMM
:
3078 if (aarch64_extend_operator_p (kind
))
3080 set_syntax_error (_("extending shift is not permitted"));
3085 case SHIFTED_ARITH_IMM
:
3086 if (kind
== AARCH64_MOD_ROR
)
3088 set_syntax_error (_("'ROR' shift is not permitted"));
3094 if (kind
!= AARCH64_MOD_LSL
)
3096 set_syntax_error (_("only 'LSL' shift is permitted"));
3102 if (kind
!= AARCH64_MOD_MUL
)
3104 set_syntax_error (_("only 'MUL' is permitted"));
3109 case SHIFTED_MUL_VL
:
3110 /* "MUL VL" consists of two separate tokens. Require the first
3111 token to be "MUL" and look for a following "VL". */
3112 if (kind
== AARCH64_MOD_MUL
)
3114 skip_whitespace (p
);
3115 if (strncasecmp (p
, "vl", 2) == 0 && !ISALPHA (p
[2]))
3118 kind
= AARCH64_MOD_MUL_VL
;
3122 set_syntax_error (_("only 'MUL VL' is permitted"));
3125 case SHIFTED_REG_OFFSET
:
3126 if (kind
!= AARCH64_MOD_UXTW
&& kind
!= AARCH64_MOD_LSL
3127 && kind
!= AARCH64_MOD_SXTW
&& kind
!= AARCH64_MOD_SXTX
)
3129 set_fatal_syntax_error
3130 (_("invalid shift for the register offset addressing mode"));
3135 case SHIFTED_LSL_MSL
:
3136 if (kind
!= AARCH64_MOD_LSL
&& kind
!= AARCH64_MOD_MSL
)
3138 set_syntax_error (_("invalid shift operator"));
3147 /* Whitespace can appear here if the next thing is a bare digit. */
3148 skip_whitespace (p
);
3150 /* Parse shift amount. */
3152 if ((mode
== SHIFTED_REG_OFFSET
&& *p
== ']') || kind
== AARCH64_MOD_MUL_VL
)
3153 exp
.X_op
= O_absent
;
3156 if (is_immediate_prefix (*p
))
3161 my_get_expression (&exp
, &p
, GE_NO_PREFIX
, 0);
3163 if (kind
== AARCH64_MOD_MUL_VL
)
3164 /* For consistency, give MUL VL the same shift amount as an implicit
3166 operand
->shifter
.amount
= 1;
3167 else if (exp
.X_op
== O_absent
)
3169 if (!aarch64_extend_operator_p (kind
) || exp_has_prefix
)
3171 set_syntax_error (_("missing shift amount"));
3174 operand
->shifter
.amount
= 0;
3176 else if (exp
.X_op
!= O_constant
)
3178 set_syntax_error (_("constant shift amount required"));
3181 /* For parsing purposes, MUL #n has no inherent range. The range
3182 depends on the operand and will be checked by operand-specific
3184 else if (kind
!= AARCH64_MOD_MUL
3185 && (exp
.X_add_number
< 0 || exp
.X_add_number
> 63))
3187 set_fatal_syntax_error (_("shift amount out of range 0 to 63"));
3192 operand
->shifter
.amount
= exp
.X_add_number
;
3193 operand
->shifter
.amount_present
= 1;
3196 operand
->shifter
.operator_present
= 1;
3197 operand
->shifter
.kind
= kind
;
3203 /* Parse a <shifter_operand> for a data processing instruction:
3206 #<immediate>, LSL #imm
3208 Validation of immediate operands is deferred to md_apply_fix.
3210 Return TRUE on success; otherwise return FALSE. */
3213 parse_shifter_operand_imm (char **str
, aarch64_opnd_info
*operand
,
3214 enum parse_shift_mode mode
)
3218 if (mode
!= SHIFTED_ARITH_IMM
&& mode
!= SHIFTED_LOGIC_IMM
)
3223 /* Accept an immediate expression. */
3224 if (! my_get_expression (&inst
.reloc
.exp
, &p
, GE_OPT_PREFIX
, 1))
3227 /* Accept optional LSL for arithmetic immediate values. */
3228 if (mode
== SHIFTED_ARITH_IMM
&& skip_past_comma (&p
))
3229 if (! parse_shift (&p
, operand
, SHIFTED_LSL
))
3232 /* Not accept any shifter for logical immediate values. */
3233 if (mode
== SHIFTED_LOGIC_IMM
&& skip_past_comma (&p
)
3234 && parse_shift (&p
, operand
, mode
))
3236 set_syntax_error (_("unexpected shift operator"));
3244 /* Parse a <shifter_operand> for a data processing instruction:
3249 #<immediate>, LSL #imm
3251 where <shift> is handled by parse_shift above, and the last two
3252 cases are handled by the function above.
3254 Validation of immediate operands is deferred to md_apply_fix.
3256 Return TRUE on success; otherwise return FALSE. */
3259 parse_shifter_operand (char **str
, aarch64_opnd_info
*operand
,
3260 enum parse_shift_mode mode
)
3262 const reg_entry
*reg
;
3263 aarch64_opnd_qualifier_t qualifier
;
3264 enum aarch64_operand_class opd_class
3265 = aarch64_get_operand_class (operand
->type
);
3267 reg
= aarch64_reg_parse_32_64 (str
, &qualifier
);
3270 if (opd_class
== AARCH64_OPND_CLASS_IMMEDIATE
)
3272 set_syntax_error (_("unexpected register in the immediate operand"));
3276 if (!aarch64_check_reg_type (reg
, REG_TYPE_R_Z
))
3278 set_syntax_error (_(get_reg_expected_msg (REG_TYPE_R_Z
)));
3282 operand
->reg
.regno
= reg
->number
;
3283 operand
->qualifier
= qualifier
;
3285 /* Accept optional shift operation on register. */
3286 if (! skip_past_comma (str
))
3289 if (! parse_shift (str
, operand
, mode
))
3294 else if (opd_class
== AARCH64_OPND_CLASS_MODIFIED_REG
)
3297 (_("integer register expected in the extended/shifted operand "
3302 /* We have a shifted immediate variable. */
3303 return parse_shifter_operand_imm (str
, operand
, mode
);
3306 /* Return TRUE on success; return FALSE otherwise. */
3309 parse_shifter_operand_reloc (char **str
, aarch64_opnd_info
*operand
,
3310 enum parse_shift_mode mode
)
3314 /* Determine if we have the sequence of characters #: or just :
3315 coming next. If we do, then we check for a :rello: relocation
3316 modifier. If we don't, punt the whole lot to
3317 parse_shifter_operand. */
3319 if ((p
[0] == '#' && p
[1] == ':') || p
[0] == ':')
3321 struct reloc_table_entry
*entry
;
3329 /* Try to parse a relocation. Anything else is an error. */
3330 if (!(entry
= find_reloc_table_entry (str
)))
3332 set_syntax_error (_("unknown relocation modifier"));
3336 if (entry
->add_type
== 0)
3339 (_("this relocation modifier is not allowed on this instruction"));
3343 /* Save str before we decompose it. */
3346 /* Next, we parse the expression. */
3347 if (! my_get_expression (&inst
.reloc
.exp
, str
, GE_NO_PREFIX
, 1))
3350 /* Record the relocation type (use the ADD variant here). */
3351 inst
.reloc
.type
= entry
->add_type
;
3352 inst
.reloc
.pc_rel
= entry
->pc_rel
;
3354 /* If str is empty, we've reached the end, stop here. */
3358 /* Otherwise, we have a shifted reloc modifier, so rewind to
3359 recover the variable name and continue parsing for the shifter. */
3361 return parse_shifter_operand_imm (str
, operand
, mode
);
3364 return parse_shifter_operand (str
, operand
, mode
);
3367 /* Parse all forms of an address expression. Information is written
3368 to *OPERAND and/or inst.reloc.
3370 The A64 instruction set has the following addressing modes:
3373 [base] // in SIMD ld/st structure
3374 [base{,#0}] // in ld/st exclusive
3376 [base,Xm{,LSL #imm}]
3377 [base,Xm,SXTX {#imm}]
3378 [base,Wm,(S|U)XTW {#imm}]
3383 [base],Xm // in SIMD ld/st structure
3384 PC-relative (literal)
3388 [base,Zm.D{,LSL #imm}]
3389 [base,Zm.S,(S|U)XTW {#imm}]
3390 [base,Zm.D,(S|U)XTW {#imm}] // ignores top 32 bits of Zm.D elements
3393 [Zn.S,Zm.S{,LSL #imm}] // in ADR
3394 [Zn.D,Zm.D{,LSL #imm}] // in ADR
3395 [Zn.D,Zm.D,(S|U)XTW {#imm}] // in ADR
3397 (As a convenience, the notation "=immediate" is permitted in conjunction
3398 with the pc-relative literal load instructions to automatically place an
3399 immediate value or symbolic address in a nearby literal pool and generate
3400 a hidden label which references it.)
3402 Upon a successful parsing, the address structure in *OPERAND will be
3403 filled in the following way:
3405 .base_regno = <base>
3406 .offset.is_reg // 1 if the offset is a register
3408 .offset.regno = <Rm>
3410 For different addressing modes defined in the A64 ISA:
3413 .pcrel=0; .preind=1; .postind=0; .writeback=0
3415 .pcrel=0; .preind=1; .postind=0; .writeback=1
3417 .pcrel=0; .preind=0; .postind=1; .writeback=1
3418 PC-relative (literal)
3419 .pcrel=1; .preind=1; .postind=0; .writeback=0
3421 The shift/extension information, if any, will be stored in .shifter.
3422 The base and offset qualifiers will be stored in *BASE_QUALIFIER and
3423 *OFFSET_QUALIFIER respectively, with NIL being used if there's no
3424 corresponding register.
3426 BASE_TYPE says which types of base register should be accepted and
3427 OFFSET_TYPE says the same for offset registers. IMM_SHIFT_MODE
3428 is the type of shifter that is allowed for immediate offsets,
3429 or SHIFTED_NONE if none.
3431 In all other respects, it is the caller's responsibility to check
3432 for addressing modes not supported by the instruction, and to set
3436 parse_address_main (char **str
, aarch64_opnd_info
*operand
,
3437 aarch64_opnd_qualifier_t
*base_qualifier
,
3438 aarch64_opnd_qualifier_t
*offset_qualifier
,
3439 aarch64_reg_type base_type
, aarch64_reg_type offset_type
,
3440 enum parse_shift_mode imm_shift_mode
)
3443 const reg_entry
*reg
;
3444 expressionS
*exp
= &inst
.reloc
.exp
;
3446 *base_qualifier
= AARCH64_OPND_QLF_NIL
;
3447 *offset_qualifier
= AARCH64_OPND_QLF_NIL
;
3448 if (! skip_past_char (&p
, '['))
3450 /* =immediate or label. */
3451 operand
->addr
.pcrel
= 1;
3452 operand
->addr
.preind
= 1;
3454 /* #:<reloc_op>:<symbol> */
3455 skip_past_char (&p
, '#');
3456 if (skip_past_char (&p
, ':'))
3458 bfd_reloc_code_real_type ty
;
3459 struct reloc_table_entry
*entry
;
3461 /* Try to parse a relocation modifier. Anything else is
3463 entry
= find_reloc_table_entry (&p
);
3466 set_syntax_error (_("unknown relocation modifier"));
3470 switch (operand
->type
)
3472 case AARCH64_OPND_ADDR_PCREL21
:
3474 ty
= entry
->adr_type
;
3478 ty
= entry
->ld_literal_type
;
3485 (_("this relocation modifier is not allowed on this "
3491 if (! my_get_expression (exp
, &p
, GE_NO_PREFIX
, 1))
3493 set_syntax_error (_("invalid relocation expression"));
3497 /* #:<reloc_op>:<expr> */
3498 /* Record the relocation type. */
3499 inst
.reloc
.type
= ty
;
3500 inst
.reloc
.pc_rel
= entry
->pc_rel
;
3505 if (skip_past_char (&p
, '='))
3506 /* =immediate; need to generate the literal in the literal pool. */
3507 inst
.gen_lit_pool
= 1;
3509 if (!my_get_expression (exp
, &p
, GE_NO_PREFIX
, 1))
3511 set_syntax_error (_("invalid address"));
3522 reg
= aarch64_addr_reg_parse (&p
, base_type
, base_qualifier
);
3523 if (!reg
|| !aarch64_check_reg_type (reg
, base_type
))
3525 set_syntax_error (_(get_reg_expected_msg (base_type
)));
3528 operand
->addr
.base_regno
= reg
->number
;
3531 if (skip_past_comma (&p
))
3534 operand
->addr
.preind
= 1;
3536 reg
= aarch64_addr_reg_parse (&p
, offset_type
, offset_qualifier
);
3539 if (!aarch64_check_reg_type (reg
, offset_type
))
3541 set_syntax_error (_(get_reg_expected_msg (offset_type
)));
3546 operand
->addr
.offset
.regno
= reg
->number
;
3547 operand
->addr
.offset
.is_reg
= 1;
3548 /* Shifted index. */
3549 if (skip_past_comma (&p
))
3552 if (! parse_shift (&p
, operand
, SHIFTED_REG_OFFSET
))
3553 /* Use the diagnostics set in parse_shift, so not set new
3554 error message here. */
3558 [base,Xm{,LSL #imm}]
3559 [base,Xm,SXTX {#imm}]
3560 [base,Wm,(S|U)XTW {#imm}] */
3561 if (operand
->shifter
.kind
== AARCH64_MOD_NONE
3562 || operand
->shifter
.kind
== AARCH64_MOD_LSL
3563 || operand
->shifter
.kind
== AARCH64_MOD_SXTX
)
3565 if (*offset_qualifier
== AARCH64_OPND_QLF_W
)
3567 set_syntax_error (_("invalid use of 32-bit register offset"));
3570 if (aarch64_get_qualifier_esize (*base_qualifier
)
3571 != aarch64_get_qualifier_esize (*offset_qualifier
))
3573 set_syntax_error (_("offset has different size from base"));
3577 else if (*offset_qualifier
== AARCH64_OPND_QLF_X
)
3579 set_syntax_error (_("invalid use of 64-bit register offset"));
3585 /* [Xn,#:<reloc_op>:<symbol> */
3586 skip_past_char (&p
, '#');
3587 if (skip_past_char (&p
, ':'))
3589 struct reloc_table_entry
*entry
;
3591 /* Try to parse a relocation modifier. Anything else is
3593 if (!(entry
= find_reloc_table_entry (&p
)))
3595 set_syntax_error (_("unknown relocation modifier"));
3599 if (entry
->ldst_type
== 0)
3602 (_("this relocation modifier is not allowed on this "
3607 /* [Xn,#:<reloc_op>: */
3608 /* We now have the group relocation table entry corresponding to
3609 the name in the assembler source. Next, we parse the
3611 if (! my_get_expression (exp
, &p
, GE_NO_PREFIX
, 1))
3613 set_syntax_error (_("invalid relocation expression"));
3617 /* [Xn,#:<reloc_op>:<expr> */
3618 /* Record the load/store relocation type. */
3619 inst
.reloc
.type
= entry
->ldst_type
;
3620 inst
.reloc
.pc_rel
= entry
->pc_rel
;
3624 if (! my_get_expression (exp
, &p
, GE_OPT_PREFIX
, 1))
3626 set_syntax_error (_("invalid expression in the address"));
3630 if (imm_shift_mode
!= SHIFTED_NONE
&& skip_past_comma (&p
))
3631 /* [Xn,<expr>,<shifter> */
3632 if (! parse_shift (&p
, operand
, imm_shift_mode
))
3638 if (! skip_past_char (&p
, ']'))
3640 set_syntax_error (_("']' expected"));
3644 if (skip_past_char (&p
, '!'))
3646 if (operand
->addr
.preind
&& operand
->addr
.offset
.is_reg
)
3648 set_syntax_error (_("register offset not allowed in pre-indexed "
3649 "addressing mode"));
3653 operand
->addr
.writeback
= 1;
3655 else if (skip_past_comma (&p
))
3658 operand
->addr
.postind
= 1;
3659 operand
->addr
.writeback
= 1;
3661 if (operand
->addr
.preind
)
3663 set_syntax_error (_("cannot combine pre- and post-indexing"));
3667 reg
= aarch64_reg_parse_32_64 (&p
, offset_qualifier
);
3671 if (!aarch64_check_reg_type (reg
, REG_TYPE_R_64
))
3673 set_syntax_error (_(get_reg_expected_msg (REG_TYPE_R_64
)));
3677 operand
->addr
.offset
.regno
= reg
->number
;
3678 operand
->addr
.offset
.is_reg
= 1;
3680 else if (! my_get_expression (exp
, &p
, GE_OPT_PREFIX
, 1))
3683 set_syntax_error (_("invalid expression in the address"));
3688 /* If at this point neither .preind nor .postind is set, we have a
3689 bare [Rn]{!}; reject [Rn]! but accept [Rn] as a shorthand for [Rn,#0]. */
3690 if (operand
->addr
.preind
== 0 && operand
->addr
.postind
== 0)
3692 if (operand
->addr
.writeback
)
3695 set_syntax_error (_("missing offset in the pre-indexed address"));
3699 operand
->addr
.preind
= 1;
3700 inst
.reloc
.exp
.X_op
= O_constant
;
3701 inst
.reloc
.exp
.X_add_number
= 0;
3708 /* Parse a base AArch64 address (as opposed to an SVE one). Return TRUE
3711 parse_address (char **str
, aarch64_opnd_info
*operand
)
3713 aarch64_opnd_qualifier_t base_qualifier
, offset_qualifier
;
3714 return parse_address_main (str
, operand
, &base_qualifier
, &offset_qualifier
,
3715 REG_TYPE_R64_SP
, REG_TYPE_R_Z
, SHIFTED_NONE
);
3718 /* Parse an address in which SVE vector registers and MUL VL are allowed.
3719 The arguments have the same meaning as for parse_address_main.
3720 Return TRUE on success. */
3722 parse_sve_address (char **str
, aarch64_opnd_info
*operand
,
3723 aarch64_opnd_qualifier_t
*base_qualifier
,
3724 aarch64_opnd_qualifier_t
*offset_qualifier
)
3726 return parse_address_main (str
, operand
, base_qualifier
, offset_qualifier
,
3727 REG_TYPE_SVE_BASE
, REG_TYPE_SVE_OFFSET
,
3731 /* Parse an operand for a MOVZ, MOVN or MOVK instruction.
3732 Return TRUE on success; otherwise return FALSE. */
3734 parse_half (char **str
, int *internal_fixup_p
)
3738 skip_past_char (&p
, '#');
3740 gas_assert (internal_fixup_p
);
3741 *internal_fixup_p
= 0;
3745 struct reloc_table_entry
*entry
;
3747 /* Try to parse a relocation. Anything else is an error. */
3749 if (!(entry
= find_reloc_table_entry (&p
)))
3751 set_syntax_error (_("unknown relocation modifier"));
3755 if (entry
->movw_type
== 0)
3758 (_("this relocation modifier is not allowed on this instruction"));
3762 inst
.reloc
.type
= entry
->movw_type
;
3765 *internal_fixup_p
= 1;
3767 if (! my_get_expression (&inst
.reloc
.exp
, &p
, GE_NO_PREFIX
, 1))
3774 /* Parse an operand for an ADRP instruction:
3776 Return TRUE on success; otherwise return FALSE. */
3779 parse_adrp (char **str
)
3786 struct reloc_table_entry
*entry
;
3788 /* Try to parse a relocation. Anything else is an error. */
3790 if (!(entry
= find_reloc_table_entry (&p
)))
3792 set_syntax_error (_("unknown relocation modifier"));
3796 if (entry
->adrp_type
== 0)
3799 (_("this relocation modifier is not allowed on this instruction"));
3803 inst
.reloc
.type
= entry
->adrp_type
;
3806 inst
.reloc
.type
= BFD_RELOC_AARCH64_ADR_HI21_PCREL
;
3808 inst
.reloc
.pc_rel
= 1;
3810 if (! my_get_expression (&inst
.reloc
.exp
, &p
, GE_NO_PREFIX
, 1))
3817 /* Miscellaneous. */
3819 /* Parse a symbolic operand such as "pow2" at *STR. ARRAY is an array
3820 of SIZE tokens in which index I gives the token for field value I,
3821 or is null if field value I is invalid. REG_TYPE says which register
3822 names should be treated as registers rather than as symbolic immediates.
3824 Return true on success, moving *STR past the operand and storing the
3825 field value in *VAL. */
3828 parse_enum_string (char **str
, int64_t *val
, const char *const *array
,
3829 size_t size
, aarch64_reg_type reg_type
)
3835 /* Match C-like tokens. */
3837 while (ISALNUM (*q
))
3840 for (i
= 0; i
< size
; ++i
)
3842 && strncasecmp (array
[i
], p
, q
- p
) == 0
3843 && array
[i
][q
- p
] == 0)
3850 if (!parse_immediate_expression (&p
, &exp
, reg_type
))
3853 if (exp
.X_op
== O_constant
3854 && (uint64_t) exp
.X_add_number
< size
)
3856 *val
= exp
.X_add_number
;
3861 /* Use the default error for this operand. */
3865 /* Parse an option for a preload instruction. Returns the encoding for the
3866 option, or PARSE_FAIL. */
3869 parse_pldop (char **str
)
3872 const struct aarch64_name_value_pair
*o
;
3875 while (ISALNUM (*q
))
3878 o
= hash_find_n (aarch64_pldop_hsh
, p
, q
- p
);
3886 /* Parse an option for a barrier instruction. Returns the encoding for the
3887 option, or PARSE_FAIL. */
3890 parse_barrier (char **str
)
3893 const asm_barrier_opt
*o
;
3896 while (ISALPHA (*q
))
3899 o
= hash_find_n (aarch64_barrier_opt_hsh
, p
, q
- p
);
3907 /* Parse an operand for a PSB barrier. Set *HINT_OPT to the hint-option record
3908 return 0 if successful. Otherwise return PARSE_FAIL. */
3911 parse_barrier_psb (char **str
,
3912 const struct aarch64_name_value_pair
** hint_opt
)
3915 const struct aarch64_name_value_pair
*o
;
3918 while (ISALPHA (*q
))
3921 o
= hash_find_n (aarch64_hint_opt_hsh
, p
, q
- p
);
3924 set_fatal_syntax_error
3925 ( _("unknown or missing option to PSB"));
3929 if (o
->value
!= 0x11)
3931 /* PSB only accepts option name 'CSYNC'. */
3933 (_("the specified option is not accepted for PSB"));
3942 /* Parse a system register or a PSTATE field name for an MSR/MRS instruction.
3943 Returns the encoding for the option, or PARSE_FAIL.
3945 If IMPLE_DEFINED_P is non-zero, the function will also try to parse the
3946 implementation defined system register name S<op0>_<op1>_<Cn>_<Cm>_<op2>.
3948 If PSTATEFIELD_P is non-zero, the function will parse the name as a PSTATE
3949 field, otherwise as a system register.
3953 parse_sys_reg (char **str
, struct hash_control
*sys_regs
,
3954 int imple_defined_p
, int pstatefield_p
)
3958 const aarch64_sys_reg
*o
;
3962 for (q
= *str
; ISALNUM (*q
) || *q
== '_'; q
++)
3964 *p
++ = TOLOWER (*q
);
3966 /* Assert that BUF be large enough. */
3967 gas_assert (p
- buf
== q
- *str
);
3969 o
= hash_find (sys_regs
, buf
);
3972 if (!imple_defined_p
)
3976 /* Parse S<op0>_<op1>_<Cn>_<Cm>_<op2>. */
3977 unsigned int op0
, op1
, cn
, cm
, op2
;
3979 if (sscanf (buf
, "s%u_%u_c%u_c%u_%u", &op0
, &op1
, &cn
, &cm
, &op2
)
3982 if (op0
> 3 || op1
> 7 || cn
> 15 || cm
> 15 || op2
> 7)
3984 value
= (op0
<< 14) | (op1
<< 11) | (cn
<< 7) | (cm
<< 3) | op2
;
3989 if (pstatefield_p
&& !aarch64_pstatefield_supported_p (cpu_variant
, o
))
3990 as_bad (_("selected processor does not support PSTATE field "
3992 if (!pstatefield_p
&& !aarch64_sys_reg_supported_p (cpu_variant
, o
))
3993 as_bad (_("selected processor does not support system register "
3995 if (aarch64_sys_reg_deprecated_p (o
))
3996 as_warn (_("system register name '%s' is deprecated and may be "
3997 "removed in a future release"), buf
);
4005 /* Parse a system reg for ic/dc/at/tlbi instructions. Returns the table entry
4006 for the option, or NULL. */
4008 static const aarch64_sys_ins_reg
*
4009 parse_sys_ins_reg (char **str
, struct hash_control
*sys_ins_regs
)
4013 const aarch64_sys_ins_reg
*o
;
4016 for (q
= *str
; ISALNUM (*q
) || *q
== '_'; q
++)
4018 *p
++ = TOLOWER (*q
);
4021 o
= hash_find (sys_ins_regs
, buf
);
4025 if (!aarch64_sys_ins_reg_supported_p (cpu_variant
, o
))
4026 as_bad (_("selected processor does not support system register "
4033 #define po_char_or_fail(chr) do { \
4034 if (! skip_past_char (&str, chr)) \
4038 #define po_reg_or_fail(regtype) do { \
4039 val = aarch64_reg_parse (&str, regtype, &rtype, NULL); \
4040 if (val == PARSE_FAIL) \
4042 set_default_error (); \
4047 #define po_int_reg_or_fail(reg_type) do { \
4048 reg = aarch64_reg_parse_32_64 (&str, &qualifier); \
4049 if (!reg || !aarch64_check_reg_type (reg, reg_type)) \
4051 set_default_error (); \
4054 info->reg.regno = reg->number; \
4055 info->qualifier = qualifier; \
4058 #define po_imm_nc_or_fail() do { \
4059 if (! parse_constant_immediate (&str, &val, imm_reg_type)) \
4063 #define po_imm_or_fail(min, max) do { \
4064 if (! parse_constant_immediate (&str, &val, imm_reg_type)) \
4066 if (val < min || val > max) \
4068 set_fatal_syntax_error (_("immediate value out of range "\
4069 #min " to "#max)); \
4074 #define po_enum_or_fail(array) do { \
4075 if (!parse_enum_string (&str, &val, array, \
4076 ARRAY_SIZE (array), imm_reg_type)) \
4080 #define po_misc_or_fail(expr) do { \
4085 /* encode the 12-bit imm field of Add/sub immediate */
4086 static inline uint32_t
4087 encode_addsub_imm (uint32_t imm
)
4092 /* encode the shift amount field of Add/sub immediate */
4093 static inline uint32_t
4094 encode_addsub_imm_shift_amount (uint32_t cnt
)
4100 /* encode the imm field of Adr instruction */
4101 static inline uint32_t
4102 encode_adr_imm (uint32_t imm
)
4104 return (((imm
& 0x3) << 29) /* [1:0] -> [30:29] */
4105 | ((imm
& (0x7ffff << 2)) << 3)); /* [20:2] -> [23:5] */
4108 /* encode the immediate field of Move wide immediate */
4109 static inline uint32_t
4110 encode_movw_imm (uint32_t imm
)
4115 /* encode the 26-bit offset of unconditional branch */
4116 static inline uint32_t
4117 encode_branch_ofs_26 (uint32_t ofs
)
4119 return ofs
& ((1 << 26) - 1);
4122 /* encode the 19-bit offset of conditional branch and compare & branch */
4123 static inline uint32_t
4124 encode_cond_branch_ofs_19 (uint32_t ofs
)
4126 return (ofs
& ((1 << 19) - 1)) << 5;
4129 /* encode the 19-bit offset of ld literal */
4130 static inline uint32_t
4131 encode_ld_lit_ofs_19 (uint32_t ofs
)
4133 return (ofs
& ((1 << 19) - 1)) << 5;
4136 /* Encode the 14-bit offset of test & branch. */
4137 static inline uint32_t
4138 encode_tst_branch_ofs_14 (uint32_t ofs
)
4140 return (ofs
& ((1 << 14) - 1)) << 5;
4143 /* Encode the 16-bit imm field of svc/hvc/smc. */
4144 static inline uint32_t
4145 encode_svc_imm (uint32_t imm
)
4150 /* Reencode add(s) to sub(s), or sub(s) to add(s). */
4151 static inline uint32_t
4152 reencode_addsub_switch_add_sub (uint32_t opcode
)
4154 return opcode
^ (1 << 30);
4157 static inline uint32_t
4158 reencode_movzn_to_movz (uint32_t opcode
)
4160 return opcode
| (1 << 30);
4163 static inline uint32_t
4164 reencode_movzn_to_movn (uint32_t opcode
)
4166 return opcode
& ~(1 << 30);
4169 /* Overall per-instruction processing. */
4171 /* We need to be able to fix up arbitrary expressions in some statements.
4172 This is so that we can handle symbols that are an arbitrary distance from
4173 the pc. The most common cases are of the form ((+/-sym -/+ . - 8) & mask),
4174 which returns part of an address in a form which will be valid for
4175 a data instruction. We do this by pushing the expression into a symbol
4176 in the expr_section, and creating a fix for that. */
4179 fix_new_aarch64 (fragS
* frag
,
4181 short int size
, expressionS
* exp
, int pc_rel
, int reloc
)
4191 new_fix
= fix_new_exp (frag
, where
, size
, exp
, pc_rel
, reloc
);
4195 new_fix
= fix_new (frag
, where
, size
, make_expr_symbol (exp
), 0,
4202 /* Diagnostics on operands errors. */
4204 /* By default, output verbose error message.
4205 Disable the verbose error message by -mno-verbose-error. */
4206 static int verbose_error_p
= 1;
4208 #ifdef DEBUG_AARCH64
4209 /* N.B. this is only for the purpose of debugging. */
4210 const char* operand_mismatch_kind_names
[] =
4213 "AARCH64_OPDE_RECOVERABLE",
4214 "AARCH64_OPDE_SYNTAX_ERROR",
4215 "AARCH64_OPDE_FATAL_SYNTAX_ERROR",
4216 "AARCH64_OPDE_INVALID_VARIANT",
4217 "AARCH64_OPDE_OUT_OF_RANGE",
4218 "AARCH64_OPDE_UNALIGNED",
4219 "AARCH64_OPDE_REG_LIST",
4220 "AARCH64_OPDE_OTHER_ERROR",
4222 #endif /* DEBUG_AARCH64 */
4224 /* Return TRUE if LHS is of higher severity than RHS, otherwise return FALSE.
4226 When multiple errors of different kinds are found in the same assembly
4227 line, only the error of the highest severity will be picked up for
4228 issuing the diagnostics. */
4230 static inline bfd_boolean
4231 operand_error_higher_severity_p (enum aarch64_operand_error_kind lhs
,
4232 enum aarch64_operand_error_kind rhs
)
4234 gas_assert (AARCH64_OPDE_RECOVERABLE
> AARCH64_OPDE_NIL
);
4235 gas_assert (AARCH64_OPDE_SYNTAX_ERROR
> AARCH64_OPDE_RECOVERABLE
);
4236 gas_assert (AARCH64_OPDE_FATAL_SYNTAX_ERROR
> AARCH64_OPDE_SYNTAX_ERROR
);
4237 gas_assert (AARCH64_OPDE_INVALID_VARIANT
> AARCH64_OPDE_FATAL_SYNTAX_ERROR
);
4238 gas_assert (AARCH64_OPDE_OUT_OF_RANGE
> AARCH64_OPDE_INVALID_VARIANT
);
4239 gas_assert (AARCH64_OPDE_UNALIGNED
> AARCH64_OPDE_OUT_OF_RANGE
);
4240 gas_assert (AARCH64_OPDE_REG_LIST
> AARCH64_OPDE_UNALIGNED
);
4241 gas_assert (AARCH64_OPDE_OTHER_ERROR
> AARCH64_OPDE_REG_LIST
);
4245 /* Helper routine to get the mnemonic name from the assembly instruction
4246 line; should only be called for the diagnosis purpose, as there is
4247 string copy operation involved, which may affect the runtime
4248 performance if used in elsewhere. */
4251 get_mnemonic_name (const char *str
)
4253 static char mnemonic
[32];
4256 /* Get the first 15 bytes and assume that the full name is included. */
4257 strncpy (mnemonic
, str
, 31);
4258 mnemonic
[31] = '\0';
4260 /* Scan up to the end of the mnemonic, which must end in white space,
4261 '.', or end of string. */
4262 for (ptr
= mnemonic
; is_part_of_name(*ptr
); ++ptr
)
4267 /* Append '...' to the truncated long name. */
4268 if (ptr
- mnemonic
== 31)
4269 mnemonic
[28] = mnemonic
[29] = mnemonic
[30] = '.';
4275 reset_aarch64_instruction (aarch64_instruction
*instruction
)
4277 memset (instruction
, '\0', sizeof (aarch64_instruction
));
4278 instruction
->reloc
.type
= BFD_RELOC_UNUSED
;
4281 /* Data structures storing one user error in the assembly code related to
4284 struct operand_error_record
4286 const aarch64_opcode
*opcode
;
4287 aarch64_operand_error detail
;
4288 struct operand_error_record
*next
;
4291 typedef struct operand_error_record operand_error_record
;
4293 struct operand_errors
4295 operand_error_record
*head
;
4296 operand_error_record
*tail
;
4299 typedef struct operand_errors operand_errors
;
4301 /* Top-level data structure reporting user errors for the current line of
4303 The way md_assemble works is that all opcodes sharing the same mnemonic
4304 name are iterated to find a match to the assembly line. In this data
4305 structure, each of the such opcodes will have one operand_error_record
4306 allocated and inserted. In other words, excessive errors related with
4307 a single opcode are disregarded. */
4308 operand_errors operand_error_report
;
4310 /* Free record nodes. */
4311 static operand_error_record
*free_opnd_error_record_nodes
= NULL
;
4313 /* Initialize the data structure that stores the operand mismatch
4314 information on assembling one line of the assembly code. */
4316 init_operand_error_report (void)
4318 if (operand_error_report
.head
!= NULL
)
4320 gas_assert (operand_error_report
.tail
!= NULL
);
4321 operand_error_report
.tail
->next
= free_opnd_error_record_nodes
;
4322 free_opnd_error_record_nodes
= operand_error_report
.head
;
4323 operand_error_report
.head
= NULL
;
4324 operand_error_report
.tail
= NULL
;
4327 gas_assert (operand_error_report
.tail
== NULL
);
4330 /* Return TRUE if some operand error has been recorded during the
4331 parsing of the current assembly line using the opcode *OPCODE;
4332 otherwise return FALSE. */
4333 static inline bfd_boolean
4334 opcode_has_operand_error_p (const aarch64_opcode
*opcode
)
4336 operand_error_record
*record
= operand_error_report
.head
;
4337 return record
&& record
->opcode
== opcode
;
4340 /* Add the error record *NEW_RECORD to operand_error_report. The record's
4341 OPCODE field is initialized with OPCODE.
4342 N.B. only one record for each opcode, i.e. the maximum of one error is
4343 recorded for each instruction template. */
4346 add_operand_error_record (const operand_error_record
* new_record
)
4348 const aarch64_opcode
*opcode
= new_record
->opcode
;
4349 operand_error_record
* record
= operand_error_report
.head
;
4351 /* The record may have been created for this opcode. If not, we need
4353 if (! opcode_has_operand_error_p (opcode
))
4355 /* Get one empty record. */
4356 if (free_opnd_error_record_nodes
== NULL
)
4358 record
= XNEW (operand_error_record
);
4362 record
= free_opnd_error_record_nodes
;
4363 free_opnd_error_record_nodes
= record
->next
;
4365 record
->opcode
= opcode
;
4366 /* Insert at the head. */
4367 record
->next
= operand_error_report
.head
;
4368 operand_error_report
.head
= record
;
4369 if (operand_error_report
.tail
== NULL
)
4370 operand_error_report
.tail
= record
;
4372 else if (record
->detail
.kind
!= AARCH64_OPDE_NIL
4373 && record
->detail
.index
<= new_record
->detail
.index
4374 && operand_error_higher_severity_p (record
->detail
.kind
,
4375 new_record
->detail
.kind
))
4377 /* In the case of multiple errors found on operands related with a
4378 single opcode, only record the error of the leftmost operand and
4379 only if the error is of higher severity. */
4380 DEBUG_TRACE ("error %s on operand %d not added to the report due to"
4381 " the existing error %s on operand %d",
4382 operand_mismatch_kind_names
[new_record
->detail
.kind
],
4383 new_record
->detail
.index
,
4384 operand_mismatch_kind_names
[record
->detail
.kind
],
4385 record
->detail
.index
);
4389 record
->detail
= new_record
->detail
;
4393 record_operand_error_info (const aarch64_opcode
*opcode
,
4394 aarch64_operand_error
*error_info
)
4396 operand_error_record record
;
4397 record
.opcode
= opcode
;
4398 record
.detail
= *error_info
;
4399 add_operand_error_record (&record
);
4402 /* Record an error of kind KIND and, if ERROR is not NULL, of the detailed
4403 error message *ERROR, for operand IDX (count from 0). */
4406 record_operand_error (const aarch64_opcode
*opcode
, int idx
,
4407 enum aarch64_operand_error_kind kind
,
4410 aarch64_operand_error info
;
4411 memset(&info
, 0, sizeof (info
));
4415 record_operand_error_info (opcode
, &info
);
4419 record_operand_error_with_data (const aarch64_opcode
*opcode
, int idx
,
4420 enum aarch64_operand_error_kind kind
,
4421 const char* error
, const int *extra_data
)
4423 aarch64_operand_error info
;
4427 info
.data
[0] = extra_data
[0];
4428 info
.data
[1] = extra_data
[1];
4429 info
.data
[2] = extra_data
[2];
4430 record_operand_error_info (opcode
, &info
);
4434 record_operand_out_of_range_error (const aarch64_opcode
*opcode
, int idx
,
4435 const char* error
, int lower_bound
,
4438 int data
[3] = {lower_bound
, upper_bound
, 0};
4439 record_operand_error_with_data (opcode
, idx
, AARCH64_OPDE_OUT_OF_RANGE
,
4443 /* Remove the operand error record for *OPCODE. */
4444 static void ATTRIBUTE_UNUSED
4445 remove_operand_error_record (const aarch64_opcode
*opcode
)
4447 if (opcode_has_operand_error_p (opcode
))
4449 operand_error_record
* record
= operand_error_report
.head
;
4450 gas_assert (record
!= NULL
&& operand_error_report
.tail
!= NULL
);
4451 operand_error_report
.head
= record
->next
;
4452 record
->next
= free_opnd_error_record_nodes
;
4453 free_opnd_error_record_nodes
= record
;
4454 if (operand_error_report
.head
== NULL
)
4456 gas_assert (operand_error_report
.tail
== record
);
4457 operand_error_report
.tail
= NULL
;
4462 /* Given the instruction in *INSTR, return the index of the best matched
4463 qualifier sequence in the list (an array) headed by QUALIFIERS_LIST.
4465 Return -1 if there is no qualifier sequence; return the first match
4466 if there is multiple matches found. */
4469 find_best_match (const aarch64_inst
*instr
,
4470 const aarch64_opnd_qualifier_seq_t
*qualifiers_list
)
4472 int i
, num_opnds
, max_num_matched
, idx
;
4474 num_opnds
= aarch64_num_of_operands (instr
->opcode
);
4477 DEBUG_TRACE ("no operand");
4481 max_num_matched
= 0;
4484 /* For each pattern. */
4485 for (i
= 0; i
< AARCH64_MAX_QLF_SEQ_NUM
; ++i
, ++qualifiers_list
)
4488 const aarch64_opnd_qualifier_t
*qualifiers
= *qualifiers_list
;
4490 /* Most opcodes has much fewer patterns in the list. */
4491 if (empty_qualifier_sequence_p (qualifiers
))
4493 DEBUG_TRACE_IF (i
== 0, "empty list of qualifier sequence");
4497 for (j
= 0, num_matched
= 0; j
< num_opnds
; ++j
, ++qualifiers
)
4498 if (*qualifiers
== instr
->operands
[j
].qualifier
)
4501 if (num_matched
> max_num_matched
)
4503 max_num_matched
= num_matched
;
4508 DEBUG_TRACE ("return with %d", idx
);
4512 /* Assign qualifiers in the qualifier sequence (headed by QUALIFIERS) to the
4513 corresponding operands in *INSTR. */
4516 assign_qualifier_sequence (aarch64_inst
*instr
,
4517 const aarch64_opnd_qualifier_t
*qualifiers
)
4520 int num_opnds
= aarch64_num_of_operands (instr
->opcode
);
4521 gas_assert (num_opnds
);
4522 for (i
= 0; i
< num_opnds
; ++i
, ++qualifiers
)
4523 instr
->operands
[i
].qualifier
= *qualifiers
;
4526 /* Print operands for the diagnosis purpose. */
4529 print_operands (char *buf
, const aarch64_opcode
*opcode
,
4530 const aarch64_opnd_info
*opnds
)
4534 for (i
= 0; i
< AARCH64_MAX_OPND_NUM
; ++i
)
4538 /* We regard the opcode operand info more, however we also look into
4539 the inst->operands to support the disassembling of the optional
4541 The two operand code should be the same in all cases, apart from
4542 when the operand can be optional. */
4543 if (opcode
->operands
[i
] == AARCH64_OPND_NIL
4544 || opnds
[i
].type
== AARCH64_OPND_NIL
)
4547 /* Generate the operand string in STR. */
4548 aarch64_print_operand (str
, sizeof (str
), 0, opcode
, opnds
, i
, NULL
, NULL
);
4552 strcat (buf
, i
== 0 ? " " : ", ");
4554 /* Append the operand string. */
4559 /* Send to stderr a string as information. */
4562 output_info (const char *format
, ...)
4568 file
= as_where (&line
);
4572 fprintf (stderr
, "%s:%u: ", file
, line
);
4574 fprintf (stderr
, "%s: ", file
);
4576 fprintf (stderr
, _("Info: "));
4577 va_start (args
, format
);
4578 vfprintf (stderr
, format
, args
);
4580 (void) putc ('\n', stderr
);
4583 /* Output one operand error record. */
4586 output_operand_error_record (const operand_error_record
*record
, char *str
)
4588 const aarch64_operand_error
*detail
= &record
->detail
;
4589 int idx
= detail
->index
;
4590 const aarch64_opcode
*opcode
= record
->opcode
;
4591 enum aarch64_opnd opd_code
= (idx
>= 0 ? opcode
->operands
[idx
]
4592 : AARCH64_OPND_NIL
);
4594 switch (detail
->kind
)
4596 case AARCH64_OPDE_NIL
:
4600 case AARCH64_OPDE_SYNTAX_ERROR
:
4601 case AARCH64_OPDE_RECOVERABLE
:
4602 case AARCH64_OPDE_FATAL_SYNTAX_ERROR
:
4603 case AARCH64_OPDE_OTHER_ERROR
:
4604 /* Use the prepared error message if there is, otherwise use the
4605 operand description string to describe the error. */
4606 if (detail
->error
!= NULL
)
4609 as_bad (_("%s -- `%s'"), detail
->error
, str
);
4611 as_bad (_("%s at operand %d -- `%s'"),
4612 detail
->error
, idx
+ 1, str
);
4616 gas_assert (idx
>= 0);
4617 as_bad (_("operand %d must be %s -- `%s'"), idx
+ 1,
4618 aarch64_get_operand_desc (opd_code
), str
);
4622 case AARCH64_OPDE_INVALID_VARIANT
:
4623 as_bad (_("operand mismatch -- `%s'"), str
);
4624 if (verbose_error_p
)
4626 /* We will try to correct the erroneous instruction and also provide
4627 more information e.g. all other valid variants.
4629 The string representation of the corrected instruction and other
4630 valid variants are generated by
4632 1) obtaining the intermediate representation of the erroneous
4634 2) manipulating the IR, e.g. replacing the operand qualifier;
4635 3) printing out the instruction by calling the printer functions
4636 shared with the disassembler.
4638 The limitation of this method is that the exact input assembly
4639 line cannot be accurately reproduced in some cases, for example an
4640 optional operand present in the actual assembly line will be
4641 omitted in the output; likewise for the optional syntax rules,
4642 e.g. the # before the immediate. Another limitation is that the
4643 assembly symbols and relocation operations in the assembly line
4644 currently cannot be printed out in the error report. Last but not
4645 least, when there is other error(s) co-exist with this error, the
4646 'corrected' instruction may be still incorrect, e.g. given
4647 'ldnp h0,h1,[x0,#6]!'
4648 this diagnosis will provide the version:
4649 'ldnp s0,s1,[x0,#6]!'
4650 which is still not right. */
4651 size_t len
= strlen (get_mnemonic_name (str
));
4655 aarch64_inst
*inst_base
= &inst
.base
;
4656 const aarch64_opnd_qualifier_seq_t
*qualifiers_list
;
4659 reset_aarch64_instruction (&inst
);
4660 inst_base
->opcode
= opcode
;
4662 /* Reset the error report so that there is no side effect on the
4663 following operand parsing. */
4664 init_operand_error_report ();
4667 result
= parse_operands (str
+ len
, opcode
)
4668 && programmer_friendly_fixup (&inst
);
4669 gas_assert (result
);
4670 result
= aarch64_opcode_encode (opcode
, inst_base
, &inst_base
->value
,
4672 gas_assert (!result
);
4674 /* Find the most matched qualifier sequence. */
4675 qlf_idx
= find_best_match (inst_base
, opcode
->qualifiers_list
);
4676 gas_assert (qlf_idx
> -1);
4678 /* Assign the qualifiers. */
4679 assign_qualifier_sequence (inst_base
,
4680 opcode
->qualifiers_list
[qlf_idx
]);
4682 /* Print the hint. */
4683 output_info (_(" did you mean this?"));
4684 snprintf (buf
, sizeof (buf
), "\t%s", get_mnemonic_name (str
));
4685 print_operands (buf
, opcode
, inst_base
->operands
);
4686 output_info (_(" %s"), buf
);
4688 /* Print out other variant(s) if there is any. */
4690 !empty_qualifier_sequence_p (opcode
->qualifiers_list
[1]))
4691 output_info (_(" other valid variant(s):"));
4693 /* For each pattern. */
4694 qualifiers_list
= opcode
->qualifiers_list
;
4695 for (i
= 0; i
< AARCH64_MAX_QLF_SEQ_NUM
; ++i
, ++qualifiers_list
)
4697 /* Most opcodes has much fewer patterns in the list.
4698 First NIL qualifier indicates the end in the list. */
4699 if (empty_qualifier_sequence_p (*qualifiers_list
))
4704 /* Mnemonics name. */
4705 snprintf (buf
, sizeof (buf
), "\t%s", get_mnemonic_name (str
));
4707 /* Assign the qualifiers. */
4708 assign_qualifier_sequence (inst_base
, *qualifiers_list
);
4710 /* Print instruction. */
4711 print_operands (buf
, opcode
, inst_base
->operands
);
4713 output_info (_(" %s"), buf
);
4719 case AARCH64_OPDE_UNTIED_OPERAND
:
4720 as_bad (_("operand %d must be the same register as operand 1 -- `%s'"),
4721 detail
->index
+ 1, str
);
4724 case AARCH64_OPDE_OUT_OF_RANGE
:
4725 if (detail
->data
[0] != detail
->data
[1])
4726 as_bad (_("%s out of range %d to %d at operand %d -- `%s'"),
4727 detail
->error
? detail
->error
: _("immediate value"),
4728 detail
->data
[0], detail
->data
[1], idx
+ 1, str
);
4730 as_bad (_("%s must be %d at operand %d -- `%s'"),
4731 detail
->error
? detail
->error
: _("immediate value"),
4732 detail
->data
[0], idx
+ 1, str
);
4735 case AARCH64_OPDE_REG_LIST
:
4736 if (detail
->data
[0] == 1)
4737 as_bad (_("invalid number of registers in the list; "
4738 "only 1 register is expected at operand %d -- `%s'"),
4741 as_bad (_("invalid number of registers in the list; "
4742 "%d registers are expected at operand %d -- `%s'"),
4743 detail
->data
[0], idx
+ 1, str
);
4746 case AARCH64_OPDE_UNALIGNED
:
4747 as_bad (_("immediate value must be a multiple of "
4748 "%d at operand %d -- `%s'"),
4749 detail
->data
[0], idx
+ 1, str
);
4758 /* Process and output the error message about the operand mismatching.
4760 When this function is called, the operand error information had
4761 been collected for an assembly line and there will be multiple
4762 errors in the case of multiple instruction templates; output the
4763 error message that most closely describes the problem. */
4766 output_operand_error_report (char *str
)
4768 int largest_error_pos
;
4769 const char *msg
= NULL
;
4770 enum aarch64_operand_error_kind kind
;
4771 operand_error_record
*curr
;
4772 operand_error_record
*head
= operand_error_report
.head
;
4773 operand_error_record
*record
= NULL
;
4775 /* No error to report. */
4779 gas_assert (head
!= NULL
&& operand_error_report
.tail
!= NULL
);
4781 /* Only one error. */
4782 if (head
== operand_error_report
.tail
)
4784 DEBUG_TRACE ("single opcode entry with error kind: %s",
4785 operand_mismatch_kind_names
[head
->detail
.kind
]);
4786 output_operand_error_record (head
, str
);
4790 /* Find the error kind of the highest severity. */
4791 DEBUG_TRACE ("multiple opcode entries with error kind");
4792 kind
= AARCH64_OPDE_NIL
;
4793 for (curr
= head
; curr
!= NULL
; curr
= curr
->next
)
4795 gas_assert (curr
->detail
.kind
!= AARCH64_OPDE_NIL
);
4796 DEBUG_TRACE ("\t%s", operand_mismatch_kind_names
[curr
->detail
.kind
]);
4797 if (operand_error_higher_severity_p (curr
->detail
.kind
, kind
))
4798 kind
= curr
->detail
.kind
;
4800 gas_assert (kind
!= AARCH64_OPDE_NIL
);
4802 /* Pick up one of errors of KIND to report. */
4803 largest_error_pos
= -2; /* Index can be -1 which means unknown index. */
4804 for (curr
= head
; curr
!= NULL
; curr
= curr
->next
)
4806 if (curr
->detail
.kind
!= kind
)
4808 /* If there are multiple errors, pick up the one with the highest
4809 mismatching operand index. In the case of multiple errors with
4810 the equally highest operand index, pick up the first one or the
4811 first one with non-NULL error message. */
4812 if (curr
->detail
.index
> largest_error_pos
4813 || (curr
->detail
.index
== largest_error_pos
&& msg
== NULL
4814 && curr
->detail
.error
!= NULL
))
4816 largest_error_pos
= curr
->detail
.index
;
4818 msg
= record
->detail
.error
;
4822 gas_assert (largest_error_pos
!= -2 && record
!= NULL
);
4823 DEBUG_TRACE ("Pick up error kind %s to report",
4824 operand_mismatch_kind_names
[record
->detail
.kind
]);
4827 output_operand_error_record (record
, str
);
4830 /* Write an AARCH64 instruction to buf - always little-endian. */
4832 put_aarch64_insn (char *buf
, uint32_t insn
)
4834 unsigned char *where
= (unsigned char *) buf
;
4836 where
[1] = insn
>> 8;
4837 where
[2] = insn
>> 16;
4838 where
[3] = insn
>> 24;
4842 get_aarch64_insn (char *buf
)
4844 unsigned char *where
= (unsigned char *) buf
;
4846 result
= (where
[0] | (where
[1] << 8) | (where
[2] << 16) | (where
[3] << 24));
4851 output_inst (struct aarch64_inst
*new_inst
)
4855 to
= frag_more (INSN_SIZE
);
4857 frag_now
->tc_frag_data
.recorded
= 1;
4859 put_aarch64_insn (to
, inst
.base
.value
);
4861 if (inst
.reloc
.type
!= BFD_RELOC_UNUSED
)
4863 fixS
*fixp
= fix_new_aarch64 (frag_now
, to
- frag_now
->fr_literal
,
4864 INSN_SIZE
, &inst
.reloc
.exp
,
4867 DEBUG_TRACE ("Prepared relocation fix up");
4868 /* Don't check the addend value against the instruction size,
4869 that's the job of our code in md_apply_fix(). */
4870 fixp
->fx_no_overflow
= 1;
4871 if (new_inst
!= NULL
)
4872 fixp
->tc_fix_data
.inst
= new_inst
;
4873 if (aarch64_gas_internal_fixup_p ())
4875 gas_assert (inst
.reloc
.opnd
!= AARCH64_OPND_NIL
);
4876 fixp
->tc_fix_data
.opnd
= inst
.reloc
.opnd
;
4877 fixp
->fx_addnumber
= inst
.reloc
.flags
;
4881 dwarf2_emit_insn (INSN_SIZE
);
4884 /* Link together opcodes of the same name. */
4888 aarch64_opcode
*opcode
;
4889 struct templates
*next
;
4892 typedef struct templates templates
;
4895 lookup_mnemonic (const char *start
, int len
)
4897 templates
*templ
= NULL
;
4899 templ
= hash_find_n (aarch64_ops_hsh
, start
, len
);
4903 /* Subroutine of md_assemble, responsible for looking up the primary
4904 opcode from the mnemonic the user wrote. STR points to the
4905 beginning of the mnemonic. */
4908 opcode_lookup (char **str
)
4910 char *end
, *base
, *dot
;
4911 const aarch64_cond
*cond
;
4915 /* Scan up to the end of the mnemonic, which must end in white space,
4916 '.', or end of string. */
4918 for (base
= end
= *str
; is_part_of_name(*end
); end
++)
4919 if (*end
== '.' && !dot
)
4922 if (end
== base
|| dot
== base
)
4925 inst
.cond
= COND_ALWAYS
;
4927 /* Handle a possible condition. */
4930 cond
= hash_find_n (aarch64_cond_hsh
, dot
+ 1, end
- dot
- 1);
4933 inst
.cond
= cond
->value
;
4949 if (inst
.cond
== COND_ALWAYS
)
4951 /* Look for unaffixed mnemonic. */
4952 return lookup_mnemonic (base
, len
);
4956 /* append ".c" to mnemonic if conditional */
4957 memcpy (condname
, base
, len
);
4958 memcpy (condname
+ len
, ".c", 2);
4961 return lookup_mnemonic (base
, len
);
4967 /* Internal helper routine converting a vector_type_el structure *VECTYPE
4968 to a corresponding operand qualifier. */
4970 static inline aarch64_opnd_qualifier_t
4971 vectype_to_qualifier (const struct vector_type_el
*vectype
)
4973 /* Element size in bytes indexed by vector_el_type. */
4974 const unsigned char ele_size
[5]
4976 const unsigned int ele_base
[5] =
4978 AARCH64_OPND_QLF_V_4B
,
4979 AARCH64_OPND_QLF_V_2H
,
4980 AARCH64_OPND_QLF_V_2S
,
4981 AARCH64_OPND_QLF_V_1D
,
4982 AARCH64_OPND_QLF_V_1Q
4985 if (!vectype
->defined
|| vectype
->type
== NT_invtype
)
4986 goto vectype_conversion_fail
;
4988 if (vectype
->type
== NT_zero
)
4989 return AARCH64_OPND_QLF_P_Z
;
4990 if (vectype
->type
== NT_merge
)
4991 return AARCH64_OPND_QLF_P_M
;
4993 gas_assert (vectype
->type
>= NT_b
&& vectype
->type
<= NT_q
);
4995 if (vectype
->defined
& (NTA_HASINDEX
| NTA_HASVARWIDTH
))
4997 /* Special case S_4B. */
4998 if (vectype
->type
== NT_b
&& vectype
->width
== 4)
4999 return AARCH64_OPND_QLF_S_4B
;
5001 /* Vector element register. */
5002 return AARCH64_OPND_QLF_S_B
+ vectype
->type
;
5006 /* Vector register. */
5007 int reg_size
= ele_size
[vectype
->type
] * vectype
->width
;
5010 if (reg_size
!= 16 && reg_size
!= 8 && reg_size
!= 4)
5011 goto vectype_conversion_fail
;
5013 /* The conversion is by calculating the offset from the base operand
5014 qualifier for the vector type. The operand qualifiers are regular
5015 enough that the offset can established by shifting the vector width by
5016 a vector-type dependent amount. */
5018 if (vectype
->type
== NT_b
)
5020 else if (vectype
->type
== NT_h
|| vectype
->type
== NT_s
)
5022 else if (vectype
->type
>= NT_d
)
5027 offset
= ele_base
[vectype
->type
] + (vectype
->width
>> shift
);
5028 gas_assert (AARCH64_OPND_QLF_V_4B
<= offset
5029 && offset
<= AARCH64_OPND_QLF_V_1Q
);
5033 vectype_conversion_fail
:
5034 first_error (_("bad vector arrangement type"));
5035 return AARCH64_OPND_QLF_NIL
;
5038 /* Process an optional operand that is found omitted from the assembly line.
5039 Fill *OPERAND for such an operand of type TYPE. OPCODE points to the
5040 instruction's opcode entry while IDX is the index of this omitted operand.
5044 process_omitted_operand (enum aarch64_opnd type
, const aarch64_opcode
*opcode
,
5045 int idx
, aarch64_opnd_info
*operand
)
5047 aarch64_insn default_value
= get_optional_operand_default_value (opcode
);
5048 gas_assert (optional_operand_p (opcode
, idx
));
5049 gas_assert (!operand
->present
);
5053 case AARCH64_OPND_Rd
:
5054 case AARCH64_OPND_Rn
:
5055 case AARCH64_OPND_Rm
:
5056 case AARCH64_OPND_Rt
:
5057 case AARCH64_OPND_Rt2
:
5058 case AARCH64_OPND_Rs
:
5059 case AARCH64_OPND_Ra
:
5060 case AARCH64_OPND_Rt_SYS
:
5061 case AARCH64_OPND_Rd_SP
:
5062 case AARCH64_OPND_Rn_SP
:
5063 case AARCH64_OPND_Rm_SP
:
5064 case AARCH64_OPND_Fd
:
5065 case AARCH64_OPND_Fn
:
5066 case AARCH64_OPND_Fm
:
5067 case AARCH64_OPND_Fa
:
5068 case AARCH64_OPND_Ft
:
5069 case AARCH64_OPND_Ft2
:
5070 case AARCH64_OPND_Sd
:
5071 case AARCH64_OPND_Sn
:
5072 case AARCH64_OPND_Sm
:
5073 case AARCH64_OPND_Va
:
5074 case AARCH64_OPND_Vd
:
5075 case AARCH64_OPND_Vn
:
5076 case AARCH64_OPND_Vm
:
5077 case AARCH64_OPND_VdD1
:
5078 case AARCH64_OPND_VnD1
:
5079 operand
->reg
.regno
= default_value
;
5082 case AARCH64_OPND_Ed
:
5083 case AARCH64_OPND_En
:
5084 case AARCH64_OPND_Em
:
5085 case AARCH64_OPND_SM3_IMM2
:
5086 operand
->reglane
.regno
= default_value
;
5089 case AARCH64_OPND_IDX
:
5090 case AARCH64_OPND_BIT_NUM
:
5091 case AARCH64_OPND_IMMR
:
5092 case AARCH64_OPND_IMMS
:
5093 case AARCH64_OPND_SHLL_IMM
:
5094 case AARCH64_OPND_IMM_VLSL
:
5095 case AARCH64_OPND_IMM_VLSR
:
5096 case AARCH64_OPND_CCMP_IMM
:
5097 case AARCH64_OPND_FBITS
:
5098 case AARCH64_OPND_UIMM4
:
5099 case AARCH64_OPND_UIMM3_OP1
:
5100 case AARCH64_OPND_UIMM3_OP2
:
5101 case AARCH64_OPND_IMM
:
5102 case AARCH64_OPND_IMM_2
:
5103 case AARCH64_OPND_WIDTH
:
5104 case AARCH64_OPND_UIMM7
:
5105 case AARCH64_OPND_NZCV
:
5106 case AARCH64_OPND_SVE_PATTERN
:
5107 case AARCH64_OPND_SVE_PRFOP
:
5108 operand
->imm
.value
= default_value
;
5111 case AARCH64_OPND_SVE_PATTERN_SCALED
:
5112 operand
->imm
.value
= default_value
;
5113 operand
->shifter
.kind
= AARCH64_MOD_MUL
;
5114 operand
->shifter
.amount
= 1;
5117 case AARCH64_OPND_EXCEPTION
:
5118 inst
.reloc
.type
= BFD_RELOC_UNUSED
;
5121 case AARCH64_OPND_BARRIER_ISB
:
5122 operand
->barrier
= aarch64_barrier_options
+ default_value
;
5129 /* Process the relocation type for move wide instructions.
5130 Return TRUE on success; otherwise return FALSE. */
5133 process_movw_reloc_info (void)
5138 is32
= inst
.base
.operands
[0].qualifier
== AARCH64_OPND_QLF_W
? 1 : 0;
5140 if (inst
.base
.opcode
->op
== OP_MOVK
)
5141 switch (inst
.reloc
.type
)
5143 case BFD_RELOC_AARCH64_MOVW_G0_S
:
5144 case BFD_RELOC_AARCH64_MOVW_G1_S
:
5145 case BFD_RELOC_AARCH64_MOVW_G2_S
:
5146 case BFD_RELOC_AARCH64_MOVW_PREL_G0
:
5147 case BFD_RELOC_AARCH64_MOVW_PREL_G1
:
5148 case BFD_RELOC_AARCH64_MOVW_PREL_G2
:
5149 case BFD_RELOC_AARCH64_MOVW_PREL_G3
:
5150 case BFD_RELOC_AARCH64_TLSGD_MOVW_G1
:
5151 case BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G0
:
5152 case BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G1
:
5153 case BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G2
:
5155 (_("the specified relocation type is not allowed for MOVK"));
5161 switch (inst
.reloc
.type
)
5163 case BFD_RELOC_AARCH64_MOVW_G0
:
5164 case BFD_RELOC_AARCH64_MOVW_G0_NC
:
5165 case BFD_RELOC_AARCH64_MOVW_G0_S
:
5166 case BFD_RELOC_AARCH64_MOVW_GOTOFF_G0_NC
:
5167 case BFD_RELOC_AARCH64_MOVW_PREL_G0
:
5168 case BFD_RELOC_AARCH64_MOVW_PREL_G0_NC
:
5169 case BFD_RELOC_AARCH64_TLSDESC_OFF_G0_NC
:
5170 case BFD_RELOC_AARCH64_TLSGD_MOVW_G0_NC
:
5171 case BFD_RELOC_AARCH64_TLSIE_MOVW_GOTTPREL_G0_NC
:
5172 case BFD_RELOC_AARCH64_TLSLD_MOVW_DTPREL_G0
:
5173 case BFD_RELOC_AARCH64_TLSLD_MOVW_DTPREL_G0_NC
:
5174 case BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G0
:
5175 case BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G0_NC
:
5178 case BFD_RELOC_AARCH64_MOVW_G1
:
5179 case BFD_RELOC_AARCH64_MOVW_G1_NC
:
5180 case BFD_RELOC_AARCH64_MOVW_G1_S
:
5181 case BFD_RELOC_AARCH64_MOVW_GOTOFF_G1
:
5182 case BFD_RELOC_AARCH64_MOVW_PREL_G1
:
5183 case BFD_RELOC_AARCH64_MOVW_PREL_G1_NC
:
5184 case BFD_RELOC_AARCH64_TLSDESC_OFF_G1
:
5185 case BFD_RELOC_AARCH64_TLSGD_MOVW_G1
:
5186 case BFD_RELOC_AARCH64_TLSIE_MOVW_GOTTPREL_G1
:
5187 case BFD_RELOC_AARCH64_TLSLD_MOVW_DTPREL_G1
:
5188 case BFD_RELOC_AARCH64_TLSLD_MOVW_DTPREL_G1_NC
:
5189 case BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G1
:
5190 case BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G1_NC
:
5193 case BFD_RELOC_AARCH64_MOVW_G2
:
5194 case BFD_RELOC_AARCH64_MOVW_G2_NC
:
5195 case BFD_RELOC_AARCH64_MOVW_G2_S
:
5196 case BFD_RELOC_AARCH64_MOVW_PREL_G2
:
5197 case BFD_RELOC_AARCH64_MOVW_PREL_G2_NC
:
5198 case BFD_RELOC_AARCH64_TLSLD_MOVW_DTPREL_G2
:
5199 case BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G2
:
5202 set_fatal_syntax_error
5203 (_("the specified relocation type is not allowed for 32-bit "
5209 case BFD_RELOC_AARCH64_MOVW_G3
:
5210 case BFD_RELOC_AARCH64_MOVW_PREL_G3
:
5213 set_fatal_syntax_error
5214 (_("the specified relocation type is not allowed for 32-bit "
5221 /* More cases should be added when more MOVW-related relocation types
5222 are supported in GAS. */
5223 gas_assert (aarch64_gas_internal_fixup_p ());
5224 /* The shift amount should have already been set by the parser. */
5227 inst
.base
.operands
[1].shifter
.amount
= shift
;
5231 /* A primitive log calculator. */
5233 static inline unsigned int
5234 get_logsz (unsigned int size
)
5236 const unsigned char ls
[16] =
5237 {0, 1, -1, 2, -1, -1, -1, 3, -1, -1, -1, -1, -1, -1, -1, 4};
5243 gas_assert (ls
[size
- 1] != (unsigned char)-1);
5244 return ls
[size
- 1];
5247 /* Determine and return the real reloc type code for an instruction
5248 with the pseudo reloc type code BFD_RELOC_AARCH64_LDST_LO12. */
5250 static inline bfd_reloc_code_real_type
5251 ldst_lo12_determine_real_reloc_type (void)
5254 enum aarch64_opnd_qualifier opd0_qlf
= inst
.base
.operands
[0].qualifier
;
5255 enum aarch64_opnd_qualifier opd1_qlf
= inst
.base
.operands
[1].qualifier
;
5257 const bfd_reloc_code_real_type reloc_ldst_lo12
[5][5] = {
5259 BFD_RELOC_AARCH64_LDST8_LO12
,
5260 BFD_RELOC_AARCH64_LDST16_LO12
,
5261 BFD_RELOC_AARCH64_LDST32_LO12
,
5262 BFD_RELOC_AARCH64_LDST64_LO12
,
5263 BFD_RELOC_AARCH64_LDST128_LO12
5266 BFD_RELOC_AARCH64_TLSLD_LDST8_DTPREL_LO12
,
5267 BFD_RELOC_AARCH64_TLSLD_LDST16_DTPREL_LO12
,
5268 BFD_RELOC_AARCH64_TLSLD_LDST32_DTPREL_LO12
,
5269 BFD_RELOC_AARCH64_TLSLD_LDST64_DTPREL_LO12
,
5270 BFD_RELOC_AARCH64_NONE
5273 BFD_RELOC_AARCH64_TLSLD_LDST8_DTPREL_LO12_NC
,
5274 BFD_RELOC_AARCH64_TLSLD_LDST16_DTPREL_LO12_NC
,
5275 BFD_RELOC_AARCH64_TLSLD_LDST32_DTPREL_LO12_NC
,
5276 BFD_RELOC_AARCH64_TLSLD_LDST64_DTPREL_LO12_NC
,
5277 BFD_RELOC_AARCH64_NONE
5280 BFD_RELOC_AARCH64_TLSLE_LDST8_TPREL_LO12
,
5281 BFD_RELOC_AARCH64_TLSLE_LDST16_TPREL_LO12
,
5282 BFD_RELOC_AARCH64_TLSLE_LDST32_TPREL_LO12
,
5283 BFD_RELOC_AARCH64_TLSLE_LDST64_TPREL_LO12
,
5284 BFD_RELOC_AARCH64_NONE
5287 BFD_RELOC_AARCH64_TLSLE_LDST8_TPREL_LO12_NC
,
5288 BFD_RELOC_AARCH64_TLSLE_LDST16_TPREL_LO12_NC
,
5289 BFD_RELOC_AARCH64_TLSLE_LDST32_TPREL_LO12_NC
,
5290 BFD_RELOC_AARCH64_TLSLE_LDST64_TPREL_LO12_NC
,
5291 BFD_RELOC_AARCH64_NONE
5295 gas_assert (inst
.reloc
.type
== BFD_RELOC_AARCH64_LDST_LO12
5296 || inst
.reloc
.type
== BFD_RELOC_AARCH64_TLSLD_LDST_DTPREL_LO12
5298 == BFD_RELOC_AARCH64_TLSLD_LDST_DTPREL_LO12_NC
)
5300 == BFD_RELOC_AARCH64_TLSLE_LDST_TPREL_LO12
)
5302 == BFD_RELOC_AARCH64_TLSLE_LDST_TPREL_LO12_NC
));
5303 gas_assert (inst
.base
.opcode
->operands
[1] == AARCH64_OPND_ADDR_UIMM12
);
5305 if (opd1_qlf
== AARCH64_OPND_QLF_NIL
)
5307 aarch64_get_expected_qualifier (inst
.base
.opcode
->qualifiers_list
,
5309 gas_assert (opd1_qlf
!= AARCH64_OPND_QLF_NIL
);
5311 logsz
= get_logsz (aarch64_get_qualifier_esize (opd1_qlf
));
5312 if (inst
.reloc
.type
== BFD_RELOC_AARCH64_TLSLD_LDST_DTPREL_LO12
5313 || inst
.reloc
.type
== BFD_RELOC_AARCH64_TLSLD_LDST_DTPREL_LO12_NC
5314 || inst
.reloc
.type
== BFD_RELOC_AARCH64_TLSLE_LDST_TPREL_LO12
5315 || inst
.reloc
.type
== BFD_RELOC_AARCH64_TLSLE_LDST_TPREL_LO12_NC
)
5316 gas_assert (logsz
<= 3);
5318 gas_assert (logsz
<= 4);
5320 /* In reloc.c, these pseudo relocation types should be defined in similar
5321 order as above reloc_ldst_lo12 array. Because the array index calculation
5322 below relies on this. */
5323 return reloc_ldst_lo12
[inst
.reloc
.type
- BFD_RELOC_AARCH64_LDST_LO12
][logsz
];
5326 /* Check whether a register list REGINFO is valid. The registers must be
5327 numbered in increasing order (modulo 32), in increments of one or two.
5329 If ACCEPT_ALTERNATE is non-zero, the register numbers should be in
5332 Return FALSE if such a register list is invalid, otherwise return TRUE. */
5335 reg_list_valid_p (uint32_t reginfo
, int accept_alternate
)
5337 uint32_t i
, nb_regs
, prev_regno
, incr
;
5339 nb_regs
= 1 + (reginfo
& 0x3);
5341 prev_regno
= reginfo
& 0x1f;
5342 incr
= accept_alternate
? 2 : 1;
5344 for (i
= 1; i
< nb_regs
; ++i
)
5346 uint32_t curr_regno
;
5348 curr_regno
= reginfo
& 0x1f;
5349 if (curr_regno
!= ((prev_regno
+ incr
) & 0x1f))
5351 prev_regno
= curr_regno
;
5357 /* Generic instruction operand parser. This does no encoding and no
5358 semantic validation; it merely squirrels values away in the inst
5359 structure. Returns TRUE or FALSE depending on whether the
5360 specified grammar matched. */
5363 parse_operands (char *str
, const aarch64_opcode
*opcode
)
5366 char *backtrack_pos
= 0;
5367 const enum aarch64_opnd
*operands
= opcode
->operands
;
5368 aarch64_reg_type imm_reg_type
;
5371 skip_whitespace (str
);
5373 if (AARCH64_CPU_HAS_FEATURE (AARCH64_FEATURE_SVE
, *opcode
->avariant
))
5374 imm_reg_type
= REG_TYPE_R_Z_SP_BHSDQ_VZP
;
5376 imm_reg_type
= REG_TYPE_R_Z_BHSDQ_V
;
5378 for (i
= 0; operands
[i
] != AARCH64_OPND_NIL
; i
++)
5381 const reg_entry
*reg
;
5382 int comma_skipped_p
= 0;
5383 aarch64_reg_type rtype
;
5384 struct vector_type_el vectype
;
5385 aarch64_opnd_qualifier_t qualifier
, base_qualifier
, offset_qualifier
;
5386 aarch64_opnd_info
*info
= &inst
.base
.operands
[i
];
5387 aarch64_reg_type reg_type
;
5389 DEBUG_TRACE ("parse operand %d", i
);
5391 /* Assign the operand code. */
5392 info
->type
= operands
[i
];
5394 if (optional_operand_p (opcode
, i
))
5396 /* Remember where we are in case we need to backtrack. */
5397 gas_assert (!backtrack_pos
);
5398 backtrack_pos
= str
;
5401 /* Expect comma between operands; the backtrack mechanism will take
5402 care of cases of omitted optional operand. */
5403 if (i
> 0 && ! skip_past_char (&str
, ','))
5405 set_syntax_error (_("comma expected between operands"));
5409 comma_skipped_p
= 1;
5411 switch (operands
[i
])
5413 case AARCH64_OPND_Rd
:
5414 case AARCH64_OPND_Rn
:
5415 case AARCH64_OPND_Rm
:
5416 case AARCH64_OPND_Rt
:
5417 case AARCH64_OPND_Rt2
:
5418 case AARCH64_OPND_Rs
:
5419 case AARCH64_OPND_Ra
:
5420 case AARCH64_OPND_Rt_SYS
:
5421 case AARCH64_OPND_PAIRREG
:
5422 case AARCH64_OPND_SVE_Rm
:
5423 po_int_reg_or_fail (REG_TYPE_R_Z
);
5426 case AARCH64_OPND_Rd_SP
:
5427 case AARCH64_OPND_Rn_SP
:
5428 case AARCH64_OPND_SVE_Rn_SP
:
5429 case AARCH64_OPND_Rm_SP
:
5430 po_int_reg_or_fail (REG_TYPE_R_SP
);
5433 case AARCH64_OPND_Rm_EXT
:
5434 case AARCH64_OPND_Rm_SFT
:
5435 po_misc_or_fail (parse_shifter_operand
5436 (&str
, info
, (operands
[i
] == AARCH64_OPND_Rm_EXT
5438 : SHIFTED_LOGIC_IMM
)));
5439 if (!info
->shifter
.operator_present
)
5441 /* Default to LSL if not present. Libopcodes prefers shifter
5442 kind to be explicit. */
5443 gas_assert (info
->shifter
.kind
== AARCH64_MOD_NONE
);
5444 info
->shifter
.kind
= AARCH64_MOD_LSL
;
5445 /* For Rm_EXT, libopcodes will carry out further check on whether
5446 or not stack pointer is used in the instruction (Recall that
5447 "the extend operator is not optional unless at least one of
5448 "Rd" or "Rn" is '11111' (i.e. WSP)"). */
5452 case AARCH64_OPND_Fd
:
5453 case AARCH64_OPND_Fn
:
5454 case AARCH64_OPND_Fm
:
5455 case AARCH64_OPND_Fa
:
5456 case AARCH64_OPND_Ft
:
5457 case AARCH64_OPND_Ft2
:
5458 case AARCH64_OPND_Sd
:
5459 case AARCH64_OPND_Sn
:
5460 case AARCH64_OPND_Sm
:
5461 case AARCH64_OPND_SVE_VZn
:
5462 case AARCH64_OPND_SVE_Vd
:
5463 case AARCH64_OPND_SVE_Vm
:
5464 case AARCH64_OPND_SVE_Vn
:
5465 val
= aarch64_reg_parse (&str
, REG_TYPE_BHSDQ
, &rtype
, NULL
);
5466 if (val
== PARSE_FAIL
)
5468 first_error (_(get_reg_expected_msg (REG_TYPE_BHSDQ
)));
5471 gas_assert (rtype
>= REG_TYPE_FP_B
&& rtype
<= REG_TYPE_FP_Q
);
5473 info
->reg
.regno
= val
;
5474 info
->qualifier
= AARCH64_OPND_QLF_S_B
+ (rtype
- REG_TYPE_FP_B
);
5477 case AARCH64_OPND_SVE_Pd
:
5478 case AARCH64_OPND_SVE_Pg3
:
5479 case AARCH64_OPND_SVE_Pg4_5
:
5480 case AARCH64_OPND_SVE_Pg4_10
:
5481 case AARCH64_OPND_SVE_Pg4_16
:
5482 case AARCH64_OPND_SVE_Pm
:
5483 case AARCH64_OPND_SVE_Pn
:
5484 case AARCH64_OPND_SVE_Pt
:
5485 reg_type
= REG_TYPE_PN
;
5488 case AARCH64_OPND_SVE_Za_5
:
5489 case AARCH64_OPND_SVE_Za_16
:
5490 case AARCH64_OPND_SVE_Zd
:
5491 case AARCH64_OPND_SVE_Zm_5
:
5492 case AARCH64_OPND_SVE_Zm_16
:
5493 case AARCH64_OPND_SVE_Zn
:
5494 case AARCH64_OPND_SVE_Zt
:
5495 reg_type
= REG_TYPE_ZN
;
5498 case AARCH64_OPND_Va
:
5499 case AARCH64_OPND_Vd
:
5500 case AARCH64_OPND_Vn
:
5501 case AARCH64_OPND_Vm
:
5502 reg_type
= REG_TYPE_VN
;
5504 val
= aarch64_reg_parse (&str
, reg_type
, NULL
, &vectype
);
5505 if (val
== PARSE_FAIL
)
5507 first_error (_(get_reg_expected_msg (reg_type
)));
5510 if (vectype
.defined
& NTA_HASINDEX
)
5513 info
->reg
.regno
= val
;
5514 if ((reg_type
== REG_TYPE_PN
|| reg_type
== REG_TYPE_ZN
)
5515 && vectype
.type
== NT_invtype
)
5516 /* Unqualified Pn and Zn registers are allowed in certain
5517 contexts. Rely on F_STRICT qualifier checking to catch
5519 info
->qualifier
= AARCH64_OPND_QLF_NIL
;
5522 info
->qualifier
= vectype_to_qualifier (&vectype
);
5523 if (info
->qualifier
== AARCH64_OPND_QLF_NIL
)
5528 case AARCH64_OPND_VdD1
:
5529 case AARCH64_OPND_VnD1
:
5530 val
= aarch64_reg_parse (&str
, REG_TYPE_VN
, NULL
, &vectype
);
5531 if (val
== PARSE_FAIL
)
5533 set_first_syntax_error (_(get_reg_expected_msg (REG_TYPE_VN
)));
5536 if (vectype
.type
!= NT_d
|| vectype
.index
!= 1)
5538 set_fatal_syntax_error
5539 (_("the top half of a 128-bit FP/SIMD register is expected"));
5542 info
->reg
.regno
= val
;
5543 /* N.B: VdD1 and VnD1 are treated as an fp or advsimd scalar register
5544 here; it is correct for the purpose of encoding/decoding since
5545 only the register number is explicitly encoded in the related
5546 instructions, although this appears a bit hacky. */
5547 info
->qualifier
= AARCH64_OPND_QLF_S_D
;
5550 case AARCH64_OPND_SVE_Zm3_INDEX
:
5551 case AARCH64_OPND_SVE_Zm3_22_INDEX
:
5552 case AARCH64_OPND_SVE_Zm4_INDEX
:
5553 case AARCH64_OPND_SVE_Zn_INDEX
:
5554 reg_type
= REG_TYPE_ZN
;
5555 goto vector_reg_index
;
5557 case AARCH64_OPND_Ed
:
5558 case AARCH64_OPND_En
:
5559 case AARCH64_OPND_Em
:
5560 case AARCH64_OPND_SM3_IMM2
:
5561 reg_type
= REG_TYPE_VN
;
5563 val
= aarch64_reg_parse (&str
, reg_type
, NULL
, &vectype
);
5564 if (val
== PARSE_FAIL
)
5566 first_error (_(get_reg_expected_msg (reg_type
)));
5569 if (vectype
.type
== NT_invtype
|| !(vectype
.defined
& NTA_HASINDEX
))
5572 info
->reglane
.regno
= val
;
5573 info
->reglane
.index
= vectype
.index
;
5574 info
->qualifier
= vectype_to_qualifier (&vectype
);
5575 if (info
->qualifier
== AARCH64_OPND_QLF_NIL
)
5579 case AARCH64_OPND_SVE_ZnxN
:
5580 case AARCH64_OPND_SVE_ZtxN
:
5581 reg_type
= REG_TYPE_ZN
;
5582 goto vector_reg_list
;
5584 case AARCH64_OPND_LVn
:
5585 case AARCH64_OPND_LVt
:
5586 case AARCH64_OPND_LVt_AL
:
5587 case AARCH64_OPND_LEt
:
5588 reg_type
= REG_TYPE_VN
;
5590 if (reg_type
== REG_TYPE_ZN
5591 && get_opcode_dependent_value (opcode
) == 1
5594 val
= aarch64_reg_parse (&str
, reg_type
, NULL
, &vectype
);
5595 if (val
== PARSE_FAIL
)
5597 first_error (_(get_reg_expected_msg (reg_type
)));
5600 info
->reglist
.first_regno
= val
;
5601 info
->reglist
.num_regs
= 1;
5605 val
= parse_vector_reg_list (&str
, reg_type
, &vectype
);
5606 if (val
== PARSE_FAIL
)
5608 if (! reg_list_valid_p (val
, /* accept_alternate */ 0))
5610 set_fatal_syntax_error (_("invalid register list"));
5613 info
->reglist
.first_regno
= (val
>> 2) & 0x1f;
5614 info
->reglist
.num_regs
= (val
& 0x3) + 1;
5616 if (operands
[i
] == AARCH64_OPND_LEt
)
5618 if (!(vectype
.defined
& NTA_HASINDEX
))
5620 info
->reglist
.has_index
= 1;
5621 info
->reglist
.index
= vectype
.index
;
5625 if (vectype
.defined
& NTA_HASINDEX
)
5627 if (!(vectype
.defined
& NTA_HASTYPE
))
5629 if (reg_type
== REG_TYPE_ZN
)
5630 set_fatal_syntax_error (_("missing type suffix"));
5634 info
->qualifier
= vectype_to_qualifier (&vectype
);
5635 if (info
->qualifier
== AARCH64_OPND_QLF_NIL
)
5639 case AARCH64_OPND_CRn
:
5640 case AARCH64_OPND_CRm
:
5642 char prefix
= *(str
++);
5643 if (prefix
!= 'c' && prefix
!= 'C')
5646 po_imm_nc_or_fail ();
5649 set_fatal_syntax_error (_(N_ ("C0 - C15 expected")));
5652 info
->qualifier
= AARCH64_OPND_QLF_CR
;
5653 info
->imm
.value
= val
;
5657 case AARCH64_OPND_SHLL_IMM
:
5658 case AARCH64_OPND_IMM_VLSR
:
5659 po_imm_or_fail (1, 64);
5660 info
->imm
.value
= val
;
5663 case AARCH64_OPND_CCMP_IMM
:
5664 case AARCH64_OPND_SIMM5
:
5665 case AARCH64_OPND_FBITS
:
5666 case AARCH64_OPND_UIMM4
:
5667 case AARCH64_OPND_UIMM3_OP1
:
5668 case AARCH64_OPND_UIMM3_OP2
:
5669 case AARCH64_OPND_IMM_VLSL
:
5670 case AARCH64_OPND_IMM
:
5671 case AARCH64_OPND_IMM_2
:
5672 case AARCH64_OPND_WIDTH
:
5673 case AARCH64_OPND_SVE_INV_LIMM
:
5674 case AARCH64_OPND_SVE_LIMM
:
5675 case AARCH64_OPND_SVE_LIMM_MOV
:
5676 case AARCH64_OPND_SVE_SHLIMM_PRED
:
5677 case AARCH64_OPND_SVE_SHLIMM_UNPRED
:
5678 case AARCH64_OPND_SVE_SHRIMM_PRED
:
5679 case AARCH64_OPND_SVE_SHRIMM_UNPRED
:
5680 case AARCH64_OPND_SVE_SIMM5
:
5681 case AARCH64_OPND_SVE_SIMM5B
:
5682 case AARCH64_OPND_SVE_SIMM6
:
5683 case AARCH64_OPND_SVE_SIMM8
:
5684 case AARCH64_OPND_SVE_UIMM3
:
5685 case AARCH64_OPND_SVE_UIMM7
:
5686 case AARCH64_OPND_SVE_UIMM8
:
5687 case AARCH64_OPND_SVE_UIMM8_53
:
5688 case AARCH64_OPND_IMM_ROT1
:
5689 case AARCH64_OPND_IMM_ROT2
:
5690 case AARCH64_OPND_IMM_ROT3
:
5691 case AARCH64_OPND_SVE_IMM_ROT1
:
5692 case AARCH64_OPND_SVE_IMM_ROT2
:
5693 po_imm_nc_or_fail ();
5694 info
->imm
.value
= val
;
5697 case AARCH64_OPND_SVE_AIMM
:
5698 case AARCH64_OPND_SVE_ASIMM
:
5699 po_imm_nc_or_fail ();
5700 info
->imm
.value
= val
;
5701 skip_whitespace (str
);
5702 if (skip_past_comma (&str
))
5703 po_misc_or_fail (parse_shift (&str
, info
, SHIFTED_LSL
));
5705 inst
.base
.operands
[i
].shifter
.kind
= AARCH64_MOD_LSL
;
5708 case AARCH64_OPND_SVE_PATTERN
:
5709 po_enum_or_fail (aarch64_sve_pattern_array
);
5710 info
->imm
.value
= val
;
5713 case AARCH64_OPND_SVE_PATTERN_SCALED
:
5714 po_enum_or_fail (aarch64_sve_pattern_array
);
5715 info
->imm
.value
= val
;
5716 if (skip_past_comma (&str
)
5717 && !parse_shift (&str
, info
, SHIFTED_MUL
))
5719 if (!info
->shifter
.operator_present
)
5721 gas_assert (info
->shifter
.kind
== AARCH64_MOD_NONE
);
5722 info
->shifter
.kind
= AARCH64_MOD_MUL
;
5723 info
->shifter
.amount
= 1;
5727 case AARCH64_OPND_SVE_PRFOP
:
5728 po_enum_or_fail (aarch64_sve_prfop_array
);
5729 info
->imm
.value
= val
;
5732 case AARCH64_OPND_UIMM7
:
5733 po_imm_or_fail (0, 127);
5734 info
->imm
.value
= val
;
5737 case AARCH64_OPND_IDX
:
5738 case AARCH64_OPND_MASK
:
5739 case AARCH64_OPND_BIT_NUM
:
5740 case AARCH64_OPND_IMMR
:
5741 case AARCH64_OPND_IMMS
:
5742 po_imm_or_fail (0, 63);
5743 info
->imm
.value
= val
;
5746 case AARCH64_OPND_IMM0
:
5747 po_imm_nc_or_fail ();
5750 set_fatal_syntax_error (_("immediate zero expected"));
5753 info
->imm
.value
= 0;
5756 case AARCH64_OPND_FPIMM0
:
5759 bfd_boolean res1
= FALSE
, res2
= FALSE
;
5760 /* N.B. -0.0 will be rejected; although -0.0 shouldn't be rejected,
5761 it is probably not worth the effort to support it. */
5762 if (!(res1
= parse_aarch64_imm_float (&str
, &qfloat
, FALSE
,
5765 || !(res2
= parse_constant_immediate (&str
, &val
,
5768 if ((res1
&& qfloat
== 0) || (res2
&& val
== 0))
5770 info
->imm
.value
= 0;
5771 info
->imm
.is_fp
= 1;
5774 set_fatal_syntax_error (_("immediate zero expected"));
5778 case AARCH64_OPND_IMM_MOV
:
5781 if (reg_name_p (str
, REG_TYPE_R_Z_SP
) ||
5782 reg_name_p (str
, REG_TYPE_VN
))
5785 po_misc_or_fail (my_get_expression (&inst
.reloc
.exp
, &str
,
5787 /* The MOV immediate alias will be fixed up by fix_mov_imm_insn
5788 later. fix_mov_imm_insn will try to determine a machine
5789 instruction (MOVZ, MOVN or ORR) for it and will issue an error
5790 message if the immediate cannot be moved by a single
5792 aarch64_set_gas_internal_fixup (&inst
.reloc
, info
, 1);
5793 inst
.base
.operands
[i
].skip
= 1;
5797 case AARCH64_OPND_SIMD_IMM
:
5798 case AARCH64_OPND_SIMD_IMM_SFT
:
5799 if (! parse_big_immediate (&str
, &val
, imm_reg_type
))
5801 assign_imm_if_const_or_fixup_later (&inst
.reloc
, info
,
5803 /* need_libopcodes_p */ 1,
5806 N.B. although AARCH64_OPND_SIMD_IMM doesn't permit any
5807 shift, we don't check it here; we leave the checking to
5808 the libopcodes (operand_general_constraint_met_p). By
5809 doing this, we achieve better diagnostics. */
5810 if (skip_past_comma (&str
)
5811 && ! parse_shift (&str
, info
, SHIFTED_LSL_MSL
))
5813 if (!info
->shifter
.operator_present
5814 && info
->type
== AARCH64_OPND_SIMD_IMM_SFT
)
5816 /* Default to LSL if not present. Libopcodes prefers shifter
5817 kind to be explicit. */
5818 gas_assert (info
->shifter
.kind
== AARCH64_MOD_NONE
);
5819 info
->shifter
.kind
= AARCH64_MOD_LSL
;
5823 case AARCH64_OPND_FPIMM
:
5824 case AARCH64_OPND_SIMD_FPIMM
:
5825 case AARCH64_OPND_SVE_FPIMM8
:
5830 dp_p
= double_precision_operand_p (&inst
.base
.operands
[0]);
5831 if (!parse_aarch64_imm_float (&str
, &qfloat
, dp_p
, imm_reg_type
)
5832 || !aarch64_imm_float_p (qfloat
))
5835 set_fatal_syntax_error (_("invalid floating-point"
5839 inst
.base
.operands
[i
].imm
.value
= encode_imm_float_bits (qfloat
);
5840 inst
.base
.operands
[i
].imm
.is_fp
= 1;
5844 case AARCH64_OPND_SVE_I1_HALF_ONE
:
5845 case AARCH64_OPND_SVE_I1_HALF_TWO
:
5846 case AARCH64_OPND_SVE_I1_ZERO_ONE
:
5851 dp_p
= double_precision_operand_p (&inst
.base
.operands
[0]);
5852 if (!parse_aarch64_imm_float (&str
, &qfloat
, dp_p
, imm_reg_type
))
5855 set_fatal_syntax_error (_("invalid floating-point"
5859 inst
.base
.operands
[i
].imm
.value
= qfloat
;
5860 inst
.base
.operands
[i
].imm
.is_fp
= 1;
5864 case AARCH64_OPND_LIMM
:
5865 po_misc_or_fail (parse_shifter_operand (&str
, info
,
5866 SHIFTED_LOGIC_IMM
));
5867 if (info
->shifter
.operator_present
)
5869 set_fatal_syntax_error
5870 (_("shift not allowed for bitmask immediate"));
5873 assign_imm_if_const_or_fixup_later (&inst
.reloc
, info
,
5875 /* need_libopcodes_p */ 1,
5879 case AARCH64_OPND_AIMM
:
5880 if (opcode
->op
== OP_ADD
)
5881 /* ADD may have relocation types. */
5882 po_misc_or_fail (parse_shifter_operand_reloc (&str
, info
,
5883 SHIFTED_ARITH_IMM
));
5885 po_misc_or_fail (parse_shifter_operand (&str
, info
,
5886 SHIFTED_ARITH_IMM
));
5887 switch (inst
.reloc
.type
)
5889 case BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_HI12
:
5890 info
->shifter
.amount
= 12;
5892 case BFD_RELOC_UNUSED
:
5893 aarch64_set_gas_internal_fixup (&inst
.reloc
, info
, 0);
5894 if (info
->shifter
.kind
!= AARCH64_MOD_NONE
)
5895 inst
.reloc
.flags
= FIXUP_F_HAS_EXPLICIT_SHIFT
;
5896 inst
.reloc
.pc_rel
= 0;
5901 info
->imm
.value
= 0;
5902 if (!info
->shifter
.operator_present
)
5904 /* Default to LSL if not present. Libopcodes prefers shifter
5905 kind to be explicit. */
5906 gas_assert (info
->shifter
.kind
== AARCH64_MOD_NONE
);
5907 info
->shifter
.kind
= AARCH64_MOD_LSL
;
5911 case AARCH64_OPND_HALF
:
5913 /* #<imm16> or relocation. */
5914 int internal_fixup_p
;
5915 po_misc_or_fail (parse_half (&str
, &internal_fixup_p
));
5916 if (internal_fixup_p
)
5917 aarch64_set_gas_internal_fixup (&inst
.reloc
, info
, 0);
5918 skip_whitespace (str
);
5919 if (skip_past_comma (&str
))
5921 /* {, LSL #<shift>} */
5922 if (! aarch64_gas_internal_fixup_p ())
5924 set_fatal_syntax_error (_("can't mix relocation modifier "
5925 "with explicit shift"));
5928 po_misc_or_fail (parse_shift (&str
, info
, SHIFTED_LSL
));
5931 inst
.base
.operands
[i
].shifter
.amount
= 0;
5932 inst
.base
.operands
[i
].shifter
.kind
= AARCH64_MOD_LSL
;
5933 inst
.base
.operands
[i
].imm
.value
= 0;
5934 if (! process_movw_reloc_info ())
5939 case AARCH64_OPND_EXCEPTION
:
5940 po_misc_or_fail (parse_immediate_expression (&str
, &inst
.reloc
.exp
,
5942 assign_imm_if_const_or_fixup_later (&inst
.reloc
, info
,
5944 /* need_libopcodes_p */ 0,
5948 case AARCH64_OPND_NZCV
:
5950 const asm_nzcv
*nzcv
= hash_find_n (aarch64_nzcv_hsh
, str
, 4);
5954 info
->imm
.value
= nzcv
->value
;
5957 po_imm_or_fail (0, 15);
5958 info
->imm
.value
= val
;
5962 case AARCH64_OPND_COND
:
5963 case AARCH64_OPND_COND1
:
5968 while (ISALPHA (*str
));
5969 info
->cond
= hash_find_n (aarch64_cond_hsh
, start
, str
- start
);
5970 if (info
->cond
== NULL
)
5972 set_syntax_error (_("invalid condition"));
5975 else if (operands
[i
] == AARCH64_OPND_COND1
5976 && (info
->cond
->value
& 0xe) == 0xe)
5978 /* Do not allow AL or NV. */
5979 set_default_error ();
5985 case AARCH64_OPND_ADDR_ADRP
:
5986 po_misc_or_fail (parse_adrp (&str
));
5987 /* Clear the value as operand needs to be relocated. */
5988 info
->imm
.value
= 0;
5991 case AARCH64_OPND_ADDR_PCREL14
:
5992 case AARCH64_OPND_ADDR_PCREL19
:
5993 case AARCH64_OPND_ADDR_PCREL21
:
5994 case AARCH64_OPND_ADDR_PCREL26
:
5995 po_misc_or_fail (parse_address (&str
, info
));
5996 if (!info
->addr
.pcrel
)
5998 set_syntax_error (_("invalid pc-relative address"));
6001 if (inst
.gen_lit_pool
6002 && (opcode
->iclass
!= loadlit
|| opcode
->op
== OP_PRFM_LIT
))
6004 /* Only permit "=value" in the literal load instructions.
6005 The literal will be generated by programmer_friendly_fixup. */
6006 set_syntax_error (_("invalid use of \"=immediate\""));
6009 if (inst
.reloc
.exp
.X_op
== O_symbol
&& find_reloc_table_entry (&str
))
6011 set_syntax_error (_("unrecognized relocation suffix"));
6014 if (inst
.reloc
.exp
.X_op
== O_constant
&& !inst
.gen_lit_pool
)
6016 info
->imm
.value
= inst
.reloc
.exp
.X_add_number
;
6017 inst
.reloc
.type
= BFD_RELOC_UNUSED
;
6021 info
->imm
.value
= 0;
6022 if (inst
.reloc
.type
== BFD_RELOC_UNUSED
)
6023 switch (opcode
->iclass
)
6027 /* e.g. CBZ or B.COND */
6028 gas_assert (operands
[i
] == AARCH64_OPND_ADDR_PCREL19
);
6029 inst
.reloc
.type
= BFD_RELOC_AARCH64_BRANCH19
;
6033 gas_assert (operands
[i
] == AARCH64_OPND_ADDR_PCREL14
);
6034 inst
.reloc
.type
= BFD_RELOC_AARCH64_TSTBR14
;
6038 gas_assert (operands
[i
] == AARCH64_OPND_ADDR_PCREL26
);
6040 (opcode
->op
== OP_BL
) ? BFD_RELOC_AARCH64_CALL26
6041 : BFD_RELOC_AARCH64_JUMP26
;
6044 gas_assert (operands
[i
] == AARCH64_OPND_ADDR_PCREL19
);
6045 inst
.reloc
.type
= BFD_RELOC_AARCH64_LD_LO19_PCREL
;
6048 gas_assert (operands
[i
] == AARCH64_OPND_ADDR_PCREL21
);
6049 inst
.reloc
.type
= BFD_RELOC_AARCH64_ADR_LO21_PCREL
;
6055 inst
.reloc
.pc_rel
= 1;
6059 case AARCH64_OPND_ADDR_SIMPLE
:
6060 case AARCH64_OPND_SIMD_ADDR_SIMPLE
:
6062 /* [<Xn|SP>{, #<simm>}] */
6064 /* First use the normal address-parsing routines, to get
6065 the usual syntax errors. */
6066 po_misc_or_fail (parse_address (&str
, info
));
6067 if (info
->addr
.pcrel
|| info
->addr
.offset
.is_reg
6068 || !info
->addr
.preind
|| info
->addr
.postind
6069 || info
->addr
.writeback
)
6071 set_syntax_error (_("invalid addressing mode"));
6075 /* Then retry, matching the specific syntax of these addresses. */
6077 po_char_or_fail ('[');
6078 po_reg_or_fail (REG_TYPE_R64_SP
);
6079 /* Accept optional ", #0". */
6080 if (operands
[i
] == AARCH64_OPND_ADDR_SIMPLE
6081 && skip_past_char (&str
, ','))
6083 skip_past_char (&str
, '#');
6084 if (! skip_past_char (&str
, '0'))
6086 set_fatal_syntax_error
6087 (_("the optional immediate offset can only be 0"));
6091 po_char_or_fail (']');
6095 case AARCH64_OPND_ADDR_REGOFF
:
6096 /* [<Xn|SP>, <R><m>{, <extend> {<amount>}}] */
6097 po_misc_or_fail (parse_address (&str
, info
));
6099 if (info
->addr
.pcrel
|| !info
->addr
.offset
.is_reg
6100 || !info
->addr
.preind
|| info
->addr
.postind
6101 || info
->addr
.writeback
)
6103 set_syntax_error (_("invalid addressing mode"));
6106 if (!info
->shifter
.operator_present
)
6108 /* Default to LSL if not present. Libopcodes prefers shifter
6109 kind to be explicit. */
6110 gas_assert (info
->shifter
.kind
== AARCH64_MOD_NONE
);
6111 info
->shifter
.kind
= AARCH64_MOD_LSL
;
6113 /* Qualifier to be deduced by libopcodes. */
6116 case AARCH64_OPND_ADDR_SIMM7
:
6117 po_misc_or_fail (parse_address (&str
, info
));
6118 if (info
->addr
.pcrel
|| info
->addr
.offset
.is_reg
6119 || (!info
->addr
.preind
&& !info
->addr
.postind
))
6121 set_syntax_error (_("invalid addressing mode"));
6124 if (inst
.reloc
.type
!= BFD_RELOC_UNUSED
)
6126 set_syntax_error (_("relocation not allowed"));
6129 assign_imm_if_const_or_fixup_later (&inst
.reloc
, info
,
6131 /* need_libopcodes_p */ 1,
6135 case AARCH64_OPND_ADDR_SIMM9
:
6136 case AARCH64_OPND_ADDR_SIMM9_2
:
6137 po_misc_or_fail (parse_address (&str
, info
));
6138 if (info
->addr
.pcrel
|| info
->addr
.offset
.is_reg
6139 || (!info
->addr
.preind
&& !info
->addr
.postind
)
6140 || (operands
[i
] == AARCH64_OPND_ADDR_SIMM9_2
6141 && info
->addr
.writeback
))
6143 set_syntax_error (_("invalid addressing mode"));
6146 if (inst
.reloc
.type
!= BFD_RELOC_UNUSED
)
6148 set_syntax_error (_("relocation not allowed"));
6151 assign_imm_if_const_or_fixup_later (&inst
.reloc
, info
,
6153 /* need_libopcodes_p */ 1,
6157 case AARCH64_OPND_ADDR_SIMM10
:
6158 case AARCH64_OPND_ADDR_OFFSET
:
6159 po_misc_or_fail (parse_address (&str
, info
));
6160 if (info
->addr
.pcrel
|| info
->addr
.offset
.is_reg
6161 || !info
->addr
.preind
|| info
->addr
.postind
)
6163 set_syntax_error (_("invalid addressing mode"));
6166 if (inst
.reloc
.type
!= BFD_RELOC_UNUSED
)
6168 set_syntax_error (_("relocation not allowed"));
6171 assign_imm_if_const_or_fixup_later (&inst
.reloc
, info
,
6173 /* need_libopcodes_p */ 1,
6177 case AARCH64_OPND_ADDR_UIMM12
:
6178 po_misc_or_fail (parse_address (&str
, info
));
6179 if (info
->addr
.pcrel
|| info
->addr
.offset
.is_reg
6180 || !info
->addr
.preind
|| info
->addr
.writeback
)
6182 set_syntax_error (_("invalid addressing mode"));
6185 if (inst
.reloc
.type
== BFD_RELOC_UNUSED
)
6186 aarch64_set_gas_internal_fixup (&inst
.reloc
, info
, 1);
6187 else if (inst
.reloc
.type
== BFD_RELOC_AARCH64_LDST_LO12
6189 == BFD_RELOC_AARCH64_TLSLD_LDST_DTPREL_LO12
)
6191 == BFD_RELOC_AARCH64_TLSLD_LDST_DTPREL_LO12_NC
)
6193 == BFD_RELOC_AARCH64_TLSLE_LDST_TPREL_LO12
)
6195 == BFD_RELOC_AARCH64_TLSLE_LDST_TPREL_LO12_NC
))
6196 inst
.reloc
.type
= ldst_lo12_determine_real_reloc_type ();
6197 /* Leave qualifier to be determined by libopcodes. */
6200 case AARCH64_OPND_SIMD_ADDR_POST
:
6201 /* [<Xn|SP>], <Xm|#<amount>> */
6202 po_misc_or_fail (parse_address (&str
, info
));
6203 if (!info
->addr
.postind
|| !info
->addr
.writeback
)
6205 set_syntax_error (_("invalid addressing mode"));
6208 if (!info
->addr
.offset
.is_reg
)
6210 if (inst
.reloc
.exp
.X_op
== O_constant
)
6211 info
->addr
.offset
.imm
= inst
.reloc
.exp
.X_add_number
;
6214 set_fatal_syntax_error
6215 (_("writeback value must be an immediate constant"));
6222 case AARCH64_OPND_SVE_ADDR_RI_S4x16
:
6223 case AARCH64_OPND_SVE_ADDR_RI_S4xVL
:
6224 case AARCH64_OPND_SVE_ADDR_RI_S4x2xVL
:
6225 case AARCH64_OPND_SVE_ADDR_RI_S4x3xVL
:
6226 case AARCH64_OPND_SVE_ADDR_RI_S4x4xVL
:
6227 case AARCH64_OPND_SVE_ADDR_RI_S6xVL
:
6228 case AARCH64_OPND_SVE_ADDR_RI_S9xVL
:
6229 case AARCH64_OPND_SVE_ADDR_RI_U6
:
6230 case AARCH64_OPND_SVE_ADDR_RI_U6x2
:
6231 case AARCH64_OPND_SVE_ADDR_RI_U6x4
:
6232 case AARCH64_OPND_SVE_ADDR_RI_U6x8
:
6233 /* [X<n>{, #imm, MUL VL}]
6235 but recognizing SVE registers. */
6236 po_misc_or_fail (parse_sve_address (&str
, info
, &base_qualifier
,
6237 &offset_qualifier
));
6238 if (base_qualifier
!= AARCH64_OPND_QLF_X
)
6240 set_syntax_error (_("invalid addressing mode"));
6244 if (info
->addr
.pcrel
|| info
->addr
.offset
.is_reg
6245 || !info
->addr
.preind
|| info
->addr
.writeback
)
6247 set_syntax_error (_("invalid addressing mode"));
6250 if (inst
.reloc
.type
!= BFD_RELOC_UNUSED
6251 || inst
.reloc
.exp
.X_op
!= O_constant
)
6253 /* Make sure this has priority over
6254 "invalid addressing mode". */
6255 set_fatal_syntax_error (_("constant offset required"));
6258 info
->addr
.offset
.imm
= inst
.reloc
.exp
.X_add_number
;
6261 case AARCH64_OPND_SVE_ADDR_R
:
6262 /* [<Xn|SP>{, <R><m>}]
6263 but recognizing SVE registers. */
6264 po_misc_or_fail (parse_sve_address (&str
, info
, &base_qualifier
,
6265 &offset_qualifier
));
6266 if (offset_qualifier
== AARCH64_OPND_QLF_NIL
)
6268 offset_qualifier
= AARCH64_OPND_QLF_X
;
6269 info
->addr
.offset
.is_reg
= 1;
6270 info
->addr
.offset
.regno
= 31;
6272 else if (base_qualifier
!= AARCH64_OPND_QLF_X
6273 || offset_qualifier
!= AARCH64_OPND_QLF_X
)
6275 set_syntax_error (_("invalid addressing mode"));
6280 case AARCH64_OPND_SVE_ADDR_RR
:
6281 case AARCH64_OPND_SVE_ADDR_RR_LSL1
:
6282 case AARCH64_OPND_SVE_ADDR_RR_LSL2
:
6283 case AARCH64_OPND_SVE_ADDR_RR_LSL3
:
6284 case AARCH64_OPND_SVE_ADDR_RX
:
6285 case AARCH64_OPND_SVE_ADDR_RX_LSL1
:
6286 case AARCH64_OPND_SVE_ADDR_RX_LSL2
:
6287 case AARCH64_OPND_SVE_ADDR_RX_LSL3
:
6288 /* [<Xn|SP>, <R><m>{, lsl #<amount>}]
6289 but recognizing SVE registers. */
6290 po_misc_or_fail (parse_sve_address (&str
, info
, &base_qualifier
,
6291 &offset_qualifier
));
6292 if (base_qualifier
!= AARCH64_OPND_QLF_X
6293 || offset_qualifier
!= AARCH64_OPND_QLF_X
)
6295 set_syntax_error (_("invalid addressing mode"));
6300 case AARCH64_OPND_SVE_ADDR_RZ
:
6301 case AARCH64_OPND_SVE_ADDR_RZ_LSL1
:
6302 case AARCH64_OPND_SVE_ADDR_RZ_LSL2
:
6303 case AARCH64_OPND_SVE_ADDR_RZ_LSL3
:
6304 case AARCH64_OPND_SVE_ADDR_RZ_XTW_14
:
6305 case AARCH64_OPND_SVE_ADDR_RZ_XTW_22
:
6306 case AARCH64_OPND_SVE_ADDR_RZ_XTW1_14
:
6307 case AARCH64_OPND_SVE_ADDR_RZ_XTW1_22
:
6308 case AARCH64_OPND_SVE_ADDR_RZ_XTW2_14
:
6309 case AARCH64_OPND_SVE_ADDR_RZ_XTW2_22
:
6310 case AARCH64_OPND_SVE_ADDR_RZ_XTW3_14
:
6311 case AARCH64_OPND_SVE_ADDR_RZ_XTW3_22
:
6312 /* [<Xn|SP>, Z<m>.D{, LSL #<amount>}]
6313 [<Xn|SP>, Z<m>.<T>, <extend> {#<amount>}] */
6314 po_misc_or_fail (parse_sve_address (&str
, info
, &base_qualifier
,
6315 &offset_qualifier
));
6316 if (base_qualifier
!= AARCH64_OPND_QLF_X
6317 || (offset_qualifier
!= AARCH64_OPND_QLF_S_S
6318 && offset_qualifier
!= AARCH64_OPND_QLF_S_D
))
6320 set_syntax_error (_("invalid addressing mode"));
6323 info
->qualifier
= offset_qualifier
;
6326 case AARCH64_OPND_SVE_ADDR_ZI_U5
:
6327 case AARCH64_OPND_SVE_ADDR_ZI_U5x2
:
6328 case AARCH64_OPND_SVE_ADDR_ZI_U5x4
:
6329 case AARCH64_OPND_SVE_ADDR_ZI_U5x8
:
6330 /* [Z<n>.<T>{, #imm}] */
6331 po_misc_or_fail (parse_sve_address (&str
, info
, &base_qualifier
,
6332 &offset_qualifier
));
6333 if (base_qualifier
!= AARCH64_OPND_QLF_S_S
6334 && base_qualifier
!= AARCH64_OPND_QLF_S_D
)
6336 set_syntax_error (_("invalid addressing mode"));
6339 info
->qualifier
= base_qualifier
;
6342 case AARCH64_OPND_SVE_ADDR_ZZ_LSL
:
6343 case AARCH64_OPND_SVE_ADDR_ZZ_SXTW
:
6344 case AARCH64_OPND_SVE_ADDR_ZZ_UXTW
:
6345 /* [Z<n>.<T>, Z<m>.<T>{, LSL #<amount>}]
6346 [Z<n>.D, Z<m>.D, <extend> {#<amount>}]
6350 [Z<n>.S, Z<m>.S, <extend> {#<amount>}]
6352 here since we get better error messages by leaving it to
6353 the qualifier checking routines. */
6354 po_misc_or_fail (parse_sve_address (&str
, info
, &base_qualifier
,
6355 &offset_qualifier
));
6356 if ((base_qualifier
!= AARCH64_OPND_QLF_S_S
6357 && base_qualifier
!= AARCH64_OPND_QLF_S_D
)
6358 || offset_qualifier
!= base_qualifier
)
6360 set_syntax_error (_("invalid addressing mode"));
6363 info
->qualifier
= base_qualifier
;
6366 case AARCH64_OPND_SYSREG
:
6367 if ((val
= parse_sys_reg (&str
, aarch64_sys_regs_hsh
, 1, 0))
6370 set_syntax_error (_("unknown or missing system register name"));
6373 inst
.base
.operands
[i
].sysreg
= val
;
6376 case AARCH64_OPND_PSTATEFIELD
:
6377 if ((val
= parse_sys_reg (&str
, aarch64_pstatefield_hsh
, 0, 1))
6380 set_syntax_error (_("unknown or missing PSTATE field name"));
6383 inst
.base
.operands
[i
].pstatefield
= val
;
6386 case AARCH64_OPND_SYSREG_IC
:
6387 inst
.base
.operands
[i
].sysins_op
=
6388 parse_sys_ins_reg (&str
, aarch64_sys_regs_ic_hsh
);
6390 case AARCH64_OPND_SYSREG_DC
:
6391 inst
.base
.operands
[i
].sysins_op
=
6392 parse_sys_ins_reg (&str
, aarch64_sys_regs_dc_hsh
);
6394 case AARCH64_OPND_SYSREG_AT
:
6395 inst
.base
.operands
[i
].sysins_op
=
6396 parse_sys_ins_reg (&str
, aarch64_sys_regs_at_hsh
);
6398 case AARCH64_OPND_SYSREG_TLBI
:
6399 inst
.base
.operands
[i
].sysins_op
=
6400 parse_sys_ins_reg (&str
, aarch64_sys_regs_tlbi_hsh
);
6402 if (inst
.base
.operands
[i
].sysins_op
== NULL
)
6404 set_fatal_syntax_error ( _("unknown or missing operation name"));
6409 case AARCH64_OPND_BARRIER
:
6410 case AARCH64_OPND_BARRIER_ISB
:
6411 val
= parse_barrier (&str
);
6412 if (val
!= PARSE_FAIL
6413 && operands
[i
] == AARCH64_OPND_BARRIER_ISB
&& val
!= 0xf)
6415 /* ISB only accepts options name 'sy'. */
6417 (_("the specified option is not accepted in ISB"));
6418 /* Turn off backtrack as this optional operand is present. */
6422 /* This is an extension to accept a 0..15 immediate. */
6423 if (val
== PARSE_FAIL
)
6424 po_imm_or_fail (0, 15);
6425 info
->barrier
= aarch64_barrier_options
+ val
;
6428 case AARCH64_OPND_PRFOP
:
6429 val
= parse_pldop (&str
);
6430 /* This is an extension to accept a 0..31 immediate. */
6431 if (val
== PARSE_FAIL
)
6432 po_imm_or_fail (0, 31);
6433 inst
.base
.operands
[i
].prfop
= aarch64_prfops
+ val
;
6436 case AARCH64_OPND_BARRIER_PSB
:
6437 val
= parse_barrier_psb (&str
, &(info
->hint_option
));
6438 if (val
== PARSE_FAIL
)
6443 as_fatal (_("unhandled operand code %d"), operands
[i
]);
6446 /* If we get here, this operand was successfully parsed. */
6447 inst
.base
.operands
[i
].present
= 1;
6451 /* The parse routine should already have set the error, but in case
6452 not, set a default one here. */
6454 set_default_error ();
6456 if (! backtrack_pos
)
6457 goto parse_operands_return
;
6460 /* We reach here because this operand is marked as optional, and
6461 either no operand was supplied or the operand was supplied but it
6462 was syntactically incorrect. In the latter case we report an
6463 error. In the former case we perform a few more checks before
6464 dropping through to the code to insert the default operand. */
6466 char *tmp
= backtrack_pos
;
6467 char endchar
= END_OF_INSN
;
6469 if (i
!= (aarch64_num_of_operands (opcode
) - 1))
6471 skip_past_char (&tmp
, ',');
6473 if (*tmp
!= endchar
)
6474 /* The user has supplied an operand in the wrong format. */
6475 goto parse_operands_return
;
6477 /* Make sure there is not a comma before the optional operand.
6478 For example the fifth operand of 'sys' is optional:
6480 sys #0,c0,c0,#0, <--- wrong
6481 sys #0,c0,c0,#0 <--- correct. */
6482 if (comma_skipped_p
&& i
&& endchar
== END_OF_INSN
)
6484 set_fatal_syntax_error
6485 (_("unexpected comma before the omitted optional operand"));
6486 goto parse_operands_return
;
6490 /* Reaching here means we are dealing with an optional operand that is
6491 omitted from the assembly line. */
6492 gas_assert (optional_operand_p (opcode
, i
));
6494 process_omitted_operand (operands
[i
], opcode
, i
, info
);
6496 /* Try again, skipping the optional operand at backtrack_pos. */
6497 str
= backtrack_pos
;
6500 /* Clear any error record after the omitted optional operand has been
6501 successfully handled. */
6505 /* Check if we have parsed all the operands. */
6506 if (*str
!= '\0' && ! error_p ())
6508 /* Set I to the index of the last present operand; this is
6509 for the purpose of diagnostics. */
6510 for (i
-= 1; i
>= 0 && !inst
.base
.operands
[i
].present
; --i
)
6512 set_fatal_syntax_error
6513 (_("unexpected characters following instruction"));
6516 parse_operands_return
:
6520 DEBUG_TRACE ("parsing FAIL: %s - %s",
6521 operand_mismatch_kind_names
[get_error_kind ()],
6522 get_error_message ());
6523 /* Record the operand error properly; this is useful when there
6524 are multiple instruction templates for a mnemonic name, so that
6525 later on, we can select the error that most closely describes
6527 record_operand_error (opcode
, i
, get_error_kind (),
6528 get_error_message ());
6533 DEBUG_TRACE ("parsing SUCCESS");
6538 /* It does some fix-up to provide some programmer friendly feature while
6539 keeping the libopcodes happy, i.e. libopcodes only accepts
6540 the preferred architectural syntax.
6541 Return FALSE if there is any failure; otherwise return TRUE. */
6544 programmer_friendly_fixup (aarch64_instruction
*instr
)
6546 aarch64_inst
*base
= &instr
->base
;
6547 const aarch64_opcode
*opcode
= base
->opcode
;
6548 enum aarch64_op op
= opcode
->op
;
6549 aarch64_opnd_info
*operands
= base
->operands
;
6551 DEBUG_TRACE ("enter");
6553 switch (opcode
->iclass
)
6556 /* TBNZ Xn|Wn, #uimm6, label
6557 Test and Branch Not Zero: conditionally jumps to label if bit number
6558 uimm6 in register Xn is not zero. The bit number implies the width of
6559 the register, which may be written and should be disassembled as Wn if
6560 uimm is less than 32. */
6561 if (operands
[0].qualifier
== AARCH64_OPND_QLF_W
)
6563 if (operands
[1].imm
.value
>= 32)
6565 record_operand_out_of_range_error (opcode
, 1, _("immediate value"),
6569 operands
[0].qualifier
= AARCH64_OPND_QLF_X
;
6573 /* LDR Wt, label | =value
6574 As a convenience assemblers will typically permit the notation
6575 "=value" in conjunction with the pc-relative literal load instructions
6576 to automatically place an immediate value or symbolic address in a
6577 nearby literal pool and generate a hidden label which references it.
6578 ISREG has been set to 0 in the case of =value. */
6579 if (instr
->gen_lit_pool
6580 && (op
== OP_LDR_LIT
|| op
== OP_LDRV_LIT
|| op
== OP_LDRSW_LIT
))
6582 int size
= aarch64_get_qualifier_esize (operands
[0].qualifier
);
6583 if (op
== OP_LDRSW_LIT
)
6585 if (instr
->reloc
.exp
.X_op
!= O_constant
6586 && instr
->reloc
.exp
.X_op
!= O_big
6587 && instr
->reloc
.exp
.X_op
!= O_symbol
)
6589 record_operand_error (opcode
, 1,
6590 AARCH64_OPDE_FATAL_SYNTAX_ERROR
,
6591 _("constant expression expected"));
6594 if (! add_to_lit_pool (&instr
->reloc
.exp
, size
))
6596 record_operand_error (opcode
, 1,
6597 AARCH64_OPDE_OTHER_ERROR
,
6598 _("literal pool insertion failed"));
6606 Unsigned Extend Byte|Halfword|Word: UXT[BH] is architectural alias
6607 for UBFM Wd,Wn,#0,#7|15, while UXTW is pseudo instruction which is
6608 encoded using ORR Wd, WZR, Wn (MOV Wd,Wn).
6609 A programmer-friendly assembler should accept a destination Xd in
6610 place of Wd, however that is not the preferred form for disassembly.
6612 if ((op
== OP_UXTB
|| op
== OP_UXTH
|| op
== OP_UXTW
)
6613 && operands
[1].qualifier
== AARCH64_OPND_QLF_W
6614 && operands
[0].qualifier
== AARCH64_OPND_QLF_X
)
6615 operands
[0].qualifier
= AARCH64_OPND_QLF_W
;
6620 /* In the 64-bit form, the final register operand is written as Wm
6621 for all but the (possibly omitted) UXTX/LSL and SXTX
6623 As a programmer-friendly assembler, we accept e.g.
6624 ADDS <Xd>, <Xn|SP>, <Xm>{, UXTB {#<amount>}} and change it to
6625 ADDS <Xd>, <Xn|SP>, <Wm>{, UXTB {#<amount>}}. */
6626 int idx
= aarch64_operand_index (opcode
->operands
,
6627 AARCH64_OPND_Rm_EXT
);
6628 gas_assert (idx
== 1 || idx
== 2);
6629 if (operands
[0].qualifier
== AARCH64_OPND_QLF_X
6630 && operands
[idx
].qualifier
== AARCH64_OPND_QLF_X
6631 && operands
[idx
].shifter
.kind
!= AARCH64_MOD_LSL
6632 && operands
[idx
].shifter
.kind
!= AARCH64_MOD_UXTX
6633 && operands
[idx
].shifter
.kind
!= AARCH64_MOD_SXTX
)
6634 operands
[idx
].qualifier
= AARCH64_OPND_QLF_W
;
6642 DEBUG_TRACE ("exit with SUCCESS");
6646 /* Check for loads and stores that will cause unpredictable behavior. */
6649 warn_unpredictable_ldst (aarch64_instruction
*instr
, char *str
)
6651 aarch64_inst
*base
= &instr
->base
;
6652 const aarch64_opcode
*opcode
= base
->opcode
;
6653 const aarch64_opnd_info
*opnds
= base
->operands
;
6654 switch (opcode
->iclass
)
6661 /* Loading/storing the base register is unpredictable if writeback. */
6662 if ((aarch64_get_operand_class (opnds
[0].type
)
6663 == AARCH64_OPND_CLASS_INT_REG
)
6664 && opnds
[0].reg
.regno
== opnds
[1].addr
.base_regno
6665 && opnds
[1].addr
.base_regno
!= REG_SP
6666 && opnds
[1].addr
.writeback
)
6667 as_warn (_("unpredictable transfer with writeback -- `%s'"), str
);
6670 case ldstnapair_offs
:
6671 case ldstpair_indexed
:
6672 /* Loading/storing the base register is unpredictable if writeback. */
6673 if ((aarch64_get_operand_class (opnds
[0].type
)
6674 == AARCH64_OPND_CLASS_INT_REG
)
6675 && (opnds
[0].reg
.regno
== opnds
[2].addr
.base_regno
6676 || opnds
[1].reg
.regno
== opnds
[2].addr
.base_regno
)
6677 && opnds
[2].addr
.base_regno
!= REG_SP
6678 && opnds
[2].addr
.writeback
)
6679 as_warn (_("unpredictable transfer with writeback -- `%s'"), str
);
6680 /* Load operations must load different registers. */
6681 if ((opcode
->opcode
& (1 << 22))
6682 && opnds
[0].reg
.regno
== opnds
[1].reg
.regno
)
6683 as_warn (_("unpredictable load of register pair -- `%s'"), str
);
6690 /* A wrapper function to interface with libopcodes on encoding and
6691 record the error message if there is any.
6693 Return TRUE on success; otherwise return FALSE. */
6696 do_encode (const aarch64_opcode
*opcode
, aarch64_inst
*instr
,
6699 aarch64_operand_error error_info
;
6700 error_info
.kind
= AARCH64_OPDE_NIL
;
6701 if (aarch64_opcode_encode (opcode
, instr
, code
, NULL
, &error_info
))
6705 gas_assert (error_info
.kind
!= AARCH64_OPDE_NIL
);
6706 record_operand_error_info (opcode
, &error_info
);
6711 #ifdef DEBUG_AARCH64
6713 dump_opcode_operands (const aarch64_opcode
*opcode
)
6716 while (opcode
->operands
[i
] != AARCH64_OPND_NIL
)
6718 aarch64_verbose ("\t\t opnd%d: %s", i
,
6719 aarch64_get_operand_name (opcode
->operands
[i
])[0] != '\0'
6720 ? aarch64_get_operand_name (opcode
->operands
[i
])
6721 : aarch64_get_operand_desc (opcode
->operands
[i
]));
6725 #endif /* DEBUG_AARCH64 */
6727 /* This is the guts of the machine-dependent assembler. STR points to a
6728 machine dependent instruction. This function is supposed to emit
6729 the frags/bytes it assembles to. */
6732 md_assemble (char *str
)
6735 templates
*template;
6736 aarch64_opcode
*opcode
;
6737 aarch64_inst
*inst_base
;
6738 unsigned saved_cond
;
6740 /* Align the previous label if needed. */
6741 if (last_label_seen
!= NULL
)
6743 symbol_set_frag (last_label_seen
, frag_now
);
6744 S_SET_VALUE (last_label_seen
, (valueT
) frag_now_fix ());
6745 S_SET_SEGMENT (last_label_seen
, now_seg
);
6748 inst
.reloc
.type
= BFD_RELOC_UNUSED
;
6750 DEBUG_TRACE ("\n\n");
6751 DEBUG_TRACE ("==============================");
6752 DEBUG_TRACE ("Enter md_assemble with %s", str
);
6754 template = opcode_lookup (&p
);
6757 /* It wasn't an instruction, but it might be a register alias of
6758 the form alias .req reg directive. */
6759 if (!create_register_alias (str
, p
))
6760 as_bad (_("unknown mnemonic `%s' -- `%s'"), get_mnemonic_name (str
),
6765 skip_whitespace (p
);
6768 as_bad (_("unexpected comma after the mnemonic name `%s' -- `%s'"),
6769 get_mnemonic_name (str
), str
);
6773 init_operand_error_report ();
6775 /* Sections are assumed to start aligned. In executable section, there is no
6776 MAP_DATA symbol pending. So we only align the address during
6777 MAP_DATA --> MAP_INSN transition.
6778 For other sections, this is not guaranteed. */
6779 enum mstate mapstate
= seg_info (now_seg
)->tc_segment_info_data
.mapstate
;
6780 if (!need_pass_2
&& subseg_text_p (now_seg
) && mapstate
== MAP_DATA
)
6781 frag_align_code (2, 0);
6783 saved_cond
= inst
.cond
;
6784 reset_aarch64_instruction (&inst
);
6785 inst
.cond
= saved_cond
;
6787 /* Iterate through all opcode entries with the same mnemonic name. */
6790 opcode
= template->opcode
;
6792 DEBUG_TRACE ("opcode %s found", opcode
->name
);
6793 #ifdef DEBUG_AARCH64
6795 dump_opcode_operands (opcode
);
6796 #endif /* DEBUG_AARCH64 */
6798 mapping_state (MAP_INSN
);
6800 inst_base
= &inst
.base
;
6801 inst_base
->opcode
= opcode
;
6803 /* Truly conditionally executed instructions, e.g. b.cond. */
6804 if (opcode
->flags
& F_COND
)
6806 gas_assert (inst
.cond
!= COND_ALWAYS
);
6807 inst_base
->cond
= get_cond_from_value (inst
.cond
);
6808 DEBUG_TRACE ("condition found %s", inst_base
->cond
->names
[0]);
6810 else if (inst
.cond
!= COND_ALWAYS
)
6812 /* It shouldn't arrive here, where the assembly looks like a
6813 conditional instruction but the found opcode is unconditional. */
6818 if (parse_operands (p
, opcode
)
6819 && programmer_friendly_fixup (&inst
)
6820 && do_encode (inst_base
->opcode
, &inst
.base
, &inst_base
->value
))
6822 /* Check that this instruction is supported for this CPU. */
6823 if (!opcode
->avariant
6824 || !AARCH64_CPU_HAS_ALL_FEATURES (cpu_variant
, *opcode
->avariant
))
6826 as_bad (_("selected processor does not support `%s'"), str
);
6830 warn_unpredictable_ldst (&inst
, str
);
6832 if (inst
.reloc
.type
== BFD_RELOC_UNUSED
6833 || !inst
.reloc
.need_libopcodes_p
)
6837 /* If there is relocation generated for the instruction,
6838 store the instruction information for the future fix-up. */
6839 struct aarch64_inst
*copy
;
6840 gas_assert (inst
.reloc
.type
!= BFD_RELOC_UNUSED
);
6841 copy
= XNEW (struct aarch64_inst
);
6842 memcpy (copy
, &inst
.base
, sizeof (struct aarch64_inst
));
6848 template = template->next
;
6849 if (template != NULL
)
6851 reset_aarch64_instruction (&inst
);
6852 inst
.cond
= saved_cond
;
6855 while (template != NULL
);
6857 /* Issue the error messages if any. */
6858 output_operand_error_report (str
);
6861 /* Various frobbings of labels and their addresses. */
6864 aarch64_start_line_hook (void)
6866 last_label_seen
= NULL
;
6870 aarch64_frob_label (symbolS
* sym
)
6872 last_label_seen
= sym
;
6874 dwarf2_emit_label (sym
);
6878 aarch64_data_in_code (void)
6880 if (!strncmp (input_line_pointer
+ 1, "data:", 5))
6882 *input_line_pointer
= '/';
6883 input_line_pointer
+= 5;
6884 *input_line_pointer
= 0;
6892 aarch64_canonicalize_symbol_name (char *name
)
6896 if ((len
= strlen (name
)) > 5 && streq (name
+ len
- 5, "/data"))
6897 *(name
+ len
- 5) = 0;
6902 /* Table of all register names defined by default. The user can
6903 define additional names with .req. Note that all register names
6904 should appear in both upper and lowercase variants. Some registers
6905 also have mixed-case names. */
6907 #define REGDEF(s,n,t) { #s, n, REG_TYPE_##t, TRUE }
6908 #define REGDEF_ALIAS(s, n, t) { #s, n, REG_TYPE_##t, FALSE}
6909 #define REGNUM(p,n,t) REGDEF(p##n, n, t)
6910 #define REGSET16(p,t) \
6911 REGNUM(p, 0,t), REGNUM(p, 1,t), REGNUM(p, 2,t), REGNUM(p, 3,t), \
6912 REGNUM(p, 4,t), REGNUM(p, 5,t), REGNUM(p, 6,t), REGNUM(p, 7,t), \
6913 REGNUM(p, 8,t), REGNUM(p, 9,t), REGNUM(p,10,t), REGNUM(p,11,t), \
6914 REGNUM(p,12,t), REGNUM(p,13,t), REGNUM(p,14,t), REGNUM(p,15,t)
6915 #define REGSET31(p,t) \
6917 REGNUM(p,16,t), REGNUM(p,17,t), REGNUM(p,18,t), REGNUM(p,19,t), \
6918 REGNUM(p,20,t), REGNUM(p,21,t), REGNUM(p,22,t), REGNUM(p,23,t), \
6919 REGNUM(p,24,t), REGNUM(p,25,t), REGNUM(p,26,t), REGNUM(p,27,t), \
6920 REGNUM(p,28,t), REGNUM(p,29,t), REGNUM(p,30,t)
6921 #define REGSET(p,t) \
6922 REGSET31(p,t), REGNUM(p,31,t)
6924 /* These go into aarch64_reg_hsh hash-table. */
6925 static const reg_entry reg_names
[] = {
6926 /* Integer registers. */
6927 REGSET31 (x
, R_64
), REGSET31 (X
, R_64
),
6928 REGSET31 (w
, R_32
), REGSET31 (W
, R_32
),
6930 REGDEF_ALIAS (ip0
, 16, R_64
), REGDEF_ALIAS (IP0
, 16, R_64
),
6931 REGDEF_ALIAS (ip1
, 17, R_64
), REGDEF_ALIAS (IP1
, 17, R_64
),
6932 REGDEF_ALIAS (fp
, 29, R_64
), REGDEF_ALIAS (FP
, 29, R_64
),
6933 REGDEF_ALIAS (lr
, 30, R_64
), REGDEF_ALIAS (LR
, 30, R_64
),
6934 REGDEF (wsp
, 31, SP_32
), REGDEF (WSP
, 31, SP_32
),
6935 REGDEF (sp
, 31, SP_64
), REGDEF (SP
, 31, SP_64
),
6937 REGDEF (wzr
, 31, Z_32
), REGDEF (WZR
, 31, Z_32
),
6938 REGDEF (xzr
, 31, Z_64
), REGDEF (XZR
, 31, Z_64
),
6940 /* Floating-point single precision registers. */
6941 REGSET (s
, FP_S
), REGSET (S
, FP_S
),
6943 /* Floating-point double precision registers. */
6944 REGSET (d
, FP_D
), REGSET (D
, FP_D
),
6946 /* Floating-point half precision registers. */
6947 REGSET (h
, FP_H
), REGSET (H
, FP_H
),
6949 /* Floating-point byte precision registers. */
6950 REGSET (b
, FP_B
), REGSET (B
, FP_B
),
6952 /* Floating-point quad precision registers. */
6953 REGSET (q
, FP_Q
), REGSET (Q
, FP_Q
),
6955 /* FP/SIMD registers. */
6956 REGSET (v
, VN
), REGSET (V
, VN
),
6958 /* SVE vector registers. */
6959 REGSET (z
, ZN
), REGSET (Z
, ZN
),
6961 /* SVE predicate registers. */
6962 REGSET16 (p
, PN
), REGSET16 (P
, PN
)
6980 #define B(a,b,c,d) (((a) << 3) | ((b) << 2) | ((c) << 1) | (d))
6981 static const asm_nzcv nzcv_names
[] = {
6982 {"nzcv", B (n
, z
, c
, v
)},
6983 {"nzcV", B (n
, z
, c
, V
)},
6984 {"nzCv", B (n
, z
, C
, v
)},
6985 {"nzCV", B (n
, z
, C
, V
)},
6986 {"nZcv", B (n
, Z
, c
, v
)},
6987 {"nZcV", B (n
, Z
, c
, V
)},
6988 {"nZCv", B (n
, Z
, C
, v
)},
6989 {"nZCV", B (n
, Z
, C
, V
)},
6990 {"Nzcv", B (N
, z
, c
, v
)},
6991 {"NzcV", B (N
, z
, c
, V
)},
6992 {"NzCv", B (N
, z
, C
, v
)},
6993 {"NzCV", B (N
, z
, C
, V
)},
6994 {"NZcv", B (N
, Z
, c
, v
)},
6995 {"NZcV", B (N
, Z
, c
, V
)},
6996 {"NZCv", B (N
, Z
, C
, v
)},
6997 {"NZCV", B (N
, Z
, C
, V
)}
7010 /* MD interface: bits in the object file. */
7012 /* Turn an integer of n bytes (in val) into a stream of bytes appropriate
7013 for use in the a.out file, and stores them in the array pointed to by buf.
7014 This knows about the endian-ness of the target machine and does
7015 THE RIGHT THING, whatever it is. Possible values for n are 1 (byte)
7016 2 (short) and 4 (long) Floating numbers are put out as a series of
7017 LITTLENUMS (shorts, here at least). */
7020 md_number_to_chars (char *buf
, valueT val
, int n
)
7022 if (target_big_endian
)
7023 number_to_chars_bigendian (buf
, val
, n
);
7025 number_to_chars_littleendian (buf
, val
, n
);
7028 /* MD interface: Sections. */
7030 /* Estimate the size of a frag before relaxing. Assume everything fits in
7034 md_estimate_size_before_relax (fragS
* fragp
, segT segtype ATTRIBUTE_UNUSED
)
7040 /* Round up a section size to the appropriate boundary. */
7043 md_section_align (segT segment ATTRIBUTE_UNUSED
, valueT size
)
7048 /* This is called from HANDLE_ALIGN in write.c. Fill in the contents
7049 of an rs_align_code fragment.
7051 Here we fill the frag with the appropriate info for padding the
7052 output stream. The resulting frag will consist of a fixed (fr_fix)
7053 and of a repeating (fr_var) part.
7055 The fixed content is always emitted before the repeating content and
7056 these two parts are used as follows in constructing the output:
7057 - the fixed part will be used to align to a valid instruction word
7058 boundary, in case that we start at a misaligned address; as no
7059 executable instruction can live at the misaligned location, we
7060 simply fill with zeros;
7061 - the variable part will be used to cover the remaining padding and
7062 we fill using the AArch64 NOP instruction.
7064 Note that the size of a RS_ALIGN_CODE fragment is always 7 to provide
7065 enough storage space for up to 3 bytes for padding the back to a valid
7066 instruction alignment and exactly 4 bytes to store the NOP pattern. */
7069 aarch64_handle_align (fragS
* fragP
)
7071 /* NOP = d503201f */
7072 /* AArch64 instructions are always little-endian. */
7073 static unsigned char const aarch64_noop
[4] = { 0x1f, 0x20, 0x03, 0xd5 };
7075 int bytes
, fix
, noop_size
;
7078 if (fragP
->fr_type
!= rs_align_code
)
7081 bytes
= fragP
->fr_next
->fr_address
- fragP
->fr_address
- fragP
->fr_fix
;
7082 p
= fragP
->fr_literal
+ fragP
->fr_fix
;
7085 gas_assert (fragP
->tc_frag_data
.recorded
);
7088 noop_size
= sizeof (aarch64_noop
);
7090 fix
= bytes
& (noop_size
- 1);
7094 insert_data_mapping_symbol (MAP_INSN
, fragP
->fr_fix
, fragP
, fix
);
7098 fragP
->fr_fix
+= fix
;
7102 memcpy (p
, aarch64_noop
, noop_size
);
7103 fragP
->fr_var
= noop_size
;
7106 /* Perform target specific initialisation of a frag.
7107 Note - despite the name this initialisation is not done when the frag
7108 is created, but only when its type is assigned. A frag can be created
7109 and used a long time before its type is set, so beware of assuming that
7110 this initialisation is performed first. */
7114 aarch64_init_frag (fragS
* fragP ATTRIBUTE_UNUSED
,
7115 int max_chars ATTRIBUTE_UNUSED
)
7119 #else /* OBJ_ELF is defined. */
7121 aarch64_init_frag (fragS
* fragP
, int max_chars
)
7123 /* Record a mapping symbol for alignment frags. We will delete this
7124 later if the alignment ends up empty. */
7125 if (!fragP
->tc_frag_data
.recorded
)
7126 fragP
->tc_frag_data
.recorded
= 1;
7128 /* PR 21809: Do not set a mapping state for debug sections
7129 - it just confuses other tools. */
7130 if (bfd_get_section_flags (NULL
, now_seg
) & SEC_DEBUGGING
)
7133 switch (fragP
->fr_type
)
7137 mapping_state_2 (MAP_DATA
, max_chars
);
7140 /* PR 20364: We can get alignment frags in code sections,
7141 so do not just assume that we should use the MAP_DATA state. */
7142 mapping_state_2 (subseg_text_p (now_seg
) ? MAP_INSN
: MAP_DATA
, max_chars
);
7145 mapping_state_2 (MAP_INSN
, max_chars
);
7152 /* Initialize the DWARF-2 unwind information for this procedure. */
7155 tc_aarch64_frame_initial_instructions (void)
7157 cfi_add_CFA_def_cfa (REG_SP
, 0);
7159 #endif /* OBJ_ELF */
7161 /* Convert REGNAME to a DWARF-2 register number. */
7164 tc_aarch64_regname_to_dw2regnum (char *regname
)
7166 const reg_entry
*reg
= parse_reg (®name
);
7172 case REG_TYPE_SP_32
:
7173 case REG_TYPE_SP_64
:
7183 return reg
->number
+ 64;
7191 /* Implement DWARF2_ADDR_SIZE. */
7194 aarch64_dwarf2_addr_size (void)
7196 #if defined (OBJ_MAYBE_ELF) || defined (OBJ_ELF)
7200 return bfd_arch_bits_per_address (stdoutput
) / 8;
7203 /* MD interface: Symbol and relocation handling. */
7205 /* Return the address within the segment that a PC-relative fixup is
7206 relative to. For AArch64 PC-relative fixups applied to instructions
7207 are generally relative to the location plus AARCH64_PCREL_OFFSET bytes. */
7210 md_pcrel_from_section (fixS
* fixP
, segT seg
)
7212 offsetT base
= fixP
->fx_where
+ fixP
->fx_frag
->fr_address
;
7214 /* If this is pc-relative and we are going to emit a relocation
7215 then we just want to put out any pipeline compensation that the linker
7216 will need. Otherwise we want to use the calculated base. */
7218 && ((fixP
->fx_addsy
&& S_GET_SEGMENT (fixP
->fx_addsy
) != seg
)
7219 || aarch64_force_relocation (fixP
)))
7222 /* AArch64 should be consistent for all pc-relative relocations. */
7223 return base
+ AARCH64_PCREL_OFFSET
;
7226 /* Under ELF we need to default _GLOBAL_OFFSET_TABLE.
7227 Otherwise we have no need to default values of symbols. */
7230 md_undefined_symbol (char *name ATTRIBUTE_UNUSED
)
7233 if (name
[0] == '_' && name
[1] == 'G'
7234 && streq (name
, GLOBAL_OFFSET_TABLE_NAME
))
7238 if (symbol_find (name
))
7239 as_bad (_("GOT already in the symbol table"));
7241 GOT_symbol
= symbol_new (name
, undefined_section
,
7242 (valueT
) 0, &zero_address_frag
);
7252 /* Return non-zero if the indicated VALUE has overflowed the maximum
7253 range expressible by a unsigned number with the indicated number of
7257 unsigned_overflow (valueT value
, unsigned bits
)
7260 if (bits
>= sizeof (valueT
) * 8)
7262 lim
= (valueT
) 1 << bits
;
7263 return (value
>= lim
);
7267 /* Return non-zero if the indicated VALUE has overflowed the maximum
7268 range expressible by an signed number with the indicated number of
7272 signed_overflow (offsetT value
, unsigned bits
)
7275 if (bits
>= sizeof (offsetT
) * 8)
7277 lim
= (offsetT
) 1 << (bits
- 1);
7278 return (value
< -lim
|| value
>= lim
);
7281 /* Given an instruction in *INST, which is expected to be a scaled, 12-bit,
7282 unsigned immediate offset load/store instruction, try to encode it as
7283 an unscaled, 9-bit, signed immediate offset load/store instruction.
7284 Return TRUE if it is successful; otherwise return FALSE.
7286 As a programmer-friendly assembler, LDUR/STUR instructions can be generated
7287 in response to the standard LDR/STR mnemonics when the immediate offset is
7288 unambiguous, i.e. when it is negative or unaligned. */
7291 try_to_encode_as_unscaled_ldst (aarch64_inst
*instr
)
7294 enum aarch64_op new_op
;
7295 const aarch64_opcode
*new_opcode
;
7297 gas_assert (instr
->opcode
->iclass
== ldst_pos
);
7299 switch (instr
->opcode
->op
)
7301 case OP_LDRB_POS
:new_op
= OP_LDURB
; break;
7302 case OP_STRB_POS
: new_op
= OP_STURB
; break;
7303 case OP_LDRSB_POS
: new_op
= OP_LDURSB
; break;
7304 case OP_LDRH_POS
: new_op
= OP_LDURH
; break;
7305 case OP_STRH_POS
: new_op
= OP_STURH
; break;
7306 case OP_LDRSH_POS
: new_op
= OP_LDURSH
; break;
7307 case OP_LDR_POS
: new_op
= OP_LDUR
; break;
7308 case OP_STR_POS
: new_op
= OP_STUR
; break;
7309 case OP_LDRF_POS
: new_op
= OP_LDURV
; break;
7310 case OP_STRF_POS
: new_op
= OP_STURV
; break;
7311 case OP_LDRSW_POS
: new_op
= OP_LDURSW
; break;
7312 case OP_PRFM_POS
: new_op
= OP_PRFUM
; break;
7313 default: new_op
= OP_NIL
; break;
7316 if (new_op
== OP_NIL
)
7319 new_opcode
= aarch64_get_opcode (new_op
);
7320 gas_assert (new_opcode
!= NULL
);
7322 DEBUG_TRACE ("Check programmer-friendly STURB/LDURB -> STRB/LDRB: %d == %d",
7323 instr
->opcode
->op
, new_opcode
->op
);
7325 aarch64_replace_opcode (instr
, new_opcode
);
7327 /* Clear up the ADDR_SIMM9's qualifier; otherwise the
7328 qualifier matching may fail because the out-of-date qualifier will
7329 prevent the operand being updated with a new and correct qualifier. */
7330 idx
= aarch64_operand_index (instr
->opcode
->operands
,
7331 AARCH64_OPND_ADDR_SIMM9
);
7332 gas_assert (idx
== 1);
7333 instr
->operands
[idx
].qualifier
= AARCH64_OPND_QLF_NIL
;
7335 DEBUG_TRACE ("Found LDURB entry to encode programmer-friendly LDRB");
7337 if (!aarch64_opcode_encode (instr
->opcode
, instr
, &instr
->value
, NULL
, NULL
))
7343 /* Called by fix_insn to fix a MOV immediate alias instruction.
7345 Operand for a generic move immediate instruction, which is an alias
7346 instruction that generates a single MOVZ, MOVN or ORR instruction to loads
7347 a 32-bit/64-bit immediate value into general register. An assembler error
7348 shall result if the immediate cannot be created by a single one of these
7349 instructions. If there is a choice, then to ensure reversability an
7350 assembler must prefer a MOVZ to MOVN, and MOVZ or MOVN to ORR. */
7353 fix_mov_imm_insn (fixS
*fixP
, char *buf
, aarch64_inst
*instr
, offsetT value
)
7355 const aarch64_opcode
*opcode
;
7357 /* Need to check if the destination is SP/ZR. The check has to be done
7358 before any aarch64_replace_opcode. */
7359 int try_mov_wide_p
= !aarch64_stack_pointer_p (&instr
->operands
[0]);
7360 int try_mov_bitmask_p
= !aarch64_zero_register_p (&instr
->operands
[0]);
7362 instr
->operands
[1].imm
.value
= value
;
7363 instr
->operands
[1].skip
= 0;
7367 /* Try the MOVZ alias. */
7368 opcode
= aarch64_get_opcode (OP_MOV_IMM_WIDE
);
7369 aarch64_replace_opcode (instr
, opcode
);
7370 if (aarch64_opcode_encode (instr
->opcode
, instr
,
7371 &instr
->value
, NULL
, NULL
))
7373 put_aarch64_insn (buf
, instr
->value
);
7376 /* Try the MOVK alias. */
7377 opcode
= aarch64_get_opcode (OP_MOV_IMM_WIDEN
);
7378 aarch64_replace_opcode (instr
, opcode
);
7379 if (aarch64_opcode_encode (instr
->opcode
, instr
,
7380 &instr
->value
, NULL
, NULL
))
7382 put_aarch64_insn (buf
, instr
->value
);
7387 if (try_mov_bitmask_p
)
7389 /* Try the ORR alias. */
7390 opcode
= aarch64_get_opcode (OP_MOV_IMM_LOG
);
7391 aarch64_replace_opcode (instr
, opcode
);
7392 if (aarch64_opcode_encode (instr
->opcode
, instr
,
7393 &instr
->value
, NULL
, NULL
))
7395 put_aarch64_insn (buf
, instr
->value
);
7400 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
7401 _("immediate cannot be moved by a single instruction"));
7404 /* An instruction operand which is immediate related may have symbol used
7405 in the assembly, e.g.
7408 .set u32, 0x00ffff00
7410 At the time when the assembly instruction is parsed, a referenced symbol,
7411 like 'u32' in the above example may not have been seen; a fixS is created
7412 in such a case and is handled here after symbols have been resolved.
7413 Instruction is fixed up with VALUE using the information in *FIXP plus
7414 extra information in FLAGS.
7416 This function is called by md_apply_fix to fix up instructions that need
7417 a fix-up described above but does not involve any linker-time relocation. */
7420 fix_insn (fixS
*fixP
, uint32_t flags
, offsetT value
)
7424 char *buf
= fixP
->fx_where
+ fixP
->fx_frag
->fr_literal
;
7425 enum aarch64_opnd opnd
= fixP
->tc_fix_data
.opnd
;
7426 aarch64_inst
*new_inst
= fixP
->tc_fix_data
.inst
;
7430 /* Now the instruction is about to be fixed-up, so the operand that
7431 was previously marked as 'ignored' needs to be unmarked in order
7432 to get the encoding done properly. */
7433 idx
= aarch64_operand_index (new_inst
->opcode
->operands
, opnd
);
7434 new_inst
->operands
[idx
].skip
= 0;
7437 gas_assert (opnd
!= AARCH64_OPND_NIL
);
7441 case AARCH64_OPND_EXCEPTION
:
7442 if (unsigned_overflow (value
, 16))
7443 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
7444 _("immediate out of range"));
7445 insn
= get_aarch64_insn (buf
);
7446 insn
|= encode_svc_imm (value
);
7447 put_aarch64_insn (buf
, insn
);
7450 case AARCH64_OPND_AIMM
:
7451 /* ADD or SUB with immediate.
7452 NOTE this assumes we come here with a add/sub shifted reg encoding
7453 3 322|2222|2 2 2 21111 111111
7454 1 098|7654|3 2 1 09876 543210 98765 43210
7455 0b000000 sf 000|1011|shift 0 Rm imm6 Rn Rd ADD
7456 2b000000 sf 010|1011|shift 0 Rm imm6 Rn Rd ADDS
7457 4b000000 sf 100|1011|shift 0 Rm imm6 Rn Rd SUB
7458 6b000000 sf 110|1011|shift 0 Rm imm6 Rn Rd SUBS
7460 3 322|2222|2 2 221111111111
7461 1 098|7654|3 2 109876543210 98765 43210
7462 11000000 sf 001|0001|shift imm12 Rn Rd ADD
7463 31000000 sf 011|0001|shift imm12 Rn Rd ADDS
7464 51000000 sf 101|0001|shift imm12 Rn Rd SUB
7465 71000000 sf 111|0001|shift imm12 Rn Rd SUBS
7466 Fields sf Rn Rd are already set. */
7467 insn
= get_aarch64_insn (buf
);
7471 insn
= reencode_addsub_switch_add_sub (insn
);
7475 if ((flags
& FIXUP_F_HAS_EXPLICIT_SHIFT
) == 0
7476 && unsigned_overflow (value
, 12))
7478 /* Try to shift the value by 12 to make it fit. */
7479 if (((value
>> 12) << 12) == value
7480 && ! unsigned_overflow (value
, 12 + 12))
7483 insn
|= encode_addsub_imm_shift_amount (1);
7487 if (unsigned_overflow (value
, 12))
7488 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
7489 _("immediate out of range"));
7491 insn
|= encode_addsub_imm (value
);
7493 put_aarch64_insn (buf
, insn
);
7496 case AARCH64_OPND_SIMD_IMM
:
7497 case AARCH64_OPND_SIMD_IMM_SFT
:
7498 case AARCH64_OPND_LIMM
:
7499 /* Bit mask immediate. */
7500 gas_assert (new_inst
!= NULL
);
7501 idx
= aarch64_operand_index (new_inst
->opcode
->operands
, opnd
);
7502 new_inst
->operands
[idx
].imm
.value
= value
;
7503 if (aarch64_opcode_encode (new_inst
->opcode
, new_inst
,
7504 &new_inst
->value
, NULL
, NULL
))
7505 put_aarch64_insn (buf
, new_inst
->value
);
7507 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
7508 _("invalid immediate"));
7511 case AARCH64_OPND_HALF
:
7512 /* 16-bit unsigned immediate. */
7513 if (unsigned_overflow (value
, 16))
7514 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
7515 _("immediate out of range"));
7516 insn
= get_aarch64_insn (buf
);
7517 insn
|= encode_movw_imm (value
& 0xffff);
7518 put_aarch64_insn (buf
, insn
);
7521 case AARCH64_OPND_IMM_MOV
:
7522 /* Operand for a generic move immediate instruction, which is
7523 an alias instruction that generates a single MOVZ, MOVN or ORR
7524 instruction to loads a 32-bit/64-bit immediate value into general
7525 register. An assembler error shall result if the immediate cannot be
7526 created by a single one of these instructions. If there is a choice,
7527 then to ensure reversability an assembler must prefer a MOVZ to MOVN,
7528 and MOVZ or MOVN to ORR. */
7529 gas_assert (new_inst
!= NULL
);
7530 fix_mov_imm_insn (fixP
, buf
, new_inst
, value
);
7533 case AARCH64_OPND_ADDR_SIMM7
:
7534 case AARCH64_OPND_ADDR_SIMM9
:
7535 case AARCH64_OPND_ADDR_SIMM9_2
:
7536 case AARCH64_OPND_ADDR_SIMM10
:
7537 case AARCH64_OPND_ADDR_UIMM12
:
7538 /* Immediate offset in an address. */
7539 insn
= get_aarch64_insn (buf
);
7541 gas_assert (new_inst
!= NULL
&& new_inst
->value
== insn
);
7542 gas_assert (new_inst
->opcode
->operands
[1] == opnd
7543 || new_inst
->opcode
->operands
[2] == opnd
);
7545 /* Get the index of the address operand. */
7546 if (new_inst
->opcode
->operands
[1] == opnd
)
7547 /* e.g. STR <Xt>, [<Xn|SP>, <R><m>{, <extend> {<amount>}}]. */
7550 /* e.g. LDP <Qt1>, <Qt2>, [<Xn|SP>{, #<imm>}]. */
7553 /* Update the resolved offset value. */
7554 new_inst
->operands
[idx
].addr
.offset
.imm
= value
;
7556 /* Encode/fix-up. */
7557 if (aarch64_opcode_encode (new_inst
->opcode
, new_inst
,
7558 &new_inst
->value
, NULL
, NULL
))
7560 put_aarch64_insn (buf
, new_inst
->value
);
7563 else if (new_inst
->opcode
->iclass
== ldst_pos
7564 && try_to_encode_as_unscaled_ldst (new_inst
))
7566 put_aarch64_insn (buf
, new_inst
->value
);
7570 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
7571 _("immediate offset out of range"));
7576 as_fatal (_("unhandled operand code %d"), opnd
);
7580 /* Apply a fixup (fixP) to segment data, once it has been determined
7581 by our caller that we have all the info we need to fix it up.
7583 Parameter valP is the pointer to the value of the bits. */
7586 md_apply_fix (fixS
* fixP
, valueT
* valP
, segT seg
)
7588 offsetT value
= *valP
;
7590 char *buf
= fixP
->fx_where
+ fixP
->fx_frag
->fr_literal
;
7592 unsigned flags
= fixP
->fx_addnumber
;
7594 DEBUG_TRACE ("\n\n");
7595 DEBUG_TRACE ("~~~~~~~~~~~~~~~~~~~~~~~~~");
7596 DEBUG_TRACE ("Enter md_apply_fix");
7598 gas_assert (fixP
->fx_r_type
<= BFD_RELOC_UNUSED
);
7600 /* Note whether this will delete the relocation. */
7602 if (fixP
->fx_addsy
== 0 && !fixP
->fx_pcrel
)
7605 /* Process the relocations. */
7606 switch (fixP
->fx_r_type
)
7608 case BFD_RELOC_NONE
:
7609 /* This will need to go in the object file. */
7614 case BFD_RELOC_8_PCREL
:
7615 if (fixP
->fx_done
|| !seg
->use_rela_p
)
7616 md_number_to_chars (buf
, value
, 1);
7620 case BFD_RELOC_16_PCREL
:
7621 if (fixP
->fx_done
|| !seg
->use_rela_p
)
7622 md_number_to_chars (buf
, value
, 2);
7626 case BFD_RELOC_32_PCREL
:
7627 if (fixP
->fx_done
|| !seg
->use_rela_p
)
7628 md_number_to_chars (buf
, value
, 4);
7632 case BFD_RELOC_64_PCREL
:
7633 if (fixP
->fx_done
|| !seg
->use_rela_p
)
7634 md_number_to_chars (buf
, value
, 8);
7637 case BFD_RELOC_AARCH64_GAS_INTERNAL_FIXUP
:
7638 /* We claim that these fixups have been processed here, even if
7639 in fact we generate an error because we do not have a reloc
7640 for them, so tc_gen_reloc() will reject them. */
7642 if (fixP
->fx_addsy
&& !S_IS_DEFINED (fixP
->fx_addsy
))
7644 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
7645 _("undefined symbol %s used as an immediate value"),
7646 S_GET_NAME (fixP
->fx_addsy
));
7647 goto apply_fix_return
;
7649 fix_insn (fixP
, flags
, value
);
7652 case BFD_RELOC_AARCH64_LD_LO19_PCREL
:
7653 if (fixP
->fx_done
|| !seg
->use_rela_p
)
7656 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
7657 _("pc-relative load offset not word aligned"));
7658 if (signed_overflow (value
, 21))
7659 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
7660 _("pc-relative load offset out of range"));
7661 insn
= get_aarch64_insn (buf
);
7662 insn
|= encode_ld_lit_ofs_19 (value
>> 2);
7663 put_aarch64_insn (buf
, insn
);
7667 case BFD_RELOC_AARCH64_ADR_LO21_PCREL
:
7668 if (fixP
->fx_done
|| !seg
->use_rela_p
)
7670 if (signed_overflow (value
, 21))
7671 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
7672 _("pc-relative address offset out of range"));
7673 insn
= get_aarch64_insn (buf
);
7674 insn
|= encode_adr_imm (value
);
7675 put_aarch64_insn (buf
, insn
);
7679 case BFD_RELOC_AARCH64_BRANCH19
:
7680 if (fixP
->fx_done
|| !seg
->use_rela_p
)
7683 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
7684 _("conditional branch target not word aligned"));
7685 if (signed_overflow (value
, 21))
7686 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
7687 _("conditional branch out of range"));
7688 insn
= get_aarch64_insn (buf
);
7689 insn
|= encode_cond_branch_ofs_19 (value
>> 2);
7690 put_aarch64_insn (buf
, insn
);
7694 case BFD_RELOC_AARCH64_TSTBR14
:
7695 if (fixP
->fx_done
|| !seg
->use_rela_p
)
7698 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
7699 _("conditional branch target not word aligned"));
7700 if (signed_overflow (value
, 16))
7701 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
7702 _("conditional branch out of range"));
7703 insn
= get_aarch64_insn (buf
);
7704 insn
|= encode_tst_branch_ofs_14 (value
>> 2);
7705 put_aarch64_insn (buf
, insn
);
7709 case BFD_RELOC_AARCH64_CALL26
:
7710 case BFD_RELOC_AARCH64_JUMP26
:
7711 if (fixP
->fx_done
|| !seg
->use_rela_p
)
7714 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
7715 _("branch target not word aligned"));
7716 if (signed_overflow (value
, 28))
7717 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
7718 _("branch out of range"));
7719 insn
= get_aarch64_insn (buf
);
7720 insn
|= encode_branch_ofs_26 (value
>> 2);
7721 put_aarch64_insn (buf
, insn
);
7725 case BFD_RELOC_AARCH64_MOVW_G0
:
7726 case BFD_RELOC_AARCH64_MOVW_G0_NC
:
7727 case BFD_RELOC_AARCH64_MOVW_G0_S
:
7728 case BFD_RELOC_AARCH64_MOVW_GOTOFF_G0_NC
:
7729 case BFD_RELOC_AARCH64_MOVW_PREL_G0
:
7730 case BFD_RELOC_AARCH64_MOVW_PREL_G0_NC
:
7733 case BFD_RELOC_AARCH64_MOVW_G1
:
7734 case BFD_RELOC_AARCH64_MOVW_G1_NC
:
7735 case BFD_RELOC_AARCH64_MOVW_G1_S
:
7736 case BFD_RELOC_AARCH64_MOVW_GOTOFF_G1
:
7737 case BFD_RELOC_AARCH64_MOVW_PREL_G1
:
7738 case BFD_RELOC_AARCH64_MOVW_PREL_G1_NC
:
7741 case BFD_RELOC_AARCH64_TLSDESC_OFF_G0_NC
:
7743 S_SET_THREAD_LOCAL (fixP
->fx_addsy
);
7744 /* Should always be exported to object file, see
7745 aarch64_force_relocation(). */
7746 gas_assert (!fixP
->fx_done
);
7747 gas_assert (seg
->use_rela_p
);
7749 case BFD_RELOC_AARCH64_TLSDESC_OFF_G1
:
7751 S_SET_THREAD_LOCAL (fixP
->fx_addsy
);
7752 /* Should always be exported to object file, see
7753 aarch64_force_relocation(). */
7754 gas_assert (!fixP
->fx_done
);
7755 gas_assert (seg
->use_rela_p
);
7757 case BFD_RELOC_AARCH64_MOVW_G2
:
7758 case BFD_RELOC_AARCH64_MOVW_G2_NC
:
7759 case BFD_RELOC_AARCH64_MOVW_G2_S
:
7760 case BFD_RELOC_AARCH64_MOVW_PREL_G2
:
7761 case BFD_RELOC_AARCH64_MOVW_PREL_G2_NC
:
7764 case BFD_RELOC_AARCH64_MOVW_G3
:
7765 case BFD_RELOC_AARCH64_MOVW_PREL_G3
:
7768 if (fixP
->fx_done
|| !seg
->use_rela_p
)
7770 insn
= get_aarch64_insn (buf
);
7774 /* REL signed addend must fit in 16 bits */
7775 if (signed_overflow (value
, 16))
7776 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
7777 _("offset out of range"));
7781 /* Check for overflow and scale. */
7782 switch (fixP
->fx_r_type
)
7784 case BFD_RELOC_AARCH64_MOVW_G0
:
7785 case BFD_RELOC_AARCH64_MOVW_G1
:
7786 case BFD_RELOC_AARCH64_MOVW_G2
:
7787 case BFD_RELOC_AARCH64_MOVW_G3
:
7788 case BFD_RELOC_AARCH64_MOVW_GOTOFF_G1
:
7789 case BFD_RELOC_AARCH64_TLSDESC_OFF_G1
:
7790 if (unsigned_overflow (value
, scale
+ 16))
7791 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
7792 _("unsigned value out of range"));
7794 case BFD_RELOC_AARCH64_MOVW_G0_S
:
7795 case BFD_RELOC_AARCH64_MOVW_G1_S
:
7796 case BFD_RELOC_AARCH64_MOVW_G2_S
:
7797 case BFD_RELOC_AARCH64_MOVW_PREL_G0
:
7798 case BFD_RELOC_AARCH64_MOVW_PREL_G1
:
7799 case BFD_RELOC_AARCH64_MOVW_PREL_G2
:
7800 /* NOTE: We can only come here with movz or movn. */
7801 if (signed_overflow (value
, scale
+ 16))
7802 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
7803 _("signed value out of range"));
7806 /* Force use of MOVN. */
7808 insn
= reencode_movzn_to_movn (insn
);
7812 /* Force use of MOVZ. */
7813 insn
= reencode_movzn_to_movz (insn
);
7817 /* Unchecked relocations. */
7823 /* Insert value into MOVN/MOVZ/MOVK instruction. */
7824 insn
|= encode_movw_imm (value
& 0xffff);
7826 put_aarch64_insn (buf
, insn
);
7830 case BFD_RELOC_AARCH64_TLSIE_LD_GOTTPREL_LO12_NC
:
7831 fixP
->fx_r_type
= (ilp32_p
7832 ? BFD_RELOC_AARCH64_TLSIE_LD32_GOTTPREL_LO12_NC
7833 : BFD_RELOC_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC
);
7834 S_SET_THREAD_LOCAL (fixP
->fx_addsy
);
7835 /* Should always be exported to object file, see
7836 aarch64_force_relocation(). */
7837 gas_assert (!fixP
->fx_done
);
7838 gas_assert (seg
->use_rela_p
);
7841 case BFD_RELOC_AARCH64_TLSDESC_LD_LO12_NC
:
7842 fixP
->fx_r_type
= (ilp32_p
7843 ? BFD_RELOC_AARCH64_TLSDESC_LD32_LO12_NC
7844 : BFD_RELOC_AARCH64_TLSDESC_LD64_LO12
);
7845 S_SET_THREAD_LOCAL (fixP
->fx_addsy
);
7846 /* Should always be exported to object file, see
7847 aarch64_force_relocation(). */
7848 gas_assert (!fixP
->fx_done
);
7849 gas_assert (seg
->use_rela_p
);
7852 case BFD_RELOC_AARCH64_TLSDESC_ADD_LO12
:
7853 case BFD_RELOC_AARCH64_TLSDESC_ADR_PAGE21
:
7854 case BFD_RELOC_AARCH64_TLSDESC_ADR_PREL21
:
7855 case BFD_RELOC_AARCH64_TLSDESC_LD32_LO12_NC
:
7856 case BFD_RELOC_AARCH64_TLSDESC_LD64_LO12
:
7857 case BFD_RELOC_AARCH64_TLSDESC_LD_PREL19
:
7858 case BFD_RELOC_AARCH64_TLSGD_ADD_LO12_NC
:
7859 case BFD_RELOC_AARCH64_TLSGD_ADR_PAGE21
:
7860 case BFD_RELOC_AARCH64_TLSGD_ADR_PREL21
:
7861 case BFD_RELOC_AARCH64_TLSGD_MOVW_G0_NC
:
7862 case BFD_RELOC_AARCH64_TLSGD_MOVW_G1
:
7863 case BFD_RELOC_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21
:
7864 case BFD_RELOC_AARCH64_TLSIE_LD32_GOTTPREL_LO12_NC
:
7865 case BFD_RELOC_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC
:
7866 case BFD_RELOC_AARCH64_TLSIE_LD_GOTTPREL_PREL19
:
7867 case BFD_RELOC_AARCH64_TLSIE_MOVW_GOTTPREL_G0_NC
:
7868 case BFD_RELOC_AARCH64_TLSIE_MOVW_GOTTPREL_G1
:
7869 case BFD_RELOC_AARCH64_TLSLD_ADD_DTPREL_HI12
:
7870 case BFD_RELOC_AARCH64_TLSLD_ADD_DTPREL_LO12
:
7871 case BFD_RELOC_AARCH64_TLSLD_ADD_DTPREL_LO12_NC
:
7872 case BFD_RELOC_AARCH64_TLSLD_ADD_LO12_NC
:
7873 case BFD_RELOC_AARCH64_TLSLD_ADR_PAGE21
:
7874 case BFD_RELOC_AARCH64_TLSLD_ADR_PREL21
:
7875 case BFD_RELOC_AARCH64_TLSLD_LDST16_DTPREL_LO12
:
7876 case BFD_RELOC_AARCH64_TLSLD_LDST16_DTPREL_LO12_NC
:
7877 case BFD_RELOC_AARCH64_TLSLD_LDST32_DTPREL_LO12
:
7878 case BFD_RELOC_AARCH64_TLSLD_LDST32_DTPREL_LO12_NC
:
7879 case BFD_RELOC_AARCH64_TLSLD_LDST64_DTPREL_LO12
:
7880 case BFD_RELOC_AARCH64_TLSLD_LDST64_DTPREL_LO12_NC
:
7881 case BFD_RELOC_AARCH64_TLSLD_LDST8_DTPREL_LO12
:
7882 case BFD_RELOC_AARCH64_TLSLD_LDST8_DTPREL_LO12_NC
:
7883 case BFD_RELOC_AARCH64_TLSLD_MOVW_DTPREL_G0
:
7884 case BFD_RELOC_AARCH64_TLSLD_MOVW_DTPREL_G0_NC
:
7885 case BFD_RELOC_AARCH64_TLSLD_MOVW_DTPREL_G1
:
7886 case BFD_RELOC_AARCH64_TLSLD_MOVW_DTPREL_G1_NC
:
7887 case BFD_RELOC_AARCH64_TLSLD_MOVW_DTPREL_G2
:
7888 case BFD_RELOC_AARCH64_TLSLE_LDST16_TPREL_LO12
:
7889 case BFD_RELOC_AARCH64_TLSLE_LDST16_TPREL_LO12_NC
:
7890 case BFD_RELOC_AARCH64_TLSLE_LDST32_TPREL_LO12
:
7891 case BFD_RELOC_AARCH64_TLSLE_LDST32_TPREL_LO12_NC
:
7892 case BFD_RELOC_AARCH64_TLSLE_LDST64_TPREL_LO12
:
7893 case BFD_RELOC_AARCH64_TLSLE_LDST64_TPREL_LO12_NC
:
7894 case BFD_RELOC_AARCH64_TLSLE_LDST8_TPREL_LO12
:
7895 case BFD_RELOC_AARCH64_TLSLE_LDST8_TPREL_LO12_NC
:
7896 case BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_HI12
:
7897 case BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_LO12
:
7898 case BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_LO12_NC
:
7899 case BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G0
:
7900 case BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G0_NC
:
7901 case BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G1
:
7902 case BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G1_NC
:
7903 case BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G2
:
7904 S_SET_THREAD_LOCAL (fixP
->fx_addsy
);
7905 /* Should always be exported to object file, see
7906 aarch64_force_relocation(). */
7907 gas_assert (!fixP
->fx_done
);
7908 gas_assert (seg
->use_rela_p
);
7911 case BFD_RELOC_AARCH64_LD_GOT_LO12_NC
:
7912 /* Should always be exported to object file, see
7913 aarch64_force_relocation(). */
7914 fixP
->fx_r_type
= (ilp32_p
7915 ? BFD_RELOC_AARCH64_LD32_GOT_LO12_NC
7916 : BFD_RELOC_AARCH64_LD64_GOT_LO12_NC
);
7917 gas_assert (!fixP
->fx_done
);
7918 gas_assert (seg
->use_rela_p
);
7921 case BFD_RELOC_AARCH64_ADD_LO12
:
7922 case BFD_RELOC_AARCH64_ADR_GOT_PAGE
:
7923 case BFD_RELOC_AARCH64_ADR_HI21_NC_PCREL
:
7924 case BFD_RELOC_AARCH64_ADR_HI21_PCREL
:
7925 case BFD_RELOC_AARCH64_GOT_LD_PREL19
:
7926 case BFD_RELOC_AARCH64_LD32_GOT_LO12_NC
:
7927 case BFD_RELOC_AARCH64_LD32_GOTPAGE_LO14
:
7928 case BFD_RELOC_AARCH64_LD64_GOTOFF_LO15
:
7929 case BFD_RELOC_AARCH64_LD64_GOTPAGE_LO15
:
7930 case BFD_RELOC_AARCH64_LD64_GOT_LO12_NC
:
7931 case BFD_RELOC_AARCH64_LDST128_LO12
:
7932 case BFD_RELOC_AARCH64_LDST16_LO12
:
7933 case BFD_RELOC_AARCH64_LDST32_LO12
:
7934 case BFD_RELOC_AARCH64_LDST64_LO12
:
7935 case BFD_RELOC_AARCH64_LDST8_LO12
:
7936 /* Should always be exported to object file, see
7937 aarch64_force_relocation(). */
7938 gas_assert (!fixP
->fx_done
);
7939 gas_assert (seg
->use_rela_p
);
7942 case BFD_RELOC_AARCH64_TLSDESC_ADD
:
7943 case BFD_RELOC_AARCH64_TLSDESC_CALL
:
7944 case BFD_RELOC_AARCH64_TLSDESC_LDR
:
7947 case BFD_RELOC_UNUSED
:
7948 /* An error will already have been reported. */
7952 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
7953 _("unexpected %s fixup"),
7954 bfd_get_reloc_code_name (fixP
->fx_r_type
));
7959 /* Free the allocated the struct aarch64_inst.
7960 N.B. currently there are very limited number of fix-up types actually use
7961 this field, so the impact on the performance should be minimal . */
7962 if (fixP
->tc_fix_data
.inst
!= NULL
)
7963 free (fixP
->tc_fix_data
.inst
);
7968 /* Translate internal representation of relocation info to BFD target
7972 tc_gen_reloc (asection
* section
, fixS
* fixp
)
7975 bfd_reloc_code_real_type code
;
7977 reloc
= XNEW (arelent
);
7979 reloc
->sym_ptr_ptr
= XNEW (asymbol
*);
7980 *reloc
->sym_ptr_ptr
= symbol_get_bfdsym (fixp
->fx_addsy
);
7981 reloc
->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
7985 if (section
->use_rela_p
)
7986 fixp
->fx_offset
-= md_pcrel_from_section (fixp
, section
);
7988 fixp
->fx_offset
= reloc
->address
;
7990 reloc
->addend
= fixp
->fx_offset
;
7992 code
= fixp
->fx_r_type
;
7997 code
= BFD_RELOC_16_PCREL
;
8002 code
= BFD_RELOC_32_PCREL
;
8007 code
= BFD_RELOC_64_PCREL
;
8014 reloc
->howto
= bfd_reloc_type_lookup (stdoutput
, code
);
8015 if (reloc
->howto
== NULL
)
8017 as_bad_where (fixp
->fx_file
, fixp
->fx_line
,
8019 ("cannot represent %s relocation in this object file format"),
8020 bfd_get_reloc_code_name (code
));
8027 /* This fix_new is called by cons via TC_CONS_FIX_NEW. */
8030 cons_fix_new_aarch64 (fragS
* frag
, int where
, int size
, expressionS
* exp
)
8032 bfd_reloc_code_real_type type
;
8036 FIXME: @@ Should look at CPU word size. */
8043 type
= BFD_RELOC_16
;
8046 type
= BFD_RELOC_32
;
8049 type
= BFD_RELOC_64
;
8052 as_bad (_("cannot do %u-byte relocation"), size
);
8053 type
= BFD_RELOC_UNUSED
;
8057 fix_new_exp (frag
, where
, (int) size
, exp
, pcrel
, type
);
8061 aarch64_force_relocation (struct fix
*fixp
)
8063 switch (fixp
->fx_r_type
)
8065 case BFD_RELOC_AARCH64_GAS_INTERNAL_FIXUP
:
8066 /* Perform these "immediate" internal relocations
8067 even if the symbol is extern or weak. */
8070 case BFD_RELOC_AARCH64_LD_GOT_LO12_NC
:
8071 case BFD_RELOC_AARCH64_TLSDESC_LD_LO12_NC
:
8072 case BFD_RELOC_AARCH64_TLSIE_LD_GOTTPREL_LO12_NC
:
8073 /* Pseudo relocs that need to be fixed up according to
8077 case BFD_RELOC_AARCH64_ADD_LO12
:
8078 case BFD_RELOC_AARCH64_ADR_GOT_PAGE
:
8079 case BFD_RELOC_AARCH64_ADR_HI21_NC_PCREL
:
8080 case BFD_RELOC_AARCH64_ADR_HI21_PCREL
:
8081 case BFD_RELOC_AARCH64_GOT_LD_PREL19
:
8082 case BFD_RELOC_AARCH64_LD32_GOT_LO12_NC
:
8083 case BFD_RELOC_AARCH64_LD32_GOTPAGE_LO14
:
8084 case BFD_RELOC_AARCH64_LD64_GOTOFF_LO15
:
8085 case BFD_RELOC_AARCH64_LD64_GOTPAGE_LO15
:
8086 case BFD_RELOC_AARCH64_LD64_GOT_LO12_NC
:
8087 case BFD_RELOC_AARCH64_LDST128_LO12
:
8088 case BFD_RELOC_AARCH64_LDST16_LO12
:
8089 case BFD_RELOC_AARCH64_LDST32_LO12
:
8090 case BFD_RELOC_AARCH64_LDST64_LO12
:
8091 case BFD_RELOC_AARCH64_LDST8_LO12
:
8092 case BFD_RELOC_AARCH64_TLSDESC_ADD_LO12
:
8093 case BFD_RELOC_AARCH64_TLSDESC_ADR_PAGE21
:
8094 case BFD_RELOC_AARCH64_TLSDESC_ADR_PREL21
:
8095 case BFD_RELOC_AARCH64_TLSDESC_LD32_LO12_NC
:
8096 case BFD_RELOC_AARCH64_TLSDESC_LD64_LO12
:
8097 case BFD_RELOC_AARCH64_TLSDESC_LD_PREL19
:
8098 case BFD_RELOC_AARCH64_TLSDESC_OFF_G0_NC
:
8099 case BFD_RELOC_AARCH64_TLSDESC_OFF_G1
:
8100 case BFD_RELOC_AARCH64_TLSGD_ADD_LO12_NC
:
8101 case BFD_RELOC_AARCH64_TLSGD_ADR_PAGE21
:
8102 case BFD_RELOC_AARCH64_TLSGD_ADR_PREL21
:
8103 case BFD_RELOC_AARCH64_TLSGD_MOVW_G0_NC
:
8104 case BFD_RELOC_AARCH64_TLSGD_MOVW_G1
:
8105 case BFD_RELOC_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21
:
8106 case BFD_RELOC_AARCH64_TLSIE_LD32_GOTTPREL_LO12_NC
:
8107 case BFD_RELOC_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC
:
8108 case BFD_RELOC_AARCH64_TLSIE_LD_GOTTPREL_PREL19
:
8109 case BFD_RELOC_AARCH64_TLSIE_MOVW_GOTTPREL_G0_NC
:
8110 case BFD_RELOC_AARCH64_TLSIE_MOVW_GOTTPREL_G1
:
8111 case BFD_RELOC_AARCH64_TLSLD_ADD_DTPREL_HI12
:
8112 case BFD_RELOC_AARCH64_TLSLD_ADD_DTPREL_LO12
:
8113 case BFD_RELOC_AARCH64_TLSLD_ADD_DTPREL_LO12_NC
:
8114 case BFD_RELOC_AARCH64_TLSLD_ADD_LO12_NC
:
8115 case BFD_RELOC_AARCH64_TLSLD_ADR_PAGE21
:
8116 case BFD_RELOC_AARCH64_TLSLD_ADR_PREL21
:
8117 case BFD_RELOC_AARCH64_TLSLD_LDST16_DTPREL_LO12
:
8118 case BFD_RELOC_AARCH64_TLSLD_LDST16_DTPREL_LO12_NC
:
8119 case BFD_RELOC_AARCH64_TLSLD_LDST32_DTPREL_LO12
:
8120 case BFD_RELOC_AARCH64_TLSLD_LDST32_DTPREL_LO12_NC
:
8121 case BFD_RELOC_AARCH64_TLSLD_LDST64_DTPREL_LO12
:
8122 case BFD_RELOC_AARCH64_TLSLD_LDST64_DTPREL_LO12_NC
:
8123 case BFD_RELOC_AARCH64_TLSLD_LDST8_DTPREL_LO12
:
8124 case BFD_RELOC_AARCH64_TLSLD_LDST8_DTPREL_LO12_NC
:
8125 case BFD_RELOC_AARCH64_TLSLD_MOVW_DTPREL_G0
:
8126 case BFD_RELOC_AARCH64_TLSLD_MOVW_DTPREL_G0_NC
:
8127 case BFD_RELOC_AARCH64_TLSLD_MOVW_DTPREL_G1
:
8128 case BFD_RELOC_AARCH64_TLSLD_MOVW_DTPREL_G1_NC
:
8129 case BFD_RELOC_AARCH64_TLSLD_MOVW_DTPREL_G2
:
8130 case BFD_RELOC_AARCH64_TLSLE_LDST16_TPREL_LO12
:
8131 case BFD_RELOC_AARCH64_TLSLE_LDST16_TPREL_LO12_NC
:
8132 case BFD_RELOC_AARCH64_TLSLE_LDST32_TPREL_LO12
:
8133 case BFD_RELOC_AARCH64_TLSLE_LDST32_TPREL_LO12_NC
:
8134 case BFD_RELOC_AARCH64_TLSLE_LDST64_TPREL_LO12
:
8135 case BFD_RELOC_AARCH64_TLSLE_LDST64_TPREL_LO12_NC
:
8136 case BFD_RELOC_AARCH64_TLSLE_LDST8_TPREL_LO12
:
8137 case BFD_RELOC_AARCH64_TLSLE_LDST8_TPREL_LO12_NC
:
8138 case BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_HI12
:
8139 case BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_LO12
:
8140 case BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_LO12_NC
:
8141 case BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G0
:
8142 case BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G0_NC
:
8143 case BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G1
:
8144 case BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G1_NC
:
8145 case BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G2
:
8146 /* Always leave these relocations for the linker. */
8153 return generic_force_reloc (fixp
);
8158 /* Implement md_after_parse_args. This is the earliest time we need to decide
8159 ABI. If no -mabi specified, the ABI will be decided by target triplet. */
8162 aarch64_after_parse_args (void)
8164 if (aarch64_abi
!= AARCH64_ABI_NONE
)
8167 /* DEFAULT_ARCH will have ":32" extension if it's configured for ILP32. */
8168 if (strlen (default_arch
) > 7 && strcmp (default_arch
+ 7, ":32") == 0)
8169 aarch64_abi
= AARCH64_ABI_ILP32
;
8171 aarch64_abi
= AARCH64_ABI_LP64
;
8175 elf64_aarch64_target_format (void)
8177 if (strcmp (TARGET_OS
, "cloudabi") == 0)
8179 /* FIXME: What to do for ilp32_p ? */
8180 return target_big_endian
? "elf64-bigaarch64-cloudabi" : "elf64-littleaarch64-cloudabi";
8182 if (target_big_endian
)
8183 return ilp32_p
? "elf32-bigaarch64" : "elf64-bigaarch64";
8185 return ilp32_p
? "elf32-littleaarch64" : "elf64-littleaarch64";
8189 aarch64elf_frob_symbol (symbolS
* symp
, int *puntp
)
8191 elf_frob_symbol (symp
, puntp
);
8195 /* MD interface: Finalization. */
8197 /* A good place to do this, although this was probably not intended
8198 for this kind of use. We need to dump the literal pool before
8199 references are made to a null symbol pointer. */
8202 aarch64_cleanup (void)
8206 for (pool
= list_of_pools
; pool
; pool
= pool
->next
)
8208 /* Put it at the end of the relevant section. */
8209 subseg_set (pool
->section
, pool
->sub_section
);
8215 /* Remove any excess mapping symbols generated for alignment frags in
8216 SEC. We may have created a mapping symbol before a zero byte
8217 alignment; remove it if there's a mapping symbol after the
8220 check_mapping_symbols (bfd
* abfd ATTRIBUTE_UNUSED
, asection
* sec
,
8221 void *dummy ATTRIBUTE_UNUSED
)
8223 segment_info_type
*seginfo
= seg_info (sec
);
8226 if (seginfo
== NULL
|| seginfo
->frchainP
== NULL
)
8229 for (fragp
= seginfo
->frchainP
->frch_root
;
8230 fragp
!= NULL
; fragp
= fragp
->fr_next
)
8232 symbolS
*sym
= fragp
->tc_frag_data
.last_map
;
8233 fragS
*next
= fragp
->fr_next
;
8235 /* Variable-sized frags have been converted to fixed size by
8236 this point. But if this was variable-sized to start with,
8237 there will be a fixed-size frag after it. So don't handle
8239 if (sym
== NULL
|| next
== NULL
)
8242 if (S_GET_VALUE (sym
) < next
->fr_address
)
8243 /* Not at the end of this frag. */
8245 know (S_GET_VALUE (sym
) == next
->fr_address
);
8249 if (next
->tc_frag_data
.first_map
!= NULL
)
8251 /* Next frag starts with a mapping symbol. Discard this
8253 symbol_remove (sym
, &symbol_rootP
, &symbol_lastP
);
8257 if (next
->fr_next
== NULL
)
8259 /* This mapping symbol is at the end of the section. Discard
8261 know (next
->fr_fix
== 0 && next
->fr_var
== 0);
8262 symbol_remove (sym
, &symbol_rootP
, &symbol_lastP
);
8266 /* As long as we have empty frags without any mapping symbols,
8268 /* If the next frag is non-empty and does not start with a
8269 mapping symbol, then this mapping symbol is required. */
8270 if (next
->fr_address
!= next
->fr_next
->fr_address
)
8273 next
= next
->fr_next
;
8275 while (next
!= NULL
);
8280 /* Adjust the symbol table. */
8283 aarch64_adjust_symtab (void)
8286 /* Remove any overlapping mapping symbols generated by alignment frags. */
8287 bfd_map_over_sections (stdoutput
, check_mapping_symbols
, (char *) 0);
8288 /* Now do generic ELF adjustments. */
8289 elf_adjust_symtab ();
8294 checked_hash_insert (struct hash_control
*table
, const char *key
, void *value
)
8296 const char *hash_err
;
8298 hash_err
= hash_insert (table
, key
, value
);
8300 printf ("Internal Error: Can't hash %s\n", key
);
8304 fill_instruction_hash_table (void)
8306 aarch64_opcode
*opcode
= aarch64_opcode_table
;
8308 while (opcode
->name
!= NULL
)
8310 templates
*templ
, *new_templ
;
8311 templ
= hash_find (aarch64_ops_hsh
, opcode
->name
);
8313 new_templ
= XNEW (templates
);
8314 new_templ
->opcode
= opcode
;
8315 new_templ
->next
= NULL
;
8318 checked_hash_insert (aarch64_ops_hsh
, opcode
->name
, (void *) new_templ
);
8321 new_templ
->next
= templ
->next
;
8322 templ
->next
= new_templ
;
8329 convert_to_upper (char *dst
, const char *src
, size_t num
)
8332 for (i
= 0; i
< num
&& *src
!= '\0'; ++i
, ++dst
, ++src
)
8333 *dst
= TOUPPER (*src
);
8337 /* Assume STR point to a lower-case string, allocate, convert and return
8338 the corresponding upper-case string. */
8339 static inline const char*
8340 get_upper_str (const char *str
)
8343 size_t len
= strlen (str
);
8344 ret
= XNEWVEC (char, len
+ 1);
8345 convert_to_upper (ret
, str
, len
);
8349 /* MD interface: Initialization. */
8357 if ((aarch64_ops_hsh
= hash_new ()) == NULL
8358 || (aarch64_cond_hsh
= hash_new ()) == NULL
8359 || (aarch64_shift_hsh
= hash_new ()) == NULL
8360 || (aarch64_sys_regs_hsh
= hash_new ()) == NULL
8361 || (aarch64_pstatefield_hsh
= hash_new ()) == NULL
8362 || (aarch64_sys_regs_ic_hsh
= hash_new ()) == NULL
8363 || (aarch64_sys_regs_dc_hsh
= hash_new ()) == NULL
8364 || (aarch64_sys_regs_at_hsh
= hash_new ()) == NULL
8365 || (aarch64_sys_regs_tlbi_hsh
= hash_new ()) == NULL
8366 || (aarch64_reg_hsh
= hash_new ()) == NULL
8367 || (aarch64_barrier_opt_hsh
= hash_new ()) == NULL
8368 || (aarch64_nzcv_hsh
= hash_new ()) == NULL
8369 || (aarch64_pldop_hsh
= hash_new ()) == NULL
8370 || (aarch64_hint_opt_hsh
= hash_new ()) == NULL
)
8371 as_fatal (_("virtual memory exhausted"));
8373 fill_instruction_hash_table ();
8375 for (i
= 0; aarch64_sys_regs
[i
].name
!= NULL
; ++i
)
8376 checked_hash_insert (aarch64_sys_regs_hsh
, aarch64_sys_regs
[i
].name
,
8377 (void *) (aarch64_sys_regs
+ i
));
8379 for (i
= 0; aarch64_pstatefields
[i
].name
!= NULL
; ++i
)
8380 checked_hash_insert (aarch64_pstatefield_hsh
,
8381 aarch64_pstatefields
[i
].name
,
8382 (void *) (aarch64_pstatefields
+ i
));
8384 for (i
= 0; aarch64_sys_regs_ic
[i
].name
!= NULL
; i
++)
8385 checked_hash_insert (aarch64_sys_regs_ic_hsh
,
8386 aarch64_sys_regs_ic
[i
].name
,
8387 (void *) (aarch64_sys_regs_ic
+ i
));
8389 for (i
= 0; aarch64_sys_regs_dc
[i
].name
!= NULL
; i
++)
8390 checked_hash_insert (aarch64_sys_regs_dc_hsh
,
8391 aarch64_sys_regs_dc
[i
].name
,
8392 (void *) (aarch64_sys_regs_dc
+ i
));
8394 for (i
= 0; aarch64_sys_regs_at
[i
].name
!= NULL
; i
++)
8395 checked_hash_insert (aarch64_sys_regs_at_hsh
,
8396 aarch64_sys_regs_at
[i
].name
,
8397 (void *) (aarch64_sys_regs_at
+ i
));
8399 for (i
= 0; aarch64_sys_regs_tlbi
[i
].name
!= NULL
; i
++)
8400 checked_hash_insert (aarch64_sys_regs_tlbi_hsh
,
8401 aarch64_sys_regs_tlbi
[i
].name
,
8402 (void *) (aarch64_sys_regs_tlbi
+ i
));
8404 for (i
= 0; i
< ARRAY_SIZE (reg_names
); i
++)
8405 checked_hash_insert (aarch64_reg_hsh
, reg_names
[i
].name
,
8406 (void *) (reg_names
+ i
));
8408 for (i
= 0; i
< ARRAY_SIZE (nzcv_names
); i
++)
8409 checked_hash_insert (aarch64_nzcv_hsh
, nzcv_names
[i
].template,
8410 (void *) (nzcv_names
+ i
));
8412 for (i
= 0; aarch64_operand_modifiers
[i
].name
!= NULL
; i
++)
8414 const char *name
= aarch64_operand_modifiers
[i
].name
;
8415 checked_hash_insert (aarch64_shift_hsh
, name
,
8416 (void *) (aarch64_operand_modifiers
+ i
));
8417 /* Also hash the name in the upper case. */
8418 checked_hash_insert (aarch64_shift_hsh
, get_upper_str (name
),
8419 (void *) (aarch64_operand_modifiers
+ i
));
8422 for (i
= 0; i
< ARRAY_SIZE (aarch64_conds
); i
++)
8425 /* A condition code may have alias(es), e.g. "cc", "lo" and "ul" are
8426 the same condition code. */
8427 for (j
= 0; j
< ARRAY_SIZE (aarch64_conds
[i
].names
); ++j
)
8429 const char *name
= aarch64_conds
[i
].names
[j
];
8432 checked_hash_insert (aarch64_cond_hsh
, name
,
8433 (void *) (aarch64_conds
+ i
));
8434 /* Also hash the name in the upper case. */
8435 checked_hash_insert (aarch64_cond_hsh
, get_upper_str (name
),
8436 (void *) (aarch64_conds
+ i
));
8440 for (i
= 0; i
< ARRAY_SIZE (aarch64_barrier_options
); i
++)
8442 const char *name
= aarch64_barrier_options
[i
].name
;
8443 /* Skip xx00 - the unallocated values of option. */
8446 checked_hash_insert (aarch64_barrier_opt_hsh
, name
,
8447 (void *) (aarch64_barrier_options
+ i
));
8448 /* Also hash the name in the upper case. */
8449 checked_hash_insert (aarch64_barrier_opt_hsh
, get_upper_str (name
),
8450 (void *) (aarch64_barrier_options
+ i
));
8453 for (i
= 0; i
< ARRAY_SIZE (aarch64_prfops
); i
++)
8455 const char* name
= aarch64_prfops
[i
].name
;
8456 /* Skip the unallocated hint encodings. */
8459 checked_hash_insert (aarch64_pldop_hsh
, name
,
8460 (void *) (aarch64_prfops
+ i
));
8461 /* Also hash the name in the upper case. */
8462 checked_hash_insert (aarch64_pldop_hsh
, get_upper_str (name
),
8463 (void *) (aarch64_prfops
+ i
));
8466 for (i
= 0; aarch64_hint_options
[i
].name
!= NULL
; i
++)
8468 const char* name
= aarch64_hint_options
[i
].name
;
8470 checked_hash_insert (aarch64_hint_opt_hsh
, name
,
8471 (void *) (aarch64_hint_options
+ i
));
8472 /* Also hash the name in the upper case. */
8473 checked_hash_insert (aarch64_pldop_hsh
, get_upper_str (name
),
8474 (void *) (aarch64_hint_options
+ i
));
8477 /* Set the cpu variant based on the command-line options. */
8479 mcpu_cpu_opt
= march_cpu_opt
;
8482 mcpu_cpu_opt
= &cpu_default
;
8484 cpu_variant
= *mcpu_cpu_opt
;
8486 /* Record the CPU type. */
8487 mach
= ilp32_p
? bfd_mach_aarch64_ilp32
: bfd_mach_aarch64
;
8489 bfd_set_arch_mach (stdoutput
, TARGET_ARCH
, mach
);
8492 /* Command line processing. */
8494 const char *md_shortopts
= "m:";
8496 #ifdef AARCH64_BI_ENDIAN
8497 #define OPTION_EB (OPTION_MD_BASE + 0)
8498 #define OPTION_EL (OPTION_MD_BASE + 1)
8500 #if TARGET_BYTES_BIG_ENDIAN
8501 #define OPTION_EB (OPTION_MD_BASE + 0)
8503 #define OPTION_EL (OPTION_MD_BASE + 1)
8507 struct option md_longopts
[] = {
8509 {"EB", no_argument
, NULL
, OPTION_EB
},
8512 {"EL", no_argument
, NULL
, OPTION_EL
},
8514 {NULL
, no_argument
, NULL
, 0}
8517 size_t md_longopts_size
= sizeof (md_longopts
);
8519 struct aarch64_option_table
8521 const char *option
; /* Option name to match. */
8522 const char *help
; /* Help information. */
8523 int *var
; /* Variable to change. */
8524 int value
; /* What to change it to. */
8525 char *deprecated
; /* If non-null, print this message. */
8528 static struct aarch64_option_table aarch64_opts
[] = {
8529 {"mbig-endian", N_("assemble for big-endian"), &target_big_endian
, 1, NULL
},
8530 {"mlittle-endian", N_("assemble for little-endian"), &target_big_endian
, 0,
8532 #ifdef DEBUG_AARCH64
8533 {"mdebug-dump", N_("temporary switch for dumping"), &debug_dump
, 1, NULL
},
8534 #endif /* DEBUG_AARCH64 */
8535 {"mverbose-error", N_("output verbose error messages"), &verbose_error_p
, 1,
8537 {"mno-verbose-error", N_("do not output verbose error messages"),
8538 &verbose_error_p
, 0, NULL
},
8539 {NULL
, NULL
, NULL
, 0, NULL
}
8542 struct aarch64_cpu_option_table
8545 const aarch64_feature_set value
;
8546 /* The canonical name of the CPU, or NULL to use NAME converted to upper
8548 const char *canonical_name
;
8551 /* This list should, at a minimum, contain all the cpu names
8552 recognized by GCC. */
8553 static const struct aarch64_cpu_option_table aarch64_cpus
[] = {
8554 {"all", AARCH64_ANY
, NULL
},
8555 {"cortex-a35", AARCH64_FEATURE (AARCH64_ARCH_V8
,
8556 AARCH64_FEATURE_CRC
), "Cortex-A35"},
8557 {"cortex-a53", AARCH64_FEATURE (AARCH64_ARCH_V8
,
8558 AARCH64_FEATURE_CRC
), "Cortex-A53"},
8559 {"cortex-a57", AARCH64_FEATURE (AARCH64_ARCH_V8
,
8560 AARCH64_FEATURE_CRC
), "Cortex-A57"},
8561 {"cortex-a72", AARCH64_FEATURE (AARCH64_ARCH_V8
,
8562 AARCH64_FEATURE_CRC
), "Cortex-A72"},
8563 {"cortex-a73", AARCH64_FEATURE (AARCH64_ARCH_V8
,
8564 AARCH64_FEATURE_CRC
), "Cortex-A73"},
8565 {"cortex-a55", AARCH64_FEATURE (AARCH64_ARCH_V8_2
,
8566 AARCH64_FEATURE_RCPC
| AARCH64_FEATURE_F16
| AARCH64_FEATURE_DOTPROD
),
8568 {"cortex-a75", AARCH64_FEATURE (AARCH64_ARCH_V8_2
,
8569 AARCH64_FEATURE_RCPC
| AARCH64_FEATURE_F16
| AARCH64_FEATURE_DOTPROD
),
8571 {"exynos-m1", AARCH64_FEATURE (AARCH64_ARCH_V8
,
8572 AARCH64_FEATURE_CRC
| AARCH64_FEATURE_CRYPTO
),
8573 "Samsung Exynos M1"},
8574 {"falkor", AARCH64_FEATURE (AARCH64_ARCH_V8
,
8575 AARCH64_FEATURE_CRC
| AARCH64_FEATURE_CRYPTO
8576 | AARCH64_FEATURE_RDMA
),
8578 {"qdf24xx", AARCH64_FEATURE (AARCH64_ARCH_V8
,
8579 AARCH64_FEATURE_CRC
| AARCH64_FEATURE_CRYPTO
8580 | AARCH64_FEATURE_RDMA
),
8581 "Qualcomm QDF24XX"},
8582 {"saphira", AARCH64_FEATURE (AARCH64_ARCH_V8_3
,
8583 AARCH64_FEATURE_CRYPTO
| AARCH64_FEATURE_PROFILE
),
8584 "Qualcomm Saphira"},
8585 {"thunderx", AARCH64_FEATURE (AARCH64_ARCH_V8
,
8586 AARCH64_FEATURE_CRC
| AARCH64_FEATURE_CRYPTO
),
8588 {"vulcan", AARCH64_FEATURE (AARCH64_ARCH_V8_1
,
8589 AARCH64_FEATURE_CRYPTO
),
8591 /* The 'xgene-1' name is an older name for 'xgene1', which was used
8592 in earlier releases and is superseded by 'xgene1' in all
8594 {"xgene-1", AARCH64_ARCH_V8
, "APM X-Gene 1"},
8595 {"xgene1", AARCH64_ARCH_V8
, "APM X-Gene 1"},
8596 {"xgene2", AARCH64_FEATURE (AARCH64_ARCH_V8
,
8597 AARCH64_FEATURE_CRC
), "APM X-Gene 2"},
8598 {"generic", AARCH64_ARCH_V8
, NULL
},
8600 {NULL
, AARCH64_ARCH_NONE
, NULL
}
8603 struct aarch64_arch_option_table
8606 const aarch64_feature_set value
;
8609 /* This list should, at a minimum, contain all the architecture names
8610 recognized by GCC. */
8611 static const struct aarch64_arch_option_table aarch64_archs
[] = {
8612 {"all", AARCH64_ANY
},
8613 {"armv8-a", AARCH64_ARCH_V8
},
8614 {"armv8.1-a", AARCH64_ARCH_V8_1
},
8615 {"armv8.2-a", AARCH64_ARCH_V8_2
},
8616 {"armv8.3-a", AARCH64_ARCH_V8_3
},
8617 {"armv8.4-a", AARCH64_ARCH_V8_4
},
8618 {NULL
, AARCH64_ARCH_NONE
}
8621 /* ISA extensions. */
8622 struct aarch64_option_cpu_value_table
8625 const aarch64_feature_set value
;
8626 const aarch64_feature_set require
; /* Feature dependencies. */
8629 static const struct aarch64_option_cpu_value_table aarch64_features
[] = {
8630 {"crc", AARCH64_FEATURE (AARCH64_FEATURE_CRC
, 0),
8632 {"crypto", AARCH64_FEATURE (AARCH64_FEATURE_CRYPTO
8633 | AARCH64_FEATURE_AES
8634 | AARCH64_FEATURE_SHA2
, 0),
8635 AARCH64_FEATURE (AARCH64_FEATURE_SIMD
, 0)},
8636 {"fp", AARCH64_FEATURE (AARCH64_FEATURE_FP
, 0),
8638 {"lse", AARCH64_FEATURE (AARCH64_FEATURE_LSE
, 0),
8640 {"simd", AARCH64_FEATURE (AARCH64_FEATURE_SIMD
, 0),
8641 AARCH64_FEATURE (AARCH64_FEATURE_FP
, 0)},
8642 {"pan", AARCH64_FEATURE (AARCH64_FEATURE_PAN
, 0),
8644 {"lor", AARCH64_FEATURE (AARCH64_FEATURE_LOR
, 0),
8646 {"ras", AARCH64_FEATURE (AARCH64_FEATURE_RAS
, 0),
8648 {"rdma", AARCH64_FEATURE (AARCH64_FEATURE_RDMA
, 0),
8649 AARCH64_FEATURE (AARCH64_FEATURE_SIMD
, 0)},
8650 {"fp16", AARCH64_FEATURE (AARCH64_FEATURE_F16
, 0),
8651 AARCH64_FEATURE (AARCH64_FEATURE_FP
, 0)},
8652 {"fp16fml", AARCH64_FEATURE (AARCH64_FEATURE_F16_FML
, 0),
8653 AARCH64_FEATURE (AARCH64_FEATURE_FP
8654 | AARCH64_FEATURE_F16
, 0)},
8655 {"profile", AARCH64_FEATURE (AARCH64_FEATURE_PROFILE
, 0),
8657 {"sve", AARCH64_FEATURE (AARCH64_FEATURE_SVE
, 0),
8658 AARCH64_FEATURE (AARCH64_FEATURE_F16
8659 | AARCH64_FEATURE_SIMD
8660 | AARCH64_FEATURE_COMPNUM
, 0)},
8661 {"compnum", AARCH64_FEATURE (AARCH64_FEATURE_COMPNUM
, 0),
8662 AARCH64_FEATURE (AARCH64_FEATURE_F16
8663 | AARCH64_FEATURE_SIMD
, 0)},
8664 {"rcpc", AARCH64_FEATURE (AARCH64_FEATURE_RCPC
, 0),
8666 {"dotprod", AARCH64_FEATURE (AARCH64_FEATURE_DOTPROD
, 0),
8668 {"sha2", AARCH64_FEATURE (AARCH64_FEATURE_SHA2
, 0),
8670 {"aes", AARCH64_FEATURE (AARCH64_FEATURE_AES
, 0),
8672 {"sm4", AARCH64_FEATURE (AARCH64_FEATURE_SM4
, 0),
8674 {"sha3", AARCH64_FEATURE (AARCH64_FEATURE_SHA2
8675 | AARCH64_FEATURE_SHA3
, 0),
8677 {NULL
, AARCH64_ARCH_NONE
, AARCH64_ARCH_NONE
},
8680 struct aarch64_long_option_table
8682 const char *option
; /* Substring to match. */
8683 const char *help
; /* Help information. */
8684 int (*func
) (const char *subopt
); /* Function to decode sub-option. */
8685 char *deprecated
; /* If non-null, print this message. */
8688 /* Transitive closure of features depending on set. */
8689 static aarch64_feature_set
8690 aarch64_feature_disable_set (aarch64_feature_set set
)
8692 const struct aarch64_option_cpu_value_table
*opt
;
8693 aarch64_feature_set prev
= 0;
8695 while (prev
!= set
) {
8697 for (opt
= aarch64_features
; opt
->name
!= NULL
; opt
++)
8698 if (AARCH64_CPU_HAS_ANY_FEATURES (opt
->require
, set
))
8699 AARCH64_MERGE_FEATURE_SETS (set
, set
, opt
->value
);
8704 /* Transitive closure of dependencies of set. */
8705 static aarch64_feature_set
8706 aarch64_feature_enable_set (aarch64_feature_set set
)
8708 const struct aarch64_option_cpu_value_table
*opt
;
8709 aarch64_feature_set prev
= 0;
8711 while (prev
!= set
) {
8713 for (opt
= aarch64_features
; opt
->name
!= NULL
; opt
++)
8714 if (AARCH64_CPU_HAS_FEATURE (set
, opt
->value
))
8715 AARCH64_MERGE_FEATURE_SETS (set
, set
, opt
->require
);
8721 aarch64_parse_features (const char *str
, const aarch64_feature_set
**opt_p
,
8722 bfd_boolean ext_only
)
8724 /* We insist on extensions being added before being removed. We achieve
8725 this by using the ADDING_VALUE variable to indicate whether we are
8726 adding an extension (1) or removing it (0) and only allowing it to
8727 change in the order -1 -> 1 -> 0. */
8728 int adding_value
= -1;
8729 aarch64_feature_set
*ext_set
= XNEW (aarch64_feature_set
);
8731 /* Copy the feature set, so that we can modify it. */
8735 while (str
!= NULL
&& *str
!= 0)
8737 const struct aarch64_option_cpu_value_table
*opt
;
8738 const char *ext
= NULL
;
8745 as_bad (_("invalid architectural extension"));
8749 ext
= strchr (++str
, '+');
8755 optlen
= strlen (str
);
8757 if (optlen
>= 2 && strncmp (str
, "no", 2) == 0)
8759 if (adding_value
!= 0)
8764 else if (optlen
> 0)
8766 if (adding_value
== -1)
8768 else if (adding_value
!= 1)
8770 as_bad (_("must specify extensions to add before specifying "
8771 "those to remove"));
8778 as_bad (_("missing architectural extension"));
8782 gas_assert (adding_value
!= -1);
8784 for (opt
= aarch64_features
; opt
->name
!= NULL
; opt
++)
8785 if (strncmp (opt
->name
, str
, optlen
) == 0)
8787 aarch64_feature_set set
;
8789 /* Add or remove the extension. */
8792 set
= aarch64_feature_enable_set (opt
->value
);
8793 AARCH64_MERGE_FEATURE_SETS (*ext_set
, *ext_set
, set
);
8797 set
= aarch64_feature_disable_set (opt
->value
);
8798 AARCH64_CLEAR_FEATURE (*ext_set
, *ext_set
, set
);
8803 if (opt
->name
== NULL
)
8805 as_bad (_("unknown architectural extension `%s'"), str
);
8816 aarch64_parse_cpu (const char *str
)
8818 const struct aarch64_cpu_option_table
*opt
;
8819 const char *ext
= strchr (str
, '+');
8825 optlen
= strlen (str
);
8829 as_bad (_("missing cpu name `%s'"), str
);
8833 for (opt
= aarch64_cpus
; opt
->name
!= NULL
; opt
++)
8834 if (strlen (opt
->name
) == optlen
&& strncmp (str
, opt
->name
, optlen
) == 0)
8836 mcpu_cpu_opt
= &opt
->value
;
8838 return aarch64_parse_features (ext
, &mcpu_cpu_opt
, FALSE
);
8843 as_bad (_("unknown cpu `%s'"), str
);
8848 aarch64_parse_arch (const char *str
)
8850 const struct aarch64_arch_option_table
*opt
;
8851 const char *ext
= strchr (str
, '+');
8857 optlen
= strlen (str
);
8861 as_bad (_("missing architecture name `%s'"), str
);
8865 for (opt
= aarch64_archs
; opt
->name
!= NULL
; opt
++)
8866 if (strlen (opt
->name
) == optlen
&& strncmp (str
, opt
->name
, optlen
) == 0)
8868 march_cpu_opt
= &opt
->value
;
8870 return aarch64_parse_features (ext
, &march_cpu_opt
, FALSE
);
8875 as_bad (_("unknown architecture `%s'\n"), str
);
8880 struct aarch64_option_abi_value_table
8883 enum aarch64_abi_type value
;
8886 static const struct aarch64_option_abi_value_table aarch64_abis
[] = {
8887 {"ilp32", AARCH64_ABI_ILP32
},
8888 {"lp64", AARCH64_ABI_LP64
},
8892 aarch64_parse_abi (const char *str
)
8898 as_bad (_("missing abi name `%s'"), str
);
8902 for (i
= 0; i
< ARRAY_SIZE (aarch64_abis
); i
++)
8903 if (strcmp (str
, aarch64_abis
[i
].name
) == 0)
8905 aarch64_abi
= aarch64_abis
[i
].value
;
8909 as_bad (_("unknown abi `%s'\n"), str
);
8913 static struct aarch64_long_option_table aarch64_long_opts
[] = {
8915 {"mabi=", N_("<abi name>\t specify for ABI <abi name>"),
8916 aarch64_parse_abi
, NULL
},
8917 #endif /* OBJ_ELF */
8918 {"mcpu=", N_("<cpu name>\t assemble for CPU <cpu name>"),
8919 aarch64_parse_cpu
, NULL
},
8920 {"march=", N_("<arch name>\t assemble for architecture <arch name>"),
8921 aarch64_parse_arch
, NULL
},
8922 {NULL
, NULL
, 0, NULL
}
8926 md_parse_option (int c
, const char *arg
)
8928 struct aarch64_option_table
*opt
;
8929 struct aarch64_long_option_table
*lopt
;
8935 target_big_endian
= 1;
8941 target_big_endian
= 0;
8946 /* Listing option. Just ignore these, we don't support additional
8951 for (opt
= aarch64_opts
; opt
->option
!= NULL
; opt
++)
8953 if (c
== opt
->option
[0]
8954 && ((arg
== NULL
&& opt
->option
[1] == 0)
8955 || streq (arg
, opt
->option
+ 1)))
8957 /* If the option is deprecated, tell the user. */
8958 if (opt
->deprecated
!= NULL
)
8959 as_tsktsk (_("option `-%c%s' is deprecated: %s"), c
,
8960 arg
? arg
: "", _(opt
->deprecated
));
8962 if (opt
->var
!= NULL
)
8963 *opt
->var
= opt
->value
;
8969 for (lopt
= aarch64_long_opts
; lopt
->option
!= NULL
; lopt
++)
8971 /* These options are expected to have an argument. */
8972 if (c
== lopt
->option
[0]
8974 && strncmp (arg
, lopt
->option
+ 1,
8975 strlen (lopt
->option
+ 1)) == 0)
8977 /* If the option is deprecated, tell the user. */
8978 if (lopt
->deprecated
!= NULL
)
8979 as_tsktsk (_("option `-%c%s' is deprecated: %s"), c
, arg
,
8980 _(lopt
->deprecated
));
8982 /* Call the sup-option parser. */
8983 return lopt
->func (arg
+ strlen (lopt
->option
) - 1);
8994 md_show_usage (FILE * fp
)
8996 struct aarch64_option_table
*opt
;
8997 struct aarch64_long_option_table
*lopt
;
8999 fprintf (fp
, _(" AArch64-specific assembler options:\n"));
9001 for (opt
= aarch64_opts
; opt
->option
!= NULL
; opt
++)
9002 if (opt
->help
!= NULL
)
9003 fprintf (fp
, " -%-23s%s\n", opt
->option
, _(opt
->help
));
9005 for (lopt
= aarch64_long_opts
; lopt
->option
!= NULL
; lopt
++)
9006 if (lopt
->help
!= NULL
)
9007 fprintf (fp
, " -%s%s\n", lopt
->option
, _(lopt
->help
));
9011 -EB assemble code for a big-endian cpu\n"));
9016 -EL assemble code for a little-endian cpu\n"));
9020 /* Parse a .cpu directive. */
9023 s_aarch64_cpu (int ignored ATTRIBUTE_UNUSED
)
9025 const struct aarch64_cpu_option_table
*opt
;
9031 name
= input_line_pointer
;
9032 while (*input_line_pointer
&& !ISSPACE (*input_line_pointer
))
9033 input_line_pointer
++;
9034 saved_char
= *input_line_pointer
;
9035 *input_line_pointer
= 0;
9037 ext
= strchr (name
, '+');
9040 optlen
= ext
- name
;
9042 optlen
= strlen (name
);
9044 /* Skip the first "all" entry. */
9045 for (opt
= aarch64_cpus
+ 1; opt
->name
!= NULL
; opt
++)
9046 if (strlen (opt
->name
) == optlen
9047 && strncmp (name
, opt
->name
, optlen
) == 0)
9049 mcpu_cpu_opt
= &opt
->value
;
9051 if (!aarch64_parse_features (ext
, &mcpu_cpu_opt
, FALSE
))
9054 cpu_variant
= *mcpu_cpu_opt
;
9056 *input_line_pointer
= saved_char
;
9057 demand_empty_rest_of_line ();
9060 as_bad (_("unknown cpu `%s'"), name
);
9061 *input_line_pointer
= saved_char
;
9062 ignore_rest_of_line ();
9066 /* Parse a .arch directive. */
9069 s_aarch64_arch (int ignored ATTRIBUTE_UNUSED
)
9071 const struct aarch64_arch_option_table
*opt
;
9077 name
= input_line_pointer
;
9078 while (*input_line_pointer
&& !ISSPACE (*input_line_pointer
))
9079 input_line_pointer
++;
9080 saved_char
= *input_line_pointer
;
9081 *input_line_pointer
= 0;
9083 ext
= strchr (name
, '+');
9086 optlen
= ext
- name
;
9088 optlen
= strlen (name
);
9090 /* Skip the first "all" entry. */
9091 for (opt
= aarch64_archs
+ 1; opt
->name
!= NULL
; opt
++)
9092 if (strlen (opt
->name
) == optlen
9093 && strncmp (name
, opt
->name
, optlen
) == 0)
9095 mcpu_cpu_opt
= &opt
->value
;
9097 if (!aarch64_parse_features (ext
, &mcpu_cpu_opt
, FALSE
))
9100 cpu_variant
= *mcpu_cpu_opt
;
9102 *input_line_pointer
= saved_char
;
9103 demand_empty_rest_of_line ();
9107 as_bad (_("unknown architecture `%s'\n"), name
);
9108 *input_line_pointer
= saved_char
;
9109 ignore_rest_of_line ();
9112 /* Parse a .arch_extension directive. */
9115 s_aarch64_arch_extension (int ignored ATTRIBUTE_UNUSED
)
9118 char *ext
= input_line_pointer
;;
9120 while (*input_line_pointer
&& !ISSPACE (*input_line_pointer
))
9121 input_line_pointer
++;
9122 saved_char
= *input_line_pointer
;
9123 *input_line_pointer
= 0;
9125 if (!aarch64_parse_features (ext
, &mcpu_cpu_opt
, TRUE
))
9128 cpu_variant
= *mcpu_cpu_opt
;
9130 *input_line_pointer
= saved_char
;
9131 demand_empty_rest_of_line ();
9134 /* Copy symbol information. */
9137 aarch64_copy_symbol_attributes (symbolS
* dest
, symbolS
* src
)
9139 AARCH64_GET_FLAG (dest
) = AARCH64_GET_FLAG (src
);