LLVM
20.0.0git
lib
MC
MCParser
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
9
#include "
llvm/MC/MCParser/MCAsmParserExtension.h
"
10
#include "
llvm/MC/MCContext.h
"
11
#include "
llvm/MC/MCExpr.h
"
12
#include "
llvm/MC/MCParser/MCAsmLexer.h
"
13
#include "
llvm/MC/MCStreamer.h
"
14
15
using namespace
llvm
;
16
17
MCAsmParserExtension::MCAsmParserExtension
() =
default
;
18
19
MCAsmParserExtension::~MCAsmParserExtension
() =
default
;
20
21
void
MCAsmParserExtension::Initialize
(
MCAsmParser
&Parser) {
22
this->Parser = &Parser;
23
}
24
25
/// parseDirectiveCGProfile
26
/// ::= .cg_profile identifier, identifier, <number>
27
bool
MCAsmParserExtension::parseDirectiveCGProfile
(
StringRef
,
SMLoc
) {
28
StringRef
From
;
29
SMLoc
FromLoc =
getLexer
().
getLoc
();
30
if
(
getParser
().parseIdentifier(
From
))
31
return
TokError
(
"expected identifier in directive"
);
32
33
if
(
getLexer
().
isNot
(
AsmToken::Comma
))
34
return
TokError
(
"expected a comma"
);
35
Lex
();
36
37
StringRef
To;
38
SMLoc
ToLoc =
getLexer
().
getLoc
();
39
if
(
getParser
().parseIdentifier(To))
40
return
TokError
(
"expected identifier in directive"
);
41
42
if
(
getLexer
().
isNot
(
AsmToken::Comma
))
43
return
TokError
(
"expected a comma"
);
44
Lex
();
45
46
int64_t Count;
47
if
(
getParser
().parseIntToken(
48
Count,
"expected integer count in '.cg_profile' directive"
))
49
return
true
;
50
51
if
(
getLexer
().
isNot
(
AsmToken::EndOfStatement
))
52
return
TokError
(
"unexpected token in directive"
);
53
54
MCSymbol
*FromSym =
getContext
().
getOrCreateSymbol
(
From
);
55
MCSymbol
*ToSym =
getContext
().
getOrCreateSymbol
(To);
56
57
getStreamer
().
emitCGProfileEntry
(
58
MCSymbolRefExpr::create
(FromSym,
MCSymbolRefExpr::VK_None
,
getContext
(),
59
FromLoc),
60
MCSymbolRefExpr::create
(ToSym,
MCSymbolRefExpr::VK_None
,
getContext
(),
61
ToLoc),
62
Count);
63
return
false
;
64
}
isNot
static bool isNot(const MachineRegisterInfo &MRI, const MachineInstr &MI)
Definition:
AMDGPULegalizerInfo.cpp:4228
From
BlockVerifier::State From
Definition:
BlockVerifier.cpp:57
MCAsmLexer.h
MCAsmParserExtension.h
MCContext.h
MCExpr.h
MCStreamer.h
llvm::AsmToken::Comma
@ Comma
Definition:
MCAsmMacro.h:49
llvm::AsmToken::EndOfStatement
@ EndOfStatement
Definition:
MCAsmMacro.h:42
llvm::MCAsmLexer::getLoc
SMLoc getLoc() const
Get the current source location.
Definition:
MCAsmLexer.cpp:22
llvm::MCAsmParserExtension::~MCAsmParserExtension
virtual ~MCAsmParserExtension()
llvm::MCAsmParserExtension::Lex
const AsmToken & Lex()
Definition:
MCAsmParserExtension.h:85
llvm::MCAsmParserExtension::Initialize
virtual void Initialize(MCAsmParser &Parser)
Initialize the extension for parsing using the given Parser.
Definition:
MCAsmParserExtension.cpp:21
llvm::MCAsmParserExtension::TokError
bool TokError(const Twine &Msg)
Definition:
MCAsmParserExtension.h:81
llvm::MCAsmParserExtension::getContext
MCContext & getContext()
Definition:
MCAsmParserExtension.h:54
llvm::MCAsmParserExtension::MCAsmParserExtension
MCAsmParserExtension()
llvm::MCAsmParserExtension::parseDirectiveCGProfile
bool parseDirectiveCGProfile(StringRef, SMLoc)
parseDirectiveCGProfile ::= .cg_profile identifier, identifier, <number>
Definition:
MCAsmParserExtension.cpp:27
llvm::MCAsmParserExtension::getStreamer
MCStreamer & getStreamer()
Definition:
MCAsmParserExtension.h:67
llvm::MCAsmParserExtension::getParser
MCAsmParser & getParser()
Definition:
MCAsmParserExtension.h:61
llvm::MCAsmParserExtension::getLexer
MCAsmLexer & getLexer()
Definition:
MCAsmParserExtension.h:56
llvm::MCAsmParser
Generic assembler parser interface, for use by target specific assembly parsers.
Definition:
MCAsmParser.h:123
llvm::MCContext::getOrCreateSymbol
MCSymbol * getOrCreateSymbol(const Twine &Name)
Lookup the symbol inside with the specified Name.
Definition:
MCContext.cpp:212
llvm::MCStreamer::emitCGProfileEntry
virtual void emitCGProfileEntry(const MCSymbolRefExpr *From, const MCSymbolRefExpr *To, uint64_t Count)
Definition:
MCStreamer.cpp:853
llvm::MCSymbolRefExpr::VK_None
@ VK_None
Definition:
MCExpr.h:195
llvm::MCSymbolRefExpr::create
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx)
Definition:
MCExpr.h:398
llvm::MCSymbol
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition:
MCSymbol.h:41
llvm::SMLoc
Represents a location in source code.
Definition:
SMLoc.h:23
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition:
StringRef.h:51
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition:
AddressRanges.h:18
Generated on Sat Dec 21 2024 23:10:30 for LLVM by
1.9.6