45uint64_t LLLexer::atoull(
const char *Buffer,
const char *
End) {
47 for (; Buffer !=
End; Buffer++) {
50 Result += *Buffer-
'0';
51 if (Result < OldRes) {
52 Error(
"constant bigger than 64 bits detected!");
59uint64_t LLLexer::HexIntToVal(
const char *Buffer,
const char *
End) {
61 for (; Buffer !=
End; ++Buffer) {
64 Result += hexDigitValue(*Buffer);
66 if (Result < OldRes) {
67 Error(
"constant bigger than 64 bits detected!");
74void LLLexer::HexToIntPair(
const char *Buffer,
const char *
End,
77 if (
End - Buffer >= 16) {
78 for (
int i = 0; i < 16; i++, Buffer++) {
81 Pair[0] += hexDigitValue(*Buffer);
85 for (
int i = 0; i < 16 && Buffer !=
End; i++, Buffer++) {
87 Pair[1] += hexDigitValue(*Buffer);
90 Error(
"constant bigger than 128 bits detected!");
95void LLLexer::FP80HexToIntPair(
const char *Buffer,
const char *
End,
98 for (
int i=0; i<4 && Buffer !=
End; i++, Buffer++) {
101 Pair[1] += hexDigitValue(*Buffer);
104 for (
int i = 0; i < 16 && Buffer !=
End; i++, Buffer++) {
106 Pair[0] += hexDigitValue(*Buffer);
109 Error(
"constant bigger than 128 bits detected!");
115 if (Str.empty())
return;
117 char *Buffer = &Str[0], *EndBuffer = Buffer+Str.size();
119 for (
char *BIn = Buffer; BIn != EndBuffer; ) {
120 if (BIn[0] ==
'\\') {
121 if (BIn < EndBuffer-1 && BIn[1] ==
'\\') {
124 }
else if (BIn < EndBuffer-2 &&
125 isxdigit(
static_cast<unsigned char>(BIn[1])) &&
126 isxdigit(
static_cast<unsigned char>(BIn[2]))) {
127 *BOut = hexDigitValue(BIn[1]) * 16 + hexDigitValue(BIn[2]);
137 Str.resize(BOut-Buffer);
142 return isalnum(
static_cast<unsigned char>(
C)) ||
C ==
'-' ||
C ==
'$' ||
143 C ==
'.' ||
C ==
'_';
149 if (CurPtr[0] ==
':')
return CurPtr+1;
161 : CurBuf(StartBuf),
ErrorInfo(Err), SM(SM), Context(
C) {
162 CurPtr = CurBuf.
begin();
165int LLLexer::getNextChar() {
166 char CurChar = *CurPtr++;
168 default:
return (
unsigned char)CurChar;
172 if (CurPtr-1 != CurBuf.
end())
185 int CurChar = getNextChar();
189 if (isalpha(
static_cast<unsigned char>(CurChar)) || CurChar ==
'_')
190 return LexIdentifier();
201 case '+':
return LexPositive();
202 case '@':
return LexAt();
203 case '$':
return LexDollar();
204 case '%':
return LexPercent();
205 case '"':
return LexQuote();
209 StrVal.assign(TokStart, CurPtr-1);
212 if (CurPtr[0] ==
'.' && CurPtr[1] ==
'.') {
220 case '!':
return LexExclaim();
225 case '#':
return LexHash();
226 case '0':
case '1':
case '2':
case '3':
case '4':
227 case '5':
case '6':
case '7':
case '8':
case '9':
229 return LexDigitOrNegative();
246void LLLexer::SkipLineComment() {
248 if (CurPtr[0] ==
'\n' || CurPtr[0] ==
'\r' || getNextChar() == EOF)
264 StrVal.assign(TokStart, CurPtr - 1);
269 if (CurPtr[0] ==
'"') {
273 int CurChar = getNextChar();
275 if (CurChar == EOF) {
276 Error(
"end of file in COMDAT variable name");
279 if (CurChar ==
'"') {
280 StrVal.assign(TokStart + 2, CurPtr - 1);
283 Error(
"Null bytes are not allowed in names");
300 const char *Start = CurPtr;
302 int CurChar = getNextChar();
304 if (CurChar == EOF) {
305 Error(
"end of file in string constant");
308 if (CurChar ==
'"') {
309 StrVal.assign(Start, CurPtr-1);
317bool LLLexer::ReadVarName() {
318 const char *NameStart = CurPtr;
319 if (isalpha(
static_cast<unsigned char>(CurPtr[0])) ||
320 CurPtr[0] ==
'-' || CurPtr[0] ==
'$' ||
321 CurPtr[0] ==
'.' || CurPtr[0] ==
'_') {
323 while (isalnum(
static_cast<unsigned char>(CurPtr[0])) ||
324 CurPtr[0] ==
'-' || CurPtr[0] ==
'$' ||
325 CurPtr[0] ==
'.' || CurPtr[0] ==
'_')
328 StrVal.assign(NameStart, CurPtr);
337 if (!isdigit(
static_cast<unsigned char>(CurPtr[0])))
340 for (++CurPtr; isdigit(
static_cast<unsigned char>(CurPtr[0])); ++CurPtr)
343 uint64_t Val = atoull(TokStart + 1, CurPtr);
344 if ((
unsigned)Val != Val)
345 Error(
"invalid value number (too large)!");
352 if (CurPtr[0] ==
'"') {
356 int CurChar = getNextChar();
358 if (CurChar == EOF) {
359 Error(
"end of file in global variable name");
362 if (CurChar ==
'"') {
363 StrVal.assign(TokStart+2, CurPtr-1);
366 Error(
"Null bytes are not allowed in names");
379 return LexUIntID(VarID);
398 if (CurPtr[0] ==
':') {
401 Error(
"Null bytes are not allowed in names");
416 if (isalpha(
static_cast<unsigned char>(CurPtr[0])) ||
417 CurPtr[0] ==
'-' || CurPtr[0] ==
'$' ||
418 CurPtr[0] ==
'.' || CurPtr[0] ==
'_' || CurPtr[0] ==
'\\') {
420 while (isalnum(
static_cast<unsigned char>(CurPtr[0])) ||
421 CurPtr[0] ==
'-' || CurPtr[0] ==
'$' ||
422 CurPtr[0] ==
'.' || CurPtr[0] ==
'_' || CurPtr[0] ==
'\\')
425 StrVal.assign(TokStart+1, CurPtr);
444 if (isdigit(
static_cast<unsigned char>(CurPtr[0])))
455 const char *StartChar = CurPtr;
456 const char *IntEnd = CurPtr[-1] ==
'i' ? nullptr : StartChar;
457 const char *KeywordEnd =
nullptr;
461 if (!IntEnd && !isdigit(
static_cast<unsigned char>(*CurPtr)))
463 if (!KeywordEnd && !isalnum(
static_cast<unsigned char>(*CurPtr)) &&
470 if (!IgnoreColonInIdentifiers && *CurPtr ==
':') {
471 StrVal.assign(StartChar-1, CurPtr++);
477 if (!IntEnd) IntEnd = CurPtr;
478 if (IntEnd != StartChar) {
480 uint64_t NumBits = atoull(StartChar, CurPtr);
483 Error(
"bitwidth for integer type out of range!");
491 if (!KeywordEnd) KeywordEnd = CurPtr;
496#define KEYWORD(STR) \
498 if (Keyword == #STR) \
499 return lltok::kw_##STR; \
525 KEYWORD(externally_initialized);
590 KEYWORD(no_sanitize_hwaddress);
591 KEYWORD(sanitize_address_dyninit);
605 KEYWORD(aarch64_sve_vector_pcs);
606 KEYWORD(aarch64_sme_preservemost_from_x0);
607 KEYWORD(aarch64_sme_preservemost_from_x1);
608 KEYWORD(aarch64_sme_preservemost_from_x2);
639 KEYWORD(amdgpu_cs_chain_preserve);
654#define GET_ATTR_NAMES
655#define ATTRIBUTE_ENUM(ENUM_NAME, DISPLAY_NAME) \
656 KEYWORD(DISPLAY_NAME);
657#include "llvm/IR/Attributes.inc"
666 KEYWORD(inaccessiblemem_or_argmemonly);
775 KEYWORD(typeCheckedLoadVCalls);
776 KEYWORD(typeTestAssumeConstVCalls);
777 KEYWORD(typeCheckedLoadConstVCalls);
782 KEYWORD(typeidCompatibleVTable);
823#define TYPEKEYWORD(STR, LLVMTY) \
825 if (Keyword == STR) { \
827 return lltok::Type; \
848#define INSTKEYWORD(STR, Enum) \
850 if (Keyword == #STR) { \
851 UIntVal = Instruction::Enum; \
852 return lltok::kw_##STR; \
917#define DWKEYWORD(TYPE, TOKEN) \
919 if (Keyword.starts_with("DW_" #TYPE "_")) { \
920 StrVal.assign(Keyword.begin(), Keyword.end()); \
921 return lltok::TOKEN; \
936#define DBGRECORDTYPEKEYWORD(STR) \
938 if (Keyword == "dbg_" #STR) { \
940 return lltok::DbgRecordType; \
948#undef DBGRECORDTYPEKEYWORD
950 if (
Keyword.starts_with(
"DIFlag")) {
955 if (
Keyword.starts_with(
"DISPFlag")) {
960 if (
Keyword.starts_with(
"CSK_")) {
965 if (Keyword ==
"NoDebug" || Keyword ==
"FullDebug" ||
966 Keyword ==
"LineTablesOnly" || Keyword ==
"DebugDirectivesOnly") {
971 if (Keyword ==
"GNU" || Keyword ==
"Apple" || Keyword ==
"None" ||
972 Keyword ==
"Default") {
979 if ((TokStart[0] ==
'u' || TokStart[0] ==
's') &&
980 TokStart[1] ==
'0' && TokStart[2] ==
'x' &&
981 isxdigit(
static_cast<unsigned char>(TokStart[3]))) {
982 int len = CurPtr-TokStart-3;
985 if (!
all_of(HexStr, isxdigit)) {
990 APInt Tmp(bits, HexStr, 16);
991 uint32_t activeBits = Tmp.getActiveBits();
992 if (activeBits > 0 && activeBits < bits)
993 Tmp = Tmp.trunc(activeBits);
994 APSIntVal =
APSInt(Tmp, TokStart[0] ==
'u');
999 if (TokStart[0] ==
'c' && TokStart[1] ==
'c') {
1000 CurPtr = TokStart+2;
1005 CurPtr = TokStart+1;
1018 CurPtr = TokStart + 2;
1021 if ((CurPtr[0] >=
'K' && CurPtr[0] <=
'M') || CurPtr[0] ==
'H' ||
1028 if (!isxdigit(
static_cast<unsigned char>(CurPtr[0]))) {
1030 CurPtr = TokStart+1;
1034 while (isxdigit(
static_cast<unsigned char>(CurPtr[0])))
1042 APInt(64, HexIntToVal(TokStart + 2, CurPtr)));
1051 FP80HexToIntPair(TokStart+3, CurPtr, Pair);
1056 HexToIntPair(TokStart+3, CurPtr, Pair);
1061 HexToIntPair(TokStart+3, CurPtr, Pair);
1066 APInt(16,HexIntToVal(TokStart+3, CurPtr)));
1071 APInt(16, HexIntToVal(TokStart + 3, CurPtr)));
1087 if (!isdigit(
static_cast<unsigned char>(TokStart[0])) &&
1088 !isdigit(
static_cast<unsigned char>(CurPtr[0]))) {
1091 StrVal.assign(TokStart,
End-1);
1102 for (; isdigit(
static_cast<unsigned char>(CurPtr[0])); ++CurPtr)
1106 if (isdigit(TokStart[0]) && CurPtr[0] ==
':') {
1107 uint64_t Val = atoull(TokStart, CurPtr);
1109 if ((
unsigned)Val != Val)
1110 Error(
"invalid value number (too large)!");
1118 StrVal.assign(TokStart,
End-1);
1126 if (CurPtr[0] !=
'.') {
1127 if (TokStart[0] ==
'0' && TokStart[1] ==
'x')
1136 while (isdigit(
static_cast<unsigned char>(CurPtr[0]))) ++CurPtr;
1138 if (CurPtr[0] ==
'e' || CurPtr[0] ==
'E') {
1139 if (isdigit(
static_cast<unsigned char>(CurPtr[1])) ||
1140 ((CurPtr[1] ==
'-' || CurPtr[1] ==
'+') &&
1141 isdigit(
static_cast<unsigned char>(CurPtr[2])))) {
1143 while (isdigit(
static_cast<unsigned char>(CurPtr[0]))) ++CurPtr;
1148 StringRef(TokStart, CurPtr - TokStart));
1157 if (!isdigit(
static_cast<unsigned char>(CurPtr[0])))
1161 for (++CurPtr; isdigit(
static_cast<unsigned char>(CurPtr[0])); ++CurPtr)
1165 if (CurPtr[0] !=
'.') {
1166 CurPtr = TokStart+1;
1173 while (isdigit(
static_cast<unsigned char>(CurPtr[0]))) ++CurPtr;
1175 if (CurPtr[0] ==
'e' || CurPtr[0] ==
'E') {
1176 if (isdigit(
static_cast<unsigned char>(CurPtr[1])) ||
1177 ((CurPtr[1] ==
'-' || CurPtr[1] ==
'+') &&
1178 isdigit(
static_cast<unsigned char>(CurPtr[2])))) {
1180 while (isdigit(
static_cast<unsigned char>(CurPtr[0]))) ++CurPtr;
1185 StringRef(TokStart, CurPtr - TokStart));
AMDGPU Mark last scratch load
amdgpu 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.
Checks Use for liveness in LiveValues If Use is not live
Performs the initial survey of the specified function
Given that RA is a live value
Find IFuncs that have resolvers that always point at the same statically known callee
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
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static uint64_t allOnes(unsigned int Count)
static bool contains(SmallPtrSetImpl< ConstantExpr * > &Cache, ConstantExpr *Expr, Constant *C)
Class for arbitrary precision integers.
An arbitrary precision integer that knows its signedness.
Base class for user error types.
Lightweight error class with error context and mandatory checking.
static 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
bool Error(LocTy ErrorLoc, 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...
Represents a location in source code.
This owns the files read by a parser, handles include stacks, and handles diagnostic wrangling.
void PrintMessage(raw_ostream &OS, SMLoc Loc, DiagKind Kind, const Twine &Msg, ArrayRef< SMRange > Ranges={}, ArrayRef< SMFixIt > FixIts={}, bool ShowColors=true) const
Emit a message about the specified location with the specified string.
SMDiagnostic GetMessage(SMLoc Loc, DiagKind Kind, const Twine &Msg, ArrayRef< SMRange > Ranges={}, ArrayRef< SMFixIt > FixIts={}) const
Return an SMDiagnostic at the specified location with the specified string.
StringRef - Represent a constant reference to a string, i.e.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
static Type * getHalfTy(LLVMContext &C)
static Type * getDoubleTy(LLVMContext &C)
static Type * getX86_FP80Ty(LLVMContext &C)
static Type * getBFloatTy(LLVMContext &C)
static Type * getX86_AMXTy(LLVMContext &C)
static Type * getMetadataTy(LLVMContext &C)
static Type * getVoidTy(LLVMContext &C)
static Type * getLabelTy(LLVMContext &C)
static Type * getFP128Ty(LLVMContext &C)
static Type * getTokenTy(LLVMContext &C)
static Type * getFloatTy(LLVMContext &C)
static Type * getPPC_FP128Ty(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)
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
FPClassTest fneg(FPClassTest Mask)
Return the test mask which returns true if the value's sign bit is flipped.
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.
auto partition(R &&Range, UnaryPredicate P)
Provide wrappers to std::partition which take ranges instead of having to pass begin/end explicitly.
static const fltSemantics & PPCDoubleDouble() LLVM_READNONE
static const fltSemantics & x87DoubleExtended() LLVM_READNONE
static const fltSemantics & IEEEquad() LLVM_READNONE
static const fltSemantics & IEEEdouble() LLVM_READNONE
static const fltSemantics & IEEEhalf() LLVM_READNONE
static const fltSemantics & BFloat() LLVM_READNONE