Path: blob/main/contrib/llvm-project/llvm/lib/MC/MCParser/MCTargetAsmParser.cpp
35294 views
//===-- MCTargetAsmParser.cpp - Target Assembly Parser --------------------===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//78#include "llvm/MC/MCParser/MCTargetAsmParser.h"9#include "llvm/MC/MCContext.h"10#include "llvm/MC/MCRegister.h"1112using namespace llvm;1314MCTargetAsmParser::MCTargetAsmParser(MCTargetOptions const &MCOptions,15const MCSubtargetInfo &STI,16const MCInstrInfo &MII)17: MCOptions(MCOptions), STI(&STI), MII(MII) {}1819MCTargetAsmParser::~MCTargetAsmParser() = default;2021MCSubtargetInfo &MCTargetAsmParser::copySTI() {22MCSubtargetInfo &STICopy = getContext().getSubtargetCopy(getSTI());23STI = &STICopy;24return STICopy;25}2627const MCSubtargetInfo &MCTargetAsmParser::getSTI() const {28return *STI;29}3031ParseStatus MCTargetAsmParser::parseDirective(AsmToken DirectiveID) {32SMLoc StartTokLoc = getTok().getLoc();33// Delegate to ParseDirective by default for transition period. Once the34// transition is over, this method should just return NoMatch.35bool Res = ParseDirective(DirectiveID);3637// Some targets erroneously report success after emitting an error.38if (getParser().hasPendingError())39return ParseStatus::Failure;4041// ParseDirective returns true if there was an error or if the directive is42// not target-specific. Disambiguate the two cases by comparing position of43// the lexer before and after calling the method: if no tokens were consumed,44// there was no match, otherwise there was a failure.45if (!Res)46return ParseStatus::Success;47if (getTok().getLoc() != StartTokLoc)48return ParseStatus::Failure;49return ParseStatus::NoMatch;50}5152bool MCTargetAsmParser::areEqualRegs(const MCParsedAsmOperand &Op1,53const MCParsedAsmOperand &Op2) const {54return Op1.isReg() && Op2.isReg() && Op1.getReg() == Op2.getReg();55}565758