• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===-- MCAsmParser.cpp - Abstract Asm Parser Interface -------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #include "llvm/MC/MCParser/MCAsmParser.h"
11 #include "llvm/ADT/Twine.h"
12 #include "llvm/MC/MCParser/MCAsmLexer.h"
13 #include "llvm/MC/MCParser/MCParsedAsmOperand.h"
14 #include "llvm/MC/MCTargetAsmParser.h"
15 #include "llvm/Support/Debug.h"
16 #include "llvm/Support/SourceMgr.h"
17 #include "llvm/Support/raw_ostream.h"
18 using namespace llvm;
19 
MCAsmParser()20 MCAsmParser::MCAsmParser() : TargetParser(nullptr), ShowParsedOperands(0) {
21 }
22 
~MCAsmParser()23 MCAsmParser::~MCAsmParser() {
24 }
25 
setTargetParser(MCTargetAsmParser & P)26 void MCAsmParser::setTargetParser(MCTargetAsmParser &P) {
27   assert(!TargetParser && "Target parser is already initialized!");
28   TargetParser = &P;
29   TargetParser->Initialize(*this);
30 }
31 
getTok() const32 const AsmToken &MCAsmParser::getTok() const {
33   return getLexer().getTok();
34 }
35 
TokError(const Twine & Msg,ArrayRef<SMRange> Ranges)36 bool MCAsmParser::TokError(const Twine &Msg, ArrayRef<SMRange> Ranges) {
37   Error(getLexer().getLoc(), Msg, Ranges);
38   return true;
39 }
40 
parseExpression(const MCExpr * & Res)41 bool MCAsmParser::parseExpression(const MCExpr *&Res) {
42   SMLoc L;
43   return parseExpression(Res, L);
44 }
45 
dump() const46 void MCParsedAsmOperand::dump() const {
47 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
48   dbgs() << "  " << *this;
49 #endif
50 }
51