[RISCV] Fix mgather -> riscv.masked.strided.load combine not extending indices (...
[llvm-project.git] / llvm / lib / MC / MCParser / MCTargetAsmParser.cpp
blob0db5fb36f7950850ebb0e10ace1142a2fe8ca229
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 //===----------------------------------------------------------------------===//
9 #include "llvm/MC/MCParser/MCTargetAsmParser.h"
10 #include "llvm/MC/MCContext.h"
12 using namespace llvm;
14 MCTargetAsmParser::MCTargetAsmParser(MCTargetOptions const &MCOptions,
15 const MCSubtargetInfo &STI,
16 const MCInstrInfo &MII)
17 : MCOptions(MCOptions), STI(&STI), MII(MII) {}
19 MCTargetAsmParser::~MCTargetAsmParser() = default;
21 MCSubtargetInfo &MCTargetAsmParser::copySTI() {
22 MCSubtargetInfo &STICopy = getContext().getSubtargetCopy(getSTI());
23 STI = &STICopy;
24 return STICopy;
27 const MCSubtargetInfo &MCTargetAsmParser::getSTI() const {
28 return *STI;
31 ParseStatus MCTargetAsmParser::parseDirective(AsmToken DirectiveID) {
32 SMLoc StartTokLoc = getTok().getLoc();
33 // Delegate to ParseDirective by default for transition period. Once the
34 // transition is over, this method should just return NoMatch.
35 bool Res = ParseDirective(DirectiveID);
37 // Some targets erroneously report success after emitting an error.
38 if (getParser().hasPendingError())
39 return ParseStatus::Failure;
41 // ParseDirective returns true if there was an error or if the directive is
42 // not target-specific. Disambiguate the two cases by comparing position of
43 // the lexer before and after calling the method: if no tokens were consumed,
44 // there was no match, otherwise there was a failure.
45 if (!Res)
46 return ParseStatus::Success;
47 if (getTok().getLoc() != StartTokLoc)
48 return ParseStatus::Failure;
49 return ParseStatus::NoMatch;