@@ -44,6 +44,11 @@ class XtensaDisassembler : public MCDisassembler {
44
44
45
45
bool hasESP32S3Ops () const {
46
46
return STI.getFeatureBits ()[Xtensa::FeatureESP32S3Ops];
47
+
48
+ }
49
+
50
+ bool hasHIFI3 () const {
51
+ return STI.getFeatureBits ()[Xtensa::FeatureHIFI3];
47
52
}
48
53
49
54
DecodeStatus getInstruction (MCInst &Instr, uint64_t &Size,
@@ -832,7 +837,7 @@ static DecodeStatus decodeMem32nOperand(MCInst &Inst, uint64_t Imm,
832
837
// / Read two bytes from the ArrayRef and return 16 bit data sorted
833
838
// / according to the given endianness.
834
839
static DecodeStatus readInstruction16 (ArrayRef<uint8_t > Bytes, uint64_t Address,
835
- uint64_t &Size, uint32_t &Insn,
840
+ uint64_t &Size, uint64_t &Insn,
836
841
bool IsLittleEndian) {
837
842
// We want to read exactly 2 Bytes of data.
838
843
if (Bytes.size () < 2 ) {
@@ -851,7 +856,7 @@ static DecodeStatus readInstruction16(ArrayRef<uint8_t> Bytes, uint64_t Address,
851
856
852
857
// / Read three bytes from the ArrayRef and return 24 bit data
853
858
static DecodeStatus readInstruction24 (ArrayRef<uint8_t > Bytes, uint64_t Address,
854
- uint64_t &Size, uint32_t &Insn,
859
+ uint64_t &Size, uint64_t &Insn,
855
860
bool IsLittleEndian) {
856
861
// We want to read exactly 3 Bytes of data.
857
862
if (Bytes.size () < 3 ) {
@@ -870,7 +875,7 @@ static DecodeStatus readInstruction24(ArrayRef<uint8_t> Bytes, uint64_t Address,
870
875
871
876
// / Read three bytes from the ArrayRef and return 32 bit data
872
877
static DecodeStatus readInstruction32 (ArrayRef<uint8_t > Bytes, uint64_t Address,
873
- uint64_t &Size, uint32_t &Insn,
878
+ uint64_t &Size, uint64_t &Insn,
874
879
bool IsLittleEndian) {
875
880
// We want to read exactly 4 Bytes of data.
876
881
if (Bytes.size () < 4 ) {
@@ -887,13 +892,37 @@ static DecodeStatus readInstruction32(ArrayRef<uint8_t> Bytes, uint64_t Address,
887
892
return MCDisassembler::Success;
888
893
}
889
894
895
+ // / Read InstSize bytes from the ArrayRef and return 24 bit data
896
+ static DecodeStatus readInstructionN (ArrayRef<uint8_t > Bytes, uint64_t Address,
897
+ unsigned InstSize,
898
+ uint64_t &Size, uint64_t &Insn,
899
+ bool IsLittleEndian) {
900
+ // We want to read exactly 3 Bytes of data.
901
+ if (Bytes.size () < InstSize) {
902
+ Size = 0 ;
903
+ return MCDisassembler::Fail;
904
+ }
905
+
906
+ if (!IsLittleEndian) {
907
+ report_fatal_error (" Big-endian mode currently is not supported!" );
908
+ } else {
909
+ Insn = 0 ;
910
+ for (unsigned i = 0 ; i < InstSize; i++)
911
+ Insn |= (Bytes[i] << 8 *i);
912
+ }
913
+
914
+ Size = InstSize;
915
+ return MCDisassembler::Success;
916
+ }
917
+
918
+
890
919
#include " XtensaGenDisassemblerTables.inc"
891
920
892
921
DecodeStatus XtensaDisassembler::getInstruction (MCInst &MI, uint64_t &Size,
893
922
ArrayRef<uint8_t > Bytes,
894
923
uint64_t Address,
895
924
raw_ostream &CS) const {
896
- uint32_t Insn;
925
+ uint64_t Insn;
897
926
DecodeStatus Result;
898
927
899
928
// Parse 16-bit instructions
@@ -946,5 +975,20 @@ DecodeStatus XtensaDisassembler::getInstruction(MCInst &MI, uint64_t &Size,
946
975
}
947
976
}
948
977
978
+ if (hasHIFI3 ()) {
979
+ LLVM_DEBUG (dbgs () << " Trying Xtensa HIFI3 24-bit instruction table :\n " );
980
+ Result = decodeInstruction (DecoderTableHIFI324, MI, Insn, Address, this , STI);
981
+ if (Result != MCDisassembler::Fail)
982
+ return Result;
983
+
984
+ Result = readInstructionN (Bytes, Address, 48 , Size, Insn, IsLittleEndian);
985
+ if (Result == MCDisassembler::Fail)
986
+ return MCDisassembler::Fail;
987
+
988
+ LLVM_DEBUG (dbgs () << " Trying Xtensa HIFI3 48-bit instruction table :\n " );
989
+ Result = decodeInstruction (DecoderTableHIFI348, MI, Insn, Address, this , STI);
990
+ if (Result != MCDisassembler::Fail)
991
+ return Result;
992
+ }
949
993
return Result;
950
994
}
0 commit comments