XCOFFAsmParser.cpp 1.6 KB

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