]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/lib/AsmParser/LLParser.h
Merge clang trunk r321017 to contrib/llvm/tools/clang.
[FreeBSD/FreeBSD.git] / contrib / llvm / lib / AsmParser / LLParser.h
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
60     LLLexer::LocTy Loc;
61     unsigned UIntVal;
62     FunctionType *FTy = nullptr;
63     std::string StrVal, StrVal2;
64     APSInt APSIntVal;
65     APFloat APFloatVal{0.0};
66     Constant *ConstantVal;
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) {
74       assert(!RHS.ConstantStructElts);
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:
89     typedef LLLexer::LocTy LocTy;
90   private:
91     LLVMContext &Context;
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.
115     StringMap<std::pair<Type*, LocTy> > NamedTypes;
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   public:
147     LLParser(StringRef F, SourceMgr &SM, SMDiagnostic &Err, Module *M,
148              SlotMapping *Slots = nullptr, bool UpgradeDebugInfo = true)
149         : Context(M->getContext()), Lex(F, SM, Err, M->getContext()), M(M),
150           Slots(Slots), BlockAddressPFS(nullptr),
151           UpgradeDebugInfo(UpgradeDebugInfo) {}
152     bool Run();
153
154     bool parseStandaloneConstantValue(Constant *&C, const SlotMapping *Slots);
155
156     bool parseTypeAtBeginning(Type *&Ty, unsigned &Read,
157                               const SlotMapping *Slots);
158
159     LLVMContext &getContext() { return Context; }
160
161   private:
162
163     bool Error(LocTy L, const Twine &Msg) const {
164       return Lex.Error(L, Msg);
165     }
166     bool TokError(const Twine &Msg) const {
167       return Error(Lex.getLoc(), Msg);
168     }
169
170     /// Restore the internal name and slot mappings using the mappings that
171     /// were created at an earlier parsing stage.
172     void restoreParsingState(const SlotMapping *Slots);
173
174     /// GetGlobalVal - Get a value with the specified name or ID, creating a
175     /// forward reference record if needed.  This can return null if the value
176     /// exists but does not have the right type.
177     GlobalValue *GetGlobalVal(const std::string &N, Type *Ty, LocTy Loc);
178     GlobalValue *GetGlobalVal(unsigned ID, Type *Ty, LocTy Loc);
179
180     /// Get a Comdat with the specified name, creating a forward reference
181     /// record if needed.
182     Comdat *getComdat(const std::string &N, LocTy Loc);
183
184     // Helper Routines.
185     bool ParseToken(lltok::Kind T, const char *ErrMsg);
186     bool EatIfPresent(lltok::Kind T) {
187       if (Lex.getKind() != T) return false;
188       Lex.Lex();
189       return true;
190     }
191
192     FastMathFlags EatFastMathFlagsIfPresent() {
193       FastMathFlags FMF;
194       while (true)
195         switch (Lex.getKind()) {
196         case lltok::kw_fast: FMF.setFast();            Lex.Lex(); continue;
197         case lltok::kw_nnan: FMF.setNoNaNs();          Lex.Lex(); continue;
198         case lltok::kw_ninf: FMF.setNoInfs();          Lex.Lex(); continue;
199         case lltok::kw_nsz:  FMF.setNoSignedZeros();   Lex.Lex(); continue;
200         case lltok::kw_arcp: FMF.setAllowReciprocal(); Lex.Lex(); continue;
201         case lltok::kw_contract:
202           FMF.setAllowContract(true);
203           Lex.Lex();
204           continue;
205         case lltok::kw_reassoc: FMF.setAllowReassoc(); Lex.Lex(); continue;
206         case lltok::kw_afn:     FMF.setApproxFunc();   Lex.Lex(); continue;
207         default: return FMF;
208         }
209       return FMF;
210     }
211
212     bool ParseOptionalToken(lltok::Kind T, bool &Present,
213                             LocTy *Loc = nullptr) {
214       if (Lex.getKind() != T) {
215         Present = false;
216       } else {
217         if (Loc)
218           *Loc = Lex.getLoc();
219         Lex.Lex();
220         Present = true;
221       }
222       return false;
223     }
224     bool ParseStringConstant(std::string &Result);
225     bool ParseUInt32(unsigned &Val);
226     bool ParseUInt32(unsigned &Val, LocTy &Loc) {
227       Loc = Lex.getLoc();
228       return ParseUInt32(Val);
229     }
230     bool ParseUInt64(uint64_t &Val);
231     bool ParseUInt64(uint64_t &Val, LocTy &Loc) {
232       Loc = Lex.getLoc();
233       return ParseUInt64(Val);
234     }
235
236     bool ParseStringAttribute(AttrBuilder &B);
237
238     bool ParseTLSModel(GlobalVariable::ThreadLocalMode &TLM);
239     bool ParseOptionalThreadLocal(GlobalVariable::ThreadLocalMode &TLM);
240     bool ParseOptionalUnnamedAddr(GlobalVariable::UnnamedAddr &UnnamedAddr);
241     bool ParseOptionalAddrSpace(unsigned &AddrSpace);
242     bool ParseOptionalParamAttrs(AttrBuilder &B);
243     bool ParseOptionalReturnAttrs(AttrBuilder &B);
244     bool ParseOptionalLinkage(unsigned &Linkage, bool &HasLinkage,
245                               unsigned &Visibility, unsigned &DLLStorageClass,
246                               bool &DSOLocal);
247     void ParseOptionalDSOLocal(bool &DSOLocal);
248     void ParseOptionalVisibility(unsigned &Visibility);
249     void ParseOptionalDLLStorageClass(unsigned &DLLStorageClass);
250     bool ParseOptionalCallingConv(unsigned &CC);
251     bool ParseOptionalAlignment(unsigned &Alignment);
252     bool ParseOptionalDerefAttrBytes(lltok::Kind AttrKind, uint64_t &Bytes);
253     bool ParseScopeAndOrdering(bool isAtomic, SyncScope::ID &SSID,
254                                AtomicOrdering &Ordering);
255     bool ParseScope(SyncScope::ID &SSID);
256     bool ParseOrdering(AtomicOrdering &Ordering);
257     bool ParseOptionalStackAlignment(unsigned &Alignment);
258     bool ParseOptionalCommaAlign(unsigned &Alignment, bool &AteExtraComma);
259     bool ParseOptionalCommaAddrSpace(unsigned &AddrSpace, LocTy &Loc,
260                                      bool &AteExtraComma);
261     bool ParseOptionalCommaInAlloca(bool &IsInAlloca);
262     bool parseAllocSizeArguments(unsigned &ElemSizeArg,
263                                  Optional<unsigned> &HowManyArg);
264     bool ParseIndexList(SmallVectorImpl<unsigned> &Indices,
265                         bool &AteExtraComma);
266     bool ParseIndexList(SmallVectorImpl<unsigned> &Indices) {
267       bool AteExtraComma;
268       if (ParseIndexList(Indices, AteExtraComma)) return true;
269       if (AteExtraComma)
270         return TokError("expected index");
271       return false;
272     }
273
274     // Top-Level Entities
275     bool ParseTopLevelEntities();
276     bool ValidateEndOfModule();
277     bool ParseTargetDefinition();
278     bool ParseModuleAsm();
279     bool ParseSourceFileName();
280     bool ParseDepLibs();        // FIXME: Remove in 4.0.
281     bool ParseUnnamedType();
282     bool ParseNamedType();
283     bool ParseDeclare();
284     bool ParseDefine();
285
286     bool ParseGlobalType(bool &IsConstant);
287     bool ParseUnnamedGlobal();
288     bool ParseNamedGlobal();
289     bool ParseGlobal(const std::string &Name, LocTy Loc, unsigned Linkage,
290                      bool HasLinkage, unsigned Visibility,
291                      unsigned DLLStorageClass, bool DSOLocal,
292                      GlobalVariable::ThreadLocalMode TLM,
293                      GlobalVariable::UnnamedAddr UnnamedAddr);
294     bool parseIndirectSymbol(const std::string &Name, LocTy Loc,
295                              unsigned Linkage, unsigned Visibility,
296                              unsigned DLLStorageClass, bool DSOLocal,
297                              GlobalVariable::ThreadLocalMode TLM,
298                              GlobalVariable::UnnamedAddr UnnamedAddr);
299     bool parseComdat();
300     bool ParseStandaloneMetadata();
301     bool ParseNamedMetadata();
302     bool ParseMDString(MDString *&Result);
303     bool ParseMDNodeID(MDNode *&Result);
304     bool ParseUnnamedAttrGrp();
305     bool ParseFnAttributeValuePairs(AttrBuilder &B,
306                                     std::vector<unsigned> &FwdRefAttrGrps,
307                                     bool inAttrGrp, LocTy &BuiltinLoc);
308
309     // Type Parsing.
310     bool ParseType(Type *&Result, const Twine &Msg, bool AllowVoid = false);
311     bool ParseType(Type *&Result, bool AllowVoid = false) {
312       return ParseType(Result, "expected type", AllowVoid);
313     }
314     bool ParseType(Type *&Result, const Twine &Msg, LocTy &Loc,
315                    bool AllowVoid = false) {
316       Loc = Lex.getLoc();
317       return ParseType(Result, Msg, AllowVoid);
318     }
319     bool ParseType(Type *&Result, LocTy &Loc, bool AllowVoid = false) {
320       Loc = Lex.getLoc();
321       return ParseType(Result, AllowVoid);
322     }
323     bool ParseAnonStructType(Type *&Result, bool Packed);
324     bool ParseStructBody(SmallVectorImpl<Type*> &Body);
325     bool ParseStructDefinition(SMLoc TypeLoc, StringRef Name,
326                                std::pair<Type*, LocTy> &Entry,
327                                Type *&ResultTy);
328
329     bool ParseArrayVectorType(Type *&Result, bool isVector);
330     bool ParseFunctionType(Type *&Result);
331
332     // Function Semantic Analysis.
333     class PerFunctionState {
334       LLParser &P;
335       Function &F;
336       std::map<std::string, std::pair<Value*, LocTy> > ForwardRefVals;
337       std::map<unsigned, std::pair<Value*, LocTy> > ForwardRefValIDs;
338       std::vector<Value*> NumberedVals;
339
340       /// FunctionNumber - If this is an unnamed function, this is the slot
341       /// number of it, otherwise it is -1.
342       int FunctionNumber;
343     public:
344       PerFunctionState(LLParser &p, Function &f, int FunctionNumber);
345       ~PerFunctionState();
346
347       Function &getFunction() const { return F; }
348
349       bool FinishFunction();
350
351       /// GetVal - Get a value with the specified name or ID, creating a
352       /// forward reference record if needed.  This can return null if the value
353       /// exists but does not have the right type.
354       Value *GetVal(const std::string &Name, Type *Ty, LocTy Loc);
355       Value *GetVal(unsigned ID, Type *Ty, LocTy Loc);
356
357       /// SetInstName - After an instruction is parsed and inserted into its
358       /// basic block, this installs its name.
359       bool SetInstName(int NameID, const std::string &NameStr, LocTy NameLoc,
360                        Instruction *Inst);
361
362       /// GetBB - Get a basic block with the specified name or ID, creating a
363       /// forward reference record if needed.  This can return null if the value
364       /// is not a BasicBlock.
365       BasicBlock *GetBB(const std::string &Name, LocTy Loc);
366       BasicBlock *GetBB(unsigned ID, LocTy Loc);
367
368       /// DefineBB - Define the specified basic block, which is either named or
369       /// unnamed.  If there is an error, this returns null otherwise it returns
370       /// the block being defined.
371       BasicBlock *DefineBB(const std::string &Name, LocTy Loc);
372
373       bool resolveForwardRefBlockAddresses();
374     };
375
376     bool ConvertValIDToValue(Type *Ty, ValID &ID, Value *&V,
377                              PerFunctionState *PFS);
378
379     bool parseConstantValue(Type *Ty, Constant *&C);
380     bool ParseValue(Type *Ty, Value *&V, PerFunctionState *PFS);
381     bool ParseValue(Type *Ty, Value *&V, PerFunctionState &PFS) {
382       return ParseValue(Ty, V, &PFS);
383     }
384
385     bool ParseValue(Type *Ty, Value *&V, LocTy &Loc,
386                     PerFunctionState &PFS) {
387       Loc = Lex.getLoc();
388       return ParseValue(Ty, V, &PFS);
389     }
390
391     bool ParseTypeAndValue(Value *&V, PerFunctionState *PFS);
392     bool ParseTypeAndValue(Value *&V, PerFunctionState &PFS) {
393       return ParseTypeAndValue(V, &PFS);
394     }
395     bool ParseTypeAndValue(Value *&V, LocTy &Loc, PerFunctionState &PFS) {
396       Loc = Lex.getLoc();
397       return ParseTypeAndValue(V, PFS);
398     }
399     bool ParseTypeAndBasicBlock(BasicBlock *&BB, LocTy &Loc,
400                                 PerFunctionState &PFS);
401     bool ParseTypeAndBasicBlock(BasicBlock *&BB, PerFunctionState &PFS) {
402       LocTy Loc;
403       return ParseTypeAndBasicBlock(BB, Loc, PFS);
404     }
405
406
407     struct ParamInfo {
408       LocTy Loc;
409       Value *V;
410       AttributeSet Attrs;
411       ParamInfo(LocTy loc, Value *v, AttributeSet attrs)
412           : Loc(loc), V(v), Attrs(attrs) {}
413     };
414     bool ParseParameterList(SmallVectorImpl<ParamInfo> &ArgList,
415                             PerFunctionState &PFS,
416                             bool IsMustTailCall = false,
417                             bool InVarArgsFunc = false);
418
419     bool
420     ParseOptionalOperandBundles(SmallVectorImpl<OperandBundleDef> &BundleList,
421                                 PerFunctionState &PFS);
422
423     bool ParseExceptionArgs(SmallVectorImpl<Value *> &Args,
424                             PerFunctionState &PFS);
425
426     // Constant Parsing.
427     bool ParseValID(ValID &ID, PerFunctionState *PFS = nullptr);
428     bool ParseGlobalValue(Type *Ty, Constant *&V);
429     bool ParseGlobalTypeAndValue(Constant *&V);
430     bool ParseGlobalValueVector(SmallVectorImpl<Constant *> &Elts,
431                                 Optional<unsigned> *InRangeOp = nullptr);
432     bool parseOptionalComdat(StringRef GlobalName, Comdat *&C);
433     bool ParseMetadataAsValue(Value *&V, PerFunctionState &PFS);
434     bool ParseValueAsMetadata(Metadata *&MD, const Twine &TypeMsg,
435                               PerFunctionState *PFS);
436     bool ParseMetadata(Metadata *&MD, PerFunctionState *PFS);
437     bool ParseMDTuple(MDNode *&MD, bool IsDistinct = false);
438     bool ParseMDNode(MDNode *&MD);
439     bool ParseMDNodeTail(MDNode *&MD);
440     bool ParseMDNodeVector(SmallVectorImpl<Metadata *> &MDs);
441     bool ParseMetadataAttachment(unsigned &Kind, MDNode *&MD);
442     bool ParseInstructionMetadata(Instruction &Inst);
443     bool ParseGlobalObjectMetadataAttachment(GlobalObject &GO);
444     bool ParseOptionalFunctionMetadata(Function &F);
445
446     template <class FieldTy>
447     bool ParseMDField(LocTy Loc, StringRef Name, FieldTy &Result);
448     template <class FieldTy> bool ParseMDField(StringRef Name, FieldTy &Result);
449     template <class ParserTy>
450     bool ParseMDFieldsImplBody(ParserTy parseField);
451     template <class ParserTy>
452     bool ParseMDFieldsImpl(ParserTy parseField, LocTy &ClosingLoc);
453     bool ParseSpecializedMDNode(MDNode *&N, bool IsDistinct = false);
454
455 #define HANDLE_SPECIALIZED_MDNODE_LEAF(CLASS)                                  \
456   bool Parse##CLASS(MDNode *&Result, bool IsDistinct);
457 #include "llvm/IR/Metadata.def"
458
459     // Function Parsing.
460     struct ArgInfo {
461       LocTy Loc;
462       Type *Ty;
463       AttributeSet Attrs;
464       std::string Name;
465       ArgInfo(LocTy L, Type *ty, AttributeSet Attr, const std::string &N)
466           : Loc(L), Ty(ty), Attrs(Attr), Name(N) {}
467     };
468     bool ParseArgumentList(SmallVectorImpl<ArgInfo> &ArgList, bool &isVarArg);
469     bool ParseFunctionHeader(Function *&Fn, bool isDefine);
470     bool ParseFunctionBody(Function &Fn);
471     bool ParseBasicBlock(PerFunctionState &PFS);
472
473     enum TailCallType { TCT_None, TCT_Tail, TCT_MustTail };
474
475     // Instruction Parsing.  Each instruction parsing routine can return with a
476     // normal result, an error result, or return having eaten an extra comma.
477     enum InstResult { InstNormal = 0, InstError = 1, InstExtraComma = 2 };
478     int ParseInstruction(Instruction *&Inst, BasicBlock *BB,
479                          PerFunctionState &PFS);
480     bool ParseCmpPredicate(unsigned &Pred, unsigned Opc);
481
482     bool ParseRet(Instruction *&Inst, BasicBlock *BB, PerFunctionState &PFS);
483     bool ParseBr(Instruction *&Inst, PerFunctionState &PFS);
484     bool ParseSwitch(Instruction *&Inst, PerFunctionState &PFS);
485     bool ParseIndirectBr(Instruction *&Inst, PerFunctionState &PFS);
486     bool ParseInvoke(Instruction *&Inst, PerFunctionState &PFS);
487     bool ParseResume(Instruction *&Inst, PerFunctionState &PFS);
488     bool ParseCleanupRet(Instruction *&Inst, PerFunctionState &PFS);
489     bool ParseCatchRet(Instruction *&Inst, PerFunctionState &PFS);
490     bool ParseCatchSwitch(Instruction *&Inst, PerFunctionState &PFS);
491     bool ParseCatchPad(Instruction *&Inst, PerFunctionState &PFS);
492     bool ParseCleanupPad(Instruction *&Inst, PerFunctionState &PFS);
493
494     bool ParseArithmetic(Instruction *&I, PerFunctionState &PFS, unsigned Opc,
495                          unsigned OperandType);
496     bool ParseLogical(Instruction *&I, PerFunctionState &PFS, unsigned Opc);
497     bool ParseCompare(Instruction *&I, PerFunctionState &PFS, unsigned Opc);
498     bool ParseCast(Instruction *&I, PerFunctionState &PFS, unsigned Opc);
499     bool ParseSelect(Instruction *&I, PerFunctionState &PFS);
500     bool ParseVA_Arg(Instruction *&I, PerFunctionState &PFS);
501     bool ParseExtractElement(Instruction *&I, PerFunctionState &PFS);
502     bool ParseInsertElement(Instruction *&I, PerFunctionState &PFS);
503     bool ParseShuffleVector(Instruction *&I, PerFunctionState &PFS);
504     int ParsePHI(Instruction *&I, PerFunctionState &PFS);
505     bool ParseLandingPad(Instruction *&I, PerFunctionState &PFS);
506     bool ParseCall(Instruction *&I, PerFunctionState &PFS,
507                    CallInst::TailCallKind IsTail);
508     int ParseAlloc(Instruction *&I, PerFunctionState &PFS);
509     int ParseLoad(Instruction *&I, PerFunctionState &PFS);
510     int ParseStore(Instruction *&I, PerFunctionState &PFS);
511     int ParseCmpXchg(Instruction *&I, PerFunctionState &PFS);
512     int ParseAtomicRMW(Instruction *&I, PerFunctionState &PFS);
513     int ParseFence(Instruction *&I, PerFunctionState &PFS);
514     int ParseGetElementPtr(Instruction *&I, PerFunctionState &PFS);
515     int ParseExtractValue(Instruction *&I, PerFunctionState &PFS);
516     int ParseInsertValue(Instruction *&I, PerFunctionState &PFS);
517
518     // Use-list order directives.
519     bool ParseUseListOrder(PerFunctionState *PFS = nullptr);
520     bool ParseUseListOrderBB();
521     bool ParseUseListOrderIndexes(SmallVectorImpl<unsigned> &Indexes);
522     bool sortUseListOrder(Value *V, ArrayRef<unsigned> Indexes, SMLoc Loc);
523   };
524 } // End llvm namespace
525
526 #endif