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/MCContext.h"
12 #include "llvm/MC/MCParser/MCAsmLexer.h"
13 #include "llvm/MC/MCParser/MCAsmParser.h"
14 #include "llvm/MC/MCParser/MCAsmParserExtension.h"
15 #include "llvm/MC/MCSectionXCOFF.h"
16 #include "llvm/MC/MCStreamer.h"
17 #include "llvm/MC/MCSymbol.h"
18 #include "llvm/MC/MCSymbolXCOFF.h"
19 #include "llvm/Support/MachineValueType.h"
25 class XCOFFAsmParser
: public MCAsmParserExtension
{
26 MCAsmParser
*Parser
= nullptr;
27 MCAsmLexer
*Lexer
= nullptr;
29 template <bool (XCOFFAsmParser::*HandlerMethod
)(StringRef
, SMLoc
)>
30 void addDirectiveHandler(StringRef Directive
) {
31 MCAsmParser::ExtensionDirectiveHandler Handler
=
32 std::make_pair(this, HandleDirective
<XCOFFAsmParser
, HandlerMethod
>);
34 getParser().addDirectiveHandler(Directive
, Handler
);
40 void Initialize(MCAsmParser
&P
) override
{
42 Lexer
= &Parser
->getLexer();
43 // Call the base implementation.
44 MCAsmParserExtension::Initialize(*Parser
);
46 addDirectiveHandler
<&XCOFFAsmParser::ParseDirectiveCSect
>(".csect");
48 bool ParseDirectiveCSect(StringRef
, SMLoc
);
51 } // end anonymous namespace
55 MCAsmParserExtension
*createXCOFFAsmParser() { return new XCOFFAsmParser
; }
57 } // end namespace llvm
59 // .csect QualName [, Number ]
60 bool XCOFFAsmParser::ParseDirectiveCSect(StringRef
, SMLoc
) {
61 report_fatal_error("XCOFFAsmParser directive not yet supported!");