LLVM 23.0.0git
LFIAsmParser.cpp
Go to the documentation of this file.
1//===----------------------------------------------------------------------===//
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/// \file
10/// LFI assembly parser.
11///
12//===----------------------------------------------------------------------===//
13
16
17using namespace llvm;
18
20 MCLFIRewriter *Rewriter;
21 template <bool (LFIAsmParser::*HandlerMethod)(StringRef, SMLoc)>
22 void addDirectiveHandler(StringRef Directive) {
25
27 }
28
29public:
30 LFIAsmParser(MCLFIRewriter *Exp) : Rewriter(Exp) {}
31 void Initialize(MCAsmParser &Parser) override {
32 // Call the base implementation.
34 addDirectiveHandler<&LFIAsmParser::parseRewriteDisable>(
35 ".lfi_rewrite_disable");
36 addDirectiveHandler<&LFIAsmParser::parseRewriteEnable>(
37 ".lfi_rewrite_enable");
38 }
39
40 /// ::= {.lfi_rewrite_disable}
44 return TokError("unexpected token");
45 Lex();
46
47 Rewriter->disable();
48
49 return false;
50 }
51
52 /// ::= {.lfi_rewrite_enable}
56 return TokError("unexpected token");
57 Lex();
58
59 Rewriter->enable();
60
61 return false;
62 }
63};
64
65namespace llvm {
69} // namespace llvm
static bool isNot(const MachineRegisterInfo &MRI, const MachineInstr &MI)
This file declares the MCLFIRewriter class, an abstract class that encapsulates the rewriting logic f...
bool parseRewriteEnable(StringRef Directive, SMLoc Loc)
::= {.lfi_rewrite_enable}
bool parseRewriteDisable(StringRef Directive, SMLoc Loc)
::= {.lfi_rewrite_disable}
LFIAsmParser(MCLFIRewriter *Exp)
void Initialize(MCAsmParser &Parser) override
Initialize the extension for parsing using the given Parser.
Generic interface for extending the MCAsmParser, which is implemented by target and object file assem...
static bool HandleDirective(MCAsmParserExtension *Target, StringRef Directive, SMLoc DirectiveLoc)
virtual void Initialize(MCAsmParser &Parser)
Initialize the extension for parsing using the given Parser.
bool TokError(const Twine &Msg)
Generic assembler parser interface, for use by target specific assembly parsers.
virtual bool checkForValidSection()=0
Ensure that we have a valid section set in the streamer.
std::pair< MCAsmParserExtension *, DirectiveHandler > ExtensionDirectiveHandler
virtual void addDirectiveHandler(StringRef Directive, ExtensionDirectiveHandler Handler)=0
Represents a location in source code.
Definition SMLoc.h:22
StringRef - Represent a constant reference to a string, i.e.
Definition StringRef.h:55
This is an optimization pass for GlobalISel generic memory operations.
Definition Types.h:26
LLVM_ABI MCAsmParserExtension * createLFIAsmParser(MCLFIRewriter *Exp)