1 //===- XCOFFAsmParser.cpp - XCOFF Assembly Parser
2 //-----------------------------===//
4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 // See https://llvm.org/LICENSE.txt for license information.
6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
8 //===----------------------------------------------------------------------===//
10 #include "llvm/BinaryFormat/XCOFF.h"
11 #include "llvm/MC/MCParser/MCAsmParser.h"
12 #include "llvm/MC/MCParser/MCAsmParserExtension.h"
18 class XCOFFAsmParser
: public MCAsmParserExtension
{
19 MCAsmParser
*Parser
= nullptr;
20 MCAsmLexer
*Lexer
= nullptr;
22 template <bool (XCOFFAsmParser::*HandlerMethod
)(StringRef
, SMLoc
)>
23 void addDirectiveHandler(StringRef Directive
) {
24 MCAsmParser::ExtensionDirectiveHandler Handler
=
25 std::make_pair(this, HandleDirective
<XCOFFAsmParser
, HandlerMethod
>);
27 getParser().addDirectiveHandler(Directive
, Handler
);
31 XCOFFAsmParser() = default;
33 void Initialize(MCAsmParser
&P
) override
{
35 Lexer
= &Parser
->getLexer();
36 // Call the base implementation.
37 MCAsmParserExtension::Initialize(*Parser
);
39 addDirectiveHandler
<&XCOFFAsmParser::ParseDirectiveCSect
>(".csect");
41 bool ParseDirectiveCSect(StringRef
, SMLoc
);
44 } // end anonymous namespace
48 MCAsmParserExtension
*createXCOFFAsmParser() { return new XCOFFAsmParser
; }
50 } // end namespace llvm
52 // .csect QualName [, Number ]
53 bool XCOFFAsmParser::ParseDirectiveCSect(StringRef
, SMLoc
) {
54 report_fatal_error("XCOFFAsmParser directive not yet supported!");