xref: /freebsd/contrib/llvm-project/llvm/lib/MC/MCParser/GOFFAsmParser.cpp (revision 84823cc70824c8d842f503d8c2e6d7b0c2d95b61)
1 //===- GOFFAsmParser.cpp - GOFF Assembly Parser ---------------------------===//
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/ADT/StringSwitch.h"
10 #include "llvm/ADT/Twine.h"
11 #include "llvm/MC/MCAsmInfo.h"
12 #include "llvm/MC/MCContext.h"
13 #include "llvm/MC/MCExpr.h"
14 #include "llvm/MC/MCParser/MCAsmLexer.h"
15 #include "llvm/MC/MCParser/MCAsmParserExtension.h"
16 #include "llvm/MC/MCSectionGOFF.h"
17 #include "llvm/MC/MCStreamer.h"
18 #include "llvm/MC/MCSymbolGOFF.h"
19 
20 using namespace llvm;
21 
22 namespace {
23 
24 class GOFFAsmParser : public MCAsmParserExtension {
25   template <bool (GOFFAsmParser::*HandlerMethod)(StringRef, SMLoc)>
26   void addDirectiveHandler(StringRef Directive) {
27     MCAsmParser::ExtensionDirectiveHandler Handler =
28         std::make_pair(this, HandleDirective<GOFFAsmParser, HandlerMethod>);
29 
30     getParser().addDirectiveHandler(Directive, Handler);
31   }
32 
33 public:
34   GOFFAsmParser() {}
35 
36   void Initialize(MCAsmParser &Parser) override {
37     // Call the base implementation.
38     this->MCAsmParserExtension::Initialize(Parser);
39   }
40 };
41 
42 } // namespace
43 
44 namespace llvm {
45 
46 MCAsmParserExtension *createGOFFAsmParser() { return new GOFFAsmParser; }
47 
48 } // namespace llvm
49