@@ -57,6 +57,7 @@ LLVMInitializeVEDisassembler() {
5757 createVEDisassembler);
5858}
5959
60+ // clang-format off
6061static const unsigned I32RegDecoderTable[] = {
6162 VE::SW0, VE::SW1, VE::SW2, VE::SW3, VE::SW4, VE::SW5, VE::SW6,
6263 VE::SW7, VE::SW8, VE::SW9, VE::SW10, VE::SW11, VE::SW12, VE::SW13,
@@ -127,6 +128,7 @@ static const unsigned MiscRegDecoderTable[] = {
127128 VE::PMC4, VE::PMC5, VE::PMC6, VE::PMC7,
128129 VE::PMC8, VE::PMC9, VE::PMC10, VE::PMC11,
129130 VE::PMC12, VE::PMC13, VE::PMC14};
131+ // clang-format on
130132
131133static DecodeStatus DecodeI32RegisterClass (MCInst &Inst, unsigned RegNo,
132134 uint64_t Address,
@@ -214,106 +216,6 @@ static DecodeStatus DecodeMISCRegisterClass(MCInst &Inst, unsigned RegNo,
214216 return MCDisassembler::Success;
215217}
216218
217- static DecodeStatus DecodeASX (MCInst &Inst, uint64_t insn, uint64_t Address,
218- const MCDisassembler *Decoder);
219- static DecodeStatus DecodeLoadI32 (MCInst &Inst, uint64_t insn, uint64_t Address,
220- const MCDisassembler *Decoder);
221- static DecodeStatus DecodeStoreI32 (MCInst &Inst, uint64_t insn,
222- uint64_t Address,
223- const MCDisassembler *Decoder);
224- static DecodeStatus DecodeLoadI64 (MCInst &Inst, uint64_t insn, uint64_t Address,
225- const MCDisassembler *Decoder);
226- static DecodeStatus DecodeStoreI64 (MCInst &Inst, uint64_t insn,
227- uint64_t Address,
228- const MCDisassembler *Decoder);
229- static DecodeStatus DecodeLoadF32 (MCInst &Inst, uint64_t insn, uint64_t Address,
230- const MCDisassembler *Decoder);
231- static DecodeStatus DecodeStoreF32 (MCInst &Inst, uint64_t insn,
232- uint64_t Address,
233- const MCDisassembler *Decoder);
234- static DecodeStatus DecodeLoadASI64 (MCInst &Inst, uint64_t insn,
235- uint64_t Address,
236- const MCDisassembler *Decoder);
237- static DecodeStatus DecodeStoreASI64 (MCInst &Inst, uint64_t insn,
238- uint64_t Address,
239- const MCDisassembler *Decoder);
240- static DecodeStatus DecodeTS1AMI64 (MCInst &Inst, uint64_t insn,
241- uint64_t Address,
242- const MCDisassembler *Decoder);
243- static DecodeStatus DecodeTS1AMI32 (MCInst &Inst, uint64_t insn,
244- uint64_t Address,
245- const MCDisassembler *Decoder);
246- static DecodeStatus DecodeCASI64 (MCInst &Inst, uint64_t insn, uint64_t Address,
247- const MCDisassembler *Decoder);
248- static DecodeStatus DecodeCASI32 (MCInst &Inst, uint64_t insn, uint64_t Address,
249- const MCDisassembler *Decoder);
250- static DecodeStatus DecodeCall (MCInst &Inst, uint64_t insn, uint64_t Address,
251- const MCDisassembler *Decoder);
252- static DecodeStatus DecodeSIMM7 (MCInst &Inst, uint64_t insn, uint64_t Address,
253- const MCDisassembler *Decoder);
254- static DecodeStatus DecodeSIMM32 (MCInst &Inst, uint64_t insn, uint64_t Address,
255- const MCDisassembler *Decoder);
256- static DecodeStatus DecodeCCOperand (MCInst &Inst, uint64_t insn,
257- uint64_t Address,
258- const MCDisassembler *Decoder);
259- static DecodeStatus DecodeRDOperand (MCInst &Inst, uint64_t insn,
260- uint64_t Address,
261- const MCDisassembler *Decoder);
262- static DecodeStatus DecodeBranchCondition (MCInst &Inst, uint64_t insn,
263- uint64_t Address,
264- const MCDisassembler *Decoder);
265- static DecodeStatus DecodeBranchConditionAlways (MCInst &Inst, uint64_t insn,
266- uint64_t Address,
267- const MCDisassembler *Decoder);
268-
269- #include " VEGenDisassemblerTables.inc"
270-
271- // / Read four bytes from the ArrayRef and return 32 bit word.
272- static DecodeStatus readInstruction64 (ArrayRef<uint8_t > Bytes, uint64_t Address,
273- uint64_t &Size, uint64_t &Insn,
274- bool IsLittleEndian) {
275- // We want to read exactly 8 Bytes of data.
276- if (Bytes.size () < 8 ) {
277- Size = 0 ;
278- return MCDisassembler::Fail;
279- }
280-
281- Insn = IsLittleEndian
282- ? ((uint64_t )Bytes[0 ] << 0 ) | ((uint64_t )Bytes[1 ] << 8 ) |
283- ((uint64_t )Bytes[2 ] << 16 ) | ((uint64_t )Bytes[3 ] << 24 ) |
284- ((uint64_t )Bytes[4 ] << 32 ) | ((uint64_t )Bytes[5 ] << 40 ) |
285- ((uint64_t )Bytes[6 ] << 48 ) | ((uint64_t )Bytes[7 ] << 56 )
286- : ((uint64_t )Bytes[7 ] << 0 ) | ((uint64_t )Bytes[6 ] << 8 ) |
287- ((uint64_t )Bytes[5 ] << 16 ) | ((uint64_t )Bytes[4 ] << 24 ) |
288- ((uint64_t )Bytes[3 ] << 32 ) | ((uint64_t )Bytes[2 ] << 40 ) |
289- ((uint64_t )Bytes[1 ] << 48 ) | ((uint64_t )Bytes[0 ] << 56 );
290-
291- return MCDisassembler::Success;
292- }
293-
294- DecodeStatus VEDisassembler::getInstruction (MCInst &Instr, uint64_t &Size,
295- ArrayRef<uint8_t > Bytes,
296- uint64_t Address,
297- raw_ostream &CStream) const {
298- uint64_t Insn;
299- bool isLittleEndian = getContext ().getAsmInfo ()->isLittleEndian ();
300- DecodeStatus Result =
301- readInstruction64 (Bytes, Address, Size, Insn, isLittleEndian);
302- if (Result == MCDisassembler::Fail)
303- return MCDisassembler::Fail;
304-
305- // Calling the auto-generated decoder function.
306-
307- Result = decodeInstruction (DecoderTableVE64, Instr, Insn, Address, this , STI);
308-
309- if (Result != MCDisassembler::Fail) {
310- Size = 8 ;
311- return Result;
312- }
313-
314- return MCDisassembler::Fail;
315- }
316-
317219typedef DecodeStatus (*DecodeFunc)(MCInst &MI, unsigned RegNo, uint64_t Address,
318220 const MCDisassembler *Decoder);
319221
@@ -629,3 +531,51 @@ static DecodeStatus DecodeBranchConditionAlways(MCInst &MI, uint64_t insn,
629531 // Decode MEMri.
630532 return DecodeAS (MI, insn, Address, Decoder);
631533}
534+
535+ #include " VEGenDisassemblerTables.inc"
536+
537+ // / Read four bytes from the ArrayRef and return 32 bit word.
538+ static DecodeStatus readInstruction64 (ArrayRef<uint8_t > Bytes, uint64_t Address,
539+ uint64_t &Size, uint64_t &Insn,
540+ bool IsLittleEndian) {
541+ // We want to read exactly 8 Bytes of data.
542+ if (Bytes.size () < 8 ) {
543+ Size = 0 ;
544+ return MCDisassembler::Fail;
545+ }
546+
547+ Insn = IsLittleEndian
548+ ? ((uint64_t )Bytes[0 ] << 0 ) | ((uint64_t )Bytes[1 ] << 8 ) |
549+ ((uint64_t )Bytes[2 ] << 16 ) | ((uint64_t )Bytes[3 ] << 24 ) |
550+ ((uint64_t )Bytes[4 ] << 32 ) | ((uint64_t )Bytes[5 ] << 40 ) |
551+ ((uint64_t )Bytes[6 ] << 48 ) | ((uint64_t )Bytes[7 ] << 56 )
552+ : ((uint64_t )Bytes[7 ] << 0 ) | ((uint64_t )Bytes[6 ] << 8 ) |
553+ ((uint64_t )Bytes[5 ] << 16 ) | ((uint64_t )Bytes[4 ] << 24 ) |
554+ ((uint64_t )Bytes[3 ] << 32 ) | ((uint64_t )Bytes[2 ] << 40 ) |
555+ ((uint64_t )Bytes[1 ] << 48 ) | ((uint64_t )Bytes[0 ] << 56 );
556+
557+ return MCDisassembler::Success;
558+ }
559+
560+ DecodeStatus VEDisassembler::getInstruction (MCInst &Instr, uint64_t &Size,
561+ ArrayRef<uint8_t > Bytes,
562+ uint64_t Address,
563+ raw_ostream &CStream) const {
564+ uint64_t Insn;
565+ bool isLittleEndian = getContext ().getAsmInfo ()->isLittleEndian ();
566+ DecodeStatus Result =
567+ readInstruction64 (Bytes, Address, Size, Insn, isLittleEndian);
568+ if (Result == MCDisassembler::Fail)
569+ return MCDisassembler::Fail;
570+
571+ // Calling the auto-generated decoder function.
572+
573+ Result = decodeInstruction (DecoderTableVE64, Instr, Insn, Address, this , STI);
574+
575+ if (Result != MCDisassembler::Fail) {
576+ Size = 8 ;
577+ return Result;
578+ }
579+
580+ return MCDisassembler::Fail;
581+ }
0 commit comments