1fb99424aSAnirudh Prasad //===- GOFFAsmParser.cpp - GOFF Assembly Parser ---------------------------===//
2fb99424aSAnirudh Prasad //
3fb99424aSAnirudh Prasad // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4fb99424aSAnirudh Prasad // See https://llvm.org/LICENSE.txt for license information.
5fb99424aSAnirudh Prasad // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6fb99424aSAnirudh Prasad //
7fb99424aSAnirudh Prasad //===----------------------------------------------------------------------===//
8fb99424aSAnirudh Prasad 
9fb99424aSAnirudh Prasad #include "llvm/MC/MCParser/MCAsmParserExtension.h"
10fb99424aSAnirudh Prasad 
11fb99424aSAnirudh Prasad using namespace llvm;
12fb99424aSAnirudh Prasad 
13fb99424aSAnirudh Prasad namespace {
14fb99424aSAnirudh Prasad 
15fb99424aSAnirudh Prasad class GOFFAsmParser : public MCAsmParserExtension {
16fb99424aSAnirudh Prasad   template <bool (GOFFAsmParser::*HandlerMethod)(StringRef, SMLoc)>
addDirectiveHandler(StringRef Directive)17fb99424aSAnirudh Prasad   void addDirectiveHandler(StringRef Directive) {
18fb99424aSAnirudh Prasad     MCAsmParser::ExtensionDirectiveHandler Handler =
19fb99424aSAnirudh Prasad         std::make_pair(this, HandleDirective<GOFFAsmParser, HandlerMethod>);
20fb99424aSAnirudh Prasad 
21fb99424aSAnirudh Prasad     getParser().addDirectiveHandler(Directive, Handler);
22fb99424aSAnirudh Prasad   }
23fb99424aSAnirudh Prasad 
24fb99424aSAnirudh Prasad public:
25*3a3cb929SKazu Hirata   GOFFAsmParser() = default;
26fb99424aSAnirudh Prasad 
Initialize(MCAsmParser & Parser)27fb99424aSAnirudh Prasad   void Initialize(MCAsmParser &Parser) override {
28fb99424aSAnirudh Prasad     // Call the base implementation.
29fb99424aSAnirudh Prasad     this->MCAsmParserExtension::Initialize(Parser);
30fb99424aSAnirudh Prasad   }
31fb99424aSAnirudh Prasad };
32fb99424aSAnirudh Prasad 
33fb99424aSAnirudh Prasad } // namespace
34fb99424aSAnirudh Prasad 
35fb99424aSAnirudh Prasad namespace llvm {
36fb99424aSAnirudh Prasad 
createGOFFAsmParser()37fb99424aSAnirudh Prasad MCAsmParserExtension *createGOFFAsmParser() { return new GOFFAsmParser; }
38fb99424aSAnirudh Prasad 
39fb99424aSAnirudh Prasad } // namespace llvm
40