Please use GitHub pull requests for new patches. Avoid migrating existing patches. Phabricator shutdown timeline
Changeset View
Changeset View
Standalone View
Standalone View
llvm/lib/Target/ARC/Disassembler/ARCDisassembler.cpp
Show First 20 Lines • Show All 101 Lines • ▼ Show 20 Lines | static DecodeStatus DecodeLdLImmInstruction(MCInst &, uint64_t, uint64_t, | ||||
const void *); | const void *); | ||||
static DecodeStatus DecodeStLImmInstruction(MCInst &, uint64_t, uint64_t, | static DecodeStatus DecodeStLImmInstruction(MCInst &, uint64_t, uint64_t, | ||||
const void *); | const void *); | ||||
static DecodeStatus DecodeLdRLImmInstruction(MCInst &, uint64_t, uint64_t, | static DecodeStatus DecodeLdRLImmInstruction(MCInst &, uint64_t, uint64_t, | ||||
const void *); | const void *); | ||||
static DecodeStatus DecodeSOPwithRS12(MCInst &, uint64_t, uint64_t, | |||||
const void *); | |||||
static DecodeStatus DecodeSOPwithRU6(MCInst &, uint64_t, uint64_t, | |||||
const void *); | |||||
static DecodeStatus DecodeCCRU6Instruction(MCInst &, uint64_t, uint64_t, | static DecodeStatus DecodeCCRU6Instruction(MCInst &, uint64_t, uint64_t, | ||||
const void *); | const void *); | ||||
static DecodeStatus DecodeMoveHRegInstruction(MCInst &Inst, uint64_t, uint64_t, | static DecodeStatus DecodeMoveHRegInstruction(MCInst &Inst, uint64_t, uint64_t, | ||||
const void *); | const void *); | ||||
static const uint16_t GPR32DecoderTable[] = { | static const uint16_t GPR32DecoderTable[] = { | ||||
ARC::R0, ARC::R1, ARC::R2, ARC::R3, ARC::R4, ARC::R5, ARC::R6, | ARC::R0, ARC::R1, ARC::R2, ARC::R3, ARC::R4, ARC::R5, ARC::R6, | ||||
▲ Show 20 Lines • Show All 188 Lines • ▼ Show 20 Lines | static DecodeStatus DecodeCCRU6Instruction(MCInst &Inst, uint64_t Insn, | ||||
using Field = decltype(Insn); | using Field = decltype(Insn); | ||||
Field U6Field = fieldFromInstruction(Insn, 6, 6); | Field U6Field = fieldFromInstruction(Insn, 6, 6); | ||||
Inst.addOperand(MCOperand::createImm(U6Field)); | Inst.addOperand(MCOperand::createImm(U6Field)); | ||||
Field CCField = fieldFromInstruction(Insn, 0, 4); | Field CCField = fieldFromInstruction(Insn, 0, 4); | ||||
Inst.addOperand(MCOperand::createImm(CCField)); | Inst.addOperand(MCOperand::createImm(CCField)); | ||||
return MCDisassembler::Success; | return MCDisassembler::Success; | ||||
} | } | ||||
static DecodeStatus DecodeSOPwithRU6(MCInst &Inst, uint64_t Insn, | |||||
uint64_t Address, const void *Decoder) { | |||||
unsigned DstB = decodeBField(Insn); | |||||
DecodeGPR32RegisterClass(Inst, DstB, Address, Decoder); | |||||
using Field = decltype(Insn); | |||||
Field U6 = fieldFromInstruction(Insn, 6, 6); | |||||
thomasjohns: This aims to decode either form:
`...ssssssSSSSSS`
or
`...uuuuuu000000`
(S12 or U6). I assumed… | |||||
Not Done ReplyInline ActionsI'd rather see you use two separate functions: DecodeSOPwithRU6 and DecodeSOPwithRS12 marksl: I'd rather see you use two separate functions: DecodeSOPwithRU6 and DecodeSOPwithRS12 | |||||
Thanks, agreed that makes sense to me to separate them. thomasjohns: Thanks, agreed that makes sense to me to separate them. | |||||
Inst.addOperand(MCOperand::createImm(U6)); | |||||
return MCDisassembler::Success; | |||||
} | |||||
static DecodeStatus DecodeSOPwithRS12(MCInst &Inst, uint64_t Insn, | |||||
uint64_t Address, const void *Decoder) { | |||||
unsigned DstB = decodeBField(Insn); | |||||
DecodeGPR32RegisterClass(Inst, DstB, Address, Decoder); | |||||
using Field = decltype(Insn); | |||||
Field Lower = fieldFromInstruction(Insn, 6, 6); | |||||
Field Upper = fieldFromInstruction(Insn, 0, 5); | |||||
Field Sign = fieldFromInstruction(Insn, 5, 1) ? -1 : 1; | |||||
Field Result = Sign * ((Upper << 6) + Lower); | |||||
Inst.addOperand(MCOperand::createImm(Result)); | |||||
return MCDisassembler::Success; | |||||
} | |||||
DecodeStatus ARCDisassembler::getInstruction(MCInst &Instr, uint64_t &Size, | DecodeStatus ARCDisassembler::getInstruction(MCInst &Instr, uint64_t &Size, | ||||
ArrayRef<uint8_t> Bytes, | ArrayRef<uint8_t> Bytes, | ||||
uint64_t Address, | uint64_t Address, | ||||
raw_ostream &cStream) const { | raw_ostream &cStream) const { | ||||
MCDisassembler::DecodeStatus Result; | MCDisassembler::DecodeStatus Result; | ||||
if (Bytes.size() < 2) { | if (Bytes.size() < 2) { | ||||
Size = 0; | Size = 0; | ||||
return Fail; | return Fail; | ||||
▲ Show 20 Lines • Show All 67 Lines • Show Last 20 Lines |
This aims to decode either form:
...ssssssSSSSSS
or
...uuuuuu000000
(S12 or U6). I assumed the leading bit of the S12 marks the sign. Is this correct @marksl ?