10 #ifndef LLVM_MC_MCPARSER_MCTARGETASMPARSER_H 11 #define LLVM_MC_MCPARSER_MCTARGETASMPARSER_H 27 class MCParsedAsmOperand;
29 class MCSubtargetInfo;
30 template <
typename T>
class SmallVectorImpl;
69 IntelExpr(
bool needBracs =
false) : NeedBracs(needBracs), Imm(0),
79 bool needBracs =
true) :
87 int64_t imm = 0,
bool needBracs =
true) :
92 return BaseReg.
size();
95 return IndexReg.
size();
101 return (Scale == 1) ||
102 (
hasIndexReg() && (Scale == 2 || Scale == 4 || Scale == 8));
116 : Kind(kind), Loc(loc), Len(len), Val(val) {}
118 :
AsmRewrite(kind, loc, len) { Label = label; }
128 : AsmRewrites(rewrites) {}
208 Result.Kind = NearMissFeature;
218 Result.Kind = NearMissPredicate;
229 unsigned OperandClass,
unsigned Opcode,
230 unsigned OperandIndex) {
232 Result.Kind = NearMissOperand;
246 Result.Kind = NearMissTooFewOperands;
252 operator bool()
const {
return Kind != NoNearMiss; }
266 return PredicateError;
270 assert(
Kind == NearMissOperand ||
Kind == NearMissTooFewOperands);
271 return MissedOperand.Class;
275 assert(
Kind == NearMissOperand ||
Kind == NearMissTooFewOperands);
276 return MissedOperand.Opcode;
281 return MissedOperand.Error;
287 return MissedOperand.Index;
295 struct MissedOpInfo {
302 struct TooFewOperandsInfo {
327 FIRST_TARGET_MATCH_RESULT_TY
338 uint64_t AvailableFeatures = 0;
341 bool ParsingInlineAsm =
false;
372 SemaCallback = Callback;
377 return getParser().parsePrimaryExpr(Res, EndLoc);
380 virtual bool ParseRegister(
unsigned &RegNo,
SMLoc &StartLoc,
403 return ParseInstruction(Info, Name, Token.
getLoc(), Operands);
416 virtual bool ParseDirective(
AsmToken DirectiveID) = 0;
424 virtual bool MatchAndEmitInstruction(
SMLoc IDLoc,
unsigned &Opcode,
427 bool MatchingInlineAsm) = 0;
438 return Match_InvalidOperand;
445 return Match_Success;
451 return Match_Success;
454 virtual void convertToMapAndConstraints(
unsigned Kind,
500 #endif // LLVM_MC_MCPARSER_MCTARGETASMPARSER_H virtual bool isLabel(AsmToken &Token)
MCAsmParserSemaCallback * SemaCallback
SemaCallback - The Sema callback implementation.
This class represents lattice values for constants.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
virtual unsigned checkEarlyTargetMatchPredicate(MCInst &Inst, const OperandVector &Operands)
Validate the instruction match against any complex target predicates before rendering any operands to...
IntelExpr(StringRef reg, int64_t imm=0, unsigned scale=0, bool needBracs=true)
virtual bool regsEqual(const MCParsedAsmOperand &Op1, const MCParsedAsmOperand &Op2) const
Returns whether two registers are equal and is used by the tied-operands checks in the AsmMatcher...
MCTargetAsmParser - Generic interface to target specific assembly parsers.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE size_t size() const
size - Get the string size.
const MCSubtargetInfo * STI
Current STI.
const FeatureBitset Features
uint64_t getAvailableFeatures() const
static NearMissInfo getMissedOperand(unsigned OperandError, unsigned OperandClass, unsigned Opcode, unsigned OperandIndex)
ParseInstructionInfo(SmallVectorImpl< AsmRewrite > *rewrites)
virtual void onLabelParsed(MCSymbol *Symbol)
unsigned getOperandClass() const
AsmRewrite(AsmRewriteKind kind, SMLoc loc, unsigned len, StringRef label)
MCTargetOptions MCOptions
Set of options which affects instrumentation of inline assembly.
amdgpu Simplify well known AMD library false Value Value const Twine & Name
unsigned getOpcode() const
IntelExpr(StringRef baseReg, StringRef indexReg, unsigned scale=0, int64_t imm=0, bool needBracs=true)
virtual unsigned validateTargetOperandClass(MCParsedAsmOperand &Op, unsigned Kind)
Allow a target to add special case operand matching for things that tblgen doesn't/can't handle effec...
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Base class for the full range of assembler expressions which are needed for parsing.
DiagnosticPredicate(DiagnosticPredicateTy T)
DiagnosticPredicate(bool Match)
Target independent representation for an assembler token.
IntelExpr(bool needBracs=false)
MCParsedAsmOperand - This abstract class represents a source-level assembly instruction operand...
static NearMissInfo getTooFewOperands(unsigned OperandClass, unsigned Opcode)
Context object for machine code objects.
unsigned getPredicateError() const
Instances of this class represent a single low-level machine instruction.
Analysis containing CSE Info
virtual void SetFrameRegister(unsigned RegNo)
Sets frame register corresponding to the current MachineFunction.
uint64_t getFeatures() const
Streaming machine code generation interface.
virtual bool OmitRegisterFromClobberLists(unsigned RegNo)
Allows targets to let registers opt out of clobber lists.
MissedOpInfo MissedOperand
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static NearMissInfo getMissedPredicate(unsigned FailureCode)
void setSemaCallback(MCAsmParserSemaCallback *Callback)
Interface to description of machine instruction set.
virtual void onEndOfFile()
virtual unsigned checkTargetMatchPredicate(MCInst &Inst)
checkTargetMatchPredicate - Validate the instruction match against any complex target predicates not ...
void setParsingInlineAsm(bool Value)
static uint64_t scale(uint64_t Num, uint32_t N, uint32_t D)
Generic Sema callback for assembly parser.
static NearMissInfo getMissedFeature(uint64_t MissingFeatures)
virtual bool starIsStartOfStatement()
virtual unsigned getReg() const =0
virtual bool ParseInstruction(ParseInstructionInfo &Info, StringRef Name, AsmToken Token, OperandVector &Operands)
virtual bool equalIsAsmAssignment()
IntelExpr(int64_t imm, bool needBracs)
virtual const MCExpr * createTargetUnaryExpr(const MCExpr *E, AsmToken::TokenKind OperatorToken, MCContext &Ctx)
DiagnosticPredicateTy Type
static NearMissInfo getSuccess()
AsmRewrite(AsmRewriteKind kind, SMLoc loc, unsigned len=0, int64_t val=0)
Base class for user error types.
virtual bool parsePrimaryExpr(const MCExpr *&Res, SMLoc &EndLoc)
void setAvailableFeatures(uint64_t Value)
Generic base class for all target subtargets.
unsigned getOperandError() const
virtual const MCExpr * applyModifierToExpr(const MCExpr *E, MCSymbolRefExpr::VariantKind, MCContext &Ctx)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
NearMissKind getKind() const
unsigned getOperandIndex() const
virtual void flushPendingInstructions(MCStreamer &Out)
Ensure that all previously parsed instructions have been emitted to the output streamer, if the target does not emit them immediately.
Generic interface for extending the MCAsmParser, which is implemented by target and object file assem...
const char AsmRewritePrecedence[]
TooFewOperandsInfo TooFewOperands
LLVM Value Representation.
virtual void doBeforeLabelEmit(MCSymbol *Symbol)
StringRef - Represent a constant reference to a string, i.e.
AsmRewrite(SMLoc loc, unsigned len, IntelExpr exp)
Represents a location in source code.
MCTargetOptions getTargetOptions() const
virtual bool isReg() const =0
isReg - Is this a register operand?
bool isParsingInlineAsm()