@@ -263,7 +263,10 @@ static DecodeStatus DecodeCall(MCInst &Inst, unsigned insn, uint64_t Address,
263263 const MCDisassembler *Decoder);
264264static DecodeStatus DecodeSIMM13 (MCInst &Inst, unsigned insn, uint64_t Address,
265265 const MCDisassembler *Decoder);
266-
266+ template <unsigned N>
267+ constexpr static DecodeStatus DecodeDisp (MCInst &MI, uint32_t ImmVal,
268+ uint64_t Address,
269+ const MCDisassembler *Decoder);
267270#include " SparcGenDisassemblerTables.inc"
268271
269272// / Read four bytes from the ArrayRef and return 32 bit word.
@@ -326,11 +329,10 @@ static bool tryAddingSymbolicOperand(int64_t Value, bool isBranch,
326329
327330static DecodeStatus DecodeCall (MCInst &MI, unsigned insn, uint64_t Address,
328331 const MCDisassembler *Decoder) {
329- unsigned tgt = fieldFromInstruction (insn, 0 , 30 );
330- tgt <<= 2 ;
331- if (!tryAddingSymbolicOperand (tgt+Address, false , Address,
332- 0 , 30 , MI, Decoder))
333- MI.addOperand (MCOperand::createImm (tgt));
332+ int64_t CallOffset = SignExtend64 (fieldFromInstruction (insn, 0 , 30 ), 30 ) * 4 ;
333+ if (!tryAddingSymbolicOperand (Address + CallOffset, false , Address, 0 , 30 , MI,
334+ Decoder))
335+ MI.addOperand (MCOperand::createImm (CallOffset));
334336 return MCDisassembler::Success;
335337}
336338
@@ -340,3 +342,14 @@ static DecodeStatus DecodeSIMM13(MCInst &MI, unsigned insn, uint64_t Address,
340342 MI.addOperand (MCOperand::createImm (SignExtend64<13 >(insn)));
341343 return MCDisassembler::Success;
342344}
345+
346+ template <unsigned N>
347+ constexpr static DecodeStatus DecodeDisp (MCInst &MI, uint32_t ImmVal,
348+ uint64_t Address,
349+ const MCDisassembler *Decoder) {
350+ int64_t BranchOffset = SignExtend64 (ImmVal, N) * 4 ;
351+ if (!tryAddingSymbolicOperand (Address + BranchOffset, true , Address, 0 , N, MI,
352+ Decoder))
353+ MI.addOperand (MCOperand::createImm (BranchOffset));
354+ return MCDisassembler::Success;
355+ }
0 commit comments