37void LLLexer::Error(LocTy ErrorLoc,
const Twine &Msg,
38 LLLexer::ErrorPriority Priority) {
39 if (Priority < ErrorInfo.Priority)
42 ErrorInfo.Priority = Priority;
57uint64_t LLLexer::atoull(
const char *Buffer,
const char *End) {
59 for (; Buffer != End; Buffer++) {
62 Result += *Buffer-
'0';
63 if (Result < OldRes) {
64 LexError(
"constant bigger than 64 bits detected");
71uint64_t LLLexer::HexIntToVal(
const char *Buffer,
const char *End) {
73 for (; Buffer != End; ++Buffer) {
78 if (Result < OldRes) {
79 LexError(
"constant bigger than 64 bits detected");
86void LLLexer::HexToIntPair(
const char *Buffer,
const char *End,
89 if (End - Buffer >= 16) {
90 for (
int i = 0; i < 16; i++, Buffer++) {
97 for (
int i = 0; i < 16 && Buffer != End; i++, Buffer++) {
102 LexError(
"constant bigger than 128 bits detected");
107void LLLexer::FP80HexToIntPair(
const char *Buffer,
const char *End,
110 for (
int i=0; i<4 && Buffer != End; i++, Buffer++) {
116 for (
int i = 0; i < 16 && Buffer != End; i++, Buffer++) {
121 LexError(
"constant bigger than 128 bits detected");
127 if (Str.empty())
return;
129 char *Buffer = &Str[0], *EndBuffer = Buffer+Str.size();
131 for (
char *BIn = Buffer; BIn != EndBuffer; ) {
132 if (BIn[0] ==
'\\') {
133 if (BIn < EndBuffer-1 && BIn[1] ==
'\\') {
136 }
else if (BIn < EndBuffer-2 &&
137 isxdigit(
static_cast<unsigned char>(BIn[1])) &&
138 isxdigit(
static_cast<unsigned char>(BIn[2]))) {
149 Str.resize(BOut-Buffer);
154 return isalnum(
static_cast<unsigned char>(
C)) ||
C ==
'-' ||
C ==
'$' ||
155 C ==
'.' ||
C ==
'_';
161 if (CurPtr[0] ==
':')
return CurPtr+1;
173 : CurBuf(StartBuf), ErrorInfo(Err), SM(SM), Context(
C) {
174 CurPtr = CurBuf.begin();
177int LLLexer::getNextChar() {
178 char CurChar = *CurPtr++;
180 default:
return (
unsigned char)CurChar;
184 if (CurPtr-1 != CurBuf.
end())
199 int CurChar = getNextChar();
203 if (isalpha(
static_cast<unsigned char>(CurChar)) || CurChar ==
'_')
204 return LexIdentifier();
214 case '+':
return LexPositive();
215 case '@':
return LexAt();
216 case '$':
return LexDollar();
217 case '%':
return LexPercent();
218 case '"':
return LexQuote();
222 StrVal.assign(TokStart, CurPtr-1);
225 if (CurPtr[0] ==
'.' && CurPtr[1] ==
'.') {
233 case '!':
return LexExclaim();
238 case '#':
return LexHash();
239 case '0':
case '1':
case '2':
case '3':
case '4':
240 case '5':
case '6':
case '7':
case '8':
case '9':
242 return LexDigitOrNegative();
256 if (getNextChar() !=
'*')
265void LLLexer::SkipLineComment() {
267 if (CurPtr[0] ==
'\n' || CurPtr[0] ==
'\r' || getNextChar() == EOF)
274bool LLLexer::SkipCComment() {
276 int CurChar = getNextChar();
279 LexError(
"unterminated comment");
283 CurChar = getNextChar();
286 if (CurChar == EOF) {
287 LexError(
"unterminated comment");
305 StrVal.assign(TokStart, CurPtr - 1);
310 if (CurPtr[0] ==
'"') {
314 int CurChar = getNextChar();
316 if (CurChar == EOF) {
317 LexError(
"end of file in COMDAT variable name");
320 if (CurChar ==
'"') {
321 StrVal.assign(TokStart + 2, CurPtr - 1);
323 if (StringRef(StrVal).
contains(0)) {
324 LexError(
"NUL character is not allowed in names");
341 const char *
Start = CurPtr;
343 int CurChar = getNextChar();
345 if (CurChar == EOF) {
346 LexError(
"end of file in string constant");
349 if (CurChar ==
'"') {
350 StrVal.assign(Start, CurPtr-1);
358bool LLLexer::ReadVarName() {
359 const char *NameStart = CurPtr;
360 if (isalpha(
static_cast<unsigned char>(CurPtr[0])) ||
361 CurPtr[0] ==
'-' || CurPtr[0] ==
'$' ||
362 CurPtr[0] ==
'.' || CurPtr[0] ==
'_') {
364 while (isalnum(
static_cast<unsigned char>(CurPtr[0])) ||
365 CurPtr[0] ==
'-' || CurPtr[0] ==
'$' ||
366 CurPtr[0] ==
'.' || CurPtr[0] ==
'_')
369 StrVal.assign(NameStart, CurPtr);
378 if (!isdigit(
static_cast<unsigned char>(CurPtr[0])))
381 for (++CurPtr; isdigit(
static_cast<unsigned char>(CurPtr[0])); ++CurPtr)
384 uint64_t Val = atoull(TokStart + 1, CurPtr);
385 if ((
unsigned)Val != Val)
386 LexError(
"invalid value number (too large)");
387 UIntVal = unsigned(Val);
393 if (CurPtr[0] ==
'"') {
397 int CurChar = getNextChar();
399 if (CurChar == EOF) {
400 LexError(
"end of file in global variable name");
403 if (CurChar ==
'"') {
404 StrVal.assign(TokStart+2, CurPtr-1);
406 if (StringRef(StrVal).
contains(0)) {
407 LexError(
"NUL character is not allowed in names");
420 return LexUIntID(
VarID);
439 if (CurPtr[0] ==
':') {
441 if (StringRef(StrVal).
contains(0)) {
442 LexError(
"NUL character is not allowed in names");
457 if (isalpha(
static_cast<unsigned char>(CurPtr[0])) ||
458 CurPtr[0] ==
'-' || CurPtr[0] ==
'$' ||
459 CurPtr[0] ==
'.' || CurPtr[0] ==
'_' || CurPtr[0] ==
'\\') {
461 while (isalnum(
static_cast<unsigned char>(CurPtr[0])) ||
462 CurPtr[0] ==
'-' || CurPtr[0] ==
'$' ||
463 CurPtr[0] ==
'.' || CurPtr[0] ==
'_' || CurPtr[0] ==
'\\')
466 StrVal.assign(TokStart+1, CurPtr);
485 if (isdigit(
static_cast<unsigned char>(CurPtr[0])))
496 const char *StartChar = CurPtr;
497 const char *IntEnd = CurPtr[-1] ==
'i' ? nullptr : StartChar;
498 const char *KeywordEnd =
nullptr;
502 if (!IntEnd && !isdigit(
static_cast<unsigned char>(*CurPtr)))
504 if (!KeywordEnd && !isalnum(
static_cast<unsigned char>(*CurPtr)) &&
511 if (!IgnoreColonInIdentifiers && *CurPtr ==
':') {
512 StrVal.assign(StartChar-1, CurPtr++);
518 if (!IntEnd) IntEnd = CurPtr;
519 if (IntEnd != StartChar) {
521 uint64_t NumBits = atoull(StartChar, CurPtr);
524 LexError(
"bitwidth for integer type out of range");
532 if (!KeywordEnd) KeywordEnd = CurPtr;
535 StringRef
Keyword(StartChar, CurPtr - StartChar);
537#define KEYWORD(STR) \
539 if (Keyword == #STR) \
540 return lltok::kw_##STR; \
566 KEYWORD(externally_initialized);
632 KEYWORD(no_sanitize_hwaddress);
633 KEYWORD(sanitize_address_dyninit);
647 KEYWORD(aarch64_sve_vector_pcs);
648 KEYWORD(aarch64_sme_preservemost_from_x0);
649 KEYWORD(aarch64_sme_preservemost_from_x1);
650 KEYWORD(aarch64_sme_preservemost_from_x2);
681 KEYWORD(amdgpu_cs_chain_preserve);
684 KEYWORD(amdgpu_gfx_whole_wave);
690 KEYWORD(cheriot_compartmentcallcc);
691 KEYWORD(cheriot_compartmentcalleecc);
692 KEYWORD(cheriot_librarycallcc);
701#define GET_ATTR_NAMES
702#define ATTRIBUTE_ENUM(ENUM_NAME, DISPLAY_NAME) \
703 KEYWORD(DISPLAY_NAME);
704#include "llvm/IR/Attributes.inc"
714 KEYWORD(inaccessiblemem_or_argmemonly);
832 KEYWORD(typeCheckedLoadVCalls);
833 KEYWORD(typeTestAssumeConstVCalls);
834 KEYWORD(typeCheckedLoadConstVCalls);
839 KEYWORD(typeidCompatibleVTable);
880#define TYPEKEYWORD(STR, LLVMTY) \
882 if (Keyword == STR) { \
884 return lltok::Type; \
905#define INSTKEYWORD(STR, Enum) \
907 if (Keyword == #STR) { \
908 UIntVal = Instruction::Enum; \
909 return lltok::kw_##STR; \
975#define DWKEYWORD(TYPE, TOKEN) \
977 if (Keyword.starts_with("DW_" #TYPE "_")) { \
978 StrVal.assign(Keyword.begin(), Keyword.end()); \
979 return lltok::TOKEN; \
991 DWKEYWORD(APPLE_ENUM_KIND, DwarfEnumKind);
996#define DBGRECORDTYPEKEYWORD(STR) \
998 if (Keyword == "dbg_" #STR) { \
1000 return lltok::DbgRecordType; \
1008#undef DBGRECORDTYPEKEYWORD
1010 if (
Keyword.starts_with(
"DIFlag")) {
1015 if (
Keyword.starts_with(
"DISPFlag")) {
1020 if (
Keyword.starts_with(
"CSK_")) {
1025 if (Keyword ==
"NoDebug" || Keyword ==
"FullDebug" ||
1026 Keyword ==
"LineTablesOnly" || Keyword ==
"DebugDirectivesOnly") {
1031 if (Keyword ==
"GNU" || Keyword ==
"Apple" || Keyword ==
"None" ||
1032 Keyword ==
"Default") {
1037 if (Keyword ==
"Binary" || Keyword ==
"Decimal" || Keyword ==
"Rational") {
1044 if ((TokStart[0] ==
'u' || TokStart[0] ==
's') &&
1045 TokStart[1] ==
'0' && TokStart[2] ==
'x' &&
1046 isxdigit(
static_cast<unsigned char>(TokStart[3]))) {
1047 int len = CurPtr-TokStart-3;
1048 uint32_t bits = len * 4;
1049 StringRef HexStr(TokStart + 3, len);
1050 if (!
all_of(HexStr, isxdigit)) {
1052 CurPtr = TokStart+3;
1055 APInt Tmp(bits, HexStr, 16);
1056 uint32_t activeBits = Tmp.getActiveBits();
1057 if (activeBits > 0 && activeBits < bits)
1058 Tmp = Tmp.trunc(activeBits);
1059 APSIntVal =
APSInt(Tmp, TokStart[0] ==
'u');
1064 if (TokStart[0] ==
'c' && TokStart[1] ==
'c') {
1065 CurPtr = TokStart+2;
1070 CurPtr = TokStart+1;
1083 CurPtr = TokStart + 2;
1086 if ((CurPtr[0] >=
'K' && CurPtr[0] <=
'M') || CurPtr[0] ==
'H' ||
1093 if (!isxdigit(
static_cast<unsigned char>(CurPtr[0]))) {
1095 CurPtr = TokStart+1;
1099 while (isxdigit(
static_cast<unsigned char>(CurPtr[0])))
1107 APInt(64, HexIntToVal(TokStart + 2, CurPtr)));
1116 FP80HexToIntPair(TokStart+3, CurPtr, Pair);
1121 HexToIntPair(TokStart+3, CurPtr, Pair);
1126 HexToIntPair(TokStart+3, CurPtr, Pair);
1131 APInt(16,HexIntToVal(TokStart+3, CurPtr)));
1136 APInt(16, HexIntToVal(TokStart + 3, CurPtr)));
1152 if (!isdigit(
static_cast<unsigned char>(TokStart[0])) &&
1153 !isdigit(
static_cast<unsigned char>(CurPtr[0]))) {
1156 StrVal.assign(TokStart, End-1);
1167 for (; isdigit(
static_cast<unsigned char>(CurPtr[0])); ++CurPtr)
1171 if (isdigit(TokStart[0]) && CurPtr[0] ==
':') {
1172 uint64_t Val = atoull(TokStart, CurPtr);
1174 if ((
unsigned)Val != Val)
1175 LexError(
"invalid value number (too large)");
1176 UIntVal = unsigned(Val);
1183 StrVal.assign(TokStart, End-1);
1191 if (CurPtr[0] !=
'.') {
1192 if (TokStart[0] ==
'0' && TokStart[1] ==
'x')
1194 APSIntVal =
APSInt(StringRef(TokStart, CurPtr - TokStart));
1201 while (isdigit(
static_cast<unsigned char>(CurPtr[0]))) ++CurPtr;
1203 if (CurPtr[0] ==
'e' || CurPtr[0] ==
'E') {
1204 if (isdigit(
static_cast<unsigned char>(CurPtr[1])) ||
1205 ((CurPtr[1] ==
'-' || CurPtr[1] ==
'+') &&
1206 isdigit(
static_cast<unsigned char>(CurPtr[2])))) {
1208 while (isdigit(
static_cast<unsigned char>(CurPtr[0]))) ++CurPtr;
1213 StringRef(TokStart, CurPtr - TokStart));
1222 if (!isdigit(
static_cast<unsigned char>(CurPtr[0])))
1226 for (++CurPtr; isdigit(
static_cast<unsigned char>(CurPtr[0])); ++CurPtr)
1230 if (CurPtr[0] !=
'.') {
1231 CurPtr = TokStart+1;
1238 while (isdigit(
static_cast<unsigned char>(CurPtr[0]))) ++CurPtr;
1240 if (CurPtr[0] ==
'e' || CurPtr[0] ==
'E') {
1241 if (isdigit(
static_cast<unsigned char>(CurPtr[1])) ||
1242 ((CurPtr[1] ==
'-' || CurPtr[1] ==
'+') &&
1243 isdigit(
static_cast<unsigned char>(CurPtr[2])))) {
1245 while (isdigit(
static_cast<unsigned char>(CurPtr[0]))) ++CurPtr;
1250 StringRef(TokStart, CurPtr - TokStart));
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
AMDGPU Mark last scratch load
AMDGPU Register Bank Select
This file implements a class to represent arbitrary precision integral constant values and operations...
static void cleanup(BlockFrequencyInfoImplBase &BFI)
Clear all memory not needed downstream.
static void UnEscapeLexed(std::string &Str)
static const char * isLabelTail(const char *CurPtr)
isLabelTail - Return true if this pointer points to a valid end of a label.
#define DBGRECORDTYPEKEYWORD(STR)
static bool isLabelChar(char C)
isLabelChar - Return true for [-a-zA-Z$._0-9].
#define TYPEKEYWORD(STR, LLVMTY)
#define DWKEYWORD(TYPE, TOKEN)
#define INSTKEYWORD(STR, Enum)
static constexpr auto TAG
dot regions Print regions of function to dot true view regions View regions of function(with no function bodies)"
static bool contains(SmallPtrSetImpl< ConstantExpr * > &Cache, ConstantExpr *Expr, Constant *C)
static uint64_t allOnes(unsigned int Count)
static const fltSemantics & BFloat()
static const fltSemantics & IEEEquad()
static const fltSemantics & IEEEdouble()
static const fltSemantics & x87DoubleExtended()
static const fltSemantics & IEEEhalf()
static const fltSemantics & PPCDoubleDouble()
Lightweight error class with error context and mandatory checking.
static LLVM_ABI IntegerType * get(LLVMContext &C, unsigned NumBits)
This static method is the primary way of constructing an IntegerType.
@ MIN_INT_BITS
Minimum number of bits that can be specified.
@ MAX_INT_BITS
Maximum number of bits that can be specified.
void Warning(LocTy WarningLoc, const Twine &Msg) const
LLLexer(StringRef StartBuf, SourceMgr &SM, SMDiagnostic &, LLVMContext &C)
This is an important class for using LLVM in a threaded context.
static PointerType * getUnqual(Type *ElementType)
This constructs a pointer to an object of the specified type in the default address space (address sp...
Instances of this class encapsulate one diagnostic report, allowing printing to a raw_ostream as a ca...
This owns the files read by a parser, handles include stacks, and handles diagnostic wrangling.
StringRef - Represent a constant reference to a string, i.e.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
static LLVM_ABI Type * getX86_AMXTy(LLVMContext &C)
static LLVM_ABI Type * getMetadataTy(LLVMContext &C)
static LLVM_ABI Type * getTokenTy(LLVMContext &C)
static LLVM_ABI Type * getPPC_FP128Ty(LLVMContext &C)
static LLVM_ABI Type * getFP128Ty(LLVMContext &C)
static LLVM_ABI Type * getLabelTy(LLVMContext &C)
static LLVM_ABI Type * getVoidTy(LLVMContext &C)
static LLVM_ABI Type * getDoubleTy(LLVMContext &C)
static LLVM_ABI Type * getX86_FP80Ty(LLVMContext &C)
static LLVM_ABI Type * getFloatTy(LLVMContext &C)
static LLVM_ABI Type * getBFloatTy(LLVMContext &C)
static LLVM_ABI Type * getHalfTy(LLVMContext &C)
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ C
The default llvm calling convention, compatible with C.
This is an optimization pass for GlobalISel generic memory operations.
GCNRegPressure max(const GCNRegPressure &P1, const GCNRegPressure &P2)
std::tuple< const DIScope *, const DIScope *, const DILocalVariable * > VarID
A unique key that represents a debug variable.
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
unsigned hexDigitValue(char C)
Interpret the given character C as a hexadecimal digit and return its value.
LLVM_ABI FPClassTest fneg(FPClassTest Mask)
Return the test mask which returns true if the value's sign bit is flipped.
LLVM_ABI Error write(MCStreamer &Out, ArrayRef< std::string > Inputs, OnCuIndexOverflow OverflowOptValue)
@ Or
Bitwise or logical OR of integers.
@ Mul
Product of integers.
@ Xor
Bitwise or logical XOR of integers.
@ And
Bitwise or logical AND of integers.
@ Sub
Subtraction of integers.
auto partition(R &&Range, UnaryPredicate P)
Provide wrappers to std::partition which take ranges instead of having to pass begin/end explicitly.