19 #ifdef CAPSTONE_HAS_ARM64
24 #include "../../cs_priv.h"
25 #include "../../utils.h"
29 #include "../../MCInst.h"
30 #include "../../MCInstrDesc.h"
31 #include "../../MCFixedLenDisassembler.h"
32 #include "../../MCRegisterInfo.h"
33 #include "../../MCDisassembler.h"
98 uint64_t Address,
const void *Decoder);
100 uint64_t Address,
const void *Decoder);
102 uint64_t Address,
const void *Decoder);
104 uint64_t Address,
const void *Decoder);
108 const void *Decoder);
111 const void *Decoder);
115 const void *Decoder);
118 const void *Decoder);
122 const void *Decoder);
125 const void *Decoder);
128 const void *Decoder);
131 const void *Decoder);
134 const void *Decoder);
137 const void *Decoder);
139 uint64_t Address,
const void *Decoder);
141 uint64_t Address,
const void *Decoder);
144 const void *Decoder);
148 const void *Decoder);
150 uint64_t Address,
const void *Decoder);
154 const void *Decoder);
156 uint64_t Addr,
const void *Decoder);
159 const void *Decoder);
161 uint64_t Addr,
const void *Decoder);
164 const void *Decoder);
166 uint64_t Addr,
const void *Decoder);
169 const void *Decoder);
171 uint64_t Addr,
const void *Decoder);
173 uint64_t Addr,
const void *Decoder);
175 uint64_t Addr,
const void *Decoder);
177 uint64_t Addr,
const void *Decoder);
179 uint64_t Addr,
const void *Decoder);
200 static uint64_t getFeatureBits(
int feature)
206 #define GET_SUBTARGETINFO_ENUM
211 #define GET_INSTRINFO_ENUM
214 #define GET_REGINFO_ENUM
215 #define GET_REGINFO_MC_DESC
218 #define Success MCDisassembler_Success
219 #define Fail MCDisassembler_Fail
220 #define SoftFail MCDisassembler_SoftFail
240 MI->
flat_insn->detail->arm64.operands[
i].vector_index = -1;
244 insn = (
code[3] << 0) | (
code[2] << 8) |
273 static const unsigned FPR128DecoderTable[] = {
274 AArch64_Q0, AArch64_Q1, AArch64_Q2, AArch64_Q3, AArch64_Q4,
275 AArch64_Q5, AArch64_Q6, AArch64_Q7, AArch64_Q8, AArch64_Q9,
276 AArch64_Q10, AArch64_Q11, AArch64_Q12, AArch64_Q13, AArch64_Q14,
277 AArch64_Q15, AArch64_Q16, AArch64_Q17, AArch64_Q18, AArch64_Q19,
278 AArch64_Q20, AArch64_Q21, AArch64_Q22, AArch64_Q23, AArch64_Q24,
279 AArch64_Q25, AArch64_Q26, AArch64_Q27, AArch64_Q28, AArch64_Q29,
280 AArch64_Q30, AArch64_Q31
291 Register = FPR128DecoderTable[RegNo];
303 return DecodeFPR128RegisterClass(Inst, RegNo, Addr, Decoder);
306 static const unsigned FPR64DecoderTable[] = {
307 AArch64_D0, AArch64_D1, AArch64_D2, AArch64_D3, AArch64_D4,
308 AArch64_D5, AArch64_D6, AArch64_D7, AArch64_D8, AArch64_D9,
309 AArch64_D10, AArch64_D11, AArch64_D12, AArch64_D13, AArch64_D14,
310 AArch64_D15, AArch64_D16, AArch64_D17, AArch64_D18, AArch64_D19,
311 AArch64_D20, AArch64_D21, AArch64_D22, AArch64_D23, AArch64_D24,
312 AArch64_D25, AArch64_D26, AArch64_D27, AArch64_D28, AArch64_D29,
313 AArch64_D30, AArch64_D31
325 Register = FPR64DecoderTable[RegNo];
330 static const unsigned FPR32DecoderTable[] = {
331 AArch64_S0, AArch64_S1, AArch64_S2, AArch64_S3, AArch64_S4,
332 AArch64_S5, AArch64_S6, AArch64_S7, AArch64_S8, AArch64_S9,
333 AArch64_S10, AArch64_S11, AArch64_S12, AArch64_S13, AArch64_S14,
334 AArch64_S15, AArch64_S16, AArch64_S17, AArch64_S18, AArch64_S19,
335 AArch64_S20, AArch64_S21, AArch64_S22, AArch64_S23, AArch64_S24,
336 AArch64_S25, AArch64_S26, AArch64_S27, AArch64_S28, AArch64_S29,
337 AArch64_S30, AArch64_S31
349 Register = FPR32DecoderTable[RegNo];
354 static const unsigned FPR16DecoderTable[] = {
355 AArch64_H0, AArch64_H1, AArch64_H2, AArch64_H3, AArch64_H4,
356 AArch64_H5, AArch64_H6, AArch64_H7, AArch64_H8, AArch64_H9,
357 AArch64_H10, AArch64_H11, AArch64_H12, AArch64_H13, AArch64_H14,
358 AArch64_H15, AArch64_H16, AArch64_H17, AArch64_H18, AArch64_H19,
359 AArch64_H20, AArch64_H21, AArch64_H22, AArch64_H23, AArch64_H24,
360 AArch64_H25, AArch64_H26, AArch64_H27, AArch64_H28, AArch64_H29,
361 AArch64_H30, AArch64_H31
373 Register = FPR16DecoderTable[RegNo];
378 static const unsigned FPR8DecoderTable[] = {
379 AArch64_B0, AArch64_B1, AArch64_B2, AArch64_B3, AArch64_B4,
380 AArch64_B5, AArch64_B6, AArch64_B7, AArch64_B8, AArch64_B9,
381 AArch64_B10, AArch64_B11, AArch64_B12, AArch64_B13, AArch64_B14,
382 AArch64_B15, AArch64_B16, AArch64_B17, AArch64_B18, AArch64_B19,
383 AArch64_B20, AArch64_B21, AArch64_B22, AArch64_B23, AArch64_B24,
384 AArch64_B25, AArch64_B26, AArch64_B27, AArch64_B28, AArch64_B29,
385 AArch64_B30, AArch64_B31
402 static const unsigned GPR64DecoderTable[] = {
403 AArch64_X0, AArch64_X1, AArch64_X2, AArch64_X3, AArch64_X4,
404 AArch64_X5, AArch64_X6, AArch64_X7, AArch64_X8, AArch64_X9,
405 AArch64_X10, AArch64_X11, AArch64_X12, AArch64_X13, AArch64_X14,
406 AArch64_X15, AArch64_X16, AArch64_X17, AArch64_X18, AArch64_X19,
407 AArch64_X20, AArch64_X21, AArch64_X22, AArch64_X23, AArch64_X24,
408 AArch64_X25, AArch64_X26, AArch64_X27, AArch64_X28, AArch64_FP,
409 AArch64_LR, AArch64_XZR
421 Register = GPR64DecoderTable[RegNo];
435 Register = GPR64DecoderTable[RegNo];
444 static const unsigned GPR32DecoderTable[] = {
445 AArch64_W0, AArch64_W1, AArch64_W2, AArch64_W3, AArch64_W4,
446 AArch64_W5, AArch64_W6, AArch64_W7, AArch64_W8, AArch64_W9,
447 AArch64_W10, AArch64_W11, AArch64_W12, AArch64_W13, AArch64_W14,
448 AArch64_W15, AArch64_W16, AArch64_W17, AArch64_W18, AArch64_W19,
449 AArch64_W20, AArch64_W21, AArch64_W22, AArch64_W23, AArch64_W24,
450 AArch64_W25, AArch64_W26, AArch64_W27, AArch64_W28, AArch64_W29,
451 AArch64_W30, AArch64_WZR
463 Register = GPR32DecoderTable[RegNo];
477 Register = GPR32DecoderTable[RegNo];
485 static const unsigned VectorDecoderTable[] = {
486 AArch64_Q0, AArch64_Q1, AArch64_Q2, AArch64_Q3, AArch64_Q4,
487 AArch64_Q5, AArch64_Q6, AArch64_Q7, AArch64_Q8, AArch64_Q9,
488 AArch64_Q10, AArch64_Q11, AArch64_Q12, AArch64_Q13, AArch64_Q14,
489 AArch64_Q15, AArch64_Q16, AArch64_Q17, AArch64_Q18, AArch64_Q19,
490 AArch64_Q20, AArch64_Q21, AArch64_Q22, AArch64_Q23, AArch64_Q24,
491 AArch64_Q25, AArch64_Q26, AArch64_Q27, AArch64_Q28, AArch64_Q29,
492 AArch64_Q30, AArch64_Q31
504 Register = VectorDecoderTable[RegNo];
509 static const unsigned QQDecoderTable[] = {
510 AArch64_Q0_Q1, AArch64_Q1_Q2, AArch64_Q2_Q3, AArch64_Q3_Q4,
511 AArch64_Q4_Q5, AArch64_Q5_Q6, AArch64_Q6_Q7, AArch64_Q7_Q8,
512 AArch64_Q8_Q9, AArch64_Q9_Q10, AArch64_Q10_Q11, AArch64_Q11_Q12,
513 AArch64_Q12_Q13, AArch64_Q13_Q14, AArch64_Q14_Q15, AArch64_Q15_Q16,
514 AArch64_Q16_Q17, AArch64_Q17_Q18, AArch64_Q18_Q19, AArch64_Q19_Q20,
515 AArch64_Q20_Q21, AArch64_Q21_Q22, AArch64_Q22_Q23, AArch64_Q23_Q24,
516 AArch64_Q24_Q25, AArch64_Q25_Q26, AArch64_Q26_Q27, AArch64_Q27_Q28,
517 AArch64_Q28_Q29, AArch64_Q29_Q30, AArch64_Q30_Q31, AArch64_Q31_Q0
533 static const unsigned QQQDecoderTable[] = {
534 AArch64_Q0_Q1_Q2, AArch64_Q1_Q2_Q3, AArch64_Q2_Q3_Q4,
535 AArch64_Q3_Q4_Q5, AArch64_Q4_Q5_Q6, AArch64_Q5_Q6_Q7,
536 AArch64_Q6_Q7_Q8, AArch64_Q7_Q8_Q9, AArch64_Q8_Q9_Q10,
537 AArch64_Q9_Q10_Q11, AArch64_Q10_Q11_Q12, AArch64_Q11_Q12_Q13,
538 AArch64_Q12_Q13_Q14, AArch64_Q13_Q14_Q15, AArch64_Q14_Q15_Q16,
539 AArch64_Q15_Q16_Q17, AArch64_Q16_Q17_Q18, AArch64_Q17_Q18_Q19,
540 AArch64_Q18_Q19_Q20, AArch64_Q19_Q20_Q21, AArch64_Q20_Q21_Q22,
541 AArch64_Q21_Q22_Q23, AArch64_Q22_Q23_Q24, AArch64_Q23_Q24_Q25,
542 AArch64_Q24_Q25_Q26, AArch64_Q25_Q26_Q27, AArch64_Q26_Q27_Q28,
543 AArch64_Q27_Q28_Q29, AArch64_Q28_Q29_Q30, AArch64_Q29_Q30_Q31,
544 AArch64_Q30_Q31_Q0, AArch64_Q31_Q0_Q1
560 static const unsigned QQQQDecoderTable[] = {
561 AArch64_Q0_Q1_Q2_Q3, AArch64_Q1_Q2_Q3_Q4, AArch64_Q2_Q3_Q4_Q5,
562 AArch64_Q3_Q4_Q5_Q6, AArch64_Q4_Q5_Q6_Q7, AArch64_Q5_Q6_Q7_Q8,
563 AArch64_Q6_Q7_Q8_Q9, AArch64_Q7_Q8_Q9_Q10, AArch64_Q8_Q9_Q10_Q11,
564 AArch64_Q9_Q10_Q11_Q12, AArch64_Q10_Q11_Q12_Q13, AArch64_Q11_Q12_Q13_Q14,
565 AArch64_Q12_Q13_Q14_Q15, AArch64_Q13_Q14_Q15_Q16, AArch64_Q14_Q15_Q16_Q17,
566 AArch64_Q15_Q16_Q17_Q18, AArch64_Q16_Q17_Q18_Q19, AArch64_Q17_Q18_Q19_Q20,
567 AArch64_Q18_Q19_Q20_Q21, AArch64_Q19_Q20_Q21_Q22, AArch64_Q20_Q21_Q22_Q23,
568 AArch64_Q21_Q22_Q23_Q24, AArch64_Q22_Q23_Q24_Q25, AArch64_Q23_Q24_Q25_Q26,
569 AArch64_Q24_Q25_Q26_Q27, AArch64_Q25_Q26_Q27_Q28, AArch64_Q26_Q27_Q28_Q29,
570 AArch64_Q27_Q28_Q29_Q30, AArch64_Q28_Q29_Q30_Q31, AArch64_Q29_Q30_Q31_Q0,
571 AArch64_Q30_Q31_Q0_Q1, AArch64_Q31_Q0_Q1_Q2
587 static const unsigned DDDecoderTable[] = {
588 AArch64_D0_D1, AArch64_D1_D2, AArch64_D2_D3, AArch64_D3_D4,
589 AArch64_D4_D5, AArch64_D5_D6, AArch64_D6_D7, AArch64_D7_D8,
590 AArch64_D8_D9, AArch64_D9_D10, AArch64_D10_D11, AArch64_D11_D12,
591 AArch64_D12_D13, AArch64_D13_D14, AArch64_D14_D15, AArch64_D15_D16,
592 AArch64_D16_D17, AArch64_D17_D18, AArch64_D18_D19, AArch64_D19_D20,
593 AArch64_D20_D21, AArch64_D21_D22, AArch64_D22_D23, AArch64_D23_D24,
594 AArch64_D24_D25, AArch64_D25_D26, AArch64_D26_D27, AArch64_D27_D28,
595 AArch64_D28_D29, AArch64_D29_D30, AArch64_D30_D31, AArch64_D31_D0
611 static const unsigned DDDDecoderTable[] = {
612 AArch64_D0_D1_D2, AArch64_D1_D2_D3, AArch64_D2_D3_D4,
613 AArch64_D3_D4_D5, AArch64_D4_D5_D6, AArch64_D5_D6_D7,
614 AArch64_D6_D7_D8, AArch64_D7_D8_D9, AArch64_D8_D9_D10,
615 AArch64_D9_D10_D11, AArch64_D10_D11_D12, AArch64_D11_D12_D13,
616 AArch64_D12_D13_D14, AArch64_D13_D14_D15, AArch64_D14_D15_D16,
617 AArch64_D15_D16_D17, AArch64_D16_D17_D18, AArch64_D17_D18_D19,
618 AArch64_D18_D19_D20, AArch64_D19_D20_D21, AArch64_D20_D21_D22,
619 AArch64_D21_D22_D23, AArch64_D22_D23_D24, AArch64_D23_D24_D25,
620 AArch64_D24_D25_D26, AArch64_D25_D26_D27, AArch64_D26_D27_D28,
621 AArch64_D27_D28_D29, AArch64_D28_D29_D30, AArch64_D29_D30_D31,
622 AArch64_D30_D31_D0, AArch64_D31_D0_D1
638 static const unsigned DDDDDecoderTable[] = {
639 AArch64_D0_D1_D2_D3, AArch64_D1_D2_D3_D4, AArch64_D2_D3_D4_D5,
640 AArch64_D3_D4_D5_D6, AArch64_D4_D5_D6_D7, AArch64_D5_D6_D7_D8,
641 AArch64_D6_D7_D8_D9, AArch64_D7_D8_D9_D10, AArch64_D8_D9_D10_D11,
642 AArch64_D9_D10_D11_D12, AArch64_D10_D11_D12_D13, AArch64_D11_D12_D13_D14,
643 AArch64_D12_D13_D14_D15, AArch64_D13_D14_D15_D16, AArch64_D14_D15_D16_D17,
644 AArch64_D15_D16_D17_D18, AArch64_D16_D17_D18_D19, AArch64_D17_D18_D19_D20,
645 AArch64_D18_D19_D20_D21, AArch64_D19_D20_D21_D22, AArch64_D20_D21_D22_D23,
646 AArch64_D21_D22_D23_D24, AArch64_D22_D23_D24_D25, AArch64_D23_D24_D25_D26,
647 AArch64_D24_D25_D26_D27, AArch64_D25_D26_D27_D28, AArch64_D26_D27_D28_D29,
648 AArch64_D27_D28_D29_D30, AArch64_D28_D29_D30_D31, AArch64_D29_D30_D31_D0,
649 AArch64_D30_D31_D0_D1, AArch64_D31_D0_D1_D2
690 if (ImmVal & (1 << (19 - 1)))
691 ImmVal |= ~((1LL << 19) - 1);
698 uint64_t Address,
const void *Decoder)
706 uint64_t Address,
const void *Decoder)
730 unsigned Rd = fieldFromInstruction(Insn, 0, 5);
731 unsigned Rn = fieldFromInstruction(Insn, 5, 5);
732 unsigned IsToVec = fieldFromInstruction(Insn, 16, 1);
735 DecodeFPR128RegisterClass(Inst, Rd, Address, Decoder);
736 DecodeGPR64RegisterClass(Inst, Rn, Address, Decoder);
738 DecodeGPR64RegisterClass(Inst, Rd, Address, Decoder);
739 DecodeFPR128RegisterClass(Inst, Rn, Address, Decoder);
765 return DecodeVecShiftRImm(Inst, Imm, 64);
772 return DecodeVecShiftRImm(Inst, Imm | 0x20, 64);
778 return DecodeVecShiftRImm(Inst, Imm, 32);
785 return DecodeVecShiftRImm(Inst, Imm | 0x10, 32);
791 return DecodeVecShiftRImm(Inst, Imm, 16);
798 return DecodeVecShiftRImm(Inst, Imm | 0x8, 16);
804 return DecodeVecShiftRImm(Inst, Imm, 8);
810 return DecodeVecShiftLImm(Inst, Imm, 64);
816 return DecodeVecShiftLImm(Inst, Imm, 32);
822 return DecodeVecShiftLImm(Inst, Imm, 16);
828 return DecodeVecShiftLImm(Inst, Imm, 8);
835 unsigned Rd = fieldFromInstruction(insn, 0, 5);
836 unsigned Rn = fieldFromInstruction(insn, 5, 5);
837 unsigned Rm = fieldFromInstruction(insn, 16, 5);
838 unsigned shiftHi = fieldFromInstruction(insn, 22, 2);
839 unsigned shiftLo = fieldFromInstruction(insn, 10, 6);
840 unsigned shift = (shiftHi << 6) | shiftLo;
846 case AArch64_ADDSWrs:
848 case AArch64_SUBSWrs:
854 case AArch64_ANDSWrs:
856 case AArch64_BICSWrs:
860 case AArch64_EONWrs: {
862 if (shiftLo >> 5 == 1)
864 DecodeGPR32RegisterClass(Inst, Rd, Addr, Decoder);
865 DecodeGPR32RegisterClass(Inst, Rn, Addr, Decoder);
866 DecodeGPR32RegisterClass(Inst, Rm, Addr, Decoder);
870 case AArch64_ADDSXrs:
872 case AArch64_SUBSXrs:
878 case AArch64_ANDSXrs:
880 case AArch64_BICSXrs:
885 DecodeGPR64RegisterClass(Inst, Rd, Addr, Decoder);
886 DecodeGPR64RegisterClass(Inst, Rn, Addr, Decoder);
887 DecodeGPR64RegisterClass(Inst, Rm, Addr, Decoder);
899 unsigned Rd = fieldFromInstruction(insn, 0, 5);
900 unsigned imm = fieldFromInstruction(insn, 5, 16);
901 unsigned shift = fieldFromInstruction(insn, 21, 2);
911 if (
shift & (1U << 5))
913 DecodeGPR32RegisterClass(Inst, Rd, Addr, Decoder);
918 DecodeGPR64RegisterClass(Inst, Rd, Addr, Decoder);
935 unsigned Rt = fieldFromInstruction(insn, 0, 5);
936 unsigned Rn = fieldFromInstruction(insn, 5, 5);
937 unsigned offset = fieldFromInstruction(insn, 10, 12);
946 case AArch64_STRBBui:
947 case AArch64_LDRBBui:
948 case AArch64_LDRSBWui:
949 case AArch64_STRHHui:
950 case AArch64_LDRHHui:
951 case AArch64_LDRSHWui:
954 DecodeGPR32RegisterClass(Inst, Rt, Addr, Decoder);
956 case AArch64_LDRSBXui:
957 case AArch64_LDRSHXui:
958 case AArch64_LDRSWui:
961 DecodeGPR64RegisterClass(Inst, Rt, Addr, Decoder);
965 DecodeFPR128RegisterClass(Inst, Rt, Addr, Decoder);
969 DecodeFPR64RegisterClass(Inst, Rt, Addr, Decoder);
973 DecodeFPR32RegisterClass(Inst, Rt, Addr, Decoder);
977 DecodeFPR16RegisterClass(Inst, Rt, Addr, Decoder);
981 DecodeFPR8RegisterClass(Inst, Rt, Addr, Decoder);
985 DecodeGPR64spRegisterClass(Inst, Rn, Addr, Decoder);
999 unsigned Rt = fieldFromInstruction(insn, 0, 5);
1000 unsigned Rn = fieldFromInstruction(insn, 5, 5);
1005 if (
offset & (1 << (9 - 1)))
1006 offset |= ~((1LL << 9) - 1);
1012 case AArch64_LDRSBWpre:
1013 case AArch64_LDRSHWpre:
1014 case AArch64_STRBBpre:
1015 case AArch64_LDRBBpre:
1016 case AArch64_STRHHpre:
1017 case AArch64_LDRHHpre:
1018 case AArch64_STRWpre:
1019 case AArch64_LDRWpre:
1020 case AArch64_LDRSBWpost:
1021 case AArch64_LDRSHWpost:
1022 case AArch64_STRBBpost:
1023 case AArch64_LDRBBpost:
1024 case AArch64_STRHHpost:
1025 case AArch64_LDRHHpost:
1026 case AArch64_STRWpost:
1027 case AArch64_LDRWpost:
1028 case AArch64_LDRSBXpre:
1029 case AArch64_LDRSHXpre:
1030 case AArch64_STRXpre:
1031 case AArch64_LDRSWpre:
1032 case AArch64_LDRXpre:
1033 case AArch64_LDRSBXpost:
1034 case AArch64_LDRSHXpost:
1035 case AArch64_STRXpost:
1036 case AArch64_LDRSWpost:
1037 case AArch64_LDRXpost:
1038 case AArch64_LDRQpre:
1039 case AArch64_STRQpre:
1040 case AArch64_LDRQpost:
1041 case AArch64_STRQpost:
1042 case AArch64_LDRDpre:
1043 case AArch64_STRDpre:
1044 case AArch64_LDRDpost:
1045 case AArch64_STRDpost:
1046 case AArch64_LDRSpre:
1047 case AArch64_STRSpre:
1048 case AArch64_LDRSpost:
1049 case AArch64_STRSpost:
1050 case AArch64_LDRHpre:
1051 case AArch64_STRHpre:
1052 case AArch64_LDRHpost:
1053 case AArch64_STRHpost:
1054 case AArch64_LDRBpre:
1055 case AArch64_STRBpre:
1056 case AArch64_LDRBpost:
1057 case AArch64_STRBpost:
1058 DecodeGPR64spRegisterClass(Inst, Rn, Addr, Decoder);
1065 case AArch64_PRFUMi:
1069 case AArch64_STURBBi:
1070 case AArch64_LDURBBi:
1071 case AArch64_LDURSBWi:
1072 case AArch64_STURHHi:
1073 case AArch64_LDURHHi:
1074 case AArch64_LDURSHWi:
1075 case AArch64_STURWi:
1076 case AArch64_LDURWi:
1077 case AArch64_LDTRSBWi:
1078 case AArch64_LDTRSHWi:
1079 case AArch64_STTRWi:
1080 case AArch64_LDTRWi:
1081 case AArch64_STTRHi:
1082 case AArch64_LDTRHi:
1083 case AArch64_LDTRBi:
1084 case AArch64_STTRBi:
1085 case AArch64_LDRSBWpre:
1086 case AArch64_LDRSHWpre:
1087 case AArch64_STRBBpre:
1088 case AArch64_LDRBBpre:
1089 case AArch64_STRHHpre:
1090 case AArch64_LDRHHpre:
1091 case AArch64_STRWpre:
1092 case AArch64_LDRWpre:
1093 case AArch64_LDRSBWpost:
1094 case AArch64_LDRSHWpost:
1095 case AArch64_STRBBpost:
1096 case AArch64_LDRBBpost:
1097 case AArch64_STRHHpost:
1098 case AArch64_LDRHHpost:
1099 case AArch64_STRWpost:
1100 case AArch64_LDRWpost:
1101 DecodeGPR32RegisterClass(Inst, Rt, Addr, Decoder);
1103 case AArch64_LDURSBXi:
1104 case AArch64_LDURSHXi:
1105 case AArch64_LDURSWi:
1106 case AArch64_STURXi:
1107 case AArch64_LDURXi:
1108 case AArch64_LDTRSBXi:
1109 case AArch64_LDTRSHXi:
1110 case AArch64_LDTRSWi:
1111 case AArch64_STTRXi:
1112 case AArch64_LDTRXi:
1113 case AArch64_LDRSBXpre:
1114 case AArch64_LDRSHXpre:
1115 case AArch64_STRXpre:
1116 case AArch64_LDRSWpre:
1117 case AArch64_LDRXpre:
1118 case AArch64_LDRSBXpost:
1119 case AArch64_LDRSHXpost:
1120 case AArch64_STRXpost:
1121 case AArch64_LDRSWpost:
1122 case AArch64_LDRXpost:
1123 DecodeGPR64RegisterClass(Inst, Rt, Addr, Decoder);
1125 case AArch64_LDURQi:
1126 case AArch64_STURQi:
1127 case AArch64_LDRQpre:
1128 case AArch64_STRQpre:
1129 case AArch64_LDRQpost:
1130 case AArch64_STRQpost:
1131 DecodeFPR128RegisterClass(Inst, Rt, Addr, Decoder);
1133 case AArch64_LDURDi:
1134 case AArch64_STURDi:
1135 case AArch64_LDRDpre:
1136 case AArch64_STRDpre:
1137 case AArch64_LDRDpost:
1138 case AArch64_STRDpost:
1139 DecodeFPR64RegisterClass(Inst, Rt, Addr, Decoder);
1141 case AArch64_LDURSi:
1142 case AArch64_STURSi:
1143 case AArch64_LDRSpre:
1144 case AArch64_STRSpre:
1145 case AArch64_LDRSpost:
1146 case AArch64_STRSpost:
1147 DecodeFPR32RegisterClass(Inst, Rt, Addr, Decoder);
1149 case AArch64_LDURHi:
1150 case AArch64_STURHi:
1151 case AArch64_LDRHpre:
1152 case AArch64_STRHpre:
1153 case AArch64_LDRHpost:
1154 case AArch64_STRHpost:
1155 DecodeFPR16RegisterClass(Inst, Rt, Addr, Decoder);
1157 case AArch64_LDURBi:
1158 case AArch64_STURBi:
1159 case AArch64_LDRBpre:
1160 case AArch64_STRBpre:
1161 case AArch64_LDRBpost:
1162 case AArch64_STRBpost:
1163 DecodeFPR8RegisterClass(Inst, Rt, Addr, Decoder);
1167 DecodeGPR64spRegisterClass(Inst, Rn, Addr, Decoder);
1170 IsLoad = fieldFromInstruction(insn, 22, 1) != 0;
1171 IsIndexed = fieldFromInstruction(insn, 10, 2) != 0;
1172 IsFP = fieldFromInstruction(insn, 26, 1) != 0;
1175 if (IsLoad && IsIndexed && !IsFP && Rn != 31 && Rt == Rn)
1183 const void *Decoder)
1185 unsigned Rt = fieldFromInstruction(insn, 0, 5);
1186 unsigned Rn = fieldFromInstruction(insn, 5, 5);
1187 unsigned Rt2 = fieldFromInstruction(insn, 10, 5);
1188 unsigned Rs = fieldFromInstruction(insn, 16, 5);
1194 case AArch64_STLXRW:
1195 case AArch64_STLXRB:
1196 case AArch64_STLXRH:
1200 DecodeGPR32RegisterClass(Inst, Rs, Addr, Decoder);
1205 case AArch64_LDAXRW:
1206 case AArch64_LDAXRB:
1207 case AArch64_LDAXRH:
1214 DecodeGPR32RegisterClass(Inst, Rt, Addr, Decoder);
1216 case AArch64_STLXRX:
1218 DecodeGPR32RegisterClass(Inst, Rs, Addr, Decoder);
1221 case AArch64_LDAXRX:
1224 DecodeGPR64RegisterClass(Inst, Rt, Addr, Decoder);
1226 case AArch64_STLXPW:
1228 DecodeGPR32RegisterClass(Inst, Rs, Addr, Decoder);
1230 case AArch64_LDAXPW:
1232 DecodeGPR32RegisterClass(Inst, Rt, Addr, Decoder);
1233 DecodeGPR32RegisterClass(Inst, Rt2, Addr, Decoder);
1235 case AArch64_STLXPX:
1237 DecodeGPR32RegisterClass(Inst, Rs, Addr, Decoder);
1239 case AArch64_LDAXPX:
1241 DecodeGPR64RegisterClass(Inst, Rt, Addr, Decoder);
1242 DecodeGPR64RegisterClass(Inst, Rt2, Addr, Decoder);
1246 DecodeGPR64spRegisterClass(Inst, Rn, Addr, Decoder);
1249 if ((
Opcode == AArch64_LDAXPW ||
Opcode == AArch64_LDXPW ||
1250 Opcode == AArch64_LDAXPX ||
Opcode == AArch64_LDXPX) &&
1259 const void *Decoder)
1261 unsigned Rt = fieldFromInstruction(insn, 0, 5);
1262 unsigned Rn = fieldFromInstruction(insn, 5, 5);
1263 unsigned Rt2 = fieldFromInstruction(insn, 10, 5);
1265 bool IsLoad = fieldFromInstruction(insn, 22, 1) != 0;
1267 bool NeedsDisjointWritebackTransfer =
false;
1271 if (
offset & (1 << (7 - 1)))
1272 offset |= ~((1LL << 7) - 1);
1278 case AArch64_LDPXpost:
1279 case AArch64_STPXpost:
1280 case AArch64_LDPSWpost:
1281 case AArch64_LDPXpre:
1282 case AArch64_STPXpre:
1283 case AArch64_LDPSWpre:
1284 case AArch64_LDPWpost:
1285 case AArch64_STPWpost:
1286 case AArch64_LDPWpre:
1287 case AArch64_STPWpre:
1288 case AArch64_LDPQpost:
1289 case AArch64_STPQpost:
1290 case AArch64_LDPQpre:
1291 case AArch64_STPQpre:
1292 case AArch64_LDPDpost:
1293 case AArch64_STPDpost:
1294 case AArch64_LDPDpre:
1295 case AArch64_STPDpre:
1296 case AArch64_LDPSpost:
1297 case AArch64_STPSpost:
1298 case AArch64_LDPSpre:
1299 case AArch64_STPSpre:
1300 DecodeGPR64spRegisterClass(Inst, Rn, Addr, Decoder);
1307 case AArch64_LDPXpost:
1308 case AArch64_STPXpost:
1309 case AArch64_LDPSWpost:
1310 case AArch64_LDPXpre:
1311 case AArch64_STPXpre:
1312 case AArch64_LDPSWpre:
1313 NeedsDisjointWritebackTransfer =
true;
1315 case AArch64_LDNPXi:
1316 case AArch64_STNPXi:
1319 case AArch64_LDPSWi:
1320 DecodeGPR64RegisterClass(Inst, Rt, Addr, Decoder);
1321 DecodeGPR64RegisterClass(Inst, Rt2, Addr, Decoder);
1323 case AArch64_LDPWpost:
1324 case AArch64_STPWpost:
1325 case AArch64_LDPWpre:
1326 case AArch64_STPWpre:
1327 NeedsDisjointWritebackTransfer =
true;
1329 case AArch64_LDNPWi:
1330 case AArch64_STNPWi:
1333 DecodeGPR32RegisterClass(Inst, Rt, Addr, Decoder);
1334 DecodeGPR32RegisterClass(Inst, Rt2, Addr, Decoder);
1336 case AArch64_LDNPQi:
1337 case AArch64_STNPQi:
1338 case AArch64_LDPQpost:
1339 case AArch64_STPQpost:
1342 case AArch64_LDPQpre:
1343 case AArch64_STPQpre:
1344 DecodeFPR128RegisterClass(Inst, Rt, Addr, Decoder);
1345 DecodeFPR128RegisterClass(Inst, Rt2, Addr, Decoder);
1347 case AArch64_LDNPDi:
1348 case AArch64_STNPDi:
1349 case AArch64_LDPDpost:
1350 case AArch64_STPDpost:
1353 case AArch64_LDPDpre:
1354 case AArch64_STPDpre:
1355 DecodeFPR64RegisterClass(Inst, Rt, Addr, Decoder);
1356 DecodeFPR64RegisterClass(Inst, Rt2, Addr, Decoder);
1358 case AArch64_LDNPSi:
1359 case AArch64_STNPSi:
1360 case AArch64_LDPSpost:
1361 case AArch64_STPSpost:
1364 case AArch64_LDPSpre:
1365 case AArch64_STPSpre:
1366 DecodeFPR32RegisterClass(Inst, Rt, Addr, Decoder);
1367 DecodeFPR32RegisterClass(Inst, Rt2, Addr, Decoder);
1371 DecodeGPR64spRegisterClass(Inst, Rn, Addr, Decoder);
1375 if (IsLoad && Rt == Rt2)
1380 if (NeedsDisjointWritebackTransfer && Rn != 31 && (Rt == Rn || Rt2 == Rn))
1388 const void *Decoder)
1390 unsigned Rd, Rn, Rm;
1391 unsigned extend = fieldFromInstruction(insn, 10, 6);
1397 Rd = fieldFromInstruction(insn, 0, 5);
1398 Rn = fieldFromInstruction(insn, 5, 5);
1399 Rm = fieldFromInstruction(insn, 16, 5);
1404 case AArch64_ADDWrx:
1405 case AArch64_SUBWrx:
1406 DecodeGPR32spRegisterClass(Inst, Rd, Addr, Decoder);
1407 DecodeGPR32spRegisterClass(Inst, Rn, Addr, Decoder);
1408 DecodeGPR32RegisterClass(Inst, Rm, Addr, Decoder);
1410 case AArch64_ADDSWrx:
1411 case AArch64_SUBSWrx:
1412 DecodeGPR32RegisterClass(Inst, Rd, Addr, Decoder);
1413 DecodeGPR32spRegisterClass(Inst, Rn, Addr, Decoder);
1414 DecodeGPR32RegisterClass(Inst, Rm, Addr, Decoder);
1416 case AArch64_ADDXrx:
1417 case AArch64_SUBXrx:
1418 DecodeGPR64spRegisterClass(Inst, Rd, Addr, Decoder);
1419 DecodeGPR64spRegisterClass(Inst, Rn, Addr, Decoder);
1420 DecodeGPR32RegisterClass(Inst, Rm, Addr, Decoder);
1422 case AArch64_ADDSXrx:
1423 case AArch64_SUBSXrx:
1424 DecodeGPR64RegisterClass(Inst, Rd, Addr, Decoder);
1425 DecodeGPR64spRegisterClass(Inst, Rn, Addr, Decoder);
1426 DecodeGPR32RegisterClass(Inst, Rm, Addr, Decoder);
1428 case AArch64_ADDXrx64:
1429 case AArch64_SUBXrx64:
1430 DecodeGPR64spRegisterClass(Inst, Rd, Addr, Decoder);
1431 DecodeGPR64spRegisterClass(Inst, Rn, Addr, Decoder);
1432 DecodeGPR64RegisterClass(Inst, Rm, Addr, Decoder);
1434 case AArch64_SUBSXrx64:
1435 case AArch64_ADDSXrx64:
1436 DecodeGPR64RegisterClass(Inst, Rd, Addr, Decoder);
1437 DecodeGPR64spRegisterClass(Inst, Rn, Addr, Decoder);
1438 DecodeGPR64RegisterClass(Inst, Rm, Addr, Decoder);
1448 const void *Decoder)
1450 unsigned Rd = fieldFromInstruction(insn, 0, 5);
1451 unsigned Rn = fieldFromInstruction(insn, 5, 5);
1452 unsigned Datasize = fieldFromInstruction(insn, 31, 1);
1457 DecodeGPR64RegisterClass(Inst, Rd, Addr, Decoder);
1459 DecodeGPR64spRegisterClass(Inst, Rd, Addr, Decoder);
1460 DecodeGPR64RegisterClass(Inst, Rn, Addr, Decoder);
1461 imm = fieldFromInstruction(insn, 10, 13);
1466 DecodeGPR32RegisterClass(Inst, Rd, Addr, Decoder);
1468 DecodeGPR32spRegisterClass(Inst, Rd, Addr, Decoder);
1469 DecodeGPR32RegisterClass(Inst, Rn, Addr, Decoder);
1470 imm = fieldFromInstruction(insn, 10, 12);
1481 const void *Decoder)
1483 unsigned Rd = fieldFromInstruction(insn, 0, 5);
1484 unsigned cmode = fieldFromInstruction(insn, 12, 4);
1485 unsigned imm = fieldFromInstruction(insn, 16, 3) << 5;
1486 imm |= fieldFromInstruction(insn, 5, 5);
1489 DecodeFPR64RegisterClass(Inst, Rd, Addr, Decoder);
1491 DecodeVectorRegisterClass(Inst, Rd, Addr, Decoder);
1498 case AArch64_MOVIv4i16:
1499 case AArch64_MOVIv8i16:
1500 case AArch64_MVNIv4i16:
1501 case AArch64_MVNIv8i16:
1502 case AArch64_MOVIv2i32:
1503 case AArch64_MOVIv4i32:
1504 case AArch64_MVNIv2i32:
1505 case AArch64_MVNIv4i32:
1508 case AArch64_MOVIv2s_msl:
1509 case AArch64_MOVIv4s_msl:
1510 case AArch64_MVNIv2s_msl:
1511 case AArch64_MVNIv4s_msl:
1521 const void *Decoder)
1523 unsigned Rd = fieldFromInstruction(insn, 0, 5);
1524 unsigned cmode = fieldFromInstruction(insn, 12, 4);
1525 unsigned imm = fieldFromInstruction(insn, 16, 3) << 5;
1526 imm |= fieldFromInstruction(insn, 5, 5);
1529 DecodeVectorRegisterClass(Inst, Rd, Addr, Decoder);
1530 DecodeVectorRegisterClass(Inst, Rd, Addr, Decoder);
1539 uint64_t Addr,
const void *Decoder)
1541 unsigned Rd = fieldFromInstruction(insn, 0, 5);
1542 int64_t imm = fieldFromInstruction(insn, 5, 19) << 2;
1543 imm |= fieldFromInstruction(insn, 29, 2);
1546 if (
imm & (1 << (21 - 1)))
1547 imm |= ~((1LL << 21) - 1);
1549 DecodeGPR64RegisterClass(Inst, Rd, Addr, Decoder);
1557 uint64_t Addr,
const void *Decoder)
1559 unsigned Rd = fieldFromInstruction(insn, 0, 5);
1560 unsigned Rn = fieldFromInstruction(insn, 5, 5);
1561 unsigned Imm = fieldFromInstruction(insn, 10, 14);
1562 unsigned S = fieldFromInstruction(insn, 29, 1);
1563 unsigned Datasize = fieldFromInstruction(insn, 31, 1);
1565 unsigned ShifterVal = (Imm >> 12) & 3;
1566 unsigned ImmVal = Imm & 0xFFF;
1568 if (ShifterVal != 0 && ShifterVal != 1)
1573 DecodeGPR64spRegisterClass(Inst, Rd, Addr, Decoder);
1575 DecodeGPR64RegisterClass(Inst, Rd, Addr, Decoder);
1576 DecodeGPR64spRegisterClass(Inst, Rn, Addr, Decoder);
1579 DecodeGPR32spRegisterClass(Inst, Rd, Addr, Decoder);
1581 DecodeGPR32RegisterClass(Inst, Rd, Addr, Decoder);
1582 DecodeGPR32spRegisterClass(Inst, Rn, Addr, Decoder);
1593 const void *Decoder)
1595 int64_t imm = fieldFromInstruction(insn, 0, 26);
1598 if (
imm & (1 << (26 - 1)))
1599 imm |= ~((1LL << 26) - 1);
1609 const void *Decoder)
1611 uint32_t op1 = fieldFromInstruction(insn, 16, 3);
1612 uint32_t op2 = fieldFromInstruction(insn, 5, 3);
1613 uint32_t crm = fieldFromInstruction(insn, 8, 4);
1615 uint32_t pstate_field = (op1 << 3) | op2;
1622 return ValidNamed ? Success : Fail;
1626 uint64_t Addr,
const void *Decoder)
1628 uint32_t Rt = fieldFromInstruction(insn, 0, 5);
1629 uint32_t bit = fieldFromInstruction(insn, 31, 1) << 5;
1632 bit |= fieldFromInstruction(insn, 19, 5);
1635 if (
dst & (1 << (14 - 1)))
1636 dst |= ~((1LL << 14) - 1);
1638 if (fieldFromInstruction(insn, 31, 1) == 0)
1639 DecodeGPR32RegisterClass(Inst, Rt, Addr, Decoder);
1641 DecodeGPR64RegisterClass(Inst, Rt, Addr, Decoder);
1665 AArch64MCRegisterClasses, 43,
1666 0, 0, AArch64RegDiffLists,
1668 AArch64SubRegIdxLists, 53,
static bool AArch64_AM_isValidDecodeLogicalImmediate(uint64_t val, unsigned regSize)
const A64NamedImmMapper A64PState_PStateMapper
const char * A64NamedImmMapper_toString(const A64NamedImmMapper *N, uint32_t Value, bool *Valid)
bool AArch64_getInstruction(csh ud, const uint8_t *code, size_t code_len, MCInst *instr, uint16_t *size, uint64_t address, void *info)
void AArch64_init(MCRegisterInfo *MRI)
@ MCDisassembler_SoftFail
unsigned MCInst_getOpcode(const MCInst *inst)
void MCInst_clear(MCInst *inst)
MCOperand * MCInst_getOperand(MCInst *inst, unsigned i)
void MCOperand_CreateReg0(MCInst *mcInst, unsigned Reg)
void MCInst_addOperand2(MCInst *inst, MCOperand *Op)
void MCOperand_CreateImm0(MCInst *mcInst, int64_t Val)
void MCRegisterInfo_InitMCRegisterInfo(MCRegisterInfo *RI, const MCRegisterDesc *D, unsigned NR, unsigned RA, unsigned PC, const MCRegisterClass *C, unsigned NC, uint16_t(*RURoots)[2], unsigned NRU, const MCPhysReg *DL, const char *Strings, const uint16_t *SubIndices, unsigned NumIndices, const uint16_t *RET)
int decodeInstruction(struct InternalInstruction *insn, byteReader_t reader, const void *readerArg, uint64_t startLoc, DisassemblerMode mode)
static RZ_NULLABLE RzILOpBitVector * shift(RzILOpBitVector *val, RZ_NULLABLE RzILOpBool **carry_out, arm_shifter type, RZ_OWN RzILOpBitVector *dist)
static RzILOpBitVector * extend(ut32 dst_bits, arm64_extender ext, RZ_OWN RzILOpBitVector *v, ut32 v_bits)
RzBinInfo * info(RzBinFile *bf)
#define MODE_IS_BIG_ENDIAN(mode)
#define offsetof(type, member)
return memset(p, 0, total)
static const char struct stat static buf struct stat static buf static vhangup int status