mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-25 16:24:23 +00:00
Thumb2 assembly parsing and encoding for LDRD(immediate).
Refactor operand handling for STRD as well. Tests for that forthcoming. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139322 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -293,6 +293,10 @@ static DecodeStatus DecodeThumbBLTargetOperand(llvm::MCInst &Inst, unsigned Val,
|
||||
uint64_t Address, const void *Decoder);
|
||||
static DecodeStatus DecodeIT(llvm::MCInst &Inst, unsigned Val,
|
||||
uint64_t Address, const void *Decoder);
|
||||
static DecodeStatus DecodeT2LDRDPreInstruction(llvm::MCInst &Inst,unsigned Insn,
|
||||
uint64_t Address, const void *Decoder);
|
||||
static DecodeStatus DecodeT2STRDPreInstruction(llvm::MCInst &Inst,unsigned Insn,
|
||||
uint64_t Address, const void *Decoder);
|
||||
|
||||
#include "ARMGenDisassemblerTables.inc"
|
||||
#include "ARMGenInstrInfo.inc"
|
||||
@ -3649,3 +3653,75 @@ static DecodeStatus DecodeIT(llvm::MCInst &Inst, unsigned Insn,
|
||||
Inst.addOperand(MCOperand::CreateImm(mask));
|
||||
return S;
|
||||
}
|
||||
|
||||
static DecodeStatus
|
||||
DecodeT2LDRDPreInstruction(llvm::MCInst &Inst, unsigned Insn,
|
||||
uint64_t Address, const void *Decoder) {
|
||||
DecodeStatus S = MCDisassembler::Success;
|
||||
|
||||
unsigned Rt = fieldFromInstruction32(Insn, 12, 4);
|
||||
unsigned Rt2 = fieldFromInstruction32(Insn, 8, 4);
|
||||
unsigned Rn = fieldFromInstruction32(Insn, 16, 4);
|
||||
unsigned addr = fieldFromInstruction32(Insn, 0, 8);
|
||||
unsigned W = fieldFromInstruction32(Insn, 21, 1);
|
||||
unsigned U = fieldFromInstruction32(Insn, 23, 1);
|
||||
unsigned P = fieldFromInstruction32(Insn, 24, 1);
|
||||
bool writeback = (W == 1) | (P == 0);
|
||||
|
||||
addr |= (U << 8) | (Rn << 9);
|
||||
|
||||
if (writeback && (Rn == Rt || Rn == Rt2))
|
||||
Check(S, MCDisassembler::SoftFail);
|
||||
if (Rt == Rt2)
|
||||
Check(S, MCDisassembler::SoftFail);
|
||||
|
||||
// Rt
|
||||
if (!Check(S, DecoderGPRRegisterClass(Inst, Rt, Address, Decoder)))
|
||||
return MCDisassembler::Fail;
|
||||
// Rt2
|
||||
if (!Check(S, DecoderGPRRegisterClass(Inst, Rt2, Address, Decoder)))
|
||||
return MCDisassembler::Fail;
|
||||
// Writeback operand
|
||||
if (!Check(S, DecoderGPRRegisterClass(Inst, Rn, Address, Decoder)))
|
||||
return MCDisassembler::Fail;
|
||||
// addr
|
||||
if (!Check(S, DecodeT2AddrModeImm8s4(Inst, addr, Address, Decoder)))
|
||||
return MCDisassembler::Fail;
|
||||
|
||||
return S;
|
||||
}
|
||||
|
||||
static DecodeStatus
|
||||
DecodeT2STRDPreInstruction(llvm::MCInst &Inst, unsigned Insn,
|
||||
uint64_t Address, const void *Decoder) {
|
||||
DecodeStatus S = MCDisassembler::Success;
|
||||
|
||||
unsigned Rt = fieldFromInstruction32(Insn, 12, 4);
|
||||
unsigned Rt2 = fieldFromInstruction32(Insn, 8, 4);
|
||||
unsigned Rn = fieldFromInstruction32(Insn, 16, 4);
|
||||
unsigned addr = fieldFromInstruction32(Insn, 0, 8);
|
||||
unsigned W = fieldFromInstruction32(Insn, 21, 1);
|
||||
unsigned U = fieldFromInstruction32(Insn, 23, 1);
|
||||
unsigned P = fieldFromInstruction32(Insn, 24, 1);
|
||||
bool writeback = (W == 1) | (P == 0);
|
||||
|
||||
addr |= (U << 8) | (Rn << 9);
|
||||
|
||||
if (writeback && (Rn == Rt || Rn == Rt2))
|
||||
Check(S, MCDisassembler::SoftFail);
|
||||
|
||||
// Writeback operand
|
||||
if (!Check(S, DecoderGPRRegisterClass(Inst, Rn, Address, Decoder)))
|
||||
return MCDisassembler::Fail;
|
||||
// Rt
|
||||
if (!Check(S, DecoderGPRRegisterClass(Inst, Rt, Address, Decoder)))
|
||||
return MCDisassembler::Fail;
|
||||
// Rt2
|
||||
if (!Check(S, DecoderGPRRegisterClass(Inst, Rt2, Address, Decoder)))
|
||||
return MCDisassembler::Fail;
|
||||
// addr
|
||||
if (!Check(S, DecodeT2AddrModeImm8s4(Inst, addr, Address, Decoder)))
|
||||
return MCDisassembler::Fail;
|
||||
|
||||
return S;
|
||||
}
|
||||
|
Reference in New Issue
Block a user