brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.6 KiB · 9b933d7 Raw
55 lines · cpp
1//===- XCOFFAsmParser.cpp - XCOFF Assembly Parser2//-----------------------------===//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-exception7//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  AsmLexer *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);38 39    addDirectiveHandler<&XCOFFAsmParser::ParseDirectiveCSect>(".csect");40  }41  bool ParseDirectiveCSect(StringRef, SMLoc);42};43 44} // end anonymous namespace45 46// .csect QualName [, Number ]47bool XCOFFAsmParser::ParseDirectiveCSect(StringRef, SMLoc) {48  report_fatal_error("XCOFFAsmParser directive not yet supported!");49  return false;50}51 52MCAsmParserExtension *llvm::createXCOFFAsmParser() {53  return new XCOFFAsmParser;54}55