LLVM  13.0.0git
MCAsmParserExtension.cpp
Go to the documentation of this file.
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 //===----------------------------------------------------------------------===//
8 
10 #include "llvm/MC/MCContext.h"
11 #include "llvm/MC/MCStreamer.h"
12 
13 using namespace llvm;
14 
16 
18 
20  this->Parser = &Parser;
21 }
22 
23 /// ParseDirectiveCGProfile
24 /// ::= .cg_profile identifier, identifier, <number>
27  SMLoc FromLoc = getLexer().getLoc();
28  if (getParser().parseIdentifier(From))
29  return TokError("expected identifier in directive");
30 
32  return TokError("expected a comma");
33  Lex();
34 
35  StringRef To;
36  SMLoc ToLoc = getLexer().getLoc();
37  if (getParser().parseIdentifier(To))
38  return TokError("expected identifier in directive");
39 
41  return TokError("expected a comma");
42  Lex();
43 
44  int64_t Count;
45  if (getParser().parseIntToken(
46  Count, "expected integer count in '.cg_profile' directive"))
47  return true;
48 
50  return TokError("unexpected token in directive");
51 
53  MCSymbol *ToSym = getContext().getOrCreateSymbol(To);
54 
57  FromLoc),
59  ToLoc),
60  Count);
61  return false;
62 }
llvm::MCAsmParser
Generic assembler parser interface, for use by target specific assembly parsers.
Definition: MCAsmParser.h:123
llvm
Definition: AllocatorList.h:23
llvm::MCSymbol
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:41
llvm::MCAsmParserExtension::ParseDirectiveCGProfile
bool ParseDirectiveCGProfile(StringRef, SMLoc)
ParseDirectiveCGProfile ::= .cg_profile identifier, identifier, <number>
Definition: MCAsmParserExtension.cpp:25
llvm::AsmToken::EndOfStatement
@ EndOfStatement
Definition: MCAsmMacro.h:42
llvm::MCAsmParserExtension::Lex
const AsmToken & Lex()
Definition: MCAsmParserExtension.h:86
llvm::MCAsmParserExtension::~MCAsmParserExtension
virtual ~MCAsmParserExtension()
llvm::MCContext::getOrCreateSymbol
MCSymbol * getOrCreateSymbol(const Twine &Name)
Lookup the symbol inside with the specified Name.
Definition: MCContext.cpp:187
llvm::MCAsmParserExtension::getStreamer
MCStreamer & getStreamer()
Definition: MCAsmParserExtension.h:68
llvm::SMLoc
Represents a location in source code.
Definition: SMLoc.h:23
llvm::MCAsmParserExtension::getContext
MCContext & getContext()
Definition: MCAsmParserExtension.h:55
MCContext.h
llvm::MCAsmParserExtension::TokError
bool TokError(const Twine &Msg)
Definition: MCAsmParserExtension.h:82
isNot
static bool isNot(const MachineRegisterInfo &MRI, const MachineInstr &MI)
Definition: AMDGPULegalizerInfo.cpp:2694
llvm::MCStreamer::emitCGProfileEntry
virtual void emitCGProfileEntry(const MCSymbolRefExpr *From, const MCSymbolRefExpr *To, uint64_t Count)
Definition: MCStreamer.cpp:782
llvm::MCAsmLexer::getLoc
SMLoc getLoc() const
Get the current source location.
Definition: MCAsmLexer.cpp:23
llvm::MCAsmParserExtension::Initialize
virtual void Initialize(MCAsmParser &Parser)
Initialize the extension for parsing using the given Parser.
Definition: MCAsmParserExtension.cpp:19
llvm::MCAsmParserExtension::MCAsmParserExtension
MCAsmParserExtension()
llvm::AsmToken::Comma
@ Comma
Definition: MCAsmMacro.h:49
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:58
MCAsmParserExtension.h
llvm::MCSymbolRefExpr::create
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx)
Definition: MCExpr.h:384
MCStreamer.h
llvm::MCSymbolRefExpr::VK_None
@ VK_None
Definition: MCExpr.h:195
llvm::MCAsmParserExtension::getLexer
MCAsmLexer & getLexer()
Definition: MCAsmParserExtension.h:57
From
BlockVerifier::State From
Definition: BlockVerifier.cpp:55
llvm::MCAsmParserExtension::getParser
MCAsmParser & getParser()
Definition: MCAsmParserExtension.h:62