LLVM 23.0.0git
MCTargetAsmParser.cpp
Go to the documentation of this file.
1//===-- MCTargetAsmParser.cpp - Target Assembly Parser --------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
10#include "llvm/MC/MCContext.h"
12#include "llvm/MC/MCRegister.h"
13
14using namespace llvm;
15
19
21
24 STI = &STICopy;
25 // The returned STI will likely be modified. Create a new fragment to prevent
26 // mixing STI values within a fragment.
27 auto &S = getStreamer();
28 if (S.isObj() && S.getCurrentFragment())
29 static_cast<MCObjectStreamer &>(S).newFragment();
30 return STICopy;
31}
32
34 return *STI;
35}
36
38 SMLoc StartTokLoc = getTok().getLoc();
39 // Delegate to ParseDirective by default for transition period. Once the
40 // transition is over, this method should just return NoMatch.
41 bool Res = ParseDirective(DirectiveID);
42
43 // Some targets erroneously report success after emitting an error.
44 if (getParser().hasPendingError())
46
47 // ParseDirective returns true if there was an error or if the directive is
48 // not target-specific. Disambiguate the two cases by comparing position of
49 // the lexer before and after calling the method: if no tokens were consumed,
50 // there was no match, otherwise there was a failure.
51 if (!Res)
53 if (getTok().getLoc() != StartTokLoc)
56}
57
59 const MCParsedAsmOperand &Op2) const {
60 return Op1.isReg() && Op2.isReg() && Op1.getReg() == Op2.getReg();
61}
Target independent representation for an assembler token.
Definition MCAsmMacro.h:22
LLVM_ABI SMLoc getLoc() const
Definition AsmLexer.cpp:31
LLVM_ABI MCSubtargetInfo & getSubtargetCopy(const MCSubtargetInfo &STI)
Interface to description of machine instruction set.
Definition MCInstrInfo.h:27
Streaming object file generation interface.
MCParsedAsmOperand - This abstract class represents a source-level assembly instruction operand.
virtual bool isReg() const =0
isReg - Is this a register operand?
virtual MCRegister getReg() const =0
Generic base class for all target subtargets.
virtual ParseStatus parseDirective(AsmToken DirectiveID)
Parses a target-specific assembler directive.
MCSubtargetInfo & copySTI()
Create a copy of STI and return a non-const reference to it.
virtual bool ParseDirective(AsmToken DirectiveID)
ParseDirective - Parse a target specific assembler directive This method is deprecated,...
virtual bool areEqualRegs(const MCParsedAsmOperand &Op1, const MCParsedAsmOperand &Op2) const
Returns whether two operands are registers and are equal.
const MCInstrInfo & MII
MCTargetAsmParser(const MCSubtargetInfo &STI, const MCInstrInfo &MII)
const MCSubtargetInfo & getSTI() const
~MCTargetAsmParser() override
const MCSubtargetInfo * STI
Current STI.
Ternary parse status returned by various parse* methods.
static constexpr StatusTy Failure
static constexpr StatusTy Success
static constexpr StatusTy NoMatch
Represents a location in source code.
Definition SMLoc.h:22
This is an optimization pass for GlobalISel generic memory operations.