aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/llvm14/lib/MC/MCParser/MCAsmLexer.cpp
blob: 497055bc1760a37f288295b2657e7a90f0de264c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
//===- MCAsmLexer.cpp - Abstract Asm Lexer Interface ----------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include "llvm/MC/MCParser/MCAsmLexer.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/SMLoc.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"

using namespace llvm;

MCAsmLexer::MCAsmLexer() {
  CurTok.emplace_back(AsmToken::Space, StringRef());
}

MCAsmLexer::~MCAsmLexer() = default;

SMLoc MCAsmLexer::getLoc() const {
  return SMLoc::getFromPointer(TokStart);
}

SMLoc AsmToken::getLoc() const {
  return SMLoc::getFromPointer(Str.data());
}

SMLoc AsmToken::getEndLoc() const {
  return SMLoc::getFromPointer(Str.data() + Str.size());
}

SMRange AsmToken::getLocRange() const {
  return SMRange(getLoc(), getEndLoc());
}

void AsmToken::dump(raw_ostream &OS) const {
  switch (Kind) {
  case AsmToken::Error:
    OS << "error";
    break;
  case AsmToken::Identifier:
    OS << "identifier: " << getString();
    break;
  case AsmToken::Integer:
    OS << "int: " << getString();
    break;
  case AsmToken::Real:
    OS << "real: " << getString();
    break;
  case AsmToken::String:
    OS << "string: " << getString();
    break;

  case AsmToken::Amp:                OS << "Amp"; break;
  case AsmToken::AmpAmp:             OS << "AmpAmp"; break;
  case AsmToken::At:                 OS << "At"; break;
  case AsmToken::BackSlash:          OS << "BackSlash"; break;
  case AsmToken::BigNum:             OS << "BigNum"; break;
  case AsmToken::Caret:              OS << "Caret"; break;
  case AsmToken::Colon:              OS << "Colon"; break;
  case AsmToken::Comma:              OS << "Comma"; break;
  case AsmToken::Comment:            OS << "Comment"; break;
  case AsmToken::Dollar:             OS << "Dollar"; break;
  case AsmToken::Dot:                OS << "Dot"; break;
  case AsmToken::EndOfStatement:     OS << "EndOfStatement"; break;
  case AsmToken::Eof:                OS << "Eof"; break;
  case AsmToken::Equal:              OS << "Equal"; break;
  case AsmToken::EqualEqual:         OS << "EqualEqual"; break;
  case AsmToken::Exclaim:            OS << "Exclaim"; break;
  case AsmToken::ExclaimEqual:       OS << "ExclaimEqual"; break;
  case AsmToken::Greater:            OS << "Greater"; break;
  case AsmToken::GreaterEqual:       OS << "GreaterEqual"; break;
  case AsmToken::GreaterGreater:     OS << "GreaterGreater"; break;
  case AsmToken::Hash:               OS << "Hash"; break;
  case AsmToken::HashDirective:      OS << "HashDirective"; break;
  case AsmToken::LBrac:              OS << "LBrac"; break;
  case AsmToken::LCurly:             OS << "LCurly"; break;
  case AsmToken::LParen:             OS << "LParen"; break;
  case AsmToken::Less:               OS << "Less"; break;
  case AsmToken::LessEqual:          OS << "LessEqual"; break;
  case AsmToken::LessGreater:        OS << "LessGreater"; break;
  case AsmToken::LessLess:           OS << "LessLess"; break;
  case AsmToken::Minus:              OS << "Minus"; break;
  case AsmToken::MinusGreater:       OS << "MinusGreater"; break;
  case AsmToken::Percent:            OS << "Percent"; break;
  case AsmToken::Pipe:               OS << "Pipe"; break;
  case AsmToken::PipePipe:           OS << "PipePipe"; break;
  case AsmToken::Plus:               OS << "Plus"; break;
  case AsmToken::RBrac:              OS << "RBrac"; break;
  case AsmToken::RCurly:             OS << "RCurly"; break;
  case AsmToken::RParen:             OS << "RParen"; break;
  case AsmToken::Slash:              OS << "Slash"; break;
  case AsmToken::Space:              OS << "Space"; break;
  case AsmToken::Star:               OS << "Star"; break;
  case AsmToken::Tilde:              OS << "Tilde"; break;
  case AsmToken::PercentCall16:      OS << "PercentCall16"; break;
  case AsmToken::PercentCall_Hi:     OS << "PercentCall_Hi"; break;
  case AsmToken::PercentCall_Lo:     OS << "PercentCall_Lo"; break;
  case AsmToken::PercentDtprel_Hi:   OS << "PercentDtprel_Hi"; break;
  case AsmToken::PercentDtprel_Lo:   OS << "PercentDtprel_Lo"; break;
  case AsmToken::PercentGot:         OS << "PercentGot"; break;
  case AsmToken::PercentGot_Disp:    OS << "PercentGot_Disp"; break;
  case AsmToken::PercentGot_Hi:      OS << "PercentGot_Hi"; break;
  case AsmToken::PercentGot_Lo:      OS << "PercentGot_Lo"; break;
  case AsmToken::PercentGot_Ofst:    OS << "PercentGot_Ofst"; break;
  case AsmToken::PercentGot_Page:    OS << "PercentGot_Page"; break;
  case AsmToken::PercentGottprel:    OS << "PercentGottprel"; break;
  case AsmToken::PercentGp_Rel:      OS << "PercentGp_Rel"; break;
  case AsmToken::PercentHi:          OS << "PercentHi"; break;
  case AsmToken::PercentHigher:      OS << "PercentHigher"; break;
  case AsmToken::PercentHighest:     OS << "PercentHighest"; break;
  case AsmToken::PercentLo:          OS << "PercentLo"; break;
  case AsmToken::PercentNeg:         OS << "PercentNeg"; break;
  case AsmToken::PercentPcrel_Hi:    OS << "PercentPcrel_Hi"; break;
  case AsmToken::PercentPcrel_Lo:    OS << "PercentPcrel_Lo"; break;
  case AsmToken::PercentTlsgd:       OS << "PercentTlsgd"; break;
  case AsmToken::PercentTlsldm:      OS << "PercentTlsldm"; break;
  case AsmToken::PercentTprel_Hi:    OS << "PercentTprel_Hi"; break;
  case AsmToken::PercentTprel_Lo:    OS << "PercentTprel_Lo"; break;
  }

  // Print the token string.
  OS << " (\"";
  OS.write_escaped(getString());
  OS << "\")";
}