MCAsmParser.cpp 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. #include "llvm/MC/MCParser/MCAsmParser.h"
  10. #include "llvm/ADT/Twine.h"
  11. #include "llvm/MC/MCParser/MCAsmLexer.h"
  12. #include "llvm/MC/MCParser/MCParsedAsmOperand.h"
  13. #include "llvm/MC/MCTargetAsmParser.h"
  14. #include "llvm/Support/Debug.h"
  15. #include "llvm/Support/SourceMgr.h"
  16. #include "llvm/Support/raw_ostream.h"
  17. using namespace llvm;
  18. MCAsmParser::MCAsmParser() : TargetParser(nullptr), ShowParsedOperands(0) {
  19. }
  20. MCAsmParser::~MCAsmParser() {
  21. }
  22. void MCAsmParser::setTargetParser(MCTargetAsmParser &P) {
  23. assert(!TargetParser && "Target parser is already initialized!");
  24. TargetParser = &P;
  25. TargetParser->Initialize(*this);
  26. }
  27. const AsmToken &MCAsmParser::getTok() const {
  28. return getLexer().getTok();
  29. }
  30. bool MCAsmParser::TokError(const Twine &Msg, ArrayRef<SMRange> Ranges) {
  31. Error(getLexer().getLoc(), Msg, Ranges);
  32. return true;
  33. }
  34. bool MCAsmParser::parseExpression(const MCExpr *&Res) {
  35. SMLoc L;
  36. return parseExpression(Res, L);
  37. }
  38. void MCParsedAsmOperand::dump() const {
  39. #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
  40. dbgs() << " " << *this;
  41. #endif
  42. }