47 const char *Features,
void *DisInfo,
int TagType,
62 std::unique_ptr<const MCAsmInfo> MAI(
71 std::unique_ptr<const MCSubtargetInfo> STI(
77 std::unique_ptr<MCContext> Ctx(
new MCContext(MAI.get(),
MRI.get(),
nullptr));
82 std::unique_ptr<MCDisassembler> DisAsm(
87 std::unique_ptr<MCRelocationInfo> RelInfo(
93 TT, GetOpInfo, SymbolLookUp, DisInfo, Ctx.get(), std::move(RelInfo)));
94 DisAsm->setSymbolizer(std::move(Symbolizer));
97 int AsmPrinterVariant = MAI->getAssemblerDialect();
99 Triple(TT), AsmPrinterVariant, *MAI, *MII, *
MRI));
104 TT, DisInfo, TagType, GetOpInfo, SymbolLookUp, TheTarget, std::move(MAI),
105 std::move(
MRI), std::move(STI), std::move(MII), std::move(Ctx),
106 std::move(DisAsm), std::move(IP));
148 while (!Comments.
empty()) {
154 FormattedOS << CommentBegin <<
' ' << Comments.
substr(0, Position);
156 Comments = Comments.
substr(Position+1);
170 const int NoInformationAvailable = -1;
174 return NoInformationAvailable;
184 for (
unsigned OpIdx = 0, OpIdxEnd = Inst.
getNumOperands(); OpIdx != OpIdxEnd;
198 const int NoInformationAvailable = -1;
213 return NoInformationAvailable;
218 DefIdx != DefEnd; ++DefIdx) {
253 uint64_t BytesSize, uint64_t PC,
char *OutString,
254 size_t OutStringSize){
287 assert(OutStringSize != 0 &&
"Output buffer cannot be zero size");
288 size_t OutputSize = std::min(OutStringSize-1, InsnStr.
size());
289 std::memcpy(OutString, InsnStr.
data(), OutputSize);
290 OutString[OutputSize] =
'\0';
307 DC->
addOptions(LLVMDisassembler_Option_UseMarkup);
308 Options &= ~LLVMDisassembler_Option_UseMarkup;
314 DC->
addOptions(LLVMDisassembler_Option_PrintImmHex);
315 Options &= ~LLVMDisassembler_Option_PrintImmHex;
324 AsmPrinterVariant = AsmPrinterVariant == 0 ? 1 : 0;
329 DC->
addOptions(LLVMDisassembler_Option_AsmPrinterVariant);
330 Options &= ~LLVMDisassembler_Option_AsmPrinterVariant;
337 DC->
addOptions(LLVMDisassembler_Option_SetInstrComments);
338 Options &= ~LLVMDisassembler_Option_SetInstrComments;
342 DC->
addOptions(LLVMDisassembler_Option_PrintLatency);
343 Options &= ~LLVMDisassembler_Option_PrintLatency;
345 return (Options == 0);
void setIP(MCInstPrinter *NewIP)
MCAsmInfo * createMCAsmInfo(const MCRegisterInfo &MRI, StringRef TheTriple, const MCTargetOptions &Options) const
createMCAsmInfo - Create a MCAsmInfo implementation for the specified target triple.
#define LLVMDisassembler_Option_SetInstrComments
This class represents lattice values for constants.
virtual DecodeStatus getInstruction(MCInst &Instr, uint64_t &Size, ArrayRef< uint8_t > Bytes, uint64_t Address, raw_ostream &CStream) const =0
Returns the disassembly of a single instruction.
DecodeStatus
Ternary decode status.
Superclass for all disassemblers.
Describe properties that are true of each instruction in the target description file.
MCInstrInfo * createMCInstrInfo() const
createMCInstrInfo - Create a MCInstrInfo implementation.
static void emitComments(LLVMDisasmContext *DC, formatted_raw_ostream &FormattedOS)
Emits the comments that are stored in DC comment stream.
void setPrintImmHex(bool Value)
A raw_ostream that writes to an SmallVector or SmallString.
MCDisassembler * createMCDisassembler(const MCSubtargetInfo &STI, MCContext &Ctx) const
#define LLVMDisassembler_Option_UseMarkup
const MCSchedClassDesc * getSchedClassDesc(unsigned SchedClassIdx) const
static const Target * lookupTarget(const std::string &Triple, std::string &Error)
lookupTarget - Lookup a target based on a target triple.
LLVMDisasmContextRef LLVMCreateDisasmCPU(const char *TT, const char *CPU, void *DisInfo, int TagType, LLVMOpInfoCallback GetOpInfo, LLVMSymbolLookupCallback SymbolLookUp)
Create a disassembler for the TripleName and a specific CPU.
static ManagedStatic< DebugCounter > DC
MCInstPrinter * createMCInstPrinter(const Triple &T, unsigned SyntaxVariant, const MCAsmInfo &MAI, const MCInstrInfo &MII, const MCRegisterInfo &MRI) const
static void emitLatency(LLVMDisasmContext *DC, const MCInst &Inst)
Emits latency information in DC->CommentStream for Inst, based on the information available in DC...
int(* LLVMOpInfoCallback)(void *DisInfo, uint64_t PC, uint64_t Offset, uint64_t Size, int TagType, void *TagBuf)
The type for the operand information call back function.
LLVM_NODISCARD StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
void * LLVMDisasmContextRef
An opaque reference to a disassembler context.
LLVM_NODISCARD bool empty() const
empty - Check if the string is empty.
Position
Position to insert a new instruction relative to an existing instruction.
const MCRegisterInfo * getRegisterInfo() const
StringRef str() const
Explicit conversion to StringRef.
Context object for machine code objects.
raw_svector_ostream CommentStream
const MCWriteLatencyEntry * getWriteLatencyEntry(const MCSchedClassDesc *SC, unsigned DefIdx) const
InstrItineraryData getInstrItineraryForCPU(StringRef CPU) const
Get scheduling itinerary of a CPU.
Itinerary data supplied by a subtarget to be used by a target.
static int getLatency(LLVMDisasmContext *DC, const MCInst &Inst)
Gets latency information for Inst, based on DC information.
Instances of this class represent a single low-level machine instruction.
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
This class is intended to be used as a base class for asm properties and features specific to the tar...
unsigned getSchedClass() const
Return the scheduling class for this instruction.
unsigned const MachineRegisterInfo * MRI
unsigned getAssemblerDialect() const
Summarize the scheduling resources required for an instruction of a particular scheduling class...
void setCommentStream(raw_ostream &OS)
Specify a stream to emit comments to.
#define LLVMDisassembler_Option_PrintImmHex
Interface to description of machine instruction set.
const MCSubtargetInfo * getSubtargetInfo() const
LLVM_NODISCARD size_t find(char C, size_t From=0) const
Search for the first character C in the string.
StringRef getCommentString() const
MCRegisterInfo * createMCRegInfo(StringRef TT) const
createMCRegInfo - Create a MCRegisterInfo implementation.
unsigned getNumOperands() const
static int getItineraryLatency(LLVMDisasmContext *DC, const MCInst &Inst)
Gets latency information for Inst from the itinerary scheduling model, based on DC information...
const MCInstrInfo * getInstrInfo() const
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Triple - Helper class for working with autoconf configuration names.
bool hasInstrSchedModel() const
Does this machine model include instruction-level scheduling.
Specify the latency in cpu cycles for a particular scheduling class and def index.
Align max(MaybeAlign Lhs, Align Rhs)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
const MCAsmInfo * getAsmInfo() const
StringRef str()
Return a StringRef for the vector contents.
const Target * getTarget() const
LLVMDisasmContextRef LLVMCreateDisasmCPUFeatures(const char *TT, const char *CPU, const char *Features, void *DisInfo, int TagType, LLVMOpInfoCallback GetOpInfo, LLVMSymbolLookupCallback SymbolLookUp)
Create a disassembler for the TripleName, a specific CPU and specific feature string.
Target - Wrapper for Target specific information.
void setUseMarkup(bool Value)
size_t LLVMDisasmInstruction(LLVMDisasmContextRef DCR, uint8_t *Bytes, uint64_t BytesSize, uint64_t PC, char *OutString, size_t OutStringSize)
Disassemble a single instruction using the disassembler context specified in the parameter DC...
int LLVMSetDisasmOptions(LLVMDisasmContextRef DCR, uint64_t Options)
Set the disassembler's options.
MCSubtargetInfo * createMCSubtargetInfo(StringRef TheTriple, StringRef CPU, StringRef Features) const
createMCSubtargetInfo - Create a MCSubtargetInfo implementation.
#define LLVMDisassembler_Option_AsmPrinterVariant
virtual void printInst(const MCInst *MI, uint64_t Address, StringRef Annot, const MCSubtargetInfo &STI, raw_ostream &OS)=0
Print the specified MCInst to the specified raw_ostream.
This is an instance of a target assembly language printer that converts an MCInst to valid target ass...
pointer data()
Return a pointer to the vector's buffer, even if empty().
uint64_t getOptions() const
const MCInstrDesc & get(unsigned Opcode) const
Return the machine instruction descriptor that corresponds to the specified instruction opcode...
void LLVMDisasmDispose(LLVMDisasmContextRef DCR)
Dispose of a disassembler context.
Generic base class for all target subtargets.
LLVMDisasmContextRef LLVMCreateDisasm(const char *TT, void *DisInfo, int TagType, LLVMOpInfoCallback GetOpInfo, LLVMSymbolLookupCallback SymbolLookUp)
Create a disassembler for the TripleName.
MCSymbolizer * createMCSymbolizer(StringRef TT, LLVMOpInfoCallback GetOpInfo, LLVMSymbolLookupCallback SymbolLookUp, void *DisInfo, MCContext *Ctx, std::unique_ptr< MCRelocationInfo > &&RelInfo) const
createMCSymbolizer - Create a target specific MCSymbolizer.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
unsigned getCommentColumn() const
This indicates the column (zero-based) at which asm comments should be printed.
MCRelocationInfo * createMCRelocationInfo(StringRef TT, MCContext &Ctx) const
createMCRelocationInfo - Create a target specific MCRelocationInfo.
Lightweight error class with error context and mandatory checking.
uint16_t NumWriteLatencyEntries
int getOperandCycle(unsigned ItinClassIndx, unsigned OperandIdx) const
Return the cycle for the given class and operand.
void addOptions(uint64_t Options)
void setCPU(const char *CPU)
const std::string & getTripleName() const
StringRef - Represent a constant reference to a string, i.e.
unsigned getOpcode() const
const MCDisassembler * getDisAsm() const
Annotations lets you mark points and ranges inside source code, for tests:
const char *(* LLVMSymbolLookupCallback)(void *DisInfo, uint64_t ReferenceValue, uint64_t *ReferenceType, uint64_t ReferencePC, const char **ReferenceName)
The type for the symbol lookup function.
SmallString< 128 > CommentsToEmit
Machine model for scheduling, bundling, and heuristics.
const MCSchedModel & getSchedModel() const
Get the machine model for this subtarget's CPU.
#define LLVMDisassembler_Option_PrintLatency