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/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" 20 21 using namespace llvm; 22 23 namespace { 24 25 class XCOFFAsmParser : public MCAsmParserExtension { 26 MCAsmParser *Parser = nullptr; 27 MCAsmLexer *Lexer = nullptr; 28 29 template <bool (XCOFFAsmParser::*HandlerMethod)(StringRef, SMLoc)> 30 void addDirectiveHandler(StringRef Directive) { 31 MCAsmParser::ExtensionDirectiveHandler Handler = 32 std::make_pair(this, HandleDirective<XCOFFAsmParser, HandlerMethod>); 33 34 getParser().addDirectiveHandler(Directive, Handler); 35 } 36 37 public: 38 XCOFFAsmParser() {} 39 40 void Initialize(MCAsmParser &P) override { 41 Parser = &P; 42 Lexer = &Parser->getLexer(); 43 // Call the base implementation. 44 MCAsmParserExtension::Initialize(*Parser); 45 46 addDirectiveHandler<&XCOFFAsmParser::ParseDirectiveCSect>(".csect"); 47 } 48 bool ParseDirectiveCSect(StringRef, SMLoc); 49 }; 50 51 } // end anonymous namespace 52 53 namespace llvm { 54 55 MCAsmParserExtension *createXCOFFAsmParser() { return new XCOFFAsmParser; } 56 57 } // end namespace llvm 58 59 // .csect QualName [, Number ] 60 bool XCOFFAsmParser::ParseDirectiveCSect(StringRef, SMLoc) { 61 report_fatal_error("XCOFFAsmParser directive not yet supported!"); 62 return false; 63 } 64