LLVM  7.0.0svn
LLParser.h
Go to the documentation of this file.
1 //===-- LLParser.h - Parser Class -------------------------------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file defines the parser class for .ll files.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_LIB_ASMPARSER_LLPARSER_H
15 #define LLVM_LIB_ASMPARSER_LLPARSER_H
16 
17 #include "LLLexer.h"
18 #include "llvm/ADT/Optional.h"
19 #include "llvm/ADT/StringMap.h"
20 #include "llvm/IR/Attributes.h"
21 #include "llvm/IR/Instructions.h"
22 #include "llvm/IR/Module.h"
23 #include "llvm/IR/Operator.h"
24 #include "llvm/IR/Type.h"
25 #include "llvm/IR/ValueHandle.h"
26 #include <map>
27 
28 namespace llvm {
29  class Module;
30  class OpaqueType;
31  class Function;
32  class Value;
33  class BasicBlock;
34  class Instruction;
35  class Constant;
36  class GlobalValue;
37  class Comdat;
38  class MDString;
39  class MDNode;
40  struct SlotMapping;
41  class StructType;
42 
43  /// ValID - Represents a reference of a definition of some sort with no type.
44  /// There are several cases where we have to parse the value but where the
45  /// type can depend on later context. This may either be a numeric reference
46  /// or a symbolic (%var) reference. This is just a discriminated union.
47  struct ValID {
48  enum {
49  t_LocalID, t_GlobalID, // ID in UIntVal.
50  t_LocalName, t_GlobalName, // Name in StrVal.
51  t_APSInt, t_APFloat, // Value in APSIntVal/APFloatVal.
52  t_Null, t_Undef, t_Zero, t_None, // No value.
53  t_EmptyArray, // No value: []
54  t_Constant, // Value in ConstantVal.
55  t_InlineAsm, // Value in FTy/StrVal/StrVal2/UIntVal.
56  t_ConstantStruct, // Value in ConstantStructElts.
57  t_PackedConstantStruct // Value in ConstantStructElts.
58  } Kind = t_LocalID;
59 
61  unsigned UIntVal;
62  FunctionType *FTy = nullptr;
63  std::string StrVal, StrVal2;
67  std::unique_ptr<Constant *[]> ConstantStructElts;
68 
69  ValID() = default;
70  ValID(const ValID &RHS)
71  : Kind(RHS.Kind), Loc(RHS.Loc), UIntVal(RHS.UIntVal), FTy(RHS.FTy),
72  StrVal(RHS.StrVal), StrVal2(RHS.StrVal2), APSIntVal(RHS.APSIntVal),
73  APFloatVal(RHS.APFloatVal), ConstantVal(RHS.ConstantVal) {
75  }
76 
77  bool operator<(const ValID &RHS) const {
78  if (Kind == t_LocalID || Kind == t_GlobalID)
79  return UIntVal < RHS.UIntVal;
80  assert((Kind == t_LocalName || Kind == t_GlobalName ||
81  Kind == t_ConstantStruct || Kind == t_PackedConstantStruct) &&
82  "Ordering not defined for this ValID kind yet");
83  return StrVal < RHS.StrVal;
84  }
85  };
86 
87  class LLParser {
88  public:
90  private:
92  LLLexer Lex;
93  Module *M;
94  SlotMapping *Slots;
95 
96  // Instruction metadata resolution. Each instruction can have a list of
97  // MDRef info associated with them.
98  //
99  // The simpler approach of just creating temporary MDNodes and then calling
100  // RAUW on them when the definition is processed doesn't work because some
101  // instruction metadata kinds, such as dbg, get stored in the IR in an
102  // "optimized" format which doesn't participate in the normal value use
103  // lists. This means that RAUW doesn't work, even on temporary MDNodes
104  // which otherwise support RAUW. Instead, we defer resolving MDNode
105  // references until the definitions have been processed.
106  struct MDRef {
107  SMLoc Loc;
108  unsigned MDKind, MDSlot;
109  };
110 
111  SmallVector<Instruction*, 64> InstsWithTBAATag;
112 
113  // Type resolution handling data structures. The location is set when we
114  // have processed a use of the type but not a definition yet.
116  std::map<unsigned, std::pair<Type*, LocTy> > NumberedTypes;
117 
118  std::map<unsigned, TrackingMDNodeRef> NumberedMetadata;
119  std::map<unsigned, std::pair<TempMDTuple, LocTy>> ForwardRefMDNodes;
120 
121  // Global Value reference information.
122  std::map<std::string, std::pair<GlobalValue*, LocTy> > ForwardRefVals;
123  std::map<unsigned, std::pair<GlobalValue*, LocTy> > ForwardRefValIDs;
124  std::vector<GlobalValue*> NumberedVals;
125 
126  // Comdat forward reference information.
127  std::map<std::string, LocTy> ForwardRefComdats;
128 
129  // References to blockaddress. The key is the function ValID, the value is
130  // a list of references to blocks in that function.
131  std::map<ValID, std::map<ValID, GlobalValue *>> ForwardRefBlockAddresses;
132  class PerFunctionState;
133  /// Reference to per-function state to allow basic blocks to be
134  /// forward-referenced by blockaddress instructions within the same
135  /// function.
136  PerFunctionState *BlockAddressPFS;
137 
138  // Attribute builder reference information.
139  std::map<Value*, std::vector<unsigned> > ForwardRefAttrGroups;
140  std::map<unsigned, AttrBuilder> NumberedAttrBuilders;
141 
142  /// Only the llvm-as tool may set this to false to bypass
143  /// UpgradeDebuginfo so it can generate broken bitcode.
144  bool UpgradeDebugInfo;
145 
146  /// DataLayout string to override that in LLVM assembly.
147  StringRef DataLayoutStr;
148 
149  public:
151  SlotMapping *Slots = nullptr, bool UpgradeDebugInfo = true,
152  StringRef DataLayoutString = "")
153  : Context(M->getContext()), Lex(F, SM, Err, M->getContext()), M(M),
154  Slots(Slots), BlockAddressPFS(nullptr),
155  UpgradeDebugInfo(UpgradeDebugInfo), DataLayoutStr(DataLayoutString) {
156  if (!DataLayoutStr.empty())
157  M->setDataLayout(DataLayoutStr);
158  }
159  bool Run();
160 
161  bool parseStandaloneConstantValue(Constant *&C, const SlotMapping *Slots);
162 
163  bool parseTypeAtBeginning(Type *&Ty, unsigned &Read,
164  const SlotMapping *Slots);
165 
167 
168  private:
169 
170  bool Error(LocTy L, const Twine &Msg) const {
171  return Lex.Error(L, Msg);
172  }
173  bool TokError(const Twine &Msg) const {
174  return Error(Lex.getLoc(), Msg);
175  }
176 
177  /// Restore the internal name and slot mappings using the mappings that
178  /// were created at an earlier parsing stage.
179  void restoreParsingState(const SlotMapping *Slots);
180 
181  /// GetGlobalVal - Get a value with the specified name or ID, creating a
182  /// forward reference record if needed. This can return null if the value
183  /// exists but does not have the right type.
184  GlobalValue *GetGlobalVal(const std::string &N, Type *Ty, LocTy Loc);
185  GlobalValue *GetGlobalVal(unsigned ID, Type *Ty, LocTy Loc);
186 
187  /// Get a Comdat with the specified name, creating a forward reference
188  /// record if needed.
189  Comdat *getComdat(const std::string &N, LocTy Loc);
190 
191  // Helper Routines.
192  bool ParseToken(lltok::Kind T, const char *ErrMsg);
193  bool EatIfPresent(lltok::Kind T) {
194  if (Lex.getKind() != T) return false;
195  Lex.Lex();
196  return true;
197  }
198 
199  FastMathFlags EatFastMathFlagsIfPresent() {
200  FastMathFlags FMF;
201  while (true)
202  switch (Lex.getKind()) {
203  case lltok::kw_fast: FMF.setFast(); Lex.Lex(); continue;
204  case lltok::kw_nnan: FMF.setNoNaNs(); Lex.Lex(); continue;
205  case lltok::kw_ninf: FMF.setNoInfs(); Lex.Lex(); continue;
206  case lltok::kw_nsz: FMF.setNoSignedZeros(); Lex.Lex(); continue;
207  case lltok::kw_arcp: FMF.setAllowReciprocal(); Lex.Lex(); continue;
208  case lltok::kw_contract:
209  FMF.setAllowContract(true);
210  Lex.Lex();
211  continue;
212  case lltok::kw_reassoc: FMF.setAllowReassoc(); Lex.Lex(); continue;
213  case lltok::kw_afn: FMF.setApproxFunc(); Lex.Lex(); continue;
214  default: return FMF;
215  }
216  return FMF;
217  }
218 
219  bool ParseOptionalToken(lltok::Kind T, bool &Present,
220  LocTy *Loc = nullptr) {
221  if (Lex.getKind() != T) {
222  Present = false;
223  } else {
224  if (Loc)
225  *Loc = Lex.getLoc();
226  Lex.Lex();
227  Present = true;
228  }
229  return false;
230  }
231  bool ParseStringConstant(std::string &Result);
232  bool ParseUInt32(unsigned &Val);
233  bool ParseUInt32(unsigned &Val, LocTy &Loc) {
234  Loc = Lex.getLoc();
235  return ParseUInt32(Val);
236  }
237  bool ParseUInt64(uint64_t &Val);
238  bool ParseUInt64(uint64_t &Val, LocTy &Loc) {
239  Loc = Lex.getLoc();
240  return ParseUInt64(Val);
241  }
242 
243  bool ParseStringAttribute(AttrBuilder &B);
244 
245  bool ParseTLSModel(GlobalVariable::ThreadLocalMode &TLM);
246  bool ParseOptionalThreadLocal(GlobalVariable::ThreadLocalMode &TLM);
247  bool ParseOptionalUnnamedAddr(GlobalVariable::UnnamedAddr &UnnamedAddr);
248  bool ParseOptionalAddrSpace(unsigned &AddrSpace);
249  bool ParseOptionalParamAttrs(AttrBuilder &B);
250  bool ParseOptionalReturnAttrs(AttrBuilder &B);
251  bool ParseOptionalLinkage(unsigned &Linkage, bool &HasLinkage,
252  unsigned &Visibility, unsigned &DLLStorageClass,
253  bool &DSOLocal);
254  void ParseOptionalDSOLocal(bool &DSOLocal);
255  void ParseOptionalVisibility(unsigned &Visibility);
256  void ParseOptionalDLLStorageClass(unsigned &DLLStorageClass);
257  bool ParseOptionalCallingConv(unsigned &CC);
258  bool ParseOptionalAlignment(unsigned &Alignment);
259  bool ParseOptionalDerefAttrBytes(lltok::Kind AttrKind, uint64_t &Bytes);
260  bool ParseScopeAndOrdering(bool isAtomic, SyncScope::ID &SSID,
261  AtomicOrdering &Ordering);
262  bool ParseScope(SyncScope::ID &SSID);
263  bool ParseOrdering(AtomicOrdering &Ordering);
264  bool ParseOptionalStackAlignment(unsigned &Alignment);
265  bool ParseOptionalCommaAlign(unsigned &Alignment, bool &AteExtraComma);
266  bool ParseOptionalCommaAddrSpace(unsigned &AddrSpace, LocTy &Loc,
267  bool &AteExtraComma);
268  bool ParseOptionalCommaInAlloca(bool &IsInAlloca);
269  bool parseAllocSizeArguments(unsigned &ElemSizeArg,
270  Optional<unsigned> &HowManyArg);
271  bool ParseIndexList(SmallVectorImpl<unsigned> &Indices,
272  bool &AteExtraComma);
273  bool ParseIndexList(SmallVectorImpl<unsigned> &Indices) {
274  bool AteExtraComma;
275  if (ParseIndexList(Indices, AteExtraComma)) return true;
276  if (AteExtraComma)
277  return TokError("expected index");
278  return false;
279  }
280 
281  // Top-Level Entities
282  bool ParseTopLevelEntities();
283  bool ValidateEndOfModule();
284  bool ParseTargetDefinition();
285  bool ParseModuleAsm();
286  bool ParseSourceFileName();
287  bool ParseDepLibs(); // FIXME: Remove in 4.0.
288  bool ParseUnnamedType();
289  bool ParseNamedType();
290  bool ParseDeclare();
291  bool ParseDefine();
292 
293  bool ParseGlobalType(bool &IsConstant);
294  bool ParseUnnamedGlobal();
295  bool ParseNamedGlobal();
296  bool ParseGlobal(const std::string &Name, LocTy Loc, unsigned Linkage,
297  bool HasLinkage, unsigned Visibility,
298  unsigned DLLStorageClass, bool DSOLocal,
300  GlobalVariable::UnnamedAddr UnnamedAddr);
301  bool parseIndirectSymbol(const std::string &Name, LocTy Loc,
302  unsigned Linkage, unsigned Visibility,
303  unsigned DLLStorageClass, bool DSOLocal,
305  GlobalVariable::UnnamedAddr UnnamedAddr);
306  bool parseComdat();
307  bool ParseStandaloneMetadata();
308  bool ParseNamedMetadata();
309  bool ParseMDString(MDString *&Result);
310  bool ParseMDNodeID(MDNode *&Result);
311  bool ParseUnnamedAttrGrp();
312  bool ParseFnAttributeValuePairs(AttrBuilder &B,
313  std::vector<unsigned> &FwdRefAttrGrps,
314  bool inAttrGrp, LocTy &BuiltinLoc);
315  bool SkipModuleSummaryEntry();
316  bool ParseSummaryEntry();
317 
318  // Type Parsing.
319  bool ParseType(Type *&Result, const Twine &Msg, bool AllowVoid = false);
320  bool ParseType(Type *&Result, bool AllowVoid = false) {
321  return ParseType(Result, "expected type", AllowVoid);
322  }
323  bool ParseType(Type *&Result, const Twine &Msg, LocTy &Loc,
324  bool AllowVoid = false) {
325  Loc = Lex.getLoc();
326  return ParseType(Result, Msg, AllowVoid);
327  }
328  bool ParseType(Type *&Result, LocTy &Loc, bool AllowVoid = false) {
329  Loc = Lex.getLoc();
330  return ParseType(Result, AllowVoid);
331  }
332  bool ParseAnonStructType(Type *&Result, bool Packed);
333  bool ParseStructBody(SmallVectorImpl<Type*> &Body);
334  bool ParseStructDefinition(SMLoc TypeLoc, StringRef Name,
335  std::pair<Type*, LocTy> &Entry,
336  Type *&ResultTy);
337 
338  bool ParseArrayVectorType(Type *&Result, bool isVector);
339  bool ParseFunctionType(Type *&Result);
340 
341  // Function Semantic Analysis.
342  class PerFunctionState {
343  LLParser &P;
344  Function &F;
345  std::map<std::string, std::pair<Value*, LocTy> > ForwardRefVals;
346  std::map<unsigned, std::pair<Value*, LocTy> > ForwardRefValIDs;
347  std::vector<Value*> NumberedVals;
348 
349  /// FunctionNumber - If this is an unnamed function, this is the slot
350  /// number of it, otherwise it is -1.
351  int FunctionNumber;
352  public:
353  PerFunctionState(LLParser &p, Function &f, int FunctionNumber);
354  ~PerFunctionState();
355 
356  Function &getFunction() const { return F; }
357 
358  bool FinishFunction();
359 
360  /// GetVal - Get a value with the specified name or ID, creating a
361  /// forward reference record if needed. This can return null if the value
362  /// exists but does not have the right type.
363  Value *GetVal(const std::string &Name, Type *Ty, LocTy Loc, bool IsCall);
364  Value *GetVal(unsigned ID, Type *Ty, LocTy Loc, bool IsCall);
365 
366  /// SetInstName - After an instruction is parsed and inserted into its
367  /// basic block, this installs its name.
368  bool SetInstName(int NameID, const std::string &NameStr, LocTy NameLoc,
369  Instruction *Inst);
370 
371  /// GetBB - Get a basic block with the specified name or ID, creating a
372  /// forward reference record if needed. This can return null if the value
373  /// is not a BasicBlock.
374  BasicBlock *GetBB(const std::string &Name, LocTy Loc);
375  BasicBlock *GetBB(unsigned ID, LocTy Loc);
376 
377  /// DefineBB - Define the specified basic block, which is either named or
378  /// unnamed. If there is an error, this returns null otherwise it returns
379  /// the block being defined.
380  BasicBlock *DefineBB(const std::string &Name, LocTy Loc);
381 
382  bool resolveForwardRefBlockAddresses();
383  };
384 
385  bool ConvertValIDToValue(Type *Ty, ValID &ID, Value *&V,
386  PerFunctionState *PFS, bool IsCall);
387 
388  bool parseConstantValue(Type *Ty, Constant *&C);
389  bool ParseValue(Type *Ty, Value *&V, PerFunctionState *PFS);
390  bool ParseValue(Type *Ty, Value *&V, PerFunctionState &PFS) {
391  return ParseValue(Ty, V, &PFS);
392  }
393 
394  bool ParseValue(Type *Ty, Value *&V, LocTy &Loc,
395  PerFunctionState &PFS) {
396  Loc = Lex.getLoc();
397  return ParseValue(Ty, V, &PFS);
398  }
399 
400  bool ParseTypeAndValue(Value *&V, PerFunctionState *PFS);
401  bool ParseTypeAndValue(Value *&V, PerFunctionState &PFS) {
402  return ParseTypeAndValue(V, &PFS);
403  }
404  bool ParseTypeAndValue(Value *&V, LocTy &Loc, PerFunctionState &PFS) {
405  Loc = Lex.getLoc();
406  return ParseTypeAndValue(V, PFS);
407  }
408  bool ParseTypeAndBasicBlock(BasicBlock *&BB, LocTy &Loc,
409  PerFunctionState &PFS);
410  bool ParseTypeAndBasicBlock(BasicBlock *&BB, PerFunctionState &PFS) {
411  LocTy Loc;
412  return ParseTypeAndBasicBlock(BB, Loc, PFS);
413  }
414 
415 
416  struct ParamInfo {
417  LocTy Loc;
418  Value *V;
420  ParamInfo(LocTy loc, Value *v, AttributeSet attrs)
421  : Loc(loc), V(v), Attrs(attrs) {}
422  };
423  bool ParseParameterList(SmallVectorImpl<ParamInfo> &ArgList,
424  PerFunctionState &PFS,
425  bool IsMustTailCall = false,
426  bool InVarArgsFunc = false);
427 
428  bool
429  ParseOptionalOperandBundles(SmallVectorImpl<OperandBundleDef> &BundleList,
430  PerFunctionState &PFS);
431 
432  bool ParseExceptionArgs(SmallVectorImpl<Value *> &Args,
433  PerFunctionState &PFS);
434 
435  // Constant Parsing.
436  bool ParseValID(ValID &ID, PerFunctionState *PFS = nullptr);
437  bool ParseGlobalValue(Type *Ty, Constant *&V);
438  bool ParseGlobalTypeAndValue(Constant *&V);
439  bool ParseGlobalValueVector(SmallVectorImpl<Constant *> &Elts,
440  Optional<unsigned> *InRangeOp = nullptr);
441  bool parseOptionalComdat(StringRef GlobalName, Comdat *&C);
442  bool ParseMetadataAsValue(Value *&V, PerFunctionState &PFS);
443  bool ParseValueAsMetadata(Metadata *&MD, const Twine &TypeMsg,
444  PerFunctionState *PFS);
445  bool ParseMetadata(Metadata *&MD, PerFunctionState *PFS);
446  bool ParseMDTuple(MDNode *&MD, bool IsDistinct = false);
447  bool ParseMDNode(MDNode *&MD);
448  bool ParseMDNodeTail(MDNode *&MD);
449  bool ParseMDNodeVector(SmallVectorImpl<Metadata *> &MDs);
450  bool ParseMetadataAttachment(unsigned &Kind, MDNode *&MD);
451  bool ParseInstructionMetadata(Instruction &Inst);
452  bool ParseGlobalObjectMetadataAttachment(GlobalObject &GO);
453  bool ParseOptionalFunctionMetadata(Function &F);
454 
455  template <class FieldTy>
456  bool ParseMDField(LocTy Loc, StringRef Name, FieldTy &Result);
457  template <class FieldTy> bool ParseMDField(StringRef Name, FieldTy &Result);
458  template <class ParserTy>
459  bool ParseMDFieldsImplBody(ParserTy parseField);
460  template <class ParserTy>
461  bool ParseMDFieldsImpl(ParserTy parseField, LocTy &ClosingLoc);
462  bool ParseSpecializedMDNode(MDNode *&N, bool IsDistinct = false);
463 
464 #define HANDLE_SPECIALIZED_MDNODE_LEAF(CLASS) \
465  bool Parse##CLASS(MDNode *&Result, bool IsDistinct);
466 #include "llvm/IR/Metadata.def"
467 
468  // Function Parsing.
469  struct ArgInfo {
470  LocTy Loc;
471  Type *Ty;
472  AttributeSet Attrs;
473  std::string Name;
474  ArgInfo(LocTy L, Type *ty, AttributeSet Attr, const std::string &N)
475  : Loc(L), Ty(ty), Attrs(Attr), Name(N) {}
476  };
477  bool ParseArgumentList(SmallVectorImpl<ArgInfo> &ArgList, bool &isVarArg);
478  bool ParseFunctionHeader(Function *&Fn, bool isDefine);
479  bool ParseFunctionBody(Function &Fn);
480  bool ParseBasicBlock(PerFunctionState &PFS);
481 
482  enum TailCallType { TCT_None, TCT_Tail, TCT_MustTail };
483 
484  // Instruction Parsing. Each instruction parsing routine can return with a
485  // normal result, an error result, or return having eaten an extra comma.
486  enum InstResult { InstNormal = 0, InstError = 1, InstExtraComma = 2 };
487  int ParseInstruction(Instruction *&Inst, BasicBlock *BB,
488  PerFunctionState &PFS);
489  bool ParseCmpPredicate(unsigned &Pred, unsigned Opc);
490 
491  bool ParseRet(Instruction *&Inst, BasicBlock *BB, PerFunctionState &PFS);
492  bool ParseBr(Instruction *&Inst, PerFunctionState &PFS);
493  bool ParseSwitch(Instruction *&Inst, PerFunctionState &PFS);
494  bool ParseIndirectBr(Instruction *&Inst, PerFunctionState &PFS);
495  bool ParseInvoke(Instruction *&Inst, PerFunctionState &PFS);
496  bool ParseResume(Instruction *&Inst, PerFunctionState &PFS);
497  bool ParseCleanupRet(Instruction *&Inst, PerFunctionState &PFS);
498  bool ParseCatchRet(Instruction *&Inst, PerFunctionState &PFS);
499  bool ParseCatchSwitch(Instruction *&Inst, PerFunctionState &PFS);
500  bool ParseCatchPad(Instruction *&Inst, PerFunctionState &PFS);
501  bool ParseCleanupPad(Instruction *&Inst, PerFunctionState &PFS);
502 
503  bool ParseArithmetic(Instruction *&I, PerFunctionState &PFS, unsigned Opc,
504  unsigned OperandType);
505  bool ParseLogical(Instruction *&I, PerFunctionState &PFS, unsigned Opc);
506  bool ParseCompare(Instruction *&I, PerFunctionState &PFS, unsigned Opc);
507  bool ParseCast(Instruction *&I, PerFunctionState &PFS, unsigned Opc);
508  bool ParseSelect(Instruction *&I, PerFunctionState &PFS);
509  bool ParseVA_Arg(Instruction *&I, PerFunctionState &PFS);
510  bool ParseExtractElement(Instruction *&I, PerFunctionState &PFS);
511  bool ParseInsertElement(Instruction *&I, PerFunctionState &PFS);
512  bool ParseShuffleVector(Instruction *&I, PerFunctionState &PFS);
513  int ParsePHI(Instruction *&I, PerFunctionState &PFS);
514  bool ParseLandingPad(Instruction *&I, PerFunctionState &PFS);
515  bool ParseCall(Instruction *&I, PerFunctionState &PFS,
516  CallInst::TailCallKind IsTail);
517  int ParseAlloc(Instruction *&I, PerFunctionState &PFS);
518  int ParseLoad(Instruction *&I, PerFunctionState &PFS);
519  int ParseStore(Instruction *&I, PerFunctionState &PFS);
520  int ParseCmpXchg(Instruction *&I, PerFunctionState &PFS);
521  int ParseAtomicRMW(Instruction *&I, PerFunctionState &PFS);
522  int ParseFence(Instruction *&I, PerFunctionState &PFS);
523  int ParseGetElementPtr(Instruction *&I, PerFunctionState &PFS);
524  int ParseExtractValue(Instruction *&I, PerFunctionState &PFS);
525  int ParseInsertValue(Instruction *&I, PerFunctionState &PFS);
526 
527  // Use-list order directives.
528  bool ParseUseListOrder(PerFunctionState *PFS = nullptr);
529  bool ParseUseListOrderBB();
530  bool ParseUseListOrderIndexes(SmallVectorImpl<unsigned> &Indexes);
531  bool sortUseListOrder(Value *V, ArrayRef<unsigned> Indexes, SMLoc Loc);
532  };
533 } // End llvm namespace
534 
535 #endif
LLLexer::LocTy Loc
Definition: LLParser.h:60
uint64_t CallInst * C
enum llvm::ValID::@308 Kind
LLParser(StringRef F, SourceMgr &SM, SMDiagnostic &Err, Module *M, SlotMapping *Slots=nullptr, bool UpgradeDebugInfo=true, StringRef DataLayoutString="")
Definition: LLParser.h:150
LLVMContext & Context
void setFast(bool B=true)
Definition: Operator.h:231
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
Various leaf nodes.
Definition: ISDOpcodes.h:60
Constant * parseConstantValue(StringRef Asm, SMDiagnostic &Err, const Module &M, const SlotMapping *Slots=nullptr)
Parse a type and a constant value in the given string.
Definition: Parser.cpp:75
A Module instance is used to store all the information related to an LLVM module. ...
Definition: Module.h:63
bool operator<(const ValID &RHS) const
Definition: LLParser.h:77
LLVMContext & getContext()
Definition: LLParser.h:166
bool Error(LocTy L, const Twine &Msg) const
Definition: LLLexer.cpp:29
void setDataLayout(StringRef Desc)
Set the data layout.
Definition: Module.cpp:355
void setNoInfs(bool B=true)
Definition: Operator.h:216
Metadata node.
Definition: Metadata.h:862
F(f)
unsigned UIntVal
Definition: LLParser.h:61
ELFYAML::ELF_STV Visibility
Definition: ELFYAML.cpp:769
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:81
This file contains the simple types necessary to represent the attributes associated with functions a...
lltok::Kind Lex()
Definition: LLLexer.h:49
AtomicOrdering
Atomic ordering for LLVM&#39;s memory model.
ValID(const ValID &RHS)
Definition: LLParser.h:70
Class to represent function types.
Definition: DerivedTypes.h:103
#define T
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool empty() const
empty - Check if the string is empty.
Definition: StringRef.h:133
std::string StrVal
Definition: LLParser.h:63
Type * parseTypeAtBeginning(StringRef Asm, unsigned &Read, SMDiagnostic &Err, const Module &M, const SlotMapping *Slots=nullptr)
Parse a string Asm that starts with a type.
Definition: Parser.cpp:103
constexpr char Attrs[]
Key for Kernel::Metadata::mAttrs.
#define P(N)
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
void setNoSignedZeros(bool B=true)
Definition: Operator.h:219
LLVM Basic Block Representation.
Definition: BasicBlock.h:59
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:46
This is an important class for using LLVM in a threaded context.
Definition: LLVMContext.h:69
This is an important base class in LLVM.
Definition: Constant.h:42
bool UpgradeDebugInfo(Module &M)
Check the debug info version number, if it is out-dated, drop the debug info.
Constant * ConstantVal
Definition: LLParser.h:66
APFloat APFloatVal
Definition: LLParser.h:65
This owns the files read by a parser, handles include stacks, and handles diagnostic wrangling...
Definition: SourceMgr.h:42
lltok::Kind getKind() const
Definition: LLLexer.h:55
static bool isAtomic(Instruction *I)
LocTy getLoc() const
Definition: LLLexer.h:54
APSInt APSIntVal
Definition: LLParser.h:64
This is a &#39;vector&#39; (really, a variable-sized array), optimized for the case when the array is small...
Definition: SmallVector.h:861
Module.h This file contains the declarations for the Module class.
bool isVector(MCInstrInfo const &MCII, MCInst const &MCI)
void setApproxFunc(bool B=true)
Definition: Operator.h:228
ValID()=default
void setNoNaNs(bool B=true)
Definition: Operator.h:213
StringMap - This is an unconventional map that is specialized for handling keys that are "strings"...
Definition: StringMap.h:220
This struct contains the mappings from the slot numbers to unnamed metadata nodes, global values and types.
Definition: SlotMapping.h:33
FunctionNumber(functionNumber)
Definition: LLParser.cpp:2639
OperandType
Operands are tagged with one of the values of this enum.
Definition: MCInstrDesc.h:44
ValID - Represents a reference of a definition of some sort with no type.
Definition: LLParser.h:47
void setAllowContract(bool B=true)
Definition: Operator.h:225
#define I(x, y, z)
Definition: MD5.cpp:58
#define N
std::unique_ptr< Constant *[]> ConstantStructElts
Definition: LLParser.h:67
void setAllowReciprocal(bool B=true)
Definition: Operator.h:222
FunctionType * FTy
Definition: LLParser.h:62
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
std::string StrVal2
Definition: LLParser.h:63
LLLexer::LocTy LocTy
Definition: LLParser.h:89
LLVM Value Representation.
Definition: Value.h:73
Convenience struct for specifying and reasoning about fast-math flags.
Definition: Operator.h:160
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49
A single uniqued string.
Definition: Metadata.h:602
Represents a location in source code.
Definition: SMLoc.h:24
void setAllowReassoc(bool B=true)
Flag setters.
Definition: Operator.h:210
Root of the metadata hierarchy.
Definition: Metadata.h:58
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
TLM
Definition: LLParser.cpp:1426
Instances of this class encapsulate one diagnostic report, allowing printing to a raw_ostream as a ca...
Definition: SourceMgr.h:260
static bool parseField(amd_kernel_code_t &C, MCAsmParser &MCParser, raw_ostream &Err)