46 uint64_t LLLexer::atoull(
const char *Buffer,
const char *
End) {
48 for (; Buffer !=
End; Buffer++) {
49 uint64_t OldRes = Result;
51 Result += *Buffer-
'0';
52 if (Result < OldRes) {
53 Error(
"constant bigger than 64 bits detected!");
60 uint64_t LLLexer::HexIntToVal(
const char *Buffer,
const char *End) {
62 for (; Buffer !=
End; ++Buffer) {
63 uint64_t OldRes = Result;
67 if (Result < OldRes) {
68 Error(
"constant bigger than 64 bits detected!");
75 void LLLexer::HexToIntPair(
const char *Buffer,
const char *End,
78 if (End - Buffer >= 16) {
79 for (
int i = 0;
i < 16;
i++, Buffer++) {
86 for (
int i = 0;
i < 16 && Buffer !=
End;
i++, Buffer++) {
91 Error(
"constant bigger than 128 bits detected!");
96 void LLLexer::FP80HexToIntPair(
const char *Buffer,
const char *End,
99 for (
int i=0;
i<4 && Buffer !=
End;
i++, Buffer++) {
105 for (
int i = 0;
i < 16 && Buffer !=
End;
i++, Buffer++) {
110 Error(
"constant bigger than 128 bits detected!");
116 if (Str.empty())
return;
118 char *Buffer = &Str[0], *EndBuffer = Buffer+Str.size();
120 for (
char *BIn = Buffer; BIn != EndBuffer; ) {
121 if (BIn[0] ==
'\\') {
122 if (BIn < EndBuffer-1 && BIn[1] ==
'\\') {
125 }
else if (BIn < EndBuffer-2 &&
126 isxdigit(static_cast<unsigned char>(BIn[1])) &&
127 isxdigit(static_cast<unsigned char>(BIn[2]))) {
138 Str.resize(BOut-Buffer);
143 return isalnum(static_cast<unsigned char>(C)) || C ==
'-' || C ==
'$' ||
144 C ==
'.' || C ==
'_';
150 if (CurPtr[0] ==
':')
return CurPtr+1;
163 CurPtr = CurBuf.
begin();
166 int LLLexer::getNextChar() {
167 char CurChar = *CurPtr++;
169 default:
return (
unsigned char)CurChar;
173 if (CurPtr-1 != CurBuf.
end())
186 int CurChar = getNextChar();
190 if (isalpha(static_cast<unsigned char>(CurChar)) || CurChar ==
'_')
191 return LexIdentifier();
202 case '+':
return LexPositive();
203 case '@':
return LexAt();
204 case '$':
return LexDollar();
205 case '%':
return LexPercent();
206 case '"':
return LexQuote();
210 StrVal.assign(TokStart, CurPtr-1);
213 if (CurPtr[0] ==
'.' && CurPtr[1] ==
'.') {
221 case '!':
return LexExclaim();
222 case '#':
return LexHash();
223 case '0':
case '1':
case '2':
case '3':
case '4':
224 case '5':
case '6':
case '7':
case '8':
case '9':
226 return LexDigitOrNegative();
243 void LLLexer::SkipLineComment() {
245 if (CurPtr[0] ==
'\n' || CurPtr[0] ==
'\r' || getNextChar() == EOF)
261 StrVal.assign(TokStart, CurPtr - 1);
266 if (CurPtr[0] ==
'"') {
270 int CurChar = getNextChar();
272 if (CurChar == EOF) {
273 Error(
"end of file in COMDAT variable name");
276 if (CurChar ==
'"') {
277 StrVal.assign(TokStart + 2, CurPtr - 1);
280 Error(
"Null bytes are not allowed in names");
297 const char *Start = CurPtr;
299 int CurChar = getNextChar();
301 if (CurChar == EOF) {
302 Error(
"end of file in string constant");
305 if (CurChar ==
'"') {
306 StrVal.assign(Start, CurPtr-1);
314 bool LLLexer::ReadVarName() {
315 const char *NameStart = CurPtr;
316 if (isalpha(static_cast<unsigned char>(CurPtr[0])) ||
317 CurPtr[0] ==
'-' || CurPtr[0] ==
'$' ||
318 CurPtr[0] ==
'.' || CurPtr[0] ==
'_') {
320 while (isalnum(static_cast<unsigned char>(CurPtr[0])) ||
321 CurPtr[0] ==
'-' || CurPtr[0] ==
'$' ||
322 CurPtr[0] ==
'.' || CurPtr[0] ==
'_')
325 StrVal.assign(NameStart, CurPtr);
333 if (CurPtr[0] ==
'"') {
337 int CurChar = getNextChar();
339 if (CurChar == EOF) {
340 Error(
"end of file in global variable name");
343 if (CurChar ==
'"') {
344 StrVal.assign(TokStart+2, CurPtr-1);
347 Error(
"Null bytes are not allowed in names");
360 if (isdigit(static_cast<unsigned char>(CurPtr[0]))) {
361 for (++CurPtr; isdigit(static_cast<unsigned char>(CurPtr[0])); ++CurPtr)
364 uint64_t Val = atoull(TokStart+1, CurPtr);
365 if ((
unsigned)Val != Val)
366 Error(
"invalid value number (too large)!");
389 if (CurPtr[0] ==
':') {
392 Error(
"Null bytes are not allowed in names");
407 if (isalpha(static_cast<unsigned char>(CurPtr[0])) ||
408 CurPtr[0] ==
'-' || CurPtr[0] ==
'$' ||
409 CurPtr[0] ==
'.' || CurPtr[0] ==
'_' || CurPtr[0] ==
'\\') {
411 while (isalnum(static_cast<unsigned char>(CurPtr[0])) ||
412 CurPtr[0] ==
'-' || CurPtr[0] ==
'$' ||
413 CurPtr[0] ==
'.' || CurPtr[0] ==
'_' || CurPtr[0] ==
'\\')
416 StrVal.assign(TokStart+1, CurPtr);
427 if (isdigit(static_cast<unsigned char>(CurPtr[0]))) {
428 for (++CurPtr; isdigit(static_cast<unsigned char>(CurPtr[0])); ++CurPtr)
431 uint64_t Val = atoull(TokStart+1, CurPtr);
432 if ((
unsigned)Val != Val)
433 Error(
"invalid value number (too large)!");
447 const char *StartChar = CurPtr;
448 const char *IntEnd = CurPtr[-1] ==
'i' ?
nullptr : StartChar;
449 const char *KeywordEnd =
nullptr;
453 if (!IntEnd && !isdigit(static_cast<unsigned char>(*CurPtr)))
455 if (!KeywordEnd && !isalnum(static_cast<unsigned char>(*CurPtr)) &&
461 if (*CurPtr ==
':') {
462 StrVal.assign(StartChar-1, CurPtr++);
468 if (!IntEnd) IntEnd = CurPtr;
469 if (IntEnd != StartChar) {
471 uint64_t NumBits = atoull(StartChar, CurPtr);
474 Error(
"bitwidth for integer type out of range!");
482 if (!KeywordEnd) KeywordEnd = CurPtr;
485 StringRef Keyword(StartChar, CurPtr - StartChar);
487 #define KEYWORD(STR) \
489 if (Keyword == #STR) \
490 return lltok::kw_##STR; \
513 KEYWORD(externally_initialized);
622 KEYWORD(dereferenceable_or_null);
624 KEYWORD(inaccessiblemem_or_argmemonly);
702 #define TYPEKEYWORD(STR, LLVMTY) \
704 if (Keyword == STR) { \
706 return lltok::Type; \
725 #define INSTKEYWORD(STR, Enum) \
727 if (Keyword == #STR) { \
728 UIntVal = Instruction::Enum; \
729 return lltok::kw_##STR; \
789 #define DWKEYWORD(TYPE, TOKEN) \
791 if (Keyword.startswith("DW_" #TYPE "_")) { \
792 StrVal.assign(Keyword.begin(), Keyword.end()); \
793 return lltok::TOKEN; \
807 if (Keyword.startswith(
"DIFlag")) {
808 StrVal.assign(Keyword.begin(), Keyword.end());
812 if (Keyword.startswith(
"CSK_")) {
813 StrVal.assign(Keyword.begin(), Keyword.end());
817 if (Keyword ==
"NoDebug" || Keyword ==
"FullDebug" ||
818 Keyword ==
"LineTablesOnly") {
819 StrVal.assign(Keyword.begin(), Keyword.end());
825 if ((TokStart[0] ==
'u' || TokStart[0] ==
's') &&
826 TokStart[1] ==
'0' && TokStart[2] ==
'x' &&
827 isxdigit(static_cast<unsigned char>(TokStart[3]))) {
828 int len = CurPtr-TokStart-3;
831 if (!
all_of(HexStr, isxdigit)) {
836 APInt Tmp(bits, HexStr, 16);
837 uint32_t activeBits = Tmp.getActiveBits();
838 if (activeBits > 0 && activeBits < bits)
839 Tmp = Tmp.trunc(activeBits);
840 APSIntVal =
APSInt(Tmp, TokStart[0] ==
'u');
845 if (TokStart[0] ==
'c' && TokStart[1] ==
'c') {
863 CurPtr = TokStart + 2;
866 if ((CurPtr[0] >=
'K' && CurPtr[0] <=
'M') || CurPtr[0] ==
'H') {
872 if (!isxdigit(static_cast<unsigned char>(CurPtr[0]))) {
878 while (isxdigit(static_cast<unsigned char>(CurPtr[0])))
886 APInt(64, HexIntToVal(TokStart + 2, CurPtr)));
895 FP80HexToIntPair(TokStart+3, CurPtr, Pair);
900 HexToIntPair(TokStart+3, CurPtr, Pair);
905 HexToIntPair(TokStart+3, CurPtr, Pair);
910 APInt(16,HexIntToVal(TokStart+3, CurPtr)));
926 if (!isdigit(static_cast<unsigned char>(TokStart[0])) &&
927 !isdigit(static_cast<unsigned char>(CurPtr[0]))) {
930 StrVal.assign(TokStart, End-1);
941 for (; isdigit(static_cast<unsigned char>(CurPtr[0])); ++CurPtr)
947 StrVal.assign(TokStart, End-1);
955 if (CurPtr[0] !=
'.') {
956 if (TokStart[0] ==
'0' && TokStart[1] ==
'x')
965 while (isdigit(static_cast<unsigned char>(CurPtr[0]))) ++CurPtr;
967 if (CurPtr[0] ==
'e' || CurPtr[0] ==
'E') {
968 if (isdigit(static_cast<unsigned char>(CurPtr[1])) ||
969 ((CurPtr[1] ==
'-' || CurPtr[1] ==
'+') &&
970 isdigit(static_cast<unsigned char>(CurPtr[2])))) {
972 while (isdigit(static_cast<unsigned char>(CurPtr[0]))) ++CurPtr;
986 if (!isdigit(static_cast<unsigned char>(CurPtr[0])))
990 for (++CurPtr; isdigit(static_cast<unsigned char>(CurPtr[0])); ++CurPtr)
994 if (CurPtr[0] !=
'.') {
1002 while (isdigit(static_cast<unsigned char>(CurPtr[0]))) ++CurPtr;
1004 if (CurPtr[0] ==
'e' || CurPtr[0] ==
'E') {
1005 if (isdigit(static_cast<unsigned char>(CurPtr[1])) ||
1006 ((CurPtr[1] ==
'-' || CurPtr[1] ==
'+') &&
1007 isdigit(static_cast<unsigned char>(CurPtr[2])))) {
1009 while (isdigit(static_cast<unsigned char>(CurPtr[0]))) ++CurPtr;
1014 StringRef(TokStart, CurPtr - TokStart));
Maximum number of bits that can be specified.
static Type * getDoubleTy(LLVMContext &C)
Minimum number of bits that can be specified.
static const char * isLabelTail(const char *CurPtr)
isLabelTail - Return true if this pointer points to a valid end of a label.
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly...
#define DWKEYWORD(TYPE, TOKEN)
static void cleanup(BlockFrequencyInfoImplBase &BFI)
Clear all memory not needed downstream.
static Type * getMetadataTy(LLVMContext &C)
static Type * getX86_MMXTy(LLVMContext &C)
static Type * getX86_FP80Ty(LLVMContext &C)
void Warning(LocTy WarningLoc, const Twine &Msg) const
static Type * getTokenTy(LLVMContext &C)
static const fltSemantics & x87DoubleExtended()
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
static Type * getFloatTy(LLVMContext &C)
APInt urem(const APInt &LHS, const APInt &RHS)
Function for unsigned remainder operation.
#define TYPEKEYWORD(STR, LLVMTY)
static Type * getPPC_FP128Ty(LLVMContext &C)
LLLexer(StringRef StartBuf, SourceMgr &SM, SMDiagnostic &, LLVMContext &C)
static bool isLabelChar(char C)
isLabelChar - Return true for [-a-zA-Z$._0-9].
This file implements a class to represent arbitrary precision integral constant values and operations...
APInt lshr(const APInt &LHS, unsigned shiftAmt)
Logical right-shift function.
static Type * getLabelTy(LLVMContext &C)
static bool sub(uint64_t *dest, const uint64_t *x, const uint64_t *y, unsigned len)
Subtracts the integer array y from the integer array x.
static void mul(uint64_t dest[], uint64_t x[], unsigned xlen, uint64_t y[], unsigned ylen)
Multiplies integer array x by integer array y and stores the result into the integer array dest...
APInt udiv(const APInt &LHS, const APInt &RHS)
Unsigned division function for APInt.
static bool add(uint64_t *dest, const uint64_t *x, const uint64_t *y, unsigned len)
This function adds the integer array x to the integer array Y and places the result in dest...
APInt sdiv(const APInt &LHS, const APInt &RHS)
Signed division function for APInt.
APInt ashr(const APInt &LHS, unsigned shiftAmt)
Arithmetic right-shift function.
Maximum length of the test input libFuzzer tries to guess a good value based on the corpus and reports it always prefer smaller inputs during the corpus shuffle When libFuzzer itself reports a bug this exit code will be used If indicates the maximal total time in seconds to run the fuzzer minimizes the provided crash input Use with etc Experimental Use value profile to guide fuzzing Number of simultaneous worker processes to run the jobs If min(jobs, NumberOfCpuCores()/2)\" is used.") FUZZER_FLAG_INT(reload
APInt srem(const APInt &LHS, const APInt &RHS)
Function for signed remainder operation.
This is an important class for using LLVM in a threaded context.
APInt Or(const APInt &LHS, const APInt &RHS)
Bitwise OR function for APInt.
APInt Xor(const APInt &LHS, const APInt &RHS)
Bitwise XOR function for APInt.
static const fltSemantics & IEEEhalf()
static Type * getVoidTy(LLVMContext &C)
static const unsigned End
rewrite statepoints for gc
This owns the files read by a parser, handles include stacks, and handles diagnostic wrangling...
bool Error(LocTy L, const Twine &Msg) const
static const fltSemantics & IEEEquad()
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
static Type * getFP128Ty(LLVMContext &C)
const APInt & umin(const APInt &A, const APInt &B)
Determine the smaller of two APInts considered to be signed.
static Type * getHalfTy(LLVMContext &C)
static IntegerType * get(LLVMContext &C, unsigned NumBits)
This static method is the primary way of constructing an IntegerType.
static GCRegistry::Add< ShadowStackGC > C("shadow-stack","Very portable GC for uncooperative code generators")
Class for arbitrary precision integers.
Base class for user error types.
const APInt & umax(const APInt &A, const APInt &B)
Determine the larger of two APInts considered to be unsigned.
static const fltSemantics & IEEEdouble()
APInt And(const APInt &LHS, const APInt &RHS)
Bitwise AND function for APInt.
Deduce function attributes
static const fltSemantics & PPCDoubleDouble()
static void UnEscapeLexed(std::string &Str)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static unsigned hexDigitValue(char C)
Interpret the given character C as a hexadecimal digit and return its value.
APInt shl(const APInt &LHS, unsigned shiftAmt)
Left-shift function.
StringRef - Represent a constant reference to a string, i.e.
SMDiagnostic GetMessage(SMLoc Loc, DiagKind Kind, const Twine &Msg, ArrayRef< SMRange > Ranges=None, ArrayRef< SMFixIt > FixIts=None) const
Return an SMDiagnostic at the specified location with the specified string.
void PrintMessage(raw_ostream &OS, SMLoc Loc, DiagKind Kind, const Twine &Msg, ArrayRef< SMRange > Ranges=None, ArrayRef< SMFixIt > FixIts=None, bool ShowColors=true) const
Emit a message about the specified location with the specified string.
Represents a location in source code.
#define INSTKEYWORD(STR, Enum)
Instances of this class encapsulate one diagnostic report, allowing printing to a raw_ostream as a ca...