blob: 3a825f03b776704108c2078ed498d7063f637521 [file] [log] [blame]
Daniel Dunbara3af3702009-07-20 18:55:04 +00001//===-- 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
Chris Lattnerc6ef2772010-01-22 01:44:57 +000010#include "llvm/MC/MCParser/MCAsmParser.h"
11#include "llvm/MC/MCParser/MCAsmLexer.h"
12#include "llvm/MC/MCParser/MCParsedAsmOperand.h"
Evan Cheng94b95502011-07-26 00:24:13 +000013#include "llvm/MC/MCTargetAsmParser.h"
Chris Lattnerb4307b32010-01-15 19:28:38 +000014#include "llvm/Support/SourceMgr.h"
Jim Grosbachb7f689b2011-07-13 15:34:57 +000015#include "llvm/Support/raw_ostream.h"
16#include "llvm/Support/Debug.h"
Evan Chenga7cfc082011-07-23 00:45:41 +000017#include "llvm/ADT/Twine.h"
Daniel Dunbara3af3702009-07-20 18:55:04 +000018using namespace llvm;
19
Daniel Dunbar3c14ca42010-08-11 06:37:09 +000020MCAsmParser::MCAsmParser() : TargetParser(0), ShowParsedOperands(0) {
Daniel Dunbara3af3702009-07-20 18:55:04 +000021}
22
23MCAsmParser::~MCAsmParser() {
24}
Chris Lattnerb4307b32010-01-15 19:28:38 +000025
Evan Cheng94b95502011-07-26 00:24:13 +000026void MCAsmParser::setTargetParser(MCTargetAsmParser &P) {
Daniel Dunbard1e3b442010-07-17 02:26:10 +000027 assert(!TargetParser && "Target parser is already initialized!");
28 TargetParser = &P;
29 TargetParser->Initialize(*this);
30}
31
Sean Callanan18b83232010-01-19 21:44:56 +000032const AsmToken &MCAsmParser::getTok() {
33 return getLexer().getTok();
34}
35
Chris Lattnerd8b7aa22011-10-16 04:47:35 +000036bool MCAsmParser::TokError(const Twine &Msg, ArrayRef<SMRange> Ranges) {
37 Error(getLexer().getLoc(), Msg, Ranges);
Daniel Dunbardc4c7da2010-07-12 17:18:45 +000038 return true;
39}
40
Chris Lattnerb4307b32010-01-15 19:28:38 +000041bool MCAsmParser::ParseExpression(const MCExpr *&Res) {
42 SMLoc L;
Chris Lattner9521c952010-01-15 19:51:05 +000043 return ParseExpression(Res, L);
Chris Lattnerb4307b32010-01-15 19:28:38 +000044}
45
Jim Grosbachb7f689b2011-07-13 15:34:57 +000046void MCParsedAsmOperand::dump() const {
47 dbgs() << " " << *this;
48}