LLVM 19.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"
11#include "llvm/MC/MCRegister.h"
12
13using namespace llvm;
14
16 const MCSubtargetInfo &STI,
17 const MCInstrInfo &MII)
18 : MCOptions(MCOptions), STI(&STI), MII(MII) {}
19
21
24 STI = &STICopy;
25 return STICopy;
26}
27
29 return *STI;
30}
31
33 SMLoc StartTokLoc = getTok().getLoc();
34 // Delegate to ParseDirective by default for transition period. Once the
35 // transition is over, this method should just return NoMatch.
36 bool Res = ParseDirective(DirectiveID);
37
38 // Some targets erroneously report success after emitting an error.
39 if (getParser().hasPendingError())
41
42 // ParseDirective returns true if there was an error or if the directive is
43 // not target-specific. Disambiguate the two cases by comparing position of
44 // the lexer before and after calling the method: if no tokens were consumed,
45 // there was no match, otherwise there was a failure.
46 if (!Res)
48 if (getTok().getLoc() != StartTokLoc)
51}
52
54 const MCParsedAsmOperand &Op2) const {
55 return Op1.isReg() && Op2.isReg() && Op1.getReg() == Op2.getReg();
56}
Target independent representation for an assembler token.
Definition: MCAsmMacro.h:21
SMLoc getLoc() const
Definition: MCAsmLexer.cpp:26
MCSubtargetInfo & getSubtargetCopy(const MCSubtargetInfo &STI)
Definition: MCContext.cpp:913
Interface to description of machine instruction set.
Definition: MCInstrInfo.h:26
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,...
MCTargetAsmParser(MCTargetOptions const &, const MCSubtargetInfo &STI, const MCInstrInfo &MII)
virtual bool areEqualRegs(const MCParsedAsmOperand &Op1, const MCParsedAsmOperand &Op2) const
Returns whether two operands are registers and are equal.
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:23
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18