Subversion Repositories Kolibri OS

Rev

Rev 5191 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 5191 Rev 6324
Line 1... Line 1...
1
/* AArch64 assembler/disassembler support.
1
/* AArch64 assembler/disassembler support.
Line 2... Line 2...
2
 
2
 
3
   Copyright 2009, 2010, 2011, 2012, 2013  Free Software Foundation, Inc.
3
   Copyright (C) 2009-2015 Free Software Foundation, Inc.
Line 4... Line 4...
4
   Contributed by ARM Ltd.
4
   Contributed by ARM Ltd.
Line 5... Line 5...
5
 
5
 
Line 25... Line 25...
25
#include "bfd.h"
25
#include "bfd.h"
26
#include "bfd_stdint.h"
26
#include "bfd_stdint.h"
27
#include 
27
#include 
28
#include 
28
#include 
Line -... Line 29...
-
 
29
 
-
 
30
#ifdef __cplusplus
-
 
31
extern "C" {
-
 
32
#endif
29
 
33
 
30
/* The offset for pc-relative addressing is currently defined to be 0.  */
34
/* The offset for pc-relative addressing is currently defined to be 0.  */
Line 31... Line 35...
31
#define AARCH64_PCREL_OFFSET		0
35
#define AARCH64_PCREL_OFFSET		0
Line 32... Line 36...
32
 
36
 
33
typedef uint32_t aarch64_insn;
37
typedef uint32_t aarch64_insn;
-
 
38
 
34
 
39
/* The following bitmasks control CPU features.  */
35
/* The following bitmasks control CPU features.  */
40
#define AARCH64_FEATURE_V8	0x00000001	/* All processors.  */
36
#define AARCH64_FEATURE_V8	0x00000001	/* All processors.  */
41
#define AARCH64_FEATURE_V8_2	0x00000020      /* ARMv8.2 processors.  */
37
#define AARCH64_FEATURE_CRYPTO	0x00010000	/* Crypto instructions.  */
42
#define AARCH64_FEATURE_CRYPTO	0x00010000	/* Crypto instructions.  */
-
 
43
#define AARCH64_FEATURE_FP	0x00020000	/* FP instructions.  */
-
 
44
#define AARCH64_FEATURE_SIMD	0x00040000	/* SIMD instructions.  */
-
 
45
#define AARCH64_FEATURE_CRC	0x00080000	/* CRC instructions.  */
-
 
46
#define AARCH64_FEATURE_LSE	0x00100000	/* LSE instructions.  */
-
 
47
#define AARCH64_FEATURE_PAN	0x00200000	/* PAN instructions.  */
-
 
48
#define AARCH64_FEATURE_LOR	0x00400000	/* LOR instructions.  */
-
 
49
#define AARCH64_FEATURE_RDMA	0x00800000	/* v8.1 SIMD instructions.  */
-
 
50
#define AARCH64_FEATURE_V8_1	0x01000000	/* v8.1 features.  */
Line 38... Line 51...
38
#define AARCH64_FEATURE_FP	0x00020000	/* FP instructions.  */
51
#define AARCH64_FEATURE_F16	0x02000000	/* v8.2 FP16 instructions.  */
39
#define AARCH64_FEATURE_SIMD	0x00040000	/* SIMD instructions.  */
52
#define AARCH64_FEATURE_RAS	0x04000000	/* RAS Extensions.  */
40
#define AARCH64_FEATURE_CRC	0x00080000	/* CRC instructions.  */
53
#define AARCH64_FEATURE_PROFILE	0x08000000	/* Statistical Profiling.  */
41
 
54
 
-
 
55
/* Architectures are the sum of the base and extensions.  */
-
 
56
#define AARCH64_ARCH_V8		AARCH64_FEATURE (AARCH64_FEATURE_V8, \
-
 
57
						 AARCH64_FEATURE_FP  \
-
 
58
						 | AARCH64_FEATURE_SIMD)
-
 
59
#define AARCH64_ARCH_V8_1	AARCH64_FEATURE (AARCH64_FEATURE_V8, \
-
 
60
						 AARCH64_FEATURE_FP  \
-
 
61
						 | AARCH64_FEATURE_SIMD	\
-
 
62
						 | AARCH64_FEATURE_CRC	\
-
 
63
						 | AARCH64_FEATURE_V8_1 \
-
 
64
						 | AARCH64_FEATURE_LSE	\
-
 
65
						 | AARCH64_FEATURE_PAN	\
-
 
66
						 | AARCH64_FEATURE_LOR	\
-
 
67
						 | AARCH64_FEATURE_RDMA)
-
 
68
#define AARCH64_ARCH_V8_2	AARCH64_FEATURE (AARCH64_FEATURE_V8,	\
-
 
69
						 AARCH64_FEATURE_V8_2	\
-
 
70
						 | AARCH64_FEATURE_F16	\
-
 
71
						 | AARCH64_FEATURE_RAS	\
-
 
72
						 | AARCH64_FEATURE_FP	\
-
 
73
						 | AARCH64_FEATURE_SIMD	\
-
 
74
						 | AARCH64_FEATURE_CRC	\
-
 
75
						 | AARCH64_FEATURE_V8_1 \
-
 
76
						 | AARCH64_FEATURE_LSE	\
42
/* Architectures are the sum of the base and extensions.  */
77
						 | AARCH64_FEATURE_PAN	\
43
#define AARCH64_ARCH_V8		AARCH64_FEATURE (AARCH64_FEATURE_V8, \
78
						 | AARCH64_FEATURE_LOR	\
Line 44... Line 79...
44
						 AARCH64_FEATURE_FP  \
79
						 | AARCH64_FEATURE_RDMA)
45
						 | AARCH64_FEATURE_SIMD)
80
 
Line 104... Line 139...
104
  AARCH64_OPND_Ra,	/* Integer register used in ddp_3src instructions.  */
139
  AARCH64_OPND_Ra,	/* Integer register used in ddp_3src instructions.  */
105
  AARCH64_OPND_Rt_SYS,	/* Integer register used in system instructions.  */
140
  AARCH64_OPND_Rt_SYS,	/* Integer register used in system instructions.  */
Line 106... Line 141...
106
 
141
 
107
  AARCH64_OPND_Rd_SP,	/* Integer Rd or SP.  */
142
  AARCH64_OPND_Rd_SP,	/* Integer Rd or SP.  */
-
 
143
  AARCH64_OPND_Rn_SP,	/* Integer Rn or SP.  */
108
  AARCH64_OPND_Rn_SP,	/* Integer Rn or SP.  */
144
  AARCH64_OPND_PAIRREG,	/* Paired register operand.  */
109
  AARCH64_OPND_Rm_EXT,	/* Integer Rm extended.  */
145
  AARCH64_OPND_Rm_EXT,	/* Integer Rm extended.  */
Line 110... Line 146...
110
  AARCH64_OPND_Rm_SFT,	/* Integer Rm shifted.  */
146
  AARCH64_OPND_Rm_SFT,	/* Integer Rm shifted.  */
111
 
147
 
Line 199... Line 235...
199
  AARCH64_OPND_SYSREG_IC,	/* System register  operand.  */
235
  AARCH64_OPND_SYSREG_IC,	/* System register  operand.  */
200
  AARCH64_OPND_SYSREG_TLBI,	/* System register  operand.  */
236
  AARCH64_OPND_SYSREG_TLBI,	/* System register  operand.  */
201
  AARCH64_OPND_BARRIER,		/* Barrier operand.  */
237
  AARCH64_OPND_BARRIER,		/* Barrier operand.  */
202
  AARCH64_OPND_BARRIER_ISB,	/* Barrier operand for ISB.  */
238
  AARCH64_OPND_BARRIER_ISB,	/* Barrier operand for ISB.  */
203
  AARCH64_OPND_PRFOP,		/* Prefetch operation.  */
239
  AARCH64_OPND_PRFOP,		/* Prefetch operation.  */
-
 
240
  AARCH64_OPND_BARRIER_PSB,	/* Barrier operand for PSB.  */
204
};
241
};
Line 205... Line 242...
205
 
242
 
206
/* Qualifier constrains an operand.  It either specifies a variant of an
243
/* Qualifier constrains an operand.  It either specifies a variant of an
Line 243... Line 280...
243
     a use is only for the ease of operand encoding/decoding and qualifier
280
     a use is only for the ease of operand encoding/decoding and qualifier
244
     sequence matching; such a use should not be applied widely; use the value
281
     sequence matching; such a use should not be applied widely; use the value
245
     constraint qualifiers for immediate operands wherever possible.  */
282
     constraint qualifiers for immediate operands wherever possible.  */
246
  AARCH64_OPND_QLF_V_8B,
283
  AARCH64_OPND_QLF_V_8B,
247
  AARCH64_OPND_QLF_V_16B,
284
  AARCH64_OPND_QLF_V_16B,
-
 
285
  AARCH64_OPND_QLF_V_2H,
248
  AARCH64_OPND_QLF_V_4H,
286
  AARCH64_OPND_QLF_V_4H,
249
  AARCH64_OPND_QLF_V_8H,
287
  AARCH64_OPND_QLF_V_8H,
250
  AARCH64_OPND_QLF_V_2S,
288
  AARCH64_OPND_QLF_V_2S,
251
  AARCH64_OPND_QLF_V_4S,
289
  AARCH64_OPND_QLF_V_4S,
252
  AARCH64_OPND_QLF_V_1D,
290
  AARCH64_OPND_QLF_V_1D,
Line 338... Line 376...
338
  ldstpair_off,
376
  ldstpair_off,
339
  ldstpair_indexed,
377
  ldstpair_indexed,
340
  loadlit,
378
  loadlit,
341
  log_imm,
379
  log_imm,
342
  log_shift,
380
  log_shift,
-
 
381
  lse_atomic,
343
  movewide,
382
  movewide,
344
  pcreladdr,
383
  pcreladdr,
345
  ic_system,
384
  ic_system,
346
  testbranch,
385
  testbranch,
347
};
386
};
Line 405... Line 444...
405
  OP_UBFX,
444
  OP_UBFX,
406
  OP_BFXIL,
445
  OP_BFXIL,
407
  OP_SBFX,
446
  OP_SBFX,
408
  OP_SBFIZ,
447
  OP_SBFIZ,
409
  OP_BFI,
448
  OP_BFI,
-
 
449
  OP_BFC,		/* ARMv8.2.  */
410
  OP_UBFIZ,
450
  OP_UBFIZ,
411
  OP_UXTB,
451
  OP_UXTB,
412
  OP_UXTH,
452
  OP_UXTH,
413
  OP_UXTW,
453
  OP_UXTW,
Line 548... Line 588...
548
#define F_MISC (1 << 22)
588
#define F_MISC (1 << 22)
549
/* Instruction has the field of 'N'; used in conjunction with F_SF.  */
589
/* Instruction has the field of 'N'; used in conjunction with F_SF.  */
550
#define F_N (1 << 23)
590
#define F_N (1 << 23)
551
/* Opcode dependent field.  */
591
/* Opcode dependent field.  */
552
#define F_OD(X) (((X) & 0x7) << 24)
592
#define F_OD(X) (((X) & 0x7) << 24)
-
 
593
/* Instruction has the field of 'sz'.  */
-
 
594
#define F_LSE_SZ (1 << 27)
553
/* Next bit is 27.  */
595
/* Next bit is 28.  */
Line 554... Line 596...
554
 
596
 
555
static inline bfd_boolean
597
static inline bfd_boolean
556
alias_opcode_p (const aarch64_opcode *opcode)
598
alias_opcode_p (const aarch64_opcode *opcode)
557
{
599
{
Line 597... Line 639...
597
}
639
}
Line 598... Line 640...
598
 
640
 
599
static inline bfd_boolean
641
static inline bfd_boolean
600
opcode_has_special_coder (const aarch64_opcode *opcode)
642
opcode_has_special_coder (const aarch64_opcode *opcode)
601
{
643
{
602
  return (opcode->flags & (F_SF | F_SIZEQ | F_FPTYPE | F_SSIZE | F_T
644
  return (opcode->flags & (F_SF | F_LSE_SZ | F_SIZEQ | F_FPTYPE | F_SSIZE | F_T
603
	  | F_GPRSIZE_IN_Q | F_LDS_SIZE | F_MISC | F_N | F_COND)) ? TRUE
645
	  | F_GPRSIZE_IN_Q | F_LDS_SIZE | F_MISC | F_N | F_COND)) ? TRUE
604
    : FALSE;
646
    : FALSE;
605
}
647
}
606

648

Line 611... Line 653...
611
};
653
};
Line 612... Line 654...
612
 
654
 
613
extern const struct aarch64_name_value_pair aarch64_operand_modifiers [];
655
extern const struct aarch64_name_value_pair aarch64_operand_modifiers [];
614
extern const struct aarch64_name_value_pair aarch64_barrier_options [16];
656
extern const struct aarch64_name_value_pair aarch64_barrier_options [16];
-
 
657
extern const struct aarch64_name_value_pair aarch64_prfops [32];
Line 615... Line 658...
615
extern const struct aarch64_name_value_pair aarch64_prfops [32];
658
extern const struct aarch64_name_value_pair aarch64_hint_options [];
616
 
659
 
617
typedef struct
660
typedef struct
618
{
661
{
Line 622... Line 665...
622
} aarch64_sys_reg;
665
} aarch64_sys_reg;
Line 623... Line 666...
623
 
666
 
624
extern const aarch64_sys_reg aarch64_sys_regs [];
667
extern const aarch64_sys_reg aarch64_sys_regs [];
625
extern const aarch64_sys_reg aarch64_pstatefields [];
668
extern const aarch64_sys_reg aarch64_pstatefields [];
-
 
669
extern bfd_boolean aarch64_sys_reg_deprecated_p (const aarch64_sys_reg *);
-
 
670
extern bfd_boolean aarch64_sys_reg_supported_p (const aarch64_feature_set,
-
 
671
						const aarch64_sys_reg *);
-
 
672
extern bfd_boolean aarch64_pstatefield_supported_p (const aarch64_feature_set,
Line 626... Line 673...
626
extern bfd_boolean aarch64_sys_reg_deprecated_p (const aarch64_sys_reg *);
673
						    const aarch64_sys_reg *);
627
 
674
 
628
typedef struct
675
typedef struct
629
{
676
{
630
  const char *template;
677
  const char *name;
631
  uint32_t value;
678
  uint32_t value;
Line -... Line 679...
-
 
679
  uint32_t flags ;
-
 
680
} aarch64_sys_ins_reg;
-
 
681
 
-
 
682
extern bfd_boolean aarch64_sys_ins_reg_has_xt (const aarch64_sys_ins_reg *);
-
 
683
extern bfd_boolean
632
  int has_xt;
684
aarch64_sys_ins_reg_supported_p (const aarch64_feature_set,
633
} aarch64_sys_ins_reg;
685
				 const aarch64_sys_ins_reg *);
634
 
686
 
635
extern const aarch64_sys_ins_reg aarch64_sys_regs_ic [];
687
extern const aarch64_sys_ins_reg aarch64_sys_regs_ic [];
Line 735... Line 787...
735
      aarch64_insn sysreg;
787
      aarch64_insn sysreg;
736
      /* The encoding of the PSTATE field.  */
788
      /* The encoding of the PSTATE field.  */
737
      aarch64_insn pstatefield;
789
      aarch64_insn pstatefield;
738
      const aarch64_sys_ins_reg *sysins_op;
790
      const aarch64_sys_ins_reg *sysins_op;
739
      const struct aarch64_name_value_pair *barrier;
791
      const struct aarch64_name_value_pair *barrier;
-
 
792
      const struct aarch64_name_value_pair *hint_option;
740
      const struct aarch64_name_value_pair *prfop;
793
      const struct aarch64_name_value_pair *prfop;
741
    };
794
    };
Line 742... Line 795...
742
 
795
 
743
  /* Operand shifter; in use when the operand is a register offset address,
796
  /* Operand shifter; in use when the operand is a register offset address,
Line 899... Line 952...
899
aarch64_num_of_operands (const aarch64_opcode *);
952
aarch64_num_of_operands (const aarch64_opcode *);
Line 900... Line 953...
900
 
953
 
901
extern int
954
extern int
Line 902... Line 955...
902
aarch64_stack_pointer_p (const aarch64_opnd_info *);
955
aarch64_stack_pointer_p (const aarch64_opnd_info *);
903
 
956
 
-
 
957
extern int
-
 
958
aarch64_zero_register_p (const aarch64_opnd_info *);
-
 
959
 
Line 904... Line 960...
904
extern
960
extern int
905
int aarch64_zero_register_p (const aarch64_opnd_info *);
961
aarch64_decode_insn (aarch64_insn, aarch64_inst *, bfd_boolean);
906
 
962
 
907
/* Given an operand qualifier, return the expected data element size
963
/* Given an operand qualifier, return the expected data element size
Line 938... Line 994...
938
#else  /* !DEBUG_AARCH64 */
994
#else  /* !DEBUG_AARCH64 */
939
#define DEBUG_TRACE(M, ...) ;
995
#define DEBUG_TRACE(M, ...) ;
940
#define DEBUG_TRACE_IF(C, M, ...) ;
996
#define DEBUG_TRACE_IF(C, M, ...) ;
941
#endif /* DEBUG_AARCH64 */
997
#endif /* DEBUG_AARCH64 */
Line -... Line 998...
-
 
998
 
-
 
999
#ifdef __cplusplus
-
 
1000
}
-
 
1001
#endif
942
 
1002