LLVM 20.0.0git
MCAsmLexer.cpp
Go to the documentation of this file.
1//===- MCAsmLexer.cpp - Abstract Asm Lexer Interface ----------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
10#include "llvm/ADT/StringRef.h"
11#include "llvm/Support/SMLoc.h"
13
14using namespace llvm;
15
17 CurTok.emplace_back(AsmToken::Space, StringRef());
18}
19
20MCAsmLexer::~MCAsmLexer() = default;
21
24}
25
27 return SMLoc::getFromPointer(Str.data());
28}
29
31 return SMLoc::getFromPointer(Str.data() + Str.size());
32}
33
35 return SMRange(getLoc(), getEndLoc());
36}
37
39 switch (Kind) {
40 case AsmToken::Error:
41 OS << "error";
42 break;
44 OS << "identifier: " << getString();
45 break;
47 OS << "int: " << getString();
48 break;
49 case AsmToken::Real:
50 OS << "real: " << getString();
51 break;
53 OS << "string: " << getString();
54 break;
55
56 case AsmToken::Amp: OS << "Amp"; break;
57 case AsmToken::AmpAmp: OS << "AmpAmp"; break;
58 case AsmToken::At: OS << "At"; break;
59 case AsmToken::BackSlash: OS << "BackSlash"; break;
60 case AsmToken::BigNum: OS << "BigNum"; break;
61 case AsmToken::Caret: OS << "Caret"; break;
62 case AsmToken::Colon: OS << "Colon"; break;
63 case AsmToken::Comma: OS << "Comma"; break;
64 case AsmToken::Comment: OS << "Comment"; break;
65 case AsmToken::Dollar: OS << "Dollar"; break;
66 case AsmToken::Dot: OS << "Dot"; break;
67 case AsmToken::EndOfStatement: OS << "EndOfStatement"; break;
68 case AsmToken::Eof: OS << "Eof"; break;
69 case AsmToken::Equal: OS << "Equal"; break;
70 case AsmToken::EqualEqual: OS << "EqualEqual"; break;
71 case AsmToken::Exclaim: OS << "Exclaim"; break;
72 case AsmToken::ExclaimEqual: OS << "ExclaimEqual"; break;
73 case AsmToken::Greater: OS << "Greater"; break;
74 case AsmToken::GreaterEqual: OS << "GreaterEqual"; break;
75 case AsmToken::GreaterGreater: OS << "GreaterGreater"; break;
76 case AsmToken::Hash: OS << "Hash"; break;
77 case AsmToken::HashDirective: OS << "HashDirective"; break;
78 case AsmToken::LBrac: OS << "LBrac"; break;
79 case AsmToken::LCurly: OS << "LCurly"; break;
80 case AsmToken::LParen: OS << "LParen"; break;
81 case AsmToken::Less: OS << "Less"; break;
82 case AsmToken::LessEqual: OS << "LessEqual"; break;
83 case AsmToken::LessGreater: OS << "LessGreater"; break;
84 case AsmToken::LessLess: OS << "LessLess"; break;
85 case AsmToken::Minus: OS << "Minus"; break;
86 case AsmToken::MinusGreater: OS << "MinusGreater"; break;
87 case AsmToken::Percent: OS << "Percent"; break;
88 case AsmToken::Pipe: OS << "Pipe"; break;
89 case AsmToken::PipePipe: OS << "PipePipe"; break;
90 case AsmToken::Plus: OS << "Plus"; break;
91 case AsmToken::Question: OS << "Question"; break;
92 case AsmToken::RBrac: OS << "RBrac"; break;
93 case AsmToken::RCurly: OS << "RCurly"; break;
94 case AsmToken::RParen: OS << "RParen"; break;
95 case AsmToken::Slash: OS << "Slash"; break;
96 case AsmToken::Space: OS << "Space"; break;
97 case AsmToken::Star: OS << "Star"; break;
98 case AsmToken::Tilde: OS << "Tilde"; break;
99 case AsmToken::PercentCall16: OS << "PercentCall16"; break;
100 case AsmToken::PercentCall_Hi: OS << "PercentCall_Hi"; break;
101 case AsmToken::PercentCall_Lo: OS << "PercentCall_Lo"; break;
102 case AsmToken::PercentDtprel_Hi: OS << "PercentDtprel_Hi"; break;
103 case AsmToken::PercentDtprel_Lo: OS << "PercentDtprel_Lo"; break;
104 case AsmToken::PercentGot: OS << "PercentGot"; break;
105 case AsmToken::PercentGot_Disp: OS << "PercentGot_Disp"; break;
106 case AsmToken::PercentGot_Hi: OS << "PercentGot_Hi"; break;
107 case AsmToken::PercentGot_Lo: OS << "PercentGot_Lo"; break;
108 case AsmToken::PercentGot_Ofst: OS << "PercentGot_Ofst"; break;
109 case AsmToken::PercentGot_Page: OS << "PercentGot_Page"; break;
110 case AsmToken::PercentGottprel: OS << "PercentGottprel"; break;
111 case AsmToken::PercentGp_Rel: OS << "PercentGp_Rel"; break;
112 case AsmToken::PercentHi: OS << "PercentHi"; break;
113 case AsmToken::PercentHigher: OS << "PercentHigher"; break;
114 case AsmToken::PercentHighest: OS << "PercentHighest"; break;
115 case AsmToken::PercentLo: OS << "PercentLo"; break;
116 case AsmToken::PercentNeg: OS << "PercentNeg"; break;
117 case AsmToken::PercentPcrel_Hi: OS << "PercentPcrel_Hi"; break;
118 case AsmToken::PercentPcrel_Lo: OS << "PercentPcrel_Lo"; break;
119 case AsmToken::PercentTlsgd: OS << "PercentTlsgd"; break;
120 case AsmToken::PercentTlsldm: OS << "PercentTlsldm"; break;
121 case AsmToken::PercentTprel_Hi: OS << "PercentTprel_Hi"; break;
122 case AsmToken::PercentTprel_Lo: OS << "PercentTprel_Lo"; break;
123 }
124
125 // Print the token string.
126 OS << " (\"";
128 OS << "\")";
129}
raw_pwrite_stream & OS
SMLoc getLoc() const
Definition: MCAsmLexer.cpp:26
StringRef getString() const
Get the string for the current token, this includes all characters (for example, the quotes on string...
Definition: MCAsmMacro.h:110
SMLoc getEndLoc() const
Definition: MCAsmLexer.cpp:30
void dump(raw_ostream &OS) const
Definition: MCAsmLexer.cpp:38
SMRange getLocRange() const
Definition: MCAsmLexer.cpp:34
SMLoc getLoc() const
Get the current source location.
Definition: MCAsmLexer.cpp:22
const char * TokStart
Definition: MCAsmLexer.h:46
virtual ~MCAsmLexer()
Represents a location in source code.
Definition: SMLoc.h:23
static SMLoc getFromPointer(const char *Ptr)
Definition: SMLoc.h:36
Represents a range in source code.
Definition: SMLoc.h:48
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
constexpr size_t size() const
size - Get the string size.
Definition: StringRef.h:137
constexpr const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
Definition: StringRef.h:131
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:52
raw_ostream & write_escaped(StringRef Str, bool UseHexEscapes=false)
Output Str, turning '\', '\t', ' ', '"', and anything that doesn't satisfy llvm::isPrint into an esca...
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18