Skip to content

Commit 8361d7e

Browse files
authored
[NFC][MC][XCore] Eliminate forward decls by rearranging functions (#155456)
1 parent b6a0802 commit 8361d7e

File tree

1 file changed

+110
-140
lines changed

1 file changed

+110
-140
lines changed

llvm/lib/Target/XCore/Disassembler/XCoreDisassembler.cpp

Lines changed: 110 additions & 140 deletions
Original file line numberDiff line numberDiff line change
@@ -74,37 +74,6 @@ static unsigned getReg(const MCDisassembler *D, unsigned RC, unsigned RegNo) {
7474
return *(RegInfo->getRegClass(RC).begin() + RegNo);
7575
}
7676

77-
static DecodeStatus Decode3RInstruction(MCInst &Inst, unsigned Insn,
78-
uint64_t Address,
79-
const MCDisassembler *Decoder);
80-
81-
static DecodeStatus Decode3RImmInstruction(MCInst &Inst, unsigned Insn,
82-
uint64_t Address,
83-
const MCDisassembler *Decoder);
84-
static DecodeStatus Decode2RUSInstruction(MCInst &Inst, unsigned Insn,
85-
uint64_t Address,
86-
const MCDisassembler *Decoder);
87-
88-
static DecodeStatus Decode2RUSBitpInstruction(MCInst &Inst, unsigned Insn,
89-
uint64_t Address,
90-
const MCDisassembler *Decoder);
91-
92-
static DecodeStatus DecodeL3RInstruction(MCInst &Inst, unsigned Insn,
93-
uint64_t Address,
94-
const MCDisassembler *Decoder);
95-
96-
static DecodeStatus DecodeL3RSrcDstInstruction(MCInst &Inst, unsigned Insn,
97-
uint64_t Address,
98-
const MCDisassembler *Decoder);
99-
100-
static DecodeStatus DecodeL2RUSInstruction(MCInst &Inst, unsigned Insn,
101-
uint64_t Address,
102-
const MCDisassembler *Decoder);
103-
104-
static DecodeStatus DecodeL2RUSBitpInstruction(MCInst &Inst, unsigned Insn,
105-
uint64_t Address,
106-
const MCDisassembler *Decoder);
107-
10877
static DecodeStatus DecodeGRRegsRegisterClass(MCInst &Inst, unsigned RegNo,
10978
uint64_t Address,
11079
const MCDisassembler *Decoder) {
@@ -178,6 +147,116 @@ Decode3OpInstruction(unsigned Insn, unsigned &Op1, unsigned &Op2,
178147
return MCDisassembler::Success;
179148
}
180149

150+
static DecodeStatus Decode3RInstruction(MCInst &Inst, unsigned Insn,
151+
uint64_t Address,
152+
const MCDisassembler *Decoder) {
153+
unsigned Op1, Op2, Op3;
154+
DecodeStatus S = Decode3OpInstruction(Insn, Op1, Op2, Op3);
155+
if (S == MCDisassembler::Success) {
156+
DecodeGRRegsRegisterClass(Inst, Op1, Address, Decoder);
157+
DecodeGRRegsRegisterClass(Inst, Op2, Address, Decoder);
158+
DecodeGRRegsRegisterClass(Inst, Op3, Address, Decoder);
159+
}
160+
return S;
161+
}
162+
163+
static DecodeStatus Decode3RImmInstruction(MCInst &Inst, unsigned Insn,
164+
uint64_t Address,
165+
const MCDisassembler *Decoder) {
166+
unsigned Op1, Op2, Op3;
167+
DecodeStatus S = Decode3OpInstruction(Insn, Op1, Op2, Op3);
168+
if (S == MCDisassembler::Success) {
169+
Inst.addOperand(MCOperand::createImm(Op1));
170+
DecodeGRRegsRegisterClass(Inst, Op2, Address, Decoder);
171+
DecodeGRRegsRegisterClass(Inst, Op3, Address, Decoder);
172+
}
173+
return S;
174+
}
175+
176+
static DecodeStatus Decode2RUSInstruction(MCInst &Inst, unsigned Insn,
177+
uint64_t Address,
178+
const MCDisassembler *Decoder) {
179+
unsigned Op1, Op2, Op3;
180+
DecodeStatus S = Decode3OpInstruction(Insn, Op1, Op2, Op3);
181+
if (S == MCDisassembler::Success) {
182+
DecodeGRRegsRegisterClass(Inst, Op1, Address, Decoder);
183+
DecodeGRRegsRegisterClass(Inst, Op2, Address, Decoder);
184+
Inst.addOperand(MCOperand::createImm(Op3));
185+
}
186+
return S;
187+
}
188+
189+
static DecodeStatus Decode2RUSBitpInstruction(MCInst &Inst, unsigned Insn,
190+
uint64_t Address,
191+
const MCDisassembler *Decoder) {
192+
unsigned Op1, Op2, Op3;
193+
DecodeStatus S = Decode3OpInstruction(Insn, Op1, Op2, Op3);
194+
if (S == MCDisassembler::Success) {
195+
DecodeGRRegsRegisterClass(Inst, Op1, Address, Decoder);
196+
DecodeGRRegsRegisterClass(Inst, Op2, Address, Decoder);
197+
DecodeBitpOperand(Inst, Op3, Address, Decoder);
198+
}
199+
return S;
200+
}
201+
202+
static DecodeStatus DecodeL3RInstruction(MCInst &Inst, unsigned Insn,
203+
uint64_t Address,
204+
const MCDisassembler *Decoder) {
205+
unsigned Op1, Op2, Op3;
206+
DecodeStatus S =
207+
Decode3OpInstruction(fieldFromInstruction(Insn, 0, 16), Op1, Op2, Op3);
208+
if (S == MCDisassembler::Success) {
209+
DecodeGRRegsRegisterClass(Inst, Op1, Address, Decoder);
210+
DecodeGRRegsRegisterClass(Inst, Op2, Address, Decoder);
211+
DecodeGRRegsRegisterClass(Inst, Op3, Address, Decoder);
212+
}
213+
return S;
214+
}
215+
216+
static DecodeStatus DecodeL3RSrcDstInstruction(MCInst &Inst, unsigned Insn,
217+
uint64_t Address,
218+
const MCDisassembler *Decoder) {
219+
unsigned Op1, Op2, Op3;
220+
DecodeStatus S =
221+
Decode3OpInstruction(fieldFromInstruction(Insn, 0, 16), Op1, Op2, Op3);
222+
if (S == MCDisassembler::Success) {
223+
DecodeGRRegsRegisterClass(Inst, Op1, Address, Decoder);
224+
DecodeGRRegsRegisterClass(Inst, Op1, Address, Decoder);
225+
DecodeGRRegsRegisterClass(Inst, Op2, Address, Decoder);
226+
DecodeGRRegsRegisterClass(Inst, Op3, Address, Decoder);
227+
}
228+
return S;
229+
}
230+
231+
static DecodeStatus DecodeL2RUSInstruction(MCInst &Inst, unsigned Insn,
232+
uint64_t Address,
233+
const MCDisassembler *Decoder) {
234+
unsigned Op1, Op2, Op3;
235+
DecodeStatus S =
236+
Decode3OpInstruction(fieldFromInstruction(Insn, 0, 16), Op1, Op2, Op3);
237+
if (S == MCDisassembler::Success) {
238+
DecodeGRRegsRegisterClass(Inst, Op1, Address, Decoder);
239+
DecodeGRRegsRegisterClass(Inst, Op2, Address, Decoder);
240+
Inst.addOperand(MCOperand::createImm(Op3));
241+
}
242+
return S;
243+
}
244+
245+
static DecodeStatus DecodeL2RUSBitpInstruction(MCInst &Inst, unsigned Insn,
246+
uint64_t Address,
247+
const MCDisassembler *Decoder) {
248+
unsigned Op1, Op2, Op3;
249+
DecodeStatus S =
250+
Decode3OpInstruction(fieldFromInstruction(Insn, 0, 16), Op1, Op2, Op3);
251+
if (S == MCDisassembler::Success) {
252+
DecodeGRRegsRegisterClass(Inst, Op1, Address, Decoder);
253+
DecodeGRRegsRegisterClass(Inst, Op2, Address, Decoder);
254+
DecodeBitpOperand(Inst, Op3, Address, Decoder);
255+
}
256+
return S;
257+
}
258+
259+
181260
static DecodeStatus Decode2OpInstructionFail(MCInst &Inst, unsigned Insn,
182261
uint64_t Address,
183262
const MCDisassembler *Decoder) {
@@ -440,115 +519,6 @@ static DecodeStatus DecodeLR2RInstruction(MCInst &Inst, unsigned Insn,
440519
return S;
441520
}
442521

443-
static DecodeStatus Decode3RInstruction(MCInst &Inst, unsigned Insn,
444-
uint64_t Address,
445-
const MCDisassembler *Decoder) {
446-
unsigned Op1, Op2, Op3;
447-
DecodeStatus S = Decode3OpInstruction(Insn, Op1, Op2, Op3);
448-
if (S == MCDisassembler::Success) {
449-
DecodeGRRegsRegisterClass(Inst, Op1, Address, Decoder);
450-
DecodeGRRegsRegisterClass(Inst, Op2, Address, Decoder);
451-
DecodeGRRegsRegisterClass(Inst, Op3, Address, Decoder);
452-
}
453-
return S;
454-
}
455-
456-
static DecodeStatus Decode3RImmInstruction(MCInst &Inst, unsigned Insn,
457-
uint64_t Address,
458-
const MCDisassembler *Decoder) {
459-
unsigned Op1, Op2, Op3;
460-
DecodeStatus S = Decode3OpInstruction(Insn, Op1, Op2, Op3);
461-
if (S == MCDisassembler::Success) {
462-
Inst.addOperand(MCOperand::createImm(Op1));
463-
DecodeGRRegsRegisterClass(Inst, Op2, Address, Decoder);
464-
DecodeGRRegsRegisterClass(Inst, Op3, Address, Decoder);
465-
}
466-
return S;
467-
}
468-
469-
static DecodeStatus Decode2RUSInstruction(MCInst &Inst, unsigned Insn,
470-
uint64_t Address,
471-
const MCDisassembler *Decoder) {
472-
unsigned Op1, Op2, Op3;
473-
DecodeStatus S = Decode3OpInstruction(Insn, Op1, Op2, Op3);
474-
if (S == MCDisassembler::Success) {
475-
DecodeGRRegsRegisterClass(Inst, Op1, Address, Decoder);
476-
DecodeGRRegsRegisterClass(Inst, Op2, Address, Decoder);
477-
Inst.addOperand(MCOperand::createImm(Op3));
478-
}
479-
return S;
480-
}
481-
482-
static DecodeStatus Decode2RUSBitpInstruction(MCInst &Inst, unsigned Insn,
483-
uint64_t Address,
484-
const MCDisassembler *Decoder) {
485-
unsigned Op1, Op2, Op3;
486-
DecodeStatus S = Decode3OpInstruction(Insn, Op1, Op2, Op3);
487-
if (S == MCDisassembler::Success) {
488-
DecodeGRRegsRegisterClass(Inst, Op1, Address, Decoder);
489-
DecodeGRRegsRegisterClass(Inst, Op2, Address, Decoder);
490-
DecodeBitpOperand(Inst, Op3, Address, Decoder);
491-
}
492-
return S;
493-
}
494-
495-
static DecodeStatus DecodeL3RInstruction(MCInst &Inst, unsigned Insn,
496-
uint64_t Address,
497-
const MCDisassembler *Decoder) {
498-
unsigned Op1, Op2, Op3;
499-
DecodeStatus S =
500-
Decode3OpInstruction(fieldFromInstruction(Insn, 0, 16), Op1, Op2, Op3);
501-
if (S == MCDisassembler::Success) {
502-
DecodeGRRegsRegisterClass(Inst, Op1, Address, Decoder);
503-
DecodeGRRegsRegisterClass(Inst, Op2, Address, Decoder);
504-
DecodeGRRegsRegisterClass(Inst, Op3, Address, Decoder);
505-
}
506-
return S;
507-
}
508-
509-
static DecodeStatus DecodeL3RSrcDstInstruction(MCInst &Inst, unsigned Insn,
510-
uint64_t Address,
511-
const MCDisassembler *Decoder) {
512-
unsigned Op1, Op2, Op3;
513-
DecodeStatus S =
514-
Decode3OpInstruction(fieldFromInstruction(Insn, 0, 16), Op1, Op2, Op3);
515-
if (S == MCDisassembler::Success) {
516-
DecodeGRRegsRegisterClass(Inst, Op1, Address, Decoder);
517-
DecodeGRRegsRegisterClass(Inst, Op1, Address, Decoder);
518-
DecodeGRRegsRegisterClass(Inst, Op2, Address, Decoder);
519-
DecodeGRRegsRegisterClass(Inst, Op3, Address, Decoder);
520-
}
521-
return S;
522-
}
523-
524-
static DecodeStatus DecodeL2RUSInstruction(MCInst &Inst, unsigned Insn,
525-
uint64_t Address,
526-
const MCDisassembler *Decoder) {
527-
unsigned Op1, Op2, Op3;
528-
DecodeStatus S =
529-
Decode3OpInstruction(fieldFromInstruction(Insn, 0, 16), Op1, Op2, Op3);
530-
if (S == MCDisassembler::Success) {
531-
DecodeGRRegsRegisterClass(Inst, Op1, Address, Decoder);
532-
DecodeGRRegsRegisterClass(Inst, Op2, Address, Decoder);
533-
Inst.addOperand(MCOperand::createImm(Op3));
534-
}
535-
return S;
536-
}
537-
538-
static DecodeStatus DecodeL2RUSBitpInstruction(MCInst &Inst, unsigned Insn,
539-
uint64_t Address,
540-
const MCDisassembler *Decoder) {
541-
unsigned Op1, Op2, Op3;
542-
DecodeStatus S =
543-
Decode3OpInstruction(fieldFromInstruction(Insn, 0, 16), Op1, Op2, Op3);
544-
if (S == MCDisassembler::Success) {
545-
DecodeGRRegsRegisterClass(Inst, Op1, Address, Decoder);
546-
DecodeGRRegsRegisterClass(Inst, Op2, Address, Decoder);
547-
DecodeBitpOperand(Inst, Op3, Address, Decoder);
548-
}
549-
return S;
550-
}
551-
552522
static DecodeStatus DecodeL6RInstruction(MCInst &Inst, unsigned Insn,
553523
uint64_t Address,
554524
const MCDisassembler *Decoder) {

0 commit comments

Comments
 (0)