[ORC] Add std::tuple support to SimplePackedSerialization.
[llvm-project.git] / llvm / lib / MC / MCParser / MCAsmParserExtension.cpp
blob0b5046cd8fad588bdada313e61a1e2b35d7f96f4
1 //===- MCAsmParserExtension.cpp - Asm Parser Hooks ------------------------===//
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/MCAsmParserExtension.h"
10 #include "llvm/MC/MCContext.h"
11 #include "llvm/MC/MCStreamer.h"
13 using namespace llvm;
15 MCAsmParserExtension::MCAsmParserExtension() = default;
17 MCAsmParserExtension::~MCAsmParserExtension() = default;
19 void MCAsmParserExtension::Initialize(MCAsmParser &Parser) {
20 this->Parser = &Parser;
23 /// ParseDirectiveCGProfile
24 /// ::= .cg_profile identifier, identifier, <number>
25 bool MCAsmParserExtension::ParseDirectiveCGProfile(StringRef, SMLoc) {
26 StringRef From;
27 SMLoc FromLoc = getLexer().getLoc();
28 if (getParser().parseIdentifier(From))
29 return TokError("expected identifier in directive");
31 if (getLexer().isNot(AsmToken::Comma))
32 return TokError("expected a comma");
33 Lex();
35 StringRef To;
36 SMLoc ToLoc = getLexer().getLoc();
37 if (getParser().parseIdentifier(To))
38 return TokError("expected identifier in directive");
40 if (getLexer().isNot(AsmToken::Comma))
41 return TokError("expected a comma");
42 Lex();
44 int64_t Count;
45 if (getParser().parseIntToken(
46 Count, "expected integer count in '.cg_profile' directive"))
47 return true;
49 if (getLexer().isNot(AsmToken::EndOfStatement))
50 return TokError("unexpected token in directive");
52 MCSymbol *FromSym = getContext().getOrCreateSymbol(From);
53 MCSymbol *ToSym = getContext().getOrCreateSymbol(To);
55 getStreamer().emitCGProfileEntry(
56 MCSymbolRefExpr::create(FromSym, MCSymbolRefExpr::VK_None, getContext(),
57 FromLoc),
58 MCSymbolRefExpr::create(ToSym, MCSymbolRefExpr::VK_None, getContext(),
59 ToLoc),
60 Count);
61 return false;