24 #define DEBUG_TYPE "sparc-disassembler" 35 virtual ~SparcDisassembler() {}
46 return new SparcDisassembler(STI, Ctx);
61 SP::G0, SP::G1, SP::G2, SP::G3,
62 SP::G4, SP::G5, SP::G6, SP::G7,
63 SP::O0, SP::O1, SP::O2, SP::O3,
64 SP::O4, SP::O5, SP::O6, SP::O7,
65 SP::L0, SP::L1, SP::L2, SP::L3,
66 SP::L4, SP::L5, SP::L6, SP::L7,
67 SP::I0, SP::I1, SP::I2, SP::I3,
68 SP::I4, SP::I5, SP::I6, SP::I7 };
71 SP::F0, SP::F1, SP::F2, SP::F3,
72 SP::F4, SP::F5, SP::F6, SP::F7,
73 SP::F8, SP::F9, SP::F10, SP::F11,
74 SP::F12, SP::F13, SP::F14, SP::F15,
75 SP::F16, SP::F17, SP::F18, SP::F19,
76 SP::F20, SP::F21, SP::F22, SP::F23,
77 SP::F24, SP::F25, SP::F26, SP::F27,
78 SP::F28, SP::F29, SP::F30, SP::F31 };
81 SP::D0, SP::D16, SP::D1, SP::D17,
82 SP::D2, SP::D18, SP::D3, SP::D19,
83 SP::D4, SP::D20, SP::D5, SP::D21,
84 SP::D6, SP::D22, SP::D7, SP::D23,
85 SP::D8, SP::D24, SP::D9, SP::D25,
86 SP::D10, SP::D26, SP::D11, SP::D27,
87 SP::D12, SP::D28, SP::D13, SP::D29,
88 SP::D14, SP::D30, SP::D15, SP::D31 };
91 SP::Q0, SP::Q8, ~0U, ~0U,
92 SP::Q1, SP::Q9, ~0U, ~0U,
93 SP::Q2, SP::Q10, ~0U, ~0U,
94 SP::Q3, SP::Q11, ~0U, ~0U,
95 SP::Q4, SP::Q12, ~0U, ~0U,
96 SP::Q5, SP::Q13, ~0U, ~0U,
97 SP::Q6, SP::Q14, ~0U, ~0U,
98 SP::Q7, SP::Q15, ~0U, ~0U } ;
101 SP::FCC0, SP::FCC1, SP::FCC2, SP::FCC3 };
104 SP::Y, SP::ASR1, SP::ASR2, SP::ASR3,
105 SP::ASR4, SP::ASR5, SP::ASR6, SP::ASR7,
106 SP::ASR8, SP::ASR9, SP::ASR10, SP::ASR11,
107 SP::ASR12, SP::ASR13, SP::ASR14, SP::ASR15,
108 SP::ASR16, SP::ASR17, SP::ASR18, SP::ASR19,
109 SP::ASR20, SP::ASR21, SP::ASR22, SP::ASR23,
110 SP::ASR24, SP::ASR25, SP::ASR26, SP::ASR27,
111 SP::ASR28, SP::ASR29, SP::ASR30, SP::ASR31};
114 SP::TPC, SP::TNPC, SP::TSTATE,
SP::TT, SP::TICK, SP::TBA, SP::PSTATE,
115 SP::TL, SP::PIL, SP::CWP, SP::CANSAVE, SP::CANRESTORE, SP::CLEANWIN,
116 SP::OTHERWIN, SP::WSTATE
120 SP::G0_G1, SP::G2_G3, SP::G4_G5, SP::G6_G7,
121 SP::O0_O1, SP::O2_O3, SP::O4_O5, SP::O6_O7,
122 SP::L0_L1, SP::L2_L3, SP::L4_L5, SP::L6_L7,
123 SP::I0_I1, SP::I2_I3, SP::I4_I5, SP::I6_I7,
127 SP::C0, SP::C1, SP::C2, SP::C3,
128 SP::C4, SP::C5, SP::C6, SP::C7,
129 SP::C8, SP::C9, SP::C10, SP::C11,
130 SP::C12, SP::C13, SP::C14, SP::C15,
131 SP::C16, SP::C17, SP::C18, SP::C19,
132 SP::C20, SP::C21, SP::C22, SP::C23,
133 SP::C24, SP::C25, SP::C26, SP::C27,
134 SP::C28, SP::C29, SP::C30, SP::C31
139 SP::C0_C1, SP::C2_C3, SP::C4_C5, SP::C6_C7,
140 SP::C8_C9, SP::C10_C11, SP::C12_C13, SP::C14_C15,
141 SP::C16_C17, SP::C18_C19, SP::C20_C21, SP::C22_C23,
142 SP::C24_C25, SP::C26_C27, SP::C28_C29, SP::C30_C31
148 const void *Decoder) {
151 unsigned Reg = IntRegDecoderTable[RegNo];
159 const void *Decoder) {
162 unsigned Reg = IntRegDecoderTable[RegNo];
171 const void *Decoder) {
174 unsigned Reg = FPRegDecoderTable[RegNo];
183 const void *Decoder) {
186 unsigned Reg = DFPRegDecoderTable[RegNo];
195 const void *Decoder) {
199 unsigned Reg = QFPRegDecoderTable[RegNo];
209 const void *Decoder) {
212 unsigned Reg = CPRegDecoderTable[RegNo];
219 const void *Decoder) {
228 const void *Decoder) {
237 const void *Decoder) {
245 uint64_t
Address,
const void *Decoder) {
254 unsigned RegisterPair = IntPairDecoderTable[RegNo/2];
260 uint64_t
Address,
const void *Decoder) {
264 unsigned RegisterPair = CPPairDecoderTable[RegNo/2];
270 const void *Decoder);
272 const void *Decoder);
274 const void *Decoder);
276 const void *Decoder);
278 const void *Decoder);
280 const void *Decoder);
282 const void *Decoder);
284 uint64_t
Address,
const void *Decoder);
286 uint64_t
Address,
const void *Decoder);
288 uint64_t
Address,
const void *Decoder);
290 uint64_t
Address,
const void *Decoder);
292 uint64_t
Address,
const void *Decoder);
294 uint64_t
Address,
const void *Decoder);
296 uint64_t
Address,
const void *Decoder);
298 uint64_t
Address,
const void *Decoder);
300 uint64_t
Address,
const void *Decoder);
302 const void *Decoder);
304 const void *Decoder);
306 const void *Decoder);
308 const void *Decoder);
310 #include "SparcGenDisassemblerTables.inc" 315 bool IsLittleEndian) {
317 if (Bytes.
size() < 4) {
322 Insn = IsLittleEndian
323 ? (Bytes[0] << 0) | (Bytes[1] << 8) | (Bytes[2] << 16) |
325 : (Bytes[3] << 0) | (Bytes[2] << 8) | (Bytes[1] << 16) |
336 bool isLittleEndian = getContext().getAsmInfo()->isLittleEndian();
344 if (STI.getFeatureBits()[Sparc::FeatureV9])
346 Result = decodeInstruction(DecoderTableSparcV932, Instr, Insn,
Address,
this, STI);
350 Result = decodeInstruction(DecoderTableSparcV832, Instr, Insn,
Address,
this, STI);
356 decodeInstruction(DecoderTableSparc32, Instr, Insn,
Address,
this, STI);
368 const void *Decoder);
373 unsigned rd = fieldFromInstruction(insn, 25, 5);
374 unsigned rs1 = fieldFromInstruction(insn, 14, 5);
375 bool isImm = fieldFromInstruction(insn, 13, 1);
376 bool hasAsi = fieldFromInstruction(insn, 23, 1);
377 unsigned asi = fieldFromInstruction(insn, 5, 8);
381 simm13 = SignExtend32<13>(fieldFromInstruction(insn, 0, 13));
383 rs2 = fieldFromInstruction(insn, 0, 5);
387 status = DecodeRD(MI, rd, Address, Decoder);
410 status = DecodeRD(MI, rd, Address, Decoder);
418 const void *Decoder) {
419 return DecodeMem(Inst, insn, Address, Decoder,
true,
424 const void *Decoder) {
425 return DecodeMem(Inst, insn, Address, Decoder,
true,
430 const void *Decoder) {
431 return DecodeMem(Inst, insn, Address, Decoder,
true,
436 const void *Decoder) {
437 return DecodeMem(Inst, insn, Address, Decoder,
true,
442 const void *Decoder) {
443 return DecodeMem(Inst, insn, Address, Decoder,
true,
448 const void *Decoder) {
449 return DecodeMem(Inst, insn, Address, Decoder,
true,
454 const void *Decoder) {
455 return DecodeMem(Inst, insn, Address, Decoder,
true,
460 uint64_t
Address,
const void *Decoder) {
461 return DecodeMem(Inst, insn, Address, Decoder,
false,
466 uint64_t
Address,
const void *Decoder) {
467 return DecodeMem(Inst, insn, Address, Decoder,
false,
472 const void *Decoder) {
473 return DecodeMem(Inst, insn, Address, Decoder,
false,
478 uint64_t
Address,
const void *Decoder) {
479 return DecodeMem(Inst, insn, Address, Decoder,
false,
484 uint64_t
Address,
const void *Decoder) {
485 return DecodeMem(Inst, insn, Address, Decoder,
false,
490 uint64_t
Address,
const void *Decoder) {
491 return DecodeMem(Inst, insn, Address, Decoder,
false,
496 uint64_t
Address,
const void *Decoder) {
497 return DecodeMem(Inst, insn, Address, Decoder,
false,
504 const void *Decoder) {
511 uint64_t
Address,
const void *Decoder) {
512 unsigned tgt = fieldFromInstruction(insn, 0, 30);
521 uint64_t
Address,
const void *Decoder) {
522 unsigned tgt = SignExtend32<13>(fieldFromInstruction(insn, 0, 13));
528 const void *Decoder) {
530 unsigned rd = fieldFromInstruction(insn, 25, 5);
531 unsigned rs1 = fieldFromInstruction(insn, 14, 5);
532 unsigned isImm = fieldFromInstruction(insn, 13, 1);
536 simm13 = SignExtend32<13>(fieldFromInstruction(insn, 0, 13));
538 rs2 = fieldFromInstruction(insn, 0, 5);
562 const void *Decoder) {
564 unsigned rs1 = fieldFromInstruction(insn, 14, 5);
565 unsigned isImm = fieldFromInstruction(insn, 13, 1);
569 simm13 = SignExtend32<13>(fieldFromInstruction(insn, 0, 13));
571 rs2 = fieldFromInstruction(insn, 0, 5);
590 const void *Decoder) {
592 unsigned rd = fieldFromInstruction(insn, 25, 5);
593 unsigned rs1 = fieldFromInstruction(insn, 14, 5);
594 unsigned isImm = fieldFromInstruction(insn, 13, 1);
595 bool hasAsi = fieldFromInstruction(insn, 23, 1);
596 unsigned asi = fieldFromInstruction(insn, 5, 8);
600 simm13 = SignExtend32<13>(fieldFromInstruction(insn, 0, 13));
602 rs2 = fieldFromInstruction(insn, 0, 5);
630 const void *Decoder) {
632 unsigned rs1 = fieldFromInstruction(insn, 14, 5);
633 unsigned isImm = fieldFromInstruction(insn, 13, 1);
634 unsigned cc =fieldFromInstruction(insn, 25, 4);
638 imm7 = fieldFromInstruction(insn, 0, 7);
640 rs2 = fieldFromInstruction(insn, 0, 5);
static DecodeStatus DecodeStoreCP(MCInst &Inst, unsigned insn, uint64_t Address, const void *Decoder)
static DecodeStatus DecodeLoadInt(MCInst &Inst, unsigned insn, uint64_t Address, const void *Decoder)
static DecodeStatus DecodeMem(MCInst &MI, unsigned insn, uint64_t Address, const void *Decoder, bool isLoad, DecodeFunc DecodeRD)
This class represents lattice values for constants.
DecodeStatus
Ternary decode status.
static DecodeStatus DecodeLoadDFP(MCInst &Inst, unsigned insn, uint64_t Address, const void *Decoder)
static DecodeStatus DecodeCPPairRegisterClass(MCInst &Inst, unsigned RegNo, uint64_t Address, const void *Decoder)
Superclass for all disassemblers.
bool tryAddingSymbolicOperand(MCInst &Inst, int64_t Value, uint64_t Address, bool IsBranch, uint64_t Offset, uint64_t InstSize) const
static const uint16_t IntPairDecoderTable[]
static DecodeStatus DecodeStoreFP(MCInst &Inst, unsigned insn, uint64_t Address, const void *Decoder)
static void RegisterMCDisassembler(Target &T, Target::MCDisassemblerCtorTy Fn)
RegisterMCDisassembler - Register a MCDisassembler implementation for the given target.
LLVM_EXTERNAL_VISIBILITY void LLVMInitializeSparcDisassembler()
static DecodeStatus DecodeDFPRegsRegisterClass(MCInst &Inst, unsigned RegNo, uint64_t Address, const void *Decoder)
static DecodeStatus DecodeStoreCPPair(MCInst &Inst, unsigned insn, uint64_t Address, const void *Decoder)
static GCMetadataPrinterRegistry::Add< OcamlGCMetadataPrinter > Y("ocaml", "ocaml 3.10-compatible collector")
static DecodeStatus DecodeLoadIntPair(MCInst &Inst, unsigned insn, uint64_t Address, const void *Decoder)
static DecodeStatus DecodeStoreInt(MCInst &Inst, unsigned insn, uint64_t Address, const void *Decoder)
static DecodeStatus DecodeStoreDFP(MCInst &Inst, unsigned insn, uint64_t Address, const void *Decoder)
static MCOperand createReg(unsigned Reg)
static DecodeStatus DecodeFPRegsRegisterClass(MCInst &Inst, unsigned RegNo, uint64_t Address, const void *Decoder)
MCDisassembler::DecodeStatus DecodeStatus
static const uint16_t CPPairDecoderTable[]
static bool isLoad(int Opcode)
static DecodeStatus DecodeLoadFP(MCInst &Inst, unsigned insn, uint64_t Address, const void *Decoder)
Context object for machine code objects.
Target & getTheSparcTarget()
static DecodeStatus readInstruction32(ArrayRef< uint8_t > Bytes, uint64_t Address, uint64_t &Size, uint32_t &Insn, bool IsLittleEndian)
Read four bytes from the ArrayRef and return 32 bit word.
Instances of this class represent a single low-level machine instruction.
static DecodeStatus DecodeTRAP(MCInst &Inst, unsigned insn, uint64_t Address, const void *Decoder)
static DecodeStatus DecodeASRRegsRegisterClass(MCInst &Inst, unsigned RegNo, uint64_t Address, const void *Decoder)
static DecodeStatus DecodeLoadCPPair(MCInst &Inst, unsigned insn, uint64_t Address, const void *Decoder)
static DecodeStatus DecodeLoadCP(MCInst &Inst, unsigned insn, uint64_t Address, const void *Decoder)
std::error_code status(const Twine &path, file_status &result, bool follow=true)
Get file status as if by POSIX stat().
size_t size() const
size - Get the array size.
static DecodeStatus DecodeCPRegsRegisterClass(MCInst &Inst, unsigned RegNo, uint64_t Address, const void *Decoder)
Target & getTheSparcelTarget()
static DecodeStatus DecodeQFPRegsRegisterClass(MCInst &Inst, unsigned RegNo, uint64_t Address, const void *Decoder)
static DecodeStatus DecodeSIMM13(MCInst &Inst, unsigned insn, uint64_t Address, const void *Decoder)
static const unsigned FCCRegDecoderTable[]
static DecodeStatus DecodeCall(MCInst &Inst, unsigned insn, uint64_t Address, const void *Decoder)
static DecodeStatus DecodeReturn(MCInst &MI, unsigned insn, uint64_t Address, const void *Decoder)
static const unsigned IntRegDecoderTable[]
static DecodeStatus DecodeStoreIntPair(MCInst &Inst, unsigned insn, uint64_t Address, const void *Decoder)
static const unsigned FPRegDecoderTable[]
static const unsigned CPRegDecoderTable[]
DecodeStatus(* DecodeFunc)(MCInst &MI, unsigned insn, uint64_t Address, const void *Decoder)
static DecodeStatus DecodeSWAP(MCInst &Inst, unsigned insn, uint64_t Address, const void *Decoder)
constexpr size_t array_lengthof(T(&)[N])
Find the length of an array.
static DecodeStatus DecodeI64RegsRegisterClass(MCInst &Inst, unsigned RegNo, uint64_t Address, const void *Decoder)
#define LLVM_EXTERNAL_VISIBILITY
static const unsigned ASRRegDecoderTable[]
static DecodeStatus DecodeLoadQFP(MCInst &Inst, unsigned insn, uint64_t Address, const void *Decoder)
static const unsigned DFPRegDecoderTable[]
Target - Wrapper for Target specific information.
static DecodeStatus DecodeIntRegsRegisterClass(MCInst &Inst, unsigned RegNo, uint64_t Address, const void *Decoder)
Target & getTheSparcV9Target()
static DecodeStatus DecodePRRegsRegisterClass(MCInst &Inst, unsigned RegNo, uint64_t Address, const void *Decoder)
static DecodeStatus DecodeStoreQFP(MCInst &Inst, unsigned insn, uint64_t Address, const void *Decoder)
static DecodeStatus DecodeJMPL(MCInst &Inst, unsigned insn, uint64_t Address, const void *Decoder)
static bool tryAddingSymbolicOperand(int64_t Value, bool isBranch, uint64_t Address, uint64_t Offset, uint64_t Width, MCInst &MI, const void *Decoder)
static const unsigned QFPRegDecoderTable[]
Generic base class for all target subtargets.
static DecodeStatus DecodeFCCRegsRegisterClass(MCInst &Inst, unsigned RegNo, uint64_t Address, const void *Decoder)
static const unsigned PRRegDecoderTable[]
static bool isBranch(unsigned Opcode)
LLVM Value Representation.
static DecodeStatus DecodeIntPairRegisterClass(MCInst &Inst, unsigned RegNo, uint64_t Address, const void *Decoder)
static MCDisassembler * createSparcDisassembler(const Target &T, const MCSubtargetInfo &STI, MCContext &Ctx)
This class implements an extremely fast bulk output stream that can only output to a stream...
void addOperand(const MCOperand &Op)
static MCOperand createImm(int64_t Val)