@@ -97,41 +97,6 @@ static DecodeStatus DecodeZREGRegisterClass(MCInst &Inst,
9797 return MCDisassembler::Success;
9898}
9999
100- static DecodeStatus decodeFIOARr (MCInst &Inst, unsigned Insn, uint64_t Address,
101- const MCDisassembler *Decoder) {
102- unsigned addr = 0 ;
103- addr |= fieldFromInstruction (Insn, 0 , 4 );
104- addr |= fieldFromInstruction (Insn, 9 , 2 ) << 4 ;
105- unsigned reg = fieldFromInstruction (Insn, 4 , 5 );
106- Inst.addOperand (MCOperand::createImm (addr));
107- if (DecodeGPR8RegisterClass (Inst, reg, Address, Decoder) ==
108- MCDisassembler::Fail)
109- return MCDisassembler::Fail;
110- return MCDisassembler::Success;
111- }
112-
113- static DecodeStatus decodeFIORdA (MCInst &Inst, unsigned Insn, uint64_t Address,
114- const MCDisassembler *Decoder) {
115- unsigned addr = 0 ;
116- addr |= fieldFromInstruction (Insn, 0 , 4 );
117- addr |= fieldFromInstruction (Insn, 9 , 2 ) << 4 ;
118- unsigned reg = fieldFromInstruction (Insn, 4 , 5 );
119- if (DecodeGPR8RegisterClass (Inst, reg, Address, Decoder) ==
120- MCDisassembler::Fail)
121- return MCDisassembler::Fail;
122- Inst.addOperand (MCOperand::createImm (addr));
123- return MCDisassembler::Success;
124- }
125-
126- static DecodeStatus decodeFIOBIT (MCInst &Inst, unsigned Insn, uint64_t Address,
127- const MCDisassembler *Decoder) {
128- unsigned addr = fieldFromInstruction (Insn, 3 , 5 );
129- unsigned b = fieldFromInstruction (Insn, 0 , 3 );
130- Inst.addOperand (MCOperand::createImm (addr));
131- Inst.addOperand (MCOperand::createImm (b));
132- return MCDisassembler::Success;
133- }
134-
135100static DecodeStatus decodeCallTarget (MCInst &Inst, unsigned Field,
136101 uint64_t Address,
137102 const MCDisassembler *Decoder) {
@@ -141,12 +106,19 @@ static DecodeStatus decodeCallTarget(MCInst &Inst, unsigned Field,
141106 return MCDisassembler::Success;
142107}
143108
144- static DecodeStatus decodeFRd (MCInst &Inst, unsigned Insn, uint64_t Address,
145- const MCDisassembler *Decoder) {
146- unsigned d = fieldFromInstruction (Insn, 4 , 5 );
147- if (DecodeGPR8RegisterClass (Inst, d, Address, Decoder) ==
148- MCDisassembler::Fail)
149- return MCDisassembler::Fail;
109+ static DecodeStatus decodeRelCondBrTarget7 (MCInst &Inst, unsigned Field,
110+ uint64_t Address,
111+ const MCDisassembler *Decoder) {
112+ // The legal range is [-128, 126] (in bytes).
113+ Inst.addOperand (MCOperand::createImm (SignExtend32 (Field, 7 ) << 1 ));
114+ return MCDisassembler::Success;
115+ }
116+
117+ static DecodeStatus decodeRelCondBrTarget13 (MCInst &Inst, unsigned Field,
118+ uint64_t Address,
119+ const MCDisassembler *Decoder) {
120+ // The legal range is [-4096, 4094] (in bytes).
121+ Inst.addOperand (MCOperand::createImm (SignExtend32 (Field, 12 ) << 1 ));
150122 return MCDisassembler::Success;
151123}
152124
@@ -225,59 +197,6 @@ static DecodeStatus decodeMemri(MCInst &Inst, unsigned Insn, uint64_t Address,
225197 return MCDisassembler::Success;
226198}
227199
228- static DecodeStatus decodeFBRk (MCInst &Inst, unsigned Insn, uint64_t Address,
229- const MCDisassembler *Decoder) {
230- // Decode the opcode.
231- switch (Insn & 0xf000 ) {
232- case 0xc000 :
233- Inst.setOpcode (AVR::RJMPk);
234- break ;
235- case 0xd000 :
236- Inst.setOpcode (AVR::RCALLk);
237- break ;
238- default : // Unknown relative branch instruction.
239- return MCDisassembler::Fail;
240- }
241- // Decode the relative offset.
242- int16_t Offset = ((int16_t )((Insn & 0xfff ) << 4 )) >> 3 ;
243- Inst.addOperand (MCOperand::createImm (Offset));
244- return MCDisassembler::Success;
245- }
246-
247- static DecodeStatus decodeCondBranch (MCInst &Inst, unsigned Insn,
248- uint64_t Address,
249- const MCDisassembler *Decoder) {
250- // These 8 instructions are not defined as aliases of BRBS/BRBC.
251- DenseMap<unsigned , unsigned > brInsts = {
252- {0x000 , AVR::BRLOk}, {0x400 , AVR::BRSHk}, {0x001 , AVR::BREQk},
253- {0x401 , AVR::BRNEk}, {0x002 , AVR::BRMIk}, {0x402 , AVR::BRPLk},
254- {0x004 , AVR::BRLTk}, {0x404 , AVR::BRGEk}};
255-
256- // Get the relative offset.
257- int16_t Offset = ((int16_t )((Insn & 0x3f8 ) << 6 )) >> 8 ;
258-
259- // Search the instruction pattern.
260- auto NotAlias = [&Insn](const std::pair<unsigned , unsigned > &I) {
261- return (Insn & 0x407 ) != I.first ;
262- };
263- llvm::partition (brInsts, NotAlias);
264- auto It = llvm::partition_point (brInsts, NotAlias);
265-
266- // Decode the instruction.
267- if (It != brInsts.end ()) {
268- // This instruction is not an alias of BRBC/BRBS.
269- Inst.setOpcode (It->second );
270- Inst.addOperand (MCOperand::createImm (Offset));
271- } else {
272- // Fall back to an ordinary BRBS/BRBC.
273- Inst.setOpcode (Insn & 0x400 ? AVR::BRBCsk : AVR::BRBSsk);
274- Inst.addOperand (MCOperand::createImm (Insn & 7 ));
275- Inst.addOperand (MCOperand::createImm (Offset));
276- }
277-
278- return MCDisassembler::Success;
279- }
280-
281200static DecodeStatus decodeLoadStore (MCInst &Inst, unsigned Insn,
282201 uint64_t Address,
283202 const MCDisassembler *Decoder) {
0 commit comments