LLVM  16.0.0git
LLLexer.cpp
Go to the documentation of this file.
1 //===- LLLexer.cpp - Lexer for .ll Files ----------------------------------===//
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 //
9 // Implement the Lexer for .ll files.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #include "llvm/AsmParser/LLLexer.h"
14 #include "llvm/ADT/APInt.h"
15 #include "llvm/ADT/STLExtras.h"
16 #include "llvm/ADT/StringExtras.h"
17 #include "llvm/ADT/Twine.h"
18 #include "llvm/IR/DerivedTypes.h"
19 #include "llvm/IR/Instruction.h"
21 #include "llvm/Support/SourceMgr.h"
22 #include <cassert>
23 #include <cctype>
24 #include <cstdio>
25 
26 using namespace llvm;
27 
28 bool LLLexer::Error(LocTy ErrorLoc, const Twine &Msg) const {
30  return true;
31 }
32 
33 void LLLexer::Warning(LocTy WarningLoc, const Twine &Msg) const {
34  SM.PrintMessage(WarningLoc, SourceMgr::DK_Warning, Msg);
35 }
36 
37 //===----------------------------------------------------------------------===//
38 // Helper functions.
39 //===----------------------------------------------------------------------===//
40 
41 // atoull - Convert an ascii string of decimal digits into the unsigned long
42 // long representation... this does not have to do input error checking,
43 // because we know that the input will be matched by a suitable regex...
44 //
45 uint64_t LLLexer::atoull(const char *Buffer, const char *End) {
46  uint64_t Result = 0;
47  for (; Buffer != End; Buffer++) {
48  uint64_t OldRes = Result;
49  Result *= 10;
50  Result += *Buffer-'0';
51  if (Result < OldRes) { // Uh, oh, overflow detected!!!
52  Error("constant bigger than 64 bits detected!");
53  return 0;
54  }
55  }
56  return Result;
57 }
58 
59 uint64_t LLLexer::HexIntToVal(const char *Buffer, const char *End) {
60  uint64_t Result = 0;
61  for (; Buffer != End; ++Buffer) {
62  uint64_t OldRes = Result;
63  Result *= 16;
64  Result += hexDigitValue(*Buffer);
65 
66  if (Result < OldRes) { // Uh, oh, overflow detected!!!
67  Error("constant bigger than 64 bits detected!");
68  return 0;
69  }
70  }
71  return Result;
72 }
73 
74 void LLLexer::HexToIntPair(const char *Buffer, const char *End,
75  uint64_t Pair[2]) {
76  Pair[0] = 0;
77  if (End - Buffer >= 16) {
78  for (int i = 0; i < 16; i++, Buffer++) {
79  assert(Buffer != End);
80  Pair[0] *= 16;
81  Pair[0] += hexDigitValue(*Buffer);
82  }
83  }
84  Pair[1] = 0;
85  for (int i = 0; i < 16 && Buffer != End; i++, Buffer++) {
86  Pair[1] *= 16;
87  Pair[1] += hexDigitValue(*Buffer);
88  }
89  if (Buffer != End)
90  Error("constant bigger than 128 bits detected!");
91 }
92 
93 /// FP80HexToIntPair - translate an 80 bit FP80 number (20 hexits) into
94 /// { low64, high16 } as usual for an APInt.
95 void LLLexer::FP80HexToIntPair(const char *Buffer, const char *End,
96  uint64_t Pair[2]) {
97  Pair[1] = 0;
98  for (int i=0; i<4 && Buffer != End; i++, Buffer++) {
99  assert(Buffer != End);
100  Pair[1] *= 16;
101  Pair[1] += hexDigitValue(*Buffer);
102  }
103  Pair[0] = 0;
104  for (int i = 0; i < 16 && Buffer != End; i++, Buffer++) {
105  Pair[0] *= 16;
106  Pair[0] += hexDigitValue(*Buffer);
107  }
108  if (Buffer != End)
109  Error("constant bigger than 128 bits detected!");
110 }
111 
112 // UnEscapeLexed - Run through the specified buffer and change \xx codes to the
113 // appropriate character.
114 static void UnEscapeLexed(std::string &Str) {
115  if (Str.empty()) return;
116 
117  char *Buffer = &Str[0], *EndBuffer = Buffer+Str.size();
118  char *BOut = Buffer;
119  for (char *BIn = Buffer; BIn != EndBuffer; ) {
120  if (BIn[0] == '\\') {
121  if (BIn < EndBuffer-1 && BIn[1] == '\\') {
122  *BOut++ = '\\'; // Two \ becomes one
123  BIn += 2;
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]);
128  BIn += 3; // Skip over handled chars
129  ++BOut;
130  } else {
131  *BOut++ = *BIn++;
132  }
133  } else {
134  *BOut++ = *BIn++;
135  }
136  }
137  Str.resize(BOut-Buffer);
138 }
139 
140 /// isLabelChar - Return true for [-a-zA-Z$._0-9].
141 static bool isLabelChar(char C) {
142  return isalnum(static_cast<unsigned char>(C)) || C == '-' || C == '$' ||
143  C == '.' || C == '_';
144 }
145 
146 /// isLabelTail - Return true if this pointer points to a valid end of a label.
147 static const char *isLabelTail(const char *CurPtr) {
148  while (true) {
149  if (CurPtr[0] == ':') return CurPtr+1;
150  if (!isLabelChar(CurPtr[0])) return nullptr;
151  ++CurPtr;
152  }
153 }
154 
155 //===----------------------------------------------------------------------===//
156 // Lexer definition.
157 //===----------------------------------------------------------------------===//
158 
160  LLVMContext &C)
161  : CurBuf(StartBuf), ErrorInfo(Err), SM(SM), Context(C), APFloatVal(0.0),
162  IgnoreColonInIdentifiers(false) {
163  CurPtr = CurBuf.begin();
164 }
165 
166 int LLLexer::getNextChar() {
167  char CurChar = *CurPtr++;
168  switch (CurChar) {
169  default: return (unsigned char)CurChar;
170  case 0:
171  // A nul character in the stream is either the end of the current buffer or
172  // a random nul in the file. Disambiguate that here.
173  if (CurPtr-1 != CurBuf.end())
174  return 0; // Just whitespace.
175 
176  // Otherwise, return end of file.
177  --CurPtr; // Another call to lex will return EOF again.
178  return EOF;
179  }
180 }
181 
182 lltok::Kind LLLexer::LexToken() {
183  while (true) {
184  TokStart = CurPtr;
185 
186  int CurChar = getNextChar();
187  switch (CurChar) {
188  default:
189  // Handle letters: [a-zA-Z_]
190  if (isalpha(static_cast<unsigned char>(CurChar)) || CurChar == '_')
191  return LexIdentifier();
192 
193  return lltok::Error;
194  case EOF: return lltok::Eof;
195  case 0:
196  case ' ':
197  case '\t':
198  case '\n':
199  case '\r':
200  // Ignore whitespace.
201  continue;
202  case '+': return LexPositive();
203  case '@': return LexAt();
204  case '$': return LexDollar();
205  case '%': return LexPercent();
206  case '"': return LexQuote();
207  case '.':
208  if (const char *Ptr = isLabelTail(CurPtr)) {
209  CurPtr = Ptr;
210  StrVal.assign(TokStart, CurPtr-1);
211  return lltok::LabelStr;
212  }
213  if (CurPtr[0] == '.' && CurPtr[1] == '.') {
214  CurPtr += 2;
215  return lltok::dotdotdot;
216  }
217  return lltok::Error;
218  case ';':
219  SkipLineComment();
220  continue;
221  case '!': return LexExclaim();
222  case '^':
223  return LexCaret();
224  case ':':
225  return lltok::colon;
226  case '#': return LexHash();
227  case '0': case '1': case '2': case '3': case '4':
228  case '5': case '6': case '7': case '8': case '9':
229  case '-':
230  return LexDigitOrNegative();
231  case '=': return lltok::equal;
232  case '[': return lltok::lsquare;
233  case ']': return lltok::rsquare;
234  case '{': return lltok::lbrace;
235  case '}': return lltok::rbrace;
236  case '<': return lltok::less;
237  case '>': return lltok::greater;
238  case '(': return lltok::lparen;
239  case ')': return lltok::rparen;
240  case ',': return lltok::comma;
241  case '*': return lltok::star;
242  case '|': return lltok::bar;
243  }
244  }
245 }
246 
247 void LLLexer::SkipLineComment() {
248  while (true) {
249  if (CurPtr[0] == '\n' || CurPtr[0] == '\r' || getNextChar() == EOF)
250  return;
251  }
252 }
253 
254 /// Lex all tokens that start with an @ character.
255 /// GlobalVar @\"[^\"]*\"
256 /// GlobalVar @[-a-zA-Z$._][-a-zA-Z$._0-9]*
257 /// GlobalVarID @[0-9]+
258 lltok::Kind LLLexer::LexAt() {
259  return LexVar(lltok::GlobalVar, lltok::GlobalID);
260 }
261 
262 lltok::Kind LLLexer::LexDollar() {
263  if (const char *Ptr = isLabelTail(TokStart)) {
264  CurPtr = Ptr;
265  StrVal.assign(TokStart, CurPtr - 1);
266  return lltok::LabelStr;
267  }
268 
269  // Handle DollarStringConstant: $\"[^\"]*\"
270  if (CurPtr[0] == '"') {
271  ++CurPtr;
272 
273  while (true) {
274  int CurChar = getNextChar();
275 
276  if (CurChar == EOF) {
277  Error("end of file in COMDAT variable name");
278  return lltok::Error;
279  }
280  if (CurChar == '"') {
281  StrVal.assign(TokStart + 2, CurPtr - 1);
282  UnEscapeLexed(StrVal);
283  if (StringRef(StrVal).find_first_of(0) != StringRef::npos) {
284  Error("Null bytes are not allowed in names");
285  return lltok::Error;
286  }
287  return lltok::ComdatVar;
288  }
289  }
290  }
291 
292  // Handle ComdatVarName: $[-a-zA-Z$._][-a-zA-Z$._0-9]*
293  if (ReadVarName())
294  return lltok::ComdatVar;
295 
296  return lltok::Error;
297 }
298 
299 /// ReadString - Read a string until the closing quote.
300 lltok::Kind LLLexer::ReadString(lltok::Kind kind) {
301  const char *Start = CurPtr;
302  while (true) {
303  int CurChar = getNextChar();
304 
305  if (CurChar == EOF) {
306  Error("end of file in string constant");
307  return lltok::Error;
308  }
309  if (CurChar == '"') {
310  StrVal.assign(Start, CurPtr-1);
311  UnEscapeLexed(StrVal);
312  return kind;
313  }
314  }
315 }
316 
317 /// ReadVarName - Read the rest of a token containing a variable name.
318 bool LLLexer::ReadVarName() {
319  const char *NameStart = CurPtr;
320  if (isalpha(static_cast<unsigned char>(CurPtr[0])) ||
321  CurPtr[0] == '-' || CurPtr[0] == '$' ||
322  CurPtr[0] == '.' || CurPtr[0] == '_') {
323  ++CurPtr;
324  while (isalnum(static_cast<unsigned char>(CurPtr[0])) ||
325  CurPtr[0] == '-' || CurPtr[0] == '$' ||
326  CurPtr[0] == '.' || CurPtr[0] == '_')
327  ++CurPtr;
328 
329  StrVal.assign(NameStart, CurPtr);
330  return true;
331  }
332  return false;
333 }
334 
335 // Lex an ID: [0-9]+. On success, the ID is stored in UIntVal and Token is
336 // returned, otherwise the Error token is returned.
337 lltok::Kind LLLexer::LexUIntID(lltok::Kind Token) {
338  if (!isdigit(static_cast<unsigned char>(CurPtr[0])))
339  return lltok::Error;
340 
341  for (++CurPtr; isdigit(static_cast<unsigned char>(CurPtr[0])); ++CurPtr)
342  /*empty*/;
343 
344  uint64_t Val = atoull(TokStart + 1, CurPtr);
345  if ((unsigned)Val != Val)
346  Error("invalid value number (too large)!");
347  UIntVal = unsigned(Val);
348  return Token;
349 }
350 
351 lltok::Kind LLLexer::LexVar(lltok::Kind Var, lltok::Kind VarID) {
352  // Handle StringConstant: \"[^\"]*\"
353  if (CurPtr[0] == '"') {
354  ++CurPtr;
355 
356  while (true) {
357  int CurChar = getNextChar();
358 
359  if (CurChar == EOF) {
360  Error("end of file in global variable name");
361  return lltok::Error;
362  }
363  if (CurChar == '"') {
364  StrVal.assign(TokStart+2, CurPtr-1);
365  UnEscapeLexed(StrVal);
366  if (StringRef(StrVal).find_first_of(0) != StringRef::npos) {
367  Error("Null bytes are not allowed in names");
368  return lltok::Error;
369  }
370  return Var;
371  }
372  }
373  }
374 
375  // Handle VarName: [-a-zA-Z$._][-a-zA-Z$._0-9]*
376  if (ReadVarName())
377  return Var;
378 
379  // Handle VarID: [0-9]+
380  return LexUIntID(VarID);
381 }
382 
383 /// Lex all tokens that start with a % character.
384 /// LocalVar ::= %\"[^\"]*\"
385 /// LocalVar ::= %[-a-zA-Z$._][-a-zA-Z$._0-9]*
386 /// LocalVarID ::= %[0-9]+
387 lltok::Kind LLLexer::LexPercent() {
388  return LexVar(lltok::LocalVar, lltok::LocalVarID);
389 }
390 
391 /// Lex all tokens that start with a " character.
392 /// QuoteLabel "[^"]+":
393 /// StringConstant "[^"]*"
394 lltok::Kind LLLexer::LexQuote() {
395  lltok::Kind kind = ReadString(lltok::StringConstant);
396  if (kind == lltok::Error || kind == lltok::Eof)
397  return kind;
398 
399  if (CurPtr[0] == ':') {
400  ++CurPtr;
401  if (StringRef(StrVal).find_first_of(0) != StringRef::npos) {
402  Error("Null bytes are not allowed in names");
403  kind = lltok::Error;
404  } else {
405  kind = lltok::LabelStr;
406  }
407  }
408 
409  return kind;
410 }
411 
412 /// Lex all tokens that start with a ! character.
413 /// !foo
414 /// !
415 lltok::Kind LLLexer::LexExclaim() {
416  // Lex a metadata name as a MetadataVar.
417  if (isalpha(static_cast<unsigned char>(CurPtr[0])) ||
418  CurPtr[0] == '-' || CurPtr[0] == '$' ||
419  CurPtr[0] == '.' || CurPtr[0] == '_' || CurPtr[0] == '\\') {
420  ++CurPtr;
421  while (isalnum(static_cast<unsigned char>(CurPtr[0])) ||
422  CurPtr[0] == '-' || CurPtr[0] == '$' ||
423  CurPtr[0] == '.' || CurPtr[0] == '_' || CurPtr[0] == '\\')
424  ++CurPtr;
425 
426  StrVal.assign(TokStart+1, CurPtr); // Skip !
427  UnEscapeLexed(StrVal);
428  return lltok::MetadataVar;
429  }
430  return lltok::exclaim;
431 }
432 
433 /// Lex all tokens that start with a ^ character.
434 /// SummaryID ::= ^[0-9]+
435 lltok::Kind LLLexer::LexCaret() {
436  // Handle SummaryID: ^[0-9]+
437  return LexUIntID(lltok::SummaryID);
438 }
439 
440 /// Lex all tokens that start with a # character.
441 /// AttrGrpID ::= #[0-9]+
442 lltok::Kind LLLexer::LexHash() {
443  // Handle AttrGrpID: #[0-9]+
444  return LexUIntID(lltok::AttrGrpID);
445 }
446 
447 /// Lex a label, integer type, keyword, or hexadecimal integer constant.
448 /// Label [-a-zA-Z$._0-9]+:
449 /// IntegerType i[0-9]+
450 /// Keyword sdiv, float, ...
451 /// HexIntConstant [us]0x[0-9A-Fa-f]+
452 lltok::Kind LLLexer::LexIdentifier() {
453  const char *StartChar = CurPtr;
454  const char *IntEnd = CurPtr[-1] == 'i' ? nullptr : StartChar;
455  const char *KeywordEnd = nullptr;
456 
457  for (; isLabelChar(*CurPtr); ++CurPtr) {
458  // If we decide this is an integer, remember the end of the sequence.
459  if (!IntEnd && !isdigit(static_cast<unsigned char>(*CurPtr)))
460  IntEnd = CurPtr;
461  if (!KeywordEnd && !isalnum(static_cast<unsigned char>(*CurPtr)) &&
462  *CurPtr != '_')
463  KeywordEnd = CurPtr;
464  }
465 
466  // If we stopped due to a colon, unless we were directed to ignore it,
467  // this really is a label.
468  if (!IgnoreColonInIdentifiers && *CurPtr == ':') {
469  StrVal.assign(StartChar-1, CurPtr++);
470  return lltok::LabelStr;
471  }
472 
473  // Otherwise, this wasn't a label. If this was valid as an integer type,
474  // return it.
475  if (!IntEnd) IntEnd = CurPtr;
476  if (IntEnd != StartChar) {
477  CurPtr = IntEnd;
478  uint64_t NumBits = atoull(StartChar, CurPtr);
479  if (NumBits < IntegerType::MIN_INT_BITS ||
480  NumBits > IntegerType::MAX_INT_BITS) {
481  Error("bitwidth for integer type out of range!");
482  return lltok::Error;
483  }
484  TyVal = IntegerType::get(Context, NumBits);
485  return lltok::Type;
486  }
487 
488  // Otherwise, this was a letter sequence. See which keyword this is.
489  if (!KeywordEnd) KeywordEnd = CurPtr;
490  CurPtr = KeywordEnd;
491  --StartChar;
492  StringRef Keyword(StartChar, CurPtr - StartChar);
493 
494 #define KEYWORD(STR) \
495  do { \
496  if (Keyword == #STR) \
497  return lltok::kw_##STR; \
498  } while (false)
499 
500  KEYWORD(true); KEYWORD(false);
501  KEYWORD(declare); KEYWORD(define);
502  KEYWORD(global); KEYWORD(constant);
503 
504  KEYWORD(dso_local);
505  KEYWORD(dso_preemptable);
506 
507  KEYWORD(private);
508  KEYWORD(internal);
509  KEYWORD(available_externally);
510  KEYWORD(linkonce);
511  KEYWORD(linkonce_odr);
512  KEYWORD(weak); // Use as a linkage, and a modifier for "cmpxchg".
513  KEYWORD(weak_odr);
514  KEYWORD(appending);
515  KEYWORD(dllimport);
516  KEYWORD(dllexport);
517  KEYWORD(common);
518  KEYWORD(default);
519  KEYWORD(hidden);
520  KEYWORD(protected);
521  KEYWORD(unnamed_addr);
522  KEYWORD(local_unnamed_addr);
523  KEYWORD(externally_initialized);
524  KEYWORD(extern_weak);
525  KEYWORD(external);
526  KEYWORD(thread_local);
527  KEYWORD(localdynamic);
528  KEYWORD(initialexec);
529  KEYWORD(localexec);
530  KEYWORD(zeroinitializer);
531  KEYWORD(undef);
532  KEYWORD(null);
533  KEYWORD(none);
534  KEYWORD(poison);
535  KEYWORD(to);
536  KEYWORD(caller);
537  KEYWORD(within);
538  KEYWORD(from);
539  KEYWORD(tail);
540  KEYWORD(musttail);
541  KEYWORD(notail);
542  KEYWORD(target);
543  KEYWORD(triple);
544  KEYWORD(source_filename);
545  KEYWORD(unwind);
546  KEYWORD(datalayout);
547  KEYWORD(volatile);
548  KEYWORD(atomic);
549  KEYWORD(unordered);
550  KEYWORD(monotonic);
551  KEYWORD(acquire);
552  KEYWORD(release);
553  KEYWORD(acq_rel);
554  KEYWORD(seq_cst);
555  KEYWORD(syncscope);
556 
557  KEYWORD(nnan);
558  KEYWORD(ninf);
559  KEYWORD(nsz);
560  KEYWORD(arcp);
561  KEYWORD(contract);
562  KEYWORD(reassoc);
563  KEYWORD(afn);
564  KEYWORD(fast);
565  KEYWORD(nuw);
566  KEYWORD(nsw);
567  KEYWORD(exact);
568  KEYWORD(inbounds);
569  KEYWORD(inrange);
570  KEYWORD(addrspace);
571  KEYWORD(section);
573  KEYWORD(alias);
574  KEYWORD(ifunc);
575  KEYWORD(module);
576  KEYWORD(asm);
577  KEYWORD(sideeffect);
578  KEYWORD(inteldialect);
579  KEYWORD(gc);
580  KEYWORD(prefix);
581  KEYWORD(prologue);
582 
583  KEYWORD(no_sanitize_address);
584  KEYWORD(no_sanitize_hwaddress);
585  KEYWORD(sanitize_address_dyninit);
586 
587  KEYWORD(ccc);
588  KEYWORD(fastcc);
589  KEYWORD(coldcc);
590  KEYWORD(cfguard_checkcc);
591  KEYWORD(x86_stdcallcc);
592  KEYWORD(x86_fastcallcc);
593  KEYWORD(x86_thiscallcc);
594  KEYWORD(x86_vectorcallcc);
595  KEYWORD(arm_apcscc);
596  KEYWORD(arm_aapcscc);
597  KEYWORD(arm_aapcs_vfpcc);
598  KEYWORD(aarch64_vector_pcs);
599  KEYWORD(aarch64_sve_vector_pcs);
600  KEYWORD(msp430_intrcc);
601  KEYWORD(avr_intrcc);
602  KEYWORD(avr_signalcc);
603  KEYWORD(ptx_kernel);
604  KEYWORD(ptx_device);
605  KEYWORD(spir_kernel);
606  KEYWORD(spir_func);
607  KEYWORD(intel_ocl_bicc);
608  KEYWORD(x86_64_sysvcc);
609  KEYWORD(win64cc);
610  KEYWORD(x86_regcallcc);
611  KEYWORD(webkit_jscc);
612  KEYWORD(swiftcc);
613  KEYWORD(swifttailcc);
614  KEYWORD(anyregcc);
615  KEYWORD(preserve_mostcc);
616  KEYWORD(preserve_allcc);
617  KEYWORD(ghccc);
618  KEYWORD(x86_intrcc);
619  KEYWORD(hhvmcc);
620  KEYWORD(hhvm_ccc);
621  KEYWORD(cxx_fast_tlscc);
622  KEYWORD(amdgpu_vs);
623  KEYWORD(amdgpu_ls);
624  KEYWORD(amdgpu_hs);
625  KEYWORD(amdgpu_es);
626  KEYWORD(amdgpu_gs);
627  KEYWORD(amdgpu_ps);
628  KEYWORD(amdgpu_cs);
629  KEYWORD(amdgpu_kernel);
630  KEYWORD(amdgpu_gfx);
631  KEYWORD(tailcc);
632 
633  KEYWORD(cc);
634  KEYWORD(c);
635 
637  KEYWORD(sync);
638  KEYWORD(async);
639 
640 #define GET_ATTR_NAMES
641 #define ATTRIBUTE_ENUM(ENUM_NAME, DISPLAY_NAME) \
642  KEYWORD(DISPLAY_NAME);
643 #include "llvm/IR/Attributes.inc"
644 
645  KEYWORD(type);
646  KEYWORD(opaque);
647 
648  KEYWORD(comdat);
649 
650  // Comdat types
651  KEYWORD(any);
652  KEYWORD(exactmatch);
653  KEYWORD(largest);
654  KEYWORD(nodeduplicate);
655  KEYWORD(samesize);
656 
657  KEYWORD(eq); KEYWORD(ne); KEYWORD(slt); KEYWORD(sgt); KEYWORD(sle);
658  KEYWORD(sge); KEYWORD(ult); KEYWORD(ugt); KEYWORD(ule); KEYWORD(uge);
659  KEYWORD(oeq); KEYWORD(one); KEYWORD(olt); KEYWORD(ogt); KEYWORD(ole);
660  KEYWORD(oge); KEYWORD(ord); KEYWORD(uno); KEYWORD(ueq); KEYWORD(une);
661 
662  KEYWORD(xchg); KEYWORD(nand); KEYWORD(max); KEYWORD(min); KEYWORD(umax);
663  KEYWORD(umin); KEYWORD(fmax); KEYWORD(fmin);
664 
665  KEYWORD(vscale);
666  KEYWORD(x);
667  KEYWORD(blockaddress);
668  KEYWORD(dso_local_equivalent);
669  KEYWORD(no_cfi);
670 
671  // Metadata types.
672  KEYWORD(distinct);
673 
674  // Use-list order directives.
675  KEYWORD(uselistorder);
676  KEYWORD(uselistorder_bb);
677 
678  KEYWORD(personality);
679  KEYWORD(cleanup);
680  KEYWORD(catch);
681  KEYWORD(filter);
682 
683  // Summary index keywords.
684  KEYWORD(path);
685  KEYWORD(hash);
686  KEYWORD(gv);
687  KEYWORD(guid);
688  KEYWORD(name);
689  KEYWORD(summaries);
690  KEYWORD(flags);
691  KEYWORD(blockcount);
692  KEYWORD(linkage);
693  KEYWORD(visibility);
694  KEYWORD(notEligibleToImport);
695  KEYWORD(live);
696  KEYWORD(dsoLocal);
697  KEYWORD(canAutoHide);
698  KEYWORD(function);
699  KEYWORD(insts);
700  KEYWORD(funcFlags);
701  KEYWORD(readNone);
702  KEYWORD(readOnly);
703  KEYWORD(noRecurse);
704  KEYWORD(returnDoesNotAlias);
705  KEYWORD(noInline);
706  KEYWORD(alwaysInline);
707  KEYWORD(noUnwind);
708  KEYWORD(mayThrow);
709  KEYWORD(hasUnknownCall);
710  KEYWORD(mustBeUnreachable);
711  KEYWORD(calls);
712  KEYWORD(callee);
713  KEYWORD(params);
714  KEYWORD(param);
715  KEYWORD(hotness);
716  KEYWORD(unknown);
717  KEYWORD(critical);
718  KEYWORD(relbf);
719  KEYWORD(variable);
720  KEYWORD(vTableFuncs);
721  KEYWORD(virtFunc);
722  KEYWORD(aliasee);
723  KEYWORD(refs);
724  KEYWORD(typeIdInfo);
725  KEYWORD(typeTests);
726  KEYWORD(typeTestAssumeVCalls);
727  KEYWORD(typeCheckedLoadVCalls);
728  KEYWORD(typeTestAssumeConstVCalls);
729  KEYWORD(typeCheckedLoadConstVCalls);
730  KEYWORD(vFuncId);
731  KEYWORD(offset);
732  KEYWORD(args);
733  KEYWORD(typeid);
734  KEYWORD(typeidCompatibleVTable);
735  KEYWORD(summary);
736  KEYWORD(typeTestRes);
737  KEYWORD(kind);
738  KEYWORD(unsat);
739  KEYWORD(byteArray);
740  KEYWORD(inline);
741  KEYWORD(single);
742  KEYWORD(allOnes);
743  KEYWORD(sizeM1BitWidth);
744  KEYWORD(alignLog2);
745  KEYWORD(sizeM1);
746  KEYWORD(bitMask);
747  KEYWORD(inlineBits);
748  KEYWORD(vcall_visibility);
749  KEYWORD(wpdResolutions);
750  KEYWORD(wpdRes);
751  KEYWORD(indir);
752  KEYWORD(singleImpl);
753  KEYWORD(branchFunnel);
754  KEYWORD(singleImplName);
755  KEYWORD(resByArg);
756  KEYWORD(byArg);
757  KEYWORD(uniformRetVal);
758  KEYWORD(uniqueRetVal);
759  KEYWORD(virtualConstProp);
760  KEYWORD(info);
761  KEYWORD(byte);
762  KEYWORD(bit);
763  KEYWORD(varFlags);
764 
765 #undef KEYWORD
766 
767  // Keywords for types.
768 #define TYPEKEYWORD(STR, LLVMTY) \
769  do { \
770  if (Keyword == STR) { \
771  TyVal = LLVMTY; \
772  return lltok::Type; \
773  } \
774  } while (false)
775 
776  TYPEKEYWORD("void", Type::getVoidTy(Context));
777  TYPEKEYWORD("half", Type::getHalfTy(Context));
778  TYPEKEYWORD("bfloat", Type::getBFloatTy(Context));
779  TYPEKEYWORD("float", Type::getFloatTy(Context));
780  TYPEKEYWORD("double", Type::getDoubleTy(Context));
781  TYPEKEYWORD("x86_fp80", Type::getX86_FP80Ty(Context));
782  TYPEKEYWORD("fp128", Type::getFP128Ty(Context));
783  TYPEKEYWORD("ppc_fp128", Type::getPPC_FP128Ty(Context));
784  TYPEKEYWORD("label", Type::getLabelTy(Context));
785  TYPEKEYWORD("metadata", Type::getMetadataTy(Context));
786  TYPEKEYWORD("x86_mmx", Type::getX86_MMXTy(Context));
787  TYPEKEYWORD("x86_amx", Type::getX86_AMXTy(Context));
788  TYPEKEYWORD("token", Type::getTokenTy(Context));
789 
790  if (Keyword == "ptr") {
791  // setOpaquePointers() must be called before creating any pointer types.
792  if (!Context.hasSetOpaquePointersValue()) {
793  Context.setOpaquePointers(true);
794  } else if (Context.supportsTypedPointers()) {
795  Warning("ptr type is only supported in -opaque-pointers mode");
796  return lltok::Error;
797  }
798  TyVal = PointerType::getUnqual(Context);
799  return lltok::Type;
800  }
801 
802 #undef TYPEKEYWORD
803 
804  // Keywords for instructions.
805 #define INSTKEYWORD(STR, Enum) \
806  do { \
807  if (Keyword == #STR) { \
808  UIntVal = Instruction::Enum; \
809  return lltok::kw_##STR; \
810  } \
811  } while (false)
812 
813  INSTKEYWORD(fneg, FNeg);
814 
815  INSTKEYWORD(add, Add); INSTKEYWORD(fadd, FAdd);
816  INSTKEYWORD(sub, Sub); INSTKEYWORD(fsub, FSub);
817  INSTKEYWORD(mul, Mul); INSTKEYWORD(fmul, FMul);
818  INSTKEYWORD(udiv, UDiv); INSTKEYWORD(sdiv, SDiv); INSTKEYWORD(fdiv, FDiv);
819  INSTKEYWORD(urem, URem); INSTKEYWORD(srem, SRem); INSTKEYWORD(frem, FRem);
820  INSTKEYWORD(shl, Shl); INSTKEYWORD(lshr, LShr); INSTKEYWORD(ashr, AShr);
821  INSTKEYWORD(and, And); INSTKEYWORD(or, Or); INSTKEYWORD(xor, Xor);
822  INSTKEYWORD(icmp, ICmp); INSTKEYWORD(fcmp, FCmp);
823 
824  INSTKEYWORD(phi, PHI);
825  INSTKEYWORD(call, Call);
826  INSTKEYWORD(trunc, Trunc);
827  INSTKEYWORD(zext, ZExt);
828  INSTKEYWORD(sext, SExt);
829  INSTKEYWORD(fptrunc, FPTrunc);
830  INSTKEYWORD(fpext, FPExt);
831  INSTKEYWORD(uitofp, UIToFP);
832  INSTKEYWORD(sitofp, SIToFP);
833  INSTKEYWORD(fptoui, FPToUI);
834  INSTKEYWORD(fptosi, FPToSI);
835  INSTKEYWORD(inttoptr, IntToPtr);
836  INSTKEYWORD(ptrtoint, PtrToInt);
837  INSTKEYWORD(bitcast, BitCast);
838  INSTKEYWORD(addrspacecast, AddrSpaceCast);
840  INSTKEYWORD(va_arg, VAArg);
841  INSTKEYWORD(ret, Ret);
842  INSTKEYWORD(br, Br);
843  INSTKEYWORD(switch, Switch);
844  INSTKEYWORD(indirectbr, IndirectBr);
845  INSTKEYWORD(invoke, Invoke);
846  INSTKEYWORD(resume, Resume);
847  INSTKEYWORD(unreachable, Unreachable);
848  INSTKEYWORD(callbr, CallBr);
849 
850  INSTKEYWORD(alloca, Alloca);
853  INSTKEYWORD(cmpxchg, AtomicCmpXchg);
854  INSTKEYWORD(atomicrmw, AtomicRMW);
855  INSTKEYWORD(fence, Fence);
856  INSTKEYWORD(getelementptr, GetElementPtr);
857 
858  INSTKEYWORD(extractelement, ExtractElement);
859  INSTKEYWORD(insertelement, InsertElement);
860  INSTKEYWORD(shufflevector, ShuffleVector);
861  INSTKEYWORD(extractvalue, ExtractValue);
862  INSTKEYWORD(insertvalue, InsertValue);
863  INSTKEYWORD(landingpad, LandingPad);
864  INSTKEYWORD(cleanupret, CleanupRet);
865  INSTKEYWORD(catchret, CatchRet);
866  INSTKEYWORD(catchswitch, CatchSwitch);
867  INSTKEYWORD(catchpad, CatchPad);
868  INSTKEYWORD(cleanuppad, CleanupPad);
869 
870  INSTKEYWORD(freeze, Freeze);
871 
872 #undef INSTKEYWORD
873 
874 #define DWKEYWORD(TYPE, TOKEN) \
875  do { \
876  if (Keyword.startswith("DW_" #TYPE "_")) { \
877  StrVal.assign(Keyword.begin(), Keyword.end()); \
878  return lltok::TOKEN; \
879  } \
880  } while (false)
881 
884  DWKEYWORD(VIRTUALITY, DwarfVirtuality);
885  DWKEYWORD(LANG, DwarfLang);
886  DWKEYWORD(CC, DwarfCC);
887  DWKEYWORD(OP, DwarfOp);
888  DWKEYWORD(MACINFO, DwarfMacinfo);
889 
890 #undef DWKEYWORD
891 
892  if (Keyword.startswith("DIFlag")) {
893  StrVal.assign(Keyword.begin(), Keyword.end());
894  return lltok::DIFlag;
895  }
896 
897  if (Keyword.startswith("DISPFlag")) {
898  StrVal.assign(Keyword.begin(), Keyword.end());
899  return lltok::DISPFlag;
900  }
901 
902  if (Keyword.startswith("CSK_")) {
903  StrVal.assign(Keyword.begin(), Keyword.end());
904  return lltok::ChecksumKind;
905  }
906 
907  if (Keyword == "NoDebug" || Keyword == "FullDebug" ||
908  Keyword == "LineTablesOnly" || Keyword == "DebugDirectivesOnly") {
909  StrVal.assign(Keyword.begin(), Keyword.end());
910  return lltok::EmissionKind;
911  }
912 
913  if (Keyword == "GNU" || Keyword == "None" || Keyword == "Default") {
914  StrVal.assign(Keyword.begin(), Keyword.end());
915  return lltok::NameTableKind;
916  }
917 
918  // Check for [us]0x[0-9A-Fa-f]+ which are Hexadecimal constant generated by
919  // the CFE to avoid forcing it to deal with 64-bit numbers.
920  if ((TokStart[0] == 'u' || TokStart[0] == 's') &&
921  TokStart[1] == '0' && TokStart[2] == 'x' &&
922  isxdigit(static_cast<unsigned char>(TokStart[3]))) {
923  int len = CurPtr-TokStart-3;
924  uint32_t bits = len * 4;
925  StringRef HexStr(TokStart + 3, len);
926  if (!all_of(HexStr, isxdigit)) {
927  // Bad token, return it as an error.
928  CurPtr = TokStart+3;
929  return lltok::Error;
930  }
931  APInt Tmp(bits, HexStr, 16);
932  uint32_t activeBits = Tmp.getActiveBits();
933  if (activeBits > 0 && activeBits < bits)
934  Tmp = Tmp.trunc(activeBits);
935  APSIntVal = APSInt(Tmp, TokStart[0] == 'u');
936  return lltok::APSInt;
937  }
938 
939  // If this is "cc1234", return this as just "cc".
940  if (TokStart[0] == 'c' && TokStart[1] == 'c') {
941  CurPtr = TokStart+2;
942  return lltok::kw_cc;
943  }
944 
945  // Finally, if this isn't known, return an error.
946  CurPtr = TokStart+1;
947  return lltok::Error;
948 }
949 
950 /// Lex all tokens that start with a 0x prefix, knowing they match and are not
951 /// labels.
952 /// HexFPConstant 0x[0-9A-Fa-f]+
953 /// HexFP80Constant 0xK[0-9A-Fa-f]+
954 /// HexFP128Constant 0xL[0-9A-Fa-f]+
955 /// HexPPC128Constant 0xM[0-9A-Fa-f]+
956 /// HexHalfConstant 0xH[0-9A-Fa-f]+
957 /// HexBFloatConstant 0xR[0-9A-Fa-f]+
958 lltok::Kind LLLexer::Lex0x() {
959  CurPtr = TokStart + 2;
960 
961  char Kind;
962  if ((CurPtr[0] >= 'K' && CurPtr[0] <= 'M') || CurPtr[0] == 'H' ||
963  CurPtr[0] == 'R') {
964  Kind = *CurPtr++;
965  } else {
966  Kind = 'J';
967  }
968 
969  if (!isxdigit(static_cast<unsigned char>(CurPtr[0]))) {
970  // Bad token, return it as an error.
971  CurPtr = TokStart+1;
972  return lltok::Error;
973  }
974 
975  while (isxdigit(static_cast<unsigned char>(CurPtr[0])))
976  ++CurPtr;
977 
978  if (Kind == 'J') {
979  // HexFPConstant - Floating point constant represented in IEEE format as a
980  // hexadecimal number for when exponential notation is not precise enough.
981  // Half, BFloat, Float, and double only.
982  APFloatVal = APFloat(APFloat::IEEEdouble(),
983  APInt(64, HexIntToVal(TokStart + 2, CurPtr)));
984  return lltok::APFloat;
985  }
986 
987  uint64_t Pair[2];
988  switch (Kind) {
989  default: llvm_unreachable("Unknown kind!");
990  case 'K':
991  // F80HexFPConstant - x87 long double in hexadecimal format (10 bytes)
992  FP80HexToIntPair(TokStart+3, CurPtr, Pair);
993  APFloatVal = APFloat(APFloat::x87DoubleExtended(), APInt(80, Pair));
994  return lltok::APFloat;
995  case 'L':
996  // F128HexFPConstant - IEEE 128-bit in hexadecimal format (16 bytes)
997  HexToIntPair(TokStart+3, CurPtr, Pair);
998  APFloatVal = APFloat(APFloat::IEEEquad(), APInt(128, Pair));
999  return lltok::APFloat;
1000  case 'M':
1001  // PPC128HexFPConstant - PowerPC 128-bit in hexadecimal format (16 bytes)
1002  HexToIntPair(TokStart+3, CurPtr, Pair);
1003  APFloatVal = APFloat(APFloat::PPCDoubleDouble(), APInt(128, Pair));
1004  return lltok::APFloat;
1005  case 'H':
1006  APFloatVal = APFloat(APFloat::IEEEhalf(),
1007  APInt(16,HexIntToVal(TokStart+3, CurPtr)));
1008  return lltok::APFloat;
1009  case 'R':
1010  // Brain floating point
1011  APFloatVal = APFloat(APFloat::BFloat(),
1012  APInt(16, HexIntToVal(TokStart + 3, CurPtr)));
1013  return lltok::APFloat;
1014  }
1015 }
1016 
1017 /// Lex tokens for a label or a numeric constant, possibly starting with -.
1018 /// Label [-a-zA-Z$._0-9]+:
1019 /// NInteger -[0-9]+
1020 /// FPConstant [-+]?[0-9]+[.][0-9]*([eE][-+]?[0-9]+)?
1021 /// PInteger [0-9]+
1022 /// HexFPConstant 0x[0-9A-Fa-f]+
1023 /// HexFP80Constant 0xK[0-9A-Fa-f]+
1024 /// HexFP128Constant 0xL[0-9A-Fa-f]+
1025 /// HexPPC128Constant 0xM[0-9A-Fa-f]+
1026 lltok::Kind LLLexer::LexDigitOrNegative() {
1027  // If the letter after the negative is not a number, this is probably a label.
1028  if (!isdigit(static_cast<unsigned char>(TokStart[0])) &&
1029  !isdigit(static_cast<unsigned char>(CurPtr[0]))) {
1030  // Okay, this is not a number after the -, it's probably a label.
1031  if (const char *End = isLabelTail(CurPtr)) {
1032  StrVal.assign(TokStart, End-1);
1033  CurPtr = End;
1034  return lltok::LabelStr;
1035  }
1036 
1037  return lltok::Error;
1038  }
1039 
1040  // At this point, it is either a label, int or fp constant.
1041 
1042  // Skip digits, we have at least one.
1043  for (; isdigit(static_cast<unsigned char>(CurPtr[0])); ++CurPtr)
1044  /*empty*/;
1045 
1046  // Check if this is a fully-numeric label:
1047  if (isdigit(TokStart[0]) && CurPtr[0] == ':') {
1048  uint64_t Val = atoull(TokStart, CurPtr);
1049  ++CurPtr; // Skip the colon.
1050  if ((unsigned)Val != Val)
1051  Error("invalid value number (too large)!");
1052  UIntVal = unsigned(Val);
1053  return lltok::LabelID;
1054  }
1055 
1056  // Check to see if this really is a string label, e.g. "-1:".
1057  if (isLabelChar(CurPtr[0]) || CurPtr[0] == ':') {
1058  if (const char *End = isLabelTail(CurPtr)) {
1059  StrVal.assign(TokStart, End-1);
1060  CurPtr = End;
1061  return lltok::LabelStr;
1062  }
1063  }
1064 
1065  // If the next character is a '.', then it is a fp value, otherwise its
1066  // integer.
1067  if (CurPtr[0] != '.') {
1068  if (TokStart[0] == '0' && TokStart[1] == 'x')
1069  return Lex0x();
1070  APSIntVal = APSInt(StringRef(TokStart, CurPtr - TokStart));
1071  return lltok::APSInt;
1072  }
1073 
1074  ++CurPtr;
1075 
1076  // Skip over [0-9]*([eE][-+]?[0-9]+)?
1077  while (isdigit(static_cast<unsigned char>(CurPtr[0]))) ++CurPtr;
1078 
1079  if (CurPtr[0] == 'e' || CurPtr[0] == 'E') {
1080  if (isdigit(static_cast<unsigned char>(CurPtr[1])) ||
1081  ((CurPtr[1] == '-' || CurPtr[1] == '+') &&
1082  isdigit(static_cast<unsigned char>(CurPtr[2])))) {
1083  CurPtr += 2;
1084  while (isdigit(static_cast<unsigned char>(CurPtr[0]))) ++CurPtr;
1085  }
1086  }
1087 
1088  APFloatVal = APFloat(APFloat::IEEEdouble(),
1089  StringRef(TokStart, CurPtr - TokStart));
1090  return lltok::APFloat;
1091 }
1092 
1093 /// Lex a floating point constant starting with +.
1094 /// FPConstant [-+]?[0-9]+[.][0-9]*([eE][-+]?[0-9]+)?
1095 lltok::Kind LLLexer::LexPositive() {
1096  // If the letter after the negative is a number, this is probably not a
1097  // label.
1098  if (!isdigit(static_cast<unsigned char>(CurPtr[0])))
1099  return lltok::Error;
1100 
1101  // Skip digits.
1102  for (++CurPtr; isdigit(static_cast<unsigned char>(CurPtr[0])); ++CurPtr)
1103  /*empty*/;
1104 
1105  // At this point, we need a '.'.
1106  if (CurPtr[0] != '.') {
1107  CurPtr = TokStart+1;
1108  return lltok::Error;
1109  }
1110 
1111  ++CurPtr;
1112 
1113  // Skip over [0-9]*([eE][-+]?[0-9]+)?
1114  while (isdigit(static_cast<unsigned char>(CurPtr[0]))) ++CurPtr;
1115 
1116  if (CurPtr[0] == 'e' || CurPtr[0] == 'E') {
1117  if (isdigit(static_cast<unsigned char>(CurPtr[1])) ||
1118  ((CurPtr[1] == '-' || CurPtr[1] == '+') &&
1119  isdigit(static_cast<unsigned char>(CurPtr[2])))) {
1120  CurPtr += 2;
1121  while (isdigit(static_cast<unsigned char>(CurPtr[0]))) ++CurPtr;
1122  }
1123  }
1124 
1125  APFloatVal = APFloat(APFloat::IEEEdouble(),
1126  StringRef(TokStart, CurPtr - TokStart));
1127  return lltok::APFloat;
1128 }
i
i
Definition: README.txt:29
llvm::lltok::APFloat
@ APFloat
Definition: LLToken.h:436
llvm::LLLexer::LLLexer
LLLexer(StringRef StartBuf, SourceMgr &SM, SMDiagnostic &, LLVMContext &C)
Definition: LLLexer.cpp:159
isLabelTail
static const char * isLabelTail(const char *CurPtr)
isLabelTail - Return true if this pointer points to a valid end of a label.
Definition: LLLexer.cpp:147
constant
we should consider alternate ways to model stack dependencies Lots of things could be done in WebAssemblyTargetTransformInfo cpp there are numerous optimization related hooks that can be overridden in WebAssemblyTargetLowering Instead of the OptimizeReturned which should consider preserving the returned attribute through to MachineInstrs and extending the MemIntrinsicResults pass to do this optimization on calls too That would also let the WebAssemblyPeephole pass clean up dead defs for such as it does for stores Consider implementing and or getMachineCombinerPatterns Find a clean way to fix the problem which leads to the Shrink Wrapping pass being run after the WebAssembly PEI pass When setting multiple variables to the same constant
Definition: README.txt:91
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
llvm::lltok::Error
@ Error
Definition: LLToken.h:21
TYPEKEYWORD
#define TYPEKEYWORD(STR, LLVMTY)
contract
objc arc contract
Definition: ObjCARCContract.cpp:725
llvm::Type::getFP128Ty
static Type * getFP128Ty(LLVMContext &C)
Definition: Type.cpp:231
TAG
static constexpr auto TAG
Definition: OpenMPOpt.cpp:172
llvm::lltok::lparen
@ lparen
Definition: LLToken.h:34
llvm::LLLexer::Error
bool Error(LocTy ErrorLoc, const Twine &Msg) const
Definition: LLLexer.cpp:28
store
Common register allocation spilling lr str ldr sxth r3 ldr mla r4 can lr mov lr str ldr sxth r3 mla r4 and then merge mul and lr str ldr sxth r3 mla r4 It also increase the likelihood the store may become dead bb27 Successors according to LLVM ID Predecessors according to mbb< bb27, 0x8b0a7c0 > Note ADDri is not a two address instruction its result reg1037 is an operand of the PHI node in bb76 and its operand reg1039 is the result of the PHI node We should treat it as a two address code and make sure the ADDri is scheduled after any node that reads reg1039 Use info(i.e. register scavenger) to assign it a free register to allow reuse the collector could move the objects and invalidate the derived pointer This is bad enough in the first but safe points can crop up unpredictably **array_addr i32 n y store obj obj **nth_el If the i64 division is lowered to a then a safe point array and nth_el no longer point into the correct object The fix for this is to copy address calculations so that dependent pointers are never live across safe point boundaries But the loads cannot be copied like this if there was an intervening store
Definition: README.txt:133
llvm::lltok::NameTableKind
@ NameTableKind
Definition: LLToken.h:426
llvm::lltok::LocalVar
@ LocalVar
Definition: LLToken.h:417
llvm::StringRef::npos
static constexpr size_t npos
Definition: StringRef.h:52
llvm::lltok::bar
@ bar
Definition: LLToken.h:37
KEYWORD
#define KEYWORD(STR)
ErrorHandling.h
llvm::lltok::DwarfMacinfo
@ DwarfMacinfo
Definition: LLToken.h:430
llvm::WebAssembly::mayThrow
bool mayThrow(const MachineInstr &MI)
Definition: WebAssemblyUtilities.cpp:64
llvm::lltok::Eof
@ Eof
Definition: LLToken.h:20
llvm::lltok::APSInt
@ APSInt
Definition: LLToken.h:437
llvm::APFloatBase::x87DoubleExtended
static const fltSemantics & x87DoubleExtended() LLVM_READNONE
Definition: APFloat.cpp:179
cleanup
static void cleanup(BlockFrequencyInfoImplBase &BFI)
Clear all memory not needed downstream.
Definition: BlockFrequencyInfoImpl.cpp:303
APInt.h
to
Should compile to
Definition: README.txt:449
llvm::APFloatBase::BFloat
static const fltSemantics & BFloat() LLVM_READNONE
Definition: APFloat.cpp:167
llvm::LLVMContext::hasSetOpaquePointersValue
bool hasSetOpaquePointersValue() const
Whether we've decided on using opaque pointers or typed pointers yet.
Definition: LLVMContext.cpp:366
llvm::Type::getTokenTy
static Type * getTokenTy(LLVMContext &C)
Definition: Type.cpp:229
llvm::lltok::star
@ star
Definition: LLToken.h:27
ret
to esp esp setne al movzbw ax esp setg cl movzbw cx cmove cx cl jne LBB1_2 esp ret(also really horrible code on ppc). This is due to the expand code for 64-bit compares. GCC produces multiple branches
llvm::IntegerType::MIN_INT_BITS
@ MIN_INT_BITS
Minimum number of bits that can be specified.
Definition: DerivedTypes.h:51
llvm::lltok::greater
@ greater
Definition: LLToken.h:33
llvm::max
Expected< ExpressionValue > max(const ExpressionValue &Lhs, const ExpressionValue &Rhs)
Definition: FileCheck.cpp:337
attributes
Deduce and propagate attributes
Definition: Attributor.cpp:3563
llvm::MipsISD::Ret
@ Ret
Definition: MipsISelLowering.h:119
STLExtras.h
llvm::LLVMContext::setOpaquePointers
void setOpaquePointers(bool Enable) const
Set whether opaque pointers are enabled.
Definition: LLVMContext.cpp:370
llvm::lltok::less
@ less
Definition: LLToken.h:32
caller
int caller(int32 arg1, int32 arg2)
Definition: README.txt:681
and
We currently generate a but we really shouldn eax ecx xorl edx divl ecx eax divl ecx movl eax ret A similar code sequence works for division We currently compile i32 v2 eax eax jo LBB1_2 and
Definition: README.txt:1271
llvm::LegalityPredicates::any
Predicate any(Predicate P0, Predicate P1)
True iff P0 or P1 are true.
Definition: LegalizerInfo.h:241
llvm::lltok::AttrGrpID
@ AttrGrpID
Definition: LLToken.h:410
llvm::APIntOps::umin
const APInt & umin(const APInt &A, const APInt &B)
Determine the smaller of two APInts considered to be unsigned.
Definition: APInt.h:2137
llvm::APFloatBase::IEEEquad
static const fltSemantics & IEEEquad() LLVM_READNONE
Definition: APFloat.cpp:176
llvm::lltok::equal
@ equal
Definition: LLToken.h:25
Context
LLVMContext & Context
Definition: NVVMIntrRange.cpp:66
Instruction.h
llvm::Type::getMetadataTy
static Type * getMetadataTy(LLVMContext &C)
Definition: Type.cpp:228
llvm::all_of
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
Definition: STLExtras.h:1618
llvm::Type::getX86_AMXTy
static Type * getX86_AMXTy(LLVMContext &C)
Definition: Type.cpp:234
llvm::LLVMContext::supportsTypedPointers
bool supportsTypedPointers() const
Whether typed pointers are supported. If false, all pointers are opaque.
Definition: LLVMContext.cpp:374
llvm::lltok::rparen
@ rparen
Definition: LLToken.h:35
select
into xmm2 addss xmm2 xmm1 xmm3 addss xmm3 movaps xmm0 unpcklps xmm0 ret seems silly when it could just be one addps Expand libm rounding functions main should enable SSE DAZ mode and other fast SSE modes Think about doing i64 math in SSE regs on x86 This testcase should have no SSE instructions in and only one load from a constant double ret double C the select is being which prevents the dag combiner from turning select(load CPI1)
llvm::SMLoc
Represents a location in source code.
Definition: SMLoc.h:23
bits
demanded bits
Definition: DemandedBits.cpp:57
shl
We currently generate a but we really shouldn eax ecx xorl edx divl ecx eax divl ecx movl eax ret A similar code sequence works for division We currently compile i32 v2 eax eax jo LBB1_2 shl
Definition: README.txt:1271
llvm::Type::getPPC_FP128Ty
static Type * getPPC_FP128Ty(LLVMContext &C)
Definition: Type.cpp:232
llvm::APFloatBase::IEEEhalf
static const fltSemantics & IEEEhalf() LLVM_READNONE
Definition: APFloat.cpp:164
llvm::Type::getDoubleTy
static Type * getDoubleTy(LLVMContext &C)
Definition: Type.cpp:227
C
(vector float) vec_cmpeq(*A, *B) C
Definition: README_ALTIVEC.txt:86
Twine.h
DWKEYWORD
#define DWKEYWORD(TYPE, TOKEN)
freeze
canon freeze
Definition: CanonicalizeFreezeInLoops.cpp:241
llvm::lltok::exclaim
@ exclaim
Definition: LLToken.h:36
llvm::SMDiagnostic
Instances of this class encapsulate one diagnostic report, allowing printing to a raw_ostream as a ca...
Definition: SourceMgr.h:281
llvm::ms_demangle::QualifierMangleMode::Result
@ Result
false
Definition: StackSlotColoring.cpp:141
llvm::IntegerType::MAX_INT_BITS
@ MAX_INT_BITS
Maximum number of bits that can be specified.
Definition: DerivedTypes.h:52
llvm::lltok::kw_cc
@ kw_cc
Definition: LLToken.h:128
llvm::SPII::Load
@ Load
Definition: SparcInstrInfo.h:32
none
@ none
Definition: HWAddressSanitizer.cpp:187
llvm::lltok::DwarfTag
@ DwarfTag
Definition: LLToken.h:420
c
the resulting code requires compare and branches when and if the revised code is with conditional branches instead of More there is a byte word extend before each where there should be only and the condition codes are not remembered when the same two values are compared twice More LSR enhancements i8 and i32 load store addressing modes are identical int int c
Definition: README.txt:418
llvm::lltok::Kind
Kind
Definition: LLToken.h:18
UnEscapeLexed
static void UnEscapeLexed(std::string &Str)
Definition: LLLexer.cpp:114
SourceMgr.h
one
the resulting code requires compare and branches when and if the revised code is with conditional branches instead of More there is a byte word extend before each where there should be only one
Definition: README.txt:401
llvm::lltok::EmissionKind
@ EmissionKind
Definition: LLToken.h:425
type
AMD64 Optimization Manual has some nice information about optimizing integer multiplication by a constant How much of it applies to Intel s X86 implementation There are definite trade offs to xmm0 cvttss2siq rdx jb L3 subss xmm0 rax cvttss2siq rdx xorq rdx rax ret instead of xmm1 cvttss2siq rcx movaps xmm2 subss xmm2 cvttss2siq rax rdx xorq rax ucomiss xmm0 cmovb rax ret Seems like the jb branch has high likelihood of being taken It would have saved a few instructions It s not possible to reference and DH registers in an instruction requiring REX prefix divb and mulb both produce results in AH If isel emits a CopyFromReg which gets turned into a movb and that can be allocated a r8b r15b To get around isel emits a CopyFromReg from AX and then right shift it down by and truncate it It s not pretty but it works We need some register allocation magic to make the hack go which would often require a callee saved register Callees usually need to keep this value live for most of their body so it doesn t add a significant burden on them We currently implement this in however this is suboptimal because it means that it would be quite awkward to implement the optimization for callers A better implementation would be to relax the LLVM IR rules for sret arguments to allow a function with an sret argument to have a non void return type
Definition: README-X86-64.txt:70
llvm::PointerType::getUnqual
static PointerType * getUnqual(Type *ElementType)
This constructs a pointer to an object of the specified type in the default address space (address sp...
Definition: DerivedTypes.h:651
llvm::lltok::MetadataVar
@ MetadataVar
Definition: LLToken.h:418
uint64_t
llvm::lltok::DwarfCC
@ DwarfCC
Definition: LLToken.h:424
llvm::StringRef::end
iterator end() const
Definition: StringRef.h:105
llvm::lltok::LabelID
@ LabelID
Definition: LLToken.h:407
llvm::SourceMgr::PrintMessage
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.
Definition: SourceMgr.cpp:348
llvm::SourceMgr::DK_Warning
@ DK_Warning
Definition: SourceMgr.h:35
llvm::ARM_AM::add
@ add
Definition: ARMAddressingModes.h:39
llvm::LLVMContext
This is an important class for using LLVM in a threaded context.
Definition: LLVMContext.h:67
llvm::lltok::SummaryID
@ SummaryID
Definition: LLToken.h:411
StringExtras.h
sub
we currently eax ecx subl eax ret We would use one fewer register if codegen d eax neg eax eax ret Note that this isn t beneficial if the load can be folded into the sub In this we want a sub
Definition: README.txt:460
call
S is passed via registers r2 But gcc stores them to the and then reload them to and r3 before issuing the call(r0 contains the address of the format string)
Definition: README.txt:190
llvm::lltok::StringConstant
@ StringConstant
Definition: LLToken.h:419
llvm::lltok::DISPFlag
@ DISPFlag
Definition: LLToken.h:429
llvm::lltok::lsquare
@ lsquare
Definition: LLToken.h:28
llvm::APFloatBase::PPCDoubleDouble
static const fltSemantics & PPCDoubleDouble() LLVM_READNONE
Definition: APFloat.cpp:185
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
load
LLVM currently emits rax rax movq rax rax ret It could narrow the loads and stores to emit rax rax movq rax rax ret The trouble is that there is a TokenFactor between the store and the load
Definition: README.txt:1531
llvm::lltok::LocalVarID
@ LocalVarID
Definition: LLToken.h:409
Ptr
@ Ptr
Definition: TargetLibraryInfo.cpp:60
llvm::LLLexer::Warning
void Warning(LocTy WarningLoc, const Twine &Msg) const
Definition: LLLexer.cpp:33
llvm::lltok::colon
@ colon
Definition: LLToken.h:38
llvm::lltok::DwarfOp
@ DwarfOp
Definition: LLToken.h:427
llvm::Type::getX86_FP80Ty
static Type * getX86_FP80Ty(LLVMContext &C)
Definition: Type.cpp:230
llvm::ErrorInfo
Base class for user error types.
Definition: Error.h:347
OP
#define OP(n)
Definition: regex2.h:73
gc
rewrite statepoints for gc
Definition: RewriteStatepointsForGC.cpp:228
info
lazy value info
Definition: LazyValueInfo.cpp:58
llvm::APInt
Class for arbitrary precision integers.
Definition: APInt.h:75
llvm::min
Expected< ExpressionValue > min(const ExpressionValue &Lhs, const ExpressionValue &Rhs)
Definition: FileCheck.cpp:357
llvm::APFloatBase::IEEEdouble
static const fltSemantics & IEEEdouble() LLVM_READNONE
Definition: APFloat.cpp:173
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
allOnes
static uint64_t allOnes(unsigned int Count)
Definition: SystemZInstrInfo.cpp:54
llvm_unreachable
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Definition: ErrorHandling.h:143
llvm::SourceMgr
This owns the files read by a parser, handles include stacks, and handles diagnostic wrangling.
Definition: SourceMgr.h:31
uint32_t
llvm::binaryformat::unknown
@ unknown
Definition: Swift.h:18
LLLexer.h
trunc
We have fiadd patterns now but the followings have the same cost and complexity We need a way to specify the later is more profitable def def The FP stackifier should handle simple permutates to reduce number of shuffle e g trunc
Definition: README-FPStack.txt:63
llvm::lltok::DwarfAttEncoding
@ DwarfAttEncoding
Definition: LLToken.h:421
llvm::partition
auto partition(R &&Range, UnaryPredicate P)
Provide wrappers to std::partition which take ranges instead of having to pass begin/end explicitly.
Definition: STLExtras.h:1731
xor
We currently generate a but we really shouldn eax ecx xorl edx divl ecx eax divl ecx movl eax ret A similar code sequence works for division We currently compile i32 v2 eax eax jo LBB1_2 xor
Definition: README.txt:1271
llvm::lltok::comma
@ comma
Definition: LLToken.h:26
llvm::AMDGPU::SendMsg::Msg
const CustomOperand< const MCSubtargetInfo & > Msg[]
Definition: AMDGPUAsmUtils.cpp:39
llvm::MCID::Select
@ Select
Definition: MCInstrDesc.h:164
llvm::lltok::Type
@ Type
Definition: LLToken.h:434
name
static const char * name
Definition: SVEIntrinsicOpts.cpp:74
llvm::APIntOps::umax
const APInt & umax(const APInt &A, const APInt &B)
Determine the larger of two APInts considered to be unsigned.
Definition: APInt.h:2142
reassoc
into llvm powi allowing the code generator to produce balanced multiplication trees the intrinsic needs to be extended to support and second the code generator needs to be enhanced to lower these to multiplication trees Interesting testcase for add shift mul reassoc
Definition: README.txt:61
llvm::Twine
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:81
llvm::lltok::lbrace
@ lbrace
Definition: LLToken.h:30
bit
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional ldr LCPI1_0 ldr ldr tst movne lsr ldr LCPI1_1 and r0 bx lr it saves an instruction and a register It might be profitable to cse MOVi16 if there are lots of bit immediates with the same bottom half Robert Muth started working on an alternate jump table implementation that does not put the tables in line in the text This is more like the llvm default jump table implementation This might be useful sometime Several revisions of patches are on the mailing beginning while CMP sets them like a subtract Therefore to be able to use CMN for comparisons other than the Z bit
Definition: README.txt:584
llvm::Type::getHalfTy
static Type * getHalfTy(LLVMContext &C)
Definition: Type.cpp:224
or
compiles or
Definition: README.txt:606
llvm::lltok::dotdotdot
@ dotdotdot
Definition: LLToken.h:24
x
TODO unsigned x
Definition: README.txt:10
llvm::SourceMgr::DK_Error
@ DK_Error
Definition: SourceMgr.h:34
llvm::Type::getBFloatTy
static Type * getBFloatTy(LLVMContext &C)
Definition: Type.cpp:225
llvm::SourceMgr::GetMessage
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.
Definition: SourceMgr.cpp:270
llvm::Type::getVoidTy
static Type * getVoidTy(LLVMContext &C)
Definition: Type.cpp:222
llvm::numbers::phi
constexpr double phi
Definition: MathExtras.h:67
llvm::lltok::rbrace
@ rbrace
Definition: LLToken.h:31
llvm::lltok::ComdatVar
@ ComdatVar
Definition: LLToken.h:416
llvm::lltok::DIFlag
@ DIFlag
Definition: LLToken.h:428
llvm::lltok::GlobalID
@ GlobalID
Definition: LLToken.h:408
llvm::lltok::DwarfLang
@ DwarfLang
Definition: LLToken.h:423
isLabelChar
static bool isLabelChar(char C)
isLabelChar - Return true for [-a-zA-Z$._0-9].
Definition: LLLexer.cpp:141
calls
amdgpu Simplify well known AMD library calls
Definition: AMDGPULibCalls.cpp:179
llvm::lltok::GlobalVar
@ GlobalVar
Definition: LLToken.h:415
DerivedTypes.h
llvm::IntegerType::get
static IntegerType * get(LLVMContext &C, unsigned NumBits)
This static method is the primary way of constructing an IntegerType.
Definition: Type.cpp:311
llvm::Type::getLabelTy
static Type * getLabelTy(LLVMContext &C)
Definition: Type.cpp:223
INSTKEYWORD
#define INSTKEYWORD(STR, Enum)
lshr
Vector Shift Left don t map to llvm shl and lshr
Definition: README_P9.txt:118
llvm::pdb::PDB_ColorItem::Keyword
@ Keyword
llvm::lltok::ChecksumKind
@ ChecksumKind
Definition: LLToken.h:431
callee
Here we don t need to write any variables to the top of the stack since they don t overwrite each other int callee(int32 arg1, int32 arg2)
llvm::Type::getX86_MMXTy
static Type * getX86_MMXTy(LLVMContext &C)
Definition: Type.cpp:233
llvm::lltok::LabelStr
@ LabelStr
Definition: LLToken.h:414
llvm::lltok::rsquare
@ rsquare
Definition: LLToken.h:29
llvm::StringRef::begin
iterator begin() const
Definition: StringRef.h:103
llvm::SPII::Store
@ Store
Definition: SparcInstrInfo.h:33
llvm::Type::getFloatTy
static Type * getFloatTy(LLVMContext &C)
Definition: Type.cpp:226
llvm::lltok::DwarfVirtuality
@ DwarfVirtuality
Definition: LLToken.h:422