1//===- XCOFFAsmParser.cpp - XCOFF Assembly Parser
2//-----------------------------===//
3//
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
7//
8//===----------------------------------------------------------------------===//
9
10#include "llvm/BinaryFormat/XCOFF.h"
11#include "llvm/MC/MCParser/MCAsmParser.h"
12#include "llvm/MC/MCParser/MCAsmParserExtension.h"
13
14using namespace llvm;
15
16namespace {
17
18class XCOFFAsmParser : public MCAsmParserExtension {
19 MCAsmParser *Parser = nullptr;
20 MCAsmLexer *Lexer = nullptr;
21
22 template <bool (XCOFFAsmParser::*HandlerMethod)(StringRef, SMLoc)>
23 void addDirectiveHandler(StringRef Directive) {
24 MCAsmParser::ExtensionDirectiveHandler Handler =
25 std::make_pair(this, HandleDirective<XCOFFAsmParser, HandlerMethod>);
26
27 getParser().addDirectiveHandler(Directive, Handler);
28 }
29
30public:
31 XCOFFAsmParser() = default;
32
33 void Initialize(MCAsmParser &P) override {
34 Parser = &P;
35 Lexer = &Parser->getLexer();
36 // Call the base implementation.
37 MCAsmParserExtension::Initialize(Parser&: *Parser);
38
39 addDirectiveHandler<&XCOFFAsmParser::ParseDirectiveCSect>(Directive: ".csect");
40 }
41 bool ParseDirectiveCSect(StringRef, SMLoc);
42};
43
44} // end anonymous namespace
45
46namespace llvm {
47
48MCAsmParserExtension *createXCOFFAsmParser() { return new XCOFFAsmParser; }
49
50} // end namespace llvm
51
52// .csect QualName [, Number ]
53bool XCOFFAsmParser::ParseDirectiveCSect(StringRef, SMLoc) {
54 report_fatal_error(reason: "XCOFFAsmParser directive not yet supported!");
55 return false;
56}
57

source code of llvm/lib/MC/MCParser/XCOFFAsmParser.cpp